@sayknow-cli/coding-agent 0.7.11 → 0.7.13

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 (427) hide show
  1. package/CHANGELOG.md +16 -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 +22 -2
  71. package/dist/types/session/auto-resume.d.ts +5 -0
  72. package/dist/types/session/messages.d.ts +5 -1
  73. package/dist/types/session/session-manager.d.ts +13 -0
  74. package/dist/types/session/session-storage.d.ts +8 -0
  75. package/dist/types/session/streaming-output.d.ts +11 -0
  76. package/dist/types/session-import/redact.d.ts +1 -1
  77. package/dist/types/skc-runtime/managed-owner-admission.d.ts +3 -0
  78. package/dist/types/skc-runtime/psmux-detect.d.ts +5 -4
  79. package/dist/types/skc-runtime/ralplan-runtime.d.ts +5 -0
  80. package/dist/types/skc-runtime/sidecar-bootstrap-env.d.ts +6 -0
  81. package/dist/types/skc-runtime/state-writer.d.ts +4 -1
  82. package/dist/types/skc-runtime/tmux-sessions.d.ts +24 -0
  83. package/dist/types/skc-runtime/ultragoal-runtime.d.ts +4 -0
  84. package/dist/types/skill-state/workflow-mutation-guard.d.ts +20 -1
  85. package/dist/types/slash-commands/helpers/mcp.d.ts +5 -0
  86. package/dist/types/ssh/ssh-executor.d.ts +3 -1
  87. package/dist/types/system-prompt.d.ts +5 -2
  88. package/dist/types/task/executor.d.ts +17 -3
  89. package/dist/types/task/isolation-dir.d.ts +26 -0
  90. package/dist/types/task/role-body.d.ts +11 -0
  91. package/dist/types/task/token-log-mode.test.d.ts +1 -0
  92. package/dist/types/tools/ask.d.ts +77 -254
  93. package/dist/types/tools/ast-edit-write-path.d.ts +23 -0
  94. package/dist/types/tools/atomic-file-write.d.ts +74 -0
  95. package/dist/types/tools/auto-generated-guard.d.ts +5 -2
  96. package/dist/types/tools/bash-allowed-prefixes.d.ts +16 -0
  97. package/dist/types/tools/bash-interactive.d.ts +2 -0
  98. package/dist/types/tools/bash-skill-urls.d.ts +5 -1
  99. package/dist/types/tools/bash.d.ts +1 -0
  100. package/dist/types/tools/browser/cdp-url.d.ts +2 -0
  101. package/dist/types/tools/browser/tab-worker.d.ts +2 -0
  102. package/dist/types/tools/debug.d.ts +2 -2
  103. package/dist/types/tools/explicit-artifact.d.ts +8 -0
  104. package/dist/types/tools/fetch.d.ts +7 -4
  105. package/dist/types/tools/github-side-effect.d.ts +22 -0
  106. package/dist/types/tools/index.d.ts +3 -0
  107. package/dist/types/tools/monitor-mutation.d.ts +9 -0
  108. package/dist/types/tools/recipe/index.d.ts +2 -0
  109. package/dist/types/tools/recipe/recipe-guard.d.ts +7 -0
  110. package/dist/types/tools/restricted-cwd.d.ts +1 -0
  111. package/dist/types/tools/reverse-engineer.d.ts +81 -0
  112. package/dist/types/tools/search-tool-bm25.d.ts +2 -0
  113. package/dist/types/tools/tmux-self-injection-guard.d.ts +17 -0
  114. package/dist/types/tools/untrusted-content.d.ts +12 -0
  115. package/dist/types/utils/file-mentions.d.ts +5 -0
  116. package/dist/types/utils/open.d.ts +0 -1
  117. package/dist/types/utils/shell-snapshot.d.ts +2 -0
  118. package/dist/types/utils/title-generator.d.ts +12 -2
  119. package/dist/types/utils/tools-checksum.d.ts +7 -0
  120. package/dist/types/utils/xml-escape.d.ts +2 -0
  121. package/dist/types/web/scrapers/types.d.ts +8 -1
  122. package/dist/types/web/search/providers/codex.d.ts +6 -7
  123. package/dist/types/web/search/providers/insane.d.ts +7 -1
  124. package/dist/types/web/search/providers/kimi.d.ts +2 -0
  125. package/dist/types/web/search/providers/searxng.d.ts +7 -0
  126. package/dist/types/web/search/providers/xai.d.ts +2 -0
  127. package/package.json +7 -7
  128. package/scripts/generate-sdk-operation-inventory.ts +4 -0
  129. package/src/async/job-manager.ts +23 -9
  130. package/src/async/result-formatting.ts +40 -0
  131. package/src/capability/fs.ts +78 -11
  132. package/src/capability/mcp.ts +2 -0
  133. package/src/cli/append-system-prompt.ts +12 -0
  134. package/src/cli/auth-broker-cli.ts +22 -12
  135. package/src/cli/config-cli.ts +8 -18
  136. package/src/cli/migrate-cli.ts +7 -5
  137. package/src/cli/ssh-cli.ts +6 -3
  138. package/src/cli/stats-cli.ts +9 -4
  139. package/src/cli/update-cli.ts +42 -0
  140. package/src/cli/web-search-cli.ts +9 -3
  141. package/src/cli.ts +5 -9
  142. package/src/commands/commit.ts +2 -2
  143. package/src/commands/contribution-prep.ts +1 -3
  144. package/src/commands/harness.ts +25 -15
  145. package/src/commands/launch.ts +1 -1
  146. package/src/commands/migrate.ts +3 -3
  147. package/src/commands/sdk.ts +115 -14
  148. package/src/commands/ultragoal.ts +14 -8
  149. package/src/commit/agentic/agent.ts +6 -6
  150. package/src/commit/analysis/conventional.ts +14 -5
  151. package/src/commit/changelog/index.ts +39 -1
  152. package/src/commit/message.ts +10 -3
  153. package/src/config/config-file.ts +106 -3
  154. package/src/config/keybindings.ts +154 -7
  155. package/src/config/mcp-schema.json +4 -0
  156. package/src/config/model-registry.ts +10 -2
  157. package/src/config/settings-schema.ts +18 -0
  158. package/src/config/settings.ts +32 -4
  159. package/src/coordinator-mcp/policy.ts +14 -4
  160. package/src/coordinator-mcp/server.ts +44 -4
  161. package/src/coordinator-mcp/session-reaper.ts +9 -1
  162. package/src/cursor-delete-path.ts +10 -0
  163. package/src/cursor-mcp-name.ts +15 -0
  164. package/src/cursor.ts +13 -2
  165. package/src/dap/client.ts +9 -2
  166. package/src/dap/config.ts +33 -13
  167. package/src/dap/defaults.json +1 -1
  168. package/src/dap/session.ts +161 -36
  169. package/src/debug/crash-diagnostics.ts +89 -6
  170. package/src/debug/report-bundle-parent.ts +22 -0
  171. package/src/debug/report-bundle.ts +100 -3
  172. package/src/debug/system-info.ts +21 -4
  173. package/src/defaults/skc/extensions/grok-cli-vendor/src/shared/base-url.ts +21 -7
  174. package/src/defaults/skc/skills/deep-interview/SKILL.md +1 -1
  175. package/src/discovery/agents-md.ts +3 -2
  176. package/src/discovery/agents.ts +3 -2
  177. package/src/discovery/builtin.ts +21 -11
  178. package/src/discovery/claude.ts +5 -4
  179. package/src/discovery/cline.ts +2 -2
  180. package/src/discovery/codex.ts +6 -5
  181. package/src/discovery/cursor.ts +11 -2
  182. package/src/discovery/gemini.ts +4 -3
  183. package/src/discovery/github.ts +2 -2
  184. package/src/discovery/helpers.ts +51 -11
  185. package/src/discovery/mcp-json.ts +28 -12
  186. package/src/discovery/opencode.ts +2 -1
  187. package/src/discovery/ssh.ts +11 -6
  188. package/src/discovery/substitute-plugin-root.ts +3 -1
  189. package/src/discovery/vscode.ts +3 -3
  190. package/src/edit/apply-patch/index.ts +12 -1
  191. package/src/edit/file-read-cache.ts +24 -6
  192. package/src/edit/index.ts +90 -20
  193. package/src/edit/modes/patch.ts +215 -9
  194. package/src/edit/modes/replace.ts +141 -0
  195. package/src/eval/js/context-manager.ts +29 -3
  196. package/src/eval/js/worker-entry.ts +51 -18
  197. package/src/eval/py/runner.py +144 -5
  198. package/src/eval/py/runtime.ts +44 -4
  199. package/src/eval/py/tool-bridge.ts +4 -0
  200. package/src/exa/mcp-client.ts +53 -11
  201. package/src/exec/bash-executor.ts +87 -4
  202. package/src/exec/non-interactive-env.ts +0 -1
  203. package/src/export/html/css-color.ts +9 -0
  204. package/src/export/html/html-export-destination.ts +16 -0
  205. package/src/export/html/index.ts +102 -8
  206. package/src/export/html/template.generated.ts +1 -1
  207. package/src/extensibility/custom-tools/loader.ts +13 -3
  208. package/src/extensibility/custom-tools/types.ts +3 -1
  209. package/src/extensibility/custom-tools/wrapper.ts +3 -1
  210. package/src/extensibility/plugins/manager.ts +3 -2
  211. package/src/extensibility/plugins/marketplace/cache.ts +15 -0
  212. package/src/extensibility/plugins/marketplace/fetcher.ts +2 -2
  213. package/src/extensibility/plugins/marketplace/manager.ts +5 -3
  214. package/src/extensibility/plugins/plugin-link-path.ts +12 -0
  215. package/src/extensibility/skc-plugins/mcp-policy.ts +2 -1
  216. package/src/goals/runtime.ts +30 -8
  217. package/src/harness-control-plane/finalize.ts +10 -0
  218. package/src/harness-control-plane/operate.ts +12 -4
  219. package/src/harness-control-plane/owner.ts +8 -1
  220. package/src/harness-control-plane/receipt-spool.ts +105 -28
  221. package/src/harness-control-plane/storage.ts +124 -6
  222. package/src/hashline/execute.ts +3 -3
  223. package/src/hashline/recovery.ts +85 -2
  224. package/src/hindsight/config.ts +9 -3
  225. package/src/hindsight/content.ts +116 -16
  226. package/src/hindsight/mental-models.ts +22 -10
  227. package/src/hindsight/state.ts +7 -4
  228. package/src/hooks/native-skill-hook.ts +17 -12
  229. package/src/i18n/messages/de.settings.ts +3 -0
  230. package/src/i18n/messages/es.settings.ts +3 -0
  231. package/src/i18n/messages/fr.settings.ts +3 -0
  232. package/src/i18n/messages/ja.settings.ts +3 -0
  233. package/src/i18n/messages/ko.settings.ts +3 -0
  234. package/src/i18n/messages/zh.settings.ts +3 -0
  235. package/src/internal-urls/artifact-protocol.ts +3 -1
  236. package/src/internal-urls/docs-index.generated.ts +10 -10
  237. package/src/internal-urls/local-protocol.ts +167 -8
  238. package/src/internal-urls/skill-path.ts +18 -0
  239. package/src/internal-urls/skill-protocol.ts +2 -0
  240. package/src/internal-urls/types.ts +2 -0
  241. package/src/lsp/client.ts +2 -1
  242. package/src/lsp/clients/biome-client.ts +2 -0
  243. package/src/lsp/clients/swiftlint-client.ts +2 -0
  244. package/src/lsp/config.ts +18 -62
  245. package/src/lsp/edits.ts +6 -0
  246. package/src/lsp/index.ts +29 -0
  247. package/src/lsp/workspace-path.ts +75 -0
  248. package/src/main.ts +33 -11
  249. package/src/memories/index.ts +141 -9
  250. package/src/migrate/action-planner.ts +57 -0
  251. package/src/migrate/adapters/claude-code.ts +23 -4
  252. package/src/migrate/adapters/codex.ts +22 -4
  253. package/src/migrate/adapters/index.ts +22 -4
  254. package/src/migrate/adapters/opencode.ts +6 -1
  255. package/src/migrate/executor.ts +84 -7
  256. package/src/migrate/report.ts +19 -2
  257. package/src/migrate/types.ts +14 -4
  258. package/src/modes/DESIGN.md +5 -0
  259. package/src/modes/acp/acp-agent.ts +35 -2
  260. package/src/modes/acp/permission-mode.ts +18 -1
  261. package/src/modes/components/custom-editor.ts +14 -0
  262. package/src/modes/components/extensions/extension-dashboard.ts +2 -2
  263. package/src/modes/components/extensions/inspector-panel.ts +9 -5
  264. package/src/modes/components/extensions/state-manager.ts +15 -5
  265. package/src/modes/components/model-selector.ts +144 -94
  266. package/src/modes/components/welcome.ts +3 -2
  267. package/src/modes/controllers/command-controller.ts +300 -9
  268. package/src/modes/controllers/event-controller.ts +1 -1
  269. package/src/modes/controllers/extension-ui-controller.ts +32 -19
  270. package/src/modes/controllers/input-controller.ts +62 -26
  271. package/src/modes/controllers/plan-mode-controller.ts +17 -7
  272. package/src/modes/controllers/runtime-mcp-command-controller.ts +25 -20
  273. package/src/modes/controllers/ssh-command-controller.ts +3 -1
  274. package/src/modes/interactive-mode.ts +10 -0
  275. package/src/modes/utils/macos-option-forwarding.ts +80 -0
  276. package/src/prompts/system/irc-incoming.md +3 -1
  277. package/src/prompts/system/project-prompt.md +19 -0
  278. package/src/prompts/system/system-prompt.md +3 -0
  279. package/src/prompts/tools/ask.md +2 -0
  280. package/src/prompts/tools/debug.md +1 -1
  281. package/src/prompts/tools/monitor.md +7 -5
  282. package/src/prompts/tools/reverse-engineer.md +29 -0
  283. package/src/runtime-credential-selector.ts +2 -2
  284. package/src/runtime-mcp/config-writer.ts +10 -6
  285. package/src/runtime-mcp/config.ts +1 -0
  286. package/src/runtime-mcp/content-limits.ts +7 -0
  287. package/src/runtime-mcp/json-rpc.ts +2 -1
  288. package/src/runtime-mcp/manager.ts +57 -9
  289. package/src/runtime-mcp/mcp-redirect.ts +73 -0
  290. package/src/runtime-mcp/oauth-flow.ts +43 -5
  291. package/src/runtime-mcp/oauth-public-url.ts +8 -0
  292. package/src/runtime-mcp/plugin-mcp-name-filter.ts +62 -0
  293. package/src/runtime-mcp/plugin-network-boundary.ts +4 -0
  294. package/src/runtime-mcp/project-host-values.ts +50 -0
  295. package/src/runtime-mcp/render.ts +16 -1
  296. package/src/runtime-mcp/smithery-registry.ts +22 -3
  297. package/src/runtime-mcp/tool-bridge.ts +194 -21
  298. package/src/runtime-mcp/transports/http.ts +4 -3
  299. package/src/runtime-mcp/transports/stdio.ts +2 -1
  300. package/src/runtime-mcp/types.ts +6 -0
  301. package/src/sdk/broker/broker.ts +11 -2
  302. package/src/sdk/broker/ensure.ts +131 -10
  303. package/src/sdk/broker/lifecycle-ledger.ts +18 -3
  304. package/src/sdk/broker/lifecycle.ts +21 -19
  305. package/src/sdk/broker/runtime.ts +1 -1
  306. package/src/sdk/bus/chat-daemon-cli.ts +38 -1
  307. package/src/sdk/bus/chat-daemon-control.ts +5 -3
  308. package/src/sdk/bus/index.ts +5 -3
  309. package/src/sdk/bus/lifecycle-control-runtime.ts +9 -2
  310. package/src/sdk/bus/session-control.ts +2 -0
  311. package/src/sdk/bus/slack-daemon.ts +8 -1
  312. package/src/sdk/bus/slack-live-provider.ts +3 -1
  313. package/src/sdk/bus/telegram-daemon-contract.ts +3 -1
  314. package/src/sdk/bus/telegram-daemon-control.ts +17 -12
  315. package/src/sdk/bus/telegram-daemon.ts +41 -1
  316. package/src/sdk/host/events.ts +67 -4
  317. package/src/sdk/mcp/server.ts +16 -3
  318. package/src/sdk/protocol/operation-inventory.generated.json +22 -0
  319. package/src/sdk/session.ts +18 -25
  320. package/src/secrets/obfuscator.ts +92 -12
  321. package/src/session/agent-session.ts +466 -100
  322. package/src/session/artifacts.ts +3 -1
  323. package/src/session/auto-resume.ts +45 -8
  324. package/src/session/history-storage.ts +172 -8
  325. package/src/session/internal/managed-session-scope.ts +130 -52
  326. package/src/session/messages.ts +47 -6
  327. package/src/session/session-manager.ts +116 -8
  328. package/src/session/session-storage.ts +31 -1
  329. package/src/session/streaming-output.ts +263 -4
  330. package/src/session-import/redact.ts +76 -3
  331. package/src/setup/hermes-setup.ts +4 -1
  332. package/src/skc-runtime/gc-runtime.ts +26 -4
  333. package/src/skc-runtime/launch-tmux.ts +21 -11
  334. package/src/skc-runtime/launch-worktree.ts +42 -3
  335. package/src/skc-runtime/managed-owner-admission.ts +46 -2
  336. package/src/skc-runtime/psmux-detect.ts +29 -5
  337. package/src/skc-runtime/ralplan-runtime.ts +14 -1
  338. package/src/skc-runtime/session-resolution.ts +38 -6
  339. package/src/skc-runtime/sidecar-bootstrap-env.ts +19 -0
  340. package/src/skc-runtime/state-writer.ts +134 -16
  341. package/src/skc-runtime/tmux-sessions.ts +85 -4
  342. package/src/skc-runtime/ultragoal-change-set.ts +18 -2
  343. package/src/skc-runtime/ultragoal-guard.ts +9 -1
  344. package/src/skc-runtime/ultragoal-runtime.ts +26 -9
  345. package/src/skill-state/active-state.ts +13 -0
  346. package/src/skill-state/workflow-mutation-guard.ts +3297 -180
  347. package/src/slash-commands/builtin-registry.ts +14 -8
  348. package/src/slash-commands/helpers/mcp.ts +20 -7
  349. package/src/ssh/ssh-executor.ts +3 -1
  350. package/src/stt/recorder.ts +26 -9
  351. package/src/system-prompt.ts +65 -16
  352. package/src/task/commands.ts +3 -1
  353. package/src/task/executor.ts +52 -7
  354. package/src/task/index.ts +28 -0
  355. package/src/task/isolation-dir.ts +143 -0
  356. package/src/task/role-body.ts +84 -0
  357. package/src/task/token-log-mode.test.ts +162 -0
  358. package/src/task/token-log.ts +91 -2
  359. package/src/task/worktree.ts +16 -7
  360. package/src/tools/archive-reader.ts +653 -31
  361. package/src/tools/ask.ts +86 -14
  362. package/src/tools/ast-edit-write-path.ts +133 -0
  363. package/src/tools/ast-edit.ts +27 -1
  364. package/src/tools/ast-grep.ts +7 -2
  365. package/src/tools/atomic-file-write.ts +625 -0
  366. package/src/tools/auto-generated-guard.ts +28 -8
  367. package/src/tools/bash-allowed-prefixes.ts +225 -6
  368. package/src/tools/bash-interactive.ts +12 -0
  369. package/src/tools/bash-skill-urls.ts +113 -7
  370. package/src/tools/bash.ts +152 -20
  371. package/src/tools/browser/cdp-url.ts +18 -0
  372. package/src/tools/browser/tab-worker.ts +49 -14
  373. package/src/tools/browser.ts +25 -8
  374. package/src/tools/cron.ts +10 -1
  375. package/src/tools/debug.ts +16 -8
  376. package/src/tools/eval.ts +71 -34
  377. package/src/tools/explicit-artifact.ts +89 -0
  378. package/src/tools/fetch.ts +26 -17
  379. package/src/tools/gh.ts +40 -12
  380. package/src/tools/github-side-effect.ts +112 -0
  381. package/src/tools/image-gen.ts +24 -10
  382. package/src/tools/index.ts +6 -0
  383. package/src/tools/monitor-mutation.ts +27 -0
  384. package/src/tools/monitor.ts +28 -1
  385. package/src/tools/output-meta.ts +74 -5
  386. package/src/tools/read.ts +24 -36
  387. package/src/tools/recipe/index.ts +12 -0
  388. package/src/tools/recipe/recipe-guard.ts +19 -0
  389. package/src/tools/recipe/runner.ts +23 -12
  390. package/src/tools/render-utils.ts +2 -2
  391. package/src/tools/restricted-cwd.ts +10 -0
  392. package/src/tools/reverse-engineer.ts +497 -0
  393. package/src/tools/search-tool-bm25.ts +14 -3
  394. package/src/tools/search.ts +3 -2
  395. package/src/tools/ssh.ts +235 -8
  396. package/src/tools/subagent-render.ts +43 -7
  397. package/src/tools/subagent.ts +7 -3
  398. package/src/tools/tmux-self-injection-guard.ts +3538 -0
  399. package/src/tools/todo-write.ts +41 -3
  400. package/src/tools/untrusted-content.ts +23 -0
  401. package/src/tools/vim.ts +2 -2
  402. package/src/tools/write.ts +37 -4
  403. package/src/tui/tree-list.ts +15 -1
  404. package/src/utils/commit-message-generator.ts +9 -2
  405. package/src/utils/external-editor.ts +21 -7
  406. package/src/utils/file-mentions.ts +75 -7
  407. package/src/utils/git.ts +38 -7
  408. package/src/utils/open.ts +73 -4
  409. package/src/utils/shell-snapshot.ts +9 -1
  410. package/src/utils/title-generator.ts +61 -16
  411. package/src/utils/tools-checksum.ts +34 -0
  412. package/src/utils/tools-manager.ts +24 -6
  413. package/src/utils/xml-escape.ts +14 -0
  414. package/src/web/insane/url-guard.ts +2 -1
  415. package/src/web/scrapers/types.ts +8 -0
  416. package/src/web/scrapers/youtube.ts +3 -2
  417. package/src/web/search/index.ts +4 -3
  418. package/src/web/search/providers/anthropic.ts +4 -4
  419. package/src/web/search/providers/codex.ts +31 -34
  420. package/src/web/search/providers/insane.ts +145 -28
  421. package/src/web/search/providers/kimi.ts +15 -5
  422. package/src/web/search/providers/searxng.ts +47 -4
  423. package/src/web/search/providers/xai.ts +7 -2
  424. package/dist/types/cli/shell-cli.d.ts +0 -8
  425. package/dist/types/commands/shell.d.ts +0 -21
  426. package/src/cli/shell-cli.ts +0 -176
  427. package/src/commands/shell.ts +0 -29
