@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,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-unipi/btw",
3
- "version": "3.0.0-alpha.2",
3
+ "version": "3.0.0-alpha.21",
4
4
  "description": "A pi extension for parallel side conversations with /unipi:btw — part of the Unipi suite",
5
5
  "type": "module",
6
6
  "main": "extensions/btw.ts",
@@ -37,7 +37,7 @@
37
37
  "@earendil-works/pi-tui": "^0.87.1"
38
38
  },
39
39
  "dependencies": {
40
- "@pi-unipi/core": "3.0.0-alpha.2"
40
+ "@pi-unipi/core": "3.0.0-alpha.21"
41
41
  },
42
42
  "pi": {
43
43
  "extensions": [
@@ -48,5 +48,8 @@
48
48
  ],
49
49
  "prompts": [],
50
50
  "themes": []
51
+ },
52
+ "scripts": {
53
+ "test": "npx tsx --test tests/*.test.ts"
51
54
  }
52
55
  }
@@ -1,151 +1,15 @@
1
1
  ---
2
2
  name: btw
3
- description: Helps you use the /unipi:btw side-conversation workflow effectively. Use when you want to think in parallel, ask side questions without interrupting ongoing work, or inject a side thread back into the main agent.
3
+ description: Ask side questions in an inline panel without interrupting the main agent — read-only, one-shot, invisible to the main session.
4
4
  ---
5
5
 
6
6
  # BTW
7
7
 
8
- Use this skill when the user wants to work in parallel with the main agent instead of derailing the current turn.
8
+ `/unipi:btw <question>` opens an inline panel and answers a side question from a fresh read-only session seeded with the main session's current context.
9
9
 
10
- BTW side sessions are read-only: they can read and search files with `read`, `grep`, `find`, and `ls`, but cannot run commands or modify files. Send requested changes to the main session with `/unipi:btw-inject` or `/unipi:btw-summarize`.
10
+ Rules the panel enforces:
11
+ - Read-only tools (`read`, `grep`, `find`, `ls`) — no commands or edits; changes belong in the main conversation.
12
+ - No memory between btw questions, and nothing reaches the main agent.
13
+ - Nothing is persisted — page history dies with the pi session.
11
14
 
12
- ## When to use BTW
13
-
14
- Prefer the BTW workflow when the user wants to:
15
-
16
- - ask a side question while the main agent keeps working
17
- - brainstorm or compare options without interrupting the current run
18
- - prepare a plan or summary before handing it back to the main agent
19
- - keep exploratory discussion out of the main transcript/context
20
-
21
- ## Commands
22
-
23
- Use these commands in your guidance to the user:
24
-
25
- ```text
26
- /unipi:btw <question>
27
- /unipi:btw --save <question>
28
- /unipi:btw-new [question]
29
- /unipi:btw-tangent <question>
30
- /unipi:btw-tangent --save <question>
31
- /unipi:btw-clear
32
- /unipi:btw-inject [instructions]
33
- /unipi:btw-summarize [instructions]
34
- ```
35
-
36
- ## How to guide the user
37
-
38
- ### For a quick side question
39
-
40
- Recommend:
41
-
42
- ```text
43
- /unipi:btw <question>
44
- ```
45
-
46
- Use this when the user wants an immediate aside and does not need a visible saved note.
47
-
48
- ### For a saved one-off note
49
-
50
- Recommend:
51
-
52
- ```text
53
- /unipi:btw --save <question>
54
- ```
55
-
56
- Use this when the user wants the exchange to appear as a visible BTW note in the session transcript.
57
-
58
- ### For a fresh side thread
59
-
60
- Recommend:
61
-
62
- ```text
63
- /unipi:btw-new
64
- ```
65
-
66
- or
67
-
68
- ```text
69
- /unipi:btw-new <question>
70
- ```
71
-
72
- Use this when the previous BTW discussion is no longer relevant, but you still want the new side thread to inherit the current main-session context.
73
-
74
- ### For a contextless tangent thread
75
-
76
- Recommend:
77
-
78
- ```text
79
- /unipi:btw-tangent <question>
80
- ```
81
-
82
- or
83
-
84
- ```text
85
- /unipi:btw-tangent --save <question>
86
- ```
87
-
88
- Use this when the user wants a side conversation that does not include the current main-session context.
89
-
90
- ### To hand the full thread back to the main agent
91
-
92
- Recommend:
93
-
94
- ```text
95
- /unipi:btw-inject <instructions>
96
- ```
97
-
98
- Use this when the exact discussion matters and the user wants the main agent to act on it.
99
-
100
- ### To hand back a condensed version
101
-
102
- Recommend:
103
-
104
- ```text
105
- /unipi:btw-summarize <instructions>
106
- ```
107
-
108
- Use this when the thread is long and only the distilled outcome should go back into the main agent.
109
-
110
- ## Recommendation rules
111
-
112
- - Prefer `/unipi:btw` over normal chat when the user explicitly wants a side conversation.
113
- - Prefer `/unipi:btw-tangent` when the user wants that side conversation to be contextless.
114
- - Prefer `/unipi:btw-summarize` over `/unipi:btw-inject` for long exploratory threads.
115
- - Prefer `/unipi:btw-inject` when precise wording, detailed tradeoffs, or a full plan matters.
116
- - Suggest `/unipi:btw-new` before starting a totally unrelated side topic when main-session context is still useful.
117
- - Suggest `/unipi:btw-clear` when the widget/thread should be dismissed.
118
-
119
- ## Response style
120
-
121
- When helping the user use BTW:
122
-
123
- - give the exact slash command to run
124
- - explain briefly why that command fits
125
- - keep the guidance short and operational
126
-
127
- ## Examples
128
-
129
- ### Example: brainstorm while coding continues
130
-
131
- ```text
132
- /unipi:btw what are the risks of switching this to optimistic updates?
133
- ```
134
-
135
- ### Example: create a clean new thread
136
-
137
- ```text
138
- /unipi:btw-new sketch a safer migration plan
139
- ```
140
-
141
- ### Example: start a contextless tangent
142
-
143
- ```text
144
- /unipi:btw-tangent think through this from first principles without using the current chat context
145
- ```
146
-
147
- ### Example: send the result back
148
-
149
- ```text
150
- /unipi:btw-summarize implement the recommended migration plan
151
- ```
15
+ When to suggest it: quick clarifications, "what is X doing" checks, reading files, thinking out loud — anything that shouldn't derail or pollute the main turn.
@@ -1,318 +1,87 @@
1
1
  # @pi-unipi/compactor
