geo-ai-search-optimization 1.3.10 → 1.3.12

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
@@ -909,6 +909,21 @@ geo-ai-search-optimization help
909
909
  - `src/cli-agent-execution-commands.js`、`src/cli-flow-commands.js`、`src/cli-planning-delivery-commands.js` 现在统一复用这些 builder
910
910
  - CLI 架构进一步接近“adapter registry + shared option builders + shared composition primitives”的模式
911
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
+
920
+ ## New in 1.3.12
921
+
922
+ - 开始把命令说明与 handler 收敛成同源 registry metadata
923
+ - `src/cli-shared.js` 新增 `buildCommandRegistry`
924
+ - `src/cli-shell-commands.js` 与 `src/cli-flow-commands.js` 现在由同一份声明同时生成 help lines 和 handlers
925
+ - CLI 开始从“多个 handler 文件”进一步推进到“显式 command registry”模式
926
+
912
927
  ## New in 1.2.20
913
928
 
914
929
  - 新增 `agent-continue`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "geo-ai-search-optimization",
3
- "version": "1.3.10",
3
+ "version": "1.3.12",
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": {
@@ -17,6 +17,7 @@ import {
17
17
  } from "./agent-state-pack.js";
18
18
  import { createAgentSession, renderAgentSessionMarkdown, writeAgentSessionOutput } from "./agent-session.js";