@@ -7,7 +7,7 @@
7
7
  import * as path from "node:path";
8
8
  import { isEnoent, peekFile } from "@sayknow-cli/utils";
9
9
  import { LRUCache } from "lru-cache/raw";
10
- import { settings } from "../config/settings";
10
+ import { Settings, type Settings as SettingsType } from "../config/settings";
11
11
  import { ToolError } from "./tool-errors";
12
12
 
13
13
  /**
@@ -16,6 +16,12 @@ import { ToolError } from "./tool-errors";
16
16
  const CHECK_BYTE_COUNT = 1024;
17
17
  const HEADER_LINE_LIMIT = 40;
18
18
 
19
+ type SettingsReader = Pick<SettingsType, "get">;
20
+
21
+ function resolveGuardSettings(settings?: SettingsReader): SettingsReader {
22
+ return settings ?? Settings.instance;
23
+ }
24
+
19
25
  const KNOWN_GENERATOR_PATTERN =
20
26
  "(?:protoc(?:-gen-[\\w-]+)?|sqlc|buf|swagger(?:-codegen)?|openapi(?:-generator)?|grpc-gateway|mockery|stringer|easyjson|deepcopy-gen|defaulter-gen|conversion-gen|client-gen|lister-gen|informer-gen|kysely-codegen|napi-rs)";
21
27
 
@@ -30,6 +36,8 @@ const AUTO_GENERATED_HEADER_MARKERS: readonly RegExp[] = [
30
36
  /\bcode\s+generated\s+by\s+[a-z0-9_.-]+/i,
31
37
  /\bthis\s+file\s+was\s+automatically\s+generated\b/i,
32
38
  new RegExp(`\\bgenerated\\s+by\\s+${KNOWN_GENERATOR_PATTERN}\\b`, "i"),
39
+ /\bgenerated\s+by\s+scripts\/[a-z0-9_./-]+/i,
40
+ /\bauto-generated\s+by\s+[a-z0-9_./-]+/i,
33
41
  ];
34
42
 
35
43
  type CommentStyle = "slash" | "hash" | "sql" | "html";
@@ -94,6 +102,7 @@ const AUTO_GENERATED_FILENAME_PATTERNS = [
94
102
  /_pb2\.py$/,
95
103
  /_pb2_grpc\.py$/,
96
104
  /\.gen\.(go|ts|js|py)$/,
105
+ /\.generated\.ts$/,
97
106
  /^generated\.(go|ts|js|py)$/,
98
107
  /\.swagger\.json$/,
99
108
  /\.openapi\.json$/,
@@ -203,8 +212,14 @@ function extractLeadingHeaderCommentText(content: string, commentStyles: readonl
203
212
  * Check if a file name indicates it might be auto-generated.
204
213
  * This is a quick pre-check before reading file content.
205
214
  */
