gsd-pi 2.34.0 → 2.35.0-dev.34ce717

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 (510) hide show
  1. package/README.md +3 -1
  2. package/dist/cli.js +7 -2
  3. package/dist/resource-loader.d.ts +1 -1
  4. package/dist/resource-loader.js +13 -1
  5. package/dist/resources/extensions/async-jobs/await-tool.js +0 -2
  6. package/dist/resources/extensions/async-jobs/job-manager.js +0 -6
  7. package/dist/resources/extensions/bg-shell/output-formatter.js +1 -19
  8. package/dist/resources/extensions/bg-shell/process-manager.js +0 -4
  9. package/dist/resources/extensions/bg-shell/types.js +0 -2
  10. package/dist/resources/extensions/context7/index.js +5 -0
  11. package/dist/resources/extensions/get-secrets-from-user.js +2 -30
  12. package/dist/resources/extensions/google-search/index.js +5 -0
  13. package/dist/resources/extensions/gsd/auto-dispatch.js +43 -1
  14. package/dist/resources/extensions/gsd/auto-loop.js +17 -3
  15. package/dist/resources/extensions/gsd/auto-model-selection.js +15 -3
  16. package/dist/resources/extensions/gsd/auto-recovery.js +35 -0
  17. package/dist/resources/extensions/gsd/auto-start.js +35 -2
  18. package/dist/resources/extensions/gsd/auto.js +59 -4
  19. package/dist/resources/extensions/gsd/changelog.js +162 -0
  20. package/dist/resources/extensions/gsd/commands-bootstrap.js +1 -0
  21. package/dist/resources/extensions/gsd/commands-handlers.js +2 -2
  22. package/dist/resources/extensions/gsd/commands-inspect.js +10 -3
  23. package/dist/resources/extensions/gsd/commands-prefs-wizard.js +5 -1
  24. package/dist/resources/extensions/gsd/commands-rate.js +31 -0
  25. package/dist/resources/extensions/gsd/commands.js +51 -2
  26. package/dist/resources/extensions/gsd/docs/preferences-reference.md +10 -0
  27. package/dist/resources/extensions/gsd/doctor-checks.js +113 -5
  28. package/dist/resources/extensions/gsd/doctor-environment.js +26 -17
  29. package/dist/resources/extensions/gsd/doctor-proactive.js +22 -0
  30. package/dist/resources/extensions/gsd/doctor.js +36 -0
  31. package/dist/resources/extensions/gsd/files.js +11 -2
  32. package/dist/resources/extensions/gsd/gitignore.js +54 -7
  33. package/dist/resources/extensions/gsd/guided-flow.js +12 -4
  34. package/dist/resources/extensions/gsd/health-widget-core.js +96 -0
  35. package/dist/resources/extensions/gsd/health-widget.js +97 -46
  36. package/dist/resources/extensions/gsd/index.js +26 -33
  37. package/dist/resources/extensions/gsd/migrate-external.js +55 -2
  38. package/dist/resources/extensions/gsd/milestone-ids.js +3 -2
  39. package/dist/resources/extensions/gsd/paths.js +74 -7
  40. package/dist/resources/extensions/gsd/post-unit-hooks.js +4 -1
  41. package/dist/resources/extensions/gsd/preferences-validation.js +54 -1
  42. package/dist/resources/extensions/gsd/preferences.js +14 -0
  43. package/dist/resources/extensions/gsd/prompts/complete-milestone.md +2 -0
  44. package/dist/resources/extensions/gsd/prompts/validate-milestone.md +2 -0
  45. package/dist/resources/extensions/gsd/roadmap-mutations.js +55 -0
  46. package/dist/resources/extensions/gsd/session-lock.js +53 -2
  47. package/dist/resources/extensions/gsd/state.js +2 -1
  48. package/dist/resources/extensions/gsd/templates/plan.md +8 -0
  49. package/dist/resources/extensions/gsd/worktree-resolver.js +12 -0
  50. package/dist/resources/extensions/mcp-client/index.js +2 -1
  51. package/dist/resources/extensions/remote-questions/remote-command.js +2 -22
  52. package/dist/resources/extensions/shared/mod.js +1 -1
  53. package/dist/resources/extensions/shared/sanitize.js +30 -0
  54. package/dist/resources/extensions/subagent/index.js +6 -14
  55. package/dist/resources/skills/create-gsd-extension/references/events-reference.md +4 -4
  56. package/package.json +2 -1
  57. package/packages/native/dist/native.d.ts +0 -2
  58. package/packages/native/dist/native.js +0 -2
  59. package/packages/native/src/native.ts +0 -3
  60. package/packages/pi-agent-core/dist/agent-loop.d.ts +14 -0
  61. package/packages/pi-agent-core/dist/agent-loop.d.ts.map +1 -1
  62. package/packages/pi-agent-core/dist/agent-loop.js +24 -27
  63. package/packages/pi-agent-core/dist/agent-loop.js.map +1 -1
  64. package/packages/pi-agent-core/dist/agent.d.ts +1 -0
  65. package/packages/pi-agent-core/dist/agent.d.ts.map +1 -1
  66. package/packages/pi-agent-core/dist/agent.js +11 -22
  67. package/packages/pi-agent-core/dist/agent.js.map +1 -1
  68. package/packages/pi-agent-core/dist/proxy.d.ts +1 -25
  69. package/packages/pi-agent-core/dist/proxy.d.ts.map +1 -1
  70. package/packages/pi-agent-core/dist/proxy.js +3 -9
  71. package/packages/pi-agent-core/dist/proxy.js.map +1 -1
  72. package/packages/pi-agent-core/src/agent-loop.ts +30 -27
  73. package/packages/pi-agent-core/src/agent.ts +12 -23
  74. package/packages/pi-agent-core/src/proxy.ts +3 -9
  75. package/packages/pi-ai/dist/api-registry.d.ts +0 -2
  76. package/packages/pi-ai/dist/api-registry.d.ts.map +1 -1
  77. package/packages/pi-ai/dist/api-registry.js +0 -10
  78. package/packages/pi-ai/dist/api-registry.js.map +1 -1
  79. package/packages/pi-ai/dist/providers/anthropic.d.ts +0 -8
  80. package/packages/pi-ai/dist/providers/anthropic.d.ts.map +1 -1
  81. package/packages/pi-ai/dist/providers/anthropic.js +1 -1
  82. package/packages/pi-ai/dist/providers/anthropic.js.map +1 -1
  83. package/packages/pi-ai/dist/providers/azure-openai-responses.d.ts.map +1 -1
  84. package/packages/pi-ai/dist/providers/azure-openai-responses.js +5 -41
  85. package/packages/pi-ai/dist/providers/azure-openai-responses.js.map +1 -1
  86. package/packages/pi-ai/dist/providers/github-copilot-headers.d.ts +0 -1
  87. package/packages/pi-ai/dist/providers/github-copilot-headers.d.ts.map +1 -1
  88. package/packages/pi-ai/dist/providers/github-copilot-headers.js +1 -1
  89. package/packages/pi-ai/dist/providers/github-copilot-headers.js.map +1 -1
  90. package/packages/pi-ai/dist/providers/google-gemini-cli.d.ts +1 -43
  91. package/packages/pi-ai/dist/providers/google-gemini-cli.d.ts.map +1 -1
  92. package/packages/pi-ai/dist/providers/google-gemini-cli.js +2 -2
  93. package/packages/pi-ai/dist/providers/google-gemini-cli.js.map +1 -1
  94. package/packages/pi-ai/dist/providers/google-shared.d.ts +0 -4
  95. package/packages/pi-ai/dist/providers/google-shared.d.ts.map +1 -1
  96. package/packages/pi-ai/dist/providers/google-shared.js +1 -1
  97. package/packages/pi-ai/dist/providers/google-shared.js.map +1 -1
  98. package/packages/pi-ai/dist/providers/openai-completions.d.ts.map +1 -1
  99. package/packages/pi-ai/dist/providers/openai-completions.js +10 -73
  100. package/packages/pi-ai/dist/providers/openai-completions.js.map +1 -1
  101. package/packages/pi-ai/dist/providers/openai-responses.d.ts.map +1 -1
  102. package/packages/pi-ai/dist/providers/openai-responses.js +9 -80
  103. package/packages/pi-ai/dist/providers/openai-responses.js.map +1 -1
  104. package/packages/pi-ai/dist/providers/openai-shared.d.ts +65 -0
  105. package/packages/pi-ai/dist/providers/openai-shared.d.ts.map +1 -0
  106. package/packages/pi-ai/dist/providers/openai-shared.js +146 -0
  107. package/packages/pi-ai/dist/providers/openai-shared.js.map +1 -0
  108. package/packages/pi-ai/dist/providers/register-builtins.d.ts +0 -1
  109. package/packages/pi-ai/dist/providers/register-builtins.d.ts.map +1 -1
  110. package/packages/pi-ai/dist/providers/register-builtins.js +1 -1
  111. package/packages/pi-ai/dist/providers/register-builtins.js.map +1 -1
  112. package/packages/pi-ai/dist/utils/event-stream.d.ts +0 -2
  113. package/packages/pi-ai/dist/utils/event-stream.d.ts.map +1 -1
  114. package/packages/pi-ai/dist/utils/event-stream.js +0 -4
  115. package/packages/pi-ai/dist/utils/event-stream.js.map +1 -1
  116. package/packages/pi-ai/dist/utils/oauth/google-antigravity.d.ts.map +1 -1
  117. package/packages/pi-ai/dist/utils/oauth/google-antigravity.js +7 -135
  118. package/packages/pi-ai/dist/utils/oauth/google-antigravity.js.map +1 -1
  119. package/packages/pi-ai/dist/utils/oauth/google-gemini-cli.d.ts.map +1 -1
  120. package/packages/pi-ai/dist/utils/oauth/google-gemini-cli.js +7 -135
  121. package/packages/pi-ai/dist/utils/oauth/google-gemini-cli.js.map +1 -1
  122. package/packages/pi-ai/dist/utils/oauth/google-oauth-utils.d.ts +46 -0
  123. package/packages/pi-ai/dist/utils/oauth/google-oauth-utils.d.ts.map +1 -0
  124. package/packages/pi-ai/dist/utils/oauth/google-oauth-utils.js +160 -0
  125. package/packages/pi-ai/dist/utils/oauth/google-oauth-utils.js.map +1 -0
  126. package/packages/pi-ai/dist/utils/overflow.d.ts +0 -4
  127. package/packages/pi-ai/dist/utils/overflow.d.ts.map +1 -1
  128. package/packages/pi-ai/dist/utils/overflow.js +0 -6
  129. package/packages/pi-ai/dist/utils/overflow.js.map +1 -1
  130. package/packages/pi-ai/dist/utils/validation.d.ts +0 -8
  131. package/packages/pi-ai/dist/utils/validation.d.ts.map +1 -1
  132. package/packages/pi-ai/dist/utils/validation.js +0 -14
  133. package/packages/pi-ai/dist/utils/validation.js.map +1 -1
  134. package/packages/pi-ai/src/api-registry.ts +0 -12
  135. package/packages/pi-ai/src/providers/anthropic.ts +1 -1
  136. package/packages/pi-ai/src/providers/azure-openai-responses.ts +11 -45
  137. package/packages/pi-ai/src/providers/github-copilot-headers.ts +1 -1
  138. package/packages/pi-ai/src/providers/google-gemini-cli.ts +2 -2
  139. package/packages/pi-ai/src/providers/google-shared.ts +1 -1
  140. package/packages/pi-ai/src/providers/openai-completions.ts +16 -86
  141. package/packages/pi-ai/src/providers/openai-responses.ts +16 -96
  142. package/packages/pi-ai/src/providers/openai-shared.ts +193 -0
  143. package/packages/pi-ai/src/providers/register-builtins.ts +1 -1
  144. package/packages/pi-ai/src/utils/event-stream.ts +0 -5
  145. package/packages/pi-ai/src/utils/oauth/google-antigravity.ts +14 -162
  146. package/packages/pi-ai/src/utils/oauth/google-gemini-cli.ts +13 -161
  147. package/packages/pi-ai/src/utils/oauth/google-oauth-utils.ts +201 -0
  148. package/packages/pi-ai/src/utils/overflow.ts +1 -8
  149. package/packages/pi-ai/src/utils/validation.ts +0 -15
  150. package/packages/pi-coding-agent/dist/config.d.ts +0 -9
  151. package/packages/pi-coding-agent/dist/config.d.ts.map +1 -1
  152. package/packages/pi-coding-agent/dist/config.js +4 -8
  153. package/packages/pi-coding-agent/dist/config.js.map +1 -1
  154. package/packages/pi-coding-agent/dist/core/agent-session.d.ts +16 -63
  155. package/packages/pi-coding-agent/dist/core/agent-session.d.ts.map +1 -1
  156. package/packages/pi-coding-agent/dist/core/agent-session.js +104 -641
  157. package/packages/pi-coding-agent/dist/core/agent-session.js.map +1 -1
  158. package/packages/pi-coding-agent/dist/core/auth-storage.d.ts +0 -1
  159. package/packages/pi-coding-agent/dist/core/auth-storage.d.ts.map +1 -1
  160. package/packages/pi-coding-agent/dist/core/auth-storage.js +4 -35
  161. package/packages/pi-coding-agent/dist/core/auth-storage.js.map +1 -1
  162. package/packages/pi-coding-agent/dist/core/compaction/branch-summarization.d.ts.map +1 -1
  163. package/packages/pi-coding-agent/dist/core/compaction/branch-summarization.js +5 -43
  164. package/packages/pi-coding-agent/dist/core/compaction/branch-summarization.js.map +1 -1
  165. package/packages/pi-coding-agent/dist/core/compaction/compaction.d.ts.map +1 -1
  166. package/packages/pi-coding-agent/dist/core/compaction/compaction.js +11 -69
  167. package/packages/pi-coding-agent/dist/core/compaction/compaction.js.map +1 -1
  168. package/packages/pi-coding-agent/dist/core/compaction/utils.d.ts +40 -0
  169. package/packages/pi-coding-agent/dist/core/compaction/utils.d.ts.map +1 -1
  170. package/packages/pi-coding-agent/dist/core/compaction/utils.js +78 -0
  171. package/packages/pi-coding-agent/dist/core/compaction/utils.js.map +1 -1
  172. package/packages/pi-coding-agent/dist/core/compaction-orchestrator.d.ts +77 -0
  173. package/packages/pi-coding-agent/dist/core/compaction-orchestrator.d.ts.map +1 -0
  174. package/packages/pi-coding-agent/dist/core/compaction-orchestrator.js +331 -0
  175. package/packages/pi-coding-agent/dist/core/compaction-orchestrator.js.map +1 -0
  176. package/packages/pi-coding-agent/dist/core/export-html/ansi-to-html.d.ts +0 -4
  177. package/packages/pi-coding-agent/dist/core/export-html/ansi-to-html.d.ts.map +1 -1
  178. package/packages/pi-coding-agent/dist/core/export-html/ansi-to-html.js +1 -1
  179. package/packages/pi-coding-agent/dist/core/export-html/ansi-to-html.js.map +1 -1
  180. package/packages/pi-coding-agent/dist/core/extensions/index.d.ts +2 -2
  181. package/packages/pi-coding-agent/dist/core/extensions/index.d.ts.map +1 -1
  182. package/packages/pi-coding-agent/dist/core/extensions/index.js +1 -1
  183. package/packages/pi-coding-agent/dist/core/extensions/index.js.map +1 -1
  184. package/packages/pi-coding-agent/dist/core/extensions/runner.d.ts +15 -5
  185. package/packages/pi-coding-agent/dist/core/extensions/runner.d.ts.map +1 -1
  186. package/packages/pi-coding-agent/dist/core/extensions/runner.js +129 -256
  187. package/packages/pi-coding-agent/dist/core/extensions/runner.js.map +1 -1
  188. package/packages/pi-coding-agent/dist/core/extensions/types.d.ts +49 -42
  189. package/packages/pi-coding-agent/dist/core/extensions/types.d.ts.map +1 -1
  190. package/packages/pi-coding-agent/dist/core/extensions/types.js +2 -21
  191. package/packages/pi-coding-agent/dist/core/extensions/types.js.map +1 -1
  192. package/packages/pi-coding-agent/dist/core/keybindings.d.ts +0 -8
  193. package/packages/pi-coding-agent/dist/core/keybindings.d.ts.map +1 -1
  194. package/packages/pi-coding-agent/dist/core/keybindings.js +2 -2
  195. package/packages/pi-coding-agent/dist/core/keybindings.js.map +1 -1
  196. package/packages/pi-coding-agent/dist/core/lock-utils.d.ts +39 -0
  197. package/packages/pi-coding-agent/dist/core/lock-utils.d.ts.map +1 -0
  198. package/packages/pi-coding-agent/dist/core/lock-utils.js +89 -0
  199. package/packages/pi-coding-agent/dist/core/lock-utils.js.map +1 -0
  200. package/packages/pi-coding-agent/dist/core/lsp/client.d.ts +0 -17
  201. package/packages/pi-coding-agent/dist/core/lsp/client.d.ts.map +1 -1
  202. package/packages/pi-coding-agent/dist/core/lsp/client.js +3 -62
  203. package/packages/pi-coding-agent/dist/core/lsp/client.js.map +1 -1
  204. package/packages/pi-coding-agent/dist/core/lsp/config.d.ts +1 -1
  205. package/packages/pi-coding-agent/dist/core/lsp/config.d.ts.map +1 -1
  206. package/packages/pi-coding-agent/dist/core/lsp/config.js +2 -6
  207. package/packages/pi-coding-agent/dist/core/lsp/config.js.map +1 -1
  208. package/packages/pi-coding-agent/dist/core/lsp/edits.d.ts +0 -5
  209. package/packages/pi-coding-agent/dist/core/lsp/edits.d.ts.map +1 -1
  210. package/packages/pi-coding-agent/dist/core/lsp/edits.js +1 -1
  211. package/packages/pi-coding-agent/dist/core/lsp/edits.js.map +1 -1
  212. package/packages/pi-coding-agent/dist/core/lsp/index.d.ts.map +1 -1
  213. package/packages/pi-coding-agent/dist/core/lsp/index.js +52 -107
  214. package/packages/pi-coding-agent/dist/core/lsp/index.js.map +1 -1
  215. package/packages/pi-coding-agent/dist/core/lsp/lspmux.d.ts +0 -1
  216. package/packages/pi-coding-agent/dist/core/lsp/lspmux.d.ts.map +1 -1
  217. package/packages/pi-coding-agent/dist/core/lsp/lspmux.js +3 -22
  218. package/packages/pi-coding-agent/dist/core/lsp/lspmux.js.map +1 -1
  219. package/packages/pi-coding-agent/dist/core/lsp/types.d.ts +0 -1
  220. package/packages/pi-coding-agent/dist/core/lsp/types.d.ts.map +1 -1
  221. package/packages/pi-coding-agent/dist/core/lsp/types.js +0 -28
  222. package/packages/pi-coding-agent/dist/core/lsp/types.js.map +1 -1
  223. package/packages/pi-coding-agent/dist/core/lsp/utils.d.ts +1 -6
  224. package/packages/pi-coding-agent/dist/core/lsp/utils.d.ts.map +1 -1
  225. package/packages/pi-coding-agent/dist/core/lsp/utils.js +1 -28
  226. package/packages/pi-coding-agent/dist/core/lsp/utils.js.map +1 -1
  227. package/packages/pi-coding-agent/dist/core/messages.d.ts +0 -8
  228. package/packages/pi-coding-agent/dist/core/messages.d.ts.map +1 -1
  229. package/packages/pi-coding-agent/dist/core/messages.js +5 -5
  230. package/packages/pi-coding-agent/dist/core/messages.js.map +1 -1
  231. package/packages/pi-coding-agent/dist/core/model-registry.d.ts +0 -3
  232. package/packages/pi-coding-agent/dist/core/model-registry.d.ts.map +1 -1
  233. package/packages/pi-coding-agent/dist/core/model-registry.js +1 -3
  234. package/packages/pi-coding-agent/dist/core/model-registry.js.map +1 -1
  235. package/packages/pi-coding-agent/dist/core/model-resolver.d.ts +1 -26
  236. package/packages/pi-coding-agent/dist/core/model-resolver.d.ts.map +1 -1
  237. package/packages/pi-coding-agent/dist/core/model-resolver.js +3 -59
  238. package/packages/pi-coding-agent/dist/core/model-resolver.js.map +1 -1
  239. package/packages/pi-coding-agent/dist/core/package-manager.d.ts.map +1 -1
  240. package/packages/pi-coding-agent/dist/core/package-manager.js +2 -4
  241. package/packages/pi-coding-agent/dist/core/package-manager.js.map +1 -1
  242. package/packages/pi-coding-agent/dist/core/prompt-templates.d.ts +0 -17
  243. package/packages/pi-coding-agent/dist/core/prompt-templates.d.ts.map +1 -1
  244. package/packages/pi-coding-agent/dist/core/prompt-templates.js +2 -2
  245. package/packages/pi-coding-agent/dist/core/prompt-templates.js.map +1 -1
  246. package/packages/pi-coding-agent/dist/core/resource-loader.d.ts +2 -4
  247. package/packages/pi-coding-agent/dist/core/resource-loader.d.ts.map +1 -1
  248. package/packages/pi-coding-agent/dist/core/resource-loader.js +46 -60
  249. package/packages/pi-coding-agent/dist/core/resource-loader.js.map +1 -1
  250. package/packages/pi-coding-agent/dist/core/retry-handler.d.ts +87 -0
  251. package/packages/pi-coding-agent/dist/core/retry-handler.d.ts.map +1 -0
  252. package/packages/pi-coding-agent/dist/core/retry-handler.js +295 -0
  253. package/packages/pi-coding-agent/dist/core/retry-handler.js.map +1 -0
  254. package/packages/pi-coding-agent/dist/core/session-manager.d.ts +0 -5
  255. package/packages/pi-coding-agent/dist/core/session-manager.d.ts.map +1 -1
  256. package/packages/pi-coding-agent/dist/core/session-manager.js +5 -32
  257. package/packages/pi-coding-agent/dist/core/session-manager.js.map +1 -1
  258. package/packages/pi-coding-agent/dist/core/settings-manager.d.ts +8 -12
  259. package/packages/pi-coding-agent/dist/core/settings-manager.d.ts.map +1 -1
  260. package/packages/pi-coding-agent/dist/core/settings-manager.js +78 -168
  261. package/packages/pi-coding-agent/dist/core/settings-manager.js.map +1 -1
  262. package/packages/pi-coding-agent/dist/core/skills.d.ts.map +1 -1
  263. package/packages/pi-coding-agent/dist/core/skills.js +1 -3
  264. package/packages/pi-coding-agent/dist/core/skills.js.map +1 -1
  265. package/packages/pi-coding-agent/dist/index.d.ts +1 -1
  266. package/packages/pi-coding-agent/dist/index.d.ts.map +1 -1
  267. package/packages/pi-coding-agent/dist/index.js +1 -1
  268. package/packages/pi-coding-agent/dist/index.js.map +1 -1
  269. package/packages/pi-coding-agent/dist/migrations.d.ts +0 -16
  270. package/packages/pi-coding-agent/dist/migrations.d.ts.map +1 -1
  271. package/packages/pi-coding-agent/dist/migrations.js +2 -2
  272. package/packages/pi-coding-agent/dist/migrations.js.map +1 -1
  273. package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector-search.d.ts +0 -2
  274. package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -1
  275. package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector-search.js +2 -2
  276. package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector-search.js.map +1 -1
  277. package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector.d.ts +1 -1
  278. package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
  279. package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector.js +9 -26
  280. package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector.js.map +1 -1
  281. package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  282. package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.js +1 -13
  283. package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.js.map +1 -1
  284. package/packages/pi-coding-agent/dist/modes/interactive/components/tree-render-utils.d.ts +44 -0
  285. package/packages/pi-coding-agent/dist/modes/interactive/components/tree-render-utils.d.ts.map +1 -0
  286. package/packages/pi-coding-agent/dist/modes/interactive/components/tree-render-utils.js +61 -0
  287. package/packages/pi-coding-agent/dist/modes/interactive/components/tree-render-utils.js.map +1 -0
  288. package/packages/pi-coding-agent/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
  289. package/packages/pi-coding-agent/dist/modes/interactive/components/tree-selector.js +6 -9
  290. package/packages/pi-coding-agent/dist/modes/interactive/components/tree-selector.js.map +1 -1
  291. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts +1 -24
  292. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  293. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js +50 -512
  294. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js.map +1 -1
  295. package/packages/pi-coding-agent/dist/modes/interactive/slash-command-handlers.d.ts +71 -0
  296. package/packages/pi-coding-agent/dist/modes/interactive/slash-command-handlers.d.ts.map +1 -0
  297. package/packages/pi-coding-agent/dist/modes/interactive/slash-command-handlers.js +514 -0
  298. package/packages/pi-coding-agent/dist/modes/interactive/slash-command-handlers.js.map +1 -0
  299. package/packages/pi-coding-agent/dist/modes/interactive/theme/theme.d.ts +65 -4
  300. package/packages/pi-coding-agent/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  301. package/packages/pi-coding-agent/dist/modes/interactive/theme/theme.js +6 -23
  302. package/packages/pi-coding-agent/dist/modes/interactive/theme/theme.js.map +1 -1
  303. package/packages/pi-coding-agent/dist/modes/interactive/theme/themes.d.ts +12 -0
  304. package/packages/pi-coding-agent/dist/modes/interactive/theme/themes.d.ts.map +1 -0
  305. package/packages/pi-coding-agent/dist/modes/interactive/theme/themes.js +175 -0
  306. package/packages/pi-coding-agent/dist/modes/interactive/theme/themes.js.map +1 -0
  307. package/packages/pi-coding-agent/dist/modes/interactive/utils/shorten-path.d.ts +6 -0
  308. package/packages/pi-coding-agent/dist/modes/interactive/utils/shorten-path.d.ts.map +1 -0
  309. package/packages/pi-coding-agent/dist/modes/interactive/utils/shorten-path.js +15 -0
  310. package/packages/pi-coding-agent/dist/modes/interactive/utils/shorten-path.js.map +1 -0
  311. package/packages/pi-coding-agent/dist/modes/print-mode.d.ts.map +1 -1
  312. package/packages/pi-coding-agent/dist/modes/print-mode.js +2 -30
  313. package/packages/pi-coding-agent/dist/modes/print-mode.js.map +1 -1
  314. package/packages/pi-coding-agent/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  315. package/packages/pi-coding-agent/dist/modes/rpc/rpc-mode.js +2 -28
  316. package/packages/pi-coding-agent/dist/modes/rpc/rpc-mode.js.map +1 -1
  317. package/packages/pi-coding-agent/dist/modes/shared/command-context-actions.d.ts +19 -0
  318. package/packages/pi-coding-agent/dist/modes/shared/command-context-actions.d.ts.map +1 -0
  319. package/packages/pi-coding-agent/dist/modes/shared/command-context-actions.js +45 -0
  320. package/packages/pi-coding-agent/dist/modes/shared/command-context-actions.js.map +1 -0
  321. package/packages/pi-coding-agent/dist/utils/changelog.d.ts +0 -4
  322. package/packages/pi-coding-agent/dist/utils/changelog.d.ts.map +1 -1
  323. package/packages/pi-coding-agent/dist/utils/changelog.js +1 -1
  324. package/packages/pi-coding-agent/dist/utils/changelog.js.map +1 -1
  325. package/packages/pi-coding-agent/dist/utils/clipboard-image.d.ts +0 -1
  326. package/packages/pi-coding-agent/dist/utils/clipboard-image.d.ts.map +1 -1
  327. package/packages/pi-coding-agent/dist/utils/clipboard-image.js +1 -1
  328. package/packages/pi-coding-agent/dist/utils/clipboard-image.js.map +1 -1
  329. package/packages/pi-coding-agent/dist/utils/error.d.ts +5 -0
  330. package/packages/pi-coding-agent/dist/utils/error.d.ts.map +1 -0
  331. package/packages/pi-coding-agent/dist/utils/error.js +7 -0
  332. package/packages/pi-coding-agent/dist/utils/error.js.map +1 -0
  333. package/packages/pi-coding-agent/dist/utils/photon.d.ts +0 -19
  334. package/packages/pi-coding-agent/dist/utils/photon.d.ts.map +1 -1
  335. package/packages/pi-coding-agent/dist/utils/photon.js +1 -120
  336. package/packages/pi-coding-agent/dist/utils/photon.js.map +1 -1
  337. package/packages/pi-coding-agent/dist/utils/tools-manager.d.ts +0 -1
  338. package/packages/pi-coding-agent/dist/utils/tools-manager.d.ts.map +1 -1
  339. package/packages/pi-coding-agent/dist/utils/tools-manager.js +1 -1
  340. package/packages/pi-coding-agent/dist/utils/tools-manager.js.map +1 -1
  341. package/packages/pi-coding-agent/package.json +1 -1
  342. package/packages/pi-coding-agent/src/config.ts +5 -10
  343. package/packages/pi-coding-agent/src/core/agent-session.ts +117 -745
  344. package/packages/pi-coding-agent/src/core/auth-storage.ts +4 -38
  345. package/packages/pi-coding-agent/src/core/compaction/branch-summarization.ts +7 -53
  346. package/packages/pi-coding-agent/src/core/compaction/compaction.ts +14 -74
  347. package/packages/pi-coding-agent/src/core/compaction/utils.ts +100 -0
  348. package/packages/pi-coding-agent/src/core/compaction-orchestrator.ts +424 -0
  349. package/packages/pi-coding-agent/src/core/export-html/ansi-to-html.ts +1 -1
  350. package/packages/pi-coding-agent/src/core/extensions/index.ts +1 -21
  351. package/packages/pi-coding-agent/src/core/extensions/runner.ts +119 -256
  352. package/packages/pi-coding-agent/src/core/extensions/types.ts +50 -69
  353. package/packages/pi-coding-agent/src/core/keybindings.ts +2 -2
  354. package/packages/pi-coding-agent/src/core/lock-utils.ts +113 -0
  355. package/packages/pi-coding-agent/src/core/lsp/client.ts +3 -73
  356. package/packages/pi-coding-agent/src/core/lsp/config.ts +2 -10
  357. package/packages/pi-coding-agent/src/core/lsp/edits.ts +1 -1
  358. package/packages/pi-coding-agent/src/core/lsp/index.ts +83 -152
  359. package/packages/pi-coding-agent/src/core/lsp/lspmux.ts +3 -23
  360. package/packages/pi-coding-agent/src/core/lsp/types.ts +0 -29
  361. package/packages/pi-coding-agent/src/core/lsp/utils.ts +1 -33
  362. package/packages/pi-coding-agent/src/core/messages.ts +5 -5
  363. package/packages/pi-coding-agent/src/core/model-registry.ts +0 -2
  364. package/packages/pi-coding-agent/src/core/model-resolver.ts +3 -77
  365. package/packages/pi-coding-agent/src/core/package-manager.ts +1 -4
  366. package/packages/pi-coding-agent/src/core/prompt-templates.ts +2 -2
  367. package/packages/pi-coding-agent/src/core/resource-loader.ts +56 -69
  368. package/packages/pi-coding-agent/src/core/retry-handler.ts +359 -0
  369. package/packages/pi-coding-agent/src/core/session-manager.ts +5 -34
  370. package/packages/pi-coding-agent/src/core/settings-manager.ts +87 -166
  371. package/packages/pi-coding-agent/src/core/skills.ts +1 -4
  372. package/packages/pi-coding-agent/src/index.ts +1 -7
  373. package/packages/pi-coding-agent/src/migrations.ts +2 -2
  374. package/packages/pi-coding-agent/src/modes/interactive/components/session-selector-search.ts +2 -2
  375. package/packages/pi-coding-agent/src/modes/interactive/components/session-selector.ts +17 -29
  376. package/packages/pi-coding-agent/src/modes/interactive/components/tool-execution.ts +1 -13
  377. package/packages/pi-coding-agent/src/modes/interactive/components/tree-render-utils.ts +81 -0
  378. package/packages/pi-coding-agent/src/modes/interactive/components/tree-selector.ts +14 -19
  379. package/packages/pi-coding-agent/src/modes/interactive/interactive-mode.ts +50 -561
  380. package/packages/pi-coding-agent/src/modes/interactive/slash-command-handlers.ts +653 -0
  381. package/packages/pi-coding-agent/src/modes/interactive/theme/theme.ts +7 -26
  382. package/packages/pi-coding-agent/src/modes/interactive/theme/themes.ts +196 -0
  383. package/packages/pi-coding-agent/src/modes/interactive/utils/shorten-path.ts +14 -0
  384. package/packages/pi-coding-agent/src/modes/print-mode.ts +2 -30
  385. package/packages/pi-coding-agent/src/modes/rpc/rpc-mode.ts +2 -28
  386. package/packages/pi-coding-agent/src/modes/shared/command-context-actions.ts +53 -0
  387. package/packages/pi-coding-agent/src/utils/changelog.ts +1 -1
  388. package/packages/pi-coding-agent/src/utils/clipboard-image.ts +1 -1
  389. package/packages/pi-coding-agent/src/utils/error.ts +6 -0
  390. package/packages/pi-coding-agent/src/utils/photon.ts +0 -137
  391. package/packages/pi-coding-agent/src/utils/tools-manager.ts +1 -1
  392. package/packages/pi-tui/dist/components/editor.d.ts +0 -10
  393. package/packages/pi-tui/dist/components/editor.d.ts.map +1 -1
  394. package/packages/pi-tui/dist/components/editor.js +1 -1
  395. package/packages/pi-tui/dist/components/editor.js.map +1 -1
  396. package/packages/pi-tui/dist/components/markdown.d.ts +5 -0
  397. package/packages/pi-tui/dist/components/markdown.d.ts.map +1 -1
  398. package/packages/pi-tui/dist/components/markdown.js +25 -31
  399. package/packages/pi-tui/dist/components/markdown.js.map +1 -1
  400. package/packages/pi-tui/dist/keys.d.ts +0 -4
  401. package/packages/pi-tui/dist/keys.d.ts.map +1 -1
  402. package/packages/pi-tui/dist/keys.js +94 -162
  403. package/packages/pi-tui/dist/keys.js.map +1 -1
  404. package/packages/pi-tui/dist/overlay-layout.d.ts +55 -0
  405. package/packages/pi-tui/dist/overlay-layout.d.ts.map +1 -0
  406. package/packages/pi-tui/dist/overlay-layout.js +288 -0
  407. package/packages/pi-tui/dist/overlay-layout.js.map +1 -0
  408. package/packages/pi-tui/dist/tui.d.ts +0 -22
  409. package/packages/pi-tui/dist/tui.d.ts.map +1 -1
  410. package/packages/pi-tui/dist/tui.js +6 -272
  411. package/packages/pi-tui/dist/tui.js.map +1 -1
  412. package/packages/pi-tui/dist/utils.d.ts +0 -7
  413. package/packages/pi-tui/dist/utils.d.ts.map +1 -1
  414. package/packages/pi-tui/dist/utils.js +0 -44
  415. package/packages/pi-tui/dist/utils.js.map +1 -1
  416. package/packages/pi-tui/src/components/editor.ts +1 -1
  417. package/packages/pi-tui/src/components/markdown.ts +25 -29
  418. package/packages/pi-tui/src/keys.ts +94 -173
  419. package/packages/pi-tui/src/overlay-layout.ts +372 -0
  420. package/packages/pi-tui/src/tui.ts +11 -312
  421. package/packages/pi-tui/src/utils.ts +0 -43
  422. package/pkg/dist/core/export-html/ansi-to-html.d.ts +0 -4
  423. package/pkg/dist/core/export-html/ansi-to-html.d.ts.map +1 -1
  424. package/pkg/dist/core/export-html/ansi-to-html.js +1 -1
  425. package/pkg/dist/core/export-html/ansi-to-html.js.map +1 -1
  426. package/pkg/dist/modes/interactive/theme/theme.d.ts +65 -4
  427. package/pkg/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  428. package/pkg/dist/modes/interactive/theme/theme.js +6 -23
  429. package/pkg/dist/modes/interactive/theme/theme.js.map +1 -1
  430. package/pkg/dist/modes/interactive/theme/themes.d.ts +12 -0
  431. package/pkg/dist/modes/interactive/theme/themes.d.ts.map +1 -0
  432. package/pkg/dist/modes/interactive/theme/themes.js +175 -0
  433. package/pkg/dist/modes/interactive/theme/themes.js.map +1 -0
  434. package/pkg/package.json +1 -1
  435. package/src/resources/extensions/async-jobs/await-tool.ts +0 -2
  436. package/src/resources/extensions/async-jobs/job-manager.ts +0 -7
  437. package/src/resources/extensions/bg-shell/output-formatter.ts +0 -17
  438. package/src/resources/extensions/bg-shell/process-manager.ts +0 -4
  439. package/src/resources/extensions/bg-shell/types.ts +0 -12
  440. package/src/resources/extensions/context7/index.ts +7 -0
  441. package/src/resources/extensions/get-secrets-from-user.ts +2 -35
  442. package/src/resources/extensions/google-search/index.ts +7 -0
  443. package/src/resources/extensions/gsd/auto-dispatch.ts +49 -1
  444. package/src/resources/extensions/gsd/auto-loop.ts +22 -2
  445. package/src/resources/extensions/gsd/auto-model-selection.ts +23 -2
  446. package/src/resources/extensions/gsd/auto-recovery.ts +39 -0
  447. package/src/resources/extensions/gsd/auto-start.ts +42 -2
  448. package/src/resources/extensions/gsd/auto.ts +61 -3
  449. package/src/resources/extensions/gsd/changelog.ts +213 -0
  450. package/src/resources/extensions/gsd/commands-bootstrap.ts +1 -0
  451. package/src/resources/extensions/gsd/commands-handlers.ts +2 -2
  452. package/src/resources/extensions/gsd/commands-inspect.ts +10 -3
  453. package/src/resources/extensions/gsd/commands-prefs-wizard.ts +5 -1
  454. package/src/resources/extensions/gsd/commands-rate.ts +55 -0
  455. package/src/resources/extensions/gsd/commands.ts +52 -2
  456. package/src/resources/extensions/gsd/docs/preferences-reference.md +10 -0
  457. package/src/resources/extensions/gsd/doctor-checks.ts +107 -5
  458. package/src/resources/extensions/gsd/doctor-environment.ts +26 -16
  459. package/src/resources/extensions/gsd/doctor-proactive.ts +24 -0
  460. package/src/resources/extensions/gsd/doctor-types.ts +9 -1
  461. package/src/resources/extensions/gsd/doctor.ts +35 -0
  462. package/src/resources/extensions/gsd/files.ts +12 -2
  463. package/src/resources/extensions/gsd/gitignore.ts +54 -7
  464. package/src/resources/extensions/gsd/guided-flow.ts +12 -4
  465. package/src/resources/extensions/gsd/health-widget-core.ts +129 -0
  466. package/src/resources/extensions/gsd/health-widget.ts +103 -59
  467. package/src/resources/extensions/gsd/index.ts +30 -33
  468. package/src/resources/extensions/gsd/migrate-external.ts +47 -2
  469. package/src/resources/extensions/gsd/milestone-ids.ts +3 -2
  470. package/src/resources/extensions/gsd/paths.ts +73 -7
  471. package/src/resources/extensions/gsd/post-unit-hooks.ts +5 -1
  472. package/src/resources/extensions/gsd/preferences-validation.ts +54 -1
  473. package/src/resources/extensions/gsd/preferences.ts +16 -1
  474. package/src/resources/extensions/gsd/prompts/complete-milestone.md +2 -0
  475. package/src/resources/extensions/gsd/prompts/validate-milestone.md +2 -0
  476. package/src/resources/extensions/gsd/roadmap-mutations.ts +66 -0
  477. package/src/resources/extensions/gsd/session-lock.ts +59 -2
  478. package/src/resources/extensions/gsd/state.ts +2 -1
  479. package/src/resources/extensions/gsd/templates/plan.md +8 -0
  480. package/src/resources/extensions/gsd/tests/commands-inspect-open-db.test.ts +46 -0
  481. package/src/resources/extensions/gsd/tests/doctor-git.test.ts +98 -2
  482. package/src/resources/extensions/gsd/tests/doctor-runtime.test.ts +59 -3
  483. package/src/resources/extensions/gsd/tests/files-loadfile-eisdir.test.ts +20 -0
  484. package/src/resources/extensions/gsd/tests/gitignore-tracked-gsd.test.ts +214 -0
  485. package/src/resources/extensions/gsd/tests/health-widget.test.ts +158 -0
  486. package/src/resources/extensions/gsd/tests/paths.test.ts +113 -0
  487. package/src/resources/extensions/gsd/tests/preferences.test.ts +40 -2
  488. package/src/resources/extensions/gsd/tests/queue-reorder-e2e.test.ts +26 -0
  489. package/src/resources/extensions/gsd/tests/test-utils.ts +165 -0
  490. package/src/resources/extensions/gsd/tests/validate-directory.test.ts +15 -0
  491. package/src/resources/extensions/gsd/tests/validate-milestone.test.ts +7 -0
  492. package/src/resources/extensions/gsd/tests/worktree-sync-milestones.test.ts +32 -0
  493. package/src/resources/extensions/gsd/worktree-resolver.ts +11 -0
  494. package/src/resources/extensions/mcp-client/index.ts +2 -1
  495. package/src/resources/extensions/remote-questions/remote-command.ts +2 -23
  496. package/src/resources/extensions/shared/mod.ts +1 -1
  497. package/src/resources/extensions/shared/sanitize.ts +36 -0
  498. package/src/resources/extensions/subagent/index.ts +6 -12
  499. package/src/resources/skills/create-gsd-extension/references/events-reference.md +4 -4
  500. package/dist/resources/extensions/shared/wizard-ui.js +0 -478
  501. package/packages/pi-coding-agent/dist/modes/interactive/theme/dark.json +0 -85
  502. package/packages/pi-coding-agent/dist/modes/interactive/theme/light.json +0 -84
  503. package/packages/pi-coding-agent/dist/modes/interactive/theme/theme-schema.json +0 -335
  504. package/packages/pi-coding-agent/src/modes/interactive/theme/dark.json +0 -85
  505. package/packages/pi-coding-agent/src/modes/interactive/theme/light.json +0 -84
  506. package/packages/pi-coding-agent/src/modes/interactive/theme/theme-schema.json +0 -335
  507. package/pkg/dist/modes/interactive/theme/dark.json +0 -85
  508. package/pkg/dist/modes/interactive/theme/light.json +0 -84
  509. package/pkg/dist/modes/interactive/theme/theme-schema.json +0 -335
  510. package/src/resources/extensions/shared/wizard-ui.ts +0 -551
