@pi-unipi/unipi 3.0.0-alpha.2 → 3.0.0-alpha.21

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 (359) hide show
  1. package/CHANGELOG.md +292 -0
  2. package/README.md +8 -11
  3. package/docs/prefix-cache-architecture.md +14 -0
  4. package/package.json +22 -24
  5. package/packages/ask-user/README.md +55 -107
  6. package/packages/ask-user/ask-ui.ts +306 -732
  7. package/packages/ask-user/clipboard.ts +50 -0
  8. package/packages/ask-user/config.ts +74 -78
  9. package/packages/ask-user/package.json +2 -2
  10. package/packages/ask-user/questions.ts +151 -0
  11. package/packages/ask-user/skills/ask-user/SKILL.md +59 -133
  12. package/packages/ask-user/tools.ts +198 -432
  13. package/packages/autocomplete/package.json +1 -1
  14. package/packages/autocomplete/src/constants.ts +38 -43
  15. package/packages/autocomplete/src/sorting.ts +8 -0
  16. package/packages/background-tasks/package.json +2 -2
  17. package/packages/background-tasks/src/config.ts +0 -73
  18. package/packages/background-tasks/src/index.ts +20 -16
  19. package/packages/background-tasks/src/registry.ts +1 -171
  20. package/packages/background-tasks/src/types.ts +0 -32
  21. package/packages/btw/README.md +13 -56
  22. package/packages/btw/extensions/btw.ts +403 -1796
  23. package/packages/btw/package.json +5 -2
  24. package/packages/btw/skills/btw/SKILL.md +7 -143
  25. package/packages/compactor/README.md +56 -287
  26. package/packages/compactor/package.json +5 -9
  27. package/packages/compactor/skills/compactor/SKILL.md +13 -20
  28. package/packages/compactor/src/card.ts +90 -0
  29. package/packages/compactor/src/commands/index.ts +73 -130
  30. package/packages/compactor/src/compaction/compact-args.ts +5 -3
  31. package/packages/compactor/src/compaction/filter-noise.ts +1 -1
  32. package/packages/compactor/src/compaction/hooks.ts +487 -311
  33. package/packages/compactor/src/compaction/source.ts +178 -0
  34. package/packages/compactor/src/compaction/summarize.ts +586 -52
  35. package/packages/compactor/src/config/manager.ts +130 -127
  36. package/packages/compactor/src/config/schema.ts +32 -48
  37. package/packages/compactor/src/index.ts +40 -431
  38. package/packages/compactor/src/info-screen.ts +44 -190
  39. package/packages/compactor/src/session/recall-blocks.ts +1 -1
  40. package/packages/compactor/src/stats.ts +76 -0
  41. package/packages/compactor/src/tools/context-budget.ts +17 -34
  42. package/packages/compactor/src/tools/ctx-doctor.ts +45 -36
  43. package/packages/compactor/src/tools/register.ts +29 -269
  44. package/packages/compactor/src/types.ts +47 -186
  45. package/packages/core/README.md +25 -0
  46. package/packages/core/child-agent.ts +1 -0
  47. package/packages/core/command-echo.ts +63 -0
  48. package/packages/core/compaction-context.ts +41 -0
  49. package/packages/core/constants.ts +8 -38
  50. package/packages/core/events.ts +0 -53
  51. package/packages/core/fusion-status.ts +4 -0
  52. package/packages/core/global.d.ts +10 -0
  53. package/packages/core/harness-messages.ts +392 -0
  54. package/packages/core/index.ts +14 -0
  55. package/packages/core/kanboard-status.ts +49 -0
  56. package/packages/core/long-horizon-owner-status.ts +46 -0
  57. package/packages/core/model-cache.ts +81 -7
  58. package/packages/core/package.json +6 -3
  59. package/packages/core/src/attach/detect.ts +163 -0
  60. package/packages/core/src/child-agent/child-args.ts +31 -0
  61. package/packages/core/src/child-agent/delivery.ts +41 -0
  62. package/packages/core/src/child-agent/index.ts +5 -0
  63. package/packages/core/src/child-agent/readers.ts +203 -0
  64. package/packages/core/src/child-agent/runtime.ts +584 -0
  65. package/packages/core/src/evidence.ts +78 -0
  66. package/packages/core/src/hints/browser.ts +278 -0
  67. package/packages/core/src/hints/crab-data.ts +19 -0
  68. package/packages/core/src/hints/index.ts +865 -0
  69. package/packages/core/src/hints/lines.ts +607 -0
  70. package/packages/core/src/hints/store.ts +120 -0
  71. package/packages/core/src/jev/chatter.ts +24 -0
  72. package/packages/core/src/jev/settings.ts +177 -14
  73. package/packages/core/src/package-colors.ts +2 -0
  74. package/packages/core/src/settings/catalog.ts +39 -15
  75. package/packages/core/src/settings/engine.ts +48 -2
  76. package/packages/core/src/settings/hub.ts +83 -20
  77. package/packages/core/src/settings/open.ts +49 -0
  78. package/packages/core/src/settings/schema.ts +27 -7
  79. package/packages/core/src/tui/hub-kit.ts +18 -5
  80. package/packages/core/src/tui/kit.ts +198 -0
  81. package/packages/core/src/tui/progress.ts +73 -0
  82. package/packages/core/src/turn/arbiter.ts +290 -0
  83. package/packages/footer/README.md +4 -6
  84. package/packages/footer/package.json +3 -3
  85. package/packages/footer/src/glance-editor.ts +19 -11
  86. package/packages/footer/src/help.ts +1 -1
  87. package/packages/footer/src/index.ts +36 -3
  88. package/packages/footer/src/presets.ts +3 -4
  89. package/packages/footer/src/rendering/icons.ts +0 -20
  90. package/packages/footer/src/segments/compactor.ts +52 -142
  91. package/packages/footer/src/segments/status-ext.ts +0 -1
  92. package/packages/fusion/README.md +14 -4
  93. package/packages/fusion/package.json +4 -3
  94. package/packages/fusion/src/child-args.ts +1 -0
  95. package/packages/fusion/src/index.ts +161 -8
  96. package/packages/fusion/src/pi-settings.ts +57 -0
  97. package/packages/fusion/src/picker.ts +186 -51
  98. package/packages/fusion/src/preset.ts +56 -2
  99. package/packages/fusion/src/prompts.ts +1 -1
  100. package/packages/fusion/src/sidekick-runtime.ts +1 -420
  101. package/packages/fusion/src/tools.ts +107 -128
  102. package/packages/fusion/src/transcript.ts +27 -85
  103. package/packages/info-screen/package.json +2 -2
  104. package/packages/input-shortcuts/README.md +18 -30
  105. package/packages/input-shortcuts/package.json +2 -2
  106. package/packages/input-shortcuts/src/burst.ts +88 -0
  107. package/packages/input-shortcuts/src/chord-overlay.ts +20 -70
  108. package/packages/input-shortcuts/src/cleared-input.ts +97 -0
  109. package/packages/input-shortcuts/src/index.ts +99 -193
  110. package/packages/input-shortcuts/src/last-response.ts +40 -0
  111. package/packages/input-shortcuts/src/registers.ts +8 -23
  112. package/packages/input-shortcuts/src/types.ts +4 -16
  113. package/packages/input-shortcuts/src/undo-redo.ts +59 -47
  114. package/packages/kanboard/README.md +51 -47
  115. package/packages/kanboard/index.ts +293 -55
  116. package/packages/kanboard/package.json +8 -8
  117. package/packages/kanboard/skills/kanboard/SKILL.md +61 -27
  118. package/packages/kanboard/src/badges.ts +93 -0
  119. package/packages/kanboard/src/bin.ts +4 -2
  120. package/packages/kanboard/src/commands.ts +218 -84
  121. package/packages/kanboard/src/debug.ts +20 -0
  122. package/packages/kanboard/src/guard.ts +267 -109
  123. package/packages/kanboard/src/monitor.ts +330 -0
  124. package/packages/kanboard/src/notice-buffer.ts +74 -0
  125. package/packages/kanboard/src/progress.ts +27 -0
  126. package/packages/kanboard/src/reminders.ts +234 -0
  127. package/packages/kanboard/src/settings.ts +69 -15
  128. package/packages/kanboard/src/shapes.ts +5 -0
  129. package/packages/long-horizon/index.ts +190 -13
  130. package/packages/long-horizon/package.json +3 -3
  131. package/packages/long-horizon/src/commands.ts +103 -7
  132. package/packages/long-horizon/src/compaction-brief.ts +35 -0
  133. package/packages/long-horizon/src/engine/continuation.ts +84 -15
  134. package/packages/long-horizon/src/engine/goal-state.ts +64 -13
  135. package/packages/long-horizon/src/engine/nudge-stash.ts +71 -0
  136. package/packages/long-horizon/src/engine/ralph.ts +3 -2
  137. package/packages/long-horizon/src/engine/runaway.ts +68 -11
  138. package/packages/long-horizon/src/engine/verifier.ts +19 -0
  139. package/packages/long-horizon/src/gate.ts +37 -12
  140. package/packages/long-horizon/src/judge/resolve.ts +1 -0
  141. package/packages/long-horizon/src/owner.ts +35 -2
  142. package/packages/long-horizon/src/progress.ts +87 -0
  143. package/packages/long-horizon/src/prompts/goal.ts +1 -1
  144. package/packages/long-horizon/src/runtime.ts +172 -18
  145. package/packages/long-horizon/src/settings.ts +54 -39
  146. package/packages/long-horizon/src/tools/goal.ts +6 -0
  147. package/packages/long-horizon/src/tools/graph.ts +1 -1
  148. package/packages/long-horizon/src/tools/swarm.ts +3 -3
  149. package/packages/mcp/package.json +2 -2
  150. package/packages/memory/commands.ts +7 -2
  151. package/packages/memory/index.ts +210 -32
  152. package/packages/memory/package.json +3 -3
  153. package/packages/memory/save-session.ts +264 -0
  154. package/packages/memory/settings.ts +17 -0
  155. package/packages/memory/tools.ts +253 -203
  156. package/packages/notify/package.json +2 -2
  157. package/packages/skill-registry/README.md +53 -16
  158. package/packages/skill-registry/index.ts +230 -0
  159. package/packages/skill-registry/package.json +19 -8
  160. package/packages/skill-registry/src/editor.ts +206 -0
  161. package/packages/skill-registry/src/judge.ts +289 -0
  162. package/packages/skill-registry/src/registry.ts +87 -0
  163. package/packages/skill-registry/src/settings.ts +259 -0
  164. package/packages/skill-registry/src/vault.ts +80 -0
  165. package/packages/subagents/README.md +39 -119
  166. package/packages/subagents/package.json +6 -13
  167. package/packages/subagents/skills/subagents/SKILL.md +18 -42
  168. package/packages/subagents/src/agents.ts +213 -0
  169. package/packages/subagents/src/cards.ts +182 -0
  170. package/packages/subagents/src/index.ts +609 -1084
  171. package/packages/subagents/src/manager.ts +429 -0
  172. package/packages/subagents/src/profiles.ts +130 -0
  173. package/packages/subagents/src/transcript.ts +154 -0
  174. package/packages/subagents/src/ui.ts +389 -0
  175. package/packages/unipi/bundled.js +39756 -45569
  176. package/packages/unipi/index.ts +55 -10
  177. package/packages/updater/package.json +2 -2
  178. package/packages/utility/README.md +76 -69
  179. package/packages/utility/package.json +2 -2
  180. package/packages/utility/skills/image/SKILL.md +37 -0
  181. package/packages/utility/skills/utility/SKILL.md +17 -60
  182. package/packages/utility/src/answer/extract.ts +128 -0
  183. package/packages/utility/src/answer/index.ts +213 -0
  184. package/packages/utility/src/answer/reply.ts +133 -0
  185. package/packages/utility/src/answer/web.ts +167 -0
  186. package/packages/utility/src/attach/index.ts +205 -0
  187. package/packages/utility/src/commands.ts +38 -142
  188. package/packages/utility/src/diagnostics/engine.ts +50 -5
  189. package/packages/utility/src/image/index.ts +33 -0
  190. package/packages/utility/src/image/models.ts +221 -0
  191. package/packages/{image/src → utility/src/image}/recognize.ts +2 -2
  192. package/packages/utility/src/image/settings.ts +178 -0
  193. package/packages/{image/src/image-source.ts → utility/src/image/source.ts} +1 -1
  194. package/packages/utility/src/image/tools.ts +168 -0
  195. package/packages/utility/src/image/transports.ts +186 -0
  196. package/packages/utility/src/index.ts +68 -389
  197. package/packages/utility/src/lifecycle/cleanup.ts +116 -311
  198. package/packages/utility/src/rename/gate.ts +102 -0
  199. package/packages/utility/src/rename/index.ts +191 -0
  200. package/packages/utility/src/rename/session.ts +170 -0
  201. package/packages/utility/src/render/delegated.ts +285 -0
  202. package/packages/utility/src/render/harness.ts +683 -0
  203. package/packages/utility/src/render/parse.ts +156 -0
  204. package/packages/utility/src/render/pi-settings.ts +38 -0
  205. package/packages/utility/src/render/reply-bg.ts +307 -0
  206. package/packages/utility/src/render/simple.ts +724 -0
  207. package/packages/utility/src/render/spacing.ts +235 -0
  208. package/packages/utility/src/render/styled.ts +251 -0
  209. package/packages/utility/src/render/tools.ts +353 -0
  210. package/packages/utility/src/settings.ts +166 -233
  211. package/packages/utility/src/types.ts +1 -222
  212. package/packages/watchdog/index.ts +17 -6
  213. package/packages/watchdog/package.json +3 -3
  214. package/packages/watchdog/src/config.ts +3 -2
  215. package/packages/web-api/package.json +2 -2
  216. package/packages/workflow/README.md +3 -0
  217. package/packages/workflow/index.ts +0 -2
  218. package/packages/workflow/package.json +2 -2
  219. package/packages/workflow/src/permission/decide.ts +6 -4
  220. package/packages/workflow/src/permission/index.ts +17 -7
  221. package/packages/workflow/src/permission/settings.ts +39 -4
  222. package/packages/workflow/src/plan/index.ts +19 -4
  223. package/packages/background-tasks/extensions/delegate-child.ts +0 -1
  224. package/packages/background-tasks/src/context-parent-snapshot.ts +0 -142
  225. package/packages/background-tasks/src/context-token-budget.ts +0 -903
  226. package/packages/background-tasks/src/context-visible-conversation-v2.ts +0 -551
  227. package/packages/background-tasks/src/delegate/artifacts.ts +0 -487
  228. package/packages/background-tasks/src/delegate/budget.ts +0 -415
  229. package/packages/background-tasks/src/delegate/hook-contract-evidence.json +0 -18
  230. package/packages/background-tasks/src/delegate/hook-contract.ts +0 -154
  231. package/packages/background-tasks/src/delegate/launch.ts +0 -484
  232. package/packages/background-tasks/src/delegate/result-package.ts +0 -459
  233. package/packages/background-tasks/src/delegate/runner.ts +0 -430
  234. package/packages/background-tasks/src/delegate/seed.ts +0 -423
  235. package/packages/background-tasks/src/delegate/types.ts +0 -323
  236. package/packages/background-tasks/src/delegate-child-extension.ts +0 -978
  237. package/packages/background-tasks/src/delegate-extension.ts +0 -654
  238. package/packages/background-tasks/src/fixtures/delegate-context-incident.json +0 -17
  239. package/packages/compactor/skills/compactor-detail/SKILL.md +0 -116
  240. package/packages/compactor/skills/compactor-doctor/SKILL.md +0 -71
  241. package/packages/compactor/skills/compactor-stats/SKILL.md +0 -51
  242. package/packages/compactor/src/compaction/build-sections.ts +0 -76
  243. package/packages/compactor/src/compaction/extract/goals.ts +0 -36
  244. package/packages/compactor/src/compaction/extract/preferences.ts +0 -40
  245. package/packages/compactor/src/compaction/format.ts +0 -53
  246. package/packages/compactor/src/compaction/merge.ts +0 -143
  247. package/packages/compactor/src/config/presets.ts +0 -160
  248. package/packages/compactor/src/executor/executor.ts +0 -233
  249. package/packages/compactor/src/executor/runtime.ts +0 -115
  250. package/packages/compactor/src/security/evaluator.ts +0 -89
  251. package/packages/compactor/src/security/policy.ts +0 -96
  252. package/packages/compactor/src/security/scanner.ts +0 -65
  253. package/packages/compactor/src/session/auto-inject.ts +0 -60
  254. package/packages/compactor/src/session/db.ts +0 -325
  255. package/packages/compactor/src/session/extract.ts +0 -144
  256. package/packages/compactor/src/session/resume-inject.ts +0 -64
  257. package/packages/compactor/src/session/snapshot.ts +0 -327
  258. package/packages/compactor/src/tools/ctx-batch-execute.ts +0 -41
  259. package/packages/compactor/src/tools/ctx-execute-file.ts +0 -23
  260. package/packages/compactor/src/tools/ctx-execute.ts +0 -23
  261. package/packages/compactor/src/tools/ctx-stats.ts +0 -96
  262. package/packages/image/README.md +0 -99
  263. package/packages/image/package.json +0 -61
  264. package/packages/image/skills/image/SKILL.md +0 -76
  265. package/packages/image/src/generate.ts +0 -256
  266. package/packages/image/src/index.ts +0 -135
  267. package/packages/image/src/models.ts +0 -519
  268. package/packages/image/src/openai-images-api.ts +0 -282
  269. package/packages/image/src/register-providers.ts +0 -209
  270. package/packages/image/src/settings.ts +0 -173
  271. package/packages/image/src/tools.ts +0 -326
  272. package/packages/input-shortcuts/src/clipboard.ts +0 -119
  273. package/packages/kanboard/src/runner.ts +0 -817
  274. package/packages/skill-registry/skills/auto/SKILL.md +0 -465
  275. package/packages/skill-registry/skills/brainstorm/SKILL.md +0 -219
  276. package/packages/skill-registry/skills/chore-create/SKILL.md +0 -315
  277. package/packages/skill-registry/skills/chore-execute/SKILL.md +0 -314
  278. package/packages/skill-registry/skills/consolidate/SKILL.md +0 -142
  279. package/packages/skill-registry/skills/consultant/SKILL.md +0 -97
  280. package/packages/skill-registry/skills/debug/SKILL.md +0 -228
  281. package/packages/skill-registry/skills/document/SKILL.md +0 -120
  282. package/packages/skill-registry/skills/fix/SKILL.md +0 -212
  283. package/packages/skill-registry/skills/gather-context/SKILL.md +0 -145
  284. package/packages/skill-registry/skills/plan/SKILL.md +0 -231
  285. package/packages/skill-registry/skills/quick-fix/SKILL.md +0 -135
  286. package/packages/skill-registry/skills/quick-work/SKILL.md +0 -110
  287. package/packages/skill-registry/skills/research/SKILL.md +0 -251
  288. package/packages/skill-registry/skills/review-work/SKILL.md +0 -187
  289. package/packages/skill-registry/skills/scan-issues/SKILL.md +0 -195
  290. package/packages/skill-registry/skills/work/SKILL.md +0 -218
  291. package/packages/skill-registry/skills/worktree-create/SKILL.md +0 -69
  292. package/packages/skill-registry/skills/worktree-list/SKILL.md +0 -78
  293. package/packages/skill-registry/skills/worktree-merge/SKILL.md +0 -89
  294. package/packages/subagents/agents/delegate.md +0 -14
  295. package/packages/subagents/agents/oracle.md +0 -78
  296. package/packages/subagents/agents/researcher.md +0 -52
  297. package/packages/subagents/agents/reviewer.md +0 -80
  298. package/packages/subagents/agents/scout.md +0 -50
  299. package/packages/subagents/agents/worker.md +0 -59
  300. package/packages/subagents/prompts/council.md +0 -48
  301. package/packages/subagents/prompts/gather-context-and-clarify.md +0 -13
  302. package/packages/subagents/prompts/parallel-cleanup.md +0 -59
  303. package/packages/subagents/prompts/parallel-research.md +0 -50
  304. package/packages/subagents/prompts/parallel-review.md +0 -54
  305. package/packages/subagents/prompts/review-loop.md +0 -43
  306. package/packages/subagents/skills/council-mode/SKILL.md +0 -230
  307. package/packages/subagents/skills/subagents/references/constraints-and-recipes.md +0 -259
  308. package/packages/subagents/skills/subagents/references/execution-controls.md +0 -454
  309. package/packages/subagents/skills/subagents/references/management-authoring-rpc.md +0 -161
  310. package/packages/subagents/skills/subagents/references/multi-lane-orchestration.md +0 -39
  311. package/packages/subagents/skills/subagents/references/prompting-and-roles.md +0 -267
  312. package/packages/subagents/src/acceptance.ts +0 -331
  313. package/packages/subagents/src/agent-manager.ts +0 -405
  314. package/packages/subagents/src/agent-memory.ts +0 -300
  315. package/packages/subagents/src/agent-overrides.ts +0 -183
  316. package/packages/subagents/src/agent-runner.ts +0 -271
  317. package/packages/subagents/src/async-runner.ts +0 -422
  318. package/packages/subagents/src/authority-policy.ts +0 -47
  319. package/packages/subagents/src/budgets.ts +0 -285
  320. package/packages/subagents/src/child-safety.ts +0 -140
  321. package/packages/subagents/src/config.ts +0 -249
  322. package/packages/subagents/src/conversation-viewer.ts +0 -281
  323. package/packages/subagents/src/core-compat.ts +0 -94
  324. package/packages/subagents/src/custom-agents.ts +0 -343
  325. package/packages/subagents/src/file-system-retry.ts +0 -50
  326. package/packages/subagents/src/fleet-data.ts +0 -105
  327. package/packages/subagents/src/fleet-view.ts +0 -322
  328. package/packages/subagents/src/foreground-detach.ts +0 -59
  329. package/packages/subagents/src/fork-context.ts +0 -285
  330. package/packages/subagents/src/global.d.ts +0 -7
  331. package/packages/subagents/src/guide.ts +0 -129
  332. package/packages/subagents/src/mission-state.ts +0 -133
  333. package/packages/subagents/src/mission-store.ts +0 -436
  334. package/packages/subagents/src/output-limits.ts +0 -142
  335. package/packages/subagents/src/parity-types.ts +0 -315
  336. package/packages/subagents/src/pi-args.ts +0 -167
  337. package/packages/subagents/src/result-files.ts +0 -232
  338. package/packages/subagents/src/result-watcher.ts +0 -221
  339. package/packages/subagents/src/retained-children.ts +0 -176
  340. package/packages/subagents/src/run-fanout-budget.ts +0 -356
  341. package/packages/subagents/src/scheduled-runs.ts +0 -349
  342. package/packages/subagents/src/schemas.ts +0 -263
  343. package/packages/subagents/src/slash-commands.ts +0 -80
  344. package/packages/subagents/src/supervisor-channel.ts +0 -249
  345. package/packages/subagents/src/tool-handler.ts +0 -1144
  346. package/packages/subagents/src/types.ts +0 -238
  347. package/packages/subagents/src/widget.ts +0 -457
  348. package/packages/subagents/src/workflow-script.ts +0 -737
  349. package/packages/subagents/src/workflow-worker.ts +0 -384
  350. package/packages/subagents/src/worktree.ts +0 -614
  351. package/packages/utility/src/analytics/collector.ts +0 -293
  352. package/packages/utility/src/info-screen.ts +0 -80
  353. package/packages/utility/src/lifecycle/process.ts +0 -162
  354. package/packages/utility/src/prefix-cache.ts +0 -263
  355. package/packages/utility/src/skill-discovery.ts +0 -542
  356. package/packages/utility/src/tools/env.ts +0 -113
  357. package/packages/utility/src/tui/name-badge-state.ts +0 -315
  358. package/packages/utility/src/tui/name-badge.ts +0 -109
  359. /package/packages/{subagents/src → core/src/child-agent}/pi-spawn.ts +0 -0
