geo-ai-search-optimization 1.3.1 → 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 +14 -0
- package/package.json +1 -1
- package/src/cli-agent-execution-commands.js +210 -0
- package/src/cli-flow-commands.js +143 -0
- package/src/cli-shared.js +54 -0
- package/src/cli.js +14 -499
package/README.md
CHANGED
|
@@ -844,6 +844,20 @@ geo-ai-search-optimization help
|
|
|
844
844
|
- `auto-flow` 已能识别 `geo-agent-state-pack` 并继续往下路由
|
|
845
845
|
- 新增 `geo-ai-search-optimization-agent-state-pack` skill
|
|
846
846
|
|
|
847
|
+
## New in 1.3.2
|
|
848
|
+
|
|
849
|
+
- 进行了 CLI 架构迭代,把 flow/routing 相关命令从主 `cli.js` 拆到独立模块
|
|
850
|
+
- 新增 `src/cli-flow-commands.js`,让 `auto-flow / agent-orchestrator / agent-resume / agent-continue / agent-state-pack / agent-session` 形成一个明确的 adapter 边界
|
|
851
|
+
- 新增 `src/cli-shared.js`,集中处理 flag 解析、输入校验和输出写回,降低后续继续加命令时的耦合
|
|
852
|
+
- 主 `cli.js` 现在更像薄路由层,后续扩充 command family 会更稳
|
|
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
|
+
|
|
847
861
|
## New in 1.2.20
|
|
848
862
|
|
|
849
863
|
- 新增 `agent-continue`
|
package/package.json
CHANGED
|
@@ -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
|
+
};
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { createAutoFlow, renderAutoFlowMarkdown, writeAutoFlowOutput } from "./auto-flow.js";
|
|
2
|
+
import {
|
|
3
|
+
createAgentContinue,
|
|
4
|
+
renderAgentContinueMarkdown,
|
|
5
|
+
writeAgentContinueOutput
|
|
6
|
+
} from "./agent-continue.js";
|
|
7
|
+
import {
|
|
8
|
+
createAgentOrchestrator,
|
|
9
|
+
renderAgentOrchestratorMarkdown,
|
|
10
|
+
writeAgentOrchestratorOutput
|
|
11
|
+
} from "./agent-orchestrator.js";
|
|
12
|
+
import { createAgentResume, renderAgentResumeMarkdown, writeAgentResumeOutput } from "./agent-resume.js";
|
|
13
|
+
import {
|
|
14
|
+
createAgentStatePack,
|
|
15
|
+
renderAgentStatePackMarkdown,
|
|
16
|
+
writeAgentStatePackOutput
|
|
17
|
+
} from "./agent-state-pack.js";
|
|
18
|
+
import { createAgentSession, renderAgentSessionMarkdown, writeAgentSessionOutput } from "./agent-session.js";
|
|
19
|
+
import {
|
|
20
|
+
getFlagValue,
|
|
21
|
+
getJsonCapableFormat,
|
|
22
|
+
getRequiredInput,
|
|
23
|
+
hasFlag,
|
|
24
|
+
writeOrPrintArtifact
|
|
25
|
+
} from "./cli-shared.js";
|
|
26
|
+
|
|
27
|
+
export const FLOW_HELP_LINES = [
|
|
28
|
+
" geo-ai-search-optimization agent-orchestrator <input> [--intent <auto|diagnose|guide|execute|share|closeout>] [--format <markdown|json>] [--out <file>]",
|
|
29
|
+
" geo-ai-search-optimization agent-resume <input> [--intent <auto|diagnose|guide|execute|share|closeout>] [--format <markdown|json>] [--out <file>]",
|
|
30
|
+
" geo-ai-search-optimization agent-continue <input> [--intent <auto|diagnose|guide|execute|share|closeout>] [--format <markdown|json>] [--out <file>]",
|
|
31
|
+
" 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>]",
|
|
32
|
+
" geo-ai-search-optimization auto-flow <input> [--intent <auto|diagnose|guide|execute|share|closeout>] [--json] [--out <file>]",
|
|
33
|
+
" geo-ai-search-optimization agent-session <input> [--intent <auto|diagnose|guide|execute|share|closeout>] [--json] [--out <file>]"
|
|
34
|
+
];
|
|
35
|
+
|
|
36
|
+
async function handleAutoFlow(args) {
|
|
37
|
+
const input = getRequiredInput(args, "auto-flow");
|
|
38
|
+
const flow = await createAutoFlow(input, {
|
|
39
|
+
intent: getFlagValue(args, "--intent")
|
|
40
|
+
});
|
|
41
|
+
const outputJson = hasFlag(args, "--json");
|
|
42
|
+
const renderedOutput = outputJson ? `${JSON.stringify(flow, null, 2)}\n` : renderAutoFlowMarkdown(flow);
|
|
43
|
+
const outputPath = getFlagValue(args, "--out");
|
|
44
|
+
|
|
45
|
+
if (outputPath) {
|
|
46
|
+
const resolvedOutputPath = await writeAutoFlowOutput(outputPath, renderedOutput);
|
|
47
|
+
process.stdout.write(`已保存 auto-flow 结果:${resolvedOutputPath}\n`);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
process.stdout.write(renderedOutput);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
async function handleAgentOrchestrator(args) {
|
|
55
|
+
const input = getRequiredInput(args, "agent-orchestrator");
|
|
56
|
+
const artifact = await createAgentOrchestrator(input, {
|
|
57
|
+
intent: getFlagValue(args, "--intent"),
|
|
58
|
+
format: getJsonCapableFormat(args)
|
|
59
|
+
});
|
|
60
|
+
return writeOrPrintArtifact({
|
|
61
|
+
args,
|
|
62
|
+
commandName: "agent-orchestrator",
|
|
63
|
+
artifact,
|
|
64
|
+
renderMarkdown: renderAgentOrchestratorMarkdown,
|
|
65
|
+
writeOutput: writeAgentOrchestratorOutput,
|
|
66
|
+
outputJson: artifact.format === "json"
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
async function handleAgentResume(args) {
|
|
71
|
+
const input = getRequiredInput(args, "agent-resume");
|
|
72
|
+
const artifact = await createAgentResume(input, {
|
|
73
|
+
intent: getFlagValue(args, "--intent"),
|
|
74
|
+
format: getJsonCapableFormat(args)
|
|
75
|
+
});
|
|
76
|
+
return writeOrPrintArtifact({
|
|
77
|
+
args,
|
|
78
|
+
commandName: "agent-resume",
|
|
79
|
+
artifact,
|
|
80
|
+
renderMarkdown: renderAgentResumeMarkdown,
|
|
81
|
+
writeOutput: writeAgentResumeOutput,
|
|
82
|
+
outputJson: artifact.format === "json"
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
async function handleAgentContinue(args) {
|
|
87
|
+
const input = getRequiredInput(args, "agent-continue");
|
|
88
|
+
const artifact = await createAgentContinue(input, {
|
|
89
|
+
intent: getFlagValue(args, "--intent"),
|
|
90
|
+
format: getJsonCapableFormat(args)
|
|
91
|
+
});
|
|
92
|
+
return writeOrPrintArtifact({
|
|
93
|
+
args,
|
|
94
|
+
commandName: "agent-continue",
|
|
95
|
+
artifact,
|
|
96
|
+
renderMarkdown: renderAgentContinueMarkdown,
|
|
97
|
+
writeOutput: writeAgentContinueOutput,
|
|
98
|
+
outputJson: artifact.format === "json"
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
async function handleAgentStatePack(args) {
|
|
103
|
+
const input = getRequiredInput(args, "agent-state-pack");
|
|
104
|
+
const artifact = await createAgentStatePack(input, {
|
|
105
|
+
intent: getFlagValue(args, "--intent"),
|
|
106
|
+
format: getJsonCapableFormat(args),
|
|
107
|
+
currentTaskId: getFlagValue(args, "--current"),
|
|
108
|
+
completedPacketIds: getFlagValue(args, "--completed"),
|
|
109
|
+
blockedReasons: getFlagValue(args, "--blocked")
|
|
110
|
+
});
|
|
111
|
+
return writeOrPrintArtifact({
|
|
112
|
+
args,
|
|
113
|
+
commandName: "agent-state-pack",
|
|
114
|
+
artifact,
|
|
115
|
+
renderMarkdown: renderAgentStatePackMarkdown,
|
|
116
|
+
writeOutput: writeAgentStatePackOutput,
|
|
117
|
+
outputJson: artifact.format === "json"
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
async function handleAgentSession(args) {
|
|
122
|
+
const input = getRequiredInput(args, "agent-session");
|
|
123
|
+
const artifact = await createAgentSession(input, {
|
|
124
|
+
intent: getFlagValue(args, "--intent")
|
|
125
|
+
});
|
|
126
|
+
return writeOrPrintArtifact({
|
|
127
|
+
args,
|
|
128
|
+
commandName: "agent-session",
|
|
129
|
+
artifact,
|
|
130
|
+
renderMarkdown: renderAgentSessionMarkdown,
|
|
131
|
+
writeOutput: writeAgentSessionOutput,
|
|
132
|
+
outputJson: hasFlag(args, "--json")
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export const FLOW_COMMAND_HANDLERS = {
|
|
137
|
+
"auto-flow": handleAutoFlow,
|
|
138
|
+
"agent-orchestrator": handleAgentOrchestrator,
|
|
139
|
+
"agent-resume": handleAgentResume,
|
|
140
|
+
"agent-continue": handleAgentContinue,
|
|
141
|
+
"agent-state-pack": handleAgentStatePack,
|
|
142
|
+
"agent-session": handleAgentSession
|
|
143
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export function getFlagValue(args, flagName) {
|
|
2
|
+
const index = args.indexOf(flagName);
|
|
3
|
+
if (index === -1) {
|
|
4
|
+
return null;
|
|
5
|
+
}
|
|
6
|
+
if (index === args.length - 1) {
|
|
7
|
+
throw new Error(`${flagName} requires a value`);
|
|
8
|
+
}
|
|
9
|
+
return args[index + 1];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function hasFlag(args, ...flagNames) {
|
|
13
|
+
return flagNames.some((flagName) => args.includes(flagName));
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function parsePositiveInteger(value, flagName) {
|
|
17
|
+
const parsed = Number.parseInt(value, 10);
|
|
18
|
+
if (!Number.isInteger(parsed) || parsed <= 0) {
|
|
19
|
+
throw new Error(`${flagName} must be a positive integer`);
|
|
20
|
+
}
|
|
21
|
+
return parsed;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function getRequiredInput(args, commandName) {
|
|
25
|
+
const input = args.find((value) => !value.startsWith("-"));
|
|
26
|
+
if (!input) {
|
|
27
|
+
throw new Error(`${commandName} 需要一个输入值,可以是任务描述、项目路径、网站网址或已导出的工件`);
|
|
28
|
+
}
|
|
29
|
+
return input;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function getJsonCapableFormat(args) {
|
|
33
|
+
return getFlagValue(args, "--format") || (hasFlag(args, "--json") ? "json" : undefined);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export async function writeOrPrintArtifact({
|
|
37
|
+
args,
|
|
38
|
+
commandName,
|
|
39
|
+
artifact,
|
|
40
|
+
renderMarkdown,
|
|
41
|
+
writeOutput,
|
|
42
|
+
outputJson
|
|
43
|
+
}) {
|
|
44
|
+
const renderedOutput = outputJson ? `${JSON.stringify(artifact, null, 2)}\n` : renderMarkdown(artifact);
|
|
45
|
+
const outputPath = getFlagValue(args, "--out");
|
|
46
|
+
|
|
47
|
+
if (outputPath) {
|
|
48
|
+
const resolvedOutputPath = await writeOutput(outputPath, renderedOutput);
|
|
49
|
+
process.stdout.write(`已保存 ${commandName} 结果:${resolvedOutputPath}\n`);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
process.stdout.write(renderedOutput);
|
|
54
|
+
}
|
package/src/cli.js
CHANGED
|
@@ -1,47 +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 { createApplyPlan, renderApplyPlanMarkdown, writeApplyPlanOutput } from "./apply-plan.js";
|
|
5
|
-
import {
|
|
6
|
-
createAgentBatchExecutor,
|
|
7
|
-
renderAgentBatchExecutorMarkdown,
|
|
8
|
-
writeAgentBatchExecutorOutput
|
|
9
|
-
} from "./agent-batch-executor.js";
|
|
10
|
-
import {
|
|
11
|
-
createAgentContinue,
|
|
12
|
-
renderAgentContinueMarkdown,
|
|
13
|
-
writeAgentContinueOutput
|
|
14
|
-
} from "./agent-continue.js";
|
|
15
4
|
import {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
} from "./
|
|
20
|
-
import {
|
|
5
|
+
AGENT_EXECUTION_COMMAND_HANDLERS,
|
|
6
|
+
AGENT_EXECUTION_HELP_LINES
|
|
7
|
+
} from "./cli-agent-execution-commands.js";
|
|
8
|
+
import { FLOW_COMMAND_HANDLERS, FLOW_HELP_LINES } from "./cli-flow-commands.js";
|
|
9
|
+
import { getFlagValue, hasFlag, parsePositiveInteger } from "./cli-shared.js";
|
|
10
|
+
import { createApplyPlan, renderApplyPlanMarkdown, writeApplyPlanOutput } from "./apply-plan.js";
|
|
21
11
|
import { createAgentHandoff, renderAgentHandoffMarkdown, writeAgentHandoffOutput } from "./agent-handoff.js";
|
|
22
|
-
import {
|
|
23
|
-
createAgentProgressTracker,
|
|
24
|
-
renderAgentProgressTrackerMarkdown,
|
|
25
|
-
writeAgentProgressTrackerOutput
|
|
26
|
-
} from "./agent-progress-tracker.js";
|
|
27
|
-
import { createAgentCheckpoint, renderAgentCheckpointMarkdown, writeAgentCheckpointOutput } from "./agent-checkpoint.js";
|
|
28
|
-
import { createAgentDecisionLog, renderAgentDecisionLogMarkdown, writeAgentDecisionLogOutput } from "./agent-decision-log.js";
|
|
29
|
-
import {
|
|
30
|
-
createAgentOrchestrator,
|
|
31
|
-
renderAgentOrchestratorMarkdown,
|
|
32
|
-
writeAgentOrchestratorOutput
|
|
33
|
-
} from "./agent-orchestrator.js";
|
|
34
|
-
import { createAgentResume, renderAgentResumeMarkdown, writeAgentResumeOutput } from "./agent-resume.js";
|
|
35
|
-
import {
|
|
36
|
-
createAgentPlaybookPack,
|
|
37
|
-
renderAgentPlaybookPackMarkdown,
|
|
38
|
-
writeAgentPlaybookPackOutput
|
|
39
|
-
} from "./agent-playbook-pack.js";
|
|
40
|
-
import { createAgentRetrospective, renderAgentRetrospectiveMarkdown, writeAgentRetrospectiveOutput } from "./agent-retrospective.js";
|
|
41
|
-
import { createAgentStatusBoard, renderAgentStatusBoardMarkdown, writeAgentStatusBoardOutput } from "./agent-status-board.js";
|
|
42
|
-
import { createAgentRunbook, renderAgentRunbookMarkdown, writeAgentRunbookOutput } from "./agent-runbook.js";
|
|
43
|
-
import { createAgentSession, renderAgentSessionMarkdown, writeAgentSessionOutput } from "./agent-session.js";
|
|
44
|
-
import { createAutoFlow, renderAutoFlowMarkdown, writeAutoFlowOutput } from "./auto-flow.js";
|
|
45
12
|
import {
|
|
46
13
|
createCompletionReport,
|
|
47
14
|
renderCompletionReportMarkdown,
|
|
@@ -96,21 +63,8 @@ function printHelp() {
|
|
|
96
63
|
"Usage:",
|
|
97
64
|
" geo-ai-search-optimization",
|
|
98
65
|
" geo-ai-search-optimization install [--target <dir>] [--json]",
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
" geo-ai-search-optimization agent-continue <input> [--intent <auto|diagnose|guide|execute|share|closeout>] [--format <markdown|json>] [--out <file>]",
|
|
102
|
-
" 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>]",
|
|
103
|
-
" geo-ai-search-optimization auto-flow <input> [--intent <auto|diagnose|guide|execute|share|closeout>] [--json] [--out <file>]",
|
|
104
|
-
" geo-ai-search-optimization agent-session <input> [--intent <auto|diagnose|guide|execute|share|closeout>] [--json] [--out <file>]",
|
|
105
|
-
" geo-ai-search-optimization agent-runbook <input> [--intent <auto|diagnose|guide|execute|share|closeout>] [--task <id>] [--format <markdown|json>] [--out <file>]",
|
|
106
|
-
" geo-ai-search-optimization agent-executor <input> [--intent <auto|diagnose|guide|execute|share|closeout>] [--task <id>] [--format <markdown|json>] [--out <file>]",
|
|
107
|
-
" geo-ai-search-optimization agent-batch-executor <input> [--intent <auto|diagnose|guide|execute|share|closeout>] [--task <id>] [--count <count>] [--format <markdown|json>] [--out <file>]",
|
|
108
|
-
" geo-ai-search-optimization agent-progress-tracker <input> [--current <id>] [--completed <id,id>] [--blocked <reason,reason>] [--format <markdown|json>] [--out <file>]",
|
|
109
|
-
" geo-ai-search-optimization agent-status-board <input> [--current <id>] [--completed <id,id>] [--blocked <reason,reason>] [--format <markdown|json>] [--out <file>]",
|
|
110
|
-
" geo-ai-search-optimization agent-checkpoint <input> [--current <id>] [--completed <id,id>] [--blocked <reason,reason>] [--format <markdown|json>] [--out <file>]",
|
|
111
|
-
" 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>]",
|
|
112
|
-
" geo-ai-search-optimization agent-retrospective <input> [--format <markdown|json>] [--out <file>]",
|
|
113
|
-
" geo-ai-search-optimization agent-playbook-pack <input> [--task <id>] [--format <markdown|json>] [--out <file>]",
|
|
66
|
+
...FLOW_HELP_LINES,
|
|
67
|
+
...AGENT_EXECUTION_HELP_LINES,
|
|
114
68
|
" geo-ai-search-optimization skills [--json]",
|
|
115
69
|
" geo-ai-search-optimization where",
|
|
116
70
|
" geo-ai-search-optimization doctor [--json]",
|
|
@@ -148,29 +102,6 @@ function printHelp() {
|
|
|
148
102
|
);
|
|
149
103
|
}
|
|
150
104
|
|
|
151
|
-
function getFlagValue(args, flagName) {
|
|
152
|
-
const index = args.indexOf(flagName);
|
|
153
|
-
if (index === -1) {
|
|
154
|
-
return null;
|
|
155
|
-
}
|
|
156
|
-
if (index === args.length - 1) {
|
|
157
|
-
throw new Error(`${flagName} requires a value`);
|
|
158
|
-
}
|
|
159
|
-
return args[index + 1];
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
function hasFlag(args, ...flagNames) {
|
|
163
|
-
return flagNames.some((flagName) => args.includes(flagName));
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
function parsePositiveInteger(value, flagName) {
|
|
167
|
-
const parsed = Number.parseInt(value, 10);
|
|
168
|
-
if (!Number.isInteger(parsed) || parsed <= 0) {
|
|
169
|
-
throw new Error(`${flagName} must be a positive integer`);
|
|
170
|
-
}
|
|
171
|
-
return parsed;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
105
|
async function handleInstall(args) {
|
|
175
106
|
const targetDir = getFlagValue(args, "--target");
|
|
176
107
|
const outputJson = hasFlag(args, "--json");
|
|
@@ -181,404 +112,6 @@ async function handleInstall(args) {
|
|
|
181
112
|
}
|
|
182
113
|
}
|
|
183
114
|
|
|
184
|
-
async function handleAutoFlow(args) {
|
|
185
|
-
const input = args.find((value) => !value.startsWith("-"));
|
|
186
|
-
if (!input) {
|
|
187
|
-
throw new Error("auto-flow 需要一个输入值,可以是任务描述、项目路径、网站网址或已导出的工件");
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
const flow = await createAutoFlow(input, {
|
|
191
|
-
intent: getFlagValue(args, "--intent")
|
|
192
|
-
});
|
|
193
|
-
const outputJson = hasFlag(args, "--json");
|
|
194
|
-
const renderedOutput = outputJson ? `${JSON.stringify(flow, null, 2)}\n` : renderAutoFlowMarkdown(flow);
|
|
195
|
-
|
|
196
|
-
const outputPath = getFlagValue(args, "--out");
|
|
197
|
-
if (outputPath) {
|
|
198
|
-
const resolvedOutputPath = await writeAutoFlowOutput(outputPath, renderedOutput);
|
|
199
|
-
process.stdout.write(`已保存 auto-flow 结果:${resolvedOutputPath}\n`);
|
|
200
|
-
return;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
process.stdout.write(renderedOutput);
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
async function handleAgentOrchestrator(args) {
|
|
207
|
-
const input = args.find((value) => !value.startsWith("-"));
|
|
208
|
-
if (!input) {
|
|
209
|
-
throw new Error("agent-orchestrator 需要一个输入值,可以是任务描述、项目路径、网站网址或已导出的工件");
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
const format = getFlagValue(args, "--format") || (hasFlag(args, "--json") ? "json" : undefined);
|
|
213
|
-
const orchestrator = await createAgentOrchestrator(input, {
|
|
214
|
-
intent: getFlagValue(args, "--intent"),
|
|
215
|
-
format
|
|
216
|
-
});
|
|
217
|
-
const outputJson = orchestrator.format === "json";
|
|
218
|
-
const renderedOutput = outputJson
|
|
219
|
-
? `${JSON.stringify(orchestrator, null, 2)}\n`
|
|
220
|
-
: renderAgentOrchestratorMarkdown(orchestrator);
|
|
221
|
-
|
|
222
|
-
const outputPath = getFlagValue(args, "--out");
|
|
223
|
-
if (outputPath) {
|
|
224
|
-
const resolvedOutputPath = await writeAgentOrchestratorOutput(outputPath, renderedOutput);
|
|
225
|
-
process.stdout.write(`已保存 agent-orchestrator 结果:${resolvedOutputPath}\n`);
|
|
226
|
-
return;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
process.stdout.write(renderedOutput);
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
async function handleAgentResume(args) {
|
|
233
|
-
const input = args.find((value) => !value.startsWith("-"));
|
|
234
|
-
if (!input) {
|
|
235
|
-
throw new Error("agent-resume 需要一个输入值,可以是任务描述、项目路径、网站网址或已导出的工件");
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
const format = getFlagValue(args, "--format") || (hasFlag(args, "--json") ? "json" : undefined);
|
|
239
|
-
const resume = await createAgentResume(input, {
|
|
240
|
-
intent: getFlagValue(args, "--intent"),
|
|
241
|
-
format
|
|
242
|
-
});
|
|
243
|
-
const outputJson = resume.format === "json";
|
|
244
|
-
const renderedOutput = outputJson ? `${JSON.stringify(resume, null, 2)}\n` : renderAgentResumeMarkdown(resume);
|
|
245
|
-
|
|
246
|
-
const outputPath = getFlagValue(args, "--out");
|
|
247
|
-
if (outputPath) {
|
|
248
|
-
const resolvedOutputPath = await writeAgentResumeOutput(outputPath, renderedOutput);
|
|
249
|
-
process.stdout.write(`已保存 agent-resume 结果:${resolvedOutputPath}\n`);
|
|
250
|
-
return;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
process.stdout.write(renderedOutput);
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
async function handleAgentContinue(args) {
|
|
257
|
-
const input = args.find((value) => !value.startsWith("-"));
|
|
258
|
-
if (!input) {
|
|
259
|
-
throw new Error("agent-continue 需要一个输入值,可以是任务描述、项目路径、网站网址或已导出的工件");
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
const format = getFlagValue(args, "--format") || (hasFlag(args, "--json") ? "json" : undefined);
|
|
263
|
-
const artifact = await createAgentContinue(input, {
|
|
264
|
-
intent: getFlagValue(args, "--intent"),
|
|
265
|
-
format
|
|
266
|
-
});
|
|
267
|
-
const outputJson = artifact.format === "json";
|
|
268
|
-
const renderedOutput = outputJson
|
|
269
|
-
? `${JSON.stringify(artifact, null, 2)}\n`
|
|
270
|
-
: renderAgentContinueMarkdown(artifact);
|
|
271
|
-
|
|
272
|
-
const outputPath = getFlagValue(args, "--out");
|
|
273
|
-
if (outputPath) {
|
|
274
|
-
const resolvedOutputPath = await writeAgentContinueOutput(outputPath, renderedOutput);
|
|
275
|
-
process.stdout.write(`已保存 agent-continue 结果:${resolvedOutputPath}\n`);
|
|
276
|
-
return;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
process.stdout.write(renderedOutput);
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
async function handleAgentStatePack(args) {
|
|
283
|
-
const input = args.find((value) => !value.startsWith("-"));
|
|
284
|
-
if (!input) {
|
|
285
|
-
throw new Error("agent-state-pack 需要一个输入值,可以是任务描述、项目路径、网站网址或已导出的工件");
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
const format = getFlagValue(args, "--format") || (hasFlag(args, "--json") ? "json" : undefined);
|
|
289
|
-
const artifact = await createAgentStatePack(input, {
|
|
290
|
-
intent: getFlagValue(args, "--intent"),
|
|
291
|
-
format,
|
|
292
|
-
currentTaskId: getFlagValue(args, "--current"),
|
|
293
|
-
completedPacketIds: getFlagValue(args, "--completed"),
|
|
294
|
-
blockedReasons: getFlagValue(args, "--blocked")
|
|
295
|
-
});
|
|
296
|
-
const outputJson = artifact.format === "json";
|
|
297
|
-
const renderedOutput = outputJson
|
|
298
|
-
? `${JSON.stringify(artifact, null, 2)}\n`
|
|
299
|
-
: renderAgentStatePackMarkdown(artifact);
|
|
300
|
-
|
|
301
|
-
const outputPath = getFlagValue(args, "--out");
|
|
302
|
-
if (outputPath) {
|
|
303
|
-
const resolvedOutputPath = await writeAgentStatePackOutput(outputPath, renderedOutput);
|
|
304
|
-
process.stdout.write(`已保存 agent-state-pack 结果:${resolvedOutputPath}\n`);
|
|
305
|
-
return;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
process.stdout.write(renderedOutput);
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
async function handleAgentSession(args) {
|
|
312
|
-
const input = args.find((value) => !value.startsWith("-"));
|
|
313
|
-
if (!input) {
|
|
314
|
-
throw new Error("agent-session 需要一个输入值,可以是任务描述、项目路径、网站网址或已导出的工件");
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
const session = await createAgentSession(input, {
|
|
318
|
-
intent: getFlagValue(args, "--intent")
|
|
319
|
-
});
|
|
320
|
-
const outputJson = hasFlag(args, "--json");
|
|
321
|
-
const renderedOutput = outputJson
|
|
322
|
-
? `${JSON.stringify(session, null, 2)}\n`
|
|
323
|
-
: renderAgentSessionMarkdown(session);
|
|
324
|
-
|
|
325
|
-
const outputPath = getFlagValue(args, "--out");
|
|
326
|
-
if (outputPath) {
|
|
327
|
-
const resolvedOutputPath = await writeAgentSessionOutput(outputPath, renderedOutput);
|
|
328
|
-
process.stdout.write(`已保存 agent-session 结果:${resolvedOutputPath}\n`);
|
|
329
|
-
return;
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
process.stdout.write(renderedOutput);
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
async function handleAgentRunbook(args) {
|
|
336
|
-
const input = args.find((value) => !value.startsWith("-"));
|
|
337
|
-
if (!input) {
|
|
338
|
-
throw new Error("agent-runbook 需要一个输入值,可以是任务描述、项目路径、网站网址或已导出的工件");
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
const format = getFlagValue(args, "--format");
|
|
342
|
-
const runbook = await createAgentRunbook(input, {
|
|
343
|
-
intent: getFlagValue(args, "--intent"),
|
|
344
|
-
format,
|
|
345
|
-
taskId: getFlagValue(args, "--task")
|
|
346
|
-
});
|
|
347
|
-
const outputJson = format === "json";
|
|
348
|
-
const renderedOutput = outputJson
|
|
349
|
-
? `${JSON.stringify(runbook, null, 2)}\n`
|
|
350
|
-
: renderAgentRunbookMarkdown(runbook);
|
|
351
|
-
|
|
352
|
-
const outputPath = getFlagValue(args, "--out");
|
|
353
|
-
if (outputPath) {
|
|
354
|
-
const resolvedOutputPath = await writeAgentRunbookOutput(outputPath, renderedOutput);
|
|
355
|
-
process.stdout.write(`已保存 agent runbook:${resolvedOutputPath}\n`);
|
|
356
|
-
return;
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
process.stdout.write(renderedOutput);
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
async function handleAgentExecutor(args) {
|
|
363
|
-
const input = args.find((value) => !value.startsWith("-"));
|
|
364
|
-
if (!input) {
|
|
365
|
-
throw new Error("agent-executor 需要一个输入值,可以是任务描述、项目路径、网站网址或已导出的工件");
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
const format = getFlagValue(args, "--format");
|
|
369
|
-
const executor = await createAgentExecutor(input, {
|
|
370
|
-
intent: getFlagValue(args, "--intent"),
|
|
371
|
-
format,
|
|
372
|
-
taskId: getFlagValue(args, "--task")
|
|
373
|
-
});
|
|
374
|
-
const outputJson = format === "json";
|
|
375
|
-
const renderedOutput = outputJson
|
|
376
|
-
? `${JSON.stringify(executor, null, 2)}\n`
|
|
377
|
-
: renderAgentExecutorMarkdown(executor);
|
|
378
|
-
|
|
379
|
-
const outputPath = getFlagValue(args, "--out");
|
|
380
|
-
if (outputPath) {
|
|
381
|
-
const resolvedOutputPath = await writeAgentExecutorOutput(outputPath, renderedOutput);
|
|
382
|
-
process.stdout.write(`已保存 agent executor:${resolvedOutputPath}\n`);
|
|
383
|
-
return;
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
process.stdout.write(renderedOutput);
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
async function handleAgentBatchExecutor(args) {
|
|
390
|
-
const input = args.find((value) => !value.startsWith("-"));
|
|
391
|
-
if (!input) {
|
|
392
|
-
throw new Error("agent-batch-executor 需要一个输入值,可以是任务描述、项目路径、网站网址或已导出的工件");
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
const format = getFlagValue(args, "--format") || (hasFlag(args, "--json") ? "json" : undefined);
|
|
396
|
-
const batch = await createAgentBatchExecutor(input, {
|
|
397
|
-
intent: getFlagValue(args, "--intent"),
|
|
398
|
-
format,
|
|
399
|
-
taskId: getFlagValue(args, "--task"),
|
|
400
|
-
count: getFlagValue(args, "--count")
|
|
401
|
-
});
|
|
402
|
-
const outputJson = batch.format === "json";
|
|
403
|
-
const renderedOutput = outputJson
|
|
404
|
-
? `${JSON.stringify(batch, null, 2)}\n`
|
|
405
|
-
: renderAgentBatchExecutorMarkdown(batch);
|
|
406
|
-
|
|
407
|
-
const outputPath = getFlagValue(args, "--out");
|
|
408
|
-
if (outputPath) {
|
|
409
|
-
const resolvedOutputPath = await writeAgentBatchExecutorOutput(outputPath, renderedOutput);
|
|
410
|
-
process.stdout.write(`已保存 agent batch executor:${resolvedOutputPath}\n`);
|
|
411
|
-
return;
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
process.stdout.write(renderedOutput);
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
async function handleAgentProgressTracker(args) {
|
|
418
|
-
const input = args.find((value) => !value.startsWith("-"));
|
|
419
|
-
if (!input) {
|
|
420
|
-
throw new Error("agent-progress-tracker 需要一个输入值,可以是项目路径、网站网址或已导出的工件");
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
const format = getFlagValue(args, "--format") || (hasFlag(args, "--json") ? "json" : undefined);
|
|
424
|
-
const tracker = await createAgentProgressTracker(input, {
|
|
425
|
-
format,
|
|
426
|
-
currentTaskId: getFlagValue(args, "--current"),
|
|
427
|
-
completedPacketIds: getFlagValue(args, "--completed"),
|
|
428
|
-
blockedReasons: getFlagValue(args, "--blocked")
|
|
429
|
-
});
|
|
430
|
-
const outputJson = tracker.format === "json";
|
|
431
|
-
const renderedOutput = outputJson
|
|
432
|
-
? `${JSON.stringify(tracker, null, 2)}\n`
|
|
433
|
-
: renderAgentProgressTrackerMarkdown(tracker);
|
|
434
|
-
|
|
435
|
-
const outputPath = getFlagValue(args, "--out");
|
|
436
|
-
if (outputPath) {
|
|
437
|
-
const resolvedOutputPath = await writeAgentProgressTrackerOutput(outputPath, renderedOutput);
|
|
438
|
-
process.stdout.write(`已保存 agent progress tracker:${resolvedOutputPath}\n`);
|
|
439
|
-
return;
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
process.stdout.write(renderedOutput);
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
async function handleAgentStatusBoard(args) {
|
|
446
|
-
const input = args.find((value) => !value.startsWith("-"));
|
|
447
|
-
if (!input) {
|
|
448
|
-
throw new Error("agent-status-board 需要一个输入值,可以是项目路径、网站网址或已导出的工件");
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
const format = getFlagValue(args, "--format") || (hasFlag(args, "--json") ? "json" : undefined);
|
|
452
|
-
const board = await createAgentStatusBoard(input, {
|
|
453
|
-
format,
|
|
454
|
-
currentTaskId: getFlagValue(args, "--current"),
|
|
455
|
-
completedPacketIds: getFlagValue(args, "--completed"),
|
|
456
|
-
blockedReasons: getFlagValue(args, "--blocked")
|
|
457
|
-
});
|
|
458
|
-
const outputJson = board.format === "json";
|
|
459
|
-
const renderedOutput = outputJson
|
|
460
|
-
? `${JSON.stringify(board, null, 2)}\n`
|
|
461
|
-
: renderAgentStatusBoardMarkdown(board);
|
|
462
|
-
|
|
463
|
-
const outputPath = getFlagValue(args, "--out");
|
|
464
|
-
if (outputPath) {
|
|
465
|
-
const resolvedOutputPath = await writeAgentStatusBoardOutput(outputPath, renderedOutput);
|
|
466
|
-
process.stdout.write(`已保存 agent status board:${resolvedOutputPath}\n`);
|
|
467
|
-
return;
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
process.stdout.write(renderedOutput);
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
async function handleAgentCheckpoint(args) {
|
|
474
|
-
const input = args.find((value) => !value.startsWith("-"));
|
|
475
|
-
if (!input) {
|
|
476
|
-
throw new Error("agent-checkpoint 需要一个输入值,可以是项目路径、网站网址或已导出的工件");
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
const format = getFlagValue(args, "--format") || (hasFlag(args, "--json") ? "json" : undefined);
|
|
480
|
-
const checkpoint = await createAgentCheckpoint(input, {
|
|
481
|
-
format,
|
|
482
|
-
currentTaskId: getFlagValue(args, "--current"),
|
|
483
|
-
completedPacketIds: getFlagValue(args, "--completed"),
|
|
484
|
-
blockedReasons: getFlagValue(args, "--blocked")
|
|
485
|
-
});
|
|
486
|
-
const outputJson = checkpoint.format === "json";
|
|
487
|
-
const renderedOutput = outputJson
|
|
488
|
-
? `${JSON.stringify(checkpoint, null, 2)}\n`
|
|
489
|
-
: renderAgentCheckpointMarkdown(checkpoint);
|
|
490
|
-
|
|
491
|
-
const outputPath = getFlagValue(args, "--out");
|
|
492
|
-
if (outputPath) {
|
|
493
|
-
const resolvedOutputPath = await writeAgentCheckpointOutput(outputPath, renderedOutput);
|
|
494
|
-
process.stdout.write(`已保存 agent checkpoint:${resolvedOutputPath}\n`);
|
|
495
|
-
return;
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
process.stdout.write(renderedOutput);
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
async function handleAgentDecisionLog(args) {
|
|
502
|
-
const input = args.find((value) => !value.startsWith("-"));
|
|
503
|
-
if (!input) {
|
|
504
|
-
throw new Error("agent-decision-log 需要一个输入值,可以是项目路径、网站网址或已导出的工件");
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
const format = getFlagValue(args, "--format") || (hasFlag(args, "--json") ? "json" : undefined);
|
|
508
|
-
const decisionLog = await createAgentDecisionLog(input, {
|
|
509
|
-
format,
|
|
510
|
-
appendFrom: getFlagValue(args, "--append-from"),
|
|
511
|
-
note: getFlagValue(args, "--note"),
|
|
512
|
-
currentTaskId: getFlagValue(args, "--current"),
|
|
513
|
-
completedPacketIds: getFlagValue(args, "--completed"),
|
|
514
|
-
blockedReasons: getFlagValue(args, "--blocked")
|
|
515
|
-
});
|
|
516
|
-
const outputJson = decisionLog.format === "json";
|
|
517
|
-
const renderedOutput = outputJson
|
|
518
|
-
? `${JSON.stringify(decisionLog, null, 2)}\n`
|
|
519
|
-
: renderAgentDecisionLogMarkdown(decisionLog);
|
|
520
|
-
|
|
521
|
-
const outputPath = getFlagValue(args, "--out");
|
|
522
|
-
if (outputPath) {
|
|
523
|
-
const resolvedOutputPath = await writeAgentDecisionLogOutput(outputPath, renderedOutput);
|
|
524
|
-
process.stdout.write(`已保存 agent decision log:${resolvedOutputPath}\n`);
|
|
525
|
-
return;
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
process.stdout.write(renderedOutput);
|
|
529
|
-
}
|
|
530
|
-
|
|
531
|
-
async function handleAgentRetrospective(args) {
|
|
532
|
-
const input = args.find((value) => !value.startsWith("-"));
|
|
533
|
-
if (!input) {
|
|
534
|
-
throw new Error("agent-retrospective 需要一个输入值,可以是项目路径、网站网址或已导出的工件");
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
const format = getFlagValue(args, "--format") || (hasFlag(args, "--json") ? "json" : undefined);
|
|
538
|
-
const retrospective = await createAgentRetrospective(input, {
|
|
539
|
-
format
|
|
540
|
-
});
|
|
541
|
-
const outputJson = retrospective.format === "json";
|
|
542
|
-
const renderedOutput = outputJson
|
|
543
|
-
? `${JSON.stringify(retrospective, null, 2)}\n`
|
|
544
|
-
: renderAgentRetrospectiveMarkdown(retrospective);
|
|
545
|
-
|
|
546
|
-
const outputPath = getFlagValue(args, "--out");
|
|
547
|
-
if (outputPath) {
|
|
548
|
-
const resolvedOutputPath = await writeAgentRetrospectiveOutput(outputPath, renderedOutput);
|
|
549
|
-
process.stdout.write(`已保存 agent retrospective:${resolvedOutputPath}\n`);
|
|
550
|
-
return;
|
|
551
|
-
}
|
|
552
|
-
|
|
553
|
-
process.stdout.write(renderedOutput);
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
async function handleAgentPlaybookPack(args) {
|
|
557
|
-
const input = args.find((value) => !value.startsWith("-"));
|
|
558
|
-
if (!input) {
|
|
559
|
-
throw new Error("agent-playbook-pack 需要一个输入值,可以是项目路径、网站网址或已导出的工件");
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
const format = getFlagValue(args, "--format") || (hasFlag(args, "--json") ? "json" : undefined);
|
|
563
|
-
const pack = await createAgentPlaybookPack(input, {
|
|
564
|
-
format,
|
|
565
|
-
taskId: getFlagValue(args, "--task")
|
|
566
|
-
});
|
|
567
|
-
const outputJson = pack.format === "json";
|
|
568
|
-
const renderedOutput = outputJson
|
|
569
|
-
? `${JSON.stringify(pack, null, 2)}\n`
|
|
570
|
-
: renderAgentPlaybookPackMarkdown(pack);
|
|
571
|
-
|
|
572
|
-
const outputPath = getFlagValue(args, "--out");
|
|
573
|
-
if (outputPath) {
|
|
574
|
-
const resolvedOutputPath = await writeAgentPlaybookPackOutput(outputPath, renderedOutput);
|
|
575
|
-
process.stdout.write(`已保存 agent playbook pack:${resolvedOutputPath}\n`);
|
|
576
|
-
return;
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
process.stdout.write(renderedOutput);
|
|
580
|
-
}
|
|
581
|
-
|
|
582
115
|
function handleWhere() {
|
|
583
116
|
process.stdout.write(
|
|
584
117
|
[
|
|
@@ -1103,6 +636,8 @@ async function handleRoadmap(args) {
|
|
|
1103
636
|
|
|
1104
637
|
export async function runCli(args = []) {
|
|
1105
638
|
const [command = "install", ...rest] = args;
|
|
639
|
+
const flowHandler = FLOW_COMMAND_HANDLERS[command];
|
|
640
|
+
const agentExecutionHandler = AGENT_EXECUTION_COMMAND_HANDLERS[command];
|
|
1106
641
|
|
|
1107
642
|
if (command === "help" || command === "--help" || command === "-h") {
|
|
1108
643
|
printHelp();
|
|
@@ -1119,33 +654,13 @@ export async function runCli(args = []) {
|
|
|
1119
654
|
return;
|
|
1120
655
|
}
|
|
1121
656
|
|
|
1122
|
-
if (
|
|
1123
|
-
await
|
|
1124
|
-
return;
|
|
1125
|
-
}
|
|
1126
|
-
|
|
1127
|
-
if (command === "agent-orchestrator") {
|
|
1128
|
-
await handleAgentOrchestrator(rest);
|
|
1129
|
-
return;
|
|
1130
|
-
}
|
|
1131
|
-
|
|
1132
|
-
if (command === "agent-resume") {
|
|
1133
|
-
await handleAgentResume(rest);
|
|
1134
|
-
return;
|
|
1135
|
-
}
|
|
1136
|
-
|
|
1137
|
-
if (command === "agent-continue") {
|
|
1138
|
-
await handleAgentContinue(rest);
|
|
1139
|
-
return;
|
|
1140
|
-
}
|
|
1141
|
-
|
|
1142
|
-
if (command === "agent-state-pack") {
|
|
1143
|
-
await handleAgentStatePack(rest);
|
|
657
|
+
if (flowHandler) {
|
|
658
|
+
await flowHandler(rest);
|
|
1144
659
|
return;
|
|
1145
660
|
}
|
|
1146
661
|
|
|
1147
|
-
if (
|
|
1148
|
-
await
|
|
662
|
+
if (agentExecutionHandler) {
|
|
663
|
+
await agentExecutionHandler(rest);
|
|
1149
664
|
return;
|
|
1150
665
|
}
|
|
1151
666
|
|