@diffra-ai/cli 0.1.1 → 0.1.2
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.
- package/CHANGELOG.md +47 -15
- package/dist/bundle/chunks/{anthropic-messages-M3HXJPTI.js → anthropic-messages-HME6WDIM.js} +1 -1
- package/dist/bundle/chunks/{azure-openai-responses-GIFO2563.js → azure-openai-responses-WKSFBZF5.js} +1 -1
- package/dist/bundle/chunks/bedrock-converse-stream.js +1 -1
- package/dist/bundle/chunks/{chunk-GT3WTHFU.js → chunk-3MKQN3ZR.js} +1 -1
- package/dist/bundle/chunks/{chunk-VJQ6ZYW4.js → chunk-4NMBWIZG.js} +5 -5
- package/dist/bundle/chunks/{chunk-INTHKDF2.js → chunk-65DC2T66.js} +1 -1
- package/dist/bundle/chunks/{chunk-N6QWAQ6I.js → chunk-6L2FT6AE.js} +1 -1
- package/dist/bundle/chunks/chunk-6ZD23B2R.js +2 -0
- package/dist/bundle/chunks/{chunk-OQFRYL4U.js → chunk-E3MJ4MPN.js} +1 -1
- package/dist/bundle/chunks/chunk-GRDBYTYT.js +2003 -0
- package/dist/bundle/chunks/{chunk-RJRIMI6M.js → chunk-GRYHVZSI.js} +1 -1
- package/dist/bundle/chunks/{chunk-CCH74R6M.js → chunk-MITPYV3F.js} +1 -1
- package/dist/bundle/chunks/{chunk-WEJVQTLI.js → chunk-MJRIJM22.js} +1 -1
- package/dist/bundle/chunks/{chunk-OOE7BGUD.js → chunk-PQGGR7SQ.js} +1 -1
- package/dist/bundle/chunks/{chunk-WAH3PGZX.js → chunk-PXE534VH.js} +2 -2
- package/dist/bundle/chunks/{chunk-262RLABF.js → chunk-QMZGTPRI.js} +1 -1
- package/dist/bundle/chunks/{chunk-VSFRR6IC.js → chunk-QQ6NVGNW.js} +1 -1
- package/dist/bundle/chunks/{chunk-N6Q2WLPG.js → chunk-RUI3NOFB.js} +1 -1
- package/dist/bundle/chunks/{chunk-6S2AQWGR.js → chunk-SI7T4LPD.js} +4 -4
- package/dist/bundle/chunks/{chunk-CVEPACZO.js → chunk-SMYD2SB5.js} +1 -1
- package/dist/bundle/chunks/{chunk-B3FUE2LF.js → chunk-XAA355T2.js} +1 -1
- package/dist/bundle/chunks/{cli-EC3ZETTA.js → cli-GKHAGQO6.js} +1 -1
- package/dist/bundle/chunks/{cloudflare-workers-ai-system-one-YW7YYPAC.js → cloudflare-workers-ai-system-one-PVUECIVD.js} +1 -1
- package/dist/bundle/chunks/{easter-egg-3d-QN5RJMZR.js → easter-egg-3d-VAZ2JWDP.js} +1 -1
- package/dist/bundle/chunks/{execute-3J63CQJG.js → execute-OEFRHFHI.js} +1 -1
- package/dist/bundle/chunks/{google-generative-ai-F6DN2LQU.js → google-generative-ai-2YH7DK5J.js} +1 -1
- package/dist/bundle/chunks/{google-vertex-MDWFDVAW.js → google-vertex-QNIS4SPE.js} +1 -1
- package/dist/bundle/chunks/{llama-cpp-classify-XO72TVVH.js → llama-cpp-classify-EMBT3ZMY.js} +1 -1
- package/dist/bundle/chunks/{mistral-conversations-KYVGR5VN.js → mistral-conversations-RCHJWX2M.js} +1 -1
- package/dist/bundle/chunks/{openai-codex-responses-SIQN5LUE.js → openai-codex-responses-LBZQ7HUY.js} +1 -1
- package/dist/bundle/chunks/{openai-completions-B22DYT4F.js → openai-completions-U7NS5GFY.js} +1 -1
- package/dist/bundle/chunks/{openai-decisions-4GVNTR54.js → openai-decisions-YC4ZEGAR.js} +1 -1
- package/dist/bundle/chunks/{openai-responses-5DVNSQCE.js → openai-responses-4YX6XMEO.js} +1 -1
- package/dist/bundle/chunks/{openrouter-images-SQMQNKJU.js → openrouter-images-QPPGKFJY.js} +1 -1
- package/dist/bundle/chunks/{pi-messages-GZ4HZRKJ.js → pi-messages-5W3GZ7B6.js} +1 -1
- package/dist/bundle/chunks/{runtime-KEVIZBAR.js → runtime-SI4R3AXJ.js} +1 -1
- package/dist/bundle/chunks/{typesafe-system-one-GMPGMPLA.js → typesafe-system-one-GWMQ2NLX.js} +1 -1
- package/dist/bundle/chunks/virtual-modules-ENTYMDSQ.js +2 -0
- package/dist/bundle/cli-runtime.js +1 -1
- package/dist/bundle/index.js +1 -1
- package/dist/bundle/rpc-entry.js +1 -1
- package/dist/cli/args.d.ts +2 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +13 -0
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/sandbox-command.d.ts +8 -0
- package/dist/cli/sandbox-command.d.ts.map +1 -0
- package/dist/cli/sandbox-command.js +52 -0
- package/dist/cli/sandbox-command.js.map +1 -0
- package/dist/config.d.ts +7 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +14 -0
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session.d.ts +20 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +72 -2
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/approval-mode.d.ts +28 -0
- package/dist/core/approval-mode.d.ts.map +1 -0
- package/dist/core/approval-mode.js +34 -0
- package/dist/core/approval-mode.js.map +1 -0
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +15 -0
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +3 -0
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +28 -1
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/fast-model.d.ts +10 -0
- package/dist/core/fast-model.d.ts.map +1 -0
- package/dist/core/fast-model.js +13 -0
- package/dist/core/fast-model.js.map +1 -0
- package/dist/core/keybindings.d.ts +8 -0
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +4 -0
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/sandbox/escalation.d.ts +32 -0
- package/dist/core/sandbox/escalation.d.ts.map +1 -0
- package/dist/core/sandbox/escalation.js +70 -0
- package/dist/core/sandbox/escalation.js.map +1 -0
- package/dist/core/sandbox/launch.d.ts +14 -0
- package/dist/core/sandbox/launch.d.ts.map +1 -0
- package/dist/core/sandbox/launch.js +18 -0
- package/dist/core/sandbox/launch.js.map +1 -0
- package/dist/core/sandbox/policy.d.ts +50 -0
- package/dist/core/sandbox/policy.d.ts.map +1 -0
- package/dist/core/sandbox/policy.js +96 -0
- package/dist/core/sandbox/policy.js.map +1 -0
- package/dist/core/sandbox/seatbelt.d.ts +17 -0
- package/dist/core/sandbox/seatbelt.d.ts.map +1 -0
- package/dist/core/sandbox/seatbelt.js +169 -0
- package/dist/core/sandbox/seatbelt.js.map +1 -0
- package/dist/core/sandbox/windows.d.ts +30 -0
- package/dist/core/sandbox/windows.d.ts.map +1 -0
- package/dist/core/sandbox/windows.js +104 -0
- package/dist/core/sandbox/windows.js.map +1 -0
- package/dist/core/settings-defaults.d.ts +28 -0
- package/dist/core/settings-defaults.d.ts.map +1 -1
- package/dist/core/settings-defaults.js +28 -0
- package/dist/core/settings-defaults.js.map +1 -1
- package/dist/core/settings-manager.d.ts +9 -1
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +58 -1
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/settings-schema.d.ts +124 -0
- package/dist/core/settings-schema.d.ts.map +1 -1
- package/dist/core/settings-schema.js +177 -0
- package/dist/core/settings-schema.js.map +1 -1
- package/dist/core/tools/bash.d.ts +12 -2
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +27 -7
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit.d.ts +3 -0
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +2 -0
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/powershell.d.ts +3 -2
- package/dist/core/tools/powershell.d.ts.map +1 -1
- package/dist/core/tools/powershell.js +4 -6
- package/dist/core/tools/powershell.js.map +1 -1
- package/dist/core/tools/render-utils.d.ts +2 -2
- package/dist/core/tools/render-utils.js +5 -5
- package/dist/core/tools/render-utils.js.map +1 -1
- package/dist/core/tools/renderers/edit.d.ts.map +1 -1
- package/dist/core/tools/renderers/edit.js +16 -19
- package/dist/core/tools/renderers/edit.js.map +1 -1
- package/dist/core/tools/write.d.ts +3 -0
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js +2 -0
- package/dist/core/tools/write.js.map +1 -1
- package/dist/extensions/agents/agent-tool.d.ts +61 -0
- package/dist/extensions/agents/agent-tool.d.ts.map +1 -0
- package/dist/extensions/agents/agent-tool.js +277 -0
- package/dist/extensions/agents/agent-tool.js.map +1 -0
- package/dist/extensions/agents/background.d.ts +56 -0
- package/dist/extensions/agents/background.d.ts.map +1 -0
- package/dist/extensions/agents/background.js +142 -0
- package/dist/extensions/agents/background.js.map +1 -0
- package/dist/extensions/agents/builtin-agents.d.ts +8 -0
- package/dist/extensions/agents/builtin-agents.d.ts.map +1 -0
- package/dist/extensions/agents/builtin-agents.js +38 -0
- package/dist/extensions/agents/builtin-agents.js.map +1 -0
- package/dist/extensions/agents/call-scopes.d.ts +34 -0
- package/dist/extensions/agents/call-scopes.d.ts.map +1 -0
- package/dist/extensions/agents/call-scopes.js +36 -0
- package/dist/extensions/agents/call-scopes.js.map +1 -0
- package/dist/extensions/agents/definitions.d.ts +64 -0
- package/dist/extensions/agents/definitions.d.ts.map +1 -0
- package/dist/extensions/agents/definitions.js +216 -0
- package/dist/extensions/agents/definitions.js.map +1 -0
- package/dist/extensions/agents/index.d.ts +15 -0
- package/dist/extensions/agents/index.d.ts.map +1 -0
- package/dist/extensions/agents/index.js +327 -0
- package/dist/extensions/agents/index.js.map +1 -0
- package/dist/extensions/agents/runner.d.ts +63 -0
- package/dist/extensions/agents/runner.d.ts.map +1 -0
- package/dist/extensions/agents/runner.js +156 -0
- package/dist/extensions/agents/runner.js.map +1 -0
- package/dist/extensions/approval/auto-classifier.d.ts +32 -0
- package/dist/extensions/approval/auto-classifier.d.ts.map +1 -0
- package/dist/extensions/approval/auto-classifier.js +116 -0
- package/dist/extensions/approval/auto-classifier.js.map +1 -0
- package/dist/extensions/approval/exit-plan-mode.d.ts +24 -0
- package/dist/extensions/approval/exit-plan-mode.d.ts.map +1 -0
- package/dist/extensions/approval/exit-plan-mode.js +99 -0
- package/dist/extensions/approval/exit-plan-mode.js.map +1 -0
- package/dist/extensions/approval/index.d.ts +15 -0
- package/dist/extensions/approval/index.d.ts.map +1 -0
- package/dist/extensions/approval/index.js +329 -0
- package/dist/extensions/approval/index.js.map +1 -0
- package/dist/extensions/approval/plan-reminders.d.ts +9 -0
- package/dist/extensions/approval/plan-reminders.d.ts.map +1 -0
- package/dist/extensions/approval/plan-reminders.js +42 -0
- package/dist/extensions/approval/plan-reminders.js.map +1 -0
- package/dist/extensions/approval/policy.d.ts +52 -0
- package/dist/extensions/approval/policy.d.ts.map +1 -0
- package/dist/extensions/approval/policy.js +124 -0
- package/dist/extensions/approval/policy.js.map +1 -0
- package/dist/extensions/approval/shell-safety.d.ts +11 -0
- package/dist/extensions/approval/shell-safety.d.ts.map +1 -0
- package/dist/extensions/approval/shell-safety.js +264 -0
- package/dist/extensions/approval/shell-safety.js.map +1 -0
- package/dist/extensions/cron/cron-expression.d.ts +30 -0
- package/dist/extensions/cron/cron-expression.d.ts.map +1 -0
- package/dist/extensions/cron/cron-expression.js +119 -0
- package/dist/extensions/cron/cron-expression.js.map +1 -0
- package/dist/extensions/cron/index.d.ts +19 -0
- package/dist/extensions/cron/index.d.ts.map +1 -0
- package/dist/extensions/cron/index.js +215 -0
- package/dist/extensions/cron/index.js.map +1 -0
- package/dist/extensions/cron/loop-args.d.ts +35 -0
- package/dist/extensions/cron/loop-args.d.ts.map +1 -0
- package/dist/extensions/cron/loop-args.js +95 -0
- package/dist/extensions/cron/loop-args.js.map +1 -0
- package/dist/extensions/cron/loop-texts.d.ts +29 -0
- package/dist/extensions/cron/loop-texts.d.ts.map +1 -0
- package/dist/extensions/cron/loop-texts.js +83 -0
- package/dist/extensions/cron/loop-texts.js.map +1 -0
- package/dist/extensions/cron/scheduler.d.ts +79 -0
- package/dist/extensions/cron/scheduler.d.ts.map +1 -0
- package/dist/extensions/cron/scheduler.js +146 -0
- package/dist/extensions/cron/scheduler.js.map +1 -0
- package/dist/extensions/cron/tools.d.ts +47 -0
- package/dist/extensions/cron/tools.d.ts.map +1 -0
- package/dist/extensions/cron/tools.js +141 -0
- package/dist/extensions/cron/tools.js.map +1 -0
- package/dist/extensions/goals/evidence.d.ts +20 -0
- package/dist/extensions/goals/evidence.d.ts.map +1 -0
- package/dist/extensions/goals/evidence.js +77 -0
- package/dist/extensions/goals/evidence.js.map +1 -0
- package/dist/extensions/goals/index.d.ts +45 -0
- package/dist/extensions/goals/index.d.ts.map +1 -0
- package/dist/extensions/goals/index.js +438 -0
- package/dist/extensions/goals/index.js.map +1 -0
- package/dist/extensions/goals/prompts.d.ts +15 -0
- package/dist/extensions/goals/prompts.d.ts.map +1 -0
- package/dist/extensions/goals/prompts.js +51 -0
- package/dist/extensions/goals/prompts.js.map +1 -0
- package/dist/extensions/goals/state.d.ts +88 -0
- package/dist/extensions/goals/state.d.ts.map +1 -0
- package/dist/extensions/goals/state.js +204 -0
- package/dist/extensions/goals/state.js.map +1 -0
- package/dist/extensions/goals/tools.d.ts +40 -0
- package/dist/extensions/goals/tools.d.ts.map +1 -0
- package/dist/extensions/goals/tools.js +118 -0
- package/dist/extensions/goals/tools.js.map +1 -0
- package/dist/extensions/goals/verifier.d.ts +30 -0
- package/dist/extensions/goals/verifier.d.ts.map +1 -0
- package/dist/extensions/goals/verifier.js +89 -0
- package/dist/extensions/goals/verifier.js.map +1 -0
- package/dist/extensions/hooks/aggregate.d.ts +30 -0
- package/dist/extensions/hooks/aggregate.d.ts.map +1 -0
- package/dist/extensions/hooks/aggregate.js +103 -0
- package/dist/extensions/hooks/aggregate.js.map +1 -0
- package/dist/extensions/hooks/config.d.ts +47 -0
- package/dist/extensions/hooks/config.d.ts.map +1 -0
- package/dist/extensions/hooks/config.js +169 -0
- package/dist/extensions/hooks/config.js.map +1 -0
- package/dist/extensions/hooks/file-watcher.d.ts +31 -0
- package/dist/extensions/hooks/file-watcher.d.ts.map +1 -0
- package/dist/extensions/hooks/file-watcher.js +106 -0
- package/dist/extensions/hooks/file-watcher.js.map +1 -0
- package/dist/extensions/hooks/index.d.ts +17 -0
- package/dist/extensions/hooks/index.d.ts.map +1 -0
- package/dist/extensions/hooks/index.js +349 -0
- package/dist/extensions/hooks/index.js.map +1 -0
- package/dist/extensions/hooks/matcher.d.ts +10 -0
- package/dist/extensions/hooks/matcher.d.ts.map +1 -0
- package/dist/extensions/hooks/matcher.js +85 -0
- package/dist/extensions/hooks/matcher.js.map +1 -0
- package/dist/extensions/hooks/runner.d.ts +54 -0
- package/dist/extensions/hooks/runner.d.ts.map +1 -0
- package/dist/extensions/hooks/runner.js +197 -0
- package/dist/extensions/hooks/runner.js.map +1 -0
- package/dist/extensions/index.d.ts.map +1 -1
- package/dist/extensions/index.js +29 -2
- package/dist/extensions/index.js.map +1 -1
- package/dist/extensions/lsp/config.d.ts +40 -0
- package/dist/extensions/lsp/config.d.ts.map +1 -0
- package/dist/extensions/lsp/config.js +92 -0
- package/dist/extensions/lsp/config.js.map +1 -0
- package/dist/extensions/lsp/connection.d.ts +32 -0
- package/dist/extensions/lsp/connection.d.ts.map +1 -0
- package/dist/extensions/lsp/connection.js +124 -0
- package/dist/extensions/lsp/connection.js.map +1 -0
- package/dist/extensions/lsp/index.d.ts +15 -0
- package/dist/extensions/lsp/index.d.ts.map +1 -0
- package/dist/extensions/lsp/index.js +103 -0
- package/dist/extensions/lsp/index.js.map +1 -0
- package/dist/extensions/lsp/server.d.ts +68 -0
- package/dist/extensions/lsp/server.d.ts.map +1 -0
- package/dist/extensions/lsp/server.js +373 -0
- package/dist/extensions/lsp/server.js.map +1 -0
- package/dist/extensions/lsp/tool.d.ts +43 -0
- package/dist/extensions/lsp/tool.d.ts.map +1 -0
- package/dist/extensions/lsp/tool.js +534 -0
- package/dist/extensions/lsp/tool.js.map +1 -0
- package/dist/extensions/memory/index.d.ts +15 -0
- package/dist/extensions/memory/index.d.ts.map +1 -0
- package/dist/extensions/memory/index.js +336 -0
- package/dist/extensions/memory/index.js.map +1 -0
- package/dist/extensions/memory/memory-agent.d.ts +29 -0
- package/dist/extensions/memory/memory-agent.d.ts.map +1 -0
- package/dist/extensions/memory/memory-agent.js +102 -0
- package/dist/extensions/memory/memory-agent.js.map +1 -0
- package/dist/extensions/memory/prompts.d.ts +18 -0
- package/dist/extensions/memory/prompts.d.ts.map +1 -0
- package/dist/extensions/memory/prompts.js +124 -0
- package/dist/extensions/memory/prompts.js.map +1 -0
- package/dist/extensions/memory/recall.d.ts +14 -0
- package/dist/extensions/memory/recall.d.ts.map +1 -0
- package/dist/extensions/memory/recall.js +80 -0
- package/dist/extensions/memory/recall.js.map +1 -0
- package/dist/extensions/memory/store.d.ts +48 -0
- package/dist/extensions/memory/store.d.ts.map +1 -0
- package/dist/extensions/memory/store.js +132 -0
- package/dist/extensions/memory/store.js.map +1 -0
- package/dist/extensions/skills/bundled/batch/SKILL.md +74 -0
- package/dist/extensions/skills/bundled/review/SKILL.md +93 -0
- package/dist/extensions/skills/index.d.ts +15 -0
- package/dist/extensions/skills/index.d.ts.map +1 -0
- package/dist/extensions/skills/index.js +68 -0
- package/dist/extensions/skills/index.js.map +1 -0
- package/dist/extensions/skills/learn.d.ts +9 -0
- package/dist/extensions/skills/learn.d.ts.map +1 -0
- package/dist/extensions/skills/learn.js +46 -0
- package/dist/extensions/skills/learn.js.map +1 -0
- package/dist/extensions/todo/index.d.ts +14 -0
- package/dist/extensions/todo/index.d.ts.map +1 -0
- package/dist/extensions/todo/index.js +55 -0
- package/dist/extensions/todo/index.js.map +1 -0
- package/dist/extensions/todo/todos.d.ts +64 -0
- package/dist/extensions/todo/todos.d.ts.map +1 -0
- package/dist/extensions/todo/todos.js +145 -0
- package/dist/extensions/todo/todos.js.map +1 -0
- package/dist/extensions/todo/tool.d.ts +23 -0
- package/dist/extensions/todo/tool.d.ts.map +1 -0
- package/dist/extensions/todo/tool.js +104 -0
- package/dist/extensions/todo/tool.js.map +1 -0
- package/dist/extensions/web-fetch/fetch-tool.d.ts +27 -0
- package/dist/extensions/web-fetch/fetch-tool.d.ts.map +1 -0
- package/dist/extensions/web-fetch/fetch-tool.js +319 -0
- package/dist/extensions/web-fetch/fetch-tool.js.map +1 -0
- package/dist/extensions/web-fetch/html-to-markdown.d.ts +7 -0
- package/dist/extensions/web-fetch/html-to-markdown.d.ts.map +1 -0
- package/dist/extensions/web-fetch/html-to-markdown.js +21 -0
- package/dist/extensions/web-fetch/html-to-markdown.js.map +1 -0
- package/dist/extensions/web-fetch/index.d.ts +10 -0
- package/dist/extensions/web-fetch/index.d.ts.map +1 -0
- package/dist/extensions/web-fetch/index.js +13 -0
- package/dist/extensions/web-fetch/index.js.map +1 -0
- package/dist/extensions/web-fetch/page-fetch.d.ts +45 -0
- package/dist/extensions/web-fetch/page-fetch.d.ts.map +1 -0
- package/dist/extensions/web-fetch/page-fetch.js +117 -0
- package/dist/extensions/web-fetch/page-fetch.js.map +1 -0
- package/dist/extensions/web-fetch/pdf-text.d.ts +29 -0
- package/dist/extensions/web-fetch/pdf-text.d.ts.map +1 -0
- package/dist/extensions/web-fetch/pdf-text.js +71 -0
- package/dist/extensions/web-fetch/pdf-text.js.map +1 -0
- package/dist/extensions/web-fetch/preapproved-hosts.d.ts +7 -0
- package/dist/extensions/web-fetch/preapproved-hosts.d.ts.map +1 -0
- package/dist/extensions/web-fetch/preapproved-hosts.js +110 -0
- package/dist/extensions/web-fetch/preapproved-hosts.js.map +1 -0
- package/dist/extensions/web-search/dashscope-search.d.ts +29 -0
- package/dist/extensions/web-search/dashscope-search.d.ts.map +1 -0
- package/dist/extensions/web-search/dashscope-search.js +279 -0
- package/dist/extensions/web-search/dashscope-search.js.map +1 -0
- package/dist/extensions/web-search/index.d.ts +15 -0
- package/dist/extensions/web-search/index.d.ts.map +1 -0
- package/dist/extensions/web-search/index.js +51 -0
- package/dist/extensions/web-search/index.js.map +1 -0
- package/dist/extensions/web-search/search-config.d.ts +53 -0
- package/dist/extensions/web-search/search-config.d.ts.map +1 -0
- package/dist/extensions/web-search/search-config.js +174 -0
- package/dist/extensions/web-search/search-config.js.map +1 -0
- package/dist/extensions/web-search/search-tool.d.ts +29 -0
- package/dist/extensions/web-search/search-tool.d.ts.map +1 -0
- package/dist/extensions/web-search/search-tool.js +149 -0
- package/dist/extensions/web-search/search-tool.js.map +1 -0
- package/dist/extensions/worktree/git-worktree.d.ts +69 -0
- package/dist/extensions/worktree/git-worktree.d.ts.map +1 -0
- package/dist/extensions/worktree/git-worktree.js +199 -0
- package/dist/extensions/worktree/git-worktree.js.map +1 -0
- package/dist/extensions/worktree/index.d.ts +27 -0
- package/dist/extensions/worktree/index.d.ts.map +1 -0
- package/dist/extensions/worktree/index.js +188 -0
- package/dist/extensions/worktree/index.js.map +1 -0
- package/dist/extensions/worktree/startup.d.ts +17 -0
- package/dist/extensions/worktree/startup.d.ts.map +1 -0
- package/dist/extensions/worktree/startup.js +56 -0
- package/dist/extensions/worktree/startup.js.map +1 -0
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +28 -4
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/custom-editor.d.ts +18 -0
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-editor.js +87 -20
- package/dist/modes/interactive/components/custom-editor.js.map +1 -1
- package/dist/modes/interactive/components/diffra-logo.d.ts +6 -0
- package/dist/modes/interactive/components/diffra-logo.d.ts.map +1 -1
- package/dist/modes/interactive/components/diffra-logo.js +30 -4
- package/dist/modes/interactive/components/diffra-logo.js.map +1 -1
- package/dist/modes/interactive/components/dynamic-border.d.ts +1 -1
- package/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -1
- package/dist/modes/interactive/components/dynamic-border.js +3 -3
- package/dist/modes/interactive/components/dynamic-border.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts +16 -0
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +84 -46
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts +5 -2
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +152 -62
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/tool-status.d.ts +5 -0
- package/dist/modes/interactive/components/tool-status.d.ts.map +1 -0
- package/dist/modes/interactive/components/tool-status.js +15 -0
- package/dist/modes/interactive/components/tool-status.js.map +1 -0
- package/dist/modes/interactive/components/user-message.d.ts +4 -8
- package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message.js +38 -36
- package/dist/modes/interactive/components/user-message.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +24 -8
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/theme/dark.json +3 -2
- package/dist/modes/interactive/theme/light.json +3 -2
- package/dist/modes/interactive/theme/system-theme.d.ts +1 -0
- package/dist/modes/interactive/theme/system-theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/system-theme.js +41 -14
- package/dist/modes/interactive/theme/system-theme.js.map +1 -1
- package/dist/utils/shell.d.ts +1 -1
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +12 -2
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/tools-manager.d.ts +5 -0
- package/dist/utils/tools-manager.d.ts.map +1 -1
- package/dist/utils/tools-manager.js +48 -0
- package/dist/utils/tools-manager.js.map +1 -1
- package/docs/approval-modes.md +99 -0
- package/docs/builtin-skills.md +53 -0
- package/docs/cli.md +380 -356
- package/docs/docs.json +264 -220
- package/docs/environment-variables.md +110 -103
- package/docs/extensions.md +24 -0
- package/docs/goals.md +84 -0
- package/docs/hooks.md +112 -0
- package/docs/keybindings.md +1 -0
- package/docs/lsp.md +71 -0
- package/docs/memory.md +71 -0
- package/docs/sandbox.md +108 -0
- package/docs/scheduled-tasks.md +84 -0
- package/docs/security.md +100 -99
- package/docs/settings.md +198 -173
- package/docs/shell-aliases.md +1 -1
- package/docs/skills.md +4 -0
- package/docs/slash-commands.md +15 -0
- package/docs/subagents.md +102 -0
- package/docs/web-tools.md +83 -0
- package/docs/windows.md +2 -1
- package/docs/worktrees.md +52 -0
- package/examples/extensions/README.md +1 -1
- package/examples/extensions/plan-mode/README.md +2 -2
- package/examples/extensions/plan-mode/index.ts +7 -4
- package/examples/extensions/subagent/README.md +2 -0
- package/examples/extensions/subagent/index.ts +3 -0
- package/examples/extensions/todo.ts +4 -0
- package/package.json +9 -8
- package/schemas/keybindings.schema.json +4 -0
- package/schemas/settings.schema.json +421 -0
- package/dist/bundle/chunks/chunk-GCKVPVMH.js +0 -2
- package/dist/bundle/chunks/chunk-UNQMECQ4.js +0 -1240
- package/dist/bundle/chunks/virtual-modules-TRFD5ZOL.js +0 -2
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Worktrees as an extension. The CLI loads it as a built-in extension; SDK users add
|
|
3
|
+
* `createWorktreeExtension()` to their extension factories.
|
|
4
|
+
*
|
|
5
|
+
* `enter_worktree` creates an isolated git worktree mid-session and tells the model to use its path
|
|
6
|
+
* for all file work; `exit_worktree` keeps or removes it. A session started with `--worktree` runs in
|
|
7
|
+
* one. The active worktree shows in the footer and is recorded in the session, so a resumed session
|
|
8
|
+
* is reminded of it.
|
|
9
|
+
*/
|
|
10
|
+
import { existsSync } from "node:fs";
|
|
11
|
+
import { resolve } from "node:path";
|
|
12
|
+
import { Type } from "typebox";
|
|
13
|
+
import { StringEnum } from "../../core/extensions/diffra-ai-extension-view.js";
|
|
14
|
+
import { attachWorktree, autoSlug, BRANCH_PREFIX, countChanges, createWorktree, git, managedWorktreeAt, readSessionMarker, removeWorktree, repositoryRoot, slugError, unmergedCommits, worktreePathOf, writeSessionMarker, } from "./git-worktree.js";
|
|
15
|
+
/** Custom entry type recording the active worktree; `null` when none. */
|
|
16
|
+
export const WORKTREE_ENTRY = "diffra.worktree";
|
|
17
|
+
export const ENTER_WORKTREE_TOOL_NAME = "enter_worktree";
|
|
18
|
+
export const EXIT_WORKTREE_TOOL_NAME = "exit_worktree";
|
|
19
|
+
const STATUS_KEY = "worktree";
|
|
20
|
+
const RESUME_NOTE_TYPE = "worktree-resumed";
|
|
21
|
+
const enterSchema = Type.Object({
|
|
22
|
+
name: Type.Optional(Type.String({
|
|
23
|
+
description: "Worktree name: letters, digits, dots, underscores, and hyphens, at most 64 characters. Omit for a generated name.",
|
|
24
|
+
})),
|
|
25
|
+
}, { additionalProperties: false });
|
|
26
|
+
const ENTER_DESCRIPTION = `Create an isolated git worktree of this repository at .diffra/worktrees/<name>, on a new branch worktree-<name> from the current branch, and work there.
|
|
27
|
+
|
|
28
|
+
Use it only when the user explicitly asks for a worktree. The session's working directory does not change: after this call, use the returned absolute path for every file operation and shell command (cd into it) until you call exit_worktree.`;
|
|
29
|
+
const exitSchema = Type.Object({
|
|
30
|
+
name: Type.String({ description: "Name of the worktree, as enter_worktree created it." }),
|
|
31
|
+
action: StringEnum(["keep", "remove"], {
|
|
32
|
+
description: "keep: leave the worktree and its branch on disk. remove: delete the worktree and its branch.",
|
|
33
|
+
}),
|
|
34
|
+
discard_changes: Type.Optional(Type.Boolean({ description: "With remove: delete even though the worktree has uncommitted changes." })),
|
|
35
|
+
}, { additionalProperties: false });
|
|
36
|
+
const EXIT_DESCRIPTION = `Leave a worktree created by enter_worktree: keep it on disk, or remove it with its branch.
|
|
37
|
+
|
|
38
|
+
remove refuses when the worktree has uncommitted changes (unless discard_changes is true), when its branch has commits no other branch or remote has, or when another session owns it. Ask the user before discarding changes.`;
|
|
39
|
+
/** Create the worktree extension. */
|
|
40
|
+
export function createWorktreeExtension() {
|
|
41
|
+
return (diffra) => {
|
|
42
|
+
let active;
|
|
43
|
+
let resumeNote;
|
|
44
|
+
diffra.on("session_start", async (event, ctx) => {
|
|
45
|
+
active = readWorktree(ctx.sessionManager.getBranch()) ?? undefined;
|
|
46
|
+
resumeNote = undefined;
|
|
47
|
+
const own = managedWorktreeAt(ctx.cwd);
|
|
48
|
+
if (own && !readSessionMarker(own.root))
|
|
49
|
+
writeSessionMarker(own.root, ctx.sessionManager.getSessionId());
|
|
50
|
+
if (active && !existsSync(active.worktreePath)) {
|
|
51
|
+
active = undefined;
|
|
52
|
+
diffra.appendEntry(WORKTREE_ENTRY, { worktree: null });
|
|
53
|
+
}
|
|
54
|
+
else if (active && event.reason !== "reload") {
|
|
55
|
+
resumeNote = `[Resumed] Active worktree: "${active.slug}" at ${active.worktreePath} (branch: ${active.worktreeBranch}). Continue using this path for all file operations.`;
|
|
56
|
+
}
|
|
57
|
+
if (!active && own)
|
|
58
|
+
active = await attachWorktree(resolve(own.root, "..", "..", ".."), own.slug, ctx.cwd);
|
|
59
|
+
updateStatus(ctx);
|
|
60
|
+
});
|
|
61
|
+
diffra.on("before_agent_start", () => {
|
|
62
|
+
const note = resumeNote;
|
|
63
|
+
resumeNote = undefined;
|
|
64
|
+
return note ? { message: { customType: RESUME_NOTE_TYPE, content: note, display: false } } : undefined;
|
|
65
|
+
});
|
|
66
|
+
diffra.registerTool({
|
|
67
|
+
name: ENTER_WORKTREE_TOOL_NAME,
|
|
68
|
+
label: "EnterWorktree",
|
|
69
|
+
description: ENTER_DESCRIPTION,
|
|
70
|
+
parameters: enterSchema,
|
|
71
|
+
executionMode: "sequential",
|
|
72
|
+
async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
|
|
73
|
+
if (active || managedWorktreeAt(ctx.cwd)) {
|
|
74
|
+
throw new Error("Already inside a git worktree. Call exit_worktree first, then enter_worktree again.");
|
|
75
|
+
}
|
|
76
|
+
const root = await requireRepository(ctx.cwd);
|
|
77
|
+
const slug = params.name?.trim() || autoSlug();
|
|
78
|
+
const problem = slugError(slug, { allowPullRequest: false });
|
|
79
|
+
if (problem)
|
|
80
|
+
throw new Error(problem);
|
|
81
|
+
const worktree = await createWorktree(root, slug, {
|
|
82
|
+
cwd: ctx.cwd,
|
|
83
|
+
symlinkDirectories: diffra.getSettings().worktree?.symlinkDirectories,
|
|
84
|
+
});
|
|
85
|
+
writeSessionMarker(worktree.worktreePath, ctx.sessionManager.getSessionId());
|
|
86
|
+
setActive(worktree, ctx);
|
|
87
|
+
const result = {
|
|
88
|
+
worktreePath: worktree.worktreePath,
|
|
89
|
+
worktreeBranch: worktree.worktreeBranch,
|
|
90
|
+
message: `Created worktree "${slug}" at ${worktree.worktreePath} on branch ${worktree.worktreeBranch}. Use this absolute path for all subsequent file operations until you call exit_worktree.`,
|
|
91
|
+
};
|
|
92
|
+
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }], details: undefined };
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
diffra.registerTool({
|
|
96
|
+
name: EXIT_WORKTREE_TOOL_NAME,
|
|
97
|
+
label: "ExitWorktree",
|
|
98
|
+
description: EXIT_DESCRIPTION,
|
|
99
|
+
parameters: exitSchema,
|
|
100
|
+
executionMode: "sequential",
|
|
101
|
+
async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
|
|
102
|
+
const problem = slugError(params.name, { allowPullRequest: true });
|
|
103
|
+
if (problem)
|
|
104
|
+
throw new Error(problem);
|
|
105
|
+
const own = managedWorktreeAt(ctx.cwd);
|
|
106
|
+
const root = own ? resolve(own.root, "..", "..", "..") : await requireRepository(ctx.cwd);
|
|
107
|
+
const path = worktreePathOf(root, params.name);
|
|
108
|
+
if (!existsSync(path))
|
|
109
|
+
throw new Error(`Worktree "${params.name}" not found at ${path}.`);
|
|
110
|
+
const leaving = active?.slug === params.name;
|
|
111
|
+
const text = params.action === "keep"
|
|
112
|
+
? `Kept worktree "${params.name}" at ${path}. Resume work there by referencing this path, or remove it later with exit_worktree.`
|
|
113
|
+
: await remove(root, path, params.name, params.discard_changes === true, ctx);
|
|
114
|
+
// The worktree a session was started in stays its worktree.
|
|
115
|
+
if (leaving && managedWorktreeAt(ctx.cwd)?.slug !== params.name)
|
|
116
|
+
setActive(undefined, ctx);
|
|
117
|
+
return { content: [{ type: "text", text }], details: undefined };
|
|
118
|
+
},
|
|
119
|
+
});
|
|
120
|
+
/** Remove a worktree when no work would be lost; throws with the reason otherwise. */
|
|
121
|
+
async function remove(root, path, name, discard, ctx) {
|
|
122
|
+
if (managedWorktreeAt(ctx.cwd)?.slug === name) {
|
|
123
|
+
throw new Error(`This session runs in worktree "${name}". Exit Diffra first, then remove it with \`git worktree remove ${path}\`.`);
|
|
124
|
+
}
|
|
125
|
+
const owner = readSessionMarker(path);
|
|
126
|
+
if (owner && owner !== ctx.sessionManager.getSessionId()) {
|
|
127
|
+
throw new Error(`Worktree "${name}" belongs to another session (${owner}). If that session has ended, remove it with \`git worktree remove ${path}\`.`);
|
|
128
|
+
}
|
|
129
|
+
let changes;
|
|
130
|
+
try {
|
|
131
|
+
changes = await countChanges(path);
|
|
132
|
+
}
|
|
133
|
+
catch (error) {
|
|
134
|
+
throw new Error(`Cannot inspect worktree "${name}": ${error instanceof Error ? error.message : String(error)}`);
|
|
135
|
+
}
|
|
136
|
+
if (changes.tracked + changes.untracked > 0 && !discard) {
|
|
137
|
+
throw new Error(`Refusing to remove worktree "${name}" — it has ${changes.tracked} tracked change(s) and ${changes.untracked} untracked file(s). Commit or stash first, or call again with discard_changes: true.`);
|
|
138
|
+
}
|
|
139
|
+
const branch = await git(path, ["rev-parse", "--abbrev-ref", "HEAD"]);
|
|
140
|
+
if (branch.startsWith(BRANCH_PREFIX)) {
|
|
141
|
+
const unmerged = await unmergedCommits(root, branch);
|
|
142
|
+
if (unmerged > 0) {
|
|
143
|
+
throw new Error(`Refusing to remove worktree "${name}" — branch ${branch} has ${unmerged} commit(s) that no other branch or remote has. Merge or push them first.`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
const { branchDeleted } = await removeWorktree(root, { worktreePath: path, worktreeBranch: branch }, changes.tracked + changes.untracked > 0);
|
|
147
|
+
return `Removed worktree "${name}" at ${path}${branchDeleted ? ` and deleted branch ${branch}` : branch.startsWith(BRANCH_PREFIX) ? `; branch ${branch} was kept` : ""}.`;
|
|
148
|
+
}
|
|
149
|
+
function setActive(worktree, ctx) {
|
|
150
|
+
active = worktree;
|
|
151
|
+
diffra.appendEntry(WORKTREE_ENTRY, { worktree: worktree ?? null });
|
|
152
|
+
updateStatus(ctx);
|
|
153
|
+
}
|
|
154
|
+
/** `⎇ <branch> (<name>)` in the footer, unless `ui.hideBuiltinWorktreeIndicator`. */
|
|
155
|
+
function updateStatus(ctx) {
|
|
156
|
+
if (!ctx.hasUI)
|
|
157
|
+
return;
|
|
158
|
+
const hidden = diffra.getSettings().ui?.hideBuiltinWorktreeIndicator === true;
|
|
159
|
+
ctx.ui.setStatus(STATUS_KEY, active && !hidden ? ctx.ui.theme.fg("accent", `⎇ ${active.worktreeBranch} (${active.slug})`) : undefined);
|
|
160
|
+
}
|
|
161
|
+
/** The repository root of `cwd`, or a clear error. */
|
|
162
|
+
async function requireRepository(cwd) {
|
|
163
|
+
try {
|
|
164
|
+
await git(cwd, ["--version"]);
|
|
165
|
+
}
|
|
166
|
+
catch {
|
|
167
|
+
throw new Error("Cannot create a worktree: git is not available.");
|
|
168
|
+
}
|
|
169
|
+
const root = await repositoryRoot(cwd);
|
|
170
|
+
if (!root) {
|
|
171
|
+
throw new Error(`Cannot create a worktree: ${cwd} is not a git repository. Initialize the repo with \`git init\` first.`);
|
|
172
|
+
}
|
|
173
|
+
return root;
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
/** The worktree recorded on `branch`; `null` after an exit, undefined when none was recorded. */
|
|
178
|
+
export function readWorktree(branch) {
|
|
179
|
+
for (let index = branch.length - 1; index >= 0; index--) {
|
|
180
|
+
const entry = branch[index];
|
|
181
|
+
if (entry.type === "custom" && entry.customType === WORKTREE_ENTRY) {
|
|
182
|
+
return entry.data.worktree;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
return undefined;
|
|
186
|
+
}
|
|
187
|
+
export default createWorktreeExtension();
|
|
188
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/extensions/worktree/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,mDAAmD,CAAC;AAG/E,OAAO,EACN,cAAc,EACd,QAAQ,EACR,aAAa,EACb,YAAY,EACZ,cAAc,EACd,GAAG,EAEH,iBAAiB,EACjB,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,SAAS,EACT,eAAe,EACf,cAAc,EACd,kBAAkB,GAClB,MAAM,mBAAmB,CAAC;AAE3B,yEAAyE;AACzE,MAAM,CAAC,MAAM,cAAc,GAAG,iBAAiB,CAAC;AAKhD,MAAM,CAAC,MAAM,wBAAwB,GAAG,gBAAgB,CAAC;AACzD,MAAM,CAAC,MAAM,uBAAuB,GAAG,eAAe,CAAC;AAEvD,MAAM,UAAU,GAAG,UAAU,CAAC;AAC9B,MAAM,gBAAgB,GAAG,kBAAkB,CAAC;AAE5C,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,CAC9B;IACC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAClB,IAAI,CAAC,MAAM,CAAC;QACX,WAAW,EACV,mHAAmH;KACpH,CAAC,C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The CLI loads it as a built-in extension; SDK users add\n * `createWorktreeExtension()` to their extension factories.\n *\n * `enter_worktree` creates an isolated git worktree mid-session and tells the model to use its path\n * for all file work; `exit_worktree` keeps or removes it. A session started with `--worktree` runs in\n * one. The active worktree shows in the footer and is recorded in the session, so a resumed session\n * is reminded of it.\n */\n\nimport { existsSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport { Type } from \"typebox\";\nimport { StringEnum } from \"../../core/extensions/diffra-ai-extension-view.ts\";\nimport type { ExtensionContext, ExtensionFactory } from \"../../core/extensions/types.ts\";\nimport type { SessionEntry } from \"../../core/session-manager.ts\";\nimport {\n\tattachWorktree,\n\tautoSlug,\n\tBRANCH_PREFIX,\n\tcountChanges,\n\tcreateWorktree,\n\tgit,\n\ttype ManagedWorktree,\n\tmanagedWorktreeAt,\n\treadSessionMarker,\n\tremoveWorktree,\n\trepositoryRoot,\n\tslugError,\n\tunmergedCommits,\n\tworktreePathOf,\n\twriteSessionMarker,\n} from \"./git-worktree.ts\";\n\n/** Custom entry type recording the active worktree; `null` when none. */\nexport const WORKTREE_ENTRY = \"diffra.worktree\";\n\n/** Data of a worktree entry. A type alias so it is JSON data. */\nexport type WorktreeEntryData = { worktree: ManagedWorktree | null };\n\nexport const ENTER_WORKTREE_TOOL_NAME = \"enter_worktree\";\nexport const EXIT_WORKTREE_TOOL_NAME = \"exit_worktree\";\n\nconst STATUS_KEY = \"worktree\";\nconst RESUME_NOTE_TYPE = \"worktree-resumed\";\n\nconst enterSchema = Type.Object(\n\t{\n\t\tname: Type.Optional(\n\t\t\tType.String({\n\t\t\t\tdescription:\n\t\t\t\t\t\"Worktree name: letters, digits, dots, underscores, and hyphens, at most 64 characters. Omit for a generated name.\",\n\t\t\t}),\n\t\t),\n\t},\n\t{ additionalProperties: false },\n);\n\nconst ENTER_DESCRIPTION = `Create an isolated git worktree of this repository at .diffra/worktrees/<name>, on a new branch worktree-<name> from the current branch, and work there.\n\nUse it only when the user explicitly asks for a worktree. The session's working directory does not change: after this call, use the returned absolute path for every file operation and shell command (cd into it) until you call exit_worktree.`;\n\nconst exitSchema = Type.Object(\n\t{\n\t\tname: Type.String({ description: \"Name of the worktree, as enter_worktree created it.\" }),\n\t\taction: StringEnum([\"keep\", \"remove\"] as const, {\n\t\t\tdescription: \"keep: leave the worktree and its branch on disk. remove: delete the worktree and its branch.\",\n\t\t}),\n\t\tdiscard_changes: Type.Optional(\n\t\t\tType.Boolean({ description: \"With remove: delete even though the worktree has uncommitted changes.\" }),\n\t\t),\n\t},\n\t{ additionalProperties: false },\n);\n\nconst EXIT_DESCRIPTION = `Leave a worktree created by enter_worktree: keep it on disk, or remove it with its branch.\n\nremove refuses when the worktree has uncommitted changes (unless discard_changes is true), when its branch has commits no other branch or remote has, or when another session owns it. Ask the user before discarding changes.`;\n\n/** Create the worktree extension. */\nexport function createWorktreeExtension(): ExtensionFactory {\n\treturn (diffra) => {\n\t\tlet active: ManagedWorktree | undefined;\n\t\tlet resumeNote: string | undefined;\n\n\t\tdiffra.on(\"session_start\", async (event, ctx) => {\n\t\t\tactive = readWorktree(ctx.sessionManager.getBranch()) ?? undefined;\n\t\t\tresumeNote = undefined;\n\t\t\tconst own = managedWorktreeAt(ctx.cwd);\n\t\t\tif (own && !readSessionMarker(own.root)) writeSessionMarker(own.root, ctx.sessionManager.getSessionId());\n\t\t\tif (active && !existsSync(active.worktreePath)) {\n\t\t\t\tactive = undefined;\n\t\t\t\tdiffra.appendEntry<WorktreeEntryData>(WORKTREE_ENTRY, { worktree: null });\n\t\t\t} else if (active && event.reason !== \"reload\") {\n\t\t\t\tresumeNote = `[Resumed] Active worktree: \"${active.slug}\" at ${active.worktreePath} (branch: ${active.worktreeBranch}). Continue using this path for all file operations.`;\n\t\t\t}\n\t\t\tif (!active && own) active = await attachWorktree(resolve(own.root, \"..\", \"..\", \"..\"), own.slug, ctx.cwd);\n\t\t\tupdateStatus(ctx);\n\t\t});\n\n\t\tdiffra.on(\"before_agent_start\", () => {\n\t\t\tconst note = resumeNote;\n\t\t\tresumeNote = undefined;\n\t\t\treturn note ? { message: { customType: RESUME_NOTE_TYPE, content: note, display: false } } : undefined;\n\t\t});\n\n\t\tdiffra.registerTool({\n\t\t\tname: ENTER_WORKTREE_TOOL_NAME,\n\t\t\tlabel: \"EnterWorktree\",\n\t\t\tdescription: ENTER_DESCRIPTION,\n\t\t\tparameters: enterSchema,\n\t\t\texecutionMode: \"sequential\",\n\t\t\tasync execute(_toolCallId, params, _signal, _onUpdate, ctx) {\n\t\t\t\tif (active || managedWorktreeAt(ctx.cwd)) {\n\t\t\t\t\tthrow new Error(\"Already inside a git worktree. Call exit_worktree first, then enter_worktree again.\");\n\t\t\t\t}\n\t\t\t\tconst root = await requireRepository(ctx.cwd);\n\t\t\t\tconst slug = params.name?.trim() || autoSlug();\n\t\t\t\tconst problem = slugError(slug, { allowPullRequest: false });\n\t\t\t\tif (problem) throw new Error(problem);\n\t\t\t\tconst worktree = await createWorktree(root, slug, {\n\t\t\t\t\tcwd: ctx.cwd,\n\t\t\t\t\tsymlinkDirectories: diffra.getSettings().worktree?.symlinkDirectories,\n\t\t\t\t});\n\t\t\t\twriteSessionMarker(worktree.worktreePath, ctx.sessionManager.getSessionId());\n\t\t\t\tsetActive(worktree, ctx);\n\t\t\t\tconst result = {\n\t\t\t\t\tworktreePath: worktree.worktreePath,\n\t\t\t\t\tworktreeBranch: worktree.worktreeBranch,\n\t\t\t\t\tmessage: `Created worktree \"${slug}\" at ${worktree.worktreePath} on branch ${worktree.worktreeBranch}. Use this absolute path for all subsequent file operations until you call exit_worktree.`,\n\t\t\t\t};\n\t\t\t\treturn { content: [{ type: \"text\", text: JSON.stringify(result, null, 2) }], details: undefined };\n\t\t\t},\n\t\t});\n\n\t\tdiffra.registerTool({\n\t\t\tname: EXIT_WORKTREE_TOOL_NAME,\n\t\t\tlabel: \"ExitWorktree\",\n\t\t\tdescription: EXIT_DESCRIPTION,\n\t\t\tparameters: exitSchema,\n\t\t\texecutionMode: \"sequential\",\n\t\t\tasync execute(_toolCallId, params, _signal, _onUpdate, ctx) {\n\t\t\t\tconst problem = slugError(params.name, { allowPullRequest: true });\n\t\t\t\tif (problem) throw new Error(problem);\n\t\t\t\tconst own = managedWorktreeAt(ctx.cwd);\n\t\t\t\tconst root = own ? resolve(own.root, \"..\", \"..\", \"..\") : await requireRepository(ctx.cwd);\n\t\t\t\tconst path = worktreePathOf(root, params.name);\n\t\t\t\tif (!existsSync(path)) throw new Error(`Worktree \"${params.name}\" not found at ${path}.`);\n\t\t\t\tconst leaving = active?.slug === params.name;\n\t\t\t\tconst text =\n\t\t\t\t\tparams.action === \"keep\"\n\t\t\t\t\t\t? `Kept worktree \"${params.name}\" at ${path}. Resume work there by referencing this path, or remove it later with exit_worktree.`\n\t\t\t\t\t\t: await remove(root, path, params.name, params.discard_changes === true, ctx);\n\t\t\t\t// The worktree a session was started in stays its worktree.\n\t\t\t\tif (leaving && managedWorktreeAt(ctx.cwd)?.slug !== params.name) setActive(undefined, ctx);\n\t\t\t\treturn { content: [{ type: \"text\", text }], details: undefined };\n\t\t\t},\n\t\t});\n\n\t\t/** Remove a worktree when no work would be lost; throws with the reason otherwise. */\n\t\tasync function remove(\n\t\t\troot: string,\n\t\t\tpath: string,\n\t\t\tname: string,\n\t\t\tdiscard: boolean,\n\t\t\tctx: ExtensionContext,\n\t\t): Promise<string> {\n\t\t\tif (managedWorktreeAt(ctx.cwd)?.slug === name) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`This session runs in worktree \"${name}\". Exit Diffra first, then remove it with \\`git worktree remove ${path}\\`.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst owner = readSessionMarker(path);\n\t\t\tif (owner && owner !== ctx.sessionManager.getSessionId()) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Worktree \"${name}\" belongs to another session (${owner}). If that session has ended, remove it with \\`git worktree remove ${path}\\`.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tlet changes: { tracked: number; untracked: number };\n\t\t\ttry {\n\t\t\t\tchanges = await countChanges(path);\n\t\t\t} catch (error) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Cannot inspect worktree \"${name}\": ${error instanceof Error ? error.message : String(error)}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (changes.tracked + changes.untracked > 0 && !discard) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Refusing to remove worktree \"${name}\" — it has ${changes.tracked} tracked change(s) and ${changes.untracked} untracked file(s). Commit or stash first, or call again with discard_changes: true.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst branch = await git(path, [\"rev-parse\", \"--abbrev-ref\", \"HEAD\"]);\n\t\t\tif (branch.startsWith(BRANCH_PREFIX)) {\n\t\t\t\tconst unmerged = await unmergedCommits(root, branch);\n\t\t\t\tif (unmerged > 0) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Refusing to remove worktree \"${name}\" — branch ${branch} has ${unmerged} commit(s) that no other branch or remote has. Merge or push them first.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst { branchDeleted } = await removeWorktree(\n\t\t\t\troot,\n\t\t\t\t{ worktreePath: path, worktreeBranch: branch },\n\t\t\t\tchanges.tracked + changes.untracked > 0,\n\t\t\t);\n\t\t\treturn `Removed worktree \"${name}\" at ${path}${branchDeleted ? ` and deleted branch ${branch}` : branch.startsWith(BRANCH_PREFIX) ? `; branch ${branch} was kept` : \"\"}.`;\n\t\t}\n\n\t\tfunction setActive(worktree: ManagedWorktree | undefined, ctx: ExtensionContext): void {\n\t\t\tactive = worktree;\n\t\t\tdiffra.appendEntry<WorktreeEntryData>(WORKTREE_ENTRY, { worktree: worktree ?? null });\n\t\t\tupdateStatus(ctx);\n\t\t}\n\n\t\t/** `⎇ <branch> (<name>)` in the footer, unless `ui.hideBuiltinWorktreeIndicator`. */\n\t\tfunction updateStatus(ctx: ExtensionContext): void {\n\t\t\tif (!ctx.hasUI) return;\n\t\t\tconst hidden = diffra.getSettings().ui?.hideBuiltinWorktreeIndicator === true;\n\t\t\tctx.ui.setStatus(\n\t\t\t\tSTATUS_KEY,\n\t\t\t\tactive && !hidden ? ctx.ui.theme.fg(\"accent\", `⎇ ${active.worktreeBranch} (${active.slug})`) : undefined,\n\t\t\t);\n\t\t}\n\n\t\t/** The repository root of `cwd`, or a clear error. */\n\t\tasync function requireRepository(cwd: string): Promise<string> {\n\t\t\ttry {\n\t\t\t\tawait git(cwd, [\"--version\"]);\n\t\t\t} catch {\n\t\t\t\tthrow new Error(\"Cannot create a worktree: git is not available.\");\n\t\t\t}\n\t\t\tconst root = await repositoryRoot(cwd);\n\t\t\tif (!root) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Cannot create a worktree: ${cwd} is not a git repository. Initialize the repo with \\`git init\\` first.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn root;\n\t\t}\n\t};\n}\n\n/** The worktree recorded on `branch`; `null` after an exit, undefined when none was recorded. */\nexport function readWorktree(branch: readonly SessionEntry[]): ManagedWorktree | null | undefined {\n\tfor (let index = branch.length - 1; index >= 0; index--) {\n\t\tconst entry = branch[index];\n\t\tif (entry.type === \"custom\" && entry.customType === WORKTREE_ENTRY) {\n\t\t\treturn (entry.data as WorktreeEntryData).worktree;\n\t\t}\n\t}\n\treturn undefined;\n}\n\nexport default createWorktreeExtension();\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `--worktree`: before the session starts, create a worktree (or re-attach to an existing one) and
|
|
3
|
+
* make it the process's working directory, so the whole session runs in it.
|
|
4
|
+
*/
|
|
5
|
+
import { type ManagedWorktree } from "./git-worktree.ts";
|
|
6
|
+
/** The worktree to run in, or why there is none. */
|
|
7
|
+
export type StartupWorktree = {
|
|
8
|
+
kind: "ready";
|
|
9
|
+
worktree: ManagedWorktree;
|
|
10
|
+
created: boolean;
|
|
11
|
+
} | {
|
|
12
|
+
kind: "error";
|
|
13
|
+
message: string;
|
|
14
|
+
};
|
|
15
|
+
/** Resolve `--worktree [name | #N | pull request URL]` against `cwd`; creates the worktree when it is new. */
|
|
16
|
+
export declare function prepareStartupWorktree(cwd: string, request: string | true, symlinkDirectories: readonly string[] | undefined): Promise<StartupWorktree>;
|
|
17
|
+
//# sourceMappingURL=startup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"startup.d.ts","sourceRoot":"","sources":["../../../src/extensions/worktree/startup.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAMN,KAAK,eAAe,EAKpB,MAAM,mBAAmB,CAAC;AAE3B,oDAAoD;AACpD,MAAM,MAAM,eAAe,GACxB;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,eAAe,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,GAC9D;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAEtC,8GAA8G;AAC9G,wBAAsB,sBAAsB,CAC3C,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,GAAG,IAAI,EACtB,kBAAkB,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,GAC/C,OAAO,CAAC,eAAe,CAAC,CAuC1B"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `--worktree`: before the session starts, create a worktree (or re-attach to an existing one) and
|
|
3
|
+
* make it the process's working directory, so the whole session runs in it.
|
|
4
|
+
*/
|
|
5
|
+
import { existsSync } from "node:fs";
|
|
6
|
+
import { attachWorktree, autoSlug, createWorktree, fetchPullRequest, git, managedWorktreeAt, repositoryRoot, slugError, worktreePathOf, } from "./git-worktree.js";
|
|
7
|
+
/** Resolve `--worktree [name | #N | pull request URL]` against `cwd`; creates the worktree when it is new. */
|
|
8
|
+
export async function prepareStartupWorktree(cwd, request, symlinkDirectories) {
|
|
9
|
+
try {
|
|
10
|
+
await git(cwd, ["--version"]);
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
return { kind: "error", message: "Cannot create a worktree: git is not available." };
|
|
14
|
+
}
|
|
15
|
+
if (managedWorktreeAt(cwd))
|
|
16
|
+
return { kind: "error", message: "Already inside a git worktree. Start Diffra from the main checkout." };
|
|
17
|
+
const root = await repositoryRoot(cwd);
|
|
18
|
+
if (!root) {
|
|
19
|
+
return {
|
|
20
|
+
kind: "error",
|
|
21
|
+
message: `Cannot create a worktree: ${cwd} is not a git repository. Initialize the repo with \`git init\` first.`,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
const pullRequest = request === true ? undefined : pullRequestNumber(request);
|
|
25
|
+
const slug = request === true ? autoSlug() : pullRequest !== undefined ? `pr-${pullRequest}` : request;
|
|
26
|
+
const problem = slugError(slug, { allowPullRequest: pullRequest !== undefined });
|
|
27
|
+
if (problem)
|
|
28
|
+
return { kind: "error", message: problem };
|
|
29
|
+
try {
|
|
30
|
+
if (existsSync(worktreePathOf(root, slug))) {
|
|
31
|
+
const attached = await attachWorktree(root, slug, cwd);
|
|
32
|
+
if (!attached) {
|
|
33
|
+
return {
|
|
34
|
+
kind: "error",
|
|
35
|
+
message: `${worktreePathOf(root, slug)} exists but is not a worktree of this repository.`,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
return { kind: "ready", worktree: attached, created: false };
|
|
39
|
+
}
|
|
40
|
+
const base = pullRequest !== undefined ? await fetchPullRequest(root, pullRequest) : undefined;
|
|
41
|
+
const worktree = await createWorktree(root, slug, { cwd, base, symlinkDirectories });
|
|
42
|
+
return { kind: "ready", worktree, created: true };
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
return {
|
|
46
|
+
kind: "error",
|
|
47
|
+
message: `Cannot create worktree "${slug}": ${error instanceof Error ? error.message : String(error)}`,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/** The number of `#123` or a pull request URL. */
|
|
52
|
+
function pullRequestNumber(request) {
|
|
53
|
+
const match = /^#([1-9]\d{0,8})$/.exec(request) ?? /\/pull\/([1-9]\d{0,8})(?:[/?#].*)?$/.exec(request);
|
|
54
|
+
return match ? Number(match[1]) : undefined;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=startup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"startup.js","sourceRoot":"","sources":["../../../src/extensions/worktree/startup.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EACN,cAAc,EACd,QAAQ,EACR,cAAc,EACd,gBAAgB,EAChB,GAAG,EAEH,iBAAiB,EACjB,cAAc,EACd,SAAS,EACT,cAAc,GACd,MAAM,mBAAmB,CAAC;AAO3B,8GAA8G;AAC9G,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC3C,GAAW,EACX,OAAsB,EACtB,kBAAiD;IAEjD,IAAI,CAAC;QACJ,MAAM,GAAG,CAAC,GAAG,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC;IAC/B,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,iDAAiD,EAAE,CAAC;IACtF,CAAC;IACD,IAAI,iBAAiB,CAAC,GAAG,CAAC;QACzB,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,qEAAqE,EAAE,CAAC;IAC1G,MAAM,IAAI,GAAG,MAAM,cAAc,CAAC,GAAG,CAAC,CAAC;IACvC,IAAI,CAAC,IAAI,EAAE,CAAC;QACX,OAAO;YACN,IAAI,EAAE,OAAO;YACb,OAAO,EAAE,6BAA6B,GAAG,wEAAwE;SACjH,CAAC;IACH,CAAC;IACD,MAAM,WAAW,GAAG,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;IAC9E,M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EAAE,OAAO;YACb,OAAO,EAAE,2BAA2B,IAAI,MAAM,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;SACtG,CAAC;IACH,CAAC;AACF,CAAC;AAED,kDAAkD;AAClD,SAAS,iBAAiB,CAAC,OAAe;IACzC,MAAM,KAAK,GAAG,mBAAmB,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,qCAAqC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACvG,OAAO,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAC7C,CAAC","sourcesContent":["/**\n * `--worktree`: before the session starts, create a worktree (or re-attach to an existing one) and\n * make it the process's working directory, so the whole session runs in it.\n */\n\nimport { existsSync } from \"node:fs\";\nimport {\n\tattachWorktree,\n\tautoSlug,\n\tcreateWorktree,\n\tfetchPullRequest,\n\tgit,\n\ttype ManagedWorktree,\n\tmanagedWorktreeAt,\n\trepositoryRoot,\n\tslugError,\n\tworktreePathOf,\n} from \"./git-worktree.ts\";\n\n/** The worktree to run in, or why there is none. */\nexport type StartupWorktree =\n\t| { kind: \"ready\"; worktree: ManagedWorktree; created: boolean }\n\t| { kind: \"error\"; message: string };\n\n/** Resolve `--worktree [name | #N | pull request URL]` against `cwd`; creates the worktree when it is new. */\nexport async function prepareStartupWorktree(\n\tcwd: string,\n\trequest: string | true,\n\tsymlinkDirectories: readonly string[] | undefined,\n): Promise<StartupWorktree> {\n\ttry {\n\t\tawait git(cwd, [\"--version\"]);\n\t} catch {\n\t\treturn { kind: \"error\", message: \"Cannot create a worktree: git is not available.\" };\n\t}\n\tif (managedWorktreeAt(cwd))\n\t\treturn { kind: \"error\", message: \"Already inside a git worktree. Start Diffra from the main checkout.\" };\n\tconst root = await repositoryRoot(cwd);\n\tif (!root) {\n\t\treturn {\n\t\t\tkind: \"error\",\n\t\t\tmessage: `Cannot create a worktree: ${cwd} is not a git repository. Initialize the repo with \\`git init\\` first.`,\n\t\t};\n\t}\n\tconst pullRequest = request === true ? undefined : pullRequestNumber(request);\n\tconst slug = request === true ? autoSlug() : pullRequest !== undefined ? `pr-${pullRequest}` : request;\n\tconst problem = slugError(slug, { allowPullRequest: pullRequest !== undefined });\n\tif (problem) return { kind: \"error\", message: problem };\n\ttry {\n\t\tif (existsSync(worktreePathOf(root, slug))) {\n\t\t\tconst attached = await attachWorktree(root, slug, cwd);\n\t\t\tif (!attached) {\n\t\t\t\treturn {\n\t\t\t\t\tkind: \"error\",\n\t\t\t\t\tmessage: `${worktreePathOf(root, slug)} exists but is not a worktree of this repository.`,\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn { kind: \"ready\", worktree: attached, created: false };\n\t\t}\n\t\tconst base = pullRequest !== undefined ? await fetchPullRequest(root, pullRequest) : undefined;\n\t\tconst worktree = await createWorktree(root, slug, { cwd, base, symlinkDirectories });\n\t\treturn { kind: \"ready\", worktree, created: true };\n\t} catch (error) {\n\t\treturn {\n\t\t\tkind: \"error\",\n\t\t\tmessage: `Cannot create worktree \"${slug}\": ${error instanceof Error ? error.message : String(error)}`,\n\t\t};\n\t}\n}\n\n/** The number of `#123` or a pull request URL. */\nfunction pullRequestNumber(request: string): number | undefined {\n\tconst match = /^#([1-9]\\d{0,8})$/.exec(request) ?? /\\/pull\\/([1-9]\\d{0,8})(?:[/?#].*)?$/.exec(request);\n\treturn match ? Number(match[1]) : undefined;\n}\n"]}
|
package/dist/main.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,EAAE,KAAK,IAAI,EAAyD,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,EAAE,KAAK,IAAI,EAAyD,MAAM,eAAe,CAAC;AAsCjG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAclE,OAAO,EAAwB,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAEjF,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAgV7D,wBAAsB,oBAAoB,CACzC,MAAM,EAAE,IAAI,EACZ,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,eAAe,EAAE,eAAe,GAC9B,OAAO,CAAC,cAAc,CAAC,CAsFzB;AA+GD,MAAM,WAAW,WAAW;IAC3B,kBAAkB,CAAC,EAAE,eAAe,EAAE,CAAC;CACvC;AAED,wBAAsB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,WAAW,iBAuf/D"}
|
package/dist/main.js
CHANGED
|
@@ -19,6 +19,7 @@ import { processFileArguments } from "./cli/file-processor.js";
|
|
|
19
19
|
import { buildInitialMessage } from "./cli/initial-message.js";
|
|
20
20
|
import { listModels } from "./cli/list-models.js";
|
|
21
21
|
import { createProjectTrustContext } from "./cli/project-trust.js";
|
|
22
|
+
import { runSandboxCommand } from "./cli/sandbox-command.js";
|
|
22
23
|
import { selectSession } from "./cli/session-picker.js";
|
|
23
24
|
import { shouldRunFirstTimeSetup, showFirstTimeSetup, showStartupSelector } from "./cli/startup-ui.js";
|
|
24
25
|
import { APP_NAME, ENV_SESSION_DIR, expandTildePath, getAgentDir, getPackageDir, VERSION } from "./config.js";
|
|
@@ -37,9 +38,11 @@ import { assertValidSessionId, SessionManager } from "./core/session-manager.js"
|
|
|
37
38
|
import { collectSettingsDiagnostics, deduplicateDiagnostics } from "./core/settings-diagnostics.js";
|
|
38
39
|
import { SettingsManager } from "./core/settings-manager.js";
|
|
39
40
|
import { printTimings, resetTimings, time } from "./core/timings.js";
|
|
41
|
+
import { resolveReadPath } from "./core/tools/path-utils.js";
|
|
40
42
|
import { hasTrustRequiringProjectResources, ProjectTrustStore } from "./core/trust-manager.js";
|
|
41
43
|
import { builtInExtensions } from "./extensions/index.js";
|
|
42
44
|
import { loadMcpCommand } from "./extensions/mcp/cli.lazy.js";
|
|
45
|
+
import { prepareStartupWorktree } from "./extensions/worktree/startup.js";
|
|
43
46
|
import { runMigrations, showDeprecationWarnings } from "./migrations.js";
|
|
44
47
|
import { writeDiagnosticsToStderr } from "./modes/diagnostics-stderr.js";
|
|
45
48
|
import { InteractiveMode, runPrintMode, runRpcMode } from "./modes/index.js";
|
|
@@ -530,6 +533,10 @@ export async function main(args, options) {
|
|
|
530
533
|
process.exitCode = await runMcpCommand(args.slice(1), { cwd, agentDir });
|
|
531
534
|
return;
|
|
532
535
|
}
|
|
536
|
+
if (args[0] === "sandbox") {
|
|
537
|
+
process.exitCode = await runSandboxCommand(args.slice(1), bootstrapSettingsManager.getSandboxSettings());
|
|
538
|
+
return;
|
|
539
|
+
}
|
|
533
540
|
const parsed = parseArgs(args);
|
|
534
541
|
if (parsed.diagnostics.length > 0) {
|
|
535
542
|
for (const d of parsed.diagnostics) {
|
|
@@ -570,6 +577,23 @@ export async function main(args, options) {
|
|
|
570
577
|
}
|
|
571
578
|
validateForkFlags(parsed);
|
|
572
579
|
validateSessionIdFlags(parsed);
|
|
580
|
+
// Path flags resolve against the directory Diffra was started in, even when it moves into a worktree.
|
|
581
|
+
const launchCwd = cwd;
|
|
582
|
+
if (parsed.worktree !== undefined) {
|
|
583
|
+
const symlinkDirectories = SettingsManager.create(cwd, agentDir).getSettings().worktree?.symlinkDirectories;
|
|
584
|
+
const prepared = await prepareStartupWorktree(cwd, parsed.worktree, symlinkDirectories);
|
|
585
|
+
if (prepared.kind === "error") {
|
|
586
|
+
console.error(chalk.red(`Error: ${prepared.message}`));
|
|
587
|
+
process.exit(1);
|
|
588
|
+
}
|
|
589
|
+
const { worktree } = prepared;
|
|
590
|
+
console.error(chalk.dim(`${prepared.created ? "Created" : "Using"} worktree "${worktree.slug}" at ${worktree.worktreePath} on branch ${worktree.worktreeBranch}`));
|
|
591
|
+
parsed.fileArgs = parsed.fileArgs.map((fileArg) => resolveReadPath(fileArg, launchCwd));
|
|
592
|
+
if (parsed.sessionDir)
|
|
593
|
+
parsed.sessionDir = resolvePath(parsed.sessionDir, launchCwd);
|
|
594
|
+
process.chdir(worktree.worktreePath);
|
|
595
|
+
cwd = worktree.worktreePath;
|
|
596
|
+
}
|
|
573
597
|
// Run migrations (pass cwd for project-local migrations)
|
|
574
598
|
const { migratedAuthProviders: migratedProviders, deprecationWarnings } = runMigrations(cwd);
|
|
575
599
|
time("runMigrations");
|
|
@@ -632,10 +656,10 @@ export async function main(args, options) {
|
|
|
632
656
|
: undefined;
|
|
633
657
|
const trustPromptMode = parsed.help || parsed.listModels !== undefined ? "print" : appMode;
|
|
634
658
|
const projectTrustByCwd = new Map();
|
|
635
|
-
const resolvedExtensionPaths = resolveCliPaths(
|
|
636
|
-
const resolvedSkillPaths = resolveCliPaths(
|
|
637
|
-
const resolvedPromptTemplatePaths = resolveCliPaths(
|
|
638
|
-
const resolvedThemePaths = resolveCliPaths(
|
|
659
|
+
const resolvedExtensionPaths = resolveCliPaths(launchCwd, parsed.extensions);
|
|
660
|
+
const resolvedSkillPaths = resolveCliPaths(launchCwd, parsed.skills);
|
|
661
|
+
const resolvedPromptTemplatePaths = resolveCliPaths(launchCwd, parsed.promptTemplates);
|
|
662
|
+
const resolvedThemePaths = resolveCliPaths(launchCwd, parsed.themes);
|
|
639
663
|
// Interactive mode installs and refreshes packages again on /reload, /new, /resume and /fork while the TUI
|
|
640
664
|
// draws on the terminal, where git and npm output would corrupt its screen (#11264). Their output is
|
|
641
665
|
// captured, and until the TUI starts each install is announced on stderr instead.
|