@piagent/platform 1.48.5 → 1.49.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.
Files changed (76) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/docs/command-reference-vietnamese.md +2 -2
  3. package/docs/distribution-standard.md +6 -6
  4. package/docs/operator-manual-vietnamese.md +7 -7
  5. package/docs/publishing-for-teams.md +1 -0
  6. package/docs/release-install-policy.md +2 -2
  7. package/docs/team-onboarding.md +2 -2
  8. package/docs-site/architecture.html +1 -1
  9. package/docs-site/assets/search-en.json +1 -1
  10. package/docs-site/assets/search-vi.json +1 -1
  11. package/docs-site/benchmark.html +1 -1
  12. package/docs-site/commands.html +1 -1
  13. package/docs-site/context-engine.html +1 -1
  14. package/docs-site/ecosystem.html +1 -1
  15. package/docs-site/en/architecture.html +1 -1
  16. package/docs-site/en/benchmark.html +1 -1
  17. package/docs-site/en/commands.html +1 -1
  18. package/docs-site/en/context-engine.html +1 -1
  19. package/docs-site/en/ecosystem.html +1 -1
  20. package/docs-site/en/index.html +9 -9
  21. package/docs-site/en/mcp-approval.html +1 -1
  22. package/docs-site/en/mcp-auth.html +1 -1
  23. package/docs-site/en/mcp-servers.html +1 -1
  24. package/docs-site/en/mcp.html +1 -1
  25. package/docs-site/en/permissions.html +1 -1
  26. package/docs-site/en/profiles.html +1 -1
  27. package/docs-site/en/quickstart.html +1 -1
  28. package/docs-site/en/runtime.html +1 -1
  29. package/docs-site/en/scope.html +1 -1
  30. package/docs-site/en/security.html +1 -1
  31. package/docs-site/en/team.html +1 -1
  32. package/docs-site/en/update.html +3 -3
  33. package/docs-site/en/whats-new.html +28 -17
  34. package/docs-site/en/windows.html +1 -1
  35. package/docs-site/en/workflows.html +1 -1
  36. package/docs-site/index.html +9 -9
  37. package/docs-site/mcp-approval.html +1 -1
  38. package/docs-site/mcp-auth.html +1 -1
  39. package/docs-site/mcp-servers.html +1 -1
  40. package/docs-site/mcp.html +1 -1
  41. package/docs-site/permissions.html +1 -1
  42. package/docs-site/profiles.html +1 -1
  43. package/docs-site/quickstart.html +1 -1
  44. package/docs-site/releases.json +31 -0
  45. package/docs-site/runtime.html +1 -1
  46. package/docs-site/scope.html +1 -1
  47. package/docs-site/security.html +1 -1
  48. package/docs-site/team.html +1 -1
  49. package/docs-site/update.html +3 -3
  50. package/docs-site/whats-new.html +28 -17
  51. package/docs-site/windows.html +1 -1
  52. package/docs-site/workflows.html +1 -1
  53. package/evals/private-holdout-v1/public-exposure.v2.json +2 -2
  54. package/package.json +1 -1
  55. package/packages/piagent-core/managed/check-questions.mjs +133 -0
  56. package/packages/piagent-core/managed/command-tools.mjs +2 -0
  57. package/packages/piagent-core/managed/helper-run.mjs +1 -1
  58. package/packages/piagent-core/managed/repository-checks.mjs +80 -0
  59. package/packages/piagent-core/managed/workflow.mjs +38 -88
  60. package/packages/piagent-core/package.json +1 -1
  61. package/packages/piagent-webui/dist/client/assets/{App-DqN7B1JR.js → App-CU-wndsb.js} +1 -1
  62. package/packages/piagent-webui/dist/client/assets/{GatewayApp-B3--WjSd.js → GatewayApp-MIvgr7kn.js} +6 -6
  63. package/packages/piagent-webui/dist/client/assets/{InspectionApp-BKQiA0Ce.js → InspectionApp-Bfvr2S8S.js} +1 -1
  64. package/packages/piagent-webui/dist/client/assets/{SessionAgentWorkspace-ZAdRbxVA.js → SessionAgentWorkspace-0Xowe-sG.js} +1 -1
  65. package/packages/piagent-webui/dist/client/assets/{SessionInspectorDrawer-B2e4-1FG.js → SessionInspectorDrawer-72Z5908P.js} +2 -2
  66. package/packages/piagent-webui/dist/client/assets/{SettingsNavigation-C3MC0X4P.js → SettingsNavigation-Bu1A7x4F.js} +1 -1
  67. package/packages/piagent-webui/dist/client/assets/{SettingsPage-D4os5vHj.js → SettingsPage-DxGxE0AF.js} +1 -1
  68. package/packages/piagent-webui/dist/client/assets/{TerminalPanel-CVYUiDkn.js → TerminalPanel-BKgx9SjR.js} +1 -1
  69. package/packages/piagent-webui/dist/client/assets/{WorkspaceCodeEditor-E0Zopcke.js → WorkspaceCodeEditor-DFrh3qs2.js} +1 -1
  70. package/packages/piagent-webui/dist/client/assets/{WorkspaceExplorer-DldLoJyf.js → WorkspaceExplorer-D6ufO-eP.js} +3 -3
  71. package/packages/piagent-webui/dist/client/assets/{index-DcrpSyBK.js → index-C3CJv1wM.js} +2 -2
  72. package/packages/piagent-webui/dist/client/index.html +1 -1
  73. package/packages/piagent-webui/server/transcript-projection.ts +2 -1
  74. package/packages/piagent-webui/shared/process-copy.ts +3 -2
  75. package/schemas/piagent-webui/transcript-v1.schema.json +1 -0
  76. package/scripts/runtime-advisory-exceptions.json +8 -0