2
2
 
3
- Deterministic context management for Pi/UniPi. The compactor keeps long coding sessions usable by replacing large conversation history with a structured, zero-LLM summary, while preserving session recall, continuity snapshots, stats, sandbox helpers, and safer tool display.
3
+ Compaction for Pi that keeps work going. When the context fills up, the compactor replaces older messages with a summary. The full history stays in the session file, so nothing is lost and anything can be recalled.
4
4
 
5
- ## What it does
5
+ ## Methods
6
6
 
7
- - **Zero-LLM compaction:** Pi asks for compaction; UniPi builds the summary locally instead of spending model tokens on a summarization call.
8
- - **Session continuity:** important goals, changed files, commits, blockers, preferences, and a recent transcript survive compaction.
9
- - **Optional percentage trigger:** UniPi can compact at a configured context percentage before Pi's fixed reserve-token safety net fires.
10
- - **Recall:** agents can search the append-only session branch, including messages that no longer fit in live LLM context.
11
- - **Runtime helpers:** sandbox execution, context budget checks, diagnostics, and stats.
12
- - **Display guards:** tool output/diff rendering is clamped and summarized to avoid noisy or terminal-breaking output.
13
-
14
- The compaction pipeline is deterministic and runs locally. It does not call an LLM during compaction.
15
-
16
- ---
17
-
18
- ## Quick start
19
-
20
- ```text
21
- /unipi:settings (Compactor)
22
- ```
23
-
24
- 1. Choose a preset in **Presets**.
25
- 2. Optionally enable **Auto → Percentage Trigger**.
26
- 3. Press **Enter** to save.
27
- 4. Use `/unipi:lossless-compact` when you want to compact immediately.
28
-
29
- Config files:
30
-
31
- | Scope | Path | Notes |
32
- |---|---|---|
33
- | Global | `~/.unipi/config/compactor/config.json` | Used by default |
34
- | Per project | `<project>/.unipi/config/compactor.json` | Enabled from settings with **Project Override** |
35
-
36
- Per-project config is merged over global config when the current project directory is known.
37
-
38
- ---
39
-
40
- ## User-facing slash commands
41
-
42
- | Command | What it does | Notes |
7
+ | Method | What it does | Cost |
43
8
  |---|---|---|
