geo-ai-search-optimization 1.3.2 → 1.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -851,6 +851,13 @@ geo-ai-search-optimization help
851
851
  - 新增 `src/cli-shared.js`,集中处理 flag 解析、输入校验和输出写回,降低后续继续加命令时的耦合
852
852
  - 主 `cli.js` 现在更像薄路由层,后续扩充 command family 会更稳
853
853
 
854
+ ## New in 1.3.3
855
+
856
+ - 继续做 CLI 架构迭代,把 agent execution family 也从主 `cli.js` 拆出
857
+ - 新增 `src/cli-agent-execution-commands.js`,接管 `agent-runbook / agent-executor / agent-batch-executor / agent-progress-tracker / agent-status-board / agent-checkpoint / agent-decision-log / agent-retrospective / agent-playbook-pack`
858
+ - 主 `cli.js` 进一步收敛成更薄的 command router
859
+ - 现在 flow family 和 execution family 都有独立 adapter 模块,后续继续拆 planning / delivery 会更顺
860
+
854
861
  ## New in 1.2.20
855
862
 
856
863
  - 新增 `agent-continue`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "geo-ai-search-optimization",
3
- "version": "1.3.2",
3
+ "version": "1.3.3",
4
4
  "description": "Install and run a Generative Engine Optimization (GEO)-first, SEO-supported Codex skill for website optimization.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -0,0 +1,210 @@
