geo-ai-search-optimization 1.3.8 → 1.3.10

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
@@ -894,6 +894,21 @@ geo-ai-search-optimization help
894
894
  - `src/cli-site-ops-commands.js` 现在统一通过组合器编排 `doctor / quick-start / onboard / onboard-url / audit / scan`
895
895
  - CLI 架构进一步收敛到“命令族 adapter + shared composition primitives”的模式
896
896
 
897
+ ## New in 1.3.9
898
+
899
+ - 继续把“直接执行型命令”也纳入共享组合模式
900
+ - `src/cli-shared.js` 新增 `createActionCommandHandler`
901
+ - `src/cli-shell-commands.js` 里的 `install` 已改成声明式 action 组合
902
+ - `src/cli-site-ops-commands.js` 里的 `init-llms / init-schema` 已改成声明式 action 组合
903
+ - CLI 现在同时覆盖 artifact、structured-output、action 三类共享 composition primitives
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
+
897
912
  ## New in 1.2.20
898
913
 
899
914
  - 新增 `agent-continue`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "geo-ai-search-optimization",
3
- "version": "1.3.8",
3
+ "version": "1.3.10",
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,6 +18,8 @@ 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
+ buildTaskFormatOptions,
21
23
  createArtifactCommandHandler,
22
24
  createPackCommandHandler,
23
25
  getFlagValue,
@@ -49,9 +51,7 @@ const handleAgentHandoff = createArtifactCommandHandler({
49
51
  createArtifact: createAgentHandoff,
50
52
  renderMarkdown: renderAgentHandoffMarkdown,
51
53
  writeOutput: writeAgentHandoffOutput,
52
- getOptions: (args) => ({
53
- format: getFlagValue(args, "--format")
54
- })
54
+ getOptions: buildFormatOptions
55
55
  });
56
56
 