44
- | `/unipi:lossless-compact` | Immediately calls Pi compaction with UniPi's zero-LLM sentinel. | Main manual compaction command. |
45
- | `/unipi:compact` | Deprecated alias for `/unipi:lossless-compact`. | Kept for backward compatibility. |
46
- | `/unipi:session-recall <query>` | Searches current session history with BM25/regex recall. | Uses the append-only session branch when available, so pre-compaction messages can still be found. |
47
- | `/unipi:compact-recall <query>` | Deprecated alias for `/unipi:session-recall`. | Kept for backward compatibility. |
48
- | `/unipi:compact-stats` | Shows session events, compaction count, token savings, sandbox runs, and search counts. | Stats are DB-backed with runtime fallbacks. |
49
- | `/unipi:compact-doctor` | Runs diagnostics for config, SQLite/session DB, and runtimes. | Useful when stats/recall/sandbox look broken. |
50
- | `/unipi:settings (Compactor)` | Opens the TUI settings overlay. | Tabs: Presets, Strategies, Auto, Pipeline. |
51
- | `/unipi:settings (Compactor › Presets) <name>` | Applies a preset globally. | Names: `precise`, `balanced`, `thorough`, `lean`. Old names map to new ones: `opencode→precise`, `verbose→thorough`, `minimal→lean`. |
52
- | `/unipi:compact-help` | Shows compact help inside Pi. | Quick command reference. |
9
+ | **Lossless** (default) | Builds a structured summary without a model call, in milliseconds. | Free |
10
+ | **Model summary** | Pi's own model-written summary, with the active-work block added on top. | One model call |
53
11
 
54
- Content/project indexing is not part of this package. Use `read`/`bash` (rg) for project search.
12
+ ### The lossless summary
55
13
 
56
- ---
14
+ It is rebuilt from the **full** session history on every compaction, never merged onto the previous summary, so it cannot drift or grow over time. Sections, in the order a resuming model needs them:
57
15
 
58
- ## User-facing settings
16
+ 1. **Active Work**: the goal, ralph loop or kanboard task in flight, supplied by those modules from their own state.
17
+ 2. **Your Requests**: the user's own messages and answers to agent questions (`ask_user`: "question → answer"). Text that extensions send with the user role (loop prompts, nudges, notifications) is excluded.
18
+ 3. **Latest State**: the most recent step and the last full progress report.
19
+ 4. **Decisions & Constraints**: the user's instructions ("keep the orange theme"), corrections ("I did not ask for this"), and answers to agent questions. Half the room goes to the most recent ones, the rest to standing rules from anywhere in the session ("always…", "never…", "by default…"). Bug reports, pasted text and code blocks are left out.
20
+ 5. **Files**: modified, created and read files, as relative paths.
21
+ 6. **Project Knowledge**: what the agent learned that no message states: project notes it wrote or read (SKILL.md, AGENTS.md, DESIGN.md, docs), build/test/deploy commands it ran more than once, and the hosts it worked against. Switched with the Files section.
22
+ 7. **Commits**: hash and subject.
23
+ 8. **Open Errors**: recent failures that were not followed by a success.
24
+ 9. **Recent Transcript**: a ranked slice of recent work.
59
25
 
60
- Open settings with `/unipi:settings (Compactor)`.
26
+ Each section has its own share of a hard budget (auto: 1.5k–4k tokens, scaling with session size). Credentials (typed passwords, API keys, bearer tokens) are redacted before anything is clipped; `session_recall` still has them. A closing line points the model to `session_recall`.
61
27
 
62
- Keyboard:
28
+ ## In the TUI
63
29
 
64
- | Key | Action |
65
- |---|---|
66
- | `Tab` | Switch tabs |
67
- | `↑/↓` | Move selection |
68
- | `Space` | Cycle/toggle selected value |
69
- | `/` | Search inside the Strategies tab |
70
- | `Enter` | Save and close |
71
- | `Esc` | Cancel |
72
-
73
- ### Presets tab
74
-
75
- Presets are profiles that set strategies, the implemented Auto Injection pipeline behavior, and sandbox mode.
76
-
77
- | Preset | Intended use | Important effects |
78
- |---|---|---|
79
- | `precise` | Code-heavy work, minimal waste | Full compaction sections, sandbox enabled, Auto Injection off. |
80
- | `balanced` | Daily/default profile | Compact transcript, sandbox enabled, Auto Injection on. |
81
- | `thorough` | Debug/audit sessions | Full transcript, sandbox enabled, Auto Injection on. |
82
- | `lean` | Quick fixes or short sessions | Brief/minimal compaction sections, no sandbox, no session continuity, Auto Injection off. |
30
+ - **Compaction card:** one line under Pi's own `[compaction]` block, e.g. `▌ Compacted 7.9k → 2.2k tokens · lossless · at 3%`. ctrl+o expands it: method, trigger, what was kept verbatim, summary sections. It is a custom entry: shown, never sent to the model.
31
+ - **Footer strip** (under the input): `5 compactions · 47k→15k · just now`, hidden until the first compaction. With the glance frame off, the `compactions` segment shows the same (`cmp 5× 47k→15k · 1m`).
32
+ - **Info screen** (`/unipi:info` → Compactor): method and trigger settings, compactions by method, tokens before → after, the last compaction.
83
33
 
