@srobroek/pi-agent-reviewer 0.15.3 → 0.16.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/CHANGELOG.md CHANGED
@@ -1,3 +1,20 @@
1
+ ## agent-reviewer [0.16.0](https://github.com/srobroek/harness-plugins/compare/agent-reviewer--v0.15.4...agent-reviewer--v0.16.0) (2026-11-25)
2
+
3
+ ### Features
4
+
5
+ * **agent-reviewer:** flag hand-written contract types and edits to generated output ([26e05ad](https://github.com/srobroek/harness-plugins/commit/26e05adeddebffb8e65f60c87030a8e074bb7b9c))
6
+
7
+ ### Bug Fixes
8
+
9
+ * **agent-reviewer:** flag serialized or published contracts with no authoritative source ([e4ec4b0](https://github.com/srobroek/harness-plugins/commit/e4ec4b0092cfab0cdf4b4f35015f77f6a21f828e))
10
+ * **agent-reviewer:** name AsyncAPI channels and bindings as an authoritative contract source ([503076c](https://github.com/srobroek/harness-plugins/commit/503076ce4b06b33084a0c34ed1a87fe07494e1f7))
11
+
12
+ ## agent-reviewer [0.15.4](https://github.com/srobroek/harness-plugins/compare/agent-reviewer--v0.15.3...agent-reviewer--v0.15.4) (2026-11-25)
13
+
14
+ ### Bug Fixes
15
+
16
+ * **agent-reviewer:** add a hardened git_read tool for shell-less pi reviewers ([b263f7b](https://github.com/srobroek/harness-plugins/commit/b263f7bd8f3bfb273cb5cc8ac1c44237b4fcaaa6))
17
+
1
18
  ## agent-reviewer [0.15.3](https://github.com/srobroek/harness-plugins/compare/agent-reviewer--v0.15.2...agent-reviewer--v0.15.3) (2026-11-25)
2
19
 
3
20
  ### Bug Fixes
package/README.md CHANGED
@@ -101,6 +101,27 @@ Pi-lens keeps `ast_grep_search` and `ast_grep_outline` inactive until `pi_lens_a
101
101
 
102
102
  None of these agents has `write` or `edit`. To get a review or challenge as a file, pass the `output` option of the `subagent` call: pi-subagents saves the agent's final reply to that path. Give an absolute path for a file in the project; pi-subagents puts a relative `output` path under the run's artifact directory.
103
103
 
104
+ ## Pi `git_read` tool
105
+
106
+ The Pi extension registers `git_read`, a read-only git tool for a reviewer subagent that has no shell. In Pi it starts inactive. A child gets it when its `tools` list names `git_read` and its `subagentOnlyExtensions` loads this package. None of this plugin's agents lists it: `code-reviewer` and `security-auditor` read git through `bash`, and `pr-reviewer` reviews only through its two `gh` reads.
107
+
108
+ A call names one subcommand and its arguments as an array. No shell parses them. The extension runs only these subcommands:
109
+
110
+ - `log`, `show` and `diff`, each with `--no-ext-diff --no-textconv` added
111
+ - `branch --list`, with listing options only, each value given as `--<option>=<value>`
112
+ - `rev-parse`, `merge-base`, `ls-files`, `ls-tree` and `for-each-ref`
113
+ - `cat-file -p <object>` and `cat-file -t <object>`
114
+
115
+ It rejects these options and every abbreviation of the long ones: `--output`, `--ext-diff`, `--textconv`, `--show-signature`, `--no-index` and `-o`.
116
+
117
+ Git runs with the environment from `hardenedGitEnv` in `lib/src/safe-git.ts`, and with every configured filter driver turned off. That environment:
118
+
119
+ - turns off fsmonitor, hooks and signature verifiers
120
+ - blocks lazy fetch and every transport
121
+ - sets the empty tree as the attribute source
122
+
123
+ The tool needs git 2.45 or later. A call that runs longer than 30 seconds fails. At 50 KB of output the tool stops git and marks the output as cut.
124
+
104
125
  ## Install
105
126
  Install the Pi package from npm:
106
127
 
@@ -1,9 +1,492 @@
1
1
  // @bun
2
2
  // Generated by scripts/build.ts. Do not edit.
3
+ // plugins/agent-reviewer/pi-src/git-read.ts
4
+ import path from "path";
5
+
6
+ // lib/src/safe-git.ts
7
+ import { devNull } from "os";
8
+ var SAFE_GIT_CONFIG = [
9
+ ["core.fsmonitor", "false"],
10
+ ["core.hooksPath", devNull]
11
+ ];
12
+ var SAFE_GIT_ARGS = [...SAFE_GIT_CONFIG.flatMap(([key, value]) => ["-c", `${key}=${value}`]), "--no-optional-locks"];
13
+ var HARDENED_GIT_CONFIG = [
14
+ ...SAFE_GIT_CONFIG,
15
+ ["core.attributesFile", devNull],
16
+ ["log.showSignature", "false"],
17
+ ["gpg.program", devNull],
18
+ ["gpg.ssh.program", devNull],
19
+ ["gpg.x509.program", devNull],
20
+ ["commit.gpgSign", "false"],
21
+ ["tag.gpgSign", "false"],
22
+ ["gpg.ssh.defaultKeyCommand", ""],
23
+ ["core.sshCommand", ""],
24
+ ["credential.helper", ""],
25
+ ["diff.external", ""]
26
+ ];
27
+ var EMPTY_TREE = "4b825dc642cb6eb9a060e54bf8d69288fbee4904";
28
+ var GIT_MIN_VERSION = [2, 45, 0];
29
+ function parseGitVersion(text) {
30
+ const match = /git version (\d+)\.(\d+)(?:\.(\d+))?/.exec(text);
31
+ if (!match)
32
+ return;
33
+ return [Number(match[1]), Number(match[2]), Number(match[3] ?? 0)];
34
+ }
35
+ var GIT_VERSION_MESSAGE = "subagent-worktree needs git 2.45+ for safe automatic merges";
36
+ function gitVersionProblem(text) {
37
+ const version = parseGitVersion(text);
38
+ if (!version)
39
+ return GIT_VERSION_MESSAGE;
40
+ for (const [index, minimum] of GIT_MIN_VERSION.entries()) {
41
+ const have = version[index] ?? 0;
42
+ if (have > minimum)
43
+ return;
44
+ if (have < minimum)
45
+ return GIT_VERSION_MESSAGE;
46
+ }
47
+ return;
48
+ }
49
+ var INHERITED_GIT_VARIABLES = [
50
+ "GIT_DIR",
51
+ "GIT_WORK_TREE",
52
+ "GIT_COMMON_DIR",
53
+ "GIT_INDEX_FILE",
54
+ "GIT_OBJECT_DIRECTORY",
55
+ "GIT_ALTERNATE_OBJECT_DIRECTORIES",
56
+ "GIT_PREFIX",
57
+ "GIT_NAMESPACE",
58
+ "GIT_REPLACE_REF_BASE",
59
+ "GIT_GRAFT_FILE",
60
+ "GIT_SHALLOW_FILE",
61
+ "GIT_CONFIG",
62
+ "GIT_EXEC_PATH",
63
+ "GIT_EXTERNAL_DIFF",
64
+ "GIT_PAGER",
65
+ "GIT_EDITOR",
66
+ "GIT_SEQUENCE_EDITOR",
67
+ "GIT_SSH",
68
+ "GIT_SSH_COMMAND",
69
+ "GIT_ASKPASS",
70
+ "GIT_PROXY_COMMAND",
71
+ "GIT_LITERAL_PATHSPECS",
72
+ "GIT_GLOB_PATHSPECS",
73
+ "GIT_NOGLOB_PATHSPECS",
74
+ "GIT_ICASE_PATHSPECS"
75
+ ];
76
+ var PROGRAM_VARIABLES = ["PAGER", "EDITOR", "VISUAL", "SSH_ASKPASS"];
77
+ function hardenedGitEnv(base) {
78
+ const env = {};
79
+ const dropped = new Set([...INHERITED_GIT_VARIABLES, ...PROGRAM_VARIABLES]);
80
+ for (const [key, value] of Object.entries(base)) {
81
+ if (value === undefined || dropped.has(key) || key.startsWith("GIT_TRACE"))
82
+ continue;
83
+ if (key === "GIT_CONFIG_PARAMETERS" || key === "GIT_CONFIG_COUNT" || /^GIT_CONFIG_(KEY|VALUE)_\d+$/.test(key))
84
+ continue;
85
+ env[key] = value;
86
+ }
87
+ let count = 0;
88
+ for (const [key, value] of HARDENED_GIT_CONFIG) {
89
+ env[`GIT_CONFIG_KEY_${count}`] = key;
90
+ env[`GIT_CONFIG_VALUE_${count}`] = value;
91
+ count += 1;
92
+ }
93
+ env.GIT_CONFIG_COUNT = String(count);
94
+ env.GIT_ATTR_SOURCE = EMPTY_TREE;
95
+ env.GIT_OPTIONAL_LOCKS = "0";
96
+ env.GIT_NO_LAZY_FETCH = "1";
97
+ env.GIT_ALLOW_PROTOCOL = "";
98
+ return env;
99
+ }
100
+ var FILTER_DRIVER_LISTING = ["config", "--name-only", "-z", "--list"];
101
+ function filterDriverOverrides(listing) {
102
+ const keys = listing.split("\x00");
103
+ if (keys.pop() !== "")
104
+ return;
105
+ const drivers = new Set;
106
+ for (const key of keys) {
107
+ const last = key.lastIndexOf(".");
108
+ if (!key.startsWith("filter.") || last < "filter.".length)
109
+ continue;
110
+ drivers.add(key.slice("filter.".length, last));
111
+ }
112
+ if ([...drivers].some((driver) => driver.includes("=") || driver.includes("\uFFFD")))
113
+ return;
114
+ return [...drivers].flatMap((driver) => ["clean=", "smudge=", "process=", "required=false"].flatMap((setting) => ["-c", `filter.${driver}.${setting}`]));
115
+ }
116
+
117
+ // lib/src/subprocess.ts
118
+ import { constants } from "os";
119
+ var EXIT_GRACE_MS = 2000;
120
+ var EXIT_POLL_MS = 100;
121
+ function goneWatch(graceMs, pollMs) {
122
+ const polls = Math.max(1, Math.ceil(graceMs / Math.max(1, pollMs)));
123
+ let since = null;
124
+ let seen = 0;
125
+ return (alive) => {
126
+ if (alive) {
127
+ since = null;
128
+ seen = 0;
129
+ return false;
130
+ }
131
+ since ??= Date.now();
132
+ seen++;
133
+ return seen > polls && Date.now() - since >= graceMs;
134
+ };
135
+ }
136
+ function processAlive(pid) {
137
+ try {
138
+ process.kill(pid, 0);
139
+ return true;
140
+ } catch (error) {
141
+ return error.code === "EPERM";
142
+ }
143
+ }
144
+ function killChild(child, group) {
145
+ if (group) {
146
+ try {
147
+ process.kill(-child.pid, "SIGKILL");
148
+ return;
149
+ } catch {}
150
+ }
151
+ try {
152
+ child.kill("SIGKILL");
153
+ } catch {}
154
+ }
155
+ function unref(timer) {
156
+ timer.unref?.();
157
+ }
158
+ function capture(stream) {
159
+ if (!(stream instanceof ReadableStream))
160
+ return { text: Promise.resolve(""), snapshot: () => "", cancel: () => {} };
161
+ const reader = stream.getReader();
162
+ const decoder = new TextDecoder;
163
+ let collected = "";
164
+ const text = (async () => {
165
+ try {
166
+ for (;; ) {
167
+ const chunk = await reader.read();
168
+ if (chunk.done)
169
+ break;
170
+ collected += decoder.decode(chunk.value, { stream: true });
171
+ }
172
+ } catch {}
173
+ collected += decoder.decode();
174
+ return collected;
175
+ })();
176
+ const cancel = () => {
177
+ try {
178
+ reader.cancel().catch(() => {
179
+ return;
180
+ });
181
+ } catch {}
182
+ };
183
+ return { text, snapshot: () => collected, cancel };
184
+ }
185
+ function supervise(child, options = {}) {
186
+ const grace = Math.max(0, options.graceMs ?? EXIT_GRACE_MS);
187
+ const pollMs = Math.max(1, options.pollMs ?? EXIT_POLL_MS);
188
+ const alive = options.alive ?? processAlive;
189
+ const group = options.group ?? false;
190
+ const { signal, timeoutMs } = options;
191
+ const out = capture(child.stdout);
192
+ const err = capture(child.stderr);
193
+ return new Promise((resolve) => {
194
+ let ended = null;
195
+ let exitSeen = false;
196
+ let settled = false;
197
+ const gone = goneWatch(grace, pollMs);
198
+ let deadline;
199
+ let graceTimer;
200
+ const settle = (run) => {
201
+ if (settled)
202
+ return;
203
+ settled = true;
204
+ clearTimeout(deadline);
205
+ clearTimeout(graceTimer);
206
+ clearInterval(poller);
207
+ signal?.removeEventListener("abort", onAbort);
208
+ resolve(run);
209
+ };
210
+ const end = (cause) => {
211
+ if (ended !== null || settled)
212
+ return;
213
+ ended = cause;
214
+ if (cause !== "lost" || group)
215
+ killChild(child, group);
216
+ out.cancel();
217
+ err.cancel();
218
+ graceTimer = setTimeout(() => settle({ kind: cause, stdout: out.snapshot(), stderr: err.snapshot() }), grace);
219
+ if (options.unref)
220
+ unref(graceTimer);
221
+ };
222
+ const onAbort = () => end("aborted");
223
+ const poller = setInterval(() => {
224
+ if (exitSeen || ended !== null || settled)
225
+ return;
226
+ if (gone(alive(child.pid)))
227
+ end("lost");
228
+ }, pollMs);
229
+ unref(poller);
230
+ if (timeoutMs !== undefined && timeoutMs > 0 && Number.isFinite(timeoutMs)) {
231
+ deadline = setTimeout(() => end("timeout"), timeoutMs);
232
+ if (options.unref)
233
+ unref(deadline);
234
+ }
235
+ signal?.addEventListener("abort", onAbort, { once: true });
236
+ if (signal?.aborted)
237
+ onAbort();
238
+ child.exited.then(() => {
239
+ exitSeen = true;
240
+ }, () => {
241
+ return;
242
+ });
243
+ Promise.all([child.exited, out.text, err.text]).then(([exitCode, stdout, stderr]) => {
244
+ if (ended !== null)
245
+ settle({ kind: ended, stdout, stderr });
246
+ else
247
+ settle({ kind: "exited", exitCode, signalCode: signalName(child.signalCode), stdout, stderr });
248
+ }, () => end("lost"));
249
+ });
250
+ }
251
+ function signalName(code) {
252
+ if (code === null || code === undefined)
253
+ return null;
254
+ if (typeof code === "string")
255
+ return code;
256
+ return Object.entries(constants.signals).find(([, n]) => n === code)?.[0] ?? String(code);
257
+ }
258
+
259
+ // plugins/agent-reviewer/pi-src/git-read.ts
260
+ import { Type } from "typebox";
261
+
262
+ // plugins/agent-reviewer/pi-src/git-read-policy.ts
263
+ var GIT_READ_SUBCOMMANDS = [
264
+ "log",
265
+ "show",
266
+ "diff",
267
+ "branch",
268
+ "rev-parse",
269
+ "merge-base",
270
+ "ls-files",
271
+ "cat-file",
272
+ "ls-tree",
273
+ "for-each-ref"
274
+ ];
275
+ var REFUSED_LONG_OPTIONS = [
276
+ ["output", "writes a file"],
277
+ ["ext-diff", "runs an external diff program"],
278
+ ["textconv", "runs a textconv program"],
279
+ ["show-signature", "runs a signature verifier"],
280
+ ["no-index", "reads files outside the repository"]
281
+ ];
282
+ var REFUSED_SHORT_OPTIONS = new Set(["-o"]);
283
+ var DIFF_GUARDS = ["--no-ext-diff", "--no-textconv"];
284
+ var DIFF_SUBCOMMANDS = new Set(["log", "show", "diff"]);
285
+ var BRANCH_LIST_FLAGS = new Set([
286
+ "--list",
287
+ "-a",
288
+ "--all",
289
+ "-r",
290
+ "--remotes",
291
+ "-v",
292
+ "-vv",
293
+ "--verbose",
294
+ "-i",
295
+ "--ignore-case",
296
+ "--no-abbrev",
297
+ "--omit-empty",
298
+ "--no-column",
299
+ "--no-color"
300
+ ]);
301
+ var BRANCH_LIST_VALUE_OPTIONS = new Set([
302
+ "--contains",
303
+ "--no-contains",
304
+ "--merged",
305
+ "--no-merged",
306
+ "--points-at",
307
+ "--sort",
308
+ "--format",
309
+ "--abbrev",
310
+ "--column",
311
+ "--color"
312
+ ]);
313
+ var CAT_FILE_MODES = new Set(["-p", "-t"]);
314
+ function isGitReadSubcommand(name) {
315
+ return GIT_READ_SUBCOMMANDS.includes(name);
316
+ }
317
+ function refusedOption(arg) {
318
+ if (REFUSED_SHORT_OPTIONS.has(arg))
319
+ return `${arg} is refused`;
320
+ if (!arg.startsWith("--"))
321
+ return;
322
+ const name = arg.slice(2).split("=", 1)[0] ?? "";
323
+ if (name === "")
324
+ return;
325
+ const match = REFUSED_LONG_OPTIONS.find(([option]) => option.startsWith(name));
326
+ if (match === undefined)
327
+ return;
328
+ const [option, why] = match;
329
+ return name === option ? `--${option} ${why}` : `${arg} abbreviates --${option}, which ${why}; spell options in full`;
330
+ }
331
+ function branchProblem(args) {
332
+ if (!args.includes("--list"))
333
+ return "branch runs only with --list";
334
+ for (const arg of args) {
335
+ if (!arg.startsWith("-") || BRANCH_LIST_FLAGS.has(arg))
336
+ continue;
337
+ const separator = arg.indexOf("=");
338
+ const name = separator === -1 ? arg : arg.slice(0, separator);
339
+ if (!BRANCH_LIST_VALUE_OPTIONS.has(name))
340
+ return `branch ${arg} is refused: only listing options run`;
341
+ if (separator === -1)
342
+ return `branch ${arg} is refused: give its value as ${name}=<value>`;
343
+ }
344
+ return;
345
+ }
346
+ function catFileProblem(args) {
347
+ const [mode, object, ...rest] = args;
348
+ const valid = mode !== undefined && CAT_FILE_MODES.has(mode) && object !== undefined && !object.startsWith("-") && rest.length === 0;
349
+ return valid ? undefined : "cat-file runs only as `cat-file -p <object>` or `cat-file -t <object>`";
350
+ }
351
+ function gitReadArgs(subcommand, args) {
352
+ if (!isGitReadSubcommand(subcommand)) {
353
+ return { allowed: false, reason: `${JSON.stringify(subcommand)} is not a git_read subcommand; use one of ${GIT_READ_SUBCOMMANDS.join(", ")}` };
354
+ }
355
+ for (const arg of args) {
356
+ const why = refusedOption(arg);
357
+ if (why !== undefined)
358
+ return { allowed: false, reason: why };
359
+ }
360
+ const problem = subcommand === "branch" ? branchProblem(args) : subcommand === "cat-file" ? catFileProblem(args) : undefined;
361
+ if (problem !== undefined)
362
+ return { allowed: false, reason: problem };
363
+ return { allowed: true, args: [subcommand, ...DIFF_SUBCOMMANDS.has(subcommand) ? DIFF_GUARDS : [], ...args] };
364
+ }
365
+
366
+ // plugins/agent-reviewer/pi-src/git-read.ts
367
+ var GIT_READ = "git_read";
368
+ var GIT_READ_TIMEOUT_MS = 30000;
369
+ var GIT_READ_MAX_BYTES = 50 * 1024;
370
+ var MAX_STDERR_BYTES = 8 * 1024;
371
+ var MAX_CONFIG_LISTING_BYTES = 1024 * 1024;
372
+ function capped(source, max, onFull) {
373
+ if (!(source instanceof ReadableStream))
374
+ return source;
375
+ const reader = source.getReader();
376
+ let room = max;
377
+ return new ReadableStream({
378
+ async pull(controller) {
379
+ const chunk = await reader.read().catch(() => ({ done: true, value: undefined }));
380
+ if (chunk.done)
381
+ return controller.close();
382
+ if (chunk.value.byteLength > room) {
383
+ controller.enqueue(chunk.value.subarray(0, room));
384
+ room = 0;
385
+ onFull();
386
+ reader.cancel().catch(() => {
387
+ return;
388
+ });
389
+ return controller.close();
390
+ }
391
+ room -= chunk.value.byteLength;
392
+ controller.enqueue(chunk.value);
393
+ },
394
+ cancel: () => reader.cancel().catch(() => {
395
+ return;
396
+ })
397
+ });
398
+ }
399
+ async function runGit(args, cwd, signal, maxBytes) {
400
+ const child = Bun.spawn(["git", ...args], { cwd, stdin: "ignore", stdout: "pipe", stderr: "pipe", env: hardenedGitEnv(Bun.env), detached: true });
401
+ let truncated = false;
402
+ const guarded = {
403
+ pid: child.pid,
404
+ exited: child.exited,
405
+ get signalCode() {
406
+ return child.signalCode;
407
+ },
408
+ kill: (code) => child.kill(code),
409
+ stdout: capped(child.stdout, maxBytes, () => {
410
+ truncated = true;
411
+ killChild(child, true);
412
+ }),
413
+ stderr: capped(child.stderr, MAX_STDERR_BYTES, () => {
414
+ return;
415
+ })
416
+ };
417
+ const run = await supervise(guarded, { timeoutMs: GIT_READ_TIMEOUT_MS, signal, group: true });
418
+ if (run.kind === "exited")
419
+ return { exitCode: run.exitCode, stdout: run.stdout, stderr: run.stderr, truncated };
420
+ return { exitCode: undefined, stdout: run.stdout, stderr: run.stderr, truncated, ended: run.kind };
421
+ }
422
+ var supported;
423
+ function gitSupported() {
424
+ supported ??= runGit(["--version"], process.cwd(), undefined, 1024).then((run) => run.exitCode === 0 && gitVersionProblem(run.stdout) === undefined, () => false);
425
+ return supported;
426
+ }
427
+ async function filterOverrides(cwd, signal) {
428
+ const listing = await runGit(FILTER_DRIVER_LISTING, cwd, signal, MAX_CONFIG_LISTING_BYTES);
429
+ if (listing.truncated)
430
+ return;
431
+ if (listing.exitCode === 1 && listing.stdout === "")
432
+ return [];
433
+ return listing.exitCode === 0 ? filterDriverOverrides(listing.stdout) : undefined;
434
+ }
435
+ function refused(reason) {
436
+ return { text: `git_read refused: ${reason}. Nothing ran.`, isError: true, details: { refused: reason } };
437
+ }
438
+ async function gitRead(params, cwd, signal) {
439
+ const decision = gitReadArgs(params.subcommand, params.args ?? []);
440
+ if (!decision.allowed)
441
+ return refused(decision.reason);
442
+ if (!await gitSupported())
443
+ return refused("git 2.45 or newer is required for hardened reads");
444
+ const directory = params.path === undefined ? cwd : path.resolve(cwd, params.path);
445
+ const overrides = await filterOverrides(directory, signal);
446
+ if (overrides === undefined)
447
+ return refused("the configured filter drivers could not be listed or disabled");
448
+ const { args } = decision;
449
+ const run = await runGit([...overrides, ...args], directory, signal, GIT_READ_MAX_BYTES);
450
+ if (run.truncated) {
451
+ const note = `[git_read: output cut at ${GIT_READ_MAX_BYTES / 1024} KB and git stopped; narrow the range, add paths, or use --stat or -n]`;
452
+ return { text: `${run.stdout}
453
+ ${note}`, isError: false, details: { args, exitCode: null, truncated: true } };
454
+ }
455
+ if (run.exitCode === undefined) {
456
+ const why = run.ended === "timeout" ? `timed out after ${GIT_READ_TIMEOUT_MS / 1000}s` : "ended without an exit status";
457
+ return { text: `git ${args.join(" ")} ${why}.
458
+ ${run.stderr}`.trim(), isError: true, details: { args, exitCode: null, truncated: false } };
459
+ }
460
+ const stderr = run.stderr.trim();
461
+ const parts = [run.stdout, stderr === "" ? "" : `[stderr]
462
+ ${stderr}`, run.exitCode === 0 ? "" : `[exit ${run.exitCode}]`];
463
+ const text = parts.filter((part) => part !== "").join(`
464
+ `) || "(no output)";
465
+ return { text, isError: run.exitCode !== 0, details: { args, exitCode: run.exitCode, truncated: false } };
466
+ }
467
+ var parameters = Type.Object({
468
+ subcommand: Type.Union(GIT_READ_SUBCOMMANDS.map((name) => Type.Literal(name)), { description: "The git subcommand" }),
469
+ args: Type.Optional(Type.Array(Type.String(), { description: 'Its arguments, one per element, never a shell string: ["--oneline", "main..feature"]' })),
470
+ path: Type.Optional(Type.String({ description: "Directory to run in; defaults to the session directory" }))
471
+ }, { additionalProperties: false });
472
+ function registerGitRead(pi) {
473
+ pi.registerTool({
474
+ name: GIT_READ,
475
+ label: "Git Read",
476
+ description: "Read-only git: log, show, diff, branch --list, rev-parse, merge-base, ls-files, cat-file -p/-t, ls-tree, for-each-ref. " + "Takes the subcommand and an argument array, no shell. Refuses every other subcommand and any option that writes a file or runs a program " + `(--output, --ext-diff, --textconv, --show-signature, --no-index, -o); spell options in full. Output is capped at ${GIT_READ_MAX_BYTES / 1024} KB.`,
477
+ parameters,
478
+ defaultActive: false,
479
+ async execute(_toolCallId, params, signal, _onUpdate, ctx) {
480
+ const result = await gitRead(params, ctx.cwd, signal);
481
+ return { content: [{ type: "text", text: result.text }], details: result.details, isError: result.isError };
482
+ }
483
+ });
484
+ }
485
+
3
486
  // plugins/agent-reviewer/pi-src/pr-reviewer-gate.ts
4
487
  import { realpathSync } from "fs";
5
488
  import { homedir } from "os";
6
- import path from "path";
489
+ import path2 from "path";
7
490
 
8
491
  // lib/src/pi-child-agent.ts
9
492
  var escapeRegExp = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
@@ -27,17 +510,17 @@ var COMMAND_REASON = "blocked by agent-reviewer: pr-reviewer runs only `gh pr vi
27
510
  var READ_REASON = "blocked by agent-reviewer: pr-reviewer reads only the skill files listed in its prompt, never repository " + "or other local files. Review from the two gh reads.";
28
511
  function skillDirectories(systemPrompt) {
29
512
  const block = /<available_skills>([\s\S]*?)<\/available_skills>/.exec(systemPrompt)?.[1] ?? "";
30
- return [...block.matchAll(/<location>([^<]+)<\/location>/g)].map((match) => match[1].trim()).filter((location) => path.isAbsolute(location)).map((location) => path.dirname(path.normalize(location)));
513
+ return [...block.matchAll(/<location>([^<]+)<\/location>/g)].map((match) => match[1].trim()).filter((location) => path2.isAbsolute(location)).map((location) => path2.dirname(path2.normalize(location)));
31
514
  }
32
515
  function resolveReadPath(value, cwd, home) {
33
516
  const bare = value.startsWith("@") ? value.slice(1) : value;
34
- const expanded = bare === "~" ? home : bare.startsWith("~/") ? path.join(home, bare.slice(2)) : bare;
35
- return path.resolve(cwd, expanded);
517
+ const expanded = bare === "~" ? home : bare.startsWith("~/") ? path2.join(home, bare.slice(2)) : bare;
518
+ return path2.resolve(cwd, expanded);
36
519
  }
37
520
  function within(target, dir, realpath) {
38
521
  try {
39
522
  const real = realpath(dir);
40
- return target === real || target.startsWith(`${real}${path.sep}`);
523
+ return target === real || target.startsWith(`${real}${path2.sep}`);
41
524
  } catch {
42
525
  return false;
43
526
  }
@@ -75,6 +558,7 @@ function registerPrReviewerGate(pi) {
75
558
  // plugins/agent-reviewer/pi-src/index.ts
76
559
  function agentReviewer(pi) {
77
560
  registerPrReviewerGate(pi);
561
+ registerGitRead(pi);
78
562
  }
79
563
  export {
80
564
  COMMAND_REASON,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@srobroek/pi-agent-reviewer",
3
- "version": "0.15.3",
3
+ "version": "0.16.0",
4
4
  "description": "A security review skill: trace untrusted input to sinks, tag CWE ids and check cross-boundary dispatch.",
5
5
  "keywords": [
6
6
  "pi-package"
@@ -30,7 +30,8 @@
30
30
  "@srobroek/pi-repomix": "*",
31
31
  "@srobroek/pi-whats-new": "*",
32
32
  "pi-lens": "*",
33
- "pi-web-access": "*"
33
+ "pi-web-access": "*",
34
+ "typebox": "*"
34
35
  },
35
36
  "peerDependenciesMeta": {
36
37
  "@srobroek/pi-code-quality": {