shortcutxl 0.2.0

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 (423) hide show
  1. package/README.md +59 -0
  2. package/agent-docs/README.md +397 -0
  3. package/agent-docs/docs/compaction.md +390 -0
  4. package/agent-docs/docs/custom-provider.md +580 -0
  5. package/agent-docs/docs/development.md +69 -0
  6. package/agent-docs/docs/extensions.md +1971 -0
  7. package/agent-docs/docs/json.md +79 -0
  8. package/agent-docs/docs/keybindings.md +174 -0
  9. package/agent-docs/docs/models.md +293 -0
  10. package/agent-docs/docs/packages.md +209 -0
  11. package/agent-docs/docs/prompt-templates.md +67 -0
  12. package/agent-docs/docs/providers.md +186 -0
  13. package/agent-docs/docs/rpc.md +1317 -0
  14. package/agent-docs/docs/sdk.md +962 -0
  15. package/agent-docs/docs/session.md +412 -0
  16. package/agent-docs/docs/settings.md +223 -0
  17. package/agent-docs/docs/shell-aliases.md +13 -0
  18. package/agent-docs/docs/skills.md +231 -0
  19. package/agent-docs/docs/terminal-setup.md +70 -0
  20. package/agent-docs/docs/termux.md +127 -0
  21. package/agent-docs/docs/themes.md +295 -0
  22. package/agent-docs/docs/tree.md +219 -0
  23. package/agent-docs/docs/tui.md +887 -0
  24. package/agent-docs/docs/windows.md +17 -0
  25. package/agent-docs/examples/README.md +25 -0
  26. package/agent-docs/examples/extensions/README.md +205 -0
  27. package/agent-docs/examples/extensions/antigravity-image-gen.ts +447 -0
  28. package/agent-docs/examples/extensions/auto-commit-on-exit.ts +49 -0
  29. package/agent-docs/examples/extensions/bash-spawn-hook.ts +30 -0
  30. package/agent-docs/examples/extensions/bookmark.ts +50 -0
  31. package/agent-docs/examples/extensions/built-in-tool-renderer.ts +256 -0
  32. package/agent-docs/examples/extensions/claude-rules.ts +86 -0
  33. package/agent-docs/examples/extensions/commands.ts +75 -0
  34. package/agent-docs/examples/extensions/confirm-destructive.ts +59 -0
  35. package/agent-docs/examples/extensions/custom-compaction.ts +126 -0
  36. package/agent-docs/examples/extensions/custom-footer.ts +63 -0
  37. package/agent-docs/examples/extensions/custom-header.ts +73 -0
  38. package/agent-docs/examples/extensions/custom-provider-anthropic/index.ts +660 -0
  39. package/agent-docs/examples/extensions/custom-provider-anthropic/package-lock.json +24 -0
  40. package/agent-docs/examples/extensions/custom-provider-anthropic/package.json +19 -0
  41. package/agent-docs/examples/extensions/custom-provider-gitlab-duo/index.ts +362 -0
  42. package/agent-docs/examples/extensions/custom-provider-gitlab-duo/package.json +16 -0
  43. package/agent-docs/examples/extensions/custom-provider-gitlab-duo/test.ts +88 -0
  44. package/agent-docs/examples/extensions/custom-provider-qwen-cli/index.ts +349 -0
  45. package/agent-docs/examples/extensions/custom-provider-qwen-cli/package.json +16 -0
  46. package/agent-docs/examples/extensions/dirty-repo-guard.ts +56 -0
  47. package/agent-docs/examples/extensions/doom-overlay/README.md +46 -0
  48. package/agent-docs/examples/extensions/doom-overlay/doom/build.sh +152 -0
  49. package/agent-docs/examples/extensions/doom-overlay/doom/doomgeneric_pi.c +72 -0
  50. package/agent-docs/examples/extensions/doom-overlay/doom-component.ts +133 -0
  51. package/agent-docs/examples/extensions/doom-overlay/doom-engine.ts +186 -0
  52. package/agent-docs/examples/extensions/doom-overlay/doom-keys.ts +108 -0
  53. package/agent-docs/examples/extensions/doom-overlay/index.ts +74 -0
  54. package/agent-docs/examples/extensions/doom-overlay/wad-finder.ts +51 -0
  55. package/agent-docs/examples/extensions/dynamic-resources/SKILL.md +8 -0
  56. package/agent-docs/examples/extensions/dynamic-resources/dynamic.json +79 -0
  57. package/agent-docs/examples/extensions/dynamic-resources/dynamic.md +5 -0
  58. package/agent-docs/examples/extensions/dynamic-resources/index.ts +15 -0
  59. package/agent-docs/examples/extensions/dynamic-tools.ts +77 -0
  60. package/agent-docs/examples/extensions/event-bus.ts +43 -0
  61. package/agent-docs/examples/extensions/file-trigger.ts +41 -0
  62. package/agent-docs/examples/extensions/git-checkpoint.ts +53 -0
  63. package/agent-docs/examples/extensions/handoff.ts +155 -0
  64. package/agent-docs/examples/extensions/hello.ts +25 -0
  65. package/agent-docs/examples/extensions/inline-bash.ts +94 -0
  66. package/agent-docs/examples/extensions/input-transform.ts +43 -0
  67. package/agent-docs/examples/extensions/interactive-shell.ts +209 -0
  68. package/agent-docs/examples/extensions/mac-system-theme.ts +47 -0
  69. package/agent-docs/examples/extensions/message-renderer.ts +59 -0
  70. package/agent-docs/examples/extensions/minimal-mode.ts +430 -0
  71. package/agent-docs/examples/extensions/modal-editor.ts +90 -0
  72. package/agent-docs/examples/extensions/model-status.ts +31 -0
  73. package/agent-docs/examples/extensions/notify.ts +55 -0
  74. package/agent-docs/examples/extensions/overlay-qa-tests.ts +936 -0
  75. package/agent-docs/examples/extensions/overlay-test.ts +159 -0
  76. package/agent-docs/examples/extensions/permission-gate.ts +37 -0
  77. package/agent-docs/examples/extensions/pirate.ts +47 -0
  78. package/agent-docs/examples/extensions/plan-mode/README.md +65 -0
  79. package/agent-docs/examples/extensions/plan-mode/index.ts +363 -0
  80. package/agent-docs/examples/extensions/plan-mode/utils.ts +173 -0
  81. package/agent-docs/examples/extensions/preset.ts +418 -0
  82. package/agent-docs/examples/extensions/protected-paths.ts +30 -0
  83. package/agent-docs/examples/extensions/qna.ts +122 -0
  84. package/agent-docs/examples/extensions/question.ts +278 -0
  85. package/agent-docs/examples/extensions/questionnaire.ts +440 -0
  86. package/agent-docs/examples/extensions/rainbow-editor.ts +90 -0
  87. package/agent-docs/examples/extensions/reload-runtime.ts +37 -0
  88. package/agent-docs/examples/extensions/rpc-demo.ts +124 -0
  89. package/agent-docs/examples/extensions/sandbox/index.ts +324 -0
  90. package/agent-docs/examples/extensions/sandbox/package-lock.json +92 -0
  91. package/agent-docs/examples/extensions/sandbox/package.json +19 -0
  92. package/agent-docs/examples/extensions/send-user-message.ts +97 -0
  93. package/agent-docs/examples/extensions/session-name.ts +27 -0
  94. package/agent-docs/examples/extensions/shutdown-command.ts +69 -0
  95. package/agent-docs/examples/extensions/snake.ts +343 -0
  96. package/agent-docs/examples/extensions/space-invaders.ts +566 -0
  97. package/agent-docs/examples/extensions/ssh.ts +233 -0
  98. package/agent-docs/examples/extensions/status-line.ts +40 -0
  99. package/agent-docs/examples/extensions/subagent/README.md +172 -0
  100. package/agent-docs/examples/extensions/subagent/agents/planner.md +37 -0
  101. package/agent-docs/examples/extensions/subagent/agents/reviewer.md +35 -0
  102. package/agent-docs/examples/extensions/subagent/agents/scout.md +50 -0
  103. package/agent-docs/examples/extensions/subagent/agents/worker.md +24 -0
  104. package/agent-docs/examples/extensions/subagent/agents.ts +130 -0
  105. package/agent-docs/examples/extensions/subagent/index.ts +1068 -0
  106. package/agent-docs/examples/extensions/subagent/prompts/implement-and-review.md +10 -0
  107. package/agent-docs/examples/extensions/subagent/prompts/implement.md +10 -0
  108. package/agent-docs/examples/extensions/subagent/prompts/scout-and-plan.md +9 -0
  109. package/agent-docs/examples/extensions/summarize.ts +206 -0
  110. package/agent-docs/examples/extensions/system-prompt-header.ts +17 -0
  111. package/agent-docs/examples/extensions/timed-confirm.ts +72 -0
  112. package/agent-docs/examples/extensions/titlebar-spinner.ts +58 -0
  113. package/agent-docs/examples/extensions/todo.ts +314 -0
  114. package/agent-docs/examples/extensions/tool-override.ts +146 -0
  115. package/agent-docs/examples/extensions/tools.ts +145 -0
  116. package/agent-docs/examples/extensions/trigger-compact.ts +40 -0
  117. package/agent-docs/examples/extensions/truncated-tool.ts +194 -0
  118. package/agent-docs/examples/extensions/widget-placement.ts +17 -0
  119. package/agent-docs/examples/extensions/with-deps/index.ts +37 -0
  120. package/agent-docs/examples/extensions/with-deps/package-lock.json +31 -0
  121. package/agent-docs/examples/extensions/with-deps/package.json +22 -0
  122. package/agent-docs/examples/rpc-extension-ui.ts +654 -0
  123. package/agent-docs/examples/sdk/01-minimal.ts +22 -0
  124. package/agent-docs/examples/sdk/02-custom-model.ts +48 -0
  125. package/agent-docs/examples/sdk/03-custom-prompt.ts +55 -0
  126. package/agent-docs/examples/sdk/04-skills.ts +53 -0
  127. package/agent-docs/examples/sdk/05-tools.ts +56 -0
  128. package/agent-docs/examples/sdk/06-extensions.ts +88 -0
  129. package/agent-docs/examples/sdk/07-context-files.ts +40 -0
  130. package/agent-docs/examples/sdk/08-prompt-templates.ts +47 -0
  131. package/agent-docs/examples/sdk/09-api-keys-and-oauth.ts +48 -0
  132. package/agent-docs/examples/sdk/10-settings.ts +54 -0
  133. package/agent-docs/examples/sdk/11-sessions.ts +48 -0
  134. package/agent-docs/examples/sdk/12-full-control.ts +82 -0
  135. package/agent-docs/examples/sdk/README.md +144 -0
  136. package/agent-docs/xll-skill.md +61 -0
  137. package/agent-docs/xll-spec.md +110 -0
  138. package/dist/cli/args.js +290 -0
  139. package/dist/cli/config-selector.js +31 -0
  140. package/dist/cli/file-processor.js +79 -0
  141. package/dist/cli/list-models.js +92 -0
  142. package/dist/cli/package-commands.js +210 -0
  143. package/dist/cli/report-settings-errors.js +11 -0
  144. package/dist/cli/session-picker.js +34 -0
  145. package/dist/cli.js +19 -0
  146. package/dist/config.js +288 -0
  147. package/dist/core/abort.js +15 -0
  148. package/dist/core/agent-loop.js +352 -0
  149. package/dist/core/agent-session.js +2019 -0
  150. package/dist/core/agent.js +410 -0
  151. package/dist/core/auth-storage.js +456 -0
  152. package/dist/core/bash-executor.js +222 -0
  153. package/dist/core/compaction/branch-summarization.js +242 -0
  154. package/dist/core/compaction/compaction.js +610 -0
  155. package/dist/core/compaction/index.js +7 -0
  156. package/dist/core/compaction/utils.js +139 -0
  157. package/dist/core/defaults.js +6 -0
  158. package/dist/core/diagnostics.js +2 -0
  159. package/dist/core/event-bus.js +25 -0
  160. package/dist/core/exec.js +71 -0
  161. package/dist/core/export-html/ansi-to-html.js +256 -0
  162. package/dist/core/export-html/index.js +238 -0
  163. package/dist/core/export-html/session-view-model.js +342 -0
  164. package/dist/core/export-html/template.css +1110 -0
  165. package/dist/core/export-html/template.html +76 -0
  166. package/dist/core/export-html/template.js +1990 -0
  167. package/dist/core/export-html/tool-renderer.js +63 -0
  168. package/dist/core/export-html/vendor/highlight.min.js +7725 -0
  169. package/dist/core/export-html/vendor/marked.min.js +1803 -0
  170. package/dist/core/extensions/index.js +9 -0
  171. package/dist/core/extensions/loader.js +422 -0
  172. package/dist/core/extensions/runner.js +651 -0
  173. package/dist/core/extensions/types.js +35 -0
  174. package/dist/core/extensions/wrapper.js +102 -0
  175. package/dist/core/footer-data-provider.js +162 -0
  176. package/dist/core/index.js +9 -0
  177. package/dist/core/keybindings.js +153 -0
  178. package/dist/core/messages.js +133 -0
  179. package/dist/core/model-registry.js +539 -0
  180. package/dist/core/model-resolver.js +370 -0
  181. package/dist/core/package-manager.js +1485 -0
  182. package/dist/core/prompt-templates.js +253 -0
  183. package/dist/core/resolve-config-value.js +59 -0
  184. package/dist/core/resource-loader.js +700 -0
  185. package/dist/core/sdk.js +197 -0
  186. package/dist/core/session-bash.js +99 -0
  187. package/dist/core/session-compaction.js +165 -0
  188. package/dist/core/session-manager.js +1153 -0
  189. package/dist/core/session-models.js +99 -0
  190. package/dist/core/session-retry.js +155 -0
  191. package/dist/core/settings-manager.js +572 -0
  192. package/dist/core/skills.js +382 -0
  193. package/dist/core/slash-commands.js +31 -0
  194. package/dist/core/system-prompt.js +161 -0
  195. package/dist/core/theme.js +770 -0
  196. package/dist/core/timings.js +26 -0
  197. package/dist/core/tools/bash.js +258 -0
  198. package/dist/core/tools/edit-diff.js +245 -0
  199. package/dist/core/tools/edit.js +148 -0
  200. package/dist/core/tools/find.js +208 -0
  201. package/dist/core/tools/grep.js +246 -0
  202. package/dist/core/tools/index.js +67 -0
  203. package/dist/core/tools/ls.js +123 -0
  204. package/dist/core/tools/path-utils.js +81 -0
  205. package/dist/core/tools/read.js +160 -0
  206. package/dist/core/tools/truncate.js +70 -0
  207. package/dist/core/tools/write.js +82 -0
  208. package/dist/custom/agents/action.js +13 -0
  209. package/dist/custom/agents/document-reader.js +70 -0
  210. package/dist/custom/agents/general.js +26 -0
  211. package/dist/custom/agents/index.js +49 -0
  212. package/dist/custom/agents/installation.js +13 -0
  213. package/dist/custom/agents/types.js +7 -0
  214. package/dist/custom/auth/refresh-timer.js +33 -0
  215. package/dist/custom/auth/shortcut-oauth.js +145 -0
  216. package/dist/custom/constants.js +21 -0
  217. package/dist/custom/context/workbook-summary.js +73 -0
  218. package/dist/custom/credits/shortcut-credits.js +29 -0
  219. package/dist/custom/cron/cron-daemon-entry.js +18 -0
  220. package/dist/custom/cron/daemon-ipc.js +131 -0
  221. package/dist/custom/cron/daemon.js +224 -0
  222. package/dist/custom/cron/jobs.js +226 -0
  223. package/dist/custom/cron/run-log.js +51 -0
  224. package/dist/custom/cron/schedule.js +72 -0
  225. package/dist/custom/cron/status-line.js +98 -0
  226. package/dist/custom/cron/store.js +87 -0
  227. package/dist/custom/cron/types.js +8 -0
  228. package/dist/custom/dev/index.js +59 -0
  229. package/dist/custom/dev/trace-export.js +58 -0
  230. package/dist/custom/ensure-excel.js +63 -0
  231. package/dist/custom/excel-config.js +36 -0
  232. package/dist/custom/preflight.js +422 -0
  233. package/dist/custom/prompts/action.js +100 -0
  234. package/dist/custom/prompts/api.js +66 -0
  235. package/dist/custom/prompts/installation.js +124 -0
  236. package/dist/custom/prompts/shared.js +138 -0
  237. package/dist/custom/providers/llm-usage.js +42 -0
  238. package/dist/custom/providers/message-converter.js +74 -0
  239. package/dist/custom/providers/provider-ids.js +9 -0
  240. package/dist/custom/providers/register-openai-codex-provider.js +27 -0
  241. package/dist/custom/providers/register-shortcut-provider.js +52 -0
  242. package/dist/custom/providers/shortcut-invoke.js +117 -0
  243. package/dist/custom/providers/shortcut-stream.js +252 -0
  244. package/dist/custom/providers/sse-protocol.js +38 -0
  245. package/dist/custom/sync-xll.js +130 -0
  246. package/dist/custom/tools/cron.js +413 -0
  247. package/dist/custom/tools/excel-exec.js +167 -0
  248. package/dist/custom/tools/excel-range.js +50 -0
  249. package/dist/custom/tools/llm-analysis.js +265 -0
  250. package/dist/custom/tools/render-helpers.js +38 -0
  251. package/dist/custom/tools/switch-mode.js +94 -0
  252. package/dist/custom/tools/task/agents.js +6 -0
  253. package/dist/custom/tools/task/index.js +8 -0
  254. package/dist/custom/tools/task/render.js +348 -0
  255. package/dist/custom/tools/task/subprocess.js +320 -0
  256. package/dist/custom/tools/task/task.js +205 -0
  257. package/dist/custom/tools/todo-list.js +195 -0
  258. package/dist/custom/tracing/session-upload.js +93 -0
  259. package/dist/index.js +45 -0
  260. package/dist/main.js +613 -0
  261. package/dist/migrations.js +265 -0
  262. package/dist/modes/index.js +8 -0
  263. package/dist/modes/interactive/components/armin.js +337 -0
  264. package/dist/modes/interactive/components/assistant-message.js +94 -0
  265. package/dist/modes/interactive/components/bash-execution.js +171 -0
  266. package/dist/modes/interactive/components/bordered-loader.js +51 -0
  267. package/dist/modes/interactive/components/branch-summary-message.js +45 -0
  268. package/dist/modes/interactive/components/compaction-summary-message.js +46 -0
  269. package/dist/modes/interactive/components/config-selector.js +488 -0
  270. package/dist/modes/interactive/components/countdown-timer.js +33 -0
  271. package/dist/modes/interactive/components/custom-editor.js +93 -0
  272. package/dist/modes/interactive/components/custom-message.js +81 -0
  273. package/dist/modes/interactive/components/daxnuts.js +140 -0
  274. package/dist/modes/interactive/components/diff.js +133 -0
  275. package/dist/modes/interactive/components/dynamic-border.js +21 -0
  276. package/dist/modes/interactive/components/extension-editor.js +105 -0
  277. package/dist/modes/interactive/components/extension-input.js +61 -0
  278. package/dist/modes/interactive/components/extension-selector.js +78 -0
  279. package/dist/modes/interactive/components/footer.js +309 -0
  280. package/dist/modes/interactive/components/index.js +33 -0
  281. package/dist/modes/interactive/components/keybinding-hints.js +61 -0
  282. package/dist/modes/interactive/components/layout.js +64 -0
  283. package/dist/modes/interactive/components/login-dialog.js +148 -0
  284. package/dist/modes/interactive/components/model-selector.js +237 -0
  285. package/dist/modes/interactive/components/oauth-selector.js +111 -0
  286. package/dist/modes/interactive/components/session-selector-search.js +157 -0
  287. package/dist/modes/interactive/components/session-selector.js +860 -0
  288. package/dist/modes/interactive/components/settings-selector.js +123 -0
  289. package/dist/modes/interactive/components/show-images-selector.js +35 -0
  290. package/dist/modes/interactive/components/skill-invocation-message.js +48 -0
  291. package/dist/modes/interactive/components/theme-selector.js +47 -0
  292. package/dist/modes/interactive/components/thinking-selector.js +47 -0
  293. package/dist/modes/interactive/components/tool-execution.js +789 -0
  294. package/dist/modes/interactive/components/tool-group.js +106 -0
  295. package/dist/modes/interactive/components/tree-selector.js +962 -0
  296. package/dist/modes/interactive/components/user-message-selector.js +115 -0
  297. package/dist/modes/interactive/components/user-message.js +48 -0
  298. package/dist/modes/interactive/components/visual-truncate.js +33 -0
  299. package/dist/modes/interactive/file-attachments.js +135 -0
  300. package/dist/modes/interactive/interactive-mode.js +3775 -0
  301. package/dist/modes/interactive/theme/dark.json +85 -0
  302. package/dist/modes/interactive/theme/light.json +85 -0
  303. package/dist/modes/interactive/theme/theme-schema.json +335 -0
  304. package/dist/modes/interactive/theme/theme.js +177 -0
  305. package/dist/modes/print-mode.js +101 -0
  306. package/dist/modes/rpc/rpc-client.js +387 -0
  307. package/dist/modes/rpc/rpc-mode.js +509 -0
  308. package/dist/modes/rpc/rpc-types.js +8 -0
  309. package/dist/subagent-entry.js +145 -0
  310. package/dist/tool-names.js +34 -0
  311. package/dist/tui/autocomplete.js +596 -0
  312. package/dist/tui/components/box.js +104 -0
  313. package/dist/tui/components/cancellable-loader.js +35 -0
  314. package/dist/tui/components/editor.js +1679 -0
  315. package/dist/tui/components/image.js +69 -0
  316. package/dist/tui/components/input.js +433 -0
  317. package/dist/tui/components/loader.js +49 -0
  318. package/dist/tui/components/markdown.js +629 -0
  319. package/dist/tui/components/select-list.js +152 -0
  320. package/dist/tui/components/settings-list.js +185 -0
  321. package/dist/tui/components/spacer.js +23 -0
  322. package/dist/tui/components/text.js +89 -0
  323. package/dist/tui/components/truncated-text.js +51 -0
  324. package/dist/tui/editor-component.js +2 -0
  325. package/dist/tui/fuzzy.js +107 -0
  326. package/dist/tui/get-east-asian-width/index.js +32 -0
  327. package/dist/tui/get-east-asian-width/lookup.js +404 -0
  328. package/dist/tui/index.js +32 -0
  329. package/dist/tui/keybindings.js +114 -0
  330. package/dist/tui/keys.js +959 -0
  331. package/dist/tui/kill-ring.js +44 -0
  332. package/dist/tui/stdin-buffer.js +317 -0
  333. package/dist/tui/terminal-image.js +288 -0
  334. package/dist/tui/terminal.js +249 -0
  335. package/dist/tui/tui/autocomplete.js +596 -0
  336. package/dist/tui/tui/components/box.js +106 -0
  337. package/dist/tui/tui/components/cancellable-loader.js +35 -0
  338. package/dist/tui/tui/components/editor.js +1679 -0
  339. package/dist/tui/tui/components/image.js +69 -0
  340. package/dist/tui/tui/components/input.js +433 -0
  341. package/dist/tui/tui/components/loader.js +49 -0
  342. package/dist/tui/tui/components/markdown.js +629 -0
  343. package/dist/tui/tui/components/select-list.js +152 -0
  344. package/dist/tui/tui/components/settings-list.js +185 -0
  345. package/dist/tui/tui/components/spacer.js +23 -0
  346. package/dist/tui/tui/components/text.js +91 -0
  347. package/dist/tui/tui/components/truncated-text.js +51 -0
  348. package/dist/tui/tui/editor-component.js +2 -0
  349. package/dist/tui/tui/fuzzy.js +107 -0
  350. package/dist/tui/tui/get-east-asian-width/index.js +32 -0
  351. package/dist/tui/tui/get-east-asian-width/lookup.js +404 -0
  352. package/dist/tui/tui/index.js +32 -0
  353. package/dist/tui/tui/keybindings.js +114 -0
  354. package/dist/tui/tui/keys.js +959 -0
  355. package/dist/tui/tui/kill-ring.js +44 -0
  356. package/dist/tui/tui/stdin-buffer.js +317 -0
  357. package/dist/tui/tui/terminal-image.js +288 -0
  358. package/dist/tui/tui/terminal.js +249 -0
  359. package/dist/tui/tui/tui.js +955 -0
  360. package/dist/tui/tui/undo-stack.js +25 -0
  361. package/dist/tui/tui/utils.js +800 -0
  362. package/dist/tui/tui.js +955 -0
  363. package/dist/tui/undo-stack.js +25 -0
  364. package/dist/tui/utils.js +800 -0
  365. package/dist/utils/changelog.js +87 -0
  366. package/dist/utils/clipboard-image.js +164 -0
  367. package/dist/utils/clipboard-native.js +14 -0
  368. package/dist/utils/clipboard.js +67 -0
  369. package/dist/utils/frontmatter.js +26 -0
  370. package/dist/utils/git.js +166 -0
  371. package/dist/utils/image-convert.js +35 -0
  372. package/dist/utils/image-resize.js +183 -0
  373. package/dist/utils/mime.js +26 -0
  374. package/dist/utils/photon.js +121 -0
  375. package/dist/utils/shell.js +217 -0
  376. package/dist/utils/sleep.js +17 -0
  377. package/dist/utils/tools-manager.js +259 -0
  378. package/package.json +78 -0
  379. package/skills/excel-com-api/SKILL.md +74 -0
  380. package/skills/excel-com-api/excel-type-library.py +27767 -0
  381. package/skills/excel-com-api/office-type-library.py +10867 -0
  382. package/skills/integrations/SKILL.md +138 -0
  383. package/skills/integrations/alphasense.md +457 -0
  384. package/skills/integrations/bloomberg.md +803 -0
  385. package/skills/integrations/calcbench.md +315 -0
  386. package/skills/integrations/capiq.md +848 -0
  387. package/skills/integrations/dynamics-365-finance.md +354 -0
  388. package/skills/integrations/earnings_transcripts.md +387 -0
  389. package/skills/integrations/factset.md +758 -0
  390. package/skills/integrations/ice-fixed-income.md +344 -0
  391. package/skills/integrations/moodys-analytics.md +313 -0
  392. package/skills/integrations/morningstar.md +433 -0
  393. package/skills/integrations/nasdaq-data-link.md +249 -0
  394. package/skills/integrations/pitchbook.md +413 -0
  395. package/skills/integrations/preqin.md +422 -0
  396. package/skills/integrations/quickbooks.md +289 -0
  397. package/skills/integrations/quickfs.md +314 -0
  398. package/skills/integrations/refinitiv.md +473 -0
  399. package/skills/integrations/sage-intacct.md +401 -0
  400. package/skills/integrations/visible-alpha.md +320 -0
  401. package/skills/integrations/xero.md +393 -0
  402. package/skills/integrations/ycharts.md +306 -0
  403. package/skills/pdf-creation/SKILL.md +93 -0
  404. package/skills/pdf-extraction/SKILL.md +32 -0
  405. package/skills/powerpoint-creation/SKILL.md +110 -0
  406. package/skills/sec-edgar/SKILL.md +127 -0
  407. package/skills/sec-edgar/sec_to_pdf.py +109 -0
  408. package/xll/ShortcutXL.xll +0 -0
  409. package/xll/modules/debug_render.py +272 -0
  410. package/xll/modules/gameboy.py +241 -0
  411. package/xll/modules/pong.py +188 -0
  412. package/xll/modules/shortcut_xl/__init__.py +18 -0
  413. package/xll/modules/shortcut_xl/_categorize.py +200 -0
  414. package/xll/modules/shortcut_xl/_com.py +108 -0
  415. package/xll/modules/shortcut_xl/_format.py +252 -0
  416. package/xll/modules/shortcut_xl/_log.py +12 -0
  417. package/xll/modules/shortcut_xl/_managed.py +116 -0
  418. package/xll/modules/shortcut_xl/_registry.py +44 -0
  419. package/xll/modules/shortcut_xl/_threading.py +161 -0
  420. package/xll/modules/shortcut_xl/_tracking.py +283 -0
  421. package/xll/modules/stocks.py +100 -0
  422. package/xll/python3.dll +0 -0
  423. package/xll/python312.dll +0 -0