84
- The **Project Override** row controls where settings are saved:
34
+ ## When it compacts
85
35
 
86
- - `disabled` → save global config.
87
- - `enabled` → save `<project>/.unipi/config/compactor.json` for only this project.
36
+ - **Pi's context limit** (default): Pi decides when, using its own compaction settings (`compaction.reserveTokens`, per-model overrides). The compactor decides what the summary contains. Pi continues the run after compacting.
37
+ - **At a percentage**: compacts once context use reaches the set percentage. This happens at a turn boundary, so running goal, ralph and kanboard loops are not interrupted.
88
38
 
89
- ### Strategies tab
39
+ ## Settings
90
40
 
91
- These settings control what is extracted into compaction summaries or how related compactor features behave.
41
+ `/unipi:settings → Compactor`
92
42
 
93
- | Setting | Values | Meaning |
43
+ | Setting | Default | |
94
44
  |---|---|---|
95
- | `Verbose Debug` | `on`, `off` | Enables internal debug state. Console debug output is intentionally muted to avoid TUI rendering issues. |
96
- | `Session Goals` | `full`, `brief`, `off` | Extracts the user's active goals/request history into `[Session Goal]`. |
97
- | `Files & Changes` | `all`, `modified-only`, `off` | Tracks read, created, edited, and written files in `[Files And Changes]`. |
98
- | `Commits` | `full`, `brief`, `off` | Captures git commit hashes/messages detected in the conversation. |
99
- | `Outstanding Context` | `full`, `critical-only`, `off` | Keeps blockers, TODOs, pending decisions, and follow-ups. |
100
- | `User Preferences` | `all`, `recent-only`, `off` | Preserves user preferences learned during the session. |
101
- | `Brief Transcript` | `full`, `compact`, `minimal`, `off` | Keeps a rolling recent transcript after the structured sections. |
102
- | `Session Continuity` | `full`, `off` | Controls XML-style resume snapshots. Off prevents snapshot creation and injection; Pi’s normal compaction summary still remains. |
103
- | `Sandbox Execution` | `all`, `off` | Controls sandbox tool registration. Changes require a session reload. Allowed languages and output limit are enforced from config. |
104
-
105
- Config-only legacy field: `fts5Index` remains in the schema for compatibility. It is hidden from Compactor settings and presets. Legacy `sessionContinuity.mode: "essential-only"`, `eventCategories`, and `sandboxExecution.mode: "safe-only"` values remain loadable; essential-only behaves as full and safe-only behaves as enabled/all until explicit filtering/security policies are designed. Legacy `toolDisplay` and `showTruncationHints` fields also remain loadable but are deprecated and ignored; their profile names were never mapped to runtime renderer modes. Narrow-terminal diff clamping remains active as independent safety behavior.
106
-
107
- ### Auto tab
108
-
109
- These settings control UniPi-managed percentage auto-compaction. They are separate from Pi core's own `compaction.reserveTokens` behavior.
110
-
111
- **Prefix-cache policy:** every compaction replaces provider-visible history and starts a new cache epoch. UniPi therefore keeps this second percentage trigger **off by default** and does not compact repeatedly merely to shorten a cache-hit request. Pi core remains the default safety trigger: with its documented defaults it compacts when estimated context exceeds `contextWindow - 16,384` reserved response tokens, while keeping about 20,000 recent tokens. If you deliberately enable the UniPi percentage trigger, 80% is an earlier explicit boundary and the cooldown/growth guards prevent loops. UniPi's compiler is deterministic and zero-LLM; it does not issue a second summarizer request.
112
-
113
- | Setting | Default | Meaning |
114
- |---|---:|---|
115
- | `Percentage Trigger` | `off` | When on, UniPi checks context usage at `agent_end` (after the agent run settles) and can call compaction when the threshold is reached. Disabled by default for backward compatibility. |
116
- | `Threshold` | `80%` | Trigger point using Pi's live `ctx.getContextUsage().percent`. |
117
- | `Cooldown` | `60s` | Minimum time between UniPi-triggered compaction attempts. Prevents loops. |
118
- | `Repeat Growth` | `4k` | If usage is still above threshold after compaction, require this many new tokens before triggering again. |
119
- | `Notifications` | `on` | Shows user-visible notifications for UniPi-triggered compaction attempts/results. |
120
-
121
- Example config:
122
-
123
- ```json
124
- {
125
- "autoCompaction": {
126
- "enabled": true,
127
- "thresholdPercent": 80,
128
- "cooldownMs": 60000,
129
- "repeatMinGrowthTokens": 4000,
130
- "notify": true
131
- }
132
- }
133
- ```
134
-
135
- ### Pipeline tab
136
-
137
- The Pipeline tab exposes only behavior implemented by the current runtime.
138
-
139
- | Setting | Preset behavior | Current effect |
140
- |---|---|---|
141
- | `Auto Injection` | On in `balanced`, `thorough`; off in `precise`, `lean` | Adds behavioral/session state to the one-shot resume context after compaction. |
142
-
143
- Deprecated config-only compatibility fields are still accepted so existing files load without migration failures, but they are ignored and no longer controlled or advertised by presets: `ttlCache`, `mmapPragma`, `proximityReranking`, `timelineSort`, and `progressiveThrottling`.
144
-
145
- Other config-only pipeline field:
146
-
147
- | Field | Meaning |
148
- |---|---|
149
- | `customNoisePatterns` | Extra regex/string patterns used by session recall filtering to remove noisy user blocks. |
150
-
151
- ---
45
+ | Method | lossless | lossless · model summary |
46
+ | Pi's /compact | same as Method | What Pi's built-in `/compact` does |
47
+ | When | Pi's context limit | Or: at a percentage |
48
+ | Percentage | 80 | Used when When = at a percentage |
49
+ | Notifications | on | The compaction card after automatic compactions (commands always show it); failures still notify |
152
50
 