@@ -1,551 +0,0 @@
1
- /**
2
- * General-purpose multi-page wizard UI.
3
- *
4
- * Supports declarative page definitions with select and text fields.
5
- * Pages can conditionally route to different next pages based on answers.
6
- *
7
- * Navigation:
8
- * ← go back one page (on page 1: triggers exit confirmation)
9
- * → / Enter advance to next page (or submit on last page)
10
- * Escape triggers exit confirmation overlay
11
- *
12
- * Exit confirmation (shown on Escape or ← from page 1):
13
- * 1. Go back — dismiss and return to current page
14
- * 2. Exit — cancel the wizard, returns null to caller
15
- *
16
- * Returns:
17
- * Record<pageId, Record<fieldId, string | string[]>> on completion
18
- * null on exit/cancel
19
- *
20
- * Example:
21
- *
22
- * const result = await showWizard(ctx, {
23
- * title: "New Project",
24
- * pages: [
25
- * {
26
- * id: "mode",
27
- * fields: [
28
- * {
29
- * type: "select",
30
- * id: "start_type",
31
- * question: "How do you want to start?",
32
- * options: [
33
- * { label: "Describe it", description: "Type what you want to build." },
34
- * { label: "Provide a file", description: "Point to an existing doc." },
35
- * ],
36
- * },
37
- * ],
38
- * next: (answers) =>
39
- * answers["mode"]?.["start_type"] === "Provide a file" ? "file_path" : null,
40
- * },
41
- * {
42
- * id: "file_path",
43
- * fields: [
44
- * { type: "text", id: "path", label: "File path", placeholder: "/path/to/doc.md" },
45
- * ],
46
- * next: () => null,
47
- * },
48
- * ],
49
- * });
50
- *
51
- * if (!result) return; // user exited
52
- * const startType = result["mode"]["start_type"]; // "Describe it" | "Provide a file"
53
- * const filePath = result["file_path"]?.["path"];
54
- */
55
-
56
- import type { ExtensionCommandContext } from "@gsd/pi-coding-agent";
57
- import { type Theme } from "@gsd/pi-coding-agent";
58
- import {
59
- Editor,
60
- Key,
61
- matchesKey,
62
- truncateToWidth,
63
- type TUI,
64
- } from "@gsd/pi-tui";
65
- import { makeUI } from "./ui.js";
66
-
67
- // ─── Public types ─────────────────────────────────────────────────────────────
68
-
69
- export interface WizardOption {
70
- label: string;
71
- description: string;
72
- }
73
-
74
- export interface SelectField {
75
- type: "select";
76
- id: string;
77
- question: string;
78
- options: WizardOption[];
79
- /** Allow multiple selections. Default: false. */
80
- allowMultiple?: boolean;
81
- }
82
-
83
- export interface TextField {
84
- type: "text";
85
- id: string;
86
- label: string;
87
- placeholder?: string;
88
- }
89
-
90
- export type WizardField = SelectField | TextField;
91
-
92
- /** Answers collected so far: pageId → fieldId → value */
93
- export type WizardAnswers = Record<string, Record<string, string | string[]>>;
94
-
95
- export interface WizardPage {
96
- id: string;
97
- /** Optional subtitle shown below the wizard title for this page. */
98
- subtitle?: string;
99
- fields: WizardField[];
100
- /**
101
- * Return the id of the next page, or null to end the wizard.
102
- * Called with all answers collected so far when the user advances.
103
- * If omitted, the wizard ends after this page.
104
- */
105
- next?: (answers: WizardAnswers) => string | null;
106
- }
107
-
108
- export interface WizardOptions {
109
- /** Title shown at the top of every page. */
110
- title: string;
111
- /** Ordered page definitions. Pages are navigated in order unless next() routes elsewhere. */
112
- pages: WizardPage[];
113
- }
114
-
115
- // ─── Internal state ───────────────────────────────────────────────────────────
116
-
117
- interface SelectState {
118
- cursorIndex: number;
119
- /** Single-select: committed option index, null if not yet chosen */
120
- committedIndex: number | null;
121
- /** Multi-select: which indices are checked */
122
- checkedIndices: Set<number>;
123
- }
124
-
125
- interface PageState {
126
- selectStates: Map<string, SelectState>;
127
- textValues: Map<string, string>;
128
- /** Which field is focused (for text fields) */
129
- focusedFieldId: string | null;
130
- }
131
-
132
- // ─── Main export ──────────────────────────────────────────────────────────────
133
-
134
- /**
135
- * Show a multi-page wizard and return collected answers, or null if the user exits.
136
- */
137
- export async function showWizard(
138
- ctx: ExtensionCommandContext,
139
- opts: WizardOptions,
140
- ): Promise<WizardAnswers | null> {
141
- const pageMap = new Map<string, WizardPage>(opts.pages.map((p) => [p.id, p]));
142
-
143
- return ctx.ui.custom<WizardAnswers | null>((tui: TUI, theme: Theme, _kb, done) => {
144
- // ── State ──────────────────────────────────────────────────────────────
145
-
146
- /** Stack of page ids visited — drives back navigation */
147
- const pageStack: string[] = [opts.pages[0].id];
148
- const pageStates = new Map<string, PageState>();
149
- /** Collected answers across all pages */
150
- const answers: WizardAnswers = {};
151
- /** Whether the exit-confirmation overlay is showing */
152
- let showingExitConfirm = false;
153
- /** Cursor in the exit-confirm overlay: 0 = go back, 1 = exit */
154
- let exitCursor = 0;
155
-
156
- let cachedLines: string[] | undefined;
157
-
158
- // Editors keyed by fieldId — one per text field
159
- // editorTheme is derived from the design system at first render
160
- const editors = new Map<string, Editor>();
161
- let resolvedEditorTheme: import("@gsd/pi-tui").EditorTheme | null = null;
162
-
163
- function getEditor(fieldId: string): Editor {
164
- if (!resolvedEditorTheme) resolvedEditorTheme = makeUI(theme, 80).editorTheme;
165
- if (!editors.has(fieldId)) editors.set(fieldId, new Editor(tui, resolvedEditorTheme));
166
- return editors.get(fieldId)!;
167
- }
168
-
169
- // ── Page state helpers ─────────────────────────────────────────────────
170
-
171
- function getPageState(pageId: string): PageState {
172
- if (!pageStates.has(pageId)) {
173
- pageStates.set(pageId, {
174
- selectStates: new Map(),
175
- textValues: new Map(),
176
- focusedFieldId: null,
177
- });
178
- }
179
- return pageStates.get(pageId)!;
180
- }
181
-
182
- function getSelectState(pageId: string, fieldId: string, _optCount: number): SelectState {
183
- const ps = getPageState(pageId);
184
- if (!ps.selectStates.has(fieldId)) {
185
- ps.selectStates.set(fieldId, {
186
- cursorIndex: 0,
187
- committedIndex: null, // nothing pre-committed — user must explicitly confirm
188
- checkedIndices: new Set(),
189
- });
190
- }
191
- return ps.selectStates.get(fieldId)!;
192
- }
193
-
194
- // ── Current page ───────────────────────────────────────────────────────
195
-
196
- function currentPageId(): string {
197
- return pageStack[pageStack.length - 1];
198
- }
199
-
200
- function currentPage(): WizardPage {
201
- return pageMap.get(currentPageId())!;
202
- }
203
-
204
- function currentPageState(): PageState {
205
- return getPageState(currentPageId());
206
- }
207
-
208
- // ── Validation ─────────────────────────────────────────────────────────
209
-
210
- function isPageComplete(page: WizardPage, ps: PageState): boolean {
211
- for (const field of page.fields) {
212
- if (field.type === "select") {
213
- const ss = ps.selectStates.get(field.id);
214
- if (!ss) return false;
215
- if (field.allowMultiple) {
216
- if (ss.checkedIndices.size === 0) return false;
217
- } else {
218
- if (ss.committedIndex === null) return false;
219
- }
220
- } else {
221
- const val = ps.textValues.get(field.id) ?? "";
222
- if (!val.trim()) return false;
223
- }
224
- }
225
- return true;
226
- }
227
-
228
- // ── Collect answers for a page ─────────────────────────────────────────
229
-
230
- function collectPageAnswers(page: WizardPage, ps: PageState): Record<string, string | string[]> {
231
- const result: Record<string, string | string[]> = {};
232
- for (const field of page.fields) {
233
- if (field.type === "select") {
234
- const ss = ps.selectStates.get(field.id);
235
- if (!ss) continue;
236
- if (field.allowMultiple) {
237
- result[field.id] = Array.from(ss.checkedIndices)
238
- .sort((a, b) => a - b)
239
- .map((i) => field.options[i].label);
240
- } else {
241
- if (ss.committedIndex !== null && ss.committedIndex < field.options.length) {
242
- result[field.id] = field.options[ss.committedIndex].label;
243
- }
244
- }
245
- } else {
246
- result[field.id] = ps.textValues.get(field.id) ?? "";
247
- }
248
- }
249
- return result;
250
- }
251
-
252
- // ── Auto-focus helper ──────────────────────────────────────────────────
253
-
254
- /** If a page's first field is a text field, focus it immediately on arrival. */
255
- function autoFocusPageIfText(pageId: string) {
256
- const page = pageMap.get(pageId);
257
- if (!page) return;
258
- const firstField = page.fields[0];
259
- if (firstField?.type === "text") {
260
- const ps = getPageState(pageId);
261
- ps.focusedFieldId = firstField.id;
262
- const editor = getEditor(firstField.id);
263
- editor.setText(ps.textValues.get(firstField.id) ?? "");
264
- }
265
- }
266
-
267
- // Auto-focus the first page if it starts with a text field
268
- autoFocusPageIfText(opts.pages[0].id);
269
-
270
- // ── Navigation ─────────────────────────────────────────────────────────
271
-
272
- function advance() {
273
- const page = currentPage();
274
- const ps = currentPageState();
275
- if (!isPageComplete(page, ps)) {
276
- refresh();
277
- return;
278
- }
279
-
280
- // Save text field values from editors
281
- for (const field of page.fields) {
282
- if (field.type === "text") {
283
- ps.textValues.set(field.id, getEditor(field.id).getText().trim());
284
- }
285
- }
286
-
287
- // Collect answers for this page
288
- answers[page.id] = collectPageAnswers(page, ps);
289
-
290
- // Route to next page
291
- const nextId = page.next ? page.next(answers) : null;
292
- if (!nextId) {
293
- // End of wizard
294
- done(answers);
295
- return;
296
- }
297
-
298
- const nextPage = pageMap.get(nextId);
299
- if (!nextPage) {
300
- done(answers);
301
- return;
302
- }
303
-
304
- pageStack.push(nextId);
305
- autoFocusPageIfText(nextId);
306
- refresh();
307
- }
308
-
309
- function goBack() {
310
- if (pageStack.length <= 1) {
311
- // Already at first page — Esc here means exit
312
- showingExitConfirm = true;
313
- exitCursor = 0;
314
- refresh();
315
- return;
316
- }
317
- pageStack.pop();
318
- autoFocusPageIfText(currentPageId());
319
- refresh();
320
- }
321
-
322
- function refresh() {
323
- cachedLines = undefined;
324
- tui.requestRender();
325
- }
326
-
327
- // ── Input handler ──────────────────────────────────────────────────────
328
-
329
- function handleInput(data: string) {
330
- // ── Exit confirm overlay ─────────────────────────────────────────
331
- if (showingExitConfirm) {
332
- if (matchesKey(data, Key.up)) { exitCursor = 0; refresh(); return; }
333
- if (matchesKey(data, Key.down)) { exitCursor = 1; refresh(); return; }
334
- if (data === "1") { showingExitConfirm = false; refresh(); return; }
335
- if (data === "2") { done(null); return; }
336
- if (matchesKey(data, Key.enter) || matchesKey(data, Key.space)) {
337
- if (exitCursor === 0) { showingExitConfirm = false; refresh(); }
338
- else { done(null); }
339
- return;
340
- }
341
- // Esc on the confirm screen = go back (dismiss confirm)
342
- if (matchesKey(data, Key.escape)) { showingExitConfirm = false; refresh(); return; }
343
- return;
344
- }
345
-
346
- // ── Text field focus ─────────────────────────────────────────────
347
- const ps = currentPageState();
348
- if (ps.focusedFieldId) {
349
- const editor = getEditor(ps.focusedFieldId);
350
- if (matchesKey(data, Key.escape)) {
351
- // First Esc: unfocus the text field
352
- ps.textValues.set(ps.focusedFieldId, editor.getText().trim());
353
- ps.focusedFieldId = null;
354
- refresh();
355
- return;
356
- }
357
- if (matchesKey(data, Key.enter)) {
358
- ps.textValues.set(ps.focusedFieldId, editor.getText().trim());
359
- ps.focusedFieldId = null;
360
- advance();
361
- return;
362
- }
363
- editor.handleInput(data);
364
- refresh();
365
- return;
366
- }
367
-
368
- // ── Esc with no text field focused: go back (or exit if on page 1) ──
369
- if (matchesKey(data, Key.escape)) { goBack(); return; }
370
-
371
- // ── Enter / → to advance ─────────────────────────────────────────
372
- if (matchesKey(data, Key.enter) || matchesKey(data, Key.right)) {
373
- // For single-select fields, commit cursor before advancing
374
- const page = currentPage();
375
- for (const field of page.fields) {
376
- if (field.type === "select" && !field.allowMultiple) {
377
- const ss = getSelectState(currentPageId(), field.id, field.options.length);
378
- if (ss.committedIndex === null) ss.committedIndex = ss.cursorIndex;
379
- }
380
- }
381
- advance();
382
- return;
383
- }
384
-
385
- // ── Select field interactions ────────────────────────────────────
386
- const page = currentPage();
387
- for (const field of page.fields) {
388
- if (field.type !== "select") continue;
389
- const ss = getSelectState(currentPageId(), field.id, field.options.length);
390
- const totalOpts = field.options.length;
391
-
392
- if (matchesKey(data, Key.up)) {
393
- ss.cursorIndex = (ss.cursorIndex - 1 + totalOpts) % totalOpts;
394
- refresh(); return;
395
- }
396
- if (matchesKey(data, Key.down)) {
397
- ss.cursorIndex = (ss.cursorIndex + 1) % totalOpts;
398
- refresh(); return;
399
- }
400
-
401
- if (field.allowMultiple) {
402
- if (matchesKey(data, Key.space)) {
403
- if (ss.checkedIndices.has(ss.cursorIndex)) ss.checkedIndices.delete(ss.cursorIndex);
404
- else ss.checkedIndices.add(ss.cursorIndex);
405
- refresh(); return;
406
- }
407
- } else {
408
- // Numeric shortcut: press the number to select and immediately advance
409
- if (data.length === 1 && data >= "1" && data <= "9") {
410
- const idx = parseInt(data, 10) - 1;
411
- if (idx < totalOpts) {
412
- ss.cursorIndex = idx;
413
- ss.committedIndex = idx;
414
- advance();
415
- return;
416
- }
417
- }
418
- // Enter/Space commit cursor and advance (Enter handled above, Space here)
419
- if (matchesKey(data, Key.space)) {
420
- ss.committedIndex = ss.cursorIndex;
421
- advance();
422
- return;
423
- }
424
- }
425
- // Only handle the first select field for nav
426
- break;
427
- }
428
- }
429
-
430
- // ── Render ─────────────────────────────────────────────────────────────
431
-
432
- function renderExitConfirm(width: number): string[] {
433
- const ui = makeUI(theme, width);
434
- const lines: string[] = [];
435
- const push = (...rows: string[][]) => { for (const r of rows) lines.push(...r); };
436
-
437
- push(
438
- ui.bar(), ui.blank(),
439
- ui.header(" Exit wizard?"),
440
- ui.blank(),
441
- ui.subtitle(" Your progress will be lost."),
442
- ui.blank(),
443
- );
444
-
445
- if (exitCursor === 0) push(ui.actionSelected(1, "Go back", "Return to where you were."));
446
- else push(ui.actionUnselected(1, "Go back", "Return to where you were."));
447
- push(ui.blank());
448
- if (exitCursor === 1) push(ui.actionSelected(2, "Exit", "Cancel and discard all answers."));
449
- else push(ui.actionUnselected(2, "Exit", "Cancel and discard all answers."));
450
- push(
451
- ui.blank(),
452
- ui.hints(["↑/↓ to choose", "1/2 to quick-select", "enter to confirm"]),
453
- ui.bar(),
454
- );
455
- return lines;
456
- }
457
-
458
- function renderSelectField(ui: ReturnType<typeof makeUI>, field: SelectField, lines: string[]) {
459
- const push = (...rows: string[][]) => { for (const r of rows) lines.push(...r); };
460
- const ss = getSelectState(currentPageId(), field.id, field.options.length);
461
- const multi = !!field.allowMultiple;
462
-
463
- push(ui.question(` ${field.question}`));
464
- if (multi) push(ui.meta(" (select all that apply — space to toggle, enter to confirm)"));
465
- push(ui.blank());
466
-
467
- for (let i = 0; i < field.options.length; i++) {
468
- const opt = field.options[i];
469
- const isCursor = i === ss.cursorIndex;
470
- const isCommitted = i === ss.committedIndex;
471
-
472
- if (multi) {
473
- const isChecked = ss.checkedIndices.has(i);
474
- if (isCursor) push(ui.checkboxSelected(opt.label, opt.description, isChecked));
475
- else push(ui.checkboxUnselected(opt.label, opt.description, isChecked));
476
- } else {
477
- if (isCursor) push(ui.optionSelected(i + 1, opt.label, opt.description, isCommitted));
478
- else push(ui.optionUnselected(i + 1, opt.label, opt.description, { isCommitted }));
479
- }
480
- }
481
- }
482
-
483
- function renderTextField(ui: ReturnType<typeof makeUI>, field: TextField, ps: PageState, lines: string[], width: number) {
484
- const push = (...rows: string[][]) => { for (const r of rows) lines.push(...r); };
485
- const isFocused = ps.focusedFieldId === field.id;
486
- const value = isFocused ? getEditor(field.id).getText() : (ps.textValues.get(field.id) ?? "");
487
-
488
- push(ui.question(` ${field.label}`), ui.blank());
489
-
490
- if (isFocused) {
491
- for (const line of getEditor(field.id).render(width - 2)) lines.push(truncateToWidth(` ${line}`, width));
492
- } else if (value) {
493
- push(ui.answer(` ${value}`));
494
- } else if (field.placeholder) {
495
- push(ui.meta(` ${field.placeholder}`));
496
- }
497
- }
498
-
499
- function render(width: number): string[] {
500
- if (cachedLines) return cachedLines;
501
- if (showingExitConfirm) { cachedLines = renderExitConfirm(width); return cachedLines; }
502
-
503
- const ui = makeUI(theme, width);
504
- const lines: string[] = [];
505
- const push = (...rows: string[][]) => { for (const r of rows) lines.push(...r); };
506
-
507
- push(ui.bar(), ui.header(` ${opts.title}`));
508
-
509
- // ── Page indicator ────────────────────────────────────────────────
510
- if (opts.pages.length > 1) {
511
- push(ui.pageDots(opts.pages.length, pageStack.length - 1));
512
- }
513
-
514
- // ── Page content ──────────────────────────────────────────────────
515
- const page = currentPage();
516
- const ps = currentPageState();
517
-
518
- if (page.subtitle) { push(ui.blank(), ui.subtitle(` ${page.subtitle}`)); }
519
- push(ui.blank());
520
-
521
- for (const field of page.fields) {
522
- if (field.type === "select") renderSelectField(ui, field, lines);
523
- else renderTextField(ui, field, ps, lines, width);
524
- push(ui.blank());
525
- }
526
-
527
- // ── Footer hints ──────────────────────────────────────────────────
528
- const isFirst = pageStack.length === 1;
529
- const ps2 = currentPageState();
530
- const hints: string[] = [];
531
- if (ps2.focusedFieldId) {
532
- hints.push("enter to continue");
533
- hints.push("esc to unfocus");
534
- } else {
535
- hints.push("↑/↓ to move");
536
- hints.push("enter to select");
537
- hints.push(!isFirst ? "esc to go back" : "esc to exit");
538
- }
539
- push(ui.hints(hints), ui.bar());
540
-
541
- cachedLines = lines;
542
- return lines;
543
- }
544
-
545
- return {
546
- render,
547
- invalidate: () => { cachedLines = undefined; },
548
- handleInput,
549
- };
550
- });
551
- }