geo-ai-search-optimization 1.3.9 → 1.3.11

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
@@ -902,6 +902,21 @@ geo-ai-search-optimization help
902
902
  - `src/cli-site-ops-commands.js` 里的 `init-llms / init-schema` 已改成声明式 action 组合
903
903
  - CLI 现在同时覆盖 artifact、structured-output、action 三类共享 composition primitives
904
904
 
905
+ ## New in 1.3.10
906
+
907
+ - 开始把重复的命令参数组装抽成共享 option builders
908
+ - `src/cli-shared.js` 新增 `buildIntentFormatOptions / buildTaskFormatOptions / buildProgressFormatOptions` 等 builder
909
+ - `src/cli-agent-execution-commands.js`、`src/cli-flow-commands.js`、`src/cli-planning-delivery-commands.js` 现在统一复用这些 builder
910
+ - CLI 架构进一步接近“adapter registry + shared option builders + shared composition primitives”的模式
911
+
912
+ ## New in 1.3.11
913
+
914
+ - 继续收敛原本仍较特殊的命令编排
915
+ - `src/cli-shared.js` 新增 `buildTaskOutputDirOptions / buildTaskFormatOutputDirOptions / createContentCommandHandler`
916
+ - `src/cli-planning-delivery-commands.js` 中的 `report` 已改成统一 content handler
917
+ - `export-pack / html-pack / publish-pack` 也开始复用共享 output-dir / task builder
918
+ - CLI 更接近统一的 command registry,而不是混合少数特例 handler
919
+
905
920
  ## New in 1.2.20
906
921
 
907
922
  - 新增 `agent-continue`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "geo-ai-search-optimization",
