pi-ui-extend 0.1.1

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 (420) hide show
  1. package/README.md +307 -0
  2. package/bin/pix.mjs +219 -0
  3. package/dist/app/app.d.ts +96 -0
  4. package/dist/app/app.js +871 -0
  5. package/dist/app/blink-controller.d.ts +23 -0
  6. package/dist/app/blink-controller.js +82 -0
  7. package/dist/app/cli.d.ts +8 -0
  8. package/dist/app/cli.js +83 -0
  9. package/dist/app/clipboard.d.ts +1 -0
  10. package/dist/app/clipboard.js +24 -0
  11. package/dist/app/command-controller.d.ts +18 -0
  12. package/dist/app/command-controller.js +58 -0
  13. package/dist/app/command-host.d.ts +44 -0
  14. package/dist/app/command-host.js +1 -0
  15. package/dist/app/command-model-actions.d.ts +12 -0
  16. package/dist/app/command-model-actions.js +176 -0
  17. package/dist/app/command-navigation-actions.d.ts +19 -0
  18. package/dist/app/command-navigation-actions.js +267 -0
  19. package/dist/app/command-registry.d.ts +32 -0
  20. package/dist/app/command-registry.js +225 -0
  21. package/dist/app/command-runtime.d.ts +5 -0
  22. package/dist/app/command-runtime.js +32 -0
  23. package/dist/app/command-session-actions.d.ts +20 -0
  24. package/dist/app/command-session-actions.js +295 -0
  25. package/dist/app/constants.d.ts +52 -0
  26. package/dist/app/constants.js +103 -0
  27. package/dist/app/conversation-entry-renderer.d.ts +21 -0
  28. package/dist/app/conversation-entry-renderer.js +81 -0
  29. package/dist/app/conversation-shell-renderer.d.ts +5 -0
  30. package/dist/app/conversation-shell-renderer.js +43 -0
  31. package/dist/app/conversation-tool-renderer.d.ts +16 -0
  32. package/dist/app/conversation-tool-renderer.js +216 -0
  33. package/dist/app/conversation-viewport.d.ts +55 -0
  34. package/dist/app/conversation-viewport.js +252 -0
  35. package/dist/app/dcp-stats.d.ts +2 -0
  36. package/dist/app/dcp-stats.js +116 -0
  37. package/dist/app/editor-layout-renderer.d.ts +31 -0
  38. package/dist/app/editor-layout-renderer.js +211 -0
  39. package/dist/app/editor-panels.d.ts +4 -0
  40. package/dist/app/editor-panels.js +130 -0
  41. package/dist/app/extension-actions-controller.d.ts +22 -0
  42. package/dist/app/extension-actions-controller.js +60 -0
  43. package/dist/app/extension-event-bus.d.ts +3 -0
  44. package/dist/app/extension-event-bus.js +23 -0
  45. package/dist/app/extension-ui-controller.d.ts +57 -0
  46. package/dist/app/extension-ui-controller.js +532 -0
  47. package/dist/app/file-link-opener.d.ts +2 -0
  48. package/dist/app/file-link-opener.js +66 -0
  49. package/dist/app/file-links.d.ts +10 -0
  50. package/dist/app/file-links.js +117 -0
  51. package/dist/app/guards.d.ts +3 -0
  52. package/dist/app/guards.js +9 -0
  53. package/dist/app/icons.d.ts +37 -0
  54. package/dist/app/icons.js +97 -0
  55. package/dist/app/id.d.ts +1 -0
  56. package/dist/app/id.js +4 -0
  57. package/dist/app/image-click-targets.d.ts +5 -0
  58. package/dist/app/image-click-targets.js +32 -0
  59. package/dist/app/image-opener.d.ts +2 -0
  60. package/dist/app/image-opener.js +64 -0
  61. package/dist/app/input-action-controller.d.ts +47 -0
  62. package/dist/app/input-action-controller.js +209 -0
  63. package/dist/app/input-controller.d.ts +60 -0
  64. package/dist/app/input-controller.js +425 -0
  65. package/dist/app/input-paste-handler.d.ts +27 -0
  66. package/dist/app/input-paste-handler.js +146 -0
  67. package/dist/app/menu-items-controller.d.ts +32 -0
  68. package/dist/app/menu-items-controller.js +182 -0
  69. package/dist/app/message-content.d.ts +8 -0
  70. package/dist/app/message-content.js +115 -0
  71. package/dist/app/model-ref.d.ts +13 -0
  72. package/dist/app/model-ref.js +50 -0
  73. package/dist/app/model-usage-controller.d.ts +35 -0
  74. package/dist/app/model-usage-controller.js +99 -0
  75. package/dist/app/model-usage-status.d.ts +125 -0
  76. package/dist/app/model-usage-status.js +749 -0
  77. package/dist/app/mouse-controller.d.ts +182 -0
  78. package/dist/app/mouse-controller.js +968 -0
  79. package/dist/app/native-modifiers.d.ts +3 -0
  80. package/dist/app/native-modifiers.js +60 -0
  81. package/dist/app/nerd-font-controller.d.ts +11 -0
  82. package/dist/app/nerd-font-controller.js +90 -0
  83. package/dist/app/popup-action-controller.d.ts +44 -0
  84. package/dist/app/popup-action-controller.js +278 -0
  85. package/dist/app/popup-menu-controller.d.ts +183 -0
  86. package/dist/app/popup-menu-controller.js +1070 -0
  87. package/dist/app/prompt-enhancer-controller.d.ts +40 -0
  88. package/dist/app/prompt-enhancer-controller.js +215 -0
  89. package/dist/app/queued-message-controller.d.ts +62 -0
  90. package/dist/app/queued-message-controller.js +377 -0
  91. package/dist/app/render-controller.d.ts +41 -0
  92. package/dist/app/render-controller.js +378 -0
  93. package/dist/app/render-text.d.ts +19 -0
  94. package/dist/app/render-text.js +67 -0
  95. package/dist/app/request-history.d.ts +23 -0
  96. package/dist/app/request-history.js +131 -0
  97. package/dist/app/runtime.d.ts +39 -0
  98. package/dist/app/runtime.js +195 -0
  99. package/dist/app/screen-selection.d.ts +6 -0
  100. package/dist/app/screen-selection.js +9 -0
  101. package/dist/app/screen-styler.d.ts +34 -0
  102. package/dist/app/screen-styler.js +168 -0
  103. package/dist/app/scroll-controller.d.ts +51 -0
  104. package/dist/app/scroll-controller.js +207 -0
  105. package/dist/app/session-event-controller.d.ts +69 -0
  106. package/dist/app/session-event-controller.js +338 -0
  107. package/dist/app/session-history.d.ts +23 -0
  108. package/dist/app/session-history.js +164 -0
  109. package/dist/app/session-lifecycle-controller.d.ts +55 -0
  110. package/dist/app/session-lifecycle-controller.js +116 -0
  111. package/dist/app/session-search.d.ts +24 -0
  112. package/dist/app/session-search.js +215 -0
  113. package/dist/app/shell-command.d.ts +27 -0
  114. package/dist/app/shell-command.js +176 -0
  115. package/dist/app/shell-controller.d.ts +28 -0
  116. package/dist/app/shell-controller.js +124 -0
  117. package/dist/app/slash-commands.d.ts +6 -0
  118. package/dist/app/slash-commands.js +75 -0
  119. package/dist/app/startup-checks.d.ts +8 -0
  120. package/dist/app/startup-checks.js +59 -0
  121. package/dist/app/startup-info.d.ts +3 -0
  122. package/dist/app/startup-info.js +176 -0
  123. package/dist/app/status-controller.d.ts +35 -0
  124. package/dist/app/status-controller.js +105 -0
  125. package/dist/app/status-line-renderer.d.ts +68 -0
  126. package/dist/app/status-line-renderer.js +453 -0
  127. package/dist/app/subagents-files.d.ts +10 -0
  128. package/dist/app/subagents-files.js +193 -0
  129. package/dist/app/subagents-model.d.ts +23 -0
  130. package/dist/app/subagents-model.js +224 -0
  131. package/dist/app/subagents-widget-controller.d.ts +43 -0
  132. package/dist/app/subagents-widget-controller.js +311 -0
  133. package/dist/app/tab-line-renderer.d.ts +26 -0
  134. package/dist/app/tab-line-renderer.js +222 -0
  135. package/dist/app/tabs-controller.d.ts +100 -0
  136. package/dist/app/tabs-controller.js +885 -0
  137. package/dist/app/terminal-controller.d.ts +40 -0
  138. package/dist/app/terminal-controller.js +135 -0
  139. package/dist/app/terminal-edit-shortcuts.d.ts +23 -0
  140. package/dist/app/terminal-edit-shortcuts.js +138 -0
  141. package/dist/app/terminal-output-buffer.d.ts +20 -0
  142. package/dist/app/terminal-output-buffer.js +52 -0
  143. package/dist/app/toast-controller.d.ts +13 -0
  144. package/dist/app/toast-controller.js +40 -0
  145. package/dist/app/toast-renderer.d.ts +9 -0
  146. package/dist/app/toast-renderer.js +79 -0
  147. package/dist/app/todo-model.d.ts +22 -0
  148. package/dist/app/todo-model.js +179 -0
  149. package/dist/app/todo-widget-controller.d.ts +21 -0
  150. package/dist/app/todo-widget-controller.js +59 -0
  151. package/dist/app/tool-block-renderer.d.ts +26 -0
  152. package/dist/app/tool-block-renderer.js +439 -0
  153. package/dist/app/types.d.ts +550 -0
  154. package/dist/app/types.js +1 -0
  155. package/dist/app/update.d.ts +36 -0
  156. package/dist/app/update.js +315 -0
  157. package/dist/app/voice-controller.d.ts +52 -0
  158. package/dist/app/voice-controller.js +600 -0
  159. package/dist/app/workspace-actions-controller.d.ts +40 -0
  160. package/dist/app/workspace-actions-controller.js +215 -0
  161. package/dist/app/workspace-undo.d.ts +44 -0
  162. package/dist/app/workspace-undo.js +215 -0
  163. package/dist/config.d.ts +62 -0
  164. package/dist/config.js +527 -0
  165. package/dist/context-progress-bar.d.ts +17 -0
  166. package/dist/context-progress-bar.js +48 -0
  167. package/dist/default-pix-config.d.ts +1 -0
  168. package/dist/default-pix-config.js +375 -0
  169. package/dist/fuzzy.d.ts +23 -0
  170. package/dist/fuzzy.js +165 -0
  171. package/dist/input-editor-files.d.ts +15 -0
  172. package/dist/input-editor-files.js +62 -0
  173. package/dist/input-editor.d.ts +186 -0
  174. package/dist/input-editor.js +835 -0
  175. package/dist/main.d.ts +1 -0
  176. package/dist/main.js +12 -0
  177. package/dist/markdown-format.d.ts +22 -0
  178. package/dist/markdown-format.js +542 -0
  179. package/dist/sdk.d.ts +3 -0
  180. package/dist/sdk.js +1 -0
  181. package/dist/syntax-highlight.d.ts +22 -0
  182. package/dist/syntax-highlight.js +528 -0
  183. package/dist/terminal-width.d.ts +6 -0
  184. package/dist/terminal-width.js +245 -0
  185. package/dist/theme.d.ts +56 -0
  186. package/dist/theme.js +118 -0
  187. package/dist/tool-renderers/apply-patch.d.ts +2 -0
  188. package/dist/tool-renderers/apply-patch.js +36 -0
  189. package/dist/tool-renderers/ast.d.ts +2 -0
  190. package/dist/tool-renderers/ast.js +5 -0
  191. package/dist/tool-renderers/compress.d.ts +2 -0
  192. package/dist/tool-renderers/compress.js +126 -0
  193. package/dist/tool-renderers/index.d.ts +3 -0
  194. package/dist/tool-renderers/index.js +44 -0
  195. package/dist/tool-renderers/question.d.ts +2 -0
  196. package/dist/tool-renderers/question.js +88 -0
  197. package/dist/tool-renderers/read.d.ts +2 -0
  198. package/dist/tool-renderers/read.js +36 -0
  199. package/dist/tool-renderers/repo.d.ts +2 -0
  200. package/dist/tool-renderers/repo.js +13 -0
  201. package/dist/tool-renderers/shell.d.ts +3 -0
  202. package/dist/tool-renderers/shell.js +27 -0
  203. package/dist/tool-renderers/skill.d.ts +2 -0
  204. package/dist/tool-renderers/skill.js +132 -0
  205. package/dist/tool-renderers/subagents.d.ts +2 -0
  206. package/dist/tool-renderers/subagents.js +51 -0
  207. package/dist/tool-renderers/todo.d.ts +2 -0
  208. package/dist/tool-renderers/todo.js +9 -0
  209. package/dist/tool-renderers/types.d.ts +42 -0
  210. package/dist/tool-renderers/types.js +1 -0
  211. package/dist/tool-renderers/utils.d.ts +31 -0
  212. package/dist/tool-renderers/utils.js +230 -0
  213. package/dist/tool-renderers/web.d.ts +3 -0
  214. package/dist/tool-renderers/web.js +9 -0
  215. package/dist/tool-renderers/write.d.ts +2 -0
  216. package/dist/tool-renderers/write.js +42 -0
  217. package/dist/ui.d.ts +56 -0
  218. package/dist/ui.js +94 -0
  219. package/docs/release.md +81 -0
  220. package/extensions/question/contract.ts +100 -0
  221. package/extensions/question/index.ts +34 -0
  222. package/extensions/question/render.ts +28 -0
  223. package/extensions/question/result.ts +86 -0
  224. package/extensions/question/tool-description.ts +11 -0
  225. package/extensions/question/tui.ts +629 -0
  226. package/extensions/question/types.ts +123 -0
  227. package/extensions/session-title/config.ts +169 -0
  228. package/extensions/session-title/index.ts +459 -0
  229. package/extensions/terminal-bell/index.ts +315 -0
  230. package/external/pi-tools-suite/README.md +242 -0
  231. package/external/pi-tools-suite/index.ts +1 -0
  232. package/external/pi-tools-suite/licenses/ollama-pi-web-search.MIT +21 -0
  233. package/external/pi-tools-suite/licenses/opencode-mystatus-MIT.txt +21 -0
  234. package/external/pi-tools-suite/package.json +53 -0
  235. package/external/pi-tools-suite/src/antigravity-auth/auth-store.ts +194 -0
  236. package/external/pi-tools-suite/src/antigravity-auth/commands.ts +80 -0
  237. package/external/pi-tools-suite/src/antigravity-auth/constants.ts +26 -0
  238. package/external/pi-tools-suite/src/antigravity-auth/headers.ts +20 -0
  239. package/external/pi-tools-suite/src/antigravity-auth/index.ts +104 -0
  240. package/external/pi-tools-suite/src/antigravity-auth/models.ts +86 -0
  241. package/external/pi-tools-suite/src/antigravity-auth/oauth.ts +305 -0
  242. package/external/pi-tools-suite/src/antigravity-auth/payload.ts +423 -0
  243. package/external/pi-tools-suite/src/antigravity-auth/status.ts +78 -0
  244. package/external/pi-tools-suite/src/antigravity-auth/stream.ts +302 -0
  245. package/external/pi-tools-suite/src/antigravity-auth/types.ts +113 -0
  246. package/external/pi-tools-suite/src/ast-grep/index.ts +6 -0
  247. package/external/pi-tools-suite/src/ast-grep/render.ts +70 -0
  248. package/external/pi-tools-suite/src/ast-grep/schema.ts +109 -0
  249. package/external/pi-tools-suite/src/ast-grep/tool.ts +345 -0
  250. package/external/pi-tools-suite/src/ast-grep/types.ts +55 -0
  251. package/external/pi-tools-suite/src/ast-grep/utils.ts +65 -0
  252. package/external/pi-tools-suite/src/async-subagents/async-subagents.sample.jsonc +222 -0
  253. package/external/pi-tools-suite/src/async-subagents/commands.ts +518 -0
  254. package/external/pi-tools-suite/src/async-subagents/constants.ts +11 -0
  255. package/external/pi-tools-suite/src/async-subagents/core/agent-strategy.ts +74 -0
  256. package/external/pi-tools-suite/src/async-subagents/core/attachment-bridge.ts +133 -0
  257. package/external/pi-tools-suite/src/async-subagents/core/cleanup.ts +66 -0
  258. package/external/pi-tools-suite/src/async-subagents/core/concurrency.ts +90 -0
  259. package/external/pi-tools-suite/src/async-subagents/core/config.ts +819 -0
  260. package/external/pi-tools-suite/src/async-subagents/core/log-limits.ts +166 -0
  261. package/external/pi-tools-suite/src/async-subagents/core/model-fallback.ts +133 -0
  262. package/external/pi-tools-suite/src/async-subagents/core/paths.ts +47 -0
  263. package/external/pi-tools-suite/src/async-subagents/core/pi-invocation.ts +35 -0
  264. package/external/pi-tools-suite/src/async-subagents/core/presets.ts +67 -0
  265. package/external/pi-tools-suite/src/async-subagents/core/process.ts +15 -0
  266. package/external/pi-tools-suite/src/async-subagents/core/prompt.ts +66 -0
  267. package/external/pi-tools-suite/src/async-subagents/core/registry.ts +224 -0
  268. package/external/pi-tools-suite/src/async-subagents/core/retry.ts +191 -0
  269. package/external/pi-tools-suite/src/async-subagents/core/routing.ts +259 -0
  270. package/external/pi-tools-suite/src/async-subagents/core/sessions.ts +138 -0
  271. package/external/pi-tools-suite/src/async-subagents/core/spawn.ts +688 -0
  272. package/external/pi-tools-suite/src/async-subagents/core/state.ts +281 -0
  273. package/external/pi-tools-suite/src/async-subagents/core/stop.ts +131 -0
  274. package/external/pi-tools-suite/src/async-subagents/core/structured-result.ts +237 -0
  275. package/external/pi-tools-suite/src/async-subagents/core/tool-guard.ts +34 -0
  276. package/external/pi-tools-suite/src/async-subagents/core/types.ts +150 -0
  277. package/external/pi-tools-suite/src/async-subagents/core/ultrawork-auto.ts +184 -0
  278. package/external/pi-tools-suite/src/async-subagents/core/utils.ts +11 -0
  279. package/external/pi-tools-suite/src/async-subagents/format.ts +41 -0
  280. package/external/pi-tools-suite/src/async-subagents/index.ts +422 -0
  281. package/external/pi-tools-suite/src/async-subagents/lib.ts +88 -0
  282. package/external/pi-tools-suite/src/async-subagents/live.ts +10 -0
  283. package/external/pi-tools-suite/src/async-subagents/polling.ts +83 -0
  284. package/external/pi-tools-suite/src/async-subagents/render.ts +230 -0
  285. package/external/pi-tools-suite/src/async-subagents/subagent-overlay.ts +77 -0
  286. package/external/pi-tools-suite/src/async-subagents/tasks.ts +120 -0
  287. package/external/pi-tools-suite/src/async-subagents/tools/cleanup.ts +99 -0
  288. package/external/pi-tools-suite/src/async-subagents/tools/result.ts +179 -0
  289. package/external/pi-tools-suite/src/async-subagents/tools/spawn.ts +372 -0
  290. package/external/pi-tools-suite/src/async-subagents/tools/status.ts +60 -0
  291. package/external/pi-tools-suite/src/async-subagents/tools/stop.ts +79 -0
  292. package/external/pi-tools-suite/src/async-subagents/tools/subagents.ts +152 -0
  293. package/external/pi-tools-suite/src/async-subagents/tools/wait.ts +67 -0
  294. package/external/pi-tools-suite/src/async-subagents/types.ts +45 -0
  295. package/external/pi-tools-suite/src/async-subagents/ui.ts +5 -0
  296. package/external/pi-tools-suite/src/compress/commands.ts +440 -0
  297. package/external/pi-tools-suite/src/compress/compress-tool.ts +368 -0
  298. package/external/pi-tools-suite/src/compress/compression-blocks.ts +524 -0
  299. package/external/pi-tools-suite/src/compress/config.ts +310 -0
  300. package/external/pi-tools-suite/src/compress/dcp-tui-filter.ts +498 -0
  301. package/external/pi-tools-suite/src/compress/index.ts +397 -0
  302. package/external/pi-tools-suite/src/compress/prompts.ts +269 -0
  303. package/external/pi-tools-suite/src/compress/pruner-candidates.ts +176 -0
  304. package/external/pi-tools-suite/src/compress/pruner-compression-blocks.ts +260 -0
  305. package/external/pi-tools-suite/src/compress/pruner-message-ids.ts +147 -0
  306. package/external/pi-tools-suite/src/compress/pruner-metadata.ts +268 -0
  307. package/external/pi-tools-suite/src/compress/pruner-nudge.ts +315 -0
  308. package/external/pi-tools-suite/src/compress/pruner-tools.ts +263 -0
  309. package/external/pi-tools-suite/src/compress/pruner-types.ts +25 -0
  310. package/external/pi-tools-suite/src/compress/pruner.ts +92 -0
  311. package/external/pi-tools-suite/src/compress/state.ts +486 -0
  312. package/external/pi-tools-suite/src/compress/ui.ts +308 -0
  313. package/external/pi-tools-suite/src/config.ts +176 -0
  314. package/external/pi-tools-suite/src/context-usage.ts +31 -0
  315. package/external/pi-tools-suite/src/default-pi-tools-suite-config.ts +355 -0
  316. package/external/pi-tools-suite/src/index.ts +46 -0
  317. package/external/pi-tools-suite/src/lib/lsp.ts +62 -0
  318. package/external/pi-tools-suite/src/lib/project.ts +42 -0
  319. package/external/pi-tools-suite/src/lib/tool-args.ts +137 -0
  320. package/external/pi-tools-suite/src/lsp/_shared/config.ts +156 -0
  321. package/external/pi-tools-suite/src/lsp/_shared/glob.ts +60 -0
  322. package/external/pi-tools-suite/src/lsp/_shared/output.ts +102 -0
  323. package/external/pi-tools-suite/src/lsp/_shared/paths.ts +138 -0
  324. package/external/pi-tools-suite/src/lsp/_shared/runner.ts +64 -0
  325. package/external/pi-tools-suite/src/lsp/_shared/template.ts +23 -0
  326. package/external/pi-tools-suite/src/lsp/_shared/trust.ts +116 -0
  327. package/external/pi-tools-suite/src/lsp/_shared/types.ts +98 -0
  328. package/external/pi-tools-suite/src/lsp/async.ts +29 -0
  329. package/external/pi-tools-suite/src/lsp/child-process.ts +81 -0
  330. package/external/pi-tools-suite/src/lsp/client.ts +340 -0
  331. package/external/pi-tools-suite/src/lsp/constants.ts +9 -0
  332. package/external/pi-tools-suite/src/lsp/diagnostics-store.ts +64 -0
  333. package/external/pi-tools-suite/src/lsp/documents.ts +24 -0
  334. package/external/pi-tools-suite/src/lsp/index.ts +31 -0
  335. package/external/pi-tools-suite/src/lsp/lsp-utils.ts +37 -0
  336. package/external/pi-tools-suite/src/lsp/manager.ts +190 -0
  337. package/external/pi-tools-suite/src/lsp/mutation-events.ts +78 -0
  338. package/external/pi-tools-suite/src/lsp/renderer.ts +1 -0
  339. package/external/pi-tools-suite/src/lsp/tool-result.ts +6 -0
  340. package/external/pi-tools-suite/src/lsp/tsserver.ts +107 -0
  341. package/external/pi-tools-suite/src/lsp/types.ts +15 -0
  342. package/external/pi-tools-suite/src/model-tools/apply-patch.ts +590 -0
  343. package/external/pi-tools-suite/src/model-tools/index.ts +430 -0
  344. package/external/pi-tools-suite/src/model-tools/path-utils.ts +6 -0
  345. package/external/pi-tools-suite/src/model-tools/tool-args.ts +11 -0
  346. package/external/pi-tools-suite/src/prompt-commands/index.ts +349 -0
  347. package/external/pi-tools-suite/src/repo-discovery/index.ts +384 -0
  348. package/external/pi-tools-suite/src/repo-discovery/project.ts +7 -0
  349. package/external/pi-tools-suite/src/startup-section.ts +13 -0
  350. package/external/pi-tools-suite/src/terminal-bell/index.ts +309 -0
  351. package/external/pi-tools-suite/src/todo/index.ts +201 -0
  352. package/external/pi-tools-suite/src/todo/state/auto-clear.ts +13 -0
  353. package/external/pi-tools-suite/src/todo/state/invariants.ts +21 -0
  354. package/external/pi-tools-suite/src/todo/state/persistence.ts +94 -0
  355. package/external/pi-tools-suite/src/todo/state/replay.ts +38 -0
  356. package/external/pi-tools-suite/src/todo/state/selectors.ts +49 -0
  357. package/external/pi-tools-suite/src/todo/state/state-reducer.ts +362 -0
  358. package/external/pi-tools-suite/src/todo/state/state.ts +18 -0
  359. package/external/pi-tools-suite/src/todo/state/store.ts +52 -0
  360. package/external/pi-tools-suite/src/todo/state/task-graph.ts +57 -0
  361. package/external/pi-tools-suite/src/todo/todo.ts +487 -0
  362. package/external/pi-tools-suite/src/todo/tool/response-envelope.ts +143 -0
  363. package/external/pi-tools-suite/src/todo/tool/types.ts +188 -0
  364. package/external/pi-tools-suite/src/todo/view/format.ts +18 -0
  365. package/external/pi-tools-suite/src/todo/view/labels.ts +13 -0
  366. package/external/pi-tools-suite/src/tool-descriptions.ts +369 -0
  367. package/external/pi-tools-suite/src/usage/index.ts +152 -0
  368. package/external/pi-tools-suite/src/usage/lib/copilot.ts +535 -0
  369. package/external/pi-tools-suite/src/usage/lib/google.ts +478 -0
  370. package/external/pi-tools-suite/src/usage/lib/openai.ts +268 -0
  371. package/external/pi-tools-suite/src/usage/lib/types.ts +114 -0
  372. package/external/pi-tools-suite/src/usage/lib/utils.ts +134 -0
  373. package/external/pi-tools-suite/src/usage/lib/zhipu.ts +228 -0
  374. package/external/pi-tools-suite/src/web-search/index.ts +397 -0
  375. package/package.json +89 -0
  376. package/skills/context7/SKILL.md +69 -0
  377. package/skills/context7/scripts/context7.sh +73 -0
  378. package/skills/handoff/SKILL.md +15 -0
  379. package/skills/pdf/LICENSE.txt +30 -0
  380. package/skills/pdf/SKILL.md +314 -0
  381. package/skills/pdf/forms.md +294 -0
  382. package/skills/pdf/reference.md +612 -0
  383. package/skills/pdf/scripts/check_bounding_boxes.py +65 -0
  384. package/skills/pdf/scripts/check_fillable_fields.py +11 -0
  385. package/skills/pdf/scripts/convert_pdf_to_images.py +33 -0
  386. package/skills/pdf/scripts/create_validation_image.py +37 -0
  387. package/skills/pdf/scripts/extract_form_field_info.py +122 -0
  388. package/skills/pdf/scripts/extract_form_structure.py +115 -0
  389. package/skills/pdf/scripts/fill_fillable_fields.py +98 -0
  390. package/skills/pdf/scripts/fill_pdf_form_with_annotations.py +107 -0
  391. package/skills/playwright-cli/SKILL.md +388 -0
  392. package/skills/playwright-cli/references/element-attributes.md +23 -0
  393. package/skills/playwright-cli/references/playwright-tests.md +39 -0
  394. package/skills/playwright-cli/references/request-mocking.md +87 -0
  395. package/skills/playwright-cli/references/running-code.md +241 -0
  396. package/skills/playwright-cli/references/session-management.md +225 -0
  397. package/skills/playwright-cli/references/spec-driven-testing.md +305 -0
  398. package/skills/playwright-cli/references/storage-state.md +275 -0
  399. package/skills/playwright-cli/references/test-generation.md +134 -0
  400. package/skills/playwright-cli/references/tracing.md +139 -0
  401. package/skills/playwright-cli/references/video-recording.md +143 -0
  402. package/skills/simplify/SKILL.md +51 -0
  403. package/skills/skill-creator/LICENSE.txt +202 -0
  404. package/skills/skill-creator/SKILL.md +485 -0
  405. package/skills/skill-creator/agents/analyzer.md +274 -0
  406. package/skills/skill-creator/agents/comparator.md +202 -0
  407. package/skills/skill-creator/agents/grader.md +223 -0
  408. package/skills/skill-creator/assets/eval_review.html +146 -0
  409. package/skills/skill-creator/eval-viewer/generate_review.py +471 -0
  410. package/skills/skill-creator/eval-viewer/viewer.html +1325 -0
  411. package/skills/skill-creator/references/schemas.md +430 -0
  412. package/skills/skill-creator/scripts/__init__.py +0 -0
  413. package/skills/skill-creator/scripts/aggregate_benchmark.py +401 -0
  414. package/skills/skill-creator/scripts/generate_report.py +326 -0
  415. package/skills/skill-creator/scripts/improve_description.py +247 -0
  416. package/skills/skill-creator/scripts/package_skill.py +136 -0
  417. package/skills/skill-creator/scripts/quick_validate.py +103 -0
  418. package/skills/skill-creator/scripts/run_eval.py +310 -0
  419. package/skills/skill-creator/scripts/run_loop.py +328 -0
  420. package/skills/skill-creator/scripts/utils.py +47 -0