57
57
  const handleApplyPlan = createArtifactCommandHandler({
@@ -60,10 +60,7 @@ const handleApplyPlan = createArtifactCommandHandler({
60
60
  createArtifact: createApplyPlan,
61
61
  renderMarkdown: renderApplyPlanMarkdown,
62
62
  writeOutput: writeApplyPlanOutput,
63
- getOptions: (args) => ({
64
- format: getFlagValue(args, "--format"),
65
- taskId: getFlagValue(args, "--task")
66
- })
63
+ getOptions: buildTaskFormatOptions
67
64
  });
68
65
 
69
66
  const handleCompletionReport = createArtifactCommandHandler({
@@ -72,9 +69,7 @@ const handleCompletionReport = createArtifactCommandHandler({
72
69
  createArtifact: createCompletionReport,
73
70
  renderMarkdown: renderCompletionReportMarkdown,
74
71
  writeOutput: writeCompletionReportOutput,
75
- getOptions: (args) => ({
76
- format: getFlagValue(args, "--format")
77
- })
72
+ getOptions: buildFormatOptions
78
73
  });
79
74
 
80
75
  const handleHandoffBundle = createArtifactCommandHandler({
@@ -83,10 +78,7 @@ const handleHandoffBundle = createArtifactCommandHandler({
83
78
  createArtifact: createHandoffBundle,
84
79
  renderMarkdown: renderHandoffBundleMarkdown,
85
80
  writeOutput: writeHandoffBundleOutput,
86
- getOptions: (args) => ({
87
- format: getFlagValue(args, "--format"),
88
- taskId: getFlagValue(args, "--task")
89
- })
81
+ getOptions: buildTaskFormatOptions
90
82
  });
91
83
 
92
84
  const handleSharePack = createArtifactCommandHandler({
@@ -95,10 +87,7 @@ const handleSharePack = createArtifactCommandHandler({
95
87
  createArtifact: createSharePack,
96
88
  renderMarkdown: renderSharePackMarkdown,
97
89
  writeOutput: writeSharePackOutput,
98
- getOptions: (args) => ({
99
- format: getFlagValue(args, "--format"),
100
- taskId: getFlagValue(args, "--task")
101
- })
90
+ getOptions: buildTaskFormatOptions
102
91
  });
103
92
 
104
93
  const handleExportPack = createPackCommandHandler({
@@ -138,9 +127,7 @@ const handleExecSummary = createArtifactCommandHandler({
138
127
  createArtifact: createExecSummary,
139
128
  renderMarkdown: renderExecSummaryMarkdown,
140
129
  writeOutput: writeExecSummaryOutput,
141
- getOptions: (args) => ({
142
- format: getFlagValue(args, "--format")
143
- })
130
+ getOptions: buildFormatOptions
144
131
  });
145
132
 
146
133
  const handleFixPlan = createArtifactCommandHandler({
@@ -149,9 +136,7 @@ const handleFixPlan = createArtifactCommandHandler({
149
136
  createArtifact: createFixPlan,
150
137
  renderMarkdown: renderFixPlanMarkdown,
151
138
  writeOutput: writeFixPlanOutput,
152
- getOptions: (args) => ({
153
- format: getFlagValue(args, "--format")
154
- })
139
+ getOptions: buildFormatOptions
155
140
  });
156
141
 
157
142
  const handleOwnerBoard = createArtifactCommandHandler({
@@ -160,9 +145,7 @@ const handleOwnerBoard = createArtifactCommandHandler({
160
145
  createArtifact: createOwnerBoard,
161
146
  renderMarkdown: renderOwnerBoardMarkdown,
162
147
  writeOutput: writeOwnerBoardOutput,
163
- getOptions: (args) => ({
164
- format: getFlagValue(args, "--format")
165
- })
148
+ getOptions: buildFormatOptions
166
149
  });
167
150
 
168
151
  const handleMeetingPack = createArtifactCommandHandler({
@@ -171,9 +154,7 @@ const handleMeetingPack = createArtifactCommandHandler({
171
154
  createArtifact: createMeetingPack,
172
155
  renderMarkdown: renderMeetingPackMarkdown,
173
156
  writeOutput: writeMeetingPackOutput,
174
- getOptions: (args) => ({
175
- format: getFlagValue(args, "--format")
176
- })
157
+ getOptions: buildFormatOptions
177
158
  });
178
159
 
179
160
  const handlePmBrief = createArtifactCommandHandler({
@@ -182,9 +163,7 @@ const handlePmBrief = createArtifactCommandHandler({
182
163
  createArtifact: createPmBrief,
183
164
  renderMarkdown: renderPmBriefMarkdown,
184
165
  writeOutput: writePmBriefOutput,
185
- getOptions: (args) => ({
186
- format: getFlagValue(args, "--format")
187
- })
166
+ getOptions: buildFormatOptions
188
167
  });
189
168
 
190
169
  const handleRoadmap = createArtifactCommandHandler({
@@ -193,9 +172,7 @@ const handleRoadmap = createArtifactCommandHandler({
193
172
  createArtifact: createRoadmap,
194
173
  renderMarkdown: renderRoadmapMarkdown,
195
174
  writeOutput: writeRoadmapOutput,
196
- getOptions: (args) => ({
197
- format: getFlagValue(args, "--format")
198
- })
175
+ getOptions: buildFormatOptions
199
176
  });
200
177
 
201
178
  async function handleReport(args) {
package/src/cli-shared.js CHANGED
@@ -33,6 +33,75 @@ 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 buildProgressOptions(args) {
61
+ return {
62
+ currentTaskId: getFlagValue(args, "--current"),
63
+ completedPacketIds: getFlagValue(args, "--completed"),
64
+ blockedReasons: getFlagValue(args, "--blocked")
65
+ };
66
+ }
67
+
68
+ export function buildIntentFormatOptions(args) {
69
+ return {
70
+ ...buildIntentOptions(args),
71
+ ...buildJsonCapableFormatOptions(args)
72
+ };
73
+ }
74
+
75
+ export function buildTaskFormatOptions(args) {
76
+ return {
77
+ ...buildFormatOptions(args),
78
+ ...buildTaskOptions(args)
79
+ };
80
+ }
81
+
82
+ export function buildIntentTaskFormatOptions(args) {
83
+ return {
84
+ ...buildIntentOptions(args),
85
+ ...buildFormatOptions(args),
86
+ ...buildTaskOptions(args)
87
+ };
88
+ }
89
+
90
+ export function buildIntentProgressFormatOptions(args) {
91
+ return {
92
+ ...buildIntentOptions(args),
93
+ ...buildJsonCapableFormatOptions(args),
94
+ ...buildProgressOptions(args)
95
+ };
96
+ }
97
+
98
+ export function buildProgressFormatOptions(args) {
99
+ return {
100
+ ...buildJsonCapableFormatOptions(args),
101
+ ...buildProgressOptions(args)
102
+ };
103
+ }
104
+
36
105
  export async function writeOrPrintArtifact({
37
106
  args,
38
107
  commandName,
@@ -113,3 +182,23 @@ export function createStructuredOutputCommandHandler({
113
182
  process.stdout.write(renderedOutput);
114
183
  };
115
184
  }
185
+
186
+ export function createActionCommandHandler({
187
+ execute,
188
+ getOutputJson,
189
+ renderText
190
+ }) {
191
+ return async function actionCommandHandler(args) {
192
+ const result = await execute(args);
193
+ const outputJson = getOutputJson ? getOutputJson(args, result) : hasFlag(args, "--json");
194
+
195
+ if (outputJson) {
196
+ process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
197
+ return;
198
+ }
199
+
200
+ if (renderText) {
201
+ process.stdout.write(renderText(result, args));
202
+ }
203
+ };
204
+ }
@@ -1,4 +1,4 @@
1
- import { getFlagValue, hasFlag } from "./cli-shared.js";
1
+ import { 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";
@@ -9,15 +9,16 @@ export const SHELL_HELP_LINES = [
9
9
  " geo-ai-search-optimization where"
10
10
  ];
11
11
 
12
- async function handleInstall(args) {
13
- const targetDir = getFlagValue(args, "--target");
14
- const outputJson = hasFlag(args, "--json");
15
- const result = await installSkill({ targetDir, silent: outputJson });
16
-
17
- if (outputJson) {
18
- process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
19
- }
20
- }
12
+ const handleInstall = createActionCommandHandler({
13
+ execute: async (args) => {
14
+ const outputJson = hasFlag(args, "--json");
15
+ return installSkill({
16
+ targetDir: getFlagValue(args, "--target"),
17
+ silent: outputJson
18
+ });
19
+ },
20
+ getOutputJson: (args) => hasFlag(args, "--json")
21
+ });
21
22
 
22
23
  async function handleSkills(args) {
23
24
  const bundle = await listBundledSkills();
@@ -1,5 +1,6 @@
1
1
  import { auditProject, renderAuditMarkdown, writeAuditOutput } from "./audit.js";
2
2
  import {
3
+ createActionCommandHandler,
3
4
  createStructuredOutputCommandHandler,
4
5
  getFlagValue,
5
6
  hasFlag,
@@ -74,46 +75,35 @@ const handleOnboardUrl = createStructuredOutputCommandHandler({
74
75
  getOutputJson: (args) => hasFlag(args, "--json")
75
76
  });
76
77
 
77
- async function handleInitLlms(args) {
78
- const targetDir = args.find((value) => !value.startsWith("-")) || ".";
79
- const outputJson = hasFlag(args, "--json");
80
- const result = await createLlmsTxt({
81
- targetDir,
82
- siteName: getFlagValue(args, "--site-name"),
83
- siteUrl: getFlagValue(args, "--site-url"),
84
- overwrite: hasFlag(args, "--overwrite")
85
- });
86
-
87
- if (outputJson) {
88
- process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
89
- return;
90
- }
91
-
92
- process.stdout.write(`Created llms.txt at ${result.outputPath}\n`);
93
- }
94
-
95
- async function handleInitSchema(args) {
96
- const [schemaType, ...rest] = args;
97
- if (!schemaType || schemaType.startsWith("-")) {
98
- throw new Error("init-schema requires a schema type");
99
- }
100
-
101
- const targetDir = rest.find((value) => !value.startsWith("-")) || ".";
102
- const outputJson = hasFlag(rest, "--json");
103
- const result = await createSchemaTemplate({
104
- schemaType,
105
- targetDir,
106
- siteUrl: getFlagValue(rest, "--site-url"),
107
- overwrite: hasFlag(rest, "--overwrite")
108
- });
109
-
110
- if (outputJson) {
111
- process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
112
- return;
113
- }
114
-
115
- process.stdout.write(`Created ${result.schemaType} schema template at ${result.outputPath}\n`);
116
- }
78
+ const handleInitLlms = createActionCommandHandler({
79
+ execute: async (args) =>
80
+ createLlmsTxt({
81
+ targetDir: args.find((value) => !value.startsWith("-")) || ".",
82
+ siteName: getFlagValue(args, "--site-name"),
83
+ siteUrl: getFlagValue(args, "--site-url"),
84
+ overwrite: hasFlag(args, "--overwrite")
85
+ }),
86
+ getOutputJson: (args) => hasFlag(args, "--json"),
87
+ renderText: (result) => `Created llms.txt at ${result.outputPath}\n`
88
+ });
89
+
90
+ const handleInitSchema = createActionCommandHandler({
91
+ execute: async (args) => {
92
+ const [schemaType, ...rest] = args;
93
+ if (!schemaType || schemaType.startsWith("-")) {
94
+ throw new Error("init-schema requires a schema type");
95
+ }
96
+
97
+ return createSchemaTemplate({
98
+ schemaType,
99
+ targetDir: rest.find((value) => !value.startsWith("-")) || ".",
100
+ siteUrl: getFlagValue(rest, "--site-url"),
101
+ overwrite: hasFlag(rest, "--overwrite")
102
+ });
103
+ },
104
+ getOutputJson: (args) => hasFlag(args, "--json"),
105
+ renderText: (result) => `Created ${result.schemaType} schema template at ${result.outputPath}\n`
106
+ });
117
107
 
118
108
  const handleAudit = createStructuredOutputCommandHandler({
119
109
  commandLabel: "审计",