153
- ## What the agent gets
51
+ **Advanced compaction** (collapsed): smart keep tail, summary budget, per-section toggles, percentage cooldown and repeat growth, extra instructions for model summaries, debug output.
154
52
 
155
- ### Agent tools
53
+ Configs from before the rework are translated automatically: `overrideDefaultCompaction: false` becomes Method = model summary, and `autoCompaction.enabled` becomes When = at a percentage.
156
54
 
157
- The extension registers tools during `session_start` after the session DB is initialized.
55
+ ## Commands
158
56
 
159
- | Tool | Purpose |
57
+ | Command | |
160
58
  |---|---|
161
- | `compact` | Agent-facing compaction request; supports `dryRun: true` preview. Slash command `/unipi:lossless-compact` is the user-facing immediate compaction path. |
162
- | `session_recall` | Search current session history with BM25 or regex. Defaults to 10 hits, hard-caps pages at 50, and caps expanded hit text at 16 KiB. |
163
- | `vcc_recall` | Deprecated alias for `session_recall`. |
164
- | `sandbox` | Run code in a sandboxed environment. Languages: JavaScript, TypeScript, Python, shell, Ruby, Go, Rust, PHP, Perl, R, Elixir. |
165
- | `sandbox_file` | Execute a file with its content injected as `FILE_CONTENT`. |
166
- | `sandbox_batch` | Run multiple sandbox execution items in one atomic response. |
167
- | `ctx_execute` | Deprecated alias for `sandbox`. |
168
- | `ctx_execute_file` | Deprecated alias for `sandbox_file`. |
169
- | `ctx_batch_execute` | Deprecated alias for `sandbox_batch`. |
170
- | `compactor_stats` | Agent-readable stats dashboard. |
171
- | `ctx_stats` | Deprecated alias for `compactor_stats`. |
172
- | `compactor_doctor` | Agent-readable diagnostics. |
173
- | `ctx_doctor` | Deprecated alias for `compactor_doctor`. |
174
- | `context_budget` | Uses live Pi context usage when available and returns compaction guidance. |
59
+ | `/unipi:compact-vcc [keep:N]` | Lossless compaction now; `keep:N` keeps the last N user turns |
60
+ | `/unipi:compact-by-llm [focus]` | Model-summary compaction now; optional text focuses the summary |
61
+ | `/unipi:session-recall <query>` | Search the full session history (`scope:all`, `page:N`) |
62
+ | `/unipi:compact-stats` | This session's compactions and savings |
63
+ | `/unipi:compact-doctor` | Check settings, Pi's compaction switch, leftovers |
64
+ | `/unipi:compact-help` | Command summary |
175
65
 
