gentle-pi 4.5.1 → 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.
Files changed (239) hide show
  1. package/README.md +9 -6
  2. package/assets/agents/gentle-ai-verify.md +4 -0
  3. package/assets/agents/gentle-ai-worker.md +1 -0
  4. package/assets/migrations/agent-body-history.json +147 -0
  5. package/assets/orchestrator-delegation-reference.md +3 -3
  6. package/assets/orchestrator-delegation.md +2 -2
  7. package/assets/orchestrator-verification.md +10 -6
  8. package/assets/orchestrator.md +8 -8
  9. package/bin/gentle-shell.mjs +61 -26
  10. package/docs/ci-performance.md +11 -0
  11. package/docs/delegated-verification.md +6 -0
  12. package/docs/fast-mode.md +15 -0
  13. package/docs/gentle-agents-activity.md +8 -0
  14. package/docs/gentle-shell.md +69 -19
  15. package/docs/install-wizard.md +1 -1
  16. package/docs/mcp-status.md +52 -0
  17. package/docs/prompt-budget.md +28 -0
  18. package/docs/readme-reference.md +79 -20
  19. package/docs/session-profile-format.md +20 -5
  20. package/docs/sound-notifications.md +1 -1
  21. package/docs/star-prompt.md +32 -0
  22. package/docs/work-continuity.md +46 -0
  23. package/extensions/ask-user-question.ts +1 -0
  24. package/extensions/codegraph-tools.ts +38 -4
  25. package/extensions/gentle-agents.ts +477 -50
  26. package/extensions/gentle-ai.ts +1041 -188
  27. package/extensions/gentle-fast.ts +61 -0
  28. package/extensions/gentle-guide.ts +174 -0
  29. package/extensions/gentle-herdr-activity.ts +21 -1
  30. package/extensions/gentle-herdr-agent.ts +144 -0
  31. package/extensions/gentle-program-identity.ts +61 -0
  32. package/extensions/gentle-shell.ts +642 -97
  33. package/extensions/gentle-star-prompt.ts +334 -0
  34. package/extensions/gentle-stats.ts +5 -5
  35. package/extensions/gentle-todo.ts +42 -22
  36. package/extensions/history/store.ts +18 -12
  37. package/extensions/skill-registry.ts +35 -3
  38. package/extensions/startup-banner.ts +39 -7
  39. package/lib/agent-assets.ts +74 -17
  40. package/lib/agent-profiles.ts +1 -1
  41. package/lib/agents-config.ts +12 -3
  42. package/lib/agents-keys.ts +8 -16
  43. package/lib/agents-protocol.ts +80 -4
  44. package/lib/agents-runner.ts +105 -4
  45. package/lib/agents-view.ts +6 -1
  46. package/lib/agents-widget.ts +132 -9
  47. package/lib/bridge-cost.ts +28 -0
  48. package/lib/codemode-renderer.ts +16 -0
  49. package/lib/command-palette-catalog.ts +1 -0
  50. package/lib/command-palette.ts +21 -8
  51. package/lib/exploration-budget.ts +62 -0
  52. package/lib/gentle-guide.ts +201 -0
  53. package/lib/gentle-shell-launcher.ts +4 -0
  54. package/lib/herdr-activity.ts +9 -3
  55. package/lib/herdr-task-summary-policy.ts +85 -0
  56. package/lib/inprocess-reviewer.ts +33 -13
  57. package/lib/jobs-sidebar-state.ts +5 -6
  58. package/lib/jobs-widget.ts +16 -52
  59. package/lib/keymaps-customize.ts +81 -0
  60. package/lib/keymaps.ts +291 -0
  61. package/lib/model-fallback-notice.ts +61 -0
  62. package/lib/model-fallback-policy.ts +141 -0
  63. package/lib/model-fallback-store.ts +143 -0
  64. package/lib/model-routing-authority.ts +10 -2
  65. package/lib/nan-provider.ts +3 -2
  66. package/lib/native-review-cli.ts +7 -2
  67. package/lib/notification-customize.ts +48 -51
  68. package/lib/openai-fast-tier.ts +22 -0
  69. package/lib/orchestrator-discovery.ts +5 -1
  70. package/lib/orchestrator-fallback.ts +75 -0
  71. package/lib/pasted-image-paths.ts +113 -0
  72. package/lib/questionnaire/questionnaire-view.ts +121 -7
  73. package/lib/review-candidate-view-owner.ts +4 -0
  74. package/lib/review-candidate-view.ts +10 -7
  75. package/lib/review-host-relay.ts +5 -1
  76. package/lib/review-integration-v2.ts +22 -7
  77. package/lib/review-repository.ts +5 -0
  78. package/lib/session-profile-append-controller.ts +21 -6
  79. package/lib/session-profile-authority.ts +119 -0
  80. package/lib/session-profile-binding.ts +54 -5
  81. package/lib/session-profile-freeze.ts +105 -9
  82. package/lib/session-profile-integration.ts +313 -0
  83. package/lib/session-profile-persistence.ts +63 -9
  84. package/lib/shell-bar.ts +171 -56
  85. package/lib/shell-card.ts +26 -6
  86. package/lib/shell-page.ts +120 -0
  87. package/lib/shell-panel.ts +149 -0
  88. package/lib/shell-prompt.ts +53 -1
  89. package/lib/shell-sidebar-layout.ts +98 -25
  90. package/lib/shell-sidebar.ts +54 -1
  91. package/lib/shell-stats.ts +123 -0
  92. package/lib/shell-todo.ts +71 -0
  93. package/lib/shell-usage.ts +12 -2
  94. package/lib/star-prompt.ts +197 -0
  95. package/lib/verifier-admission.ts +18 -8
  96. package/lib/verifier-settle-reminder.ts +64 -0
  97. package/lib/vim-editor-adapter.ts +6 -1
  98. package/lib/visual-customization-policy.ts +41 -6
  99. package/lib/visual-customize-view.ts +164 -26
  100. package/lib/visual-layout-preview.ts +43 -0
  101. package/lib/yolo-session-policy.ts +28 -1
  102. package/package.json +1 -1
  103. package/runtime/gentle-shell-launcher.mjs +4 -0
  104. package/runtime/native-review-cli.mjs +7 -2
  105. package/runtime/review-integration-v2.mjs +22 -7
  106. package/runtime/windows-session-transport.ps1 +60 -3
  107. package/scripts/bootstrap.sh +4 -1
  108. package/scripts/installer-preflight.mjs +1 -1
  109. package/scripts/pi-update.mjs +113 -3
  110. package/scripts/run-test-suite.mjs +17 -1
  111. package/scripts/shell-snapshot.mjs +340 -0
  112. package/scripts/test-packed-runner.mjs +1 -1
  113. package/scripts/update-agent-body-history.mjs +41 -0
  114. package/scripts/verify-installer-tap.mjs +45 -0
  115. package/scripts/verify-package-files.mjs +2 -0
  116. package/skills/gentle-ai/SKILL.md +2 -2
  117. package/skills/tui-design/NOTICE.md +5 -0
  118. package/skills/tui-design/SKILL.md +56 -0
  119. package/skills/tui-design/references/commands.md +75 -0
  120. package/skills/tui-design/references/critique.md +48 -0
  121. package/skills/tui-design/references/design-doc.md +44 -0
  122. package/skills/tui-design/references/terminal-craft.md +64 -0
  123. package/skills/tui-design/references/visual-loop.md +32 -0
  124. package/tests/agents-protocol.test.ts +53 -1
  125. package/tests/agents-runner.test.ts +168 -3
  126. package/tests/agents-view.test.ts +27 -0
  127. package/tests/agents-widget.test.ts +312 -10
  128. package/tests/bounded-scan-contract.test.ts +39 -0
  129. package/tests/bridge-cost.test.ts +32 -0
  130. package/tests/bundled-install.test.ts +6 -4
  131. package/tests/ci-concurrency.test.ts +11 -0
  132. package/tests/ci-merge-base-identity.test.ts +114 -0
  133. package/tests/codegraph-tools.test.ts +69 -0
  134. package/tests/codemode-rendering.test.ts +22 -2
  135. package/tests/command-palette.test.ts +16 -2
  136. package/tests/commit-slice-signal.test.ts +11 -9
  137. package/tests/delegate-for-reason-contract.test.ts +5 -4
  138. package/tests/exploration-budget.test.ts +128 -0
  139. package/tests/fixtures/agent-assets/gentle-ai-worker.strict-tdd-era.md +122 -0
  140. package/tests/fixtures/measure-orchestrator-prompt.mjs +2 -1
  141. package/tests/fixtures/primary-session-prompt/gentleman.golden.md +18 -10
  142. package/tests/fixtures/session-profile-v1/replay.ts +125 -0
  143. package/tests/fixtures/session-profile-v1/session-profile-authority.ts +113 -0
  144. package/tests/fixtures/session-profile-v1/session-profile-binding.ts +83 -0
  145. package/tests/fixtures/session-profile-v1/session-profile-disk-reader.ts +182 -0
  146. package/tests/fixtures/session-profile-v1/session-profile-freeze.ts +290 -0
  147. package/tests/fixtures/session-profile-v1/session-profile-persistence.ts +195 -0
  148. package/tests/fixtures/session-profile-v1/v1-inputs.ts +16 -0
  149. package/tests/fixtures/windows-pipe-availability.ps1 +26 -0
  150. package/tests/fixtures/windows-session-bootstrap.ps1 +6 -2
  151. package/tests/gentle-agents.test.ts +416 -21
  152. package/tests/gentle-ai-exploration-budget.test.ts +135 -0
  153. package/tests/gentle-ai.test.ts +1007 -33
  154. package/tests/gentle-fast.test.ts +73 -0
  155. package/tests/gentle-guide.test.ts +208 -0
  156. package/tests/gentle-herdr-activity.test.ts +76 -2
  157. package/tests/gentle-herdr-agent.test.ts +111 -0
  158. package/tests/gentle-program-identity.test.ts +197 -0
  159. package/tests/gentle-shell-bin.test.ts +49 -26
  160. package/tests/gentle-shell-launcher.test.ts +18 -2
  161. package/tests/gentle-shell.test.ts +1068 -37
  162. package/tests/gentle-stats.test.ts +15 -2
  163. package/tests/gentle-todo.test.ts +50 -4
  164. package/tests/herdr-task-summary-policy.test.ts +128 -0
  165. package/tests/history-store-private-mode.test.ts +40 -0
  166. package/tests/image-paste-chips.test.ts +42 -0
  167. package/tests/inprocess-reviewer.test.ts +122 -0
  168. package/tests/installer-posix-bootstrap.test.ts +67 -5
  169. package/tests/installer-server.test.ts +2 -2
  170. package/tests/installer-windows-diagnostics.test.ts +4 -5
  171. package/tests/isolated-config-home.ts +28 -0
  172. package/tests/jobs-widget.test.ts +25 -37
  173. package/tests/keymaps-customize.test.ts +114 -0
  174. package/tests/keymaps.test.ts +103 -0
  175. package/tests/maintainer/mcp-status.maintest.ts +88 -0
  176. package/tests/maintainer/pi-update-source.maintest.ts +116 -0
  177. package/tests/model-fallback-notice.test.ts +45 -0
  178. package/tests/model-fallback-policy.test.ts +83 -0
  179. package/tests/model-fallback-store.test.ts +111 -0
  180. package/tests/nan-provider.test.ts +4 -4
  181. package/tests/no-self-pause-contract.test.ts +19 -0
  182. package/tests/notification-customize.test.ts +58 -34
  183. package/tests/odd-routing-canonical-ratchet.test.ts +3 -3
  184. package/tests/odd-routing-contract.test.ts +1 -1
  185. package/tests/orchestrator-fallback.test.ts +82 -0
  186. package/tests/orchestrator-prompt-budget.test.ts +131 -0
  187. package/tests/package-manifest.test.ts +160 -7
  188. package/tests/pasted-image-paths.test.ts +118 -0
  189. package/tests/persona-reply-language.test.ts +20 -1
  190. package/tests/pi-update-launcher.test.ts +32 -8
  191. package/tests/pi-update-source.test.ts +162 -0
  192. package/tests/profile-fast-tier.test.ts +311 -0
  193. package/tests/profile-tier-footer.test.ts +79 -0
  194. package/tests/questionnaire-view.test.ts +150 -0
  195. package/tests/review-candidate-owner-sweep.test.ts +93 -0
  196. package/tests/review-candidate-view.test.ts +51 -0
  197. package/tests/review-controller-native-routing.test.ts +120 -6
  198. package/tests/review-gate.test.ts +24 -0
  199. package/tests/review-inspect-preflight.test.ts +197 -0
  200. package/tests/review-integration-v2-forward.test.ts +59 -0
  201. package/tests/review-repository.test.ts +52 -1
  202. package/tests/review-sidebar-state.test.ts +5 -5
  203. package/tests/run-test-suite.test.ts +61 -5
  204. package/tests/sensitive-path-tools.test.ts +74 -0
  205. package/tests/session-profile-append-controller.test.ts +63 -0
  206. package/tests/session-profile-authority.test.ts +259 -0
  207. package/tests/session-profile-binding.test.ts +15 -0
  208. package/tests/session-profile-extension.test.ts +615 -0
  209. package/tests/session-profile-freeze.test.ts +110 -2
  210. package/tests/session-profile-integration.test.ts +857 -0
  211. package/tests/session-profile-persistence.test.ts +57 -0
  212. package/tests/session-profile-v1-compat.test.ts +221 -0
  213. package/tests/shell-bar.test.ts +113 -55
  214. package/tests/shell-card.test.ts +13 -1
  215. package/tests/shell-page.test.ts +108 -0
  216. package/tests/shell-panel.test.ts +332 -0
  217. package/tests/shell-prompt.test.ts +54 -0
  218. package/tests/shell-render-cache.test.ts +5 -0
  219. package/tests/shell-sidebar-fullscreen.test.ts +12 -0
  220. package/tests/shell-sidebar-layout.test.ts +159 -27
  221. package/tests/shell-stats.test.ts +90 -0
  222. package/tests/shell-usage.test.ts +14 -0
  223. package/tests/skill-registry.test.ts +68 -1
  224. package/tests/star-prompt.test.ts +470 -0
  225. package/tests/startup-banner.test.ts +57 -1
  226. package/tests/task-size-routing-contract.test.ts +45 -1
  227. package/tests/verifier-settle-reminder.test.ts +281 -0
  228. package/tests/verify-first-launch-contract.test.ts +56 -5
  229. package/tests/verify-installer-tap.test.ts +57 -0
  230. package/tests/vim-editor-adapter.test.ts +2 -2
  231. package/tests/visual-customization-policy.test.ts +61 -7
  232. package/tests/visual-customize-view.test.ts +253 -8
  233. package/tests/visual-layout-preview.test.ts +28 -0
  234. package/tests/windows-session-bootstrap.test.ts +105 -2
  235. package/tests/work-continuity-contract.test.ts +86 -0
  236. package/tests/writer-surfaces.test.ts +12 -10
  237. package/tests/yolo-customize.test.ts +30 -11
  238. package/tests/yolo-mode-runtime.test.ts +4 -2
  239. package/tests/yolo-mode.test.ts +16 -2
