@sayknow-cli/coding-agent 0.7.10 → 0.7.12

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 (425) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/types/async/result-formatting.d.ts +2 -0
  3. package/dist/types/capability/fs.d.ts +22 -3
  4. package/dist/types/capability/mcp.d.ts +2 -0
  5. package/dist/types/cli/append-system-prompt.d.ts +6 -0
  6. package/dist/types/cli/update-cli.d.ts +3 -0
  7. package/dist/types/commands/contribution-prep.d.ts +0 -3
  8. package/dist/types/commands/migrate.d.ts +1 -1
  9. package/dist/types/commands/sdk.d.ts +9 -0
  10. package/dist/types/commit/changelog/index.d.ts +1 -0
  11. package/dist/types/config/settings-schema.d.ts +14 -0
  12. package/dist/types/config/settings.d.ts +7 -1
  13. package/dist/types/coordinator-mcp/session-reaper.d.ts +5 -0
  14. package/dist/types/cursor-delete-path.d.ts +1 -0
  15. package/dist/types/cursor-mcp-name.d.ts +8 -0
  16. package/dist/types/dap/config.d.ts +8 -4
  17. package/dist/types/dap/session.d.ts +11 -2
  18. package/dist/types/debug/report-bundle-parent.d.ts +2 -0
  19. package/dist/types/debug/system-info.d.ts +6 -1
  20. package/dist/types/discovery/helpers.d.ts +11 -3
  21. package/dist/types/discovery/mcp-json.d.ts +1 -0
  22. package/dist/types/edit/file-read-cache.d.ts +4 -0
  23. package/dist/types/edit/modes/patch.d.ts +14 -0
  24. package/dist/types/edit/modes/replace.d.ts +8 -0
  25. package/dist/types/eval/py/runtime.d.ts +9 -0
  26. package/dist/types/exa/mcp-client.d.ts +11 -6
  27. package/dist/types/exec/bash-executor.d.ts +18 -1
  28. package/dist/types/export/html/css-color.d.ts +2 -0
  29. package/dist/types/export/html/html-export-destination.d.ts +2 -0
  30. package/dist/types/export/html/template.generated.d.ts +1 -1
  31. package/dist/types/extensibility/custom-tools/loader.d.ts +3 -2
  32. package/dist/types/extensibility/custom-tools/types.d.ts +3 -1
  33. package/dist/types/extensibility/plugins/marketplace/cache.d.ts +2 -0
  34. package/dist/types/extensibility/plugins/plugin-link-path.d.ts +2 -0
  35. package/dist/types/goals/runtime.d.ts +6 -0
  36. package/dist/types/harness-control-plane/receipt-spool.d.ts +4 -0
  37. package/dist/types/hindsight/content.d.ts +5 -6
  38. package/dist/types/internal-urls/skill-path.d.ts +1 -0
  39. package/dist/types/internal-urls/types.d.ts +2 -0
  40. package/dist/types/lsp/clients/swiftlint-client.d.ts +0 -4
  41. package/dist/types/lsp/config.d.ts +8 -5
  42. package/dist/types/lsp/workspace-path.d.ts +1 -0
  43. package/dist/types/migrate/adapters/codex.d.ts +2 -1
  44. package/dist/types/migrate/adapters/index.d.ts +10 -1
  45. package/dist/types/migrate/executor.d.ts +3 -1
  46. package/dist/types/migrate/types.d.ts +15 -3
  47. package/dist/types/modes/components/custom-editor.d.ts +6 -0
  48. package/dist/types/modes/components/extensions/state-manager.d.ts +4 -3
  49. package/dist/types/modes/components/model-selector.d.ts +46 -0
  50. package/dist/types/modes/controllers/input-controller.d.ts +9 -0
  51. package/dist/types/modes/interactive-mode.d.ts +1 -0
  52. package/dist/types/modes/utils/macos-option-forwarding.d.ts +17 -0
  53. package/dist/types/runtime-mcp/content-limits.d.ts +4 -0
  54. package/dist/types/runtime-mcp/manager.d.ts +9 -1
  55. package/dist/types/runtime-mcp/mcp-redirect.d.ts +9 -0
  56. package/dist/types/runtime-mcp/oauth-public-url.d.ts +1 -0
  57. package/dist/types/runtime-mcp/plugin-mcp-name-filter.d.ts +22 -0
  58. package/dist/types/runtime-mcp/plugin-network-boundary.d.ts +1 -0
  59. package/dist/types/runtime-mcp/project-host-values.d.ts +33 -0
  60. package/dist/types/runtime-mcp/smithery-registry.d.ts +24 -0
  61. package/dist/types/runtime-mcp/tool-bridge.d.ts +4 -0
  62. package/dist/types/runtime-mcp/types.d.ts +6 -0
  63. package/dist/types/sdk/broker/ensure.d.ts +2 -0
  64. package/dist/types/sdk/broker/lifecycle-ledger.d.ts +5 -1
  65. package/dist/types/sdk/broker/runtime.d.ts +1 -1
  66. package/dist/types/sdk/bus/chat-daemon-control.d.ts +3 -1
  67. package/dist/types/sdk/bus/telegram-daemon-contract.d.ts +3 -1
  68. package/dist/types/sdk/bus/telegram-daemon.d.ts +1 -0
  69. package/dist/types/sdk/host/events.d.ts +4 -0
  70. package/dist/types/session/agent-session.d.ts +20 -1
  71. package/dist/types/session/messages.d.ts +5 -1
  72. package/dist/types/session/session-manager.d.ts +13 -0
  73. package/dist/types/session/session-storage.d.ts +8 -0
  74. package/dist/types/session/streaming-output.d.ts +11 -0
  75. package/dist/types/session-import/redact.d.ts +1 -1
  76. package/dist/types/skc-runtime/managed-owner-admission.d.ts +3 -0
  77. package/dist/types/skc-runtime/psmux-detect.d.ts +5 -4
  78. package/dist/types/skc-runtime/ralplan-runtime.d.ts +5 -0
  79. package/dist/types/skc-runtime/sidecar-bootstrap-env.d.ts +6 -0
  80. package/dist/types/skc-runtime/state-writer.d.ts +4 -1
  81. package/dist/types/skc-runtime/tmux-sessions.d.ts +24 -0
  82. package/dist/types/skc-runtime/ultragoal-runtime.d.ts +4 -0
  83. package/dist/types/skill-state/workflow-mutation-guard.d.ts +20 -1
  84. package/dist/types/slash-commands/helpers/mcp.d.ts +5 -0
  85. package/dist/types/ssh/ssh-executor.d.ts +3 -1
  86. package/dist/types/system-prompt.d.ts +5 -2
  87. package/dist/types/task/executor.d.ts +17 -3
  88. package/dist/types/task/isolation-dir.d.ts +26 -0
  89. package/dist/types/task/role-body.d.ts +11 -0
  90. package/dist/types/task/token-log-mode.test.d.ts +1 -0
  91. package/dist/types/tools/ask.d.ts +77 -254
  92. package/dist/types/tools/ast-edit-write-path.d.ts +23 -0
  93. package/dist/types/tools/atomic-file-write.d.ts +74 -0
  94. package/dist/types/tools/auto-generated-guard.d.ts +5 -2
  95. package/dist/types/tools/bash-allowed-prefixes.d.ts +16 -0
  96. package/dist/types/tools/bash-interactive.d.ts +2 -0
  97. package/dist/types/tools/bash-skill-urls.d.ts +5 -1
  98. package/dist/types/tools/bash.d.ts +1 -0
  99. package/dist/types/tools/browser/cdp-url.d.ts +2 -0
  100. package/dist/types/tools/browser/tab-worker.d.ts +2 -0
  101. package/dist/types/tools/debug.d.ts +2 -2
  102. package/dist/types/tools/explicit-artifact.d.ts +8 -0
  103. package/dist/types/tools/fetch.d.ts +7 -4
  104. package/dist/types/tools/github-side-effect.d.ts +22 -0
  105. package/dist/types/tools/index.d.ts +3 -0
  106. package/dist/types/tools/monitor-mutation.d.ts +9 -0
  107. package/dist/types/tools/recipe/index.d.ts +2 -0
  108. package/dist/types/tools/recipe/recipe-guard.d.ts +7 -0
  109. package/dist/types/tools/restricted-cwd.d.ts +1 -0
  110. package/dist/types/tools/reverse-engineer.d.ts +81 -0
  111. package/dist/types/tools/search-tool-bm25.d.ts +2 -0
  112. package/dist/types/tools/tmux-self-injection-guard.d.ts +17 -0
  113. package/dist/types/tools/untrusted-content.d.ts +12 -0
  114. package/dist/types/utils/file-mentions.d.ts +5 -0
  115. package/dist/types/utils/open.d.ts +0 -1
  116. package/dist/types/utils/shell-snapshot.d.ts +2 -0
  117. package/dist/types/utils/title-generator.d.ts +12 -2
  118. package/dist/types/utils/tools-checksum.d.ts +7 -0
  119. package/dist/types/utils/xml-escape.d.ts +2 -0
  120. package/dist/types/web/scrapers/types.d.ts +8 -1
  121. package/dist/types/web/search/providers/codex.d.ts +6 -7
  122. package/dist/types/web/search/providers/insane.d.ts +7 -1
  123. package/dist/types/web/search/providers/kimi.d.ts +2 -0
  124. package/dist/types/web/search/providers/searxng.d.ts +7 -0
  125. package/dist/types/web/search/providers/xai.d.ts +2 -0
  126. package/package.json +7 -7
  127. package/scripts/generate-sdk-operation-inventory.ts +4 -0
  128. package/src/async/job-manager.ts +23 -9
  129. package/src/async/result-formatting.ts +40 -0
  130. package/src/capability/fs.ts +78 -11
  131. package/src/capability/mcp.ts +2 -0
  132. package/src/cli/append-system-prompt.ts +12 -0
  133. package/src/cli/auth-broker-cli.ts +22 -12
  134. package/src/cli/config-cli.ts +8 -18
  135. package/src/cli/migrate-cli.ts +7 -5
  136. package/src/cli/ssh-cli.ts +6 -3
  137. package/src/cli/stats-cli.ts +9 -4
  138. package/src/cli/update-cli.ts +42 -0
  139. package/src/cli/web-search-cli.ts +9 -3
  140. package/src/cli.ts +5 -9
  141. package/src/commands/commit.ts +2 -2
  142. package/src/commands/contribution-prep.ts +1 -3
  143. package/src/commands/harness.ts +25 -15
  144. package/src/commands/launch.ts +1 -1
  145. package/src/commands/migrate.ts +3 -3
  146. package/src/commands/sdk.ts +115 -14
  147. package/src/commands/ultragoal.ts +14 -8
  148. package/src/commit/agentic/agent.ts +6 -6
  149. package/src/commit/analysis/conventional.ts +14 -5
  150. package/src/commit/changelog/index.ts +39 -1
  151. package/src/commit/message.ts +10 -3
  152. package/src/config/config-file.ts +106 -3
  153. package/src/config/keybindings.ts +154 -7
  154. package/src/config/mcp-schema.json +4 -0
  155. package/src/config/model-registry.ts +10 -2
  156. package/src/config/settings-schema.ts +18 -0
  157. package/src/config/settings.ts +32 -4
  158. package/src/coordinator-mcp/policy.ts +14 -4
  159. package/src/coordinator-mcp/server.ts +44 -4
  160. package/src/coordinator-mcp/session-reaper.ts +9 -1
  161. package/src/cursor-delete-path.ts +10 -0
  162. package/src/cursor-mcp-name.ts +15 -0
  163. package/src/cursor.ts +13 -2
  164. package/src/dap/client.ts +9 -2
  165. package/src/dap/config.ts +33 -13
  166. package/src/dap/defaults.json +1 -1
  167. package/src/dap/session.ts +161 -36
  168. package/src/debug/crash-diagnostics.ts +89 -6
  169. package/src/debug/report-bundle-parent.ts +22 -0
  170. package/src/debug/report-bundle.ts +100 -3
  171. package/src/debug/system-info.ts +21 -4
  172. package/src/defaults/skc/extensions/grok-cli-vendor/src/shared/base-url.ts +21 -7
  173. package/src/defaults/skc/skills/deep-interview/SKILL.md +1 -1
  174. package/src/discovery/agents-md.ts +3 -2
  175. package/src/discovery/agents.ts +3 -2
  176. package/src/discovery/builtin.ts +21 -11
  177. package/src/discovery/claude.ts +5 -4
  178. package/src/discovery/cline.ts +2 -2
  179. package/src/discovery/codex.ts +6 -5
  180. package/src/discovery/cursor.ts +11 -2
  181. package/src/discovery/gemini.ts +4 -3
  182. package/src/discovery/github.ts +2 -2
  183. package/src/discovery/helpers.ts +51 -11
  184. package/src/discovery/mcp-json.ts +28 -12
  185. package/src/discovery/opencode.ts +2 -1
  186. package/src/discovery/ssh.ts +11 -6
  187. package/src/discovery/substitute-plugin-root.ts +3 -1
  188. package/src/discovery/vscode.ts +3 -3
  189. package/src/edit/apply-patch/index.ts +12 -1
  190. package/src/edit/file-read-cache.ts +24 -6
  191. package/src/edit/index.ts +90 -20
  192. package/src/edit/modes/patch.ts +215 -9
  193. package/src/edit/modes/replace.ts +141 -0
  194. package/src/eval/js/context-manager.ts +29 -3
  195. package/src/eval/js/worker-entry.ts +51 -18
  196. package/src/eval/py/runner.py +144 -5
  197. package/src/eval/py/runtime.ts +44 -4
  198. package/src/eval/py/tool-bridge.ts +4 -0
  199. package/src/exa/mcp-client.ts +53 -11
  200. package/src/exec/bash-executor.ts +87 -4
  201. package/src/exec/non-interactive-env.ts +0 -1
  202. package/src/export/html/css-color.ts +9 -0
  203. package/src/export/html/html-export-destination.ts +16 -0
  204. package/src/export/html/index.ts +102 -8
  205. package/src/export/html/template.generated.ts +1 -1
  206. package/src/extensibility/custom-tools/loader.ts +13 -3
  207. package/src/extensibility/custom-tools/types.ts +3 -1
  208. package/src/extensibility/custom-tools/wrapper.ts +3 -1
  209. package/src/extensibility/plugins/manager.ts +3 -2
  210. package/src/extensibility/plugins/marketplace/cache.ts +15 -0
  211. package/src/extensibility/plugins/marketplace/fetcher.ts +2 -2
  212. package/src/extensibility/plugins/marketplace/manager.ts +5 -3
  213. package/src/extensibility/plugins/plugin-link-path.ts +12 -0
  214. package/src/extensibility/skc-plugins/mcp-policy.ts +2 -1
  215. package/src/goals/runtime.ts +30 -8
  216. package/src/harness-control-plane/finalize.ts +10 -0
  217. package/src/harness-control-plane/operate.ts +12 -4
  218. package/src/harness-control-plane/owner.ts +8 -1
  219. package/src/harness-control-plane/receipt-spool.ts +105 -28
  220. package/src/harness-control-plane/storage.ts +124 -6
  221. package/src/hashline/execute.ts +3 -3
  222. package/src/hashline/recovery.ts +85 -2
  223. package/src/hindsight/config.ts +9 -3
  224. package/src/hindsight/content.ts +116 -16
  225. package/src/hindsight/mental-models.ts +22 -10
  226. package/src/hindsight/state.ts +7 -4
  227. package/src/hooks/native-skill-hook.ts +17 -12
  228. package/src/i18n/messages/de.settings.ts +3 -0
  229. package/src/i18n/messages/es.settings.ts +3 -0
  230. package/src/i18n/messages/fr.settings.ts +3 -0
  231. package/src/i18n/messages/ja.settings.ts +3 -0
  232. package/src/i18n/messages/ko.settings.ts +3 -0
  233. package/src/i18n/messages/zh.settings.ts +3 -0
  234. package/src/internal-urls/artifact-protocol.ts +3 -1
  235. package/src/internal-urls/docs-index.generated.ts +10 -10
  236. package/src/internal-urls/local-protocol.ts +167 -8
  237. package/src/internal-urls/skill-path.ts +18 -0
  238. package/src/internal-urls/skill-protocol.ts +2 -0
  239. package/src/internal-urls/types.ts +2 -0
  240. package/src/lsp/client.ts +2 -1
  241. package/src/lsp/clients/biome-client.ts +2 -0
  242. package/src/lsp/clients/swiftlint-client.ts +2 -0
  243. package/src/lsp/config.ts +18 -62
  244. package/src/lsp/edits.ts +6 -0
  245. package/src/lsp/index.ts +29 -0
  246. package/src/lsp/workspace-path.ts +75 -0
  247. package/src/main.ts +33 -11
  248. package/src/memories/index.ts +141 -9
  249. package/src/migrate/action-planner.ts +57 -0
  250. package/src/migrate/adapters/claude-code.ts +23 -4
  251. package/src/migrate/adapters/codex.ts +22 -4
  252. package/src/migrate/adapters/index.ts +22 -4
  253. package/src/migrate/adapters/opencode.ts +6 -1
  254. package/src/migrate/executor.ts +84 -7
  255. package/src/migrate/report.ts +19 -2
  256. package/src/migrate/types.ts +14 -4
  257. package/src/modes/DESIGN.md +5 -0
  258. package/src/modes/acp/acp-agent.ts +35 -2
  259. package/src/modes/acp/permission-mode.ts +18 -1
  260. package/src/modes/components/custom-editor.ts +14 -0
  261. package/src/modes/components/extensions/extension-dashboard.ts +2 -2
  262. package/src/modes/components/extensions/inspector-panel.ts +9 -5
  263. package/src/modes/components/extensions/state-manager.ts +15 -5
  264. package/src/modes/components/model-selector.ts +144 -94
  265. package/src/modes/components/welcome.ts +3 -2
  266. package/src/modes/controllers/command-controller.ts +300 -9
  267. package/src/modes/controllers/event-controller.ts +1 -1
  268. package/src/modes/controllers/extension-ui-controller.ts +32 -19
  269. package/src/modes/controllers/input-controller.ts +62 -26
  270. package/src/modes/controllers/plan-mode-controller.ts +17 -7
  271. package/src/modes/controllers/runtime-mcp-command-controller.ts +25 -20
  272. package/src/modes/controllers/ssh-command-controller.ts +3 -1
  273. package/src/modes/interactive-mode.ts +10 -0
  274. package/src/modes/utils/macos-option-forwarding.ts +80 -0
  275. package/src/prompts/system/irc-incoming.md +3 -1
  276. package/src/prompts/system/project-prompt.md +19 -0
  277. package/src/prompts/system/system-prompt.md +3 -0
  278. package/src/prompts/tools/ask.md +2 -0
  279. package/src/prompts/tools/debug.md +1 -1
  280. package/src/prompts/tools/monitor.md +7 -5
  281. package/src/prompts/tools/reverse-engineer.md +29 -0
  282. package/src/runtime-credential-selector.ts +2 -2
  283. package/src/runtime-mcp/config-writer.ts +10 -6
  284. package/src/runtime-mcp/config.ts +1 -0
  285. package/src/runtime-mcp/content-limits.ts +7 -0
  286. package/src/runtime-mcp/json-rpc.ts +2 -1
  287. package/src/runtime-mcp/manager.ts +57 -9
  288. package/src/runtime-mcp/mcp-redirect.ts +73 -0
  289. package/src/runtime-mcp/oauth-flow.ts +43 -5
  290. package/src/runtime-mcp/oauth-public-url.ts +8 -0
  291. package/src/runtime-mcp/plugin-mcp-name-filter.ts +62 -0
  292. package/src/runtime-mcp/plugin-network-boundary.ts +4 -0
  293. package/src/runtime-mcp/project-host-values.ts +50 -0
  294. package/src/runtime-mcp/render.ts +16 -1
  295. package/src/runtime-mcp/smithery-registry.ts +22 -3
  296. package/src/runtime-mcp/tool-bridge.ts +194 -21
  297. package/src/runtime-mcp/transports/http.ts +4 -3
  298. package/src/runtime-mcp/transports/stdio.ts +2 -1
  299. package/src/runtime-mcp/types.ts +6 -0
  300. package/src/sdk/broker/broker.ts +11 -2
  301. package/src/sdk/broker/ensure.ts +131 -10
  302. package/src/sdk/broker/lifecycle-ledger.ts +18 -3
  303. package/src/sdk/broker/lifecycle.ts +21 -19
  304. package/src/sdk/broker/runtime.ts +1 -1
  305. package/src/sdk/bus/chat-daemon-cli.ts +38 -1
  306. package/src/sdk/bus/chat-daemon-control.ts +5 -3
  307. package/src/sdk/bus/index.ts +5 -3
  308. package/src/sdk/bus/lifecycle-control-runtime.ts +9 -2
  309. package/src/sdk/bus/session-control.ts +2 -0
  310. package/src/sdk/bus/slack-daemon.ts +8 -1
  311. package/src/sdk/bus/slack-live-provider.ts +3 -1
  312. package/src/sdk/bus/telegram-daemon-contract.ts +3 -1
  313. package/src/sdk/bus/telegram-daemon-control.ts +17 -12
  314. package/src/sdk/bus/telegram-daemon.ts +41 -1
  315. package/src/sdk/host/events.ts +67 -4
  316. package/src/sdk/mcp/server.ts +16 -3
  317. package/src/sdk/protocol/operation-inventory.generated.json +22 -0
  318. package/src/sdk/session.ts +18 -25
  319. package/src/secrets/obfuscator.ts +92 -12
  320. package/src/session/agent-session.ts +395 -79
  321. package/src/session/artifacts.ts +3 -1
  322. package/src/session/history-storage.ts +172 -8
  323. package/src/session/internal/managed-session-scope.ts +130 -52
  324. package/src/session/messages.ts +47 -6
  325. package/src/session/session-manager.ts +170 -10
  326. package/src/session/session-storage.ts +31 -1
  327. package/src/session/streaming-output.ts +263 -4
  328. package/src/session-import/redact.ts +76 -3
  329. package/src/setup/hermes-setup.ts +4 -1
  330. package/src/skc-runtime/gc-runtime.ts +26 -4
  331. package/src/skc-runtime/launch-tmux.ts +21 -11
  332. package/src/skc-runtime/launch-worktree.ts +42 -3
  333. package/src/skc-runtime/managed-owner-admission.ts +46 -2
  334. package/src/skc-runtime/psmux-detect.ts +29 -5
  335. package/src/skc-runtime/ralplan-runtime.ts +14 -1
  336. package/src/skc-runtime/session-resolution.ts +38 -6
  337. package/src/skc-runtime/sidecar-bootstrap-env.ts +19 -0
  338. package/src/skc-runtime/state-writer.ts +134 -16
  339. package/src/skc-runtime/tmux-sessions.ts +85 -4
  340. package/src/skc-runtime/ultragoal-change-set.ts +18 -2
  341. package/src/skc-runtime/ultragoal-guard.ts +9 -1
  342. package/src/skc-runtime/ultragoal-runtime.ts +26 -9
  343. package/src/skill-state/active-state.ts +13 -0
  344. package/src/skill-state/workflow-mutation-guard.ts +3297 -180
  345. package/src/slash-commands/builtin-registry.ts +14 -8
  346. package/src/slash-commands/helpers/mcp.ts +20 -7
  347. package/src/ssh/ssh-executor.ts +3 -1
  348. package/src/stt/recorder.ts +26 -9
  349. package/src/system-prompt.ts +65 -16
  350. package/src/task/commands.ts +3 -1
  351. package/src/task/executor.ts +52 -7
  352. package/src/task/index.ts +28 -0
  353. package/src/task/isolation-dir.ts +143 -0
  354. package/src/task/role-body.ts +84 -0
  355. package/src/task/token-log-mode.test.ts +162 -0
  356. package/src/task/token-log.ts +91 -2
  357. package/src/task/worktree.ts +16 -7
  358. package/src/tools/archive-reader.ts +653 -31
  359. package/src/tools/ask.ts +86 -14
  360. package/src/tools/ast-edit-write-path.ts +133 -0
  361. package/src/tools/ast-edit.ts +27 -1
  362. package/src/tools/ast-grep.ts +7 -2
  363. package/src/tools/atomic-file-write.ts +625 -0
  364. package/src/tools/auto-generated-guard.ts +28 -8
  365. package/src/tools/bash-allowed-prefixes.ts +225 -6
  366. package/src/tools/bash-interactive.ts +12 -0
  367. package/src/tools/bash-skill-urls.ts +113 -7
  368. package/src/tools/bash.ts +152 -20
  369. package/src/tools/browser/cdp-url.ts +18 -0
  370. package/src/tools/browser/tab-worker.ts +49 -14
  371. package/src/tools/browser.ts +25 -8
  372. package/src/tools/cron.ts +10 -1
  373. package/src/tools/debug.ts +16 -8
  374. package/src/tools/eval.ts +71 -34
  375. package/src/tools/explicit-artifact.ts +89 -0
  376. package/src/tools/fetch.ts +26 -17
  377. package/src/tools/gh.ts +40 -12
  378. package/src/tools/github-side-effect.ts +112 -0
  379. package/src/tools/image-gen.ts +24 -10
  380. package/src/tools/index.ts +6 -0
  381. package/src/tools/monitor-mutation.ts +27 -0
  382. package/src/tools/monitor.ts +28 -1
  383. package/src/tools/output-meta.ts +74 -5
  384. package/src/tools/read.ts +24 -36
  385. package/src/tools/recipe/index.ts +12 -0
  386. package/src/tools/recipe/recipe-guard.ts +19 -0
  387. package/src/tools/recipe/runner.ts +23 -12
  388. package/src/tools/render-utils.ts +2 -2
  389. package/src/tools/restricted-cwd.ts +10 -0
  390. package/src/tools/reverse-engineer.ts +497 -0
  391. package/src/tools/search-tool-bm25.ts +14 -3
  392. package/src/tools/search.ts +3 -2
  393. package/src/tools/ssh.ts +235 -8
  394. package/src/tools/subagent-render.ts +43 -7
  395. package/src/tools/subagent.ts +7 -3
  396. package/src/tools/tmux-self-injection-guard.ts +3538 -0
  397. package/src/tools/todo-write.ts +41 -3
  398. package/src/tools/untrusted-content.ts +23 -0
  399. package/src/tools/vim.ts +2 -2
  400. package/src/tools/write.ts +37 -4
  401. package/src/tui/tree-list.ts +15 -1
  402. package/src/utils/commit-message-generator.ts +9 -2
  403. package/src/utils/external-editor.ts +21 -7
  404. package/src/utils/file-mentions.ts +75 -7
  405. package/src/utils/git.ts +38 -7
  406. package/src/utils/open.ts +73 -4
  407. package/src/utils/shell-snapshot.ts +9 -1
  408. package/src/utils/title-generator.ts +61 -16
  409. package/src/utils/tools-checksum.ts +34 -0
  410. package/src/utils/tools-manager.ts +24 -6
  411. package/src/utils/xml-escape.ts +14 -0
  412. package/src/web/insane/url-guard.ts +2 -1
  413. package/src/web/scrapers/types.ts +8 -0
  414. package/src/web/scrapers/youtube.ts +3 -2
  415. package/src/web/search/index.ts +4 -3
  416. package/src/web/search/providers/anthropic.ts +4 -4
  417. package/src/web/search/providers/codex.ts +31 -34
  418. package/src/web/search/providers/insane.ts +145 -28
  419. package/src/web/search/providers/kimi.ts +15 -5
  420. package/src/web/search/providers/searxng.ts +47 -4
  421. package/src/web/search/providers/xai.ts +7 -2
  422. package/dist/types/cli/shell-cli.d.ts +0 -8
  423. package/dist/types/commands/shell.d.ts +0 -21
  424. package/src/cli/shell-cli.ts +0 -176
  425. package/src/commands/shell.ts +0 -29