176
- ### Agent skills
66
+ Removed: `/unipi:compact` and `/unipi:lossless-compact` (use `/unipi:compact-vcc`), `/unipi:compact-recall` (use `/unipi:session-recall`), `/unipi:compact-jev` and the jev method (a saved `method: "jev"` behaves as lossless).
177
67
 
178
- | Skill | Purpose |
179
- |---|---|
180
- | `compactor` | Small always-loadable routing skill: when to compact, recall, check budget, or use sandbox. |
181
- | `compactor-detail` | On-demand full tool reference and workflow guidance. |
182
- | `compactor-stats` | Help interpreting compactor stats. |
183
- | `compactor-doctor` | Help diagnosing config/DB/runtime issues. |
184
-
185
- ---
186
-
187
- ## How the system works
188
-
189
- ### Chronological hook flow
190
-
191
- Typical session order:
192
-
193
- 1. **Extension load**
194
- - Registers compaction hooks immediately with lazy dependencies.
195
- - Creates in-memory runtime counters/state.
196
-
197
- 2. **`session_start`**
198
- - Scaffolds config if needed.
199
- - Initializes `SessionDB` and sandbox executor.
200
- - Computes the current session ID, including worktree suffix.
201
- - Registers agent tools and slash commands.
202
- - Registers the info-screen Compactor group.
203
- - Emits UniPi `MODULE_READY`.
204
-
205
- 3. **`before_agent_start`**
206
- - Reloads config for the active project.
207
- - Applies runtime `autoDetect` behavior, such as disabling commit extraction outside git repos.
208
- - Rebuilds cached recall blocks from Pi's append-only session branch.
209
- - If a resume snapshot exists from a prior compaction, injects it into session context and marks it consumed.
210
-
211
- 4. **`input`**
212
- - Performs advisory security checks for shell/network/file patterns.
213
- - Can block some known-dangerous network shell commands.
214
-
215
- 5. **Tool execution → `tool_result`**
216
- - Extracts file/change/search/sandbox events into the session DB.
217
- - Updates runtime byte/tool counters.
218
- - Applies display overrides and width-safe diff clamping before output reaches the TUI.
219
-
220
- 6. **`agent_end`**
221
- - If percentage auto-compaction is enabled, reads `ctx.getContextUsage()`.
222
- - Runs cooldown/repeat-growth safeguards.
223
- - Calls `ctx.compact({ customInstructions: COMPACTOR_INSTRUCTION })` when eligible.
224
- - Fires only after the agent run settles: `ctx.compact()` aborts any active operation first, so triggering mid-run (e.g. at `turn_end`) would kill the next provider request.
225
-
226
- 7. **Pi decides to compact**
227
- - This can be from `/unipi:lossless-compact`, UniPi percentage auto-compaction, or Pi core's reserve-token fallback.
228
-
229
- 8. **`session_before_compact`**
230
- - Pi provides `preparation`, `branchEntries`, and optional custom instructions.
231
- - If compactor should handle it, UniPi:
232
- 1. chooses the safe cut point (`buildOwnCut`),
233
- 2. converts messages to LLM-like input,
234
- 3. runs the zero-LLM compile pipeline,
235
- 4. persists stats/snapshots,
236
- 5. returns `{ compaction: { summary, details, tokensBefore, firstKeptEntryId } }` to Pi.
237
-
238
- 9. **`session_compact`**
239
- - Pi commits the compaction entry.
240
- - UniPi increments compaction counters and persists token/character savings.
241
-
242
- 10. **Next `before_agent_start` after compaction**
243
- - UniPi injects the resume snapshot so the agent gets continuity without needing the full old transcript in context.
244
-
245
- 11. **`session_shutdown`**
246
- - Cleans old sessions.
247
- - Cleans sandbox/background processes.
248
- - Closes DB handles.
249
-
250
- ### Zero-LLM compile pipeline
251
-
252
- When UniPi handles `session_before_compact`, it transforms old messages through these deterministic stages:
68
+ ## Tools
253
69
 
