@raytrace-cli/cli 0.19.3 → 0.19.4
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/package.json +1 -1
- package/src/local-sandbox.mjs +21 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@raytrace-cli/cli",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.4",
|
|
4
4
|
"mcpName": "io.github.Godcreatebugs/raytrace",
|
|
5
5
|
"description": "See what your coding agent did: traces, tool calls, cost and step-by-step evidence for Claude Code and Codex.",
|
|
6
6
|
"license": "MIT",
|
package/src/local-sandbox.mjs
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
import { spawnSync } from 'node:child_process';
|
|
14
14
|
import { createHash, randomBytes } from 'node:crypto';
|
|
15
15
|
import { closeSync, existsSync, mkdirSync, openSync, readFileSync, readdirSync, renameSync, rmSync, writeFileSync } from 'node:fs';
|
|
16
|
-
import { basename, join } from 'node:path';
|
|
16
|
+
import { basename, join, posix } from 'node:path';
|
|
17
17
|
import { AGENTS } from './agents.mjs';
|
|
18
18
|
import { paths } from './paths.mjs';
|
|
19
19
|
import { portInUse, runningPid, start as startProxy, stop as stopProxy } from './proxy-process.mjs';
|
|
@@ -279,15 +279,29 @@ export async function start(id) {
|
|
|
279
279
|
say(`${registry()[id].name} running`);
|
|
280
280
|
}
|
|
281
281
|
|
|
282
|
-
/**
|
|
283
|
-
|
|
282
|
+
/**
|
|
283
|
+
* A path as the lists keep it, and as the VM will: from the project's root,
|
|
284
|
+
* `/`-separated, with no `.` segments, repeated or trailing slashes. Paths the
|
|
285
|
+
* VM would refuse (absolute, a `..` segment, NUL) are refused here, naming the flag.
|
|
286
|
+
*/
|
|
287
|
+
function listPath(path, flag) {
|
|
288
|
+
const given = String(path).trim().replace(/\\/g, '/');
|
|
289
|
+
const shown = `--${flag} ${String(path).trim().replace(/\0/g, '\\0')}`;
|
|
290
|
+
if (given.includes('\0')) throw new Error(`${shown}: a path cannot contain a NUL character.`);
|
|
291
|
+
if (given.startsWith('/') || given.split('/').includes('..')) {
|
|
292
|
+
throw new Error(`${shown}: paths are from the project's root and cannot leave it.`);
|
|
293
|
+
}
|
|
294
|
+
const clean = posix.normalize(given).replace(/\/+$/, '');
|
|
295
|
+
return clean === '.' ? '' : clean;
|
|
296
|
+
}
|
|
284
297
|
|
|
285
298
|
/**
|
|
286
299
|
* The two lists after a change. A file is on one list at most: restricting a
|
|
287
300
|
* reported file moves it, and the other way round. `clear` takes it off both.
|
|
288
301
|
*/
|
|
289
302
|
export function changedLists(current, { restrict = [], report = [], clear = [] } = {}) {
|
|
290
|
-
const [toRestrict, toReport, toClear] = [restrict, report,
|
|
303
|
+
const [toRestrict, toReport, toClear] = [['restrict', restrict], ['report', report], ['clear', clear]]
|
|
304
|
+
.map(([flag, paths]) => paths.map((path) => listPath(path, flag)).filter(Boolean));
|
|
291
305
|
const both = toRestrict.filter((path) => toReport.includes(path));
|
|
292
306
|
if (both.length) throw new Error(`${both[0]} is given to both --restrict and --report; pick one.`);
|
|
293
307
|
const gone = new Set([...toClear, ...toRestrict, ...toReport]);
|
|
@@ -304,11 +318,13 @@ export function changedLists(current, { restrict = [], report = [], clear = [] }
|
|
|
304
318
|
*/
|
|
305
319
|
export async function files(ref, change = {}) {
|
|
306
320
|
const id = pickId(ref);
|
|
321
|
+
const changing = ['restrict', 'report', 'clear'].some((key) => change[key]?.length);
|
|
322
|
+
// Refuse a bad path before the VM is started for it.
|
|
323
|
+
if (changing) changedLists({}, change);
|
|
307
324
|
ensureVm();
|
|
308
325
|
const { name } = registry()[id];
|
|
309
326
|
const read = (args, options) => JSON.parse(projects(args, options).stdout);
|
|
310
327
|
let lists = read(['guardrails', id]);
|
|
311
|
-
const changing = ['restrict', 'report', 'clear'].some((key) => change[key]?.length);
|
|
312
328
|
if (changing) {
|
|
313
329
|
const wanted = changedLists(lists, change);
|
|
314
330
|
lists = read(['set-guardrails', id], { input: JSON.stringify(wanted) });
|