@@ -1,10 +1,14 @@
1
1
  import assert from "node:assert/strict";
2
2
  import { join } from "node:path";
3
- import test from "node:test";
3
+ import test, { after } from "node:test";
4
4
  import { fileURLToPath } from "node:url";
5
5
  import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
6
6
  import { stripAnsi } from "../lib/terminal-theme.ts";
7
- import gentleStats, { STATS_COMMAND_NAME, statsSessionRoots, statsViewKey } from "../extensions/gentle-stats.ts";
7
+ import installGentleStats, { STATS_COMMAND_NAME, statsSessionRoots, statsViewKey } from "../extensions/gentle-stats.ts";
8
+ import { isolatedConfigEnv, keymapsConfigHome, removeIsolatedConfigHomes } from "./isolated-config-home.ts";
9
+
10
+ const gentleStats: typeof installGentleStats = (pi, deps = {}) => installGentleStats(pi, { ...deps, env: isolatedConfigEnv(deps.env ?? {}) });
11
+ after(removeIsolatedConfigHomes);
8
12
 
9
13
  // /gentle:stats wiring: the command (and optional shortcut) opens the stats
10
14
  // panel as a full-terminal overlay, loads sessions after it opens, closes
@@ -62,6 +66,15 @@ async function until(check: () => boolean, attempts = 200) {
62
66
  assert.ok(check(), "condition not reached");
63
67
  }
