gentle-pi 4.6.0 → 4.7.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/README.md +10 -11
- package/assets/agents/gentle-ai-explore.md +1 -0
- package/assets/agents/gentle-ai-verify.md +5 -2
- package/assets/agents/gentle-ai-worker.md +3 -0
- package/assets/agents/jd-fix-agent.md +1 -0
- package/assets/agents/jd-judge-a.md +1 -0
- package/assets/agents/jd-judge-b.md +1 -0
- package/assets/design-canvas/canvas.css +13 -1
- package/assets/design-canvas/canvas.js +11 -2
- package/assets/install-wizard/wizard.js +1 -0
- package/assets/migrations/agent-body-history.json +16 -1
- package/assets/orchestrator-delegation-reference.md +4 -4
- package/assets/orchestrator-delegation.md +1 -1
- package/assets/orchestrator-full-delegation-card.md +65 -0
- package/assets/orchestrator-full-delegation.md +34 -0
- package/assets/orchestrator-memory.md +3 -3
- package/assets/orchestrator-prompts.md +1 -1
- package/assets/orchestrator-skills.md +1 -1
- package/assets/orchestrator-verification.md +7 -5
- package/assets/orchestrator.md +3 -3
- package/bin/gentle-shell.mjs +164 -56
- package/docs/agent-status.md +61 -0
- package/docs/bundled-install.md +7 -5
- package/docs/delegated-verification.md +29 -7
- package/docs/gentle-agents-activity.md +14 -0
- package/docs/gentle-shell.md +54 -16
- package/docs/install-wizard.md +1 -1
- package/docs/permission-modes.md +9 -4
- package/docs/readme-reference.md +75 -30
- package/docs/render-cache-performance.md +11 -1
- package/docs/review-coordinator.md +33 -0
- package/docs/review-request-context.md +19 -0
- package/docs/review-windows-acl.md +18 -0
- package/docs/voice.md +6 -3
- package/docs/yolo-mode.md +5 -5
- package/extensions/ask-user-choice.ts +1 -0
- package/extensions/ask-user-question.ts +1 -0
- package/extensions/child-safety.ts +3 -0
- package/extensions/gentle-agent-status.ts +99 -0
- package/extensions/gentle-agents.ts +326 -34
- package/extensions/gentle-ai.ts +1496 -454
- package/extensions/gentle-shell.ts +293 -63
- package/extensions/gentle-todo.ts +18 -2
- package/extensions/gentle-tps.ts +48 -0
- package/extensions/quiet-tools.ts +38 -8
- package/extensions/skill-registry.ts +175 -18
- package/extensions/startup-banner.ts +30 -3
- package/lib/agent-profile-pin.ts +3 -3
- package/lib/agent-profiles.ts +160 -2
- package/lib/agent-status.ts +105 -0
- package/lib/agents-config.ts +46 -0
- package/lib/agents-history.ts +24 -5
- package/lib/agents-messaging.ts +47 -5
- package/lib/agents-runner.ts +183 -12
- package/lib/auto-permission-runtime.ts +1 -1
- package/lib/bounded-writer-admission.ts +13 -1
- package/lib/card-content-policy.ts +8 -6
- package/lib/command-palette.ts +133 -17
- package/lib/context-backstop.ts +14 -5
- package/lib/destructive-command-guard.ts +48 -4
- package/lib/execution-surface-guard.ts +20 -0
- package/lib/exploration-budget.ts +4 -2
- package/lib/gentle-ai-binary.ts +1 -1
- package/lib/gentle-design.ts +3 -0
- package/lib/gentle-shell-bundled.ts +6 -19
- package/lib/gentle-shell-launcher.ts +43 -8
- package/lib/herdr-activity.ts +14 -2
- package/lib/herdr-busy.ts +45 -0
- package/lib/image-attachments.ts +33 -0
- package/lib/image-disk-cache.ts +137 -0
- package/lib/inprocess-reviewer.ts +270 -140
- package/lib/jobs-view.ts +198 -11
- package/lib/model-routing-authority.ts +22 -4
- package/lib/native-choice-list.ts +20 -2
- package/lib/native-review-cli.ts +96 -19
- package/lib/orchestrator-mode-policy.ts +105 -0
- package/lib/questionnaire/questionnaire-view.ts +105 -12
- package/lib/rdd-mode-control.ts +32 -0
- package/lib/reply-language-anchor.ts +104 -0
- package/lib/review-blocker.ts +92 -0
- package/lib/review-candidate-symlink-scan.ts +136 -0
- package/lib/review-candidate-view-owner.ts +81 -44
- package/lib/review-continuation-registry.ts +99 -0
- package/lib/review-coordinator.ts +163 -0
- package/lib/review-failure-facts.ts +49 -0
- package/lib/review-host-relay.ts +46 -10
- package/lib/review-integration-v2.ts +7 -1
- package/lib/review-relay-phase-timing.ts +45 -0
- package/lib/review-start-context.ts +17 -0
- package/lib/session-profile-freeze.ts +4 -2
- package/lib/shell-bar.ts +140 -58
- package/lib/shell-changes.ts +2 -0
- package/lib/shell-panel.ts +17 -3
- package/lib/shell-sidebar-layout.ts +112 -40
- package/lib/shell-sidebar.ts +7 -0
- package/lib/shell-todo.ts +10 -3
- package/lib/verifier-admission.ts +1 -1
- package/lib/visual-customization-policy.ts +36 -16
- package/lib/visual-customize-view.ts +216 -21
- package/lib/visual-layout-preview.ts +9 -5
- package/lib/visual-profiles.ts +2 -2
- package/lib/windows-session-transport.ts +53 -2
- package/lib/yolo-session-policy.ts +40 -15
- package/package.json +2 -1
- package/runtime/gentle-ai-binary.mjs +1 -1
- package/runtime/gentle-shell-bundled.mjs +6 -19
- package/runtime/gentle-shell-launcher.mjs +42 -7
- package/runtime/native-review-cli.mjs +93 -16
- package/runtime/review-integration-v2.mjs +7 -1
- package/scripts/build-full-delegation-card.mjs +175 -0
- package/scripts/bundled-install.mjs +38 -8
- package/scripts/download-progress.mjs +68 -0
- package/scripts/gentle-ai-installer.mjs +41 -18
- package/scripts/gentle-ai-proxy.mjs +294 -0
- package/scripts/install-gentle-ai.mjs +14 -1
- package/scripts/installer-preflight.mjs +5 -5
- package/scripts/installer-runner.mjs +27 -12
- package/scripts/installer-server.mjs +8 -7
- package/scripts/render-cache-host.mjs +72 -0
- package/scripts/render-cache-performance-worker.mjs +5 -4
- package/scripts/render-cache-performance.mjs +6 -1
- package/scripts/run-test-suite.mjs +40 -28
- package/scripts/verify-package-files.mjs +12 -2
- package/scripts/voice-worker.cjs +32 -6
- package/skills/design/SKILL.md +11 -8
- package/skills/gentle-ai/SKILL.md +2 -2
- package/skills/gentle-ui-design/SKILL.md +46 -0
- package/skills/gentle-ui-design/references/adaptive-interfaces.md +46 -0
- package/skills/gentle-ui-design/references/browse-and-compare.md +62 -0
- package/skills/gentle-ui-design/references/composition-and-feedback.md +56 -0
- package/skills/gentle-ui-design/references/task-and-content.md +60 -0
- package/skills/skill-registry/SKILL.md +4 -2
- package/skills/work-unit-commits/SKILL.md +6 -7
- package/tests/agent-home.test.ts +28 -9
- package/tests/agent-profiles-workflow.test.ts +163 -0
- package/tests/agent-risk-escalation.test.ts +1 -1
- package/tests/agent-status.test.ts +143 -0
- package/tests/agents-config.test.ts +96 -0
- package/tests/agents-history.test.ts +31 -0
- package/tests/agents-jobs-frames.test.ts +93 -0
- package/tests/agents-prompt-lifecycle-runtime.test.ts +376 -0
- package/tests/agents-runner-drain.test.ts +193 -0
- package/tests/agents-runner.test.ts +178 -2
- package/tests/append-system-prompt-route.test.ts +4 -1
- package/tests/ask-user-choice.test.ts +4 -3
- package/tests/ask-user-question.test.ts +97 -0
- package/tests/auto-permission-runtime.test.ts +1 -1
- package/tests/autonomous-guard.test.ts +346 -10
- package/tests/bounded-stop-contract.test.ts +43 -3
- package/tests/bridge-cost.test.ts +19 -4
- package/tests/bundled-install.test.ts +30 -5
- package/tests/card-content-policy.test.ts +3 -3
- package/tests/chained-pr-skill.test.ts +8 -6
- package/tests/child-safety.test.ts +11 -0
- package/tests/codegraph-tools.test.ts +11 -5
- package/tests/command-palette.test.ts +284 -1
- package/tests/delegate-for-reason-contract.test.ts +3 -3
- package/tests/design-canvas-assets.test.ts +185 -2
- package/tests/destructive-command-guard.test.ts +52 -0
- package/tests/download-progress.test.ts +71 -0
- package/tests/execution-surface-guard.test.ts +55 -0
- package/tests/fixtures/primary-session-prompt/gentleman.golden.md +9 -5
- package/tests/fixtures/proxy-tls/proxy.crt +19 -0
- package/tests/fixtures/proxy-tls/proxy.key +28 -0
- package/tests/fixtures/session-profile-v1/gentle-ai-reviewer.ts +89 -0
- package/tests/fixtures/session-profile-v1/replay.ts +53 -6
- package/tests/full-delegation-closure.test.ts +131 -0
- package/tests/full-delegation-notices.test.ts +76 -0
- package/tests/generic-agent-tools.test.ts +3 -3
- package/tests/gentle-agent-status.test.ts +74 -0
- package/tests/gentle-agents-child-jobs.test.ts +237 -0
- package/tests/gentle-agents.test.ts +1070 -12
- package/tests/gentle-ai-binary.test.ts +3 -1
- package/tests/gentle-ai-elapsed-store.test.ts +19 -0
- package/tests/gentle-ai-exploration-budget.test.ts +18 -2
- package/tests/gentle-ai-installer.test.ts +134 -51
- package/tests/gentle-ai-proxy.test.ts +434 -0
- package/tests/gentle-ai.test.ts +113 -38
- package/tests/gentle-design.test.ts +21 -0
- package/tests/gentle-herdr-activity.test.ts +9 -6
- package/tests/gentle-shell-bin.test.ts +123 -0
- package/tests/gentle-shell-bundled.test.ts +207 -31
- package/tests/gentle-shell-launcher.test.ts +77 -10
- package/tests/gentle-shell.test.ts +899 -59
- package/tests/gentle-todo.test.ts +19 -2
- package/tests/gentle-tps.test.ts +123 -0
- package/tests/gentle-ui-design-skill.test.ts +59 -0
- package/tests/herdr-busy.test.ts +59 -0
- package/tests/herdr-task-summary-policy.test.ts +8 -4
- package/tests/image-disk-cache.test.ts +163 -0
- package/tests/independent-recovery-delivery.test.ts +83 -0
- package/tests/inprocess-reviewer.test.ts +176 -4
- package/tests/installer-posix-bootstrap.test.ts +1 -1
- package/tests/installer-preflight.test.ts +5 -4
- package/tests/installer-runner.test.ts +79 -44
- package/tests/installer-server.test.ts +14 -11
- package/tests/jobs-view.test.ts +260 -6
- package/tests/modal-mouse-boundaries.test.ts +136 -0
- package/tests/model-routing-authority.test.ts +178 -2
- package/tests/native-choice-list.test.ts +77 -2
- package/tests/native-review-capability-contract.test.ts +7 -1
- package/tests/native-review-cli.test.ts +269 -1
- package/tests/no-self-pause-contract.test.ts +4 -1
- package/tests/odd-routing-canonical-ratchet.test.ts +3 -3
- package/tests/orchestrator-budget.test.ts +7 -2
- package/tests/orchestrator-delegation-mode.test.ts +153 -0
- package/tests/orchestrator-mode-policy.test.ts +175 -0
- package/tests/orchestrator-prompt-budget.test.ts +3 -1
- package/tests/orchestrator-rdd-ownership.test.ts +2 -2
- package/tests/package-manifest.test.ts +11 -9
- package/tests/permission-allowlist.test.ts +202 -0
- package/tests/pi-update-launcher.test.ts +8 -0
- package/tests/pnpm-workspace-config.test.ts +58 -0
- package/tests/primary-session-prompt.test.ts +13 -0
- package/tests/profile-pin.test.ts +29 -2
- package/tests/profile-tier-footer.test.ts +5 -0
- package/tests/profiles-panel-delegation-mode.test.ts +422 -0
- package/tests/questionnaire-view.test.ts +115 -0
- package/tests/quiet-bash-runtime.test.ts +1 -1
- package/tests/quiet-tool-rendering.test.ts +48 -0
- package/tests/rdd-aware-verification-contract.test.ts +16 -11
- package/tests/rdd-customize.test.ts +287 -0
- package/tests/rdd-mode-cache.test.ts +450 -0
- package/tests/rdd-mode-control.test.ts +407 -0
- package/tests/rdd-mode-scope-regression.test.ts +137 -0
- package/tests/rdd-off-independent-regression.test.ts +69 -0
- package/tests/rdd-status-line.test.ts +18 -0
- package/tests/render-cache-performance.test.ts +171 -2
- package/tests/reply-language-anchor.test.ts +173 -0
- package/tests/review-agent-end-preflight.test.ts +1 -1
- package/tests/review-blocker.test.ts +193 -0
- package/tests/review-candidate-owner-retry.test.ts +1 -1
- package/tests/review-candidate-symlink-scan.test.ts +157 -0
- package/tests/review-candidate-view.test.ts +1 -1
- package/tests/review-candidate-windows-boundary.test.ts +131 -0
- package/tests/review-candidate-windows-probe.test.ts +63 -0
- package/tests/review-committed-restart-ack.test.ts +129 -0
- package/tests/review-continuation-registry.test.ts +76 -0
- package/tests/review-controller-native-routing.test.ts +261 -5
- package/tests/review-controller-workspace-root.test.ts +230 -3
- package/tests/review-controller.test.ts +96 -11
- package/tests/review-coordinator-runtime.test.ts +117 -0
- package/tests/review-coordinator.test.ts +195 -0
- package/tests/review-failure-facts.test.ts +87 -0
- package/tests/review-host-relay-routing.test.ts +258 -4
- package/tests/review-host-relay.test.ts +39 -0
- package/tests/review-integration-v2.test.ts +46 -3
- package/tests/review-json-arguments.test.ts +65 -10
- package/tests/review-last-event-closure.test.ts +68 -0
- package/tests/review-loadout-rdd-off-sdk.test.ts +65 -31
- package/tests/review-owner-identity.test.ts +60 -24
- package/tests/review-relay-phase-timing.test.ts +128 -0
- package/tests/review-relay-transport-agent.test.ts +12 -2
- package/tests/review-reviewer-evidence.test.ts +183 -0
- package/tests/review-risk-assessment.test.ts +74 -3
- package/tests/review-session-standing-permission-controller.test.ts +21 -1
- package/tests/review-start-context.test.ts +19 -0
- package/tests/review-tool-prose-budget.test.ts +121 -0
- package/tests/run-test-suite.test.ts +122 -1
- package/tests/runtime-harness.mjs +4 -1
- package/tests/sensitive-path-tools.test.ts +181 -5
- package/tests/session-profile-append-controller-pi.test.ts +60 -31
- package/tests/session-profile-binding.test.ts +19 -1
- package/tests/session-profile-disk-reader-pi.test.ts +58 -16
- package/tests/session-profile-v1-compat.test.ts +35 -1
- package/tests/shell-bar.test.ts +186 -42
- package/tests/shell-panel.test.ts +50 -22
- package/tests/shell-sidebar-fullscreen.test.ts +5 -5
- package/tests/shell-sidebar-layout.test.ts +294 -23
- package/tests/shell-sidebar-scroll-benchmark.test.ts +1 -1
- package/tests/shell-surface-transparent.test.ts +89 -0
- package/tests/shell-todo.test.ts +12 -0
- package/tests/skill-registry.test.ts +838 -5
- package/tests/startup-banner.test.ts +152 -1
- package/tests/startup-home-repo.test.ts +2 -0
- package/tests/support/review-coordinator-runtime.ts +69 -0
- package/tests/task-size-routing-contract.test.ts +5 -3
- package/tests/verifier-admission.test.ts +49 -0
- package/tests/verify-first-launch-contract.test.ts +78 -3
- package/tests/visual-customization-policy.test.ts +39 -6
- package/tests/visual-customize-view.test.ts +573 -9
- package/tests/visual-layout-preview.test.ts +15 -1
- package/tests/visual-profiles.test.ts +11 -0
- package/tests/voice-worker.test.ts +73 -2
- package/tests/windows-session-transport.test.ts +126 -0
- package/tests/work-continuity-contract.test.ts +28 -0
- package/tests/writer-feature-document-admission.test.ts +92 -0
- package/tests/yolo-customize.test.ts +27 -4
- package/tests/yolo-mode.test.ts +23 -18
- package/tests/yolo-session-policy.test.ts +270 -1
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import test from "node:test";
|
|
3
|
+
import { createDownloadProgress, formatDownloadProgress } from "../scripts/download-progress.mjs";
|
|
4
|
+
|
|
5
|
+
test("formatDownloadProgress shows size, percent, rate and a bar with a known total", () => {
|
|
6
|
+
const line = formatDownloadProgress({ label: "gentle-ai v4.1.1", received: 3 * 1024 * 1024, total: 6 * 1024 * 1024, elapsedMs: 2000, width: 80 });
|
|
7
|
+
assert.match(line, /^gentle-ai v4\.1\.1 /);
|
|
8
|
+
assert.match(line, /3\.0\/6\.0 MB/);
|
|
9
|
+
assert.match(line, / 50%/);
|
|
10
|
+
assert.match(line, /1\.5 MB\/s/);
|
|
11
|
+
assert.match(line, /\[#+-+\]/);
|
|
12
|
+
assert.ok([...line].length <= 80);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
test("formatDownloadProgress omits percent and bar without a total and uses KB for small rates", () => {
|
|
16
|
+
const line = formatDownloadProgress({ label: "x", received: 20 * 1024, total: undefined, elapsedMs: 1000, width: 80 });
|
|
17
|
+
assert.match(line, /20 KB/);
|
|
18
|
+
assert.match(line, /20 KB\/s/);
|
|
19
|
+
assert.doesNotMatch(line, /%|\[/);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
test("formatDownloadProgress never exceeds a narrow width and survives zero elapsed time", () => {
|
|
23
|
+
const line = formatDownloadProgress({ label: "a-very-long-label", received: 1, total: 10, elapsedMs: 0, width: 12 });
|
|
24
|
+
assert.ok([...line].length <= 12, line);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test("createDownloadProgress throttles redraws, always draws completion, and clears its line", () => {
|
|
28
|
+
let now = 0;
|
|
29
|
+
const writes: string[] = [];
|
|
30
|
+
const progress = createDownloadProgress({ label: "x", write: (text: string) => writes.push(text), now: () => now, width: () => 60, intervalMs: 100 });
|
|
31
|
+
progress.update({ received: 1, total: 10 });
|
|
32
|
+
now = 50;
|
|
33
|
+
progress.update({ received: 2, total: 10 });
|
|
34
|
+
now = 150;
|
|
35
|
+
progress.update({ received: 5, total: 10 });
|
|
36
|
+
now = 160;
|
|
37
|
+
progress.update({ received: 10, total: 10 });
|
|
38
|
+
assert.equal(writes.length, 3, "first, throttled-through and final draws only");
|
|
39
|
+
for (const text of writes) assert.match(text, /^\r.*\x1b\[K$/);
|
|
40
|
+
assert.match(writes[2], /100%/);
|
|
41
|
+
progress.done();
|
|
42
|
+
assert.equal(writes.at(-1), "\r\x1b[K");
|
|
43
|
+
progress.done();
|
|
44
|
+
assert.equal(writes.length, 4, "done is idempotent");
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
test("createDownloadProgress done without any update writes nothing", () => {
|
|
48
|
+
const writes: string[] = [];
|
|
49
|
+
createDownloadProgress({ label: "x", write: (text: string) => writes.push(text) }).done();
|
|
50
|
+
assert.deepEqual(writes, []);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
test("formatDownloadProgress keeps the amount and percent visible when the label does not fit", () => {
|
|
54
|
+
const label = "Downloading Gentle AI v4.1.1";
|
|
55
|
+
const known = formatDownloadProgress({ label, received: 3 * 1024 * 1024, total: 6 * 1024 * 1024, elapsedMs: 0, width: 23 });
|
|
56
|
+
assert.ok([...known].length <= 23, known);
|
|
57
|
+
assert.match(known, /3\.0\/6\.0 MB/);
|
|
58
|
+
assert.match(known, / 50%/);
|
|
59
|
+
const unknown = formatDownloadProgress({ label, received: 20 * 1024, total: undefined, elapsedMs: 0, width: 23 });
|
|
60
|
+
assert.ok([...unknown].length <= 23, unknown);
|
|
61
|
+
assert.match(unknown, /20 KB/);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
test("createDownloadProgress never throws from a failing writer, including on done", () => {
|
|
65
|
+
let fail = false;
|
|
66
|
+
const progress = createDownloadProgress({ label: "x", write: () => { if (fail) throw new Error("EPIPE"); } });
|
|
67
|
+
progress.update({ received: 1, total: 10 });
|
|
68
|
+
fail = true;
|
|
69
|
+
assert.doesNotThrow(() => progress.update({ received: 10, total: 10 }));
|
|
70
|
+
assert.doesNotThrow(() => progress.done());
|
|
71
|
+
});
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import test from "node:test";
|
|
3
|
+
import { EXTERNAL_FALLBACK_PROHIBITED, evaluateExecutionSurfaceTool } from "../lib/execution-surface-guard.ts";
|
|
4
|
+
|
|
5
|
+
// gentle-shell#379: a tool call that asks to open an external project pane is
|
|
6
|
+
// classified by its own input property, never by the tool name.
|
|
7
|
+
|
|
8
|
+
const reason = (toolName: string) => `Gentle AI blocked an execution-surface escalation. code=${EXTERNAL_FALLBACK_PROHIBITED} tool=${toolName} property=openProjectPaneIfMissing next=Run the work through subagent_* or the native Agent in the current runtime; if neither is available, stop and tell the user.`;
|
|
9
|
+
|
|
10
|
+
test("the stable code names the external fallback prohibition", () => {
|
|
11
|
+
assert.equal(EXTERNAL_FALLBACK_PROHIBITED, "gentle-ai.execution-surface.external-fallback-prohibited");
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
for (const [label, input] of [
|
|
15
|
+
["absent", { action: "send", cwd: "/tmp/other" }],
|
|
16
|
+
["false", { action: "send", cwd: "/tmp/other", openProjectPaneIfMissing: false }],
|
|
17
|
+
["non-object input", "openProjectPaneIfMissing"],
|
|
18
|
+
["undefined input", undefined],
|
|
19
|
+
] as const) {
|
|
20
|
+
test(`an ${label} openProjectPaneIfMissing leaves the call untouched`, () => {
|
|
21
|
+
assert.equal(evaluateExecutionSurfaceTool("intercom", input), undefined);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
for (const [label, value] of [
|
|
26
|
+
["true", true],
|
|
27
|
+
["the string \"yes\"", "yes"],
|
|
28
|
+
["the number 1", 1],
|
|
29
|
+
["null", null],
|
|
30
|
+
["an object", {}],
|
|
31
|
+
] as const) {
|
|
32
|
+
test(`openProjectPaneIfMissing set to ${label} is blocked with the stable code`, () => {
|
|
33
|
+
const result = evaluateExecutionSurfaceTool("synthetic_surface", { action: "ask", cwd: "/secret/repo", message: "leak me", openProjectPaneIfMissing: value });
|
|
34
|
+
assert.deepEqual(result, { block: true, reason: reason("synthetic_surface") });
|
|
35
|
+
assert.equal(result?.reason?.includes("/secret/repo"), false, "the reason never echoes input paths");
|
|
36
|
+
assert.equal(result?.reason?.includes("leak me"), false, "the reason never echoes input content");
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
test("only an own openProjectPaneIfMissing other than false blocks (gentle-shell#379)", () => {
|
|
41
|
+
for (const value of ["false", "0", "", 0, undefined, [true]]) {
|
|
42
|
+
assert.equal(evaluateExecutionSurfaceTool("t", { openProjectPaneIfMissing: value })?.block, true, String(value));
|
|
43
|
+
}
|
|
44
|
+
assert.equal(evaluateExecutionSurfaceTool("t", JSON.parse('{"openProjectPaneIfMissing":true}'))?.block, true);
|
|
45
|
+
assert.equal(evaluateExecutionSurfaceTool("t", { options: { openProjectPaneIfMissing: true } }), undefined);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// Pi structuredClones tool args before the hook, and structuredClone drops a
|
|
49
|
+
// JSON-parsed __proto__ key's prototype, so a prototype-only property never
|
|
50
|
+
// reaches the tool as a pane request and is not a bypass.
|
|
51
|
+
test("a structuredCloned __proto__ pane request carries no property and is not blocked (gentle-shell#379)", () => {
|
|
52
|
+
const cloned = structuredClone(JSON.parse('{"__proto__":{"openProjectPaneIfMissing":true}}'));
|
|
53
|
+
assert.equal(cloned.openProjectPaneIfMissing, undefined);
|
|
54
|
+
assert.equal(evaluateExecutionSurfaceTool("t", cloned), undefined);
|
|
55
|
+
});
|
|
@@ -30,9 +30,13 @@ Interpret short replies such as "yes", "go ahead", or "eso mismo" against the im
|
|
|
30
30
|
|
|
31
31
|
Resolving an incident or subdecision does not complete or cancel the original authorized objective; resume safe, necessary in-scope steps automatically, using judgment for proportionate recovery and respecting explicit user dispositions. Investigate pending technical uncertainty rather than treating it alone as a new human decision.
|
|
32
32
|
|
|
33
|
-
Stop
|
|
33
|
+
Stop for an unresolved consequential scope/product decision, required explicit consent, a denied action, or the human's explicit stop. Unavailable required proof blocks completion and delivery; it does not alone prohibit specifically authorized in-scope implementation where actual native authority and other limits permit it. Do not infer permission for publishing, destructive actions, unrelated scope or native consent from this continuity rule. Report a concrete blocker and the exact decision needed rather than requesting a generic "continue".
|
|
34
34
|
|
|
35
|
-
Before a terminal bounded-stop outcome, distinguish a recoverable technical or harness failure from genuinely inaccessible required proof. A failed test or harness check may be corrected and rerun without another authorization only within the authorized scope and existing correction budget, subject to every applicable limit. Honor explicit one run, no retries, or diagnostic-only limits; stop for permission denial, required new consent, or exhausted budget. Do not propose diagnostic-only or single-attempt authorization unless the human requested it. Respect terminal review and verification outcomes and existing bounded-stop rules: never reset budgets, add retry allowances, weaken checks, or override final outcomes.
|
|
35
|
+
Before a terminal bounded-stop outcome, distinguish a recoverable technical or harness failure from genuinely inaccessible required proof. A failed test or harness check may be corrected and rerun without another authorization only within the authorized scope and existing correction budget, subject to every applicable limit. Honor explicit one run, no retries, or diagnostic-only limits; stop for permission denial, required new consent, or exhausted budget. Do not propose diagnostic-only or single-attempt authorization unless the human requested it. Respect terminal review and verification outcomes and existing bounded-stop rules: never reset budgets, add retry allowances, weaken checks, or override final outcomes.
|
|
36
|
+
|
|
37
|
+
A failed verifier setup is a preparation failure, not an unavailable verifier capability. If setup fails before probes, preserve the failed attempt and report zero tests run; the checks remain unverified. For a genuinely unavailable capability: An unavailable verifier remains unavailable; do not retry or escalate it. After a setup prerequisite is repaired, the human may explicitly request one new bounded verification attempt. This is a new request, not an automatic retry, and it does not reset the prior attempt or unrelated budgets. Before proceeding, confirm no child is active or has an uncertain status. Establish the required payload, dependencies and scratch capacity before isolated setup; do not blindly repeat an oversized copy. Never bypass consent, a denial, explicit one-run or no-retry limits, terminal native outcomes, or exhausted native budgets.
|
|
38
|
+
|
|
39
|
+
An exhausted worker-local correction limit ends that automatic cycle, not necessarily the feature. Partial worker execution is not by itself exhausted proof or a terminal native review outcome. Stop and report the remaining work, failed checks and missing proof, and offer an explicit human-controlled bounded continuation. Name its scope, executor, correction limit and checks, or let the human stop. Before any worker continuation, confirm no child is active or has an uncertain status. The Close step's bounded stop ends the current automatic cycle; a later explicit human request is separate and remains subject to native authority. A new session does not reset any limit. When specifically authorized and not prohibited by actual native authority, continue ordinary in-scope compilation or implementation; unavailable proof still blocks completion and delivery.
|
|
36
40
|
|
|
37
41
|
For worker-prohibited maintenance or rollback, worker prohibitions remain unchanged. The parent only may perform the operation when the human explicitly authorized the operation itself, exact scope, ownership, and preservation are established, and available permitted tools can perform it; fresh runtime/native consent and guards remain binding. A broad feature authorization is not destructive authority; never substitute another worker or tool to bypass a denial. For an upgrade require a validated backup, artifact and migration validation where applicable, and a recovery path. For rollback preserve unrelated edits even in the same file, remove only proven task-created helpers, and never blanket restore, reset, or clean. Stop when ambiguous ownership or denial stops the operation, or any prerequisite is missing. This route is guidance, not authorization.
|
|
38
42
|
|
|
@@ -72,7 +76,7 @@ Package assets root: `{{GENTLE_PI_ASSETS_ROOT}}`. Lazy asset paths below are rel
|
|
|
72
76
|
|
|
73
77
|
You are a COORDINATOR, not the default executor for substantial work. Maintain one thin conversation thread, delegate real phase work to Pi subagents when available, and synthesize results for the user.
|
|
74
78
|
|
|
75
|
-
|
|
79
|
+
Default to concise synthesis: decision, outcome, next action. Expand on request or when detail is needed.
|
|
76
80
|
|
|
77
81
|
Batch independent tool calls in one turn (parallel calls or one multi-file command). Never spend a turn only on a `todo` or status update.
|
|
78
82
|
|
|
@@ -114,7 +118,7 @@ Delegation Triggers — each mechanism turns on only when its own trigger condit
|
|
|
114
118
|
|
|
115
119
|
1. **Ask** — open product or design decision → one focused question; stop and wait.
|
|
116
120
|
2. **Evidence-budget rule** — understanding needs more than one read batch or >~5 sequential lookups → stop and delegate one `gentle-ai-explore`, handoff at most ~2k tokens with `path:line` evidence; one spot check only. Reassess cumulative discovery each batch, never reset. A fired trigger overrides initial size, including read-only: it limits mutation, not routing. Exempt only preparation for an understood inline write, not discovery.
|
|
117
|
-
3. **Verification rule** — only a named high-risk item (assess `escalate`) → independent `gentle-ai-verify`; else inline; runtime admission, gates/overengineering: `orchestrator-verification.md`.
|
|
121
|
+
3. **Verification rule** — only a named high-risk item (assess `escalate` when RDD is on or unknown) → independent `gentle-ai-verify`; else inline; runtime admission, gates/overengineering: `orchestrator-verification.md`.
|
|
118
122
|
4. **Track** — large task → feature document, Engram mirror, `todo`, work-unit commits (`orchestrator-tracking.md`, `orchestrator-memory.md`).
|
|
119
123
|
5. **Writer rule** — never by file count or a large task alone; only for a reason (`orchestrator-writer.md`): 2+ independent units of behavior, each heavier than a subagent start (several minutes of work: several files or roughly 100+ changed lines), launched together in background, else inline; Context backstop. Small module or command changes stay inline, even when independent. Tests, docs, and code of the same behavior are one unit, never separate writers; dependent deliveries are not independent.
|
|
120
124
|
6. **Incident rule** — diagnose wrong cwd/worktree/git/tooling incidents separately before resuming.
|
|
@@ -147,5 +151,5 @@ This package injects the mirrored provider-bundle review execution contract into
|
|
|
147
151
|
- Never commit unless the user explicitly asks, except the work-unit commits authorized large ODD implementation makes on its feature branch (ODD step 6).
|
|
148
152
|
- Ask before destructive git operations, publishing, or irreversible file changes.
|
|
149
153
|
- Parallel writers only with disjoint Allowed edit surfaces (runtime-enforced) or isolated worktrees.
|
|
150
|
-
- Keep session work inside the project root and registered same-clone worktrees; ask before any read or write outside it, naming the absolute path. Grants are per-target, per-session, never blanket: in-project scripts naming outside paths are not standing consent.
|
|
154
|
+
- Keep session work inside the project root and registered same-clone worktrees; ask before any read or write outside it, naming the absolute path. Exception: reading the task's exact resolved skill files needs no per-file question in any mode. Grants are per-target, per-session, never blanket: in-project scripts naming outside paths are not standing consent.
|
|
151
155
|
- Preserve human control: user decisions beat agent momentum.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
-----BEGIN CERTIFICATE-----
|
|
2
|
+
MIIDGzCCAgOgAwIBAgIUYexwMGieLdNZ3F9TejD6N22co70wDQYJKoZIhvcNAQEL
|
|
3
|
+
BQAw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of the last release before A1 (gentle-shell#2742, section
|
|
2
|
+
// 10; #2720 is A1). The functions below are byte-identical copies of
|
|
3
|
+
// `extensions/gentle-ai.ts` at 9fe14aad except their import lines. What A1 and
|
|
4
|
+
// A2 do not change is read live, like the other `v1-inputs.ts` inputs.
|
|
5
|
+
import { join } from "node:path";
|
|
6
|
+
import { resolveGentlePiAgentHome, gentlePiConfigHome } from "../../../lib/agent-home.ts";
|
|
7
|
+
import { PROVIDER_REVIEW_ROLES } from "../../../lib/agents-config.ts";
|
|
8
|
+
import type { AgentModelConfig, AgentRoutingEntry } from "../../../lib/model-routing-authority.ts";
|
|
9
|
+
import { readOrchestratorSettings } from "../../../lib/profiles-orchestrator.ts";
|
|
10
|
+
import { readModelConfig } from "../../../extensions/gentle-ai.ts";
|
|
11
|
+
import { resolveProfilePin } from "./v1-inputs.ts";
|
|
12
|
+
import { readSessionProfileBinding } from "./session-profile-binding.ts";
|
|
13
|
+
|
|
14
|
+
function gentleAiConfigHome(): string {
|
|
15
|
+
return gentlePiConfigHome();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function cloneModelConfig(config: AgentModelConfig): AgentModelConfig {
|
|
19
|
+
return Object.fromEntries(
|
|
20
|
+
Object.entries(config).map(([name, entry]) => [name, { ...entry }]),
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The routing a launch would resolve: a winning per-repository pin replaces subagent
|
|
26
|
+
* routing wholesale, so when one wins it is the effective routing. The launch
|
|
27
|
+
* resolver decides, so the profile shown as effective is exactly the profile a launch
|
|
28
|
+
* would use -- there is no second precedence rule here.
|
|
29
|
+
*/
|
|
30
|
+
function pinnedEffectiveModelConfig(cwd: string): AgentModelConfig | undefined {
|
|
31
|
+
const resolution = resolveProfilePin({ cwd, configHome: gentleAiConfigHome() });
|
|
32
|
+
return resolution === undefined ? undefined : cloneModelConfig(resolution.modelProfiles);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Resolve one complete reviewer routing snapshot without per-role fallback. */
|
|
36
|
+
function readReviewerModelConfig(cwd: string, sessionId: string | undefined): AgentModelConfig {
|
|
37
|
+
return readSessionProfileBinding(sessionId)?.modelProfiles ?? pinnedEffectiveModelConfig(cwd) ?? readModelConfig(cwd);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function gentlePiAgentHome(): string {
|
|
41
|
+
return resolveGentlePiAgentHome();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Pi's own global settings file, which is where the orchestrator model lives.
|
|
46
|
+
* Profiles own the three `default*` keys there; nothing else in this extension
|
|
47
|
+
* reads or writes that file.
|
|
48
|
+
*/
|
|
49
|
+
function orchestratorSettingsPath(): string {
|
|
50
|
+
return join(gentlePiAgentHome(), "settings.json");
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function isProviderReviewRole(name: string): boolean {
|
|
54
|
+
return PROVIDER_REVIEW_ROLES.some((role) => role === name);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// gentle-pi#311 P2 (superseding gentle-shell#1136 / #1158): the lens's
|
|
58
|
+
// completion selection comes from its entry in the agent model routing
|
|
59
|
+
// config, keyed by its routing key (`review-<lens>`). There is no extension
|
|
60
|
+
// allowlist and no ambient default model: the in-process completion resolves
|
|
61
|
+
// its provider through the live model registry the caller supplies, or it is
|
|
62
|
+
// refused before materialize ever runs (validateReviewerSelectionConfiguration
|
|
63
|
+
// in lib/review-host-relay.ts).
|
|
64
|
+
//
|
|
65
|
+
// gentle-pi#2271: review-refuter and review-validator are provider review
|
|
66
|
+
// roles, not installable agents, so nothing seeds their entries and profiles
|
|
67
|
+
// never carry them. For those two keys only, a snapshot with no model falls
|
|
68
|
+
// back to Pi's persisted default model and effort, the default the routing
|
|
69
|
+
// panel already labels them with. Lens keys keep the fail-closed rule.
|
|
70
|
+
function reviewHostRelaySelection(lens: string | undefined, config: AgentModelConfig): { selection?: string; thinking?: string; routingKey: string } {
|
|
71
|
+
const routingKey = lens === undefined || lens.length === 0 ? "review capture" : lens.startsWith("review-") ? lens : `review-${lens}`;
|
|
72
|
+
const entry = config[routingKey];
|
|
73
|
+
let model = typeof entry === "object" && entry !== null && typeof (entry as AgentRoutingEntry).model === "string" && (entry as AgentRoutingEntry).model!.length > 0 ? (entry as AgentRoutingEntry).model : undefined;
|
|
74
|
+
let thinking = typeof entry === "object" && entry !== null && typeof (entry as AgentRoutingEntry).thinking === "string" ? (entry as AgentRoutingEntry).thinking : undefined;
|
|
75
|
+
if (model === undefined && isProviderReviewRole(routingKey)) {
|
|
76
|
+
const persisted = readOrchestratorSettings(orchestratorSettingsPath());
|
|
77
|
+
if (persisted.status === "valid" && persisted.entry?.model !== undefined) {
|
|
78
|
+
model = persisted.entry.model;
|
|
79
|
+
thinking ??= persisted.entry.thinking;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return {
|
|
83
|
+
...(model === undefined ? {} : { selection: model }),
|
|
84
|
+
...(thinking === undefined ? {} : { thinking }),
|
|
85
|
+
routingKey,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export { readReviewerModelConfig, reviewHostRelaySelection };
|
|
@@ -6,7 +6,8 @@ import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
|
6
6
|
import { tmpdir } from "node:os";
|
|
7
7
|
import { join } from "node:path";
|
|
8
8
|
import { createProfile, emptyProfilesFile, profilesFilePath, setActiveProfile, writeProfilesFileSync } from "../../../lib/agent-profiles.ts";
|
|
9
|
-
import { localProfilePinPath, repoProfileDeclarationPath, writeProfilePinSync } from "../../../lib/agent-profile-pin.ts";
|
|
9
|
+
import { localProfilePinPath, repoProfileDeclarationPath, setProfilePinWorktreeResolverForTesting, writeProfilePinSync } from "../../../lib/agent-profile-pin.ts";
|
|
10
|
+
import { __testing } from "../../../extensions/gentle-ai.ts";
|
|
10
11
|
import type { AgentModelConfig } from "../../../lib/model-routing-authority.ts";
|
|
11
12
|
import * as currentAuthority from "../../../lib/session-profile-authority.ts";
|
|
12
13
|
import * as currentBinding from "../../../lib/session-profile-binding.ts";
|
|
@@ -16,6 +17,7 @@ import type { WorktreeIdentity } from "../../../lib/session-worktree-registry.ts
|
|
|
16
17
|
import * as v1Authority from "./session-profile-authority.ts";
|
|
17
18
|
import * as v1Binding from "./session-profile-binding.ts";
|
|
18
19
|
import * as v1Freeze from "./session-profile-freeze.ts";
|
|
20
|
+
import * as v1Reviewer from "./gentle-ai-reviewer.ts";
|
|
19
21
|
|
|
20
22
|
export interface TranscriptDefaults {
|
|
21
23
|
profiles: Record<string, AgentModelConfig>;
|
|
@@ -93,8 +95,16 @@ function writeSession(base: string, records: unknown[]) {
|
|
|
93
95
|
};
|
|
94
96
|
}
|
|
95
97
|
|
|
98
|
+
interface Resumed {
|
|
99
|
+
authority: boolean;
|
|
100
|
+
options: { sessionId: string; cwd: string; configHome: string; resolveWorktree: () => WorktreeIdentity; env: NodeJS.ProcessEnv };
|
|
101
|
+
foreign: WorktreeIdentity;
|
|
102
|
+
/** An empty agent home, so ambient agents and subagents.json never reach the replay. */
|
|
103
|
+
agentHome: string;
|
|
104
|
+
}
|
|
105
|
+
|
|
96
106
|
/** Resume `transcript` under one version, with that version's process state reset first. */
|
|
97
|
-
|
|
107
|
+
function resume<T>(version: Version, transcript: Transcript, observe: (resumed: Resumed) => T): T {
|
|
98
108
|
const modules = versions[version];
|
|
99
109
|
const base = mkdtempSync(join(tmpdir(), `gentle-pi-v1-replay-${version}-`));
|
|
100
110
|
try {
|
|
@@ -109,17 +119,54 @@ export function replay(version: Version, transcript: Transcript): ReplayObservat
|
|
|
109
119
|
const authority = modules.authority.readSessionProfileAuthority(manager);
|
|
110
120
|
const options = { sessionId: SESSION_ID, cwd: home.root, configHome, resolveWorktree: () => home, env: transcript.env ?? {} };
|
|
111
121
|
modules.freeze.freezeSessionProfileAtStartup(options);
|
|
122
|
+
return observe({ authority: authority.available, options, foreign, agentHome: join(base, "agent-home") });
|
|
123
|
+
} finally {
|
|
124
|
+
rmSync(base, { recursive: true, force: true });
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** What a launch and the status line see after resuming `transcript` under one version. */
|
|
129
|
+
export function replay(version: Version, transcript: Transcript): ReplayObservation {
|
|
130
|
+
const modules = versions[version];
|
|
131
|
+
return resume(version, transcript, ({ authority, options, foreign }) => {
|
|
132
|
+
const { configHome } = options;
|
|
112
133
|
const resolution = modules.freeze.resolveSessionProfile(options);
|
|
113
134
|
const foreignTarget = { cwd: foreign.root, configHome, resolveWorktree: () => foreign, foreignRepository: true };
|
|
114
135
|
return {
|
|
115
|
-
authority
|
|
136
|
+
authority,
|
|
116
137
|
kind: resolution.kind,
|
|
117
138
|
label: modules.freeze.sessionProfileLabel(resolution),
|
|
118
139
|
routing: modules.freeze.sessionProfileRoutingAt(resolution, { ...options, foreignRepository: false }),
|
|
119
140
|
foreignRouting: modules.freeze.sessionProfileRoutingAt(resolution, foreignTarget),
|
|
120
141
|
notice: modules.freeze.inheritedProfileDriftNotice(options),
|
|
121
142
|
};
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* The routing snapshot a reviewer reads after resuming `transcript` in the
|
|
148
|
+
* session's own repository: v1 is the selection before A1 (#2720). Both read
|
|
149
|
+
* the replay's config home, worktree and environment through the process-wide
|
|
150
|
+
* defaults, so the environment the tests run in never leaks into the replay.
|
|
151
|
+
*/
|
|
152
|
+
export function replayReviewerRouting(version: Version, transcript: Transcript): AgentModelConfig {
|
|
153
|
+
return resume(version, transcript, ({ options, agentHome }) => {
|
|
154
|
+
const replayed: NodeJS.ProcessEnv = { GENTLE_PI_AGENTS_CHILD: undefined, GENTLE_PI_PROFILE_FOLLOW: undefined, ...options.env, GENTLE_PI_CONFIG_HOME: options.configHome, GENTLE_PI_AGENT_HOME: agentHome };
|
|
155
|
+
const previous = Object.fromEntries(Object.keys(replayed).map((key) => [key, process.env[key]]));
|
|
156
|
+
const assign = (values: NodeJS.ProcessEnv) => {
|
|
157
|
+
for (const [key, value] of Object.entries(values)) {
|
|
158
|
+
if (value === undefined) delete process.env[key];
|
|
159
|
+
else process.env[key] = value;
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
assign(replayed);
|
|
163
|
+
setProfilePinWorktreeResolverForTesting(options.resolveWorktree);
|
|
164
|
+
try {
|
|
165
|
+
const read = version === "v1" ? v1Reviewer.readReviewerModelConfig : __testing.readReviewerModelConfig;
|
|
166
|
+
return JSON.parse(JSON.stringify(read(options.cwd, options.sessionId)));
|
|
167
|
+
} finally {
|
|
168
|
+
setProfilePinWorktreeResolverForTesting();
|
|
169
|
+
assign(previous);
|
|
170
|
+
}
|
|
171
|
+
});
|
|
125
172
|
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import test from "node:test";
|
|
5
|
+
|
|
6
|
+
// ---------------------------------------------------------------------------
|
|
7
|
+
// full-delegation-mode-conflicts S2/S3/S4/S6/S8.
|
|
8
|
+
//
|
|
9
|
+
// In full delegation mode the organic routing rules are removed from what the
|
|
10
|
+
// orchestrator can read, never annotated as "does not apply": a rule left in
|
|
11
|
+
// context is a rule a model may follow. This file pins that closure over the
|
|
12
|
+
// whole always-on prompt AND every lazy asset it names, so the day the mirrored
|
|
13
|
+
// provider contract or a shared asset reintroduces an inline-first rule, this
|
|
14
|
+
// test fails instead of a user's session deadlocking.
|
|
15
|
+
// ---------------------------------------------------------------------------
|
|
16
|
+
|
|
17
|
+
const REPO_ROOT = join(import.meta.dirname, "..");
|
|
18
|
+
const ASSETS = join(REPO_ROOT, "assets");
|
|
19
|
+
const { __testing } = await import("../extensions/gentle-ai.ts");
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Phrases that route work inline, or decide delegation by size. "Task Size" is deliberately absent: it defines
|
|
23
|
+
* tracking and risk in both modes, and the full delegation core keeps that section.
|
|
24
|
+
*/
|
|
25
|
+
const ORGANIC_ROUTING = /\binline\b|small path|small edits|never delegates|Writer (?:rule|trigger)/i;
|
|
26
|
+
|
|
27
|
+
test("S6: the closure rule recognises the organic sentences a narrower pattern let through", () => {
|
|
28
|
+
// Independent verification B1: each of these, inserted into a reachable asset, passed an earlier,
|
|
29
|
+
// phrase-by-phrase pattern. Any "inline" now fails the closure, with no allowlist to maintain.
|
|
30
|
+
for (const sentence of [
|
|
31
|
+
"Units of about 100 changed lines or less always run inline: the parent edits them.",
|
|
32
|
+
"Without a reason, the parent works inline, following the logbook.",
|
|
33
|
+
"Is the change small? If no, delegate it. If no, do it inline.",
|
|
34
|
+
"Small task pattern: parent edits inline, then reports.",
|
|
35
|
+
"6. **Implement task by task.** Implement inline unless a trigger fires.",
|
|
36
|
+
"A large task alone never delegates.",
|
|
37
|
+
]) {
|
|
38
|
+
assert.ok(ORGANIC_ROUTING.test(sentence), sentence);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
function render(mode: "organic" | "full-delegation"): string {
|
|
43
|
+
return __testing.buildGentlePrompt("gentleman", REPO_ROOT, undefined, undefined, undefined, mode);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function namesIn(text: string): string[] {
|
|
47
|
+
return [...new Set([...text.matchAll(/orchestrator(?:-[a-z]+)*\.md/g)].map((match) => match[0]))];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Every lazy asset reachable from the prompt: named by it, or by an asset it names, transitively. */
|
|
51
|
+
function namedAssets(prompt: string): string[] {
|
|
52
|
+
const reached = new Set<string>();
|
|
53
|
+
const pending = namesIn(prompt);
|
|
54
|
+
while (pending.length > 0) {
|
|
55
|
+
const name = pending.pop()!;
|
|
56
|
+
if (reached.has(name)) continue;
|
|
57
|
+
reached.add(name);
|
|
58
|
+
const path = join(ASSETS, name);
|
|
59
|
+
if (existsSync(path)) pending.push(...namesIn(readFileSync(path, "utf8")));
|
|
60
|
+
}
|
|
61
|
+
return [...reached].sort();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function organicLines(text: string): string[] {
|
|
65
|
+
return text.split("\n").filter((line) => ORGANIC_ROUTING.test(line));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
test("S2/S6: the full delegation prompt carries no organic routing rule", () => {
|
|
69
|
+
assert.deepEqual(organicLines(render("full-delegation")), []);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
test("S2/S6: no lazy asset reachable from the full delegation prompt carries an organic routing rule", () => {
|
|
73
|
+
const named = namedAssets(render("full-delegation"));
|
|
74
|
+
assert.ok(named.length > 0, "the prompt must still point at its lazy detail");
|
|
75
|
+
for (const name of named) {
|
|
76
|
+
const path = join(ASSETS, name);
|
|
77
|
+
assert.ok(existsSync(path), `the prompt names a lazy asset that does not exist: ${name}`);
|
|
78
|
+
assert.deepEqual(organicLines(readFileSync(path, "utf8")), [], `${name} reaches a full delegation session`);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
test("S3: full delegation keeps a Task Size that decides tracking and risk, never who writes", () => {
|
|
83
|
+
const prompt = render("full-delegation");
|
|
84
|
+
assert.match(prompt, /## Task Size/);
|
|
85
|
+
assert.match(prompt, /resume test/i);
|
|
86
|
+
for (const item of ["(1)", "(2)", "(3)", "(4)", "(5)", "(6)"]) assert.ok(prompt.includes(item), `high-risk item ${item} is missing`);
|
|
87
|
+
assert.match(prompt, /Risk line/);
|
|
88
|
+
assert.doesNotMatch(prompt, /small work follows/i);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
test("S4: full delegation tells the agent how the human switches the mode, and that no new session is needed", () => {
|
|
92
|
+
const prompt = render("full-delegation");
|
|
93
|
+
assert.match(prompt, /\/gentle:profiles/);
|
|
94
|
+
assert.match(prompt, /`w`/);
|
|
95
|
+
assert.match(prompt, /next turn/i);
|
|
96
|
+
assert.match(prompt, /no new session/i);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
test("S2: the projected ODD steps keep every unchanged step and the shared tail lines byte for byte", () => {
|
|
100
|
+
const organic = render("organic").split("\n");
|
|
101
|
+
const full = render("full-delegation");
|
|
102
|
+
for (const step of ["1. **Authorize.**", "3. **Resolve uncertainty.**", "5. **Track before the first write.**", "7. **Close.**", "Phase reporting: "]) {
|
|
103
|
+
const line = organic.find((candidate) => candidate.startsWith(step));
|
|
104
|
+
assert.ok(line, `organic render lost ${step}`);
|
|
105
|
+
assert.ok(full.includes(line), `full delegation must keep ${step} verbatim`);
|
|
106
|
+
}
|
|
107
|
+
// The resume line is shared too; only its pointer to the organic card is projected.
|
|
108
|
+
const resume = organic.find((candidate) => candidate.startsWith("Resume an interrupted feature "));
|
|
109
|
+
assert.ok(resume?.includes("`orchestrator-delegation.md`"));
|
|
110
|
+
assert.ok(full.includes(resume!.replace("`orchestrator-delegation.md`", "`orchestrator-full-delegation-card.md`")), "resume keeps every byte but its pointer");
|
|
111
|
+
for (const step of ["2. **Explore.**", "4. **Classify.**", "6. **Implement task by task.**"]) {
|
|
112
|
+
assert.ok(full.split("\n").some((line) => line.startsWith(step)), `full delegation must keep a step ${step}`);
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
test("S8: the organic render still carries the mirrored steps unprojected", () => {
|
|
117
|
+
const organic = render("organic");
|
|
118
|
+
assert.match(organic, /4\. \*\*Classify\.\*\* Size the task by the orchestrator's Task Size section; its criteria and resume test alone decide small or large, and small work follows its small path\./);
|
|
119
|
+
assert.match(organic, /when in doubt, work inline/);
|
|
120
|
+
assert.match(organic, /`orchestrator-delegation-reference\.md`/);
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
test("S2: the full delegation card is up to date with the organic sources it projects", async () => {
|
|
124
|
+
const { renderFullDelegationCard, FULL_DELEGATION_CARD } = await import("../scripts/build-full-delegation-card.mjs");
|
|
125
|
+
assert.equal(
|
|
126
|
+
readFileSync(join(ASSETS, FULL_DELEGATION_CARD), "utf8"),
|
|
127
|
+
renderFullDelegationCard(ASSETS),
|
|
128
|
+
"run node scripts/build-full-delegation-card.mjs --write",
|
|
129
|
+
);
|
|
130
|
+
});
|
|
131
|
+
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import test from "node:test";
|
|
3
|
+
|
|
4
|
+
import { createContextBackstopSignal } from "../lib/context-backstop.ts";
|
|
5
|
+
import { createExplorationBudget } from "../lib/exploration-budget.ts";
|
|
6
|
+
import { todoPromptBlock } from "../lib/shell-todo.ts";
|
|
7
|
+
|
|
8
|
+
// ---------------------------------------------------------------------------
|
|
9
|
+
// full-delegation-mode-conflicts S5: runtime notices emitted in full delegation
|
|
10
|
+
// mode never tell the parent to work inline. Organic notices keep their exact
|
|
11
|
+
// text. The mode is passed as a thunk so it is resolved only when a notice is
|
|
12
|
+
// actually emitted, never on every tool result.
|
|
13
|
+
// ---------------------------------------------------------------------------
|
|
14
|
+
|
|
15
|
+
const INLINE = /stays? inline|inline write|do it and report/;
|
|
16
|
+
const env = { GENTLE_PI_CONTEXT_BACKSTOP_TOKENS: "1000" };
|
|
17
|
+
const usage = { tokens: 5_000, contextWindow: 100_000 };
|
|
18
|
+
|
|
19
|
+
test("S5: the context backstop notice in full delegation mode has no inline clause", () => {
|
|
20
|
+
const notice = createContextBackstopSignal(env)("full", usage, () => "full-delegation");
|
|
21
|
+
assert.ok(notice);
|
|
22
|
+
assert.doesNotMatch(notice, INLINE);
|
|
23
|
+
assert.match(notice, /delegate the next bounded unit/);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
test("S5: the organic context backstop notice is unchanged", () => {
|
|
27
|
+
const organic = createContextBackstopSignal(env)("organic", usage, () => "organic");
|
|
28
|
+
const legacy = createContextBackstopSignal(env)("legacy", usage);
|
|
29
|
+
assert.equal(organic, legacy, "an organic mode and no mode at all read the same");
|
|
30
|
+
assert.match(organic ?? "", /while single small edits and state checks stay inline\.$/);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test("S5: the mode is resolved only when the backstop notice is emitted", () => {
|
|
34
|
+
let resolved = 0;
|
|
35
|
+
const signal = createContextBackstopSignal(env);
|
|
36
|
+
signal("lazy", { tokens: 10, contextWindow: 100_000 }, () => { resolved += 1; return "full-delegation"; });
|
|
37
|
+
assert.equal(resolved, 0, "below the backstop nothing reads the mode");
|
|
38
|
+
signal("lazy", usage, () => { resolved += 1; return "full-delegation"; });
|
|
39
|
+
signal("lazy", usage, () => { resolved += 1; return "full-delegation"; });
|
|
40
|
+
assert.equal(resolved, 1, "one notice per crossing, one resolution");
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
function overBudget(mode?: () => "organic" | "full-delegation"): string | undefined {
|
|
44
|
+
const budget = createExplorationBudget();
|
|
45
|
+
budget.start("s");
|
|
46
|
+
let notice: string | undefined;
|
|
47
|
+
for (let index = 0; index < 5; index++) {
|
|
48
|
+
const id = `call-${index}`;
|
|
49
|
+
budget.call("s", id, "read");
|
|
50
|
+
notice ??= budget.result("s", { toolCallId: id, toolName: "read", isError: false, content: [{ type: "text", text: "x".repeat(20_000) }] } as never, true, false, mode);
|
|
51
|
+
}
|
|
52
|
+
return notice;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
test("S5: the exploration budget notice in full delegation mode names the writer, not an inline write", () => {
|
|
56
|
+
const notice = overBudget(() => "full-delegation");
|
|
57
|
+
assert.ok(notice);
|
|
58
|
+
assert.doesNotMatch(notice, INLINE);
|
|
59
|
+
assert.match(notice, /Reading that prepares a writer belongs in that writer's prompt\./);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
test("S5: the organic exploration budget notice is unchanged", () => {
|
|
63
|
+
const organic = overBudget(() => "organic");
|
|
64
|
+
assert.equal(organic, overBudget());
|
|
65
|
+
assert.match(organic ?? "", /Preparation for an already-understood authorized inline write remains exempt\./);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
test("S5: the todo block in full delegation mode delegates small tasks instead of doing them", () => {
|
|
69
|
+
assert.doesNotMatch(todoPromptBlock("full-delegation"), INLINE);
|
|
70
|
+
assert.match(todoPromptBlock("full-delegation"), /A small task \(Task Size\) uses no todo list: delegate it and report\./);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
test("S5: the organic todo block is byte-identical", () => {
|
|
74
|
+
assert.equal(todoPromptBlock("organic"), todoPromptBlock());
|
|
75
|
+
assert.match(todoPromptBlock(), /A small task \(Task Size\) uses no todo list: do it and report\./);
|
|
76
|
+
});
|
|
@@ -5,9 +5,9 @@ import test from "node:test";
|
|
|
5
5
|
|
|
6
6
|
const agents = join(process.cwd(), "assets", "agents");
|
|
7
7
|
const roles: Record<string, string[]> = {
|
|
8
|
-
"gentle-ai-explore.md": ["read", "grep", "find", "codegraph", "web_enable", "web_search", "source_check", "fetch_content", "get_search_content"],
|
|
9
|
-
"gentle-ai-worker.md": ["read", "grep", "find", "edit", "write", "bash", "mem_save"],
|
|
10
|
-
"gentle-ai-verify.md": ["read", "grep", "find", "bash"],
|
|
8
|
+
"gentle-ai-explore.md": ["read", "grep", "find", "codegraph", "web_enable", "web_search", "source_check", "fetch_content", "get_search_content", "mcp__codegraph__codegraph_explore"],
|
|
9
|
+
"gentle-ai-worker.md": ["read", "grep", "find", "edit", "write", "bash", "mem_save", "mcp__codegraph__codegraph_explore"],
|
|
10
|
+
"gentle-ai-verify.md": ["read", "grep", "find", "bash", "mcp__codegraph__codegraph_explore"],
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
function tools(file: string): string[] {
|