gentle-pi 4.5.0 → 4.6.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 +9 -6
- package/assets/agents/gentle-ai-verify.md +4 -0
- package/assets/agents/gentle-ai-worker.md +1 -0
- package/assets/migrations/agent-body-history.json +147 -0
- package/assets/orchestrator-delegation-reference.md +3 -3
- package/assets/orchestrator-delegation.md +2 -2
- package/assets/orchestrator-verification.md +10 -6
- package/assets/orchestrator.md +8 -8
- package/bin/gentle-shell.mjs +61 -26
- package/docs/ci-performance.md +11 -0
- package/docs/delegated-verification.md +6 -0
- package/docs/fast-mode.md +15 -0
- package/docs/gentle-agents-activity.md +8 -0
- package/docs/gentle-music.md +6 -3
- package/docs/gentle-shell.md +70 -20
- package/docs/install-wizard.md +1 -1
- package/docs/mcp-status.md +52 -0
- package/docs/prompt-budget.md +28 -0
- package/docs/readme-reference.md +82 -21
- package/docs/session-profile-format.md +20 -5
- package/docs/sound-notifications.md +1 -1
- package/docs/star-prompt.md +32 -0
- package/docs/work-continuity.md +46 -0
- package/extensions/ask-user-question.ts +1 -0
- package/extensions/codegraph-tools.ts +38 -4
- package/extensions/gentle-agents.ts +477 -50
- package/extensions/gentle-ai.ts +1046 -191
- package/extensions/gentle-fast.ts +61 -0
- package/extensions/gentle-guide.ts +174 -0
- package/extensions/gentle-herdr-activity.ts +21 -1
- package/extensions/gentle-herdr-agent.ts +144 -0
- package/extensions/gentle-music.ts +10 -0
- package/extensions/gentle-program-identity.ts +61 -0
- package/extensions/gentle-shell.ts +642 -97
- package/extensions/gentle-star-prompt.ts +334 -0
- package/extensions/gentle-stats.ts +5 -5
- package/extensions/gentle-todo.ts +42 -22
- package/extensions/history/store.ts +18 -12
- package/extensions/skill-registry.ts +35 -3
- package/extensions/startup-banner.ts +39 -7
- package/lib/agent-assets.ts +74 -17
- package/lib/agent-profiles.ts +1 -1
- package/lib/agents-config.ts +12 -3
- package/lib/agents-keys.ts +8 -16
- package/lib/agents-protocol.ts +80 -4
- package/lib/agents-runner.ts +105 -4
- package/lib/agents-view.ts +6 -1
- package/lib/agents-widget.ts +132 -9
- package/lib/bridge-cost.ts +28 -0
- package/lib/codemode-renderer.ts +16 -0
- package/lib/command-palette-catalog.ts +1 -0
- package/lib/command-palette.ts +21 -8
- package/lib/exploration-budget.ts +62 -0
- package/lib/gentle-guide.ts +201 -0
- package/lib/gentle-shell-launcher.ts +4 -0
- package/lib/herdr-activity.ts +9 -3
- package/lib/herdr-task-summary-policy.ts +85 -0
- package/lib/inprocess-reviewer.ts +33 -13
- package/lib/jobs-sidebar-state.ts +5 -6
- package/lib/jobs-widget.ts +16 -52
- package/lib/keymaps-customize.ts +81 -0
- package/lib/keymaps.ts +291 -0
- package/lib/model-fallback-notice.ts +61 -0
- package/lib/model-fallback-policy.ts +141 -0
- package/lib/model-fallback-store.ts +143 -0
- package/lib/model-routing-authority.ts +10 -2
- package/lib/nan-provider.ts +3 -2
- package/lib/native-review-cli.ts +7 -2
- package/lib/notification-customize.ts +48 -51
- package/lib/openai-fast-tier.ts +22 -0
- package/lib/orchestrator-discovery.ts +5 -1
- package/lib/orchestrator-fallback.ts +75 -0
- package/lib/pasted-image-paths.ts +113 -0
- package/lib/questionnaire/questionnaire-view.ts +121 -7
- package/lib/review-candidate-view-owner.ts +4 -0
- package/lib/review-candidate-view.ts +10 -7
- package/lib/review-host-relay.ts +5 -1
- package/lib/review-integration-v2.ts +22 -7
- package/lib/review-repository.ts +5 -0
- package/lib/session-profile-append-controller.ts +21 -6
- package/lib/session-profile-authority.ts +119 -0
- package/lib/session-profile-binding.ts +54 -5
- package/lib/session-profile-freeze.ts +105 -9
- package/lib/session-profile-integration.ts +313 -0
- package/lib/session-profile-persistence.ts +63 -9
- package/lib/shell-bar.ts +171 -56
- package/lib/shell-card.ts +26 -6
- package/lib/shell-page.ts +120 -0
- package/lib/shell-panel.ts +149 -0
- package/lib/shell-prompt.ts +53 -1
- package/lib/shell-sidebar-layout.ts +98 -25
- package/lib/shell-sidebar.ts +54 -1
- package/lib/shell-stats.ts +123 -0
- package/lib/shell-todo.ts +71 -0
- package/lib/shell-usage.ts +12 -2
- package/lib/star-prompt.ts +197 -0
- package/lib/verifier-admission.ts +18 -8
- package/lib/verifier-settle-reminder.ts +64 -0
- package/lib/vim-editor-adapter.ts +6 -1
- package/lib/visual-customization-policy.ts +41 -6
- package/lib/visual-customize-view.ts +164 -26
- package/lib/visual-layout-preview.ts +43 -0
- package/lib/yolo-session-policy.ts +28 -1
- package/package.json +1 -1
- package/runtime/gentle-shell-launcher.mjs +4 -0
- package/runtime/native-review-cli.mjs +7 -2
- package/runtime/review-integration-v2.mjs +22 -7
- package/runtime/windows-session-transport.ps1 +60 -3
- package/scripts/bootstrap.sh +4 -1
- package/scripts/installer-preflight.mjs +1 -1
- package/scripts/pi-update.mjs +113 -3
- package/scripts/run-test-suite.mjs +17 -1
- package/scripts/shell-snapshot.mjs +340 -0
- package/scripts/test-packed-runner.mjs +1 -1
- package/scripts/update-agent-body-history.mjs +41 -0
- package/scripts/verify-installer-tap.mjs +45 -0
- package/scripts/verify-package-files.mjs +2 -0
- package/skills/gentle-ai/SKILL.md +2 -2
- package/skills/tui-design/NOTICE.md +5 -0
- package/skills/tui-design/SKILL.md +56 -0
- package/skills/tui-design/references/commands.md +75 -0
- package/skills/tui-design/references/critique.md +48 -0
- package/skills/tui-design/references/design-doc.md +44 -0
- package/skills/tui-design/references/terminal-craft.md +64 -0
- package/skills/tui-design/references/visual-loop.md +32 -0
- package/tests/agents-protocol.test.ts +53 -1
- package/tests/agents-runner.test.ts +168 -3
- package/tests/agents-view.test.ts +27 -0
- package/tests/agents-widget.test.ts +312 -10
- package/tests/bounded-scan-contract.test.ts +39 -0
- package/tests/bridge-cost.test.ts +32 -0
- package/tests/bundled-install.test.ts +6 -4
- package/tests/ci-concurrency.test.ts +11 -0
- package/tests/ci-merge-base-identity.test.ts +114 -0
- package/tests/codegraph-tools.test.ts +69 -0
- package/tests/codemode-rendering.test.ts +22 -2
- package/tests/command-palette.test.ts +16 -2
- package/tests/commit-slice-signal.test.ts +11 -9
- package/tests/delegate-for-reason-contract.test.ts +5 -4
- package/tests/design-canvas-server.test.ts +6 -2
- package/tests/exploration-budget.test.ts +128 -0
- package/tests/fixtures/agent-assets/gentle-ai-worker.strict-tdd-era.md +122 -0
- package/tests/fixtures/measure-orchestrator-prompt.mjs +2 -1
- package/tests/fixtures/primary-session-prompt/gentleman.golden.md +18 -10
- package/tests/fixtures/session-profile-v1/replay.ts +125 -0
- package/tests/fixtures/session-profile-v1/session-profile-authority.ts +113 -0
- package/tests/fixtures/session-profile-v1/session-profile-binding.ts +83 -0
- package/tests/fixtures/session-profile-v1/session-profile-disk-reader.ts +182 -0
- package/tests/fixtures/session-profile-v1/session-profile-freeze.ts +290 -0
- package/tests/fixtures/session-profile-v1/session-profile-persistence.ts +195 -0
- package/tests/fixtures/session-profile-v1/v1-inputs.ts +16 -0
- package/tests/fixtures/windows-pipe-availability.ps1 +26 -0
- package/tests/fixtures/windows-session-bootstrap.ps1 +6 -2
- package/tests/gentle-agents.test.ts +416 -21
- package/tests/gentle-ai-exploration-budget.test.ts +135 -0
- package/tests/gentle-ai.test.ts +1011 -37
- package/tests/gentle-fast.test.ts +73 -0
- package/tests/gentle-guide.test.ts +208 -0
- package/tests/gentle-herdr-activity.test.ts +76 -2
- package/tests/gentle-herdr-agent.test.ts +111 -0
- package/tests/gentle-music.test.ts +36 -1
- package/tests/gentle-program-identity.test.ts +197 -0
- package/tests/gentle-shell-bin.test.ts +49 -26
- package/tests/gentle-shell-launcher.test.ts +18 -2
- package/tests/gentle-shell.test.ts +1068 -37
- package/tests/gentle-stats.test.ts +15 -2
- package/tests/gentle-todo.test.ts +50 -4
- package/tests/herdr-task-summary-policy.test.ts +128 -0
- package/tests/history-store-private-mode.test.ts +40 -0
- package/tests/image-paste-chips.test.ts +42 -0
- package/tests/inprocess-reviewer.test.ts +122 -0
- package/tests/installer-posix-bootstrap.test.ts +67 -5
- package/tests/installer-server.test.ts +2 -2
- package/tests/installer-windows-diagnostics.test.ts +4 -5
- package/tests/isolated-config-home.ts +28 -0
- package/tests/jobs-widget.test.ts +25 -37
- package/tests/keymaps-customize.test.ts +114 -0
- package/tests/keymaps.test.ts +103 -0
- package/tests/maintainer/mcp-status.maintest.ts +88 -0
- package/tests/maintainer/pi-update-source.maintest.ts +116 -0
- package/tests/model-fallback-notice.test.ts +45 -0
- package/tests/model-fallback-policy.test.ts +83 -0
- package/tests/model-fallback-store.test.ts +111 -0
- package/tests/nan-provider.test.ts +4 -4
- package/tests/no-self-pause-contract.test.ts +19 -0
- package/tests/notification-customize.test.ts +58 -34
- package/tests/odd-routing-canonical-ratchet.test.ts +3 -3
- package/tests/odd-routing-contract.test.ts +1 -1
- package/tests/orchestrator-fallback.test.ts +82 -0
- package/tests/orchestrator-prompt-budget.test.ts +131 -0
- package/tests/package-manifest.test.ts +160 -7
- package/tests/pasted-image-paths.test.ts +118 -0
- package/tests/persona-reply-language.test.ts +61 -0
- package/tests/pi-update-launcher.test.ts +32 -8
- package/tests/pi-update-source.test.ts +162 -0
- package/tests/profile-fast-tier.test.ts +311 -0
- package/tests/profile-tier-footer.test.ts +79 -0
- package/tests/questionnaire-view.test.ts +150 -0
- package/tests/review-candidate-owner-sweep.test.ts +93 -0
- package/tests/review-candidate-view.test.ts +51 -0
- package/tests/review-controller-native-routing.test.ts +120 -6
- package/tests/review-gate.test.ts +24 -0
- package/tests/review-inspect-preflight.test.ts +197 -0
- package/tests/review-integration-v2-forward.test.ts +59 -0
- package/tests/review-repository.test.ts +52 -1
- package/tests/review-sidebar-state.test.ts +5 -5
- package/tests/run-test-suite.test.ts +61 -5
- package/tests/sensitive-path-tools.test.ts +74 -0
- package/tests/session-profile-append-controller.test.ts +63 -0
- package/tests/session-profile-authority.test.ts +259 -0
- package/tests/session-profile-binding.test.ts +15 -0
- package/tests/session-profile-extension.test.ts +615 -0
- package/tests/session-profile-freeze.test.ts +110 -2
- package/tests/session-profile-integration.test.ts +857 -0
- package/tests/session-profile-persistence.test.ts +57 -0
- package/tests/session-profile-v1-compat.test.ts +221 -0
- package/tests/shell-bar.test.ts +113 -55
- package/tests/shell-card.test.ts +13 -1
- package/tests/shell-page.test.ts +108 -0
- package/tests/shell-panel.test.ts +332 -0
- package/tests/shell-prompt.test.ts +54 -0
- package/tests/shell-render-cache.test.ts +5 -0
- package/tests/shell-sidebar-fullscreen.test.ts +12 -0
- package/tests/shell-sidebar-layout.test.ts +159 -27
- package/tests/shell-stats.test.ts +90 -0
- package/tests/shell-usage.test.ts +14 -0
- package/tests/skill-registry.test.ts +68 -1
- package/tests/star-prompt.test.ts +470 -0
- package/tests/startup-banner.test.ts +57 -1
- package/tests/task-size-routing-contract.test.ts +45 -1
- package/tests/verifier-settle-reminder.test.ts +281 -0
- package/tests/verify-first-launch-contract.test.ts +56 -5
- package/tests/verify-installer-tap.test.ts +57 -0
- package/tests/vim-editor-adapter.test.ts +2 -2
- package/tests/visual-customization-policy.test.ts +61 -7
- package/tests/visual-customize-view.test.ts +253 -8
- package/tests/visual-layout-preview.test.ts +28 -0
- package/tests/windows-session-bootstrap.test.ts +105 -2
- package/tests/work-continuity-contract.test.ts +86 -0
- package/tests/writer-surfaces.test.ts +12 -10
- package/tests/yolo-customize.test.ts +30 -11
- package/tests/yolo-mode-runtime.test.ts +4 -2
- package/tests/yolo-mode.test.ts +16 -2
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { mkdtempSync, readFileSync, rmSync } from "node:fs";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import test from "node:test";
|
|
6
|
+
import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
7
|
+
import { createGentleAiExtension } from "../extensions/gentle-ai.ts";
|
|
8
|
+
import { VERIFIER_RISK_REJECTION, declaredHighRiskItem, rejectUnriskedVerifierLaunch } from "../lib/verifier-admission.ts";
|
|
9
|
+
import {
|
|
10
|
+
VERIFIER_SETTLE_REMINDER_TYPE,
|
|
11
|
+
createVerifierSettleReminders,
|
|
12
|
+
finalAssistantText,
|
|
13
|
+
verifierSettleReminderText,
|
|
14
|
+
} from "../lib/verifier-settle-reminder.ts";
|
|
15
|
+
|
|
16
|
+
// odd/tasks/verifier-settle-reminder.md (#2652): a run that declares `Risk: item N` in its final message and never
|
|
17
|
+
// attempted a `gentle-ai-verify` launch gets one visible reminder and one continuation at settle.
|
|
18
|
+
|
|
19
|
+
const assistant = (text: string) => ({ role: "assistant", content: [{ type: "text", text }] });
|
|
20
|
+
const user = (text: string) => ({ role: "user", content: [{ type: "text", text }] });
|
|
21
|
+
|
|
22
|
+
test("S1: the settle check reuses the admission grammar and names the declared item", () => {
|
|
23
|
+
assert.equal(declaredHighRiskItem("Done.\nRisk: item 3 (shared parser)"), 3);
|
|
24
|
+
assert.equal(declaredHighRiskItem("Done. Risk: item 2, item 3 (auth)"), 2);
|
|
25
|
+
for (const text of ["Done.\nRisk: none", "Do not write Risk: item 3 here.", "Risk: item 7", "Done."]) {
|
|
26
|
+
assert.equal(declaredHighRiskItem(text), undefined, text);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test("S1: the final assistant text is the last assistant message's text", () => {
|
|
31
|
+
const messages = [user("Fix it."), assistant("Risk: item 1"), user("And?"), { role: "assistant", content: [{ type: "thinking", thinking: "Risk: item 4" }, { type: "text", text: "Done.\nRisk: item 2" }] }, { role: "toolResult", content: [] }];
|
|
32
|
+
assert.equal(finalAssistantText(messages), "Done.\nRisk: item 2");
|
|
33
|
+
assert.equal(finalAssistantText([user("Risk: item 3")]), undefined);
|
|
34
|
+
assert.equal(finalAssistantText([{ role: "assistant", content: "Risk: item 5" }]), "Risk: item 5");
|
|
35
|
+
// Adjacent text blocks are one rendered text: a split near-miss never becomes a line-start declaration.
|
|
36
|
+
const split = finalAssistantText([{ role: "assistant", content: [{ type: "text", text: "Do not write " }, { type: "text", text: "Risk: item 3 here." }] }]);
|
|
37
|
+
assert.equal(split, "Do not write Risk: item 3 here.");
|
|
38
|
+
assert.equal(declaredHighRiskItem(split!), undefined);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
test("S2: the reminder names the item, the launch, the approval rule, and the Needs your decision close", () => {
|
|
42
|
+
const text = verifierSettleReminderText(4);
|
|
43
|
+
assert.match(text, /`Risk: item 4`/);
|
|
44
|
+
assert.match(text, /launch `gentle-ai-verify` with the `Risk: item 4` line in its `task`/);
|
|
45
|
+
assert.match(text, /a user's visual or manual approval does not replace technical verification/i);
|
|
46
|
+
assert.match(text, /close with \*\*Needs your decision\*\* naming the missing proof/);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test("S1/S3: one reminder per user prompt, none for Risk: none or after a verifier attempt", () => {
|
|
50
|
+
const reminders = createVerifierSettleReminders<string>();
|
|
51
|
+
reminders.userPrompt("s");
|
|
52
|
+
assert.equal(reminders.beforeSettle("s", "Done.\nRisk: none"), undefined, "Risk: none earns no reminder");
|
|
53
|
+
assert.equal(reminders.beforeSettle("s", "Done."), undefined, "no declaration earns no reminder");
|
|
54
|
+
assert.equal(reminders.beforeSettle("s", undefined), undefined, "no final text earns no reminder");
|
|
55
|
+
assert.equal(reminders.beforeSettle("s", "Done.\nRisk: item 3"), verifierSettleReminderText(3), "the first declared settle reminds");
|
|
56
|
+
assert.equal(reminders.beforeSettle("s", "Still done.\nRisk: item 3"), undefined, "the continuation of the same prompt is not reminded again");
|
|
57
|
+
reminders.userPrompt("s");
|
|
58
|
+
assert.equal(reminders.beforeSettle("s", "Risk: item 1"), verifierSettleReminderText(1), "a new user prompt resets the reminder");
|
|
59
|
+
reminders.userPrompt("s");
|
|
60
|
+
reminders.toolCall("s", "subagent_run", { agent: "gentle-ai-verify", task: "Verify it." });
|
|
61
|
+
assert.equal(reminders.beforeSettle("s", "Risk: item 1"), undefined, "an attempted verifier launch, even one rejected, earns no reminder");
|
|
62
|
+
reminders.userPrompt("s");
|
|
63
|
+
reminders.toolCall("s", "subagent_run", { agent: "gentle-ai-worker", task: "Risk: item 1" });
|
|
64
|
+
reminders.toolCall("s", "subagent_continue", { agent: "gentle-ai-verify", task_id: "t-1" });
|
|
65
|
+
assert.equal(reminders.beforeSettle("s", "Risk: item 1"), verifierSettleReminderText(1), "other agents and continuations are not verifier attempts");
|
|
66
|
+
assert.equal(reminders.beforeSettle("other", "Risk: item 2"), verifierSettleReminderText(2), "sessions are independent");
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
test("S4: the admission rejection says no supported declaration was recognized", (t) => {
|
|
70
|
+
assert.doesNotMatch(VERIFIER_RISK_REJECTION, /This change declares none/);
|
|
71
|
+
assert.match(VERIFIER_RISK_REJECTION, /No supported `Risk: item N` declaration was recognized in the launch `task` or `context`/);
|
|
72
|
+
assert.match(VERIFIER_RISK_REJECTION, /run its focused test and suite inline yourself now/);
|
|
73
|
+
assert.match(VERIFIER_RISK_REJECTION, /never add a Risk line or create a feature document only to get a verifier admitted/);
|
|
74
|
+
const root = mkdtempSync(join(tmpdir(), "verifier-settle-"));
|
|
75
|
+
t.after(() => rmSync(root, { recursive: true, force: true }));
|
|
76
|
+
const denied = rejectUnriskedVerifierLaunch({ agent: "gentle-ai-verify", task: "Verify it." }, { root, contextUsage: { tokens: 0, contextWindow: 400_000 } });
|
|
77
|
+
assert.equal(denied?.reason, VERIFIER_RISK_REJECTION);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
type Handler = (event: unknown, ctx: ExtensionContext) => unknown;
|
|
81
|
+
interface SettleResult { entries?: Array<{ type: string; customType?: string; content?: unknown; display?: boolean }>; continue?: boolean }
|
|
82
|
+
|
|
83
|
+
function hookedExtension(processEnv: NodeJS.ProcessEnv = {}) {
|
|
84
|
+
const handlers = new Map<string, Handler[]>();
|
|
85
|
+
const sent: unknown[] = [];
|
|
86
|
+
const pi = {
|
|
87
|
+
on(name: string, handler: Handler) { handlers.set(name, [...(handlers.get(name) ?? []), handler]); },
|
|
88
|
+
events: { emit() {}, on() { return () => {}; } },
|
|
89
|
+
registerCommand() {}, registerTool() {}, registerShortcut() {}, registerFlag() {}, registerMessageRenderer() {},
|
|
90
|
+
sendMessage(message: unknown) { sent.push(message); },
|
|
91
|
+
appendEntry() {},
|
|
92
|
+
} as unknown as ExtensionAPI;
|
|
93
|
+
createGentleAiExtension({ nativeReviewCli: null, processEnv })(pi);
|
|
94
|
+
const ctx = {
|
|
95
|
+
cwd: tmpdir(), hasUI: false, ui: { confirm: async () => true, notify() {}, setStatus() {} },
|
|
96
|
+
getContextUsage: () => ({ tokens: 0, contextWindow: 272_000, percent: 0 }),
|
|
97
|
+
sessionManager: { getSessionId: () => "session-1", getCwd: () => tmpdir(), getEntries: () => [], getBranch: () => [] },
|
|
98
|
+
} as unknown as ExtensionContext;
|
|
99
|
+
const emit = async (name: string, event: unknown) => {
|
|
100
|
+
let last: unknown;
|
|
101
|
+
for (const handler of handlers.get(name) ?? []) last = await handler(event, ctx);
|
|
102
|
+
return last;
|
|
103
|
+
};
|
|
104
|
+
return {
|
|
105
|
+
input: (text = "Do it.") => emit("input", { type: "input", text, source: "interactive" }),
|
|
106
|
+
toolCall: (toolName: string, input: Record<string, unknown>) => emit("tool_call", { type: "tool_call", toolName, toolCallId: "c-1", input }),
|
|
107
|
+
settle: async (finalText: string, entries: unknown[] = []) => (await emit("agent_before_settle", {
|
|
108
|
+
type: "agent_before_settle", entries, continue: false, outcome: "completed",
|
|
109
|
+
context: { contextEntries: [], contextMessages: [user("Do it."), assistant(finalText)], llmMessages: [], pendingMessages: [], canContinue: false },
|
|
110
|
+
})) as SettleResult | undefined,
|
|
111
|
+
agentStart: (event: Record<string, unknown> = {}) => emit("before_agent_start", { type: "before_agent_start", prompt: "Do it.", systemPrompt: "", ...event }),
|
|
112
|
+
agentEnd: () => emit("agent_end", { type: "agent_end", messages: [] }),
|
|
113
|
+
settled: () => emit("agent_settled", { type: "agent_settled" }),
|
|
114
|
+
sent,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
test("S1/S2: the settle hook appends one visible reminder and requests one continuation", async () => {
|
|
119
|
+
const session = hookedExtension();
|
|
120
|
+
await session.input();
|
|
121
|
+
const prior = { type: "custom", customType: "other.extension" };
|
|
122
|
+
const result = await session.settle("Implemented.\nRisk: item 3 (shared parser)", [prior]);
|
|
123
|
+
assert.equal(result?.continue, true);
|
|
124
|
+
assert.equal(result?.entries?.length, 2, "earlier proposed entries are kept");
|
|
125
|
+
assert.deepEqual(result?.entries?.[0], prior);
|
|
126
|
+
const reminder = result?.entries?.[1];
|
|
127
|
+
assert.equal(reminder?.type, "custom_message");
|
|
128
|
+
assert.equal(reminder?.customType, VERIFIER_SETTLE_REMINDER_TYPE);
|
|
129
|
+
assert.equal(reminder?.display, true, "the reminder is visible");
|
|
130
|
+
assert.equal(reminder?.content, verifierSettleReminderText(3));
|
|
131
|
+
assert.equal(await session.settle("Ran the verifier? No.\nRisk: item 3"), undefined, "the continuation of the same prompt is not reminded again");
|
|
132
|
+
await session.input("Next task.");
|
|
133
|
+
assert.equal((await session.settle("Risk: item 2"))?.continue, true, "a new user prompt resets the reminder");
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
test("S3: no settle reminder for Risk: none, no item, or a rejected verifier attempt", async () => {
|
|
137
|
+
const session = hookedExtension();
|
|
138
|
+
await session.input();
|
|
139
|
+
assert.equal(await session.settle("Done.\nRisk: none"), undefined);
|
|
140
|
+
assert.equal(await session.settle("Done."), undefined);
|
|
141
|
+
const rejected = await session.toolCall("subagent_run", { agent: "gentle-ai-verify", mode: "task", task: "Verify the change." }) as { block?: boolean } | undefined;
|
|
142
|
+
assert.equal(rejected?.block, true, "the admission still rejects the unrisked launch");
|
|
143
|
+
assert.equal(await session.settle("Done.\nRisk: item 3"), undefined, "a rejected verifier attempt counts as attempted");
|
|
144
|
+
await session.input("Again.");
|
|
145
|
+
const admitted = await session.toolCall("subagent_run", { agent: "gentle-ai-verify", mode: "task", task: "Verify it.\nRisk: item 3" }) as { block?: boolean } | undefined;
|
|
146
|
+
assert.equal(admitted?.block, undefined);
|
|
147
|
+
assert.equal(await session.settle("Done.\nRisk: item 3"), undefined, "an admitted verifier attempt counts as attempted");
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
test("S1: a child session never gets the settle reminder", async () => {
|
|
151
|
+
const child = hookedExtension({ GENTLE_PI_AGENTS_CHILD: "1" });
|
|
152
|
+
await child.input();
|
|
153
|
+
assert.equal(await child.settle("Done.\nRisk: item 3"), undefined);
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
test("S1: the existing agent_end review preflight stays inert without a native review CLI", async () => {
|
|
157
|
+
const session = hookedExtension();
|
|
158
|
+
await session.input();
|
|
159
|
+
await session.agentEnd();
|
|
160
|
+
assert.deepEqual(session.sent, [], "agent_end sends no preflight nudge and the settle reminder never uses sendMessage");
|
|
161
|
+
await session.settle("Risk: item 1");
|
|
162
|
+
assert.deepEqual(session.sent, []);
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
test("S5: the gentle_review input description documents the ASSESS escalate shape", () => {
|
|
166
|
+
const source = readFileSync(join(import.meta.dirname, "..", "extensions", "gentle-ai.ts"), "utf8");
|
|
167
|
+
const description = source.split("\n").find(line => line.includes("ASSESS accepts an optional object with baseRef"));
|
|
168
|
+
assert.ok(description, "the gentle_review input description exists");
|
|
169
|
+
assert.match(description, /writerEffort, nativeReviewOutcome, and escalate/);
|
|
170
|
+
assert.match(description, /escalate is \{\\"item\\":N,\\"reason\\":\\"\.\.\.\\"\} with item an integer from 1 to 6 and a non-empty reason of at most 500 characters; any other shape is rejected, and omitting it means no escalation/);
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
test("S6: the reference docs describe the settle reminder", () => {
|
|
174
|
+
const docs = readFileSync(join(import.meta.dirname, "..", "docs", "readme-reference.md"), "utf8");
|
|
175
|
+
const start = docs.indexOf("A third admission check keeps the independent verifier for high-risk changes");
|
|
176
|
+
assert.ok(start >= 0);
|
|
177
|
+
const paragraph = docs.slice(start, docs.indexOf("\n\n", docs.indexOf("\n\n", start) + 2));
|
|
178
|
+
assert.match(paragraph, /no supported `Risk: item N` declaration was recognized/);
|
|
179
|
+
assert.match(paragraph, /`agent_before_settle`[^]*one visible reminder[^]*one continuation/);
|
|
180
|
+
assert.match(paragraph, /once per user prompt/);
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
// #2652 regression: a real Pi session hands `agent_before_settle` a completed run with `canContinue: false` (the last
|
|
184
|
+
// message is the assistant's). The reminder must still be appended and continue exactly once.
|
|
185
|
+
test("a real Pi session appends one settle reminder and continues once after a declared high risk", async () => {
|
|
186
|
+
const sdk = await import("@earendil-works/pi-coding-agent");
|
|
187
|
+
const ai = await import("@earendil-works/pi-ai");
|
|
188
|
+
const root = mkdtempSync(join(tmpdir(), "vsr-"));
|
|
189
|
+
const profile = join(root, "profile");
|
|
190
|
+
const bindings: Record<string, string> = { PI_CODING_AGENT_DIR: profile, PI_CODING_AGENT_SESSION_DIR: join(root, "sessions"), GENTLE_PI_AGENT_HOME: profile, GENTLE_PI_CONFIG_HOME: join(root, "config") };
|
|
191
|
+
const previous = Object.fromEntries(Object.keys(bindings).map(key => [key, process.env[key]]));
|
|
192
|
+
Object.assign(process.env, bindings);
|
|
193
|
+
const replies = ["Implemented.\nRisk: item 6 (no regression test)"];
|
|
194
|
+
let calls = 0;
|
|
195
|
+
const usage = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, totalTokens: 0, cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 } };
|
|
196
|
+
const cost = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 };
|
|
197
|
+
const model = { id: "driver", name: "driver", provider: "fx", api: "fx", baseUrl: "http://invalid.local", reasoning: false, input: ["text"], contextWindow: 1_000_000, maxTokens: 1024, cost } as any;
|
|
198
|
+
try {
|
|
199
|
+
const { mkdirSync } = await import("node:fs");
|
|
200
|
+
mkdirSync(profile);
|
|
201
|
+
const manager = sdk.SessionManager.inMemory(root);
|
|
202
|
+
const settings = sdk.SettingsManager.inMemory({ compaction: { enabled: false }, retry: { enabled: false }, cacheWarming: "off", packages: [] } as any);
|
|
203
|
+
const runtime = await sdk.ModelRuntime.create({ credentials: new ai.InMemoryCredentialStore(), modelsPath: null, modelsStorePath: join(root, "models.json"), refreshOnCreate: false, allowModelNetwork: false } as any);
|
|
204
|
+
const loader = new sdk.DefaultResourceLoader({
|
|
205
|
+
cwd: root, agentDir: profile, settingsManager: settings, noExtensions: true, noSkills: true, noPromptTemplates: true, noThemes: true, noContextFiles: true, systemPrompt: "fixture",
|
|
206
|
+
extensionFactories: [(pi: ExtensionAPI) => {
|
|
207
|
+
createGentleAiExtension({ nativeReviewCli: null, candidateViews: null, processEnv: bindings, resolveTelemetryTriggerBinary: () => { throw new Error("fixture"); } } as any)(pi);
|
|
208
|
+
pi.registerProvider("fx", {
|
|
209
|
+
api: "fx", apiKey: "x", baseUrl: "http://invalid.local",
|
|
210
|
+
models: [{ id: model.id, name: model.name, reasoning: false, input: ["text"], cost, contextWindow: model.contextWindow, maxTokens: model.maxTokens }],
|
|
211
|
+
streamSimple() {
|
|
212
|
+
const stream = ai.createAssistantMessageEventStream();
|
|
213
|
+
calls++;
|
|
214
|
+
const message = { role: "assistant", api: "fx", provider: "fx", model: "driver", content: [{ type: "text", text: replies.shift() ?? "Needs your decision: independent verification is pending." }], stopReason: "stop", timestamp: Date.now(), usage } as any;
|
|
215
|
+
queueMicrotask(() => { stream.push({ type: "start", partial: message }); stream.push({ type: "done", reason: "stop", message }); stream.end(); });
|
|
216
|
+
return stream;
|
|
217
|
+
},
|
|
218
|
+
} as any);
|
|
219
|
+
}],
|
|
220
|
+
} as any);
|
|
221
|
+
await loader.reload();
|
|
222
|
+
const { session } = await sdk.createAgentSession({ cwd: root, agentDir: profile, modelRuntime: runtime, model, thinkingLevel: "off", resourceLoader: loader, tools: [], sessionManager: manager, settingsManager: settings } as any);
|
|
223
|
+
const errors: unknown[] = [];
|
|
224
|
+
await session.bindExtensions({ mode: "json", onError: (error: any) => errors.push(error.error) } as any);
|
|
225
|
+
await session.prompt("Do the change.", { source: "interactive" } as any);
|
|
226
|
+
const reminders = manager.getEntries().filter((entry: any) => entry.type === "custom_message" && entry.customType === "gentle-pi.verifier-settle-reminder");
|
|
227
|
+
await session.abort();
|
|
228
|
+
session.dispose();
|
|
229
|
+
assert.deepEqual(errors, []);
|
|
230
|
+
assert.equal(reminders.length, 1);
|
|
231
|
+
assert.equal(calls, 2);
|
|
232
|
+
} finally {
|
|
233
|
+
for (const [key, value] of Object.entries(previous)) { if (value === undefined) delete process.env[key]; else process.env[key] = value; }
|
|
234
|
+
rmSync(root, { recursive: true, force: true });
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
// #2653 follow-up: an in-process named-agent run never records verifier attempts (its tool calls are not primary), so its
|
|
239
|
+
// settle must never remind, whatever its final text declares. The next primary run still is reminded.
|
|
240
|
+
test("S1: a named-agent run is never reminded at settle, and the next primary run still is", async () => {
|
|
241
|
+
const session = hookedExtension();
|
|
242
|
+
await session.input();
|
|
243
|
+
await session.agentStart({ agentName: "gentle-ai-worker" });
|
|
244
|
+
await session.agentEnd();
|
|
245
|
+
assert.equal(await session.settle("Worker done.\nRisk: item 3 (shared parser)"), undefined);
|
|
246
|
+
await session.settled();
|
|
247
|
+
await session.agentStart();
|
|
248
|
+
const result = await session.settle("Implemented.\nRisk: item 3 (shared parser)");
|
|
249
|
+
assert.equal(result?.continue, true);
|
|
250
|
+
assert.equal(result?.entries?.[0]?.content, verifierSettleReminderText(3));
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
// A named agent nested inside a primary run settles before it. Its settle is paired off without touching the primary
|
|
254
|
+
// run's classification, and without relying on `agent_end` (which, without native review, never pairs the depth off).
|
|
255
|
+
test("S1: a named-agent run nested in a primary run does not suppress the primary run's reminder", async () => {
|
|
256
|
+
const session = hookedExtension();
|
|
257
|
+
await session.input();
|
|
258
|
+
await session.agentStart();
|
|
259
|
+
await session.agentStart({ agentName: "review-readability" });
|
|
260
|
+
await session.agentEnd();
|
|
261
|
+
assert.equal(await session.settle("Review done.\nRisk: item 2 (auth)"), undefined, "the nested named run is not reminded");
|
|
262
|
+
await session.settled();
|
|
263
|
+
await session.agentEnd();
|
|
264
|
+
const result = await session.settle("Implemented.\nRisk: item 3 (shared parser)");
|
|
265
|
+
assert.equal(result?.continue, true, "the primary run is still reminded");
|
|
266
|
+
assert.equal(result?.entries?.[0]?.content, verifierSettleReminderText(3));
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
// Pi can check settlement again after a continuation without a new `before_agent_start`, so a named run stays named until
|
|
270
|
+
// `agent_settled`, and only then does the next settle count as the primary run's.
|
|
271
|
+
test("S1: a named-agent run stays unreminded across continuation settles until it has settled", async () => {
|
|
272
|
+
const session = hookedExtension();
|
|
273
|
+
await session.input();
|
|
274
|
+
await session.agentStart();
|
|
275
|
+
await session.agentStart({ agentName: "review-readability" });
|
|
276
|
+
assert.equal(await session.settle("Review done.\nRisk: item 2 (auth)"), undefined);
|
|
277
|
+
assert.equal(await session.settle("Review still done.\nRisk: item 2 (auth)"), undefined, "a continuation settle of the named run is not reminded");
|
|
278
|
+
await session.settled();
|
|
279
|
+
const result = await session.settle("Implemented.\nRisk: item 3 (shared parser)");
|
|
280
|
+
assert.equal(result?.continue, true, "the primary run is reminded once the named run settled");
|
|
281
|
+
});
|
|
@@ -23,6 +23,56 @@ function containsAll(text: string, clauses: readonly string[], label: string): v
|
|
|
23
23
|
for (const clause of clauses) assert.ok(text.includes(clause), `${label} is missing: ${clause}`);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
// Issue #1494: these pin prompt policy, not a runtime-enforced limit or model compliance.
|
|
27
|
+
test("S1: verifier makes one isolated preparation attempt before checks", () => {
|
|
28
|
+
containsAll(verify, [
|
|
29
|
+
"Make one isolated preparation attempt",
|
|
30
|
+
"If preparation succeeds, run the authorized checks and independent spec-derived probes",
|
|
31
|
+
], "preparation bound");
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
test("S2: preparation failure reports a concrete blocker and exact unrun checks", () => {
|
|
35
|
+
containsAll(verify, [
|
|
36
|
+
"At the first inability to prepare a required copy, environment, dependency, or helper, stop setup",
|
|
37
|
+
"report one concrete setup blocker and the exact checks left unrun as unverified, not passed",
|
|
38
|
+
"list every scratch directory you created by exact path",
|
|
39
|
+
], "setup failure");
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
test("S3: setup failures do not trigger repair loops or automatic relaunch", () => {
|
|
43
|
+
containsAll(verify, ["Do not retry setup or enter repair-helper loops"], "verifier setup");
|
|
44
|
+
containsAll(verification, [
|
|
45
|
+
"Do not automatically relaunch the verifier for the same missing prerequisite",
|
|
46
|
+
"Distinguish setup or infrastructure failure from genuine code findings",
|
|
47
|
+
"stop with one **Needs your decision** result identifying the missing prerequisite and exact unrun checks",
|
|
48
|
+
"Do not keep repairing helpers",
|
|
49
|
+
"Auxiliary tooling defects remain subject to the existing correction bound",
|
|
50
|
+
], "parent setup");
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
test("S5: documentation identifies the instruction as policy rather than runtime enforcement", () => {
|
|
54
|
+
const docs = read("docs/delegated-verification.md");
|
|
55
|
+
containsAll(docs, [
|
|
56
|
+
"one isolated preparation attempt",
|
|
57
|
+
"prompt policy, not a runtime-enforced limit",
|
|
58
|
+
"unverified, not passed",
|
|
59
|
+
], "delegated verification documentation");
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
test("S4: successful setup retains independent probes, isolation, consent and finding correction", () => {
|
|
63
|
+
containsAll(verify, [
|
|
64
|
+
"independent probes required by the risk tier",
|
|
65
|
+
"never `git worktree`, `git stash`, or a symlink into the workspace",
|
|
66
|
+
"No network, no installs, no writes outside the scratch directory",
|
|
67
|
+
"one correction batch and one recheck limited to the reported blockers",
|
|
68
|
+
], "verification safeguards");
|
|
69
|
+
containsAll(verification, [
|
|
70
|
+
"one separate `gentle-ai-verify` run",
|
|
71
|
+
"one correction batch that fixes every reported blocker",
|
|
72
|
+
], "parent safeguards");
|
|
73
|
+
assert.ok(read("docs/delegated-verification.md").includes("human consent for native review"));
|
|
74
|
+
});
|
|
75
|
+
|
|
26
76
|
test("T16: read-only means no repository or git-state edits", () => {
|
|
27
77
|
containsAll(verify, [
|
|
28
78
|
"read-only technical verifier for generic ODD work",
|
|
@@ -116,14 +166,15 @@ test("T16: the verify handoff names probe command forms and the scratch location
|
|
|
116
166
|
], "verify handoff");
|
|
117
167
|
});
|
|
118
168
|
|
|
119
|
-
// T17b (L42):
|
|
120
|
-
//
|
|
121
|
-
|
|
122
|
-
test("T17b: the core Evidence-budget rule never fires to prepare an inline write", () => {
|
|
169
|
+
// T17b (L42): preparation for an understood inline write stays inline, but
|
|
170
|
+
// discovery cannot evade the evidence budget merely because a write is planned.
|
|
171
|
+
test("T17b: inline-write preparation is distinct from discovery", () => {
|
|
123
172
|
const core = read("assets/orchestrator.md");
|
|
124
173
|
const rule = core.split("\n").find((line) => line.includes("**Evidence-budget rule**"));
|
|
125
174
|
assert.ok(rule, "Evidence-budget rule is missing");
|
|
126
|
-
assert.
|
|
175
|
+
assert.match(rule, /Exempt only preparation for an understood inline write, not discovery/);
|
|
176
|
+
assert.match(rule, /cumulative discovery each batch, never reset/);
|
|
177
|
+
assert.match(core, /No explore, worker, or verifier unless a trigger fires/);
|
|
127
178
|
});
|
|
128
179
|
|
|
129
180
|
test("T17: the always-on Explore step delegates exploration only for a map the parent needs", () => {
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
import { spawnSync } from "node:child_process";
|
|
4
|
+
import test from "node:test";
|
|
5
|
+
|
|
6
|
+
const source = readFileSync(new URL("./installer-windows-bootstrap.test.ts", import.meta.url), "utf8");
|
|
7
|
+
const names = [...source.matchAll(/^test\(("native Windows(?:[^"\\]|\\.)*")\s*,/gm)].map((match) => JSON.parse(match[1]) as string);
|
|
8
|
+
const modes = JSON.parse(`[${/^const probeModes = \[([^\]]*)\] as const;$/m.exec(source)![1]}]`) as string[];
|
|
9
|
+
names.push(...modes.map((mode) => `native Windows: pre-Node production process primitive ${mode}`));
|
|
10
|
+
assert.equal(names.length, 38);
|
|
11
|
+
|
|
12
|
+
// Node's TAP reporter escapes backslashes in test names.
|
|
13
|
+
const tapNames = names.map((name) => name.replaceAll("\\", "\\\\"));
|
|
14
|
+
function tap(results = tapNames.map((name, i) => `ok ${i + 1} - ${name}`)) {
|
|
15
|
+
return [`TAP version 13`, ...results, `ok ${results.length + 1} - other platform # SKIP unavailable`,
|
|
16
|
+
`1..${results.length + 1}`, `# tests ${results.length + 1}`, `# suites 0`, `# pass ${results.length}`,
|
|
17
|
+
`# fail 0`, `# cancelled 0`, `# skipped 1`, `# todo 0`, `# duration_ms 1.2`, ""].join("\n");
|
|
18
|
+
}
|
|
19
|
+
function verify(input: string) {
|
|
20
|
+
return spawnSync(process.execPath, ["scripts/verify-installer-tap.mjs"], { input, encoding: "utf8" });
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
test("accepts every native pass even with an unrelated platform skip", () => {
|
|
24
|
+
const input = tap().replace("ok 1 - ", "# Subtest: native fixture\n ---\n duration_ms: 1\n ...\nok 1 - ");
|
|
25
|
+
const result = verify(input.replaceAll("\n", "\r\n"));
|
|
26
|
+
assert.equal(result.status, 0, result.stderr);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const cases: [string, (input: string) => string][] = [
|
|
30
|
+
["missing native result", (s) => s.replace(` - ${names[0]}\n`, " - unrelated replacement\n")],
|
|
31
|
+
["duplicate native result", (s) => s.replace(` - ${names[1]}\n`, ` - ${names[0]}\n`)],
|
|
32
|
+
["native skip", (s) => s.replace(` - ${names[0]}\n`, ` - ${names[0]} # SKIP unavailable\n`)],
|
|
33
|
+
["native TODO", (s) => s.replace(` - ${names[0]}\n`, ` - ${names[0]} # TODO later\n`)],
|
|
34
|
+
["native failure", (s) => s.replace(`ok 1 - ${names[0]}`, `not ok 1 - ${names[0]}`)],
|
|
35
|
+
["missing final summary", (s) => s.slice(0, s.indexOf("# tests"))],
|
|
36
|
+
["missing plan", (s) => s.replace(/^1\.\.\d+\n/m, "")],
|
|
37
|
+
["duplicate plan", (s) => s.replace(/^(1\.\.\d+)\n/m, "$1\n$1\n")],
|
|
38
|
+
["duplicate summary", (s) => s + s.slice(s.indexOf("# tests"))],
|
|
39
|
+
["truncated final line", (s) => s.slice(0, -1)],
|
|
40
|
+
["inconsistent plan", (s) => s.replace("1..39", "1..40")],
|
|
41
|
+
["inconsistent summary", (s) => s.replace("# tests 39", "# tests 40")],
|
|
42
|
+
["unaccounted skip", (s) => s.replace("# pass 38", "# pass 39").replace("# skipped 1", "# skipped 0")],
|
|
43
|
+
["duplicate partial summary", (s) => s.replace("1..39\n", "# tests 39\n1..39\n")],
|
|
44
|
+
["duplicate header", (s) => s.replace("1..39\n", "TAP version 13\n1..39\n")],
|
|
45
|
+
["duplicate result number", (s) => s.replace("ok 2 - ", "ok 1 - ")],
|
|
46
|
+
["unexpected failure", (s) => s.replace("# fail 0", "# fail 1")],
|
|
47
|
+
["unexpected TODO", (s) => s.replace("# todo 0", "# todo 1")],
|
|
48
|
+
["unexpected cancellation", (s) => s.replace("# cancelled 0", "# cancelled 1")],
|
|
49
|
+
["malformed result", (s) => s.replace("ok 2 - ", "okay 2 - ")],
|
|
50
|
+
];
|
|
51
|
+
for (const [label, mutate] of cases) {
|
|
52
|
+
test(`rejects ${label}`, () => {
|
|
53
|
+
const result = verify(mutate(tap()));
|
|
54
|
+
assert.notEqual(result.status, 0);
|
|
55
|
+
assert.match(result.stderr, /installer TAP:/);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
@@ -277,12 +277,12 @@ test("resolveVimRuntime resolves local bundle cli entrypoint when provided", ()
|
|
|
277
277
|
});
|
|
278
278
|
|
|
279
279
|
test("audited Pi editor releases are one frozen exact allowlist that includes the installed TUI", () => {
|
|
280
|
-
assert.deepEqual([...AUDITED_PI_EDITOR_VERSIONS], ["0.99.1", "0.99.2", "1.0.0", "1.1.0", "1.2.0", "1.3.0", "1.4.0"]);
|
|
280
|
+
assert.deepEqual([...AUDITED_PI_EDITOR_VERSIONS], ["0.99.1", "0.99.2", "1.0.0", "1.1.0", "1.2.0", "1.3.0", "1.4.0", "1.5.0"]);
|
|
281
281
|
assert.equal(bundledAgent.VERSION, INSTALLED_PI, "bundled and local metadata must describe the same actual installed release");
|
|
282
282
|
assert.ok(Object.isFrozen(AUDITED_PI_EDITOR_VERSIONS));
|
|
283
283
|
assert.throws(() => (AUDITED_PI_EDITOR_VERSIONS as unknown as string[]).push("0.99.3"), TypeError);
|
|
284
284
|
assert.ok(isAuditedPiEditorVersion(INSTALLED_PI), `installed pi-tui ${INSTALLED_PI} must be audited`);
|
|
285
|
-
for (const unknown of ["0.99.3", "0.99.10", "0.99", "v0.99.2", " 0.99.2", "0.99.2-rc.1", ">=0.99.2", "1.0.1", ">=1.0.0", "v1.0.0", " 1.0.0", "1.0.0-rc.1", "1.2.1", "1.2.0-rc.1", "v1.2.0", ">=1.2.0", "1.4.1", "1.5.
|
|
285
|
+
for (const unknown of ["0.99.3", "0.99.10", "0.99", "v0.99.2", " 0.99.2", "0.99.2-rc.1", ">=0.99.2", "1.0.1", ">=1.0.0", "v1.0.0", " 1.0.0", "1.0.0-rc.1", "1.2.1", "1.2.0-rc.1", "v1.2.0", ">=1.2.0", "1.4.1", "1.5.1", "1.4.0-rc.1", undefined, 99.2]) {
|
|
286
286
|
assert.equal(isAuditedPiEditorVersion(unknown), false, String(unknown));
|
|
287
287
|
}
|
|
288
288
|
});
|
|
@@ -3,7 +3,7 @@ import { mkdtempSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync, wr
|
|
|
3
3
|
import { tmpdir } from "node:os";
|
|
4
4
|
import { join } from "node:path";
|
|
5
5
|
import { test } from "node:test";
|
|
6
|
-
import { DEFAULT_VISUAL_SETTINGS, DENSITY, HEADER_PLACEMENT, parseVisualSettingsFile, resolveVisualSettings, STATUS_PLACEMENT, VISUAL_SECTION_KEYS, writeVisualSettings, VISUAL_SCHEMA } from "../lib/visual-customization-policy.ts";
|
|
6
|
+
import { applyVisualPreset, DEFAULT_VISUAL_SETTINGS, DENSITY, HEADER_PLACEMENT, isVisualSettings, parseVisualSettingsFile, resolveVisualSettings, STATUS_PLACEMENT, VISUAL_PRESET, VISUAL_SECTION_KEYS, visualPresetOf, writeVisualSettings, VISUAL_SCHEMA } from "../lib/visual-customization-policy.ts";
|
|
7
7
|
|
|
8
8
|
test("missing settings use responsive defaults and return independent copies", () => {
|
|
9
9
|
const home = mkdtempSync(join(tmpdir(), "visual-policy-"));
|
|
@@ -13,7 +13,7 @@ test("missing settings use responsive defaults and return independent copies", (
|
|
|
13
13
|
assert.equal(DEFAULT_VISUAL_SETTINGS.statusPlacement, "auto");
|
|
14
14
|
assert.equal(DEFAULT_VISUAL_SETTINGS.headerPlacement, "top");
|
|
15
15
|
assert.equal(DEFAULT_VISUAL_SETTINGS.density, "comfortable");
|
|
16
|
-
assert.deepEqual(DEFAULT_VISUAL_SETTINGS.visibility, { changes: true, rdd: true, agents: true, todo: true, usageCost: true, modelDetails: true, contextWarning: true });
|
|
16
|
+
assert.deepEqual(DEFAULT_VISUAL_SETTINGS.visibility, { changes: true, rdd: true, agents: true, todo: true, usageCost: true, modelDetails: true, contextWarning: true, stats: false });
|
|
17
17
|
resolved.settings.visibility.agents = false;
|
|
18
18
|
assert.equal(DEFAULT_VISUAL_SETTINGS.visibility.agents, true);
|
|
19
19
|
assert.equal(resolveVisualSettings({ gentlePiConfigHome: home }).settings.visibility.agents, true);
|
|
@@ -29,13 +29,13 @@ test("strict versioned parsing rejects malformed and partial settings", () => {
|
|
|
29
29
|
});
|
|
30
30
|
|
|
31
31
|
test("Sections rows follow one ordered key list that covers every visibility key", () => {
|
|
32
|
-
assert.deepEqual(VISUAL_SECTION_KEYS, ["changes", "rdd", "agents", "todo", "usageCost", "modelDetails", "contextWarning"]);
|
|
32
|
+
assert.deepEqual(VISUAL_SECTION_KEYS, ["changes", "rdd", "agents", "todo", "usageCost", "modelDetails", "contextWarning", "stats"]);
|
|
33
33
|
assert.deepEqual([...VISUAL_SECTION_KEYS].sort(), Object.keys(DEFAULT_VISUAL_SETTINGS.visibility).sort());
|
|
34
34
|
});
|
|
35
35
|
|
|
36
36
|
test("settings saved before the rdd section existed load as valid with rdd shown", () => {
|
|
37
37
|
const legacy = { schema: VISUAL_SCHEMA, ...DEFAULT_VISUAL_SETTINGS, visibility: { changes: false, agents: true, todo: false, usageCost: true, modelDetails: false } };
|
|
38
|
-
const expected = { ...DEFAULT_VISUAL_SETTINGS, visibility: { changes: false, rdd: true, agents: true, todo: false, usageCost: true, modelDetails: false, contextWarning: true } };
|
|
38
|
+
const expected = { ...DEFAULT_VISUAL_SETTINGS, visibility: { changes: false, rdd: true, agents: true, todo: false, usageCost: true, modelDetails: false, contextWarning: true, stats: false } };
|
|
39
39
|
assert.deepEqual(parseVisualSettingsFile(JSON.stringify(legacy)), expected);
|
|
40
40
|
assert.deepEqual(parseVisualSettingsFile(JSON.stringify({ ...legacy, visibility: { ...expected.visibility, rdd: false } })), { ...expected, visibility: { ...expected.visibility, rdd: false } });
|
|
41
41
|
for (const visibility of [{ ...legacy.visibility, extra: true }, { ...legacy.visibility, rdd: "no" }, { ...legacy.visibility, todo: "yes" }, { agents: true, todo: true, usageCost: true, modelDetails: true, rdd: true }]) {
|
|
@@ -58,13 +58,13 @@ test("settings saved before contextWarning existed load it shown and preserve rd
|
|
|
58
58
|
const shared = { schema: VISUAL_SCHEMA, ...DEFAULT_VISUAL_SETTINGS };
|
|
59
59
|
const preRdd = { ...shared, visibility: { changes: false, agents: true, todo: false, usageCost: true, modelDetails: false } };
|
|
60
60
|
assert.deepEqual(parseVisualSettingsFile(JSON.stringify(preRdd)), { ...DEFAULT_VISUAL_SETTINGS,
|
|
61
|
-
visibility: { changes: false, rdd: true, agents: true, todo: false, usageCost: true, modelDetails: false, contextWarning: true } });
|
|
61
|
+
visibility: { changes: false, rdd: true, agents: true, todo: false, usageCost: true, modelDetails: false, contextWarning: true, stats: false } });
|
|
62
62
|
const preContext = { ...shared, visibility: { changes: false, rdd: false, agents: true, todo: false, usageCost: true, modelDetails: false } };
|
|
63
63
|
assert.deepEqual(parseVisualSettingsFile(JSON.stringify(preContext)), { ...DEFAULT_VISUAL_SETTINGS,
|
|
64
|
-
visibility: { changes: false, rdd: false, agents: true, todo: false, usageCost: true, modelDetails: false, contextWarning: true } });
|
|
64
|
+
visibility: { changes: false, rdd: false, agents: true, todo: false, usageCost: true, modelDetails: false, contextWarning: true, stats: false } });
|
|
65
65
|
const withoutRdd = { ...shared, visibility: { changes: true, agents: true, todo: true, usageCost: true, modelDetails: true, contextWarning: false } };
|
|
66
66
|
assert.deepEqual(parseVisualSettingsFile(JSON.stringify(withoutRdd)), { ...DEFAULT_VISUAL_SETTINGS,
|
|
67
|
-
visibility: { changes: true, rdd: true, agents: true, todo: true, usageCost: true, modelDetails: true, contextWarning: false } });
|
|
67
|
+
visibility: { changes: true, rdd: true, agents: true, todo: true, usageCost: true, modelDetails: true, contextWarning: false, stats: false } });
|
|
68
68
|
});
|
|
69
69
|
|
|
70
70
|
test("a present non-boolean added key in a partial legacy shape is rejected before default fill", () => {
|
|
@@ -137,3 +137,57 @@ test("atomic write round trips and invalid existing files fall back without over
|
|
|
137
137
|
assert.equal(readFileSync(path, "utf8"), "broken");
|
|
138
138
|
} finally { rmSync(home, { recursive: true, force: true }); }
|
|
139
139
|
});
|
|
140
|
+
|
|
141
|
+
// Presets (/gentle:customize → Layout → Preset) bundle the existing density and
|
|
142
|
+
// visibility switches; they never add a key, so every binary keeps reading the file.
|
|
143
|
+
test("presets are valid settings that keep the file format and the header placement; Light drops the rail", () => {
|
|
144
|
+
assert.deepEqual(Object.values(VISUAL_PRESET), ["light", "neutral", "power-user"]);
|
|
145
|
+
const custom = { ...DEFAULT_VISUAL_SETTINGS, statusPlacement: STATUS_PLACEMENT.RIGHT, headerPlacement: HEADER_PLACEMENT.BELOW_INPUT };
|
|
146
|
+
for (const preset of Object.values(VISUAL_PRESET)) {
|
|
147
|
+
const applied = applyVisualPreset(custom, preset);
|
|
148
|
+
assert.ok(isVisualSettings(applied), `${preset} is a valid settings object`);
|
|
149
|
+
assert.equal(applied.headerPlacement, HEADER_PLACEMENT.BELOW_INPUT, "a preset keeps the header placement");
|
|
150
|
+
assert.equal(applied.statusPlacement, preset === VISUAL_PRESET.LIGHT ? STATUS_PLACEMENT.BOTTOM : STATUS_PLACEMENT.RIGHT, "Light moves Status to the bottom bar (no rail); the others keep the placement");
|
|
151
|
+
assert.equal(visualPresetOf(applied), preset);
|
|
152
|
+
}
|
|
153
|
+
const fromLight = applyVisualPreset(applyVisualPreset(DEFAULT_VISUAL_SETTINGS, VISUAL_PRESET.LIGHT), VISUAL_PRESET.NEUTRAL);
|
|
154
|
+
assert.equal(fromLight.statusPlacement, STATUS_PLACEMENT.AUTO, "leaving Light brings the rail back");
|
|
155
|
+
assert.equal(applyVisualPreset({ ...DEFAULT_VISUAL_SETTINGS, statusPlacement: STATUS_PLACEMENT.BOTTOM }, VISUAL_PRESET.NEUTRAL).statusPlacement, STATUS_PLACEMENT.BOTTOM, "a bottom placement chosen by hand stays");
|
|
156
|
+
assert.equal(visualPresetOf({ ...applyVisualPreset(DEFAULT_VISUAL_SETTINGS, VISUAL_PRESET.LIGHT), statusPlacement: STATUS_PLACEMENT.AUTO }), undefined, "Light switches with a rail are a custom mix");
|
|
157
|
+
assert.deepEqual(applyVisualPreset(DEFAULT_VISUAL_SETTINGS, VISUAL_PRESET.NEUTRAL), DEFAULT_VISUAL_SETTINGS, "Neutral is today's default");
|
|
158
|
+
const light = applyVisualPreset(DEFAULT_VISUAL_SETTINGS, VISUAL_PRESET.LIGHT);
|
|
159
|
+
assert.equal(light.density, DENSITY.MINIMAL);
|
|
160
|
+
assert.deepEqual({ changes: light.visibility.changes, todo: light.visibility.todo, agents: light.visibility.agents, modelDetails: light.visibility.modelDetails, usageCost: light.visibility.usageCost }, { changes: false, todo: false, agents: true, modelDetails: true, usageCost: true }, "Light keeps priority 1: model, context, agent questions");
|
|
161
|
+
const power = applyVisualPreset(DEFAULT_VISUAL_SETTINGS, VISUAL_PRESET.POWER_USER);
|
|
162
|
+
assert.equal(power.density, DENSITY.COMFORTABLE, "Power user keeps Neutral's spacing");
|
|
163
|
+
assert.ok(Object.values(power.visibility).every(Boolean), "Power user shows everything");
|
|
164
|
+
assert.equal(visualPresetOf({ ...DEFAULT_VISUAL_SETTINGS, visibility: { ...DEFAULT_VISUAL_SETTINGS.visibility, rdd: false } }), undefined, "a hand-tuned mix is custom");
|
|
165
|
+
const home = mkdtempSync(join(tmpdir(), "visual-preset-"));
|
|
166
|
+
try {
|
|
167
|
+
writeVisualSettings(light, { gentlePiConfigHome: home });
|
|
168
|
+
const stored = JSON.parse(readFileSync(join(home, "visual-customization.json"), "utf8"));
|
|
169
|
+
assert.deepEqual(Object.keys(stored).sort(), ["density", "headerPlacement", "schema", "statusPlacement", "visibility"], "no preset key is stored");
|
|
170
|
+
assert.deepEqual(resolveVisualSettings({ gentlePiConfigHome: home }).settings, light);
|
|
171
|
+
} finally {
|
|
172
|
+
rmSync(home, { recursive: true, force: true });
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
test("settings saved before the stats section existed load as valid with Stats hidden", () => {
|
|
177
|
+
const { stats: _stats, ...visibility } = DEFAULT_VISUAL_SETTINGS.visibility;
|
|
178
|
+
const parsed = parseVisualSettingsFile(JSON.stringify({ schema: VISUAL_SCHEMA, ...DEFAULT_VISUAL_SETTINGS, visibility: { ...visibility, rdd: false } }));
|
|
179
|
+
assert.equal(parsed?.visibility.stats, false, "a missing stats key stays hidden, unlike rdd and contextWarning");
|
|
180
|
+
assert.equal(parsed?.visibility.rdd, false, "present keys are preserved");
|
|
181
|
+
const shown = parseVisualSettingsFile(JSON.stringify({ schema: VISUAL_SCHEMA, ...DEFAULT_VISUAL_SETTINGS, visibility: { ...visibility, stats: true } }));
|
|
182
|
+
assert.equal(shown?.visibility.stats, true);
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
test("Power user keeps Neutral's spacing and adds Stats; Neutral and Light leave Stats off", () => {
|
|
186
|
+
const power = applyVisualPreset(DEFAULT_VISUAL_SETTINGS, VISUAL_PRESET.POWER_USER);
|
|
187
|
+
assert.equal(power.density, DEFAULT_VISUAL_SETTINGS.density, "same spacing as Neutral");
|
|
188
|
+
assert.equal(power.visibility.stats, true);
|
|
189
|
+
assert.equal(visualPresetOf(power), VISUAL_PRESET.POWER_USER);
|
|
190
|
+
assert.equal(visualPresetOf(DEFAULT_VISUAL_SETTINGS), VISUAL_PRESET.NEUTRAL);
|
|
191
|
+
assert.equal(applyVisualPreset(power, VISUAL_PRESET.NEUTRAL).visibility.stats, false);
|
|
192
|
+
assert.equal(applyVisualPreset(power, VISUAL_PRESET.LIGHT).visibility.stats, false);
|
|
193
|
+
});
|