gentle-pi 5.0.0 → 5.1.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 (234) hide show
  1. package/README.md +1 -1
  2. package/assets/agents/gentle-ai-explore.md +3 -6
  3. package/assets/agents/gentle-ai-verify.md +1 -1
  4. package/assets/agents/gentle-ai-worker.md +9 -9
  5. package/assets/agents/jd-fix-agent.md +1 -1
  6. package/assets/agents/jd-judge-a.md +0 -1
  7. package/assets/agents/jd-judge-b.md +0 -1
  8. package/assets/migrations/agent-body-history.json +6 -0
  9. package/assets/orchestrator-full-delegation.md +1 -1
  10. package/assets/orchestrator-maintenance.md +11 -0
  11. package/assets/orchestrator-quota-recovery.md +1 -1
  12. package/assets/orchestrator-skills.md +10 -0
  13. package/assets/orchestrator-verification.md +9 -7
  14. package/assets/orchestrator.md +1 -1
  15. package/bin/gentle-shell.mjs +67 -15
  16. package/contracts/review-provider-contract-mirror/provider-contract.lock.json +10 -10
  17. package/contracts/review-provider-contract-mirror/{v1.6.0 → v1.7.0}/bundle/manifest.json +5 -5
  18. package/contracts/review-provider-contract-mirror/{v1.6.0 → v1.7.0}/bundle/orchestration/pi.md +5 -3
  19. package/contracts/review-provider-contract-mirror/{v1.6.0 → v1.7.0}/bundle/routing/pi.md +1 -1
  20. package/contracts/review-provider-contract-mirror/{v1.6.0 → v1.7.0}/bundle/schemas/lens.schema.json +3 -3
  21. package/contracts/review-provider-contract-mirror/v1.7.0/bundle/vectors/lens.json +1 -0
  22. package/contracts/review-provider-contract-mirror/{v1.6.0 → v1.7.0}/generated/provider-capabilities.baseline.json +3 -3
  23. package/contracts/review-provider-contract-mirror/{v1.6.0 → v1.7.0}/generated/provider-roles.baseline.json +3 -3
  24. package/docs/bundled-install.md +2 -2
  25. package/docs/delegated-verification.md +8 -4
  26. package/docs/desktop-feed.md +15 -6
  27. package/docs/desktop-rpc.md +44 -20
  28. package/docs/gentle-shell-desktop.md +10 -3
  29. package/docs/gentle-shell.md +17 -13
  30. package/docs/install-wizard.md +2 -2
  31. package/docs/odd-preparation-continuity.md +2 -2
  32. package/docs/permission-modes.md +10 -2
  33. package/docs/readme-reference.md +46 -11
  34. package/docs/session-profile-format.md +33 -7
  35. package/docs/work-continuity.md +7 -7
  36. package/docs/yolo-mode.md +1 -1
  37. package/extensions/child-context.ts +2 -11
  38. package/extensions/gentle-agents.ts +47 -28
  39. package/extensions/gentle-ai.ts +573 -353
  40. package/extensions/gentle-desktop-feed.ts +13 -3
  41. package/extensions/gentle-fast.ts +9 -2
  42. package/extensions/gentle-shell.ts +142 -55
  43. package/extensions/gentle-tps.ts +5 -0
  44. package/extensions/quiet-tools.ts +13 -22
  45. package/extensions/skill-registry.ts +9 -1
  46. package/herdr/mods/gentle-agents/snapshot.js +30 -23
  47. package/herdr/mods/gentle-chat/feed.js +6 -0
  48. package/herdr/mods/gentle-chat/main.js +76 -16
  49. package/herdr/mods/gentle-chat/session.js +13 -5
  50. package/herdr/mods/gentle-chat/snapshot.js +30 -23
  51. package/herdr/mods/gentle-chat/ui.js +7 -1
  52. package/herdr/mods/gentle-inspector/main.js +2 -0
  53. package/herdr/mods/gentle-inspector/snapshot.js +30 -23
  54. package/herdr/mods/gentle-palette/main.js +1 -1
  55. package/herdr/mods/gentle-palette/snapshot.js +30 -23
  56. package/herdr/mods/gentle-pane/snapshot.js +30 -23
  57. package/herdr/mods/gentle-sidebar/snapshot.js +30 -23
  58. package/herdr/mods/gentle-spaces/snapshot.js +30 -23
  59. package/herdr/mods/gentle-status/snapshot.js +30 -23
  60. package/herdr/mods/gentle-tabs/main.js +3 -2
  61. package/herdr/mods/gentle-tabs/new-tab.js +9 -0
  62. package/herdr/mods/gentle-tabs/snapshot.js +30 -23
  63. package/herdr/mods/gentle-tokens/snapshot.js +30 -23
  64. package/lib/agent-profiles.ts +50 -10
  65. package/lib/agents-config.ts +59 -4
  66. package/lib/agents-runner.ts +34 -1
  67. package/lib/auto-permission-runtime.ts +2 -1
  68. package/lib/background-jobs-tools.ts +24 -16
  69. package/lib/claude-bridge-config.ts +41 -0
  70. package/lib/desktop-agent-definitions-service.ts +10 -6
  71. package/lib/desktop-command-rpc.ts +71 -0
  72. package/lib/desktop-feed-sources.ts +44 -1
  73. package/lib/desktop-feed.ts +41 -29
  74. package/lib/desktop-rpc-agent-definitions.ts +7 -3
  75. package/lib/desktop-rpc-changes.ts +13 -4
  76. package/lib/desktop-rpc-config.ts +106 -3
  77. package/lib/exploration-budget.ts +3 -7
  78. package/lib/gentle-design.ts +23 -4
  79. package/lib/gentle-shell-desktop.ts +85 -0
  80. package/lib/gentle-shell-launcher.ts +106 -3
  81. package/lib/mcp-config.ts +214 -0
  82. package/lib/native-review-cli.ts +78 -34
  83. package/lib/odd-phase-inference.ts +1 -1
  84. package/lib/orchestrator-mode-policy.ts +25 -12
  85. package/lib/path-consent-fence.ts +113 -0
  86. package/lib/pi-settings.ts +157 -0
  87. package/lib/review-continuation-registry.ts +7 -20
  88. package/lib/review-coordinator.ts +5 -0
  89. package/lib/review-host-relay.ts +2 -35
  90. package/lib/review-integration-v2.ts +31 -12
  91. package/lib/sensitive-paths.ts +22 -2
  92. package/lib/session-profile-freeze.ts +11 -4
  93. package/lib/session-worktree-registry.ts +11 -5
  94. package/lib/shell-card.ts +27 -1
  95. package/lib/shell-changes-view.ts +6 -2
  96. package/lib/shell-changes.ts +94 -37
  97. package/lib/shell-git-worker.ts +158 -0
  98. package/lib/shell-idle-changes.ts +88 -0
  99. package/lib/shell-untracked-cache.ts +142 -0
  100. package/lib/shell-untracked-lines.ts +178 -0
  101. package/lib/tps-policy.ts +85 -0
  102. package/lib/vim-editor-adapter.ts +3 -2
  103. package/lib/voice-artifacts.ts +8 -1
  104. package/lib/voice-install.ts +7 -3
  105. package/lib/yolo-session-policy.ts +2 -2
  106. package/package.json +1 -1
  107. package/runtime/gentle-shell-desktop.mjs +85 -0
  108. package/runtime/gentle-shell-launcher.mjs +106 -3
  109. package/runtime/native-review-cli.mjs +77 -33
  110. package/runtime/review-integration-v2.mjs +31 -12
  111. package/runtime/sensitive-paths.mjs +22 -2
  112. package/scripts/gentle-ai-installer.mjs +10 -10
  113. package/scripts/main-channel.mjs +27 -7
  114. package/scripts/verify-package-files.mjs +13 -12
  115. package/skills/rdd-defect-workflow/SKILL.md +2 -2
  116. package/tests/agent-profiles-workflow.test.ts +102 -0
  117. package/tests/agents-config.test.ts +1 -2
  118. package/tests/agents-protocol.test.ts +1 -1
  119. package/tests/agents-runner.test.ts +94 -2
  120. package/tests/append-system-prompt-route.test.ts +16 -11
  121. package/tests/auto-permission-runtime.test.ts +4 -4
  122. package/tests/bounded-stop-contract.test.ts +50 -62
  123. package/tests/child-context-files.test.ts +6 -6
  124. package/tests/child-web-package.test.ts +1 -1
  125. package/tests/controlled-engineering-editor.test.ts +192 -0
  126. package/tests/controlled-engineering-launch.test.ts +136 -0
  127. package/tests/controlled-engineering.test.ts +244 -0
  128. package/tests/delivery-b-rendered-surfaces.test.ts +1 -1
  129. package/tests/desktop-feed-tool-summaries.test.ts +1 -1
  130. package/tests/desktop-feed-transcript.test.ts +17 -0
  131. package/tests/desktop-feed.test.ts +141 -7
  132. package/tests/desktop-liveness.test.ts +125 -0
  133. package/tests/desktop-persona.test.ts +17 -0
  134. package/tests/desktop-rpc-agent-definitions.test.ts +23 -2
  135. package/tests/desktop-rpc-changes.test.ts +80 -3
  136. package/tests/desktop-rpc-config-mcp-fidelity.test.ts +106 -0
  137. package/tests/desktop-rpc-config-readonly-stores.test.ts +458 -0
  138. package/tests/desktop-rpc-config.test.ts +5 -2
  139. package/tests/desktop-rpc-design.test.ts +21 -0
  140. package/tests/desktop-rpc-session-snapshot-commands.test.ts +50 -0
  141. package/tests/desktop-session-switch.test.ts +237 -0
  142. package/tests/desktop-target-session.test.ts +104 -0
  143. package/tests/destructive-command-guard.test.ts +187 -0
  144. package/tests/devbinary/pi-host-relay.devtest.ts +73 -9
  145. package/tests/exploration-budget.test.ts +2 -26
  146. package/tests/fixtures/primary-session-prompt/gentleman.golden.md +14 -10
  147. package/tests/full-delegation-closure.test.ts +19 -9
  148. package/tests/generic-agent-tools.test.ts +3 -3
  149. package/tests/gentle-agents.test.ts +214 -9
  150. package/tests/gentle-ai-exploration-budget.test.ts +3 -2
  151. package/tests/gentle-ai-installer.test.ts +52 -51
  152. package/tests/gentle-ai.test.ts +29 -5
  153. package/tests/gentle-chat-read-failure.test.ts +74 -0
  154. package/tests/gentle-chat-session-read.test.ts +127 -0
  155. package/tests/gentle-design.test.ts +39 -0
  156. package/tests/gentle-shell-desktop.test.ts +108 -0
  157. package/tests/gentle-shell-launcher-auto-provision.test.ts +152 -0
  158. package/tests/gentle-shell-launcher-machine-output.test.ts +356 -0
  159. package/tests/gentle-shell.test.ts +93 -12
  160. package/tests/gentle-tps.test.ts +57 -0
  161. package/tests/independent-recovery-delivery.test.ts +15 -13
  162. package/tests/installer-preflight.test.ts +3 -2
  163. package/tests/job-turn-end-texts.test.ts +57 -0
  164. package/tests/lazy-module-contradictions-contract.test.ts +1 -2
  165. package/tests/main-channel.test.ts +12 -1
  166. package/tests/maintainer/desktop-rpc.maintest.ts +2 -2
  167. package/tests/native-review-capability-contract.test.ts +7 -1
  168. package/tests/native-review-cli.test.ts +113 -1
  169. package/tests/no-self-pause-contract.test.ts +8 -7
  170. package/tests/odd-phase-inference.test.ts +2 -2
  171. package/tests/odd-routing-canonical-ratchet.test.ts +1 -1
  172. package/tests/odd-routing-contract.test.ts +1 -1
  173. package/tests/orchestrator-budget.test.ts +7 -2
  174. package/tests/orchestrator-prompt-diet-contract.test.ts +5 -5
  175. package/tests/orchestrator-skills-inline-contract.test.ts +26 -0
  176. package/tests/package-manifest.test.ts +11 -16
  177. package/tests/packaged-agent-codemode.test.ts +79 -0
  178. package/tests/path-consent-fence.test.ts +326 -0
  179. package/tests/pi-update-launcher.test.ts +1 -1
  180. package/tests/primary-session-prompt.test.ts +9 -7
  181. package/tests/profile-fast-tier.test.ts +79 -4
  182. package/tests/progress-rule-contract.test.ts +54 -0
  183. package/tests/rdd-delivery-warning.test.ts +42 -4
  184. package/tests/review-actor-tool-deny.test.ts +1 -2
  185. package/tests/review-continuation-registry.test.ts +17 -17
  186. package/tests/review-controller-native-recovery.test.ts +100 -0
  187. package/tests/review-controller-native-routing.test.ts +129 -24
  188. package/tests/review-coordinator.test.ts +14 -0
  189. package/tests/review-host-relay-restart-parity.test.ts +2 -52
  190. package/tests/review-host-relay-routing.test.ts +57 -297
  191. package/tests/review-host-relay.test.ts +0 -46
  192. package/tests/review-integration-v2-forward.test.ts +39 -2
  193. package/tests/review-json-arguments.test.ts +30 -9
  194. package/tests/review-one-call-findings.test.ts +1 -0
  195. package/tests/review-untracked-inventory-replay.test.ts +181 -0
  196. package/tests/runtime-harness.mjs +27 -1
  197. package/tests/sensitive-path-tools.test.ts +155 -4
  198. package/tests/session-profile-extension.test.ts +90 -11
  199. package/tests/session-profile-freeze.test.ts +49 -2
  200. package/tests/session-profile-v1-compat.test.ts +11 -3
  201. package/tests/session-worktree-registry.test.ts +23 -0
  202. package/tests/shell-changes-idle-start.test.ts +510 -0
  203. package/tests/shell-changes-untracked-bound.test.ts +230 -0
  204. package/tests/shell-changes-view.test.ts +8 -2
  205. package/tests/shell-changes.test.ts +134 -0
  206. package/tests/shell-git-runner-stall.test.ts +74 -0
  207. package/tests/shell-git-worker-fallback.test.ts +140 -0
  208. package/tests/shell-git-worker-lifetime.test.ts +91 -0
  209. package/tests/shell-render-cache-runtime.test.ts +256 -3
  210. package/tests/shell-untracked-cache.test.ts +213 -0
  211. package/tests/short-check-routing-contract.test.ts +11 -7
  212. package/tests/skill-registry.test.ts +3 -3
  213. package/tests/support/chat-ui.ts +39 -0
  214. package/tests/t7-recovery-preservation.test.ts +68 -0
  215. package/tests/tps-policy.test.ts +96 -0
  216. package/tests/turn-end-rule-contract.test.ts +155 -0
  217. package/tests/turn-end-scope.test.ts +39 -0
  218. package/tests/verification-scoped-stop-contract.test.ts +1 -1
  219. package/tests/verification-tiers-contract.test.ts +4 -3
  220. package/tests/verify-first-launch-contract.test.ts +19 -7
  221. package/tests/vim-editor-adapter.test.ts +4 -4
  222. package/tests/voice-install.test.ts +97 -11
  223. package/tests/windows-hidden-processes.test.ts +11 -44
  224. package/tests/work-continuity-contract.test.ts +48 -55
  225. package/tests/yolo-session-policy.test.ts +2 -0
  226. package/contracts/review-provider-contract-mirror/v1.6.0/bundle/vectors/lens.json +0 -1
  227. package/extensions/codegraph-tools.ts +0 -437
  228. package/tests/child-codegraph-bootstrap.test.ts +0 -74
  229. package/tests/codegraph-tools.test.ts +0 -554
  230. /package/contracts/review-provider-contract-mirror/{v1.6.0 → v1.7.0}/bundle/README.md +0 -0
  231. /package/contracts/review-provider-contract-mirror/{v1.6.0 → v1.7.0}/bundle/schemas/refuter.schema.json +0 -0
  232. /package/contracts/review-provider-contract-mirror/{v1.6.0 → v1.7.0}/bundle/schemas/targeted-validator.schema.json +0 -0
  233. /package/contracts/review-provider-contract-mirror/{v1.6.0 → v1.7.0}/bundle/vectors/refuter.json +0 -0
  234. /package/contracts/review-provider-contract-mirror/{v1.6.0 → v1.7.0}/bundle/vectors/targeted-validator.json +0 -0