1
+ import {
2
+ createAgentBatchExecutor,
3
+ renderAgentBatchExecutorMarkdown,
4
+ writeAgentBatchExecutorOutput
5
+ } from "./agent-batch-executor.js";
6
+ import { createAgentExecutor, renderAgentExecutorMarkdown, writeAgentExecutorOutput } from "./agent-executor.js";
7
+ import {
8
+ createAgentProgressTracker,
9
+ renderAgentProgressTrackerMarkdown,
10
+ writeAgentProgressTrackerOutput
11
+ } from "./agent-progress-tracker.js";
12
+ import { createAgentCheckpoint, renderAgentCheckpointMarkdown, writeAgentCheckpointOutput } from "./agent-checkpoint.js";
13
+ import { createAgentDecisionLog, renderAgentDecisionLogMarkdown, writeAgentDecisionLogOutput } from "./agent-decision-log.js";
14
+ import {
15
+ createAgentPlaybookPack,
16
+ renderAgentPlaybookPackMarkdown,
17
+ writeAgentPlaybookPackOutput
18
+ } from "./agent-playbook-pack.js";
19
+ import { createAgentRetrospective, renderAgentRetrospectiveMarkdown, writeAgentRetrospectiveOutput } from "./agent-retrospective.js";
20
+ import { createAgentStatusBoard, renderAgentStatusBoardMarkdown, writeAgentStatusBoardOutput } from "./agent-status-board.js";
21
+ import { createAgentRunbook, renderAgentRunbookMarkdown, writeAgentRunbookOutput } from "./agent-runbook.js";
22
+ import {
23
+ getFlagValue,
24
+ getJsonCapableFormat,
25
+ getRequiredInput,
26
+ writeOrPrintArtifact
27
+ } from "./cli-shared.js";
28
+
29
+ export const AGENT_EXECUTION_HELP_LINES = [
30
+ " geo-ai-search-optimization agent-runbook <input> [--intent <auto|diagnose|guide|execute|share|closeout>] [--task <id>] [--format <markdown|json>] [--out <file>]",
31
+ " geo-ai-search-optimization agent-executor <input> [--intent <auto|diagnose|guide|execute|share|closeout>] [--task <id>] [--format <markdown|json>] [--out <file>]",
32
+ " geo-ai-search-optimization agent-batch-executor <input> [--intent <auto|diagnose|guide|execute|share|closeout>] [--task <id>] [--count <count>] [--format <markdown|json>] [--out <file>]",
33
+ " geo-ai-search-optimization agent-progress-tracker <input> [--current <id>] [--completed <id,id>] [--blocked <reason,reason>] [--format <markdown|json>] [--out <file>]",
34
+ " geo-ai-search-optimization agent-status-board <input> [--current <id>] [--completed <id,id>] [--blocked <reason,reason>] [--format <markdown|json>] [--out <file>]",
35
+ " geo-ai-search-optimization agent-checkpoint <input> [--current <id>] [--completed <id,id>] [--blocked <reason,reason>] [--format <markdown|json>] [--out <file>]",
36
+ " geo-ai-search-optimization agent-decision-log <input> [--append-from <file>] [--note <text>] [--current <id>] [--completed <id,id>] [--blocked <reason,reason>] [--format <markdown|json>] [--out <file>]",
37
+ " geo-ai-search-optimization agent-retrospective <input> [--format <markdown|json>] [--out <file>]",
38
+ " geo-ai-search-optimization agent-playbook-pack <input> [--task <id>] [--format <markdown|json>] [--out <file>]"
39
+ ];
40
+
41
+ async function handleAgentRunbook(args) {
42
+ const input = getRequiredInput(args, "agent-runbook");
43
+ const format = getFlagValue(args, "--format");
44
+ const artifact = await createAgentRunbook(input, {
45
+ intent: getFlagValue(args, "--intent"),
46
+ format,
47
+ taskId: getFlagValue(args, "--task")
48
+ });
49
+ return writeOrPrintArtifact({
50
+ args,
51
+ commandName: "agent runbook",
52
+ artifact,
53
+ renderMarkdown: renderAgentRunbookMarkdown,
54
+ writeOutput: writeAgentRunbookOutput,
55
+ outputJson: format === "json"
56
+ });
57
+ }
58
+
59
+ async function handleAgentExecutor(args) {
60
+ const input = getRequiredInput(args, "agent-executor");
61
+ const format = getFlagValue(args, "--format");
62
+ const artifact = await createAgentExecutor(input, {
63
+ intent: getFlagValue(args, "--intent"),
64
+ format,
65
+ taskId: getFlagValue(args, "--task")
66
+ });
67
+ return writeOrPrintArtifact({
68
+ args,
69
+ commandName: "agent executor",
70
+ artifact,
71
+ renderMarkdown: renderAgentExecutorMarkdown,
72
+ writeOutput: writeAgentExecutorOutput,
73
+ outputJson: format === "json"
74
+ });
75
+ }
76
+
77
+ async function handleAgentBatchExecutor(args) {
78
+ const input = getRequiredInput(args, "agent-batch-executor");
79
+ const artifact = await createAgentBatchExecutor(input, {
80
+ intent: getFlagValue(args, "--intent"),
81
+ format: getJsonCapableFormat(args),
82
+ taskId: getFlagValue(args, "--task"),
83
+ count: getFlagValue(args, "--count")
84
+ });
85
+ return writeOrPrintArtifact({
86
+ args,
87
+ commandName: "agent batch executor",
88
+ artifact,
89
+ renderMarkdown: renderAgentBatchExecutorMarkdown,
90
+ writeOutput: writeAgentBatchExecutorOutput,
91
+ outputJson: artifact.format === "json"
92
+ });
93
+ }
94
+
95
+ async function handleAgentProgressTracker(args) {
96
+ const input = getRequiredInput(args, "agent-progress-tracker");
97
+ const artifact = await createAgentProgressTracker(input, {
98
+ format: getJsonCapableFormat(args),
99
+ currentTaskId: getFlagValue(args, "--current"),
100
+ completedPacketIds: getFlagValue(args, "--completed"),
101
+ blockedReasons: getFlagValue(args, "--blocked")
102
+ });
103
+ return writeOrPrintArtifact({
104
+ args,
105
+ commandName: "agent progress tracker",
106
+ artifact,
107
+ renderMarkdown: renderAgentProgressTrackerMarkdown,
108
+ writeOutput: writeAgentProgressTrackerOutput,
109
+ outputJson: artifact.format === "json"
110
+ });
111
+ }
112
+
113
+ async function handleAgentStatusBoard(args) {
114
+ const input = getRequiredInput(args, "agent-status-board");
115
+ const artifact = await createAgentStatusBoard(input, {
116
+ format: getJsonCapableFormat(args),
117
+ currentTaskId: getFlagValue(args, "--current"),
118
+ completedPacketIds: getFlagValue(args, "--completed"),
119
+ blockedReasons: getFlagValue(args, "--blocked")
120
+ });
121
+ return writeOrPrintArtifact({
122
+ args,
123
+ commandName: "agent status board",
124
+ artifact,
125
+ renderMarkdown: renderAgentStatusBoardMarkdown,
126
+ writeOutput: writeAgentStatusBoardOutput,
127
+ outputJson: artifact.format === "json"
128
+ });
129
+ }
130
+
131
+ async function handleAgentCheckpoint(args) {
132
+ const input = getRequiredInput(args, "agent-checkpoint");
133
+ const artifact = await createAgentCheckpoint(input, {
134
+ format: getJsonCapableFormat(args),
135
+ currentTaskId: getFlagValue(args, "--current"),
136
+ completedPacketIds: getFlagValue(args, "--completed"),
137
+ blockedReasons: getFlagValue(args, "--blocked")
138
+ });
139
+ return writeOrPrintArtifact({
140
+ args,
141
+ commandName: "agent checkpoint",
142
+ artifact,
143
+ renderMarkdown: renderAgentCheckpointMarkdown,
144
+ writeOutput: writeAgentCheckpointOutput,
145
+ outputJson: artifact.format === "json"
146
+ });
147
+ }
148
+
149
+ async function handleAgentDecisionLog(args) {
150
+ const input = getRequiredInput(args, "agent-decision-log");
151
+ const artifact = await createAgentDecisionLog(input, {
152
+ format: getJsonCapableFormat(args),
153
+ appendFrom: getFlagValue(args, "--append-from"),
154
+ note: getFlagValue(args, "--note"),
155
+ currentTaskId: getFlagValue(args, "--current"),
156
+ completedPacketIds: getFlagValue(args, "--completed"),
157
+ blockedReasons: getFlagValue(args, "--blocked")
158
+ });
159
+ return writeOrPrintArtifact({
160
+ args,
161
+ commandName: "agent decision log",
162
+ artifact,
163
+ renderMarkdown: renderAgentDecisionLogMarkdown,
164
+ writeOutput: writeAgentDecisionLogOutput,
165
+ outputJson: artifact.format === "json"
166
+ });
167
+ }
168
+
169
+ async function handleAgentRetrospective(args) {
170
+ const input = getRequiredInput(args, "agent-retrospective");
171
+ const artifact = await createAgentRetrospective(input, {
172
+ format: getJsonCapableFormat(args)
173
+ });
174
+ return writeOrPrintArtifact({
175
+ args,
176
+ commandName: "agent retrospective",
177
+ artifact,
178
+ renderMarkdown: renderAgentRetrospectiveMarkdown,
179
+ writeOutput: writeAgentRetrospectiveOutput,
180
+ outputJson: artifact.format === "json"
181
+ });
182
+ }
183
+
184
+ async function handleAgentPlaybookPack(args) {
185
+ const input = getRequiredInput(args, "agent-playbook-pack");
186
+ const artifact = await createAgentPlaybookPack(input, {
187
+ format: getJsonCapableFormat(args),
188
+ taskId: getFlagValue(args, "--task")
189
+ });
190
+ return writeOrPrintArtifact({
191
+ args,
192
+ commandName: "agent playbook pack",
193
+ artifact,
194
+ renderMarkdown: renderAgentPlaybookPackMarkdown,
195
+ writeOutput: writeAgentPlaybookPackOutput,
196
+ outputJson: artifact.format === "json"
197
+ });
198
+ }
199
+
200
+ export const AGENT_EXECUTION_COMMAND_HANDLERS = {
201
+ "agent-runbook": handleAgentRunbook,
202
+ "agent-executor": handleAgentExecutor,
203
+ "agent-batch-executor": handleAgentBatchExecutor,
204
+ "agent-progress-tracker": handleAgentProgressTracker,
205
+ "agent-status-board": handleAgentStatusBoard,
206
+ "agent-checkpoint": handleAgentCheckpoint,
207
+ "agent-decision-log": handleAgentDecisionLog,
208
+ "agent-retrospective": handleAgentRetrospective,
209
+ "agent-playbook-pack": handleAgentPlaybookPack
210
+ };
package/src/cli.js CHANGED
@@ -1,31 +1,14 @@
1
1
  import { fileURLToPath } from "node:url";
