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
|
@@ -118,7 +118,7 @@ test("profile name submission never accepts a hidden field at heights 3–5, inc
|
|
|
118
118
|
|
|
119
119
|
test("profile preview and cancel never apply; keyboard name and confirmations require deliberate input", async () => {
|
|
120
120
|
const events: string[] = [];
|
|
121
|
-
const profile = { name: "Desk", themeName: "Light Theme", animationPolicy: "potato" as const, banner: { showRose: false, showTextLogo: true, color: "cyan" as const }, visual: { statusPlacement: "hidden" as const, headerPlacement: "below-input" as const, density: "compact" as const, visibility: { changes: false, rdd: false, agents: true, todo: false, usageCost: true, modelDetails: false, contextWarning: false } } };
|
|
121
|
+
const profile = { name: "Desk", themeName: "Light Theme", animationPolicy: "potato" as const, banner: { showRose: false, showTextLogo: true, color: "cyan" as const }, visual: { statusPlacement: "hidden" as const, headerPlacement: "below-input" as const, density: "compact" as const, visibility: { changes: false, rdd: false, agents: true, todo: false, usageCost: true, modelDetails: false, contextWarning: false, stats: false } } };
|
|
122
122
|
const view = new VisualCustomizeView({ rows: [], theme, requestRender: () => {}, onClose: () => {}, profiles: {
|
|
123
123
|
list: () => [profile], save: (name, replace) => { events.push(`save:${name}:${replace}`); }, apply: (name) => { events.push(`apply:${name}`); }, delete: (name) => { events.push(`delete:${name}`); }, reset: () => { events.push("reset"); },
|
|
124
124
|
} });
|
|
@@ -147,7 +147,7 @@ test("profile preview and cancel never apply; keyboard name and confirmations re
|
|
|
147
147
|
|
|
148
148
|
test("profile confirmation stays visible at six rows for every destructive or applying action", async () => {
|
|
149
149
|
const events: string[] = [];
|
|
150
|
-
const profile = { name: "Desk", themeName: "Light", animationPolicy: "potato" as const, banner: { showRose: false, showTextLogo: true, color: "cyan" as const }, visual: { statusPlacement: "hidden" as const, headerPlacement: "below-input" as const, density: "compact" as const, visibility: { changes: false, rdd: false, agents: true, todo: false, usageCost: true, modelDetails: false, contextWarning: false } } };
|
|
150
|
+
const profile = { name: "Desk", themeName: "Light", animationPolicy: "potato" as const, banner: { showRose: false, showTextLogo: true, color: "cyan" as const }, visual: { statusPlacement: "hidden" as const, headerPlacement: "below-input" as const, density: "compact" as const, visibility: { changes: false, rdd: false, agents: true, todo: false, usageCost: true, modelDetails: false, contextWarning: false, stats: false } } };
|
|
151
151
|
const view = new VisualCustomizeView({ rows: [], theme, rowsAvailable: () => 6, requestRender: () => {}, onClose: () => {}, profiles: {
|
|
152
152
|
list: () => [profile], save: (name, replace) => { events.push(`save:${name}:${replace}`); }, apply: (name) => { events.push(`apply:${name}`); }, delete: (name) => { events.push(`delete:${name}`); }, reset: () => { events.push("reset"); },
|
|
153
153
|
} });
|
|
@@ -165,7 +165,7 @@ test("profile confirmation stays visible at six rows for every destructive or ap
|
|
|
165
165
|
|
|
166
166
|
test("profile confirmation captures selected name across catalog mutation and cancels vanished targets", async () => {
|
|
167
167
|
const events: string[] = [];
|
|
168
|
-
const base = { themeName: "Light", animationPolicy: "potato" as const, banner: { showRose: false, showTextLogo: true, color: "cyan" as const }, visual: { statusPlacement: "hidden" as const, headerPlacement: "below-input" as const, density: "compact" as const, visibility: { changes: false, rdd: false, agents: true, todo: false, usageCost: true, modelDetails: false, contextWarning: false } } };
|
|
168
|
+
const base = { themeName: "Light", animationPolicy: "potato" as const, banner: { showRose: false, showTextLogo: true, color: "cyan" as const }, visual: { statusPlacement: "hidden" as const, headerPlacement: "below-input" as const, density: "compact" as const, visibility: { changes: false, rdd: false, agents: true, todo: false, usageCost: true, modelDetails: false, contextWarning: false, stats: false } } };
|
|
169
169
|
let catalog = [{ ...base, name: "Desk" }, { ...base, name: "Mobile" }];
|
|
170
170
|
const view = new VisualCustomizeView({ rows: [], theme, rowsAvailable: () => 6, requestRender: () => {}, onClose: () => {}, profiles: {
|
|
171
171
|
list: () => catalog, save: (name, replace) => { events.push(`save:${name}:${replace}`); }, apply: (name) => { events.push(`apply:${name}`); }, delete: (name) => { events.push(`delete:${name}`); }, reset: () => { events.push("reset"); },
|
|
@@ -190,7 +190,7 @@ test("profile confirmation captures selected name across catalog mutation and ca
|
|
|
190
190
|
test("unrendered or clipped confirmations cannot be accepted", () => {
|
|
191
191
|
const events: string[] = [];
|
|
192
192
|
let height = 6;
|
|
193
|
-
const base = { name: "Desk", themeName: "Light", animationPolicy: "potato" as const, banner: { showRose: false, showTextLogo: true, color: "cyan" as const }, visual: { statusPlacement: "hidden" as const, headerPlacement: "below-input" as const, density: "compact" as const, visibility: { changes: false, rdd: false, agents: true, todo: false, usageCost: true, modelDetails: false, contextWarning: false } } };
|
|
193
|
+
const base = { name: "Desk", themeName: "Light", animationPolicy: "potato" as const, banner: { showRose: false, showTextLogo: true, color: "cyan" as const }, visual: { statusPlacement: "hidden" as const, headerPlacement: "below-input" as const, density: "compact" as const, visibility: { changes: false, rdd: false, agents: true, todo: false, usageCost: true, modelDetails: false, contextWarning: false, stats: false } } };
|
|
194
194
|
const view = new VisualCustomizeView({ rows: [], theme, rowsAvailable: () => height, requestRender: () => {}, onClose: () => {}, profiles: {
|
|
195
195
|
list: () => [base], save: () => {}, apply: () => {}, delete: () => { events.push("delete"); }, reset: () => { events.push("reset"); },
|
|
196
196
|
} });
|
|
@@ -204,7 +204,7 @@ test("unrendered or clipped confirmations cannot be accepted", () => {
|
|
|
204
204
|
|
|
205
205
|
test("profile confirmations cannot execute after an unrendered resize hides full identity and yes", () => {
|
|
206
206
|
const name = "A".repeat(64);
|
|
207
|
-
const profile = { name, themeName: "dark", animationPolicy: "quality" as const, banner: { showRose: true, showTextLogo: true, color: "pink" as const }, visual: { statusPlacement: "auto" as const, headerPlacement: "top" as const, density: "comfortable" as const, visibility: { changes: true, rdd: true, agents: true, todo: true, usageCost: true, modelDetails: true, contextWarning: true } } };
|
|
207
|
+
const profile = { name, themeName: "dark", animationPolicy: "quality" as const, banner: { showRose: true, showTextLogo: true, color: "pink" as const }, visual: { statusPlacement: "auto" as const, headerPlacement: "top" as const, density: "comfortable" as const, visibility: { changes: true, rdd: true, agents: true, todo: true, usageCost: true, modelDetails: true, contextWarning: true, stats: false } } };
|
|
208
208
|
for (const [key, action] of [["a", "apply"], ["d", "delete"], ["r", "replace"], ["z", "reset"]] as const) {
|
|
209
209
|
for (const width of [100, 36]) for (const shortHeight of [1, 2]) {
|
|
210
210
|
let height = 12;
|
|
@@ -226,7 +226,7 @@ test("profile confirmations cannot execute after an unrendered resize hides full
|
|
|
226
226
|
});
|
|
227
227
|
|
|
228
228
|
test("profile confirmation refuses a changed target identity without another render", () => {
|
|
229
|
-
let catalog = [{ name: "First", themeName: "dark", animationPolicy: "quality" as const, banner: { showRose: true, showTextLogo: true, color: "pink" as const }, visual: { statusPlacement: "auto" as const, headerPlacement: "top" as const, density: "comfortable" as const, visibility: { changes: true, rdd: true, agents: true, todo: true, usageCost: true, modelDetails: true, contextWarning: true } } }];
|
|
229
|
+
let catalog = [{ name: "First", themeName: "dark", animationPolicy: "quality" as const, banner: { showRose: true, showTextLogo: true, color: "pink" as const }, visual: { statusPlacement: "auto" as const, headerPlacement: "top" as const, density: "comfortable" as const, visibility: { changes: true, rdd: true, agents: true, todo: true, usageCost: true, modelDetails: true, contextWarning: true, stats: false } } }];
|
|
230
230
|
const effects: string[] = [];
|
|
231
231
|
const view = new VisualCustomizeView({ rows: [], theme, rowsAvailable: () => 12, requestRender: () => {}, onClose: () => {}, profiles: { list: () => catalog, save: () => {}, apply: name => { effects.push(name); }, delete: () => {}, reset: () => {} } });
|
|
232
232
|
view.handleInput("p"); view.handleInput("a");
|
|
@@ -263,7 +263,7 @@ test("main controls require a visible selected row at the last rendered width an
|
|
|
263
263
|
});
|
|
264
264
|
|
|
265
265
|
test("profile confirmation refuses same-name content drift for apply, replace and delete", () => {
|
|
266
|
-
const original = { name: "Desk", themeName: "dark", animationPolicy: "quality" as const, banner: { showRose: true, showTextLogo: true, color: "pink" as const }, visual: { statusPlacement: "auto" as const, headerPlacement: "top" as const, density: "comfortable" as const, visibility: { changes: true, rdd: true, agents: true, todo: true, usageCost: true, modelDetails: true, contextWarning: true } } };
|
|
266
|
+
const original = { name: "Desk", themeName: "dark", animationPolicy: "quality" as const, banner: { showRose: true, showTextLogo: true, color: "pink" as const }, visual: { statusPlacement: "auto" as const, headerPlacement: "top" as const, density: "comfortable" as const, visibility: { changes: true, rdd: true, agents: true, todo: true, usageCost: true, modelDetails: true, contextWarning: true, stats: false } } };
|
|
267
267
|
for (const key of ["a", "r", "d"]) {
|
|
268
268
|
let catalog = [original];
|
|
269
269
|
const effects: string[] = [];
|
|
@@ -313,7 +313,7 @@ test("category panel renders bounded wide and narrow frames with independent nav
|
|
|
313
313
|
test("long profile confirmation displays complete identity and yes instruction before accepting", async () => {
|
|
314
314
|
const name = "A".repeat(64);
|
|
315
315
|
const events: string[] = [];
|
|
316
|
-
const profile = { name, themeName: "dark", animationPolicy: "quality" as const, banner: { showRose: true, showTextLogo: true, color: "pink" as const }, visual: { statusPlacement: "auto" as const, headerPlacement: "top" as const, density: "comfortable" as const, visibility: { changes: true, rdd: true, agents: true, todo: true, usageCost: true, modelDetails: true, contextWarning: true } } };
|
|
316
|
+
const profile = { name, themeName: "dark", animationPolicy: "quality" as const, banner: { showRose: true, showTextLogo: true, color: "pink" as const }, visual: { statusPlacement: "auto" as const, headerPlacement: "top" as const, density: "comfortable" as const, visibility: { changes: true, rdd: true, agents: true, todo: true, usageCost: true, modelDetails: true, contextWarning: true, stats: false } } };
|
|
317
317
|
let height = 8;
|
|
318
318
|
const view = new VisualCustomizeView({ rows: [], theme, rowsAvailable: () => height, requestRender: () => {}, onClose: () => {}, profiles: { list: () => [profile], save: () => {}, apply: value => { events.push(value); }, delete: () => {}, reset: () => {} } });
|
|
319
319
|
view.handleInput("p");
|
|
@@ -492,6 +492,114 @@ test("inline field submits a visible value and drops invisible resizes without w
|
|
|
492
492
|
assert.deepEqual(submitted, ["/local/a.wav"], "an Enter that cannot see the field must not submit");
|
|
493
493
|
});
|
|
494
494
|
|
|
495
|
+
test("inline audio paths wrap fully at 80 columns and submit their exact value", async () => {
|
|
496
|
+
const prompt = "Local audio path (WAV/OGG/FLAC, absolute, no URLs)";
|
|
497
|
+
for (const length of [23, 24, 103, 175]) {
|
|
498
|
+
const value = `C:/${"a".repeat(length - 7)}.wav`;
|
|
499
|
+
assert.equal(value.length, length);
|
|
500
|
+
const submitted: string[] = [];
|
|
501
|
+
const view = inlineView(async inline => {
|
|
502
|
+
const result = await inline.input({ prompt, value: "" });
|
|
503
|
+
if (result !== undefined) submitted.push(result);
|
|
504
|
+
});
|
|
505
|
+
view.render(80); view.handleInput("\r"); await tick();
|
|
506
|
+
view.handleInput(`\x1b[200~${value}\x1b[201~`);
|
|
507
|
+
const frame = view.render(80);
|
|
508
|
+
const content = frame.map(line => line.slice(2, -2).trimEnd()).join("");
|
|
509
|
+
assert.ok(content.includes(`${prompt}: ${value}▏`), "every input character and cursor must be visible in order");
|
|
510
|
+
assert.ok(frame.length <= 12);
|
|
511
|
+
assert.ok(frame.every(line => visibleWidth(line) === 80));
|
|
512
|
+
assert.doesNotMatch(frame.join("\n"), /Value too wide|Needs \d+ columns/);
|
|
513
|
+
assert.deepEqual(submitted, [], "rendering must not submit");
|
|
514
|
+
view.handleInput("\r"); await tick();
|
|
515
|
+
assert.deepEqual(submitted, [value]);
|
|
516
|
+
}
|
|
517
|
+
});
|
|
518
|
+
|
|
519
|
+
test("inline overflow reports sufficient room, rejects Enter and remains editable", async () => {
|
|
520
|
+
const submitted: string[] = [];
|
|
521
|
+
const value = "a".repeat(222); // Path: + cursor makes 229 cells; three 76-cell lines hold 228.
|
|
522
|
+
const view = inlineView(async inline => {
|
|
523
|
+
const result = await inline.input({ prompt: "Path", value });
|
|
524
|
+
if (result !== undefined) submitted.push(result);
|
|
525
|
+
});
|
|
526
|
+
view.render(80); view.handleInput("\r"); await tick();
|
|
527
|
+
const frame = view.render(80);
|
|
528
|
+
assert.match(frame.join("\n"), /Needs 233 columns for one line · Esc cancel/);
|
|
529
|
+
assert.ok(frame.every(line => visibleWidth(line) === 80));
|
|
530
|
+
assert.ok(frame.length <= 12);
|
|
531
|
+
view.handleInput("\r"); await tick();
|
|
532
|
+
assert.deepEqual(submitted, []);
|
|
533
|
+
view.handleInput("\x7f");
|
|
534
|
+
view.render(80); view.handleInput("\r"); await tick();
|
|
535
|
+
assert.deepEqual(submitted, [value.slice(0, -1)]);
|
|
536
|
+
});
|
|
537
|
+
|
|
538
|
+
test("wrapped inline values refuse a height shrink before Enter and submit after recovery", async () => {
|
|
539
|
+
let height = 12;
|
|
540
|
+
const submitted: string[] = [];
|
|
541
|
+
const value = "x".repeat(100);
|
|
542
|
+
const view = inlineView(async inline => {
|
|
543
|
+
const result = await inline.input({ prompt: "Path", value });
|
|
544
|
+
if (result !== undefined) submitted.push(result);
|
|
545
|
+
}, { rowsAvailable: () => height });
|
|
546
|
+
view.render(80); view.handleInput("\r"); await tick();
|
|
547
|
+
view.render(80);
|
|
548
|
+
height = 8;
|
|
549
|
+
view.handleInput("\r"); await tick();
|
|
550
|
+
assert.deepEqual(submitted, [], "Enter must recheck live height, not the previous three-line render");
|
|
551
|
+
const shortFrame = view.render(80);
|
|
552
|
+
assert.ok(shortFrame.length <= 8);
|
|
553
|
+
assert.match(shortFrame.join("\n"), /Needs 111 columns for one line/);
|
|
554
|
+
height = 12;
|
|
555
|
+
view.render(80); view.handleInput("\r"); await tick();
|
|
556
|
+
assert.deepEqual(submitted, [value]);
|
|
557
|
+
});
|
|
558
|
+
|
|
559
|
+
test("inline wrapping keeps wide graphemes intact and single-line submission unchanged", async () => {
|
|
560
|
+
for (const value of ["/local/a.wav", "界👩💻e\u0301".repeat(16)]) {
|
|
561
|
+
const submitted: string[] = [];
|
|
562
|
+
const view = inlineView(async inline => {
|
|
563
|
+
const result = await inline.input({ prompt: "Path", value });
|
|
564
|
+
if (result !== undefined) submitted.push(result);
|
|
565
|
+
});
|
|
566
|
+
view.render(80); view.handleInput("\r"); await tick();
|
|
567
|
+
const frame = view.render(80);
|
|
568
|
+
assert.ok(frame.every(line => visibleWidth(line) === 80));
|
|
569
|
+
const content = frame.map(line => line.slice(2, -2).trimEnd()).join("");
|
|
570
|
+
assert.ok(content.includes(`Path: ${value}▏`));
|
|
571
|
+
view.handleInput("\r"); await tick();
|
|
572
|
+
assert.deepEqual(submitted, [value]);
|
|
573
|
+
}
|
|
574
|
+
});
|
|
575
|
+
|
|
576
|
+
test("inline key capture returns the next raw key, and Esc cancels it without closing the card", async () => {
|
|
577
|
+
const seen: (string | undefined)[] = [];
|
|
578
|
+
let closed = false;
|
|
579
|
+
const view = inlineView(async inline => { seen.push(await inline.capture("Press the new key for Command palette")); }, { onClose: () => { closed = true; } });
|
|
580
|
+
view.render(76);
|
|
581
|
+
view.handleInput("\r");
|
|
582
|
+
await tick();
|
|
583
|
+
assert.match(view.render(76).join("\n"), /Press the new key for Command palette · Esc cancel/);
|
|
584
|
+
view.handleInput("\x1bj");
|
|
585
|
+
await tick();
|
|
586
|
+
assert.deepEqual(seen, ["\x1bj"]);
|
|
587
|
+
view.handleInput("\r");
|
|
588
|
+
await tick();
|
|
589
|
+
view.handleInput("\x1b");
|
|
590
|
+
await tick();
|
|
591
|
+
assert.deepEqual(seen, ["\x1bj", undefined]);
|
|
592
|
+
assert.equal(closed, false, "Esc only cancels the capture");
|
|
593
|
+
view.handleInput("\x1b");
|
|
594
|
+
assert.equal(closed, true, "a second Esc closes the card as usual");
|
|
595
|
+
});
|
|
596
|
+
|
|
597
|
+
test("a Keymaps row shows its own footer hint", () => {
|
|
598
|
+
const view = new VisualCustomizeView({ rows: [{ category: "Keymaps", label: "Command palette: alt+k", keyhint: "Enter assign · ⌫ disable · r default · Esc close", action: () => {} }], theme, rowsAvailable: () => 14, requestRender: () => {}, onClose: () => {} });
|
|
599
|
+
view.handleInput("\r");
|
|
600
|
+
assert.match(view.render(90).join("\n"), /Enter assign · ⌫ disable · r default · Esc close/);
|
|
601
|
+
});
|
|
602
|
+
|
|
495
603
|
test("inline confirmation accepts only a fully visible yes and resolves false otherwise", async () => {
|
|
496
604
|
let height = 12;
|
|
497
605
|
const seen: boolean[] = [];
|
|
@@ -694,3 +802,140 @@ test("the audio footer drops f WAV when the selected row has no keyhint and adve
|
|
|
694
802
|
const advanced = view.render(80).join("\n");
|
|
695
803
|
assert.match(advanced, /Tab panes · Enter change · f WAV · p test · Esc close/, "a row with a keyhint advertises the WAV key");
|
|
696
804
|
});
|
|
805
|
+
|
|
806
|
+
function settingsView(applied: string[] = []) {
|
|
807
|
+
const state = { density: "comfortable", status: "auto" };
|
|
808
|
+
const choice = (setting: string, key: "density" | "status", value: string, hint: string): CustomizeRow => ({
|
|
809
|
+
category: "Layout",
|
|
810
|
+
label: () => `${setting}: ${value}${state[key] === value ? " (current)" : ""}`,
|
|
811
|
+
choice: { setting, value, current: () => state[key] === value, hint },
|
|
812
|
+
preview: () => ({ title: `${setting} · ${value}`, sample: `line one ${value}\nline two` }),
|
|
813
|
+
action: () => { state[key] = value; applied.push(`${setting}=${value}`); },
|
|
814
|
+
});
|
|
815
|
+
const rows: CustomizeRow[] = [
|
|
816
|
+
...["auto", "right", "bottom"].map((value) => choice("Status placement", "status", value, "Where Status lives")),
|
|
817
|
+
...["comfortable", "compact", "minimal"].map((value) => choice("Density", "density", value, "Space between sections")),
|
|
818
|
+
{ category: "Layout", label: "Reset layout", action: () => { applied.push("reset"); } },
|
|
819
|
+
];
|
|
820
|
+
const view = new VisualCustomizeView({ rows, theme, requestRender() {}, rowsAvailable: () => 24, onClose() {} });
|
|
821
|
+
// The user sees the card before the first key.
|
|
822
|
+
view.render(100);
|
|
823
|
+
view.handleInput("\x1b[C");
|
|
824
|
+
return { view, state, applied };
|
|
825
|
+
}
|
|
826
|
+
const settle = () => new Promise((resolve) => setTimeout(resolve, 0));
|
|
827
|
+
|
|
828
|
+
test("choices of one setting share a line: the current one is marked, without repeating the setting name", () => {
|
|
829
|
+
const { view } = settingsView();
|
|
830
|
+
const lines = view.render(100);
|
|
831
|
+
const status = lines.filter((line) => line.includes("Status placement") && /[●○]/.test(line));
|
|
832
|
+
assert.equal(status.length, 1, "one line for the setting");
|
|
833
|
+
assert.match(status[0]!, /▸ Status placement\s+● auto\s+○ right\s+○ bottom/);
|
|
834
|
+
assert.match(lines.find((line) => line.includes("Density"))!, /Density\s+● comfortable\s+○ compact\s+○ minimal/);
|
|
835
|
+
assert.ok(lines.some((line) => line.includes("Reset layout")), "plain rows stay rows");
|
|
836
|
+
assert.ok(!lines.join("\n").includes("(current)"), "no (current) suffix");
|
|
837
|
+
assert.ok(lines.some((line) => line.includes("Layout · 1/3")), "the position counts settings, not choices");
|
|
838
|
+
assert.ok(lines.some((line) => line.includes("Status placement — Where Status lives")), "the focused setting is described");
|
|
839
|
+
assert.ok(lines.some((line) => line.includes("line one auto")) && lines.some((line) => line.includes("line two")), "multi-line previews keep every line");
|
|
840
|
+
for (const line of lines) assert.equal(visibleWidth(line), 100);
|
|
841
|
+
});
|
|
842
|
+
|
|
843
|
+
test("↑/↓ move between settings; ←/→ change the value and apply it at once; ← on the first choice returns to the categories", async () => {
|
|
844
|
+
const { view, state, applied } = settingsView();
|
|
845
|
+
view.handleInput("\x1b[C");
|
|
846
|
+
await settle();
|
|
847
|
+
assert.equal(state.status, "right");
|
|
848
|
+
assert.deepEqual(applied, ["Status placement=right"]);
|
|
849
|
+
view.handleInput("\x1b[C");
|
|
850
|
+
await settle();
|
|
851
|
+
view.handleInput("\x1b[C");
|
|
852
|
+
await settle();
|
|
853
|
+
assert.equal(state.status, "bottom", "→ stops at the last choice");
|
|
854
|
+
assert.equal(applied.length, 2);
|
|
855
|
+
view.handleInput("\x1b[B");
|
|
856
|
+
assert.match(view.render(100).find((line) => line.includes("Density"))!, /▸ Density/, "↓ goes to the next setting, not the next choice");
|
|
857
|
+
view.handleInput("\x1b[D");
|
|
858
|
+
await settle();
|
|
859
|
+
assert.equal(state.density, "comfortable", "← on the first choice applies nothing");
|
|
860
|
+
assert.ok(view.render(100).some((line) => /▸ Layout/.test(line)), "and returns focus to the categories");
|
|
861
|
+
view.handleInput("\x1b[C");
|
|
862
|
+
view.handleInput("\x1b[B");
|
|
863
|
+
view.handleInput("\r");
|
|
864
|
+
await settle();
|
|
865
|
+
assert.equal(applied.at(-1), "reset", "plain rows still apply on Enter");
|
|
866
|
+
});
|
|
867
|
+
|
|
868
|
+
test("focus() selects a row by label without applying it", () => {
|
|
869
|
+
const { view, applied } = settingsView();
|
|
870
|
+
assert.equal(view.focus("Density: minimal"), true);
|
|
871
|
+
assert.deepEqual(applied, []);
|
|
872
|
+
assert.match(view.render(100).find((line) => line.includes("Density") && /[●○›]/.test(line))!, /▸ Density\s+● comfortable\s+○ compact\s+› minimal/, "the cursor shows where it is when it is not on the current value");
|
|
873
|
+
assert.equal(view.focus("No such row"), false);
|
|
874
|
+
});
|
|
875
|
+
|
|
876
|
+
test("a setting too wide for the pane shows only the selected choice with arrows", () => {
|
|
877
|
+
const { view } = settingsView();
|
|
878
|
+
const line = view.render(44).find((row) => row.includes("Status placement"))!;
|
|
879
|
+
assert.match(line, /‹ auto › 1\/3/);
|
|
880
|
+
assert.equal(visibleWidth(line), 44);
|
|
881
|
+
});
|
|
882
|
+
|
|
883
|
+
test("arrows never apply a setting while the card is too small to show its controls", async () => {
|
|
884
|
+
const applied: string[] = [];
|
|
885
|
+
let rows = 3;
|
|
886
|
+
const view = new VisualCustomizeView({
|
|
887
|
+
rows: [
|
|
888
|
+
{ category: "Layout", label: "Status: auto", choice: { setting: "Status", value: "auto", current: () => true }, action: () => { applied.push("auto"); } },
|
|
889
|
+
{ category: "Layout", label: "Status: right", choice: { setting: "Status", value: "right", current: () => false }, action: () => { applied.push("right"); } },
|
|
890
|
+
],
|
|
891
|
+
theme, requestRender() {}, rowsAvailable: () => rows, onClose() {},
|
|
892
|
+
});
|
|
893
|
+
view.handleInput("\x1b[C");
|
|
894
|
+
assert.deepEqual(view.render(90), ["Customization", "Enlarge terminal"]);
|
|
895
|
+
view.handleInput("\x1b[C");
|
|
896
|
+
await settle();
|
|
897
|
+
assert.deepEqual(applied, [], "→ applies nothing behind 'Enlarge terminal'");
|
|
898
|
+
rows = 24;
|
|
899
|
+
view.render(90);
|
|
900
|
+
view.handleInput("\x1b[C");
|
|
901
|
+
await settle();
|
|
902
|
+
assert.deepEqual(applied, ["right"], "once the controls show, → applies");
|
|
903
|
+
view.handleInput("\t");
|
|
904
|
+
assert.match(view.render(90).join("\n"), /↑\/↓ categories|→ open|Tab panes/, "the categories pane does not advertise setting keys");
|
|
905
|
+
assert.doesNotMatch(view.render(90).join("\n"), /←\/→ change/);
|
|
906
|
+
});
|
|
907
|
+
|
|
908
|
+
|
|
909
|
+
test("deferred choices share Layout's line without applying permissions on arrows", async () => {
|
|
910
|
+
const writes: string[] = [];
|
|
911
|
+
let current = "normal";
|
|
912
|
+
const rows: CustomizeRow[] = ["normal", "auto", "yolo", "super-yolo"].map(value => ({
|
|
913
|
+
category: "Editor", label: `Session permissions: ${value}`,
|
|
914
|
+
choice: { setting: "Session permissions", value, current: () => current === value, applyOnMove: false },
|
|
915
|
+
preview: () => ({ title: value, sample: value === "auto" ? "extra inference cost; hard safety and consent remain" : "session only" }),
|
|
916
|
+
action: () => { current = value; writes.push(value); },
|
|
917
|
+
}));
|
|
918
|
+
const view = new VisualCustomizeView({ rows, theme, requestRender() {}, rowsAvailable: () => 24, onClose() {} });
|
|
919
|
+
view.render(140); view.handleInput("\x1b[C"); view.handleInput("\x1b[C");
|
|
920
|
+
await settle();
|
|
921
|
+
assert.equal(current, "normal"); assert.deepEqual(writes, [], "navigation writes nothing");
|
|
922
|
+
const lines = view.render(140);
|
|
923
|
+
assert.equal(lines.filter(line => line.includes("Session permissions") && /[●○›]/.test(line)).length, 1);
|
|
924
|
+
assert.match(lines.join("\n"), /● normal.*› auto/);
|
|
925
|
+
assert.match(lines.join("\n"), /extra inference cost; hard safety and consent remain/);
|
|
926
|
+
assert.match(lines.join("\n"), /Enter apply/);
|
|
927
|
+
view.handleInput("\r"); await settle();
|
|
928
|
+
assert.equal(current, "auto"); assert.deepEqual(writes, ["auto"]);
|
|
929
|
+
view.handleInput("\x1b[C"); view.handleInput("\x1b"); await settle();
|
|
930
|
+
assert.deepEqual(writes, ["auto"], "canceling a different preview grants nothing");
|
|
931
|
+
});
|
|
932
|
+
|
|
933
|
+
test("inline notification choices retain their sound keys instead of advertising profiles", () => {
|
|
934
|
+
const view = new VisualCustomizeView({ rows: [{ category: "Notifications", label: "Success",
|
|
935
|
+
choice: { setting: "Success", value: "silence", current: () => true, applyOnMove: false },
|
|
936
|
+
keyhint: "←/→ choose · Enter apply · f sound · p test · Esc close", action() {},
|
|
937
|
+
}], theme, requestRender() {}, rowsAvailable: () => 24, onClose() {} });
|
|
938
|
+
view.render(120); view.handleInput("\x1b[C");
|
|
939
|
+
const rendered = view.render(120).join("\n");
|
|
940
|
+
assert.match(rendered, /f sound · p test/); assert.doesNotMatch(rendered, /p profiles/);
|
|
941
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import test from "node:test";
|
|
3
|
+
import { visibleWidth } from "@earendil-works/pi-tui";
|
|
4
|
+
import { layoutSchematic } from "../lib/visual-layout-preview.ts";
|
|
5
|
+
import { applyVisualPreset, DEFAULT_VISUAL_SETTINGS, VISUAL_PRESET } from "../lib/visual-customization-policy.ts";
|
|
6
|
+
|
|
7
|
+
test("the layout schematic draws where the header, Status and sections go", () => {
|
|
8
|
+
const neutral = layoutSchematic(DEFAULT_VISUAL_SETTINGS).split("\n");
|
|
9
|
+
assert.equal(neutral.length, 4);
|
|
10
|
+
for (const line of neutral) assert.equal(visibleWidth(line), visibleWidth(neutral[0]!), "a closed box");
|
|
11
|
+
assert.match(neutral[0]!, /^┌─ header ─+┬─ Status ─+┐$/);
|
|
12
|
+
assert.match(neutral.join("\n"), /todos/);
|
|
13
|
+
assert.doesNotMatch(neutral.join("\n"), /stats/);
|
|
14
|
+
assert.match(neutral[3]!, /bar under 140 cols/, "auto explains its fallback");
|
|
15
|
+
|
|
16
|
+
const power = layoutSchematic(applyVisualPreset(DEFAULT_VISUAL_SETTINGS, VISUAL_PRESET.POWER_USER)).split("\n");
|
|
17
|
+
assert.match(power.join("\n"), /stats/, "Power user shows its Stats section");
|
|
18
|
+
|
|
19
|
+
const light = layoutSchematic(applyVisualPreset(DEFAULT_VISUAL_SETTINGS, VISUAL_PRESET.LIGHT)).split("\n");
|
|
20
|
+
assert.doesNotMatch(light.join("\n"), /Status ─|todos/, "Light has no rail");
|
|
21
|
+
assert.match(light[3]!, /status bar/);
|
|
22
|
+
|
|
23
|
+
const below = layoutSchematic({ ...DEFAULT_VISUAL_SETTINGS, headerPlacement: "below-input", statusPlacement: "hidden" }).split("\n");
|
|
24
|
+
assert.doesNotMatch(below[0]!, /header/);
|
|
25
|
+
assert.match(below.join("\n"), /› input · header/);
|
|
26
|
+
assert.doesNotMatch(below.join("\n"), /Status|status bar/, "hidden shows no Status at all");
|
|
27
|
+
for (const line of below) assert.equal(visibleWidth(line), visibleWidth(below[0]!));
|
|
28
|
+
});
|
|
@@ -2,9 +2,10 @@ import assert from "node:assert/strict";
|
|
|
2
2
|
import { spawn } from "node:child_process";
|
|
3
3
|
import { EventEmitter } from "node:events";
|
|
4
4
|
import { mkdtemp, mkdir, readFile, stat } from "node:fs/promises";
|
|
5
|
-
import { createConnection } from "node:net";
|
|
5
|
+
import { createConnection, createServer } from "node:net";
|
|
6
6
|
import os from "node:os";
|
|
7
7
|
import { dirname, join } from "node:path";
|
|
8
|
+
import { createInterface } from "node:readline";
|
|
8
9
|
import test from "node:test";
|
|
9
10
|
import { fileURLToPath } from "node:url";
|
|
10
11
|
import { FIXED_WINDOWS_POWERSHELL, WindowsActiveSessionClient, WindowsActiveSessionListener, WindowsSessionPresenceRegistry, WindowsSessionRegistryPhaseSequence, type WindowsSessionRegistryPhaseEvent, parseWindowsHostFrame } from "../lib/windows-session-transport.ts";
|
|
@@ -433,6 +434,7 @@ async function openInitializedHelper(agentHome: string, options: Readonly<{ diag
|
|
|
433
434
|
shutdown: () => request("shutdown"),
|
|
434
435
|
presence: (operation: "record" | "publish" | "list" | "resolve" | "remove" | "listen" | "stop-listener", values: Record<string, unknown> = {}) => request(operation, values),
|
|
435
436
|
invalidStartSchema: async () => { child.stdin.write(`${JSON.stringify({ requestId: `invalid-${frames.length + 1}`, operation: "start", extra: true })}\n`); await exitWithin(); },
|
|
437
|
+
terminate: async () => { child.kill(); assert.equal(await waitForChildClose(lifecycle, deadlines.killMs), true); return lifecycle.exitCode; },
|
|
436
438
|
closeInput: closeWithStreamCheck,
|
|
437
439
|
};
|
|
438
440
|
}
|
|
@@ -1067,6 +1069,12 @@ test("Windows-native presence publishes, resolves, lists, and removes only its o
|
|
|
1067
1069
|
const agentHome = join(root, "profile", "agent");
|
|
1068
1070
|
await mkdir(join(agentHome, "gentle-agents"), { recursive: true });
|
|
1069
1071
|
const held = await openInitializedHelper(agentHome, { diagnostics });
|
|
1072
|
+
const pipes: ReturnType<typeof createServer>[] = [];
|
|
1073
|
+
const listen = async (endpoint: string) => {
|
|
1074
|
+
const pipe = createServer((socket) => socket.destroy());
|
|
1075
|
+
pipes.push(pipe);
|
|
1076
|
+
await new Promise<void>((resolve, reject) => { pipe.once("error", reject); pipe.listen(endpoint, resolve); });
|
|
1077
|
+
};
|
|
1070
1078
|
try {
|
|
1071
1079
|
const recorded = await held.presence("record", { sessionId: "session-a", createdAt: 1 });
|
|
1072
1080
|
assert.equal(recorded.ok, true);
|
|
@@ -1074,12 +1082,14 @@ test("Windows-native presence publishes, resolves, lists, and removes only its o
|
|
|
1074
1082
|
assert.deepEqual(Object.keys(record).sort(), ["createdAt", "endpoint", "sessionId", "version"]);
|
|
1075
1083
|
assert.equal(record.sessionId, "session-a");
|
|
1076
1084
|
assert.match(record.endpoint as string, /^\\\\\.\\pipe\\gentle-pi-[0-9a-f]{32}$/);
|
|
1085
|
+
await listen(record.endpoint as string);
|
|
1077
1086
|
assert.equal((await held.presence("publish", { record })).ok, true);
|
|
1078
1087
|
assert.equal((await held.presence("publish", { record })).error, "busy", "no-replace collision preserves the published record");
|
|
1079
1088
|
assert.deepEqual(requirePublicPresenceResult(await held.presence("list")), { records: [record] }, "an omitted excludeSessionId lists one record");
|
|
1080
1089
|
const secondReply = await held.presence("record", { sessionId: "session-b", createdAt: 2 });
|
|
1081
1090
|
assert.equal(secondReply.ok, true);
|
|
1082
1091
|
const secondRecord = secondReply.result as Record<string, unknown>;
|
|
1092
|
+
await listen(secondRecord.endpoint as string);
|
|
1083
1093
|
assert.equal((await held.presence("publish", { record: secondRecord })).ok, true);
|
|
1084
1094
|
assert.deepEqual(requirePublicPresenceResult(await held.presence("list")), { records: [record, secondRecord] }, "an omitted excludeSessionId lists multiple records");
|
|
1085
1095
|
assert.deepEqual(requirePublicPresenceResult(await held.presence("list", { excludeSessionId: "session-b" })), { records: [record] }, "a valid excludeSessionId is honored");
|
|
@@ -1092,7 +1102,70 @@ test("Windows-native presence publishes, resolves, lists, and removes only its o
|
|
|
1092
1102
|
assert.deepEqual(requirePublicPresenceResult(await held.presence("list")), { records: [record] }, "the replacement retains the public record and accepted ACL");
|
|
1093
1103
|
assert.equal((await held.presence("remove", { record })).error, "unsafe", "a replacement with identical public bytes and ACL is not owned");
|
|
1094
1104
|
await stat(publishedPath);
|
|
1095
|
-
} finally {
|
|
1105
|
+
} finally {
|
|
1106
|
+
await held.closeInput();
|
|
1107
|
+
await Promise.all(pipes.map((pipe) => new Promise<void>((resolve) => pipe.close(() => resolve()))));
|
|
1108
|
+
}
|
|
1109
|
+
});
|
|
1110
|
+
|
|
1111
|
+
test("Windows-native discovery reclaims an orphan without deleting a resumed activation", { skip: process.platform !== "win32", timeout: 40_000 }, async (t) => {
|
|
1112
|
+
const root = await mkdtemp(join(os.tmpdir(), "gentle-pi-stale-presence-"));
|
|
1113
|
+
const agentHome = join(root, "profile", "agent");
|
|
1114
|
+
await mkdir(join(agentHome, "gentle-agents"), { recursive: true });
|
|
1115
|
+
const previous = await openInitializedHelper(agentHome, { diagnostics: t });
|
|
1116
|
+
try {
|
|
1117
|
+
const old = requirePublicPresenceResult(await previous.presence("listen", { sessionId: "resumed", createdAt: 1 })) as Record<string, unknown>;
|
|
1118
|
+
// Forced termination is a test fixture for an orphan, not a claim about
|
|
1119
|
+
// the original event in issue #1846.
|
|
1120
|
+
assert.notEqual(await previous.terminate(), 0);
|
|
1121
|
+
assert.equal(await probeWindowsNativeEndpoint(old.endpoint as string), "ENOENT");
|
|
1122
|
+
await withInitializedHelpers([agentHome, agentHome], async ([resumed, observer]) => {
|
|
1123
|
+
assert.equal((requirePublicPresenceResult(await observer.enumerate()) as { entries: number }).entries, 1);
|
|
1124
|
+
const current = requirePublicPresenceResult(await resumed.presence("listen", { sessionId: "resumed", createdAt: 2 })) as Record<string, unknown>;
|
|
1125
|
+
assert.notEqual(current.endpoint, old.endpoint);
|
|
1126
|
+
assert.deepEqual(requirePublicPresenceResult(await observer.presence("list")), { records: [current] });
|
|
1127
|
+
assert.equal((requirePublicPresenceResult(await observer.enumerate()) as { entries: number }).entries, 1, "the old identity is reclaimed, not merely hidden by the newer record");
|
|
1128
|
+
assert.deepEqual(requirePublicPresenceResult(await observer.presence("resolve", { sessionId: "resumed" })), current);
|
|
1129
|
+
assert.equal((await resumed.presence("stop-listener", { record: current })).ok, true);
|
|
1130
|
+
assert.deepEqual(requirePublicPresenceResult(await observer.presence("list")), { records: [] }, "the old activation must not reappear after clean shutdown");
|
|
1131
|
+
assert.equal((await observer.presence("resolve", { sessionId: "resumed" })).error, "not_found");
|
|
1132
|
+
assert.equal((requirePublicPresenceResult(await observer.enumerate()) as { entries: number }).entries, 0);
|
|
1133
|
+
}, { diagnostics: t });
|
|
1134
|
+
} finally { await previous.closeInput(); }
|
|
1135
|
+
});
|
|
1136
|
+
|
|
1137
|
+
test("Windows-native discovery preserves a busy endpoint without connecting or mutating its record", { skip: process.platform !== "win32", timeout: 30_000 }, async (t) => {
|
|
1138
|
+
const root = await mkdtemp(join(os.tmpdir(), "gentle-pi-busy-presence-"));
|
|
1139
|
+
const agentHome = join(root, "profile", "agent");
|
|
1140
|
+
await mkdir(join(agentHome, "gentle-agents"), { recursive: true });
|
|
1141
|
+
await withInitializedHelpers([agentHome, agentHome], async ([owner, observer]) => {
|
|
1142
|
+
const record = requirePublicPresenceResult(await owner.presence("listen", { sessionId: "busy", createdAt: 1 })) as Record<string, unknown>;
|
|
1143
|
+
const probe = await openWindowsNativeAvailabilityProbe(record.endpoint as string);
|
|
1144
|
+
const sockets: Awaited<ReturnType<typeof openWindowsNativePipe>>[] = [];
|
|
1145
|
+
const assertBusy = async () => {
|
|
1146
|
+
// WaitNamedPipe times out with ERROR_SEM_TIMEOUT when all instances are occupied.
|
|
1147
|
+
assert.deepEqual(await probe.check(), { available: false, code: 121 });
|
|
1148
|
+
};
|
|
1149
|
+
try {
|
|
1150
|
+
assert.deepEqual(await probe.check(), { available: true, code: 0 });
|
|
1151
|
+
for (let index = 0; index < 4; index++) sockets.push(await openWindowsNativePipe(record.endpoint as string));
|
|
1152
|
+
await assertBusy();
|
|
1153
|
+
const before = requirePublicPresenceResult(await observer.enumerate());
|
|
1154
|
+
await assertBusy();
|
|
1155
|
+
assert.deepEqual(requirePublicPresenceResult(await observer.presence("list")), { records: [record] });
|
|
1156
|
+
await assertBusy();
|
|
1157
|
+
assert.deepEqual(requirePublicPresenceResult(await observer.presence("resolve", { sessionId: "busy" })), record);
|
|
1158
|
+
await assertBusy();
|
|
1159
|
+
assert.deepEqual(requirePublicPresenceResult(await observer.enumerate()), before);
|
|
1160
|
+
await assertBusy();
|
|
1161
|
+
assert.equal((await owner.presence("stop-listener", { record })).ok, true);
|
|
1162
|
+
assert.deepEqual(await probe.check(), { available: false, code: 2 });
|
|
1163
|
+
assert.deepEqual(requirePublicPresenceResult(await observer.presence("list")), { records: [] });
|
|
1164
|
+
} finally {
|
|
1165
|
+
for (const socket of sockets) socket.destroy();
|
|
1166
|
+
await probe.close();
|
|
1167
|
+
}
|
|
1168
|
+
}, { diagnostics: t });
|
|
1096
1169
|
});
|
|
1097
1170
|
|
|
1098
1171
|
test("Windows-native owned publication removes its unchanged rooted record", { skip: process.platform !== "win32", timeout: 30_000 }, async (t) => {
|
|
@@ -1498,6 +1571,36 @@ test("packed lifecycle source uses the exported phase sequence", async (t) => {
|
|
|
1498
1571
|
assert.doesNotMatch(source, /Object\.defineProperty\(candidate|Host\.prototype|windowsRegistryObservation\.restore|let expected = "start"/);
|
|
1499
1572
|
});
|
|
1500
1573
|
|
|
1574
|
+
async function openWindowsNativeAvailabilityProbe(endpoint: string) {
|
|
1575
|
+
const script = fileURLToPath(new URL("fixtures/windows-pipe-availability.ps1", import.meta.url));
|
|
1576
|
+
const child = spawn(FIXED_WINDOWS_POWERSHELL, ["-NoLogo", "-NoProfile", "-NonInteractive", "-File", script, "-Endpoint", endpoint], { shell: false, windowsHide: true, stdio: ["pipe", "pipe", "pipe"] });
|
|
1577
|
+
const lifecycle = observeChildLifecycle(child);
|
|
1578
|
+
const output = createInterface({ input: child.stdout, crlfDelay: Infinity });
|
|
1579
|
+
const lines = output[Symbol.asyncIterator]();
|
|
1580
|
+
child.stderr.resume();
|
|
1581
|
+
const next = async (deadlineMs: number) => {
|
|
1582
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
1583
|
+
try {
|
|
1584
|
+
const line = await Promise.race([
|
|
1585
|
+
lines.next(),
|
|
1586
|
+
new Promise<never>((_, reject) => { timer = setTimeout(() => reject(new Error("Windows native availability probe did not reply")), deadlineMs); }),
|
|
1587
|
+
]);
|
|
1588
|
+
assert.equal(line.done, false, "the availability probe must return a result");
|
|
1589
|
+
return JSON.parse(line.value!) as Record<string, unknown>;
|
|
1590
|
+
} finally { clearTimeout(timer); }
|
|
1591
|
+
};
|
|
1592
|
+
const close = async () => {
|
|
1593
|
+
try {
|
|
1594
|
+
child.stdin.end();
|
|
1595
|
+
await settleOwnedChild(child, lifecycle, { terminateMs: 2_500, killMs: 2_500 });
|
|
1596
|
+
assert.equal(lifecycle.exitCode, 0, "the availability probe must exit cleanly");
|
|
1597
|
+
} finally { output.close(); }
|
|
1598
|
+
};
|
|
1599
|
+
try { assert.deepEqual(await next(25_000), { ready: true }); }
|
|
1600
|
+
catch (error) { try { await close(); } catch { /* preserve the startup failure */ } throw error; }
|
|
1601
|
+
return { check: async () => { child.stdin.write("probe\n"); return next(3_000); }, close };
|
|
1602
|
+
}
|
|
1603
|
+
|
|
1501
1604
|
function openWindowsNativePipe(endpoint: string) {
|
|
1502
1605
|
return new Promise<ReturnType<typeof createConnection>>((resolve, reject) => {
|
|
1503
1606
|
const socket = createConnection(endpoint);
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import test, { after, before } from "node:test";
|
|
3
|
+
import { mkdir, mkdtemp, rm } from "node:fs/promises";
|
|
4
|
+
import { tmpdir } from "node:os";
|
|
5
|
+
import { join } from "node:path";
|
|
6
|
+
import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
7
|
+
import { createGentleAiExtension } from "../extensions/gentle-ai.ts";
|
|
8
|
+
|
|
9
|
+
// These assertions cover delivered instructions, not an agent's execution of them.
|
|
10
|
+
let root: string;
|
|
11
|
+
let cwd: string;
|
|
12
|
+
let env: NodeJS.ProcessEnv;
|
|
13
|
+
const previous = new Map<string, string | undefined>();
|
|
14
|
+
before(async () => {
|
|
15
|
+
root = await mkdtemp(join(tmpdir(), "gentle-work-continuity-"));
|
|
16
|
+
cwd = join(root, "project");
|
|
17
|
+
const home = join(root, "home");
|
|
18
|
+
await mkdir(cwd);
|
|
19
|
+
await mkdir(home);
|
|
20
|
+
env = { HOME: home, USERPROFILE: home, GENTLE_PI_CONFIG_HOME: join(home, "config"), GENTLE_PI_AGENT_HOME: join(home, "agents"), PI_CODING_AGENT_DIR: join(home, "pi"), XDG_CONFIG_HOME: join(home, "xdg") };
|
|
21
|
+
for (const [key, value] of Object.entries(env)) {
|
|
22
|
+
previous.set(key, process.env[key]);
|
|
23
|
+
process.env[key] = value;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
after(async () => {
|
|
27
|
+
for (const [key, value] of previous) {
|
|
28
|
+
if (value === undefined) delete process.env[key];
|
|
29
|
+
else process.env[key] = value;
|
|
30
|
+
}
|
|
31
|
+
if (root) await rm(root, { recursive: true, force: true });
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
async function delivered(): Promise<string> {
|
|
35
|
+
const handlers = new Map<string, (event: unknown, ctx: ExtensionContext) => unknown>();
|
|
36
|
+
const pi = { on(name: string, handler: (event: unknown, ctx: ExtensionContext) => unknown) { handlers.set(name, handler); }, events: { emit() {} }, registerCommand() {}, registerTool() {} } as unknown as ExtensionAPI;
|
|
37
|
+
createGentleAiExtension({ nativeReviewCli: null, processEnv: { ...env, GENTLE_PI_AGENTS_CHILD: "0", GENTLE_AI_TELEMETRY: "0" }, resolveTelemetryTriggerBinary: () => join(cwd, "never-executed"), telemetryTriggerSpawn: () => assert.fail("fixture must not spawn telemetry") })(pi);
|
|
38
|
+
const event = { systemPrompt: "base", systemPromptOptions: { appendSystemPrompt: "" } };
|
|
39
|
+
const ctx = { cwd, hasUI: true, ui: { notify() {}, setWidget() {} }, sessionManager: { getSessionId: () => "continuity-test", getBranch: () => [] } } as unknown as ExtensionContext;
|
|
40
|
+
await handlers.get("before_agent_start")!(event, ctx);
|
|
41
|
+
const prompt = event.systemPromptOptions.appendSystemPrompt;
|
|
42
|
+
const start = prompt.indexOf("## Authorized work continuity");
|
|
43
|
+
const end = prompt.indexOf("# el Gentleman Orchestrator", start);
|
|
44
|
+
assert.ok(start >= 0 && end > start, "always-on parent continuity block is delivered before the core");
|
|
45
|
+
return prompt.slice(start, end);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function includesAll(text: string, clauses: string[]): void {
|
|
49
|
+
for (const clause of clauses) assert.ok(text.includes(clause), `missing delivered clause: ${clause}`);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
test("recoverable failure is distinguished from terminal missing proof within existing bounds", async () => {
|
|
53
|
+
includesAll(await delivered(), [
|
|
54
|
+
"Before a terminal bounded-stop outcome",
|
|
55
|
+
"recoverable technical or harness failure",
|
|
56
|
+
"within the authorized scope and existing correction budget",
|
|
57
|
+
"genuinely inaccessible required proof",
|
|
58
|
+
"explicit one run, no retries, or diagnostic-only limits",
|
|
59
|
+
"permission denial, required new consent, or exhausted budget",
|
|
60
|
+
"never reset budgets, add retry allowances, weaken checks, or override final outcomes",
|
|
61
|
+
"subject to every applicable limit",
|
|
62
|
+
"Respect terminal review and verification outcomes and existing bounded-stop rules",
|
|
63
|
+
"An unavailable verifier remains unavailable; do not retry or escalate it.",
|
|
64
|
+
]);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
test("worker-prohibited maintenance has a bounded parent-only route, not a permission bypass", async () => {
|
|
68
|
+
includesAll(await delivered(), [
|
|
69
|
+
"worker prohibitions remain unchanged",
|
|
70
|
+
"parent only",
|
|
71
|
+
"human explicitly authorized the operation itself",
|
|
72
|
+
"exact scope, ownership, and preservation",
|
|
73
|
+
"available permitted tools",
|
|
74
|
+
"fresh runtime/native consent and guards remain binding",
|
|
75
|
+
"broad feature authorization is not destructive authority",
|
|
76
|
+
"never substitute another worker or tool to bypass a denial",
|
|
77
|
+
"validated backup",
|
|
78
|
+
"artifact and migration validation where applicable",
|
|
79
|
+
"recovery path",
|
|
80
|
+
"preserve unrelated edits even in the same file",
|
|
81
|
+
"remove only proven task-created helpers",
|
|
82
|
+
"never blanket restore, reset, or clean",
|
|
83
|
+
"ambiguous ownership or denial stops",
|
|
84
|
+
"This route is guidance, not authorization.",
|
|
85
|
+
]);
|
|
86
|
+
});
|