恢复 Codex PlanList 并更新发布包

This commit is contained in:
shiyue
2026-09-29 09:58:18 +08:00
parent d70bbf08d9
commit 75989cb4de
7 changed files with 139 additions and 16 deletions

View File

@@ -1122,10 +1122,10 @@ function assertPlanListProgressContract() {
});
const entry = { ws: {}, toolCalls: [], fullText: '' };
runtime.processCodexAppNotification(entry, {
method: 'plan/updated',
method: 'turn/plan/updated',
params: {
id: 'regression-plan-progress',
status: 'inProgress',
threadId: 'regression-thread',
turnId: 'regression-turn',
plan: [
{ step: '完成数据契约', status: 'completed' },
{ step: '完成 DOM', status: 'completed' },
@@ -1135,13 +1135,41 @@ function assertPlanListProgressContract() {
],
},
}, 'plan-progress-session');
const update = sent.find((message) => message.type === 'tool_update' && message.toolUseId === 'regression-plan-progress');
const update = sent.find((message) => message.type === 'tool_update' && message.toolUseId === 'codex-app-plan');
assert(update, 'Plan updates should emit a tool_update payload');
const start = sent.find((message) => message.type === 'tool_start' && message.toolUseId === 'codex-app-plan');
assert(start?.name === 'PlanList' && start?.kind === 'todo_list', 'Native update_plan should start a visible PlanList tool card');
assert(update.meta?.progress?.completed === 3 && update.meta?.progress?.total === 5, 'Plan metadata should expose 3/5 progress');
assert(update.input?.progress?.completed === 3 && update.input?.progress?.total === 5, 'Normalized todo input should expose 3/5 progress');
const cardSource = extractFunctionSource(source, 'createToolCallElement');
assert(cardSource.includes("tool.name === 'AskUserQuestion' || kind === 'todo_list'"), 'PlanList contents should be expanded by default');
const result = JSON.parse(update.result);
assert(result.progress?.completed === 3 && result.progress?.total === 5, 'Persisted todo result should expose 3/5 progress');
const { TOOLS } = require(path.join(REPO_DIR, 'lib', 'ccweb-mcp-server'));
const fallbackTool = TOOLS.find((tool) => tool.name === 'ccweb_update_plan');
assert(fallbackTool?.inputSchema?.properties?.plan?.maxItems === 20, 'ccweb MCP should expose a bounded update_plan fallback');
assert(fs.readFileSync(SERVER_PATH, 'utf8').includes("case 'ccweb_update_plan':"), 'Internal MCP should handle the update_plan fallback');
const fallbackEntry = { ws: {}, toolCalls: [], fullText: '' };
const fallbackPlan = (status) => ({
type: 'mcpToolCall', server: 'ccweb', tool: 'ccweb_update_plan',
arguments: { plan: [
{ step: '准备计划', status: 'completed' },
{ step: '完成实现', status },
] },
});
for (const [id, status] of [['mcp-plan-first', 'in_progress'], ['mcp-plan-second', 'completed']]) {
const item = { ...fallbackPlan(status), id };
runtime.processCodexAppNotification(fallbackEntry, { method: 'item/started', params: { item } }, 'fallback-plan-session');
runtime.processCodexAppNotification(fallbackEntry, { method: 'item/completed', params: { item } }, 'fallback-plan-session');
}
const fallbackStarts = sent.filter((message) => message.type === 'tool_start' && message.toolUseId === 'ccweb-update-plan');
assert(fallbackStarts.length === 1, 'Repeated fallback updates should keep one PlanList card');
assert(fallbackStarts[0].name === 'PlanList' && fallbackStarts[0].kind === 'todo_list', 'Fallback should render as a PlanList card');
assert(fallbackEntry.toolCalls.length === 1, 'Repeated fallback updates should persist one PlanList tool call');
assert(JSON.stringify(JSON.parse(fallbackEntry.toolCalls[0].result).progress) === JSON.stringify({ completed: 2, total: 2 }),
'Fallback PlanList should persist the latest progress');
const summarySource = extractFunctionSource(source, 'applyToolSummary');
const progressElementSource = extractFunctionSource(source, 'createPlanProgressElementFromProgress');
assert(summarySource.includes('createPlanProgressElement(tool)'), 'Tool summaries should append the plan progress element beside the title');