terminal-pilot 0.0.30 → 0.0.32

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 (329) hide show
  1. package/dist/cli.js +1599 -497
  2. package/dist/cli.js.map +4 -4
  3. package/dist/commands/close-session.js +489 -6
  4. package/dist/commands/close-session.js.map +4 -4
  5. package/dist/commands/create-session.js +489 -6
  6. package/dist/commands/create-session.js.map +4 -4
  7. package/dist/commands/fill.js +489 -6
  8. package/dist/commands/fill.js.map +4 -4
  9. package/dist/commands/get-session.js +489 -6
  10. package/dist/commands/get-session.js.map +4 -4
  11. package/dist/commands/index.js +630 -44
  12. package/dist/commands/index.js.map +4 -4
  13. package/dist/commands/install.js +626 -40
  14. package/dist/commands/install.js.map +4 -4
  15. package/dist/commands/installer.js +68 -17
  16. package/dist/commands/installer.js.map +4 -4
  17. package/dist/commands/list-sessions.js +489 -6
  18. package/dist/commands/list-sessions.js.map +4 -4
  19. package/dist/commands/press-key.js +489 -6
  20. package/dist/commands/press-key.js.map +4 -4
  21. package/dist/commands/read-history.js +489 -6
  22. package/dist/commands/read-history.js.map +4 -4
  23. package/dist/commands/read-screen.js +489 -6
  24. package/dist/commands/read-screen.js.map +4 -4
  25. package/dist/commands/resize.js +489 -6
  26. package/dist/commands/resize.js.map +4 -4
  27. package/dist/commands/runtime.js.map +1 -1
  28. package/dist/commands/screenshot.js +489 -6
  29. package/dist/commands/screenshot.js.map +4 -4
  30. package/dist/commands/send-signal.js +489 -6
  31. package/dist/commands/send-signal.js.map +4 -4
  32. package/dist/commands/type.js +489 -6
  33. package/dist/commands/type.js.map +4 -4
  34. package/dist/commands/uninstall.js +554 -20
  35. package/dist/commands/uninstall.js.map +4 -4
  36. package/dist/commands/wait-for-exit.js +489 -6
  37. package/dist/commands/wait-for-exit.js.map +4 -4
  38. package/dist/commands/wait-for.js +489 -6
  39. package/dist/commands/wait-for.js.map +4 -4
  40. package/dist/testing/cli-repl.js +1599 -497
  41. package/dist/testing/cli-repl.js.map +4 -4
  42. package/dist/testing/qa-cli.js +1609 -507
  43. package/dist/testing/qa-cli.js.map +4 -4
  44. package/node_modules/@poe-code/agent-defs/README.md +35 -0
  45. package/node_modules/@poe-code/agent-defs/dist/agents/claude-code.d.ts +2 -0
  46. package/node_modules/@poe-code/agent-defs/dist/agents/claude-code.js +21 -0
  47. package/node_modules/@poe-code/agent-defs/dist/agents/claude-desktop.d.ts +2 -0
  48. package/node_modules/@poe-code/agent-defs/dist/agents/claude-desktop.js +18 -0
  49. package/node_modules/@poe-code/agent-defs/dist/agents/codex.d.ts +2 -0
  50. package/node_modules/@poe-code/agent-defs/dist/agents/codex.js +25 -0
  51. package/node_modules/@poe-code/agent-defs/dist/agents/cursor.d.ts +2 -0
  52. package/node_modules/@poe-code/agent-defs/dist/agents/cursor.js +15 -0
  53. package/node_modules/@poe-code/agent-defs/dist/agents/gemini-cli.d.ts +2 -0
  54. package/node_modules/@poe-code/agent-defs/dist/agents/gemini-cli.js +16 -0
  55. package/node_modules/@poe-code/agent-defs/dist/agents/goose.d.ts +2 -0
  56. package/node_modules/@poe-code/agent-defs/dist/agents/goose.js +16 -0
  57. package/node_modules/@poe-code/agent-defs/dist/agents/index.d.ts +9 -0
  58. package/node_modules/@poe-code/agent-defs/dist/agents/index.js +9 -0
  59. package/node_modules/@poe-code/agent-defs/dist/agents/kimi.d.ts +2 -0
  60. package/node_modules/@poe-code/agent-defs/dist/agents/kimi.js +16 -0
  61. package/node_modules/@poe-code/agent-defs/dist/agents/opencode.d.ts +2 -0
  62. package/node_modules/@poe-code/agent-defs/dist/agents/opencode.js +20 -0
  63. package/node_modules/@poe-code/agent-defs/dist/agents/poe-agent.d.ts +2 -0
  64. package/node_modules/@poe-code/agent-defs/dist/agents/poe-agent.js +14 -0
  65. package/node_modules/@poe-code/agent-defs/dist/index.d.ts +5 -0
  66. package/node_modules/@poe-code/agent-defs/dist/index.js +3 -0
  67. package/node_modules/@poe-code/agent-defs/dist/registry.d.ts +3 -0
  68. package/node_modules/@poe-code/agent-defs/dist/registry.js +45 -0
  69. package/node_modules/@poe-code/agent-defs/dist/specifier.d.ts +7 -0
  70. package/node_modules/@poe-code/agent-defs/dist/specifier.js +40 -0
  71. package/node_modules/@poe-code/agent-defs/dist/types.d.ts +28 -0
  72. package/node_modules/@poe-code/agent-defs/dist/types.js +1 -0
  73. package/node_modules/@poe-code/agent-defs/package.json +20 -0
  74. package/node_modules/@poe-code/agent-skill-config/dist/apply.js +2 -1
  75. package/node_modules/@poe-code/agent-skill-config/dist/bridge-active-skills.d.ts +1 -0
  76. package/node_modules/@poe-code/agent-skill-config/dist/bridge-active-skills.js +37 -18
  77. package/node_modules/@poe-code/agent-skill-config/dist/resolve-skill-reference.js +8 -4
  78. package/node_modules/@poe-code/agent-skill-config/package.json +1 -5
  79. package/node_modules/@poe-code/config-mutations/README.md +55 -0
  80. package/node_modules/@poe-code/config-mutations/dist/error-codes.d.ts +1 -0
  81. package/node_modules/@poe-code/config-mutations/dist/error-codes.js +6 -0
  82. package/node_modules/@poe-code/config-mutations/dist/execution/apply-mutation.d.ts +6 -0
  83. package/node_modules/@poe-code/config-mutations/dist/execution/apply-mutation.js +829 -0
  84. package/node_modules/@poe-code/config-mutations/dist/execution/path-utils.d.ts +17 -0
  85. package/node_modules/@poe-code/config-mutations/dist/execution/path-utils.js +64 -0
  86. package/node_modules/@poe-code/config-mutations/dist/execution/run-mutations.d.ts +7 -0
  87. package/node_modules/@poe-code/config-mutations/dist/execution/run-mutations.js +39 -0
  88. package/node_modules/@poe-code/config-mutations/dist/formats/index.d.ts +13 -0
  89. package/node_modules/@poe-code/config-mutations/dist/formats/index.js +49 -0
  90. package/node_modules/@poe-code/config-mutations/dist/formats/json.d.ts +32 -0
  91. package/node_modules/@poe-code/config-mutations/dist/formats/json.js +171 -0
  92. package/node_modules/@poe-code/config-mutations/dist/formats/object.d.ts +4 -0
  93. package/node_modules/@poe-code/config-mutations/dist/formats/object.js +27 -0
  94. package/node_modules/@poe-code/config-mutations/dist/formats/toml.d.ts +2 -0
  95. package/node_modules/@poe-code/config-mutations/dist/formats/toml.js +75 -0
  96. package/node_modules/@poe-code/config-mutations/dist/formats/yaml.d.ts +2 -0
  97. package/node_modules/@poe-code/config-mutations/dist/formats/yaml.js +76 -0
  98. package/node_modules/@poe-code/config-mutations/dist/fs-utils.d.ts +18 -0
  99. package/node_modules/@poe-code/config-mutations/dist/fs-utils.js +43 -0
  100. package/node_modules/@poe-code/config-mutations/dist/index.d.ts +8 -0
  101. package/node_modules/@poe-code/config-mutations/dist/index.js +8 -0
  102. package/node_modules/@poe-code/config-mutations/dist/mutations/config-mutation.d.ts +47 -0
  103. package/node_modules/@poe-code/config-mutations/dist/mutations/config-mutation.js +34 -0
  104. package/node_modules/@poe-code/config-mutations/dist/mutations/file-mutation.d.ts +62 -0
  105. package/node_modules/@poe-code/config-mutations/dist/mutations/file-mutation.js +55 -0
  106. package/node_modules/@poe-code/config-mutations/dist/mutations/template-mutation.d.ts +40 -0
  107. package/node_modules/@poe-code/config-mutations/dist/mutations/template-mutation.js +32 -0
  108. package/node_modules/@poe-code/config-mutations/dist/template/render.d.ts +6 -0
  109. package/node_modules/@poe-code/config-mutations/dist/template/render.js +8 -0
  110. package/node_modules/@poe-code/config-mutations/dist/testing/format-utils.d.ts +7 -0
  111. package/node_modules/@poe-code/config-mutations/dist/testing/format-utils.js +21 -0
  112. package/node_modules/@poe-code/config-mutations/dist/testing/index.d.ts +3 -0
  113. package/node_modules/@poe-code/config-mutations/dist/testing/index.js +2 -0
  114. package/node_modules/@poe-code/config-mutations/dist/testing/mock-fs.d.ts +25 -0
  115. package/node_modules/@poe-code/config-mutations/dist/testing/mock-fs.js +194 -0
  116. package/node_modules/@poe-code/config-mutations/dist/types.d.ts +168 -0
  117. package/node_modules/@poe-code/config-mutations/dist/types.js +6 -0
  118. package/node_modules/@poe-code/config-mutations/package.json +29 -0
  119. package/node_modules/@poe-code/frontmatter/README.md +35 -0
  120. package/node_modules/@poe-code/frontmatter/dist/fences.d.ts +25 -0
  121. package/node_modules/@poe-code/frontmatter/dist/fences.js +100 -0
  122. package/node_modules/@poe-code/frontmatter/dist/index.d.ts +3 -0
  123. package/node_modules/@poe-code/frontmatter/dist/index.js +3 -0
  124. package/node_modules/@poe-code/frontmatter/dist/parse.d.ts +20 -0
  125. package/node_modules/@poe-code/frontmatter/dist/parse.js +209 -0
  126. package/node_modules/@poe-code/frontmatter/dist/stringify.d.ts +1 -0
  127. package/node_modules/@poe-code/frontmatter/dist/stringify.js +48 -0
  128. package/node_modules/@poe-code/frontmatter/package.json +25 -0
  129. package/node_modules/toolcraft-design/README.md +160 -0
  130. package/node_modules/toolcraft-design/dist/acp/components.d.ts +12 -0
  131. package/node_modules/toolcraft-design/dist/acp/components.js +137 -0
  132. package/node_modules/toolcraft-design/dist/acp/index.d.ts +3 -0
  133. package/node_modules/toolcraft-design/dist/acp/index.js +2 -0
  134. package/node_modules/toolcraft-design/dist/acp/writer.d.ts +13 -0
  135. package/node_modules/toolcraft-design/dist/acp/writer.js +21 -0
  136. package/node_modules/toolcraft-design/dist/components/browser.d.ts +15 -0
  137. package/node_modules/toolcraft-design/dist/components/browser.js +31 -0
  138. package/node_modules/toolcraft-design/dist/components/catalog.d.ts +26 -0
  139. package/node_modules/toolcraft-design/dist/components/catalog.js +95 -0
  140. package/node_modules/toolcraft-design/dist/components/color.d.ts +31 -0
  141. package/node_modules/toolcraft-design/dist/components/color.js +102 -0
  142. package/node_modules/toolcraft-design/dist/components/command-errors.d.ts +16 -0
  143. package/node_modules/toolcraft-design/dist/components/command-errors.js +23 -0
  144. package/node_modules/toolcraft-design/dist/components/detail-card.d.ts +22 -0
  145. package/node_modules/toolcraft-design/dist/components/detail-card.js +45 -0
  146. package/node_modules/toolcraft-design/dist/components/help-formatter-plain.d.ts +5 -0
  147. package/node_modules/toolcraft-design/dist/components/help-formatter-plain.js +132 -0
  148. package/node_modules/toolcraft-design/dist/components/help-formatter.d.ts +33 -0
  149. package/node_modules/toolcraft-design/dist/components/help-formatter.js +213 -0
  150. package/node_modules/toolcraft-design/dist/components/index.d.ts +16 -0
  151. package/node_modules/toolcraft-design/dist/components/index.js +10 -0
  152. package/node_modules/toolcraft-design/dist/components/logger.d.ts +11 -0
  153. package/node_modules/toolcraft-design/dist/components/logger.js +60 -0
  154. package/node_modules/toolcraft-design/dist/components/symbols.d.ts +12 -0
  155. package/node_modules/toolcraft-design/dist/components/symbols.js +71 -0
  156. package/node_modules/toolcraft-design/dist/components/table.d.ts +15 -0
  157. package/node_modules/toolcraft-design/dist/components/table.js +302 -0
  158. package/node_modules/toolcraft-design/dist/components/template.d.ts +10 -0
  159. package/node_modules/toolcraft-design/dist/components/template.js +437 -0
  160. package/node_modules/toolcraft-design/dist/components/text.d.ts +16 -0
  161. package/node_modules/toolcraft-design/dist/components/text.js +145 -0
  162. package/node_modules/toolcraft-design/dist/dashboard/ansi.d.ts +18 -0
  163. package/node_modules/toolcraft-design/dist/dashboard/ansi.js +343 -0
  164. package/node_modules/toolcraft-design/dist/dashboard/buffer.d.ts +25 -0
  165. package/node_modules/toolcraft-design/dist/dashboard/buffer.js +219 -0
  166. package/node_modules/toolcraft-design/dist/dashboard/components/border.d.ts +9 -0
  167. package/node_modules/toolcraft-design/dist/dashboard/components/border.js +123 -0
  168. package/node_modules/toolcraft-design/dist/dashboard/components/footer.d.ts +8 -0
  169. package/node_modules/toolcraft-design/dist/dashboard/components/footer.js +56 -0
  170. package/node_modules/toolcraft-design/dist/dashboard/components/output-pane.d.ts +12 -0
  171. package/node_modules/toolcraft-design/dist/dashboard/components/output-pane.js +268 -0
  172. package/node_modules/toolcraft-design/dist/dashboard/components/stats-pane.d.ts +7 -0
  173. package/node_modules/toolcraft-design/dist/dashboard/components/stats-pane.js +107 -0
  174. package/node_modules/toolcraft-design/dist/dashboard/dashboard.d.ts +20 -0
  175. package/node_modules/toolcraft-design/dist/dashboard/dashboard.js +167 -0
  176. package/node_modules/toolcraft-design/dist/dashboard/demo.d.ts +13 -0
  177. package/node_modules/toolcraft-design/dist/dashboard/demo.js +145 -0
  178. package/node_modules/toolcraft-design/dist/dashboard/index.d.ts +8 -0
  179. package/node_modules/toolcraft-design/dist/dashboard/index.js +4 -0
  180. package/node_modules/toolcraft-design/dist/dashboard/keymap.d.ts +8 -0
  181. package/node_modules/toolcraft-design/dist/dashboard/keymap.js +233 -0
  182. package/node_modules/toolcraft-design/dist/dashboard/layout.d.ts +25 -0
  183. package/node_modules/toolcraft-design/dist/dashboard/layout.js +79 -0
  184. package/node_modules/toolcraft-design/dist/dashboard/should-use-dashboard.d.ts +10 -0
  185. package/node_modules/toolcraft-design/dist/dashboard/should-use-dashboard.js +7 -0
  186. package/node_modules/toolcraft-design/dist/dashboard/snapshot.d.ts +10 -0
  187. package/node_modules/toolcraft-design/dist/dashboard/snapshot.js +68 -0
  188. package/node_modules/toolcraft-design/dist/dashboard/store.d.ts +8 -0
  189. package/node_modules/toolcraft-design/dist/dashboard/store.js +51 -0
  190. package/node_modules/toolcraft-design/dist/dashboard/terminal-width.d.ts +4 -0
  191. package/node_modules/toolcraft-design/dist/dashboard/terminal-width.js +71 -0
  192. package/node_modules/toolcraft-design/dist/dashboard/terminal.d.ts +37 -0
  193. package/node_modules/toolcraft-design/dist/dashboard/terminal.js +264 -0
  194. package/node_modules/toolcraft-design/dist/dashboard/types.d.ts +38 -0
  195. package/node_modules/toolcraft-design/dist/dashboard/types.js +1 -0
  196. package/node_modules/toolcraft-design/dist/explorer/actions.d.ts +16 -0
  197. package/node_modules/toolcraft-design/dist/explorer/actions.js +39 -0
  198. package/node_modules/toolcraft-design/dist/explorer/demo.d.ts +13 -0
  199. package/node_modules/toolcraft-design/dist/explorer/demo.js +297 -0
  200. package/node_modules/toolcraft-design/dist/explorer/events.d.ts +67 -0
  201. package/node_modules/toolcraft-design/dist/explorer/events.js +1 -0
  202. package/node_modules/toolcraft-design/dist/explorer/filter.d.ts +10 -0
  203. package/node_modules/toolcraft-design/dist/explorer/filter.js +95 -0
  204. package/node_modules/toolcraft-design/dist/explorer/index.d.ts +8 -0
  205. package/node_modules/toolcraft-design/dist/explorer/index.js +8 -0
  206. package/node_modules/toolcraft-design/dist/explorer/jobs.d.ts +7 -0
  207. package/node_modules/toolcraft-design/dist/explorer/jobs.js +59 -0
  208. package/node_modules/toolcraft-design/dist/explorer/keymap.d.ts +21 -0
  209. package/node_modules/toolcraft-design/dist/explorer/keymap.js +376 -0
  210. package/node_modules/toolcraft-design/dist/explorer/layout.d.ts +20 -0
  211. package/node_modules/toolcraft-design/dist/explorer/layout.js +73 -0
  212. package/node_modules/toolcraft-design/dist/explorer/reducer.d.ts +9 -0
  213. package/node_modules/toolcraft-design/dist/explorer/reducer.js +782 -0
  214. package/node_modules/toolcraft-design/dist/explorer/render/detail.d.ts +4 -0
  215. package/node_modules/toolcraft-design/dist/explorer/render/detail.js +97 -0
  216. package/node_modules/toolcraft-design/dist/explorer/render/footer.d.ts +4 -0
  217. package/node_modules/toolcraft-design/dist/explorer/render/footer.js +73 -0
  218. package/node_modules/toolcraft-design/dist/explorer/render/header.d.ts +4 -0
  219. package/node_modules/toolcraft-design/dist/explorer/render/header.js +49 -0
  220. package/node_modules/toolcraft-design/dist/explorer/render/index.d.ts +8 -0
  221. package/node_modules/toolcraft-design/dist/explorer/render/index.js +53 -0
  222. package/node_modules/toolcraft-design/dist/explorer/render/list.d.ts +4 -0
  223. package/node_modules/toolcraft-design/dist/explorer/render/list.js +116 -0
  224. package/node_modules/toolcraft-design/dist/explorer/render/modal.d.ts +3 -0
  225. package/node_modules/toolcraft-design/dist/explorer/render/modal.js +87 -0
  226. package/node_modules/toolcraft-design/dist/explorer/render/test-fixtures.d.ts +8 -0
  227. package/node_modules/toolcraft-design/dist/explorer/render/test-fixtures.js +156 -0
  228. package/node_modules/toolcraft-design/dist/explorer/render/text.d.ts +12 -0
  229. package/node_modules/toolcraft-design/dist/explorer/render/text.js +81 -0
  230. package/node_modules/toolcraft-design/dist/explorer/runtime.d.ts +2 -0
  231. package/node_modules/toolcraft-design/dist/explorer/runtime.js +340 -0
  232. package/node_modules/toolcraft-design/dist/explorer/runtime.test-helpers.d.ts +50 -0
  233. package/node_modules/toolcraft-design/dist/explorer/runtime.test-helpers.js +101 -0
  234. package/node_modules/toolcraft-design/dist/explorer/state.d.ts +137 -0
  235. package/node_modules/toolcraft-design/dist/explorer/state.js +86 -0
  236. package/node_modules/toolcraft-design/dist/explorer/theme.d.ts +27 -0
  237. package/node_modules/toolcraft-design/dist/explorer/theme.js +29 -0
  238. package/node_modules/toolcraft-design/dist/index.d.ts +50 -0
  239. package/node_modules/toolcraft-design/dist/index.js +43 -0
  240. package/node_modules/toolcraft-design/dist/internal/color-support.d.ts +9 -0
  241. package/node_modules/toolcraft-design/dist/internal/color-support.js +12 -0
  242. package/node_modules/toolcraft-design/dist/internal/output-format.d.ts +6 -0
  243. package/node_modules/toolcraft-design/dist/internal/output-format.js +22 -0
  244. package/node_modules/toolcraft-design/dist/internal/strip-ansi.d.ts +1 -0
  245. package/node_modules/toolcraft-design/dist/internal/strip-ansi.js +50 -0
  246. package/node_modules/toolcraft-design/dist/internal/theme-detect.d.ts +12 -0
  247. package/node_modules/toolcraft-design/dist/internal/theme-detect.js +71 -0
  248. package/node_modules/toolcraft-design/dist/internal/theme-state.d.ts +12 -0
  249. package/node_modules/toolcraft-design/dist/internal/theme-state.js +35 -0
  250. package/node_modules/toolcraft-design/dist/prompts/index.d.ts +91 -0
  251. package/node_modules/toolcraft-design/dist/prompts/index.js +137 -0
  252. package/node_modules/toolcraft-design/dist/prompts/interactive/cancel-symbol.d.ts +2 -0
  253. package/node_modules/toolcraft-design/dist/prompts/interactive/cancel-symbol.js +4 -0
  254. package/node_modules/toolcraft-design/dist/prompts/interactive/confirm.d.ts +9 -0
  255. package/node_modules/toolcraft-design/dist/prompts/interactive/confirm.js +47 -0
  256. package/node_modules/toolcraft-design/dist/prompts/interactive/core.d.ts +55 -0
  257. package/node_modules/toolcraft-design/dist/prompts/interactive/core.js +274 -0
  258. package/node_modules/toolcraft-design/dist/prompts/interactive/glyphs.d.ts +20 -0
  259. package/node_modules/toolcraft-design/dist/prompts/interactive/glyphs.js +53 -0
  260. package/node_modules/toolcraft-design/dist/prompts/interactive/index.d.ts +6 -0
  261. package/node_modules/toolcraft-design/dist/prompts/interactive/index.js +6 -0
  262. package/node_modules/toolcraft-design/dist/prompts/interactive/keys.d.ts +2 -0
  263. package/node_modules/toolcraft-design/dist/prompts/interactive/keys.js +28 -0
  264. package/node_modules/toolcraft-design/dist/prompts/interactive/multiselect.d.ts +13 -0
  265. package/node_modules/toolcraft-design/dist/prompts/interactive/multiselect.js +131 -0
  266. package/node_modules/toolcraft-design/dist/prompts/interactive/pagination.d.ts +10 -0
  267. package/node_modules/toolcraft-design/dist/prompts/interactive/pagination.js +52 -0
  268. package/node_modules/toolcraft-design/dist/prompts/interactive/password.d.ts +10 -0
  269. package/node_modules/toolcraft-design/dist/prompts/interactive/password.js +55 -0
  270. package/node_modules/toolcraft-design/dist/prompts/interactive/select.d.ts +18 -0
  271. package/node_modules/toolcraft-design/dist/prompts/interactive/select.js +89 -0
  272. package/node_modules/toolcraft-design/dist/prompts/interactive/test-helpers.d.ts +21 -0
  273. package/node_modules/toolcraft-design/dist/prompts/interactive/test-helpers.js +32 -0
  274. package/node_modules/toolcraft-design/dist/prompts/interactive/text.d.ts +12 -0
  275. package/node_modules/toolcraft-design/dist/prompts/interactive/text.js +60 -0
  276. package/node_modules/toolcraft-design/dist/prompts/interactive/wrap.d.ts +4 -0
  277. package/node_modules/toolcraft-design/dist/prompts/interactive/wrap.js +18 -0
  278. package/node_modules/toolcraft-design/dist/prompts/primitives/cancel.d.ts +2 -0
  279. package/node_modules/toolcraft-design/dist/prompts/primitives/cancel.js +9 -0
  280. package/node_modules/toolcraft-design/dist/prompts/primitives/intro.d.ts +1 -0
  281. package/node_modules/toolcraft-design/dist/prompts/primitives/intro.js +16 -0
  282. package/node_modules/toolcraft-design/dist/prompts/primitives/log.d.ts +18 -0
  283. package/node_modules/toolcraft-design/dist/prompts/primitives/log.js +104 -0
  284. package/node_modules/toolcraft-design/dist/prompts/primitives/note.d.ts +1 -0
  285. package/node_modules/toolcraft-design/dist/prompts/primitives/note.js +39 -0
  286. package/node_modules/toolcraft-design/dist/prompts/primitives/outro.d.ts +1 -0
  287. package/node_modules/toolcraft-design/dist/prompts/primitives/outro.js +16 -0
  288. package/node_modules/toolcraft-design/dist/prompts/primitives/spinner.d.ts +6 -0
  289. package/node_modules/toolcraft-design/dist/prompts/primitives/spinner.js +74 -0
  290. package/node_modules/toolcraft-design/dist/prompts/theme.d.ts +11 -0
  291. package/node_modules/toolcraft-design/dist/prompts/theme.js +15 -0
  292. package/node_modules/toolcraft-design/dist/static/index.d.ts +4 -0
  293. package/node_modules/toolcraft-design/dist/static/index.js +2 -0
  294. package/node_modules/toolcraft-design/dist/static/menu.d.ts +11 -0
  295. package/node_modules/toolcraft-design/dist/static/menu.js +42 -0
  296. package/node_modules/toolcraft-design/dist/static/spinner.d.ts +14 -0
  297. package/node_modules/toolcraft-design/dist/static/spinner.js +52 -0
  298. package/node_modules/toolcraft-design/dist/terminal-markdown/ast.d.ts +92 -0
  299. package/node_modules/toolcraft-design/dist/terminal-markdown/ast.js +1 -0
  300. package/node_modules/toolcraft-design/dist/terminal-markdown/demo-content.d.ts +2 -0
  301. package/node_modules/toolcraft-design/dist/terminal-markdown/demo-content.js +139 -0
  302. package/node_modules/toolcraft-design/dist/terminal-markdown/index.d.ts +6 -0
  303. package/node_modules/toolcraft-design/dist/terminal-markdown/index.js +8 -0
  304. package/node_modules/toolcraft-design/dist/terminal-markdown/parser/block.d.ts +7 -0
  305. package/node_modules/toolcraft-design/dist/terminal-markdown/parser/block.js +1495 -0
  306. package/node_modules/toolcraft-design/dist/terminal-markdown/parser/frontmatter.d.ts +8 -0
  307. package/node_modules/toolcraft-design/dist/terminal-markdown/parser/frontmatter.js +36 -0
  308. package/node_modules/toolcraft-design/dist/terminal-markdown/parser/inline.d.ts +10 -0
  309. package/node_modules/toolcraft-design/dist/terminal-markdown/parser/inline.js +1190 -0
  310. package/node_modules/toolcraft-design/dist/terminal-markdown/parser.d.ts +5 -0
  311. package/node_modules/toolcraft-design/dist/terminal-markdown/parser.js +42 -0
  312. package/node_modules/toolcraft-design/dist/terminal-markdown/renderer.d.ts +6 -0
  313. package/node_modules/toolcraft-design/dist/terminal-markdown/renderer.js +615 -0
  314. package/node_modules/toolcraft-design/dist/terminal-markdown/testing/theme-render-fixture.d.ts +1 -0
  315. package/node_modules/toolcraft-design/dist/terminal-markdown/testing/theme-render-fixture.js +27 -0
  316. package/node_modules/toolcraft-design/dist/tokens/brand.d.ts +5 -0
  317. package/node_modules/toolcraft-design/dist/tokens/brand.js +5 -0
  318. package/node_modules/toolcraft-design/dist/tokens/colors.d.ts +37 -0
  319. package/node_modules/toolcraft-design/dist/tokens/colors.js +85 -0
  320. package/node_modules/toolcraft-design/dist/tokens/index.d.ts +6 -0
  321. package/node_modules/toolcraft-design/dist/tokens/index.js +5 -0
  322. package/node_modules/toolcraft-design/dist/tokens/spacing.d.ts +6 -0
  323. package/node_modules/toolcraft-design/dist/tokens/spacing.js +6 -0
  324. package/node_modules/toolcraft-design/dist/tokens/typography.d.ts +7 -0
  325. package/node_modules/toolcraft-design/dist/tokens/typography.js +8 -0
  326. package/node_modules/toolcraft-design/dist/tokens/widths.d.ts +5 -0
  327. package/node_modules/toolcraft-design/dist/tokens/widths.js +5 -0
  328. package/node_modules/toolcraft-design/package.json +44 -0
  329. package/package.json +15 -5
