@alexwkleung/reika 0.3.0 → 0.4.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/dist/agent/loop.js +1 -0
- package/dist/check/typecheck.js +115 -7
- package/dist/cli.js +3 -0
- package/dist/headless.js +27 -2
- package/dist/headlessargs.js +12 -0
- package/dist/tools/_sandbox.js +42 -3
- package/dist/tools/bash.js +11 -27
- package/package.json +1 -1
- package/skills/review.md +8 -2
package/dist/agent/loop.js
CHANGED
package/dist/check/typecheck.js
CHANGED
|
@@ -3,6 +3,7 @@ import { createHash } from 'node:crypto';
|
|
|
3
3
|
import { stat } from 'node:fs/promises';
|
|
4
4
|
import { tmpdir } from 'node:os';
|
|
5
5
|
import { dirname, isAbsolute, join, relative, resolve } from 'node:path';
|
|
6
|
+
import { SANDBOX_EXEC_ERROR_PREFIX, sandboxArgv, sandboxPlan } from '../tools/_sandbox.js';
|
|
6
7
|
const DEFAULT_TIMEOUT_MS = 30_000;
|
|
7
8
|
// One tsc cascade can be hundreds of lines; a 16k-window model can't absorb that. Cap what the
|
|
8
9
|
// model sees and tell it how many were elided rather than truncating silently.
|
|
@@ -156,7 +157,8 @@ export async function runTypecheck(cwd, opts = {}) {
|
|
|
156
157
|
const buildInfo = opts.tsBuildInfoFile ?? defaultBuildInfoFile(cwd);
|
|
157
158
|
// `--incremental` with an explicit `--tsBuildInfoFile` is what makes the re-check cheap and is
|
|
158
159
|
// accepted alongside `--noEmit` across TS versions. `--pretty false` forces the stable
|
|
159
|
-
// one-line-per-diagnostic format regardless of TTY, which DIAG_RE parses.
|
|
160
|
+
// one-line-per-diagnostic format regardless of TTY, which DIAG_RE parses. One list, used by both
|
|
161
|
+
// spawns below, so the confined and unconfined runs cannot drift apart.
|
|
160
162
|
const args = [
|
|
161
163
|
'--noEmit',
|
|
162
164
|
'--incremental',
|
|
@@ -167,34 +169,124 @@ export async function runTypecheck(cwd, opts = {}) {
|
|
|
167
169
|
'-p',
|
|
168
170
|
tsconfig,
|
|
169
171
|
];
|
|
170
|
-
|
|
172
|
+
const timeoutMs = opts.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
173
|
+
// Route the project-local `tsc` through the sandbox wrapper so it runs inside confinement — the
|
|
174
|
+
// same profile model-run bash gets (writes confined to cwd, temp and cache dirs, network denied;
|
|
175
|
+
// the temp allow is what lets `--tsBuildInfoFile` land in os.tmpdir()). The wrapper takes a shell
|
|
176
|
+
// command, so the binary has to be part of the line and both it and every argument must be
|
|
177
|
+
// quoted: a bare flag list would be run *as* the command (`/bin/sh -c "--noEmit …"` is an
|
|
178
|
+
// invalid option, exit 2), and tsc would never start — indistinguishable from a clean check, and
|
|
179
|
+
// so a silently dead gate. When the sandbox is unavailable, fall back to the direct spawn
|
|
180
|
+
// (fail-open), which is the gate's standing design.
|
|
181
|
+
//
|
|
182
|
+
// Once a plan exists there is no unconfined retry, even when the wrapper looks like it refused:
|
|
183
|
+
// that verdict is read off the output of the process we just ran, and a planted tsc can print the
|
|
184
|
+
// wrapper's line and exit 65 as easily as sandbox-exec can. A retry would hand it exactly the
|
|
185
|
+
// unconfined run this exists to prevent, so a refusal disables the gate for the turn instead.
|
|
186
|
+
if (opts.sandbox !== false) {
|
|
187
|
+
const plan = sandboxPlan(cwd, { network: false });
|
|
188
|
+
if ('args' in plan) {
|
|
189
|
+
const argv = sandboxArgv(plan, [tsc, ...args].map(shellQuote).join(' '));
|
|
190
|
+
if (argv)
|
|
191
|
+
return runTscProcess(argv.cmd, argv.args, cwd, timeoutMs, opts.signal, true);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
return runTscProcess(tsc, args, cwd, timeoutMs, opts.signal);
|
|
195
|
+
}
|
|
196
|
+
// Whether the sandbox wrapper itself refused to run the command: nonzero exit, the wrapper's own
|
|
197
|
+
// line in the output, and nothing that parses as a diagnostic (so a tsc that really ran — even one
|
|
198
|
+
// whose errors the DIAG_RE cannot parse — is never mistaken for a refusal). A profile the OS
|
|
199
|
+
// rejects, or a param without its `-D` binding, exits 65 having run nothing; `sandboxPlan` probes
|
|
200
|
+
// the real argv for that before tsc runs (#738), so this is the backstop. Undetected, the empty
|
|
201
|
+
// output parses to zero diagnostics and masquerades as a green check. Any nonzero exit in this shape
|
|
202
|
+
// counts rather than bash.ts's exit-65 pin: an apply failure (71) leaves the same nothing-ran
|
|
203
|
+
// signature, and the prefix is required there too. Spoofable by the process inside, which is why a
|
|
204
|
+
// refusal only ever resolves "didn't run" and never buys a retry: the worst a fake one can do is
|
|
205
|
+
// switch the gate off for a turn.
|
|
206
|
+
export function sandboxRefused(code, out) {
|
|
207
|
+
return (code !== null &&
|
|
208
|
+
code !== 0 &&
|
|
209
|
+
out.includes(SANDBOX_EXEC_ERROR_PREFIX) &&
|
|
210
|
+
parseTscOutput(out).length === 0);
|
|
171
211
|
}
|
|
172
|
-
|
|
212
|
+
// Single-quote one argument for the `/bin/sh -c` line `sandboxArgv` builds. Every path interpolated
|
|
213
|
+
// into that line is user-controlled — a cwd, tsconfig, or tsbuildinfo path may contain spaces or
|
|
214
|
+
// quotes — so concatenating bare would split one argument into several or let a quote re-parse the
|
|
215
|
+
// rest. `'\''` is the only way to carry a single quote inside a single-quoted string. Exported for
|
|
216
|
+
// tests: the quoting is the security boundary here, and a round-trip through a real /bin/sh is the
|
|
217
|
+
// only proof it holds.
|
|
218
|
+
export function shellQuote(arg) {
|
|
219
|
+
return `'${arg.replace(/'/g, "'\\''")}'`;
|
|
220
|
+
}
|
|
221
|
+
// What `/bin/sh` exits with when it could not run the command it was given: 126 found but not
|
|
222
|
+
// executable (a lost exec bit), 127 not found (a shebang interpreter missing from PATH). The direct
|
|
223
|
+
// spawn reports both as a spawn error; behind the wrapper they are ordinary exits with no tsc
|
|
224
|
+
// output, which would otherwise parse as zero diagnostics — a clean check from a tsc that never ran.
|
|
225
|
+
const SHELL_COULD_NOT_RUN = new Set([126, 127]);
|
|
226
|
+
// The wrapper is `sandbox-exec` → `/bin/sh` → tsc, so a kill aimed at the child pid can stop short
|
|
227
|
+
// of tsc (a shim that runs node without exec). Each spawn gets its own process group and every
|
|
228
|
+
// kill goes to the group, as bash.ts does (#408); the exit sweep covers a reika exit mid-check,
|
|
229
|
+
// since a group of its own is one the terminal's hangup no longer reaches.
|
|
230
|
+
const liveGroups = new Set();
|
|
231
|
+
process.once('exit', () => {
|
|
232
|
+
for (const pid of liveGroups) {
|
|
233
|
+
try {
|
|
234
|
+
process.kill(-pid, 'SIGKILL');
|
|
235
|
+
}
|
|
236
|
+
catch {
|
|
237
|
+
// Already gone.
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
// Exported for tests: the refusal branch is this gate's fail-open boundary — the case that used to
|
|
242
|
+
// resolve as a green check — and a real sandbox-exec refusing to load a profile is the only
|
|
243
|
+
// faithful way to drive it.
|
|
244
|
+
export function runTscProcess(bin, args, cwd, timeoutMs, signal, viaSandboxWrapper = false) {
|
|
173
245
|
return new Promise(resolve => {
|
|
174
246
|
let child;
|
|
175
247
|
try {
|
|
176
|
-
child = spawn(bin, args, { cwd });
|
|
248
|
+
child = spawn(bin, args, { cwd, detached: process.platform !== 'win32' });
|
|
177
249
|
}
|
|
178
250
|
catch (e) {
|
|
179
251
|
resolve({ ran: false, reason: `spawn failed: ${e.message}` });
|
|
180
252
|
return;
|
|
181
253
|
}
|
|
254
|
+
const pid = child.pid;
|
|
255
|
+
if (pid != null && process.platform !== 'win32')
|
|
256
|
+
liveGroups.add(pid);
|
|
257
|
+
const killTree = () => {
|
|
258
|
+
try {
|
|
259
|
+
if (pid == null || process.platform === 'win32')
|
|
260
|
+
throw new Error('no group');
|
|
261
|
+
process.kill(-pid, 'SIGKILL');
|
|
262
|
+
}
|
|
263
|
+
catch {
|
|
264
|
+
try {
|
|
265
|
+
child.kill('SIGKILL');
|
|
266
|
+
}
|
|
267
|
+
catch {
|
|
268
|
+
// Already gone.
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
};
|
|
182
272
|
let out = '';
|
|
183
273
|
let settled = false;
|
|
184
274
|
const finish = (r) => {
|
|
185
275
|
if (settled)
|
|
186
276
|
return;
|
|
187
277
|
settled = true;
|
|
278
|
+
if (pid != null)
|
|
279
|
+
liveGroups.delete(pid);
|
|
188
280
|
clearTimeout(timer);
|
|
189
281
|
signal?.removeEventListener('abort', onAbort);
|
|
190
282
|
resolve(r);
|
|
191
283
|
};
|
|
192
284
|
const timer = setTimeout(() => {
|
|
193
|
-
|
|
285
|
+
killTree();
|
|
194
286
|
finish({ ran: false, reason: `timed out after ${timeoutMs}ms` });
|
|
195
287
|
}, timeoutMs);
|
|
196
288
|
const onAbort = () => {
|
|
197
|
-
|
|
289
|
+
killTree();
|
|
198
290
|
finish({ ran: false, reason: 'aborted' });
|
|
199
291
|
};
|
|
200
292
|
signal?.addEventListener('abort', onAbort, { once: true });
|
|
@@ -203,6 +295,22 @@ function runTscProcess(bin, args, cwd, timeoutMs, signal) {
|
|
|
203
295
|
child.stdout?.on('data', d => (out += d.toString()));
|
|
204
296
|
child.stderr?.on('data', d => (out += d.toString()));
|
|
205
297
|
child.on('error', e => finish({ ran: false, reason: `process error: ${e.message}` }));
|
|
206
|
-
child.on('close',
|
|
298
|
+
child.on('close', code => {
|
|
299
|
+
// Only the wrapper spawn gets refusal semantics: a nonzero exit there with the wrapper's own
|
|
300
|
+
// line and no tsc output means the command never ran — read as a clean check, that outcome is
|
|
301
|
+
// the silently-dead gate (see sandboxRefused above).
|
|
302
|
+
if (viaSandboxWrapper && sandboxRefused(code, out)) {
|
|
303
|
+
finish({ ran: false, reason: `sandbox wrapper refused to run tsc (exit ${code})` });
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
if (viaSandboxWrapper &&
|
|
307
|
+
code !== null &&
|
|
308
|
+
SHELL_COULD_NOT_RUN.has(code) &&
|
|
309
|
+
parseTscOutput(out).length === 0) {
|
|
310
|
+
finish({ ran: false, reason: `shell could not run tsc (exit ${code})` });
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
finish({ ran: true, diagnostics: parseTscOutput(out) });
|
|
314
|
+
});
|
|
207
315
|
});
|
|
208
316
|
}
|
package/dist/cli.js
CHANGED
|
@@ -3,6 +3,9 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
3
3
|
import { sweepStaleSpills } from './tools/_spill.js';
|
|
4
4
|
import { USAGE, parseHeadlessArgs } from './headlessargs.js';
|
|
5
5
|
import { VERSION } from './version.js';
|
|
6
|
+
// Lowercase like the command: ps/top/Activity Monitor otherwise list every session as `node`, and
|
|
7
|
+
// pgrep/pkill match case-sensitively.
|
|
8
|
+
process.title = 'reika';
|
|
6
9
|
// Spill directories are removed on a normal exit, but SIGHUP (closing the terminal window),
|
|
7
10
|
// SIGTERM, SIGKILL and hard crashes never reach that handler (#224). The sweep is the cleanup
|
|
8
11
|
// path for those, and it belongs here rather than in a React effect: it is a property of the
|
package/dist/headless.js
CHANGED
|
@@ -54,6 +54,28 @@ export async function buildHeadlessInput(prompt, config, bundle, mode) {
|
|
|
54
54
|
}
|
|
55
55
|
return { modelText, notices };
|
|
56
56
|
}
|
|
57
|
+
// `--profile` is the user naming the profile outright, so it outranks a launch REIKA_MODEL and the
|
|
58
|
+
// mode's own model alike (#710). Matched case-insensitively like /model; a name no profile defines
|
|
59
|
+
// keeps the run going on the profile it would have used anyway, and says so — passed through raw,
|
|
60
|
+
// it reached the session as a profile nothing defines and lost the default's probed window.
|
|
61
|
+
export function headlessProfile(config, mode, named) {
|
|
62
|
+
const fallback = startProfiles(config, mode, {}).profile;
|
|
63
|
+
if (named === undefined)
|
|
64
|
+
return { profile: fallback };
|
|
65
|
+
const key = named.toLowerCase();
|
|
66
|
+
if (config.profiles[key])
|
|
67
|
+
return { profile: key };
|
|
68
|
+
const known = Object.keys(config.profiles).join(', ');
|
|
69
|
+
return {
|
|
70
|
+
profile: fallback,
|
|
71
|
+
notice: `no profile named "${named}" (defined: ${known}); using "${fallback}"`,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
// Names the route the turn was on, since with --profile it may not be the default one. Not worded
|
|
75
|
+
// as a fetch failure: an abort, a 400 or a tool throw lands here too.
|
|
76
|
+
export function formatTurnFailure(profile, baseURL, message) {
|
|
77
|
+
return `reika: turn failed (profile "${profile}" at ${baseURL}): ${message}`;
|
|
78
|
+
}
|
|
57
79
|
export async function runHeadless(args, io) {
|
|
58
80
|
const prompt = (args.prompt ?? (await io.readStdin())).trim();
|
|
59
81
|
if (!prompt) {
|
|
@@ -67,7 +89,10 @@ export async function runHeadless(args, io) {
|
|
|
67
89
|
// with its own model in REIKA_MODE_MODELS runs that one, `--mode` or not. Headless has no /model
|
|
68
90
|
// and no saved state — its env is the whole answer — so an empty state is the whole of #365 here.
|
|
69
91
|
const mode = args.mode ?? resolveDefaultMode();
|
|
70
|
-
const
|
|
92
|
+
const chosen = headlessProfile(loaded, mode, args.profile);
|
|
93
|
+
if (chosen.notice)
|
|
94
|
+
io.stderr(`reika: ${chosen.notice}\n`);
|
|
95
|
+
const profile = chosen.profile;
|
|
71
96
|
const stream = args.stream ? createStreamPrinter(io, args.json) : null;
|
|
72
97
|
const session = await createSession({
|
|
73
98
|
cwd: process.cwd(),
|
|
@@ -181,7 +206,7 @@ export async function runHeadless(args, io) {
|
|
|
181
206
|
}
|
|
182
207
|
if (failed) {
|
|
183
208
|
debugLog(`headless: turn failed: ${failed.message}`);
|
|
184
|
-
io.stderr(
|
|
209
|
+
io.stderr(`${formatTurnFailure(profile, config.baseURL, failed.message)}\n`);
|
|
185
210
|
return controller.signal.aborted ? 130 : 1;
|
|
186
211
|
}
|
|
187
212
|
if (args.json && !args.stream) {
|
package/dist/headlessargs.js
CHANGED
|
@@ -2,6 +2,7 @@ export const USAGE = `usage: reika start the interactive TUI in
|
|
|
2
2
|
reika -p [prompt] ... run one turn without the TUI and print the reply
|
|
3
3
|
|
|
4
4
|
-p, --prompt [text] run one turn headless; reads stdin when no text is given
|
|
5
|
+
--profile <name> with -p: use this profile (outranks REIKA_MODEL and REIKA_MODE_MODELS)
|
|
5
6
|
--mode <mode> agent | plan | vibe | minimal | grind | chat (default: REIKA_DEFAULT_MODE, else agent)
|
|
6
7
|
--json print the turn's messages as a JSON array instead of the reply text
|
|
7
8
|
--stream print as the turn runs: the reply as it is generated, tool calls on
|
|
@@ -47,6 +48,13 @@ export function parseHeadlessArgs(argv) {
|
|
|
47
48
|
}
|
|
48
49
|
args.mode = value;
|
|
49
50
|
}
|
|
51
|
+
else if (a === '--profile') {
|
|
52
|
+
// A flag-shaped value is a missing name: taking it would swallow the -p or --json after it.
|
|
53
|
+
const value = argv[++i];
|
|
54
|
+
if (!value || value.startsWith('-'))
|
|
55
|
+
throw new Error('--profile needs a profile name');
|
|
56
|
+
args.profile = value;
|
|
57
|
+
}
|
|
50
58
|
else if (a === '--json') {
|
|
51
59
|
args.json = true;
|
|
52
60
|
}
|
|
@@ -82,5 +90,9 @@ export function parseHeadlessArgs(argv) {
|
|
|
82
90
|
throw new Error(`unexpected argument ${a}\n${USAGE}`);
|
|
83
91
|
}
|
|
84
92
|
}
|
|
93
|
+
// The TUI does not read it, so starting one would drop the flag without a word.
|
|
94
|
+
if (!headless && args.profile !== undefined) {
|
|
95
|
+
throw new Error(`--profile applies to a headless run; add -p\n${USAGE}`);
|
|
96
|
+
}
|
|
85
97
|
return headless ? args : null;
|
|
86
98
|
}
|
package/dist/tools/_sandbox.js
CHANGED
|
@@ -32,8 +32,8 @@ import { dropCarriers, hasExecutableSubstitution, hasRawSubstitution, maskQuoted
|
|
|
32
32
|
// affordance fix, which is why `sandboxFooter` exists and why it names `ps` explicitly rather than
|
|
33
33
|
// letting a model read this as a bug in its own pipeline.
|
|
34
34
|
// A malformed profile makes `sandbox-exec` exit 65 *without running the command* — the sandbox
|
|
35
|
-
// fails closed, which is the opposite of what a fail-open feature wants.
|
|
36
|
-
//
|
|
35
|
+
// fails closed, which is the opposite of what a fail-open feature wants. `sandboxPlan` probes for it
|
|
36
|
+
// before any command runs (`profileLoadFailure`); the typecheck gate also reads it off its output.
|
|
37
37
|
export const SANDBOX_PROFILE_ERROR_CODE = 65;
|
|
38
38
|
export const SANDBOX_EXEC_ERROR_PREFIX = 'sandbox-exec:';
|
|
39
39
|
/** Seatbelt profile for one cwd. Pure string in, string out — the unit under test. */
|
|
@@ -484,6 +484,7 @@ function hasSandboxExec() {
|
|
|
484
484
|
export function resetSandboxCache() {
|
|
485
485
|
execAvailable = undefined;
|
|
486
486
|
gitDirs.clear();
|
|
487
|
+
profileProbes.clear();
|
|
487
488
|
}
|
|
488
489
|
/**
|
|
489
490
|
* How to run a command under the sandbox, or why it can't be sandboxed.
|
|
@@ -531,7 +532,45 @@ export function sandboxPlan(cwd, opts) {
|
|
|
531
532
|
const args = ['-p', sandboxProfile(opts)];
|
|
532
533
|
for (const [k, v] of Object.entries(params))
|
|
533
534
|
args.push('-D', `${k}=${v}`);
|
|
534
|
-
|
|
535
|
+
const failure = profileLoadFailure(args);
|
|
536
|
+
return failure ? { reason: failure } : { args };
|
|
537
|
+
}
|
|
538
|
+
const profileProbes = new Map();
|
|
539
|
+
/**
|
|
540
|
+
* Why `sandbox-exec` will not load these exact args, or null when it does. A generator bug (a bad
|
|
541
|
+
* rule, an unbound param) makes it exit 65 having run nothing, so every command would fail. Asking
|
|
542
|
+
* here, against `:`, settles that before a model's command exists (#738): the old check read the
|
|
543
|
+
* refusal off the confined command's own output, and `echo 'sandbox-exec: x' >&2; exit 65` bought
|
|
544
|
+
* itself an unconfined rerun. The probe runs the same bytes the command will get, and loading
|
|
545
|
+
* depends on nothing else, so a pass here means the real run loads too, and its exit 65 is its own.
|
|
546
|
+
*
|
|
547
|
+
* Only a refusal counts. A timeout or spawn error reads as loaded: assuming it failed would let a
|
|
548
|
+
* swapping machine switch the sandbox off, where assuming it loaded costs at worst a command that
|
|
549
|
+
* fails closed, visibly. Cached per argv: at most one per cwd and network setting.
|
|
550
|
+
*/
|
|
551
|
+
export function profileLoadFailure(args) {
|
|
552
|
+
const key = args.join('\0');
|
|
553
|
+
const cached = profileProbes.get(key);
|
|
554
|
+
if (cached !== undefined)
|
|
555
|
+
return cached;
|
|
556
|
+
let failure = null;
|
|
557
|
+
try {
|
|
558
|
+
const r = spawnSync('/usr/bin/sandbox-exec', [...args, '/bin/sh', '-c', ':'], {
|
|
559
|
+
stdio: ['ignore', 'ignore', 'pipe'],
|
|
560
|
+
encoding: 'utf8',
|
|
561
|
+
timeout: 5_000,
|
|
562
|
+
});
|
|
563
|
+
// `:` cannot fail, so any exit but 0 is sandbox-exec's own (65 a parse or bind error, 71 apply).
|
|
564
|
+
if (r.error === undefined && r.status !== null && r.status !== 0) {
|
|
565
|
+
const detail = r.stderr.trim().split('\n')[0] ?? '';
|
|
566
|
+
failure = `the sandbox profile failed to load (sandbox-exec exit ${r.status}${detail ? `: ${detail}` : ''})`;
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
catch {
|
|
570
|
+
// Spawn threw: same as a timeout, read as loaded.
|
|
571
|
+
}
|
|
572
|
+
profileProbes.set(key, failure);
|
|
573
|
+
return failure;
|
|
535
574
|
}
|
|
536
575
|
/** The `-D` bindings for the profile's params. Exported so tests can prove every param is bound
|
|
537
576
|
* even where `sandboxPlan` refuses (nested seatbelt exits 71, but still parses the profile). */
|
package/dist/tools/bash.js
CHANGED
|
@@ -4,7 +4,7 @@ import { detectDangerousPatterns } from './_danger.js';
|
|
|
4
4
|
import { scanHeredocs } from './_heredoc.js';
|
|
5
5
|
import { remoteUrlRisk } from './_exfil.js';
|
|
6
6
|
import { declineSummary } from '../approval.js';
|
|
7
|
-
import {
|
|
7
|
+
import { broadWorkdirNotice, isBroadWorkdir, networkAllowedFor, sandboxArgv, sandboxFooter, sandboxNotice, sandboxPlan, refusedWriteLine, } from './_sandbox.js';
|
|
8
8
|
import { recordCapped } from './_spillstats.js';
|
|
9
9
|
import { GH_PLAN_READ_LIST, READ_ONLY_COMMAND_LIST, isProvablyReadOnly } from './_readonly.js';
|
|
10
10
|
import { changesSince, snapshotTree } from './_treediff.js';
|
|
@@ -276,10 +276,14 @@ export function execStream(command, ctx, sandbox) {
|
|
|
276
276
|
// A UI receipt, never in the model's context (the agent prompt carries the model's copy). Nothing
|
|
277
277
|
// otherwise announces the sandbox, so without this the user's only evidence would be a command
|
|
278
278
|
// that mysteriously failed. Once per cwd, both for the receipt and for the machine-fault warning.
|
|
279
|
-
// Marked shown only when a run completes with it attached (below): an aborted first command
|
|
280
|
-
//
|
|
279
|
+
// Marked shown only when a run completes with it attached (below): an aborted first command must
|
|
280
|
+
// not consume the one receipt this cwd gets.
|
|
281
|
+
//
|
|
282
|
+
// Keyed by the reason as well when there is one: the two network settings are separate profiles,
|
|
283
|
+
// and a receipt the other one already showed must not hide that this one runs unconfined.
|
|
284
|
+
const noticeKey = plan && 'reason' in plan ? `${ctx.cwd}\0${plan.reason}` : ctx.cwd;
|
|
281
285
|
let notice;
|
|
282
|
-
if (plan && !sandboxNoticed.has(
|
|
286
|
+
if (plan && !sandboxNoticed.has(noticeKey)) {
|
|
283
287
|
notice = argv
|
|
284
288
|
? {
|
|
285
289
|
tone: 'info',
|
|
@@ -433,7 +437,7 @@ export function execStream(command, ctx, sandbox) {
|
|
|
433
437
|
// did it end?", which the head cannot give once a run passes the cap.
|
|
434
438
|
const display = buildCommandDisplay(command, uiTail.text(), rawBytes > uiTail.bytes);
|
|
435
439
|
if (notice && plan)
|
|
436
|
-
sandboxNoticed.add(
|
|
440
|
+
sandboxNoticed.add(noticeKey);
|
|
437
441
|
// On the output's shape, not the exit status: `mkdir ~/x; echo ok` exits 0 with the denial in
|
|
438
442
|
// its output, and the user would otherwise never learn the flag exists.
|
|
439
443
|
if (refusedWrite !== null && !sandboxDenialNoticed.has(ctx.cwd)) {
|
|
@@ -481,28 +485,8 @@ export function execStream(command, ctx, sandbox) {
|
|
|
481
485
|
});
|
|
482
486
|
}
|
|
483
487
|
};
|
|
484
|
-
//
|
|
485
|
-
//
|
|
486
|
-
// every command into an uninterpretable failure. Retried unsandboxed, exactly once — and said,
|
|
487
|
-
// as a warn: a command that ran unconfined after the sandbox refused to load is the one event
|
|
488
|
-
// here the user must see, and the one that points at a generator bug.
|
|
489
|
-
if (argv &&
|
|
490
|
-
code === SANDBOX_PROFILE_ERROR_CODE &&
|
|
491
|
-
rawOutput.includes(SANDBOX_EXEC_ERROR_PREFIX)) {
|
|
492
|
-
execStream(command, ctx).then(r => resolve({
|
|
493
|
-
...r,
|
|
494
|
-
notice: {
|
|
495
|
-
tone: 'warn',
|
|
496
|
-
content: [
|
|
497
|
-
r.notice?.content,
|
|
498
|
-
`Not sandboxed: the sandbox profile failed to load (sandbox-exec exit ${code}); re-ran unsandboxed: ${command}`,
|
|
499
|
-
]
|
|
500
|
-
.filter(Boolean)
|
|
501
|
-
.join('\n'),
|
|
502
|
-
},
|
|
503
|
-
}));
|
|
504
|
-
return;
|
|
505
|
-
}
|
|
488
|
+
// No retry on exit 65: `sandboxPlan` has already proved this profile loads (#738), so a 65
|
|
489
|
+
// here is the command's own, and re-running it unsandboxed is what a fake refusal was after.
|
|
506
490
|
// Recorded whether or not spilling is on: the question this answers is how often bash
|
|
507
491
|
// output exceeds the cap at all, which is a property of the workload, not of the flag. The
|
|
508
492
|
// spilling arm records below instead, after the write, so `spilled` reports whether an
|
package/package.json
CHANGED
package/skills/review.md
CHANGED
|
@@ -23,8 +23,14 @@ straight on to the diff.
|
|
|
23
23
|
|
|
24
24
|
If output comes back it is the linked issue, in the same JSON shape as before:
|
|
25
25
|
`body` may be empty, and then the content is in `comments`. The issue may itself
|
|
26
|
-
reference other numbers (`#179`, `#185`).
|
|
27
|
-
|
|
26
|
+
reference other numbers (`#179`, `#185`). Most are background — leave them. Read
|
|
27
|
+
one only when this issue does not state the requirement itself: its body sends
|
|
28
|
+
you elsewhere for it ("see #179", "as described in #185", "follow-up to #179"),
|
|
29
|
+
or is too short to say what is wanted. Then run, once, for that one number:
|
|
30
|
+
|
|
31
|
+
gh issue view <that number> --json title,body
|
|
32
|
+
|
|
33
|
+
and go on. Do not follow any number that second issue mentions.
|
|
28
34
|
|
|
29
35
|
Then, before any other call, write one or two sentences in your reply saying what
|
|
30
36
|
the issue asks for — not what the PR does, the requirement. Later tool output can
|