kimi-plugin-cc 2.7.3 → 3.1.0
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/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +3 -16
- package/README.md +428 -515
- package/assets/logo.svg +6 -0
- package/cordis.patch.yml +18 -0
- package/dist/background-spawn.js +14 -19
- package/dist/cli-client.js +163 -105
- package/dist/commands/ask.js +44 -96
- package/dist/commands/cancel.js +11 -59
- package/dist/commands/cli-helpers.js +102 -1
- package/dist/commands/models.js +2 -3
- package/dist/commands/pursue.js +8 -21
- package/dist/commands/registry.js +7 -26
- package/dist/commands/repair-sessions.js +121 -12
- package/dist/commands/replay.js +4 -3
- package/dist/commands/rescue.js +29 -87
- package/dist/commands/result.js +7 -1
- package/dist/commands/review.js +28 -18
- package/dist/commands/setup.js +813 -462
- package/dist/commands/status.js +2 -2
- package/dist/commands/swarm.js +112 -125
- package/dist/commands/worker.js +1 -2
- package/dist/companion.js +145 -19
- package/dist/git.js +1 -9
- package/dist/help.js +13 -9
- package/dist/hook-escape.js +7 -16
- package/dist/hooks/approval-hook.js +1766 -87
- package/dist/hooks/approval-policy.js +86 -19
- package/dist/hooks/config-safety.js +31 -64
- package/dist/hooks/hook-timing.js +48 -0
- package/dist/hooks/install-paths.js +179 -107
- package/dist/hooks/install.js +126 -53
- package/dist/hooks/managed-block.js +121 -127
- package/dist/job-store.js +206 -166
- package/dist/jobs.js +66 -19
- package/dist/kimi-command.js +74 -1
- package/dist/kimi-engine.js +198 -127
- package/dist/kimi-errors.js +15 -70
- package/dist/kimi-home.js +6 -0
- package/dist/kimi-journal.js +42 -0
- package/dist/kimi-releases.js +123 -0
- package/dist/kimi-timeouts.js +2 -16
- package/dist/kimi-version-probe.js +24 -108
- package/dist/logging.js +12 -7
- package/dist/mcp/binding.js +13 -4
- package/dist/mcp/job-control.js +390 -95
- package/dist/mcp/launcher.js +13 -7
- package/dist/mcp/operations.js +405 -179
- package/dist/mcp/protocol.js +124 -33
- package/dist/mcp/skills.js +130 -0
- package/dist/mcp/stdio.js +18 -4
- package/dist/model-command.js +5 -3
- package/dist/native-v2-preflight.js +243 -80
- package/dist/parsing.js +211 -243
- package/dist/paths.js +28 -10
- package/dist/plugin-data.js +28 -83
- package/dist/process-tree.js +35 -24
- package/dist/read-scope.js +435 -0
- package/dist/render.js +58 -46
- package/dist/rescue-approval.js +461 -84
- package/dist/session-references.js +216 -0
- package/dist/session-title.js +26 -6
- package/dist/stream-json.js +1 -3
- package/dist/surface-routing.js +108 -0
- package/dist/swarm-activation.js +74 -188
- package/dist/swarm-policy.js +2 -1
- package/dist/swarm-recovery.js +2 -1
- package/dist/util.js +28 -0
- package/dist/version.js +1 -1
- package/docs/migration.md +45 -206
- package/docs/models.md +24 -66
- package/docs/safety.md +198 -353
- package/docs/session-visibility.md +25 -13
- package/docs/swarm-recovery.md +26 -20
- package/dsh/index.json +54 -0
- package/mcp_config.json +10 -0
- package/package.json +23 -82
- package/plugin.json +19 -0
- package/plugins/kimi-codex/.codex-plugin/plugin.json +7 -7
- package/plugins/kimi-codex/.mcp.json +3 -3
- package/plugins/kimi-codex/dist/background-spawn.js +14 -19
- package/plugins/kimi-codex/dist/cli-client.js +163 -105
- package/plugins/kimi-codex/dist/commands/ask.js +44 -96
- package/plugins/kimi-codex/dist/commands/cancel.js +11 -59
- package/plugins/kimi-codex/dist/commands/cli-helpers.js +102 -1
- package/plugins/kimi-codex/dist/commands/models.js +2 -3
- package/plugins/kimi-codex/dist/commands/pursue.js +8 -21
- package/plugins/kimi-codex/dist/commands/registry.js +7 -26
- package/plugins/kimi-codex/dist/commands/repair-sessions.js +121 -12
- package/plugins/kimi-codex/dist/commands/replay.js +4 -3
- package/plugins/kimi-codex/dist/commands/rescue.js +29 -87
- package/plugins/kimi-codex/dist/commands/result.js +7 -1
- package/plugins/kimi-codex/dist/commands/review.js +28 -18
- package/plugins/kimi-codex/dist/commands/setup.js +813 -462
- package/plugins/kimi-codex/dist/commands/status.js +2 -2
- package/plugins/kimi-codex/dist/commands/swarm.js +112 -125
- package/plugins/kimi-codex/dist/commands/worker.js +1 -2
- package/plugins/kimi-codex/dist/companion.js +145 -19
- package/plugins/kimi-codex/dist/git.js +1 -9
- package/plugins/kimi-codex/dist/help.js +13 -9
- package/plugins/kimi-codex/dist/hook-escape.js +7 -16
- package/plugins/kimi-codex/dist/hooks/approval-hook.js +1766 -87
- package/plugins/kimi-codex/dist/hooks/approval-policy.js +86 -19
- package/plugins/kimi-codex/dist/hooks/config-safety.js +31 -64
- package/plugins/kimi-codex/dist/hooks/hook-timing.js +48 -0
- package/plugins/kimi-codex/dist/hooks/install-paths.js +179 -107
- package/plugins/kimi-codex/dist/hooks/install.js +126 -53
- package/plugins/kimi-codex/dist/hooks/managed-block.js +121 -127
- package/plugins/kimi-codex/dist/job-store.js +206 -166
- package/plugins/kimi-codex/dist/jobs.js +66 -19
- package/plugins/kimi-codex/dist/kimi-command.js +74 -1
- package/plugins/kimi-codex/dist/kimi-engine.js +198 -127
- package/plugins/kimi-codex/dist/kimi-errors.js +15 -70
- package/plugins/kimi-codex/dist/kimi-home.js +6 -0
- package/plugins/kimi-codex/dist/kimi-journal.js +42 -0
- package/plugins/kimi-codex/dist/kimi-releases.js +123 -0
- package/plugins/kimi-codex/dist/kimi-timeouts.js +2 -16
- package/plugins/kimi-codex/dist/kimi-version-probe.js +24 -108
- package/plugins/kimi-codex/dist/logging.js +12 -7
- package/plugins/kimi-codex/dist/mcp/binding.js +13 -4
- package/plugins/kimi-codex/dist/mcp/job-control.js +390 -95
- package/plugins/kimi-codex/dist/mcp/launcher.js +13 -7
- package/plugins/kimi-codex/dist/mcp/operations.js +405 -179
- package/plugins/kimi-codex/dist/mcp/protocol.js +124 -33
- package/plugins/kimi-codex/dist/mcp/skills.js +130 -0
- package/plugins/kimi-codex/dist/mcp/stdio.js +18 -4
- package/plugins/kimi-codex/dist/model-command.js +5 -3
- package/plugins/kimi-codex/dist/native-v2-preflight.js +243 -80
- package/plugins/kimi-codex/dist/parsing.js +211 -243
- package/plugins/kimi-codex/dist/paths.js +28 -10
- package/plugins/kimi-codex/dist/plugin-data.js +28 -83
- package/plugins/kimi-codex/dist/process-tree.js +35 -24
- package/plugins/kimi-codex/dist/read-scope.js +435 -0
- package/plugins/kimi-codex/dist/render.js +58 -46
- package/plugins/kimi-codex/dist/rescue-approval.js +461 -84
- package/plugins/kimi-codex/dist/session-references.js +216 -0
- package/plugins/kimi-codex/dist/session-title.js +26 -6
- package/plugins/kimi-codex/dist/stream-json.js +1 -3
- package/plugins/kimi-codex/dist/surface-routing.js +108 -0
- package/plugins/kimi-codex/dist/swarm-activation.js +74 -188
- package/plugins/kimi-codex/dist/swarm-policy.js +2 -1
- package/plugins/kimi-codex/dist/swarm-recovery.js +2 -1
- package/plugins/kimi-codex/dist/util.js +28 -0
- package/plugins/kimi-codex/dist/version.js +1 -1
- package/plugins/kimi-codex/scripts/companion.sh +4 -15
- package/plugins/kimi-codex/skills/kimi/SKILL.md +77 -0
- package/plugins/kimi-codex/skills/kimi/agents/openai.yaml +6 -0
- package/scripts/companion.sh +4 -15
- package/skills/kimi/SKILL.md +77 -0
- package/skills/kimi/agents/openai.yaml +6 -0
- package/CHANGELOG.md +0 -1333
- package/agents/kimi-ask.md +0 -89
- package/agents/kimi-challenge.md +0 -86
- package/agents/kimi-pursue.md +0 -93
- package/agents/kimi-rescue.md +0 -92
- package/agents/kimi-review.md +0 -86
- package/agents/kimi-swarm-write.md +0 -96
- package/agents/kimi-swarm.md +0 -86
- package/commands/README.md +0 -16
- package/commands/ask.md +0 -38
- package/commands/cancel.md +0 -17
- package/commands/challenge.md +0 -35
- package/commands/pursue.md +0 -41
- package/commands/replay.md +0 -13
- package/commands/rescue.md +0 -38
- package/commands/result.md +0 -13
- package/commands/review.md +0 -35
- package/commands/setup.md +0 -23
- package/commands/status.md +0 -13
- package/commands/swarm.md +0 -44
- package/dist/commands/not-implemented.js +0 -4
- package/dist/commands/review-gate.js +0 -390
- package/dist/config.js +0 -22
- package/dist/dsh/companion.js +0 -177
- package/dist/dsh/index.js +0 -169
- package/dist/hooks/review-gate-stop.js +0 -19
- package/dist/schemas/review-gate-output.js +0 -43
- package/docs/registry-releases.md +0 -228
- package/docs/upstream-2.4.1-certification.md +0 -54
- package/docs/upstream-2.5.0-certification.md +0 -52
- package/docs/upstream-2.5.1-certification.md +0 -47
- package/docs/upstream-2.5.2-certification.md +0 -40
- package/docs/upstream-2.5.3-certification.md +0 -73
- package/docs/upstream-2.6.0-certification.md +0 -65
- package/docs/upstream-2.6.2-certification.md +0 -144
- package/docs/upstream-2.6.3-certification.md +0 -100
- package/docs/upstream-2.7.2-certification.md +0 -113
- package/docs/upstream-2.7.3-certification.md +0 -83
- package/docs/windows-validation.md +0 -39
- package/hooks/README.md +0 -9
- package/hooks/hooks.json +0 -16
- package/plugins/kimi-codex/dist/commands/not-implemented.js +0 -4
- package/plugins/kimi-codex/dist/commands/review-gate.js +0 -390
- package/plugins/kimi-codex/dist/config.js +0 -22
- package/plugins/kimi-codex/dist/dsh/companion.js +0 -177
- package/plugins/kimi-codex/dist/dsh/index.js +0 -169
- package/plugins/kimi-codex/dist/hooks/review-gate-stop.js +0 -19
- package/plugins/kimi-codex/dist/schemas/review-gate-output.js +0 -43
- package/plugins/kimi-codex/scripts/review-gate-hook.sh +0 -32
- package/plugins/kimi-codex/skills/kimi-ask/SKILL.md +0 -35
- package/plugins/kimi-codex/skills/kimi-ask/agents/openai.yaml +0 -6
- package/plugins/kimi-codex/skills/kimi-cancel/SKILL.md +0 -25
- package/plugins/kimi-codex/skills/kimi-cancel/agents/openai.yaml +0 -6
- package/plugins/kimi-codex/skills/kimi-challenge/SKILL.md +0 -34
- package/plugins/kimi-codex/skills/kimi-challenge/agents/openai.yaml +0 -6
- package/plugins/kimi-codex/skills/kimi-pursue/SKILL.md +0 -32
- package/plugins/kimi-codex/skills/kimi-pursue/agents/openai.yaml +0 -6
- package/plugins/kimi-codex/skills/kimi-replay/SKILL.md +0 -25
- package/plugins/kimi-codex/skills/kimi-replay/agents/openai.yaml +0 -6
- package/plugins/kimi-codex/skills/kimi-rescue/SKILL.md +0 -34
- package/plugins/kimi-codex/skills/kimi-rescue/agents/openai.yaml +0 -6
- package/plugins/kimi-codex/skills/kimi-result/SKILL.md +0 -25
- package/plugins/kimi-codex/skills/kimi-result/agents/openai.yaml +0 -6
- package/plugins/kimi-codex/skills/kimi-review/SKILL.md +0 -34
- package/plugins/kimi-codex/skills/kimi-review/agents/openai.yaml +0 -6
- package/plugins/kimi-codex/skills/kimi-setup/SKILL.md +0 -34
- package/plugins/kimi-codex/skills/kimi-setup/agents/openai.yaml +0 -6
- package/plugins/kimi-codex/skills/kimi-status/SKILL.md +0 -25
- package/plugins/kimi-codex/skills/kimi-status/agents/openai.yaml +0 -6
- package/plugins/kimi-codex/skills/kimi-swarm/SKILL.md +0 -35
- package/plugins/kimi-codex/skills/kimi-swarm/agents/openai.yaml +0 -6
- package/plugins/kimi-codex/skills/kimi-swarm-write/SKILL.md +0 -36
- package/plugins/kimi-codex/skills/kimi-swarm-write/agents/openai.yaml +0 -6
- package/plugins/kimi-dsh/LICENSE +0 -201
- package/plugins/kimi-dsh/README.md +0 -83
- package/plugins/kimi-dsh/cordis.patch.yml +0 -45
- package/plugins/kimi-dsh/dist/background-spawn.js +0 -216
- package/plugins/kimi-dsh/dist/cli-cancellation.js +0 -43
- package/plugins/kimi-dsh/dist/cli-client.js +0 -1078
- package/plugins/kimi-dsh/dist/commands/ask.js +0 -336
- package/plugins/kimi-dsh/dist/commands/cancel.js +0 -216
- package/plugins/kimi-dsh/dist/commands/cli-helpers.js +0 -201
- package/plugins/kimi-dsh/dist/commands/models.js +0 -140
- package/plugins/kimi-dsh/dist/commands/not-implemented.js +0 -4
- package/plugins/kimi-dsh/dist/commands/pursue.js +0 -307
- package/plugins/kimi-dsh/dist/commands/recover-swarm.js +0 -140
- package/plugins/kimi-dsh/dist/commands/registry.js +0 -74
- package/plugins/kimi-dsh/dist/commands/repair-sessions.js +0 -160
- package/plugins/kimi-dsh/dist/commands/replay.js +0 -124
- package/plugins/kimi-dsh/dist/commands/rescue.js +0 -347
- package/plugins/kimi-dsh/dist/commands/result.js +0 -66
- package/plugins/kimi-dsh/dist/commands/review-gate.js +0 -390
- package/plugins/kimi-dsh/dist/commands/review.js +0 -220
- package/plugins/kimi-dsh/dist/commands/setup.js +0 -1129
- package/plugins/kimi-dsh/dist/commands/status.js +0 -27
- package/plugins/kimi-dsh/dist/commands/swarm.js +0 -849
- package/plugins/kimi-dsh/dist/commands/worker.js +0 -25
- package/plugins/kimi-dsh/dist/companion.js +0 -97
- package/plugins/kimi-dsh/dist/config.js +0 -22
- package/plugins/kimi-dsh/dist/dsh/companion.js +0 -177
- package/plugins/kimi-dsh/dist/dsh/index.js +0 -169
- package/plugins/kimi-dsh/dist/errors.js +0 -40
- package/plugins/kimi-dsh/dist/git.js +0 -224
- package/plugins/kimi-dsh/dist/help.js +0 -43
- package/plugins/kimi-dsh/dist/hook-escape.js +0 -71
- package/plugins/kimi-dsh/dist/hooks/approval-hook.js +0 -104
- package/plugins/kimi-dsh/dist/hooks/approval-policy.js +0 -233
- package/plugins/kimi-dsh/dist/hooks/config-safety.js +0 -665
- package/plugins/kimi-dsh/dist/hooks/install-paths.js +0 -428
- package/plugins/kimi-dsh/dist/hooks/install.js +0 -210
- package/plugins/kimi-dsh/dist/hooks/managed-block.js +0 -684
- package/plugins/kimi-dsh/dist/hooks/review-gate-stop.js +0 -19
- package/plugins/kimi-dsh/dist/job-id.js +0 -12
- package/plugins/kimi-dsh/dist/job-store.js +0 -659
- package/plugins/kimi-dsh/dist/jobs.js +0 -217
- package/plugins/kimi-dsh/dist/kimi-command.js +0 -71
- package/plugins/kimi-dsh/dist/kimi-engine.js +0 -675
- package/plugins/kimi-dsh/dist/kimi-errors.js +0 -260
- package/plugins/kimi-dsh/dist/kimi-home.js +0 -9
- package/plugins/kimi-dsh/dist/kimi-timeouts.js +0 -52
- package/plugins/kimi-dsh/dist/kimi-version-probe.js +0 -234
- package/plugins/kimi-dsh/dist/logging.js +0 -22
- package/plugins/kimi-dsh/dist/mcp/binding.js +0 -58
- package/plugins/kimi-dsh/dist/mcp/job-control.js +0 -345
- package/plugins/kimi-dsh/dist/mcp/launcher.js +0 -257
- package/plugins/kimi-dsh/dist/mcp/operations.js +0 -301
- package/plugins/kimi-dsh/dist/mcp/protocol.js +0 -275
- package/plugins/kimi-dsh/dist/mcp/server.js +0 -8
- package/plugins/kimi-dsh/dist/mcp/stdio.js +0 -78
- package/plugins/kimi-dsh/dist/mcp/supervised-child.js +0 -15
- package/plugins/kimi-dsh/dist/mcp/tool-result.js +0 -7
- package/plugins/kimi-dsh/dist/mcp/workspace.js +0 -34
- package/plugins/kimi-dsh/dist/model-command.js +0 -32
- package/plugins/kimi-dsh/dist/native-v2-preflight.js +0 -525
- package/plugins/kimi-dsh/dist/package.json +0 -1
- package/plugins/kimi-dsh/dist/parsing.js +0 -620
- package/plugins/kimi-dsh/dist/paths.js +0 -27
- package/plugins/kimi-dsh/dist/plugin-data.js +0 -98
- package/plugins/kimi-dsh/dist/process-tree.js +0 -586
- package/plugins/kimi-dsh/dist/prompt-size.js +0 -18
- package/plugins/kimi-dsh/dist/render.js +0 -177
- package/plugins/kimi-dsh/dist/rescue-approval.js +0 -865
- package/plugins/kimi-dsh/dist/schemas/review-gate-output.js +0 -43
- package/plugins/kimi-dsh/dist/session-recovery.js +0 -202
- package/plugins/kimi-dsh/dist/session-title.js +0 -293
- package/plugins/kimi-dsh/dist/stream-json.js +0 -346
- package/plugins/kimi-dsh/dist/swarm-activation.js +0 -1197
- package/plugins/kimi-dsh/dist/swarm-policy.js +0 -73
- package/plugins/kimi-dsh/dist/swarm-recovery.js +0 -165
- package/plugins/kimi-dsh/dist/swarm-tool-policy.js +0 -146
- package/plugins/kimi-dsh/dist/types.js +0 -1
- package/plugins/kimi-dsh/dist/vendor/shell-quote/LICENSE +0 -24
- package/plugins/kimi-dsh/dist/vendor/shell-quote/index.js +0 -1
- package/plugins/kimi-dsh/dist/vendor/shell-quote/parse.js +0 -229
- package/plugins/kimi-dsh/dist/vendor/smol-toml/LICENSE +0 -24
- package/plugins/kimi-dsh/dist/vendor/smol-toml/date.js +0 -156
- package/plugins/kimi-dsh/dist/vendor/smol-toml/error.js +0 -67
- package/plugins/kimi-dsh/dist/vendor/smol-toml/extract.js +0 -293
- package/plugins/kimi-dsh/dist/vendor/smol-toml/parse.js +0 -164
- package/plugins/kimi-dsh/dist/vendor/smol-toml/primitive.js +0 -151
- package/plugins/kimi-dsh/dist/vendor/smol-toml/struct.js +0 -156
- package/plugins/kimi-dsh/dist/vendor/smol-toml/util.js +0 -57
- package/plugins/kimi-dsh/dist/version.js +0 -7
- package/plugins/kimi-dsh/package.json +0 -78
- package/plugins/kimi-dsh/scripts/companion.sh +0 -37
- package/plugins/kimi-dsh/scripts/review-gate-hook.sh +0 -32
- package/scripts/review-gate-hook.sh +0 -32
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { RuntimeError } from "./errors.js";
|
|
2
|
+
import { SCOPE_FLAGS_WRITE_MESSAGE } from "./read-scope.js";
|
|
2
3
|
/**
|
|
3
4
|
* Unknown flag-shaped tokens hard-fail instead of being absorbed into prose.
|
|
4
5
|
* Parsing still switches to prose at the first non-flag token or after `--`.
|
|
5
6
|
*/
|
|
6
|
-
function looksLikeFlag(token) {
|
|
7
|
+
export function looksLikeFlag(token) {
|
|
7
8
|
if (!token.startsWith("-")) {
|
|
8
9
|
return false;
|
|
9
10
|
}
|
|
@@ -13,11 +14,15 @@ function looksLikeFlag(token) {
|
|
|
13
14
|
// Short flag: a single dash followed by exactly one letter (`-r`, `-m`).
|
|
14
15
|
return /^-[a-zA-Z]$/.test(token);
|
|
15
16
|
}
|
|
16
|
-
|
|
17
|
-
export const
|
|
18
|
-
export const
|
|
19
|
-
|
|
20
|
-
export const
|
|
17
|
+
const SCOPE_SUPPORTED_FLAGS = "--read-root <absolute-dir> (repeatable), --network";
|
|
18
|
+
export const MAX_SESSION_REFERENCES = 8;
|
|
19
|
+
export const SESSION_REFERENCE_ID_MAX = 128;
|
|
20
|
+
const REFERENCE_SUPPORTED_FLAG = `--reference-session <job-id|session-id> (repeatable, at most ${MAX_SESSION_REFERENCES})`;
|
|
21
|
+
export const RESCUE_SUPPORTED_FLAGS = `-m/--model <name>, --thinking <off|low|medium|high>, --budget <30m|1h|90s>, --background, --wait, --fresh, -r, --resume <job-id|session-id>, ${REFERENCE_SUPPORTED_FLAG}`;
|
|
22
|
+
export const ASK_SUPPORTED_FLAGS = `${RESCUE_SUPPORTED_FLAGS}, ${SCOPE_SUPPORTED_FLAGS}`;
|
|
23
|
+
export const REVIEW_SUPPORTED_FLAGS = `--base <ref>, -m/--model <name>, --thinking <off|low|medium|high>, --budget <30m|1h|90s>, ${SCOPE_SUPPORTED_FLAGS}, ${REFERENCE_SUPPORTED_FLAG}`;
|
|
24
|
+
export const JOB_LOOKUP_SUPPORTED_FLAGS = "--type <review|challenge|rescue|ask>, --json";
|
|
25
|
+
export const SETUP_SUPPORTED_FLAGS = "--check, --uninstall, --models [--json] (without other setup flags), --install-kimi [--json] (without other setup flags), --repair-sessions [--apply] [--all] (without other setup flags)";
|
|
21
26
|
export const RECOVER_SWARM_SUPPORTED_FLAGS = "--apply";
|
|
22
27
|
export const REPAIR_SESSIONS_SUPPORTED_FLAGS = "--apply, --all";
|
|
23
28
|
export const REPLAY_SUPPORTED_FLAGS = "none (one job-id required)";
|
|
@@ -30,7 +35,7 @@ export function validateThinkingEffort(value, stage = "args.parse", lowercase =
|
|
|
30
35
|
return effort;
|
|
31
36
|
}
|
|
32
37
|
export const PURSUE_SUPPORTED_FLAGS = "-m/--model <name>, --thinking <off|low|medium|high>, --budget <30m|1h|90s>, --turns <N>";
|
|
33
|
-
export const SWARM_SUPPORTED_FLAGS =
|
|
38
|
+
export const SWARM_SUPPORTED_FLAGS = `-m/--model <name>, --thinking <off|low|medium|high>, --budget <30m|1h|90s>, --cap <N>, --max-concurrency <N>, --write, ${SCOPE_SUPPORTED_FLAGS} (read-only swarm only), ${REFERENCE_SUPPORTED_FLAG}`;
|
|
34
39
|
/**
|
|
35
40
|
* Parser for /kimi:swarm. Foreground-only: no --background/--fresh/--resume.
|
|
36
41
|
* Trailing tokens are the objective.
|
|
@@ -42,16 +47,17 @@ export function parseSwarmArgs(argv) {
|
|
|
42
47
|
let cap;
|
|
43
48
|
let maxConcurrency;
|
|
44
49
|
let write = false;
|
|
50
|
+
const readRoots = [];
|
|
51
|
+
let network = false;
|
|
52
|
+
const references = [];
|
|
45
53
|
let trailingTokens;
|
|
46
54
|
for (let index = 0; index < argv.length; index += 1) {
|
|
47
55
|
const token = argv[index];
|
|
48
|
-
|
|
49
|
-
|
|
56
|
+
const thinking = readThinkingFlag(argv, index);
|
|
57
|
+
if (thinking) {
|
|
58
|
+
[thinkingEffort, index] = thinking;
|
|
50
59
|
continue;
|
|
51
60
|
}
|
|
52
|
-
if (token === "--no-thinking" || token.startsWith("--no-thinking=")) {
|
|
53
|
-
throw new RuntimeError("INVALID_ARGS", "--no-thinking is unsupported; use --thinking off", "args.parse");
|
|
54
|
-
}
|
|
55
61
|
if (token === "--") {
|
|
56
62
|
trailingTokens = argv.slice(index + 1);
|
|
57
63
|
break;
|
|
@@ -62,40 +68,30 @@ export function parseSwarmArgs(argv) {
|
|
|
62
68
|
}
|
|
63
69
|
switch (token) {
|
|
64
70
|
case "-m":
|
|
65
|
-
case "--model":
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
if (value.startsWith("-")) {
|
|
71
|
-
throw new RuntimeError("INVALID_ARGS", `${token} value cannot start with '-'; pass a model name`, "swarm.parse");
|
|
72
|
-
}
|
|
73
|
-
model = value;
|
|
74
|
-
index += 1;
|
|
71
|
+
case "--model":
|
|
72
|
+
model = readModel(token, argv[++index], "swarm.parse");
|
|
73
|
+
break;
|
|
74
|
+
case "--reference-session":
|
|
75
|
+
references.push(referenceSessionValue(argv[++index], "swarm.parse"));
|
|
75
76
|
break;
|
|
76
|
-
}
|
|
77
77
|
case "--write":
|
|
78
78
|
write = true;
|
|
79
79
|
break;
|
|
80
|
-
case "--
|
|
81
|
-
|
|
82
|
-
if (!value || value.startsWith("-")) {
|
|
83
|
-
throw new RuntimeError("INVALID_ARGS", "--budget requires a duration (e.g. 30m, 1h, 90s).", "swarm.parse");
|
|
84
|
-
}
|
|
85
|
-
budgetMs = parseDurationMs(value, "--budget", "swarm.parse", "safety");
|
|
86
|
-
index += 1;
|
|
80
|
+
case "--read-root":
|
|
81
|
+
readRoots.push(readRootValue(argv[++index], "swarm.parse"));
|
|
87
82
|
break;
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
cap = parsePositiveIntFlag("--cap", argv[index + 1]);
|
|
91
|
-
index += 1;
|
|
83
|
+
case "--network":
|
|
84
|
+
network = true;
|
|
92
85
|
break;
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
86
|
+
case "--budget":
|
|
87
|
+
budgetMs = readBudget(argv[++index], "swarm.parse", "safety");
|
|
88
|
+
break;
|
|
89
|
+
case "--cap":
|
|
90
|
+
cap = parsePositiveIntFlag("--cap", argv[++index], "swarm.parse");
|
|
91
|
+
break;
|
|
92
|
+
case "--max-concurrency":
|
|
93
|
+
maxConcurrency = parsePositiveIntFlag("--max-concurrency", argv[++index], "swarm.parse");
|
|
97
94
|
break;
|
|
98
|
-
}
|
|
99
95
|
default:
|
|
100
96
|
if (looksLikeFlag(token)) {
|
|
101
97
|
throw new RuntimeError("INVALID_ARGS", `Unknown flag ${token} for swarm. Supported flags: ${SWARM_SUPPORTED_FLAGS}. Use \`--\` before flag-shaped objective text to pass it through.`, "swarm.parse");
|
|
@@ -105,6 +101,9 @@ export function parseSwarmArgs(argv) {
|
|
|
105
101
|
break;
|
|
106
102
|
}
|
|
107
103
|
}
|
|
104
|
+
if (write && (readRoots.length > 0 || network)) {
|
|
105
|
+
throw new RuntimeError("INVALID_ARGS", `swarm --write rejects scope flags. ${SCOPE_FLAGS_WRITE_MESSAGE}`, "swarm.parse");
|
|
106
|
+
}
|
|
108
107
|
return {
|
|
109
108
|
budgetMs,
|
|
110
109
|
cap,
|
|
@@ -112,26 +111,88 @@ export function parseSwarmArgs(argv) {
|
|
|
112
111
|
write,
|
|
113
112
|
model,
|
|
114
113
|
thinkingEffort,
|
|
114
|
+
...scopeFields(readRoots, network),
|
|
115
|
+
...referenceSessionsField(references, "swarm.parse"),
|
|
115
116
|
objective: trailingTokens?.join(" "),
|
|
116
117
|
};
|
|
117
118
|
}
|
|
119
|
+
function referenceSessionValue(value, stage) {
|
|
120
|
+
if (!value || value.startsWith("-")) {
|
|
121
|
+
throw new RuntimeError("INVALID_ARGS", "--reference-session requires a job id or Kimi session id.", stage);
|
|
122
|
+
}
|
|
123
|
+
return value;
|
|
124
|
+
}
|
|
125
|
+
/** Omitted when absent so parsed shapes stay unchanged; refuses more than the cap. */
|
|
126
|
+
function referenceSessionsField(values, stage) {
|
|
127
|
+
if (values.length === 0)
|
|
128
|
+
return {};
|
|
129
|
+
const unique = [...new Set(values)];
|
|
130
|
+
if (unique.length > MAX_SESSION_REFERENCES) {
|
|
131
|
+
throw new RuntimeError("INVALID_ARGS", `--reference-session accepts at most ${MAX_SESSION_REFERENCES} distinct sessions; got ${unique.length}.`, stage);
|
|
132
|
+
}
|
|
133
|
+
return { referenceSessions: unique };
|
|
134
|
+
}
|
|
135
|
+
/** Omit default-scope fields so parsed shapes stay unchanged without the flags. */
|
|
136
|
+
function scopeFields(readRoots, network) {
|
|
137
|
+
return {
|
|
138
|
+
...(readRoots.length > 0 ? { readRoots } : {}),
|
|
139
|
+
...(network ? { network } : {}),
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
function readRootValue(value, stage) {
|
|
143
|
+
if (!value || value.startsWith("-")) {
|
|
144
|
+
throw new RuntimeError("INVALID_ARGS", "--read-root requires an absolute directory path.", stage);
|
|
145
|
+
}
|
|
146
|
+
return value;
|
|
147
|
+
}
|
|
148
|
+
function rejectScopeFlag(token, command, stage) {
|
|
149
|
+
throw new RuntimeError("INVALID_ARGS", `${command} rejects ${token}. ${SCOPE_FLAGS_WRITE_MESSAGE}`, stage);
|
|
150
|
+
}
|
|
118
151
|
/**
|
|
119
|
-
* Shared positive-integer flag parser for swarm's `--cap` / `--max-concurrency
|
|
120
|
-
*
|
|
121
|
-
* to kimi-code's
|
|
122
|
-
*
|
|
123
|
-
*
|
|
152
|
+
* Shared positive-integer flag parser for swarm's `--cap` / `--max-concurrency`
|
|
153
|
+
* and pursue's `--turns`. Each must be a strict positive integer;
|
|
154
|
+
* `--max-concurrency` in particular maps to kimi-code's
|
|
155
|
+
* `KIMI_CODE_AGENT_SWARM_MAX_CONCURRENCY`, whose upstream resolver THROWS on a
|
|
156
|
+
* non-positive-integer — so the same `Number.isInteger && > 0` predicate
|
|
157
|
+
* guarantees every accepted value round-trips through `String()`.
|
|
124
158
|
*/
|
|
125
|
-
function parsePositiveIntFlag(flag, value) {
|
|
159
|
+
function parsePositiveIntFlag(flag, value, stage) {
|
|
126
160
|
if (!value || value.startsWith("-")) {
|
|
127
|
-
throw new RuntimeError("INVALID_ARGS", `${flag} requires a positive integer.`,
|
|
161
|
+
throw new RuntimeError("INVALID_ARGS", `${flag} requires a positive integer.`, stage);
|
|
128
162
|
}
|
|
129
163
|
const parsed = Number(value);
|
|
130
164
|
if (!Number.isInteger(parsed) || parsed <= 0) {
|
|
131
|
-
throw new RuntimeError("INVALID_ARGS", `${flag} must be a positive integer.`,
|
|
165
|
+
throw new RuntimeError("INVALID_ARGS", `${flag} must be a positive integer.`, stage);
|
|
132
166
|
}
|
|
133
167
|
return parsed;
|
|
134
168
|
}
|
|
169
|
+
/** `--thinking <effort>` / `--thinking=<effort>`: [effort, last consumed index]; undefined for other tokens. */
|
|
170
|
+
function readThinkingFlag(argv, index) {
|
|
171
|
+
const token = argv[index];
|
|
172
|
+
if (token === "--thinking" || token.startsWith("--thinking=")) {
|
|
173
|
+
const value = token === "--thinking" ? argv[++index] : token.slice("--thinking=".length);
|
|
174
|
+
return [validateThinkingEffort(value), index];
|
|
175
|
+
}
|
|
176
|
+
if (token === "--no-thinking" || token.startsWith("--no-thinking=")) {
|
|
177
|
+
throw new RuntimeError("INVALID_ARGS", "--no-thinking is unsupported; use --thinking off", "args.parse");
|
|
178
|
+
}
|
|
179
|
+
return undefined;
|
|
180
|
+
}
|
|
181
|
+
function readModel(flag, value, stage) {
|
|
182
|
+
if (!value) {
|
|
183
|
+
throw new RuntimeError("INVALID_ARGS", `${flag} requires a model value.`, stage);
|
|
184
|
+
}
|
|
185
|
+
if (value.startsWith("-")) {
|
|
186
|
+
throw new RuntimeError("INVALID_ARGS", `${flag} value cannot start with '-'; pass a model name`, stage);
|
|
187
|
+
}
|
|
188
|
+
return value;
|
|
189
|
+
}
|
|
190
|
+
function readBudget(value, stage, budgetKind) {
|
|
191
|
+
if (!value || value.startsWith("-")) {
|
|
192
|
+
throw new RuntimeError("INVALID_ARGS", "--budget requires a duration (e.g. 30m, 1h, 90s).", stage);
|
|
193
|
+
}
|
|
194
|
+
return parseDurationMs(value, "--budget", stage, budgetKind);
|
|
195
|
+
}
|
|
135
196
|
/**
|
|
136
197
|
* Upper bound for any `--budget` duration. The budget is the SOLE hard
|
|
137
198
|
* wall-clock bound on the plugin's autonomous/fan-out surfaces (pursue, swarm),
|
|
@@ -181,13 +242,11 @@ export function parsePursueArgs(argv) {
|
|
|
181
242
|
let trailingTokens;
|
|
182
243
|
for (let index = 0; index < argv.length; index += 1) {
|
|
183
244
|
const token = argv[index];
|
|
184
|
-
|
|
185
|
-
|
|
245
|
+
const thinking = readThinkingFlag(argv, index);
|
|
246
|
+
if (thinking) {
|
|
247
|
+
[thinkingEffort, index] = thinking;
|
|
186
248
|
continue;
|
|
187
249
|
}
|
|
188
|
-
if (token === "--no-thinking" || token.startsWith("--no-thinking=")) {
|
|
189
|
-
throw new RuntimeError("INVALID_ARGS", "--no-thinking is unsupported; use --thinking off", "args.parse");
|
|
190
|
-
}
|
|
191
250
|
if (token === "--") {
|
|
192
251
|
trailingTokens = argv.slice(index + 1);
|
|
193
252
|
break;
|
|
@@ -198,40 +257,18 @@ export function parsePursueArgs(argv) {
|
|
|
198
257
|
}
|
|
199
258
|
switch (token) {
|
|
200
259
|
case "-m":
|
|
201
|
-
case "--model":
|
|
202
|
-
|
|
203
|
-
if (!value) {
|
|
204
|
-
throw new RuntimeError("INVALID_ARGS", `${token} requires a model value.`, "pursue.parse");
|
|
205
|
-
}
|
|
206
|
-
if (value.startsWith("-")) {
|
|
207
|
-
throw new RuntimeError("INVALID_ARGS", `${token} value cannot start with '-'; pass a model name`, "pursue.parse");
|
|
208
|
-
}
|
|
209
|
-
model = value;
|
|
210
|
-
index += 1;
|
|
260
|
+
case "--model":
|
|
261
|
+
model = readModel(token, argv[++index], "pursue.parse");
|
|
211
262
|
break;
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
const value = argv[index + 1];
|
|
215
|
-
if (!value || value.startsWith("-")) {
|
|
216
|
-
throw new RuntimeError("INVALID_ARGS", "--budget requires a duration (e.g. 30m, 1h, 90s).", "pursue.parse");
|
|
217
|
-
}
|
|
218
|
-
budgetMs = parseDurationMs(value, "--budget", "pursue.parse", "safety");
|
|
219
|
-
index += 1;
|
|
263
|
+
case "--budget":
|
|
264
|
+
budgetMs = readBudget(argv[++index], "pursue.parse", "safety");
|
|
220
265
|
break;
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
const value = argv[index + 1];
|
|
224
|
-
if (!value || value.startsWith("-")) {
|
|
225
|
-
throw new RuntimeError("INVALID_ARGS", "--turns requires a positive integer.", "pursue.parse");
|
|
226
|
-
}
|
|
227
|
-
const parsedTurns = Number(value);
|
|
228
|
-
if (!Number.isInteger(parsedTurns) || parsedTurns <= 0) {
|
|
229
|
-
throw new RuntimeError("INVALID_ARGS", "--turns must be a positive integer.", "pursue.parse");
|
|
230
|
-
}
|
|
231
|
-
turns = parsedTurns;
|
|
232
|
-
index += 1;
|
|
266
|
+
case "--turns":
|
|
267
|
+
turns = parsePositiveIntFlag("--turns", argv[++index], "pursue.parse");
|
|
233
268
|
break;
|
|
234
|
-
|
|
269
|
+
case "--read-root":
|
|
270
|
+
case "--network":
|
|
271
|
+
rejectScopeFlag(token, "pursue", "pursue.parse");
|
|
235
272
|
default:
|
|
236
273
|
if (looksLikeFlag(token)) {
|
|
237
274
|
throw new RuntimeError("INVALID_ARGS", `Unknown flag ${token} for pursue. Supported flags: ${PURSUE_SUPPORTED_FLAGS}. Use \`--\` before flag-shaped objective text to pass it through.`, "pursue.parse");
|
|
@@ -249,7 +286,7 @@ export function parsePursueArgs(argv) {
|
|
|
249
286
|
objective: trailingTokens?.join(" "),
|
|
250
287
|
};
|
|
251
288
|
}
|
|
252
|
-
const VALUE_TAKING_FLAGS = new Set(["--thinking", "-m", "--model", "--budget", "--resume", "--base", "--cap", "--max-concurrency", "--turns", "--type"]);
|
|
289
|
+
const VALUE_TAKING_FLAGS = new Set(["--mode", "--thinking", "-m", "--model", "--budget", "--resume", "--base", "--cap", "--max-concurrency", "--turns", "--type", "--read-root", "--reference-session"]);
|
|
253
290
|
/**
|
|
254
291
|
* `--help` / `-h` counts only inside the leading flag region: before `--`
|
|
255
292
|
* and before the first prose token. The value of a value-taking flag is
|
|
@@ -265,7 +302,7 @@ export function hasHelpFlag(argv) {
|
|
|
265
302
|
return false;
|
|
266
303
|
if (token === "--help" || token === "-h")
|
|
267
304
|
return true;
|
|
268
|
-
if (!token
|
|
305
|
+
if (!looksLikeFlag(token))
|
|
269
306
|
return false;
|
|
270
307
|
if (VALUE_TAKING_FLAGS.has(token)) {
|
|
271
308
|
const value = argv[index + 1];
|
|
@@ -276,7 +313,41 @@ export function hasHelpFlag(argv) {
|
|
|
276
313
|
}
|
|
277
314
|
return false;
|
|
278
315
|
}
|
|
316
|
+
/**
|
|
317
|
+
* Remove every occurrence of a boolean selector flag from the leading flag
|
|
318
|
+
* region the prompt parsers use (prose starts at `--` or the first token that
|
|
319
|
+
* is not flag-shaped, such as `-5`); undefined when the region lacks it, so a
|
|
320
|
+
* selector inside prose never changes the operation.
|
|
321
|
+
*/
|
|
322
|
+
export function withoutLeadingFlag(argv, flag) {
|
|
323
|
+
const kept = [];
|
|
324
|
+
let found = false;
|
|
325
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
326
|
+
const token = argv[index];
|
|
327
|
+
if (token === "--" || !looksLikeFlag(token)) {
|
|
328
|
+
kept.push(...argv.slice(index));
|
|
329
|
+
break;
|
|
330
|
+
}
|
|
331
|
+
if (token === flag) {
|
|
332
|
+
found = true;
|
|
333
|
+
continue;
|
|
334
|
+
}
|
|
335
|
+
kept.push(token);
|
|
336
|
+
if (VALUE_TAKING_FLAGS.has(token) && index + 1 < argv.length) {
|
|
337
|
+
kept.push(argv[index + 1]);
|
|
338
|
+
index += 1;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
return found ? kept : undefined;
|
|
342
|
+
}
|
|
279
343
|
export function parseAskArgs(argv) {
|
|
344
|
+
return parsePromptArgs(argv, "ask");
|
|
345
|
+
}
|
|
346
|
+
export function parseRescueArgs(argv) {
|
|
347
|
+
return parsePromptArgs(argv, "rescue");
|
|
348
|
+
}
|
|
349
|
+
/** ask and rescue accept the same flags; only the command word in messages and stages differs. */
|
|
350
|
+
function parsePromptArgs(argv, kind) {
|
|
280
351
|
if (hasHelpFlag(argv))
|
|
281
352
|
return { help: true, background: false, wait: false, fresh: false, resume: false };
|
|
282
353
|
let budgetMs;
|
|
@@ -288,16 +359,17 @@ export function parseAskArgs(argv) {
|
|
|
288
359
|
let resume = false;
|
|
289
360
|
let resumeTarget;
|
|
290
361
|
let explicitResumeTarget = false;
|
|
362
|
+
const readRoots = [];
|
|
363
|
+
let network = false;
|
|
364
|
+
const references = [];
|
|
291
365
|
let trailingTokens;
|
|
292
366
|
for (let index = 0; index < argv.length; index += 1) {
|
|
293
367
|
const token = argv[index];
|
|
294
|
-
|
|
295
|
-
|
|
368
|
+
const thinking = readThinkingFlag(argv, index);
|
|
369
|
+
if (thinking) {
|
|
370
|
+
[thinkingEffort, index] = thinking;
|
|
296
371
|
continue;
|
|
297
372
|
}
|
|
298
|
-
if (token === "--no-thinking" || token.startsWith("--no-thinking=")) {
|
|
299
|
-
throw new RuntimeError("INVALID_ARGS", "--no-thinking is unsupported; use --thinking off", "args.parse");
|
|
300
|
-
}
|
|
301
373
|
if (token === "--") {
|
|
302
374
|
trailingTokens = argv.slice(index + 1);
|
|
303
375
|
break;
|
|
@@ -307,28 +379,16 @@ export function parseAskArgs(argv) {
|
|
|
307
379
|
break;
|
|
308
380
|
}
|
|
309
381
|
switch (token) {
|
|
310
|
-
case "--budget":
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
}
|
|
315
|
-
budgetMs = parseDurationMs(value, "--budget", "ask.parse", "response");
|
|
316
|
-
index += 1;
|
|
382
|
+
case "--budget":
|
|
383
|
+
budgetMs = readBudget(argv[++index], `${kind}.parse`, "response");
|
|
384
|
+
break;
|
|
385
|
+
case "--reference-session":
|
|
386
|
+
references.push(referenceSessionValue(argv[++index], `${kind}.parse`));
|
|
317
387
|
break;
|
|
318
|
-
}
|
|
319
388
|
case "-m":
|
|
320
|
-
case "--model":
|
|
321
|
-
|
|
322
|
-
if (!value) {
|
|
323
|
-
throw new RuntimeError("INVALID_ARGS", `${token} requires a model value.`, "args.parse");
|
|
324
|
-
}
|
|
325
|
-
if (value.startsWith("-")) {
|
|
326
|
-
throw new RuntimeError("INVALID_ARGS", `${token} value cannot start with '-'; pass a model name`, "args.parse");
|
|
327
|
-
}
|
|
328
|
-
model = value;
|
|
329
|
-
index += 1;
|
|
389
|
+
case "--model":
|
|
390
|
+
model = readModel(token, argv[++index], "args.parse");
|
|
330
391
|
break;
|
|
331
|
-
}
|
|
332
392
|
case "--background":
|
|
333
393
|
background = true;
|
|
334
394
|
break;
|
|
@@ -338,13 +398,23 @@ export function parseAskArgs(argv) {
|
|
|
338
398
|
case "--fresh":
|
|
339
399
|
fresh = true;
|
|
340
400
|
break;
|
|
401
|
+
case "--read-root":
|
|
402
|
+
if (kind === "rescue")
|
|
403
|
+
rejectScopeFlag(token, kind, `${kind}.parse`);
|
|
404
|
+
readRoots.push(readRootValue(argv[++index], `${kind}.parse`));
|
|
405
|
+
break;
|
|
406
|
+
case "--network":
|
|
407
|
+
if (kind === "rescue")
|
|
408
|
+
rejectScopeFlag(token, kind, `${kind}.parse`);
|
|
409
|
+
network = true;
|
|
410
|
+
break;
|
|
341
411
|
case "-r":
|
|
342
412
|
resume = true;
|
|
343
413
|
break;
|
|
344
414
|
case "--resume": {
|
|
345
415
|
const value = argv[index + 1];
|
|
346
416
|
if (!value || value.startsWith("-")) {
|
|
347
|
-
throw new RuntimeError("INVALID_ARGS",
|
|
417
|
+
throw new RuntimeError("INVALID_ARGS", `--resume requires a job-id or session-id. Use -r to resume the latest ${kind} session for this repo.`, `${kind}.parse`);
|
|
348
418
|
}
|
|
349
419
|
resume = true;
|
|
350
420
|
resumeTarget = value;
|
|
@@ -354,7 +424,7 @@ export function parseAskArgs(argv) {
|
|
|
354
424
|
}
|
|
355
425
|
default:
|
|
356
426
|
if (looksLikeFlag(token)) {
|
|
357
|
-
throw new RuntimeError("INVALID_ARGS", `Unknown flag ${token} for
|
|
427
|
+
throw new RuntimeError("INVALID_ARGS", `Unknown flag ${token} for ${kind}. Supported flags: ${kind === "rescue" ? RESCUE_SUPPORTED_FLAGS : ASK_SUPPORTED_FLAGS}. Use \`--\` before flag-shaped prompt text to pass it through.`, "args.parse");
|
|
358
428
|
}
|
|
359
429
|
trailingTokens = argv.slice(index);
|
|
360
430
|
index = argv.length;
|
|
@@ -362,10 +432,10 @@ export function parseAskArgs(argv) {
|
|
|
362
432
|
}
|
|
363
433
|
}
|
|
364
434
|
if (fresh && resume) {
|
|
365
|
-
throw new RuntimeError("INVALID_ARGS",
|
|
435
|
+
throw new RuntimeError("INVALID_ARGS", `${kind} does not allow --fresh and --resume together.`, `${kind}.parse`);
|
|
366
436
|
}
|
|
367
437
|
if (explicitResumeTarget && trailingTokens?.length) {
|
|
368
|
-
throw new RuntimeError("INVALID_ARGS",
|
|
438
|
+
throw new RuntimeError("INVALID_ARGS", `--resume only accepts a job-id or session-id. Use -r to resume the latest ${kind} session with a prompt.`, `${kind}.parse`);
|
|
369
439
|
}
|
|
370
440
|
return {
|
|
371
441
|
budgetMs,
|
|
@@ -376,11 +446,13 @@ export function parseAskArgs(argv) {
|
|
|
376
446
|
resumeTarget,
|
|
377
447
|
model,
|
|
378
448
|
thinkingEffort,
|
|
449
|
+
...scopeFields(readRoots, network),
|
|
450
|
+
...referenceSessionsField(references, `${kind}.parse`),
|
|
379
451
|
prompt: trailingTokens?.join(" "),
|
|
380
452
|
};
|
|
381
453
|
}
|
|
382
454
|
export function parseReviewArgs(argv, commandName = "review") {
|
|
383
|
-
const parsed = parseKnownFlags(argv, new Set(["--budget", "--base", "--background", "--wait", "-m", "--model"]), commandName);
|
|
455
|
+
const parsed = parseKnownFlags(argv, new Set(["--budget", "--base", "--background", "--wait", "-m", "--model", "--read-root", "--network", "--reference-session"]), commandName);
|
|
384
456
|
return {
|
|
385
457
|
budgetMs: parsed.budgetMs,
|
|
386
458
|
base: parsed.base,
|
|
@@ -388,112 +460,11 @@ export function parseReviewArgs(argv, commandName = "review") {
|
|
|
388
460
|
wait: parsed.wait,
|
|
389
461
|
model: parsed.model,
|
|
390
462
|
thinkingEffort: parsed.thinkingEffort,
|
|
463
|
+
...scopeFields(parsed.readRoots, parsed.network),
|
|
464
|
+
...referenceSessionsField(parsed.references, `${commandName}.parse`),
|
|
391
465
|
focus: parsed.trailingText,
|
|
392
466
|
};
|
|
393
467
|
}
|
|
394
|
-
export function parseRescueArgs(argv) {
|
|
395
|
-
if (hasHelpFlag(argv))
|
|
396
|
-
return { help: true, background: false, wait: false, fresh: false, resume: false };
|
|
397
|
-
let budgetMs;
|
|
398
|
-
let model;
|
|
399
|
-
let thinkingEffort;
|
|
400
|
-
let background = false;
|
|
401
|
-
let wait = false;
|
|
402
|
-
let fresh = false;
|
|
403
|
-
let resume = false;
|
|
404
|
-
let resumeTarget;
|
|
405
|
-
let explicitResumeTarget = false;
|
|
406
|
-
let trailingTokens;
|
|
407
|
-
for (let index = 0; index < argv.length; index += 1) {
|
|
408
|
-
const token = argv[index];
|
|
409
|
-
if (token === "--thinking" || token.startsWith("--thinking=")) {
|
|
410
|
-
thinkingEffort = validateThinkingEffort(token === "--thinking" ? argv[++index] : token.slice("--thinking=".length));
|
|
411
|
-
continue;
|
|
412
|
-
}
|
|
413
|
-
if (token === "--no-thinking" || token.startsWith("--no-thinking=")) {
|
|
414
|
-
throw new RuntimeError("INVALID_ARGS", "--no-thinking is unsupported; use --thinking off", "args.parse");
|
|
415
|
-
}
|
|
416
|
-
if (token === "--") {
|
|
417
|
-
trailingTokens = argv.slice(index + 1);
|
|
418
|
-
break;
|
|
419
|
-
}
|
|
420
|
-
if (!token.startsWith("-")) {
|
|
421
|
-
trailingTokens = argv.slice(index);
|
|
422
|
-
break;
|
|
423
|
-
}
|
|
424
|
-
switch (token) {
|
|
425
|
-
case "--budget": {
|
|
426
|
-
const value = argv[index + 1];
|
|
427
|
-
if (!value || value.startsWith("-")) {
|
|
428
|
-
throw new RuntimeError("INVALID_ARGS", "--budget requires a duration (e.g. 30m, 1h, 90s).", "rescue.parse");
|
|
429
|
-
}
|
|
430
|
-
budgetMs = parseDurationMs(value, "--budget", "rescue.parse", "response");
|
|
431
|
-
index += 1;
|
|
432
|
-
break;
|
|
433
|
-
}
|
|
434
|
-
case "-m":
|
|
435
|
-
case "--model": {
|
|
436
|
-
const value = argv[index + 1];
|
|
437
|
-
if (!value) {
|
|
438
|
-
throw new RuntimeError("INVALID_ARGS", `${token} requires a model value.`, "args.parse");
|
|
439
|
-
}
|
|
440
|
-
if (value.startsWith("-")) {
|
|
441
|
-
throw new RuntimeError("INVALID_ARGS", `${token} value cannot start with '-'; pass a model name`, "args.parse");
|
|
442
|
-
}
|
|
443
|
-
model = value;
|
|
444
|
-
index += 1;
|
|
445
|
-
break;
|
|
446
|
-
}
|
|
447
|
-
case "--background":
|
|
448
|
-
background = true;
|
|
449
|
-
break;
|
|
450
|
-
case "--wait":
|
|
451
|
-
wait = true;
|
|
452
|
-
break;
|
|
453
|
-
case "--fresh":
|
|
454
|
-
fresh = true;
|
|
455
|
-
break;
|
|
456
|
-
case "-r":
|
|
457
|
-
resume = true;
|
|
458
|
-
break;
|
|
459
|
-
case "--resume": {
|
|
460
|
-
const value = argv[index + 1];
|
|
461
|
-
if (!value || value.startsWith("-")) {
|
|
462
|
-
throw new RuntimeError("INVALID_ARGS", "--resume requires a job-id or session-id. Use -r to resume the latest rescue session for this repo.", "rescue.parse");
|
|
463
|
-
}
|
|
464
|
-
resume = true;
|
|
465
|
-
resumeTarget = value;
|
|
466
|
-
explicitResumeTarget = true;
|
|
467
|
-
index += 1;
|
|
468
|
-
break;
|
|
469
|
-
}
|
|
470
|
-
default:
|
|
471
|
-
if (looksLikeFlag(token)) {
|
|
472
|
-
throw new RuntimeError("INVALID_ARGS", `Unknown flag ${token} for rescue. Supported flags: ${RESCUE_SUPPORTED_FLAGS}. Use \`--\` before flag-shaped prompt text to pass it through.`, "args.parse");
|
|
473
|
-
}
|
|
474
|
-
trailingTokens = argv.slice(index);
|
|
475
|
-
index = argv.length;
|
|
476
|
-
break;
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
if (fresh && resume) {
|
|
480
|
-
throw new RuntimeError("INVALID_ARGS", "rescue does not allow --fresh and --resume together.", "rescue.parse");
|
|
481
|
-
}
|
|
482
|
-
if (explicitResumeTarget && trailingTokens?.length) {
|
|
483
|
-
throw new RuntimeError("INVALID_ARGS", "--resume only accepts a job-id or session-id. Use -r to resume the latest rescue session with a prompt.", "rescue.parse");
|
|
484
|
-
}
|
|
485
|
-
return {
|
|
486
|
-
budgetMs,
|
|
487
|
-
background,
|
|
488
|
-
wait,
|
|
489
|
-
fresh,
|
|
490
|
-
resume,
|
|
491
|
-
resumeTarget,
|
|
492
|
-
model,
|
|
493
|
-
thinkingEffort,
|
|
494
|
-
prompt: trailingTokens?.join(" "),
|
|
495
|
-
};
|
|
496
|
-
}
|
|
497
468
|
export function parseJobLookupArgs(argv) {
|
|
498
469
|
let type;
|
|
499
470
|
let jobId;
|
|
@@ -503,7 +474,7 @@ export function parseJobLookupArgs(argv) {
|
|
|
503
474
|
if (token === "--type") {
|
|
504
475
|
const value = argv[index + 1];
|
|
505
476
|
if (!value || !isManagedCommandType(value)) {
|
|
506
|
-
throw new RuntimeError("INVALID_ARGS", "--type requires one of review, challenge, rescue,
|
|
477
|
+
throw new RuntimeError("INVALID_ARGS", "--type requires one of review, challenge, rescue, ask.", "args.parse");
|
|
507
478
|
}
|
|
508
479
|
type = value;
|
|
509
480
|
index += 1;
|
|
@@ -531,7 +502,6 @@ function isManagedCommandType(value) {
|
|
|
531
502
|
return (value === "review" ||
|
|
532
503
|
value === "challenge" ||
|
|
533
504
|
value === "rescue" ||
|
|
534
|
-
value === "review_gate" ||
|
|
535
505
|
value === "ask");
|
|
536
506
|
}
|
|
537
507
|
function parseKnownFlags(argv, knownFlags, commandName) {
|
|
@@ -541,16 +511,17 @@ function parseKnownFlags(argv, knownFlags, commandName) {
|
|
|
541
511
|
let base;
|
|
542
512
|
let background = false;
|
|
543
513
|
let wait = false;
|
|
514
|
+
const readRoots = [];
|
|
515
|
+
let network = false;
|
|
516
|
+
const references = [];
|
|
544
517
|
let trailingTokens;
|
|
545
518
|
for (let index = 0; index < argv.length; index += 1) {
|
|
546
519
|
const token = argv[index];
|
|
547
|
-
|
|
548
|
-
|
|
520
|
+
const thinking = readThinkingFlag(argv, index);
|
|
521
|
+
if (thinking) {
|
|
522
|
+
[thinkingEffort, index] = thinking;
|
|
549
523
|
continue;
|
|
550
524
|
}
|
|
551
|
-
if (token === "--no-thinking" || token.startsWith("--no-thinking=")) {
|
|
552
|
-
throw new RuntimeError("INVALID_ARGS", "--no-thinking is unsupported; use --thinking off", "args.parse");
|
|
553
|
-
}
|
|
554
525
|
if (token === "--") {
|
|
555
526
|
trailingTokens = argv.slice(index + 1);
|
|
556
527
|
break;
|
|
@@ -563,28 +534,13 @@ function parseKnownFlags(argv, knownFlags, commandName) {
|
|
|
563
534
|
break;
|
|
564
535
|
}
|
|
565
536
|
switch (token) {
|
|
566
|
-
case "--budget":
|
|
567
|
-
|
|
568
|
-
if (!value || value.startsWith("-")) {
|
|
569
|
-
throw new RuntimeError("INVALID_ARGS", "--budget requires a duration (e.g. 30m, 1h, 90s).", `${commandName}.parse`);
|
|
570
|
-
}
|
|
571
|
-
budgetMs = parseDurationMs(value, "--budget", `${commandName}.parse`, "response");
|
|
572
|
-
index += 1;
|
|
537
|
+
case "--budget":
|
|
538
|
+
budgetMs = readBudget(argv[++index], `${commandName}.parse`, "response");
|
|
573
539
|
break;
|
|
574
|
-
}
|
|
575
540
|
case "-m":
|
|
576
|
-
case "--model":
|
|
577
|
-
|
|
578
|
-
if (!value) {
|
|
579
|
-
throw new RuntimeError("INVALID_ARGS", `${token} requires a model value.`, "args.parse");
|
|
580
|
-
}
|
|
581
|
-
if (value.startsWith("-")) {
|
|
582
|
-
throw new RuntimeError("INVALID_ARGS", `${token} value cannot start with '-'; pass a model name`, "args.parse");
|
|
583
|
-
}
|
|
584
|
-
model = value;
|
|
585
|
-
index += 1;
|
|
541
|
+
case "--model":
|
|
542
|
+
model = readModel(token, argv[++index], "args.parse");
|
|
586
543
|
break;
|
|
587
|
-
}
|
|
588
544
|
case "--base": {
|
|
589
545
|
const value = argv[index + 1];
|
|
590
546
|
if (!value) {
|
|
@@ -603,6 +559,15 @@ function parseKnownFlags(argv, knownFlags, commandName) {
|
|
|
603
559
|
case "--wait":
|
|
604
560
|
wait = true;
|
|
605
561
|
break;
|
|
562
|
+
case "--read-root":
|
|
563
|
+
readRoots.push(readRootValue(argv[++index], `${commandName}.parse`));
|
|
564
|
+
break;
|
|
565
|
+
case "--network":
|
|
566
|
+
network = true;
|
|
567
|
+
break;
|
|
568
|
+
case "--reference-session":
|
|
569
|
+
references.push(referenceSessionValue(argv[++index], `${commandName}.parse`));
|
|
570
|
+
break;
|
|
606
571
|
// The early `if (!knownFlags.has(token))` gate above means we only
|
|
607
572
|
// reach this switch with tokens that ARE in knownFlags, and every
|
|
608
573
|
// member is handled above. A `default` arm would be unreachable.
|
|
@@ -613,6 +578,9 @@ function parseKnownFlags(argv, knownFlags, commandName) {
|
|
|
613
578
|
base,
|
|
614
579
|
background,
|
|
615
580
|
wait,
|
|
581
|
+
readRoots,
|
|
582
|
+
network,
|
|
583
|
+
references,
|
|
616
584
|
model,
|
|
617
585
|
thinkingEffort,
|
|
618
586
|
trailingText: trailingTokens?.join(" "),
|