kimi-plugin-cc 2.7.3 → 3.0.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 +1 -1
- package/.claude-plugin/plugin.json +3 -5
- package/CHANGELOG.md +69 -0
- package/README.md +505 -448
- package/agents/kimi-pursue.md +6 -6
- package/agents/kimi-review.md +22 -22
- package/agents/kimi-swarm.md +25 -23
- package/agents/{kimi-ask.md → kimi-task.md} +34 -30
- package/commands/README.md +4 -6
- package/commands/pursue.md +1 -1
- package/commands/review.md +8 -3
- package/commands/setup.md +4 -2
- package/commands/swarm.md +3 -2
- package/commands/{rescue.md → task.md} +13 -11
- package/dist/background-spawn.js +10 -17
- package/dist/cli-client.js +65 -46
- package/dist/commands/ask.js +22 -89
- package/dist/commands/cancel.js +7 -46
- package/dist/commands/cli-helpers.js +102 -1
- package/dist/commands/models.js +2 -3
- package/dist/commands/pursue.js +5 -19
- package/dist/commands/repair-sessions.js +118 -12
- package/dist/commands/rescue.js +12 -82
- package/dist/commands/result.js +7 -1
- package/dist/commands/review-gate.js +1 -0
- package/dist/commands/review.js +12 -15
- package/dist/commands/setup.js +606 -270
- package/dist/commands/status.js +2 -2
- package/dist/commands/swarm.js +93 -119
- package/dist/commands/worker.js +1 -2
- package/dist/companion.js +3 -1
- package/dist/dsh/index.js +15 -17
- package/dist/git.js +1 -9
- package/dist/help.js +3 -3
- package/dist/hooks/approval-hook.js +41 -0
- package/dist/hooks/approval-policy.js +72 -10
- package/dist/hooks/config-safety.js +19 -43
- package/dist/hooks/hook-timing.js +48 -0
- package/dist/hooks/install.js +206 -11
- package/dist/hooks/managed-block.js +78 -33
- package/dist/job-store.js +100 -128
- package/dist/jobs.js +14 -19
- package/dist/kimi-command.js +74 -1
- package/dist/kimi-engine.js +170 -75
- package/dist/kimi-errors.js +14 -69
- package/dist/kimi-home.js +6 -0
- package/dist/kimi-journal.js +41 -0
- package/dist/kimi-releases.js +144 -0
- package/dist/kimi-timeouts.js +1 -1
- package/dist/kimi-version-probe.js +12 -48
- package/dist/mcp/job-control.js +4 -6
- package/dist/mcp/launcher.js +12 -6
- package/dist/mcp/operations.js +50 -18
- package/dist/mcp/protocol.js +16 -14
- package/dist/mcp/stdio.js +3 -2
- package/dist/model-command.js +5 -3
- package/dist/native-v2-preflight.js +139 -68
- package/dist/parsing.js +171 -237
- package/dist/paths.js +8 -0
- package/dist/process-tree.js +35 -24
- package/dist/read-scope.js +435 -0
- package/dist/render.js +46 -9
- package/dist/rescue-approval.js +461 -84
- package/dist/schemas/review-gate-output.js +3 -5
- package/dist/session-title.js +25 -5
- package/dist/stream-json.js +1 -3
- package/dist/surface-routing.js +21 -0
- package/dist/swarm-activation.js +72 -75
- 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 +24 -3
- package/docs/models.md +2 -2
- package/docs/registry-releases.md +1 -1
- package/docs/safety.md +120 -70
- package/docs/session-visibility.md +5 -3
- package/docs/swarm-recovery.md +1 -1
- package/docs/upstream-2.7.3-certification.md +14 -2
- package/package.json +1 -1
- package/plugins/kimi-codex/.codex-plugin/plugin.json +3 -3
- package/plugins/kimi-codex/.mcp.json +1 -0
- package/plugins/kimi-codex/dist/background-spawn.js +10 -17
- package/plugins/kimi-codex/dist/cli-client.js +65 -46
- package/plugins/kimi-codex/dist/commands/ask.js +22 -89
- package/plugins/kimi-codex/dist/commands/cancel.js +7 -46
- 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 +5 -19
- package/plugins/kimi-codex/dist/commands/repair-sessions.js +118 -12
- package/plugins/kimi-codex/dist/commands/rescue.js +12 -82
- package/plugins/kimi-codex/dist/commands/result.js +7 -1
- package/plugins/kimi-codex/dist/commands/review-gate.js +1 -0
- package/plugins/kimi-codex/dist/commands/review.js +12 -15
- package/plugins/kimi-codex/dist/commands/setup.js +606 -270
- package/plugins/kimi-codex/dist/commands/status.js +2 -2
- package/plugins/kimi-codex/dist/commands/swarm.js +93 -119
- package/plugins/kimi-codex/dist/commands/worker.js +1 -2
- package/plugins/kimi-codex/dist/companion.js +3 -1
- package/plugins/kimi-codex/dist/dsh/index.js +15 -17
- package/plugins/kimi-codex/dist/git.js +1 -9
- package/plugins/kimi-codex/dist/help.js +3 -3
- package/plugins/kimi-codex/dist/hooks/approval-hook.js +41 -0
- package/plugins/kimi-codex/dist/hooks/approval-policy.js +72 -10
- package/plugins/kimi-codex/dist/hooks/config-safety.js +19 -43
- package/plugins/kimi-codex/dist/hooks/hook-timing.js +48 -0
- package/plugins/kimi-codex/dist/hooks/install.js +206 -11
- package/plugins/kimi-codex/dist/hooks/managed-block.js +78 -33
- package/plugins/kimi-codex/dist/job-store.js +100 -128
- package/plugins/kimi-codex/dist/jobs.js +14 -19
- package/plugins/kimi-codex/dist/kimi-command.js +74 -1
- package/plugins/kimi-codex/dist/kimi-engine.js +170 -75
- package/plugins/kimi-codex/dist/kimi-errors.js +14 -69
- package/plugins/kimi-codex/dist/kimi-home.js +6 -0
- package/plugins/kimi-codex/dist/kimi-journal.js +41 -0
- package/plugins/kimi-codex/dist/kimi-releases.js +144 -0
- package/plugins/kimi-codex/dist/kimi-timeouts.js +1 -1
- package/plugins/kimi-codex/dist/kimi-version-probe.js +12 -48
- package/plugins/kimi-codex/dist/mcp/job-control.js +4 -6
- package/plugins/kimi-codex/dist/mcp/launcher.js +12 -6
- package/plugins/kimi-codex/dist/mcp/operations.js +50 -18
- package/plugins/kimi-codex/dist/mcp/protocol.js +16 -14
- package/plugins/kimi-codex/dist/mcp/stdio.js +3 -2
- package/plugins/kimi-codex/dist/model-command.js +5 -3
- package/plugins/kimi-codex/dist/native-v2-preflight.js +139 -68
- package/plugins/kimi-codex/dist/parsing.js +171 -237
- package/plugins/kimi-codex/dist/paths.js +8 -0
- 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 +46 -9
- package/plugins/kimi-codex/dist/rescue-approval.js +461 -84
- package/plugins/kimi-codex/dist/schemas/review-gate-output.js +3 -5
- package/plugins/kimi-codex/dist/session-title.js +25 -5
- package/plugins/kimi-codex/dist/stream-json.js +1 -3
- package/plugins/kimi-codex/dist/surface-routing.js +21 -0
- package/plugins/kimi-codex/dist/swarm-activation.js +72 -75
- 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/skills/kimi-pursue/SKILL.md +1 -1
- package/plugins/kimi-codex/skills/kimi-review/SKILL.md +8 -7
- package/plugins/kimi-codex/skills/kimi-review/agents/openai.yaml +1 -1
- package/plugins/kimi-codex/skills/kimi-setup/SKILL.md +2 -1
- package/plugins/kimi-codex/skills/kimi-swarm/SKILL.md +8 -6
- package/plugins/kimi-codex/skills/kimi-swarm/agents/openai.yaml +1 -1
- package/plugins/kimi-codex/skills/{kimi-ask → kimi-task}/SKILL.md +11 -9
- package/plugins/kimi-codex/skills/kimi-task/agents/openai.yaml +6 -0
- package/plugins/kimi-dsh/README.md +3 -2
- package/plugins/kimi-dsh/dist/background-spawn.js +10 -17
- package/plugins/kimi-dsh/dist/cli-client.js +65 -46
- package/plugins/kimi-dsh/dist/commands/ask.js +22 -89
- package/plugins/kimi-dsh/dist/commands/cancel.js +7 -46
- package/plugins/kimi-dsh/dist/commands/cli-helpers.js +102 -1
- package/plugins/kimi-dsh/dist/commands/models.js +2 -3
- package/plugins/kimi-dsh/dist/commands/pursue.js +5 -19
- package/plugins/kimi-dsh/dist/commands/repair-sessions.js +118 -12
- package/plugins/kimi-dsh/dist/commands/rescue.js +12 -82
- package/plugins/kimi-dsh/dist/commands/result.js +7 -1
- package/plugins/kimi-dsh/dist/commands/review-gate.js +1 -0
- package/plugins/kimi-dsh/dist/commands/review.js +12 -15
- package/plugins/kimi-dsh/dist/commands/setup.js +606 -270
- package/plugins/kimi-dsh/dist/commands/status.js +2 -2
- package/plugins/kimi-dsh/dist/commands/swarm.js +93 -119
- package/plugins/kimi-dsh/dist/commands/worker.js +1 -2
- package/plugins/kimi-dsh/dist/companion.js +3 -1
- package/plugins/kimi-dsh/dist/dsh/index.js +15 -17
- package/plugins/kimi-dsh/dist/git.js +1 -9
- package/plugins/kimi-dsh/dist/help.js +3 -3
- package/plugins/kimi-dsh/dist/hooks/approval-hook.js +41 -0
- package/plugins/kimi-dsh/dist/hooks/approval-policy.js +72 -10
- package/plugins/kimi-dsh/dist/hooks/config-safety.js +19 -43
- package/plugins/kimi-dsh/dist/hooks/hook-timing.js +48 -0
- package/plugins/kimi-dsh/dist/hooks/install.js +206 -11
- package/plugins/kimi-dsh/dist/hooks/managed-block.js +78 -33
- package/plugins/kimi-dsh/dist/job-store.js +100 -128
- package/plugins/kimi-dsh/dist/jobs.js +14 -19
- package/plugins/kimi-dsh/dist/kimi-command.js +74 -1
- package/plugins/kimi-dsh/dist/kimi-engine.js +170 -75
- package/plugins/kimi-dsh/dist/kimi-errors.js +14 -69
- package/plugins/kimi-dsh/dist/kimi-home.js +6 -0
- package/plugins/kimi-dsh/dist/kimi-journal.js +41 -0
- package/plugins/kimi-dsh/dist/kimi-releases.js +144 -0
- package/plugins/kimi-dsh/dist/kimi-timeouts.js +1 -1
- package/plugins/kimi-dsh/dist/kimi-version-probe.js +12 -48
- package/plugins/kimi-dsh/dist/mcp/job-control.js +4 -6
- package/plugins/kimi-dsh/dist/mcp/launcher.js +12 -6
- package/plugins/kimi-dsh/dist/mcp/operations.js +50 -18
- package/plugins/kimi-dsh/dist/mcp/protocol.js +16 -14
- package/plugins/kimi-dsh/dist/mcp/stdio.js +3 -2
- package/plugins/kimi-dsh/dist/model-command.js +5 -3
- package/plugins/kimi-dsh/dist/native-v2-preflight.js +139 -68
- package/plugins/kimi-dsh/dist/parsing.js +171 -237
- package/plugins/kimi-dsh/dist/paths.js +8 -0
- package/plugins/kimi-dsh/dist/process-tree.js +35 -24
- package/plugins/kimi-dsh/dist/read-scope.js +435 -0
- package/plugins/kimi-dsh/dist/render.js +46 -9
- package/plugins/kimi-dsh/dist/rescue-approval.js +461 -84
- package/plugins/kimi-dsh/dist/schemas/review-gate-output.js +3 -5
- package/plugins/kimi-dsh/dist/session-title.js +25 -5
- package/plugins/kimi-dsh/dist/stream-json.js +1 -3
- package/plugins/kimi-dsh/dist/surface-routing.js +21 -0
- package/plugins/kimi-dsh/dist/swarm-activation.js +72 -75
- package/plugins/kimi-dsh/dist/swarm-policy.js +2 -1
- package/plugins/kimi-dsh/dist/swarm-recovery.js +2 -1
- package/plugins/kimi-dsh/dist/util.js +28 -0
- package/plugins/kimi-dsh/dist/version.js +1 -1
- package/plugins/kimi-dsh/package.json +1 -1
- package/agents/kimi-challenge.md +0 -86
- package/agents/kimi-rescue.md +0 -92
- package/agents/kimi-swarm-write.md +0 -96
- package/commands/ask.md +0 -38
- package/commands/challenge.md +0 -35
- package/dist/commands/not-implemented.js +0 -4
- package/plugins/kimi-codex/dist/commands/not-implemented.js +0 -4
- package/plugins/kimi-codex/skills/kimi-ask/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-rescue/SKILL.md +0 -34
- package/plugins/kimi-codex/skills/kimi-rescue/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/dist/commands/not-implemented.js +0 -4
package/dist/parsing.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
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 `--`.
|
|
@@ -13,11 +14,12 @@ 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
|
+
const SCOPE_SUPPORTED_FLAGS = "--read-root <absolute-dir> (repeatable), --network";
|
|
17
18
|
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>";
|
|
18
|
-
export const
|
|
19
|
+
export const ASK_SUPPORTED_FLAGS = `${RESCUE_SUPPORTED_FLAGS}, ${SCOPE_SUPPORTED_FLAGS}`;
|
|
20
|
+
export const REVIEW_SUPPORTED_FLAGS = `--base <ref>, -m/--model <name>, --thinking <off|low|medium|high>, --budget <30m|1h|90s>, ${SCOPE_SUPPORTED_FLAGS}`;
|
|
19
21
|
export const JOB_LOOKUP_SUPPORTED_FLAGS = "--type <review|challenge|rescue|review_gate|ask>, --json";
|
|
20
|
-
export const SETUP_SUPPORTED_FLAGS = "--check, --uninstall, --all (with --uninstall), --enable-review-gate, --disable-review-gate, --models [--json] (without other setup flags)";
|
|
22
|
+
export const SETUP_SUPPORTED_FLAGS = "--check, --uninstall, --all (with --uninstall), --enable-review-gate, --disable-review-gate, --models [--json] (without other setup flags), --install-kimi [--json] (without other setup flags)";
|
|
21
23
|
export const RECOVER_SWARM_SUPPORTED_FLAGS = "--apply";
|
|
22
24
|
export const REPAIR_SESSIONS_SUPPORTED_FLAGS = "--apply, --all";
|
|
23
25
|
export const REPLAY_SUPPORTED_FLAGS = "none (one job-id required)";
|
|
@@ -30,7 +32,7 @@ export function validateThinkingEffort(value, stage = "args.parse", lowercase =
|
|
|
30
32
|
return effort;
|
|
31
33
|
}
|
|
32
34
|
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 =
|
|
35
|
+
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)`;
|
|
34
36
|
/**
|
|
35
37
|
* Parser for /kimi:swarm. Foreground-only: no --background/--fresh/--resume.
|
|
36
38
|
* Trailing tokens are the objective.
|
|
@@ -42,16 +44,16 @@ export function parseSwarmArgs(argv) {
|
|
|
42
44
|
let cap;
|
|
43
45
|
let maxConcurrency;
|
|
44
46
|
let write = false;
|
|
47
|
+
const readRoots = [];
|
|
48
|
+
let network = false;
|
|
45
49
|
let trailingTokens;
|
|
46
50
|
for (let index = 0; index < argv.length; index += 1) {
|
|
47
51
|
const token = argv[index];
|
|
48
|
-
|
|
49
|
-
|
|
52
|
+
const thinking = readThinkingFlag(argv, index);
|
|
53
|
+
if (thinking) {
|
|
54
|
+
[thinkingEffort, index] = thinking;
|
|
50
55
|
continue;
|
|
51
56
|
}
|
|
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
57
|
if (token === "--") {
|
|
56
58
|
trailingTokens = argv.slice(index + 1);
|
|
57
59
|
break;
|
|
@@ -62,40 +64,27 @@ export function parseSwarmArgs(argv) {
|
|
|
62
64
|
}
|
|
63
65
|
switch (token) {
|
|
64
66
|
case "-m":
|
|
65
|
-
case "--model":
|
|
66
|
-
|
|
67
|
-
if (!value) {
|
|
68
|
-
throw new RuntimeError("INVALID_ARGS", `${token} requires a model value.`, "swarm.parse");
|
|
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;
|
|
67
|
+
case "--model":
|
|
68
|
+
model = readModel(token, argv[++index], "swarm.parse");
|
|
75
69
|
break;
|
|
76
|
-
}
|
|
77
70
|
case "--write":
|
|
78
71
|
write = true;
|
|
79
72
|
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;
|
|
73
|
+
case "--read-root":
|
|
74
|
+
readRoots.push(readRootValue(argv[++index], "swarm.parse"));
|
|
87
75
|
break;
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
cap = parsePositiveIntFlag("--cap", argv[index + 1]);
|
|
91
|
-
index += 1;
|
|
76
|
+
case "--network":
|
|
77
|
+
network = true;
|
|
92
78
|
break;
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
79
|
+
case "--budget":
|
|
80
|
+
budgetMs = readBudget(argv[++index], "swarm.parse", "safety");
|
|
81
|
+
break;
|
|
82
|
+
case "--cap":
|
|
83
|
+
cap = parsePositiveIntFlag("--cap", argv[++index], "swarm.parse");
|
|
84
|
+
break;
|
|
85
|
+
case "--max-concurrency":
|
|
86
|
+
maxConcurrency = parsePositiveIntFlag("--max-concurrency", argv[++index], "swarm.parse");
|
|
97
87
|
break;
|
|
98
|
-
}
|
|
99
88
|
default:
|
|
100
89
|
if (looksLikeFlag(token)) {
|
|
101
90
|
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 +94,9 @@ export function parseSwarmArgs(argv) {
|
|
|
105
94
|
break;
|
|
106
95
|
}
|
|
107
96
|
}
|
|
97
|
+
if (write && (readRoots.length > 0 || network)) {
|
|
98
|
+
throw new RuntimeError("INVALID_ARGS", `swarm --write rejects scope flags. ${SCOPE_FLAGS_WRITE_MESSAGE}`, "swarm.parse");
|
|
99
|
+
}
|
|
108
100
|
return {
|
|
109
101
|
budgetMs,
|
|
110
102
|
cap,
|
|
@@ -112,26 +104,71 @@ export function parseSwarmArgs(argv) {
|
|
|
112
104
|
write,
|
|
113
105
|
model,
|
|
114
106
|
thinkingEffort,
|
|
107
|
+
...scopeFields(readRoots, network),
|
|
115
108
|
objective: trailingTokens?.join(" "),
|
|
116
109
|
};
|
|
117
110
|
}
|
|
111
|
+
/** Omit default-scope fields so parsed shapes stay unchanged without the flags. */
|
|
112
|
+
function scopeFields(readRoots, network) {
|
|
113
|
+
return {
|
|
114
|
+
...(readRoots.length > 0 ? { readRoots } : {}),
|
|
115
|
+
...(network ? { network } : {}),
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
function readRootValue(value, stage) {
|
|
119
|
+
if (!value || value.startsWith("-")) {
|
|
120
|
+
throw new RuntimeError("INVALID_ARGS", "--read-root requires an absolute directory path.", stage);
|
|
121
|
+
}
|
|
122
|
+
return value;
|
|
123
|
+
}
|
|
124
|
+
function rejectScopeFlag(token, command, stage) {
|
|
125
|
+
throw new RuntimeError("INVALID_ARGS", `${command} rejects ${token}. ${SCOPE_FLAGS_WRITE_MESSAGE}`, stage);
|
|
126
|
+
}
|
|
118
127
|
/**
|
|
119
|
-
* Shared positive-integer flag parser for swarm's `--cap` / `--max-concurrency
|
|
120
|
-
*
|
|
121
|
-
* to kimi-code's
|
|
122
|
-
*
|
|
123
|
-
*
|
|
128
|
+
* Shared positive-integer flag parser for swarm's `--cap` / `--max-concurrency`
|
|
129
|
+
* and pursue's `--turns`. Each must be a strict positive integer;
|
|
130
|
+
* `--max-concurrency` in particular maps to kimi-code's
|
|
131
|
+
* `KIMI_CODE_AGENT_SWARM_MAX_CONCURRENCY`, whose upstream resolver THROWS on a
|
|
132
|
+
* non-positive-integer — so the same `Number.isInteger && > 0` predicate
|
|
133
|
+
* guarantees every accepted value round-trips through `String()`.
|
|
124
134
|
*/
|
|
125
|
-
function parsePositiveIntFlag(flag, value) {
|
|
135
|
+
function parsePositiveIntFlag(flag, value, stage) {
|
|
126
136
|
if (!value || value.startsWith("-")) {
|
|
127
|
-
throw new RuntimeError("INVALID_ARGS", `${flag} requires a positive integer.`,
|
|
137
|
+
throw new RuntimeError("INVALID_ARGS", `${flag} requires a positive integer.`, stage);
|
|
128
138
|
}
|
|
129
139
|
const parsed = Number(value);
|
|
130
140
|
if (!Number.isInteger(parsed) || parsed <= 0) {
|
|
131
|
-
throw new RuntimeError("INVALID_ARGS", `${flag} must be a positive integer.`,
|
|
141
|
+
throw new RuntimeError("INVALID_ARGS", `${flag} must be a positive integer.`, stage);
|
|
132
142
|
}
|
|
133
143
|
return parsed;
|
|
134
144
|
}
|
|
145
|
+
/** `--thinking <effort>` / `--thinking=<effort>`: [effort, last consumed index]; undefined for other tokens. */
|
|
146
|
+
function readThinkingFlag(argv, index) {
|
|
147
|
+
const token = argv[index];
|
|
148
|
+
if (token === "--thinking" || token.startsWith("--thinking=")) {
|
|
149
|
+
const value = token === "--thinking" ? argv[++index] : token.slice("--thinking=".length);
|
|
150
|
+
return [validateThinkingEffort(value), index];
|
|
151
|
+
}
|
|
152
|
+
if (token === "--no-thinking" || token.startsWith("--no-thinking=")) {
|
|
153
|
+
throw new RuntimeError("INVALID_ARGS", "--no-thinking is unsupported; use --thinking off", "args.parse");
|
|
154
|
+
}
|
|
155
|
+
return undefined;
|
|
156
|
+
}
|
|
157
|
+
function readModel(flag, value, stage) {
|
|
158
|
+
if (!value) {
|
|
159
|
+
throw new RuntimeError("INVALID_ARGS", `${flag} requires a model value.`, stage);
|
|
160
|
+
}
|
|
161
|
+
if (value.startsWith("-")) {
|
|
162
|
+
throw new RuntimeError("INVALID_ARGS", `${flag} value cannot start with '-'; pass a model name`, stage);
|
|
163
|
+
}
|
|
164
|
+
return value;
|
|
165
|
+
}
|
|
166
|
+
function readBudget(value, stage, budgetKind) {
|
|
167
|
+
if (!value || value.startsWith("-")) {
|
|
168
|
+
throw new RuntimeError("INVALID_ARGS", "--budget requires a duration (e.g. 30m, 1h, 90s).", stage);
|
|
169
|
+
}
|
|
170
|
+
return parseDurationMs(value, "--budget", stage, budgetKind);
|
|
171
|
+
}
|
|
135
172
|
/**
|
|
136
173
|
* Upper bound for any `--budget` duration. The budget is the SOLE hard
|
|
137
174
|
* wall-clock bound on the plugin's autonomous/fan-out surfaces (pursue, swarm),
|
|
@@ -181,13 +218,11 @@ export function parsePursueArgs(argv) {
|
|
|
181
218
|
let trailingTokens;
|
|
182
219
|
for (let index = 0; index < argv.length; index += 1) {
|
|
183
220
|
const token = argv[index];
|
|
184
|
-
|
|
185
|
-
|
|
221
|
+
const thinking = readThinkingFlag(argv, index);
|
|
222
|
+
if (thinking) {
|
|
223
|
+
[thinkingEffort, index] = thinking;
|
|
186
224
|
continue;
|
|
187
225
|
}
|
|
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
226
|
if (token === "--") {
|
|
192
227
|
trailingTokens = argv.slice(index + 1);
|
|
193
228
|
break;
|
|
@@ -198,40 +233,18 @@ export function parsePursueArgs(argv) {
|
|
|
198
233
|
}
|
|
199
234
|
switch (token) {
|
|
200
235
|
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;
|
|
236
|
+
case "--model":
|
|
237
|
+
model = readModel(token, argv[++index], "pursue.parse");
|
|
211
238
|
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;
|
|
239
|
+
case "--budget":
|
|
240
|
+
budgetMs = readBudget(argv[++index], "pursue.parse", "safety");
|
|
220
241
|
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;
|
|
242
|
+
case "--turns":
|
|
243
|
+
turns = parsePositiveIntFlag("--turns", argv[++index], "pursue.parse");
|
|
233
244
|
break;
|
|
234
|
-
|
|
245
|
+
case "--read-root":
|
|
246
|
+
case "--network":
|
|
247
|
+
rejectScopeFlag(token, "pursue", "pursue.parse");
|
|
235
248
|
default:
|
|
236
249
|
if (looksLikeFlag(token)) {
|
|
237
250
|
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 +262,7 @@ export function parsePursueArgs(argv) {
|
|
|
249
262
|
objective: trailingTokens?.join(" "),
|
|
250
263
|
};
|
|
251
264
|
}
|
|
252
|
-
const VALUE_TAKING_FLAGS = new Set(["--thinking", "-m", "--model", "--budget", "--resume", "--base", "--cap", "--max-concurrency", "--turns", "--type"]);
|
|
265
|
+
const VALUE_TAKING_FLAGS = new Set(["--thinking", "-m", "--model", "--budget", "--resume", "--base", "--cap", "--max-concurrency", "--turns", "--type", "--read-root"]);
|
|
253
266
|
/**
|
|
254
267
|
* `--help` / `-h` counts only inside the leading flag region: before `--`
|
|
255
268
|
* and before the first prose token. The value of a value-taking flag is
|
|
@@ -276,7 +289,41 @@ export function hasHelpFlag(argv) {
|
|
|
276
289
|
}
|
|
277
290
|
return false;
|
|
278
291
|
}
|
|
292
|
+
/**
|
|
293
|
+
* Remove every occurrence of a boolean selector flag from the leading flag
|
|
294
|
+
* region the prompt parsers use (prose starts at `--` or the first token that
|
|
295
|
+
* is not flag-shaped, such as `-5`); undefined when the region lacks it, so a
|
|
296
|
+
* selector inside prose never changes the operation.
|
|
297
|
+
*/
|
|
298
|
+
export function withoutLeadingFlag(argv, flag) {
|
|
299
|
+
const kept = [];
|
|
300
|
+
let found = false;
|
|
301
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
302
|
+
const token = argv[index];
|
|
303
|
+
if (token === "--" || !looksLikeFlag(token)) {
|
|
304
|
+
kept.push(...argv.slice(index));
|
|
305
|
+
break;
|
|
306
|
+
}
|
|
307
|
+
if (token === flag) {
|
|
308
|
+
found = true;
|
|
309
|
+
continue;
|
|
310
|
+
}
|
|
311
|
+
kept.push(token);
|
|
312
|
+
if (VALUE_TAKING_FLAGS.has(token) && index + 1 < argv.length) {
|
|
313
|
+
kept.push(argv[index + 1]);
|
|
314
|
+
index += 1;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
return found ? kept : undefined;
|
|
318
|
+
}
|
|
279
319
|
export function parseAskArgs(argv) {
|
|
320
|
+
return parsePromptArgs(argv, "ask");
|
|
321
|
+
}
|
|
322
|
+
export function parseRescueArgs(argv) {
|
|
323
|
+
return parsePromptArgs(argv, "rescue");
|
|
324
|
+
}
|
|
325
|
+
/** ask and rescue accept the same flags; only the command word in messages and stages differs. */
|
|
326
|
+
function parsePromptArgs(argv, kind) {
|
|
280
327
|
if (hasHelpFlag(argv))
|
|
281
328
|
return { help: true, background: false, wait: false, fresh: false, resume: false };
|
|
282
329
|
let budgetMs;
|
|
@@ -288,16 +335,16 @@ export function parseAskArgs(argv) {
|
|
|
288
335
|
let resume = false;
|
|
289
336
|
let resumeTarget;
|
|
290
337
|
let explicitResumeTarget = false;
|
|
338
|
+
const readRoots = [];
|
|
339
|
+
let network = false;
|
|
291
340
|
let trailingTokens;
|
|
292
341
|
for (let index = 0; index < argv.length; index += 1) {
|
|
293
342
|
const token = argv[index];
|
|
294
|
-
|
|
295
|
-
|
|
343
|
+
const thinking = readThinkingFlag(argv, index);
|
|
344
|
+
if (thinking) {
|
|
345
|
+
[thinkingEffort, index] = thinking;
|
|
296
346
|
continue;
|
|
297
347
|
}
|
|
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
348
|
if (token === "--") {
|
|
302
349
|
trailingTokens = argv.slice(index + 1);
|
|
303
350
|
break;
|
|
@@ -307,28 +354,13 @@ export function parseAskArgs(argv) {
|
|
|
307
354
|
break;
|
|
308
355
|
}
|
|
309
356
|
switch (token) {
|
|
310
|
-
case "--budget":
|
|
311
|
-
|
|
312
|
-
if (!value || value.startsWith("-")) {
|
|
313
|
-
throw new RuntimeError("INVALID_ARGS", "--budget requires a duration (e.g. 30m, 1h, 90s).", "ask.parse");
|
|
314
|
-
}
|
|
315
|
-
budgetMs = parseDurationMs(value, "--budget", "ask.parse", "response");
|
|
316
|
-
index += 1;
|
|
357
|
+
case "--budget":
|
|
358
|
+
budgetMs = readBudget(argv[++index], `${kind}.parse`, "response");
|
|
317
359
|
break;
|
|
318
|
-
}
|
|
319
360
|
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;
|
|
361
|
+
case "--model":
|
|
362
|
+
model = readModel(token, argv[++index], "args.parse");
|
|
330
363
|
break;
|
|
331
|
-
}
|
|
332
364
|
case "--background":
|
|
333
365
|
background = true;
|
|
334
366
|
break;
|
|
@@ -338,13 +370,23 @@ export function parseAskArgs(argv) {
|
|
|
338
370
|
case "--fresh":
|
|
339
371
|
fresh = true;
|
|
340
372
|
break;
|
|
373
|
+
case "--read-root":
|
|
374
|
+
if (kind === "rescue")
|
|
375
|
+
rejectScopeFlag(token, kind, `${kind}.parse`);
|
|
376
|
+
readRoots.push(readRootValue(argv[++index], `${kind}.parse`));
|
|
377
|
+
break;
|
|
378
|
+
case "--network":
|
|
379
|
+
if (kind === "rescue")
|
|
380
|
+
rejectScopeFlag(token, kind, `${kind}.parse`);
|
|
381
|
+
network = true;
|
|
382
|
+
break;
|
|
341
383
|
case "-r":
|
|
342
384
|
resume = true;
|
|
343
385
|
break;
|
|
344
386
|
case "--resume": {
|
|
345
387
|
const value = argv[index + 1];
|
|
346
388
|
if (!value || value.startsWith("-")) {
|
|
347
|
-
throw new RuntimeError("INVALID_ARGS",
|
|
389
|
+
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
390
|
}
|
|
349
391
|
resume = true;
|
|
350
392
|
resumeTarget = value;
|
|
@@ -354,7 +396,7 @@ export function parseAskArgs(argv) {
|
|
|
354
396
|
}
|
|
355
397
|
default:
|
|
356
398
|
if (looksLikeFlag(token)) {
|
|
357
|
-
throw new RuntimeError("INVALID_ARGS", `Unknown flag ${token} for
|
|
399
|
+
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
400
|
}
|
|
359
401
|
trailingTokens = argv.slice(index);
|
|
360
402
|
index = argv.length;
|
|
@@ -362,10 +404,10 @@ export function parseAskArgs(argv) {
|
|
|
362
404
|
}
|
|
363
405
|
}
|
|
364
406
|
if (fresh && resume) {
|
|
365
|
-
throw new RuntimeError("INVALID_ARGS",
|
|
407
|
+
throw new RuntimeError("INVALID_ARGS", `${kind} does not allow --fresh and --resume together.`, `${kind}.parse`);
|
|
366
408
|
}
|
|
367
409
|
if (explicitResumeTarget && trailingTokens?.length) {
|
|
368
|
-
throw new RuntimeError("INVALID_ARGS",
|
|
410
|
+
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
411
|
}
|
|
370
412
|
return {
|
|
371
413
|
budgetMs,
|
|
@@ -376,11 +418,12 @@ export function parseAskArgs(argv) {
|
|
|
376
418
|
resumeTarget,
|
|
377
419
|
model,
|
|
378
420
|
thinkingEffort,
|
|
421
|
+
...scopeFields(readRoots, network),
|
|
379
422
|
prompt: trailingTokens?.join(" "),
|
|
380
423
|
};
|
|
381
424
|
}
|
|
382
425
|
export function parseReviewArgs(argv, commandName = "review") {
|
|
383
|
-
const parsed = parseKnownFlags(argv, new Set(["--budget", "--base", "--background", "--wait", "-m", "--model"]), commandName);
|
|
426
|
+
const parsed = parseKnownFlags(argv, new Set(["--budget", "--base", "--background", "--wait", "-m", "--model", "--read-root", "--network"]), commandName);
|
|
384
427
|
return {
|
|
385
428
|
budgetMs: parsed.budgetMs,
|
|
386
429
|
base: parsed.base,
|
|
@@ -388,112 +431,10 @@ export function parseReviewArgs(argv, commandName = "review") {
|
|
|
388
431
|
wait: parsed.wait,
|
|
389
432
|
model: parsed.model,
|
|
390
433
|
thinkingEffort: parsed.thinkingEffort,
|
|
434
|
+
...scopeFields(parsed.readRoots, parsed.network),
|
|
391
435
|
focus: parsed.trailingText,
|
|
392
436
|
};
|
|
393
437
|
}
|
|
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
438
|
export function parseJobLookupArgs(argv) {
|
|
498
439
|
let type;
|
|
499
440
|
let jobId;
|
|
@@ -541,16 +482,16 @@ function parseKnownFlags(argv, knownFlags, commandName) {
|
|
|
541
482
|
let base;
|
|
542
483
|
let background = false;
|
|
543
484
|
let wait = false;
|
|
485
|
+
const readRoots = [];
|
|
486
|
+
let network = false;
|
|
544
487
|
let trailingTokens;
|
|
545
488
|
for (let index = 0; index < argv.length; index += 1) {
|
|
546
489
|
const token = argv[index];
|
|
547
|
-
|
|
548
|
-
|
|
490
|
+
const thinking = readThinkingFlag(argv, index);
|
|
491
|
+
if (thinking) {
|
|
492
|
+
[thinkingEffort, index] = thinking;
|
|
549
493
|
continue;
|
|
550
494
|
}
|
|
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
495
|
if (token === "--") {
|
|
555
496
|
trailingTokens = argv.slice(index + 1);
|
|
556
497
|
break;
|
|
@@ -563,28 +504,13 @@ function parseKnownFlags(argv, knownFlags, commandName) {
|
|
|
563
504
|
break;
|
|
564
505
|
}
|
|
565
506
|
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;
|
|
507
|
+
case "--budget":
|
|
508
|
+
budgetMs = readBudget(argv[++index], `${commandName}.parse`, "response");
|
|
573
509
|
break;
|
|
574
|
-
}
|
|
575
510
|
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;
|
|
511
|
+
case "--model":
|
|
512
|
+
model = readModel(token, argv[++index], "args.parse");
|
|
586
513
|
break;
|
|
587
|
-
}
|
|
588
514
|
case "--base": {
|
|
589
515
|
const value = argv[index + 1];
|
|
590
516
|
if (!value) {
|
|
@@ -603,6 +529,12 @@ function parseKnownFlags(argv, knownFlags, commandName) {
|
|
|
603
529
|
case "--wait":
|
|
604
530
|
wait = true;
|
|
605
531
|
break;
|
|
532
|
+
case "--read-root":
|
|
533
|
+
readRoots.push(readRootValue(argv[++index], `${commandName}.parse`));
|
|
534
|
+
break;
|
|
535
|
+
case "--network":
|
|
536
|
+
network = true;
|
|
537
|
+
break;
|
|
606
538
|
// The early `if (!knownFlags.has(token))` gate above means we only
|
|
607
539
|
// reach this switch with tokens that ARE in knownFlags, and every
|
|
608
540
|
// member is handled above. A `default` arm would be unreachable.
|
|
@@ -613,6 +545,8 @@ function parseKnownFlags(argv, knownFlags, commandName) {
|
|
|
613
545
|
base,
|
|
614
546
|
background,
|
|
615
547
|
wait,
|
|
548
|
+
readRoots,
|
|
549
|
+
network,
|
|
616
550
|
model,
|
|
617
551
|
thinkingEffort,
|
|
618
552
|
trailingText: trailingTokens?.join(" "),
|
package/dist/paths.js
CHANGED
|
@@ -15,6 +15,14 @@ export function resolvePluginPaths(env) {
|
|
|
15
15
|
configPath: path.join(pluginRoot, "config.json"),
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* Plugin-owned kimi-code installs (`setup --install-kimi`): one directory per
|
|
20
|
+
* exact version plus a `current` symlink. Binary resolution and the installer
|
|
21
|
+
* both use this helper so they cannot disagree about the location.
|
|
22
|
+
*/
|
|
23
|
+
export function resolveKimiBinDir(env) {
|
|
24
|
+
return path.join(resolvePluginPaths(env).pluginRoot, "kimi-bin");
|
|
25
|
+
}
|
|
18
26
|
export async function ensurePluginPaths(paths) {
|
|
19
27
|
await mkdir(paths.pluginRoot, { recursive: true });
|
|
20
28
|
await mkdir(paths.logsDir, { recursive: true });
|