19
19
  import {
20
+ buildCommandRegistry,
20
21
  buildIntentFormatOptions,
21
22
  buildIntentProgressFormatOptions,
22
23
  createArtifactCommandHandler,
@@ -26,15 +27,6 @@ import {
26
27
  hasFlag
27
28
  } from "./cli-shared.js";
28
29
 
29
- export const FLOW_HELP_LINES = [
30
- " geo-ai-search-optimization agent-orchestrator <input> [--intent <auto|diagnose|guide|execute|share|closeout>] [--format <markdown|json>] [--out <file>]",
31
- " geo-ai-search-optimization agent-resume <input> [--intent <auto|diagnose|guide|execute|share|closeout>] [--format <markdown|json>] [--out <file>]",
32
- " geo-ai-search-optimization agent-continue <input> [--intent <auto|diagnose|guide|execute|share|closeout>] [--format <markdown|json>] [--out <file>]",
33
- " geo-ai-search-optimization agent-state-pack <input> [--intent <auto|diagnose|guide|execute|share|closeout>] [--current <id>] [--completed <id,id>] [--blocked <reason,reason>] [--format <markdown|json>] [--out <file>]",
34
- " geo-ai-search-optimization auto-flow <input> [--intent <auto|diagnose|guide|execute|share|closeout>] [--json] [--out <file>]",
35
- " geo-ai-search-optimization agent-session <input> [--intent <auto|diagnose|guide|execute|share|closeout>] [--json] [--out <file>]"
36
- ];
37
-
38
30
  const handleAutoFlow = createStructuredOutputCommandHandler({
39
31
  commandLabel: "auto-flow",
40
32
  execute: async (args) => {
@@ -96,11 +88,38 @@ const handleAgentSession = createArtifactCommandHandler({
96
88
  })
97
89
  });
98
90
 
99
- export const FLOW_COMMAND_HANDLERS = {
100
- "auto-flow": handleAutoFlow,
101
- "agent-orchestrator": handleAgentOrchestrator,
102
- "agent-resume": handleAgentResume,
103
- "agent-continue": handleAgentContinue,
104
- "agent-state-pack": handleAgentStatePack,
105
- "agent-session": handleAgentSession
106
- };
91
+ const FLOW_COMMAND_REGISTRY = buildCommandRegistry([
92
+ {
93
+ name: "agent-orchestrator",
94
+ help: " geo-ai-search-optimization agent-orchestrator <input> [--intent <auto|diagnose|guide|execute|share|closeout>] [--format <markdown|json>] [--out <file>]",
95
+ handler: handleAgentOrchestrator
96
+ },
97
+ {
98
+ name: "agent-resume",
99
+ help: " geo-ai-search-optimization agent-resume <input> [--intent <auto|diagnose|guide|execute|share|closeout>] [--format <markdown|json>] [--out <file>]",
100
+ handler: handleAgentResume
101
+ },
102
+ {
103
+ name: "agent-continue",
104
+ help: " geo-ai-search-optimization agent-continue <input> [--intent <auto|diagnose|guide|execute|share|closeout>] [--format <markdown|json>] [--out <file>]",
105
+ handler: handleAgentContinue
106
+ },
107
+ {
108
+ name: "agent-state-pack",
109
+ help: " geo-ai-search-optimization agent-state-pack <input> [--intent <auto|diagnose|guide|execute|share|closeout>] [--current <id>] [--completed <id,id>] [--blocked <reason,reason>] [--format <markdown|json>] [--out <file>]",
110
+ handler: handleAgentStatePack
111
+ },
112
+ {
113
+ name: "auto-flow",
114
+ help: " geo-ai-search-optimization auto-flow <input> [--intent <auto|diagnose|guide|execute|share|closeout>] [--json] [--out <file>]",
115
+ handler: handleAutoFlow
116
+ },
117
+ {
118
+ name: "agent-session",
119
+ help: " geo-ai-search-optimization agent-session <input> [--intent <auto|diagnose|guide|execute|share|closeout>] [--json] [--out <file>]",
120
+ handler: handleAgentSession
121
+ }
122
+ ]);
123
+
124
+ export const FLOW_HELP_LINES = FLOW_COMMAND_REGISTRY.helpLines;
125
+ export const FLOW_COMMAND_HANDLERS = FLOW_COMMAND_REGISTRY.handlers;
@@ -19,11 +19,13 @@ import { createRoadmap, renderRoadmapMarkdown, writeRoadmapOutput } from "./road
19
19
  import { createSharePack, renderSharePackMarkdown, writeSharePackOutput } from "./share-pack.js";
20
20
  import {
21
21
  buildFormatOptions,
22
+ buildTaskFormatOutputDirOptions,
23
+ buildTaskOutputDirOptions,
24
+ createContentCommandHandler,
22
25
  buildTaskFormatOptions,
23
26
  createArtifactCommandHandler,
24
27
  createPackCommandHandler,
25
28
  getFlagValue,
26
- getRequiredInput,
27
29
  parsePositiveInteger
28
30
  } from "./cli-shared.js";
29
31
 
@@ -94,31 +96,21 @@ const handleExportPack = createPackCommandHandler({
94
96
  commandName: "export-pack",
95
97
  writePack: writeExportPack,
96
98
  renderMarkdown: renderExportPackMarkdown,
97
- getOptions: (args) => ({
98
- format: getFlagValue(args, "--format"),
99
- taskId: getFlagValue(args, "--task"),
100
- outputDir: getFlagValue(args, "--out-dir")
101
- })
99
+ getOptions: buildTaskFormatOutputDirOptions
102
100
  });
103
101
 
104
102
  const handleHtmlPack = createPackCommandHandler({
105
103
  commandName: "html-pack",
106
104
  writePack: writeHtmlPack,
107
105
  renderMarkdown: renderHtmlPackMarkdown,
108
- getOptions: (args) => ({
109
- taskId: getFlagValue(args, "--task"),
110
- outputDir: getFlagValue(args, "--out-dir")
111
- })
106
+ getOptions: buildTaskOutputDirOptions
112
107
  });
113
108
 
114
109
  const handlePublishPack = createPackCommandHandler({
115
110
  commandName: "publish-pack",
116
111
  writePack: writePublishPack,
117
112
  renderMarkdown: renderPublishPackMarkdown,
118
- getOptions: (args) => ({
119
- taskId: getFlagValue(args, "--task"),
120
- outputDir: getFlagValue(args, "--out-dir")
121
- })
113
+ getOptions: buildTaskOutputDirOptions
122
114
  });
123
115
 
124
116
  const handleExecSummary = createArtifactCommandHandler({
@@ -175,26 +167,22 @@ const handleRoadmap = createArtifactCommandHandler({
175
167
  getOptions: buildFormatOptions
176
168
  });
177
169
 
178
- async function handleReport(args) {
179
- const input = getRequiredInput(args, "report");
180
- const maxFileSizeValue = getFlagValue(args, "--max-file-size");
181
- const maxExamplesValue = getFlagValue(args, "--max-examples");
182
- const report = await generateReport(input, {
183
- mode: getFlagValue(args, "--mode"),
184
- format: getFlagValue(args, "--format"),
185
- maxFileSize: maxFileSizeValue ? parsePositiveInteger(maxFileSizeValue, "--max-file-size") : undefined,
186
- maxExamples: maxExamplesValue ? parsePositiveInteger(maxExamplesValue, "--max-examples") : undefined
187
- });
188
-
189
- const outputPath = getFlagValue(args, "--out");
190
- if (outputPath) {
191
- const resolvedOutputPath = await writeReportOutput(outputPath, report.content);
192
- process.stdout.write(`已保存报告:${resolvedOutputPath}\n`);
193
- return;
194
- }
195
-
196
- process.stdout.write(report.content);
197
- }
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
+ });
198
186
 
199
187
  export const PLANNING_DELIVERY_COMMAND_HANDLERS = {
200
188
  "agent-handoff": handleAgentHandoff,
package/src/cli-shared.js CHANGED
@@ -57,6 +57,12 @@ export function buildTaskOptions(args) {
57
57
  };
58
58
  }
59
59
 
60
+ export function buildOutputDirOptions(args) {
61
+ return {
62
+ outputDir: getFlagValue(args, "--out-dir")
63
+ };
64
+ }
65
+
60
66
  export function buildProgressOptions(args) {
61
67
  return {
62
68
  currentTaskId: getFlagValue(args, "--current"),
@@ -79,6 +85,20 @@ export function buildTaskFormatOptions(args) {
79
85
  };
80
86
  }
81
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
+
82
102
  export function buildIntentTaskFormatOptions(args) {
83
103
  return {
84
104
  ...buildIntentOptions(args),
@@ -202,3 +222,32 @@ export function createActionCommandHandler({
202
222
  }
203
223
  };
204
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
+ }
247
+
248
+ export function buildCommandRegistry(commandEntries) {
249
+ return {
250
+ helpLines: commandEntries.map((entry) => entry.help),
251
+ handlers: Object.fromEntries(commandEntries.map((entry) => [entry.name, entry.handler]))
252
+ };
253
+ }
@@ -1,14 +1,8 @@
1
- import { createActionCommandHandler, getFlagValue, hasFlag } from "./cli-shared.js";
1
+ import { buildCommandRegistry, createActionCommandHandler, getFlagValue, hasFlag } from "./cli-shared.js";
2
2
  import { installSkill } from "./install-skill.js";
3
3
  import { getBundledSkillPath, getInstalledSkillPath, getSkillName, getSkillsDir } from "./paths.js";
4
4
  import { listBundledSkills, renderBundledSkillsMarkdown } from "./skills.js";
5
5
 
6
- export const SHELL_HELP_LINES = [
7
- " geo-ai-search-optimization install [--target <dir>] [--json]",
8
- " geo-ai-search-optimization skills [--json]",
9
- " geo-ai-search-optimization where"
10
- ];
11
-
12
6
  const handleInstall = createActionCommandHandler({
13
7
  execute: async (args) => {
14
8
  const outputJson = hasFlag(args, "--json");
@@ -41,8 +35,23 @@ function handleWhere() {
41
35
  );
42
36
  }
43
37
 
44
- export const SHELL_COMMAND_HANDLERS = {
45
- install: handleInstall,
46
- skills: handleSkills,
47
- where: handleWhere
48
- };
38
+ const SHELL_COMMAND_REGISTRY = buildCommandRegistry([
39
+ {
40
+ name: "install",
41
+ help: " geo-ai-search-optimization install [--target <dir>] [--json]",
42
+ handler: handleInstall
43
+ },
44
+ {
45
+ name: "skills",
46
+ help: " geo-ai-search-optimization skills [--json]",
47
+ handler: handleSkills
48
+ },
49
+ {
50
+ name: "where",
51
+ help: " geo-ai-search-optimization where",
52
+ handler: handleWhere
53
+ }
54
+ ]);
55
+
56
+ export const SHELL_HELP_LINES = SHELL_COMMAND_REGISTRY.helpLines;
57
+ export const SHELL_COMMAND_HANDLERS = SHELL_COMMAND_REGISTRY.handlers;