@@ -0,0 +1,133 @@
1
+ import { randomUUID } from 'node:crypto';
2
+ import { memberQuestions } from './member-questions.mjs';
3
+ import { effectivePermission } from './permission.mjs';
4
+
5
+ // How much to test is the member's decision: a one-line fix should not cost a
6
+ // thirty-minute suite. The harness asks at the end of a change, before a whole
7
+ // suite and before a push, on the dashboard card or in the Terminal. Bypass skips
8
+ // the questions about the work (it runs the tests that cover the change) but not
9
+ // the one before a push. With no screen nobody can answer: nothing is asked.
10
+
11
+ // How much of the suite a test command covers: 'partial' (a filter, one file, one
12
+ // package), 'suite' (the whole test command) or null when it runs no tests.
13
+ const VERSION_ONLY = /(?:^|\s)(?:--version|-V|--help)(?:\s|$)/;
14
+ const FILTERED = /(?:^|\s)(?:-k|-t|--grep|--testNamePattern|--test-name-pattern|--filter|--only|--testPathPattern)(?:[\s=]|$)|\bgo\s+test\b.*\s-run[\s=]|\bpytest\b.*\s::|\.only\b/;
15
+ const TEST_RUNNER = /\b(npm|pnpm|yarn|bun)\s+(run\s+)?test(:\S+)?(?=\s|$)|\bnode\s+--test\b|\b(vitest|jest|mocha|pytest|rspec|phpunit)\b|\bplaywright\s+test\b|\bpython3?\s+-m\s+(pytest|unittest)\b|\b(go|cargo|swift|dotnet|deno)\s+test\b|\bmake\s+test\b|\bxcodebuild\b.*\btest\b|\b(gradle|gradlew|mvn|mvnw)\b.*\b(test|verify)\b/;
16
+ // Test commands start a command: `npm install -D vitest` or `rm jest.config.ts` only name one.
17
+ const TEST_START = new RegExp(`^(?:${TEST_RUNNER.source})`);
18
+ const LAUNCHER = /^(?:\w+=\S*\s+|time\s+|nohup\s+|timeout\s+\S+\s+|npx\s+(?:-\S+\s+)*|bunx\s+|pnpm\s+(?:exec|dlx)\s+|uv\s+run\s+|poetry\s+run\s+|yarn\s+(?=jest|vitest|mocha|playwright)|node_modules\/\.bin\/|\.\/)+/;
19
+ const partsOf = bare => bare.split(/\s*(?:\|\|?|&&|;)\s*/).map(part => part.replace(/\s\d*>.*$/, '').trim());
20
+ const NOT_TESTS = /\b(lint|typecheck|type-check|tsc|eslint|biome|ruff|mypy|pyright|vet|clippy|format|build)\b/;
21
+ const TARGET_FLAG = /^(-p|--package|-w|--workspace|--tests)$|^(-Dtest=|-only-testing:|--workspace=|--package=)/;
22
+ const VALUE_FLAG = /^(-c|--config|--reporter|--project|--workers|--timeout|--rootDir|--root|-f|--file|-o|--output)$/;
23
+ // A file or folder named on the command line; a flag's own value names none.
24
+ const targetsPart = args => args.some((a, i) => {
25
+ if (TARGET_FLAG.test(a)) return true;
26
+ if (a.startsWith('-') || VALUE_FLAG.test(args[i - 1] ?? '') || a.includes('*') || a.endsWith('...')) return false;
27
+ return a.includes('/') || /\.(test|spec)\.\w+$|_test\.\w+$|^test_\w+\.\w+$/.test(a);
28
+ });
29
+ // What a command runs, without the text it merely quotes (a commit message, an echo).
30
+ const unquoted = text => text.replace(/"[^"]*"|'[^']*'/g, '""');
31
+ export function checkScope(command, declared = []) {
32
+ const text = String(command ?? '').replace(/\s+/g, ' ').trim();
33
+ if (!text || /^(echo|printf|grep|rg|cat|sed|awk|head|tail|less|git|ls|find)\b/.test(text) || VERSION_ONLY.test(text) || /--collect-only/.test(text)) return null;
34
+ const bare = unquoted(text);
35
+ for (const part of partsOf(bare)) {
36
+ const own = part.replace(LAUNCHER, ''), runner = own.match(TEST_START);
37
+ if (!runner) continue;
38
+ if (FILTERED.test(own)) return 'partial';
39
+ return !declared.includes(text) && targetsPart(own.slice(runner[0].length).split(' ').filter(Boolean)) ? 'partial' : 'suite';
40
+ }
41
+ // A script the repository declares: it cannot be narrowed from here.
42
+ const named = declared.find(d => partsOf(bare).some(part => part.startsWith(unquoted(d))));
43
+ return named && !NOT_TESTS.test(named) ? 'suite' : null;
44
+ }
45
+ // The member's own words asking for the whole suite: nothing to ask them then.
46
+ const RUN_ALL = String.raw`(?:full|all(?:\s+the)?|whole(?:\s+the)?|entire(?:\s+the)?|the\s+(?:full|whole|entire))`;
47
+ const FULL_WORDS = new RegExp([
48
+ String.raw`(?:^|\s)(?:run|rerun|execute)\s+${RUN_ALL}\s+(?:tests?|suite|checks?)(?:\s|$|[.,!?])`,
49
+ String.raw`(?:^|\s)(?:chạy|chay)(?:\s+lại)?\s+(?:full|toàn bộ|toan bo|tất cả|tat ca|hết|het)(?:\s+các)?\s+(?:tests?|suite|kiểm thử|kiểm tra)`,
50
+ String.raw`(?:^|\s)(?:chạy|chay)(?:\s+lại)?\s+tests?\s+(?:full|toàn bộ|toan bo|tất cả|tat ca|hết|het)`,
51
+ ].join('|'), 'i');
52
+ const NOT_WORDS = /(không|khong|đừng|chưa|\bno\b|\bnot\b|don't|skip|bỏ qua)[^.!?\n]{0,24}$/i;
53
+ export function asksFullChecks(text) {
54
+ const value = String(text ?? ''), hit = value.match(FULL_WORDS);
55
+ return !!hit && !NOT_WORDS.test(value.slice(0, hit.index));
56
+ }
57
+ // A push the harness can see; handoff-policy still asks for its own approval.
58
+ export const isGitPush = command => /(^|[\s;&|(])git\s+(?:(?:-C|-c)\s+\S+\s+|--\S+\s+)*push\b/.test(unquoted(String(command ?? '')));
59
+
60
+ const PART = 'Chỉ chạy phần liên quan', KEEP = 'Giữ kết quả phần đã chạy', FULL = 'Chạy toàn bộ', NONE = 'Không chạy lúc này';
61
+ const PUSH_FULL = 'Chạy toàn bộ rồi mới push', PUSH_NOW = 'Push luôn, không chạy thêm';
62
+ const GATEWAY_UI = Symbol.for('piagent.webui.gateway-runtime-ui.v1');
63
+
64
+ // The screen to ask on: the dashboard's card, else the Terminal. The turn's end
65
+ // has no tool context, so the Terminal comes from the extension runner there.
66
+ function surfaceOf(self, ctx) {
67
+ const sessionId = self.session?.sessionManager?.getSessionId?.();
68
+ if (sessionId && memberQuestions.hasSurface(sessionId)) return { sessionId };
69
+ const runner = self.session?.extensionRunner, ui = ctx ? ctx.hasUI && ctx.ui : runner?.hasUI?.() && runner.getUIContext?.();
70
+ return ui?.select && !ui[GATEWAY_UI] ? { ui } : null;
71
+ }
72
+ // The label picked, { other } for the member's own words, undefined for no answer (Esc, stopped).
73
+ async function ask(surface, question, labels, signal) {
74
+ if (surface.ui) return surface.ui.select(question, labels, { signal });
75
+ const questions = [{ header: 'Test', question, options: labels.map(label => ({ label, description: '' })), multiSelect: false }];
76
+ const answer = await memberQuestions.ask({ sessionId: surface.sessionId, toolCallId: `check-scope-${randomUUID()}`, questions, signal }).catch(() => null);
77
+ if (!answer || answer.skipped) return undefined;
78
+ const { selected, other } = answer.answers[0];
79
+ return other ? { other } : labels[selected[0]];
80
+ }
81
+
82
+ // At the end of a change: { choice: 'partial' | 'full' | 'skip', words? }, or null
83
+ // when nobody can answer. No answer takes the cheap choice: the status says only part ran.
84
+ export async function askCheckScope(self, { partPassed = false, signal } = {}) {
85
+ const surface = surfaceOf(self);
86
+ if (!surface) return null;
87
+ if (effectivePermission(self) === 'bypass') return { choice: 'partial' };
88
+ const part = partPassed ? KEEP : PART;
89
+ const picked = await ask(surface, partPassed ? 'Code đã đổi, phần test liên quan đã pass. Có chạy toàn bộ test không?' : 'Code đã đổi, chưa chạy test. Chạy phần nào?', [part, FULL, NONE], signal);
90
+ if (signal?.aborted) return null;
91
+ if (picked?.other) return { choice: 'partial', words: picked.other };
92
+ return { choice: picked === FULL ? 'full' : picked === NONE ? 'skip' : 'partial' };
93
+ }
94
+
95
+ const PARTIAL_REASON = 'managed-check-scope: the member chose to run only the tests that cover the change. Run one file, a filter or one package, not the whole suite. If this project has no way to run part of it, say so and repeat the command: the member is asked.';
96
+ const BYPASS_REASON = 'managed-check-scope: run the tests that cover the change (one file, a filter, one package). A whole-suite run needs the member to ask for it, or their answer before a push. If this project has no way to run part of it, say so and repeat the command.';
97
+ const PUSH_REASON = 'managed-check-scope: the member wants the whole suite before this push. Run it, fix what fails, then push.';
98
+ const STOPPED_REASON = 'managed-check-scope: the member did not answer whether to push now. Do not push; say so and let them decide.';
99
+ const WORDS_REASON = words => `managed-check-scope: this command did not run. The member answered about testing: "${String(words).slice(0, 500)}". Follow that.`;
100
+
101
+ // Before a whole suite or a push: returns to let it run, throws to send the agent another way.
102
+ export async function beforeCheckOrPush(self, command, ctx, signal) {
103
+ const run = self.run;
104
+ if (!run || run.policy?.verify === 'off') return;
105
+ // Calls sent together wait for one answer: the next one sees it.
106
+ const turn = (run.scopeQuestion ?? Promise.resolve()).then(() => holdOrLet(self, run, command, ctx, signal));
107
+ run.scopeQuestion = turn.catch(() => {});
108
+ return turn;
109
+ }
110
+ async function holdOrLet(self, run, command, ctx, signal) {
111
+ const push = isGitPush(command);
112
+ if (!push && (checkScope(command, run.checks.commands) !== 'suite' || run.fullAsked || run.scopeChoice === 'full')) return;
113
+ const surface = surfaceOf(self, ctx);
114
+ if (!surface) return;
115
+ if (push) {
116
+ const now = await self.digest();
117
+ if (run.suitePassedOn(now) || (run.pushAllowedOn !== undefined && run.pushAllowedOn === now)) return;
118
+ const picked = await ask(surface, 'Sắp push code nhưng toàn bộ test chưa pass trên code này. Làm gì?', [PUSH_FULL, PUSH_NOW], signal);
119
+ if (picked === PUSH_NOW) { run.pushAllowedOn = now; return; }
120
+ if (picked?.other) throw Error(WORDS_REASON(picked.other));
121
+ if (picked !== PUSH_FULL) throw Error(STOPPED_REASON);
122
+ run.scopeChoice = 'full';
123
+ throw Error(PUSH_REASON);
124
+ }
125
+ // Sent another way once; the same command again means the part did not do: the member decides (Bypass: it runs).
126
+ const held = run.scopeHeld ??= new Set(), again = held.has(command); held.add(command);
127
+ if (effectivePermission(self) === 'bypass') { if (again) return; throw Error(BYPASS_REASON); }
128
+ if (run.scopeChoice === 'partial' && !again) throw Error(PARTIAL_REASON);
129
+ const picked = await ask(surface, `Agent muốn chạy toàn bộ test: ${String(command).slice(0, 160)}`, [PART, FULL], signal);
130
+ if (picked === FULL) { run.scopeChoice = 'full'; return; }
131
+ run.scopeChoice = 'partial';
132
+ throw Error(picked?.other ? WORDS_REASON(picked.other) : PARTIAL_REASON);
133
+ }
@@ -1,4 +1,5 @@
1
1
  import { spawn } from 'node:child_process';
2
+ import { beforeCheckOrPush } from './check-questions.mjs';
2
3
  import { asksOnlyHandoff, broadAccess, effectivePermission, networkConfirmation } from './permission.mjs';
3
4
  import { handoffReason } from '../runtime/policy/handoff-policy.mjs';
4
5
  import { engineAlive, engineLauncher } from './container-engine.mjs';
@@ -105,6 +106,7 @@ function commandTool(self, kind) {
105
106
  if (memberOnly) throw Error(MEMBER_ONLY(memberOnly));
106
107
  const notSimulator = kind === 'simulator' ? simulatorCommandReason(args.command, self.cwd) : null;
107
108
  if (notSimulator) throw Error(`managed-simulator-command: ${notSimulator}.`);
109
+ if (kind !== 'simulator') await beforeCheckOrPush(self, args.command, ctx, signal); // how much to test, before the command's own approval
108
110
  const confirm = await spec.confirm(self, args.command);
109
111
  if (confirm !== null) {
110
112
  const why = confirm === 'ask' ? null : stillAsks(self, confirm), handoff = await handoffReason(args.command);
@@ -144,7 +144,7 @@ async function answerUnder(managed, key, task, signal, harness, snapshot, parts,
144
144
  (managed.jobTitles ??= new WeakMap()).set(runtime, jobTitle(task, title));
145
145
  const setup = HELPER_SETUP[role], memory = helperMemoryTools(managed, () => grant, renew);
146
146
  boundary = new ManagedToolBoundary({ cwd: managed.cwd, sdkRoot: managed.sdk, protectedRoots: managed.protectedRoots, readOnly: true, commands: setup.commands });
147
- const checks = role === 'verify' ? `\n\nRepository checks: ${managed.checks.commands.length ? managed.checks.commands.map(c => '`' + c + '`').join(', ') : 'none declared or detected; choose the tests, type check or build that cover the claims'}.` : '';
147
+ const checks = role === 'verify' ? `\n\nRepository checks: ${managed.checks.commands.length ? managed.checks.commands.map(c => '`' + c + '`').join(', ') : 'none declared or detected; choose the tests, type check or build that cover the claims'}.${managed.run?.fullAsked || managed.run?.scopeChoice === 'full' ? '' : ' Run only the tests that cover the claims: the member decides about a whole-suite run.'}` : '';
148
148
  // One helper session answers the brief (with one part of the patch for a
149
149
  // review in parts); its reply and tokens. A helper runs at its role's
150
150
  // level from Studio (fixed by the Harness, or its main agent's).
@@ -0,0 +1,80 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import { discoverDeliveryContext } from './delivery-context.mjs';
4
+
5
+ // Checks come from the repository: a "## Checks" section in AGENTS.md (code
6
+ // block lines or `command` bullets), else what its manifests imply.
7
+ const HEADING = /^#{1,6}\s+(checks?|verification|kiểm tra)\s*$/i;
8
+ export function declaredChecks(agentsFiles = []) {
9
+ const out = [];
10
+ for (const file of agentsFiles) {
11
+ let inside = false, fence = false;
12
+ for (const line of String(file.content ?? '').split('\n')) {
13
+ if (!fence && /^#{1,6}\s/.test(line)) { inside = HEADING.test(line.trim()); continue; }
14
+ if (!inside) continue;
15
+ if (/^\s*(```|~~~)/.test(line)) { fence = !fence; continue; }
16
+ const command = (fence ? line : line.match(/^\s*[-*]\s+`([^`]+)`/)?.[1] ?? '').trim();
17
+ if (command && !command.startsWith('#') && command.length <= 200 && !out.includes(command) && out.length < 10) out.push(command);
18
+ }
19
+ }
20
+ return out;
21
+ }
22
+ export function detectedChecks(dir) {
23
+ const has = name => { try { const s = fs.lstatSync(path.join(dir, name)); return s.isFile() && s.size <= 1024 * 1024; } catch { return false; } };
24
+ const out = [];
25
+ if (has('package.json')) {
26
+ try {
27
+ const scripts = JSON.parse(fs.readFileSync(path.join(dir, 'package.json'), 'utf8')).scripts ?? {};
28
+ const runner = has('pnpm-lock.yaml') ? 'pnpm' : has('yarn.lock') ? 'yarn' : has('bun.lock') || has('bun.lockb') ? 'bun' : 'npm';
29
+ for (const name of ['typecheck', 'type-check', 'lint', 'test', 'test:unit', 'test:integration', 'test:api', 'test:contract', 'test:e2e']) if (typeof scripts[name] === 'string') out.push(name === 'test' && runner === 'npm' ? 'npm test' : `${runner} run ${name}`);
30
+ } catch { /* not JSON: nothing implied */ }
31
+ }
32
+ if (has('go.mod')) out.push('go vet ./...', 'go test ./...');
33
+ if (has('Package.swift')) out.push('swift build', 'swift test');
34
+ if (has('Cargo.toml')) out.push('cargo check', 'cargo test');
35
+ if (has('pyproject.toml') || has('pytest.ini')) out.push(has('uv.lock') ? 'uv run pytest' : 'pytest');
36
+ if (has('pom.xml')) out.push(has('mvnw') ? './mvnw verify' : 'mvn verify');
37
+ if (has('build.gradle') || has('build.gradle.kts')) out.push(has('gradlew') ? './gradlew test' : 'gradle test');
38
+ return out.slice(0, 16);
39
+ }
40
+ export function repositoryChecks(agentsFiles, cwd, top = cwd) {
41
+ const declared = declaredChecks(agentsFiles);
42
+ if (declared.length) return { source: 'agents', commands: declared };
43
+ const detected = detectedChecks(cwd);
44
+ // Include package/repository-local checks even when the workspace root has a
45
+ // lint command. These are candidates, not a request to test unrelated repos.
46
+ const quote = value => "'" + value.replaceAll("'", "'\\''") + "'";
47
+ const nested = discoverDeliveryContext(cwd).units.filter(unit => unit.path !== '.').flatMap(unit =>
48
+ detectedChecks(path.join(cwd, unit.path)).map(command => `cd ${quote(unit.path)} && ${command}`));
49
+ const commands = [...new Set([...detected, ...nested])].slice(0, 64);
50
+ return { source: 'detected', commands: commands.length || cwd === top ? commands : detectedChecks(top) };
51
+ }
52
+ // A command that verifies code: a declared check, or a known test, type,
53
+ // lint or build runner. Text tools that merely mention one do not count.
54
+ const RUNNER = /\b(npm|pnpm|yarn|bun)\s+(run\s+)?(test|lint|typecheck|type-check|check|build|verify)\b|\bnode\s+--test\b|\b(tsc|vitest|jest|eslint|biome|ruff|mypy|pyright|pytest|rspec|phpunit)\b|\bplaywright\s+test\b|\bpython3?\s+-m\s+(pytest|unittest|mypy)\b|\bgo\s+(test|vet|build)\b|\bcargo\s+(test|check|clippy|build)\b|\bswift\s+(test|build)\b|\bxcodebuild\b.*\b(test|build)\b|\bmake\s+(test|check|lint)\b|\b(gradle|gradlew|mvn|mvnw)\b.*\b(test|check|verify|compile|package|build)\b|\bdotnet\s+(test|build)\b|\bdeno\s+(test|check|lint)\b/;
55
+ // Files no check covers: documentation, pictures and documents,
56
+ // and Spec Kit's .specify/ state. A turn that changed only these changed no
57
+ // code: no check is required of it (one is still reported if it ran).
58
+ const NON_CODE = /\.(md|mdx|markdown|rst|adoc|asciidoc|org|png|jpe?g|gif|webp|bmp|ico|pdf|docx?|xlsx?|pptx?|odt|ods|odp|rtf)$/i;
59
+ export function nonCodePath(file) {
60
+ const name = String(file ?? '').replaceAll('\\', '/');
61
+ return !!name && (NON_CODE.test(name) || /(^|\/)\.specify\//.test(name) || /(^|\/)(LICENSE|NOTICE|AUTHORS|CODEOWNERS)$/.test(name));
62
+ }
63
+ export const onlyNonCode = paths => { const list = [...(paths ?? [])]; return list.length > 0 && list.every(nonCodePath); };
64
+
65
+ // A command that only reads: each part starts with a reading tool and nothing
66
+ // is written to a file. Anything else may change files. Git may name the
67
+ // repository first (git -C <folder>): a workspace folder holding several
68
+ // repositories is read that way.
69
+ const GIT_READ = String.raw`git(\s+(-C\s+('[^']*'|"[^"]*"|\S+)|-c\s+\S+|--no-pager))*\s+(status|diff|log|show|branch|ls-files|rev-parse|rev-list|blame|describe|shortlog|cat-file|for-each-ref|reflog(?!\s+(expire|delete))|remote(\s+(-v|--verbose|show|get-url)\b|$))`;
70
+ const READER = new RegExp(String.raw`^(ls|cat|head|tail|wc|grep|egrep|rg|find|fd|sed|awk|cut|sort|uniq|tr|echo|printf|pwd|which|stat|file|du|df|tree|jq|diff|cmp|basename|dirname|realpath|date|true|cd|${GIT_READ})(\b|$)`);
71
+ export function isReadOnlyCommand(command) {
72
+ const text = String(command ?? '').trim();
73
+ if (!text || />(?!>|\s*&\d|\s*\/dev\/null)|\btee\b|\bsed\s+(-[a-zA-Z]*i|--in-place)|\s-(delete|exec|execdir|fprint|ok)\b|\bxargs\b|\$\(|`/.test(text)) return false;
74
+ return text.split(/&&|\|\||;|\||\n/).every(part => !part.trim() || READER.test(part.trim()));
75
+ }
76
+ export function isCheckCommand(command, declared = []) {
77
+ const text = String(command ?? '').replace(/\s+/g, ' ').trim();
78
+ if (!text || /^(echo|printf|grep|rg|cat|sed|awk|head|tail|less|git|ls|find)\b/.test(text)) return false;
79
+ return declared.some(d => text.includes(d)) || RUNNER.test(text);
80
+ }
@@ -1,10 +1,10 @@
1
- import fs from 'node:fs';
2
- import path from 'node:path';
3
1
  import { reviewUnavailableReason } from './patch-snapshot.mjs';
4
2
  import { failureCode, unnamedFailureText } from '../runtime/managed-failure.mjs';
5
3
  import { TsDiagnostics } from './ts-diagnostics.mjs';
6
4
  import { checkpointsOf } from './checkpoints.mjs';
7
- import { discoverDeliveryContext } from './delivery-context.mjs';
5
+ import { declaredChecks, detectedChecks, repositoryChecks, isCheckCommand, isReadOnlyCommand, nonCodePath, onlyNonCode } from './repository-checks.mjs';
6
+ export { declaredChecks, detectedChecks, repositoryChecks, isCheckCommand, isReadOnlyCommand, nonCodePath, onlyNonCode };
7
+ import { askCheckScope, asksFullChecks, beforeCheckOrPush, checkScope } from './check-questions.mjs';
8
8
  import { LANE_LIMITS, patchStats, changeLane, lanePolicy } from './risk-lanes.mjs';
9
9
  import { briefCounts, decisionsText, ledgerGuard, ledgerOf, ledgerWords, reviewFocus, saveLedger, setStatus, settleLedger } from './ledger.mjs';
10
10
 
@@ -22,83 +22,6 @@ export function workflowPolicy(manifest) {
22
22
  return { plan: mode(w.plan), verify: mode(w.verify), review: config.review ? mode(w.review) : 'off', maxFixLoops: loops, lanes: w.lanes !== false };
23
23
  }
24
24
 
25
- // Checks come from the repository: a "## Checks" section in AGENTS.md (code
26
- // block lines or `command` bullets), else what its manifests imply.
27
- const HEADING = /^#{1,6}\s+(checks?|verification|kiểm tra)\s*$/i;
28
- export function declaredChecks(agentsFiles = []) {
29
- const out = [];
30
- for (const file of agentsFiles) {
31
- let inside = false, fence = false;
32
- for (const line of String(file.content ?? '').split('\n')) {
33
- if (!fence && /^#{1,6}\s/.test(line)) { inside = HEADING.test(line.trim()); continue; }
34
- if (!inside) continue;
35
- if (/^\s*(```|~~~)/.test(line)) { fence = !fence; continue; }
36
- const command = (fence ? line : line.match(/^\s*[-*]\s+`([^`]+)`/)?.[1] ?? '').trim();
37
- if (command && !command.startsWith('#') && command.length <= 200 && !out.includes(command) && out.length < 10) out.push(command);
38
- }
39
- }
40
- return out;
41
- }
42
- export function detectedChecks(dir) {
43
- const has = name => { try { const s = fs.lstatSync(path.join(dir, name)); return s.isFile() && s.size <= 1024 * 1024; } catch { return false; } };
44
- const out = [];
45
- if (has('package.json')) {
46
- try {
47
- const scripts = JSON.parse(fs.readFileSync(path.join(dir, 'package.json'), 'utf8')).scripts ?? {};
48
- const runner = has('pnpm-lock.yaml') ? 'pnpm' : has('yarn.lock') ? 'yarn' : has('bun.lock') || has('bun.lockb') ? 'bun' : 'npm';
49
- for (const name of ['typecheck', 'type-check', 'lint', 'test', 'test:unit', 'test:integration', 'test:api', 'test:contract', 'test:e2e']) if (typeof scripts[name] === 'string') out.push(name === 'test' && runner === 'npm' ? 'npm test' : `${runner} run ${name}`);
50
- } catch { /* not JSON: nothing implied */ }
51
- }
52
- if (has('go.mod')) out.push('go vet ./...', 'go test ./...');
53
- if (has('Package.swift')) out.push('swift build', 'swift test');
54
- if (has('Cargo.toml')) out.push('cargo check', 'cargo test');
55
- if (has('pyproject.toml') || has('pytest.ini')) out.push(has('uv.lock') ? 'uv run pytest' : 'pytest');
56
- if (has('pom.xml')) out.push(has('mvnw') ? './mvnw verify' : 'mvn verify');
57
- if (has('build.gradle') || has('build.gradle.kts')) out.push(has('gradlew') ? './gradlew test' : 'gradle test');
58
- return out.slice(0, 16);
59
- }
60
- export function repositoryChecks(agentsFiles, cwd, top = cwd) {
61
- const declared = declaredChecks(agentsFiles);
62
- if (declared.length) return { source: 'agents', commands: declared };
63
- const detected = detectedChecks(cwd);
64
- // Include package/repository-local checks even when the workspace root has a
65
- // lint command. These are candidates, not a request to test unrelated repos.
66
- const quote = value => "'" + value.replaceAll("'", "'\\''") + "'";
67
- const nested = discoverDeliveryContext(cwd).units.filter(unit => unit.path !== '.').flatMap(unit =>
68
- detectedChecks(path.join(cwd, unit.path)).map(command => `cd ${quote(unit.path)} && ${command}`));
69
- const commands = [...new Set([...detected, ...nested])].slice(0, 64);
70
- return { source: 'detected', commands: commands.length || cwd === top ? commands : detectedChecks(top) };
71
- }
72
- // A command that verifies code: a declared check, or a known test, type,
73
- // lint or build runner. Text tools that merely mention one do not count.
74
- const RUNNER = /\b(npm|pnpm|yarn|bun)\s+(run\s+)?(test|lint|typecheck|type-check|check|build|verify)\b|\bnode\s+--test\b|\b(tsc|vitest|jest|eslint|biome|ruff|mypy|pyright|pytest|rspec|phpunit)\b|\bplaywright\s+test\b|\bpython3?\s+-m\s+(pytest|unittest|mypy)\b|\bgo\s+(test|vet|build)\b|\bcargo\s+(test|check|clippy|build)\b|\bswift\s+(test|build)\b|\bxcodebuild\b.*\b(test|build)\b|\bmake\s+(test|check|lint)\b|\b(gradle|gradlew|mvn|mvnw)\b.*\b(test|check|verify|compile|package|build)\b|\bdotnet\s+(test|build)\b|\bdeno\s+(test|check|lint)\b/;
75
- // Files no check covers: documentation, pictures and documents,
76
- // and Spec Kit's .specify/ state. A turn that changed only these changed no
77
- // code: no check is required of it (one is still reported if it ran).
78
- const NON_CODE = /\.(md|mdx|markdown|rst|adoc|asciidoc|org|png|jpe?g|gif|webp|bmp|ico|pdf|docx?|xlsx?|pptx?|odt|ods|odp|rtf)$/i;
79
- export function nonCodePath(file) {
80
- const name = String(file ?? '').replaceAll('\\', '/');
81
- return !!name && (NON_CODE.test(name) || /(^|\/)\.specify\//.test(name) || /(^|\/)(LICENSE|NOTICE|AUTHORS|CODEOWNERS)$/.test(name));
82
- }
83
- export const onlyNonCode = paths => { const list = [...(paths ?? [])]; return list.length > 0 && list.every(nonCodePath); };
84
-
85
- // A command that only reads: each part starts with a reading tool and nothing
86
- // is written to a file. Anything else may change files. Git may name the
87
- // repository first (git -C <folder>): a workspace folder holding several
88
- // repositories is read that way.
89
- const GIT_READ = String.raw`git(\s+(-C\s+('[^']*'|"[^"]*"|\S+)|-c\s+\S+|--no-pager))*\s+(status|diff|log|show|branch|ls-files|rev-parse|rev-list|blame|describe|shortlog|cat-file|for-each-ref|reflog(?!\s+(expire|delete))|remote(\s+(-v|--verbose|show|get-url)\b|$))`;
90
- const READER = new RegExp(String.raw`^(ls|cat|head|tail|wc|grep|egrep|rg|find|fd|sed|awk|cut|sort|uniq|tr|echo|printf|pwd|which|stat|file|du|df|tree|jq|diff|cmp|basename|dirname|realpath|date|true|cd|${GIT_READ})(\b|$)`);
91
- export function isReadOnlyCommand(command) {
92
- const text = String(command ?? '').trim();
93
- if (!text || />(?!>|\s*&\d|\s*\/dev\/null)|\btee\b|\bsed\s+(-[a-zA-Z]*i|--in-place)|\s-(delete|exec|execdir|fprint|ok)\b|\bxargs\b|\$\(|`/.test(text)) return false;
94
- return text.split(/&&|\|\||;|\||\n/).every(part => !part.trim() || READER.test(part.trim()));
95
- }
96
- export function isCheckCommand(command, declared = []) {
97
- const text = String(command ?? '').replace(/\s+/g, ' ').trim();
98
- if (!text || /^(echo|printf|grep|rg|cat|sed|awk|head|tail|less|git|ls|find)\b/.test(text)) return false;
99
- return declared.some(d => text.includes(d)) || RUNNER.test(text);
100
- }
101
-
102
25
  // update_plan: the agent's checklist, kept as a session entry so it survives
103
26
  // compaction and "continue", and shown to the member beside the conversation.
104
27
  export const PLAN_ENTRY = 'agent-watch-plan';
@@ -148,7 +71,7 @@ export function workflowPrompt(policy, checks) {
148
71
  if (policy.plan !== 'off') lines.push(`- Plan: for work with several steps keep a checklist with update_plan and update it as you go. When the member asks for several items (plans, files, tickets), put every item in the checklist and work through all of them; do not end your turn to report between items.${policy.plan === 'require' ? ' For a complex task, file edits are refused until a plan exists. A checklist left with pending steps sends you back to the next one until every step is completed or deferred: if you cannot go on without the member, ask with ask_user. Mark a step deferred only when the member asked to leave it for later or it is no longer needed; never mark completed a step you did not do.' : ''}`);
149
72
  if (policy.verify !== 'off') {
150
73
  const list = checks.commands.length ? `${checks.commands.map(c => '`' + c + '`').join(', ')}${checks.source === 'detected' ? ' (detected; the repository declares none in AGENTS.md "## Checks")' : ''}` : 'none declared: choose the tests, type check or build that cover the change';
151
- lines.push(`- Verify: after changing code, run the repository checks that cover the change and fix failures before you finish. Repository checks: ${list}.${policy.verify === 'require' ? ' The turn does not end until a check has passed on the final code.' : ''} Only the member may skip the checks: when they ask to, call waive_checks with their words; never skip them on your own.`);
74
+ lines.push(`- Verify: after changing code, run the tests that cover the change (one file, a filter, one package) and fix failures before you finish; after a failure rerun the part that failed. Do not choose the whole test suite yourself: it can take long, so the harness asks the member before a full run and before a push. Repository checks: ${list}.${policy.verify === 'require' ? ' The turn does not end until a check has passed on the final code.' : ''} Only the member may skip the checks: when they ask to, call waive_checks with their words; never skip them on your own.`);
152
75
  }
153
76
  // What each severity asks: blocking is fixed or argued, major decided, minor only listed.
154
77
  const severities = ' Blocking findings: fix them, or reject one with resolve_objection and the reviewer judges your reason; a disagreement that remains goes to the member. Major findings: fix them or reject them with resolve_objection; no new review follows. Minor findings are listed for the member and need nothing.';
@@ -251,6 +174,8 @@ export class RunProcess {
251
174
  // its answer and see whether the code moved).
252
175
  ledger: [], disputes: [], verifyFails: [], claimsAsked: false, claimsAt: null, claimsRechecked: false, claimsDone: false, mainReviews: 0, minorFindings: 0,
253
176
  sentAt: null, sentDigest: null, rejudged: false, reviewSettled: false, decideAsked: false,
177
+ // How much of the suite the member wants run (check-questions.mjs).
178
+ scopeChoice: null, scopeWords: null, fullAsked: asksFullChecks(request), pushAllowedOn: undefined,
254
179
  // The patch's risk lane (workflow.lanes) and the main agent's own web lookups.
255
180
  lane: null, laneStats: null, laneDigest: null, webLookups: 0 });
256
181
  }
@@ -275,17 +200,25 @@ export class RunProcess {
275
200
  async afterTool(name, args, ok, digestOf) {
276
201
  if (['write', 'edit'].includes(name) && ok) this.edited = true;
277
202
  if (name === 'bash' && isCheckCommand(args?.command, this.checks.commands)) {
203
+ const scope = checkScope(args.command, this.checks.commands), digest = await digestOf(), last = this.lastCheck;
278
204
  this.checksRun += 1; if (!ok) this.checksFailed += 1;
279
- this.lastCheck = { ok, digest: await digestOf(), mutations: this.mutations };
205
+ // A lint after a partial test run does not make it the whole suite.
206
+ this.lastCheck = { ok, digest, mutations: this.mutations, scope: scope ?? (last?.scope === 'partial' && last.digest === digest ? 'partial' : 'other') };
207
+ // The member's "run it all" covers one run; after a fix they are asked again.
208
+ if (scope === 'suite' && this.scopeChoice === 'full') this.scopeChoice = null;
280
209
  // A command may change files, so it counts. Without a git repository to
281
210
  // compare the code against, one that only reads does not: counting every
282
211
  // command reported code changes in turns that only read and checked.
283
212
  } else if (['write', 'edit'].includes(name) && ok || name === 'bash' && (this.startDigest !== null || !isReadOnlyCommand(args?.command))) this.mutations += 1;
284
213
  }
285
- verifiedOn(digest) {
214
+ passedOn(digest) {
286
215
  const c = this.lastCheck;
287
216
  return !!c?.ok && (digest !== null && c.digest !== null ? c.digest === digest : c.mutations === this.mutations);
288
217
  }
218
+ partOnlyOn(digest) { return this.passedOn(digest) && this.lastCheck.scope === 'partial'; }
219
+ suitePassedOn(digest) { return this.passedOn(digest) && this.lastCheck.scope === 'suite'; }
220
+ // A partial run counts unless the member wants the whole suite.
221
+ verifiedOn(digest) { return this.passedOn(digest) && !(this.partOnlyOn(digest) && (this.fullAsked || this.scopeChoice === 'full')); }
289
222
  // Version 2 (a broker advertising "process-v2") adds whether code was
290
223
  // changed without the required plan and how many calls named no tool.
291
224
  // Version 3 adds helper objections, those the agent answered and the
@@ -351,10 +284,26 @@ export async function completionGate(managed, run, signal) {
351
284
  // The member declined the approval a check needed (a JDK, Docker, the
352
285
  // network): asking again would only repeat the same answer.
353
286
  if (policy.verify === 'require' && !run.verified && run.approvalDeclined && run.fixLoops > 0) verifyGaveUp = true;
354
- if (policy.verify === 'require' && !run.verified && !run.docsOnly && !verifyGaveUp && run.waivedDigest !== digest) {
287
+ // "Do not run" covered the code it was given for; new code is asked about again.
288
+ if (run.scopeChoice === 'skip' && run.waivedDigest !== digest) run.scopeChoice = null;
289
+ // How much to test is the member's call; asked once, not while a check is failing.
290
+ if (policy.verify === 'require' && !run.docsOnly && !verifyGaveUp && run.waivedDigest !== digest && !run.scopeChoice && !run.fullAsked && run.lastCheck?.ok !== false && (!run.verified || run.partOnlyOn(digest))) {
291
+ const answer = await askCheckScope(managed, { partPassed: run.partOnlyOn(digest), signal });
292
+ if (stopped()) { interrupted = true; break; }
293
+ if (answer) {
294
+ run.scopeChoice = answer.choice; run.scopeWords = answer.words ?? null;
295
+ if (answer.choice === 'skip') run.waivedDigest = digest; // the same record as waive_checks: this exact code, reported unverified
296
+ run.verified = run.verifiedOn(digest);
297
+ }
298
+ }
299
+ if (policy.verify === 'require' && (!run.verified || run.scopeWords) && !run.docsOnly && !verifyGaveUp && run.waivedDigest !== digest) {
355
300
  run.fixLoops += 1;
356
301
  const list = run.checks.commands.length ? run.checks.commands.map(c => '`' + c + '`').join(', ') : 'the tests, type check or build that cover the change';
357
- await send(`Harness process check: code changed in this turn, but no check has passed on the current code. Run the checks that cover your change (${list}) and fix what fails. If a check cannot run because the machine lacks something (a runtime such as a JDK, Docker, a database or another service, the network), request the approval that makes it run (run_with_network, run_with_docker, start_docker, run_on_host) or ask the member with ask_user, then run it; install or start nothing without that approval. If it fails for a reason unrelated to your change, say so plainly.`,
302
+ const words = run.scopeWords; run.scopeWords = null;
303
+ const ask = words ? `The member answered about testing: "${String(words).slice(0, 500)}". Follow that and fix what fails.`
304
+ : run.scopeChoice === 'partial' ? 'Run only the tests that cover your change (one file, a filter, one package), not the whole suite, and fix what fails.'
305
+ : `Run the checks that cover your change (${list}) and fix what fails.${run.fullAsked || run.scopeChoice === 'full' ? ' The member wants the whole suite: a partial run does not count.' : ''}`;
306
+ await send(`Harness process check: code changed in this turn, but no check has passed on the current code. ${ask} If a check cannot run because the machine lacks something (a runtime such as a JDK, Docker, a database or another service, the network), request the approval that makes it run (run_with_network, run_with_docker, start_docker, run_on_host) or ask the member with ask_user, then run it; install or start nothing without that approval. If it fails for a reason unrelated to your change, say so plainly.`,
358
307
  { phase: 'verify', loop: run.fixLoops, maxLoops: policy.maxFixLoops, lastCheckFailed: run.lastCheck?.ok === false });
359
308
  continue;
360
309
  }
@@ -363,7 +312,7 @@ export async function completionGate(managed, run, signal) {
363
312
  const answer = run.sentAt !== null ? answerSince(run.sentAt) + decisionsText(run, 'review') : '';
364
313
  // After a fix the reviewer checks its blocking findings and the files changed since.
365
314
  const focus = run.sentAt !== null ? await reviewFocus(managed) : null, previous = (review?.findings ?? []).filter(f => f.severity === 'blocking').map((f, i) => `${i + 1}. ${findingText(f)}`).join('\n');
366
- const brief = `Review the current patch against the member's request.\n\nChecks: ${run.verified ? 'a repository check passed on this code' : 'no check has passed on this code'}.${answer ? `\n\nThe main agent's answer to your previous blocking findings (the code changed after it):\n${answer}` : ''}${focus ? `\n\nSince your last review only these files changed: ${focus.files.join(', ')}. Judge whether each previous blocking finding is fixed (repeat it when it is not) and review the changes in these files; the rest of the patch was reviewed and has not changed.${previous ? `\nYour previous blocking findings:\n${previous}` : ''}` : ''}`;
315
+ const brief = `Review the current patch against the member's request.\n\nChecks: ${run.partOnlyOn(digest) ? 'only part of the test suite passed on this code' : run.verified ? 'a repository check passed on this code' : 'no check has passed on this code'}.${answer ? `\n\nThe main agent's answer to your previous blocking findings (the code changed after it):\n${answer}` : ''}${focus ? `\n\nSince your last review only these files changed: ${focus.files.join(', ')}. Judge whether each previous blocking finding is fixed (repeat it when it is not) and review the changes in these files; the rest of the patch was reviewed and has not changed.${previous ? `\nYour previous blocking findings:\n${previous}` : ''}` : ''}`;
367
316
  managed.reviewFocus = focus;
368
317
  try { await managed.delegate({ role: 'review', task: brief }, signal, { harness: true }); }
369
318
  catch (error) {
@@ -443,8 +392,8 @@ export async function completionGate(managed, run, signal) {
443
392
  if (!run.changed && !run.disputes.length && !ledgerOf(run).length) return;
444
393
  const finalPlan = currentPlan(session.sessionManager), planOpen = run.planUpdated ? finalPlan?.plan?.filter(p => p.status === 'pending' || p.status === 'in_progress').length ?? 0 : 0;
445
394
  const status = { verified: run.verified, reviewed: run.reviewed, blockingOpen: run.blockingOpen, checks: run.checksRun, fixLoops: run.fixLoops,
446
- ...(planOpen ? { planOpen } : {}), ...(run.planSkipped ? { planSkipped: true } : {}), ...(!run.verified && run.waivedDigest === digest ? { checksWaived: true } : {}), ...(run.disputes.length ? { disputes: run.disputes.length } : {}), ...(run.changed ? {} : { unchanged: true }) };
447
- const words = [...(run.changed ? [run.verified ? 'a check passed on the final code' : policy.verify === 'off' ? null : run.docsOnly ? 'only documentation changed: no check needed' : run.waivedDigest === digest ? 'no check passed on the final code: the member waived the checks' : 'no check passed on the final code',
395
+ ...(planOpen ? { planOpen } : {}), ...(run.planSkipped ? { planSkipped: true } : {}), ...(!run.verified && run.waivedDigest === digest ? { checksWaived: true } : {}), ...(run.verified && run.partOnlyOn(digest) ? { partOnly: true } : {}), ...(run.disputes.length ? { disputes: run.disputes.length } : {}), ...(run.changed ? {} : { unchanged: true }) };
396
+ const words = [...(run.changed ? [run.partOnlyOn(digest) && run.verified ? 'only part of the test suite passed on the final code' : run.verified ? 'a check passed on the final code' : policy.verify === 'off' ? null : run.docsOnly ? 'only documentation changed: no check needed' : run.waivedDigest === digest ? 'no check passed on the final code: the member waived the checks' : 'no check passed on the final code',
448
397
  run.reviewed ? (run.blockingOpen ? `review: ${run.blockingOpen} blocking issue(s) still open` : 'review: no blocking issue') : policy.review === 'off' ? null : run.reviewUnavailable ? `review could not run (${run.reviewUnavailableReason})` : 'not reviewed',
449
398
  run.planSkipped ? 'code was changed before the required plan existed' : null, planOpen ? `plan: ${planOpen} step(s) not completed` : null] : []),
450
399
  run.disputes.length ? `${run.disputes.length} disagreement(s) between the main agent and a subagent go to the member` : null, ledgerWords(run)].filter(Boolean);
@@ -465,6 +414,7 @@ export function processEditTools(session, tools) {
465
414
  session.run?.beforeEdit(tool.name, plan, session.mainAnswers);
466
415
  // An open premise objection is resolved before files change (ledger.mjs).
467
416
  if (tool.name !== 'bash' || !isReadOnlyCommand(args[1]?.command)) ledgerGuard(session.run, session.mainAnswers);
417
+ if (tool.name === 'bash') await beforeCheckOrPush(session, args[1]?.command, args[4], args[2]);
468
418
  // While a required plan is missing, a command that changes files
469
419
  // counts as an edit: the code is compared after each command.
470
420
  const watch = tool.name === 'bash' && !!session.run?.planMissing(plan) && !session.run.unplannedChange && session.run.startDigest !== null;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@piagent/core",
3
- "version": "1.48.5",
3
+ "version": "1.49.0",
4
4
  "type": "module",
5
5
  "private": true,
6
6
  "license": "MIT",