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,215 @@
1
+ import { getAgentDir } from "@earendil-works/pi-coding-agent";
2
+ import { copyTextToClipboard } from "./clipboard.js";
3
+ import { isRecord } from "./guards.js";
4
+ import { createId } from "./id.js";
5
+ import { loadWorkspaceUndoIndex, prepareWorkspaceMutation, revertWorkspaceMutations, saveWorkspaceUndoIndex, workspaceMutationFromToolExecution, workspaceUndoIndexKey, } from "./workspace-undo.js";
6
+ export class AppWorkspaceActionsController {
7
+ host;
8
+ workspaceUndoIndex = loadWorkspaceUndoIndex(getAgentDir());
9
+ constructor(host) {
10
+ this.host = host;
11
+ }
12
+ prepareWorkspaceMutation(toolName, args) {
13
+ const runtime = this.host.runtime();
14
+ return runtime ? prepareWorkspaceMutation(runtime.cwd, toolName, args) : undefined;
15
+ }
16
+ workspaceMutationFromToolExecution(input) {
17
+ const runtime = this.host.runtime();
18
+ return runtime ? workspaceMutationFromToolExecution({ cwd: runtime.cwd, ...input }) : undefined;
19
+ }
20
+ recordWorkspaceMutationForUserEntry(entryId, mutation) {
21
+ const entry = this.host.findUserEntry(entryId);
22
+ if (!entry)
23
+ return;
24
+ entry.workspaceMutations = [...(entry.workspaceMutations ?? []), mutation];
25
+ const sessionEntryId = this.resolveUserSessionEntryId(entry);
26
+ if (sessionEntryId)
27
+ this.persistWorkspaceMutations(sessionEntryId, entry.workspaceMutations);
28
+ this.host.touchEntry(entry);
29
+ }
30
+ scheduleUserSessionEntryMetadataSync() {
31
+ const timer = setTimeout(() => {
32
+ this.syncUserSessionEntryMetadata();
33
+ if (this.host.isRunning())
34
+ this.host.render();
35
+ }, 0);
36
+ timer.unref?.();
37
+ }
38
+ syncUserSessionEntryMetadata() {
39
+ const runtime = this.host.runtime();
40
+ if (!runtime)
41
+ return;
42
+ const branchUserEntries = runtime.session.sessionManager.getBranch().flatMap((sessionEntry) => {
43
+ if (sessionEntry.type !== "message")
44
+ return [];
45
+ if (!isRecord(sessionEntry.message) || sessionEntry.message.role !== "user")
46
+ return [];
47
+ return [{ entryId: sessionEntry.id }];
48
+ });
49
+ if (branchUserEntries.length === 0)
50
+ return;
51
+ let branchIndex = 0;
52
+ for (const entry of this.host.entries) {
53
+ if (entry.kind !== "user")
54
+ continue;
55
+ const sessionEntry = branchUserEntries[branchIndex];
56
+ branchIndex += 1;
57
+ if (!sessionEntry)
58
+ break;
59
+ let changed = false;
60
+ if (entry.sessionEntryId !== sessionEntry.entryId) {
61
+ entry.sessionEntryId = sessionEntry.entryId;
62
+ changed = true;
63
+ }
64
+ const hasPersistedMutations = this.hasWorkspaceMutationsForSessionEntry(sessionEntry.entryId);
65
+ const persistedMutations = this.workspaceMutationsForSessionEntry(sessionEntry.entryId);
66
+ if (!entry.workspaceMutations && hasPersistedMutations) {
67
+ entry.workspaceMutations = persistedMutations;
68
+ changed = true;
69
+ }
70
+ if (entry.workspaceMutations && (!hasPersistedMutations || !sameWorkspaceMutations(persistedMutations, entry.workspaceMutations))) {
71
+ this.persistWorkspaceMutations(sessionEntry.entryId, entry.workspaceMutations);
72
+ }
73
+ if (changed)
74
+ this.host.touchEntry(entry);
75
+ }
76
+ }
77
+ copyUserMessage(entryId) {
78
+ const entry = this.host.findUserEntry(entryId);
79
+ if (!entry)
80
+ throw new Error("User message is no longer available");
81
+ copyTextToClipboard(entry.text);
82
+ this.host.showToast("Message copied", "success");
83
+ this.host.setSessionStatus(this.host.runtime()?.session);
84
+ }
85
+ async forkFromUserMessage(entryId) {
86
+ const runtime = this.getIdleRuntimeForAction("fork");
87
+ if (!runtime)
88
+ return;
89
+ const entry = this.host.findUserEntry(entryId);
90
+ if (!entry)
91
+ throw new Error("User message is no longer available");
92
+ const sessionEntryId = this.resolveUserSessionEntryId(entry);
93
+ if (!sessionEntryId)
94
+ throw new Error("Session entry for this message is not available yet");
95
+ this.host.setStatus("forking session");
96
+ this.host.render();
97
+ const result = await runtime.fork(sessionEntryId);
98
+ if (result.cancelled) {
99
+ this.host.addEntry({ id: createId("system"), kind: "system", text: "Fork cancelled." });
100
+ this.host.setSessionStatus(runtime.session);
101
+ return;
102
+ }
103
+ this.host.resetSessionView();
104
+ this.host.loadSessionHistory();
105
+ if (result.selectedText)
106
+ this.host.setInput(result.selectedText);
107
+ this.host.addEntry({ id: createId("system"), kind: "system", text: `Forked from entry ${sessionEntryId}.` });
108
+ this.host.setSessionStatus(runtime.session);
109
+ this.host.showToast("Session forked", "success");
110
+ }
111
+ async undoChangesFromUserMessage(entryId) {
112
+ const runtime = this.getIdleRuntimeForAction("undo changes");
113
+ if (!runtime)
114
+ return;
115
+ const entry = this.host.findUserEntry(entryId);
116
+ if (!entry)
117
+ throw new Error("User message is no longer available");
118
+ const sessionEntryId = this.resolveUserSessionEntryId(entry);
119
+ if (!sessionEntryId)
120
+ throw new Error("Session entry for this message is not available yet");
121
+ const hasMutationLog = entry.workspaceMutations !== undefined || this.hasWorkspaceMutationsForSessionEntry(sessionEntryId);
122
+ const mutations = entry.workspaceMutations ?? this.workspaceMutationsForSessionEntry(sessionEntryId);
123
+ if (!hasMutationLog) {
124
+ throw new Error("No workspace mutation log was captured for this message. Undo is available for messages sent after this build.");
125
+ }
126
+ if (mutations.length > 0) {
127
+ this.host.setStatus("reverting recorded commands");
128
+ this.host.render();
129
+ }
130
+ const reverted = mutations.length === 0 ? { ok: true, changedFiles: 0, revertedChanges: 0 } : revertWorkspaceMutations(runtime.cwd, mutations);
131
+ if (!reverted.ok)
132
+ throw new Error(reverted.error);
133
+ this.host.setStatus("truncating session");
134
+ this.host.render();
135
+ const result = await runtime.session.navigateTree(sessionEntryId);
136
+ if (result.aborted) {
137
+ this.host.showToast("Undo cancelled", "info");
138
+ this.host.setSessionStatus(runtime.session);
139
+ return;
140
+ }
141
+ if (result.cancelled) {
142
+ this.host.addEntry({ id: createId("system"), kind: "system", text: "Undo cancelled." });
143
+ this.host.setSessionStatus(runtime.session);
144
+ return;
145
+ }
146
+ this.host.resetSessionView();
147
+ this.host.loadSessionHistory();
148
+ if (result.editorText && !this.host.getInput().trim())
149
+ this.host.setInput(result.editorText);
150
+ this.host.addEntry({
151
+ id: createId("system"),
152
+ kind: "system",
153
+ text: `Undid changes from entry ${sessionEntryId}. Reverted ${reverted.revertedChanges} command${reverted.revertedChanges === 1 ? "" : "s"} across ${reverted.changedFiles} file${reverted.changedFiles === 1 ? "" : "s"}.`,
154
+ });
155
+ this.host.setSessionStatus(runtime.session);
156
+ this.host.showToast("Changes undone", "success");
157
+ }
158
+ resolveUserSessionEntryId(entry) {
159
+ if (!entry.sessionEntryId)
160
+ this.syncUserSessionEntryMetadata();
161
+ return entry.sessionEntryId;
162
+ }
163
+ getIdleRuntimeForAction(actionName) {
164
+ const runtime = this.host.runtime();
165
+ if (!runtime) {
166
+ this.host.addEntry({ id: createId("error"), kind: "error", text: "Runtime is not initialized" });
167
+ this.host.showToast(`${actionName} unavailable`, "error");
168
+ this.host.render();
169
+ return undefined;
170
+ }
171
+ if (runtime.session.isStreaming) {
172
+ this.host.showToast(`${actionName} is unavailable while the agent is running`, "warning");
173
+ this.host.render();
174
+ return undefined;
175
+ }
176
+ if (runtime.session.isCompacting) {
177
+ this.host.showToast(`${actionName} is unavailable while compacting`, "warning");
178
+ this.host.render();
179
+ return undefined;
180
+ }
181
+ return runtime;
182
+ }
183
+ workspaceMutationsForSessionEntry(entryId) {
184
+ const key = this.workspaceUndoIndexKey(entryId);
185
+ return key ? (this.workspaceUndoIndex.entries[key] ?? []) : [];
186
+ }
187
+ hasWorkspaceMutationsForSessionEntry(entryId) {
188
+ const key = this.workspaceUndoIndexKey(entryId);
189
+ return key ? Object.prototype.hasOwnProperty.call(this.workspaceUndoIndex.entries, key) : false;
190
+ }
191
+ persistWorkspaceMutations(entryId, mutations) {
192
+ const key = this.workspaceUndoIndexKey(entryId);
193
+ if (!key)
194
+ return;
195
+ const hasExisting = Object.prototype.hasOwnProperty.call(this.workspaceUndoIndex.entries, key);
196
+ if (hasExisting && sameWorkspaceMutations(this.workspaceUndoIndex.entries[key] ?? [], mutations))
197
+ return;
198
+ this.workspaceUndoIndex.entries[key] = [...mutations];
199
+ try {
200
+ saveWorkspaceUndoIndex(getAgentDir(), this.workspaceUndoIndex);
201
+ }
202
+ catch {
203
+ // Undo persistence is best-effort; in-memory undo still works for this run.
204
+ }
205
+ }
206
+ workspaceUndoIndexKey(entryId) {
207
+ const session = this.host.runtime()?.session;
208
+ if (!session)
209
+ return undefined;
210
+ return workspaceUndoIndexKey(session.sessionFile, session.sessionManager.getSessionId(), entryId);
211
+ }
212
+ }
213
+ function sameWorkspaceMutations(left, right) {
214
+ return JSON.stringify(left) === JSON.stringify(right);
215
+ }
@@ -0,0 +1,44 @@
1
+ export type WorkspaceUndoIndex = {
2
+ version: 1;
3
+ entries: Record<string, WorkspaceMutation[]>;
4
+ };
5
+ export type WorkspaceMutation = WorkspacePatchMutation | WorkspaceWriteMutation;
6
+ export type WorkspacePatchMutation = {
7
+ type: "patch";
8
+ patch: string;
9
+ toolName?: string;
10
+ };
11
+ export type WorkspaceWriteMutation = {
12
+ type: "write";
13
+ path: string;
14
+ beforeContent?: string;
15
+ afterContent: string;
16
+ toolName?: string;
17
+ };
18
+ export type WorkspaceMutationPreparation = {
19
+ type: "write";
20
+ path: string;
21
+ beforeContent?: string;
22
+ };
23
+ export type WorkspaceMutationFromToolInput = {
24
+ cwd: string;
25
+ toolName: string;
26
+ args: unknown;
27
+ details: unknown;
28
+ isError: boolean;
29
+ preparation?: WorkspaceMutationPreparation | undefined;
30
+ };
31
+ export type WorkspaceRevertResult = {
32
+ ok: true;
33
+ changedFiles: number;
34
+ revertedChanges: number;
35
+ } | {
36
+ ok: false;
37
+ error: string;
38
+ };
39
+ export declare function workspaceUndoIndexKey(_sessionFile: string | undefined, _sessionId: string, entryId: string): string;
40
+ export declare function loadWorkspaceUndoIndex(agentDir: string): WorkspaceUndoIndex;
41
+ export declare function saveWorkspaceUndoIndex(agentDir: string, index: WorkspaceUndoIndex): void;
42
+ export declare function prepareWorkspaceMutation(cwd: string, toolName: string, args: unknown): WorkspaceMutationPreparation | undefined;
43
+ export declare function workspaceMutationFromToolExecution(input: WorkspaceMutationFromToolInput): WorkspaceMutation | undefined;
44
+ export declare function revertWorkspaceMutations(cwd: string, mutations: readonly WorkspaceMutation[]): WorkspaceRevertResult;
@@ -0,0 +1,215 @@
1
+ import { spawnSync } from "node:child_process";
2
+ import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
3
+ import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
4
+ const UNDO_INDEX_VERSION = 1;
5
+ export function workspaceUndoIndexKey(_sessionFile, _sessionId, entryId) {
6
+ return entryId;
7
+ }
8
+ export function loadWorkspaceUndoIndex(agentDir) {
9
+ try {
10
+ const parsed = JSON.parse(readFileSync(workspaceUndoIndexPath(agentDir), "utf8"));
11
+ return parseUndoIndex(parsed) ?? emptyUndoIndex();
12
+ }
13
+ catch {
14
+ return emptyUndoIndex();
15
+ }
16
+ }
17
+ export function saveWorkspaceUndoIndex(agentDir, index) {
18
+ const path = workspaceUndoIndexPath(agentDir);
19
+ mkdirSync(dirname(path), { recursive: true });
20
+ writeFileSync(path, `${JSON.stringify(index, null, 2)}\n`, "utf8");
21
+ }
22
+ export function prepareWorkspaceMutation(cwd, toolName, args) {
23
+ const name = normalizedToolName(toolName);
24
+ if (name !== "write")
25
+ return undefined;
26
+ const record = plainRecord(args);
27
+ const rawPath = stringValue(record?.path);
28
+ const afterContent = stringValue(record?.content);
29
+ if (!rawPath || afterContent === undefined)
30
+ return undefined;
31
+ const safePath = safeRelativePath(cwd, rawPath);
32
+ if (!safePath)
33
+ return undefined;
34
+ const absolutePath = resolve(cwd, safePath);
35
+ return {
36
+ type: "write",
37
+ path: safePath,
38
+ ...(existsSync(absolutePath) ? { beforeContent: readFileSync(absolutePath, "utf8") } : {}),
39
+ };
40
+ }
41
+ export function workspaceMutationFromToolExecution(input) {
42
+ if (input.isError)
43
+ return undefined;
44
+ const name = normalizedToolName(input.toolName);
45
+ if (name === "write" && input.preparation?.type === "write") {
46
+ const record = plainRecord(input.args);
47
+ const afterContent = stringValue(record?.content);
48
+ if (afterContent === undefined || input.preparation.beforeContent === afterContent)
49
+ return undefined;
50
+ return {
51
+ type: "write",
52
+ path: input.preparation.path,
53
+ ...(input.preparation.beforeContent === undefined ? {} : { beforeContent: input.preparation.beforeContent }),
54
+ afterContent,
55
+ toolName: input.toolName,
56
+ };
57
+ }
58
+ const patch = patchFromDetails(input.details) ?? patchFromArgs(input.args);
59
+ if (!patch || !looksLikeUnifiedPatch(patch))
60
+ return undefined;
61
+ if (name === "edit" || name === "apply_patch" || name === "ast_apply") {
62
+ return { type: "patch", patch, toolName: input.toolName };
63
+ }
64
+ return undefined;
65
+ }
66
+ export function revertWorkspaceMutations(cwd, mutations) {
67
+ const changedFiles = new Set();
68
+ const applied = [];
69
+ for (const mutation of [...mutations].reverse()) {
70
+ const result = applyMutation(cwd, mutation, "undo");
71
+ if (!result.ok) {
72
+ const rollback = rollbackMutations(cwd, applied);
73
+ const rollbackText = rollback.ok ? "Rolled back already-applied undo steps." : `Rollback failed: ${rollback.error}`;
74
+ return { ok: false, error: `${result.error}\n${rollbackText}` };
75
+ }
76
+ for (const file of result.changedFiles)
77
+ changedFiles.add(file);
78
+ applied.push(mutation);
79
+ }
80
+ return { ok: true, changedFiles: changedFiles.size, revertedChanges: applied.length };
81
+ }
82
+ function rollbackMutations(cwd, appliedUndoMutations) {
83
+ for (const mutation of [...appliedUndoMutations].reverse()) {
84
+ const result = applyMutation(cwd, mutation, "redo");
85
+ if (!result.ok)
86
+ return { ok: false, error: result.error };
87
+ }
88
+ return { ok: true, changedFiles: 0, revertedChanges: appliedUndoMutations.length };
89
+ }
90
+ function applyMutation(cwd, mutation, direction) {
91
+ if (mutation.type === "patch")
92
+ return applyPatchMutation(cwd, mutation, direction);
93
+ return applyWriteMutation(cwd, mutation, direction);
94
+ }
95
+ function applyPatchMutation(cwd, mutation, direction) {
96
+ const args = ["apply", ...(direction === "undo" ? ["--reverse"] : []), "--whitespace=nowarn"];
97
+ const check = runGitApply(cwd, [...args, "--check"], mutation.patch);
98
+ if (check.status !== 0)
99
+ return { ok: false, error: commandError(`git ${args.join(" ")} --check`, check) };
100
+ const apply = runGitApply(cwd, args, mutation.patch);
101
+ if (apply.status !== 0)
102
+ return { ok: false, error: commandError(`git ${args.join(" ")}`, apply) };
103
+ return { ok: true, changedFiles: filesFromPatch(mutation.patch) };
104
+ }
105
+ function applyWriteMutation(cwd, mutation, direction) {
106
+ const safePath = safeRelativePath(cwd, mutation.path);
107
+ if (!safePath)
108
+ return { ok: false, error: `Refusing to modify path outside workspace: ${mutation.path}` };
109
+ const absolutePath = resolve(cwd, safePath);
110
+ const expectedContent = direction === "undo" ? mutation.afterContent : mutation.beforeContent;
111
+ const nextContent = direction === "undo" ? mutation.beforeContent : mutation.afterContent;
112
+ const currentExists = existsSync(absolutePath);
113
+ const currentContent = currentExists ? readFileSync(absolutePath, "utf8") : undefined;
114
+ if (currentContent !== expectedContent) {
115
+ return { ok: false, error: `Refusing to ${direction} write for ${safePath}: file content changed since the recorded command.` };
116
+ }
117
+ if (nextContent === undefined) {
118
+ if (currentExists)
119
+ rmSync(absolutePath, { force: true });
120
+ }
121
+ else {
122
+ mkdirSync(dirname(absolutePath), { recursive: true });
123
+ writeFileSync(absolutePath, nextContent, "utf8");
124
+ }
125
+ return { ok: true, changedFiles: [safePath] };
126
+ }
127
+ function emptyUndoIndex() {
128
+ return { version: UNDO_INDEX_VERSION, entries: {} };
129
+ }
130
+ function parseUndoIndex(value) {
131
+ if (!value || typeof value !== "object")
132
+ return undefined;
133
+ const record = value;
134
+ if (record.version !== UNDO_INDEX_VERSION || !isMutationRecord(record.entries))
135
+ return undefined;
136
+ return { version: UNDO_INDEX_VERSION, entries: record.entries };
137
+ }
138
+ function workspaceUndoIndexPath(agentDir) {
139
+ return join(agentDir, "pix", "workspace-undo", "index.json");
140
+ }
141
+ function runGitApply(cwd, args, input) {
142
+ return spawnSync("git", ["-c", "core.autocrlf=false", ...args], {
143
+ cwd,
144
+ input,
145
+ encoding: "utf8",
146
+ maxBuffer: 20 * 1024 * 1024,
147
+ });
148
+ }
149
+ function commandError(command, result) {
150
+ if (result.error)
151
+ return `${command} failed: ${result.error.message}`;
152
+ const message = result.stderr?.trim() || result.stdout?.trim() || `exit code ${result.status ?? "unknown"}`;
153
+ return `${command} failed: ${message}`;
154
+ }
155
+ function normalizedToolName(toolName) {
156
+ return toolName.split(/[.:/]/).filter(Boolean).at(-1)?.trim().toLowerCase() ?? toolName.toLowerCase();
157
+ }
158
+ function plainRecord(value) {
159
+ return value && typeof value === "object" && !Array.isArray(value) ? value : undefined;
160
+ }
161
+ function stringValue(value) {
162
+ return typeof value === "string" ? value : undefined;
163
+ }
164
+ function patchFromDetails(details) {
165
+ const record = plainRecord(details);
166
+ return stringValue(record?.patch) ?? stringValue(record?.diff);
167
+ }
168
+ function patchFromArgs(args) {
169
+ const record = plainRecord(args);
170
+ return stringValue(record?.patch) ?? stringValue(record?.input);
171
+ }
172
+ function looksLikeUnifiedPatch(text) {
173
+ return /^---\s+/m.test(text) && /^\+\+\+\s+/m.test(text) && /^@@\s/m.test(text);
174
+ }
175
+ function filesFromPatch(patch) {
176
+ const files = new Set();
177
+ for (const line of patch.split("\n")) {
178
+ const match = /^(?:---|\+\+\+)\s+(.+?)(?:\t.*)?$/.exec(line);
179
+ const file = match?.[1]?.trim();
180
+ if (!file || file === "/dev/null")
181
+ continue;
182
+ files.add(file.replace(/^[ab]\//, ""));
183
+ }
184
+ return [...files];
185
+ }
186
+ function safeRelativePath(cwd, inputPath) {
187
+ const absolutePath = isAbsolute(inputPath) ? resolve(inputPath) : resolve(cwd, inputPath);
188
+ const relativePath = relative(resolve(cwd), absolutePath);
189
+ if (!relativePath || relativePath === ".." || relativePath.startsWith(`..${sep}`) || isAbsolute(relativePath))
190
+ return undefined;
191
+ return relativePath;
192
+ }
193
+ function isMutationRecord(value) {
194
+ if (!value || typeof value !== "object")
195
+ return false;
196
+ return Object.values(value).every(isMutations);
197
+ }
198
+ function isMutations(value) {
199
+ return Array.isArray(value) && value.every(isMutation);
200
+ }
201
+ function isMutation(value) {
202
+ if (!value || typeof value !== "object")
203
+ return false;
204
+ const record = value;
205
+ if (record.type === "patch") {
206
+ return typeof record.patch === "string" && (record.toolName === undefined || typeof record.toolName === "string");
207
+ }
208
+ if (record.type === "write") {
209
+ return (typeof record.path === "string" &&
210
+ typeof record.afterContent === "string" &&
211
+ (record.beforeContent === undefined || typeof record.beforeContent === "string") &&
212
+ (record.toolName === undefined || typeof record.toolName === "string"));
213
+ }
214
+ return false;
215
+ }
@@ -0,0 +1,62 @@
1
+ import { type AppIconThemeName } from "./app/icons.js";
2
+ export type ToolRendererRule = {
3
+ previewLines?: number;
4
+ direction?: "head" | "tail";
5
+ color?: string;
6
+ defaultExpanded?: boolean;
7
+ compactHidden?: boolean;
8
+ hidden?: boolean;
9
+ };
10
+ export type ResolvedToolRule = {
11
+ previewLines: number;
12
+ direction: "head" | "tail";
13
+ color: string;
14
+ defaultExpanded?: boolean;
15
+ compactHidden?: boolean;
16
+ hidden?: boolean;
17
+ };
18
+ export type ToolRendererConfig = {
19
+ default: ToolRendererRule;
20
+ tools: Record<string, ToolRendererRule>;
21
+ };
22
+ export type OutputFiltersConfig = {
23
+ patterns: string[];
24
+ };
25
+ export type PromptEnhancerConfig = {
26
+ modelRef: string;
27
+ };
28
+ export type ModelColorsConfig = {
29
+ rules: Record<string, string>;
30
+ };
31
+ export type IconThemeConfig = {
32
+ name: AppIconThemeName;
33
+ };
34
+ export type DictationLanguageModelConfig = {
35
+ dirName: string;
36
+ url: string;
37
+ label: string;
38
+ };
39
+ export type DictationConfig = {
40
+ languages: Record<string, DictationLanguageModelConfig>;
41
+ language?: string;
42
+ };
43
+ export type PixConfig = {
44
+ toolRenderer: ToolRendererConfig;
45
+ outputFilters: OutputFiltersConfig;
46
+ promptEnhancer: PromptEnhancerConfig;
47
+ modelColors: ModelColorsConfig;
48
+ iconTheme: IconThemeConfig;
49
+ dictation: DictationConfig;
50
+ };
51
+ export declare function getPixConfigPath(homeDir?: string): string;
52
+ export declare function loadPixConfig(): PixConfig;
53
+ export declare function savePixDictationLanguage(language: string): void;
54
+ export declare function upsertPixDictationLanguageInJsonc(source: string, language: string): string;
55
+ export declare function resolveModelColor(modelRef: string, config: ModelColorsConfig): string | undefined;
56
+ export declare function compileOutputFilterPatterns(patterns: readonly string[]): RegExp[];
57
+ export declare function stripDcpDisplayMetadata(text: string): string;
58
+ export declare function applyOutputFilters(text: string, filters: readonly RegExp[]): string;
59
+ export declare function outputFiltersRemoveDcpIdMetadataLine(filters: readonly RegExp[]): boolean;
60
+ export declare function suppressPendingDcpIdMetadataLine(text: string): string;
61
+ export declare function resolveToolRule(toolName: string, config: ToolRendererConfig): ResolvedToolRule;
62
+ export declare function resolveColor(colorRef: string, themeColors: Record<string, string>): string;