@diffra-ai/cli 0.1.1 → 0.1.3
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 +38 -0
- package/dist/bundle/chunks/{anthropic-messages-M3HXJPTI.js → anthropic-messages-5EMOURYI.js} +1 -1
- package/dist/bundle/chunks/{azure-openai-responses-GIFO2563.js → azure-openai-responses-N67KWG2X.js} +1 -1
- package/dist/bundle/chunks/bedrock-converse-stream.js +1 -1
- package/dist/bundle/chunks/{chunk-CVEPACZO.js → chunk-3UNTEQ65.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-6ZD23B2R.js +2 -0
- package/dist/bundle/chunks/{chunk-WEJVQTLI.js → chunk-BF423NQ7.js} +1 -1
- package/dist/bundle/chunks/{chunk-262RLABF.js → chunk-CES65UJH.js} +1 -1
- package/dist/bundle/chunks/{chunk-RJRIMI6M.js → chunk-GRYHVZSI.js} +1 -1
- package/dist/bundle/chunks/{chunk-WAH3PGZX.js → chunk-HFTZ6OJJ.js} +2 -2
- package/dist/bundle/chunks/{chunk-N6Q2WLPG.js → chunk-NEFH2K3C.js} +1 -1
- package/dist/bundle/chunks/{chunk-OQFRYL4U.js → chunk-PISJX26Y.js} +1 -1
- package/dist/bundle/chunks/{chunk-VSFRR6IC.js → chunk-QQ6NVGNW.js} +1 -1
- package/dist/bundle/chunks/{chunk-N6QWAQ6I.js → chunk-QYYUGS66.js} +1 -1
- package/dist/bundle/chunks/{chunk-GT3WTHFU.js → chunk-RLMZZV4Q.js} +1 -1
- package/dist/bundle/chunks/chunk-RTPG7C5I.js +2003 -0
- package/dist/bundle/chunks/{chunk-6S2AQWGR.js → chunk-SI7T4LPD.js} +4 -4
- package/dist/bundle/chunks/{chunk-CCH74R6M.js → chunk-VOKUVFV4.js} +1 -1
- package/dist/bundle/chunks/{chunk-OOE7BGUD.js → chunk-VWWMBH3G.js} +1 -1
- package/dist/bundle/chunks/{chunk-B3FUE2LF.js → chunk-XAA355T2.js} +1 -1
- package/dist/bundle/chunks/{cli-EC3ZETTA.js → cli-55VO5MAJ.js} +1 -1
- package/dist/bundle/chunks/{cloudflare-workers-ai-system-one-YW7YYPAC.js → cloudflare-workers-ai-system-one-HB5U67WC.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-XRHE7R52.js} +1 -1
- package/dist/bundle/chunks/{google-vertex-MDWFDVAW.js → google-vertex-75CQOPKC.js} +1 -1
- package/dist/bundle/chunks/{llama-cpp-classify-XO72TVVH.js → llama-cpp-classify-LKIRB7ZR.js} +1 -1
- package/dist/bundle/chunks/{mistral-conversations-KYVGR5VN.js → mistral-conversations-KLGIHK73.js} +1 -1
- package/dist/bundle/chunks/{openai-codex-responses-SIQN5LUE.js → openai-codex-responses-7L5VV67U.js} +1 -1
- package/dist/bundle/chunks/{openai-completions-B22DYT4F.js → openai-completions-RBF6UXDW.js} +1 -1
- package/dist/bundle/chunks/{openai-decisions-4GVNTR54.js → openai-decisions-W3PJQIOF.js} +1 -1
- package/dist/bundle/chunks/{openai-responses-5DVNSQCE.js → openai-responses-W5ZMLOTR.js} +1 -1
- package/dist/bundle/chunks/{openrouter-images-SQMQNKJU.js → openrouter-images-4FW6VFV4.js} +1 -1
- package/dist/bundle/chunks/{pi-messages-GZ4HZRKJ.js → pi-messages-RT7FVQ4G.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-DSJ7OYVL.js} +1 -1
- package/dist/bundle/chunks/virtual-modules-M75O3ECA.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 +30 -3
- 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 +25 -1
- package/docs/docs.json +44 -0
- package/docs/environment-variables.md +7 -0
- package/docs/extensions.md +27 -2
- 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 +3 -2
- package/docs/settings.md +28 -3
- 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,373 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One language server process: checked and started before use, initialized with the project folder,
|
|
3
|
+
* kept in sync with the files it is asked about, and shut down with the session.
|
|
4
|
+
*/
|
|
5
|
+
import { spawn } from "node:child_process";
|
|
6
|
+
import { readFileSync } from "node:fs";
|
|
7
|
+
import { connect } from "node:net";
|
|
8
|
+
import { basename, extname, isAbsolute, relative, resolve } from "node:path";
|
|
9
|
+
import { pathToFileURL } from "node:url";
|
|
10
|
+
import { LspConnection } from "./connection.js";
|
|
11
|
+
export const REQUEST_TIMEOUT_MS = 15_000;
|
|
12
|
+
const PROBE_TIMEOUT_MS = 2_000;
|
|
13
|
+
/** Servers need a moment after `didOpen` before they answer about the file. */
|
|
14
|
+
const OPEN_SETTLE_MS = 200;
|
|
15
|
+
const PUSH_DIAGNOSTICS_WAIT_MS = 2_000;
|
|
16
|
+
const SOCKET_RETRY_START_MS = 250;
|
|
17
|
+
const SOCKET_RETRY_MAX_MS = 1_000;
|
|
18
|
+
/** Environment keys `.lsp.json` may not set: they change what runs or how a shell starts. */
|
|
19
|
+
const BLOCKED_ENV_KEYS = new Set([
|
|
20
|
+
"PATH",
|
|
21
|
+
"NODE_OPTIONS",
|
|
22
|
+
"BASH_ENV",
|
|
23
|
+
"ENV",
|
|
24
|
+
"ZDOTDIR",
|
|
25
|
+
"PROMPT_COMMAND",
|
|
26
|
+
"LD_PRELOAD",
|
|
27
|
+
"LD_LIBRARY_PATH",
|
|
28
|
+
"DYLD_INSERT_LIBRARIES",
|
|
29
|
+
"DYLD_LIBRARY_PATH",
|
|
30
|
+
]);
|
|
31
|
+
/** Language ids of common extensions, used when a server's entry maps none. */
|
|
32
|
+
const DEFAULT_LANGUAGES = {
|
|
33
|
+
".ts": "typescript",
|
|
34
|
+
".mts": "typescript",
|
|
35
|
+
".cts": "typescript",
|
|
36
|
+
".tsx": "typescriptreact",
|
|
37
|
+
".js": "javascript",
|
|
38
|
+
".mjs": "javascript",
|
|
39
|
+
".cjs": "javascript",
|
|
40
|
+
".jsx": "javascriptreact",
|
|
41
|
+
".py": "python",
|
|
42
|
+
".go": "go",
|
|
43
|
+
".rs": "rust",
|
|
44
|
+
".c": "c",
|
|
45
|
+
".h": "c",
|
|
46
|
+
".cc": "cpp",
|
|
47
|
+
".cpp": "cpp",
|
|
48
|
+
".cxx": "cpp",
|
|
49
|
+
".hpp": "cpp",
|
|
50
|
+
".java": "java",
|
|
51
|
+
".cs": "csharp",
|
|
52
|
+
".rb": "ruby",
|
|
53
|
+
".php": "php",
|
|
54
|
+
};
|
|
55
|
+
/** A language server of the project. */
|
|
56
|
+
export class LspServer {
|
|
57
|
+
config;
|
|
58
|
+
status = "stopped";
|
|
59
|
+
error;
|
|
60
|
+
capabilities = {};
|
|
61
|
+
/** Diagnostics the server pushed, by document URI. */
|
|
62
|
+
diagnostics = new Map();
|
|
63
|
+
root;
|
|
64
|
+
connection;
|
|
65
|
+
child;
|
|
66
|
+
socket;
|
|
67
|
+
starting;
|
|
68
|
+
stopping = false;
|
|
69
|
+
restarts = 0;
|
|
70
|
+
documents = new Map();
|
|
71
|
+
diagnosticWaiters = new Map();
|
|
72
|
+
constructor(config, root) {
|
|
73
|
+
this.config = config;
|
|
74
|
+
this.root = root;
|
|
75
|
+
}
|
|
76
|
+
/** The language id of `path` when this server serves it. */
|
|
77
|
+
languageOf(path) {
|
|
78
|
+
const extension = extname(path).toLowerCase();
|
|
79
|
+
const mapped = this.config.extensionToLanguage[extension];
|
|
80
|
+
if (mapped)
|
|
81
|
+
return mapped;
|
|
82
|
+
const fallback = DEFAULT_LANGUAGES[extension];
|
|
83
|
+
return fallback &&
|
|
84
|
+
this.config.languages.some((language) => fallback === language || fallback === `${language}react`)
|
|
85
|
+
? fallback
|
|
86
|
+
: undefined;
|
|
87
|
+
}
|
|
88
|
+
/** Start once; later calls share the same start. */
|
|
89
|
+
start() {
|
|
90
|
+
this.starting ??= this.launch().catch((error) => {
|
|
91
|
+
this.status = "failed";
|
|
92
|
+
this.error = error instanceof Error ? error.message : String(error);
|
|
93
|
+
this.stopProcess();
|
|
94
|
+
});
|
|
95
|
+
return this.starting;
|
|
96
|
+
}
|
|
97
|
+
async launch() {
|
|
98
|
+
this.status = "starting";
|
|
99
|
+
this.error = undefined;
|
|
100
|
+
this.stopping = false;
|
|
101
|
+
const command = this.config.command ? this.resolveCommand(this.config.command) : undefined;
|
|
102
|
+
const env = this.environment();
|
|
103
|
+
if (command)
|
|
104
|
+
await probe(command, env);
|
|
105
|
+
const streams = await this.openStreams(command, env);
|
|
106
|
+
const connection = new LspConnection(streams.input, streams.output, (method, params) => this.answer(method, params));
|
|
107
|
+
this.connection = connection;
|
|
108
|
+
connection.onNotification("textDocument/publishDiagnostics", (params) => this.receiveDiagnostics(params));
|
|
109
|
+
const folder = pathToFileURL(this.config.workspaceFolder).href;
|
|
110
|
+
const result = (await connection.request("initialize", {
|
|
111
|
+
processId: process.pid,
|
|
112
|
+
clientInfo: { name: "diffra" },
|
|
113
|
+
rootPath: this.config.workspaceFolder,
|
|
114
|
+
rootUri: folder,
|
|
115
|
+
workspaceFolders: [{ uri: folder, name: basename(this.config.workspaceFolder) }],
|
|
116
|
+
...(this.config.initializationOptions !== undefined
|
|
117
|
+
? { initializationOptions: this.config.initializationOptions }
|
|
118
|
+
: {}),
|
|
119
|
+
capabilities: CLIENT_CAPABILITIES,
|
|
120
|
+
}, this.config.startupTimeout));
|
|
121
|
+
this.capabilities =
|
|
122
|
+
result && typeof result.capabilities === "object" && result.capabilities !== null
|
|
123
|
+
? result.capabilities
|
|
124
|
+
: {};
|
|
125
|
+
connection.notify("initialized", {});
|
|
126
|
+
if (this.config.settings !== undefined) {
|
|
127
|
+
connection.notify("workspace/didChangeConfiguration", { settings: this.config.settings });
|
|
128
|
+
}
|
|
129
|
+
this.status = "ready";
|
|
130
|
+
}
|
|
131
|
+
/** Start the process; talk over its stdio, or over the configured socket once it listens. */
|
|
132
|
+
async openStreams(command, env) {
|
|
133
|
+
if (command) {
|
|
134
|
+
const child = spawn(command, this.config.args, {
|
|
135
|
+
cwd: this.config.workspaceFolder,
|
|
136
|
+
env,
|
|
137
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
138
|
+
windowsHide: true,
|
|
139
|
+
});
|
|
140
|
+
this.child = child;
|
|
141
|
+
child.stderr.resume();
|
|
142
|
+
child.on("exit", (code) => this.onExit(code));
|
|
143
|
+
await new Promise((resolveSpawn, rejectSpawn) => {
|
|
144
|
+
child.once("spawn", resolveSpawn);
|
|
145
|
+
child.once("error", rejectSpawn);
|
|
146
|
+
});
|
|
147
|
+
if (this.config.transport === "stdio")
|
|
148
|
+
return { input: child.stdout, output: child.stdin };
|
|
149
|
+
}
|
|
150
|
+
this.socket = await this.connectSocket();
|
|
151
|
+
return { input: this.socket, output: this.socket };
|
|
152
|
+
}
|
|
153
|
+
/** Bare names run from PATH; a relative path must stay inside the project. */
|
|
154
|
+
resolveCommand(command) {
|
|
155
|
+
if (!/[\\/]/.test(command) || isAbsolute(command))
|
|
156
|
+
return command;
|
|
157
|
+
const resolved = resolve(this.root, command);
|
|
158
|
+
const inside = relative(this.root, resolved);
|
|
159
|
+
if (inside.startsWith("..") || isAbsolute(inside))
|
|
160
|
+
throw new Error(`command path is unsafe: ${command}`);
|
|
161
|
+
return resolved;
|
|
162
|
+
}
|
|
163
|
+
environment() {
|
|
164
|
+
const env = { ...process.env };
|
|
165
|
+
for (const [key, value] of Object.entries(this.config.env)) {
|
|
166
|
+
if (!BLOCKED_ENV_KEYS.has(key.toUpperCase()))
|
|
167
|
+
env[key] = value;
|
|
168
|
+
}
|
|
169
|
+
return env;
|
|
170
|
+
}
|
|
171
|
+
async connectSocket() {
|
|
172
|
+
const target = this.config.socket ?? {};
|
|
173
|
+
const deadline = Date.now() + this.config.startupTimeout;
|
|
174
|
+
let delay = SOCKET_RETRY_START_MS;
|
|
175
|
+
while (true) {
|
|
176
|
+
try {
|
|
177
|
+
return await new Promise((resolveSocket, rejectSocket) => {
|
|
178
|
+
const socket = target.path
|
|
179
|
+
? connect(target.path)
|
|
180
|
+
: connect({ host: target.host ?? "127.0.0.1", port: target.port ?? 0 });
|
|
181
|
+
socket.once("connect", () => resolveSocket(socket));
|
|
182
|
+
socket.once("error", rejectSocket);
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
catch (error) {
|
|
186
|
+
if (Date.now() + delay > deadline)
|
|
187
|
+
throw error;
|
|
188
|
+
await sleep(delay);
|
|
189
|
+
delay = Math.min(delay * 2, SOCKET_RETRY_MAX_MS);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
/** Answers to requests servers send to clients. */
|
|
194
|
+
answer(method, params) {
|
|
195
|
+
switch (method) {
|
|
196
|
+
case "workspace/configuration": {
|
|
197
|
+
const items = params?.items ?? [];
|
|
198
|
+
return items.map((item) => sectionOf(this.config.settings, item.section));
|
|
199
|
+
}
|
|
200
|
+
case "workspace/workspaceFolders": {
|
|
201
|
+
const folder = pathToFileURL(this.config.workspaceFolder).href;
|
|
202
|
+
return [{ uri: folder, name: basename(this.config.workspaceFolder) }];
|
|
203
|
+
}
|
|
204
|
+
default:
|
|
205
|
+
return null;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
receiveDiagnostics(params) {
|
|
209
|
+
const { uri, diagnostics } = (params ?? {});
|
|
210
|
+
if (typeof uri !== "string" || !Array.isArray(diagnostics))
|
|
211
|
+
return;
|
|
212
|
+
this.diagnostics.set(uri, diagnostics);
|
|
213
|
+
for (const wake of this.diagnosticWaiters.get(uri) ?? [])
|
|
214
|
+
wake();
|
|
215
|
+
this.diagnosticWaiters.delete(uri);
|
|
216
|
+
}
|
|
217
|
+
onExit(code) {
|
|
218
|
+
this.connection?.close(new Error(`The language server exited with code ${code}.`));
|
|
219
|
+
this.connection = undefined;
|
|
220
|
+
this.child = undefined;
|
|
221
|
+
if (this.stopping)
|
|
222
|
+
return;
|
|
223
|
+
this.status = "failed";
|
|
224
|
+
this.error = code === 127 ? `command not found: ${this.config.command}` : `exited with code ${code}`;
|
|
225
|
+
this.documents.clear();
|
|
226
|
+
if (this.config.restartOnCrash && this.restarts < this.config.maxRestarts) {
|
|
227
|
+
this.restarts++;
|
|
228
|
+
this.starting = undefined;
|
|
229
|
+
void this.start();
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
/** Open `path` in the server, or send its new text; true when it was opened just now. */
|
|
233
|
+
async sync(path) {
|
|
234
|
+
const uri = pathToFileURL(path).href;
|
|
235
|
+
const text = readFileSync(path, "utf-8");
|
|
236
|
+
const known = this.documents.get(uri);
|
|
237
|
+
const connection = this.requireConnection();
|
|
238
|
+
if (!known) {
|
|
239
|
+
this.documents.set(uri, { version: 1, text });
|
|
240
|
+
connection.notify("textDocument/didOpen", {
|
|
241
|
+
textDocument: { uri, languageId: this.languageOf(path) ?? this.config.languages[0], version: 1, text },
|
|
242
|
+
});
|
|
243
|
+
await sleep(OPEN_SETTLE_MS);
|
|
244
|
+
return { uri, opened: true };
|
|
245
|
+
}
|
|
246
|
+
if (known.text !== text) {
|
|
247
|
+
const version = known.version + 1;
|
|
248
|
+
this.documents.set(uri, { version, text });
|
|
249
|
+
connection.notify("textDocument/didChange", {
|
|
250
|
+
textDocument: { uri, version },
|
|
251
|
+
contentChanges: [{ text }],
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
return { uri, opened: false };
|
|
255
|
+
}
|
|
256
|
+
openDocumentCount() {
|
|
257
|
+
return this.documents.size;
|
|
258
|
+
}
|
|
259
|
+
request(method, params) {
|
|
260
|
+
return this.requireConnection().request(method, params, REQUEST_TIMEOUT_MS);
|
|
261
|
+
}
|
|
262
|
+
/** Pushed diagnostics of `uri`, waiting briefly for the first push after opening it. */
|
|
263
|
+
async pushedDiagnostics(uri) {
|
|
264
|
+
if (!this.diagnostics.has(uri)) {
|
|
265
|
+
await new Promise((wake) => {
|
|
266
|
+
const timer = setTimeout(wake, PUSH_DIAGNOSTICS_WAIT_MS);
|
|
267
|
+
const waiters = this.diagnosticWaiters.get(uri) ?? [];
|
|
268
|
+
waiters.push(() => {
|
|
269
|
+
clearTimeout(timer);
|
|
270
|
+
wake();
|
|
271
|
+
});
|
|
272
|
+
this.diagnosticWaiters.set(uri, waiters);
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
return this.diagnostics.get(uri) ?? [];
|
|
276
|
+
}
|
|
277
|
+
/** Ask the server to shut down, bounded by its shutdown timeout, then end the process. */
|
|
278
|
+
async stop() {
|
|
279
|
+
this.stopping = true;
|
|
280
|
+
const connection = this.connection;
|
|
281
|
+
if (connection && this.status === "ready") {
|
|
282
|
+
try {
|
|
283
|
+
await connection.request("shutdown", null, this.config.shutdownTimeout);
|
|
284
|
+
connection.notify("exit", null);
|
|
285
|
+
}
|
|
286
|
+
catch {
|
|
287
|
+
// The process is ended below either way.
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
connection?.close(new Error("The language server was stopped."));
|
|
291
|
+
const child = this.child;
|
|
292
|
+
// Wait for the process to end: on Windows its working directory cannot be removed before.
|
|
293
|
+
const exited = child && child.exitCode === null ? new Promise((done) => child.once("exit", () => done())) : undefined;
|
|
294
|
+
this.stopProcess();
|
|
295
|
+
if (exited)
|
|
296
|
+
await Promise.race([exited, sleep(this.config.shutdownTimeout)]);
|
|
297
|
+
this.status = "stopped";
|
|
298
|
+
this.starting = undefined;
|
|
299
|
+
this.documents.clear();
|
|
300
|
+
}
|
|
301
|
+
stopProcess() {
|
|
302
|
+
this.socket?.destroy();
|
|
303
|
+
this.socket = undefined;
|
|
304
|
+
this.child?.kill();
|
|
305
|
+
this.child = undefined;
|
|
306
|
+
this.connection = undefined;
|
|
307
|
+
}
|
|
308
|
+
requireConnection() {
|
|
309
|
+
if (!this.connection || this.status !== "ready")
|
|
310
|
+
throw new Error(`LSP server ${this.config.name} is not ready.`);
|
|
311
|
+
return this.connection;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
const CLIENT_CAPABILITIES = {
|
|
315
|
+
textDocument: {
|
|
316
|
+
synchronization: { dynamicRegistration: false, didSave: false },
|
|
317
|
+
definition: { linkSupport: true },
|
|
318
|
+
implementation: { linkSupport: true },
|
|
319
|
+
references: {},
|
|
320
|
+
hover: { contentFormat: ["markdown", "plaintext"] },
|
|
321
|
+
documentSymbol: { hierarchicalDocumentSymbolSupport: true },
|
|
322
|
+
callHierarchy: {},
|
|
323
|
+
codeAction: {
|
|
324
|
+
codeActionLiteralSupport: {
|
|
325
|
+
codeActionKind: {
|
|
326
|
+
valueSet: ["quickfix", "refactor", "refactor.extract", "refactor.inline", "refactor.rewrite", "source"],
|
|
327
|
+
},
|
|
328
|
+
},
|
|
329
|
+
},
|
|
330
|
+
publishDiagnostics: {},
|
|
331
|
+
diagnostic: {},
|
|
332
|
+
},
|
|
333
|
+
workspace: { symbol: {}, configuration: true, workspaceFolders: true, diagnostics: {} },
|
|
334
|
+
window: { workDoneProgress: false },
|
|
335
|
+
};
|
|
336
|
+
/** Check that the command can be started at all: `<command> --version`. */
|
|
337
|
+
function probe(command, env) {
|
|
338
|
+
return new Promise((resolveProbe, rejectProbe) => {
|
|
339
|
+
const child = spawn(command, ["--version"], { env, stdio: "ignore", windowsHide: true });
|
|
340
|
+
const timer = setTimeout(() => {
|
|
341
|
+
// Still running after the probe time: the command exists.
|
|
342
|
+
child.kill();
|
|
343
|
+
resolveProbe();
|
|
344
|
+
}, PROBE_TIMEOUT_MS);
|
|
345
|
+
child.once("error", (error) => {
|
|
346
|
+
clearTimeout(timer);
|
|
347
|
+
rejectProbe(new Error(error.code === "ENOENT" ? `command not found: ${command}` : error.message));
|
|
348
|
+
});
|
|
349
|
+
child.once("exit", (code) => {
|
|
350
|
+
clearTimeout(timer);
|
|
351
|
+
if (code === 127)
|
|
352
|
+
rejectProbe(new Error(`command not found: ${command}`));
|
|
353
|
+
else
|
|
354
|
+
resolveProbe();
|
|
355
|
+
});
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
/** The part of the settings a `workspace/configuration` item asks for. */
|
|
359
|
+
function sectionOf(settings, section) {
|
|
360
|
+
if (!section)
|
|
361
|
+
return settings ?? null;
|
|
362
|
+
let value = settings;
|
|
363
|
+
for (const key of section.split(".")) {
|
|
364
|
+
if (typeof value !== "object" || value === null)
|
|
365
|
+
return null;
|
|
366
|
+
value = value[key];
|
|
367
|
+
}
|
|
368
|
+
return value ?? null;
|
|
369
|
+
}
|
|
370
|
+
function sleep(ms) {
|
|
371
|
+
return new Promise((resolveSleep) => setTimeout(resolveSleep, ms));
|
|
372
|
+
}
|
|
373
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"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,IAAI,IAAI,CAAC;AACtB,CAAC;AAED,SAAS,KAAK,CAAC,EAAU;IACxB,OAAO,IAAI,OAAO,CAAC,CAAC,YAAY,EAAE,EAAE,CAAC,UAAU,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC,CAAC;AACpE,CAAC","sourcesContent":["/**\n * One language server process: checked and started before use, initialized with the project folder,\n * kept in sync with the files it is asked about, and shut down with the session.\n */\n\nimport { type ChildProcess, spawn } from \"node:child_process\";\nimport { readFileSync } from \"node:fs\";\nimport { connect, type Socket } from \"node:net\";\nimport { basename, extname, isAbsolute, relative, resolve } from \"node:path\";\nimport type { Readable, Writable } from \"node:stream\";\nimport { pathToFileURL } from \"node:url\";\nimport type { LspServerConfig } from \"./config.ts\";\nimport { LspConnection } from \"./connection.ts\";\n\nexport type LspServerStatus = \"stopped\" | \"starting\" | \"ready\" | \"failed\" | \"skipped\";\n\n/** A diagnostic as servers send it. Server input: fields are checked where used. */\nexport type LspDiagnostic = {\n\trange?: { start?: { line?: number; character?: number } };\n\tseverity?: number;\n\tcode?: string | number;\n\tsource?: string;\n\tmessage?: string;\n};\n\nexport const REQUEST_TIMEOUT_MS = 15_000;\nconst PROBE_TIMEOUT_MS = 2_000;\n/** Servers need a moment after `didOpen` before they answer about the file. */\nconst OPEN_SETTLE_MS = 200;\nconst PUSH_DIAGNOSTICS_WAIT_MS = 2_000;\nconst SOCKET_RETRY_START_MS = 250;\nconst SOCKET_RETRY_MAX_MS = 1_000;\n\n/** Environment keys `.lsp.json` may not set: they change what runs or how a shell starts. */\nconst BLOCKED_ENV_KEYS = new Set([\n\t\"PATH\",\n\t\"NODE_OPTIONS\",\n\t\"BASH_ENV\",\n\t\"ENV\",\n\t\"ZDOTDIR\",\n\t\"PROMPT_COMMAND\",\n\t\"LD_PRELOAD\",\n\t\"LD_LIBRARY_PATH\",\n\t\"DYLD_INSERT_LIBRARIES\",\n\t\"DYLD_LIBRARY_PATH\",\n]);\n\n/** Language ids of common extensions, used when a server's entry maps none. */\nconst DEFAULT_LANGUAGES: Record<string, string> = {\n\t\".ts\": \"typescript\",\n\t\".mts\": \"typescript\",\n\t\".cts\": \"typescript\",\n\t\".tsx\": \"typescriptreact\",\n\t\".js\": \"javascript\",\n\t\".mjs\": \"javascript\",\n\t\".cjs\": \"javascript\",\n\t\".jsx\": \"javascriptreact\",\n\t\".py\": \"python\",\n\t\".go\": \"go\",\n\t\".rs\": \"rust\",\n\t\".c\": \"c\",\n\t\".h\": \"c\",\n\t\".cc\": \"cpp\",\n\t\".cpp\": \"cpp\",\n\t\".cxx\": \"cpp\",\n\t\".hpp\": \"cpp\",\n\t\".java\": \"java\",\n\t\".cs\": \"csharp\",\n\t\".rb\": \"ruby\",\n\t\".php\": \"php\",\n};\n\n/** A language server of the project. */\nexport class LspServer {\n\treadonly config: LspServerConfig;\n\tstatus: LspServerStatus = \"stopped\";\n\terror: string | undefined;\n\tcapabilities: Record<string, unknown> = {};\n\t/** Diagnostics the server pushed, by document URI. */\n\treadonly diagnostics = new Map<string, LspDiagnostic[]>();\n\tprivate readonly root: string;\n\tprivate connection: LspConnection | undefined;\n\tprivate child: ChildProcess | undefined;\n\tprivate socket: Socket | undefined;\n\tprivate starting: Promise<void> | undefined;\n\tprivate stopping = false;\n\tprivate restarts = 0;\n\tprivate readonly documents = new Map<string, { version: number; text: string }>();\n\tprivate readonly diagnosticWaiters = new Map<string, Array<() => void>>();\n\n\tconstructor(config: LspServerConfig, root: string) {\n\t\tthis.config = config;\n\t\tthis.root = root;\n\t}\n\n\t/** The language id of `path` when this server serves it. */\n\tlanguageOf(path: string): string | undefined {\n\t\tconst extension = extname(path).toLowerCase();\n\t\tconst mapped = this.config.extensionToLanguage[extension];\n\t\tif (mapped) return mapped;\n\t\tconst fallback = DEFAULT_LANGUAGES[extension];\n\t\treturn fallback &&\n\t\t\tthis.config.languages.some((language) => fallback === language || fallback === `${language}react`)\n\t\t\t? fallback\n\t\t\t: undefined;\n\t}\n\n\t/** Start once; later calls share the same start. */\n\tstart(): Promise<void> {\n\t\tthis.starting ??= this.launch().catch((error: unknown) => {\n\t\t\tthis.status = \"failed\";\n\t\t\tthis.error = error instanceof Error ? error.message : String(error);\n\t\t\tthis.stopProcess();\n\t\t});\n\t\treturn this.starting;\n\t}\n\n\tprivate async launch(): Promise<void> {\n\t\tthis.status = \"starting\";\n\t\tthis.error = undefined;\n\t\tthis.stopping = false;\n\t\tconst command = this.config.command ? this.resolveCommand(this.config.command) : undefined;\n\t\tconst env = this.environment();\n\t\tif (command) await probe(command, env);\n\t\tconst streams = await this.openStreams(command, env);\n\t\tconst connection = new LspConnection(streams.input, streams.output, (method, params) =>\n\t\t\tthis.answer(method, params),\n\t\t);\n\t\tthis.connection = connection;\n\t\tconnection.onNotification(\"textDocument/publishDiagnostics\", (params) => this.receiveDiagnostics(params));\n\t\tconst folder = pathToFileURL(this.config.workspaceFolder).href;\n\t\tconst result = (await connection.request(\n\t\t\t\"initialize\",\n\t\t\t{\n\t\t\t\tprocessId: process.pid,\n\t\t\t\tclientInfo: { name: \"diffra\" },\n\t\t\t\trootPath: this.config.workspaceFolder,\n\t\t\t\trootUri: folder,\n\t\t\t\tworkspaceFolders: [{ uri: folder, name: basename(this.config.workspaceFolder) }],\n\t\t\t\t...(this.config.initializationOptions !== undefined\n\t\t\t\t\t? { initializationOptions: this.config.initializationOptions }\n\t\t\t\t\t: {}),\n\t\t\t\tcapabilities: CLIENT_CAPABILITIES,\n\t\t\t},\n\t\t\tthis.config.startupTimeout,\n\t\t)) as { capabilities?: unknown } | null;\n\t\tthis.capabilities =\n\t\t\tresult && typeof result.capabilities === \"object\" && result.capabilities !== null\n\t\t\t\t? (result.capabilities as Record<string, unknown>)\n\t\t\t\t: {};\n\t\tconnection.notify(\"initialized\", {});\n\t\tif (this.config.settings !== undefined) {\n\t\t\tconnection.notify(\"workspace/didChangeConfiguration\", { settings: this.config.settings });\n\t\t}\n\t\tthis.status = \"ready\";\n\t}\n\n\t/** Start the process; talk over its stdio, or over the configured socket once it listens. */\n\tprivate async openStreams(\n\t\tcommand: string | undefined,\n\t\tenv: NodeJS.ProcessEnv,\n\t): Promise<{ input: Readable; output: Writable }> {\n\t\tif (command) {\n\t\t\tconst child = spawn(command, this.config.args, {\n\t\t\t\tcwd: this.config.workspaceFolder,\n\t\t\t\tenv,\n\t\t\t\tstdio: [\"pipe\", \"pipe\", \"pipe\"],\n\t\t\t\twindowsHide: true,\n\t\t\t});\n\t\t\tthis.child = child;\n\t\t\tchild.stderr.resume();\n\t\t\tchild.on(\"exit\", (code) => this.onExit(code));\n\t\t\tawait new Promise<void>((resolveSpawn, rejectSpawn) => {\n\t\t\t\tchild.once(\"spawn\", resolveSpawn);\n\t\t\t\tchild.once(\"error\", rejectSpawn);\n\t\t\t});\n\t\t\tif (this.config.transport === \"stdio\") return { input: child.stdout, output: child.stdin };\n\t\t}\n\t\tthis.socket = await this.connectSocket();\n\t\treturn { input: this.socket, output: this.socket };\n\t}\n\n\t/** Bare names run from PATH; a relative path must stay inside the project. */\n\tprivate resolveCommand(command: string): string {\n\t\tif (!/[\\\\/]/.test(command) || isAbsolute(command)) return command;\n\t\tconst resolved = resolve(this.root, command);\n\t\tconst inside = relative(this.root, resolved);\n\t\tif (inside.startsWith(\"..\") || isAbsolute(inside)) throw new Error(`command path is unsafe: ${command}`);\n\t\treturn resolved;\n\t}\n\n\tprivate environment(): NodeJS.ProcessEnv {\n\t\tconst env: NodeJS.ProcessEnv = { ...process.env };\n\t\tfor (const [key, value] of Object.entries(this.config.env)) {\n\t\t\tif (!BLOCKED_ENV_KEYS.has(key.toUpperCase())) env[key] = value;\n\t\t}\n\t\treturn env;\n\t}\n\n\tprivate async connectSocket(): Promise<Socket> {\n\t\tconst target = this.config.socket ?? {};\n\t\tconst deadline = Date.now() + this.config.startupTimeout;\n\t\tlet delay = SOCKET_RETRY_START_MS;\n\t\twhile (true) {\n\t\t\ttry {\n\t\t\t\treturn await new Promise<Socket>((resolveSocket, rejectSocket) => {\n\t\t\t\t\tconst socket = target.path\n\t\t\t\t\t\t? connect(target.path)\n\t\t\t\t\t\t: connect({ host: target.host ?? \"127.0.0.1\", port: target.port ?? 0 });\n\t\t\t\t\tsocket.once(\"connect\", () => resolveSocket(socket));\n\t\t\t\t\tsocket.once(\"error\", rejectSocket);\n\t\t\t\t});\n\t\t\t} catch (error) {\n\t\t\t\tif (Date.now() + delay > deadline) throw error;\n\t\t\t\tawait sleep(delay);\n\t\t\t\tdelay = Math.min(delay * 2, SOCKET_RETRY_MAX_MS);\n\t\t\t}\n\t\t}\n\t}\n\n\t/** Answers to requests servers send to clients. */\n\tprivate answer(method: string, params: unknown): unknown {\n\t\tswitch (method) {\n\t\t\tcase \"workspace/configuration\": {\n\t\t\t\tconst items = (params as { items?: Array<{ section?: string }> } | null)?.items ?? [];\n\t\t\t\treturn items.map((item) => sectionOf(this.config.settings, item.section));\n\t\t\t}\n\t\t\tcase \"workspace/workspaceFolders\": {\n\t\t\t\tconst folder = pathToFileURL(this.config.workspaceFolder).href;\n\t\t\t\treturn [{ uri: folder, name: basename(this.config.workspaceFolder) }];\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\treturn null;\n\t\t}\n\t}\n\n\tprivate receiveDiagnostics(params: unknown): void {\n\t\tconst { uri, diagnostics } = (params ?? {}) as { uri?: unknown; diagnostics?: unknown };\n\t\tif (typeof uri !== \"string\" || !Array.isArray(diagnostics)) return;\n\t\tthis.diagnostics.set(uri, diagnostics as LspDiagnostic[]);\n\t\tfor (const wake of this.diagnosticWaiters.get(uri) ?? []) wake();\n\t\tthis.diagnosticWaiters.delete(uri);\n\t}\n\n\tprivate onExit(code: number | null): void {\n\t\tthis.connection?.close(new Error(`The language server exited with code ${code}.`));\n\t\tthis.connection = undefined;\n\t\tthis.child = undefined;\n\t\tif (this.stopping) return;\n\t\tthis.status = \"failed\";\n\t\tthis.error = code === 127 ? `command not found: ${this.config.command}` : `exited with code ${code}`;\n\t\tthis.documents.clear();\n\t\tif (this.config.restartOnCrash && this.restarts < this.config.maxRestarts) {\n\t\t\tthis.restarts++;\n\t\t\tthis.starting = undefined;\n\t\t\tvoid this.start();\n\t\t}\n\t}\n\n\t/** Open `path` in the server, or send its new text; true when it was opened just now. */\n\tasync sync(path: string): Promise<{ uri: string; opened: boolean }> {\n\t\tconst uri = pathToFileURL(path).href;\n\t\tconst text = readFileSync(path, \"utf-8\");\n\t\tconst known = this.documents.get(uri);\n\t\tconst connection = this.requireConnection();\n\t\tif (!known) {\n\t\t\tthis.documents.set(uri, { version: 1, text });\n\t\t\tconnection.notify(\"textDocument/didOpen\", {\n\t\t\t\ttextDocument: { uri, languageId: this.languageOf(path) ?? this.config.languages[0], version: 1, text },\n\t\t\t});\n\t\t\tawait sleep(OPEN_SETTLE_MS);\n\t\t\treturn { uri, opened: true };\n\t\t}\n\t\tif (known.text !== text) {\n\t\t\tconst version = known.version + 1;\n\t\t\tthis.documents.set(uri, { version, text });\n\t\t\tconnection.notify(\"textDocument/didChange\", {\n\t\t\t\ttextDocument: { uri, version },\n\t\t\t\tcontentChanges: [{ text }],\n\t\t\t});\n\t\t}\n\t\treturn { uri, opened: false };\n\t}\n\n\topenDocumentCount(): number {\n\t\treturn this.documents.size;\n\t}\n\n\trequest(method: string, params: unknown): Promise<unknown> {\n\t\treturn this.requireConnection().request(method, params, REQUEST_TIMEOUT_MS);\n\t}\n\n\t/** Pushed diagnostics of `uri`, waiting briefly for the first push after opening it. */\n\tasync pushedDiagnostics(uri: string): Promise<LspDiagnostic[]> {\n\t\tif (!this.diagnostics.has(uri)) {\n\t\t\tawait new Promise<void>((wake) => {\n\t\t\t\tconst timer = setTimeout(wake, PUSH_DIAGNOSTICS_WAIT_MS);\n\t\t\t\tconst waiters = this.diagnosticWaiters.get(uri) ?? [];\n\t\t\t\twaiters.push(() => {\n\t\t\t\t\tclearTimeout(timer);\n\t\t\t\t\twake();\n\t\t\t\t});\n\t\t\t\tthis.diagnosticWaiters.set(uri, waiters);\n\t\t\t});\n\t\t}\n\t\treturn this.diagnostics.get(uri) ?? [];\n\t}\n\n\t/** Ask the server to shut down, bounded by its shutdown timeout, then end the process. */\n\tasync stop(): Promise<void> {\n\t\tthis.stopping = true;\n\t\tconst connection = this.connection;\n\t\tif (connection && this.status === \"ready\") {\n\t\t\ttry {\n\t\t\t\tawait connection.request(\"shutdown\", null, this.config.shutdownTimeout);\n\t\t\t\tconnection.notify(\"exit\", null);\n\t\t\t} catch {\n\t\t\t\t// The process is ended below either way.\n\t\t\t}\n\t\t}\n\t\tconnection?.close(new Error(\"The language server was stopped.\"));\n\t\tconst child = this.child;\n\t\t// Wait for the process to end: on Windows its working directory cannot be removed before.\n\t\tconst exited =\n\t\t\tchild && child.exitCode === null ? new Promise<void>((done) => child.once(\"exit\", () => done())) : undefined;\n\t\tthis.stopProcess();\n\t\tif (exited) await Promise.race([exited, sleep(this.config.shutdownTimeout)]);\n\t\tthis.status = \"stopped\";\n\t\tthis.starting = undefined;\n\t\tthis.documents.clear();\n\t}\n\n\tprivate stopProcess(): void {\n\t\tthis.socket?.destroy();\n\t\tthis.socket = undefined;\n\t\tthis.child?.kill();\n\t\tthis.child = undefined;\n\t\tthis.connection = undefined;\n\t}\n\n\tprivate requireConnection(): LspConnection {\n\t\tif (!this.connection || this.status !== \"ready\") throw new Error(`LSP server ${this.config.name} is not ready.`);\n\t\treturn this.connection;\n\t}\n}\n\nconst CLIENT_CAPABILITIES = {\n\ttextDocument: {\n\t\tsynchronization: { dynamicRegistration: false, didSave: false },\n\t\tdefinition: { linkSupport: true },\n\t\timplementation: { linkSupport: true },\n\t\treferences: {},\n\t\thover: { contentFormat: [\"markdown\", \"plaintext\"] },\n\t\tdocumentSymbol: { hierarchicalDocumentSymbolSupport: true },\n\t\tcallHierarchy: {},\n\t\tcodeAction: {\n\t\t\tcodeActionLiteralSupport: {\n\t\t\t\tcodeActionKind: {\n\t\t\t\t\tvalueSet: [\"quickfix\", \"refactor\", \"refactor.extract\", \"refactor.inline\", \"refactor.rewrite\", \"source\"],\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\tpublishDiagnostics: {},\n\t\tdiagnostic: {},\n\t},\n\tworkspace: { symbol: {}, configuration: true, workspaceFolders: true, diagnostics: {} },\n\twindow: { workDoneProgress: false },\n};\n\n/** Check that the command can be started at all: `<command> --version`. */\nfunction probe(command: string, env: NodeJS.ProcessEnv): Promise<void> {\n\treturn new Promise((resolveProbe, rejectProbe) => {\n\t\tconst child = spawn(command, [\"--version\"], { env, stdio: \"ignore\", windowsHide: true });\n\t\tconst timer = setTimeout(() => {\n\t\t\t// Still running after the probe time: the command exists.\n\t\t\tchild.kill();\n\t\t\tresolveProbe();\n\t\t}, PROBE_TIMEOUT_MS);\n\t\tchild.once(\"error\", (error: NodeJS.ErrnoException) => {\n\t\t\tclearTimeout(timer);\n\t\t\trejectProbe(new Error(error.code === \"ENOENT\" ? `command not found: ${command}` : error.message));\n\t\t});\n\t\tchild.once(\"exit\", (code) => {\n\t\t\tclearTimeout(timer);\n\t\t\tif (code === 127) rejectProbe(new Error(`command not found: ${command}`));\n\t\t\telse resolveProbe();\n\t\t});\n\t});\n}\n\n/** The part of the settings a `workspace/configuration` item asks for. */\nfunction sectionOf(settings: unknown, section: string | undefined): unknown {\n\tif (!section) return settings ?? null;\n\tlet value: unknown = settings;\n\tfor (const key of section.split(\".\")) {\n\t\tif (typeof value !== \"object\" || value === null) return null;\n\t\tvalue = (value as Record<string, unknown>)[key];\n\t}\n\treturn value ?? null;\n}\n\nfunction sleep(ms: number): Promise<void> {\n\treturn new Promise((resolveSleep) => setTimeout(resolveSleep, ms));\n}\n"]}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `lsp` tool: code intelligence from the project's language servers. Definitions, references,
|
|
3
|
+
* hover, symbols, implementations, call hierarchy, diagnostics, and code actions. Positions are
|
|
4
|
+
* 1-based in its parameters and output.
|
|
5
|
+
*/
|
|
6
|
+
import { Type } from "typebox";
|
|
7
|
+
import type { ToolDefinition } from "../../core/extensions/types.ts";
|
|
8
|
+
import type { LspServer } from "./server.ts";
|
|
9
|
+
export declare const LSP_TOOL_NAME = "lsp";
|
|
10
|
+
/** Same-host access to the running servers. */
|
|
11
|
+
export interface LspToolHost {
|
|
12
|
+
/** Whether LSP is on and its servers were started for this session. */
|
|
13
|
+
enabled(): boolean;
|
|
14
|
+
servers(): readonly LspServer[];
|
|
15
|
+
}
|
|
16
|
+
declare const lspSchema: Type.TObject<{
|
|
17
|
+
operation: Type.TUnsafe<"codeActions" | "diagnostics" | "documentSymbol" | "findReferences" | "goToDefinition" | "goToImplementation" | "hover" | "incomingCalls" | "outgoingCalls" | "prepareCallHierarchy" | "workspaceDiagnostics" | "workspaceSymbol">;
|
|
18
|
+
filePath: Type.TOptional<Type.TString>;
|
|
19
|
+
line: Type.TOptional<Type.TNumber>;
|
|
20
|
+
character: Type.TOptional<Type.TNumber>;
|
|
21
|
+
endLine: Type.TOptional<Type.TNumber>;
|
|
22
|
+
endCharacter: Type.TOptional<Type.TNumber>;
|
|
23
|
+
includeDeclaration: Type.TOptional<Type.TBoolean>;
|
|
24
|
+
query: Type.TOptional<Type.TString>;
|
|
25
|
+
callHierarchyItem: Type.TOptional<Type.TObject<{
|
|
26
|
+
name: Type.TString;
|
|
27
|
+
kind: Type.TNumber;
|
|
28
|
+
uri: Type.TString;
|
|
29
|
+
range: Type.TUnknown;
|
|
30
|
+
selectionRange: Type.TUnknown;
|
|
31
|
+
detail: Type.TOptional<Type.TString>;
|
|
32
|
+
data: Type.TOptional<Type.TUnknown>;
|
|
33
|
+
serverName: Type.TOptional<Type.TString>;
|
|
34
|
+
}>>;
|
|
35
|
+
serverName: Type.TOptional<Type.TString>;
|
|
36
|
+
limit: Type.TOptional<Type.TInteger>;
|
|
37
|
+
diagnostics: Type.TOptional<Type.TArray<Type.TUnknown>>;
|
|
38
|
+
codeActionKinds: Type.TOptional<Type.TArray<Type.TString>>;
|
|
39
|
+
}>;
|
|
40
|
+
/** Create the `lsp` tool. */
|
|
41
|
+
export declare function createLspToolDefinition(host: LspToolHost): ToolDefinition<typeof lspSchema>;
|
|
42
|
+
export {};
|
|
43
|
+
//# sourceMappingURL=tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../../../src/extensions/lsp/tool.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAE5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAGrE,OAAO,KAAK,EAAiB,SAAS,EAAE,MAAM,aAAa,CAAC;AAE5D,eAAO,MAAM,aAAa,QAAQ,CAAC;AAEnC,+CAA+C;AAC/C,MAAM,WAAW,WAAW;IAC3B,uEAAuE;IACvE,OAAO,IAAI,OAAO,CAAC;IACnB,OAAO,IAAI,SAAS,SAAS,EAAE,CAAC;CAChC;AAmBD,QAAA,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;EAmCb,CAAC;AA4BH,6BAA6B;AAC7B,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,WAAW,GAAG,cAAc,CAAC,OAAO,SAAS,CAAC,CA2C3F"}
|