@peterxiaoyang/superspec 0.1.14 → 0.1.15-alpha
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/dist/cli.d.ts +2 -0
- package/dist/cli.js +302 -0
- package/dist/format.d.ts +29 -0
- package/dist/format.js +141 -0
- package/dist/next.d.ts +3 -0
- package/dist/next.js +161 -0
- package/dist/openspec.d.ts +9 -0
- package/dist/openspec.js +41 -0
- package/dist/record.d.ts +20 -0
- package/dist/record.js +211 -0
- package/dist/skill_loop.d.ts +23 -0
- package/dist/skill_loop.js +58 -0
- package/dist/store.d.ts +31 -0
- package/dist/store.js +213 -0
- package/dist/sync.d.ts +3 -0
- package/dist/sync.js +135 -0
- package/dist/task.d.ts +7 -0
- package/dist/task.js +44 -0
- package/dist/transition.d.ts +34 -0
- package/dist/transition.js +400 -0
- package/dist/types.d.ts +138 -0
- package/dist/types.js +3 -0
- package/package.json +8 -53
- package/templates/workflow/skills/superspec-apply/SKILL.md +46 -118
- package/templates/workflow/skills/superspec-archive/SKILL.md +22 -47
- package/templates/workflow/skills/superspec-explore/SKILL.md +38 -69
- package/templates/workflow/skills/superspec-propose/SKILL.md +58 -60
- package/templates/workflow/skills/superspec-review/SKILL.md +36 -81
- package/adapters/codex/agents/architect.toml +0 -13
- package/adapters/codex/agents/code-reviewer.toml +0 -13
- package/adapters/codex/agents/critic.toml +0 -13
- package/adapters/codex/agents/executor.toml +0 -13
- package/adapters/codex/agents/explore.toml +0 -13
- package/adapters/codex/agents/test-engineer.toml +0 -13
- package/adapters/codex/agents/test-runner.toml +0 -13
- package/adapters/codex/agents/verifier.toml +0 -13
- package/adapters/codex/install-map.json +0 -116
- package/bin/launch.js +0 -37
- package/bin/superspec-check.js +0 -4
- package/bin/superspec-hook.js +0 -4
- package/bin/superspec-init.js +0 -4
- package/bin/superspec.js +0 -4
- package/dist/src/apply_worker_chain.d.ts +0 -60
- package/dist/src/apply_worker_chain.js +0 -1283
- package/dist/src/apply_worker_chain_lifecycle.d.ts +0 -21
- package/dist/src/apply_worker_chain_lifecycle.js +0 -409
- package/dist/src/archive.d.ts +0 -23
- package/dist/src/archive.js +0 -430
- package/dist/src/cli.d.ts +0 -1
- package/dist/src/cli.js +0 -33
- package/dist/src/cli_args.d.ts +0 -32
- package/dist/src/cli_args.js +0 -454
- package/dist/src/core.d.ts +0 -20
- package/dist/src/core.js +0 -394
- package/dist/src/disclosure.d.ts +0 -35
- package/dist/src/disclosure.js +0 -671
- package/dist/src/doctor.d.ts +0 -44
- package/dist/src/doctor.js +0 -230
- package/dist/src/evidence.d.ts +0 -29
- package/dist/src/evidence.js +0 -1107
- package/dist/src/gates.d.ts +0 -19
- package/dist/src/gates.js +0 -1631
- package/dist/src/git.d.ts +0 -8
- package/dist/src/git.js +0 -112
- package/dist/src/hooks/adapter.d.ts +0 -5
- package/dist/src/hooks/adapter.js +0 -347
- package/dist/src/hooks/guard_api.d.ts +0 -12
- package/dist/src/hooks/guard_api.js +0 -797
- package/dist/src/hooks/health.d.ts +0 -4
- package/dist/src/hooks/health.js +0 -86
- package/dist/src/hooks/policy_event.d.ts +0 -41
- package/dist/src/hooks/policy_event.js +0 -2634
- package/dist/src/hooks/types.d.ts +0 -72
- package/dist/src/hooks/types.js +0 -1
- package/dist/src/hooks/validation.d.ts +0 -3
- package/dist/src/hooks/validation.js +0 -70
- package/dist/src/i18n.d.ts +0 -21
- package/dist/src/i18n.js +0 -720
- package/dist/src/init_cli.d.ts +0 -28
- package/dist/src/init_cli.js +0 -404
- package/dist/src/install_engine.d.ts +0 -71
- package/dist/src/install_engine.js +0 -538
- package/dist/src/invariants.d.ts +0 -16
- package/dist/src/invariants.js +0 -363
- package/dist/src/openspec.d.ts +0 -37
- package/dist/src/openspec.js +0 -274
- package/dist/src/packet_render.d.ts +0 -5
- package/dist/src/packet_render.js +0 -1767
- package/dist/src/packet_schema.d.ts +0 -59
- package/dist/src/packet_schema.js +0 -1
- package/dist/src/paths.d.ts +0 -22
- package/dist/src/paths.js +0 -203
- package/dist/src/project_init.d.ts +0 -33
- package/dist/src/project_init.js +0 -191
- package/dist/src/self_update.d.ts +0 -14
- package/dist/src/self_update.js +0 -56
- package/dist/src/state.d.ts +0 -37
- package/dist/src/state.js +0 -464
- package/dist/src/tasks.d.ts +0 -38
- package/dist/src/tasks.js +0 -373
- package/dist/src/util.d.ts +0 -163
- package/dist/src/util.js +0 -792
- package/dist/superspec.d.ts +0 -6
- package/dist/superspec.js +0 -97
- package/dist/superspec_guard.d.ts +0 -4
- package/dist/superspec_guard.js +0 -19
- package/dist/superspec_hook.d.ts +0 -4
- package/dist/superspec_hook.js +0 -35
- package/dist/superspec_init.d.ts +0 -2
- package/dist/superspec_init.js +0 -17
- package/schemas/hook-event.schema.json +0 -27
- package/schemas/install-manifest.schema.json +0 -97
- package/templates/hooks/codex-hooks.json +0 -35
- package/templates/sidecar/archive-preservation.json +0 -11
- package/templates/sidecar/business-invariants.md +0 -38
- package/templates/sidecar/config.yaml +0 -13
- package/templates/sidecar/discovery.md +0 -33
- package/templates/sidecar/test-contract.md +0 -27
- package/templates/workflow/prompts/architect.md +0 -27
- package/templates/workflow/prompts/code-reviewer.md +0 -34
- package/templates/workflow/prompts/critic.md +0 -30
- package/templates/workflow/prompts/executor.md +0 -32
- package/templates/workflow/prompts/explore.md +0 -27
- package/templates/workflow/prompts/test-engineer.md +0 -28
- package/templates/workflow/prompts/test-runner.md +0 -35
- package/templates/workflow/prompts/verifier.md +0 -35
package/dist/src/cli_args.js
DELETED
|
@@ -1,454 +0,0 @@
|
|
|
1
|
-
import { command_zh } from "./i18n.js";
|
|
2
|
-
import { GuardError, parseDecisionOutputFormat, parsePacketOutputFormat } from "./util.js";
|
|
3
|
-
import { normalize_gate } from "./openspec.js";
|
|
4
|
-
const SIMPLE_COMMANDS = [
|
|
5
|
-
"status",
|
|
6
|
-
"recompute",
|
|
7
|
-
"check-init",
|
|
8
|
-
"check-apply-ready",
|
|
9
|
-
"check-review-ready",
|
|
10
|
-
"check-review-complete",
|
|
11
|
-
"check-verify-ready",
|
|
12
|
-
"check-archive-ready",
|
|
13
|
-
"check-archived",
|
|
14
|
-
"hook-health",
|
|
15
|
-
"hook-session-status",
|
|
16
|
-
];
|
|
17
|
-
const COMMANDS = [
|
|
18
|
-
"init",
|
|
19
|
-
...SIMPLE_COMMANDS,
|
|
20
|
-
"check-artifact",
|
|
21
|
-
"check-enter",
|
|
22
|
-
"check-task-reopen",
|
|
23
|
-
"check-task-edit",
|
|
24
|
-
"check-task-complete",
|
|
25
|
-
"workflow-packet",
|
|
26
|
-
"review-packet",
|
|
27
|
-
"apply-test-packet",
|
|
28
|
-
"apply-executor-packet",
|
|
29
|
-
"apply-code-review-packet",
|
|
30
|
-
"apply-verify-packet",
|
|
31
|
-
"ledger-render",
|
|
32
|
-
"hook-check-write",
|
|
33
|
-
"hook-check-command",
|
|
34
|
-
"hook-record-test",
|
|
35
|
-
"hook-record-subagent-start",
|
|
36
|
-
"hook-record-subagent-stop",
|
|
37
|
-
"hook-session-begin",
|
|
38
|
-
"hook-session-end",
|
|
39
|
-
];
|
|
40
|
-
const COMMAND_LIST = COMMANDS.join(",");
|
|
41
|
-
const COMMAND_CHOICES = COMMANDS.map((item) => `'${item}'`).join(", ");
|
|
42
|
-
function isPacketCommand(command) {
|
|
43
|
-
return command === "workflow-packet"
|
|
44
|
-
|| command === "review-packet"
|
|
45
|
-
|| command === "apply-test-packet"
|
|
46
|
-
|| command === "apply-executor-packet"
|
|
47
|
-
|| command === "apply-code-review-packet"
|
|
48
|
-
|| command === "apply-verify-packet"
|
|
49
|
-
|| command === "ledger-render";
|
|
50
|
-
}
|
|
51
|
-
function isHookEventCommand(command) {
|
|
52
|
-
return command === "hook-check-write"
|
|
53
|
-
|| command === "hook-check-command"
|
|
54
|
-
|| command === "hook-record-test"
|
|
55
|
-
|| command === "hook-record-subagent-start"
|
|
56
|
-
|| command === "hook-record-subagent-stop";
|
|
57
|
-
}
|
|
58
|
-
function requiredValueFlags(command) {
|
|
59
|
-
const flags = ["--change"];
|
|
60
|
-
if (command === "check-artifact")
|
|
61
|
-
flags.push("--artifact");
|
|
62
|
-
if (command === "check-enter")
|
|
63
|
-
flags.push("--gate");
|
|
64
|
-
if (command === "check-task-reopen" || command === "check-task-edit" || command === "check-task-complete")
|
|
65
|
-
flags.push("--task-id");
|
|
66
|
-
if (command === "workflow-packet")
|
|
67
|
-
flags.push("--gate");
|
|
68
|
-
if (command === "review-packet")
|
|
69
|
-
flags.push("--gate", "--role", "--round");
|
|
70
|
-
if (command === "apply-test-packet")
|
|
71
|
-
flags.push("--task-id", "--test-id", "--phase");
|
|
72
|
-
if (command === "apply-executor-packet")
|
|
73
|
-
flags.push("--task-id");
|
|
74
|
-
if (command === "apply-code-review-packet")
|
|
75
|
-
flags.push("--task-id", "--executor-report-ref");
|
|
76
|
-
if (command === "apply-verify-packet")
|
|
77
|
-
flags.push("--task-id", "--executor-report-ref", "--task-code-review-report-ref");
|
|
78
|
-
if (command === "ledger-render")
|
|
79
|
-
flags.push("--gate");
|
|
80
|
-
if (isHookEventCommand(command))
|
|
81
|
-
flags.push("--event-ref");
|
|
82
|
-
if (command === "hook-session-begin")
|
|
83
|
-
flags.push("--workflow", "--entrypoint-token");
|
|
84
|
-
if (command === "hook-session-end")
|
|
85
|
-
flags.push("--reason");
|
|
86
|
-
return flags;
|
|
87
|
-
}
|
|
88
|
-
function requiredBooleanFlags(command) {
|
|
89
|
-
return command === "init" ? ["--create"] : [];
|
|
90
|
-
}
|
|
91
|
-
function optionalBooleanFlags(command) {
|
|
92
|
-
if (isPacketCommand(command))
|
|
93
|
-
return [];
|
|
94
|
-
return ["--user-facing", ...(command === "recompute" ? ["--force-unlock", "--rebuild-corrupt"] : [])];
|
|
95
|
-
}
|
|
96
|
-
function optionalValueFlags(command) {
|
|
97
|
-
if (command === "workflow-packet")
|
|
98
|
-
return ["--task-id"];
|
|
99
|
-
if (command === "review-packet")
|
|
100
|
-
return ["--kind"];
|
|
101
|
-
if (command === "apply-test-packet")
|
|
102
|
-
return ["--task-code-review-report-ref"];
|
|
103
|
-
if (command === "apply-executor-packet")
|
|
104
|
-
return ["--apply-worker-chain-ref"];
|
|
105
|
-
if (command === "apply-verify-packet")
|
|
106
|
-
return ["--green-test-run-evidence-ref", "--alternative-verification-evidence-ref", "--red-test-run-evidence-ref", "--characterization-test-run-evidence-ref"];
|
|
107
|
-
if (command === "ledger-render")
|
|
108
|
-
return ["--round"];
|
|
109
|
-
if (command === "hook-session-end")
|
|
110
|
-
return ["--lifecycle-token"];
|
|
111
|
-
return [];
|
|
112
|
-
}
|
|
113
|
-
function formatUsage(command) {
|
|
114
|
-
if (command === "workflow-packet")
|
|
115
|
-
return "--format {agent}";
|
|
116
|
-
if (command === "review-packet"
|
|
117
|
-
|| command === "apply-test-packet"
|
|
118
|
-
|| command === "apply-executor-packet"
|
|
119
|
-
|| command === "apply-code-review-packet"
|
|
120
|
-
|| command === "apply-verify-packet")
|
|
121
|
-
return "--format {agent,prompt}";
|
|
122
|
-
if (command === "ledger-render")
|
|
123
|
-
return null;
|
|
124
|
-
return "[--format {json,agent,user}]";
|
|
125
|
-
}
|
|
126
|
-
function requiresFormat(command) {
|
|
127
|
-
return command === "workflow-packet"
|
|
128
|
-
|| command === "review-packet"
|
|
129
|
-
|| command === "apply-test-packet"
|
|
130
|
-
|| command === "apply-executor-packet"
|
|
131
|
-
|| command === "apply-code-review-packet"
|
|
132
|
-
|| command === "apply-verify-packet";
|
|
133
|
-
}
|
|
134
|
-
function rootUsage() {
|
|
135
|
-
return `usage: superspec [-h]\n {${COMMAND_LIST}}\n ...\n`;
|
|
136
|
-
}
|
|
137
|
-
function rootHelp() {
|
|
138
|
-
const commandLines = COMMANDS.map((command) => {
|
|
139
|
-
const zh = command_zh(command);
|
|
140
|
-
return ` ${command.padEnd(22, " ")} ${zh.label_zh} / ${zh.hint_zh}\n`;
|
|
141
|
-
}).join("");
|
|
142
|
-
return `${rootUsage()}\nSuperSpec 守护检查(v1)\n\n位置参数:\n {${COMMAND_LIST}}\n\n命令:\n${commandLines}\n可选参数:\n -h, --help 显示帮助并退出\n`;
|
|
143
|
-
}
|
|
144
|
-
function commandUsage(command) {
|
|
145
|
-
const usageFlags = [
|
|
146
|
-
"[-h]",
|
|
147
|
-
...requiredValueFlags(command).map((flag) => `${flag} ${flag.slice(2).replace(/-/g, "_").toUpperCase()}`),
|
|
148
|
-
...(formatUsage(command) ? [formatUsage(command)] : []),
|
|
149
|
-
...optionalValueFlags(command).map((flag) => `[${flag} ${flag.slice(2).replace(/-/g, "_").toUpperCase()}]`),
|
|
150
|
-
...requiredBooleanFlags(command),
|
|
151
|
-
...optionalBooleanFlags(command),
|
|
152
|
-
];
|
|
153
|
-
return `usage: superspec ${command} ${usageFlags.join(" ")}\n`;
|
|
154
|
-
}
|
|
155
|
-
function commandHelp(command) {
|
|
156
|
-
const zh = command_zh(command);
|
|
157
|
-
const lines = [commandUsage(command), `\n${zh.label_zh}:${zh.hint_zh}\n`, "\n可选参数:\n", " -h, --help 显示帮助并退出\n"];
|
|
158
|
-
for (const flag of requiredValueFlags(command)) {
|
|
159
|
-
const metavariable = flag.slice(2).replace(/-/g, "_").toUpperCase();
|
|
160
|
-
lines.push(` ${flag} ${metavariable}\n`);
|
|
161
|
-
}
|
|
162
|
-
for (const flag of requiredBooleanFlags(command)) {
|
|
163
|
-
lines.push(` ${flag}\n`);
|
|
164
|
-
}
|
|
165
|
-
const formatToken = formatUsage(command);
|
|
166
|
-
if (formatToken)
|
|
167
|
-
lines.push(` ${formatToken}\n`);
|
|
168
|
-
for (const flag of optionalValueFlags(command)) {
|
|
169
|
-
const metavariable = flag.slice(2).replace(/-/g, "_").toUpperCase();
|
|
170
|
-
lines.push(` ${flag} ${metavariable}\n`);
|
|
171
|
-
}
|
|
172
|
-
for (const flag of optionalBooleanFlags(command)) {
|
|
173
|
-
lines.push(` ${flag}\n`);
|
|
174
|
-
}
|
|
175
|
-
return lines.join("");
|
|
176
|
-
}
|
|
177
|
-
function hasFlag(argv, flag) {
|
|
178
|
-
return argv.includes(flag);
|
|
179
|
-
}
|
|
180
|
-
function missingRequiredFlags(command, args) {
|
|
181
|
-
const missing = [...requiredValueFlags(command), ...requiredBooleanFlags(command)].filter((flag) => !hasFlag(args, flag));
|
|
182
|
-
if (requiresFormat(command) && !hasFlag(args, "--format"))
|
|
183
|
-
missing.push("--format");
|
|
184
|
-
return missing;
|
|
185
|
-
}
|
|
186
|
-
export function emitArgparsePreamble(argv) {
|
|
187
|
-
if (argv.length === 0) {
|
|
188
|
-
process.stderr.write(`${rootUsage()}superspec:错误:缺少必填参数:command\n`);
|
|
189
|
-
return 2;
|
|
190
|
-
}
|
|
191
|
-
const command = argv[0];
|
|
192
|
-
if (command === "-h" || command === "--help") {
|
|
193
|
-
process.stdout.write(rootHelp());
|
|
194
|
-
return 0;
|
|
195
|
-
}
|
|
196
|
-
if (!COMMANDS.includes(command)) {
|
|
197
|
-
process.stderr.write(`${rootUsage()}superspec:错误:命令无效:'${command}';可选值:${COMMAND_CHOICES}\n`);
|
|
198
|
-
return 2;
|
|
199
|
-
}
|
|
200
|
-
const args = argv.slice(1);
|
|
201
|
-
if (args.includes("-h") || args.includes("--help")) {
|
|
202
|
-
process.stdout.write(commandHelp(command));
|
|
203
|
-
return 0;
|
|
204
|
-
}
|
|
205
|
-
if (!isPacketCommand(command)) {
|
|
206
|
-
const missing = missingRequiredFlags(command, args);
|
|
207
|
-
if (missing.length > 0) {
|
|
208
|
-
if (isHookEventCommand(command) && missing.length === 1 && missing[0] === "--event-ref") {
|
|
209
|
-
process.stderr.write(`${commandUsage(command)}superspec ${command}:错误:--event-ref must point to a readable hook event JSON file\n`);
|
|
210
|
-
return 2;
|
|
211
|
-
}
|
|
212
|
-
process.stderr.write(`${commandUsage(command)}superspec ${command}:错误:缺少必填参数:${missing.join(", ")}\n`);
|
|
213
|
-
return 2;
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
return null;
|
|
217
|
-
}
|
|
218
|
-
export function parse_argv(argv) {
|
|
219
|
-
if (argv.length === 0)
|
|
220
|
-
throw new Error("缺少命令");
|
|
221
|
-
const command = argv[0];
|
|
222
|
-
const args = argv.slice(1);
|
|
223
|
-
const getValues = (flag) => {
|
|
224
|
-
const values = [];
|
|
225
|
-
for (let idx = 0; idx < args.length; idx += 1) {
|
|
226
|
-
if (args[idx] !== flag)
|
|
227
|
-
continue;
|
|
228
|
-
const value = args[idx + 1];
|
|
229
|
-
if (value === undefined || value.startsWith("--"))
|
|
230
|
-
throw new GuardError(`${flag} 缺少取值`);
|
|
231
|
-
values.push(value);
|
|
232
|
-
}
|
|
233
|
-
return values;
|
|
234
|
-
};
|
|
235
|
-
const getValue = (flag) => getValues(flag)[0];
|
|
236
|
-
const formatValues = getValues("--format");
|
|
237
|
-
const isPacketOutputCommand = command === "workflow-packet"
|
|
238
|
-
|| command === "review-packet"
|
|
239
|
-
|| command === "apply-test-packet"
|
|
240
|
-
|| command === "apply-executor-packet"
|
|
241
|
-
|| command === "apply-code-review-packet"
|
|
242
|
-
|| command === "apply-verify-packet";
|
|
243
|
-
const isPacketCommand = isPacketOutputCommand || command === "ledger-render";
|
|
244
|
-
const selectedPacketFormat = formatValues.length > 0 ? formatValues[formatValues.length - 1] : undefined;
|
|
245
|
-
if (isPacketOutputCommand) {
|
|
246
|
-
if (!selectedPacketFormat)
|
|
247
|
-
throw new GuardError("缺少必填参数 --format");
|
|
248
|
-
for (const value of formatValues)
|
|
249
|
-
parsePacketOutputFormat(value, { allowPrompt: command !== "workflow-packet" });
|
|
250
|
-
}
|
|
251
|
-
else {
|
|
252
|
-
for (const value of formatValues)
|
|
253
|
-
parseDecisionOutputFormat(value);
|
|
254
|
-
}
|
|
255
|
-
const selectedFormat = hasFlag(args, "--user-facing")
|
|
256
|
-
? "user"
|
|
257
|
-
: (formatValues.length > 0 ? formatValues[formatValues.length - 1] : "json");
|
|
258
|
-
const format = isPacketCommand ? undefined : parseDecisionOutputFormat(selectedFormat);
|
|
259
|
-
const change = getValue("--change");
|
|
260
|
-
if (!change)
|
|
261
|
-
throw new (isPacketCommand ? GuardError : Error)("缺少必填参数 --change");
|
|
262
|
-
if (command === "init") {
|
|
263
|
-
if (!hasFlag(args, "--create"))
|
|
264
|
-
throw new Error("缺少必填参数 --create");
|
|
265
|
-
return { command, change, format, create: true };
|
|
266
|
-
}
|
|
267
|
-
if (command === "check-artifact") {
|
|
268
|
-
const artifact = getValue("--artifact");
|
|
269
|
-
if (!artifact)
|
|
270
|
-
throw new Error("缺少必填参数 --artifact");
|
|
271
|
-
return { command, change, format, artifact };
|
|
272
|
-
}
|
|
273
|
-
if (command === "check-enter") {
|
|
274
|
-
const gate = getValue("--gate");
|
|
275
|
-
if (!gate)
|
|
276
|
-
throw new Error("缺少必填参数 --gate");
|
|
277
|
-
return { command, change, format, gate };
|
|
278
|
-
}
|
|
279
|
-
if (command === "workflow-packet") {
|
|
280
|
-
const gate = getValue("--gate");
|
|
281
|
-
if (!gate)
|
|
282
|
-
throw new GuardError("缺少必填参数 --gate");
|
|
283
|
-
const normalizedGate = normalize_gate(gate);
|
|
284
|
-
const taskId = getValue("--task-id");
|
|
285
|
-
if ((normalizedGate === "task_edit" || normalizedGate === "task_complete" || normalizedGate === "task_reopen") && !taskId) {
|
|
286
|
-
throw new GuardError("workflow-packet 缺少必填参数 --task-id");
|
|
287
|
-
}
|
|
288
|
-
return { command, change, gate, task_id: taskId, packet_format: parsePacketOutputFormat(selectedPacketFormat, { allowPrompt: false }) };
|
|
289
|
-
}
|
|
290
|
-
if (command === "review-packet") {
|
|
291
|
-
const gate = getValue("--gate");
|
|
292
|
-
const role = getValue("--role");
|
|
293
|
-
const roundValue = getValue("--round");
|
|
294
|
-
const evidenceKind = getValue("--kind");
|
|
295
|
-
if (!gate)
|
|
296
|
-
throw new GuardError("缺少必填参数 --gate");
|
|
297
|
-
if (!role)
|
|
298
|
-
throw new GuardError("缺少必填参数 --role");
|
|
299
|
-
if (!roundValue)
|
|
300
|
-
throw new GuardError("缺少必填参数 --round");
|
|
301
|
-
if (evidenceKind !== undefined && evidenceKind !== "source_guidance" && evidenceKind !== "verification_review") {
|
|
302
|
-
throw new GuardError("--kind 只允许 source_guidance 或 verification_review");
|
|
303
|
-
}
|
|
304
|
-
const round = Number.parseInt(roundValue, 10);
|
|
305
|
-
if (!Number.isInteger(round) || round < 1)
|
|
306
|
-
throw new GuardError("--round 必须是大于等于 1 的整数");
|
|
307
|
-
return {
|
|
308
|
-
command,
|
|
309
|
-
change,
|
|
310
|
-
gate,
|
|
311
|
-
role,
|
|
312
|
-
evidence_kind: evidenceKind,
|
|
313
|
-
round,
|
|
314
|
-
packet_format: parsePacketOutputFormat(selectedPacketFormat, { allowPrompt: true }),
|
|
315
|
-
};
|
|
316
|
-
}
|
|
317
|
-
if (command === "apply-test-packet") {
|
|
318
|
-
const taskId = getValue("--task-id");
|
|
319
|
-
const testId = getValue("--test-id");
|
|
320
|
-
const phase = getValue("--phase");
|
|
321
|
-
if (!taskId)
|
|
322
|
-
throw new GuardError("apply-test-packet 缺少必填参数 --task-id");
|
|
323
|
-
if (!testId)
|
|
324
|
-
throw new GuardError("apply-test-packet 缺少必填参数 --test-id");
|
|
325
|
-
if (phase !== "red" && phase !== "characterization" && phase !== "green") {
|
|
326
|
-
throw new GuardError("--phase 只允许 red、characterization 或 green");
|
|
327
|
-
}
|
|
328
|
-
return {
|
|
329
|
-
command,
|
|
330
|
-
change,
|
|
331
|
-
task_id: taskId,
|
|
332
|
-
test_id: testId,
|
|
333
|
-
phase,
|
|
334
|
-
task_code_review_report_refs: getValues("--task-code-review-report-ref"),
|
|
335
|
-
packet_format: parsePacketOutputFormat(selectedPacketFormat, { allowPrompt: true }),
|
|
336
|
-
};
|
|
337
|
-
}
|
|
338
|
-
if (command === "apply-executor-packet") {
|
|
339
|
-
const taskId = getValue("--task-id");
|
|
340
|
-
if (!taskId)
|
|
341
|
-
throw new GuardError("apply-executor-packet 缺少必填参数 --task-id");
|
|
342
|
-
return {
|
|
343
|
-
command,
|
|
344
|
-
change,
|
|
345
|
-
task_id: taskId,
|
|
346
|
-
apply_worker_chain_refs: getValues("--apply-worker-chain-ref"),
|
|
347
|
-
packet_format: parsePacketOutputFormat(selectedPacketFormat, { allowPrompt: true }),
|
|
348
|
-
};
|
|
349
|
-
}
|
|
350
|
-
if (command === "apply-code-review-packet") {
|
|
351
|
-
const taskId = getValue("--task-id");
|
|
352
|
-
const executorRefs = getValues("--executor-report-ref");
|
|
353
|
-
if (!taskId)
|
|
354
|
-
throw new GuardError("apply-code-review-packet 缺少必填参数 --task-id");
|
|
355
|
-
if (executorRefs.length === 0)
|
|
356
|
-
throw new GuardError("apply-code-review-packet 缺少必填参数 --executor-report-ref");
|
|
357
|
-
return {
|
|
358
|
-
command,
|
|
359
|
-
change,
|
|
360
|
-
task_id: taskId,
|
|
361
|
-
executor_report_refs: executorRefs,
|
|
362
|
-
packet_format: parsePacketOutputFormat(selectedPacketFormat, { allowPrompt: true }),
|
|
363
|
-
};
|
|
364
|
-
}
|
|
365
|
-
if (command === "apply-verify-packet") {
|
|
366
|
-
const taskId = getValue("--task-id");
|
|
367
|
-
const executorRefs = getValues("--executor-report-ref");
|
|
368
|
-
const codeReviewRefs = getValues("--task-code-review-report-ref");
|
|
369
|
-
const greenRefs = getValues("--green-test-run-evidence-ref");
|
|
370
|
-
const alternativeRefs = getValues("--alternative-verification-evidence-ref");
|
|
371
|
-
const redRefs = getValues("--red-test-run-evidence-ref");
|
|
372
|
-
const characterizationRefs = getValues("--characterization-test-run-evidence-ref");
|
|
373
|
-
if (!taskId)
|
|
374
|
-
throw new GuardError("apply-verify-packet 缺少必填参数 --task-id");
|
|
375
|
-
if (executorRefs.length === 0)
|
|
376
|
-
throw new GuardError("apply-verify-packet 缺少必填参数 --executor-report-ref");
|
|
377
|
-
if (codeReviewRefs.length === 0)
|
|
378
|
-
throw new GuardError("apply-verify-packet 缺少必填参数 --task-code-review-report-ref");
|
|
379
|
-
if (greenRefs.length === 0 && alternativeRefs.length === 0) {
|
|
380
|
-
throw new GuardError("apply-verify-packet requires --green-test-run-evidence-ref or --alternative-verification-evidence-ref");
|
|
381
|
-
}
|
|
382
|
-
if (greenRefs.length > 0 && alternativeRefs.length > 0) {
|
|
383
|
-
throw new GuardError("apply-verify-packet requires either GREEN refs or alternative verification refs, not both");
|
|
384
|
-
}
|
|
385
|
-
if (greenRefs.length > 0 && redRefs.length === 0 && characterizationRefs.length === 0) {
|
|
386
|
-
throw new GuardError("apply-verify-packet requires --red-test-run-evidence-ref or --characterization-test-run-evidence-ref");
|
|
387
|
-
}
|
|
388
|
-
if (alternativeRefs.length > 0 && (redRefs.length > 0 || characterizationRefs.length > 0)) {
|
|
389
|
-
throw new GuardError("apply-verify-packet alternative verification branch must not include RED or characterization refs");
|
|
390
|
-
}
|
|
391
|
-
return {
|
|
392
|
-
command,
|
|
393
|
-
change,
|
|
394
|
-
task_id: taskId,
|
|
395
|
-
executor_report_refs: executorRefs,
|
|
396
|
-
task_code_review_report_refs: codeReviewRefs,
|
|
397
|
-
green_test_run_evidence_refs: greenRefs,
|
|
398
|
-
alternative_verification_evidence_refs: alternativeRefs,
|
|
399
|
-
red_test_run_evidence_refs: redRefs,
|
|
400
|
-
characterization_test_run_evidence_refs: characterizationRefs,
|
|
401
|
-
packet_format: parsePacketOutputFormat(selectedPacketFormat, { allowPrompt: true }),
|
|
402
|
-
};
|
|
403
|
-
}
|
|
404
|
-
if (command === "ledger-render") {
|
|
405
|
-
const gate = getValue("--gate");
|
|
406
|
-
const roundValue = getValue("--round");
|
|
407
|
-
if (!gate)
|
|
408
|
-
throw new GuardError("缺少必填参数 --gate");
|
|
409
|
-
if (roundValue === undefined)
|
|
410
|
-
return { command, change, gate };
|
|
411
|
-
const round = Number.parseInt(roundValue, 10);
|
|
412
|
-
if (!Number.isInteger(round) || round < 1)
|
|
413
|
-
throw new GuardError("--round 必须是大于等于 1 的整数");
|
|
414
|
-
return { command, change, gate, round };
|
|
415
|
-
}
|
|
416
|
-
if (isHookEventCommand(command)) {
|
|
417
|
-
const eventRef = getValue("--event-ref");
|
|
418
|
-
if (!eventRef)
|
|
419
|
-
throw new GuardError("--event-ref must point to a readable hook event JSON file");
|
|
420
|
-
return { command, change, format, event_ref: eventRef };
|
|
421
|
-
}
|
|
422
|
-
if (command === "hook-session-begin") {
|
|
423
|
-
const workflow = getValue("--workflow");
|
|
424
|
-
const entrypointToken = getValue("--entrypoint-token");
|
|
425
|
-
if (!workflow)
|
|
426
|
-
throw new Error("缺少必填参数 --workflow");
|
|
427
|
-
if (!entrypointToken)
|
|
428
|
-
throw new Error("缺少必填参数 --entrypoint-token");
|
|
429
|
-
return { command, change, format, workflow, entrypoint_token: entrypointToken };
|
|
430
|
-
}
|
|
431
|
-
if (command === "hook-session-end") {
|
|
432
|
-
const endReason = getValue("--reason");
|
|
433
|
-
const lifecycleToken = getValue("--lifecycle-token");
|
|
434
|
-
if (!endReason)
|
|
435
|
-
throw new Error("缺少必填参数 --reason");
|
|
436
|
-
return { command, change, format, end_reason: endReason, lifecycle_token: lifecycleToken ?? "" };
|
|
437
|
-
}
|
|
438
|
-
if (command === "check-task-reopen" || command === "check-task-edit" || command === "check-task-complete") {
|
|
439
|
-
const taskId = getValue("--task-id");
|
|
440
|
-
if (!taskId)
|
|
441
|
-
throw new Error("缺少必填参数 --task-id");
|
|
442
|
-
return { command, change, format, task_id: taskId };
|
|
443
|
-
}
|
|
444
|
-
const simple = new Set(SIMPLE_COMMANDS);
|
|
445
|
-
if (!simple.has(command))
|
|
446
|
-
throw new Error(`未知命令:${command}`);
|
|
447
|
-
return {
|
|
448
|
-
command,
|
|
449
|
-
change,
|
|
450
|
-
format,
|
|
451
|
-
force_unlock: command === "recompute" && hasFlag(args, "--force-unlock"),
|
|
452
|
-
rebuild_corrupt: command === "recompute" && hasFlag(args, "--rebuild-corrupt"),
|
|
453
|
-
};
|
|
454
|
-
}
|
package/dist/src/core.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
export * from "./util.ts";
|
|
3
|
-
export * from "./openspec.ts";
|
|
4
|
-
export * from "./paths.ts";
|
|
5
|
-
export * from "./disclosure.ts";
|
|
6
|
-
export * from "./evidence.ts";
|
|
7
|
-
export * from "./tasks.ts";
|
|
8
|
-
export * from "./invariants.ts";
|
|
9
|
-
export * from "./git.ts";
|
|
10
|
-
export * from "./state.ts";
|
|
11
|
-
export * from "./archive.ts";
|
|
12
|
-
export * from "./apply_worker_chain.ts";
|
|
13
|
-
export * from "./gates.ts";
|
|
14
|
-
export * from "./install_engine.ts";
|
|
15
|
-
import type { ParsedArgs } from "./cli_args.ts";
|
|
16
|
-
import type { JsonMap } from "./util.ts";
|
|
17
|
-
export declare function load_context(change: string): [JsonMap, string, string, JsonMap[]];
|
|
18
|
-
export declare function cmd_status(change: string): JsonMap;
|
|
19
|
-
export declare function cmd_init_summary(change: string, changeRoot: string, decision: JsonMap): JsonMap;
|
|
20
|
-
export declare function dispatch(args: ParsedArgs): [JsonMap, string];
|