@@ -0,0 +1,397 @@
1
+ // ---------------------------------------------------------------------------
2
+ // Dynamic Context Pruning (DCP) — module entry point for pi-tools-suite
3
+ // ---------------------------------------------------------------------------
4
+
5
+ import type { ExtensionAPI, ExtensionContext } from "@mariozechner/pi-coding-agent"
6
+ import { loadConfig } from "./config.js"
7
+ import {
8
+ createState,
9
+ resetState,
10
+ createInputFingerprint,
11
+ serializeState,
12
+ restoreState,
13
+ type DcpState,
14
+ } from "./state.js"
15
+ import {
16
+ SYSTEM_PROMPT,
17
+ MANUAL_MODE_SYSTEM_PROMPT,
18
+ CONTEXT_LIMIT_NUDGE_STRONG,
19
+ CONTEXT_LIMIT_NUDGE_SOFT,
20
+ TURN_NUDGE,
21
+ ITERATION_NUDGE,
22
+ } from "./prompts.js"
23
+ import {
24
+ applyPruning,
25
+ injectNudge,
26
+ getNudgeType,
27
+ detectCompressionCandidate,
28
+ detectMessageCompressionCandidates,
29
+ appendConcreteNudgeGuidance,
30
+ applyAnchoredNudges,
31
+ nudgeTypeLabel,
32
+ upsertNudgeAnchor,
33
+ getActiveSummaryTokenEstimate,
34
+ resolveContextThresholds,
35
+ estimateTokens,
36
+ } from "./pruner.js"
37
+ import type { DcpNudgeType } from "./pruner-types.js"
38
+ import { registerCompressTool } from "./compress-tool.js"
39
+ import { registerCommands } from "./commands.js"
40
+ import { DcpUiController, normalizeDcpContextUsage } from "./ui.js"
41
+ import { registerTuiFilter } from "./dcp-tui-filter.js"
42
+ import { ignoreStaleExtensionContextError, safeGetContextUsage } from "../context-usage.js"
43
+
44
+ const DCP_CONTEXT_USAGE_EVENT = "pi-tools-suite:dcp-context-usage"
45
+
46
+ // ---------------------------------------------------------------------------
47
+ // Helpers
48
+ // ---------------------------------------------------------------------------
49
+
50
+ /**
51
+ * Persist the current DCP runtime state as a custom session entry so it
52
+ * survives session restarts and pi process restarts.
53
+ */
54
+ function saveState(pi: ExtensionAPI, state: DcpState): void {
55
+ pi.appendEntry("dcp-state", serializeState(state))
56
+ }
57
+
58
+ function annotateMessagesWithBranchEntryIds(messages: any[], ctx: ExtensionContext): void {
59
+ let branch: any[] = []
60
+ try {
61
+ branch = ctx.sessionManager.getBranch()
62
+ } catch {
63
+ return
64
+ }
65
+
66
+ const entries = branch.filter((entry) => entry?.type === "message" && entry.message)
67
+ let searchFrom = 0
68
+ for (const msg of messages) {
69
+ for (let i = searchFrom; i < entries.length; i++) {
70
+ const entry = entries[i]
71
+ const entryMsg = entry.message
72
+ if (entryMsg?.role !== msg?.role) continue
73
+ if (
74
+ Number.isFinite(entryMsg?.timestamp) &&
75
+ Number.isFinite(msg?.timestamp) &&
76
+ entryMsg.timestamp !== msg.timestamp
77
+ ) continue
78
+ msg._dcpEntryId = entry.id
79
+ searchFrom = i + 1
80
+ break
81
+ }
82
+ }
83
+ }
84
+
85
+ function baseNudgeText(type: DcpNudgeType): string {
86
+ if (type === "context-strong") return CONTEXT_LIMIT_NUDGE_STRONG
87
+ if (type === "context-soft") return CONTEXT_LIMIT_NUDGE_SOFT
88
+ if (type === "iteration") return ITERATION_NUDGE
89
+ return TURN_NUDGE
90
+ }
91
+
92
+ // ---------------------------------------------------------------------------
93
+ // Module export
94
+ // ---------------------------------------------------------------------------
95
+
96
+ export default async function dcpModule(pi: ExtensionAPI): Promise<void> {
97
+ // ── 1. Load config ────────────────────────────────────────────────────────
98
+ const config = loadConfig(process.cwd())
99
+
100
+ if (!config.enabled) return
101
+
102
+ // ── 2. Create state ───────────────────────────────────────────────────────
103
+ const state = createState()
104
+ const ui = new DcpUiController(state)
105
+ const updateUi = (ctx: ExtensionContext): void => {
106
+ try {
107
+ if (!ctx?.hasUI) return
108
+ ui.setUICtx(ctx.ui)
109
+ ui.update(ctx)
110
+ } catch (error) {
111
+ ignoreStaleExtensionContextError(error)
112
+ }
113
+ }
114
+ const emitContextUsage = (ctx: ExtensionContext): void => {
115
+ const usage = safeGetContextUsage(ctx)
116
+ if (!usage) return
117
+ try {
118
+ ;(pi as { events?: { emit?: (name: string, data: unknown) => void } }).events?.emit?.(DCP_CONTEXT_USAGE_EVENT, usage)
119
+ } catch (error) {
120
+ ignoreStaleExtensionContextError(error)
121
+ }
122
+ }
123
+ const appendNudgeTelemetry = (
124
+ type: DcpNudgeType,
125
+ anchor: { id: number; anchorTimestamp: number; anchorStableId?: string; anchorRole: string },
126
+ usage: ReturnType<typeof normalizeDcpContextUsage>,
127
+ toolCallsSinceLastUser: number,
128
+ ): void => {
129
+ try {
130
+ pi.appendEntry("dcp-nudge", {
131
+ event: "emitted",
132
+ type,
133
+ label: nudgeTypeLabel(type),
134
+ anchorId: anchor.id,
135
+ anchorTimestamp: anchor.anchorTimestamp,
136
+ anchorStableId: anchor.anchorStableId,
137
+ anchorRole: anchor.anchorRole,
138
+ contextTokens: usage?.tokens,
139
+ contextWindow: usage?.contextWindow,
140
+ contextPercent: usage?.percent,
141
+ toolCallsSinceLastUser,
142
+ createdAt: Date.now(),
143
+ })
144
+ } catch {
145
+ // Telemetry is diagnostic only; never block context construction.
146
+ }
147
+ }
148
+
149
+ // Apply config baseline for manual mode before any session events fire.
150
+ if (config.manualMode.enabled) {
151
+ state.manualMode = true
152
+ }
153
+
154
+ // ── 3. Register TUI filter (strip DCP tags from displayed messages) ───────
155
+ registerTuiFilter(pi)
156
+
157
+ // ── 4. Register compress tool ─────────────────────────────────────────────
158
+ registerCompressTool(pi, state, config)
159
+
160
+ // ── 5. Register /dcp commands ─────────────────────────────────────────────
161
+ registerCommands(pi, state, config, {
162
+ onStateChanged(ctx) {
163
+ updateUi(ctx)
164
+ },
165
+ })
166
+
167
+ // ── 6. session_start: restore state from session entries ──────────────────
168
+ pi.on("session_start", async (_event, ctx) => {
169
+ // Reset to a clean slate first.
170
+ resetState(state)
171
+
172
+ // Re-apply config baseline so manual mode survives a session_start reset.
173
+ if (config.manualMode.enabled) {
174
+ state.manualMode = true
175
+ }
176
+
177
+ // Walk the branch looking for the most-recent persisted dcp-state entry.
178
+ let latestDcpState: unknown
179
+ for (const entry of ctx.sessionManager.getBranch()) {
180
+ if (entry.type === "custom" && entry.customType === "dcp-state") {
181
+ latestDcpState = entry.data
182
+ }
183
+ }
184
+
185
+ restoreState(state, latestDcpState)
186
+
187
+ // Show a rich status indicator + floating cleaned-context widget in the pi TUI.
188
+ updateUi(ctx)
189
+ })
190
+
191
+ // ── 7. session_shutdown: save state ───────────────────────────────────────
192
+ pi.on("session_shutdown", async (_event, _ctx) => {
193
+ saveState(pi, state)
194
+ ui.dispose()
195
+ })
196
+
197
+ // ── 8. before_agent_start: inject system prompt ───────────────────────────
198
+ pi.on("before_agent_start", async (event, _ctx) => {
199
+ const promptAddition = state.manualMode
200
+ ? MANUAL_MODE_SYSTEM_PROMPT
201
+ : SYSTEM_PROMPT
202
+
203
+ return {
204
+ systemPrompt: event.systemPrompt + "\n\n" + promptAddition,
205
+ }
206
+ })
207
+
208
+ // ── 9. tool_call: record input args for dedup / purge fingerprinting ───────
209
+ pi.on("tool_call", async (event, _ctx) => {
210
+ if (!state.toolCalls.has(event.toolCallId)) {
211
+ state.toolCalls.set(event.toolCallId, {
212
+ toolCallId: event.toolCallId,
213
+ toolName: event.toolName,
214
+ inputArgs: event.input as Record<string, unknown>,
215
+ inputFingerprint: createInputFingerprint(
216
+ event.toolName,
217
+ event.input as Record<string, unknown>,
218
+ ),
219
+ isError: false,
220
+ turnIndex: state.currentTurn,
221
+ timestamp: 0,
222
+ tokenEstimate: 0,
223
+ })
224
+ }
225
+ })
226
+
227
+ // ── 10. tool_result: finalise tool record with result info ─────────────────
228
+ pi.on("tool_result", async (event, ctx) => {
229
+ const record = state.toolCalls.get(event.toolCallId)
230
+
231
+ const outputText = event.content
232
+ .map((c: any) => (c.type === "text" ? c.text : ""))
233
+ .join("")
234
+ const tokenEstimate = estimateTokens(outputText)
235
+
236
+ if (record) {
237
+ record.isError = event.isError
238
+ record.timestamp = Date.now()
239
+ record.tokenEstimate = tokenEstimate
240
+ record.outputText = outputText
241
+ record.outputDetails = event.details
242
+ } else {
243
+ state.toolCalls.set(event.toolCallId, {
244
+ toolCallId: event.toolCallId,
245
+ toolName: event.toolName,
246
+ inputArgs: {},
247
+ inputFingerprint: createInputFingerprint(event.toolName, {}),
248
+ isError: event.isError,
249
+ turnIndex: state.currentTurn,
250
+ timestamp: Date.now(),
251
+ tokenEstimate,
252
+ outputText,
253
+ outputDetails: event.details,
254
+ })
255
+ }
256
+
257
+ if (event.toolName === "compress" && ctx.hasUI) {
258
+ updateUi(ctx)
259
+ emitContextUsage(ctx)
260
+ }
261
+ })
262
+
263
+ // ── 11. context: apply pruning and inject nudges ──────────────────────────
264
+ pi.on("context", async (event, ctx) => {
265
+ annotateMessagesWithBranchEntryIds(event.messages, ctx)
266
+ let prunedMessages = applyPruning(event.messages, state, config)
267
+ let candidate = null as ReturnType<typeof detectCompressionCandidate>
268
+ let messageCandidates = [] as ReturnType<typeof detectMessageCompressionCandidates>
269
+
270
+ // In manual mode we still apply pruning strategies (if
271
+ // automaticStrategies is on) but skip routine autonomous nudges. Emergency
272
+ // max-context nudges are still allowed, matching the manual-mode prompt.
273
+ const usage = normalizeDcpContextUsage(safeGetContextUsage(ctx))
274
+ if (usage) {
275
+ const contextPercent = typeof usage.percent === "number" && Number.isFinite(usage.percent)
276
+ ? usage.percent / 100
277
+ : typeof usage.tokens === "number"
278
+ ? usage.tokens / usage.contextWindow
279
+ : undefined
280
+
281
+ if (contextPercent === undefined) {
282
+ if (state.manualMode) {
283
+ state.nudgeAnchors = state.nudgeAnchors.filter((anchor) =>
284
+ anchor.type === "context-strong" || anchor.type === "context-soft",
285
+ )
286
+ }
287
+ applyAnchoredNudges(prunedMessages, state, (anchor) =>
288
+ appendConcreteNudgeGuidance(baseNudgeText(anchor.type), candidate, messageCandidates, state),
289
+ )
290
+ updateUi(ctx)
291
+ emitContextUsage(ctx)
292
+ return { messages: prunedMessages }
293
+ }
294
+
295
+ const ctxModel = (ctx as any).model
296
+ const provider = ctxModel?.provider ?? ctxModel?.providerId ?? ctxModel?.providerID
297
+ const model = ctxModel?.id ?? ctxModel?.model ?? ctxModel?.modelId ?? ctxModel?.modelID
298
+ const thresholds = resolveContextThresholds(config, [
299
+ provider && model ? `${provider}/${model}` : undefined,
300
+ model,
301
+ ], usage.contextWindow)
302
+ if (config.compress.summaryBuffer) {
303
+ thresholds.maxContextPercent += getActiveSummaryTokenEstimate(state) / usage.contextWindow
304
+ }
305
+
306
+ let toolCallsSinceLastUser = 0
307
+ for (let i = prunedMessages.length - 1; i >= 0; i--) {
308
+ const msg = prunedMessages[i] as any
309
+ if (msg.role === "user") break
310
+ if (msg.role === "toolResult") toolCallsSinceLastUser++
311
+ }
312
+
313
+ const nudgeType = getNudgeType(
314
+ contextPercent,
315
+ state,
316
+ config,
317
+ toolCallsSinceLastUser,
318
+ thresholds,
319
+ )
320
+
321
+ const manualEmergencyOnly =
322
+ state.manualMode &&
323
+ (nudgeType !== "context-strong" && nudgeType !== "context-soft")
324
+
325
+ candidate = detectCompressionCandidate(
326
+ prunedMessages,
327
+ state,
328
+ config,
329
+ contextPercent,
330
+ )
331
+ messageCandidates = detectMessageCompressionCandidates(
332
+ prunedMessages,
333
+ config,
334
+ contextPercent,
335
+ )
336
+
337
+ if (nudgeType && !manualEmergencyOnly) {
338
+ const nudgeText = appendConcreteNudgeGuidance(
339
+ baseNudgeText(nudgeType),
340
+ candidate,
341
+ messageCandidates,
342
+ state,
343
+ )
344
+
345
+ const anchorResult = upsertNudgeAnchor(
346
+ prunedMessages,
347
+ state,
348
+ nudgeType,
349
+ { contextPercent },
350
+ )
351
+ if (anchorResult.anchor) {
352
+ if (anchorResult.updated) {
353
+ appendNudgeTelemetry(nudgeType, anchorResult.anchor, usage, toolCallsSinceLastUser)
354
+ saveState(pi, state)
355
+ }
356
+ } else {
357
+ // No safe existing message could be anchored (rare); keep the older
358
+ // synthetic reminder fallback so DCP never silently drops a nudge.
359
+ injectNudge(prunedMessages, nudgeText)
360
+ }
361
+ state.nudgeCounter = 0
362
+ state.lastNudgeTurn = state.currentTurn
363
+ } else {
364
+ state.nudgeCounter++
365
+ }
366
+ }
367
+
368
+ if (state.manualMode) {
369
+ state.nudgeAnchors = state.nudgeAnchors.filter((anchor) =>
370
+ anchor.type === "context-strong" || anchor.type === "context-soft",
371
+ )
372
+ }
373
+ applyAnchoredNudges(prunedMessages, state, (anchor) =>
374
+ appendConcreteNudgeGuidance(baseNudgeText(anchor.type), candidate, messageCandidates, state),
375
+ )
376
+
377
+
378
+ // Update footer status and floating widget after each context event.
379
+ updateUi(ctx)
380
+ emitContextUsage(ctx)
381
+
382
+ return { messages: prunedMessages }
383
+ })
384
+
385
+ // ── 12. turn_end: refresh DCP status from Pi's final context percentage ───
386
+ pi.on("turn_end", async (_event, ctx) => {
387
+ updateUi(ctx)
388
+ emitContextUsage(ctx)
389
+ })
390
+
391
+ // ── 13. agent_end: persist state after each agent run ────────────────────
392
+ pi.on("agent_end", async (_event, ctx) => {
393
+ updateUi(ctx)
394
+ emitContextUsage(ctx)
395
+ saveState(pi, state)
396
+ })
397
+ }
@@ -0,0 +1,269 @@
1
+ // ---------------------------------------------------------------------------
2
+ // Dynamic Context Pruning (DCP) — PI extension prompts
3
+ // ---------------------------------------------------------------------------
4
+ // All prompt text is exported as plain strings so the extension index can
5
+ // reference them by name without executing any logic here.
6
+ // ---------------------------------------------------------------------------
7
+
8
+ /**
9
+ * Appended to the existing system prompt when DCP is enabled (automatic mode).
10
+ */
11
+ export const SYSTEM_PROMPT = `
12
+ You operate in a context-constrained environment. Manage context continuously to avoid buildup and preserve retrieval quality. Efficient context management is paramount for your agentic performance.
13
+
14
+ The ONLY tool you have for context management is \`compress\`. It replaces older conversation content with technical summaries you produce. It supports both range compression (\`ranges\`) and surgical one-message compression (\`messages\`).
15
+
16
+ \`[dcp-id]: # (mNNN)\` markdown reference lines and \`<dcp-system-reminder>\` tags are environment-injected metadata. Do not output them.
17
+
18
+ THE PHILOSOPHY OF COMPRESS
19
+ \`compress\` transforms conversation content into dense, high-fidelity summaries. This is cleanup plus preservation: keep the state needed to continue, discard incidental transcript detail.
20
+
21
+ Think of compression as phase transitions: raw exploration becomes refined understanding. The original context served its purpose; your summary now carries that understanding forward.
22
+
23
+ OPERATING STANCE
24
+ Prefer short, closed, summary-safe compressions.
25
+ When multiple independent stale sections exist, prefer several focused compressions (in parallel when possible) over one broad compression.
26
+ When one older message is huge but the surrounding context is still useful, use message-mode compression for that single message instead of compressing a broad range.
27
+ Summaries should be proportional to future usefulness, not proportional to the amount of text being removed.
28
+
29
+ Use \`compress\` as steady housekeeping while you work. After any completed implementation + verification slice, compress that closed slice before replying or starting a new task unless the next step needs exact raw logs/diffs. Do not carry large stale tool outputs across task boundaries.
30
+
31
+ When a \`<dcp-system-reminder>\` appears, treat it as an active instruction for the next safe action, not as background advice. Before making another exploratory tool call or starting a new subtask, check whether any earlier slice is closed; if yes, call \`compress\` first. Do not merely acknowledge the reminder or postpone it across multiple tool calls.
32
+
33
+ CADENCE, SIGNALS, AND LATENCY
34
+
35
+ - No fixed threshold mandates compression
36
+ - Prioritize closedness and independence over raw size
37
+ - Prefer smaller, regular compressions over infrequent massive compressions for better latency and summary quality
38
+ - When multiple independent stale sections are ready, batch compressions in parallel
39
+
40
+ COMPRESS WHEN
41
+
42
+ A section is genuinely closed and the raw conversation has served its purpose:
43
+
44
+ - Research concluded and findings are clear
45
+ - Implementation finished and verified
46
+ - Exploration exhausted and patterns understood
47
+ - Dead-end noise can be discarded without waiting for a whole chapter to close
48
+
49
+ DO NOT COMPRESS IF
50
+
51
+ - Raw context is still relevant and needed for edits or precise references
52
+ - The target content is still actively in progress
53
+ - You may need exact code, error messages, or file contents in the immediate next steps
54
+
55
+ Before compressing, ask: _"Is this section closed enough to become summary-only right now?"_
56
+
57
+ Evaluate conversation signal-to-noise REGULARLY. Use \`compress\` deliberately with quality-first summaries. Prioritize stale content intelligently to maintain a high-signal context window that supports your agency.
58
+
59
+ It is your responsibility to keep a sharp, high-quality context window for optimal performance.
60
+ `.trim()
61
+
62
+ /**
63
+ * Used as the \`description\` field when registering the \`compress\` tool.
64
+ *
65
+ * Tool signature:
66
+ * {
67
+ * topic: string // 3-5 word label for this compression
68
+ * ranges: Array<{
69
+ * startId: string // mNNN or bN
70
+ * endId: string // mNNN or bN
71
+ * summary: string // continuation-focused technical summary
72
+ * }>
73
+ * }
74
+ */
75
+ export const COMPRESS_RANGE_DESCRIPTION = `Collapse one or more ranges of the conversation into detailed summaries.
76
+
77
+ AUTONOMOUS HOUSEKEEPING
78
+ Do not wait for context emergencies. After a completed implementation + verification slice, compress that closed slice before replying or starting a new task unless the next step needs exact raw logs/diffs. Do not carry large stale tool outputs across task boundaries.
79
+
80
+ DCP REMINDERS
81
+ If a \`<dcp-system-reminder>\` is present in context, treat it as a direct instruction to evaluate compression immediately. If a safe closed range exists, call this tool before further exploration. Skipping compression is acceptable only when the newest raw context is still needed for the next concrete edit, test, or answer.
82
+
83
+ THE SUMMARY
84
+ Your summary must be COMPLETE FOR CONTINUATION, not a transcript rewrite. Preserve only information that will plausibly matter later: user intent, accepted constraints, decisions, files/symbols changed or inspected, exact errors that are still actionable, verification status, and next steps.
85
+
86
+ Default to a compact structured summary (roughly 5-15 bullets for a normal completed work slice). Grow beyond that only when the compressed range contains multiple independent decisions, unresolved blockers, or precise state that is genuinely required to continue.
87
+
88
+ Do not copy long raw code, JSON, diffs, logs, or tool output into summaries. Prefer semantic descriptions such as “updated foo.json so scene_assets_1.zai-svg has maxConcurrentRuns set to 5.” Include exact snippets only when the literal text is required for safe continuation, and keep them short and single-line.
89
+
90
+ SUMMARY ARGUMENT SAFETY
91
+ The summary is passed as a JSON string argument to the compress tool. Avoid raw double-quoted JSON fragments, multiline object literals, and diff hunks because they can make tool-call arguments malformed. If a literal field name matters, prefer plain prose or quote-light code spans such as \`maxConcurrentRuns: 5\` instead of raw \`"maxConcurrentRuns": 5\` blocks.
92
+
93
+ USER INTENT FIDELITY
94
+ When the compressed range includes user messages, preserve the user's intent with extra care. Do not change scope, constraints, priorities, acceptance criteria, or requested outcomes.
95
+ Directly quote user messages when they are short enough to include safely. Direct quotes are preferred when they best preserve exact meaning.
96
+
97
+ Be LEAN. Strip away the noise: failed attempts that led nowhere, verbose tool outputs, back-and-forth exploration, and incidental line-by-line edit history. What remains should be pure signal with enough detail to resume work confidently.
98
+
99
+ TWO COMPRESSION MODES
100
+ You may use either or both modes in one call:
101
+
102
+ - \`ranges\`: collapse contiguous conversation spans using \`startId\`, \`endId\`, and \`summary\`.
103
+ - \`messages\`: collapse individual raw messages using \`messageId\`, optional \`topic\`, and \`summary\`.
104
+
105
+ Use \`messages\` for a single large stale message when surrounding messages should remain raw. \`messages\` accepts only raw \`mNNN\` IDs, not \`bN\` compressed block IDs.
106
+
107
+ PROTECTED PROMPT CONTENT
108
+ If selected user text contains \`<protect>...</protect>\` content, preserve that protected content verbatim in your summary. The tool may append protected text automatically, but you should still account for it semantically.
109
+
110
+ COMPRESSED BLOCK PLACEHOLDERS
111
+ When the selected range includes previously compressed blocks, use this exact placeholder format when referencing one:
112
+
113
+ - \`(bN)\`
114
+
115
+ Compressed block sections in context are clearly marked with a header:
116
+
117
+ - \`[Compressed conversation section]\`
118
+
119
+ Compressed block IDs always use the \`bN\` form (never \`mNNN\`) and are represented as hidden markdown reference metadata lines.
120
+
121
+ Rules:
122
+
123
+ - Include every required block placeholder exactly once when you intentionally roll up older compressed blocks. If you omit one or duplicate one, the tool will try to recover by preserving the missing block summaries automatically, but do not rely on that recovery path.
124
+ - Do not invent placeholders for blocks outside the selected range.
125
+ - Treat \`(bN)\` placeholders as RESERVED TOKENS. Do not emit \`(bN)\` text anywhere except intentional placeholders.
126
+ - If you need to mention a block in prose, use plain text like \`compressed bN\` (not as a placeholder).
127
+ - Preflight check before finalizing: the set of \`(bN)\` placeholders in your summary should match the required set, with no duplicates.
128
+
129
+ These placeholders are semantic references. They will be replaced with the full stored compressed block content when the tool processes your output.
130
+
131
+ FLOW PRESERVATION WITH PLACEHOLDERS
132
+ When you use compressed block placeholders, write the surrounding summary text so it still reads correctly AFTER placeholder expansion.
133
+
134
+ - Treat each placeholder as a stand-in for a full conversation segment, not as a short label.
135
+ - Ensure transitions before and after each placeholder preserve chronology and causality.
136
+ - Do not write text that depends on the placeholder staying literal (for example, "as noted in \`(b2)\`").
137
+ - Your final meaning must be coherent once each placeholder is replaced with its full compressed block content.
138
+
139
+ BOUNDARY IDS
140
+ You specify boundaries by ID using the injected metadata IDs present in the conversation context:
141
+
142
+ - \`mNNN\` IDs identify raw messages (3 digits, zero-padded, e.g. \`m001\`, \`m042\`)
143
+ - \`bN\` IDs identify previously compressed blocks
144
+
145
+ Each message has an ID in a hidden single-line markdown reference metadata line like \`[dcp-id]: # (m001)\`.
146
+ Some message-compression candidate hints include a low/medium/high priority; prefer high-priority stale message IDs for message-mode compression when a full range would be too broad.
147
+ The ID reference line appears at the end of the message it belongs to — it identifies the message above it, not the one below it.
148
+ Treat these reference lines as boundary metadata only, not as tool result content.
149
+
150
+ Rules:
151
+
152
+ - Pick \`startId\` and \`endId\` directly from injected IDs in context.
153
+ - IDs must exist in the current conversation context.
154
+ - \`startId\` must appear before \`endId\`.
155
+ - Do not invent IDs. Use only IDs that are present in context.
156
+
157
+ BATCHING
158
+ When multiple independent ranges or individual messages are ready, include all of them in one \`compress\` call. Range entries must not overlap. Message entries should each summarize exactly one raw message.`
159
+
160
+ /**
161
+ * Injected into messages when context usage exceeds maxContextPercent.
162
+ * nudgeForce = "strong" — emergency recovery tone.
163
+ */
164
+ export const CONTEXT_LIMIT_NUDGE_STRONG = `<dcp-system-reminder>
165
+ CRITICAL WARNING: MAX CONTEXT LIMIT REACHED
166
+
167
+ You are at or beyond the configured max context threshold. This is an emergency context-recovery moment.
168
+
169
+ You MUST use the \`compress\` tool now. Do not continue normal exploration until compression is handled.
170
+
171
+ If you are in the middle of a critical atomic operation, finish that atomic step first, then compress immediately.
172
+
173
+ RANGE STRATEGY (MANDATORY)
174
+ Prioritize one large, closed, high-yield compression range first.
175
+ This overrides the normal preference for many small compressions.
176
+ Only split into multiple compressions if one large range would reduce summary quality or make boundary selection unsafe.
177
+
178
+ RANGE SELECTION
179
+ Start from older, resolved history and capture as much stale context as safely possible in one pass.
180
+ Avoid the newest active working slice unless it is clearly closed.
181
+ Use injected boundary IDs for compression (\`mNNN\` for messages, \`bN\` for compressed blocks), and ensure \`startId\` appears before \`endId\`.
182
+ For a single large stale message, use the \`messages\` array with its injected \`mNNN\` ID.
183
+
184
+ SUMMARY REQUIREMENTS
185
+ Your summary must cover all essential details from the selected range so work can continue without reopening raw messages, but it should not restate raw code, JSON, logs, or diffs unless a short literal is required.
186
+ If the compressed range includes user messages, preserve user intent exactly. Prefer direct quotes for short user messages to avoid semantic drift.
187
+ </dcp-system-reminder>`
188
+
189
+ /**
190
+ * Injected into messages when context usage exceeds maxContextPercent.
191
+ * nudgeForce = "soft" — steady housekeeping tone.
192
+ */
193
+ export const CONTEXT_LIMIT_NUDGE_SOFT = `<dcp-system-reminder>
194
+ ACTION REQUIRED: Context usage is high.
195
+
196
+ Before doing more exploration, look for a closed, self-contained range that no longer needs to stay raw and compress it now.
197
+
198
+ Do not treat this as optional housekeeping. If any completed research, implementation, verification, CI-log inspection, or dead-end debugging slice is present, call the \`compress\` tool before continuing normal work.
199
+
200
+ RANGE SELECTION
201
+ Prefer older, resolved history. Avoid the newest active working slice unless it is clearly done.
202
+ Use injected boundary IDs (\`mNNN\` for messages, \`bN\` for compressed blocks) and ensure \`startId\` appears before \`endId\`.
203
+ For a single large stale message, use message-mode compression via the \`messages\` array.
204
+
205
+ If multiple independent ranges are ready, batch them in a single \`compress\` call.
206
+ If nothing is cleanly closed yet, continue only with the next atomic step and re-check immediately afterward.
207
+ </dcp-system-reminder>`
208
+
209
+ /**
210
+ * Injected as a lightweight reminder between minContextPercent and maxContextPercent
211
+ * at the configured nudgeFrequency cadence.
212
+ */
213
+ export const TURN_NUDGE = `<dcp-system-reminder>
214
+ ACTION REQUIRED: Evaluate the conversation for compressible ranges before continuing.
215
+
216
+ If any range is cleanly closed and unlikely to be needed again, use the \`compress\` tool now.
217
+ If direction has shifted, compress earlier ranges that are now less relevant.
218
+
219
+ Do not defer this across another batch of searches, reads, CI log fetches, or tests. The next safe action should be compression whenever a closed slice exists.
220
+
221
+ Prefer small, closed-range compressions over one broad compression.
222
+ Use message-mode compression for isolated large stale messages.
223
+ The goal is to filter noise and distill key information so context accumulation stays under control.
224
+ Keep active context uncompressed.
225
+ </dcp-system-reminder>`
226
+
227
+ /**
228
+ * Injected after iterationNudgeThreshold tool calls since the last user message.
229
+ */
230
+ export const ITERATION_NUDGE = `<dcp-system-reminder>
231
+ ACTION REQUIRED: You've been iterating for a while after the last user message.
232
+
233
+ Pause before the next non-atomic tool call. If there is a closed portion that is unlikely to be referenced immediately (for example, finished research before implementation, completed CI-log triage, a verified fix, or a dead-end investigation), use the \`compress\` tool on it now.
234
+
235
+ Do not keep accumulating tool outputs while a completed slice remains raw. If a range is closed, compression is the next safe action.
236
+
237
+ Prefer multiple short, closed ranges over one large range when several independent slices are ready.
238
+ Use message-mode compression for isolated large stale messages.
239
+ </dcp-system-reminder>`
240
+
241
+ /**
242
+ * Replaces SYSTEM_PROMPT when manualMode.enabled = true.
243
+ * The agent should NOT proactively compress — only compress when explicitly
244
+ * requested by the user or when a context-limit nudge fires.
245
+ */
246
+ export const MANUAL_MODE_SYSTEM_PROMPT = `
247
+ You are operating in DCP manual mode for context management.
248
+
249
+ \`[dcp-id]: # (mNNN)\` markdown reference lines and \`<dcp-system-reminder>\` tags are environment-injected metadata. Do not output them.
250
+
251
+ In manual mode you do NOT proactively compress conversation content. Compression is a deliberate, user-directed action.
252
+
253
+ WHEN TO COMPRESS
254
+ - Only when the user explicitly asks you to compress
255
+ - Only when a \`<dcp-system-reminder>\` nudge instructs you to (context-limit emergency)
256
+ - Never as background housekeeping or on your own initiative
257
+
258
+ WHEN YOU DO COMPRESS
259
+ Apply the same quality standards as always:
260
+
261
+ - Summaries must be complete for continuation, not transcript-sized; keep only file paths, decisions, findings, exact constraints, unresolved blockers, and verification state that may matter later
262
+ - Avoid raw JSON/code/diff/log blocks in summary strings; describe changes in prose or use very short quote-light code spans when literals are necessary
263
+ - Preserve user intent precisely; prefer direct quotes for short user messages
264
+ - Use only boundary IDs present in context (\`mNNN\` for messages, \`bN\` for compressed blocks)
265
+ - Batch independent ranges in a single \`compress\` call when possible
266
+ - Use message-mode compression for isolated large stale messages when directed by a context-limit nudge
267
+
268
+ Do not compress active, still-needed context. Only compress ranges that are genuinely closed and whose raw form is no longer required.
269
+ `.trim()