zelio-cli 0.0.0-stage → 0.1.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +185 -2
- package/dist/attachments.js +121 -0
- package/dist/attachments.js.map +1 -0
- package/dist/cli.js +496 -0
- package/dist/cli.js.map +1 -0
- package/dist/cloud/board.js +311 -0
- package/dist/cloud/board.js.map +1 -0
- package/dist/cloud/command.js +281 -0
- package/dist/cloud/command.js.map +1 -0
- package/dist/cloud/config.js +132 -0
- package/dist/cloud/config.js.map +1 -0
- package/dist/cloud/credentials.js +134 -0
- package/dist/cloud/credentials.js.map +1 -0
- package/dist/cloud/login.js +165 -0
- package/dist/cloud/login.js.map +1 -0
- package/dist/cloud/pair.js +110 -0
- package/dist/cloud/pair.js.map +1 -0
- package/dist/cloud/pkce.js +16 -0
- package/dist/cloud/pkce.js.map +1 -0
- package/dist/cloud/push-nudge.js +65 -0
- package/dist/cloud/push-nudge.js.map +1 -0
- package/dist/cloud/relay.js +134 -0
- package/dist/cloud/relay.js.map +1 -0
- package/dist/cloud/token.js +66 -0
- package/dist/cloud/token.js.map +1 -0
- package/dist/cloud/tunnel.js +474 -0
- package/dist/cloud/tunnel.js.map +1 -0
- package/dist/db/db.js +1741 -0
- package/dist/db/db.js.map +1 -0
- package/dist/db/lifecycle.js +146 -0
- package/dist/db/lifecycle.js.map +1 -0
- package/dist/limits.js +35 -0
- package/dist/limits.js.map +1 -0
- package/dist/metrics.js +30 -0
- package/dist/metrics.js.map +1 -0
- package/dist/orchestrator/claude-session.js +208 -0
- package/dist/orchestrator/claude-session.js.map +1 -0
- package/dist/orchestrator/codex-session.js +326 -0
- package/dist/orchestrator/codex-session.js.map +1 -0
- package/dist/orchestrator/contract.js +184 -0
- package/dist/orchestrator/contract.js.map +1 -0
- package/dist/orchestrator/explore.js +176 -0
- package/dist/orchestrator/explore.js.map +1 -0
- package/dist/orchestrator/new-task-prompt.js +51 -0
- package/dist/orchestrator/new-task-prompt.js.map +1 -0
- package/dist/orchestrator/pi-session.js +228 -0
- package/dist/orchestrator/pi-session.js.map +1 -0
- package/dist/orchestrator/prompt.js +110 -0
- package/dist/orchestrator/prompt.js.map +1 -0
- package/dist/orchestrator/research.js +178 -0
- package/dist/orchestrator/research.js.map +1 -0
- package/dist/orchestrator/runtime.js +1207 -0
- package/dist/orchestrator/runtime.js.map +1 -0
- package/dist/orchestrator/session.js +2 -0
- package/dist/orchestrator/session.js.map +1 -0
- package/dist/orchestrator/types.js +2 -0
- package/dist/orchestrator/types.js.map +1 -0
- package/dist/orchestrator/web.js +276 -0
- package/dist/orchestrator/web.js.map +1 -0
- package/dist/repo/index.js +188 -0
- package/dist/repo/index.js.map +1 -0
- package/dist/repo/instructions.js +58 -0
- package/dist/repo/instructions.js.map +1 -0
- package/dist/repo/linked-boards.js +137 -0
- package/dist/repo/linked-boards.js.map +1 -0
- package/dist/repo/project-repos.js +78 -0
- package/dist/repo/project-repos.js.map +1 -0
- package/dist/run/actions.js +257 -0
- package/dist/run/actions.js.map +1 -0
- package/dist/run/auto-review.js +102 -0
- package/dist/run/auto-review.js.map +1 -0
- package/dist/run/bash-guard.js +183 -0
- package/dist/run/bash-guard.js.map +1 -0
- package/dist/run/claude-runtime.js +270 -0
- package/dist/run/claude-runtime.js.map +1 -0
- package/dist/run/claude-stream.js +306 -0
- package/dist/run/claude-stream.js.map +1 -0
- package/dist/run/codex-client.js +202 -0
- package/dist/run/codex-client.js.map +1 -0
- package/dist/run/codex-runtime.js +460 -0
- package/dist/run/codex-runtime.js.map +1 -0
- package/dist/run/consult.js +105 -0
- package/dist/run/consult.js.map +1 -0
- package/dist/run/context.js +87 -0
- package/dist/run/context.js.map +1 -0
- package/dist/run/diff.js +238 -0
- package/dist/run/diff.js.map +1 -0
- package/dist/run/evidence.js +48 -0
- package/dist/run/evidence.js.map +1 -0
- package/dist/run/finish.js +408 -0
- package/dist/run/finish.js.map +1 -0
- package/dist/run/handoff.js +51 -0
- package/dist/run/handoff.js.map +1 -0
- package/dist/run/harness-runtime.js +31 -0
- package/dist/run/harness-runtime.js.map +1 -0
- package/dist/run/harnesses.js +273 -0
- package/dist/run/harnesses.js.map +1 -0
- package/dist/run/issue.js +79 -0
- package/dist/run/issue.js.map +1 -0
- package/dist/run/keep-awake.js +58 -0
- package/dist/run/keep-awake.js.map +1 -0
- package/dist/run/lead.js +159 -0
- package/dist/run/lead.js.map +1 -0
- package/dist/run/manager.js +2546 -0
- package/dist/run/manager.js.map +1 -0
- package/dist/run/mentions.js +35 -0
- package/dist/run/mentions.js.map +1 -0
- package/dist/run/merge-watch.js +425 -0
- package/dist/run/merge-watch.js.map +1 -0
- package/dist/run/models.js +88 -0
- package/dist/run/models.js.map +1 -0
- package/dist/run/phases.js +23 -0
- package/dist/run/phases.js.map +1 -0
- package/dist/run/pi-rpc.js +439 -0
- package/dist/run/pi-rpc.js.map +1 -0
- package/dist/run/piped-check.js +56 -0
- package/dist/run/piped-check.js.map +1 -0
- package/dist/run/pr-checks.js +67 -0
- package/dist/run/pr-checks.js.map +1 -0
- package/dist/run/pr-merge.js +121 -0
- package/dist/run/pr-merge.js.map +1 -0
- package/dist/run/profiles.js +43 -0
- package/dist/run/profiles.js.map +1 -0
- package/dist/run/prompt.js +388 -0
- package/dist/run/prompt.js.map +1 -0
- package/dist/run/pull-request.js +23 -0
- package/dist/run/pull-request.js.map +1 -0
- package/dist/run/red-check.js +130 -0
- package/dist/run/red-check.js.map +1 -0
- package/dist/run/result-tool.js +93 -0
- package/dist/run/result-tool.js.map +1 -0
- package/dist/run/result.js +113 -0
- package/dist/run/result.js.map +1 -0
- package/dist/run/retro.js +346 -0
- package/dist/run/retro.js.map +1 -0
- package/dist/run/settings.js +27 -0
- package/dist/run/settings.js.map +1 -0
- package/dist/run/skills.js +146 -0
- package/dist/run/skills.js.map +1 -0
- package/dist/run/tests-first.js +146 -0
- package/dist/run/tests-first.js.map +1 -0
- package/dist/run/thinking.js +41 -0
- package/dist/run/thinking.js.map +1 -0
- package/dist/run/types.js +2 -0
- package/dist/run/types.js.map +1 -0
- package/dist/run/watchdog.js +259 -0
- package/dist/run/watchdog.js.map +1 -0
- package/dist/run/workflow.js +277 -0
- package/dist/run/workflow.js.map +1 -0
- package/dist/run/worktree.js +354 -0
- package/dist/run/worktree.js.map +1 -0
- package/dist/server/app.js +2946 -0
- package/dist/server/app.js.map +1 -0
- package/dist/server/auth.js +93 -0
- package/dist/server/auth.js.map +1 -0
- package/dist/server/demo.js +96 -0
- package/dist/server/demo.js.map +1 -0
- package/dist/server/idempotency.js +104 -0
- package/dist/server/idempotency.js.map +1 -0
- package/dist/server/port.js +36 -0
- package/dist/server/port.js.map +1 -0
- package/dist/server/principal.js +93 -0
- package/dist/server/principal.js.map +1 -0
- package/dist/server/repo-picker.js +18 -0
- package/dist/server/repo-picker.js.map +1 -0
- package/dist/server/terminal.js +285 -0
- package/dist/server/terminal.js.map +1 -0
- package/dist/setup/components.js +98 -0
- package/dist/setup/components.js.map +1 -0
- package/dist/setup/config.js +102 -0
- package/dist/setup/config.js.map +1 -0
- package/dist/setup/ink-ui.js +189 -0
- package/dist/setup/ink-ui.js.map +1 -0
- package/dist/setup/onboarding.js +167 -0
- package/dist/setup/onboarding.js.map +1 -0
- package/dist/setup/run.js +70 -0
- package/dist/setup/run.js.map +1 -0
- package/dist/skills.js +151 -0
- package/dist/skills.js.map +1 -0
- package/dist/ticket-cli.js +157 -0
- package/dist/ticket-cli.js.map +1 -0
- package/dist/version.js +13 -0
- package/dist/version.js.map +1 -0
- package/dist/voice/index.js +69 -0
- package/dist/voice/index.js.map +1 -0
- package/dist/voice/moonshine.js +247 -0
- package/dist/voice/moonshine.js.map +1 -0
- package/dist/voice/wav.js +54 -0
- package/dist/voice/wav.js.map +1 -0
- package/dist/voice/whisper.js +491 -0
- package/dist/voice/whisper.js.map +1 -0
- package/dist/web/assets/index-CCQMrUIF.js +255 -0
- package/dist/web/assets/index-lzGSgTRQ.css +1 -0
- package/dist/web/icons/apple-touch-icon.png +0 -0
- package/dist/web/icons/icon-192.png +0 -0
- package/dist/web/icons/icon-512.png +0 -0
- package/dist/web/icons/maskable-512.png +0 -0
- package/dist/web/index.html +21 -0
- package/dist/web/manifest.webmanifest +30 -0
- package/dist/web/sw.js +185 -0
- package/package.json +96 -4
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { boundedText, fencedOr, lastJsonObject, listed, readOnlyAnswer } from "./consult.js";
|
|
2
|
+
/** Automatic reviews that may send one ticket back before the person decides. */
|
|
3
|
+
export const MAX_AUTO_REVIEWS = 2;
|
|
4
|
+
const REVIEW_TIMEOUT_MS = 180_000;
|
|
5
|
+
/** Characters kept from each earlier round's findings. */
|
|
6
|
+
const EARLIER_MAX = 2000;
|
|
7
|
+
export const AUTO_REVIEW_PROMPT = `You are the reviewer on a Zelio board. The developer says a ticket is done and the board's checks pass. Checks prove only what they test; your job is the question they cannot answer: does this change give the person what they asked for? You are read-only: you can read and search the worktree, and you never edit files, run commands, commit, or move tickets.
|
|
8
|
+
|
|
9
|
+
You get what the person asked for in their own words (the "Original user intent" line among the card's facts), the screenshots they attached, the card's goal, acceptance and out of scope, and the diff. Open every screenshot before you judge: when the person attached one, it is the clearest statement of what they want. Read the code the diff touches when you need to be sure of a behaviour. A new file appears in the diff only by name, on its "Untracked:" line: open it, because it is usually where the new behaviour lives.
|
|
10
|
+
|
|
11
|
+
Decide one thing:
|
|
12
|
+
|
|
13
|
+
- "pass": the change delivers what the person asked for and what the acceptance describes. Style, naming, and things you would have built differently are not reasons to send it back; mention them in the summary at most.
|
|
14
|
+
- "changes": something the person asked for or the acceptance requires is missing or wrong, or the change has a bug they would hit. Write findings for the developer: what is missing or wrong, where (file:line), and what done looks like, most important first, under 1500 characters.
|
|
15
|
+
|
|
16
|
+
If you reviewed this ticket before, your earlier findings are included: check each one against the new diff, and do not raise a new minor point to keep the ticket back.
|
|
17
|
+
|
|
18
|
+
Answer with exactly one fenced json block and nothing after it, one of:
|
|
19
|
+
{"verdict":"pass","summary":"..."}
|
|
20
|
+
{"verdict":"changes","findings":"..."}`;
|
|
21
|
+
/** The review of the tests alone, before any implementation exists. */
|
|
22
|
+
export const TEST_REVIEW_PROMPT = `You are the reviewer on a Zelio board. The developer has written only the tests for a ticket, before any implementation, and the board has seen them fail on the code as it is. Your job is to decide whether these tests check what the person asked for. You are read-only: you can read and search the worktree, and you never edit files, run commands, commit, or move tickets.
|
|
23
|
+
|
|
24
|
+
You get what the person asked for in their own words (the "Original user intent" line among the card's facts), the screenshots they attached, the card's goal ("Today / After / Done when"), acceptance and out of scope, and the tests. Open every screenshot before you judge.
|
|
25
|
+
|
|
26
|
+
Decide one thing:
|
|
27
|
+
|
|
28
|
+
- "pass": each part of the goal's "Done when" and each acceptance criterion, including its failure case, is checked by at least one test that would fail if that part were missing. Style, naming and test layout are not reasons to send it back.
|
|
29
|
+
- "changes": a test checks something the person did not ask for, misses part of what they asked for, or could pass without the behaviour (it asserts nothing that matters, or mocks the very thing it should check). Write findings for the developer: which part of the request is not tested, or which test is wrong and what it should check instead, under 1500 characters.
|
|
30
|
+
|
|
31
|
+
If you reviewed these tests before, your earlier findings are included: check each one, and do not raise a new minor point to hold the tests back.
|
|
32
|
+
|
|
33
|
+
Answer with exactly one fenced json block and nothing after it, one of:
|
|
34
|
+
{"verdict":"pass","summary":"..."}
|
|
35
|
+
{"verdict":"changes","findings":"..."}`;
|
|
36
|
+
/** Said to the final review when the tests were reviewed first. */
|
|
37
|
+
const TESTS_REVIEWED_NOTE = "The tests were reviewed against the person's request before the change was built, so you need not check them again. Look at what tests cannot show: does the result match the screenshots, did the change pass the tests honestly rather than by special-casing them, and did anything outside the ticket change.";
|
|
38
|
+
export function reviewPacket(input) {
|
|
39
|
+
const earlier = input.earlier.length > 0
|
|
40
|
+
? [
|
|
41
|
+
"",
|
|
42
|
+
"Your earlier findings on this ticket (the developer was sent back with them):",
|
|
43
|
+
...input.earlier.flatMap((findings, index) => [
|
|
44
|
+
`${index + 1}.`,
|
|
45
|
+
findings.length > EARLIER_MAX ? `${findings.slice(0, EARLIER_MAX)}…` : findings,
|
|
46
|
+
]),
|
|
47
|
+
]
|
|
48
|
+
: [];
|
|
49
|
+
return [
|
|
50
|
+
`Ticket ${input.ticketId}: ${input.title}`,
|
|
51
|
+
input.focus === "tests"
|
|
52
|
+
? `This is test review ${input.round} on this ticket.`
|
|
53
|
+
: `This is automatic review ${input.round} on this ticket.`,
|
|
54
|
+
...(input.testsReviewed && input.focus !== "tests" ? ["", TESTS_REVIEWED_NOTE] : []),
|
|
55
|
+
...earlier,
|
|
56
|
+
"",
|
|
57
|
+
"What the person asked for, and what the planner verified:",
|
|
58
|
+
...listed(input.context),
|
|
59
|
+
"",
|
|
60
|
+
"Screenshots the person attached (open each one):",
|
|
61
|
+
...listed(input.screenshots),
|
|
62
|
+
"",
|
|
63
|
+
"Goal:",
|
|
64
|
+
input.goal,
|
|
65
|
+
"",
|
|
66
|
+
"Out of scope:",
|
|
67
|
+
input.outOfScope,
|
|
68
|
+
"",
|
|
69
|
+
"Acceptance:",
|
|
70
|
+
input.acceptance,
|
|
71
|
+
"",
|
|
72
|
+
input.focus === "tests" ? "The tests:" : "The change:",
|
|
73
|
+
...fencedOr(input.diff, "diff", "(no changes)"),
|
|
74
|
+
].join("\n");
|
|
75
|
+
}
|
|
76
|
+
export function readReviewVerdict(text) {
|
|
77
|
+
const record = lastJsonObject(text);
|
|
78
|
+
if (!record)
|
|
79
|
+
return null;
|
|
80
|
+
if (record.verdict === "pass") {
|
|
81
|
+
const summary = boundedText(record.summary, 1, 1500);
|
|
82
|
+
return summary === null ? null : { verdict: "pass", summary };
|
|
83
|
+
}
|
|
84
|
+
if (record.verdict === "changes") {
|
|
85
|
+
const findings = boundedText(record.findings, 1, 3000);
|
|
86
|
+
return findings === null ? null : { verdict: "changes", findings };
|
|
87
|
+
}
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
/** One read-only review. Never throws; no usable answer is null. */
|
|
91
|
+
export async function consultReviewer(input, options) {
|
|
92
|
+
const text = await readOnlyAnswer(input.worktreePath, reviewPacket(input), {
|
|
93
|
+
runtime: options.runtime,
|
|
94
|
+
systemPrompt: input.focus === "tests" ? TEST_REVIEW_PROMPT : AUTO_REVIEW_PROMPT,
|
|
95
|
+
thinking: options.thinking ?? "high",
|
|
96
|
+
timeoutMs: options.timeoutMs ?? REVIEW_TIMEOUT_MS,
|
|
97
|
+
...(options.command ? { command: options.command } : {}),
|
|
98
|
+
...(options.model ? { model: options.model } : {}),
|
|
99
|
+
});
|
|
100
|
+
return text === null ? null : readReviewVerdict(text);
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=auto-review.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto-review.js","sourceRoot":"","sources":["../../src/run/auto-review.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAmD7F,iFAAiF;AACjF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAElC,MAAM,iBAAiB,GAAG,OAAO,CAAC;AAElC,0DAA0D;AAC1D,MAAM,WAAW,GAAG,IAAI,CAAC;AAEzB,MAAM,CAAC,MAAM,kBAAkB,GAAG;;;;;;;;;;;;;uCAaK,CAAC;AAExC,uEAAuE;AACvE,MAAM,CAAC,MAAM,kBAAkB,GAAG;;;;;;;;;;;;;uCAaK,CAAC;AAExC,mEAAmE;AACnE,MAAM,mBAAmB,GACvB,mTAAmT,CAAC;AAEtT,MAAM,UAAU,YAAY,CAAC,KAAkB;IAC7C,MAAM,OAAO,GACX,KAAK,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC;QACtB,CAAC,CAAC;YACE,EAAE;YACF,+EAA+E;YAC/E,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE,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OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACnD,CAAC,CAAC;IACH,OAAO,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;AACxD,CAAC"}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { stripWorktreeCd } from "./actions.js";
|
|
2
|
+
/**
|
|
3
|
+
* The shell file-readers a developer run must not spend a turn on.
|
|
4
|
+
*
|
|
5
|
+
* The prompt already says to read and search with the tools; a prompt is a
|
|
6
|
+
* suggestion, and an agent that pipes `sed` over a file costs a trace row with
|
|
7
|
+
* the whole file inside it. `read`, `grep`, `find` and `ls` are on the run's
|
|
8
|
+
* tool allowlist, so every one of these names has a cheaper, bounded answer.
|
|
9
|
+
*/
|
|
10
|
+
export const SHELL_READERS = [
|
|
11
|
+
"cat",
|
|
12
|
+
"find",
|
|
13
|
+
"grep",
|
|
14
|
+
"head",
|
|
15
|
+
"ls",
|
|
16
|
+
"rg",
|
|
17
|
+
"sed",
|
|
18
|
+
"tail",
|
|
19
|
+
"wc",
|
|
20
|
+
];
|
|
21
|
+
/** The extension file Pi loads for a developer run. */
|
|
22
|
+
export const BASH_GUARD_EXTENSION = new URL("./bash-guard.js", import.meta.url);
|
|
23
|
+
const READER_NAME = new Set(SHELL_READERS);
|
|
24
|
+
/**
|
|
25
|
+
* The refusal is the agent's next instruction, not a scolding: name the tools
|
|
26
|
+
* that do the job and the run recovers on its next call.
|
|
27
|
+
*/
|
|
28
|
+
function bashGuardRefusal(reader) {
|
|
29
|
+
return (`zelio: \`${reader}\` is blocked in the developer bash tool. ` +
|
|
30
|
+
"Use the read tool for a file body, grep to search the repo, find to locate a path, and ls to list a directory.");
|
|
31
|
+
}
|
|
32
|
+
const QUOTES = new Set(["'", '"']);
|
|
33
|
+
/**
|
|
34
|
+
* Split a command line into the simple commands it runs. `&&`, `|`, `;` and a
|
|
35
|
+
* newline are four ways of putting two commands on one line, and each half is
|
|
36
|
+
* checked on its own: `cd src && grep -rn foo .` reads.
|
|
37
|
+
*
|
|
38
|
+
* Quotes are tracked so an operator or a reader name inside an argument stays
|
|
39
|
+
* text — `git commit -m "grep fix"` is a commit, not a search.
|
|
40
|
+
*/
|
|
41
|
+
function commandSegments(command) {
|
|
42
|
+
const segments = [];
|
|
43
|
+
let current = "";
|
|
44
|
+
let quote = "";
|
|
45
|
+
for (let index = 0; index < command.length; index += 1) {
|
|
46
|
+
const char = command[index] ?? "";
|
|
47
|
+
if (quote) {
|
|
48
|
+
current += char;
|
|
49
|
+
if (char === quote)
|
|
50
|
+
quote = "";
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
if (QUOTES.has(char)) {
|
|
54
|
+
quote = char;
|
|
55
|
+
current += char;
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
if (char === "\\") {
|
|
59
|
+
current += char + (command[index + 1] ?? "");
|
|
60
|
+
index += 1;
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
if (char === ";" || char === "&" || char === "|" || char === "\n") {
|
|
64
|
+
segments.push(current);
|
|
65
|
+
current = "";
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
current += char;
|
|
69
|
+
}
|
|
70
|
+
segments.push(current);
|
|
71
|
+
return segments;
|
|
72
|
+
}
|
|
73
|
+
/** The words of one simple command, unquoted, so `"grep"` is the word `grep`. */
|
|
74
|
+
function words(segment) {
|
|
75
|
+
const parts = [];
|
|
76
|
+
let current = "";
|
|
77
|
+
let quote = "";
|
|
78
|
+
const flush = () => {
|
|
79
|
+
if (!current)
|
|
80
|
+
return;
|
|
81
|
+
parts.push(current);
|
|
82
|
+
current = "";
|
|
83
|
+
};
|
|
84
|
+
for (let index = 0; index < segment.length; index += 1) {
|
|
85
|
+
const char = segment[index] ?? "";
|
|
86
|
+
if (quote) {
|
|
87
|
+
current += char;
|
|
88
|
+
if (char === quote)
|
|
89
|
+
quote = "";
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
if (QUOTES.has(char)) {
|
|
93
|
+
quote = char;
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
if (/\s/.test(char)) {
|
|
97
|
+
flush();
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
current += char;
|
|
101
|
+
}
|
|
102
|
+
flush();
|
|
103
|
+
return parts;
|
|
104
|
+
}
|
|
105
|
+
/** `FOO=bar grep …` still runs grep, and the assignment is not the command. */
|
|
106
|
+
const ASSIGNMENT = /^[A-Za-z_][A-Za-z0-9_]*=/;
|
|
107
|
+
/** Words that only introduce the command after them. */
|
|
108
|
+
const LEAD_INS = new Set([
|
|
109
|
+
"sudo",
|
|
110
|
+
"command",
|
|
111
|
+
"builtin",
|
|
112
|
+
"exec",
|
|
113
|
+
"env",
|
|
114
|
+
"nohup",
|
|
115
|
+
"time",
|
|
116
|
+
"then",
|
|
117
|
+
"do",
|
|
118
|
+
"else",
|
|
119
|
+
"!",
|
|
120
|
+
"{",
|
|
121
|
+
"(",
|
|
122
|
+
]);
|
|
123
|
+
/** The command a segment runs, once assignments and lead-ins are stepped over. */
|
|
124
|
+
function commandWord(segment) {
|
|
125
|
+
for (const part of words(segment)) {
|
|
126
|
+
if (ASSIGNMENT.test(part) || LEAD_INS.has(part))
|
|
127
|
+
continue;
|
|
128
|
+
return part;
|
|
129
|
+
}
|
|
130
|
+
return "";
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* The refusal for a bash command that shell-reads, or null when the command is
|
|
134
|
+
* something else.
|
|
135
|
+
*
|
|
136
|
+
* Only a bare reader name in command position counts: a reader run from a path,
|
|
137
|
+
* or hidden behind `awk`, `rg`, `xargs` or `bash -c`, is a wrapped read and out
|
|
138
|
+
* of scope.
|
|
139
|
+
*
|
|
140
|
+
* The judgement is made here, on the command the agent wrote, and not by putting
|
|
141
|
+
* shims on the run's `PATH`. Shims look like the stronger refusal and are not:
|
|
142
|
+
* every process the run starts inherits that `PATH`, and the launchers the run
|
|
143
|
+
* depends on are themselves shell scripts that read through these very names —
|
|
144
|
+
* pnpm's own shim computes its install path with `sed`, so `pnpm check` died
|
|
145
|
+
* before it ran. A run that cannot run its check never reaches its status.
|
|
146
|
+
*/
|
|
147
|
+
export function bashGuardReason(command) {
|
|
148
|
+
for (const segment of commandSegments(stripWorktreeCd(command))) {
|
|
149
|
+
const word = commandWord(segment);
|
|
150
|
+
if (word && READER_NAME.has(word))
|
|
151
|
+
return bashGuardRefusal(word);
|
|
152
|
+
}
|
|
153
|
+
return null;
|
|
154
|
+
}
|
|
155
|
+
/** The refusal text the guard returns, as the tool output that reports it. */
|
|
156
|
+
const REFUSAL_OUTPUT = /^zelio: `([^`]+)` is blocked in the developer bash tool\./;
|
|
157
|
+
/**
|
|
158
|
+
* The reader a guard refusal names, or null when the output is anything else.
|
|
159
|
+
* Used to recognise a blocked call in a finished run, so the board can count
|
|
160
|
+
* guard blocks without the guard having to report them separately.
|
|
161
|
+
*/
|
|
162
|
+
export function bashGuardBlockedReader(output) {
|
|
163
|
+
const match = REFUSAL_OUTPUT.exec(output?.trim() ?? "");
|
|
164
|
+
return match?.[1] ?? null;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Pi loads this as an extension before a developer run starts. The hook fires
|
|
168
|
+
* before the bash tool executes, so a shell read is blocked at the tool layer
|
|
169
|
+
* instead of being executed and then hidden from the board's trace.
|
|
170
|
+
*/
|
|
171
|
+
export function registerBashGuard(pi) {
|
|
172
|
+
pi.on("tool_call", async (event) => {
|
|
173
|
+
if (event.toolName !== "bash")
|
|
174
|
+
return undefined;
|
|
175
|
+
const command = event.input?.command;
|
|
176
|
+
if (typeof command !== "string")
|
|
177
|
+
return undefined;
|
|
178
|
+
const reason = bashGuardReason(command);
|
|
179
|
+
return reason ? { block: true, reason } : undefined;
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
export default registerBashGuard;
|
|
183
|
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,CAAC;IACnE,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,8EAA8E;AAC9E,MAAM,cAAc,GAAG,2DAA2D,CAAC;AAEnF;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CAAC,MAAiC;IACtE,MAAM,KAAK,GAAG,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IACxD,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC;AAC5B,CAAC;AAaD;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,EAAyB;IACzD,EAAE,CAAC,EAAE,CAAC,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;QACjC,IAAI,KAAK,CAAC,QAAQ,KAAK,MAAM;YAAE,OAAO,SAAS,CAAC;QAChD,MAAM,OAAO,GAAG,KAAK,CAAC,KAAK,EAAE,OAAO,CAAC;QACrC,IAAI,OAAO,OAAO,KAAK,QAAQ;YAAE,OAAO,SAAS,CAAC;QAClD,MAAM,MAAM,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;QACxC,OAAO,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;IACtD,CAAC,CAAC,CAAC;AACL,CAAC;AAED,eAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { existsSync, readdirSync } from "node:fs";
|
|
3
|
+
import { homedir } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { ClaudeStreamMapper, claudeArgs, claudeToolNames, userMessageLine, } from "./claude-stream.js";
|
|
6
|
+
import { DEVELOPER_TOOLS } from "./pi-rpc.js";
|
|
7
|
+
import { CODING_AGENT_PROMPT } from "./prompt.js";
|
|
8
|
+
/** A read-only job's whole budget; for a developer, how long one turn may stay silent. */
|
|
9
|
+
const DEFAULT_TIMEOUT_MS = 30 * 60_000;
|
|
10
|
+
const KILL_GRACE_MS = 2_000;
|
|
11
|
+
const STDERR_MAX = 4_000;
|
|
12
|
+
const READ_ONLY_TOOLS = ["read", "grep", "find", "ls"];
|
|
13
|
+
const WRITE_TOOLS = new Set(["bash", "edit", "write"]);
|
|
14
|
+
/**
|
|
15
|
+
* Whether a claude session transcript already exists under the config dir. The
|
|
16
|
+
* CLI refuses `--session-id` for an existing id and `--resume` for a missing one,
|
|
17
|
+
* so this decides which flag a run gets.
|
|
18
|
+
*/
|
|
19
|
+
export function claudeSessionExists(id, configDir) {
|
|
20
|
+
if (id === "" || /[\\/]/.test(id))
|
|
21
|
+
return false;
|
|
22
|
+
try {
|
|
23
|
+
const projects = join(configDir, "projects");
|
|
24
|
+
return readdirSync(projects).some((dir) => existsSync(join(projects, dir, `${id}.jsonl`)));
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
class EventQueue {
|
|
31
|
+
items = [];
|
|
32
|
+
wake;
|
|
33
|
+
done = false;
|
|
34
|
+
events = this.iterate();
|
|
35
|
+
push(event) {
|
|
36
|
+
this.items.push(event);
|
|
37
|
+
const wake = this.wake;
|
|
38
|
+
this.wake = undefined;
|
|
39
|
+
wake?.();
|
|
40
|
+
}
|
|
41
|
+
finish() {
|
|
42
|
+
this.done = true;
|
|
43
|
+
const wake = this.wake;
|
|
44
|
+
this.wake = undefined;
|
|
45
|
+
wake?.();
|
|
46
|
+
}
|
|
47
|
+
async *iterate() {
|
|
48
|
+
for (;;) {
|
|
49
|
+
if (this.items.length === 0) {
|
|
50
|
+
if (this.done)
|
|
51
|
+
return;
|
|
52
|
+
// oxlint-disable-next-line no-await-in-loop
|
|
53
|
+
await new Promise((resolve) => {
|
|
54
|
+
this.wake = resolve;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
const event = this.items.shift();
|
|
58
|
+
if (!event)
|
|
59
|
+
continue;
|
|
60
|
+
yield event;
|
|
61
|
+
if (event.type === "exit")
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Claude Code over stream-json. One process per ticket run; the prompt and any
|
|
68
|
+
* follow-up turns go in on stdin, and the stream-json output is mapped to the
|
|
69
|
+
* board's events. `shellGuard` and `reporting` are not supported on this
|
|
70
|
+
* harness: the board runs its own gate, as it does for codex.
|
|
71
|
+
*/
|
|
72
|
+
export class ClaudeRuntime {
|
|
73
|
+
command;
|
|
74
|
+
fixedCommand;
|
|
75
|
+
timeoutMs;
|
|
76
|
+
configDir;
|
|
77
|
+
constructor(options = {}) {
|
|
78
|
+
this.command = options.command?.trim() || "claude";
|
|
79
|
+
this.fixedCommand = options.command?.trim() || undefined;
|
|
80
|
+
this.timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
81
|
+
this.configDir =
|
|
82
|
+
options.configDir ?? process.env.CLAUDE_CONFIG_DIR ?? join(homedir(), ".claude");
|
|
83
|
+
}
|
|
84
|
+
spawn(cwd, prompt, options = {}) {
|
|
85
|
+
const queue = new EventQueue();
|
|
86
|
+
const base = options.tools ?? (options.readOnly ? READ_ONLY_TOOLS : DEVELOPER_TOOLS);
|
|
87
|
+
const tools = options.readOnly ? base.filter((tool) => !WRITE_TOOLS.has(tool)) : base;
|
|
88
|
+
const sessionId = options.sessionId?.trim() || undefined;
|
|
89
|
+
const args = claudeArgs({
|
|
90
|
+
model: options.model?.trim() || undefined,
|
|
91
|
+
thinking: options.thinking,
|
|
92
|
+
sessionId,
|
|
93
|
+
resume: sessionId !== undefined && claudeSessionExists(sessionId, this.configDir),
|
|
94
|
+
systemPrompt: options.systemPrompt ?? CODING_AGENT_PROMPT,
|
|
95
|
+
tools: claudeToolNames(tools),
|
|
96
|
+
persist: sessionId !== undefined,
|
|
97
|
+
});
|
|
98
|
+
const command = this.fixedCommand || options.command?.trim() || this.command;
|
|
99
|
+
const mapper = new ClaudeStreamMapper();
|
|
100
|
+
let aborted = false;
|
|
101
|
+
let finished = false;
|
|
102
|
+
let timedOut = false;
|
|
103
|
+
let inputEnded = false;
|
|
104
|
+
let stdoutBuffer = "";
|
|
105
|
+
let stderr = "";
|
|
106
|
+
let killTimer;
|
|
107
|
+
let timer;
|
|
108
|
+
const child = spawn(command, args, {
|
|
109
|
+
cwd,
|
|
110
|
+
stdio: "pipe",
|
|
111
|
+
env: { ...process.env, ...options.env },
|
|
112
|
+
});
|
|
113
|
+
const finish = (event) => {
|
|
114
|
+
if (finished)
|
|
115
|
+
return;
|
|
116
|
+
finished = true;
|
|
117
|
+
clearTimeout(timer);
|
|
118
|
+
timer = undefined;
|
|
119
|
+
queue.push(event);
|
|
120
|
+
queue.finish();
|
|
121
|
+
};
|
|
122
|
+
const endInput = () => {
|
|
123
|
+
if (inputEnded)
|
|
124
|
+
return;
|
|
125
|
+
inputEnded = true;
|
|
126
|
+
child.stdin.end();
|
|
127
|
+
// A child that ignores a closed stdin must not outlive the run until the
|
|
128
|
+
// 30-minute timeout; close() clears this when it exits on its own.
|
|
129
|
+
killTimer ??= setTimeout(() => child.kill("SIGKILL"), KILL_GRACE_MS);
|
|
130
|
+
};
|
|
131
|
+
// SIGINT first; SIGKILL only if the child is still alive after the grace.
|
|
132
|
+
const terminate = () => {
|
|
133
|
+
endInput();
|
|
134
|
+
child.kill("SIGINT");
|
|
135
|
+
};
|
|
136
|
+
const interrupt = () => {
|
|
137
|
+
terminate();
|
|
138
|
+
finish({ type: "exit", code: null, stderr: "", timedOut, spawnError: false });
|
|
139
|
+
};
|
|
140
|
+
// Read-only jobs keep one wall-clock budget. A developer times out only when
|
|
141
|
+
// its active turn goes silent: the clock stops while the board runs its
|
|
142
|
+
// checks between turns, and the next prompt starts it again.
|
|
143
|
+
const startClock = () => {
|
|
144
|
+
if (finished || (options.readOnly && timer))
|
|
145
|
+
return;
|
|
146
|
+
clearTimeout(timer);
|
|
147
|
+
timer = setTimeout(() => {
|
|
148
|
+
timedOut = true;
|
|
149
|
+
aborted = true;
|
|
150
|
+
interrupt();
|
|
151
|
+
}, this.timeoutMs);
|
|
152
|
+
};
|
|
153
|
+
const pauseClock = () => {
|
|
154
|
+
if (options.readOnly)
|
|
155
|
+
return;
|
|
156
|
+
clearTimeout(timer);
|
|
157
|
+
timer = undefined;
|
|
158
|
+
};
|
|
159
|
+
startClock();
|
|
160
|
+
const writeLine = (line) => {
|
|
161
|
+
if (inputEnded || !child.stdin.writable)
|
|
162
|
+
return false;
|
|
163
|
+
child.stdin.write(line);
|
|
164
|
+
return true;
|
|
165
|
+
};
|
|
166
|
+
const sendUser = (text) => {
|
|
167
|
+
if (!writeLine(userMessageLine(text)))
|
|
168
|
+
return false;
|
|
169
|
+
startClock();
|
|
170
|
+
return true;
|
|
171
|
+
};
|
|
172
|
+
const onSettled = () => {
|
|
173
|
+
const next = options.continuationPrompt;
|
|
174
|
+
if (!next) {
|
|
175
|
+
endInput();
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
void Promise.resolve()
|
|
179
|
+
.then(() => next())
|
|
180
|
+
.catch(() => undefined)
|
|
181
|
+
.then((answer) => {
|
|
182
|
+
if (finished || aborted)
|
|
183
|
+
return;
|
|
184
|
+
if (typeof answer === "string" && answer.trim() !== "") {
|
|
185
|
+
sendUser(answer);
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
endInput();
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
};
|
|
192
|
+
const handleLine = (line) => {
|
|
193
|
+
if (!options.readOnly)
|
|
194
|
+
timer?.refresh();
|
|
195
|
+
for (const event of mapper.push(line)) {
|
|
196
|
+
if (finished)
|
|
197
|
+
return;
|
|
198
|
+
if (event.type === "exit") {
|
|
199
|
+
terminate();
|
|
200
|
+
finish({
|
|
201
|
+
type: "exit",
|
|
202
|
+
code: event.code,
|
|
203
|
+
stderr: event.stderr,
|
|
204
|
+
timedOut,
|
|
205
|
+
spawnError: false,
|
|
206
|
+
});
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
queue.push(event);
|
|
210
|
+
if (event.type === "settled") {
|
|
211
|
+
pauseClock();
|
|
212
|
+
onSettled();
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
child.stdin.on("error", () => undefined);
|
|
217
|
+
child.stdout.setEncoding("utf8");
|
|
218
|
+
child.stdout.on("data", (chunk) => {
|
|
219
|
+
stdoutBuffer += chunk;
|
|
220
|
+
let newline = stdoutBuffer.indexOf("\n");
|
|
221
|
+
while (newline !== -1) {
|
|
222
|
+
const line = stdoutBuffer.slice(0, newline);
|
|
223
|
+
stdoutBuffer = stdoutBuffer.slice(newline + 1);
|
|
224
|
+
handleLine(line);
|
|
225
|
+
if (finished)
|
|
226
|
+
return;
|
|
227
|
+
newline = stdoutBuffer.indexOf("\n");
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
child.stderr.setEncoding("utf8");
|
|
231
|
+
child.stderr.on("data", (chunk) => {
|
|
232
|
+
stderr = (stderr + chunk).slice(-STDERR_MAX);
|
|
233
|
+
});
|
|
234
|
+
child.on("error", (error) => {
|
|
235
|
+
finish({
|
|
236
|
+
type: "exit",
|
|
237
|
+
code: null,
|
|
238
|
+
stderr: error.message,
|
|
239
|
+
timedOut,
|
|
240
|
+
spawnError: child.pid === undefined,
|
|
241
|
+
});
|
|
242
|
+
});
|
|
243
|
+
child.on("close", (code) => {
|
|
244
|
+
clearTimeout(killTimer);
|
|
245
|
+
if (!finished && stdoutBuffer.trim() !== "")
|
|
246
|
+
handleLine(stdoutBuffer);
|
|
247
|
+
stdoutBuffer = "";
|
|
248
|
+
finish({ type: "exit", code, stderr: stderr.trim(), timedOut, spawnError: false });
|
|
249
|
+
});
|
|
250
|
+
sendUser(prompt);
|
|
251
|
+
return {
|
|
252
|
+
events: queue.events,
|
|
253
|
+
get aborted() {
|
|
254
|
+
return aborted;
|
|
255
|
+
},
|
|
256
|
+
abort: () => {
|
|
257
|
+
if (finished || aborted)
|
|
258
|
+
return;
|
|
259
|
+
aborted = true;
|
|
260
|
+
interrupt();
|
|
261
|
+
},
|
|
262
|
+
sendMessage: async (text) => {
|
|
263
|
+
if (finished || aborted || !text.trim())
|
|
264
|
+
return false;
|
|
265
|
+
return sendUser(text);
|
|
266
|
+
},
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
//# sourceMappingURL=claude-runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claude-runtime.js","sourceRoot":"","sources":["../../src/run/claude-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EACL,kBAAkB,EAClB,UAAU,EACV,eAAe,EACf,eAAe,GAChB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAGlD,0FAA0F;AAC1F,MAAM,kBAAkB,GAAG,EAAE,GAAG,MAAM,CAAC;AACvC,MAAM,aAAa,GAAG,KAAK,CAAC;AAC5B,MAAM,UAAU,GAAG,KAAK,CAAC;AACzB,MAAM,eAAe,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,CAAU,CAAC;AAChE,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAQvD;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,EAAU,EAAE,SAAiB;IAC/D,IAAI,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