@@ -0,0 +1,101 @@
1
+ export class FakeTerminalDriver {
2
+ cols;
3
+ rows;
4
+ keyQueue = [];
5
+ writes = [];
6
+ flushes = [];
7
+ rawMode = false;
8
+ altScreen = false;
9
+ lineWrap = true;
10
+ cursorVisible = true;
11
+ destroyed = false;
12
+ enterAltScreenCount = 0;
13
+ exitAltScreenCount = 0;
14
+ enterRawModeCount = 0;
15
+ exitRawModeCount = 0;
16
+ keypressHandlers = new Set();
17
+ resizeHandlers = new Set();
18
+ constructor(cols = 120, rows = 24) {
19
+ this.cols = cols;
20
+ this.rows = rows;
21
+ }
22
+ get output() {
23
+ return this.writes.join("");
24
+ }
25
+ enterRawMode() {
26
+ this.rawMode = true;
27
+ this.enterRawModeCount += 1;
28
+ }
29
+ exitRawMode() {
30
+ this.rawMode = false;
31
+ this.exitRawModeCount += 1;
32
+ }
33
+ enterAltScreen() {
34
+ this.altScreen = true;
35
+ this.enterAltScreenCount += 1;
36
+ }
37
+ exitAltScreen() {
38
+ this.altScreen = false;
39
+ this.exitAltScreenCount += 1;
40
+ }
41
+ disableLineWrap() {
42
+ this.lineWrap = false;
43
+ }
44
+ enableLineWrap() {
45
+ this.lineWrap = true;
46
+ }
47
+ hideCursor() {
48
+ this.cursorVisible = false;
49
+ }
50
+ showCursor() {
51
+ this.cursorVisible = true;
52
+ }
53
+ moveTo(x, y) {
54
+ this.write(`\u001b[${Math.max(1, y + 1)};${Math.max(1, x + 1)}H`);
55
+ }
56
+ write(text) {
57
+ if (!this.destroyed) {
58
+ this.writes.push(text);
59
+ }
60
+ }
61
+ flush(changes) {
62
+ this.flushes.push(changes);
63
+ }
64
+ getSize() {
65
+ return { cols: this.cols, rows: this.rows };
66
+ }
67
+ resize(cols, rows) {
68
+ this.cols = cols;
69
+ this.rows = rows;
70
+ for (const handler of this.resizeHandlers) {
71
+ handler();
72
+ }
73
+ }
74
+ onResize(handler) {
75
+ this.resizeHandlers.add(handler);
76
+ return () => {
77
+ this.resizeHandlers.delete(handler);
78
+ };
79
+ }
80
+ onKeypress(handler) {
81
+ this.keypressHandlers.add(handler);
82
+ return () => {
83
+ this.keypressHandlers.delete(handler);
84
+ };
85
+ }
86
+ press(key) {
87
+ this.keyQueue.push(key);
88
+ for (const handler of this.keypressHandlers) {
89
+ handler(key);
90
+ }
91
+ }
92
+ destroy() {
93
+ this.destroyed = true;
94
+ this.rawMode = false;
95
+ this.lineWrap = true;
96
+ this.altScreen = false;
97
+ this.cursorVisible = true;
98
+ this.keypressHandlers.clear();
99
+ this.resizeHandlers.clear();
100
+ }
101
+ }
@@ -0,0 +1,137 @@
1
+ import { type ResolvedBindings } from "./keymap.js";
2
+ export type Tone = "success" | "warning" | "error" | "info" | "muted";
3
+ export interface Row {
4
+ id: string;
5
+ title: string;
6
+ subtitle?: string;
7
+ badge?: {
8
+ text: string;
9
+ tone?: Tone;
10
+ };
11
+ group?: string;
12
+ }
13
+ export interface DetailItem {
14
+ id: string;
15
+ title?: string;
16
+ subtitle?: string;
17
+ badge?: {
18
+ text: string;
19
+ tone?: Tone;
20
+ };
21
+ render: (ctx: DetailCtx) => string | Promise<string>;
22
+ renderedContent?: string;
23
+ }
24
+ export interface Detail<R> {
25
+ items: (row: Row, ctx: DetailCtx) => Promise<DetailItem[]>;
26
+ actions?: Action<R>[];
27
+ }
28
+ export interface DetailCtx {
29
+ width: number;
30
+ height: number;
31
+ signal: AbortSignal;
32
+ row: Row;
33
+ }
34
+ export interface Action<R> {
35
+ id: string;
36
+ label: string | (() => string);
37
+ key?: string | string[];
38
+ predicate?: (ctx: ActionContext<R>) => boolean;
39
+ handler: (ctx: ActionContext<R>) => void | Promise<void>;
40
+ destructive?: boolean;
41
+ primary?: boolean;
42
+ showInFooter?: boolean;
43
+ }
44
+ export interface ActionContext<R> {
45
+ row: Row;
46
+ rows: Row[];
47
+ item?: DetailItem;
48
+ filter: string;
49
+ refresh: () => Promise<void>;
50
+ suspendAnd: <T>(fn: () => Promise<T>) => Promise<T>;
51
+ toast: (msg: string, tone?: Tone) => void;
52
+ confirm: (prompt: string) => Promise<boolean>;
53
+ exit: (after?: () => void | Promise<void>) => void;
54
+ }
55
+ export interface ReorderContext {
56
+ refresh: () => Promise<void>;
57
+ toast: (msg: string, tone?: Tone) => void;
58
+ }
59
+ export interface ExplorerConfig<R> {
60
+ title: string;
61
+ rows: () => Promise<Row[]>;
62
+ refresh?: () => Promise<void>;
63
+ detail: Detail<R>;
64
+ actions: Action<R>[];
65
+ reorder?: {
66
+ onReorder: (orderedIds: string[], ctx?: ReorderContext) => void | Promise<void>;
67
+ };
68
+ multiSelect?: boolean;
69
+ keybindOverrides?: Record<string, string | string[]>;
70
+ emptyHint?: string;
71
+ initialFilter?: string;
72
+ }
73
+ export declare const REGION_HEADER: number;
74
+ export declare const REGION_LIST: number;
75
+ export declare const REGION_DETAIL: number;
76
+ export declare const REGION_FOOTER: number;
77
+ export declare const REGION_MODAL: number;
78
+ export declare const REGION_TOAST: number;
79
+ export declare const REGION_ALL: number;
80
+ export type Dirty = number;
81
+ export type ExplorerLayoutMode = "wide" | "medium" | "narrow-vertical" | "narrow-list-only" | "too-narrow";
82
+ export interface ExplorerSize {
83
+ cols: number;
84
+ rows: number;
85
+ }
86
+ export interface ExplorerState {
87
+ title: string;
88
+ emptyHint: string;
89
+ rows: Row[];
90
+ filtered: number[];
91
+ matchPositions: Map<number, number[]>;
92
+ cursor: number;
93
+ filter: string;
94
+ filterFocused: boolean;
95
+ focused: "list" | "detail";
96
+ detail: {
97
+ rowId: string | null;
98
+ items: DetailItem[] | null;
99
+ cursor: number;
100
+ scroll: number;
101
+ token: number;
102
+ loading: boolean;
103
+ };
104
+ selected: Set<string>;
105
+ multiSelect: boolean;
106
+ modal: null | {
107
+ kind: "help";
108
+ } | {
109
+ kind: "confirm";
110
+ action: Action<unknown>;
111
+ rows: Row[];
112
+ resolver: (ok: boolean) => void;
113
+ } | {
114
+ kind: "palette";
115
+ query: string;
116
+ cursor: number;
117
+ };
118
+ toast: {
119
+ message: string;
120
+ tone: Tone;
121
+ expiresAt: number;
122
+ } | null;
123
+ dirty: Dirty;
124
+ size: ExplorerSize;
125
+ layout: ExplorerLayoutMode;
126
+ bindings: ResolvedBindings;
127
+ actionState: Map<string, ActionStateEntry>;
128
+ }
129
+ export interface ActionStateEntry {
130
+ available: boolean;
131
+ label: string;
132
+ running?: boolean;
133
+ action?: Action<unknown>;
134
+ source?: "row" | "detail";
135
+ }
136
+ export declare function createInitialState<R>(config: ExplorerConfig<R>, size: ExplorerSize): ExplorerState;
137
+ export declare function resolveExplorerLayoutMode(cols: number): ExplorerLayoutMode;
@@ -0,0 +1,86 @@
1
+ import { resolveBindings } from "./keymap.js";
2
+ export const REGION_HEADER = 1 << 0;
3
+ export const REGION_LIST = 1 << 1;
4
+ export const REGION_DETAIL = 1 << 2;
5
+ export const REGION_FOOTER = 1 << 3;
6
+ export const REGION_MODAL = 1 << 4;
7
+ export const REGION_TOAST = 1 << 5;
8
+ export const REGION_ALL = REGION_HEADER |
9
+ REGION_LIST |
10
+ REGION_DETAIL |
11
+ REGION_FOOTER |
12
+ REGION_MODAL |
13
+ REGION_TOAST;
14
+ export function createInitialState(config, size) {
15
+ const normalizedSize = {
16
+ cols: normalizeSize(size.cols),
17
+ rows: normalizeSize(size.rows)
18
+ };
19
+ const multiSelect = config.multiSelect ?? true;
20
+ return {
21
+ title: config.title,
22
+ emptyHint: config.emptyHint ?? "No detail",
23
+ rows: [],
24
+ filtered: [],
25
+ matchPositions: new Map(),
26
+ cursor: 0,
27
+ filter: config.initialFilter ?? "",
28
+ filterFocused: false,
29
+ focused: "list",
30
+ detail: {
31
+ rowId: null,
32
+ items: null,
33
+ cursor: 0,
34
+ scroll: 0,
35
+ token: 0,
36
+ loading: false
37
+ },
38
+ selected: new Set(),
39
+ multiSelect,
40
+ modal: null,
41
+ toast: null,
42
+ dirty: REGION_ALL,
43
+ size: normalizedSize,
44
+ layout: resolveExplorerLayoutMode(normalizedSize.cols),
45
+ bindings: resolveBindings(config),
46
+ actionState: createInitialActionState(config)
47
+ };
48
+ }
49
+ function createInitialActionState(config) {
50
+ const state = new Map();
51
+ for (const [source, actions] of [["row", config.actions], ["detail", config.detail.actions ?? []]]) {
52
+ for (const action of actions) {
53
+ if (state.has(action.id)) {
54
+ throw new Error(`Duplicate explorer action id: ${action.id}`);
55
+ }
56
+ state.set(action.id, {
57
+ available: true,
58
+ label: typeof action.label === "function" ? action.id : action.label,
59
+ action: action,
60
+ source
61
+ });
62
+ }
63
+ }
64
+ return state;
65
+ }
66
+ export function resolveExplorerLayoutMode(cols) {
67
+ if (cols < 40) {
68
+ return "too-narrow";
69
+ }
70
+ if (cols < 80) {
71
+ return "narrow-list-only";
72
+ }
73
+ if (cols < 100) {
74
+ return "narrow-vertical";
75
+ }
76
+ if (cols < 120) {
77
+ return "medium";
78
+ }
79
+ return "wide";
80
+ }
81
+ function normalizeSize(value) {
82
+ if (!Number.isFinite(value)) {
83
+ return 0;
84
+ }
85
+ return Math.max(0, Math.floor(value));
86
+ }
@@ -0,0 +1,27 @@
1
+ import type { Tone } from "./state.js";
2
+ type CellStyle = {
3
+ fg?: string;
4
+ bg?: string;
5
+ bold?: boolean;
6
+ dim?: boolean;
7
+ underline?: boolean;
8
+ };
9
+ export interface ExplorerTheme {
10
+ accent: (text: string) => string;
11
+ muted: (text: string) => string;
12
+ border: (text: string) => string;
13
+ borderFocused: (text: string) => string;
14
+ badge: (text: string, tone: Tone) => string;
15
+ matchHighlight: (text: string) => string;
16
+ }
17
+ export interface ExplorerStyles {
18
+ accent: CellStyle;
19
+ muted: CellStyle;
20
+ border: CellStyle;
21
+ borderFocused: CellStyle;
22
+ matchHighlight: CellStyle;
23
+ tones: Record<Tone, CellStyle>;
24
+ }
25
+ export declare function getExplorerTheme(): ExplorerTheme;
26
+ export declare function getExplorerStyles(): ExplorerStyles;
27
+ export {};
@@ -0,0 +1,29 @@
1
+ import { getTheme } from "../internal/theme-detect.js";
2
+ export function getExplorerTheme() {
3
+ const theme = getTheme();
4
+ return {
5
+ accent: theme.accent,
6
+ muted: theme.muted,
7
+ border: theme.muted,
8
+ borderFocused: theme.accent,
9
+ badge: (text, tone) => theme[tone](` ${text} `),
10
+ matchHighlight: (text) => theme.accent(`\u001b[4m${text}\u001b[24m`)
11
+ };
12
+ }
13
+ export function getExplorerStyles() {
14
+ const styles = getTheme().styles;
15
+ return {
16
+ accent: styles.accent,
17
+ muted: styles.muted,
18
+ border: styles.muted,
19
+ borderFocused: styles.accent,
20
+ matchHighlight: { ...styles.accent, underline: true },
21
+ tones: {
22
+ success: styles.success,
23
+ warning: styles.warning,
24
+ error: styles.error,
25
+ info: styles.info,
26
+ muted: styles.muted
27
+ }
28
+ };
29
+ }
@@ -0,0 +1,50 @@
1
+ export * as tokens from "./tokens/index.js";
2
+ export { brand, dark, light } from "./tokens/colors.js";
3
+ export { brands } from "./tokens/brand.js";
4
+ export type { Brand } from "./tokens/brand.js";
5
+ export type { ThemeName, ThemePalette } from "./tokens/colors.js";
6
+ export { spacing } from "./tokens/spacing.js";
7
+ export { typography } from "./tokens/typography.js";
8
+ export { widths } from "./tokens/widths.js";
9
+ export { text } from "./components/text.js";
10
+ export { color } from "./components/color.js";
11
+ export type { Color } from "./components/color.js";
12
+ export { symbols } from "./components/symbols.js";
13
+ export { createLogger, logger } from "./components/logger.js";
14
+ export type { LoggerOutput } from "./components/logger.js";
15
+ export { helpFormatter, formatColumns, formatCommand, formatUsage, formatOption, formatCommandList, formatOptionList } from "./components/help-formatter.js";
16
+ export * as helpFormatterPlain from "./components/help-formatter-plain.js";
17
+ export type { CommandInfo, OptionInfo, FormatColumnsOptions } from "./components/help-formatter.js";
18
+ export { formatCommandNotFound } from "./components/command-errors.js";
19
+ export { formatCommandNotFoundPanel } from "./components/command-errors.js";
20
+ export { renderTable } from "./components/table.js";
21
+ export type { TableColumn, RenderTableOptions } from "./components/table.js";
22
+ export { renderCatalog } from "./components/catalog.js";
23
+ export type { CatalogGroup, CatalogItem, CatalogMetric, CatalogTone, RenderCatalogOptions } from "./components/catalog.js";
24
+ export { renderDetailCard } from "./components/detail-card.js";
25
+ export type { DetailCardRow, DetailCardSection, RenderDetailCardOptions } from "./components/detail-card.js";
26
+ export { getTemplatePartialNames, renderTemplate, resolveTemplatePartials } from "./components/template.js";
27
+ export type { RenderTemplateOptions, TemplateEscape } from "./components/template.js";
28
+ export { openExternal } from "./components/browser.js";
29
+ export * as acp from "./acp/index.js";
30
+ export * as dashboard from "./dashboard/index.js";
31
+ export { createDashboard, shouldUseInteractiveDashboard } from "./dashboard/index.js";
32
+ export type { Dashboard, DashboardOptions } from "./dashboard/index.js";
33
+ export * as explorer from "./explorer/index.js";
34
+ export { runExplorer, singleDetail } from "./explorer/index.js";
35
+ export type { Row, DetailItem, Detail, DetailCtx, Action, ActionContext, ExplorerConfig, ReorderContext, Tone } from "./explorer/index.js";
36
+ export * as prompts from "./prompts/index.js";
37
+ export { intro, introPlain, outro, note, select, multiselect, text as promptText, confirm, confirmOrCancel, password, spinner, withSpinner, isCancel, cancel, log, PromptCancelledError } from "./prompts/index.js";
38
+ export type { SelectOptions, MultiselectOptions, TextOptions, ConfirmOptions, PasswordOptions, SpinnerOptions, WithSpinnerOptions } from "./prompts/index.js";
39
+ export { promptTheme } from "./prompts/theme.js";
40
+ export * as staticRender from "./static/index.js";
41
+ export { SPINNER_FRAMES, renderSpinnerFrame, renderSpinnerStopped, renderMenu } from "./static/index.js";
42
+ export type { SpinnerFrameOptions, SpinnerStoppedOptions, MenuOption, RenderMenuOptions } from "./static/index.js";
43
+ export { parse, render, renderMarkdown } from "./terminal-markdown/index.js";
44
+ export type { MdNode, RenderOptions } from "./terminal-markdown/index.js";
45
+ export { getTheme, resolveThemeName, resetThemeCache } from "./internal/theme-detect.js";
46
+ export type { ThemeEnv } from "./internal/theme-detect.js";
47
+ export { configureTheme, getThemeConfig, resetTheme } from "./internal/theme-state.js";
48
+ export { stripAnsi } from "./internal/strip-ansi.js";
49
+ export { resolveOutputFormat, resetOutputFormatCache, withOutputFormat } from "./internal/output-format.js";
50
+ export type { OutputFormat } from "./internal/output-format.js";
@@ -0,0 +1,43 @@
1
+ // Tokens
2
+ export * as tokens from "./tokens/index.js";
3
+ export { brand, dark, light } from "./tokens/colors.js";
4
+ export { brands } from "./tokens/brand.js";
5
+ export { spacing } from "./tokens/spacing.js";
6
+ export { typography } from "./tokens/typography.js";
7
+ export { widths } from "./tokens/widths.js";
8
+ // Components
9
+ export { text } from "./components/text.js";
10
+ export { color } from "./components/color.js";
11
+ export { symbols } from "./components/symbols.js";
12
+ export { createLogger, logger } from "./components/logger.js";
13
+ export { helpFormatter, formatColumns, formatCommand, formatUsage, formatOption, formatCommandList, formatOptionList } from "./components/help-formatter.js";
14
+ export * as helpFormatterPlain from "./components/help-formatter-plain.js";
15
+ export { formatCommandNotFound } from "./components/command-errors.js";
16
+ export { formatCommandNotFoundPanel } from "./components/command-errors.js";
17
+ export { renderTable } from "./components/table.js";
18
+ export { renderCatalog } from "./components/catalog.js";
19
+ export { renderDetailCard } from "./components/detail-card.js";
20
+ export { getTemplatePartialNames, renderTemplate, resolveTemplatePartials } from "./components/template.js";
21
+ export { openExternal } from "./components/browser.js";
22
+ // ACP rendering
23
+ export * as acp from "./acp/index.js";
24
+ // Dashboard
25
+ export * as dashboard from "./dashboard/index.js";
26
+ export { createDashboard, shouldUseInteractiveDashboard } from "./dashboard/index.js";
27
+ // Explorer
28
+ export * as explorer from "./explorer/index.js";
29
+ export { runExplorer, singleDetail } from "./explorer/index.js";
30
+ // Prompts
31
+ export * as prompts from "./prompts/index.js";
32
+ export { intro, introPlain, outro, note, select, multiselect, text as promptText, confirm, confirmOrCancel, password, spinner, withSpinner, isCancel, cancel, log, PromptCancelledError } from "./prompts/index.js";
33
+ export { promptTheme } from "./prompts/theme.js";
34
+ // Static rendering
35
+ export * as staticRender from "./static/index.js";
36
+ export { SPINNER_FRAMES, renderSpinnerFrame, renderSpinnerStopped, renderMenu } from "./static/index.js";
37
+ // Terminal markdown
38
+ export { parse, render, renderMarkdown } from "./terminal-markdown/index.js";
39
+ // Internal utilities (for advanced use)
40
+ export { getTheme, resolveThemeName, resetThemeCache } from "./internal/theme-detect.js";
41
+ export { configureTheme, getThemeConfig, resetTheme } from "./internal/theme-state.js";
42
+ export { stripAnsi } from "./internal/strip-ansi.js";
43
+ export { resolveOutputFormat, resetOutputFormatCache, withOutputFormat } from "./internal/output-format.js";
@@ -0,0 +1,9 @@
1
+ export interface ColorSupportEnv {
2
+ NO_COLOR?: string;
3
+ FORCE_COLOR?: string;
4
+ TERM?: string;
5
+ }
6
+ export interface ColorSupportStream {
7
+ isTTY?: boolean;
8
+ }
9
+ export declare function supportsColor(env?: ColorSupportEnv, stream?: ColorSupportStream): boolean;
@@ -0,0 +1,12 @@
1
+ export function supportsColor(env = process.env, stream = process.stdout) {
2
+ if (env.FORCE_COLOR !== undefined && env.FORCE_COLOR !== "0") {
3
+ return true;
4
+ }
5
+ if (env.NO_COLOR !== undefined) {
6
+ return false;
7
+ }
8
+ if (stream.isTTY !== true) {
9
+ return false;
10
+ }
11
+ return typeof env.TERM === "string" && env.TERM.length > 0 && env.TERM !== "dumb";
12
+ }
@@ -0,0 +1,6 @@
1
+ export type OutputFormat = "terminal" | "markdown" | "json";
2
+ export declare function resolveOutputFormat(env?: {
3
+ OUTPUT_FORMAT?: string;
4
+ }): OutputFormat;
5
+ export declare function withOutputFormat<T>(format: OutputFormat, fn: () => T): T;
6
+ export declare function resetOutputFormatCache(): void;
@@ -0,0 +1,22 @@
1
+ import { AsyncLocalStorage } from "node:async_hooks";
2
+ const VALID_FORMATS = new Set(["terminal", "markdown", "json"]);
3
+ const formatStorage = new AsyncLocalStorage();
4
+ let cached;
5
+ export function resolveOutputFormat(env = process.env) {
6
+ const scoped = formatStorage.getStore();
7
+ if (scoped) {
8
+ return scoped;
9
+ }
10
+ if (cached) {
11
+ return cached;
12
+ }
13
+ const raw = env.OUTPUT_FORMAT?.toLowerCase();
14
+ cached = VALID_FORMATS.has(raw) ? raw : "terminal";
15
+ return cached;
16
+ }
17
+ export function withOutputFormat(format, fn) {
18
+ return formatStorage.run(format, fn);
19
+ }
20
+ export function resetOutputFormatCache() {
21
+ cached = undefined;
22
+ }
@@ -0,0 +1 @@
1
+ export declare function stripAnsi(value: string): string;
@@ -0,0 +1,50 @@
1
+ export function stripAnsi(value) {
2
+ let output = "";
3
+ let index = 0;
4
+ while (index < value.length) {
5
+ const char = value[index];
6
+ if (char === "\u001b") {
7
+ index = skipEscapeSequence(value, index);
8
+ continue;
9
+ }
10
+ if (char === "\u009b") {
11
+ index = skipCsiSequence(value, index + 1);
12
+ continue;
13
+ }
14
+ output += char;
15
+ index += char.length;
16
+ }
17
+ return output;
18
+ }
19
+ function skipEscapeSequence(value, index) {
20
+ const next = value[index + 1];
21
+ if (next === "[") {
22
+ return skipCsiSequence(value, index + 2);
23
+ }
24
+ if (next === "]") {
25
+ return skipOscSequence(value, index + 2);
26
+ }
27
+ return Math.min(value.length, index + 2);
28
+ }
29
+ function skipCsiSequence(value, index) {
30
+ while (index < value.length) {
31
+ const codePoint = value.charCodeAt(index);
32
+ index += 1;
33
+ if (codePoint >= 0x40 && codePoint <= 0x7e) {
34
+ break;
35
+ }
36
+ }
37
+ return index;
38
+ }
39
+ function skipOscSequence(value, index) {
40
+ while (index < value.length) {
41
+ if (value[index] === "\u0007") {
42
+ return index + 1;
43
+ }
44
+ if (value[index] === "\u001b" && value[index + 1] === "\\") {
45
+ return index + 2;
46
+ }
47
+ index += 1;
48
+ }
49
+ return index;
50
+ }
@@ -0,0 +1,12 @@
1
+ import { type ThemeName, type ThemePalette } from "../tokens/colors.js";
2
+ export interface ThemeEnv {
3
+ POE_CODE_THEME?: string;
4
+ POE_THEME?: string;
5
+ POE_BRAND?: string;
6
+ APPLE_INTERFACE_STYLE?: string;
7
+ VSCODE_COLOR_THEME_KIND?: string;
8
+ COLORFGBG?: string;
9
+ }
10
+ export declare function resolveThemeName(env?: ThemeEnv): ThemeName;
11
+ export declare function getTheme(env?: ThemeEnv): ThemePalette;
12
+ export declare function resetThemeCache(): void;
@@ -0,0 +1,71 @@
1
+ import { getThemeConfig, getThemeRevision, isThemeBrandConfigured } from "./theme-state.js";
2
+ import { brands } from "../tokens/brand.js";
3
+ import { createPalette, dark, light } from "../tokens/colors.js";
4
+ function detectThemeFromEnv(env) {
5
+ const apple = env.APPLE_INTERFACE_STYLE;
6
+ if (typeof apple === "string") {
7
+ return apple.toLowerCase() === "dark" ? "dark" : "light";
8
+ }
9
+ const vscodeKind = env.VSCODE_COLOR_THEME_KIND;
10
+ if (typeof vscodeKind === "string") {
11
+ const normalized = vscodeKind.toLowerCase();
12
+ if (normalized.includes("light")) {
13
+ return "light";
14
+ }
15
+ if (normalized.includes("dark")) {
16
+ return "dark";
17
+ }
18
+ }
19
+ const colorFGBG = env.COLORFGBG;
20
+ if (typeof colorFGBG === "string") {
21
+ const parts = colorFGBG.split(";").map((part) => Number.parseInt(part, 10));
22
+ const background = parts.at(-1);
23
+ if (Number.isFinite(background)) {
24
+ return background >= 8 ? "light" : "dark";
25
+ }
26
+ }
27
+ return undefined;
28
+ }
29
+ export function resolveThemeName(env = process.env) {
30
+ const raw = (env.POE_CODE_THEME ?? env.POE_THEME)?.toLowerCase();
31
+ if (raw === "light" || raw === "dark") {
32
+ return raw;
33
+ }
34
+ const detected = detectThemeFromEnv(env);
35
+ if (detected) {
36
+ return detected;
37
+ }
38
+ return "dark";
39
+ }
40
+ const themeCache = new Map();
41
+ let cachedRevision = -1;
42
+ export function getTheme(env) {
43
+ const themeName = resolveThemeName(env);
44
+ const config = getThemeConfig();
45
+ const requestedBrand = env?.POE_BRAND?.toLowerCase();
46
+ const activeBrandName = !isThemeBrandConfigured() && requestedBrand && Object.hasOwn(brands, requestedBrand)
47
+ ? requestedBrand
48
+ : config.brand;
49
+ const revision = getThemeRevision();
50
+ if (revision !== cachedRevision) {
51
+ themeCache.clear();
52
+ cachedRevision = revision;
53
+ }
54
+ const cacheKey = `${activeBrandName}:${themeName}`;
55
+ const cachedTheme = themeCache.get(cacheKey);
56
+ if (cachedTheme) {
57
+ return cachedTheme;
58
+ }
59
+ const activeBrand = brands[activeBrandName];
60
+ const theme = activeBrandName === "purple"
61
+ ? themeName === "light"
62
+ ? light
63
+ : dark
64
+ : createPalette(activeBrand, themeName);
65
+ themeCache.set(cacheKey, theme);
66
+ return theme;
67
+ }
68
+ export function resetThemeCache() {
69
+ themeCache.clear();
70
+ cachedRevision = getThemeRevision();
71
+ }