2
2
  import { readFile } from "node:fs/promises";
3
3
  import path from "node:path";
4
+ import {
5
+ AGENT_EXECUTION_COMMAND_HANDLERS,
6
+ AGENT_EXECUTION_HELP_LINES
7
+ } from "./cli-agent-execution-commands.js";
4
8
  import { FLOW_COMMAND_HANDLERS, FLOW_HELP_LINES } from "./cli-flow-commands.js";
5
9
  import { getFlagValue, hasFlag, parsePositiveInteger } from "./cli-shared.js";
6
10
  import { createApplyPlan, renderApplyPlanMarkdown, writeApplyPlanOutput } from "./apply-plan.js";
7
- import {
8
- createAgentBatchExecutor,
9
- renderAgentBatchExecutorMarkdown,
10
- writeAgentBatchExecutorOutput
11
- } from "./agent-batch-executor.js";
12
- import { createAgentExecutor, renderAgentExecutorMarkdown, writeAgentExecutorOutput } from "./agent-executor.js";
13
11
  import { createAgentHandoff, renderAgentHandoffMarkdown, writeAgentHandoffOutput } from "./agent-handoff.js";
14
- import {
15
- createAgentProgressTracker,
16
- renderAgentProgressTrackerMarkdown,
17
- writeAgentProgressTrackerOutput
18
- } from "./agent-progress-tracker.js";
19
- import { createAgentCheckpoint, renderAgentCheckpointMarkdown, writeAgentCheckpointOutput } from "./agent-checkpoint.js";
20
- import { createAgentDecisionLog, renderAgentDecisionLogMarkdown, writeAgentDecisionLogOutput } from "./agent-decision-log.js";
21
- import {
22
- createAgentPlaybookPack,
23
- renderAgentPlaybookPackMarkdown,
24
- writeAgentPlaybookPackOutput
25
- } from "./agent-playbook-pack.js";
26
- import { createAgentRetrospective, renderAgentRetrospectiveMarkdown, writeAgentRetrospectiveOutput } from "./agent-retrospective.js";
27
- import { createAgentStatusBoard, renderAgentStatusBoardMarkdown, writeAgentStatusBoardOutput } from "./agent-status-board.js";
28
- import { createAgentRunbook, renderAgentRunbookMarkdown, writeAgentRunbookOutput } from "./agent-runbook.js";
29
12
  import {
30
13
  createCompletionReport,
31
14
  renderCompletionReportMarkdown,
@@ -81,15 +64,7 @@ function printHelp() {
81
64
  " geo-ai-search-optimization",
82
65
  " geo-ai-search-optimization install [--target <dir>] [--json]",
83
66
  ...FLOW_HELP_LINES,
84
- " geo-ai-search-optimization agent-runbook <input> [--intent <auto|diagnose|guide|execute|share|closeout>] [--task <id>] [--format <markdown|json>] [--out <file>]",
85
- " geo-ai-search-optimization agent-executor <input> [--intent <auto|diagnose|guide|execute|share|closeout>] [--task <id>] [--format <markdown|json>] [--out <file>]",
86
- " geo-ai-search-optimization agent-batch-executor <input> [--intent <auto|diagnose|guide|execute|share|closeout>] [--task <id>] [--count <count>] [--format <markdown|json>] [--out <file>]",
87
- " geo-ai-search-optimization agent-progress-tracker <input> [--current <id>] [--completed <id,id>] [--blocked <reason,reason>] [--format <markdown|json>] [--out <file>]",
88
- " geo-ai-search-optimization agent-status-board <input> [--current <id>] [--completed <id,id>] [--blocked <reason,reason>] [--format <markdown|json>] [--out <file>]",
89
- " geo-ai-search-optimization agent-checkpoint <input> [--current <id>] [--completed <id,id>] [--blocked <reason,reason>] [--format <markdown|json>] [--out <file>]",
90
- " geo-ai-search-optimization agent-decision-log <input> [--append-from <file>] [--note <text>] [--current <id>] [--completed <id,id>] [--blocked <reason,reason>] [--format <markdown|json>] [--out <file>]",
91
- " geo-ai-search-optimization agent-retrospective <input> [--format <markdown|json>] [--out <file>]",
92
- " geo-ai-search-optimization agent-playbook-pack <input> [--task <id>] [--format <markdown|json>] [--out <file>]",
67
+ ...AGENT_EXECUTION_HELP_LINES,
93
68
  " geo-ai-search-optimization skills [--json]",
94
69
  " geo-ai-search-optimization where",
95
70
  " geo-ai-search-optimization doctor [--json]",
@@ -137,253 +112,6 @@ async function handleInstall(args) {
137
112
  }
138
113
  }
139
114
 
140
- async function handleAgentRunbook(args) {
141
- const input = args.find((value) => !value.startsWith("-"));
142
- if (!input) {
143
- throw new Error("agent-runbook 需要一个输入值,可以是任务描述、项目路径、网站网址或已导出的工件");
144
- }
145
-
146
- const format = getFlagValue(args, "--format");
147
- const runbook = await createAgentRunbook(input, {
148
- intent: getFlagValue(args, "--intent"),
149
- format,
150
- taskId: getFlagValue(args, "--task")
151
- });
152
- const outputJson = format === "json";
153
- const renderedOutput = outputJson
154
- ? `${JSON.stringify(runbook, null, 2)}\n`
155
- : renderAgentRunbookMarkdown(runbook);
156
-
157
- const outputPath = getFlagValue(args, "--out");
158
- if (outputPath) {
159
- const resolvedOutputPath = await writeAgentRunbookOutput(outputPath, renderedOutput);
160
- process.stdout.write(`已保存 agent runbook:${resolvedOutputPath}\n`);
161
- return;
162
- }
163
-
164
- process.stdout.write(renderedOutput);
165
- }
166
-
167
- async function handleAgentExecutor(args) {
168
- const input = args.find((value) => !value.startsWith("-"));
169
- if (!input) {
170
- throw new Error("agent-executor 需要一个输入值,可以是任务描述、项目路径、网站网址或已导出的工件");
171
- }
172
-
173
- const format = getFlagValue(args, "--format");
174
- const executor = await createAgentExecutor(input, {
175
- intent: getFlagValue(args, "--intent"),
176
- format,
177
- taskId: getFlagValue(args, "--task")
178
- });
179
- const outputJson = format === "json";
180
- const renderedOutput = outputJson
181
- ? `${JSON.stringify(executor, null, 2)}\n`
182
- : renderAgentExecutorMarkdown(executor);
183
-
184
- const outputPath = getFlagValue(args, "--out");
185
- if (outputPath) {
186
- const resolvedOutputPath = await writeAgentExecutorOutput(outputPath, renderedOutput);
187
- process.stdout.write(`已保存 agent executor:${resolvedOutputPath}\n`);
188
- return;
189
- }
190
-
191
- process.stdout.write(renderedOutput);
192
- }
193
-
194
- async function handleAgentBatchExecutor(args) {
195
- const input = args.find((value) => !value.startsWith("-"));
196
- if (!input) {
197
- throw new Error("agent-batch-executor 需要一个输入值,可以是任务描述、项目路径、网站网址或已导出的工件");
198
- }
199
-
200
- const format = getFlagValue(args, "--format") || (hasFlag(args, "--json") ? "json" : undefined);
201
- const batch = await createAgentBatchExecutor(input, {
202
- intent: getFlagValue(args, "--intent"),
203
- format,
204
- taskId: getFlagValue(args, "--task"),
205
- count: getFlagValue(args, "--count")
206
- });
207
- const outputJson = batch.format === "json";
208
- const renderedOutput = outputJson
209
- ? `${JSON.stringify(batch, null, 2)}\n`
210
- : renderAgentBatchExecutorMarkdown(batch);
211
-
212
- const outputPath = getFlagValue(args, "--out");
213
- if (outputPath) {
214
- const resolvedOutputPath = await writeAgentBatchExecutorOutput(outputPath, renderedOutput);
215
- process.stdout.write(`已保存 agent batch executor:${resolvedOutputPath}\n`);
216
- return;
217
- }
218
-
219
- process.stdout.write(renderedOutput);
220
- }
221
-
222
- async function handleAgentProgressTracker(args) {
223
- const input = args.find((value) => !value.startsWith("-"));
224
- if (!input) {
225
- throw new Error("agent-progress-tracker 需要一个输入值,可以是项目路径、网站网址或已导出的工件");
226
- }
227
-
228
- const format = getFlagValue(args, "--format") || (hasFlag(args, "--json") ? "json" : undefined);
229
- const tracker = await createAgentProgressTracker(input, {
230
- format,
231
- currentTaskId: getFlagValue(args, "--current"),
232
- completedPacketIds: getFlagValue(args, "--completed"),
233
- blockedReasons: getFlagValue(args, "--blocked")
234
- });
235
- const outputJson = tracker.format === "json";
236
- const renderedOutput = outputJson
237
- ? `${JSON.stringify(tracker, null, 2)}\n`
238
- : renderAgentProgressTrackerMarkdown(tracker);
239
-
240
- const outputPath = getFlagValue(args, "--out");
241
- if (outputPath) {
242
- const resolvedOutputPath = await writeAgentProgressTrackerOutput(outputPath, renderedOutput);
243
- process.stdout.write(`已保存 agent progress tracker:${resolvedOutputPath}\n`);
244
- return;
245
- }
246
-
247
- process.stdout.write(renderedOutput);
248
- }
249
-
250
- async function handleAgentStatusBoard(args) {
251
- const input = args.find((value) => !value.startsWith("-"));
252
- if (!input) {
253
- throw new Error("agent-status-board 需要一个输入值,可以是项目路径、网站网址或已导出的工件");
254
- }
255
-
256
- const format = getFlagValue(args, "--format") || (hasFlag(args, "--json") ? "json" : undefined);
257
- const board = await createAgentStatusBoard(input, {
258
- format,
259
- currentTaskId: getFlagValue(args, "--current"),
260
- completedPacketIds: getFlagValue(args, "--completed"),
261
- blockedReasons: getFlagValue(args, "--blocked")
262
- });
263
- const outputJson = board.format === "json";
264
- const renderedOutput = outputJson
265
- ? `${JSON.stringify(board, null, 2)}\n`
266
- : renderAgentStatusBoardMarkdown(board);
267
-
268
- const outputPath = getFlagValue(args, "--out");
269
- if (outputPath) {
270
- const resolvedOutputPath = await writeAgentStatusBoardOutput(outputPath, renderedOutput);
271
- process.stdout.write(`已保存 agent status board:${resolvedOutputPath}\n`);
272
- return;
273
- }
274
-
275
- process.stdout.write(renderedOutput);
276
- }
277
-
278
- async function handleAgentCheckpoint(args) {
279
- const input = args.find((value) => !value.startsWith("-"));
280
- if (!input) {
281
- throw new Error("agent-checkpoint 需要一个输入值,可以是项目路径、网站网址或已导出的工件");
282
- }
283
-
284
- const format = getFlagValue(args, "--format") || (hasFlag(args, "--json") ? "json" : undefined);
285
- const checkpoint = await createAgentCheckpoint(input, {
286
- format,
287
- currentTaskId: getFlagValue(args, "--current"),
288
- completedPacketIds: getFlagValue(args, "--completed"),
289
- blockedReasons: getFlagValue(args, "--blocked")
290
- });
291
- const outputJson = checkpoint.format === "json";
292
- const renderedOutput = outputJson
293
- ? `${JSON.stringify(checkpoint, null, 2)}\n`
294
- : renderAgentCheckpointMarkdown(checkpoint);
295
-
296
- const outputPath = getFlagValue(args, "--out");
297
- if (outputPath) {
298
- const resolvedOutputPath = await writeAgentCheckpointOutput(outputPath, renderedOutput);
299
- process.stdout.write(`已保存 agent checkpoint:${resolvedOutputPath}\n`);
300
- return;
301
- }
302
-
303
- process.stdout.write(renderedOutput);
304
- }
305
-
306
- async function handleAgentDecisionLog(args) {
307
- const input = args.find((value) => !value.startsWith("-"));
308
- if (!input) {
309
- throw new Error("agent-decision-log 需要一个输入值,可以是项目路径、网站网址或已导出的工件");
310
- }
311
-
312
- const format = getFlagValue(args, "--format") || (hasFlag(args, "--json") ? "json" : undefined);
313
- const decisionLog = await createAgentDecisionLog(input, {
314
- format,
315
- appendFrom: getFlagValue(args, "--append-from"),
316
- note: getFlagValue(args, "--note"),
317
- currentTaskId: getFlagValue(args, "--current"),
318
- completedPacketIds: getFlagValue(args, "--completed"),
319
- blockedReasons: getFlagValue(args, "--blocked")
320
- });
321
- const outputJson = decisionLog.format === "json";
322
- const renderedOutput = outputJson
323
- ? `${JSON.stringify(decisionLog, null, 2)}\n`
324
- : renderAgentDecisionLogMarkdown(decisionLog);
325
-
326
- const outputPath = getFlagValue(args, "--out");
327
- if (outputPath) {
328
- const resolvedOutputPath = await writeAgentDecisionLogOutput(outputPath, renderedOutput);
329
- process.stdout.write(`已保存 agent decision log:${resolvedOutputPath}\n`);
330
- return;
331
- }
332
-
333
- process.stdout.write(renderedOutput);
334
- }
335
-
336
- async function handleAgentRetrospective(args) {
337
- const input = args.find((value) => !value.startsWith("-"));
338
- if (!input) {
339
- throw new Error("agent-retrospective 需要一个输入值,可以是项目路径、网站网址或已导出的工件");
340
- }
341
-
342
- const format = getFlagValue(args, "--format") || (hasFlag(args, "--json") ? "json" : undefined);
343
- const retrospective = await createAgentRetrospective(input, {
344
- format
345
- });
346
- const outputJson = retrospective.format === "json";
347
- const renderedOutput = outputJson
348
- ? `${JSON.stringify(retrospective, null, 2)}\n`
349
- : renderAgentRetrospectiveMarkdown(retrospective);
350
-
351
- const outputPath = getFlagValue(args, "--out");
352
- if (outputPath) {
353
- const resolvedOutputPath = await writeAgentRetrospectiveOutput(outputPath, renderedOutput);
354
- process.stdout.write(`已保存 agent retrospective:${resolvedOutputPath}\n`);
355
- return;
356
- }
357
-
358
- process.stdout.write(renderedOutput);
359
- }
360
-
361
- async function handleAgentPlaybookPack(args) {
362
- const input = args.find((value) => !value.startsWith("-"));
363
- if (!input) {
364
- throw new Error("agent-playbook-pack 需要一个输入值,可以是项目路径、网站网址或已导出的工件");
365
- }
366
-
367
- const format = getFlagValue(args, "--format") || (hasFlag(args, "--json") ? "json" : undefined);
368
- const pack = await createAgentPlaybookPack(input, {
369
- format,
370
- taskId: getFlagValue(args, "--task")
371
- });
372
- const outputJson = pack.format === "json";
373
- const renderedOutput = outputJson
374
- ? `${JSON.stringify(pack, null, 2)}\n`
375
- : renderAgentPlaybookPackMarkdown(pack);
376
-
377
- const outputPath = getFlagValue(args, "--out");
378
- if (outputPath) {
379
- const resolvedOutputPath = await writeAgentPlaybookPackOutput(outputPath, renderedOutput);
380
- process.stdout.write(`已保存 agent playbook pack:${resolvedOutputPath}\n`);
381
- return;
382
- }
383
-
384
- process.stdout.write(renderedOutput);
385
- }
386
-
387
115
  function handleWhere() {
388
116
  process.stdout.write(
389
117
  [
@@ -909,6 +637,7 @@ async function handleRoadmap(args) {
909
637
  export async function runCli(args = []) {
910
638
  const [command = "install", ...rest] = args;
911
639
  const flowHandler = FLOW_COMMAND_HANDLERS[command];
640
+ const agentExecutionHandler = AGENT_EXECUTION_COMMAND_HANDLERS[command];
912
641
 
913
642
  if (command === "help" || command === "--help" || command === "-h") {
914
643
  printHelp();
@@ -930,6 +659,11 @@ export async function runCli(args = []) {
930
659
  return;
931
660
  }
932
661
 
662
+ if (agentExecutionHandler) {
663
+ await agentExecutionHandler(rest);
664
+ return;
665
+ }
666
+
933
667
  if (command === "agent-runbook") {
934
668
  await handleAgentRunbook(rest);
935
669
  return;