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
|
@@ -8,7 +8,8 @@ test("the layout schematic draws where the header, Status and sections go", () =
|
|
|
8
8
|
const neutral = layoutSchematic(DEFAULT_VISUAL_SETTINGS).split("\n");
|
|
9
9
|
assert.equal(neutral.length, 4);
|
|
10
10
|
for (const line of neutral) assert.equal(visibleWidth(line), visibleWidth(neutral[0]!), "a closed box");
|
|
11
|
-
assert.match(neutral[0]!, /^┌─ header
|
|
11
|
+
assert.match(neutral[0]!, /^┌─ header ─+┐$/, "the top header spans the conversation and rail");
|
|
12
|
+
assert.doesNotMatch(neutral[0]!, /┬|Status/);
|
|
12
13
|
assert.match(neutral.join("\n"), /todos/);
|
|
13
14
|
assert.doesNotMatch(neutral.join("\n"), /stats/);
|
|
14
15
|
assert.match(neutral[3]!, /bar under 140 cols/, "auto explains its fallback");
|
|
@@ -20,9 +21,22 @@ test("the layout schematic draws where the header, Status and sections go", () =
|
|
|
20
21
|
assert.doesNotMatch(light.join("\n"), /Status ─|todos/, "Light has no rail");
|
|
21
22
|
assert.match(light[3]!, /status bar/);
|
|
22
23
|
|
|
24
|
+
const belowRail = layoutSchematic({ ...DEFAULT_VISUAL_SETTINGS, headerPlacement: "below-input" }).split("\n");
|
|
25
|
+
assert.match(belowRail[0]!, /┬─ Status/);
|
|
26
|
+
assert.match(belowRail[3]!, /^└─ status bar ─+┘$/, "the bottom bar spans both columns");
|
|
27
|
+
for (const line of belowRail) assert.equal(visibleWidth(line), visibleWidth(belowRail[0]!));
|
|
28
|
+
|
|
23
29
|
const below = layoutSchematic({ ...DEFAULT_VISUAL_SETTINGS, headerPlacement: "below-input", statusPlacement: "hidden" }).split("\n");
|
|
24
30
|
assert.doesNotMatch(below[0]!, /header/);
|
|
25
31
|
assert.match(below.join("\n"), /› input · header/);
|
|
26
32
|
assert.doesNotMatch(below.join("\n"), /Status|status bar/, "hidden shows no Status at all");
|
|
27
33
|
for (const line of below) assert.equal(visibleWidth(line), visibleWidth(below[0]!));
|
|
28
34
|
});
|
|
35
|
+
|
|
36
|
+
test("the layout schematic draws a split header as a title row over the rail and a status bar under it", () => {
|
|
37
|
+
const split = layoutSchematic({ ...DEFAULT_VISUAL_SETTINGS, headerPlacement: "split" }).split("\n");
|
|
38
|
+
assert.match(split[0]!, /^┌─ title ─+┐$/, "the title row spans the rail");
|
|
39
|
+
assert.match(split[split.length - 1]!, /status bar/);
|
|
40
|
+
assert.match(split.join("\n"), /todos/, "the rail sections stay");
|
|
41
|
+
for (const line of split) assert.equal(visibleWidth(line), visibleWidth(split[0]!), "a closed box");
|
|
42
|
+
});
|
|
@@ -85,3 +85,14 @@ test("symlinked catalog file is rejected instead of followed, and save/delete le
|
|
|
85
85
|
assert.throws(() => deleteVisualProfile("x", { gentlePiConfigHome: home }));
|
|
86
86
|
assert.equal(readFileSync(target, "utf8"), targetContent);
|
|
87
87
|
});
|
|
88
|
+
|
|
89
|
+
test("a profile stores the chrome surface only when tinted and reads older profiles as the transparent default", () => {
|
|
90
|
+
const home = { gentlePiConfigHome: mkdtempSync(join(tmpdir(), "visual-profiles-surface-")) };
|
|
91
|
+
saveVisualProfile("clear", values, home);
|
|
92
|
+
saveVisualProfile("tinted", { ...values, visual: { ...structuredClone(DEFAULT_VISUAL_SETTINGS), surface: "tinted" } }, home);
|
|
93
|
+
const stored = JSON.parse(readFileSync(join(home.gentlePiConfigHome, "visual-profiles.json"), "utf8")) as { profiles: { name: string; visual: Record<string, unknown> }[] };
|
|
94
|
+
assert.equal(Object.hasOwn(stored.profiles.find((p) => p.name === "clear")!.visual, "surface"), false, "older versions keep reading it");
|
|
95
|
+
assert.equal(stored.profiles.find((p) => p.name === "tinted")!.visual.surface, "tinted");
|
|
96
|
+
assert.equal(getVisualProfile("clear", home)?.visual.surface, "transparent");
|
|
97
|
+
assert.equal(getVisualProfile("tinted", home)?.visual.surface, "tinted");
|
|
98
|
+
});
|
|
@@ -19,6 +19,8 @@ const { runVoiceWorker } = createRequire(import.meta.url)("../scripts/voice-work
|
|
|
19
19
|
const SCHEMA = "gentle.voice/v1";
|
|
20
20
|
const SHERPA_ENTRY = "node_modules/sherpa-onnx-node/non-streaming-asr.js";
|
|
21
21
|
const CPAL_ENTRY = "node_modules/node-cpal/index.js";
|
|
22
|
+
const PULSE_ENTRY = "node_modules/node-cpal/backend-pulseaudio.js";
|
|
23
|
+
const PULSE_NATIVE = "node_modules/node-cpal/bin/backend-pulseaudio/linux-x64/index.node";
|
|
22
24
|
const NATIVE = "node_modules/sherpa-onnx-linux-x64/sherpa-onnx.node";
|
|
23
25
|
const uid = typeof process.getuid === "function" ? process.getuid() : undefined;
|
|
24
26
|
|
|
@@ -34,7 +36,7 @@ function install(t: test.TestContext): Install {
|
|
|
34
36
|
const dir = mkdtempSync(join(base, "voice-worker-"));
|
|
35
37
|
t.after(() => rmSync(dir, { recursive: true, force: true }));
|
|
36
38
|
const runtimeRoot = join(dir, "runtime");
|
|
37
|
-
for (const file of [SHERPA_ENTRY, CPAL_ENTRY, NATIVE]) {
|
|
39
|
+
for (const file of [SHERPA_ENTRY, CPAL_ENTRY, NATIVE, PULSE_ENTRY, PULSE_NATIVE]) {
|
|
38
40
|
mkdirSync(dirname(join(runtimeRoot, file)), { recursive: true });
|
|
39
41
|
writeFileSync(join(runtimeRoot, file), `// ${file}\n`);
|
|
40
42
|
}
|
|
@@ -128,7 +130,7 @@ function harness(t: test.TestContext, fake: FakeOptions = {}, io: Record<string,
|
|
|
128
130
|
loaded.push(file);
|
|
129
131
|
if (fake.loadError) throw new Error(fake.loadError);
|
|
130
132
|
if (file === join(paths.runtimeRoot, ...SHERPA_ENTRY.split("/"))) return { OfflineRecognizer };
|
|
131
|
-
if (file === join(paths.runtimeRoot, ...
|
|
133
|
+
if ([CPAL_ENTRY, PULSE_ENTRY].some((entry) => file === join(paths.runtimeRoot, ...entry.split("/")))) return { convenience };
|
|
132
134
|
throw new Error(`unexpected module ${file}`);
|
|
133
135
|
},
|
|
134
136
|
platform: "linux",
|
|
@@ -152,6 +154,35 @@ const interleaved = (frames: number, channels: number, value: (frame: number, ch
|
|
|
152
154
|
return data;
|
|
153
155
|
};
|
|
154
156
|
|
|
157
|
+
test("WSL uses the shipped PulseAudio backend without loading ALSA", async (t) => {
|
|
158
|
+
const h = harness(t, {}, { kernelRelease: "6.18-microsoft-standard-WSL2" });
|
|
159
|
+
h.send(startRequest(h.paths));
|
|
160
|
+
await h.waitFor(() => h.types().includes("recording"));
|
|
161
|
+
h.send({ schema: SCHEMA, type: "cancel" });
|
|
162
|
+
await h.done;
|
|
163
|
+
assert.deepEqual(h.loaded, [join(h.paths.runtimeRoot, PULSE_ENTRY)]);
|
|
164
|
+
assert.equal(h.streams[0].closes, 1);
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
test("ordinary Linux keeps the default capture backend", async (t) => {
|
|
168
|
+
const h = harness(t, {}, { kernelRelease: "6.8.0-generic" });
|
|
169
|
+
h.send(startRequest(h.paths));
|
|
170
|
+
await h.waitFor(() => h.types().includes("recording"));
|
|
171
|
+
h.send({ schema: SCHEMA, type: "cancel" });
|
|
172
|
+
await h.done;
|
|
173
|
+
assert.deepEqual(h.loaded, [join(h.paths.runtimeRoot, CPAL_ENTRY)]);
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
test("WSL refuses an incomplete PulseAudio backend before native loading", async (t) => {
|
|
177
|
+
const h = harness(t, {}, { kernelRelease: "6.18-microsoft-standard-WSL2" });
|
|
178
|
+
rmSync(join(h.paths.runtimeRoot, PULSE_NATIVE));
|
|
179
|
+
h.send(startRequest(h.paths));
|
|
180
|
+
await h.done;
|
|
181
|
+
assert.deepEqual(h.loaded, []);
|
|
182
|
+
assert.deepEqual(h.messages, [{ schema: SCHEMA, type: "error", code: "runtime-invalid" }]);
|
|
183
|
+
assert.equal(h.exitCode(), 1);
|
|
184
|
+
});
|
|
185
|
+
|
|
155
186
|
test("records multichannel audio, resamples it to 16 kHz mono and closes its retained stream once on stop", async (t) => {
|
|
156
187
|
const worker = harness(t);
|
|
157
188
|
worker.send(startRequest(worker.paths));
|
|
@@ -312,6 +343,46 @@ test("reports a missing microphone, an unusable format and empty audio", async (
|
|
|
312
343
|
}
|
|
313
344
|
});
|
|
314
345
|
|
|
346
|
+
// node-cpal reports stream errors as CpalError objects with a string code.
|
|
347
|
+
const cpalError = (code: string, message: string) => Object.assign(new Error(message), { code });
|
|
348
|
+
|
|
349
|
+
test("a buffer underrun or overrun keeps capturing and the dictation is still transcribed", async (t) => {
|
|
350
|
+
const worker = harness(t);
|
|
351
|
+
worker.send(startRequest(worker.paths));
|
|
352
|
+
await worker.waitFor(() => worker.types().includes("recording"));
|
|
353
|
+
const [stream] = worker.streams;
|
|
354
|
+
// WASAPI reports one before the first buffer on some devices; others may report one between buffers.
|
|
355
|
+
stream!.options.onError(cpalError("XRUN", "A buffer underrun or overrun occurred."));
|
|
356
|
+
stream!.options.onData(interleaved(4800, 2, () => 16384));
|
|
357
|
+
stream!.options.onError(cpalError("XRUN", "A buffer underrun or overrun occurred."));
|
|
358
|
+
stream!.options.onData(interleaved(4800, 2, () => 16384));
|
|
359
|
+
worker.send({ schema: SCHEMA, type: "stop" });
|
|
360
|
+
await worker.done;
|
|
361
|
+
assert.deepEqual(worker.types(), ["recording", "transcribing", "result"]);
|
|
362
|
+
assert.equal(worker.messages.at(-1)!.text, "hello world");
|
|
363
|
+
assert.equal(worker.recognizers[0]!.waves[0]!.samples.length, 3200);
|
|
364
|
+
assert.equal(stream!.closes, 1);
|
|
365
|
+
assert.equal(worker.exitCode(), 0);
|
|
366
|
+
});
|
|
367
|
+
|
|
368
|
+
test("any other stream error ends the session with capture", async (t) => {
|
|
369
|
+
for (const error of [cpalError("DEVICE_NOT_AVAILABLE", "The requested audio device is not available."), cpalError("OTHER", "backend failure"), new Error("no code"), undefined]) {
|
|
370
|
+
await t.test(String(error?.message), async (st) => {
|
|
371
|
+
const worker = harness(st);
|
|
372
|
+
worker.send(startRequest(worker.paths));
|
|
373
|
+
await worker.waitFor(() => worker.types().includes("recording"));
|
|
374
|
+
const [stream] = worker.streams;
|
|
375
|
+
stream!.options.onData(interleaved(4800, 2, () => 16384));
|
|
376
|
+
stream!.options.onError(error);
|
|
377
|
+
await worker.done;
|
|
378
|
+
assert.deepEqual(worker.messages.at(-1), { schema: SCHEMA, type: "error", code: "capture" });
|
|
379
|
+
assert.equal(worker.exitCode(), 1);
|
|
380
|
+
assert.equal(stream!.closes, 1);
|
|
381
|
+
assert.equal(worker.recognizers.length, 0);
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
});
|
|
385
|
+
|
|
315
386
|
test("refuses to run on Node older than 22", async (t) => {
|
|
316
387
|
const worker = harness(t, {}, { nodeVersion: "20.18.0" });
|
|
317
388
|
await worker.done;
|
|
@@ -752,3 +752,129 @@ test("Windows host late guards prevent unhandled errors without external error l
|
|
|
752
752
|
assert.equal(child.stdout.listenerCount("error"), 0);
|
|
753
753
|
assert.equal(child.stderr.listenerCount("error"), 0);
|
|
754
754
|
});
|
|
755
|
+
|
|
756
|
+
test("Windows host classifies known bootstrap stderr markers into sanitized codes and drops unknown lines", async () => {
|
|
757
|
+
const cases: Array<{ chunks: string[]; expected: string[] }> = [
|
|
758
|
+
// Split across chunks with a CRLF terminator, as Console.Error.WriteLine writes on Windows.
|
|
759
|
+
{ chunks: ['{"kind":"windows-session-bootstrap-diagnostic","category":"comp', 'iler","compilerCodes":["CS1001"],"reason":"source-code-error","languageMode":"full"}\r\n'], expected: ["diagnostic-compiler"] },
|
|
760
|
+
{ chunks: ['{"kind":"windows-session-bootstrap-rejection","stage":"transport-assert-owned","ntstatus":3221225524}\n'], expected: ["rejection-transport-assert-owned"] },
|
|
761
|
+
// Unknown, private, malformed, and oversized lines are consumed and dropped; only the first known marker is reported.
|
|
762
|
+
{ chunks: [
|
|
763
|
+
"plain stderr C:\\Users\\secret\\token\n",
|
|
764
|
+
'{"kind":"windows-session-bootstrap-rejection","stage":"transport-assert-owned","ntstatus":0,"sid":"S-1-5-18"}\n',
|
|
765
|
+
'{"kind":"windows-session-bootstrap-rejection","stage":"SECRET","ntstatus":null}\n',
|
|
766
|
+
'{"kind":"windows-session-bootstrap-diagnostic","category":"other","compilerCodes":[],"reason":"unknown"}\n',
|
|
767
|
+
`${"x".repeat(20_000)}`, '{"kind":"windows-session-bootstrap-rejection","stage":"volume-open","ntstatus":null}\n',
|
|
768
|
+
'{"kind":"windows-session-bootstrap-diagnostic","category":"security","compilerCodes":[],"reason":"unknown","languageMode":"constrained"}\n',
|
|
769
|
+
'{"kind":"windows-session-bootstrap-rejection","stage":"ancestor-open","ntstatus":null}\n',
|
|
770
|
+
], expected: ["diagnostic-security"] },
|
|
771
|
+
{ chunks: ["unrelated warning\n", "{}\n"], expected: [] },
|
|
772
|
+
];
|
|
773
|
+
for (const { chunks, expected } of cases) {
|
|
774
|
+
const child = new FakeTransportChild();
|
|
775
|
+
const codes: string[] = [];
|
|
776
|
+
const host = new WindowsSessionTransportHost({ spawnProcess: () => child as never, onBootstrapDiagnostic: (code) => { codes.push(code); return undefined; } });
|
|
777
|
+
const starting = host.start();
|
|
778
|
+
assert.equal(child.stderr.listenerCount("data"), 1, "stderr stays consumed by the host");
|
|
779
|
+
for (const chunk of chunks) child.stderr.emit("data", Buffer.from(chunk));
|
|
780
|
+
assert.deepEqual(codes, expected);
|
|
781
|
+
assert.equal(host.bootstrapDiagnostic, expected[0] ?? null);
|
|
782
|
+
child.stdout.emit("data", Buffer.from('{"requestId":"start-1","ok":true,"result":{"state":"partial"}}\n'));
|
|
783
|
+
await starting;
|
|
784
|
+
child.emit("exit", 1, null);
|
|
785
|
+
child.emit("close", 1, null);
|
|
786
|
+
assert.equal(child.stderr.listenerCount("data"), 0, "the owned stderr data listener is disposed with the child");
|
|
787
|
+
}
|
|
788
|
+
// A throwing observer never disturbs the helper.
|
|
789
|
+
const child = new FakeTransportChild();
|
|
790
|
+
const host = new WindowsSessionTransportHost({ spawnProcess: () => child as never, onBootstrapDiagnostic: () => { throw new Error("observer"); } });
|
|
791
|
+
const starting = host.start();
|
|
792
|
+
assert.doesNotThrow(() => child.stderr.emit("data", Buffer.from('{"kind":"windows-session-bootstrap-rejection","stage":"unknown","ntstatus":null}\n')));
|
|
793
|
+
child.stdout.emit("data", Buffer.from('{"requestId":"start-1","ok":true,"result":{"state":"partial"}}\n'));
|
|
794
|
+
await starting;
|
|
795
|
+
assert.equal(host.bootstrapDiagnostic, "rejection-unknown");
|
|
796
|
+
child.emit("exit", 1, null);
|
|
797
|
+
child.emit("close", 1, null);
|
|
798
|
+
});
|
|
799
|
+
|
|
800
|
+
const startBootstrapHost = async (child: FakeTransportChild = new FakeTransportChild()) => {
|
|
801
|
+
const codes: string[] = [];
|
|
802
|
+
const host = new WindowsSessionTransportHost({ spawnProcess: () => child as never, onBootstrapDiagnostic: (code) => { codes.push(code); return undefined; } });
|
|
803
|
+
const starting = host.start();
|
|
804
|
+
const finish = async () => {
|
|
805
|
+
child.stdout.emit("data", Buffer.from('{"requestId":"start-1","ok":true,"result":{"state":"partial"}}\n'));
|
|
806
|
+
await starting;
|
|
807
|
+
child.emit("exit", 1, null);
|
|
808
|
+
child.emit("close", 1, null);
|
|
809
|
+
};
|
|
810
|
+
return { child, host, codes, finish };
|
|
811
|
+
};
|
|
812
|
+
|
|
813
|
+
test("Windows bootstrap stderr classifier rejects prototype keys, case variants, and extra or missing keys", async () => {
|
|
814
|
+
const { child, host, codes, finish } = await startBootstrapHost();
|
|
815
|
+
for (const line of [
|
|
816
|
+
'{"kind":"windows-session-bootstrap-rejection","stage":"constructor","ntstatus":null}',
|
|
817
|
+
'{"kind":"windows-session-bootstrap-rejection","stage":"toString","ntstatus":null}',
|
|
818
|
+
'{"kind":"windows-session-bootstrap-rejection","stage":"unknown","ntstatus":null,"__proto__":{}}',
|
|
819
|
+
'{"kind":"windows-session-bootstrap-diagnostic","category":"__proto__","compilerCodes":[],"reason":"unknown","languageMode":"full"}',
|
|
820
|
+
'{"kind":"Windows-Session-Bootstrap-Rejection","stage":"unknown","ntstatus":null}',
|
|
821
|
+
'{"kind":"windows-session-bootstrap-rejection","stage":"Unknown","ntstatus":null}',
|
|
822
|
+
'{"kind":"windows-session-bootstrap-diagnostic","category":"Compiler","compilerCodes":[],"reason":"unknown","languageMode":"full"}',
|
|
823
|
+
'{"kind":"windows-session-bootstrap-rejection","stage":"unknown","ntstatus":null,"extra":1}',
|
|
824
|
+
'{"kind":"windows-session-bootstrap-rejection","stage":"unknown"}',
|
|
825
|
+
'{"kind":"windows-session-bootstrap-diagnostic","category":"other","compilerCodes":[],"reason":"unknown","languageMode":"full","extra":1}',
|
|
826
|
+
'["windows-session-bootstrap-rejection"]',
|
|
827
|
+
"null",
|
|
828
|
+
]) child.stderr.emit("data", Buffer.from(`${line}\n`));
|
|
829
|
+
assert.deepEqual(codes, []);
|
|
830
|
+
assert.equal(host.bootstrapDiagnostic, null);
|
|
831
|
+
child.stderr.emit("data", Buffer.from('{"kind":"windows-session-bootstrap-rejection","stage":"routing-open","ntstatus":null}\n'));
|
|
832
|
+
assert.deepEqual(codes, ["rejection-routing-open"]);
|
|
833
|
+
await finish();
|
|
834
|
+
});
|
|
835
|
+
|
|
836
|
+
test("Windows bootstrap stderr classifier accepts a 16384-byte line, drops 16385 bytes, and resets overflow across chunks", async () => {
|
|
837
|
+
const marker = '{"kind":"windows-session-bootstrap-rejection","stage":"volume-open","ntstatus":null}';
|
|
838
|
+
const padded = (bytes: number) => marker + " ".repeat(bytes - Buffer.byteLength(marker));
|
|
839
|
+
const exact = await startBootstrapHost();
|
|
840
|
+
exact.child.stderr.emit("data", Buffer.from(`${padded(16_384)}\n`));
|
|
841
|
+
assert.deepEqual(exact.codes, ["rejection-volume-open"]);
|
|
842
|
+
await exact.finish();
|
|
843
|
+
const over = await startBootstrapHost();
|
|
844
|
+
over.child.stderr.emit("data", Buffer.from(`${padded(16_385)}\n`));
|
|
845
|
+
assert.deepEqual(over.codes, []);
|
|
846
|
+
over.child.stderr.emit("data", Buffer.from('{"kind":"windows-session-bootstrap-rejection","stage":"ancestor-open","ntstatus":null}\n'));
|
|
847
|
+
assert.deepEqual(over.codes, ["rejection-ancestor-open"], "the next line is classified after an oversized one");
|
|
848
|
+
await over.finish();
|
|
849
|
+
const split = await startBootstrapHost();
|
|
850
|
+
split.child.stderr.emit("data", Buffer.from(" ".repeat(10_000)));
|
|
851
|
+
split.child.stderr.emit("data", Buffer.from(" ".repeat(7_000)));
|
|
852
|
+
// The tail of an overflowed line is dropped even when it looks like a marker.
|
|
853
|
+
split.child.stderr.emit("data", Buffer.from(`${marker}\n`));
|
|
854
|
+
assert.deepEqual(split.codes, []);
|
|
855
|
+
split.child.stderr.emit("data", Buffer.from('{"kind":"windows-session-bootstrap-rejection","stage":"presence-assert-owned","ntstatus":null}\n'));
|
|
856
|
+
assert.deepEqual(split.codes, ["rejection-presence-assert-owned"], "overflow resets at the next newline");
|
|
857
|
+
await split.finish();
|
|
858
|
+
});
|
|
859
|
+
|
|
860
|
+
test("Windows bootstrap stderr classifier ignores non-Buffer chunks without disturbing the helper", async () => {
|
|
861
|
+
const { child, host, codes, finish } = await startBootstrapHost();
|
|
862
|
+
assert.doesNotThrow(() => child.stderr.emit("data", '{"kind":"windows-session-bootstrap-rejection","stage":"unknown","ntstatus":null}\n' as never));
|
|
863
|
+
assert.deepEqual(codes, []);
|
|
864
|
+
assert.equal(host.bootstrapDiagnostic, null);
|
|
865
|
+
child.stderr.emit("data", Buffer.from('{"kind":"windows-session-bootstrap-diagnostic","category":"type-load","compilerCodes":[],"reason":"unknown","languageMode":"full"}\n'));
|
|
866
|
+
assert.deepEqual(codes, ["diagnostic-type-load"]);
|
|
867
|
+
await finish();
|
|
868
|
+
});
|
|
869
|
+
|
|
870
|
+
test("Windows bootstrap stderr listeners do not accumulate across repeated host create and close", async () => {
|
|
871
|
+
const child = new FakeTransportChild();
|
|
872
|
+
for (let index = 0; index < 5; index++) {
|
|
873
|
+
const { finish } = await startBootstrapHost(child);
|
|
874
|
+
assert.equal(child.stderr.listenerCount("data"), 1);
|
|
875
|
+
await finish();
|
|
876
|
+
assert.equal(child.stderr.listenerCount("data"), 0);
|
|
877
|
+
assert.equal(child.stderr.listenerCount("error"), 0);
|
|
878
|
+
assert.equal(child.stdout.listenerCount("data"), 0);
|
|
879
|
+
}
|
|
880
|
+
});
|
|
@@ -64,6 +64,34 @@ test("recoverable failure is distinguished from terminal missing proof within ex
|
|
|
64
64
|
]);
|
|
65
65
|
});
|
|
66
66
|
|
|
67
|
+
test("S2: setup failure preserves unrun proof without calling the verifier unavailable", async () => {
|
|
68
|
+
includesAll(await delivered(), [
|
|
69
|
+
"A failed verifier setup is a preparation failure, not an unavailable verifier capability.",
|
|
70
|
+
"If setup fails before probes, preserve the failed attempt and report zero tests run; the checks remain unverified.",
|
|
71
|
+
"An unavailable verifier remains unavailable; do not retry or escalate it.",
|
|
72
|
+
]);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
test("S3: a repaired setup needs one explicit request and keeps every existing limit", async () => {
|
|
76
|
+
includesAll(await delivered(), [
|
|
77
|
+
"After a setup prerequisite is repaired, the human may explicitly request one new bounded verification attempt.",
|
|
78
|
+
"This is a new request, not an automatic retry, and it does not reset the prior attempt or unrelated budgets.",
|
|
79
|
+
"Before proceeding, confirm no child is active or has an uncertain status.",
|
|
80
|
+
"Never bypass consent, a denial, explicit one-run or no-retry limits, terminal native outcomes, or exhausted native budgets.",
|
|
81
|
+
]);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
test("S4-S5: worker exhaustion exposes a bounded continuation without waiving proof", async () => {
|
|
85
|
+
includesAll(await delivered(), [
|
|
86
|
+
"An exhausted worker-local correction limit ends that automatic cycle, not necessarily the feature.",
|
|
87
|
+
"Stop and report the remaining work, failed checks and missing proof, and offer an explicit human-controlled bounded continuation.",
|
|
88
|
+
"Name its scope, executor, correction limit and checks, or let the human stop.",
|
|
89
|
+
"Before any worker continuation, confirm no child is active or has an uncertain status.",
|
|
90
|
+
"A new session does not reset any limit.",
|
|
91
|
+
"When specifically authorized and not prohibited by actual native authority, continue ordinary in-scope compilation or implementation; unavailable proof still blocks completion and delivery.",
|
|
92
|
+
]);
|
|
93
|
+
});
|
|
94
|
+
|
|
67
95
|
test("worker-prohibited maintenance has a bounded parent-only route, not a permission bypass", async () => {
|
|
68
96
|
includesAll(await delivered(), [
|
|
69
97
|
"worker prohibitions remain unchanged",
|
|
@@ -154,3 +154,95 @@ test("S16: child sessions are exempt and an empty workspace_root falls back to t
|
|
|
154
154
|
const emptyRoot = await launchThroughHook({ agent: "gentle-ai-worker", mode: "background", workspace_root: "", task: `Spec: odd/tasks/ledger.md, T1${surfaces}` }, documented, 0);
|
|
155
155
|
assert.equal(emptyRoot?.block, undefined, "an empty workspace_root means the session cwd");
|
|
156
156
|
});
|
|
157
|
+
|
|
158
|
+
// full-delegation-mode-conflicts S1/S7. In full delegation mode the orchestrator never implements, so the admission
|
|
159
|
+
// above would deadlock every small task: the prompt forbids the inline write and this guard forbids the writer.
|
|
160
|
+
// The mode admits the generic writer; the edit-surface guard, which runs first, still applies.
|
|
161
|
+
|
|
162
|
+
test("S1: full delegation mode admits a writer with no feature document, below the backstop", (t) => {
|
|
163
|
+
const root = workspace(false);
|
|
164
|
+
t.after(() => rmSync(root, { recursive: true, force: true }));
|
|
165
|
+
const input = { agent: "gentle-ai-worker", task: `Change the accent colors.${surfaces}` };
|
|
166
|
+
const contextUsage = { tokens: 20_000, contextWindow: 400_000 };
|
|
167
|
+
assert.equal(rejectUndocumentedWriterLaunch(input, { root, contextUsage, orchestratorMode: "full-delegation" }), undefined);
|
|
168
|
+
// Organic mode, stated explicitly, keeps today's rejection word for word.
|
|
169
|
+
const organic = rejectUndocumentedWriterLaunch(input, { root, contextUsage, orchestratorMode: "organic" });
|
|
170
|
+
assert.equal(organic?.block, true);
|
|
171
|
+
assert.match(organic?.reason ?? "", /write this unit inline yourself/);
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
test("S1: full delegation mode admits only generic writers, never widens other agents", (t) => {
|
|
175
|
+
const root = workspace(false);
|
|
176
|
+
t.after(() => rmSync(root, { recursive: true, force: true }));
|
|
177
|
+
const contextUsage = { tokens: 20_000, contextWindow: 400_000 };
|
|
178
|
+
for (const agent of ["gentle-ai-explore", "jd-fix-agent"]) {
|
|
179
|
+
assert.equal(rejectUndocumentedWriterLaunch({ agent, task: "x" }, { root, contextUsage, orchestratorMode: "full-delegation" }), undefined, agent);
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
function withConfigHome<T>(workflowMode: string | undefined, run: (home: string) => Promise<T>): Promise<T> {
|
|
184
|
+
const home = mkdtempSync(join(tmpdir(), "writer-admission-home-"));
|
|
185
|
+
writeFileSync(join(home, "profiles.json"), JSON.stringify({
|
|
186
|
+
kind: "gentle-pi.agent_model_profiles",
|
|
187
|
+
version: 1,
|
|
188
|
+
active: "frontier-local",
|
|
189
|
+
profiles: { "frontier-local": { orchestrator: { model: "openai/gpt-6.1-terra" } } },
|
|
190
|
+
...(workflowMode === undefined ? {} : { workflow: { "frontier-local": { orchestratorMode: workflowMode } } }),
|
|
191
|
+
}));
|
|
192
|
+
const previous = process.env.GENTLE_PI_CONFIG_HOME;
|
|
193
|
+
process.env.GENTLE_PI_CONFIG_HOME = home;
|
|
194
|
+
return run(home).finally(() => {
|
|
195
|
+
if (previous === undefined) delete process.env.GENTLE_PI_CONFIG_HOME;
|
|
196
|
+
else process.env.GENTLE_PI_CONFIG_HOME = previous;
|
|
197
|
+
rmSync(home, { recursive: true, force: true });
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
test("S7: the reported deadlock — a full delegation profile delegates a small task through the real hook", async (t) => {
|
|
202
|
+
const bare = workspace(false);
|
|
203
|
+
t.after(() => rmSync(bare, { recursive: true, force: true }));
|
|
204
|
+
await withConfigHome("full-delegation", async () => {
|
|
205
|
+
const admitted = await launchThroughHook({ agent: "gentle-ai-worker", mode: "background", task: `Change the accent colors.${surfaces}` }, bare, 20_000);
|
|
206
|
+
assert.equal(admitted?.block, undefined, "the small task reaches the writer instead of being sent back inline");
|
|
207
|
+
// The mode never lifts the edit-surface requirement: that guard runs before admission.
|
|
208
|
+
const unscoped = await launchThroughHook({ agent: "gentle-ai-worker", mode: "background", task: "Change the accent colors." }, bare, 20_000);
|
|
209
|
+
assert.equal(unscoped?.block, true, "a writer without allowed edit surfaces is still refused");
|
|
210
|
+
assert.doesNotMatch(unscoped?.reason ?? "", /write this unit inline yourself/);
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
test("S1: an organic profile keeps the undocumented-writer rejection through the real hook", async (t) => {
|
|
215
|
+
const bare = workspace(false);
|
|
216
|
+
t.after(() => rmSync(bare, { recursive: true, force: true }));
|
|
217
|
+
await withConfigHome(undefined, async () => {
|
|
218
|
+
const blocked = await launchThroughHook({ agent: "gentle-ai-worker", mode: "background", task: `Change the accent colors.${surfaces}` }, bare, 20_000);
|
|
219
|
+
assert.equal(blocked?.block, true);
|
|
220
|
+
assert.match(blocked?.reason ?? "", /write this unit inline yourself/);
|
|
221
|
+
});
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
test("S1: the session environment override reaches the guard, as it reaches the prompt", async (t) => {
|
|
225
|
+
const bare = workspace(false);
|
|
226
|
+
t.after(() => rmSync(bare, { recursive: true, force: true }));
|
|
227
|
+
await withConfigHome(undefined, async () => {
|
|
228
|
+
const admitted = await launchThroughHook({ agent: "gentle-ai-worker", mode: "background", task: `Change the accent colors.${surfaces}` }, bare, 20_000, { GENTLE_PI_ORCHESTRATOR_MODE: "full-delegation" });
|
|
229
|
+
assert.equal(admitted?.block, undefined);
|
|
230
|
+
});
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
// Independent verification probe (B-S1): an omitted and an organic mode decide exactly alike for every agent and
|
|
234
|
+
// context, and full delegation widens only the two generic writers.
|
|
235
|
+
test("S1: an omitted or organic mode decides exactly alike; full delegation widens only generic writers", (t) => {
|
|
236
|
+
const root = workspace(false);
|
|
237
|
+
t.after(() => rmSync(root, { recursive: true, force: true }));
|
|
238
|
+
for (const agent of ["gentle-ai-worker", "worker", "gentle-ai-explore", "gentle-ai-verify", "jd-fix-agent", "unknown"]) {
|
|
239
|
+
for (const contextUsage of [undefined, { tokens: 20_000, contextWindow: 400_000 }, { tokens: 150_000, contextWindow: 1_000_000 }]) {
|
|
240
|
+
const input = { agent, task: `Do it.${surfaces}` };
|
|
241
|
+
const omitted = rejectUndocumentedWriterLaunch(input, { root, contextUsage });
|
|
242
|
+
assert.deepEqual(rejectUndocumentedWriterLaunch(input, { root, contextUsage, orchestratorMode: "organic" }), omitted, agent);
|
|
243
|
+
const full = rejectUndocumentedWriterLaunch(input, { root, contextUsage, orchestratorMode: "full-delegation" });
|
|
244
|
+
assert.deepEqual(full, agent === "gentle-ai-worker" || agent === "worker" ? undefined : omitted, agent);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
|
|
@@ -24,7 +24,7 @@ function fixture(t: test.TestContext, order = "owner-first", env: NodeJS.Process
|
|
|
24
24
|
const statuses = new Map<string, unknown>();
|
|
25
25
|
const widgets = new Map<string, unknown>();
|
|
26
26
|
const notices: string[] = [];
|
|
27
|
-
let renders = 0, sessionId = "menu-session";
|
|
27
|
+
let renders = 0, sessionId = "menu-session", slashMode: string | undefined;
|
|
28
28
|
let view: View | undefined, finish: (() => void) | undefined;
|
|
29
29
|
let component: VisualCustomizeView | undefined, actionReady: (() => void) | undefined;
|
|
30
30
|
if (observeActionReady) {
|
|
@@ -51,10 +51,11 @@ function fixture(t: test.TestContext, order = "owner-first", env: NodeJS.Process
|
|
|
51
51
|
sendUserMessage() { assert.fail("menu must not send synthetic user messages"); },
|
|
52
52
|
} as unknown as ExtensionAPI;
|
|
53
53
|
const ctx = {
|
|
54
|
-
cwd:
|
|
54
|
+
cwd: home, mode: "tui", hasUI: true,
|
|
55
55
|
sessionManager: { getSessionId: () => sessionId },
|
|
56
56
|
ui: {
|
|
57
57
|
theme, getAllThemes: () => [{ name: "dark" }], getTheme: () => theme, getEditorComponent: () => undefined,
|
|
58
|
+
select: async (_title: string, choices: string[]) => choices.find(choice => choice.startsWith(`${slashMode} —`)),
|
|
58
59
|
notify: (text: string) => notices.push(text),
|
|
59
60
|
setStatus: (key: string, value: unknown) => statuses.set(key, value),
|
|
60
61
|
setWidget: (key: string, value: unknown) => widgets.set(key, value),
|
|
@@ -68,7 +69,7 @@ function fixture(t: test.TestContext, order = "owner-first", env: NodeJS.Process
|
|
|
68
69
|
},
|
|
69
70
|
} as unknown as ExtensionContext;
|
|
70
71
|
let controller: yolo.YoloSessionController | undefined;
|
|
71
|
-
const owner = () => { controller = yolo.registerYoloSessionPolicy(pi, { ...env, GENTLE_PI_CONFIG_HOME: home }); };
|
|
72
|
+
const owner = () => { controller = yolo.registerYoloSessionPolicy(pi, { ...env, GENTLE_PI_CONFIG_HOME: home }, { resolveIdentity: async () => undefined }); };
|
|
72
73
|
const shell = () => gentleShell(pi, { ...env, GENTLE_PI_CONFIG_HOME: home, GENTLE_PI_SHELL_CHANGES_WATCH_MS: "off" }, {
|
|
73
74
|
fetch: async () => { assert.fail("network disabled"); }, activeProfile: () => undefined, devBinary: () => undefined,
|
|
74
75
|
});
|
|
@@ -77,7 +78,8 @@ function fixture(t: test.TestContext, order = "owner-first", env: NodeJS.Process
|
|
|
77
78
|
const snapshot = () => Object.fromEntries(readdirSync(home).sort().map(name => [name, readFileSync(join(home, name), "utf8")]));
|
|
78
79
|
return {
|
|
79
80
|
pi, ctx, home, events, notices, statuses, widgets, snapshot, controller: () => controller!, renders: () => renders,
|
|
80
|
-
setSessionId: (id: string) => { sessionId = id; },
|
|
81
|
+
setSessionId: (id: string) => { sessionId = id; }, setSlashMode: (mode: string) => { slashMode = mode; },
|
|
82
|
+
view: () => { assert.ok(view); return view; },
|
|
81
83
|
async command(args: string) { await commands.get("gentle:yolo")!.handler(args, ctx); },
|
|
82
84
|
async apply(data: string) {
|
|
83
85
|
assert.ok(observeActionReady && view, "action-ready observation is enabled");
|
|
@@ -145,6 +147,19 @@ test("Customize selects Auto for this session and saves either elevated default
|
|
|
145
147
|
open.close();await open.result;
|
|
146
148
|
});
|
|
147
149
|
|
|
150
|
+
test("slash mode selection refreshes the open Customize view without saving a default", async t => {
|
|
151
|
+
const h = fixture(t); const before = h.snapshot();
|
|
152
|
+
const open = await h.open(); const view = h.view();
|
|
153
|
+
assert.ok(view.focus("Session permissions: SUPER-YOLO")); view.render(140);
|
|
154
|
+
h.setSlashMode("super-yolo"); await h.command("");
|
|
155
|
+
await settle(() => view.focus("Session permissions: SUPER-YOLO (current)"));
|
|
156
|
+
assert.match(text(view), /Session permissions[^\n]*(?:● SUPER-YOLO|‹ SUPER-YOLO ›)/);
|
|
157
|
+
assert.equal(h.statuses.get(yolo.MODE_STATUS_KEY), "Permissions: SUPER-YOLO");
|
|
158
|
+
await h.command("status"); assert.equal(h.notices.at(-1), yolo.SUPER_YOLO_STATUS_TEXT);
|
|
159
|
+
assert.deepEqual(h.snapshot(), before);
|
|
160
|
+
open.close(); await open.result;
|
|
161
|
+
});
|
|
162
|
+
|
|
148
163
|
for (const order of ["owner-first", "shell-first"]) test(`Editor YOLO menu and slash share one owner (${order})`, async t => {
|
|
149
164
|
const h = fixture(t, order, {}, true);
|
|
150
165
|
for (const name of ["vim-policy.json", "visual-settings.json", "visual-profiles.json", "runtime-guardrails.json", "history-capture-policy.json", "agent-profiles.json"]) writeFileSync(join(h.home, name), "{}\n");
|
|
@@ -188,6 +203,14 @@ for (const invalid of [false, true]) test(`absent/invalid owner is unavailable,
|
|
|
188
203
|
|
|
189
204
|
test("scope revocation refreshes without notification recursion or Git during render", async t => {
|
|
190
205
|
const h = fixture(t); await h.command("enable");
|
|
206
|
+
// Resolve the unrelated RDD discovery immediately so its timeout repaint
|
|
207
|
+
// cannot be mistaken for a recursive YOLO revocation notification.
|
|
208
|
+
h.events.on("gentle:rdd:host-ui", data => {
|
|
209
|
+
(data as { respond(value: unknown): void }).respond({
|
|
210
|
+
read: async () => undefined,
|
|
211
|
+
open: async () => { throw new Error("YOLO revocation must not open RDD"); },
|
|
212
|
+
});
|
|
213
|
+
});
|
|
191
214
|
const open = await h.open(); const view = h.view(); selectYolo(view);
|
|
192
215
|
assert.match(text(view), /YOLO: ON/);
|
|
193
216
|
const count = h.renders();
|
package/tests/yolo-mode.test.ts
CHANGED
|
@@ -12,7 +12,13 @@ import { sidebarState } from "../lib/shell-sidebar.ts";
|
|
|
12
12
|
const ON_TEXT = "🚀 YOLO ON 🔥 — destructive confirmations remain";
|
|
13
13
|
const USAGE = "Use /gentle:yolo enable|disable|status. State unchanged.";
|
|
14
14
|
const STALE_MENU = "YOLO unchanged — the session changed while the menu was open.";
|
|
15
|
-
const
|
|
15
|
+
const MODE_CHOICES = [
|
|
16
|
+
"normal — standard permission prompts",
|
|
17
|
+
"auto — independent checks; extra model calls",
|
|
18
|
+
"yolo — scoped work; destructive actions ask",
|
|
19
|
+
"super-yolo — no permission prompts; private paths blocked; consent remains",
|
|
20
|
+
] as const;
|
|
21
|
+
const menuTitle = (state: "NORMAL" | "YOLO") => `Permissions for this session (current: ${state})`;
|
|
16
22
|
|
|
17
23
|
// An empty env would resolve the developer's real ~/.pi/gentle-ai and inherit its persisted mode default.
|
|
18
24
|
const isolatedConfigHomes: string[] = [];
|
|
@@ -106,32 +112,32 @@ test("no argument without a select-capable UI reports status and never toggles",
|
|
|
106
112
|
await h.command(""); assert.equal(h.notices.at(-1), ON_TEXT);
|
|
107
113
|
assert.equal(h.statuses.get("gentle:yolo"), ON_TEXT);
|
|
108
114
|
let prompts = 0;
|
|
109
|
-
h.setSelect(async () => { prompts++; return
|
|
115
|
+
h.setSelect(async () => { prompts++; return MODE_CHOICES[0]; });
|
|
110
116
|
Object.assign(h.ctx, { hasUI: false });
|
|
111
117
|
await h.command("");
|
|
112
118
|
assert.equal(prompts, 0, "headless callers never see the menu");
|
|
113
119
|
assert.match(h.notices.at(-1)!, /OFF/, "headless status reflects fail-closed scope, not a menu choice");
|
|
114
120
|
});
|
|
115
121
|
|
|
116
|
-
test("no-argument menu shows the
|
|
122
|
+
test("no-argument menu shows the live permission mode; only an explicit selection changes it", async () => {
|
|
117
123
|
const h = harness();
|
|
118
124
|
const prompts: Array<{ title: string; options: string[] }> = [];
|
|
119
125
|
let answer: string | undefined;
|
|
120
126
|
h.setSelect(async (title, options) => { prompts.push({ title, options }); return answer; });
|
|
121
127
|
const notices = h.notices.length;
|
|
122
128
|
await h.command("");
|
|
123
|
-
assert.deepEqual(prompts.at(-1), { title: menuTitle("
|
|
129
|
+
assert.deepEqual(prompts.at(-1), { title: menuTitle("NORMAL"), options: MODE_CHOICES });
|
|
124
130
|
assert.equal(h.notices.length, notices, "cancel does nothing");
|
|
125
131
|
assert.equal(h.statuses.get("gentle:yolo"), undefined);
|
|
126
|
-
answer =
|
|
127
|
-
assert.equal(h.notices.at(-1), "
|
|
128
|
-
answer =
|
|
129
|
-
assert.equal(h.statuses.get("gentle:yolo"), ON_TEXT); assert.equal(h.notices.at(-1),
|
|
132
|
+
answer = MODE_CHOICES[0]; await h.command("");
|
|
133
|
+
assert.equal(h.notices.at(-1), "Permissions: NORMAL"); assert.equal(h.statuses.get("gentle:yolo"), undefined);
|
|
134
|
+
answer = MODE_CHOICES[2]; await h.command("");
|
|
135
|
+
assert.equal(h.statuses.get("gentle:yolo"), ON_TEXT); assert.equal(h.notices.at(-1), "Permissions: YOLO");
|
|
130
136
|
answer = undefined; await h.command("");
|
|
131
|
-
assert.equal(prompts.at(-1)!.title, menuTitle("
|
|
137
|
+
assert.equal(prompts.at(-1)!.title, menuTitle("YOLO"));
|
|
132
138
|
assert.equal(h.statuses.get("gentle:yolo"), ON_TEXT, "cancel leaves ON unchanged");
|
|
133
|
-
answer =
|
|
134
|
-
assert.equal(h.statuses.get("gentle:yolo"), undefined); assert.equal(h.notices.at(-1), "
|
|
139
|
+
answer = MODE_CHOICES[0]; await h.command("");
|
|
140
|
+
assert.equal(h.statuses.get("gentle:yolo"), undefined); assert.equal(h.notices.at(-1), "Permissions: NORMAL");
|
|
135
141
|
const shown = prompts.length;
|
|
136
142
|
await h.command("status"); await h.command("invalid");
|
|
137
143
|
assert.equal(prompts.length, shown, "explicit arguments bypass the menu");
|
|
@@ -157,7 +163,7 @@ test("child, headless, RPC and nonexistent workspace cannot activate", async ()
|
|
|
157
163
|
if (variant === "rpc") Object.assign(h.ctx, { mode: "rpc" });
|
|
158
164
|
if (variant === "no-workspace") Object.assign(h.ctx, { cwd: "/nonexistent-gentle-workspace" });
|
|
159
165
|
await h.command("enable"); assert.notEqual(h.statuses.get("gentle:yolo"), ON_TEXT);
|
|
160
|
-
h.setSelect(async () =>
|
|
166
|
+
h.setSelect(async () => MODE_CHOICES[2]);
|
|
161
167
|
await h.command(""); assert.notEqual(h.statuses.get("gentle:yolo"), ON_TEXT, `${variant} menu enable fails closed`);
|
|
162
168
|
}
|
|
163
169
|
});
|
|
@@ -287,17 +293,16 @@ test("tool input and task text cannot activate; scope/UI loss removes instructio
|
|
|
287
293
|
assert.equal(h.statuses.get("gentle:yolo"), undefined);
|
|
288
294
|
});
|
|
289
295
|
|
|
290
|
-
test("a session replaced while the menu is open cannot receive the
|
|
296
|
+
test("a session replaced while the menu is open cannot receive the YOLO choice", async () => {
|
|
291
297
|
const h = harness();
|
|
292
|
-
h.setSelect(async () => { h.setSessionId("replacement-session"); return
|
|
298
|
+
h.setSelect(async () => { h.setSessionId("replacement-session"); return MODE_CHOICES[2]; });
|
|
293
299
|
await h.command("");
|
|
294
300
|
assert.equal(h.statuses.get("gentle:yolo"), undefined, "stale menu choice never activates the new session");
|
|
295
301
|
assert.equal(h.notices.at(-1), STALE_MENU, "the discarded choice is reported, not silent");
|
|
296
|
-
h.setSelect(async () => { h.setSessionId("another-session"); return
|
|
297
|
-
await h.command("");
|
|
298
|
-
assert.equal(h.notices.at(-1), STALE_MENU, "a stale disable is reported too");
|
|
299
|
-
h.setSelect(async () => "status");
|
|
302
|
+
h.setSelect(async () => { h.setSessionId("another-session"); return MODE_CHOICES[0]; });
|
|
300
303
|
await h.command("");
|
|
304
|
+
assert.equal(h.notices.at(-1), STALE_MENU, "a stale Normal choice is reported too");
|
|
305
|
+
await h.command("status");
|
|
301
306
|
assert.equal(h.notices.at(-1), "YOLO OFF");
|
|
302
307
|
});
|
|
303
308
|
|