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
|
@@ -300,7 +300,7 @@ test("the rail draws Todos as a panel section whose header row 0 is the collapse
|
|
|
300
300
|
const rail = sidebarState(tui as never).parts.get("todo")!;
|
|
301
301
|
assert.equal((rail as { surface?: string }).surface, "panel", "the rail paints this section on the panel surface");
|
|
302
302
|
const rows = rail.render(48).map((row) => stripAnsi(row).trimEnd());
|
|
303
|
-
assert.deepEqual(rows, ["▾ TODOS
|
|
303
|
+
assert.deepEqual(rows, ["▾ TODOS ctrl+shift+t 1/3", " ✓ 1 done", " ◐ B", " └ job-1", " ○ C"]);
|
|
304
304
|
assert.doesNotMatch(rows.join("\n"), /[╭╮╰╯│▎]/u, "no card chrome in the rail");
|
|
305
305
|
const pointer = (type: "move" | "click", y: number) => ({
|
|
306
306
|
type, button: type === "move" ? "none" as const : "left" as const, x: 1, y, screenX: 1, screenY: y, width: 48, height: rows.length, shift: false, alt: false, ctrl: false,
|
|
@@ -308,7 +308,7 @@ test("the rail draws Todos as a panel section whose header row 0 is the collapse
|
|
|
308
308
|
assert.deepEqual(rail.handleMouse?.(pointer("move", 0)), { handled: true, render: true }, "the header row is hoverable");
|
|
309
309
|
assert.equal(rail.handleMouse?.(pointer("click", 1)), undefined, "a body row is not the control");
|
|
310
310
|
assert.equal(rail.handleMouse?.(pointer("click", 0))?.handled, true);
|
|
311
|
-
assert.deepEqual(rail.render(48).map((row) => stripAnsi(row).trimEnd()), ["▸ TODOS
|
|
311
|
+
assert.deepEqual(rail.render(48).map((row) => stripAnsi(row).trimEnd()), ["▸ TODOS ctrl+shift+t 1/3", " ◐ B"]);
|
|
312
312
|
}
|
|
313
313
|
});
|
|
314
314
|
|
|
@@ -848,3 +848,20 @@ test("a todo write emits the session's progress; list and errors emit nothing",
|
|
|
848
848
|
await todo({ action: "update", id: 2, status: "done" });
|
|
849
849
|
assert.deepEqual(emitted.at(-1)?.data, { sessionId: "s1", done: 2, total: 3, current: null });
|
|
850
850
|
});
|
|
851
|
+
|
|
852
|
+
// full-delegation-mode-conflicts S5: the todo rules block follows the session's orchestrator mode, so a full
|
|
853
|
+
// delegation session is told to delegate a small task instead of doing it. Organic stays byte-identical above.
|
|
854
|
+
test("S5: a full delegation session gets the delegate wording; the organic wording is unchanged", async () => {
|
|
855
|
+
const full = fakePi();
|
|
856
|
+
gentleTodo(full.pi, { GENTLE_PI_ORCHESTRATOR_MODE: "full-delegation" });
|
|
857
|
+
const fullEvent = promptEvent();
|
|
858
|
+
await full.fire("before_agent_start", { ...fakeContext().ctx, cwd: process.cwd() } as ExtensionContext, fullEvent);
|
|
859
|
+
assert.match(fullEvent.systemPromptOptions.appendSystemPrompt, /uses no todo list: delegate it and report\./);
|
|
860
|
+
assert.doesNotMatch(fullEvent.systemPromptOptions.appendSystemPrompt, /do it and report/);
|
|
861
|
+
|
|
862
|
+
const organic = fakePi();
|
|
863
|
+
gentleTodo(organic.pi, { GENTLE_PI_ORCHESTRATOR_MODE: "organic" });
|
|
864
|
+
const organicEvent = promptEvent();
|
|
865
|
+
await organic.fire("before_agent_start", { ...fakeContext().ctx, cwd: process.cwd() } as ExtensionContext, organicEvent);
|
|
866
|
+
assert.match(organicEvent.systemPromptOptions.appendSystemPrompt, /uses no todo list: do it and report\./);
|
|
867
|
+
});
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import test, { type TestContext } from "node:test";
|
|
3
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
4
|
+
import gentleTps from "../extensions/gentle-tps.ts";
|
|
5
|
+
|
|
6
|
+
type Usage = { input: number; output: number; cacheRead: number; cacheWrite: number; totalTokens: number };
|
|
7
|
+
|
|
8
|
+
function assistant(usage: Partial<Usage>) {
|
|
9
|
+
return { role: "assistant", content: [], usage };
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const smallUsage = { input: 7, output: 20, cacheRead: 3, cacheWrite: 2, totalTokens: 32 };
|
|
13
|
+
const smallNotification = `TPS 20.0 tok/s. out ${(20).toLocaleString()}, in ${(7).toLocaleString()}, cache r/w ${(3).toLocaleString()}/${(2).toLocaleString()}, total ${(32).toLocaleString()}, 1.0s`;
|
|
14
|
+
|
|
15
|
+
function harness(t: TestContext) {
|
|
16
|
+
let now = 0;
|
|
17
|
+
t.mock.method(Date, "now", () => now);
|
|
18
|
+
const handlers = new Map<string, (event: any, ctx: any) => void>();
|
|
19
|
+
const notifications: { message: string; type: string | undefined }[] = [];
|
|
20
|
+
const ctx = {
|
|
21
|
+
hasUI: true,
|
|
22
|
+
ui: { notify: (message: string, type?: string) => notifications.push({ message, type }) },
|
|
23
|
+
};
|
|
24
|
+
gentleTps({ on: (name: string, handler: (event: any, ctx: any) => void) => {
|
|
25
|
+
assert.equal(handlers.has(name), false, `duplicate handler: ${name}`);
|
|
26
|
+
handlers.set(name, handler);
|
|
27
|
+
} } as unknown as ExtensionAPI);
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
ctx,
|
|
31
|
+
handlers,
|
|
32
|
+
notifications,
|
|
33
|
+
start(time: number) {
|
|
34
|
+
now = time;
|
|
35
|
+
assert.ok(handlers.has("agent_start"));
|
|
36
|
+
handlers.get("agent_start")!({ type: "agent_start" }, ctx);
|
|
37
|
+
},
|
|
38
|
+
end(time: number, messages: unknown[]) {
|
|
39
|
+
now = time;
|
|
40
|
+
assert.ok(handlers.has("agent_end"));
|
|
41
|
+
handlers.get("agent_end")!({ type: "agent_end", messages }, ctx);
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
test("reports aggregate assistant usage over the whole agent run", (t) => {
|
|
47
|
+
const h = harness(t);
|
|
48
|
+
assert.deepEqual([...h.handlers.keys()], ["agent_start", "agent_end"]);
|
|
49
|
+
h.start(0);
|
|
50
|
+
h.end(2_500, [
|
|
51
|
+
{ role: "user", usage: { input: 90_000, output: 90_000, cacheRead: 90_000, cacheWrite: 90_000, totalTokens: 90_000 } },
|
|
52
|
+
assistant({ input: 1_500, output: 1_000, cacheRead: 4_000, cacheWrite: 42, totalTokens: 6_542 }),
|
|
53
|
+
{ role: "toolResult", usage: { input: 90_000, output: 90_000, cacheRead: 90_000, cacheWrite: 90_000, totalTokens: 90_000 } },
|
|
54
|
+
assistant({ input: 250, output: 25, cacheRead: 100, cacheWrite: 8, totalTokens: 383 }),
|
|
55
|
+
assistant({}),
|
|
56
|
+
]);
|
|
57
|
+
// Number formatting follows the host locale, just like the existing notification.
|
|
58
|
+
assert.deepEqual(h.notifications, [{
|
|
59
|
+
message: `TPS 410.0 tok/s. out ${(1_025).toLocaleString()}, in ${(1_750).toLocaleString()}, cache r/w ${(4_100).toLocaleString()}/${(50).toLocaleString()}, total ${(6_925).toLocaleString()}, 2.5s`,
|
|
60
|
+
type: "info",
|
|
61
|
+
}]);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
test("ignores an end without a start and consumes a successful end once", (t) => {
|
|
65
|
+
const h = harness(t);
|
|
66
|
+
h.end(1_000, [assistant(smallUsage)]);
|
|
67
|
+
assert.deepEqual(h.notifications, []);
|
|
68
|
+
h.start(2_000);
|
|
69
|
+
h.end(3_000, [assistant(smallUsage)]);
|
|
70
|
+
assert.deepEqual(h.notifications, [{ message: smallNotification, type: "info" }]);
|
|
71
|
+
h.end(4_000, [assistant({ ...smallUsage, output: 200 })]);
|
|
72
|
+
assert.deepEqual(h.notifications, [{ message: smallNotification, type: "info" }]);
|
|
73
|
+
h.start(5_000);
|
|
74
|
+
h.end(7_000, [assistant(smallUsage)]);
|
|
75
|
+
assert.deepEqual(h.notifications, [
|
|
76
|
+
{ message: smallNotification, type: "info" },
|
|
77
|
+
{ message: `TPS 10.0 tok/s. out ${(20).toLocaleString()}, in ${(7).toLocaleString()}, cache r/w ${(3).toLocaleString()}/${(2).toLocaleString()}, total ${(32).toLocaleString()}, 2.0s`, type: "info" },
|
|
78
|
+
]);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
test("suppresses headless runs and consumes their ends", (t) => {
|
|
82
|
+
const h = harness(t);
|
|
83
|
+
h.ctx.hasUI = false;
|
|
84
|
+
h.start(1_000);
|
|
85
|
+
h.end(2_000, [assistant(smallUsage)]);
|
|
86
|
+
assert.deepEqual(h.notifications, []);
|
|
87
|
+
h.ctx.hasUI = true;
|
|
88
|
+
h.end(3_000, [assistant(smallUsage)]);
|
|
89
|
+
assert.deepEqual(h.notifications, []);
|
|
90
|
+
h.start(4_000);
|
|
91
|
+
h.end(5_000, [assistant(smallUsage)]);
|
|
92
|
+
assert.deepEqual(h.notifications, [{ message: smallNotification, type: "info" }]);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
test("suppresses nonpositive elapsed time and consumes the end", (t) => {
|
|
96
|
+
const h = harness(t);
|
|
97
|
+
for (const endTime of [1_000, 999]) {
|
|
98
|
+
h.start(1_000);
|
|
99
|
+
h.end(endTime, [assistant(smallUsage)]);
|
|
100
|
+
assert.deepEqual(h.notifications, []);
|
|
101
|
+
h.end(2_000, [assistant(smallUsage)]);
|
|
102
|
+
assert.deepEqual(h.notifications, []);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
test("suppresses nonpositive assistant output and consumes the end", (t) => {
|
|
107
|
+
const h = harness(t);
|
|
108
|
+
for (const output of [0, -1]) {
|
|
109
|
+
h.start(1_000);
|
|
110
|
+
h.end(2_000, [assistant({ ...smallUsage, output }), { role: "toolResult", usage: smallUsage }]);
|
|
111
|
+
assert.deepEqual(h.notifications, []);
|
|
112
|
+
h.end(3_000, [assistant(smallUsage)]);
|
|
113
|
+
assert.deepEqual(h.notifications, []);
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
test("a new start replaces the previous start time", (t) => {
|
|
118
|
+
const h = harness(t);
|
|
119
|
+
h.start(1_000);
|
|
120
|
+
h.start(3_000);
|
|
121
|
+
h.end(4_000, [assistant(smallUsage)]);
|
|
122
|
+
assert.deepEqual(h.notifications, [{ message: smallNotification, type: "info" }]);
|
|
123
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
|
|
3
|
+
import { join, resolve } from "node:path";
|
|
4
|
+
import test from "node:test";
|
|
5
|
+
import { requiredPaths } from "../scripts/verify-package-files.mjs";
|
|
6
|
+
|
|
7
|
+
const root = resolve(import.meta.dirname, "..");
|
|
8
|
+
const skillDir = join(root, "skills/gentle-ui-design");
|
|
9
|
+
const references = [
|
|
10
|
+
"references/task-and-content.md",
|
|
11
|
+
"references/browse-and-compare.md",
|
|
12
|
+
"references/composition-and-feedback.md",
|
|
13
|
+
"references/adaptive-interfaces.md",
|
|
14
|
+
];
|
|
15
|
+
const read = (path: string) => readFileSync(join(skillDir, path), "utf8");
|
|
16
|
+
|
|
17
|
+
test("product design skill is discoverable and distinct from existing workflows", () => {
|
|
18
|
+
const skill = read("SKILL.md");
|
|
19
|
+
assert.match(skill, /^---\nname: gentle-ui-design\ndescription: "Trigger: [^\n]+"\nlicense: Apache-2\.0\nmetadata:\n author: gentleman-programming\n version: "1\.0"\n---/);
|
|
20
|
+
for (const section of ["Activation Contract", "Hard Rules", "Decision Gates", "Execution Steps", "Output Contract", "References"]) {
|
|
21
|
+
assert.match(skill, new RegExp(`^## ${section}$`, "m"));
|
|
22
|
+
}
|
|
23
|
+
assert.match(skill, /gentle-design/);
|
|
24
|
+
assert.match(skill, /gentle-ai-tui-design/);
|
|
25
|
+
assert.match(skill, /read.only/i);
|
|
26
|
+
const names = readdirSync(join(root, "skills"), { withFileTypes: true })
|
|
27
|
+
.filter((entry) => entry.isDirectory() && existsSync(join(root, "skills", entry.name, "SKILL.md")))
|
|
28
|
+
.map((entry) => readFileSync(join(root, "skills", entry.name, "SKILL.md"), "utf8").match(/^name: (.+)$/m)?.[1]);
|
|
29
|
+
assert.equal(names.filter((name) => name === "gentle-ui-design").length, 1);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
test("the skill loads its bundled guidance through local links", () => {
|
|
33
|
+
const links = [...read("SKILL.md").matchAll(/`(references\/[^`]+\.md)`/g)].map((match) => match[1]);
|
|
34
|
+
assert.deepEqual(new Set(links), new Set(references));
|
|
35
|
+
for (const path of ["SKILL.md", ...references]) {
|
|
36
|
+
assert.ok(requiredPaths.includes(`skills/gentle-ui-design/${path}`), `${path} must be required`);
|
|
37
|
+
assert.ok(statSync(join(skillDir, path)).isFile());
|
|
38
|
+
assert.equal(statSync(join(skillDir, path)).mode & 0o111, 0, `${path} must not be executable`);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
test("the package contains only the skill and its four guidance documents", () => {
|
|
43
|
+
const files = readdirSync(skillDir, { recursive: true, withFileTypes: true })
|
|
44
|
+
.filter((entry) => entry.isFile())
|
|
45
|
+
.map((entry) => join(entry.parentPath, entry.name).slice(skillDir.length + 1));
|
|
46
|
+
assert.deepEqual(files.sort(), ["SKILL.md", ...references].sort());
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test("guidance covers product tasks, browsing, presentation and adaptation", () => {
|
|
50
|
+
const all = ["SKILL.md", ...references].map(read).join("\n");
|
|
51
|
+
for (const topic of [/task/i, /search/i, /filter/i, /result/i, /keyboard/i, /focus/i, /contrast/i, /loading/i, /error/i, /motion/i]) assert.match(all, topic);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test("shell documentation exposes the skill without changing existing design workflows", () => {
|
|
55
|
+
const docs = readFileSync(join(root, "docs/gentle-shell.md"), "utf8");
|
|
56
|
+
assert.match(docs, /\/skill:gentle-ui-design/);
|
|
57
|
+
assert.match(docs, /gentle-design/);
|
|
58
|
+
assert.match(docs, /gentle-ai-tui-design/);
|
|
59
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import test from "node:test";
|
|
3
|
+
import { herdrBusyLabel, nextHerdrBusyAction } from "../lib/herdr-busy.ts";
|
|
4
|
+
|
|
5
|
+
// Pure projection for the herdr:busy producer (gentle-shell#626). It mirrors
|
|
6
|
+
// pi-subagents' edge-triggered emitter: raise once, dedup an unchanged label,
|
|
7
|
+
// relabel as lower-then-raise, lower once. No I/O, no global state.
|
|
8
|
+
|
|
9
|
+
const task = (status: string): { status: string } => ({ status });
|
|
10
|
+
|
|
11
|
+
test("raises once when owned work starts", () => {
|
|
12
|
+
assert.deepEqual(nextHerdrBusyAction([task("queued")], undefined), { kind: "raise", label: "1 subagent running" });
|
|
13
|
+
assert.deepEqual(nextHerdrBusyAction([task("running")], undefined), { kind: "raise", label: "1 subagent running" });
|
|
14
|
+
assert.deepEqual(nextHerdrBusyAction([task("waiting")], undefined), { kind: "raise", label: "1 subagent running" });
|
|
15
|
+
assert.deepEqual(nextHerdrBusyAction([task("running"), task("running"), task("queued")], undefined), { kind: "raise", label: "3 subagents running" });
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
test("emits nothing while the label is unchanged", () => {
|
|
19
|
+
assert.deepEqual(nextHerdrBusyAction([task("running")], { active: true, label: "1 subagent running" }), { kind: "none" });
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
test("a label change is a lower-then-raise in one step", () => {
|
|
23
|
+
assert.deepEqual(
|
|
24
|
+
nextHerdrBusyAction([task("running"), task("running")], { active: true, label: "1 subagent running" }),
|
|
25
|
+
{ kind: "lower-then-raise", label: "2 subagents running" },
|
|
26
|
+
);
|
|
27
|
+
assert.deepEqual(
|
|
28
|
+
nextHerdrBusyAction([task("running")], { active: true, label: "2 subagents running" }),
|
|
29
|
+
{ kind: "lower-then-raise", label: "1 subagent running" },
|
|
30
|
+
);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test("lowers once when the last task settles, and never re-lowers", () => {
|
|
34
|
+
assert.deepEqual(nextHerdrBusyAction([], { active: true, label: "2 subagents running" }), { kind: "lower" });
|
|
35
|
+
assert.deepEqual(nextHerdrBusyAction([], undefined), { kind: "none" });
|
|
36
|
+
assert.deepEqual(nextHerdrBusyAction([], { active: false }), { kind: "none" });
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
test("cancellation, failure and timeout each lower busy", () => {
|
|
40
|
+
for (const status of ["completed", "failed", "cancelled", "timed_out"]) {
|
|
41
|
+
assert.deepEqual(nextHerdrBusyAction([task(status)], { active: true, label: "1 subagent running" }), { kind: "lower" }, status);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
test("malformed input fails closed as a no-op", () => {
|
|
46
|
+
assert.deepEqual(nextHerdrBusyAction(undefined, undefined), { kind: "none" });
|
|
47
|
+
assert.deepEqual(nextHerdrBusyAction("running", undefined), { kind: "none" });
|
|
48
|
+
assert.deepEqual(nextHerdrBusyAction([null], undefined), { kind: "none" });
|
|
49
|
+
assert.deepEqual(nextHerdrBusyAction([42], undefined), { kind: "none" });
|
|
50
|
+
assert.deepEqual(nextHerdrBusyAction([{}], undefined), { kind: "none" });
|
|
51
|
+
assert.deepEqual(nextHerdrBusyAction([{ status: 7 }], undefined), { kind: "none" });
|
|
52
|
+
// A malformed previously-emitted state is simply not busy.
|
|
53
|
+
assert.deepEqual(nextHerdrBusyAction([task("running")], "busy"), { kind: "raise", label: "1 subagent running" });
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
test("the label is content-free and derived from counts only", () => {
|
|
57
|
+
assert.equal(herdrBusyLabel(1), "1 subagent running");
|
|
58
|
+
assert.equal(herdrBusyLabel(3), "3 subagents running");
|
|
59
|
+
});
|
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import assert from "node:assert/strict";
|
|
2
2
|
import fs, { mkdirSync, mkdtempSync, readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
|
|
3
3
|
import { syncBuiltinESMExports } from "node:module";
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
4
|
+
import { tmpdir } from "node:os";
|
|
5
|
+
import { join } from "node:path";
|
|
6
|
+
import test, { after } from "node:test";
|
|
6
7
|
import {
|
|
7
8
|
DEFAULT_HERDR_TASK_SUMMARY_SETTINGS, HERDR_SUMMARY_COLORS, HERDR_TASK_SUMMARY_SCHEMA,
|
|
8
9
|
resolveHerdrTaskSummarySettings, writeHerdrTaskSummarySettings,
|
|
9
10
|
type HerdrTaskSummarySettings,
|
|
10
11
|
} from "../lib/herdr-task-summary-policy.ts";
|
|
11
12
|
|
|
13
|
+
// Fixtures live under the system temp directory, never inside the worktree.
|
|
14
|
+
// fs.rmSync (not the named export) because one test mocks it on the fs object.
|
|
15
|
+
const root = mkdtempSync(join(tmpdir(), "gentle-herdr-task-summary-"));
|
|
16
|
+
after(() => fs.rmSync(root, { recursive: true, force: true }));
|
|
17
|
+
|
|
12
18
|
function fixture() {
|
|
13
|
-
const root = resolve("odd/work/herdr-c65-pure/fixtures/task-summary-policy");
|
|
14
|
-
mkdirSync(root, { recursive: true });
|
|
15
19
|
const home = mkdtempSync(join(root, "case-"));
|
|
16
20
|
return { options: { gentlePiConfigHome: home }, home, file: join(home, "herdr-task-summary.json") };
|
|
17
21
|
}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import test from "node:test";
|
|
2
|
+
import assert from "node:assert/strict";
|
|
3
|
+
import { mkdtempSync, statSync, existsSync, readFileSync, mkdirSync, writeFileSync, utimesSync } from "node:fs";
|
|
4
|
+
import { tmpdir } from "node:os";
|
|
5
|
+
import { join } from "node:path";
|
|
6
|
+
import { ImageDiskCache, defaultCacheRoot } from "../lib/image-disk-cache.ts";
|
|
7
|
+
import { ImageAttachments } from "../lib/image-attachments.ts";
|
|
8
|
+
|
|
9
|
+
function tempRoot(): string {
|
|
10
|
+
return mkdtempSync(join(tmpdir(), "gentle-image-cache-"));
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const PNG = new Uint8Array([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]);
|
|
14
|
+
|
|
15
|
+
test("the cache root honours XDG_CACHE_HOME and falls back to ~/.cache", () => {
|
|
16
|
+
const xdg = join(tmpdir(), "custom-cache");
|
|
17
|
+
assert.equal(defaultCacheRoot({ XDG_CACHE_HOME: xdg }, "/home/u"), join(xdg, "gentle-shell", "images"));
|
|
18
|
+
assert.equal(defaultCacheRoot({}, "/home/u"), join("/home/u", ".cache", "gentle-shell", "images"));
|
|
19
|
+
assert.equal(defaultCacheRoot({ XDG_CACHE_HOME: "" }, "/home/u"), join("/home/u", ".cache", "gentle-shell", "images"));
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
test("a session id cannot escape its own directory", () => {
|
|
23
|
+
const root = tempRoot();
|
|
24
|
+
const cache = new ImageDiskCache({ root, sessionId: "../../etc" });
|
|
25
|
+
assert.equal(cache.directory, join(root, "etc"));
|
|
26
|
+
assert.ok(cache.directory.startsWith(root));
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
test("writing stores the exact bytes with a private directory and file", () => {
|
|
30
|
+
const root = tempRoot();
|
|
31
|
+
const cache = new ImageDiskCache({ root, sessionId: "s1" });
|
|
32
|
+
const path = cache.write(1, PNG, "image/png");
|
|
33
|
+
|
|
34
|
+
assert.ok(path, "write must return the file path");
|
|
35
|
+
assert.deepEqual(new Uint8Array(readFileSync(path)), PNG);
|
|
36
|
+
if (process.platform !== "win32") {
|
|
37
|
+
// Windows has no POSIX owner/group/other bits; the mode is accepted but not enforced.
|
|
38
|
+
assert.equal(statSync(cache.directory).mode & 0o777, 0o700, "session directory is private");
|
|
39
|
+
assert.equal(statSync(path).mode & 0o777, 0o600, "image file is private");
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test("the file extension follows the mime type", () => {
|
|
44
|
+
const root = tempRoot();
|
|
45
|
+
const cache = new ImageDiskCache({ root, sessionId: "s1" });
|
|
46
|
+
assert.match(cache.write(2, PNG, "image/jpeg") ?? "", /image-2\.jpg$/);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test("a write that cannot happen degrades instead of throwing", () => {
|
|
50
|
+
const blocked = join(tempRoot(), "not-a-directory");
|
|
51
|
+
writeFileSync(blocked, "x");
|
|
52
|
+
const cache = new ImageDiskCache({ root: blocked, sessionId: "s1" });
|
|
53
|
+
assert.equal(cache.write(1, PNG, "image/png"), undefined);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
test("disposing removes only this session's directory", () => {
|
|
57
|
+
const root = tempRoot();
|
|
58
|
+
const mine = new ImageDiskCache({ root, sessionId: "mine" });
|
|
59
|
+
const other = new ImageDiskCache({ root, sessionId: "other" });
|
|
60
|
+
mine.write(1, PNG, "image/png");
|
|
61
|
+
const otherPath = other.write(1, PNG, "image/png");
|
|
62
|
+
|
|
63
|
+
mine.dispose();
|
|
64
|
+
|
|
65
|
+
assert.equal(existsSync(mine.directory), false, "own directory is gone");
|
|
66
|
+
assert.ok(otherPath && existsSync(otherPath), "another session is untouched");
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
test("the sweep removes stale sessions and keeps fresh ones", () => {
|
|
70
|
+
const root = tempRoot();
|
|
71
|
+
const stale = new ImageDiskCache({ root, sessionId: "stale" });
|
|
72
|
+
const fresh = new ImageDiskCache({ root, sessionId: "fresh" });
|
|
73
|
+
const staleFile = stale.write(1, PNG, "image/png")!;
|
|
74
|
+
fresh.write(1, PNG, "image/png");
|
|
75
|
+
const longAgo = new Date(Date.now() - 30 * 24 * 60 * 60 * 1000);
|
|
76
|
+
utimesSync(staleFile, longAgo, longAgo);
|
|
77
|
+
|
|
78
|
+
const removed = ImageDiskCache.sweepStale(root, 7 * 24 * 60 * 60 * 1000);
|
|
79
|
+
|
|
80
|
+
assert.equal(removed, 1);
|
|
81
|
+
assert.equal(existsSync(stale.directory), false, "old session removed");
|
|
82
|
+
assert.ok(existsSync(fresh.directory), "fresh session kept");
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
test("a relative XDG_CACHE_HOME is ignored, as the spec requires", () => {
|
|
86
|
+
assert.equal(defaultCacheRoot({ XDG_CACHE_HOME: "cache" }, "/home/u"), join("/home/u", ".cache", "gentle-shell", "images"));
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
test("runtime cache changes work: setCache reports paths, dropping it stops them", () => {
|
|
90
|
+
const root = tempRoot();
|
|
91
|
+
const attachments = new ImageAttachments();
|
|
92
|
+
assert.equal(attachments.cachedPaths().length, 0, "no cache, nothing to report");
|
|
93
|
+
|
|
94
|
+
attachments.setCache(new ImageDiskCache({ root, sessionId: "s1" }));
|
|
95
|
+
const withCache = attachments.add({ bytes: PNG, mimeType: "image/png" } as never);
|
|
96
|
+
assert.deepEqual(attachments.cachedPaths(), [{ token: withCache.token, path: withCache.diskPath }]);
|
|
97
|
+
|
|
98
|
+
attachments.setCache(undefined);
|
|
99
|
+
const withoutCache = attachments.add({ bytes: PNG, mimeType: "image/png" } as never);
|
|
100
|
+
assert.equal(withoutCache.diskPath, undefined, "dropping the cache stops new paths");
|
|
101
|
+
assert.equal(attachments.cachedPaths().length, 1, "earlier paths still registered");
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
test("cachedPaths only reports chips the draft still references", () => {
|
|
105
|
+
const root = tempRoot();
|
|
106
|
+
const attachments = new ImageAttachments(new ImageDiskCache({ root, sessionId: "s1" }));
|
|
107
|
+
const first = attachments.add({ bytes: PNG, mimeType: "image/png" } as never);
|
|
108
|
+
const second = attachments.add({ bytes: PNG, mimeType: "image/png" } as never);
|
|
109
|
+
|
|
110
|
+
assert.equal(attachments.cachedPaths(`${first.token} ${second.token}`).length, 2);
|
|
111
|
+
const kept = attachments.cachedPaths(`only ${second.token} survives`);
|
|
112
|
+
assert.deepEqual(kept, [{ token: second.token, path: second.diskPath }], "a deleted chip is not reported");
|
|
113
|
+
attachments.dispose();
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
test("a failed cache write leaves the chip usable without a path", () => {
|
|
117
|
+
const blocked = join(tempRoot(), "not-a-directory");
|
|
118
|
+
writeFileSync(blocked, "x");
|
|
119
|
+
const attachments = new ImageAttachments(new ImageDiskCache({ root: blocked, sessionId: "s1" }));
|
|
120
|
+
const attachment = attachments.add({ bytes: PNG, mimeType: "image/png" } as never);
|
|
121
|
+
assert.equal(attachment.diskPath, undefined);
|
|
122
|
+
assert.ok(attachment.base64.length > 0, "the payload is still intact");
|
|
123
|
+
assert.deepEqual(attachments.cachedPaths(), [], "nothing to report");
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
test("the sweep leaves a directory that also holds a file it did not write", () => {
|
|
127
|
+
const root = tempRoot();
|
|
128
|
+
const mixed = new ImageDiskCache({ root, sessionId: "mixed" });
|
|
129
|
+
const own = mixed.write(1, PNG, "image/png")!;
|
|
130
|
+
const foreign = join(mixed.directory, "notes.txt");
|
|
131
|
+
writeFileSync(foreign, "someone else");
|
|
132
|
+
const longAgo = new Date(Date.now() - 30 * 24 * 60 * 60 * 1000);
|
|
133
|
+
utimesSync(own, longAgo, longAgo);
|
|
134
|
+
|
|
135
|
+
const removed = ImageDiskCache.sweepStale(root, 7 * 24 * 60 * 60 * 1000);
|
|
136
|
+
|
|
137
|
+
assert.equal(removed, 0, "a directory with foreign content is not removed");
|
|
138
|
+
assert.ok(existsSync(foreign), "the foreign file survives");
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
test("the sweep never deletes outside the cache root", () => {
|
|
142
|
+
const root = tempRoot();
|
|
143
|
+
const outside = mkdtempSync(join(tmpdir(), "gentle-outside-"));
|
|
144
|
+
mkdirSync(join(outside, "victim"));
|
|
145
|
+
assert.equal(ImageDiskCache.sweepStale(outside, 0), 0);
|
|
146
|
+
assert.ok(existsSync(join(outside, "victim")), "a foreign directory is left alone");
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
test("attachments keep their in-memory contract and gain a path only when a cache is given", () => {
|
|
150
|
+
const plain = new ImageAttachments();
|
|
151
|
+
const withoutCache = plain.add({ bytes: PNG, mimeType: "image/png" } as never);
|
|
152
|
+
assert.equal(withoutCache.diskPath, undefined, "no cache, no path, old behaviour");
|
|
153
|
+
assert.ok(withoutCache.base64.length > 0, "base64 stays the source of truth");
|
|
154
|
+
|
|
155
|
+
const root = tempRoot();
|
|
156
|
+
const withCache = new ImageAttachments(new ImageDiskCache({ root, sessionId: "s1" }));
|
|
157
|
+
const withPath = withCache.add({ bytes: PNG, mimeType: "image/png" } as never);
|
|
158
|
+
assert.ok(withPath.diskPath && existsSync(withPath.diskPath), "path exists on disk");
|
|
159
|
+
assert.ok(withPath.token.startsWith("[Image#"), "chip token unchanged");
|
|
160
|
+
|
|
161
|
+
withCache.dispose();
|
|
162
|
+
assert.equal(existsSync(join(root, "s1")), false, "dispose clears the session directory");
|
|
163
|
+
});
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { mkdirSync, mkdtempSync, readFileSync, rmSync } from "node:fs";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import test, { after, before } from "node:test";
|
|
6
|
+
import { __testing } from "../extensions/gentle-ai.ts";
|
|
7
|
+
import { parseAgentDefinition } from "../lib/agents-config.ts";
|
|
8
|
+
|
|
9
|
+
const read = (p: string) => readFileSync(new URL(`../${p}`, import.meta.url), "utf8");
|
|
10
|
+
const paragraph = (p: string, prefix: string) => {
|
|
11
|
+
const text = p.split("\n\n").find(s => s.startsWith(prefix));
|
|
12
|
+
assert.ok(text, prefix);
|
|
13
|
+
return text;
|
|
14
|
+
};
|
|
15
|
+
let cwd: string;
|
|
16
|
+
let prior: string | undefined;
|
|
17
|
+
before(() => {
|
|
18
|
+
cwd = mkdtempSync(join(tmpdir(), "recovery-delivery-"));
|
|
19
|
+
prior = process.env.GENTLE_PI_CONFIG_HOME;
|
|
20
|
+
process.env.GENTLE_PI_CONFIG_HOME = join(cwd, "config");
|
|
21
|
+
mkdirSync(join(cwd, "project"));
|
|
22
|
+
});
|
|
23
|
+
after(() => {
|
|
24
|
+
if (prior === undefined) delete process.env.GENTLE_PI_CONFIG_HOME;
|
|
25
|
+
else process.env.GENTLE_PI_CONFIG_HOME = prior;
|
|
26
|
+
rmSync(cwd, { recursive: true, force: true });
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
// S2-S5: positive setup/implementation routes and negative authority boundaries
|
|
30
|
+
// must coexist in the delivered parent prompt, in every persona and RDD mode.
|
|
31
|
+
for (const persona of ["gentleman", "neutral"] as const) {
|
|
32
|
+
for (const mode of ["on", "off", "unknown"]) {
|
|
33
|
+
test(`S2-S5 delivered recovery is bounded: ${persona}/${mode}`, () => {
|
|
34
|
+
const p = __testing.buildGentlePrompt(persona, join(cwd, "project"), ["read"], `Receipt-driven development: ${mode}`);
|
|
35
|
+
assert.equal(p.split("## Authorized work continuity").length, 2);
|
|
36
|
+
const setup = paragraph(p, "A failed verifier setup");
|
|
37
|
+
assert.match(setup, /prerequisite is repaired, the human may explicitly request one new bounded verification attempt/);
|
|
38
|
+
assert.match(setup, /zero tests run; the checks remain unverified/);
|
|
39
|
+
assert.match(setup, /unavailable verifier remains unavailable; do not retry or escalate it/);
|
|
40
|
+
for (const guard of ["consent", "a denial", "one-run", "no-retry", "terminal native outcomes", "exhausted native budgets"]) assert.ok(setup.includes(guard), guard);
|
|
41
|
+
assert.match(setup, /no child is active or has an uncertain status/);
|
|
42
|
+
const worker = paragraph(p, "An exhausted worker-local");
|
|
43
|
+
assert.match(worker, /scope, executor, correction limit and checks/);
|
|
44
|
+
assert.match(worker, /later explicit human request is separate and remains subject to native authority/);
|
|
45
|
+
assert.match(worker, /new session does not reset any limit/);
|
|
46
|
+
assert.match(worker, /specifically authorized.*actual native authority.*in-scope compilation or implementation/);
|
|
47
|
+
assert.match(worker, /unavailable proof still blocks completion and delivery/);
|
|
48
|
+
assert.match(worker, /no child is active or has an uncertain status/);
|
|
49
|
+
assert.match(p, /7\. \*\*Close\.\*\*[^\n]*never more verification/);
|
|
50
|
+
assert.doesNotMatch(p, /Stop only for[^\n]*unavailable required proof/);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
test("S3-S5 parsed worker and verifier contracts retain confinement and proof limits", () => {
|
|
56
|
+
const agent = (name: string) => {
|
|
57
|
+
const p = `assets/agents/gentle-ai-${name}.md`;
|
|
58
|
+
const parsed = parseAgentDefinition(read(p), p, "global");
|
|
59
|
+
assert.ok(!("error" in parsed));
|
|
60
|
+
return parsed;
|
|
61
|
+
};
|
|
62
|
+
const worker = agent("worker");
|
|
63
|
+
assert.match(worker.instructions, /handoff is not authorization to continue/);
|
|
64
|
+
assert.match(worker.instructions, /Do not start a fresh correction cycle/);
|
|
65
|
+
assert.match(worker.instructions, /missing proof still blocks completion and delivery/);
|
|
66
|
+
const verify = agent("verify");
|
|
67
|
+
assert.deepEqual(verify.tools, ["read", "grep", "find", "bash", "mcp__codegraph__codegraph_explore"]);
|
|
68
|
+
assert.match(verify.instructions, /Before isolated setup[^\n]*space and inodes/);
|
|
69
|
+
assert.match(verify.instructions, /smaller copy[^\n]*all source, test\/build files, baseline material, and dependencies/);
|
|
70
|
+
assert.match(verify.instructions, /first inability[^\n]*stop setup/);
|
|
71
|
+
assert.match(verify.instructions, /setup fails before probes[^\n]*zero tests run/);
|
|
72
|
+
assert.match(verify.instructions, /Do not retry setup or enter repair-helper loops/);
|
|
73
|
+
for (const guard of ["system temp directory", "a symlink into the workspace", "No network, no installs, no writes outside", "NODE_COMPILE_CACHE", "NO_UPDATE_NOTIFIER=1"]) assert.ok(verify.instructions.includes(guard), guard);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
test("S2-S5 user recovery docs retain the independent-proof and native-authority boundaries", () => {
|
|
77
|
+
const docs = read("docs/delegated-verification.md");
|
|
78
|
+
assert.match(docs, /static inspection and parent tests do not replace the missing independent runtime proof/);
|
|
79
|
+
assert.match(docs, /no instantiated native budget[^\n]*grants no review approval/);
|
|
80
|
+
assert.match(docs, /Missing required proof still blocks completion and delivery/);
|
|
81
|
+
assert.match(docs, /active or uncertain child prevents continuation/);
|
|
82
|
+
assert.match(docs, /explicit one-run\/no-retry limit/);
|
|
83
|
+
});
|