package/docs/yolo-mode.md CHANGED
@@ -23,7 +23,7 @@ While it is active:
23
23
 
24
24
  - Every shell-guard confirmation is waived, data loss included: recursive `rm`, SQL drops, ordinary pushes, rebases, forced branch deletion, `npm publish` and configured guardrail `confirm`/`block` rules all run without dialogs. Code-level hard denies stay blocked (`git reset --hard`, forced clean, force push); see below.
25
25
  - The Auto classifier does not run.
26
- - The **sensitive-path guard stays hard-blocked**: `read`, `write` and `edit` of `.env` files, `.ssh`, keychains, `*.pem/*.key/*.p12/*.pfx`, `auth.json`, `secrets/` directories and cloud credential files are refused in every mode, Super Yolo included.
26
+ - The **sensitive-path guard stays on**: the `read`, `grep`, `find`, `ls`, `write` and `edit` tools refuse `.env` files, `.ssh`, keychains, `*.pem/*.key/*.p12/*.pfx`, `auth.json`, `secrets/` directories and cloud credential files in every mode, Super Yolo included. A shell command is judged as a whole line, and a sensitive path in it is blocked when the line contains a command that shows, copies, sends, opens, deletes or prints the environment (`cat`, `grep`, `cp`, `tar`, `scp`, `curl`, `git`, `vim`, `rm`, `printenv`, `env`, `xargs` and similar), `cd`/`pushd`, or `.`/`source` (env files excepted); when the path is under `.ssh` and the line contains a program that creates files there (`install`, `touch`, `mkdir`, `ssh-keygen`, `ssh-copy-id`); or when the path is a script rather than a path (`bash -c "true;cat key"`), the first word of a command, or a redirection target (`< .env`, `> .env`). Any other command may hand the file to a program, as in `docker compose --env-file .env.local up` or `ssh -i ~/.ssh/id_ed25519 host`, but a line that uses a secret file and also holds a reader (`docker compose --env-file .env.local logs app | tail -50`) is blocked as a whole: run the parts separately. The identity word of `ssh -i key host …` is exempt from the `.ssh` writer rule only, so `ssh -i key host npm install` passes. `printenv` and `env` are blocked, but not every way of printing the environment is: `export -p`, `declare`, `set` and `echo "$VAR"` after sourcing an env file pass. Other limits: the guard does not see a program not on the list that prints or sends a file, a write into `.ssh` through `docker run -v` or an unlisted program, a reader whose name is assembled at run time (`x=cat; $x .env`), an interpreter that receives the key as an argument, or what a program prints.
27
27
  - Code-level catastrophic denies remain: `rm -rf /`, `rm -rf ~`, `--no-preserve-root`, `git reset --hard`, forced clean and force push are blocked without a dialog.