64
68
 
69
+ test("a saved keymap gives /gentle:stats a shortcut, and the environment still wins", () => {
70
+ const keyed = fakePi();
71
+ gentleStats(keyed.pi, { env: { GENTLE_PI_CONFIG_HOME: keymapsConfigHome({ "stats.view": "alt+t" }) } });
72
+ assert.deepEqual([...keyed.shortcuts.keys()], ["alt+t"]);
73
+ const envWins = fakePi();
74
+ gentleStats(envWins.pi, { env: { GENTLE_PI_CONFIG_HOME: keymapsConfigHome({ "stats.view": "alt+t" }), GENTLE_PI_STATS_VIEW_KEY: "off" } });
75
+ assert.deepEqual([...envWins.shortcuts.keys()], []);
76
+ });
77
+
65
78
  test("statsViewKey is off by default and honors an explicit key", () => {
66
79
  assert.equal(statsViewKey({}), undefined);
67
80
  assert.equal(statsViewKey({ GENTLE_PI_STATS_VIEW_KEY: "alt+t" }), "alt+t");
@@ -2,13 +2,17 @@ import assert from "node:assert/strict";
2
2
  import test, { after, before } from "node:test";
3
3
  import { convertToLlm, type ExtensionAPI, type ExtensionContext } from "@earendil-works/pi-coding-agent";
4
4
  import type { Component, TUI } from "@earendil-works/pi-tui";
5
- import gentleTodo, { todoCollapseKey, todoEnabled } from "../extensions/gentle-todo.ts";
5
+ import installGentleTodo, { todoCollapseKey, todoEnabled } from "../extensions/gentle-todo.ts";
6
+ import { isolatedConfigEnv, keymapsConfigHome, removeIsolatedConfigHomes } from "./isolated-config-home.ts";
6
7
  import { TODO_PROGRESS_EVENT } from "../lib/shell-todo.ts";
7
8
  import { CARD_STYLE, cardStyle, setCardStyle } from "../lib/shell-card.ts";
8
9
  import { stripAnsi } from "../lib/terminal-theme.ts";
9
10
  import { sidebarState } from "../lib/shell-sidebar.ts";
10
11
  import { installSidebar } from "../lib/shell-sidebar-layout.ts";
11
12
 
13
+ const gentleTodo: typeof installGentleTodo = (pi, env) => installGentleTodo(pi, isolatedConfigEnv(env));
14
+ after(removeIsolatedConfigHomes);
15
+
12
16
  // The card style defaults to float; these assertions pin the outlined (neon)
13
17
  // panels unless a test switches the style itself.
14
18
  const initialCardStyle = cardStyle();
@@ -97,11 +101,14 @@ test("long Todo widgets stay bounded, scroll, resize and keep their collapse con
97
101
  for (const component of [bottom, rail]) {
98
102
  const before = component.render(40).map(stripAnsi);
99
103
  assert.ok(before.length <= 10, "card uses at most one third of terminal height");
100
- const header = style === CARD_STYLE.FLOAT ? 1 : 0;
101
- assert.match(before[header]!, /Todos ▾/);
104
+ // The rail draws a panel section (header on row 0 in every style); the
105
+ // bottom widget keeps the card, whose float header sits below padding.
106
+ const header = component === rail ? 0 : style === CARD_STYLE.FLOAT ? 1 : 0;
107
+ const title = component === rail ? /▾ TODOS/ : /Todos ▾/;
108
+ assert.match(before[header]!, title);
102
109
  assert.equal(component.handleMouse?.({ type: "wheel", button: "none", wheelDelta: 10000, x: 5, y: header + 2, screenX: 5, screenY: 5, width: 40, height: before.length, shift: false, alt: false, ctrl: false })?.handled, true);
103
110
  const after = component.render(40).map(stripAnsi);
104
- assert.match(after[header]!, /Todos ▾/);
111
+ assert.match(after[header]!, title);
105
112
  assert.match(after.join("\n"), /LAST TASK/, "all details remain reachable by scrolling");
106
113
  assert.notDeepEqual(after, before);
107
114
  }
@@ -121,6 +128,15 @@ test("long Todo widgets stay bounded, scroll, resize and keep their collapse con
121
128
  t.after(() => setCardStyle(CARD_STYLE.NEON));
122
129
  });
123
130
 
131
+ test("a saved keymap replaces the todo collapse key", () => {
132
+ const { pi, shortcuts } = fakePi();
133
+ gentleTodo(pi, { GENTLE_PI_CONFIG_HOME: keymapsConfigHome({ "todo.collapse": "alt+t" }) });
134
+ assert.deepEqual([...shortcuts.keys()].sort(), ["alt+shift+down", "alt+shift+up", "alt+t"]);
135
+ const envWins = fakePi();
136
+ gentleTodo(envWins.pi, { GENTLE_PI_CONFIG_HOME: keymapsConfigHome({ "todo.collapse": "alt+t" }), GENTLE_PI_TODO_KEY: "off" });
137
+ assert.deepEqual([...envWins.shortcuts.keys()].sort(), ["alt+shift+down", "alt+shift+up"]);
138
+ });
139
+
124
140
  test("Todo shortcuts never take a key Pi binds by default, so startup reports no shortcut conflict", async () => {
125
141
  // Pi keeps its default table in dist/core/keybindings.js, next to the package entry.
126
142
  const { KEYBINDINGS } = await import(new URL("core/keybindings.js", import.meta.resolve("@earendil-works/pi-coding-agent")).href) as
@@ -166,6 +182,7 @@ test("Todo keyboard scrolling targets the visible card after a cached sidebar br
166
182
  const after = railLines();
167
183
  assert.notDeepEqual(after, before, "DOWN changes the visible cached rail, not the hidden bottom widget");
168
184
  assert.match(after.join("\n"), /↑↓ 4–/);
185
+ assert.match(after.join("\n"), /alt\+shift\+↑\/↓/, "scroll hint reflects alt+shift shortcuts");
169
186
  await shortcuts.get("alt+shift+up")!.handler(ctx);
170
187
  assert.deepEqual(railLines(), before, "UP restores the expanded viewport");
171
188
  } finally {
@@ -266,6 +283,35 @@ test("the Todo header paints the shared hover role while hovered, and clears it
266
283
  assert.deepEqual(component.handleMouse?.(move(0)), { handled: true });
267
284
  });
268
285
 
286
+ test("the rail draws Todos as a panel section whose header row 0 is the collapse control in every card style", async (t) => {
287
+ const found = cardStyle();
288
+ t.after(() => setCardStyle(found));
289
+ for (const style of [CARD_STYLE.NEON, CARD_STYLE.FLOAT]) {
290
+ setCardStyle(style);
291
+ const { pi, tools, fire } = fakePi();
292
+ gentleTodo(pi, {});
293
+ const { ctx, widgets } = fakeContext();
294
+ await fire("session_start", ctx);
295
+ await tools.get("todo")!.execute("c1", { action: "write", tasks: [{ title: "A", status: "done" }, { title: "B", status: "in_progress", note: "job-1" }, { title: "C" }] }, undefined, undefined, ctx);
296
+ await fire("tool_execution_end", ctx, { toolName: "todo" });
297
+ const tui = { requestRender() {}, terminal: { rows: 40, columns: 160 } };
298
+ const theme = { ...plainTheme, bg: (_color: string, text: string) => `\x1b[48;5;22m${text}\x1b[49m` };
299
+ widgets.get("gentle-todo")!(tui, theme);
300
+ const rail = sidebarState(tui as never).parts.get("todo")!;
301
+ assert.equal((rail as { surface?: string }).surface, "panel", "the rail paints this section on the panel surface");
302
+ const rows = rail.render(48).map((row) => stripAnsi(row).trimEnd());
303
+ assert.deepEqual(rows, ["▾ TODOS 1/3", " ✓ 1 done", " ◐ B", " └ job-1", " ○ C"]);
304
+ assert.doesNotMatch(rows.join("\n"), /[╭╮╰╯│▎]/u, "no card chrome in the rail");
305
+ const pointer = (type: "move" | "click", y: number) => ({
306
+ type, button: type === "move" ? "none" as const : "left" as const, x: 1, y, screenX: 1, screenY: y, width: 48, height: rows.length, shift: false, alt: false, ctrl: false,
307
+ });
308
+ assert.deepEqual(rail.handleMouse?.(pointer("move", 0)), { handled: true, render: true }, "the header row is hoverable");
309
+ assert.equal(rail.handleMouse?.(pointer("click", 1)), undefined, "a body row is not the control");
310
+ assert.equal(rail.handleMouse?.(pointer("click", 0))?.handled, true);
311
+ assert.deepEqual(rail.render(48).map((row) => stripAnsi(row).trimEnd()), ["▸ TODOS 1/3", " ◐ B"]);
312
+ }
313
+ });
314
+
269
315
  test("in the float style the Todos header sits on row 1 below the top padding, and hover and click work there", async (t) => {
270
316
  const found = cardStyle();
271
317
  t.after(() => setCardStyle(found));
@@ -0,0 +1,128 @@
1
+ import assert from "node:assert/strict";
2
+ import fs, { mkdirSync, mkdtempSync, readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
3
+ import { syncBuiltinESMExports } from "node:module";
4
+ import { join, resolve } from "node:path";
5
+ import test from "node:test";
6
+ import {
7
+ DEFAULT_HERDR_TASK_SUMMARY_SETTINGS, HERDR_SUMMARY_COLORS, HERDR_TASK_SUMMARY_SCHEMA,
8
+ resolveHerdrTaskSummarySettings, writeHerdrTaskSummarySettings,
9
+ type HerdrTaskSummarySettings,
10
+ } from "../lib/herdr-task-summary-policy.ts";
11
+
12
+ function fixture() {
13
+ const root = resolve("odd/work/herdr-c65-pure/fixtures/task-summary-policy");
14
+ mkdirSync(root, { recursive: true });
15
+ const home = mkdtempSync(join(root, "case-"));
16
+ return { options: { gentlePiConfigHome: home }, home, file: join(home, "herdr-task-summary.json") };
17
+ }
18
+
19
+ test("missing settings preserve legacy defaults and return independent values", () => {
20
+ const { options, file } = fixture();
21
+ assert.deepEqual(resolveHerdrTaskSummarySettings(options), {
22
+ settings: DEFAULT_HERDR_TASK_SUMMARY_SETTINGS, malformed: false, readError: false,
23
+ source: "default", globalFile: file,
24
+ });
25
+ resolveHerdrTaskSummarySettings(options).settings.enabled = false;
26
+ assert.equal(resolveHerdrTaskSummarySettings(options).settings.enabled, true);
27
+ });
28
+
29
+ test("all semantic roles persist atomically at 0600; visibility preserves both colors", () => {
30
+ const { options, file, home } = fixture();
31
+ assert.deepEqual(HERDR_SUMMARY_COLORS, ["accent", "text", "muted", "dim", "success", "warning", "error"]);
32
+ for (const summaryColor of HERDR_SUMMARY_COLORS) {
33
+ for (const continuationColor of HERDR_SUMMARY_COLORS) {
34
+ for (const enabled of [false, true]) {
35
+ const settings = { enabled, summaryColor, continuationColor };
36
+ assert.equal(writeHerdrTaskSummarySettings(settings, options), file);
37
+ assert.deepEqual(resolveHerdrTaskSummarySettings(options), {
38
+ settings, malformed: false, readError: false, source: "global_file", globalFile: file,
39
+ });
40
+ assert.deepEqual(JSON.parse(readFileSync(file, "utf8")), { schema: HERDR_TASK_SUMMARY_SCHEMA, ...settings });
41
+ assert.equal(statSync(file).mode & 0o777, 0o600);
42
+ assert.deepEqual(readdirSync(home), ["herdr-task-summary.json"]);
43
+ }
44
+ }
45
+ }
46
+ });
47
+
48
+ test("strict writer rejects wrong types, unknown roles and extra/missing fields without effects", () => {
49
+ const { options, file, home } = fixture();
50
+ const valid = { ...DEFAULT_HERDR_TASK_SUMMARY_SETTINGS };
51
+ writeHerdrTaskSummarySettings(valid, options);
52
+ const original = readFileSync(file, "utf8");
53
+ for (const invalid of [null, [], {}, { ...valid, enabled: "false" }, { ...valid, summaryColor: "#abcdef" },
54
+ { ...valid, continuationColor: "blue" }, { ...valid, summaryColor: 1 }, { ...valid, extra: true },
55
+ { enabled: true, summaryColor: "accent" }]) {
56
+ assert.throws(() => writeHerdrTaskSummarySettings(invalid as HerdrTaskSummarySettings, options), TypeError);
57
+ assert.equal(readFileSync(file, "utf8"), original);
58
+ assert.deepEqual(readdirSync(home), ["herdr-task-summary.json"]);
59
+ }
60
+ });
61
+
62
+ test("malformed existing settings never get silently overwritten", () => {
63
+ const { options, file, home } = fixture();
64
+ const valid = DEFAULT_HERDR_TASK_SUMMARY_SETTINGS;
65
+ for (const raw of ["{", "null", "[]", "{}", JSON.stringify({ ...valid, schema: "wrong" }),
66
+ JSON.stringify({ schema: HERDR_TASK_SUMMARY_SCHEMA, ...valid, enabled: 0 }),
67
+ JSON.stringify({ schema: HERDR_TASK_SUMMARY_SCHEMA, ...valid, summaryColor: "red" }),
68
+ JSON.stringify({ schema: HERDR_TASK_SUMMARY_SCHEMA, ...valid, continuationColor: null }),
69
+ JSON.stringify({ schema: HERDR_TASK_SUMMARY_SCHEMA, ...valid, unknown: true })]) {
70
+ writeFileSync(file, raw);
71
+ assert.deepEqual(resolveHerdrTaskSummarySettings(options), {
72
+ settings: valid, malformed: true, readError: false, source: "global_file", globalFile: file,
73
+ });
74
+ assert.throws(() => writeHerdrTaskSummarySettings(valid, options), /Refusing/);
75
+ assert.equal(readFileSync(file, "utf8"), raw);
76
+ assert.deepEqual(readdirSync(home), ["herdr-task-summary.json"]);
77
+ }
78
+ });
79
+
80
+ test("unreadable non-file and bounded oversized stores refuse writes without effects", () => {
81
+ for (const directory of [true, false]) {
82
+ const { options, file, home } = fixture();
83
+ if (directory) mkdirSync(file); else writeFileSync(file, " ".repeat(4097));
84
+ assert.deepEqual(resolveHerdrTaskSummarySettings(options), {
85
+ settings: DEFAULT_HERDR_TASK_SUMMARY_SETTINGS, malformed: false, readError: true,
86
+ source: "global_file", globalFile: file,
87
+ });
88
+ assert.throws(() => writeHerdrTaskSummarySettings(DEFAULT_HERDR_TASK_SUMMARY_SETTINGS, options), /Refusing/);
89
+ assert.equal(statSync(file).isDirectory(), directory);
90
+ if (!directory) assert.equal(readFileSync(file, "utf8"), " ".repeat(4097));
91
+ assert.deepEqual(readdirSync(home), ["herdr-task-summary.json"]);
92
+ }
93
+ });
94
+
95
+ for (const step of ["writeFileSync", "renameSync"] as const) test(`a failed ${step} removes the temporary file and keeps the previous store`, t => {
96
+ const { options, file, home } = fixture();
97
+ writeHerdrTaskSummarySettings({ ...DEFAULT_HERDR_TASK_SUMMARY_SETTINGS, enabled: false }, options);
98
+ const before = readFileSync(file, "utf8");
99
+ const original = fs[step];
100
+ const failure = Object.assign(new Error(`controlled ${step} failure`), { code: "ENOSPC" });
101
+ t.mock.method(fs, step, (...args: unknown[]) => {
102
+ // The temporary file exists when the failure happens, as with a full disk.
103
+ if (step === "writeFileSync") Reflect.apply(original, fs, [args[0], "", { flag: "wx", mode: 0o600 }]);
104
+ throw failure;
105
+ });
106
+ syncBuiltinESMExports();
107
+ try {
108
+ assert.throws(() => writeHerdrTaskSummarySettings(DEFAULT_HERDR_TASK_SUMMARY_SETTINGS, options), failure);
109
+ } finally { t.mock.restoreAll(); syncBuiltinESMExports(); }
110
+ assert.deepEqual(readdirSync(home).filter(name => name.endsWith(".tmp")), []);
111
+ assert.equal(readFileSync(file, "utf8"), before);
112
+ assert.equal(resolveHerdrTaskSummarySettings(options).settings.enabled, false);
113
+ });
114
+
115
+ test("a failed cleanup never masks the original write failure", t => {
116
+ const { options } = fixture();
117
+ const original = fs.writeFileSync;
118
+ const failure = Object.assign(new Error("controlled write failure"), { code: "ENOSPC" });
119
+ t.mock.method(fs, "writeFileSync", (...args: unknown[]) => {
120
+ Reflect.apply(original, fs, [args[0], "", { flag: "wx", mode: 0o600 }]);
121
+ throw failure;
122
+ });
123
+ t.mock.method(fs, "rmSync", () => { throw Object.assign(new Error("controlled cleanup failure"), { code: "EACCES" }); });
124
+ syncBuiltinESMExports();
125
+ try {
126
+ assert.throws(() => writeHerdrTaskSummarySettings(DEFAULT_HERDR_TASK_SUMMARY_SETTINGS, options), failure);
127
+ } finally { t.mock.restoreAll(); syncBuiltinESMExports(); }
128
+ });
@@ -0,0 +1,40 @@
1
+ import { test } from "node:test";
2
+ import assert from "node:assert/strict";
3
+ import fs from "node:fs";
4
+ import os from "node:os";
5
+ import path from "node:path";
6
+ import {
7
+ appendSessionCapture,
8
+ ensureRegistryEntry,
9
+ openSessionWriter,
10
+ registryPath,
11
+ } from "../extensions/history/store.ts";
12
+
13
+ // Prompt history can hold anything pasted into the composer, so its files are
14
+ // private (0600) and the directories it creates are owner-only (0700), the
15
+ // same convention as the package's other state files. POSIX modes only.
16
+ const posix = process.platform !== "win32";
17
+
18
+ function mode(file: string): number {
19
+ return fs.statSync(file).mode & 0o777;
20
+ }
21
+
22
+ test("history store creates private files and owner-only directories", { skip: !posix }, () => {
23
+ const base = fs.mkdtempSync(path.join(os.tmpdir(), "history-private-mode-"));
24
+ const root = path.join(base, "history");
25
+ const cwd = path.join(base, "project");
26
+ const previous = process.umask(0o022);
27
+ try {
28
+ ensureRegistryEntry(root, cwd);
29
+ const writer = openSessionWriter(root, cwd, "instance-1");
30
+ appendSessionCapture(writer, "token: example-secret-value");
31
+
32
+ assert.equal(mode(root), 0o700, "history root directory");
33
+ assert.equal(mode(registryPath(root)), 0o600, "registry file");
34
+ assert.equal(mode(path.dirname(writer.filePath)), 0o700, "project directory");
35
+ assert.equal(mode(writer.filePath), 0o600, "session capture file");
36
+ } finally {
37
+ process.umask(previous);
38
+ fs.rmSync(base, { recursive: true, force: true });
39
+ }
40
+ });
@@ -7,6 +7,9 @@ import type { ClipboardImage } from "../lib/clipboard-image.ts";
7
7
  import { ImageAttachments } from "../lib/image-attachments.ts";
8
8
  import { createVimEditorAdapter } from "../lib/vim-editor-adapter.ts";
9
9
  import { createRequire } from "node:module";
10
+ import { mkdtempSync, writeFileSync } from "node:fs";
11
+ import { tmpdir } from "node:os";
12
+ import { join } from "node:path";
10
13
 
11
14
  const INSTALLED_PI = (createRequire(import.meta.url)("@earendil-works/pi-tui/package.json") as { version: string }).version;
12
15
 
@@ -234,3 +237,42 @@ test("models without declared input capabilities are treated as image-capable",
234
237
  assert.equal(modelAcceptsImages({ input: ["text", "image"] }), true);
235
238
  assert.equal(modelAcceptsImages({ input: ["text"] }), false);
236
239
  });
240
+
241
+ // Herdr hands an image to a terminal on another machine (desktop app, --remote)
242
+ // as a temp-file path, and drops or file-manager copies arrive as quoted paths.
243
+ // A paste made only of image paths becomes chips; any other paste stays Pi's.
244
+
245
+ function imagePaste(text: string) {
246
+ return `\x1b[200~${text}\x1b[201~`;
247
+ }
248
+
249
+ function temporaryImage(name = "herdr-paste-1.png"): string {
250
+ const directory = mkdtempSync(join(tmpdir(), "gentle-paste-"));
251
+ const path = join(directory, name);
252
+ writeFileSync(path, PNG_2X1);
253
+ return path;
254
+ }
255
+
256
+ test("a pasted image path becomes a chip instead of text", () => {
257
+ const { editor, attachments } = chipEditor(async () => png());
258
+ editor.setText("look");
259
+ editor.handleInput(imagePaste(`${temporaryImage()}\n`));
260
+ assert.equal(editor.getText(), "look [Image#1]");
261
+ assert.equal(attachments.size, 1);
262
+ });
263
+
264
+ test("several quoted image paths from a drop become one chip each", () => {
265
+ const first = temporaryImage("a.png");
266
+ const second = temporaryImage("b.png");
267
+ const { editor, attachments } = chipEditor(async () => png());
268
+ editor.handleInput(imagePaste(`'${first}' '${second}' `));
269
+ assert.equal(editor.getText(), "[Image#1] [Image#2]");
270
+ assert.equal(attachments.size, 2);
271
+ });
272
+
273
+ test("a paste that is not only image paths stays Pi's normal text paste", () => {
274
+ const path = temporaryImage();
275
+ const { editor } = chipEditor(async () => png());
276
+ editor.handleInput(imagePaste(`look at ${path}`));
277
+ assert.equal(editor.getText(), `look at ${path}`);
278
+ });
@@ -396,6 +396,100 @@ test("passes exactly one user message with the verbatim prompt, no systemPrompt,
396
396
  assert.ok(!("tools" in calls[0]!.context));
397
397
  });
398
398
 
399
+ // ---------------------------------------------------------------------------
400
+ // Resolved auth context — synthetic OAuth-like endpoint and provider env
401
+ // ---------------------------------------------------------------------------
402
+
403
+ for (const dispatch of ["composed provider", "compatibility complete"] as const) {
404
+ function captureDispatch() {
405
+ const provider = capturingProvider(assistantText("ok"));
406
+ const compatibility = capturingComplete(assistantText("ok"));
407
+ return {
408
+ getProvider: dispatch === "composed provider" ? provider.getProvider : undefined,
409
+ complete: dispatch === "composed provider" ? unreachableComplete : compatibility.complete,
410
+ calls: dispatch === "composed provider" ? provider.calls : compatibility.calls,
411
+ };
412
+ }
413
+
414
+ test(`${dispatch} preserves the registry's exchanged key, headers, account endpoint, and env`, async () => {
415
+ const original = Object.freeze(fakeModel({ provider: "github-copilot", baseUrl: "https://api.individual.githubcopilot.com" }));
416
+ const snapshot = { ...original };
417
+ const baseUrl = "https://api.synthetic-account.githubcopilot.com";
418
+ const headers = Object.freeze({ "x-synthetic-auth": "registry-header", "x-suppress-default": null });
419
+ const env = Object.freeze({ RDD_SYNTHETIC_PROVIDER_REGION: "test-region" });
420
+ const ambientBefore = process.env.RDD_SYNTHETIC_PROVIDER_REGION;
421
+ const { getProvider, complete, calls } = captureDispatch();
422
+ const outcome = await runInProcessReviewer(baseRequest({ selection: "github-copilot/gpt-5" }), {
423
+ registry: {
424
+ ...fakeRegistry([original], async (resolvedModel) => {
425
+ assert.equal(resolvedModel, original, "auth must resolve against the registry model");
426
+ return { ok: true, apiKey: "synthetic-exchanged-access-token", headers, baseUrl, env };
427
+ }),
428
+ ...(getProvider === undefined ? {} : { getProvider }),
429
+ },
430
+ complete,
431
+ });
432
+ assert.equal(expectText(outcome).reviewerModel, "github-copilot/gpt-5");
433
+ assert.equal(calls.length, 1);
434
+ assert.deepEqual(calls[0]!.model, { ...snapshot, baseUrl });
435
+ assert.notEqual(calls[0]!.model, original, "the endpoint override needs a request-local model");
436
+ assert.equal(calls[0]!.options?.apiKey, "synthetic-exchanged-access-token");
437
+ assert.equal(calls[0]!.options?.headers, headers);
438
+ assert.equal(calls[0]!.options?.env, env);
439
+ assert.deepEqual(original, snapshot, "shared registry state must remain unchanged");
440
+ assert.equal(process.env.RDD_SYNTHETIC_PROVIDER_REGION, ambientBefore, "env must be forwarded, not installed globally");
441
+ });
442
+
443
+ test(`${dispatch} forwards env without an endpoint override`, async () => {
444
+ const original = Object.freeze(fakeModel());
445
+ const env = Object.freeze({ RDD_SYNTHETIC_PROVIDER_REGION: "env-only-region" });
446
+ const { getProvider, complete, calls } = captureDispatch();
447
+ expectText(await runInProcessReviewer(baseRequest(), {
448
+ registry: {
449
+ ...fakeRegistry([original], async () => ({ ok: true, apiKey: "synthetic-key", env })),
450
+ ...(getProvider === undefined ? {} : { getProvider }),
451
+ },
452
+ complete,
453
+ }));
454
+ assert.equal(calls[0]!.model, original);
455
+ assert.equal(calls[0]!.options?.env, env);
456
+ });
457
+
458
+ test(`${dispatch} preserves model defaults and omits unresolved env`, async () => {
459
+ const original = Object.freeze(fakeModel());
460
+ const { getProvider, complete, calls } = captureDispatch();
461
+ expectText(await runInProcessReviewer(baseRequest(), {
462
+ registry: { ...fakeRegistry([original]), ...(getProvider === undefined ? {} : { getProvider }) },
463
+ complete,
464
+ }));
465
+ assert.equal(calls[0]!.model, original);
466
+ assert.equal(calls[0]!.model.baseUrl, "https://api.openai.com");
467
+ assert.ok(!("env" in (calls[0]!.options ?? {})));
468
+ });
469
+
470
+ for (const routedToOpenCode of [true, false]) {
471
+ test(`${dispatch} uses the resolved endpoint for attribution when routed ${routedToOpenCode ? "to" : "away from"} OpenCode`, async () => {
472
+ const original = Object.freeze(fakeModel({
473
+ provider: "custom",
474
+ baseUrl: routedToOpenCode ? "https://default.invalid" : "https://opencode.ai/v1",
475
+ }));
476
+ const baseUrl = routedToOpenCode ? "https://opencode.ai/v1" : "https://account.invalid/v1";
477
+ const { getProvider, complete, calls } = captureDispatch();
478
+ expectText(await runInProcessReviewer(baseRequest({ selection: "custom/gpt-5", sessionId: "ses-synthetic" }), {
479
+ registry: {
480
+ ...fakeRegistry([original], async () => ({ ok: true, apiKey: "synthetic-key", baseUrl })),
481
+ ...(getProvider === undefined ? {} : { getProvider }),
482
+ },
483
+ complete,
484
+ }));
485
+ assert.deepEqual(calls[0]!.options?.headers, routedToOpenCode
486
+ ? { "x-opencode-session": "ses-synthetic", "x-opencode-client": "pi" }
487
+ : undefined);
488
+ assert.equal(calls[0]!.model.baseUrl, baseUrl);
489
+ });
490
+ }
491
+ }
492
+
399
493
  // ---------------------------------------------------------------------------
400
494
  // Thinking mapping
401
495
  // ---------------------------------------------------------------------------
@@ -470,6 +564,34 @@ for (const { name, model, selection } of OPENCODE_ATTRIBUTION_TESTS) {
470
564
  });
471
565
  }
472
566
 
567
+ test("each completion carries its own sessionId, never the parent session's", async () => {
568
+ const { complete, calls } = capturingComplete(assistantText("ok"));
569
+ const deps = { registry: fakeRegistry([fakeModel({ provider: "anthropic", id: "claude-sonnet-4" })]), complete };
570
+ expectText(await runInProcessReviewer(baseRequest({ selection: "anthropic/claude-sonnet-4", sessionId: "ses-live-1" }), deps));
571
+ expectText(await runInProcessReviewer(baseRequest({ selection: "anthropic/claude-sonnet-4", sessionId: "ses-live-1" }), deps));
572
+ assert.equal(calls.length, 2);
573
+ const [first, second] = calls.map((call) => call.options?.sessionId);
574
+ assert.ok(typeof first === "string" && first.length > 0);
575
+ assert.ok(typeof second === "string" && second.length > 0);
576
+ assert.notEqual(first, second);
577
+ assert.notEqual(first, "ses-live-1");
578
+ assert.notEqual(second, "ses-live-1");
579
+ });
580
+
581
+ test("an OpenCode model with a live parent keeps the parent id in the attribution header while options.sessionId stays synthetic", async () => {
582
+ const { complete, calls } = capturingComplete(assistantText("ok"));
583
+ const outcome = await runInProcessReviewer(baseRequest({ selection: "opencode/sonnet-4", sessionId: "ses-live-1" }), {
584
+ registry: fakeRegistry([fakeModel({ provider: "opencode", id: "sonnet-4", baseUrl: "https://opencode.ai" })]),
585
+ complete,
586
+ });
587
+ expectText(outcome);
588
+ assert.equal(calls.length, 1);
589
+ assert.equal(calls[0]!.options?.headers?.["x-opencode-session"], "ses-live-1");
590
+ const sessionId = calls[0]!.options?.sessionId;
591
+ assert.ok(typeof sessionId === "string" && sessionId.length > 0);
592
+ assert.notEqual(sessionId, "ses-live-1");
593
+ });
594
+
473
595
  test("a non-OpenCode model adds no attribution headers and leaves the options unchanged", async () => {
474
596
  const { complete, calls } = capturingComplete(assistantText("ok"));
475
597
  const outcome = await runInProcessReviewer(baseRequest({ selection: "anthropic/claude-sonnet-4", sessionId: "ses-live-1" }), {
@@ -190,6 +190,55 @@ posixTest("no initial Node acquires verified native binary and refreshes child P
190
190
  assert.deepEqual(readdirSync(f.home), [], "successful wizard exit removes the owned tools");
191
191
  } finally { f.cleanup(); }
192
192
  });
193
+ // BSD ls appends `@` (extended attributes) or `+` (an ACL) to the mode
194
+ // string. Current macOS attaches com.apple.provenance to every new
195
+ // directory, so `@` is the normal case there (#2144). GNU ls appends `.`
196
+ // when the directory has an SELinux security context, which is every
197
+ // directory on an SELinux-enabled host, and `+` for an ACL. This ls reports a
198
+ // fixed marker on every host, so the guard is checked the same way on
199
+ // Linux CI and macOS.
200
+ function lsWithModeMarker(f: ReturnType<typeof fixture>, marker: "" | "@" | "." | "+") {
201
+ f.executable("ls", `${systemUtility("ls")} "$@" | awk -v m='${marker}' '{ sub(/[@+.]$/, "", $1); $1 = $1 m; print }'`);
202
+ }
203
+ posixTest("a tools directory whose mode shows the extended-attribute marker @ is accepted (#2144)", () => {
204
+ const f = fixture();
205
+ try {
206
+ f.addPnpm(); f.wizard(); lsWithModeMarker(f, "@");
207
+ const result = f.run();
208
+ assert.equal(result.status, 0, result.stderr);
209
+ assert.doesNotMatch(result.stderr, /Unsafe tooling ownership/);
210
+ assert.match(result.stdout, /wizard-child:.*bootstrap-tools/);
211
+ } finally { f.cleanup(); }
212
+ });
213
+ posixTest("a tools directory whose mode shows the SELinux context marker . is accepted (#2144)", () => {
214
+ const f = fixture();
215
+ try {
216
+ f.addPnpm(); f.wizard(); lsWithModeMarker(f, ".");
217
+ const result = f.run();
218
+ assert.equal(result.status, 0, result.stderr);
219
+ assert.doesNotMatch(result.stderr, /Unsafe tooling ownership/);
220
+ assert.match(result.stdout, /wizard-child:.*bootstrap-tools/);
221
+ } finally { f.cleanup(); }
222
+ });
223
+ posixTest("a tools directory whose mode shows the ACL marker + is still refused", () => {
224
+ const f = fixture();
225
+ try {
226
+ f.addPnpm(); f.wizard(); lsWithModeMarker(f, "+");
227
+ const result = f.run();
228
+ assert.notEqual(result.status, 0);
229
+ assert.match(result.stderr, /Unsafe tooling ownership/);
230
+ assert.doesNotMatch(result.stdout, /wizard-child/);
231
+ } finally { f.cleanup(); }
232
+ });
233
+ posixTest("a tools directory with a plain drwx------ mode is still accepted", () => {
234
+ const f = fixture();
235
+ try {
236
+ f.addPnpm(); f.wizard(); lsWithModeMarker(f, "");
237
+ const result = f.run();
238
+ assert.equal(result.status, 0, result.stderr);
239
+ assert.match(result.stdout, /wizard-child:/);
240
+ } finally { f.cleanup(); }
241
+ });
193
242
  posixTest("successful exit removes only the owned tools directory", () => {
194
243
  const f = fixture();
195
244
  try {
@@ -587,7 +636,18 @@ for (const [os, arch, platform, architecture] of [["Darwin", "arm64", "darwin",
587
636
  try {
588
637
  f.addPnpm(); f.wizard();
589
638
  const hash = artifactFor("node", platform, architecture).integrity.slice(7);
590
- assert.equal(f.run({ FAKE_OS: os, FAKE_ARCH: arch, FAKE_HASH: hash }).status, 0);
639
+ const result = f.run({ FAKE_OS: os, FAKE_ARCH: arch, FAKE_HASH: hash });
640
+ assert.equal(result.status, 0, JSON.stringify({
641
+ status: result.status,
642
+ signal: result.signal,
643
+ error: result.error ? {
644
+ name: result.error.name,
645
+ message: result.error.message,
646
+ code: "code" in result.error ? result.error.code : null,
647
+ } : null,
648
+ stdout: result.stdout,
649
+ stderr: result.stderr,
650
+ }));
591
651
  } finally { f.cleanup(); }
592
652
  });
593
653
  }
@@ -1193,9 +1253,11 @@ test("the CI native Windows gate requires exactly the native tests the Windows b
1193
1253
  const modes = /^const probeModes = \[([^\]]*)\] as const;$/m.exec(source)?.[1].split(",").filter((mode) => mode.trim().length > 0).length ?? 0;
1194
1254
  assert.ok(/^for \(const mode of probeModes\) \{\n\ttest\(`native Windows: /m.test(source.slice(source.indexOf("const probeModes"))));
1195
1255
  const ci = readFileSync(new URL("../.github/workflows/ci.yml", import.meta.url), "utf8");
1196
- const gate = /\[int\]\$passes\.Groups\[1\]\.Value -ne (\d+) -or/.exec(ci);
1197
- assert.ok(gate, "the gate compares the passed count exactly");
1198
- assert.ok(/\[int\]\$skips\.Groups\[1\]\.Value -ne 0/.test(ci), "0 skips stays required");
1199
1256
  assert.equal(literal + modes, 38);
1200
- assert.equal(Number(gate[1]), literal + modes);
1257
+ const installerJob = ci.slice(ci.indexOf("\n installer:"));
1258
+ assert.equal((installerJob.match(/node --experimental-strip-types --test --test-reporter=tap /g) ?? []).length, 1);
1259
+ assert.match(installerJob, /status=\("\$\{PIPESTATUS\[@\]\}"\)/);
1260
+ assert.match(installerJob, /if \[ "\$\{status\[0\]\}" -ne 0 \]; then exit "\$\{status\[0\]\}"; fi/);
1261
+ assert.match(installerJob, /if \[ "\$RUNNER_OS" = Windows \]; then\n\s+node scripts\/verify-installer-tap\.mjs < "\$RUNNER_TEMP\/installer\.tap"/);
1262
+ assert.doesNotMatch(installerJob, /--test-name-pattern "\^native Windows"/);
1201
1263
  });
@@ -306,8 +306,8 @@ test("/api/plan names the found and required version of an older Gentle Shell an
306
306
  const view = await plan(port, await login());
307
307
  assert.deepEqual(view.blockers.map((blocker: { code: string; tool: string }) => [blocker.code, blocker.tool]), [["incompatible-tool", "shell"]]);
308
308
  assert.equal(view.blockers[0].guidance,
309
- "Gentle Shell 3.4.0 is installed globally with pnpm, but this installer needs 4.5.1 or newer. Nothing was replaced. " +
310
- "Update it with `pnpm add -g gentle-pi@4.5.1`, or remove it with `pnpm remove -g gentle-pi`, then select Check again.");
309
+ "Gentle Shell 3.4.0 is installed globally with pnpm, but this installer needs 4.6.0 or newer. Nothing was replaced. " +
310
+ "Update it with `pnpm add -g gentle-pi@4.6.0`, or remove it with `pnpm remove -g gentle-pi`, then select Check again.");
311
311
  assert.deepEqual(view.actions, []);
312
312
  } finally {
313
313
  await host.close("test");
@@ -1,14 +1,13 @@
1
1
  import test from 'node:test';
2
2
  import assert from 'node:assert/strict';
3
- import { mkdirSync, mkdtempSync, writeFileSync } from 'node:fs';
4
- import { basename, dirname, join, parse, resolve } from 'node:path';
3
+ import { mkdtempSync, writeFileSync } from 'node:fs';
4
+ import { tmpdir } from 'node:os';
5
+ import { basename, dirname, join, parse } from 'node:path';
5
6
  import { getSystemErrorName } from 'node:util';
6
7
  import { windowsProcessCheck, windowsBootstrapReason } from '../scripts/installer-windows.mjs';
7
8
 
8
9
  // Only owned inert Node children. Never invoke PowerShell, ACL/storage or setup.
9
- const base = resolve('odd/checks/issue-1921-windows-prerequisite-diagnostics');
10
- mkdirSync(base, { recursive: true });
11
- const root = mkdtempSync(join(base, 'inert-'));
10
+ const root = mkdtempSync(join(tmpdir(), 'gentle-installer-diagnostics-1921-'));
12
11
  const fixture = join(root, 'child.mjs');
13
12
  writeFileSync(fixture, `import { writeSync } from 'node:fs';
14
13
  const mode = process.argv[2];
@@ -0,0 +1,28 @@
1
+ import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
2
+ import { tmpdir } from "node:os";
3
+ import { join } from "node:path";
4
+
5
+ // Without GENTLE_PI_CONFIG_HOME an extension reads ~/.pi/gentle-ai, so a
6
+ // developer's saved preferences (keymaps.json among them) would leak into
7
+ // tests. isolatedConfigEnv gives each call a fresh empty config home unless
8
+ // the test owns one; removeIsolatedConfigHomes deletes them after the file.
9
+ const homes: string[] = [];
10
+
11
+ export function isolatedConfigEnv(env: NodeJS.ProcessEnv = process.env): NodeJS.ProcessEnv {
12
+ if (env.GENTLE_PI_CONFIG_HOME !== undefined) return env;
13
+ const home = mkdtempSync(join(tmpdir(), "gentle-config-"));
14
+ homes.push(home);
15
+ return { ...env, GENTLE_PI_CONFIG_HOME: home };
16
+ }
17
+
18
+ /** A fresh config home whose keymaps.json holds `bindings`. */
19
+ export function keymapsConfigHome(bindings: Record<string, string | null>): string {
20
+ const home = mkdtempSync(join(tmpdir(), "gentle-keymaps-"));
21
+ homes.push(home);
22
+ writeFileSync(join(home, "keymaps.json"), JSON.stringify({ schema: 1, bindings }));
23
+ return home;
24
+ }
25
+
26
+ export function removeIsolatedConfigHomes(): void {
27
+ for (const home of homes.splice(0)) rmSync(home, { recursive: true, force: true });
28
+ }