@@ -1,101 +1,7 @@
1
1
  /**
2
- * @pi-unipi/utility — Shared types
3
- *
4
- * Type definitions for utility modules: lifecycle, cache, analytics,
5
- * diagnostics, display, TUI, and tools.
2
+ * @pi-unipi/utility — Shared types (diagnostics)
6
3
  */
7
4
 
8
- // ─── Lifecycle ───────────────────────────────────────────────────────────────
9
-
10
- /** Cleanup function registered with the lifecycle manager */
11
- export type CleanupFn = () => void | Promise<void>;
12
-
13
- /** Process lifecycle state */
14
- export type LifecycleState = "running" | "shutting_down" | "orphaned" | "error";
15
-
16
- /** Options for ProcessLifecycle */
17
- export interface ProcessLifecycleOptions {
18
- /** Polling interval in ms for parent PID checks (default: 30000) */
19
- pollIntervalMs?: number;
20
- /** Whether to install signal handlers (default: true) */
21
- handleSignals?: boolean;
22
- }
23
-
24
- // ─── Cache ───────────────────────────────────────────────────────────────────
25
-
26
- /** Cache entry with metadata */
27
- export interface CacheEntry<V> {
28
- value: V;
29
- expiresAt: number;
30
- createdAt: number;
31
- }
32
-
33
- /** TTL cache backend interface */
34
- export interface CacheBackend<K, V> {
35
- get(key: K): Promise<V | undefined>;
36
- set(key: K, value: V, ttlMs: number): Promise<void>;
37
- has(key: K): Promise<boolean>;
38
- delete(key: K): Promise<boolean>;
39
- cleanupExpired(): Promise<number>;
40
- clear(): Promise<void>;
41
- }
42
-
43
- /** TTL cache options */
44
- export interface TTLCacheOptions {
45
- /** Use SQLite persistence (default: false) */
46
- persistent?: boolean;
47
- /** SQLite DB path (default: auto) */
48
- dbPath?: string;
49
- /** Default TTL in ms */
50
- defaultTtlMs?: number;
51
- /** Max entries in memory cache */
52
- maxMemoryEntries?: number;
53
- }
54
-
55
- // ─── Analytics ───────────────────────────────────────────────────────────────
56
-
57
- /** Analytics event types */
58
- export type AnalyticsEventType =
59
- | "module_load"
60
- | "command_run"
61
- | "tool_call"
62
- | "error"
63
- | "compaction"
64
- | "search";
65
-
66
- /** Single analytics event record */
67
- export interface AnalyticsEvent {
68
- id: string;
69
- type: AnalyticsEventType;
70
- timestamp: number;
71
- module?: string;
72
- command?: string;
73
- tool?: string;
74
- durationMs?: number;
75
- success?: boolean;
76
- metadata?: Record<string, unknown>;
77
- }
78
-
79
- /** Daily rollup of analytics events */
80
- export interface AnalyticsRollup {
81
- date: string; // YYYY-MM-DD
82
- events: Record<AnalyticsEventType, number>;
83
- totalDurationMs: number;
84
- errorCount: number;
85
- }
86
-
87
- /** Analytics collector options */
88
- export interface AnalyticsOptions {
89
- /** SQLite DB path */
90
- dbPath?: string;
91
- /** Max events before auto-rollup (default: 10000) */
92
- maxEvents?: number;
93
- /** Enable daily rollup (default: true) */
94
- rollupEnabled?: boolean;
95
- }
96
-
97
- // ─── Diagnostics ─────────────────────────────────────────────────────────────
98
-
99
5
  /** Health status for a single check */