3
- "version": "1.3.9",
3
+ "version": "1.3.11",
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": {
@@ -20,9 +20,12 @@ import { createAgentRetrospective, renderAgentRetrospectiveMarkdown, writeAgentR
20
20
  import { createAgentStatusBoard, renderAgentStatusBoardMarkdown, writeAgentStatusBoardOutput } from "./agent-status-board.js";
21
21
  import { createAgentRunbook, renderAgentRunbookMarkdown, writeAgentRunbookOutput } from "./agent-runbook.js";
22
22
  import {
23
+ buildIntentTaskFormatOptions,
24
+ buildJsonCapableFormatOptions,
25
+ buildProgressFormatOptions,
26
+ buildTaskOptions,
23
27
  createArtifactCommandHandler,
24
- getFlagValue,
25
- getJsonCapableFormat
28
+ getFlagValue
26
29
  } from "./cli-shared.js";
27
30
 
28
31
  export const AGENT_EXECUTION_HELP_LINES = [
@@ -43,11 +46,7 @@ const handleAgentRunbook = createArtifactCommandHandler({
43
46
  createArtifact: createAgentRunbook,
44
47
  renderMarkdown: renderAgentRunbookMarkdown,
45
48
  writeOutput: writeAgentRunbookOutput,
46
- getOptions: (args) => ({
47
- intent: getFlagValue(args, "--intent"),
48
- format: getFlagValue(args, "--format"),
49
- taskId: getFlagValue(args, "--task")
50
- })
49
+ getOptions: buildIntentTaskFormatOptions
51
50
  });
52
51
 
53
52
  const handleAgentExecutor = createArtifactCommandHandler({
@@ -56,11 +55,7 @@ const handleAgentExecutor = createArtifactCommandHandler({
56
55
  createArtifact: createAgentExecutor,
57
56
  renderMarkdown: renderAgentExecutorMarkdown,
58
57
  writeOutput: writeAgentExecutorOutput,
59
- getOptions: (args) => ({
60
- intent: getFlagValue(args, "--intent"),
61
- format: getFlagValue(args, "--format"),
62
- taskId: getFlagValue(args, "--task")
63
- })
58
+ getOptions: buildIntentTaskFormatOptions
64
59
  });
65
60
 
66
61
  const handleAgentBatchExecutor = createArtifactCommandHandler({
@@ -70,9 +65,7 @@ const handleAgentBatchExecutor = createArtifactCommandHandler({
70
65
  renderMarkdown: renderAgentBatchExecutorMarkdown,
71
66
  writeOutput: writeAgentBatchExecutorOutput,
72
67
  getOptions: (args) => ({
73
- intent: getFlagValue(args, "--intent"),
74
- format: getJsonCapableFormat(args),
75
- taskId: getFlagValue(args, "--task"),
68
+ ...buildIntentTaskFormatOptions(args),
76
69
  count: getFlagValue(args, "--count")
77
70
  })
78
71
  });
@@ -83,12 +76,7 @@ const handleAgentProgressTracker = createArtifactCommandHandler({
83
76
  createArtifact: createAgentProgressTracker,
84
77
  renderMarkdown: renderAgentProgressTrackerMarkdown,
85
78
  writeOutput: writeAgentProgressTrackerOutput,
86
- getOptions: (args) => ({
87
- format: getJsonCapableFormat(args),
88
- currentTaskId: getFlagValue(args, "--current"),
89
- completedPacketIds: getFlagValue(args, "--completed"),
90
- blockedReasons: getFlagValue(args, "--blocked")
91
- })
79
+ getOptions: buildProgressFormatOptions
92
80
  });
93
81
 
94
82
  const handleAgentStatusBoard = createArtifactCommandHandler({
@@ -97,12 +85,7 @@ const handleAgentStatusBoard = createArtifactCommandHandler({
97
85
  createArtifact: createAgentStatusBoard,
98
86
  renderMarkdown: renderAgentStatusBoardMarkdown,
99
87
  writeOutput: writeAgentStatusBoardOutput,
100
- getOptions: (args) => ({
101
- format: getJsonCapableFormat(args),
102
- currentTaskId: getFlagValue(args, "--current"),
103
- completedPacketIds: getFlagValue(args, "--completed"),
104
- blockedReasons: getFlagValue(args, "--blocked")
105
- })
88
+ getOptions: buildProgressFormatOptions
106
89
  });
107
90
 
108
91
  const handleAgentCheckpoint = createArtifactCommandHandler({
@@ -111,12 +94,7 @@ const handleAgentCheckpoint = createArtifactCommandHandler({
111
94
  createArtifact: createAgentCheckpoint,
112
95
  renderMarkdown: renderAgentCheckpointMarkdown,
113
96
  writeOutput: writeAgentCheckpointOutput,
114
- getOptions: (args) => ({
115
- format: getJsonCapableFormat(args),
116
- currentTaskId: getFlagValue(args, "--current"),
117
- completedPacketIds: getFlagValue(args, "--completed"),
118
- blockedReasons: getFlagValue(args, "--blocked")
119
- })
97
+ getOptions: buildProgressFormatOptions
120
98
  });
121
99
 
122
100
  const handleAgentDecisionLog = createArtifactCommandHandler({
@@ -126,12 +104,9 @@ const handleAgentDecisionLog = createArtifactCommandHandler({
126
104
  renderMarkdown: renderAgentDecisionLogMarkdown,
127
105
  writeOutput: writeAgentDecisionLogOutput,
128
106
  getOptions: (args) => ({
129
- format: getJsonCapableFormat(args),
107
+ ...buildProgressFormatOptions(args),
130
108
  appendFrom: getFlagValue(args, "--append-from"),
131
- note: getFlagValue(args, "--note"),
132
- currentTaskId: getFlagValue(args, "--current"),
133
- completedPacketIds: getFlagValue(args, "--completed"),
134
- blockedReasons: getFlagValue(args, "--blocked")
109
+ note: getFlagValue(args, "--note")
135
110
  })
136
111
  });
137
112
 
@@ -141,9 +116,7 @@ const handleAgentRetrospective = createArtifactCommandHandler({
141
116
  createArtifact: createAgentRetrospective,
142
117
  renderMarkdown: renderAgentRetrospectiveMarkdown,
143
118
  writeOutput: writeAgentRetrospectiveOutput,
144
- getOptions: (args) => ({
145
- format: getJsonCapableFormat(args)
146
- })
119
+ getOptions: buildJsonCapableFormatOptions
147
120
  });
148
121
 
149
122
  const handleAgentPlaybookPack = createArtifactCommandHandler({
@@ -153,8 +126,8 @@ const handleAgentPlaybookPack = createArtifactCommandHandler({
153
126
  renderMarkdown: renderAgentPlaybookPackMarkdown,
154
127
  writeOutput: writeAgentPlaybookPackOutput,
155
128
  getOptions: (args) => ({
156
- format: getJsonCapableFormat(args),
157
- taskId: getFlagValue(args, "--task")
129
+ ...buildJsonCapableFormatOptions(args),
130
+ ...buildTaskOptions(args)
158
131
  })
159
132
  });
160
133
 
@@ -17,10 +17,11 @@ import {
17
17
  } from "./agent-state-pack.js";
18
18
  import { createAgentSession, renderAgentSessionMarkdown, writeAgentSessionOutput } from "./agent-session.js";
19
19
  import {
20
+ buildIntentFormatOptions,
21
+ buildIntentProgressFormatOptions,
20
22
  createArtifactCommandHandler,
21
23
  createStructuredOutputCommandHandler,
22
24
  getFlagValue,
23
- getJsonCapableFormat,
24
25
  getRequiredInput,
25
26
  hasFlag
26
27
  } from "./cli-shared.js";
@@ -53,10 +54,7 @@ const handleAgentOrchestrator = createArtifactCommandHandler({
53
54
  createArtifact: createAgentOrchestrator,
54
55
  renderMarkdown: renderAgentOrchestratorMarkdown,
55
56
  writeOutput: writeAgentOrchestratorOutput,
56
- getOptions: (args) => ({
57
- intent: getFlagValue(args, "--intent"),
58
- format: getJsonCapableFormat(args)
59
- })
57
+ getOptions: buildIntentFormatOptions
60
58
  });
61
59
 
62
60
  const handleAgentResume = createArtifactCommandHandler({
@@ -65,10 +63,7 @@ const handleAgentResume = createArtifactCommandHandler({
65
63
  createArtifact: createAgentResume,
66
64
  renderMarkdown: renderAgentResumeMarkdown,
67
65
  writeOutput: writeAgentResumeOutput,
68
- getOptions: (args) => ({
69
- intent: getFlagValue(args, "--intent"),
70
- format: getJsonCapableFormat(args)
71
- })
66
+ getOptions: buildIntentFormatOptions
72
67
  });
73
68
 
74
69
  const handleAgentContinue = createArtifactCommandHandler({
@@ -77,10 +72,7 @@ const handleAgentContinue = createArtifactCommandHandler({
77
72
  createArtifact: createAgentContinue,
78
73
  renderMarkdown: renderAgentContinueMarkdown,
79
74
  writeOutput: writeAgentContinueOutput,
80
- getOptions: (args) => ({
81
- intent: getFlagValue(args, "--intent"),
82
- format: getJsonCapableFormat(args)
83
- })
75
+ getOptions: buildIntentFormatOptions
84
76
  });
85
77
 
86
78
  const handleAgentStatePack = createArtifactCommandHandler({
@@ -89,13 +81,7 @@ const handleAgentStatePack = createArtifactCommandHandler({
89
81
  createArtifact: createAgentStatePack,
90
82
  renderMarkdown: renderAgentStatePackMarkdown,
91
83
  writeOutput: writeAgentStatePackOutput,
92
- getOptions: (args) => ({
93
- intent: getFlagValue(args, "--intent"),
94
- format: getJsonCapableFormat(args),
95
- currentTaskId: getFlagValue(args, "--current"),
96
- completedPacketIds: getFlagValue(args, "--completed"),
97
- blockedReasons: getFlagValue(args, "--blocked")
98
- })
84
+ getOptions: buildIntentProgressFormatOptions
99
85
  });
100
86
 
101
87
  const handleAgentSession = createArtifactCommandHandler({
@@ -105,7 +91,8 @@ const handleAgentSession = createArtifactCommandHandler({
105
91
  renderMarkdown: renderAgentSessionMarkdown,
106
92
  writeOutput: writeAgentSessionOutput,
107
93
  getOptions: (args) => ({
108
- intent: getFlagValue(args, "--intent")
94
+ ...buildIntentFormatOptions(args),
95
+ format: undefined
109
96
  })
110
97
  });
111
98
 
@@ -18,10 +18,14 @@ import { generateReport, writeReportOutput } from "./report.js";
18
18
  import { createRoadmap, renderRoadmapMarkdown, writeRoadmapOutput } from "./roadmap.js";
19
19
  import { createSharePack, renderSharePackMarkdown, writeSharePackOutput } from "./share-pack.js";
20
20
  import {
21
+ buildFormatOptions,
22
+ buildTaskFormatOutputDirOptions,
23
+ buildTaskOutputDirOptions,
24
+ createContentCommandHandler,
25
+ buildTaskFormatOptions,
21
26
  createArtifactCommandHandler,
22
27
  createPackCommandHandler,
23
28
  getFlagValue,
24
- getRequiredInput,
25
29
  parsePositiveInteger
26
30
  } from "./cli-shared.js";
27
31
 
@@ -49,9 +53,7 @@ const handleAgentHandoff = createArtifactCommandHandler({
49
53
  createArtifact: createAgentHandoff,
50
54
  renderMarkdown: renderAgentHandoffMarkdown,
51
55
  writeOutput: writeAgentHandoffOutput,
52
- getOptions: (args) => ({
53
- format: getFlagValue(args, "--format")
54
- })
56
+ getOptions: buildFormatOptions
55
57
  });
56
58
 
57
59
  const handleApplyPlan = createArtifactCommandHandler({
@@ -60,10 +62,7 @@ const handleApplyPlan = createArtifactCommandHandler({
60
62
  createArtifact: createApplyPlan,
61
63
  renderMarkdown: renderApplyPlanMarkdown,
62
64
  writeOutput: writeApplyPlanOutput,
63
- getOptions: (args) => ({
64
- format: getFlagValue(args, "--format"),
65
- taskId: getFlagValue(args, "--task")
66
- })
65
+ getOptions: buildTaskFormatOptions
67
66
  });
68
67
 
69
68
  const handleCompletionReport = createArtifactCommandHandler({
@@ -72,9 +71,7 @@ const handleCompletionReport = createArtifactCommandHandler({
72
71
  createArtifact: createCompletionReport,
73
72
  renderMarkdown: renderCompletionReportMarkdown,
74
73
  writeOutput: writeCompletionReportOutput,
75
- getOptions: (args) => ({
76
- format: getFlagValue(args, "--format")
77
- })
74
+ getOptions: buildFormatOptions
78
75
  });
79
76
 
80
77
  const handleHandoffBundle = createArtifactCommandHandler({
@@ -83,10 +80,7 @@ const handleHandoffBundle = createArtifactCommandHandler({
83
80
  createArtifact: createHandoffBundle,
84
81
  renderMarkdown: renderHandoffBundleMarkdown,
85
82
  writeOutput: writeHandoffBundleOutput,
86
- getOptions: (args) => ({
87
- format: getFlagValue(args, "--format"),
88
- taskId: getFlagValue(args, "--task")
89
- })
83
+ getOptions: buildTaskFormatOptions
90
84
  });
91
85
 
92
86
  const handleSharePack = createArtifactCommandHandler({
@@ -95,41 +89,28 @@ const handleSharePack = createArtifactCommandHandler({
95
89
  createArtifact: createSharePack,
96
90
  renderMarkdown: renderSharePackMarkdown,
97
91
  writeOutput: writeSharePackOutput,
98
- getOptions: (args) => ({
99
- format: getFlagValue(args, "--format"),
100
- taskId: getFlagValue(args, "--task")
101
- })
92
+ getOptions: buildTaskFormatOptions
102
93
  });
103
94
 
104
95
  const handleExportPack = createPackCommandHandler({
105
96
  commandName: "export-pack",
106
97
  writePack: writeExportPack,
107
98
  renderMarkdown: renderExportPackMarkdown,
108
- getOptions: (args) => ({
109
- format: getFlagValue(args, "--format"),
110
- taskId: getFlagValue(args, "--task"),
111
- outputDir: getFlagValue(args, "--out-dir")
112
- })
99
+ getOptions: buildTaskFormatOutputDirOptions
113
100
  });
114
101
 
115
102
  const handleHtmlPack = createPackCommandHandler({
116
103
  commandName: "html-pack",
117
104
  writePack: writeHtmlPack,
118
105
  renderMarkdown: renderHtmlPackMarkdown,
119
- getOptions: (args) => ({
120
- taskId: getFlagValue(args, "--task"),
121
- outputDir: getFlagValue(args, "--out-dir")
122
- })
106
+ getOptions: buildTaskOutputDirOptions
123
107
  });
124
108
 
125
109
  const handlePublishPack = createPackCommandHandler({
126
110
  commandName: "publish-pack",
127
111
  writePack: writePublishPack,
128
112
  renderMarkdown: renderPublishPackMarkdown,
129
- getOptions: (args) => ({
130
- taskId: getFlagValue(args, "--task"),
131
- outputDir: getFlagValue(args, "--out-dir")
132
- })
113
+ getOptions: buildTaskOutputDirOptions
133
114
  });
134
115
 
135
116
  const handleExecSummary = createArtifactCommandHandler({
@@ -138,9 +119,7 @@ const handleExecSummary = createArtifactCommandHandler({
138
119
  createArtifact: createExecSummary,
139
120
  renderMarkdown: renderExecSummaryMarkdown,
140
121
  writeOutput: writeExecSummaryOutput,
141
- getOptions: (args) => ({
142
- format: getFlagValue(args, "--format")
143
- })
122
+ getOptions: buildFormatOptions
144
123
  });
145
124
 
146
125
  const handleFixPlan = createArtifactCommandHandler({
@@ -149,9 +128,7 @@ const handleFixPlan = createArtifactCommandHandler({
149
128
  createArtifact: createFixPlan,
150
129
  renderMarkdown: renderFixPlanMarkdown,
151
130
  writeOutput: writeFixPlanOutput,
152
- getOptions: (args) => ({
153
- format: getFlagValue(args, "--format")
154
- })
131
+ getOptions: buildFormatOptions
155
132
  });
156
133
 
157
134
  const handleOwnerBoard = createArtifactCommandHandler({
@@ -160,9 +137,7 @@ const handleOwnerBoard = createArtifactCommandHandler({
160
137
  createArtifact: createOwnerBoard,
161
138
  renderMarkdown: renderOwnerBoardMarkdown,
162
139
  writeOutput: writeOwnerBoardOutput,
163
- getOptions: (args) => ({
164
- format: getFlagValue(args, "--format")
165
- })
140
+ getOptions: buildFormatOptions
166
141
  });
167
142
 
168
143
  const handleMeetingPack = createArtifactCommandHandler({
@@ -171,9 +146,7 @@ const handleMeetingPack = createArtifactCommandHandler({
171
146
  createArtifact: createMeetingPack,
172
147
  renderMarkdown: renderMeetingPackMarkdown,
173
148
  writeOutput: writeMeetingPackOutput,
174
- getOptions: (args) => ({
175
- format: getFlagValue(args, "--format")
176
- })
149
+ getOptions: buildFormatOptions
177
150
  });
178
151
 
179
152
  const handlePmBrief = createArtifactCommandHandler({
@@ -182,9 +155,7 @@ const handlePmBrief = createArtifactCommandHandler({
182
155
  createArtifact: createPmBrief,
183
156
  renderMarkdown: renderPmBriefMarkdown,
184
157
  writeOutput: writePmBriefOutput,
185
- getOptions: (args) => ({
186
- format: getFlagValue(args, "--format")
187
- })
158
+ getOptions: buildFormatOptions
188
159
  });
189
160
 
190
161
  const handleRoadmap = createArtifactCommandHandler({
@@ -193,31 +164,25 @@ const handleRoadmap = createArtifactCommandHandler({
193
164
  createArtifact: createRoadmap,
194
165
  renderMarkdown: renderRoadmapMarkdown,
195
166
  writeOutput: writeRoadmapOutput,
196
- getOptions: (args) => ({
197
- format: getFlagValue(args, "--format")
198
- })
167
+ getOptions: buildFormatOptions
199
168
  });
200
169
 
201
- async function handleReport(args) {
202
- const input = getRequiredInput(args, "report");
203
- const maxFileSizeValue = getFlagValue(args, "--max-file-size");
204
- const maxExamplesValue = getFlagValue(args, "--max-examples");
205
- const report = await generateReport(input, {
206
- mode: getFlagValue(args, "--mode"),
207
- format: getFlagValue(args, "--format"),
208
- maxFileSize: maxFileSizeValue ? parsePositiveInteger(maxFileSizeValue, "--max-file-size") : undefined,
209
- maxExamples: maxExamplesValue ? parsePositiveInteger(maxExamplesValue, "--max-examples") : undefined
210
- });
211
-
212
- const outputPath = getFlagValue(args, "--out");
213
- if (outputPath) {
214
- const resolvedOutputPath = await writeReportOutput(outputPath, report.content);
215
- process.stdout.write(`已保存报告:${resolvedOutputPath}\n`);
216
- return;
217
- }
218
-
219
- process.stdout.write(report.content);
220
- }
170
+ const handleReport = createContentCommandHandler({
171
+ commandName: "report",
172
+ execute: async (input, args) => {
173
+ const maxFileSizeValue = getFlagValue(args, "--max-file-size");
174
+ const maxExamplesValue = getFlagValue(args, "--max-examples");
175
+
176
+ return generateReport(input, {
177
+ mode: getFlagValue(args, "--mode"),
178
+ format: getFlagValue(args, "--format"),
179
+ maxFileSize: maxFileSizeValue ? parsePositiveInteger(maxFileSizeValue, "--max-file-size") : undefined,
180
+ maxExamples: maxExamplesValue ? parsePositiveInteger(maxExamplesValue, "--max-examples") : undefined
181
+ });
182
+ },
183
+ getContent: (report) => report.content,
184
+ writeOutput: writeReportOutput
185
+ });
221
186
 
222
187
  export const PLANNING_DELIVERY_COMMAND_HANDLERS = {
223
188
  "agent-handoff": handleAgentHandoff,
package/src/cli-shared.js CHANGED
@@ -33,6 +33,95 @@ export function getJsonCapableFormat(args) {
33
33
  return getFlagValue(args, "--format") || (hasFlag(args, "--json") ? "json" : undefined);
34
34
  }
35
35
 
36
+ export function buildIntentOptions(args) {
37
+ return {
38
+ intent: getFlagValue(args, "--intent")
39
+ };
40
+ }
41
+
42
+ export function buildFormatOptions(args) {
43
+ return {
44
+ format: getFlagValue(args, "--format")
45
+ };
46
+ }
47
+
48
+ export function buildJsonCapableFormatOptions(args) {
49
+ return {
50
+ format: getJsonCapableFormat(args)
51
+ };
52
+ }
53
+
54
+ export function buildTaskOptions(args) {
55
+ return {
56
+ taskId: getFlagValue(args, "--task")
57
+ };
58
+ }
59
+
60
+ export function buildOutputDirOptions(args) {
61
+ return {
62
+ outputDir: getFlagValue(args, "--out-dir")
63
+ };
64
+ }
65
+
66
+ export function buildProgressOptions(args) {
67
+ return {
68
+ currentTaskId: getFlagValue(args, "--current"),
69
+ completedPacketIds: getFlagValue(args, "--completed"),
70
+ blockedReasons: getFlagValue(args, "--blocked")
71
+ };
72
+ }
73
+
74
+ export function buildIntentFormatOptions(args) {
75
+ return {
76
+ ...buildIntentOptions(args),
77
+ ...buildJsonCapableFormatOptions(args)
78
+ };
79
+ }
80
+
81
+ export function buildTaskFormatOptions(args) {
82
+ return {
83
+ ...buildFormatOptions(args),
84
+ ...buildTaskOptions(args)
85
+ };
86
+ }
87
+
88
+ export function buildTaskOutputDirOptions(args) {
89
+ return {
90
+ ...buildTaskOptions(args),
91
+ ...buildOutputDirOptions(args)
92
+ };
93
+ }
94
+
95
+ export function buildTaskFormatOutputDirOptions(args) {
96
+ return {
97
+ ...buildFormatOptions(args),
98
+ ...buildTaskOutputDirOptions(args)
99
+ };
100
+ }
101
+
102
+ export function buildIntentTaskFormatOptions(args) {
103
+ return {
104
+ ...buildIntentOptions(args),
105
+ ...buildFormatOptions(args),
106
+ ...buildTaskOptions(args)
107
+ };
108
+ }
109
+
110
+ export function buildIntentProgressFormatOptions(args) {
111
+ return {
112
+ ...buildIntentOptions(args),
113
+ ...buildJsonCapableFormatOptions(args),
114
+ ...buildProgressOptions(args)
115
+ };
116
+ }
117
+
118
+ export function buildProgressFormatOptions(args) {
119
+ return {
120
+ ...buildJsonCapableFormatOptions(args),
121
+ ...buildProgressOptions(args)
122
+ };
123
+ }
124
+
36
125
  export async function writeOrPrintArtifact({
37
126
  args,
38
127
  commandName,
@@ -133,3 +222,25 @@ export function createActionCommandHandler({
133
222
  }
134
223
  };
135
224
  }
225
+
226
+ export function createContentCommandHandler({
227
+ commandName,
228
+ execute,
229
+ getContent,
230
+ writeOutput
231
+ }) {
232
+ return async function contentCommandHandler(args) {
233
+ const input = getRequiredInput(args, commandName);
234
+ const result = await execute(input, args);
235
+ const content = getContent(result);
236
+ const outputPath = getFlagValue(args, "--out");
237
+
238
+ if (outputPath) {
239
+ const resolvedOutputPath = await writeOutput(outputPath, content);
240
+ process.stdout.write(`已保存${commandName === "report" ? "报告" : ` ${commandName} 结果`}:${resolvedOutputPath}\n`);
241
+ return;
242
+ }
243
+
244
+ process.stdout.write(content);
245
+ };
246
+ }