254
- 1. **Normalize** — flatten user/assistant/tool/thinking messages into normalized blocks.
255
- 2. **Filter** — remove noise and apply `customNoisePatterns`.
256
- 3. **Build sections** — extract goals, files, commits, outstanding context, preferences, and transcript entries.
257
- 4. **Brief** — cap and condense transcript lines.
258
- 5. **Format** — emit a structured markdown summary.
259
- 6. **Merge** — merge with the previous summary when Pi provides one.
70
+ - `session_recall`: keyword/regex search over the session branch, including compacted-away messages. `expand` returns full entries by index (the `#N` refs in summaries); `mode: "touched"` lists files.
71
+ - `context_budget`: how full the context is.
260
72
 
261
- The resulting summary is optimized for continuity, not for perfect archival fidelity. Use `session_recall` when the agent needs details from the raw session branch. Recall is deliberately paginated: request another offset page or narrow the query instead of injecting an unbounded result set. Even with `expand: true`, each hit is capped at 16 KiB to prevent a single historical message or tool result from dominating future cold-cache requests.
73
+ ## For other modules
262
74
 
263
- ---
75
+ Register an active-work provider so summaries lead with your state:
264
76
 
265
- ## Benchmarks
266
-
267
- Synthetic compile-only benchmark, run on this repository with Node 24 using `compile()` directly. Token counts use the common `chars / 4` estimate. Real compaction also keeps a recent live tail, so final live-context size can be larger than the summary-only number below.
268
-
269
- | Synthetic session | Input chars | Approx input tokens | Summary chars | Approx summary tokens | Reduction | Compile time |
270
- |---:|---:|---:|---:|---:|---:|---:|
271
- | 100 turns / 400 messages | 356,913 | 89,228 | 36,451 | 9,113 | 89.8% | 12.5 ms |
272
- | 250 turns / 1,000 messages | 894,063 | 223,516 | 36,585 | 9,146 | 95.9% | 16.6 ms |
273
- | 500 turns / 2,000 messages | 1,789,313 | 447,328 | 36,605 | 9,151 | 98.0% | 35.8 ms |
274
-
275
- Practical interpretation:
276
-
277
- - Larger sessions compress better because the structured summary has fixed caps.
278
- - Runtime is local and usually small relative to model/tool latency.
279
- - Actual savings reported to users should come from `/unipi:compact-stats`, because Pi supplies real `tokensBefore` during compaction when available.
280
-
281
- ---
282
-
283
- ## Troubleshooting
284
-
285
- ### "Whatever preset I choose, Pipeline is always off"
286
-
287
- That means preset application is not updating `config.pipeline`. The intended behavior is:
288
-
289
- - `precise`: Auto Injection off.
290
- - `balanced`: Auto Injection on.
291
- - `thorough`: Auto Injection on.
292
- - `lean`: Auto Injection off.
293
-
294
- The five deprecated compatibility fields remain off in every preset.
295
-
296
- Make sure you are running a version with the preset pipeline fix, select the preset, and press **Enter** to save.
297
-
298
- ### "Compaction did not happen"
299
-
300
- - For immediate user-triggered compaction, use `/unipi:lossless-compact`.
301
- - For automatic percentage compaction, enable **Auto → Percentage Trigger**.
302
- - Pi core still has its own reserve-token fallback; UniPi's percentage trigger is optional and disabled by default.
303
-
304
- ### "Stats show zero"
305
-
306
- - Stats only increase after compaction or after tracked sandbox/search events.
307
- - Run `/unipi:compact-doctor` to check DB/config health.
308
- - Long sessions may show all-time DB fallbacks if current in-memory counters are zero.
309
-
310
- ### "Recall cannot find something"
77
+ ```ts
78
+ import { registerCompactionContext } from "@pi-unipi/core";
79
+ registerCompactionContext("my-module", () => (running ? "Task X is in progress — …" : null));
80
+ ```
311
81
 
312
- - Use specific terms with `/unipi:session-recall <query>`.
313
- - The recall path prefers Pi's append-only branch and falls back to cached normalized blocks.
314
- - Extra noise filtering can be added with `pipeline.customNoisePatterns`.
82
+ Compactions applied at a turn boundary (percentage trigger) do not fire Pi's `session_compact`; listen to `UNIPI_EVENTS.COMPACTOR_COMPACTED` to react to every compaction.
315
83
 
316
- ## License
84
+ ## Removed in 3.0
317
85
 