100
6
  export type HealthStatus = "healthy" | "warning" | "error" | "unknown";
101
7
 
@@ -128,130 +34,3 @@ export interface DiagnosticPlugin {
128
34
  module: string;
129
35
  run(): Promise<DiagnosticCheck[]>;
130
36
  }
131
-
132
- // ─── Display ─────────────────────────────────────────────────────────────────
133
-
134
- /** Detected terminal capabilities */
135
- export interface TerminalCapabilities {
136
- /** Terminal supports basic colors */
137
- color: boolean;
138
- /** Terminal supports 256/truecolor */
139
- truecolor: boolean;
140
- /** Nerd Font detected */
141
- nerdFont: boolean;
142
- /** Unicode support level */
143
- unicode: "none" | "basic" | "full";
144
- /** Terminal width in columns */
145
- width: number;
146
- /** Terminal height in rows */
147
- height: number;
148
- }
149
-
150
- /** Width management options */
151
- export interface WidthOptions {
152
- /** Truncation indicator (default: "…") */
153
- ellipsis?: string;
154
- /** Whether to break words (default: false) */
155
- breakWords?: boolean;
156
- }
157
-
158
- // ─── TUI ─────────────────────────────────────────────────────────────────────
159
-
160
- /** Settings schema entry */
161
- export interface SettingSchema {
162
- key: string;
163
- type: "string" | "number" | "boolean" | "object" | "array";
164
- description: string;
165
- default?: unknown;
166
- required?: boolean;
167
- }
168
-
169
- /** Settings inspector state */
170
- export interface SettingsInspectorState {
171
- schemas: SettingSchema[];
172
- values: Record<string, unknown>;
173
- selectedIndex: number;
174
- searchQuery: string;
175
- editMode: boolean;
176
- }
177
-
178
- // ─── Tools ───────────────────────────────────────────────────────────────────
179
-
180
- /** Single batch command entry */
181
- export interface BatchCommand {
182
- type: "command" | "tool" | "search";
183
- name: string;
184
- args?: Record<string, unknown>;
185
- }
186
-
187
- /** Batch execution options */
188
- export interface BatchOptions {
189
- /** Fail on first error (default: true) */
190
- failFast?: boolean;
191
- /** Timeout per command in ms (default: 30000) */
192
- commandTimeoutMs?: number;
193
- /** Total timeout in ms (default: 300000) */
194
- totalTimeoutMs?: number;
195
- }
196
-
197
- /** Result of a single batch command */
198
- export interface BatchResult {
199
- command: BatchCommand;
200
- success: boolean;
201
- result?: unknown;
202
- error?: string;
203
- durationMs: number;
204
- }
205
-
206
- /** Complete batch execution result */
207
- export interface BatchReport {
208
- success: boolean;
209
- results: BatchResult[];
210
- totalDurationMs: number;
211
- rolledBack: boolean;
212
- }
213
-
214
- /** Environment info returned by ctx_env */
215
- export interface EnvironmentInfo {
216
- nodeVersion: string;
217
- piVersion: string;
218
- os: string;
219
- platform: string;
220
- unipiModules: string[];
221
- configPaths: string[];
222
- extensionPaths: string[];
223
- }
224
-
225
- // ─── Cleanup ─────────────────────────────────────────────────────────────────
226
-
227
- /** Result of a cleanup operation */
228
- export interface CleanupResult {
229
- /** What was cleaned */
230
- category: "db" | "temp" | "tool-results" | "session" | "cache" | "log";
231
- /** Items removed */
232
- removed: number;
233
- /** Bytes freed (approximate) */
234
- bytesFreed: number;
235
- /** Paths that were cleaned */
236
- paths: string[];
237
- }
238
-
239
- /** Complete cleanup report */
240
- export interface CleanupReport {
241
- timestamp: number;
242
- results: CleanupResult[];
243
- totalRemoved: number;
244
- totalBytesFreed: number;
245
- }
246
-
247
- /** Cleanup options */
248
- export interface CleanupOptions {
249
- /** Max age in days for DB files (default: 14) */
250
- dbMaxAgeDays?: number;
251
- /** Max age in days for temp files (default: 7) */
252
- tempMaxAgeDays?: number;
253
- /** Max age in days for sessions (default: 30) */
254
- sessionMaxAgeDays?: number;
255
- /** Dry run — report only (default: false) */
256
- dryRun?: boolean;
257
- }
@@ -14,7 +14,7 @@
14
14
  import { appendFileSync, mkdirSync } from "node:fs";