215
+ function guardFileName(filePath: string): string {
216
+ // resolvePlanPath keeps the platform separator. Anchored patterns such as
217
+ // zz_generated.* and generated.ts must see that basename on Windows too.
218
+ return path.win32.basename(filePath);
219
+ }
220
+
206
221
  function isAutoGeneratedFileName(filePath: string): boolean {
207
- const fileName = filePath.split("/").pop() ?? "";
222
+ const fileName = guardFileName(filePath);
208
223
  return AUTO_GENERATED_FILENAME_PATTERNS.some(pattern => pattern.test(fileName));
209
224
  }
210
225
 
@@ -245,11 +260,14 @@ const autoGeneratedMap = new LRUCache<string, { marker: string | undefined }>({
245
260
 
246
261
  async function getAutoGeneratedMarker(filePath: string): Promise<string | undefined> {
247
262
  if (isAutoGeneratedFileName(filePath)) {
248
- return filePath.split("/").pop() ?? "";
263
+ return guardFileName(filePath);
249
264
  }
250
265
 
251
266
  const cached = autoGeneratedMap.get(filePath);
252
- if (cached) return cached.marker;
267
+ // A cached miss only means the file was handwritten at the last read.
268
+ // An earlier patch entry can write a generated header before a later
269
+ // rename checks the same destination, so do not trust that miss.
270
+ if (cached && cached.marker !== undefined) return cached.marker;
253
271
 
254
272
  let marker: string | undefined;
255
273
  try {
@@ -273,8 +291,9 @@ async function getAutoGeneratedMarker(filePath: string): Promise<string | undefi
273
291
  * @param absolutePath - Absolute path to the file
274
292
  * @param displayPath - Path to show in error messages (relative or as provided)
275
293
  */
276
- export async function assertEditableFile(absolutePath: string, displayPath?: string) {
277
- if (!settings.get("edit.blockAutoGenerated")) {
294
+ export async function assertEditableFile(absolutePath: string, displayPath?: string, settings?: SettingsReader) {
295
+ const activeSettings = resolveGuardSettings(settings);
296
+ if (!activeSettings.get("edit.blockAutoGenerated")) {
278
297
  return;
279
298
  }
280
299
  const pathForDisplay = displayPath ?? absolutePath;
@@ -292,8 +311,9 @@ export async function assertEditableFile(absolutePath: string, displayPath?: str
292
311
  * @param content - File content to check (can be full content or prefix)
293
312
  * @param displayPath - Path to show in error messages
294
313
  */
295
- export function assertEditableFileContent(content: string, displayPath: string): void {
296
- if (!settings.get("edit.blockAutoGenerated")) {
314
+ export function assertEditableFileContent(content: string, displayPath: string, settings?: SettingsReader): void {
315
+ const activeSettings = resolveGuardSettings(settings);
316
+ if (!activeSettings.get("edit.blockAutoGenerated")) {
297
317
  return;
298
318
  }
299
319
 
@@ -1,3 +1,5 @@
1
+ import * as fs from "node:fs";
2
+ import * as path from "node:path";
1
3
  import {
2
4
  classifyStateArgv,
3
5
  STATE_ACTION_NAMES,
@@ -13,8 +15,19 @@ export interface BashAllowedPrefixesCheck {
13
15
 
14
16
  export type BashRestrictionProfile = "workflow" | "read-only";
15
17
 
18
+ /** Session identity and workspace the restricted `skc` command may name. */
19
+ export interface SkcSessionBinding {
20
+ /** Tool session id; it is also the SKC_SESSION_ID the restricted child receives. */
21
+ sessionId?: string | null;
22
+ /** Session workspace. A `--worktree-root` must be this repo, not a foreign one. */
23
+ worktreeRoot: string;
24
+ /** Child cwd. Relative `--worktree-root` resolves against it, as ralplan does. */
25
+ invocationCwd: string;
26
+ }
27
+
16
28
  export interface BashRestrictionOptions {
17
29
  profile?: BashRestrictionProfile;
30
+ skcSessionBinding?: SkcSessionBinding;
18
31
  }
19
32
 
20
33
  const SHELL_CONTROL_CHARS = new Set([";", "|", "&", "<", ">", "(", ")"]);
@@ -228,6 +241,33 @@ function isLongOption(word: string, option: string): boolean {
228
241
  return word === option || word.startsWith(`${option}=`);
229
242
  }
230
243
 
244
+ function fileCompilesMagic(words: readonly string[]): boolean {
245
+ const valueOptions = ["--exclude", "--exclude-quiet", "--files-from", "--separator", "--magic-file", "--parameter"];
246
+ for (let index = 1; index < words.length; index += 1) {
247
+ const word = words[index]!;
248
+ if (word === "--") break;
249
+ if (word.startsWith("--")) {
250
+ const equalsAt = word.indexOf("=");
251
+ const name = equalsAt === -1 ? word : word.slice(0, equalsAt);
252
+ if (name.length > 2 && "--compile".startsWith(name)) return true;
253
+ if (equalsAt === -1 && valueOptions.some(option => name.length > 2 && option.startsWith(name))) {
254
+ index += 1;
255
+ }
256
+ } else if (word.startsWith("-")) {
257
+ for (let offset = 1; offset < word.length; offset += 1) {
258
+ const flag = word[offset]!;
259
+ if (flag === "C") return true;
260
+ // Required arguments consume the rest of the cluster, or the next word (even `--`).
261
+ if ("eFfmMP".includes(flag)) {
262
+ if (offset === word.length - 1) index += 1;
263
+ break;
264
+ }
265
+ }
266
+ }
267
+ }
268
+ return false;
269
+ }
270
+
231
271
  function hasShortOption(word: string, option: string): boolean {
232
272
  return word.startsWith("-") && !word.startsWith("--") && word.slice(1).includes(option);
233
273
  }
@@ -236,7 +276,9 @@ function shellQuote(value: string): string {
236
276
  }
237
277
 
238
278
  function resolvedExternalCommand(command: string): string | undefined {
239
- return Bun.which(command) ?? undefined;
279
+ // Bun.which caches a command name until PATH is passed explicitly, so a test
280
+ // or a later session that changes PATH must be visible here.
281
+ return Bun.which(command, { PATH: process.env.PATH ?? "" }) ?? undefined;
240
282
  }
241
283
 
242
284
  function validateReadOnlyCommand(words: readonly string[]): BashAllowedPrefixesCheck {
@@ -251,6 +293,9 @@ function validateReadOnlyCommand(words: readonly string[]): BashAllowedPrefixesC
251
293
  if (isLongOption(option, "--pre") || isLongOption(option, "--pre-glob")) {
252
294
  return { allowed: false, reason: "read-only bash does not allow ripgrep preprocessors" };
253
295
  }
296
+ if (isLongOption(option, "--hostname-bin")) {
297
+ return { allowed: false, reason: "read-only bash does not allow ripgrep hostname commands" };
298
+ }
254
299
  if (isLongOption(option, "--search-zip") || hasShortOption(option, "z")) {
255
300
  return { allowed: false, reason: "read-only bash does not allow ripgrep compressed-file subprocesses" };
256
301
  }
@@ -265,17 +310,167 @@ function validateReadOnlyCommand(words: readonly string[]): BashAllowedPrefixesC
265
310
  }
266
311
  }
267
312
 
313
+ if (command === "file" && fileCompilesMagic(words)) {
314
+ return { allowed: false, reason: "read-only bash does not allow file magic compilation" };
315
+ }
316
+
317
+ const gitWrite = rejectGitHostAccess(words);
318
+ if (gitWrite) return gitWrite;
319
+
268
320
  return { allowed: true };
269
321
  }
270
322
 
271
- function validateMatchedSkcCommand(words: readonly string[]): BashAllowedPrefixesCheck {
323
+ const GIT_DIFF_FAMILY_SUBCOMMANDS = new Set(["blame", "diff", "log", "show"]);
324
+
325
+ function gitOptionName(word: string): string {
326
+ const equalsAt = word.indexOf("=");
327
+ return equalsAt === -1 ? word : word.slice(0, equalsAt);
328
+ }
329
+
330
+ /** Enabling forms only. `--no-ext-diff` and `--no-textconv` stay allowed. */
331
+ function gitEnablesExternalHelper(word: string): boolean {
332
+ if (!word.startsWith("--")) return false;
333
+ const name = gitOptionName(word);
334
+ return name === "--ext-diff" || name === "--textconv";
335
+ }
336
+
337
+ function rejectGitHostAccess(words: readonly string[]): BashAllowedPrefixesCheck | undefined {
338
+ if (words[0] !== "git") return undefined;
339
+ for (const option of optionWords(words)) {
340
+ if (isLongOption(option, "--output") || isLongOption(option, "--no-index")) {
341
+ return { allowed: false, reason: "restricted bash does not allow git --output or --no-index" };
342
+ }
343
+ if (gitEnablesExternalHelper(option)) {
344
+ return {
345
+ allowed: false,
346
+ reason: "restricted bash does not allow git external diff or textconv helpers",
347
+ };
348
+ }
349
+ }
350
+ return undefined;
351
+ }
352
+
353
+ /**
354
+ * Diff-family git commands run `diff.external`, `GIT_EXTERNAL_DIFF`, and textconv
355
+ * filters unless these flags are present. Place them immediately after the
356
+ * subcommand so a later value-taking option cannot consume them and they stay
357
+ * before a `--` pathspec. The gate rejects a later `--ext-diff` or `--textconv`,
358
+ * which would otherwise win.
359
+ */
360
+ function disableGitExternalHelpers(commandName: string, argv: readonly string[]): string[] {
361
+ if (commandName !== "git" || !GIT_DIFF_FAMILY_SUBCOMMANDS.has(argv[1] ?? "")) return [...argv];
362
+ const next = [...argv];
363
+ next.splice(2, 0, "--no-ext-diff", "--no-textconv");
364
+ return next;
365
+ }
366
+
367
+ const SKC_SESSION_BIND_REASON = "restricted role-agent bash binds skc to the current session";
368
+ const SKC_WORKTREE_BIND_REASON = "restricted role-agent bash binds skc --worktree-root to the current repository";
369
+
370
+ function separateFlagValues(words: readonly string[], flag: string): string[] {
371
+ const values: string[] = [];
372
+ for (let index = 0; index < words.length; index += 1) {
373
+ if (words[index] !== flag) continue;
374
+ values.push(words[index + 1] ?? "");
375
+ index += 1;
376
+ }
377
+ return values;
378
+ }
379
+
380
+ function boundSessionIds(binding: SkcSessionBinding): ReadonlySet<string> {
381
+ const ids = new Set<string>();
382
+ const trimmed = typeof binding.sessionId === "string" ? binding.sessionId.trim() : "";
383
+ if (trimmed) ids.add(trimmed);
384
+ return ids;
385
+ }
386
+
387
+ function inlineStateSessionIds(words: readonly string[]): string[] {
388
+ if (words[1] !== "state") return [];
389
+ const ids: string[] = [];
390
+ for (const input of classifyStateArgv(words.slice(2)).inputs) {
391
+ if (input.kind !== "inline") continue;
392
+ let payload: unknown;
393
+ try {
394
+ payload = JSON.parse(input.raw);
395
+ } catch {
396
+ continue;
397
+ }
398
+ if (!payload || typeof payload !== "object" || Array.isArray(payload)) continue;
399
+ const sessionId = (payload as Record<string, unknown>).session_id;
400
+ if (typeof sessionId === "string") ids.push(sessionId);
401
+ }
402
+ return ids;
403
+ }
404
+
405
+ function gitCommonDir(directory: string): string | undefined {
406
+ const result = Bun.spawnSync(["git", "-C", directory, "rev-parse", "--git-common-dir"], {
407
+ stdout: "pipe",
408
+ stderr: "ignore",
409
+ });
410
+ if (result.exitCode !== 0) return undefined;
411
+ const text = result.stdout.toString().trim();
412
+ if (!text) return undefined;
413
+ const absolute = path.isAbsolute(text) ? text : path.resolve(directory, text);
414
+ try {
415
+ return fs.realpathSync(absolute);
416
+ } catch {
417
+ return undefined;
418
+ }
419
+ }
420
+
421
+ /** Same directory, or another worktree of the same git common dir (isolated tasks). */
422
+ function sameRepository(workspace: string, target: string): boolean {
423
+ let workspaceReal: string;
424
+ let targetReal: string;
425
+ try {
426
+ workspaceReal = fs.realpathSync(workspace);
427
+ targetReal = fs.realpathSync(target);
428
+ } catch {
429
+ return false;
430
+ }
431
+ if (workspaceReal === targetReal) return true;
432
+ const workspaceCommon = gitCommonDir(workspaceReal);
433
+ const targetCommon = gitCommonDir(targetReal);
434
+ return workspaceCommon !== undefined && workspaceCommon === targetCommon;
435
+ }
436
+
437
+ function worktreeSelectorAllowed(binding: SkcSessionBinding, rawTarget: string): boolean {
438
+ const trimmed = rawTarget.trim();
439
+ if (!trimmed) return false;
440
+ const resolved = path.isAbsolute(trimmed) ? trimmed : path.resolve(binding.invocationCwd, trimmed);
441
+ return sameRepository(binding.worktreeRoot, resolved);
442
+ }
443
+
444
+ function rejectUnboundSkcCommand(
445
+ words: readonly string[],
446
+ options: BashRestrictionOptions,
447
+ ): BashAllowedPrefixesCheck | undefined {
448
+ const binding = options.skcSessionBinding;
449
+ if (!binding) return undefined;
450
+ const allowed = boundSessionIds(binding);
451
+ const sessionSelectors = [...separateFlagValues(words, "--session-id"), ...inlineStateSessionIds(words)];
452
+ if (sessionSelectors.some(value => !allowed.has(value.trim()))) {
453
+ return { allowed: false, reason: SKC_SESSION_BIND_REASON };
454
+ }
455
+ if (separateFlagValues(words, "--worktree-root").some(value => !worktreeSelectorAllowed(binding, value))) {
456
+ return { allowed: false, reason: SKC_WORKTREE_BIND_REASON };
457
+ }
458
+ return undefined;
459
+ }
460
+
461
+ function validateMatchedSkcCommand(
462
+ words: readonly string[],
463
+ options: BashRestrictionOptions,
464
+ ): BashAllowedPrefixesCheck {
465
+ const gitWrite = rejectGitHostAccess(words);
466
+ if (gitWrite) return gitWrite;
272
467
  if (words[0] !== "skc") return { allowed: true };
273
468
 
274
469
  if (words[1] === "ralplan") {
275
470
  if (!words.includes("--write")) {
276
471
  return { allowed: false, reason: "restricted role-agent bash only allows `skc ralplan --write ...`" };
277
472
  }
278
- return { allowed: true };
473
+ return rejectUnboundSkcCommand(words, options) ?? { allowed: true };
279
474
  }
280
475
 
281
476
  if (words[1] === "state") {
@@ -293,10 +488,10 @@ function validateMatchedSkcCommand(words: readonly string[]): BashAllowedPrefixe
293
488
  reason: `restricted role-agent bash does not allow \`skc state ${classification.parsed.action}\``,
294
489
  };
295
490
  }
296
- return { allowed: true };
491
+ return rejectUnboundSkcCommand(words, options) ?? { allowed: true };
297
492
  }
298
493
 
299
- return { allowed: true };
494
+ return rejectUnboundSkcCommand(words, options) ?? { allowed: true };
300
495
  }
301
496
 
302
497
  function commandAllowedPrefixesReason(normalizedPrefixes: readonly string[], options: BashRestrictionOptions): string {
@@ -306,6 +501,30 @@ function commandAllowedPrefixesReason(normalizedPrefixes: readonly string[], opt
306
501
  : `restricted role-agent bash only allows commands starting with: ${prefixList}`;
307
502
  }
308
503
 
504
+ /**
505
+ * Workflow restricted bash keeps the lexical prefix check, then runs the resolved
506
+ * executable. Callers also skip the shell snapshot and shell prefix, because a
507
+ * snapshot function can be named for that absolute path.
508
+ */
509
+ export function normalizeWorkflowBashCommand(
510
+ command: string,
511
+ allowedPrefixes: readonly string[] | undefined,
512
+ options: BashRestrictionOptions = {},
513
+ ): string | undefined {
514
+ if (options.profile === "read-only") return undefined;
515
+ const gate = checkBashAllowedPrefixes(command, allowedPrefixes, { ...options, profile: "workflow" });
516
+ if (!gate.allowed) return undefined;
517
+ const parsed = parseShellWords(command.trim());
518
+ if (parsed.reason || parsed.words.length === 0) return undefined;
519
+ const [head, ...rest] = parsed.words;
520
+ if (!head) return undefined;
521
+ const resolvedHead = resolvedExternalCommand(head);
522
+ if (!resolvedHead) return undefined;
523
+ return disableGitExternalHelpers(head, [resolvedHead, ...rest])
524
+ .map(shellQuote)
525
+ .join(" ");
526
+ }
527
+
309
528
  export function normalizeReadOnlyBashCommand(command: string): string | undefined {
310
529
  const parsed = parseShellWords(command.trim());
311
530
  if (parsed.reason || parsed.words.length === 0) return undefined;
@@ -342,5 +561,5 @@ export function checkBashAllowedPrefixes(
342
561
  if (options.profile === "read-only") {
343
562
  return validateReadOnlyCommand(parsed.words);
344
563
  }
345
- return validateMatchedSkcCommand(parsed.words);
564
+ return validateMatchedSkcCommand(parsed.words, options);
346
565
  }
@@ -11,6 +11,7 @@ import {
11
11
  visibleWidth,
12
12
  } from "@sayknow-cli/tui";
13
13
  import { sanitizeText } from "@sayknow-cli/utils";
14
+ import { projectDeclaredSpawnHookNames, projectSafeHomeOverride } from "@sayknow-cli/utils/shell-config";
14
15
  import type { Terminal as XtermTerminalType } from "@xterm/headless";
15
16
  import { Settings } from "../config/settings";
16
17
  import { NON_INTERACTIVE_ENV } from "../exec/non-interactive-env";
@@ -283,6 +284,10 @@ class BashInteractiveOverlayComponent implements Component {
283
284
  }
284
285
  }
285
286
 
287
+ function ptyUnsetHookNames(explicit: Record<string, string> | undefined): string[] {
288
+ return projectDeclaredSpawnHookNames().filter(name => !Object.hasOwn(explicit ?? {}, name));
289
+ }
290
+
286
291
  export async function runInteractiveBashPty(
287
292
  ui: NonNullable<AgentToolContext["ui"]>,
288
293
  options: {
@@ -291,6 +296,8 @@ export async function runInteractiveBashPty(
291
296
  timeoutMs: number;
292
297
  signal?: AbortSignal;
293
298
  env?: Record<string, string>;
299
+ /** Environment names to hide from the PTY child. Explicit `env` values win. */
300
+ unsetEnv?: string[];
294
301
  artifactPath?: string;
295
302
  artifactId?: string;
296
303
  },
@@ -363,10 +370,15 @@ export async function runInteractiveBashPty(
363
370
  command: options.command,
364
371
  cwd: options.cwd,
365
372
  timeoutMs: options.timeoutMs,
373
+ // The PTY child inherits the process env; drop project hook variables
374
+ // unless this call sets them explicitly. A dropped HOME is replaced by
375
+ // the trusted account home so the shell and git still have one.
366
376
  env: {
377
+ ...projectSafeHomeOverride(options.env),
367
378
  ...NON_INTERACTIVE_ENV,
368
379
  ...options.env,
369
380
  },
381
+ unsetEnv: [...(options.unsetEnv ?? []), ...ptyUnsetHookNames(options.env)],
370
382
  signal: options.signal,
371
383
  cols,
372
384
  rows,
@@ -1,7 +1,14 @@
1
+ import type * as fsTypes from "node:fs";
1
2
  import * as fs from "node:fs/promises";
2
3
  import * as path from "node:path";
4
+ import { isEnoent } from "@sayknow-cli/utils";
3
5
  import type { Skill } from "../extensibility/skills";
4
- import { initializeLocalRoot, type LocalProtocolOptions, resolveLocalUrlToPath } from "../internal-urls";
6
+ import {
7
+ initializeLocalRoot,
8
+ type LocalProtocolOptions,
9
+ resolveLocalRoot,
10
+ resolveLocalUrlToPath,
11
+ } from "../internal-urls/local-protocol";
5
12
  import { validateRelativePath } from "../internal-urls/skill-protocol";
6
13
  import type { InternalResource } from "../internal-urls/types";
7
14
  import { normalizeLocalScheme } from "./path-utils";
@@ -34,7 +41,7 @@ export interface InternalUrlExpansionOptions {
34
41
  * Resolve a single skill:// URL to its absolute filesystem path.
35
42
  * Does NOT read file content or verify existence.
36
43
  */
37
- export function resolveSkillUrlToPath(url: string, skills: readonly Skill[]): string {
44
+ export function resolveSkillUrl(url: string, skills: readonly Skill[]): { skill: Skill; lexicalPath: string } {
38
45
  const parsed = /^skill:\/\/([^/?#]+)(\/[^?#]*)?(?:[?#].*)?$/.exec(url);
39
46
  if (!parsed) {
40
47
  throw new ToolError(`Invalid skill:// URL: ${url}`);
@@ -66,7 +73,7 @@ export function resolveSkillUrlToPath(url: string, skills: readonly Skill[]): st
66
73
  const hasRelativePath = rawPath !== "" && rawPath !== "/";
67
74
 
68
75
  if (!hasRelativePath) {
69
- return path.resolve(skill.filePath);
76
+ return { skill, lexicalPath: path.resolve(skill.filePath) };
70
77
  }
71
78
 
72
79
  let relativePath: string;
@@ -89,7 +96,11 @@ export function resolveSkillUrlToPath(url: string, skills: readonly Skill[]): st
89
96
  throw new ToolError("Path traversal is not allowed in skill:// URLs");
90
97
  }
91
98
 
92
- return resolvedPath;
99
+ return { skill, lexicalPath: resolvedPath };
100
+ }
101
+
102
+ export function resolveSkillUrlToPath(url: string, skills: readonly Skill[]): string {
103
+ return resolveSkillUrl(url, skills).lexicalPath;
93
104
  }
94
105
 
95
106
  /**
@@ -125,6 +136,99 @@ function matchSkillName(
125
136
  return { skill: undefined, suffix: undefined };
126
137
  }
127
138
 
139
+ function localPathEscapes(realRoot: string, candidate: string): boolean {
140
+ return candidate !== realRoot && !candidate.startsWith(`${realRoot}${path.sep}`);
141
+ }
142
+
143
+ async function canonicalLocalPath(localRoot: string, lexicalPath: string): Promise<string> {
144
+ const realRoot = await fs.realpath(localRoot);
145
+ try {
146
+ const realTarget = await fs.realpath(lexicalPath);
147
+ if (localPathEscapes(realRoot, realTarget)) {
148
+ throw new ToolError("local:// path escapes the session local root");
149
+ }
150
+ return realTarget;
151
+ } catch (error) {
152
+ if (error instanceof ToolError || !isEnoent(error)) throw error;
153
+ }
154
+
155
+ const missing: string[] = [];
156
+ let cursor = lexicalPath;
157
+ for (;;) {
158
+ let stat: fsTypes.Stats | undefined;
159
+ try {
160
+ stat = await fs.lstat(cursor);
161
+ } catch (error) {
162
+ if (!isEnoent(error)) throw error;
163
+ }
164
+ if (stat) {
165
+ let realAncestor: string;
166
+ try {
167
+ realAncestor = await fs.realpath(cursor);
168
+ } catch (error) {
169
+ if (isEnoent(error)) throw new ToolError("local:// path escapes the session local root");
170
+ throw error;
171
+ }
172
+ const canonical = path.join(realAncestor, ...missing);
173
+ if (localPathEscapes(realRoot, canonical)) {
174
+ throw new ToolError("local:// path escapes the session local root");
175
+ }
176
+ return canonical;
177
+ }
178
+ const parent = path.dirname(cursor);
179
+ if (parent === cursor) throw new ToolError("local:// path escapes the session local root");
180
+ missing.unshift(path.basename(cursor));
181
+ cursor = parent;
182
+ }
183
+ }
184
+
185
+ const SKILL_ESCAPE = "Path traversal is not allowed in skill:// URLs";
186
+
187
+ /** Real path of `target`, or the real ancestor plus the missing suffix. */
188
+ async function canonicalPathOrAncestor(target: string, escapeMessage: string): Promise<string> {
189
+ try {
190
+ return await fs.realpath(target);
191
+ } catch (error) {
192
+ if (!isEnoent(error)) throw error;
193
+ }
194
+
195
+ const missing: string[] = [];
196
+ let cursor = target;
197
+ for (;;) {
198
+ let stat: fsTypes.Stats | undefined;
199
+ try {
200
+ stat = await fs.lstat(cursor);
201
+ } catch (error) {
202
+ if (!isEnoent(error)) throw error;
203
+ }
204
+ if (stat) {
205
+ try {
206
+ return path.join(await fs.realpath(cursor), ...missing);
207
+ } catch (error) {
208
+ if (isEnoent(error)) throw new ToolError(escapeMessage);
209
+ throw error;
210
+ }
211
+ }
212
+ const parent = path.dirname(cursor);
213
+ if (parent === cursor) throw new ToolError(escapeMessage);
214
+ missing.unshift(path.basename(cursor));
215
+ cursor = parent;
216
+ }
217
+ }
218
+
219
+ /**
220
+ * Keep the lexical skill path, then bind the shell to the real path inside the skill directory.
221
+ * A missing file under a real in-skill ancestor still expands.
222
+ */
223
+ async function canonicalSkillExpansionPath(baseDir: string, lexicalPath: string): Promise<string> {
224
+ const realBase = await canonicalPathOrAncestor(baseDir, SKILL_ESCAPE);
225
+ const realTarget = await canonicalPathOrAncestor(lexicalPath, SKILL_ESCAPE);
226
+ if (localPathEscapes(realBase, realTarget)) {
227
+ throw new ToolError(SKILL_ESCAPE);
228
+ }
229
+ return realTarget;
230
+ }
231
+
128
232
  function extractScheme(url: string): SupportedInternalScheme | undefined {
129
233
  const match = /^([a-z][a-z0-9+.-]*):\/\//i.exec(url);
130
234
  if (!match) return undefined;
@@ -159,7 +263,8 @@ async function resolveInternalUrlToPath(
159
263
  }
160
264
 
161
265
  if (scheme === "skill") {
162
- return resolveSkillUrlToPath(url, skills);
266
+ const { skill, lexicalPath } = resolveSkillUrl(url, skills);
267
+ return canonicalSkillExpansionPath(skill.baseDir, lexicalPath);
163
268
  }
164
269
 
165
270
  // Managed artifact and agent resources carry session authority. Expanding
@@ -180,10 +285,11 @@ async function resolveInternalUrlToPath(
180
285
  }
181
286
  await initializeLocalRoot(localOptions);
182
287
  const resolvedLocalPath = resolveLocalUrlToPath(url, localOptions);
288
+ const realTarget = await canonicalLocalPath(resolveLocalRoot(localOptions), resolvedLocalPath);
183
289
  if (ensureLocalParentDirs) {
184
- await fs.mkdir(path.dirname(resolvedLocalPath), { recursive: true });
290
+ await fs.mkdir(path.dirname(realTarget), { recursive: true });
185
291
  }
186
- return resolvedLocalPath;
292
+ return realTarget;
187
293
  }
188
294
 
189
295
  if (!internalRouter?.canHandle(url)) {