package/dist/main.js ADDED
@@ -0,0 +1,613 @@
1
+ /**
2
+ * Main entry point for the coding agent CLI.
3
+ *
4
+ * This file handles CLI argument parsing and translates them into
5
+ * createAgentSession() options. The SDK does the heavy lifting.
6
+ */
7
+ import { supportsXhigh } from '@mariozechner/pi-ai';
8
+ import chalk from 'chalk';
9
+ import { spawn } from 'child_process';
10
+ import { createInterface } from 'readline';
11
+ import { parseArgs, printHelp } from './cli/args.js';
12
+ import { selectConfig } from './cli/config-selector.js';
13
+ import { processFileArguments } from './cli/file-processor.js';
14
+ import { listModels } from './cli/list-models.js';
15
+ import { handlePackageCommand } from './cli/package-commands.js';
16
+ import { reportSettingsErrors } from './cli/report-settings-errors.js';
17
+ import { selectSession } from './cli/session-picker.js';
18
+ import { getAgentDir, getModelsPath, getUpdateCommand, NPM_PACKAGE_NAME, NPM_REGISTRY_URL, VERSION } from './config.js';
19
+ import { AuthStorage } from './core/auth-storage.js';
20
+ // SHORTCUT PATCH: removed DEFAULT_THINKING_LEVEL import (no longer needed without scoped models)
21
+ import { DEV_MODE, isInstalled } from './config.js';
22
+ import { exportFromFile } from './core/export-html/index.js';
23
+ import { KeybindingsManager } from './core/keybindings.js';
24
+ import { ModelRegistry } from './core/model-registry.js';
25
+ import { resolveCliModel } from './core/model-resolver.js';
26
+ import { DefaultPackageManager } from './core/package-manager.js';
27
+ import { DefaultResourceLoader } from './core/resource-loader.js';
28
+ import { createAgentSession } from './core/sdk.js';
29
+ import { SessionManager } from './core/session-manager.js';
30
+ import { SettingsManager } from './core/settings-manager.js';
31
+ import { initTheme, stopThemeWatcher } from './core/theme.js';
32
+ import { printTimings, time } from './core/timings.js';
33
+ import { allTools } from './core/tools/index.js';
34
+ import { actionAgent, installationAgent } from './custom/agents/index.js';
35
+ import { startProactiveRefresh } from './custom/auth/refresh-timer.js';
36
+ import { EXCEL_HTTP_URL, SHORTCUT_LLM_PROXY_URL } from './custom/constants.js';
37
+ import { fetchWorkbookSummary, formatSummaryForLlm, parseWorkbookNames } from './custom/context/workbook-summary.js';
38
+ import { fetchCreditBalance } from './custom/credits/shortcut-credits.js';
39
+ import { startCronStatusPolling } from './custom/cron/status-line.js';
40
+ import { getDevHooks } from './custom/dev/index.js';
41
+ import { runPreflight } from './custom/preflight.js';
42
+ import { SHORTCUT_PROVIDER_ID } from './custom/providers/provider-ids.js';
43
+ // TODO: Re-enable when we support multiple providers
44
+ // import { registerOpenAICodexProvider } from './custom/providers/register-openai-codex-provider.js';
45
+ import { registerShortcutProvider } from './custom/providers/register-shortcut-provider.js';
46
+ import { syncXll } from './custom/sync-xll.js';
47
+ import { createCronTool } from './custom/tools/cron.js';
48
+ import { createExcelExecTool } from './custom/tools/excel-exec.js';
49
+ import { createLlmAnalysisTool } from './custom/tools/llm-analysis.js';
50
+ import { createSwitchModeTool, setCurrentMode } from './custom/tools/switch-mode.js';
51
+ import { createTaskTool } from './custom/tools/task/index.js';
52
+ import { createTodoListTool, setTodoWidget } from './custom/tools/todo-list.js';
53
+ import { attachSessionUpload } from './custom/tracing/session-upload.js';
54
+ import { runMigrations, showDeprecationWarnings } from './migrations.js';
55
+ import { InteractiveMode, runPrintMode, runRpcMode } from './modes/index.js';
56
+ import { runSubagent } from './subagent-entry.js';
57
+ import { CRON, EXCEL_EXEC, LLM_ANALYSIS, SWITCH_MODE, TASK, TODO_LIST } from './tool-names.js';
58
+ /**
59
+ * Read all content from piped stdin.
60
+ * Returns undefined if stdin is a TTY (interactive terminal).
61
+ */
62
+ async function readPipedStdin() {
63
+ // If stdin is a TTY, we're running interactively - don't read stdin
64
+ if (process.stdin.isTTY) {
65
+ return undefined;
66
+ }
67
+ return new Promise((resolve) => {
68
+ let data = '';
69
+ process.stdin.setEncoding('utf8');
70
+ process.stdin.on('data', (chunk) => {
71
+ data += chunk;
72
+ });
73
+ process.stdin.on('end', () => {
74
+ resolve(data.trim() || undefined);
75
+ });
76
+ process.stdin.resume();
77
+ });
78
+ }
79
+ function isTruthyEnvFlag(value) {
80
+ if (!value)
81
+ return false;
82
+ return value === '1' || value.toLowerCase() === 'true' || value.toLowerCase() === 'yes';
83
+ }
84
+ async function prepareInitialMessage(parsed, autoResizeImages) {
85
+ if (parsed.fileArgs.length === 0) {
86
+ return {};
87
+ }
88
+ const { text, images } = await processFileArguments(parsed.fileArgs, { autoResizeImages });
89
+ let initialMessage;
90
+ if (parsed.messages.length > 0) {
91
+ initialMessage = text + parsed.messages[0];
92
+ parsed.messages.shift();
93
+ }
94
+ else {
95
+ initialMessage = text;
96
+ }
97
+ return {
98
+ initialMessage,
99
+ initialImages: images.length > 0 ? images : undefined
100
+ };
101
+ }
102
+ /**
103
+ * Resolve a session argument to a file path.
104
+ * If it looks like a path, use as-is. Otherwise try to match as session ID prefix.
105
+ */
106
+ async function resolveSessionPath(sessionArg, cwd, sessionDir) {
107
+ // If it looks like a file path, use as-is
108
+ if (sessionArg.includes('/') || sessionArg.includes('\\') || sessionArg.endsWith('.jsonl')) {
109
+ return { type: 'path', path: sessionArg };
110
+ }
111
+ // Try to match as session ID in current project first
112
+ const localSessions = await SessionManager.list(cwd, sessionDir);
113
+ const localMatches = localSessions.filter((s) => s.id.startsWith(sessionArg));
114
+ if (localMatches.length >= 1) {
115
+ return { type: 'local', path: localMatches[0].path };
116
+ }
117
+ // Try global search across all projects
118
+ const allSessions = await SessionManager.listAll();
119
+ const globalMatches = allSessions.filter((s) => s.id.startsWith(sessionArg));
120
+ if (globalMatches.length >= 1) {
121
+ const match = globalMatches[0];
122
+ return { type: 'global', path: match.path, cwd: match.cwd };
123
+ }
124
+ // Not found anywhere
125
+ return { type: 'not_found', arg: sessionArg };
126
+ }
127
+ /** Prompt user for yes/no confirmation */
128
+ async function promptConfirm(message) {
129
+ return new Promise((resolve) => {
130
+ const rl = createInterface({
131
+ input: process.stdin,
132
+ output: process.stdout
133
+ });
134
+ rl.question(`${message} [y/N] `, (answer) => {
135
+ rl.close();
136
+ resolve(answer.toLowerCase() === 'y' || answer.toLowerCase() === 'yes');
137
+ });
138
+ });
139
+ }
140
+ async function createSessionManager(parsed, cwd) {
141
+ if (parsed.noSession) {
142
+ return SessionManager.inMemory();
143
+ }
144
+ if (parsed.session) {
145
+ const resolved = await resolveSessionPath(parsed.session, cwd, parsed.sessionDir);
146
+ switch (resolved.type) {
147
+ case 'path':
148
+ case 'local':
149
+ return SessionManager.open(resolved.path, parsed.sessionDir);
150
+ case 'global': {
151
+ // Session found in different project - ask user if they want to fork
152
+ console.log(chalk.yellow(`Session found in different project: ${resolved.cwd}`));
153
+ const shouldFork = await promptConfirm('Fork this session into current directory?');
154
+ if (!shouldFork) {
155
+ console.log(chalk.dim('Aborted.'));
156
+ process.exit(0);
157
+ }
158
+ return SessionManager.forkFrom(resolved.path, cwd, parsed.sessionDir);
159
+ }
160
+ case 'not_found':
161
+ console.error(chalk.red(`No session found matching '${resolved.arg}'`));
162
+ process.exit(1);
163
+ }
164
+ }
165
+ if (parsed.continue) {
166
+ return SessionManager.continueRecent(cwd, parsed.sessionDir);
167
+ }
168
+ // --resume is handled separately (needs picker UI)
169
+ // If --session-dir provided without --continue/--resume, create new session there
170
+ if (parsed.sessionDir) {
171
+ return SessionManager.create(cwd, parsed.sessionDir);
172
+ }
173
+ // Default case (new session) returns undefined, SDK will create one
174
+ return undefined;
175
+ }
176
+ // Lazy reference — set during main(), used by tools via closures
177
+ let sessionRef = null;
178
+ // SHORTCUT PATCH: simplified buildSessionOptions — removed scopedModels parameter
179
+ function buildSessionOptions(parsed, sessionManager, modelRegistry, _settingsManager) {
180
+ const options = {};
181
+ let cliThinkingFromModel = false;
182
+ if (sessionManager) {
183
+ options.sessionManager = sessionManager;
184
+ }
185
+ // Model from CLI
186
+ // - supports --provider <name> --model <pattern>
187
+ // - supports --model <provider>/<pattern>
188
+ if (parsed.model) {
189
+ const resolved = resolveCliModel({
190
+ cliProvider: parsed.provider,
191
+ cliModel: parsed.model,
192
+ modelRegistry
193
+ });
194
+ if (resolved.warning) {
195
+ console.warn(chalk.yellow(`Warning: ${resolved.warning}`));
196
+ }
197
+ if (resolved.error) {
198
+ console.error(chalk.red(resolved.error));
199
+ process.exit(1);
200
+ }
201
+ if (resolved.model) {
202
+ options.model = resolved.model;
203
+ // Allow "--model <pattern>:<thinking>" as a shorthand.
204
+ // Explicit --thinking still takes precedence (applied later).
205
+ if (!parsed.thinking && resolved.thinkingLevel) {
206
+ options.thinkingLevel = resolved.thinkingLevel;
207
+ cliThinkingFromModel = true;
208
+ }
209
+ }
210
+ }
211
+ // Thinking level from CLI
212
+ if (parsed.thinking) {
213
+ options.thinkingLevel = parsed.thinking;
214
+ }
215
+ // API key from CLI - set in authStorage
216
+ // (handled by caller before createAgentSession)
217
+ // Tools
218
+ if (parsed.noTools) {
219
+ // --no-tools: start with no built-in tools
220
+ // --tools can still add specific ones back
221
+ if (parsed.tools && parsed.tools.length > 0) {
222
+ options.tools = parsed.tools.map((name) => allTools[name]);
223
+ }
224
+ else {
225
+ options.tools = [];
226
+ }
227
+ }
228
+ else if (parsed.tools) {
229
+ options.tools = parsed.tools.map((name) => allTools[name]);
230
+ }
231
+ // Register custom tools.
232
+ // --no-custom-tools: register nothing (used by subagents that need no custom tools).
233
+ // --custom-tools <names>: register only the named tools (comma-separated).
234
+ // Unset: register all (default for interactive use).
235
+ const availableCustomTools = [];
236
+ if (!parsed.noCustomTools) {
237
+ const customToolSet = parsed.customTools ? new Set(parsed.customTools) : null;
238
+ if (!customToolSet || customToolSet.has(EXCEL_EXEC)) {
239
+ availableCustomTools.push(createExcelExecTool(EXCEL_HTTP_URL));
240
+ }
241
+ if (!customToolSet || customToolSet.has(TASK)) {
242
+ availableCustomTools.push(createTaskTool());
243
+ }
244
+ if (!customToolSet || customToolSet.has(TODO_LIST)) {
245
+ availableCustomTools.push(createTodoListTool());
246
+ }
247
+ if (!customToolSet || customToolSet.has(CRON)) {
248
+ availableCustomTools.push(createCronTool());
249
+ }
250
+ if (!customToolSet || customToolSet.has(SWITCH_MODE)) {
251
+ availableCustomTools.push(createSwitchModeTool(() => sessionRef));
252
+ }
253
+ if (!customToolSet || customToolSet.has(LLM_ANALYSIS)) {
254
+ availableCustomTools.push(createLlmAnalysisTool(SHORTCUT_LLM_PROXY_URL));
255
+ }
256
+ }
257
+ options.customTools = [...(options.customTools ?? []), ...availableCustomTools];
258
+ return { options, cliThinkingFromModel };
259
+ }
260
+ async function handleConfigCommand(args) {
261
+ if (args[0] !== 'config') {
262
+ return false;
263
+ }
264
+ const cwd = process.cwd();
265
+ const agentDir = getAgentDir();
266
+ const settingsManager = SettingsManager.create(cwd, agentDir);
267
+ reportSettingsErrors(settingsManager, 'config command');
268
+ const packageManager = new DefaultPackageManager({ cwd, agentDir, settingsManager });
269
+ const resolvedPaths = await packageManager.resolve();
270
+ await selectConfig({
271
+ resolvedPaths,
272
+ settingsManager,
273
+ cwd,
274
+ agentDir
275
+ });
276
+ process.exit(0);
277
+ }
278
+ /**
279
+ * Check for a newer version and install it in the background.
280
+ * The update takes effect on the next launch — no re-exec needed.
281
+ */
282
+ function backgroundAutoUpdate() {
283
+ if (process.env.SHORTCUT_SKIP_VERSION_CHECK || process.env.SHORTCUT_OFFLINE)
284
+ return;
285
+ const command = getUpdateCommand(NPM_PACKAGE_NAME);
286
+ if (!command)
287
+ return; // bun-binary — can't auto-update
288
+ fetch(NPM_REGISTRY_URL, { signal: AbortSignal.timeout(10_000) })
289
+ .then((res) => (res.ok ? res.json() : undefined))
290
+ .then((data) => {
291
+ const latest = data?.version;
292
+ if (!latest || latest === VERSION)
293
+ return;
294
+ // Install in background — fire and forget
295
+ const child = spawn(command, {
296
+ shell: true,
297
+ stdio: 'ignore',
298
+ detached: true
299
+ });
300
+ child.unref();
301
+ })
302
+ .catch(() => {
303
+ // Silent — network errors, timeouts, etc.
304
+ });
305
+ }
306
+ export async function main(args) {
307
+ // Fast path for subagent child processes — skip all heavy startup
308
+ if (args.includes('--subagent')) {
309
+ return runSubagent(args.filter((a) => a !== '--subagent'));
310
+ }
311
+ // Fast path for cron daemon — minimal startup, no TUI, no tools
312
+ if (args[0] === 'cron-daemon') {
313
+ const { runCronDaemon } = await import('./custom/cron/cron-daemon-entry.js');
314
+ return runCronDaemon();
315
+ }
316
+ const offlineMode = args.includes('--offline') || isTruthyEnvFlag(process.env.SHORTCUT_OFFLINE);
317
+ if (offlineMode) {
318
+ process.env.SHORTCUT_OFFLINE = '1';
319
+ process.env.SHORTCUT_SKIP_VERSION_CHECK = '1';
320
+ }
321
+ // Auto-update in background — takes effect on next launch
322
+ backgroundAutoUpdate();
323
+ if (await handlePackageCommand(args)) {
324
+ return;
325
+ }
326
+ if (await handleConfigCommand(args)) {
327
+ return;
328
+ }
329
+ // Run migrations (pass cwd for project-local migrations)
330
+ const { migratedAuthProviders: migratedProviders, deprecationWarnings } = runMigrations(process.cwd());
331
+ // First pass: parse args to get --extension paths
332
+ const firstPass = parseArgs(args);
333
+ // Early load extensions to discover their CLI flags
334
+ const cwd = process.cwd();
335
+ const agentDir = getAgentDir();
336
+ const settingsManager = SettingsManager.create(cwd, agentDir);
337
+ reportSettingsErrors(settingsManager, 'startup');
338
+ const authStorage = AuthStorage.create();
339
+ const modelRegistry = new ModelRegistry(authStorage, getModelsPath());
340
+ // Pick the initial agent based on installation state
341
+ const needsSetup = !isInstalled();
342
+ const startupWarnings = [];
343
+ const startupInfos = [];
344
+ // Sync shipped XLL binaries to the stable user-local directory.
345
+ // This ensures ~/.shortcut/agent/xll/ always has the latest version,
346
+ // regardless of where npm installed the package.
347
+ const { updated: xllFilesUpdated, xllReady } = syncXll();
348
+ if (xllFilesUpdated > 0 && DEV_MODE) {
349
+ startupWarnings.push(`Updated ${xllFilesUpdated} XLL file(s) in ${getAgentDir()}/xll/`);
350
+ }
351
+ if (!xllReady && needsSetup) {
352
+ console.error(chalk.red('Error: ShortcutXL.xll could not be synced to the stable directory.'));
353
+ console.error(chalk.red(`Expected at: ${getAgentDir()}/xll/ShortcutXL.xll`));
354
+ console.error(chalk.yellow('Check that the npm package installed correctly and try again.'));
355
+ process.exit(1);
356
+ }
357
+ if (!xllReady && !needsSetup) {
358
+ startupWarnings.push('XLL sync failed, but a previous installation exists. Continuing with existing files.');
359
+ }
360
+ // Deterministic pre-flight: auto-install Git Bash, Python, registry key,
361
+ // launch Excel, and run smoke test. Regardless of outcome, the installation
362
+ // agent always runs afterward to verify everything is set up correctly.
363
+ let preflightComplete = false;
364
+ if (needsSetup) {
365
+ preflightComplete = await runPreflight();
366
+ startupInfos.push('Setting up ShortcutXL...');
367
+ }
368
+ let systemPrompt;
369
+ let initialAgent;
370
+ if (firstPass.systemPrompt) {
371
+ systemPrompt = firstPass.systemPrompt;
372
+ }
373
+ else if (needsSetup) {
374
+ initialAgent = installationAgent();
375
+ systemPrompt = initialAgent.systemPrompt;
376
+ }
377
+ else {
378
+ initialAgent = actionAgent();
379
+ systemPrompt = initialAgent.systemPrompt;
380
+ }
381
+ const resourceLoader = new DefaultResourceLoader({
382
+ cwd,
383
+ agentDir,
384
+ settingsManager,
385
+ additionalExtensionPaths: firstPass.extensions,
386
+ additionalSkillPaths: firstPass.skills,
387
+ additionalPromptTemplatePaths: firstPass.promptTemplates,
388
+ additionalThemePaths: firstPass.themes,
389
+ noExtensions: firstPass.noExtensions,
390
+ noSkills: firstPass.noSkills,
391
+ noPromptTemplates: firstPass.noPromptTemplates,
392
+ noThemes: firstPass.noThemes,
393
+ systemPrompt,
394
+ appendSystemPrompt: firstPass.appendSystemPrompt,
395
+ // AGENTS.md / CLAUDE.md context files are dev-only (not useful for end users)
396
+ agentsFilesOverride: DEV_MODE ? undefined : () => ({ agentsFiles: [] })
397
+ });
398
+ await resourceLoader.reload();
399
+ time('resourceLoader.reload');
400
+ const extensionsResult = resourceLoader.getExtensions();
401
+ for (const { path, error } of extensionsResult.errors) {
402
+ console.error(chalk.red(`Failed to load extension "${path}": ${error}`));
403
+ }
404
+ // Apply pending provider registrations from extensions immediately
405
+ // so they're available for model resolution before AgentSession is created
406
+ for (const { name, config } of extensionsResult.runtime.pendingProviderRegistrations) {
407
+ modelRegistry.registerProvider(name, config);
408
+ }
409
+ extensionsResult.runtime.pendingProviderRegistrations = [];
410
+ // Register Shortcut as a provider with custom stream through the Python backend
411
+ registerShortcutProvider(modelRegistry, SHORTCUT_LLM_PROXY_URL);
412
+ // Keep Shortcut OAuth tokens fresh while the TUI is idle.
413
+ // Without this, the access token (7-min TTL on staging) expires silently
414
+ // and the next LLM request fails with 401.
415
+ startProactiveRefresh(authStorage, SHORTCUT_PROVIDER_ID);
416
+ // TODO: Re-enable when we support multiple providers
417
+ // Register OpenAI Codex provider (ChatGPT Plus/Pro OAuth, gpt-5.4)
418
+ // registerOpenAICodexProvider(modelRegistry);
419
+ const extensionFlags = new Map();
420
+ for (const ext of extensionsResult.extensions) {
421
+ for (const [name, flag] of ext.flags) {
422
+ extensionFlags.set(name, { type: flag.type });
423
+ }
424
+ }
425
+ // Second pass: parse args with extension flags
426
+ const parsed = parseArgs(args, extensionFlags);
427
+ // Pass flag values to extensions via runtime
428
+ for (const [name, value] of parsed.unknownFlags) {
429
+ extensionsResult.runtime.flagValues.set(name, value);
430
+ }
431
+ if (parsed.version) {
432
+ console.log(VERSION);
433
+ process.exit(0);
434
+ }
435
+ if (parsed.help) {
436
+ printHelp();
437
+ process.exit(0);
438
+ }
439
+ if (parsed.listModels !== undefined) {
440
+ const searchPattern = typeof parsed.listModels === 'string' ? parsed.listModels : undefined;
441
+ await listModels(modelRegistry, searchPattern);
442
+ process.exit(0);
443
+ }
444
+ // Read piped stdin content (if any) - skip for RPC mode which uses stdin for JSON-RPC
445
+ if (parsed.mode !== 'rpc') {
446
+ const stdinContent = await readPipedStdin();
447
+ if (stdinContent !== undefined) {
448
+ // Force print mode since interactive mode requires a TTY for keyboard input
449
+ parsed.print = true;
450
+ // Prepend stdin content to messages
451
+ parsed.messages.unshift(stdinContent);
452
+ }
453
+ }
454
+ if (parsed.export) {
455
+ let result;
456
+ try {
457
+ const outputPath = parsed.messages.length > 0 ? parsed.messages[0] : undefined;
458
+ result = await exportFromFile(parsed.export, outputPath);
459
+ }
460
+ catch (error) {
461
+ const message = error instanceof Error ? error.message : 'Failed to export session';
462
+ console.error(chalk.red(`Error: ${message}`));
463
+ process.exit(1);
464
+ }
465
+ console.log(`Exported to: ${result}`);
466
+ process.exit(0);
467
+ }
468
+ if (parsed.mode === 'rpc' && parsed.fileArgs.length > 0) {
469
+ console.error(chalk.red('Error: @file arguments are not supported in RPC mode'));
470
+ process.exit(1);
471
+ }
472
+ let { initialMessage, initialImages } = await prepareInitialMessage(parsed, settingsManager.getImageAutoResize());
473
+ // Auto-start the installation flow so the user doesn't have to type anything
474
+ if (needsSetup && !initialMessage) {
475
+ initialMessage = 'Start the installation process.';
476
+ }
477
+ const isInteractive = !parsed.print && parsed.mode === undefined;
478
+ const mode = parsed.mode || 'text';
479
+ initTheme(settingsManager.getTheme(), isInteractive);
480
+ // Show deprecation warnings in interactive mode
481
+ if (isInteractive && deprecationWarnings.length > 0) {
482
+ await showDeprecationWarnings(deprecationWarnings);
483
+ }
484
+ // SHORTCUT PATCH: removed scoped models resolution — all authed models available for cycling
485
+ // Create session manager based on CLI flags
486
+ let sessionManager = await createSessionManager(parsed, cwd);
487
+ // Handle --resume: show session picker
488
+ if (parsed.resume) {
489
+ // Initialize keybindings so session picker respects user config
490
+ KeybindingsManager.create();
491
+ const selectedPath = await selectSession((onProgress) => SessionManager.list(cwd, parsed.sessionDir, onProgress), SessionManager.listAll);
492
+ if (!selectedPath) {
493
+ console.log(chalk.dim('No session selected'));
494
+ stopThemeWatcher();
495
+ process.exit(0);
496
+ }
497
+ sessionManager = SessionManager.open(selectedPath);
498
+ }
499
+ const { options: sessionOptions, cliThinkingFromModel } = buildSessionOptions(parsed, sessionManager, modelRegistry, settingsManager);
500
+ sessionOptions.authStorage = authStorage;
501
+ sessionOptions.modelRegistry = modelRegistry;
502
+ sessionOptions.resourceLoader = resourceLoader;
503
+ sessionOptions.prePromptContext = async () => {
504
+ const summary = await fetchWorkbookSummary();
505
+ if (!summary)
506
+ return null;
507
+ return {
508
+ text: formatSummaryForLlm(summary),
509
+ details: { workbooks: parseWorkbookNames(summary) }
510
+ };
511
+ };
512
+ // Handle CLI --api-key as runtime override (not persisted)
513
+ if (parsed.apiKey) {
514
+ if (!sessionOptions.model) {
515
+ console.error(chalk.red('--api-key requires a model to be specified via --model or --provider/--model'));
516
+ process.exit(1);
517
+ }
518
+ authStorage.setRuntimeApiKey(sessionOptions.model.provider, parsed.apiKey);
519
+ }
520
+ const { session, modelFallbackMessage } = await createAgentSession(sessionOptions);
521
+ sessionRef = session;
522
+ // Apply initial agent's tool set and track current mode
523
+ if (initialAgent) {
524
+ session.setActiveToolsByName([...initialAgent.tools]);
525
+ setCurrentMode(initialAgent.name);
526
+ }
527
+ // Trace hooks (always active for /trace command; dev hooks add extra commands)
528
+ const traceHooks = getDevHooks(session);
529
+ const devHooks = DEV_MODE ? traceHooks : undefined;
530
+ // Upload session traces to Shortcut backend for centralized observability.
531
+ // Uses the user's own OAuth token — no shared API keys.
532
+ attachSessionUpload(session, {
533
+ getAccessToken: () => {
534
+ const cred = authStorage.get('shortcut');
535
+ return cred?.type === 'oauth' ? cred.access : undefined;
536
+ }
537
+ });
538
+ if (!isInteractive && !session.model) {
539
+ console.error(chalk.red('No models available.'));
540
+ console.error(chalk.yellow('\nSet an API key environment variable:'));
541
+ console.error(' ANTHROPIC_API_KEY, OPENAI_API_KEY, GEMINI_API_KEY, etc.');
542
+ console.error(chalk.yellow(`\nOr create ${getModelsPath()}`));
543
+ process.exit(1);
544
+ }
545
+ // Clamp thinking level to model capabilities for CLI-provided thinking levels.
546
+ // This covers both --thinking <level> and --model <pattern>:<thinking>.
547
+ const cliThinkingOverride = parsed.thinking !== undefined || cliThinkingFromModel;
548
+ if (session.model && cliThinkingOverride) {
549
+ let effectiveThinking = session.thinkingLevel;
550
+ if (!session.model.reasoning) {
551
+ effectiveThinking = 'off';
552
+ }
553
+ else if (effectiveThinking === 'xhigh' && !supportsXhigh(session.model)) {
554
+ effectiveThinking = 'high';
555
+ }
556
+ if (effectiveThinking !== session.thinkingLevel) {
557
+ session.setThinkingLevel(effectiveThinking);
558
+ }
559
+ }
560
+ // In non-interactive modes, print startup messages to stderr since there's no TUI
561
+ for (const info of startupInfos) {
562
+ console.warn(chalk.dim(info));
563
+ }
564
+ for (const warning of startupWarnings) {
565
+ console.warn(chalk.yellow(warning));
566
+ }
567
+ if (mode === 'rpc') {
568
+ await runRpcMode(session);
569
+ }
570
+ else if (isInteractive) {
571
+ printTimings();
572
+ const mode = new InteractiveMode(session, {
573
+ migratedProviders,
574
+ modelFallbackMessage,
575
+ startupWarnings,
576
+ startupInfos,
577
+ initialMessage,
578
+ initialImages,
579
+ initialMessages: parsed.messages,
580
+ verbose: parsed.verbose,
581
+ fetchCreditBalance: async (apiKey) => {
582
+ const model = session.model;
583
+ if (!model || model.provider !== SHORTCUT_PROVIDER_ID)
584
+ return 'not_applicable';
585
+ return fetchCreditBalance(apiKey);
586
+ },
587
+ // TODO: Re-enable when we support multiple providers
588
+ oauthProviderOrder: [SHORTCUT_PROVIDER_ID],
589
+ extraSlashCommands: devHooks?.slashCommands,
590
+ onDevCommand: traceHooks.onDevCommand,
591
+ onAgentEnd: traceHooks.onAgentEnd,
592
+ onReady: ({ setStatus, setWidget }) => {
593
+ startCronStatusPolling(setStatus);
594
+ setTodoWidget(setWidget);
595
+ }
596
+ });
597
+ await mode.run();
598
+ }
599
+ else {
600
+ await runPrintMode(session, {
601
+ mode,
602
+ messages: parsed.messages,
603
+ initialMessage,
604
+ initialImages
605
+ });
606
+ stopThemeWatcher();
607
+ if (process.stdout.writableLength > 0) {
608
+ await new Promise((resolve) => process.stdout.once('drain', resolve));
609
+ }
610
+ process.exit(0);
611
+ }
612
+ }
613
+ //# sourceMappingURL=main.js.map