15
15
  import * as os from "node:os";
16
16
  import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
17
- import { askJev, readJudgeJevSettings } from "@pi-unipi/core";
17
+ import { askJev, harnessToolResultDetails, harnessMetadata, resolveDecisionModel, sendHarnessUserMessage } from "@pi-unipi/core";
18
18
  import { getSharedTaskRegistry } from "@pi-unipi/background-tasks";
19
19
  import { loadWatchdogSettings, registerWatchdogSettings, type WatchdogSettings } from "./src/config.js";
20
20
  import { evaluateTick } from "./src/decide.js";
@@ -25,8 +25,7 @@ import { extractText } from "./src/extract.js";
25
25
  const NEVER_WATCH = new Set([
26
26
  "read", "write", "edit", "grep", "find", "ls",
27
27
  "ask_user",
28
- "bg_result", "bg_kill", "bg_tasks",
29
- "set_session_name", "ctx_env",
28
+ "read_subagent", "bg_kill", "bg_tasks",
30
29
  ]);
31
30
 
32
31
  interface TrackedCall {
@@ -217,6 +216,12 @@ export function registerWatchdogExtension(pi: { on(event: string, handler: (even
217
216
  return {
218
217
  content: [{ type: "text", text: `${warning}\n\n${original}` }],
219
218
  isError: true,
219
+ details: harnessToolResultDetails(
220
+ (event as { details?: unknown }).details,
221
+ { source: "Watchdog", title: "Kill warning", synopsis: "Killed after timeout — do not blindly re-run", severity: "warning" },
222
+ "boundary",
223
+ warning,
224
+ ),
220
225
  };
221
226
  });
222
227
 
@@ -230,6 +235,7 @@ export function registerWatchdogExtension(pi: { on(event: string, handler: (even
230
235
  customType: "unipi-watchdog",
231
236
  content,
232
237
  display: true,
238
+ details: { unipiHarness: harnessMetadata({ source: "Watchdog", title: "Watchdog warnings", synopsis: "Drained pending warnings", severity: "warning" }, "before_agent_start") },
233
239
  },
234
240
  };
235
241
  });
@@ -302,7 +308,7 @@ function gatherWatched(settings: WatchdogSettings): WatchedItem[] {
302
308
  items.push({
303
309
  key: `bg:${task.id}`,
304
310
  kind: "bg",
305
- toolName: task.delegate ? "bg_delegate" : "bg_run",
311
+ toolName: "bg_run",
306
312
  command: task.command.slice(0, 500),
307
313
  startedAt: task.startTime,
308
314
  // Filled in tick() from the per-key tail history.
@@ -352,7 +358,7 @@ async function tick(enabled: boolean): Promise<void> {
352
358
  else ctx.ui.setStatus("watchdog", undefined);
353
359
 
354
360
  // One jevSettings read for the entire tick.
355
- const jevSettings = readJudgeJevSettings(ctx.cwd);
361
+ const jevSettings = resolveDecisionModel(ctx.cwd, "watchdog");
356
362
 
357
363
  for (const item of items) {
358
364
  // At most once per intervalMin per item.
@@ -459,7 +465,12 @@ async function tick(enabled: boolean): Promise<void> {
459
465
  const text = `⚠ Watchdog aborted "${item.toolName}": jev judged it ${reason}.`;
460
466
  try {
461
467
  ctx.abort();
462
- state.pi?.sendUserMessage(text, { deliverAs: "followUp" });
468
+ sendHarnessUserMessage(
469
+ state.pi!,
470
+ text,
471
+ { source: "Watchdog", title: "Tool aborted", synopsis: "jev judged the tool stuck", severity: "warning" },
472
+ { deliverAs: "followUp" },
473
+ );
463
474
  } catch {
464
475
  // best-effort
465
476
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-unipi/watchdog",
3
- "version": "3.0.0-alpha.2",
3
+ "version": "3.0.0-alpha.21",
4
4
  "description": "Jev watchdog for long-running tool calls and background tasks — judges stuck work via TypeSafe System One and kills or warns",
5
5
  "type": "module",
6
6
  "main": "index.ts",
@@ -32,8 +32,8 @@
32
32
  "access": "public"
33
33
  },
34
34
  "dependencies": {
35
- "@pi-unipi/background-tasks": "3.0.0-alpha.2",
36
- "@pi-unipi/core": "3.0.0-alpha.2"
35
+ "@pi-unipi/background-tasks": "3.0.0-alpha.21",
36
+ "@pi-unipi/core": "3.0.0-alpha.21"
37
37
  },
38
38
  "peerDependencies": {
39
39
  "@earendil-works/pi-coding-agent": "^0.87.1",
@@ -5,7 +5,7 @@
5
5
  * edited via /unipi:settings (Watchdog group).
6
6
  */
7
7
 
8
- import { getSettings, registerSettings } from "@pi-unipi/core";
8
+ import { getSettings, registerSettings, decisionModelSection, DEFAULT_DECISION_OVERRIDE } from "@pi-unipi/core";
9
9
 
10
10
  export type WatchdogAction = "kill" | "warn";
11
11
  export type OtherToolsMode = "off" | "warn" | "abort-turn";
@@ -80,7 +80,7 @@ export function registerWatchdogSettings(cwd: string): void {
80
80
  registerSettings({
81
81
  namespace: "watchdog",
82
82
  label: "Watchdog",
83
- defaults: { ...DEFAULT_WATCHDOG_SETTINGS } as unknown as Record<string, unknown>,
83
+ defaults: { ...DEFAULT_WATCHDOG_SETTINGS, decisionModel: DEFAULT_DECISION_OVERRIDE } as unknown as Record<string, unknown>,
84
84
  schema: [
85
85
  {
86
86
  title: "Watchdog",
@@ -115,6 +115,7 @@ export function registerWatchdogSettings(cwd: string): void {
115
115
  },
116
116
  ],
117
117
  },
118
+ decisionModelSection({ title: "Watchdog — Decision model" }),
118
119
  ],
119
120
  });
120
121
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-unipi/web-api",
3
- "version": "3.0.0-alpha.2",
3
+ "version": "3.0.0-alpha.21",
4
4
  "description": "Web search, read, and summarize tools with provider-based backend selection for Pi coding agent",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -31,7 +31,7 @@
31
31
  "README.md"
32
32
  ],
33
33
  "dependencies": {
34
- "@pi-unipi/core": "3.0.0-alpha.2",
34
+ "@pi-unipi/core": "3.0.0-alpha.21",
35
35
  "defuddle": "^0.18.1",
36
36
  "linkedom": "^0.18.12",
37
37
  "wreq-js": "^2.3.0"
@@ -78,6 +78,9 @@ Entering plan mode (`/unipi:plan`, `Alt+P`):
78
78
  - a compact message states the rules: investigation only, the plan file is the ONLY
79
79
  writable path (`docs/plans/<YYYY-MM-DD>-<short-session-id>.md`), bash is limited
80
80
  to read-only commands;
81
+ - the plan opens with `## Summary` — 5–10 lines of plain language for the human
82
+ deciding whether to approve (what changes and why, what you'll notice, risks or
83
+ open decisions) — then the full detail: Steps, Files, Risks, Verification;
81
84
  - every later turn gets a short reminder `[plan mode: read-only · plan file … ·
82
85
  call plan_submit when ready]` — appended as a message, never to the system prompt,
83
86
  so the provider prefix cache stays intact.
@@ -9,8 +9,6 @@
9
9
  * judging ambiguous bash in auto mode;
10
10
  * - plan mode (/unipi:plan, Alt+P) makes a session read-only except for its
11
11
  * plan file.
12
- *
13
- * The bundled skills moved to @pi-unipi/skill-registry.
14
12
  */
15
13
 
16
14
  import { dirname } from "node:path";
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-unipi/workflow",
3
- "version": "3.0.0-alpha.2",
3
+ "version": "3.0.0-alpha.21",
4
4
  "description": "Plan mode and permission modes for the Pi coding agent",
5
5
  "type": "module",
6
6
  "main": "index.ts",
@@ -27,7 +27,7 @@
27
27
  "access": "public"
28
28
  },
29
29
  "dependencies": {
30
- "@pi-unipi/core": "3.0.0-alpha.2"
30
+ "@pi-unipi/core": "3.0.0-alpha.21"
31
31
  },
32
32
  "peerDependencies": {
33
33
  "@earendil-works/pi-ai": "^0.87.1",
@@ -20,10 +20,9 @@ export const READ_ONLY_TOOLS = new Set([
20
20
  "ffgrep", "fffind", "session_recall", "ask_user",
21
21
  "memory_search", "memory_list", "global_memory_search", "global_memory_list",
22
22
  "web_search", "multi_web_content_read", "web_llm_summarize",
23
- "bg_status", "bg_logs", "bg_result", "get_helper_result",
24
- "compactor_stats", "compactor_doctor", "context_budget", "ctx_env", "ctx_budget",
23
+ "bg_status", "bg_logs", "read_subagent",
24
+ "compactor_stats", "compactor_doctor", "context_budget", "ctx_budget",
25
25
  "omniroute_status", "loop_status", "swarm_status", "view_agent_graph", "get_goal",
26
- "read_subagent",
27
26
  ]);
28
27
 
29
28
  export type Decision =
@@ -91,10 +90,13 @@ export async function decideToolCall(input: ToolCallInput, deps: DecideDeps): Pr
91
90
  // 2. Read-only tools.
92
91
  if (READ_ONLY_TOOLS.has(tool)) return { action: "allow", reason: "read-only tool" };
93
92
 
94
- // 3. write / edit — inside the workspace or the temp dir is fine outside ask mode.
93
+ // 3. write / edit — inside the workspace or the temp dir is fine outside ask mode;
94
+ // full mode runs everything (UNI-40: it must be able to write anywhere, e.g. the
95
+ // installed-extension hot-patch in ~/.pi), so only ask/auto prompt on outside writes.
95
96
  if (isWrite) {
96
97
  const inside = isInsidePath(subject, deps.cwd) || isInsidePath(subject, deps.tmpdir);
97
98
  if (inside && deps.mode !== "ask") return { action: "allow", reason: "inside the workspace" };
99
+ if (deps.mode === "full") return { action: "allow", reason: "full mode · outside the workspace" };
98
100
  if (!deps.hasUI) return { action: "allow", reason: "no UI — full behaviour" };
99
101
  return {
100
102
  action: "ask",
@@ -4,18 +4,21 @@
4
4
  * Every tool call is classified (read-only, workspace write, bash, other) and
5
5
  * gated by the active mode. In `auto`, an unrecognized bash command is judged by
6
6
  * jev (one Decision-model call) instead of prompting; anything destructive or
7
- * ambiguous always asks. Without a UI nothing prompts: it behaves like `full`,
8
- * except saved deny rules and dangerous patterns, which are blocked outright.
7
+ * ambiguous always asks. `full` runs everything short of saved deny rules (and
8
+ * dangerous bash in headless runs, where nothing could confirm it). Without a UI
9
+ * nothing prompts: it behaves like `full`, except saved deny rules and dangerous
10
+ * patterns, which are blocked outright.
9
11
  */
10
12
 
11
13
  import { appendFileSync, mkdirSync } from "node:fs";
12
14
  import { homedir, tmpdir } from "node:os";
13
15
  import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
14
16
  import {
17
+ getSettingsScoped,
15
18
  UNIPI_EVENTS,
16
19
  askJev,
17
20
  emitEvent,
18
- readJudgeJevSettings,
21
+ resolveDecisionModel,
19
22
  registerCommandRunner,
20
23
  runCommandByName,
21
24
  setSharedPermissionMode,
@@ -62,7 +65,7 @@ function debugLog(line: string): void {
62
65
 
63
66
  /** One jev risk question; null (fail-open → prompt) on error, timeout or no key. */
64
67
  export async function askJevRisk(cwd: string, state: string): Promise<JevRisk | null> {
65
- const settings = readJudgeJevSettings(cwd);
68
+ const settings = resolveDecisionModel(cwd, "permission");
66
69
  const answers = await askJev({
67
70
  state,
68
71
  questions: {
@@ -165,15 +168,22 @@ export function registerPermissionModes(pi: ExtensionAPI, controller: Permission
165
168
  ? "Prompt before every write, bash call and other tool"
166
169
  : m === "auto"
167
170
  ? "Read-only and workspace writes run; jev judges ambiguous bash (default)"
168
- : "Run everything except saved deny rules and dangerous patterns",
171
+ : "Run everything — only saved deny rules block",
169
172
  }));
170
173
  return items.length > 0 ? items : null;
171
174
  },
172
175
  handler: async (args, ctx) => {
173
176
  const requested = (args ?? "").trim().toLowerCase();
174
- if (!requested) {
177
+ if (!requested || requested === "status") {
175
178
  const current = controller.mode(ctx.cwd);
176
- ctx.ui.notify(`Permission mode: ${current}`, "info");
179
+ const project = getSettingsScoped("permission", "project", ctx.cwd);
180
+ const global = getSettingsScoped("permission", "global", ctx.cwd);
181
+ const proj = typeof project?.mode === "string" ? project.mode : "-";
182
+ const glob = typeof global?.defaultMode === "string" ? global.defaultMode : typeof global?.mode === "string" ? global.mode : "-";
183
+ ctx.ui.notify(
184
+ `Permission mode: ${current} (project: ${proj} · default: ${glob})`,
185
+ "info",
186
+ );
177
187
  return;
178
188
  }
179
189
  if (!MODES.includes(requested as PermissionMode)) {
@@ -5,10 +5,13 @@
5
5
 
6
6
  import {
7
7
  getSettings,
8
+ getSettingsScoped,
8
9
  registerSettings,
9
10
  setSettings,
10
11
  settingsLayers,
11
12
  type SettingsSection,
13
+ decisionModelSection,
14
+ DEFAULT_DECISION_OVERRIDE,
12
15
  } from "@pi-unipi/core";
13
16
  import { normalizeRules, type PermissionRule } from "./rules.js";
14
17
 
@@ -16,6 +19,7 @@ export type PermissionMode = "ask" | "auto" | "full";
16
19
 
17
20
  export interface PermissionSettings {
18
21
  mode: PermissionMode;
22
+ defaultMode: PermissionMode;
19
23
  jevJudge: boolean;
20
24
  jevConfidence: number;
21
25
  rules: PermissionRule[];
@@ -23,6 +27,7 @@ export interface PermissionSettings {
23
27
 
24
28
  export const DEFAULT_SETTINGS = {
25
29
  mode: "auto",
30
+ defaultMode: "auto",
26
31
  jevJudge: true,
27
32
  jevConfidence: 0.7,
28
33
  rules: [] as PermissionRule[],
@@ -42,9 +47,19 @@ export const PERMISSION_SECTIONS: SettingsSection[] = [
42
47
  {
43
48
  key: "mode",
44
49
  type: "enum",
45
- label: "Mode",
50
+ label: "Mode (this project)",
46
51
  options: MODE_OPTIONS.map((o) => ({ ...o })),
47
- description: "Alt+M cycles · auto lets jev decide ambiguous bash",
52
+ clearable: true,
53
+ scopes: ["project"],
54
+ description: "Alt+M cycles · use-default clears the project mode",
55
+ },
56
+ {
57
+ key: "defaultMode",
58
+ type: "enum",
59
+ label: "Default mode (all projects)",
60
+ scope: "global",
61
+ options: MODE_OPTIONS.map((o) => ({ ...o })),
62
+ description: "Fallback mode for projects that set none",
48
63
  },
49
64
  {
50
65
  key: "jevJudge",
@@ -69,14 +84,23 @@ export const PERMISSION_SECTIONS: SettingsSection[] = [
69
84
  },
70
85
  ],
71
86
  },
87
+ decisionModelSection({ title: "Auto mode — Decision model" }),
72
88
  ];
73
89
 
74
90
  export function registerPermissionSettings(cwd?: string): void {
91
+ // One-time, idempotent migration: an existing global `mode` (pre-defaultMode
92
+ // installs) is copied to `defaultMode` so the hub shows it instead of "unset".
93
+ if (cwd) {
94
+ const global = getSettingsScoped("permission", "global", cwd);
95
+ if (global && typeof global.mode === "string" && global.defaultMode === undefined) {
96
+ setSettings("permission", { defaultMode: global.mode }, "global", cwd);
97
+ }
98
+ }
75
99
  const count = cwd ? readPermissionSettings(cwd).rules.length : 0;
76
100
  registerSettings({
77
101
  namespace: "permission",
78
102
  label: "Permissions",
79
- defaults: DEFAULT_SETTINGS as unknown as Record<string, unknown>,
103
+ defaults: { ...DEFAULT_SETTINGS, decisionModel: DEFAULT_DECISION_OVERRIDE } as unknown as Record<string, unknown>,
80
104
  schema: PERMISSION_SECTIONS.map((section) => ({
81
105
  ...section,
82
106
  fields: section.fields.map((field) =>
@@ -95,7 +119,8 @@ function coerceMode(value: unknown): PermissionMode {
95
119
  export function readPermissionSettings(cwd: string): PermissionSettings {
96
120
  const raw = getSettings("permission", cwd);
97
121
  return {
98
- mode: coerceMode(raw.mode),
122
+ mode: effectivePermissionMode(cwd),
123
+ defaultMode: coerceMode(raw.defaultMode),
99
124
  jevJudge: raw.jevJudge !== false,
100
125
  jevConfidence:
101
126
  typeof raw.jevConfidence === "number" && raw.jevConfidence >= 0 && raw.jevConfidence <= 1
@@ -105,6 +130,16 @@ export function readPermissionSettings(cwd: string): PermissionSettings {
105
130
  };
106
131
  }
107
132
 
133
+ /** project `mode` → global `defaultMode` → legacy global `mode` → auto. */
134
+ export function effectivePermissionMode(cwd: string): PermissionMode {
135
+ const project = getSettingsScoped("permission", "project", cwd);
136
+ if (project && typeof project.mode === "string") return coerceMode(project.mode);
137
+ const global = getSettingsScoped("permission", "global", cwd);
138
+ if (global && typeof global.defaultMode === "string") return coerceMode(global.defaultMode);
139
+ if (global && typeof global.mode === "string") return coerceMode(global.mode); // legacy installs
140
+ return "auto";
141
+ }
142
+
108
143
  /** Written to the project scope: the mode is a property of the workspace. */
109
144
  export function writePermissionMode(mode: PermissionMode, cwd: string): void {
110
145
  setSettings("permission", { mode }, "project", cwd);
@@ -10,7 +10,7 @@
10
10
  import { existsSync, readFileSync } from "node:fs";
11
11
  import { Type } from "typebox";
12
12
  import type { ExtensionAPI, ExtensionCommandContext, ExtensionContext } from "@earendil-works/pi-coding-agent";
13
- import { UNIPI_EVENTS, emitEvent, registerCommandRunner, setSharedPlanMode } from "@pi-unipi/core";
13
+ import { UNIPI_EVENTS, emitEvent, harnessMetadata, registerCommandRunner, sendHarnessUserMessage, setSharedPlanMode } from "@pi-unipi/core";
14
14
  import {
15
15
  PLAN_MESSAGE_TYPE,
16
16
  PLAN_STATE_ENTRY,
@@ -37,8 +37,14 @@ export function planInstructions(planPath: string): string {
37
37
  "Plan mode is ON — investigation only, no implementation.",
38
38
  `The ONLY file you may write or edit is ${planPath}.`,
39
39
  "Bash is limited to read-only commands; every mutating tool is refused.",
40
- "Investigate the codebase, then write the plan to that file. It must start with:",
40
+ "Investigate the codebase, then write the plan to that file using these",
41
+ "headings verbatim, in this order:",
41
42
  PLAN_TEMPLATE.join("\n"),
43
+ "## Summary comes first and is written for the human approving the plan:",
44
+ "5–10 lines of plain language covering what will change and why, what the",
45
+ "user will notice, and any risks or decisions that need them — no file",
46
+ "paths or code unless essential. Everything below it is the full plan for",
47
+ "whoever implements it.",
42
48
  `When the plan is written, call ${PLAN_TOOL} to ask for approval.`,
43
49
  ].join("\n");
44
50
  }
@@ -92,8 +98,10 @@ export async function approvePlan(
92
98
  }
93
99
 
94
100
  disablePlanMode(pi, ctx, "approved");
95
- pi.sendUserMessage(
101
+ sendHarnessUserMessage(
102
+ pi,
96
103
  `Implement the approved plan below. Treat it as authoritative; do not re-plan.\n\n${content}`,
104
+ { source: "Plan mode", title: "Approved plan", synopsis: "Plan approved — implementation handoff" },
97
105
  { deliverAs: "followUp" },
98
106
  );
99
107
  return { status: "approved" };
@@ -147,6 +155,7 @@ export function enablePlanMode(
147
155
  customType: PLAN_MESSAGE_TYPE,
148
156
  content: planInstructions(displayPlanPath(ctx.cwd, planFile)),
149
157
  display: true,
158
+ details: { unipiHarness: harnessMetadata({ source: "Plan mode", title: "Plan mode on", synopsis: "Investigation only — plan file required" }, "direct") },
150
159
  });
151
160
  ctx.ui.notify(`Plan mode on — plan file ${displayPlanPath(ctx.cwd, planFile)}`, "info");
152
161
  return planFile;
@@ -172,7 +181,12 @@ export function disablePlanMode(
172
181
  });
173
182
  if (reason !== "approved") {
174
183
  const note = reason === "discarded" ? "[plan mode off — plan discarded]" : "[plan mode off]";
175
- pi.sendMessage({ customType: PLAN_MESSAGE_TYPE, content: note, display: true });
184
+ pi.sendMessage({
185
+ customType: PLAN_MESSAGE_TYPE,
186
+ content: note,
187
+ display: true,
188
+ details: { unipiHarness: harnessMetadata({ source: "Plan mode", title: reason === "discarded" ? "Plan discarded" : "Plan mode off" }, "direct") },
189
+ });
176
190
  }
177
191
  ctx.ui.notify(
178
192
  reason === "discarded" ? "Plan mode off — plan discarded" : "Plan mode off",
@@ -329,6 +343,7 @@ export function registerPlanMode(pi: ExtensionAPI): void {
329
343
  customType: PLAN_MESSAGE_TYPE,
330
344
  content: planReminder(displayPlanPath(ctx.cwd, state.planFile)),
331
345
  display: false,
346
+ details: { unipiHarness: harnessMetadata({ source: "Plan mode", title: "Plan reminder (hidden)" }, "before_agent_start") },
332
347
  },
333
348
  };
334
349
  });
@@ -1 +0,0 @@
1
- export { default } from '../src/delegate-child-extension.js';