28
28
  - `ask_user` tools, provider consent, maintenance/recovery authorization and opaque-token decisions are never automatically answered.
29
29
  - `/gentle:yolo status` identifies Super Yolo while it is active, and `/gentle:yolo disable` returns to Normal. Children never inherit Super Yolo; their bounded delegation and child guards are unchanged.
@@ -1,23 +1,14 @@
1
1
  import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
2
2
  import { filterChildSessionContextFiles, type ContextFileOptions } from "../lib/child-context-files.ts";
3
- import { CHILD_SKILLS_CATALOG_ENV, REQUESTED_TOOLS_ENV } from "../lib/agents-runner.ts";
4
- import { registerCodeGraphTool } from "./codegraph-tools.ts";
3
+ import { CHILD_SKILLS_CATALOG_ENV } from "../lib/agents-runner.ts";
5
4
 
6
5
  // gentle-shell#1587: delegated children drop the orchestrator-only gentle-ai
7
6
  // managed blocks and the engram-protocol memory block from their context files
8
7
  // and keep everything else. Gentle Agents passes this file to every child with
9
8
  // --extension because children do not load the gentle-pi package in the
10
- // isolated Gentle Shell home. At startup it also supplies the existing
11
- // CodeGraph implementation only when explicitly requested and absent (the full
12
- // package already registers it). Outside a child session it is inert.
9
+ // isolated Gentle Shell home. Outside a child session it is inert.
13
10
  export function createChildContextExtension(env: NodeJS.ProcessEnv = process.env): (pi: ExtensionAPI) => void {
14
11
  return (pi) => {
15
- const requested = (env[REQUESTED_TOOLS_ENV] ?? "").split(",").map(name => name.trim());
16
- if (env.GENTLE_PI_AGENTS_CHILD === "1" && requested.includes("codegraph")) {
17
- pi.on("session_start", () => {
18
- if (!pi.getAllTools().some(tool => tool.name === "codegraph")) registerCodeGraphTool(pi);
19
- });
20
- }
21
12
  pi.on("before_agent_start", (event) => {
22
13
  if (env.GENTLE_PI_AGENTS_CHILD !== "1") return undefined;
23
14
  // The filtered copies replace contextFiles on the same options object
@@ -5,6 +5,7 @@ import type { ThinkingLevel } from "../lib/model-routing-authority.ts";
5
5
  import { agentsViewKey, agentsCollapseKey, agentsStopKey } from "../lib/agents-keys.ts";
6
6
  import { loadKeymaps } from "../lib/keymaps.ts";
7
7
  import { CHILD_TIER_ENV } from "../lib/openai-fast-tier.ts";
8
+ import { CONTROLLED_ENGINEERING_ENV, workflowFromProfile, type ControlledEngineeringRole } from "../lib/orchestrator-mode-policy.ts";
8
9
  import { spawn } from "node:child_process";
9
10
  import { Type } from "typebox";
10
11
  import { recordReviewMutation } from "../lib/review-reminder-receipt.ts";
@@ -73,7 +74,7 @@ import { createNativeFullscreenInteraction } from "../lib/native-fullscreen-inte
73
74
  import { HERDR_BUSY_CHANNEL, nextHerdrBusyAction, type HerdrBusyEmitted } from "../lib/herdr-busy.ts";
74
75
  import { HERDR_DESKTOP_TASKS, HERDR_DESKTOP_TASKS_REQUEST, HERDR_DESKTOP_TASK_FINISHED, HERDR_DESKTOP_JOBS, HERDR_DESKTOP_JOB_SETTLED, HERDR_DESKTOP_CONSULT, HERDR_DESKTOP_SEND, HERDR_DESKTOP_INBOUND, type HerdrDesktopInbound, type HerdrDesktopJobSettled } from "../lib/herdr-desktop-events.ts";
75
76
  import { AGENTS_GLYPH, agentsCardTone, agentsSpend, agentsSummary, renderAgentsAlert, renderAgentsCard, renderAgentsSection, widgetExpiryMs, widgetRows } from "../lib/agents-widget.ts";
76
- import { CARD_TONE, cardAwaitingResult, cardBodyRows, cardBottom, cardInnerWidth, cardRunningLine, cardTop, floatRows, headingFits, markCardResult, panelHeaderRow, panelInnerWidth, renderCard, type CardRowContext, type CardTheme, type CardTone } from "../lib/shell-card.ts";
77
+ import { CARD_TONE, cachedCard, cardAwaitingResult, cardBodyRows, cardBottom, cardInnerWidth, cardRunningLine, cardTop, floatRows, headingFits, markCardResult, panelHeaderRow, panelInnerWidth, renderCard, type CardRowContext, type CardTheme, type CardTone } from "../lib/shell-card.ts";
77
78
  import { openInExternalEditor } from "./gentle-shell.ts";
78
79
  import { gentlePiConfigHome } from "../lib/agent-home.ts";
79
80
  import { resolveAgentHomeDirectory } from "../lib/agent-model-resolution.ts";
@@ -197,6 +198,13 @@ export interface SessionTransportFactory {
197
198
  createClient(registry: SessionTransportRegistry, sessionId: string): SessionTransportClient;
198
199
  }
199
200
 
201
+ /** Which Controlled Engineering section each child agent gets (controlled-engineering S3). */
202
+ const CONTROLLED_ENGINEERING_AGENT_ROLES: Partial<Record<string, ControlledEngineeringRole>> = {
203
+ "gentle-ai-worker": "writer",
204
+ "jd-fix-agent": "writer",
205
+ "gentle-ai-verify": "verify",
206
+ };
207
+
200
208
  export interface AgentsDeps extends RunnerDeps {
201
209
  home: string;
202
210
  agentHome?: string;
@@ -1531,7 +1539,7 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
1531
1539
  if (tasks + running === 0) return undefined;
1532
1540
  return {
1533
1541
  block: true,
1534
- reason: `Standalone sleep is blocked while background work is active (${tasks} task(s), ${running} job(s)). End the turn now; each completion arrives automatically as a session message and starts a new turn.`,
1542
+ reason: `Standalone sleep is blocked while background work is active (${tasks} task(s), ${running} job(s)). Continue independent in-scope work; end the turn to wait only when none remains. Each completion arrives automatically as a session message and starts a new turn.`,
1535
1543
  };
1536
1544
  });
1537
1545
  let activeAgentRuns = 0;
@@ -2242,23 +2250,21 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
2242
2250
  const content = message.content as string | Array<{ type: string; text?: string }>;
2243
2251
  const text = typeof content === "string" ? content : content.map((part) => (part.type === "text" ? (part.text ?? "") : "")).join("\n");
2244
2252
  const tone = details?.status === "completed" ? CARD_TONE.SUCCESS : CARD_TONE.ERROR;
2245
- const hint = expandHint(options.expanded);
2253
+ const expanded = options.expanded;
2254
+ const hint = expandHint(expanded);
2246
2255
  // The same answer card as the tool result: iris chrome, the state pill
2247
2256
  // on top, the answer below ("answer" keeps its name through the flow).
2248
2257
  const t = agentTheme(theme, tone);
2249
2258
  const facts = details?.status ? statusCardFacts({ gentleAgents: details }) : undefined;
2250
2259
  const chips = [details?.agent, modelChip(facts?.model), facts?.thinking ? sanitizeTerminalText(facts.thinking) : undefined];
2251
- const answer = options.expanded ? text.split("\n") : agentResultPreview(text).split("\n").filter((line) => line.trim() !== "");
2260
+ const answer = expanded ? text.split("\n") : agentResultPreview(text).split("\n").filter((line) => line.trim() !== "");
2252
2261
  const body = facts ? [statusCardRows(facts, t, false)[0], ...answer] : answer;
2253
- return {
2254
- render(width: number) {
2255
- // Same one-line heading budget as the tool cards: the answer card's
2256
- // inner columns are the style's, not the terminal's.
2257
- const subtitle = fitSubject({ title: "Agent answer", tone, glyph: ACTION_GLYPH.result }, hint, panelInnerWidth(theme, width, tone), chips);
2258
- return renderCard({ title: "Agent answer", subtitle, body, tone, glyph: ACTION_GLYPH.result }, t, width, { expanded: options.expanded, previewRows: 3, hint });
2259
- },
2260
- invalidate() {},
2261
- };
2262
+ return cachedCard((width) => {
2263
+ // Same one-line heading budget as the tool cards: the answer card's
2264
+ // inner columns are the style's, not the terminal's.
2265
+ const subtitle = fitSubject({ title: "Agent answer", tone, glyph: ACTION_GLYPH.result }, hint, panelInnerWidth(theme, width, tone), chips);
2266
+ return renderCard({ title: "Agent answer", subtitle, body, tone, glyph: ACTION_GLYPH.result }, t, width, { expanded, previewRows: 3, hint });
2267
+ });
2262
2268
  });
2263
2269
 
2264
2270
  // A stale completion is appended as a custom entry: durable transcript
@@ -2803,12 +2809,24 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
2803
2809
  if (profile.tier && childModel?.provider && childModel.id) {
2804
2810
  childEnv[CHILD_TIER_ENV] = JSON.stringify({ tier: profile.tier, model: `${childModel.provider}/${childModel.id}` });
2805
2811
  }
2812
+ // controlled-engineering S3: only the writers and the verifier, and only when
2813
+ // the launching session's profile enables the option; read live per launch.
2814
+ const sessionProfileName = sessionProfile.kind === "explicit" ? sessionProfile.name : sessionProfile.profile?.name;
2815
+ delete childEnv[CONTROLLED_ENGINEERING_ENV];
2816
+ const controlledRole = CONTROLLED_ENGINEERING_AGENT_ROLES[agent.name];
2817
+ if (controlledRole !== undefined && sessionProfileName !== undefined
2818
+ && workflowFromProfile(profileConfigHome, sessionProfileName).controlledEngineering === true) {
2819
+ childEnv[CONTROLLED_ENGINEERING_ENV] = controlledRole;
2820
+ }
2806
2821
  if (foreign) for (const key of inheritedUnsafeGitEnvironmentKeys(childEnv)) delete childEnv[key];
2807
2822
  const extensions = childExtensionRequest(deps.env, deps.childExtensionPaths);
2808
2823
  if (profile.tier && !parseChildPackageInjection(deps.env)) {
2809
2824
  const fastPath = fileURLToPath(new URL("./gentle-fast.ts", import.meta.url));
2810
2825
  if (existsSync(fastPath)) extensions.extensionPaths = [...new Set([...(extensions.extensionPaths ?? []), fastPath])];
2811
2826
  }
2827
+ const activeMcpTools = typeof pi.getAllTools === "function"
2828
+ ? pi.getAllTools().map((tool) => tool.name).filter((name) => name.startsWith("mcp__"))
2829
+ : undefined;
2812
2830
  const request: TaskRequest = {
2813
2831
  agent,
2814
2832
  prompt,
@@ -2817,6 +2835,7 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
2817
2835
  mode,
2818
2836
  cwd: target ?? parentWorktreeRoot,
2819
2837
  parentSessionId,
2838
+ ...(activeMcpTools && activeMcpTools.length > 0 ? { mcpTools: activeMcpTools } : {}),
2820
2839
  ...(admittedModel === undefined ? {} : { beforeSpawn: () => {
2821
2840
  if (!current()) throw new Error("Writer session changed before spawn.");
2822
2841
  registry.validate(originalCwd);
@@ -2834,8 +2853,7 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
2834
2853
  thinking: profile.thinking,
2835
2854
  ...(() => {
2836
2855
  // The chain of the profile this launch resolved, else the active profile's.
2837
- const name = sessionProfile.kind === "explicit" ? sessionProfile.name : sessionProfile.profile?.name;
2838
- const fallbacks = profileFallbackChain(profileConfigHome, name, agent.name);
2856
+ const fallbacks = profileFallbackChain(profileConfigHome, sessionProfileName, agent.name);
2839
2857
  return fallbacks.length ? { fallbacks } : {};
2840
2858
  })(),
2841
2859
  sessionDir,
@@ -3080,20 +3098,21 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
3080
3098
  facts?.thinking ? headingText(facts.thinking) : undefined,
3081
3099
  ]
3082
3100
  : [];
3083
- return {
3084
- render(width: number) {
3085
- if (width <= 0) return [];
3086
- const hint = expandHint(options.expanded);
3087
- return floatRows(tone, iris, width, (inner) => ({
3088
- ...(ownHeading ? {
3089
- head: [cardTop({ title: heading, subtitle: fitSubject({ title: heading, tone, glyph }, hint, inner, ownChips), body: [], tone, glyph }, iris, inner, hint)],
3090
- } : { afterHeading: true }),
3091
- body: cardBodyRows(fitRows ? rows.map((row) => truncateToWidth(row, cardInnerWidth(inner), "…")) : rows, tone, iris, inner, { expanded: options.expanded, previewRows: ownHeading ? 3 : undefined }),
3092
- bottom: cardBottom(tone, iris, inner),
3093
- }));
3094
- },
3095
- invalidate() {},
3101
+ const expanded = options.expanded;
3102
+ const render = (width: number) => {
3103
+ if (width <= 0) return [];
3104
+ const hint = expandHint(expanded);
3105
+ return floatRows(tone, iris, width, (inner) => ({
3106
+ ...(ownHeading ? {
3107
+ head: [cardTop({ title: heading, subtitle: fitSubject({ title: heading, tone, glyph }, hint, inner, ownChips), body: [], tone, glyph }, iris, inner, hint)],
3108
+ } : { afterHeading: true }),
3109
+ body: cardBodyRows(fitRows ? rows.map((row) => truncateToWidth(row, cardInnerWidth(inner), "…")) : rows, tone, iris, inner, { expanded, previewRows: ownHeading ? 3 : undefined }),
3110
+ bottom: cardBottom(tone, iris, inner),
3111
+ }));
3096
3112
  };
3113
+ // Pi reconstructs the result on output, expansion, and theme changes;
3114
+ // the separate call still reads its live task and shared state.
3115
+ return options.isPartial === false ? cachedCard(render) : { render, invalidate() {} };
3097
3116
  },
3098
3117
  async execute(_id, params, signal, _onUpdate, ctx) {
3099
3118
  return execute(params as Record<string, unknown>, ctx, signal);