@@ -3,6 +3,7 @@ import { getSupportedEfforts, type Model, modelsAreEqual } from "@sayknow-cli/ai
3
3
  import {
4
4
  Container,
5
5
  fuzzyFilter,
6
+ fuzzyMatch,
6
7
  getKeybindings,
7
8
  Input,
8
9
  matchesKey,
@@ -114,6 +115,8 @@ interface ModelItem extends SearchableItem {
114
115
  selector: string;
115
116
  thinkingLevel?: ThinkingLevel;
116
117
  explicitThinkingLevel?: boolean;
118
+ /** Tokenized fuzzy match score for the active query; lower is better. */
119
+ fuzzyScore?: number;
117
120
  }
118
121
 
119
122
  interface CanonicalModelItem extends SearchableItem {
@@ -124,6 +127,141 @@ interface CanonicalModelItem extends SearchableItem {
124
127
  variantCount: number;
125
128
  thinkingLevel?: ThinkingLevel;
126
129
  explicitThinkingLevel?: boolean;
130
+ /** Tokenized fuzzy match score for the active query; lower is better. */
131
+ fuzzyScore?: number;
132
+ }
133
+
134
+ type ModelScoreItem = Pick<ModelItem, "id" | "provider" | "fuzzyScore">;
135
+ type CanonicalScoreItem = Pick<CanonicalModelItem, "searchText" | "fuzzyScore">;
136
+ type RankedModelItem = Pick<ModelItem, "id" | "provider" | "model" | "selector" | "fuzzyScore">;
137
+ type RankedCanonicalItem = Pick<CanonicalModelItem, "id" | "model" | "fuzzyScore">;
138
+
139
+ /** Sum of per-token fuzzy scores, matching fuzzyFilter's token semantics; undefined on any miss. */
140
+ function fuzzyTokensScore(query: string, text: string): number | undefined {
141
+ const tokens = query
142
+ .trim()
143
+ .split(/\s+/)
144
+ .filter(token => token.length > 0);
145
+ if (tokens.length === 0) return undefined;
146
+ let total = 0;
147
+ for (const token of tokens) {
148
+ const match = fuzzyMatch(token, text);
149
+ if (!match.matches) return undefined;
150
+ total += match.score;
151
+ }
152
+ return total;
153
+ }
154
+
155
+ /** Assign every item its score for `query`, overwriting stale scores from an earlier query. */
156
+ export function assignFuzzyScoresToModels(items: ModelScoreItem[], query: string): void {
157
+ const active = query.trim().length > 0;
158
+ for (const item of items) {
159
+ item.fuzzyScore = active ? fuzzyTokensScore(query, `${item.id} ${item.provider}`) : undefined;
160
+ }
161
+ }
162
+
163
+ export function assignFuzzyScoresToCanonicalModels(items: CanonicalScoreItem[], query: string): void {
164
+ const active = query.trim().length > 0;
165
+ for (const item of items) {
166
+ item.fuzzyScore = active ? fuzzyTokensScore(query, item.searchText) : undefined;
167
+ }
168
+ }
169
+
170
+ export interface RankedModelOrderContext {
171
+ roles: Record<string, RoleAssignment | undefined>;
172
+ mruIndex: ReadonlyMap<string, number>;
173
+ providerAuthStateById: ReadonlyMap<string, ProviderAuthState>;
174
+ }
175
+
176
+ const MODEL_DATE_RE = /-(\d{8})$/;
177
+ const MODEL_LATEST_RE = /-latest$/;
178
+
179
+ /** Match quality first while searching; ties keep default, MRU, provider, then recency order. */
180
+ function compareFuzzyScores(a: number | undefined, b: number | undefined): number {
181
+ if (a === undefined && b === undefined) return 0;
182
+ return (a ?? Number.MAX_SAFE_INTEGER) - (b ?? Number.MAX_SAFE_INTEGER);
183
+ }
184
+
185
+ export function compareModelItemsForRanking(
186
+ a: RankedModelItem,
187
+ b: RankedModelItem,
188
+ context: RankedModelOrderContext,
189
+ ): number {
190
+ const { roles, mruIndex, providerAuthStateById } = context;
191
+ const scoreCmp = compareFuzzyScores(a.fuzzyScore, b.fuzzyScore);
192
+ if (scoreCmp !== 0) return scoreCmp;
193
+
194
+ const aRank = computeModelRank(a.model, roles);
195
+ const bRank = computeModelRank(b.model, roles);
196
+ if (aRank !== bRank) return aRank - bRank;
197
+
198
+ // Then MRU order (models in mruIndex come before those not in it)
199
+ const aMru = mruIndex.get(a.selector) ?? Number.MAX_SAFE_INTEGER;
200
+ const bMru = mruIndex.get(b.selector) ?? Number.MAX_SAFE_INTEGER;
201
+ if (aMru !== bMru) return aMru - bMru;
202
+
203
+ const providerCmp = compareRankedProviders(
204
+ { id: a.provider, label: a.provider, authState: providerAuthStateById.get(a.provider) ?? "none" },
205
+ { id: b.provider, label: b.provider, authState: providerAuthStateById.get(b.provider) ?? "none" },
206
+ );
207
+ if (providerCmp !== 0) return providerCmp;
208
+
209
+ // Priority field (lower = better, e.g. OpenAI code backend priority values)
210
+ const aPri = a.model.priority ?? Number.MAX_SAFE_INTEGER;
211
+ const bPri = b.model.priority ?? Number.MAX_SAFE_INTEGER;
212
+ if (aPri !== bPri) return aPri - bPri;
213
+
214
+ // Version number descending (higher version = better model)
215
+ const aVer = extractVersionNumber(a.id);
216
+ const bVer = extractVersionNumber(b.id);
217
+ if (aVer !== bVer) return bVer - aVer;
218
+
219
+ const aIsLatest = MODEL_LATEST_RE.test(a.id);
220
+ const bIsLatest = MODEL_LATEST_RE.test(b.id);
221
+ const aDate = a.id.match(MODEL_DATE_RE)?.[1] ?? "";
222
+ const bDate = b.id.match(MODEL_DATE_RE)?.[1] ?? "";
223
+ // Models with recency info come before those without; -latest first, then newest date.
224
+ const aHasRecency = aIsLatest || aDate !== "";
225
+ const bHasRecency = bIsLatest || bDate !== "";
226
+ if (aHasRecency !== bHasRecency) return aHasRecency ? -1 : 1;
227
+ if (!aHasRecency) return a.id.localeCompare(b.id);
228
+ if (aIsLatest !== bIsLatest) return aIsLatest ? -1 : 1;
229
+ if (aDate && bDate) return bDate.localeCompare(aDate);
230
+ return aIsLatest ? -1 : bIsLatest ? 1 : a.id.localeCompare(b.id);
231
+ }
232
+
233
+ export function compareCanonicalModelItemsForRanking(
234
+ a: RankedCanonicalItem,
235
+ b: RankedCanonicalItem,
236
+ context: RankedModelOrderContext,
237
+ ): number {
238
+ const { roles, mruIndex, providerAuthStateById } = context;
239
+ const scoreCmp = compareFuzzyScores(a.fuzzyScore, b.fuzzyScore);
240
+ if (scoreCmp !== 0) return scoreCmp;
241
+
242
+ const aRank = computeModelRank(a.model, roles);
243
+ const bRank = computeModelRank(b.model, roles);
244
+ if (aRank !== bRank) return aRank - bRank;
245
+
246
+ const aMru = mruIndex.get(`${a.model.provider}/${a.model.id}`) ?? Number.MAX_SAFE_INTEGER;
247
+ const bMru = mruIndex.get(`${b.model.provider}/${b.model.id}`) ?? Number.MAX_SAFE_INTEGER;
248
+ if (aMru !== bMru) return aMru - bMru;
249
+
250
+ const providerCmp = compareRankedProviders(
251
+ {
252
+ id: a.model.provider,
253
+ label: a.model.provider,
254
+ authState: providerAuthStateById.get(a.model.provider) ?? "none",
255
+ },
256
+ {
257
+ id: b.model.provider,
258
+ label: b.model.provider,
259
+ authState: providerAuthStateById.get(b.model.provider) ?? "none",
260
+ },
261
+ );
262
+ if (providerCmp !== 0) return providerCmp;
263
+
264
+ return a.id.localeCompare(b.id);
127
265
  }
128
266
 
129
267
  type ScopedModelItem = ScopedModelSelection;
@@ -646,73 +784,8 @@ export class ModelSelectorComponent extends Container {
646
784
  }
647
785
  }
648
786
 
649
- const modelRank = (item: ModelItem) => computeModelRank(item.model, this.#roles);
650
-
651
- const dateRe = /-(\d{8})$/;
652
- const latestRe = /-latest$/;
653
-
654
- models.sort((a, b) => {
655
- const aKey = a.selector;
656
- const bKey = b.selector;
657
-
658
- const aRank = modelRank(a);
659
- const bRank = modelRank(b);
660
- if (aRank !== bRank) return aRank - bRank;
661
-
662
- // Then MRU order (models in mruIndex come before those not in it)
663
- const aMru = mruIndex.get(aKey) ?? Number.MAX_SAFE_INTEGER;
664
- const bMru = mruIndex.get(bKey) ?? Number.MAX_SAFE_INTEGER;
665
- if (aMru !== bMru) return aMru - bMru;
666
-
667
- // By provider, then recency within provider
668
- const providerCmp = compareRankedProviders(
669
- {
670
- id: a.provider,
671
- label: a.provider,
672
- authState: providerAuthStateById.get(a.provider) ?? "none",
673
- },
674
- {
675
- id: b.provider,
676
- label: b.provider,
677
- authState: providerAuthStateById.get(b.provider) ?? "none",
678
- },
679
- );
680
- if (providerCmp !== 0) return providerCmp;
681
-
682
- // Priority field (lower = better, e.g. OpenAI code backend priority values)
683
- const aPri = a.model.priority ?? Number.MAX_SAFE_INTEGER;
684
- const bPri = b.model.priority ?? Number.MAX_SAFE_INTEGER;
685
- if (aPri !== bPri) return aPri - bPri;
686
-
687
- // Version number descending (higher version = better model)
688
- const aVer = extractVersionNumber(a.id);
689
- const bVer = extractVersionNumber(b.id);
690
- if (aVer !== bVer) return bVer - aVer;
691
-
692
- const aIsLatest = latestRe.test(a.id);
693
- const bIsLatest = latestRe.test(b.id);
694
- const aDate = a.id.match(dateRe)?.[1] ?? "";
695
- const bDate = b.id.match(dateRe)?.[1] ?? "";
696
-
697
- // Both have dates or latest tags — sort by recency
698
- const aHasRecency = aIsLatest || aDate !== "";
699
- const bHasRecency = bIsLatest || bDate !== "";
700
-
701
- // Models with recency info come before those without
702
- if (aHasRecency !== bHasRecency) return aHasRecency ? -1 : 1;
703
-
704
- // If neither has recency info, fall back to alphabetical
705
- if (!aHasRecency) return a.id.localeCompare(b.id);
706
-
707
- // -latest always sorts first within recency group
708
- if (aIsLatest !== bIsLatest) return aIsLatest ? -1 : 1;
709
-
710
- // Both have dates — descending (newest first)
711
- if (aDate && bDate) return bDate.localeCompare(aDate);
712
-
713
- // One has date, other is latest — latest first
714
- return aIsLatest ? -1 : bIsLatest ? 1 : a.id.localeCompare(b.id);
715
- });
787
+ const context: RankedModelOrderContext = { roles: this.#roles, mruIndex, providerAuthStateById };
788
+ models.sort((a, b) => compareModelItemsForRanking(a, b, context));
716
789
  }
717
790
 
718
791
  #sortCanonicalModels(models: CanonicalModelItem[]): void {
@@ -725,33 +798,8 @@ export class ModelSelectorComponent extends Container {
725
798
  }
726
799
  }
727
800
 
728
- const modelRank = (item: CanonicalModelItem) => computeModelRank(item.model, this.#roles);
729
-
730
- models.sort((a, b) => {
731
- const aRank = modelRank(a);
732
- const bRank = modelRank(b);
733
- if (aRank !== bRank) return aRank - bRank;
734
-
735
- const aMru = mruIndex.get(`${a.model.provider}/${a.model.id}`) ?? Number.MAX_SAFE_INTEGER;
736
- const bMru = mruIndex.get(`${b.model.provider}/${b.model.id}`) ?? Number.MAX_SAFE_INTEGER;
737
- if (aMru !== bMru) return aMru - bMru;
738
-
739
- const providerCmp = compareRankedProviders(
740
- {
741
- id: a.model.provider,
742
- label: a.model.provider,
743
- authState: providerAuthStateById.get(a.model.provider) ?? "none",
744
- },
745
- {
746
- id: b.model.provider,
747
- label: b.model.provider,
748
- authState: providerAuthStateById.get(b.model.provider) ?? "none",
749
- },
750
- );
751
- if (providerCmp !== 0) return providerCmp;
752
-
753
- return a.id.localeCompare(b.id);
754
- });
801
+ const context: RankedModelOrderContext = { roles: this.#roles, mruIndex, providerAuthStateById };
802
+ models.sort((a, b) => compareCanonicalModelItemsForRanking(a, b, context));
755
803
  }
756
804
 
757
805
  async #loadModels(): Promise<void> {
@@ -960,10 +1008,12 @@ export class ModelSelectorComponent extends Container {
960
1008
 
961
1009
  if (isCanonicalTab) {
962
1010
  const fuzzyMatches = filterSearchableItems(baseCanonicalModels, query);
1011
+ assignFuzzyScoresToCanonicalModels(fuzzyMatches, query);
963
1012
  this.#sortCanonicalModels(fuzzyMatches);
964
1013
  this.#filteredCanonicalModels = fuzzyMatches;
965
1014
  } else {
966
1015
  const fuzzyMatches = filterSearchableItems(baseModels, query);
1016
+ assignFuzzyScoresToModels(fuzzyMatches, query);
967
1017
  this.#sortModels(fuzzyMatches);
968
1018
  this.#filteredModels = fuzzyMatches;
969
1019
  }
@@ -4,6 +4,7 @@ import { formatBuildLabel } from "../../build-metadata";
4
4
  import { formatKeyHint, type KeyDisplayContext } from "../../config/keybindings";
5
5
  import { type MsgKey, t } from "../../i18n";
6
6
  import { theme } from "../../modes/theme/theme";
7
+ import { sanitizeStatusText } from "../shared";
7
8
 
8
9
  export interface RecentSession {
9
10
  name: string;
@@ -368,10 +369,10 @@ export class WelcomeComponent implements Component {
368
369
  if (this.modelName === "Unknown" || this.modelName.length === 0) {
369
370
  return `${theme.fg("accent", t("welcome.chooseModel"))}${sep}${theme.fg("dim", t("welcome.modelHint"))}`;
370
371
  }
371
- const parts = [theme.bold(theme.fg("statusLineModel", this.modelName))];
372
+ const parts = [theme.bold(theme.fg("statusLineModel", sanitizeStatusText(this.modelName)))];
372
373
  const level = this.#snapshot.thinkingLevel;
373
374
  if (level) parts.push(theme.getThinkingBorderColor(String(level) as ThinkingLevel)(String(level)));
374
- else if (this.providerName) parts.push(theme.fg("muted", this.providerName));
375
+ else if (this.providerName) parts.push(theme.fg("muted", sanitizeStatusText(this.providerName)));
375
376
  return parts.join(sep);
376
377
  }
377
378
 
@@ -11,7 +11,8 @@ import {
11
11
  type UsageReport,
12
12
  } from "@sayknow-cli/ai";
13
13
  import { type Keybinding, Loader, Markdown, padding, Spacer, Text, visibleWidth } from "@sayknow-cli/tui";
14
- import { formatDuration, Snowflake, setProjectDir } from "@sayknow-cli/utils";
14
+ import { formatDuration, setProjectDir } from "@sayknow-cli/utils";
15
+ import { canonicalEnvKey, projectEnvSnapshot } from "@sayknow-cli/utils/env-file";
15
16
  import { resolveAppendOnlyMode } from "../../append-only-mode";
16
17
  import { jobElapsedMs } from "../../async";
17
18
  import { reset as resetCapabilities } from "../../capability";
@@ -57,6 +58,7 @@ import {
57
58
  buildConversationTitleInput,
58
59
  generateSessionTitle,
59
60
  setSessionTerminalTitle,
61
+ titleInputObfuscator,
60
62
  } from "../../utils/title-generator";
61
63
  import { prepareTranscriptRebuild } from "../utils/ui-helpers";
62
64
 
@@ -107,6 +109,266 @@ export function buildHelpMarkdown(keybindings: Pick<KeybindingsManager, "getAcce
107
109
  ].join("\n");
108
110
  }
109
111
 
112
+ const GH_SHARE_TRUST_KEYS = [
113
+ "GH_HOST",
114
+ "GH_CONFIG_DIR",
115
+ "GH_TOKEN",
116
+ "GITHUB_TOKEN",
117
+ "GH_ENTERPRISE_TOKEN",
118
+ "GITHUB_ENTERPRISE_TOKEN",
119
+ "XDG_CONFIG_HOME",
120
+ "HOME",
121
+ "USERPROFILE",
122
+ "APPDATA",
123
+ "BASH_ENV",
124
+ "BUN_OPTIONS",
125
+ "ENV",
126
+ "ZDOTDIR",
127
+ "NODE_OPTIONS",
128
+ "NODE_PATH",
129
+ "PYTHONHOME",
130
+ "PYTHONPATH",
131
+ "PYTHONUSERBASE",
132
+ "PYTHONSTARTUP",
133
+ "JULIA_DEPOT_PATH",
134
+ "JULIA_LOAD_PATH",
135
+ "JULIA_PROJECT",
136
+ "TCL_LIBRARY",
137
+ "TCLLIBPATH",
138
+ "LUA_INIT",
139
+ "LUA_INIT_5_1",
140
+ "LUA_INIT_5_2",
141
+ "LUA_INIT_5_3",
142
+ "LUA_INIT_5_4",
143
+ "LUA_INIT_5_5",
144
+ "LUA_PATH",
145
+ "LUA_CPATH",
146
+ "LUA_PATH_5_1",
147
+ "LUA_PATH_5_2",
148
+ "LUA_PATH_5_3",
149
+ "LUA_PATH_5_4",
150
+ "LUA_PATH_5_5",
151
+ "LUA_CPATH_5_1",
152
+ "LUA_CPATH_5_2",
153
+ "LUA_CPATH_5_3",
154
+ "LUA_CPATH_5_4",
155
+ "LUA_CPATH_5_5",
156
+ "R_ENVIRON",
157
+ "R_ENVIRON_USER",
158
+ "R_PROFILE",
159
+ "R_PROFILE_USER",
160
+ "ELIXIR_ERL_OPTIONS",
161
+ "ERL_AFLAGS",
162
+ "ERL_FLAGS",
163
+ "ERL_ZFLAGS",
164
+ "BUNDLER_SETUP",
165
+ "BUNDLE_GEMFILE",
166
+ "GEM_HOME",
167
+ "GEM_PATH",
168
+ "RUBYGEMS_GEMDEPS",
169
+ "RUBYOPT",
170
+ "RUBYLIB",
171
+ "PERL5OPT",
172
+ "PERL5LIB",
173
+ "PERLLIB",
174
+ "JAVA_HOME",
175
+ "JAVA_TOOL_OPTIONS",
176
+ "JDK_JAVA_OPTIONS",
177
+ "_JAVA_OPTIONS",
178
+ "CLASSPATH",
179
+ "PHPRC",
180
+ "PHP_INI_SCAN_DIR",
181
+ "DOTNET_STARTUP_HOOKS",
182
+ "DOTNET_ROOT",
183
+ "DOTNET_ROOT_X86",
184
+ "DOTNET_ROOT_X64",
185
+ "DOTNET_ROOT_ARM",
186
+ "DOTNET_ROOT_ARM64",
187
+ "CORECLR_ENABLE_PROFILING",
188
+ "DOTNET_ENABLE_PROFILING",
189
+ "CORECLR_PROFILER",
190
+ "DOTNET_PROFILER",
191
+ "CORECLR_PROFILER_PATH",
192
+ "CORECLR_PROFILER_PATH_32",
193
+ "CORECLR_PROFILER_PATH_64",
194
+ "CORECLR_PROFILER_PATH_ARM32",
195
+ "CORECLR_PROFILER_PATH_ARM64",
196
+ "DOTNET_PROFILER_PATH",
197
+ "DOTNET_PROFILER_PATH_32",
198
+ "DOTNET_PROFILER_PATH_64",
199
+ "DOTNET_PROFILER_PATH_ARM32",
200
+ "DOTNET_PROFILER_PATH_ARM64",
201
+ "PATH",
202
+ "HTTP_PROXY",
203
+ "HTTPS_PROXY",
204
+ "ALL_PROXY",
205
+ "NO_PROXY",
206
+ "OPENSSL_CONF",
207
+ "OPENSSL_CONF_INCLUDE",
208
+ "OPENSSL_MODULES",
209
+ "OPENSSL_ENGINES",
210
+ "SSL_CERT_FILE",
211
+ "SSL_CERT_DIR",
212
+ "LD_PRELOAD",
213
+ "LD_LIBRARY_PATH",
214
+ "LD_AUDIT",
215
+ "DYLD_INSERT_LIBRARIES",
216
+ "DYLD_LIBRARY_PATH",
217
+ "DYLD_FRAMEWORK_PATH",
218
+ "DYLD_FALLBACK_LIBRARY_PATH",
219
+ "DYLD_FALLBACK_FRAMEWORK_PATH",
220
+ "DYLD_ROOT_PATH",
221
+ ] as const;
222
+ const GH_SHARE_TRUST_KEY_SET = new Set(GH_SHARE_TRUST_KEYS.map(name => name.toUpperCase()));
223
+
224
+ /**
225
+ * Project dotenv at import, before `/move` changes cwd. Those declarations are
226
+ * already in the process environment, and a later `setProjectDir` does not
227
+ * remove them.
228
+ */
229
+ const ghShareProjectSnapshot = projectEnvSnapshot();
230
+ const ghShareOperatorPath = process.env.PATH;
231
+ const ghShareLaunchRoot = path.resolve(process.cwd());
232
+
233
+ function isInsideDirectory(root: string, candidate: string): boolean {
234
+ const relative = path.relative(root, candidate);
235
+ return relative === "" || (relative !== ".." && !relative.startsWith(`..${path.sep}`) && !path.isAbsolute(relative));
236
+ }
237
+
238
+ async function findCheckoutRoots(directory: string): Promise<string[] | undefined> {
239
+ const resolvedDirectory = await fs.realpath(directory).catch(() => undefined);
240
+ if (!resolvedDirectory) return undefined;
241
+ const roots: string[] = [];
242
+ let ancestor = resolvedDirectory;
243
+ while (true) {
244
+ try {
245
+ await fs.lstat(path.join(ancestor, ".git"));
246
+ roots.push(ancestor);
247
+ } catch (error) {
248
+ if (!(error instanceof Error) || !("code" in error) || error.code !== "ENOENT") return undefined;
249
+ }
250
+ const parent = path.dirname(ancestor);
251
+ if (parent === ancestor) break;
252
+ ancestor = parent;
253
+ }
254
+ return roots;
255
+ }
256
+
257
+ function isInsideAnyDirectory(roots: readonly string[], candidate: string): boolean {
258
+ return roots.some(root => isInsideDirectory(root, candidate));
259
+ }
260
+
261
+ async function resolveGhShareExecutable(): Promise<{ executable: string; searchPath: string } | undefined> {
262
+ const operatorPath = ghShareOperatorPath;
263
+ const key = canonicalEnvKey("PATH");
264
+ const declared = ghShareProjectSnapshot.values[key];
265
+ if (
266
+ !operatorPath ||
267
+ (declared !== undefined && (ghShareProjectSnapshot.dynamic.has(key) || declared.trim() === operatorPath.trim()))
268
+ )
269
+ return undefined;
270
+ const checkoutRoots = new Set<string>();
271
+ for (const directory of new Set([ghShareLaunchRoot, path.resolve(process.cwd())])) {
272
+ const roots = await findCheckoutRoots(directory);
273
+ if (!roots) return undefined;
274
+ for (const root of roots) checkoutRoots.add(root);
275
+ }
276
+ const untrustedDirectories = [...checkoutRoots];
277
+ const trustedDirectories: string[] = [];
278
+ const seenDirectories = new Set<string>();
279
+ let executable: string | undefined;
280
+ for (const directory of operatorPath.split(path.delimiter)) {
281
+ if (!path.isAbsolute(directory)) continue;
282
+ const absoluteDirectory = path.resolve(directory);
283
+ if (isInsideAnyDirectory(untrustedDirectories, absoluteDirectory)) continue;
284
+ const realDirectory = await fs.realpath(absoluteDirectory).catch(() => undefined);
285
+ if (
286
+ !realDirectory ||
287
+ isInsideAnyDirectory(untrustedDirectories, realDirectory) ||
288
+ seenDirectories.has(realDirectory)
289
+ )
290
+ continue;
291
+ const candidate = Bun.which("gh", { PATH: realDirectory });
292
+ if (candidate) {
293
+ const absoluteCandidate = path.resolve(candidate);
294
+ if (isInsideAnyDirectory(untrustedDirectories, absoluteCandidate)) continue;
295
+ const realExecutable = await fs.realpath(absoluteCandidate).catch(() => undefined);
296
+ if (!realExecutable || isInsideAnyDirectory(untrustedDirectories, realExecutable)) continue;
297
+ executable ??= realExecutable;
298
+ }
299
+ seenDirectories.add(realDirectory);
300
+ trustedDirectories.push(realDirectory);
301
+ }
302
+ return executable ? { executable, searchPath: trustedDirectories.join(path.delimiter) } : undefined;
303
+ }
304
+
305
+ /**
306
+ * Environment for the default `/share` `gh` children. GitHub CLI routing,
307
+ * config, authentication, proxy, certificate, shell/runtime startup, executable-search,
308
+ * and dynamic loader overrides that match the project dotenv are omitted so a repository
309
+ * cannot redirect the upload, substitute the `gh` binary, authenticate with a
310
+ * project-provided token, or intercept its HTTPS request. The executable itself
311
+ * and its child search path use absolute operator PATH directories whose real
312
+ * paths are outside actual launch and active checkout roots. Operator values the project
313
+ * does not declare are kept.
314
+ */
315
+ function ghShareChildEnv(trustedPath: string, env: NodeJS.ProcessEnv = process.env): NodeJS.ProcessEnv {
316
+ const child: NodeJS.ProcessEnv = { ...env };
317
+ for (const name of Object.keys(child)) {
318
+ if (!GH_SHARE_TRUST_KEY_SET.has(name.toUpperCase())) continue;
319
+ const raw = child[name];
320
+ if (typeof raw !== "string") continue;
321
+ const key = canonicalEnvKey(name);
322
+ const declared = ghShareProjectSnapshot.values[key];
323
+ if (declared === undefined) continue;
324
+ if (!(ghShareProjectSnapshot.dynamic.has(key) || declared.trim() === raw.trim())) continue;
325
+ delete child[name];
326
+ if (process.platform === "win32") {
327
+ for (const present of Object.keys(child)) {
328
+ if (canonicalEnvKey(present) === key) delete child[present];
329
+ }
330
+ }
331
+ }
332
+ const ghConfigDirKey = canonicalEnvKey("GH_CONFIG_DIR");
333
+ const xdgConfigHomeKey = canonicalEnvKey("XDG_CONFIG_HOME");
334
+ for (const name of Object.keys(child)) {
335
+ const key = canonicalEnvKey(name);
336
+ if (key !== ghConfigDirKey && key !== xdgConfigHomeKey) continue;
337
+ const value = child[name];
338
+ if (typeof value !== "string" || value.length === 0 || path.isAbsolute(value)) continue;
339
+ // `gh` children use the filesystem root as cwd to avoid project Bun
340
+ // preloads, so retain the launch-directory meaning of relative config paths.
341
+ child[name] = path.resolve(ghShareLaunchRoot, value);
342
+ }
343
+ const certFileKey = canonicalEnvKey("SSL_CERT_FILE");
344
+ const certDirKey = canonicalEnvKey("SSL_CERT_DIR");
345
+ for (const name of Object.keys(child)) {
346
+ const key = canonicalEnvKey(name);
347
+ const value = child[name];
348
+ if (typeof value !== "string" || value.length === 0) continue;
349
+ if (key === certFileKey && !path.isAbsolute(value)) {
350
+ // Certificate overrides retain their launch-directory meaning even
351
+ // though `gh` children run from the filesystem root.
352
+ child[name] = path.resolve(ghShareLaunchRoot, value);
353
+ } else if (key === certDirKey) {
354
+ child[name] = value
355
+ .split(path.delimiter)
356
+ .map(directory =>
357
+ directory.length > 0 && !path.isAbsolute(directory)
358
+ ? path.resolve(ghShareLaunchRoot, directory)
359
+ : directory,
360
+ )
361
+ .join(path.delimiter);
362
+ }
363
+ }
364
+ const pathKey = canonicalEnvKey("PATH");
365
+ for (const name of Object.keys(child)) {
366
+ if (canonicalEnvKey(name) === pathKey) delete child[name];
367
+ }
368
+ child.PATH = trustedPath;
369
+ return child;
370
+ }
371
+
110
372
  export class CommandController {
111
373
  constructor(private readonly ctx: InteractiveModeContext) {}
112
374
 
@@ -147,6 +409,7 @@ export class CommandController {
147
409
  }
148
410
 
149
411
  async handleDebugTranscriptCommand(): Promise<void> {
412
+ let tempDir: string | undefined;
150
413
  try {
151
414
  const width = Math.max(1, this.ctx.ui.terminal.columns);
152
415
  const renderedLines = this.ctx.chatContainer.render(width).map(line => replaceTabs(Bun.stripANSI(line)));
@@ -155,10 +418,22 @@ export class CommandController {
155
418
  this.ctx.showError("No messages to dump yet.");
156
419
  return;
157
420
  }
158
- const tmpPath = path.join(os.tmpdir(), `${Snowflake.next()}-tmp.txt`);
159
- await Bun.write(tmpPath, `${rendered}\n`);
421
+ // Random directory plus an exclusive create: a preexisting symlink under the
422
+ // shared temp directory is not opened, and the transcript is not left world-readable.
423
+ tempDir = await fs.mkdtemp(path.join(os.tmpdir(), "skc-debug-transcript-"));
424
+ if (process.platform !== "win32") await fs.chmod(tempDir, 0o700);
425
+ const tmpPath = path.join(tempDir, "transcript.txt");
426
+ const handle = await fs.open(tmpPath, "wx", 0o600);
427
+ try {
428
+ await handle.writeFile(`${rendered}\n`);
429
+ } finally {
430
+ await handle.close();
431
+ }
432
+ if (process.platform !== "win32") await fs.chmod(tmpPath, 0o600);
160
433
  this.ctx.showStatus(`Debug transcript written to:\n${tmpPath}`);
434
+ tempDir = undefined;
161
435
  } catch (error: unknown) {
436
+ if (tempDir) await fs.rm(tempDir, { recursive: true, force: true }).catch(() => {});
162
437
  this.ctx.showError(
163
438
  `Failed to write debug transcript: ${error instanceof Error ? error.message : "Unknown error"}`,
164
439
  );
@@ -238,9 +513,21 @@ export class CommandController {
238
513
  return;
239
514
  }
240
515
 
516
+ const ghShare = await resolveGhShareExecutable();
517
+ if (!ghShare) {
518
+ this.ctx.showError(
519
+ "GitHub CLI (gh) is not installed on the trusted operator PATH. Install it from https://cli.github.com/",
520
+ );
521
+ return;
522
+ }
523
+ const ghShareExecutable = ghShare.executable;
524
+ // Bun wrappers load project bunfig.toml preloads from their working directory.
525
+ const ghShareCwd = path.parse(ghShareLaunchRoot).root;
526
+ const ghEnv = ghShareChildEnv(ghShare.searchPath);
241
527
  try {
242
- const authProcess = Bun.spawn(["gh", "auth", "status"], {
243
- env: process.env,
528
+ const authProcess = Bun.spawn([ghShareExecutable, "auth", "status"], {
529
+ cwd: ghShareCwd,
530
+ env: ghEnv,
244
531
  stdin: "ignore",
245
532
  stdout: "ignore",
246
533
  stderr: "ignore",
@@ -269,8 +556,9 @@ export class CommandController {
269
556
 
270
557
  let cancellationRequested = false;
271
558
  try {
272
- const gistProcess = Bun.spawn(["gh", "gist", "create", "--public=false", tmpFile], {
273
- env: process.env,
559
+ const gistProcess = Bun.spawn([ghShareExecutable, "gist", "create", "--public=false", tmpFile], {
560
+ cwd: ghShareCwd,
561
+ env: ghEnv,
274
562
  stdin: "ignore",
275
563
  stdout: "pipe",
276
564
  stderr: "pipe",
@@ -1135,7 +1423,9 @@ export class CommandController {
1135
1423
  try {
1136
1424
  if (!title?.trim()) {
1137
1425
  const generation = beginSessionTitleGeneration(this.ctx.sessionManager);
1138
- const input = buildConversationTitleInput(this.ctx.session.messages);
1426
+ const activeCwd = this.ctx.sessionManager.getCwd();
1427
+ const obfuscateText = await titleInputObfuscator(this.ctx.settings, activeCwd);
1428
+ const input = buildConversationTitleInput(this.ctx.session.messages, obfuscateText);
1139
1429
  if (!input) {
1140
1430
  this.ctx.showError("Nothing to summarize yet — pass a title: /rename <title>");
1141
1431
  return;
@@ -1148,10 +1438,11 @@ export class CommandController {
1148
1438
  this.ctx.session.sessionId,
1149
1439
  this.ctx.session.model,
1150
1440
  provider => this.ctx.session.agent.metadataForProvider(provider),
1441
+ activeCwd,
1151
1442
  );
1152
1443
  if (
1153
1444
  !isSessionTitleGenerationCurrent(this.ctx.sessionManager, generation) ||
1154
- buildConversationTitleInput(this.ctx.session.messages) !== input
1445
+ buildConversationTitleInput(this.ctx.session.messages, obfuscateText) !== input
1155
1446
  )
1156
1447
  return;
1157
1448
  if (!generated) {
@@ -554,7 +554,7 @@ export class EventController {
554
554
  ): Promise<void> {
555
555
  this.ctx.showStatus(`Fallback model: ${event.from} → ${event.to}`);
556
556
  this.ctx.statusLine.invalidate();
557
- this.ctx.ui.requestRender();
557
+ this.ctx.updateEditorBorderColor();
558
558
  }
559
559
 
560
560
  async #handleNotice(event: Extract<AgentSessionEvent, { type: "notice" }>): Promise<void> {