318
- MIT
86
+ - **Session continuity**: the SQLite event log and the hidden snapshot restored after compaction. It logged every session under one shared ID, so snapshots mixed projects and grew to ~60k tokens. The summary now derives files, errors and commits from the session itself. `/unipi:compact-doctor` reports the old `~/.unipi/db/compactor` directory, which can be deleted.
87
+ - **Sandbox tools** (`sandbox`, `sandbox_file`, `sandbox_batch`), the `compact` tool (it never compacted), `compactor_stats` / `compactor_doctor` tools (use the commands), presets, and the inert strategy modes.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pi-unipi/compactor",
3
- "version": "3.0.0-alpha.2",
4
- "description": "Context engine for Pi — zero-LLM compaction, session continuity, sandbox execution, and tool display optimization",
3
+ "version": "3.0.0-alpha.21",
4
+ "description": "Compaction for Pi — lossless zero-LLM or model summaries, rebuilt from full history, with session recall",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
7
7
  "license": "MIT",
@@ -18,8 +18,7 @@
18
18
  "unipi",
19
19
  "compactor",
20
20
  "context",
21
- "sandbox",
22
- "fts5"
21
+ "compaction"
23
22
  ],
24
23
  "scripts": {
25
24
  "test": "npx bun test tests"
@@ -34,8 +33,8 @@
34
33
  "access": "public"
35
34
  },
36
35
  "dependencies": {
37
- "@pi-unipi/core": "3.0.0-alpha.2",
38
- "@pi-unipi/info-screen": "3.0.0-alpha.2",
36
+ "@pi-unipi/core": "3.0.0-alpha.21",
37
+ "@pi-unipi/info-screen": "3.0.0-alpha.21",
39
38
  "@earendil-works/pi-agent-core": "^0.87.1"
40
39
  },
41
40
  "peerDependencies": {
@@ -47,9 +46,6 @@
47
46
  "@types/node": "^25.6.0",
48
47
  "typescript": "^6.0.0"
49
48
  },
50
- "optionalDependencies": {
51
- "better-sqlite3": ">=11.0.0"
52
- },
53
49
  "pi": {
54
50
  "extensions": [
55
51
  "./index.ts"
@@ -1,29 +1,22 @@
1
1
  ---
2
2
  name: compactor
3
- description: Context management — compact session, recall history, run code, search content.
3
+ description: Session recall and compaction — use when earlier parts of this session are missing from context, or after a compaction summary.
4
4
  ---
5
5
 
6
- # Compactor — Context Management
6
+ # Compactor
7
7
 
8
- ## When Context Is Tight
9
- - `context_budget` → check % full. `compact` → free tokens (zero-LLM, 98%+ reduction).
10
- Compact BEFORE complex work. `compact(dryRun: true)` to preview without compacting.
11
- - `compactor_stats` → check savings. `compactor_doctor` → diagnose.
8
+ Compaction is automatic: when the context fills, it is replaced by a summary and the work carries on. Keep working through it.
12
9
 
13
- ## Finding Past Work
14
- - `session_recall(query)` → search this session (BM25 or regex), including raw messages that may no longer be in live context after compaction.
15
- - For project/file search, use `read`/`bash` (rg) directly; content indexing is not part of compactor.
10
+ ## After a compaction
16
11
 
17
- ## Running Code
18
- - `sandbox(lang, code)` → single script. `sandbox_batch(items)` → atomic.
19
- `sandbox_file(lang, path)` → run file. Only stdout enters context.
12
+ The summary opens with **Active Work** (the goal, ralph loop or kanboard task in flight) — treat it as authoritative and continue that work. Then come the user's requests, the latest state, decisions, files, commits and open errors.
20
13
 
21
- ## Complex Multi-Step Tasks
22
- ⚠ When the task spans many operations, PREFER Ralph loops
23
- (`the implementation step`, `ralph_start`) if available — they manage
24
- context pressure better than monolithic runs.
14
+ ## Recall
25
15
 
26
- ## Critical Rules
27
- - Compact BEFORE starting, not when full.
28
- - `session_recall` instead of scrolling history.
29
- - Index project files early if you'll search often.
16
+ The full session history is kept. Reach for `session_recall` whenever a detail is missing:
17
+
18
+ - `session_recall(query: "redis cache decision")` — plain keywords work best.
19
+ - `#123`-style refs in the summary are entry indices: `session_recall(expand: [123])` returns the full content.
20
+ - `mode: "touched"` lists the files worked on; `scope: "all"` also covers edited or retried turns.
21
+
22
+ `context_budget` reports how full the context is.