mindweave 0.0.1 → 2.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/LICENSE +190 -0
- package/README.md +171 -14
- package/dist/alternator/chassis/cache.js +47 -0
- package/dist/alternator/chassis/cache.js.map +1 -0
- package/dist/alternator/chassis/domRefs.js +53 -0
- package/dist/alternator/chassis/domRefs.js.map +1 -0
- package/dist/alternator/chassis/extractWorker.js +65 -0
- package/dist/alternator/chassis/extractWorker.js.map +1 -0
- package/dist/alternator/chassis/graph.js +221 -0
- package/dist/alternator/chassis/graph.js.map +1 -0
- package/dist/alternator/chassis/index.js +463 -0
- package/dist/alternator/chassis/index.js.map +1 -0
- package/dist/alternator/chassis/isolation.js +336 -0
- package/dist/alternator/chassis/isolation.js.map +1 -0
- package/dist/alternator/chassis/langCases.js +69 -0
- package/dist/alternator/chassis/langCases.js.map +1 -0
- package/dist/alternator/chassis/lsp.js +469 -0
- package/dist/alternator/chassis/lsp.js.map +1 -0
- package/dist/alternator/chassis/markup.js +262 -0
- package/dist/alternator/chassis/markup.js.map +1 -0
- package/dist/alternator/chassis/provision.js +198 -0
- package/dist/alternator/chassis/provision.js.map +1 -0
- package/dist/alternator/chassis/rank.js +72 -0
- package/dist/alternator/chassis/rank.js.map +1 -0
- package/dist/alternator/chassis/servers.js +215 -0
- package/dist/alternator/chassis/servers.js.map +1 -0
- package/dist/alternator/chassis/treesitter.js +608 -0
- package/dist/alternator/chassis/treesitter.js.map +1 -0
- package/dist/alternator/chassis/types.js +24 -0
- package/dist/alternator/chassis/types.js.map +1 -0
- package/dist/alternator/lane.js +67 -0
- package/dist/alternator/lane.js.map +1 -0
- package/dist/cli/App.js +2586 -0
- package/dist/cli/App.js.map +1 -0
- package/dist/cli/altScreen.js +67 -0
- package/dist/cli/altScreen.js.map +1 -0
- package/dist/cli/approvalChannel.js +72 -0
- package/dist/cli/approvalChannel.js.map +1 -0
- package/dist/cli/attachments.js +188 -0
- package/dist/cli/attachments.js.map +1 -0
- package/dist/cli/bootstrap.js +279 -0
- package/dist/cli/bootstrap.js.map +1 -0
- package/dist/cli/chatAnchor.js +94 -0
- package/dist/cli/chatAnchor.js.map +1 -0
- package/dist/cli/commandArgs.js +79 -0
- package/dist/cli/commandArgs.js.map +1 -0
- package/dist/cli/commandRoute.js +78 -0
- package/dist/cli/commandRoute.js.map +1 -0
- package/dist/cli/compaction.js +69 -0
- package/dist/cli/compaction.js.map +1 -0
- package/dist/cli/components/ApprovalBox.js +100 -0
- package/dist/cli/components/ApprovalBox.js.map +1 -0
- package/dist/cli/components/BlockView.js +128 -0
- package/dist/cli/components/BlockView.js.map +1 -0
- package/dist/cli/components/FirstRunFrame.js +41 -0
- package/dist/cli/components/FirstRunFrame.js.map +1 -0
- package/dist/cli/components/KeyManager.js +197 -0
- package/dist/cli/components/KeyManager.js.map +1 -0
- package/dist/cli/components/KeySetup.js +125 -0
- package/dist/cli/components/KeySetup.js.map +1 -0
- package/dist/cli/components/MenuFrame.js +24 -0
- package/dist/cli/components/MenuFrame.js.map +1 -0
- package/dist/cli/components/Picker.js +82 -0
- package/dist/cli/components/Picker.js.map +1 -0
- package/dist/cli/components/PromptInput.js +509 -0
- package/dist/cli/components/PromptInput.js.map +1 -0
- package/dist/cli/components/SubagentView.js +86 -0
- package/dist/cli/components/SubagentView.js.map +1 -0
- package/dist/cli/components/ToolGroup.js +60 -0
- package/dist/cli/components/ToolGroup.js.map +1 -0
- package/dist/cli/components/ToolLine.js +123 -0
- package/dist/cli/components/ToolLine.js.map +1 -0
- package/dist/cli/components/TrustGate.js +37 -0
- package/dist/cli/components/TrustGate.js.map +1 -0
- package/dist/cli/costView.js +40 -0
- package/dist/cli/costView.js.map +1 -0
- package/dist/cli/frameRate.js +30 -0
- package/dist/cli/frameRate.js.map +1 -0
- package/dist/cli/framebuffer/paint.js +165 -0
- package/dist/cli/framebuffer/paint.js.map +1 -0
- package/dist/cli/framebuffer/parse.js +266 -0
- package/dist/cli/framebuffer/parse.js.map +1 -0
- package/dist/cli/framebuffer/screen.js +196 -0
- package/dist/cli/framebuffer/screen.js.map +1 -0
- package/dist/cli/framebuffer/writer.js +139 -0
- package/dist/cli/framebuffer/writer.js.map +1 -0
- package/dist/cli/groupReveal.js +51 -0
- package/dist/cli/groupReveal.js.map +1 -0
- package/dist/cli/help.js +55 -0
- package/dist/cli/help.js.map +1 -0
- package/dist/cli/inputView.js +105 -0
- package/dist/cli/inputView.js.map +1 -0
- package/dist/cli/keyManager.js +65 -0
- package/dist/cli/keyManager.js.map +1 -0
- package/dist/cli/keySetup.js +35 -0
- package/dist/cli/keySetup.js.map +1 -0
- package/dist/cli/keyStore.js +73 -0
- package/dist/cli/keyStore.js.map +1 -0
- package/dist/cli/markdown.js +460 -0
- package/dist/cli/markdown.js.map +1 -0
- package/dist/cli/messageQueue.js +96 -0
- package/dist/cli/messageQueue.js.map +1 -0
- package/dist/cli/modes.js +90 -0
- package/dist/cli/modes.js.map +1 -0
- package/dist/cli/mouse.js +78 -0
- package/dist/cli/mouse.js.map +1 -0
- package/dist/cli/pasteAssembler.js +44 -0
- package/dist/cli/pasteAssembler.js.map +1 -0
- package/dist/cli/pathComplete.js +39 -0
- package/dist/cli/pathComplete.js.map +1 -0
- package/dist/cli/perfLog.js +90 -0
- package/dist/cli/perfLog.js.map +1 -0
- package/dist/cli/reveal.js +32 -0
- package/dist/cli/reveal.js.map +1 -0
- package/dist/cli/revealPace.js +59 -0
- package/dist/cli/revealPace.js.map +1 -0
- package/dist/cli/sessionCarry.js +19 -0
- package/dist/cli/sessionCarry.js.map +1 -0
- package/dist/cli/smoothScroll.js +74 -0
- package/dist/cli/smoothScroll.js.map +1 -0
- package/dist/cli/startupArgs.js +96 -0
- package/dist/cli/startupArgs.js.map +1 -0
- package/dist/cli/terminalRestore.js +34 -0
- package/dist/cli/terminalRestore.js.map +1 -0
- package/dist/cli/toolDisplay.js +219 -0
- package/dist/cli/toolDisplay.js.map +1 -0
- package/dist/cli/toolItems.js +65 -0
- package/dist/cli/toolItems.js.map +1 -0
- package/dist/cli/transcript.js +351 -0
- package/dist/cli/transcript.js.map +1 -0
- package/dist/cli/trust.js +79 -0
- package/dist/cli/trust.js.map +1 -0
- package/dist/cli/updateCheck.js +107 -0
- package/dist/cli/updateCheck.js.map +1 -0
- package/dist/cli/version.js +39 -0
- package/dist/cli/version.js.map +1 -0
- package/dist/cli/viewport.js +179 -0
- package/dist/cli/viewport.js.map +1 -0
- package/dist/cli/virtualWindow.js +103 -0
- package/dist/cli/virtualWindow.js.map +1 -0
- package/dist/cli/workingVerb.js +37 -0
- package/dist/cli/workingVerb.js.map +1 -0
- package/dist/cli/wrap.js +145 -0
- package/dist/cli/wrap.js.map +1 -0
- package/dist/drivers/anthropic/cachePoints.js +77 -0
- package/dist/drivers/anthropic/cachePoints.js.map +1 -0
- package/dist/drivers/anthropic/client.js +432 -0
- package/dist/drivers/anthropic/client.js.map +1 -0
- package/dist/drivers/anthropic/index.js +10 -0
- package/dist/drivers/anthropic/index.js.map +1 -0
- package/dist/drivers/anthropic/manifest.js +221 -0
- package/dist/drivers/anthropic/manifest.js.map +1 -0
- package/dist/drivers/cerebras/client.js +69 -0
- package/dist/drivers/cerebras/client.js.map +1 -0
- package/dist/drivers/cerebras/index.js +5 -0
- package/dist/drivers/cerebras/index.js.map +1 -0
- package/dist/drivers/cerebras/manifest.js +140 -0
- package/dist/drivers/cerebras/manifest.js.map +1 -0
- package/dist/drivers/clientId.js +41 -0
- package/dist/drivers/clientId.js.map +1 -0
- package/dist/drivers/contextOverflow.js +77 -0
- package/dist/drivers/contextOverflow.js.map +1 -0
- package/dist/drivers/deepseek/client.js +168 -0
- package/dist/drivers/deepseek/client.js.map +1 -0
- package/dist/drivers/deepseek/index.js +16 -0
- package/dist/drivers/deepseek/index.js.map +1 -0
- package/dist/drivers/deepseek/inlineTools.js +46 -0
- package/dist/drivers/deepseek/inlineTools.js.map +1 -0
- package/dist/drivers/deepseek/manifest.js +166 -0
- package/dist/drivers/deepseek/manifest.js.map +1 -0
- package/dist/drivers/gemini/client.js +38 -0
- package/dist/drivers/gemini/client.js.map +1 -0
- package/dist/drivers/gemini/index.js +5 -0
- package/dist/drivers/gemini/index.js.map +1 -0
- package/dist/drivers/gemini/manifest.js +150 -0
- package/dist/drivers/gemini/manifest.js.map +1 -0
- package/dist/drivers/glm/client.js +90 -0
- package/dist/drivers/glm/client.js.map +1 -0
- package/dist/drivers/glm/index.js +9 -0
- package/dist/drivers/glm/index.js.map +1 -0
- package/dist/drivers/glm/manifest.js +183 -0
- package/dist/drivers/glm/manifest.js.map +1 -0
- package/dist/drivers/groq/client.js +80 -0
- package/dist/drivers/groq/client.js.map +1 -0
- package/dist/drivers/groq/index.js +5 -0
- package/dist/drivers/groq/index.js.map +1 -0
- package/dist/drivers/groq/manifest.js +160 -0
- package/dist/drivers/groq/manifest.js.map +1 -0
- package/dist/drivers/kimi/client.js +82 -0
- package/dist/drivers/kimi/client.js.map +1 -0
- package/dist/drivers/kimi/index.js +9 -0
- package/dist/drivers/kimi/index.js.map +1 -0
- package/dist/drivers/kimi/manifest.js +168 -0
- package/dist/drivers/kimi/manifest.js.map +1 -0
- package/dist/drivers/meta/client.js +30 -0
- package/dist/drivers/meta/client.js.map +1 -0
- package/dist/drivers/meta/index.js +5 -0
- package/dist/drivers/meta/index.js.map +1 -0
- package/dist/drivers/meta/manifest.js +101 -0
- package/dist/drivers/meta/manifest.js.map +1 -0
- package/dist/drivers/minimax/client.js +36 -0
- package/dist/drivers/minimax/client.js.map +1 -0
- package/dist/drivers/minimax/index.js +5 -0
- package/dist/drivers/minimax/index.js.map +1 -0
- package/dist/drivers/minimax/manifest.js +120 -0
- package/dist/drivers/minimax/manifest.js.map +1 -0
- package/dist/drivers/mistral/client.js +54 -0
- package/dist/drivers/mistral/client.js.map +1 -0
- package/dist/drivers/mistral/index.js +5 -0
- package/dist/drivers/mistral/index.js.map +1 -0
- package/dist/drivers/mistral/manifest.js +118 -0
- package/dist/drivers/mistral/manifest.js.map +1 -0
- package/dist/drivers/openai/client.js +290 -0
- package/dist/drivers/openai/client.js.map +1 -0
- package/dist/drivers/openai/index.js +9 -0
- package/dist/drivers/openai/index.js.map +1 -0
- package/dist/drivers/openai/manifest.js +133 -0
- package/dist/drivers/openai/manifest.js.map +1 -0
- package/dist/drivers/openaiCompat/wire.js +493 -0
- package/dist/drivers/openaiCompat/wire.js.map +1 -0
- package/dist/drivers/partialTurn.js +23 -0
- package/dist/drivers/partialTurn.js.map +1 -0
- package/dist/drivers/providerError.js +181 -0
- package/dist/drivers/providerError.js.map +1 -0
- package/dist/drivers/qwen/client.js +93 -0
- package/dist/drivers/qwen/client.js.map +1 -0
- package/dist/drivers/qwen/index.js +9 -0
- package/dist/drivers/qwen/index.js.map +1 -0
- package/dist/drivers/qwen/manifest.js +146 -0
- package/dist/drivers/qwen/manifest.js.map +1 -0
- package/dist/drivers/registry.js +177 -0
- package/dist/drivers/registry.js.map +1 -0
- package/dist/drivers/retryPolicy.js +129 -0
- package/dist/drivers/retryPolicy.js.map +1 -0
- package/dist/drivers/searchBlocks.js +61 -0
- package/dist/drivers/searchBlocks.js.map +1 -0
- package/dist/drivers/types.js +2 -0
- package/dist/drivers/types.js.map +1 -0
- package/dist/drivers/xai/client.js +63 -0
- package/dist/drivers/xai/client.js.map +1 -0
- package/dist/drivers/xai/index.js +5 -0
- package/dist/drivers/xai/index.js.map +1 -0
- package/dist/drivers/xai/manifest.js +137 -0
- package/dist/drivers/xai/manifest.js.map +1 -0
- package/dist/dynamo/_probe.tmp.js +20 -0
- package/dist/dynamo/_probe.tmp.js.map +1 -0
- package/dist/dynamo/cacheBreak.js +88 -0
- package/dist/dynamo/cacheBreak.js.map +1 -0
- package/dist/dynamo/contextWindow.js +243 -0
- package/dist/dynamo/contextWindow.js.map +1 -0
- package/dist/dynamo/engine.js +2011 -0
- package/dist/dynamo/engine.js.map +1 -0
- package/dist/dynamo/guard.js +132 -0
- package/dist/dynamo/guard.js.map +1 -0
- package/dist/dynamo/liveMeter.js +58 -0
- package/dist/dynamo/liveMeter.js.map +1 -0
- package/dist/dynamo/model.js +172 -0
- package/dist/dynamo/model.js.map +1 -0
- package/dist/dynamo/planArtifact.js +125 -0
- package/dist/dynamo/planArtifact.js.map +1 -0
- package/dist/dynamo/pricing.js +140 -0
- package/dist/dynamo/pricing.js.map +1 -0
- package/dist/dynamo/prompt.js +264 -0
- package/dist/dynamo/prompt.js.map +1 -0
- package/dist/dynamo/spend.js +45 -0
- package/dist/dynamo/spend.js.map +1 -0
- package/dist/dynamo/verify.js +483 -0
- package/dist/dynamo/verify.js.map +1 -0
- package/dist/governor/forbidden.js +181 -0
- package/dist/governor/forbidden.js.map +1 -0
- package/dist/governor/freshness.js +83 -0
- package/dist/governor/freshness.js.map +1 -0
- package/dist/governor/frontmatter.js +38 -0
- package/dist/governor/frontmatter.js.map +1 -0
- package/dist/governor/glob.js +75 -0
- package/dist/governor/glob.js.map +1 -0
- package/dist/governor/index.js +87 -0
- package/dist/governor/index.js.map +1 -0
- package/dist/governor/rules.js +80 -0
- package/dist/governor/rules.js.map +1 -0
- package/dist/governor/scope.js +91 -0
- package/dist/governor/scope.js.map +1 -0
- package/dist/governor/skills.js +176 -0
- package/dist/governor/skills.js.map +1 -0
- package/dist/governor/types.js +16 -0
- package/dist/governor/types.js.map +1 -0
- package/dist/governor/write.js +182 -0
- package/dist/governor/write.js.map +1 -0
- package/dist/index.js +89 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/catalog.js +232 -0
- package/dist/mcp/catalog.js.map +1 -0
- package/dist/mcp/config.js +116 -0
- package/dist/mcp/config.js.map +1 -0
- package/dist/mcp/configWrite.js +254 -0
- package/dist/mcp/configWrite.js.map +1 -0
- package/dist/mcp/connection.js +504 -0
- package/dist/mcp/connection.js.map +1 -0
- package/dist/mcp/deferred.js +104 -0
- package/dist/mcp/deferred.js.map +1 -0
- package/dist/mcp/discover.js +128 -0
- package/dist/mcp/discover.js.map +1 -0
- package/dist/mcp/manager.js +679 -0
- package/dist/mcp/manager.js.map +1 -0
- package/dist/mcp/paramHeaders.js +163 -0
- package/dist/mcp/paramHeaders.js.map +1 -0
- package/dist/mcp/prompts.js +136 -0
- package/dist/mcp/prompts.js.map +1 -0
- package/dist/mcp/protocol.js +171 -0
- package/dist/mcp/protocol.js.map +1 -0
- package/dist/mcp/resources.js +119 -0
- package/dist/mcp/resources.js.map +1 -0
- package/dist/mcp/resultStore.js +180 -0
- package/dist/mcp/resultStore.js.map +1 -0
- package/dist/mcp/subscriptions.js +74 -0
- package/dist/mcp/subscriptions.js.map +1 -0
- package/dist/mcp/transport/headerValue.js +40 -0
- package/dist/mcp/transport/headerValue.js.map +1 -0
- package/dist/mcp/transport/http.js +321 -0
- package/dist/mcp/transport/http.js.map +1 -0
- package/dist/mcp/transport/stdio.js +234 -0
- package/dist/mcp/transport/stdio.js.map +1 -0
- package/dist/mcp/transport/types.js +27 -0
- package/dist/mcp/transport/types.js.map +1 -0
- package/dist/mcp/trust.js +98 -0
- package/dist/mcp/trust.js.map +1 -0
- package/dist/mcp/trustStore.js +55 -0
- package/dist/mcp/trustStore.js.map +1 -0
- package/dist/memory/autoMemory.js +340 -0
- package/dist/memory/autoMemory.js.map +1 -0
- package/dist/memory/compaction.js +513 -0
- package/dist/memory/compaction.js.map +1 -0
- package/dist/memory/images.js +173 -0
- package/dist/memory/images.js.map +1 -0
- package/dist/memory/presence.js +59 -0
- package/dist/memory/presence.js.map +1 -0
- package/dist/memory/projectNotes.js +247 -0
- package/dist/memory/projectNotes.js.map +1 -0
- package/dist/memory/restore.js +72 -0
- package/dist/memory/restore.js.map +1 -0
- package/dist/memory/session.js +472 -0
- package/dist/memory/session.js.map +1 -0
- package/dist/memory/sessionMemory.js +142 -0
- package/dist/memory/sessionMemory.js.map +1 -0
- package/dist/memory/sessionMemoryCompact.js +136 -0
- package/dist/memory/sessionMemoryCompact.js.map +1 -0
- package/dist/memory/store.js +217 -0
- package/dist/memory/store.js.map +1 -0
- package/dist/memory/types.js +14 -0
- package/dist/memory/types.js.map +1 -0
- package/dist/memory/workingSet.js +383 -0
- package/dist/memory/workingSet.js.map +1 -0
- package/dist/project/context.js +425 -0
- package/dist/project/context.js.map +1 -0
- package/dist/tools/approval.js +189 -0
- package/dist/tools/approval.js.map +1 -0
- package/dist/tools/askUser.js +103 -0
- package/dist/tools/askUser.js.map +1 -0
- package/dist/tools/atomicWrite.js +151 -0
- package/dist/tools/atomicWrite.js.map +1 -0
- package/dist/tools/backgroundShells.js +468 -0
- package/dist/tools/backgroundShells.js.map +1 -0
- package/dist/tools/captureSweep.js +77 -0
- package/dist/tools/captureSweep.js.map +1 -0
- package/dist/tools/chassisMux.js +92 -0
- package/dist/tools/chassisMux.js.map +1 -0
- package/dist/tools/checkpoints.js +328 -0
- package/dist/tools/checkpoints.js.map +1 -0
- package/dist/tools/codeIntel.js +267 -0
- package/dist/tools/codeIntel.js.map +1 -0
- package/dist/tools/deferredNative.js +121 -0
- package/dist/tools/deferredNative.js.map +1 -0
- package/dist/tools/detail.js +135 -0
- package/dist/tools/detail.js.map +1 -0
- package/dist/tools/diagnostics.js +174 -0
- package/dist/tools/diagnostics.js.map +1 -0
- package/dist/tools/edit.js +167 -0
- package/dist/tools/edit.js.map +1 -0
- package/dist/tools/editCore.js +283 -0
- package/dist/tools/editCore.js.map +1 -0
- package/dist/tools/editFile.js +183 -0
- package/dist/tools/editFile.js.map +1 -0
- package/dist/tools/editRipple.js +126 -0
- package/dist/tools/editRipple.js.map +1 -0
- package/dist/tools/editTarget.js +131 -0
- package/dist/tools/editTarget.js.map +1 -0
- package/dist/tools/editWindow.js +49 -0
- package/dist/tools/editWindow.js.map +1 -0
- package/dist/tools/eol.js +56 -0
- package/dist/tools/eol.js.map +1 -0
- package/dist/tools/exitPlan.js +175 -0
- package/dist/tools/exitPlan.js.map +1 -0
- package/dist/tools/focus.js +42 -0
- package/dist/tools/focus.js.map +1 -0
- package/dist/tools/gitignore.js +148 -0
- package/dist/tools/gitignore.js.map +1 -0
- package/dist/tools/glob.js +134 -0
- package/dist/tools/glob.js.map +1 -0
- package/dist/tools/governorTools.js +258 -0
- package/dist/tools/governorTools.js.map +1 -0
- package/dist/tools/grep.js +450 -0
- package/dist/tools/grep.js.map +1 -0
- package/dist/tools/guard.js +220 -0
- package/dist/tools/guard.js.map +1 -0
- package/dist/tools/killTree.js +215 -0
- package/dist/tools/killTree.js.map +1 -0
- package/dist/tools/listDir.js +143 -0
- package/dist/tools/listDir.js.map +1 -0
- package/dist/tools/mcpAdd.js +176 -0
- package/dist/tools/mcpAdd.js.map +1 -0
- package/dist/tools/mcpResources.js +116 -0
- package/dist/tools/mcpResources.js.map +1 -0
- package/dist/tools/mcpSearch.js +123 -0
- package/dist/tools/mcpSearch.js.map +1 -0
- package/dist/tools/multiEdit.js +168 -0
- package/dist/tools/multiEdit.js.map +1 -0
- package/dist/tools/paths.js +225 -0
- package/dist/tools/paths.js.map +1 -0
- package/dist/tools/posixShell.js +123 -0
- package/dist/tools/posixShell.js.map +1 -0
- package/dist/tools/readFile.js +371 -0
- package/dist/tools/readFile.js.map +1 -0
- package/dist/tools/readSymbol.js +145 -0
- package/dist/tools/readSymbol.js.map +1 -0
- package/dist/tools/registry.js +120 -0
- package/dist/tools/registry.js.map +1 -0
- package/dist/tools/replaceSymbol.js +141 -0
- package/dist/tools/replaceSymbol.js.map +1 -0
- package/dist/tools/results.js +15 -0
- package/dist/tools/results.js.map +1 -0
- package/dist/tools/ripgrep.js +145 -0
- package/dist/tools/ripgrep.js.map +1 -0
- package/dist/tools/runCommand.js +633 -0
- package/dist/tools/runCommand.js.map +1 -0
- package/dist/tools/saveMemory.js +102 -0
- package/dist/tools/saveMemory.js.map +1 -0
- package/dist/tools/screenshot.js +200 -0
- package/dist/tools/screenshot.js.map +1 -0
- package/dist/tools/screenshotWin.js +227 -0
- package/dist/tools/screenshotWin.js.map +1 -0
- package/dist/tools/search.js +121 -0
- package/dist/tools/search.js.map +1 -0
- package/dist/tools/sessionTools.js +187 -0
- package/dist/tools/sessionTools.js.map +1 -0
- package/dist/tools/shellCheckpoint.js +123 -0
- package/dist/tools/shellCheckpoint.js.map +1 -0
- package/dist/tools/shellLint.js +102 -0
- package/dist/tools/shellLint.js.map +1 -0
- package/dist/tools/shellTools.js +203 -0
- package/dist/tools/shellTools.js.map +1 -0
- package/dist/tools/spanCore.js +78 -0
- package/dist/tools/spanCore.js.map +1 -0
- package/dist/tools/subagent.js +224 -0
- package/dist/tools/subagent.js.map +1 -0
- package/dist/tools/subagentReport.js +114 -0
- package/dist/tools/subagentReport.js.map +1 -0
- package/dist/tools/tempSweep.js +118 -0
- package/dist/tools/tempSweep.js.map +1 -0
- package/dist/tools/todo.js +117 -0
- package/dist/tools/todo.js.map +1 -0
- package/dist/tools/types.js +2 -0
- package/dist/tools/types.js.map +1 -0
- package/dist/tools/untrusted.js +46 -0
- package/dist/tools/untrusted.js.map +1 -0
- package/dist/tools/useSkill.js +62 -0
- package/dist/tools/useSkill.js.map +1 -0
- package/dist/tools/walk.js +152 -0
- package/dist/tools/walk.js.map +1 -0
- package/dist/tools/web.js +61 -0
- package/dist/tools/web.js.map +1 -0
- package/dist/tools/webFetch.js +444 -0
- package/dist/tools/webFetch.js.map +1 -0
- package/dist/tools/webSearch.js +130 -0
- package/dist/tools/webSearch.js.map +1 -0
- package/dist/tools/workspace.js +212 -0
- package/dist/tools/workspace.js.map +1 -0
- package/dist/tools/workspaceDiscover.js +216 -0
- package/dist/tools/workspaceDiscover.js.map +1 -0
- package/dist/tools/writeFile.js +162 -0
- package/dist/tools/writeFile.js.map +1 -0
- package/package.json +74 -28
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* paths.ts — the one place tools turn a model-supplied path into a real one.
|
|
3
|
+
*
|
|
4
|
+
* Every file tool takes a path from the model that may be absolute or relative,
|
|
5
|
+
* and must resolve it against the *session* working directory (`ctx.cwd`), not
|
|
6
|
+
* Node's `process.cwd()` — because `run_command` can move the session's cwd with
|
|
7
|
+
* `cd`, and a later read/edit must follow it. Keeping this in one helper means
|
|
8
|
+
* every tool resolves paths the same way.
|
|
9
|
+
*/
|
|
10
|
+
import { promises as fs, realpath as realpathCb } from "node:fs";
|
|
11
|
+
import { basename, dirname, isAbsolute, relative, resolve } from "node:path";
|
|
12
|
+
import { promisify } from "node:util";
|
|
13
|
+
/**
|
|
14
|
+
* The OS's own realpath, not Node's JS reimplementation, and the difference is
|
|
15
|
+
* load-bearing on Windows.
|
|
16
|
+
*
|
|
17
|
+
* `fs.realpath` resolves symlinks but leaves an 8.3 SHORT path exactly as it found
|
|
18
|
+
* it, so `C:\Users\RUNNER~1\...` and `C:\Users\runneradmin\...` both survive as
|
|
19
|
+
* distinct strings for one directory. The native call expands short names to their
|
|
20
|
+
* real on-disk form (and fixes the casing), which is what makes the two comparable.
|
|
21
|
+
*
|
|
22
|
+
* This is not exotic: Windows generates a short name for any component over eight
|
|
23
|
+
* characters, so it happens to every user whose account name is longer than that.
|
|
24
|
+
* An eleven-character account name such as a CI runner's `runneradmin` hits it on the
|
|
25
|
+
* first path it builds, while a short one never can — which is exactly the kind of
|
|
26
|
+
* difference between two machines that this function exists to erase.
|
|
27
|
+
*
|
|
28
|
+
* There is no `.native` on the promises API, so the callback form is promisified.
|
|
29
|
+
*/
|
|
30
|
+
const realpathNative = promisify(realpathCb.native);
|
|
31
|
+
import { addFocus } from "./focus.js";
|
|
32
|
+
import { noteScopePath } from "../governor/scope.js";
|
|
33
|
+
/**
|
|
34
|
+
* Resolve a directory to its PHYSICAL path, following symlinks.
|
|
35
|
+
*
|
|
36
|
+
* Every root and every recorded cwd goes through this once, on the way in, so the
|
|
37
|
+
* whole session speaks one form of every path.
|
|
38
|
+
*
|
|
39
|
+
* Why it has to exist: `run_command` records where a command ended up using
|
|
40
|
+
* `pwd -P`, which is physical. macOS puts a great deal behind symlinks — `/tmp` is
|
|
41
|
+
* `/private/tmp`, and `os.tmpdir()` sits under `/private/var` — so a session opened
|
|
42
|
+
* at a logical path and a cwd read back as a physical one describe the same
|
|
43
|
+
* directory with different strings. Nothing compares equal after that: the session
|
|
44
|
+
* appears to have moved on a command that never ran `cd`, and because the recorded
|
|
45
|
+
* cwd is then no longer under the session root, `relativize` gives up and every path
|
|
46
|
+
* the model sees turns absolute.
|
|
47
|
+
*
|
|
48
|
+
* Canonicalising both sides is the fix, and it belongs here rather than at the call
|
|
49
|
+
* site: this module is already the one place a path becomes real.
|
|
50
|
+
*
|
|
51
|
+
* Degrades to the input when the path cannot be resolved (it may not exist yet), so
|
|
52
|
+
* this can be applied unconditionally.
|
|
53
|
+
*/
|
|
54
|
+
export async function canonicalRoot(path) {
|
|
55
|
+
try {
|
|
56
|
+
return await realpathNative(path);
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
return path;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The session's roots, primary first. A single-root session is the common case;
|
|
64
|
+
* `/include` adds more (e.g. a backend + a frontend). Falls back to the live cwd
|
|
65
|
+
* when none are set (bare test contexts), so single-root behavior is unchanged.
|
|
66
|
+
*/
|
|
67
|
+
export function rootsOf(ctx) {
|
|
68
|
+
return ctx.roots && ctx.roots.length > 0 ? ctx.roots : [ctx.cwd];
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* The immutable session anchor — the primary root, which never moves. `run_command`
|
|
72
|
+
* shifts `ctx.cwd` with `cd`, but the anchor stays put, so file tools resolve relative
|
|
73
|
+
* paths against a fixed base instead of a shell cwd that may have wandered into a
|
|
74
|
+
* subdirectory. File tools never follow the shell cwd;
|
|
75
|
+
* without it, a `cd src-tauri` before a build makes a later `edit("App.css")`
|
|
76
|
+
* resolve to `…/src-tauri/App.css` and fail "file not found" on a file that plainly
|
|
77
|
+
* exists — the exact bug this decoupling kills.
|
|
78
|
+
*/
|
|
79
|
+
export function anchorOf(ctx) {
|
|
80
|
+
return rootsOf(ctx)[0];
|
|
81
|
+
}
|
|
82
|
+
/** True when more than one root is in play — the only time paths carry a label. */
|
|
83
|
+
export function isMultiRoot(ctx) {
|
|
84
|
+
return rootsOf(ctx).length > 1;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* A short, unique label for a root — its folder name, disambiguated with the
|
|
88
|
+
* parent folder if two roots share a name (`api/server` vs `web/server`). Labels
|
|
89
|
+
* are how a path stays collision-proof across roots: every displayed path is
|
|
90
|
+
* `label/relative`, and that exact string resolves back to the right root.
|
|
91
|
+
*/
|
|
92
|
+
export function rootLabel(roots, root) {
|
|
93
|
+
const base = basename(root) || root;
|
|
94
|
+
const collides = roots.some((r) => r !== root && (basename(r) || r) === base);
|
|
95
|
+
return collides ? `${basename(dirname(root))}/${base}` : base;
|
|
96
|
+
}
|
|
97
|
+
/** The root that contains `abs`, or null when it's outside every root. */
|
|
98
|
+
function containingRoot(roots, abs) {
|
|
99
|
+
for (const root of roots) {
|
|
100
|
+
const rel = relative(root, abs);
|
|
101
|
+
if (rel === "" || (!rel.startsWith("..") && !isAbsolute(rel)))
|
|
102
|
+
return root;
|
|
103
|
+
}
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Resolve a model-supplied path to an absolute path. Absolute paths pass through;
|
|
108
|
+
* a relative path resolves against the fixed session anchor (NOT the shell cwd, which
|
|
109
|
+
* `run_command` may have moved with `cd`) — UNLESS it's `label/…` for a known added
|
|
110
|
+
* root, which resolves under that root (so the model can reach any root by name without
|
|
111
|
+
* juggling absolute paths).
|
|
112
|
+
*/
|
|
113
|
+
export function resolvePath(ctx, raw) {
|
|
114
|
+
if (isAbsolute(raw))
|
|
115
|
+
return resolve(raw);
|
|
116
|
+
const roots = rootsOf(ctx);
|
|
117
|
+
if (roots.length > 1) {
|
|
118
|
+
const norm = raw.split("\\").join("/");
|
|
119
|
+
const slash = norm.indexOf("/");
|
|
120
|
+
const head = slash >= 0 ? norm.slice(0, slash) : norm;
|
|
121
|
+
const rest = slash >= 0 ? norm.slice(slash + 1) : "";
|
|
122
|
+
for (const root of roots) {
|
|
123
|
+
if (rootLabel(roots, root) === head)
|
|
124
|
+
return resolve(root, rest);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return resolve(anchorOf(ctx), raw);
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* A short, display-friendly form of an absolute path. Single-root: relative to the
|
|
131
|
+
* live cwd (or absolute when outside it). Multi-root: `label/relative` so a path is
|
|
132
|
+
* never ambiguous between roots — and that string round-trips back through
|
|
133
|
+
* `resolvePath`.
|
|
134
|
+
*/
|
|
135
|
+
export function relativize(ctx, abs) {
|
|
136
|
+
const roots = rootsOf(ctx);
|
|
137
|
+
if (roots.length <= 1) {
|
|
138
|
+
// Relative to the fixed anchor, not the moving shell cwd — so a path displays the
|
|
139
|
+
// same regardless of where a `cd` left the shell, and run_command's "in <dir>" line
|
|
140
|
+
// shows the shell's location as a clean subpath of the root (e.g. `src-tauri`).
|
|
141
|
+
const rel = relative(anchorOf(ctx), abs);
|
|
142
|
+
if (rel === "")
|
|
143
|
+
return ".";
|
|
144
|
+
return rel.startsWith("..") ? abs : rel.split("\\").join("/");
|
|
145
|
+
}
|
|
146
|
+
const root = containingRoot(roots, abs);
|
|
147
|
+
if (!root)
|
|
148
|
+
return abs; // outside all roots — show it absolute
|
|
149
|
+
const rel = relative(root, abs);
|
|
150
|
+
const label = rootLabel(roots, root);
|
|
151
|
+
return rel === "" ? label : `${label}/${rel.split("\\").join("/")}`;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Decide what a search tool should scan. With an explicit `path`, that one target
|
|
155
|
+
* (resolved, then expressed as root + subpath so output can be labeled). Without
|
|
156
|
+
* one: every root in a multi-root session (so "search" means "search everywhere"),
|
|
157
|
+
* or just the live cwd in the single-root case (unchanged behavior).
|
|
158
|
+
*/
|
|
159
|
+
export function searchUnits(ctx, rawPath) {
|
|
160
|
+
const roots = rootsOf(ctx);
|
|
161
|
+
if (rawPath && rawPath !== ".") {
|
|
162
|
+
const abs = resolvePath(ctx, rawPath);
|
|
163
|
+
const root = containingRoot(roots, abs) ?? ctx.cwd;
|
|
164
|
+
const rel = relative(root, abs);
|
|
165
|
+
return [{ root, sub: rel === "" ? "" : rel.split("\\").join("/") }];
|
|
166
|
+
}
|
|
167
|
+
if (roots.length > 1)
|
|
168
|
+
return roots.map((root) => ({ root, sub: "" }));
|
|
169
|
+
return [{ root: ctx.cwd, sub: "" }];
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Tell the governor this session has worked in `absPath`, firing any glob-scoped rule
|
|
173
|
+
* that matches it.
|
|
174
|
+
*
|
|
175
|
+
* Called wherever a file enters the read ledger, which is the definition of "the
|
|
176
|
+
* session touched this". Deliberately separate from `ctx.reads` itself: the ledger is
|
|
177
|
+
* cleared at a compaction and this must not be, so the two are written together and
|
|
178
|
+
* forgotten apart.
|
|
179
|
+
*
|
|
180
|
+
* A no-op when the session has no governance or no scope (a sub-agent, a test), and
|
|
181
|
+
* cheap when it has no glob-scoped rules — see scope.ts.
|
|
182
|
+
*/
|
|
183
|
+
export function markScope(ctx, absPath) {
|
|
184
|
+
const scope = ctx.ruleScope;
|
|
185
|
+
const rules = ctx.governance?.rules;
|
|
186
|
+
if (!scope || !rules || rules.length === 0)
|
|
187
|
+
return;
|
|
188
|
+
noteScopePath(scope, rules, ctx.governance.forbidden.root, absPath);
|
|
189
|
+
}
|
|
190
|
+
/** Monotonic clock for read/edit recency (drives the working set's LRU ordering). */
|
|
191
|
+
let touchClock = 0;
|
|
192
|
+
export function nextTouch() {
|
|
193
|
+
return ++touchClock;
|
|
194
|
+
}
|
|
195
|
+
/** Bump a tracked file's recency (and optionally record a focused line span) without
|
|
196
|
+
* changing its read state. Used by tools that re-touch a file they already track. */
|
|
197
|
+
export function touch(ctx, absPath, focus) {
|
|
198
|
+
const rec = ctx.reads.get(absPath);
|
|
199
|
+
if (!rec)
|
|
200
|
+
return;
|
|
201
|
+
rec.touchedAt = nextTouch();
|
|
202
|
+
if (focus)
|
|
203
|
+
rec.focus = addFocus(rec.focus, focus);
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Record that a file was just written/edited. It satisfies the read-before-edit gate
|
|
207
|
+
* (the path is now tracked) and updates recency + the focused region. Marked
|
|
208
|
+
* `full: false`: an edit hands the model only a WINDOW, not the whole file — the
|
|
209
|
+
* working set, not this record, is the source of truth for "the model has the current
|
|
210
|
+
* content." (Marking it `full: true` here is what caused the re-read storm: a later
|
|
211
|
+
* full read got wrongly deduped, so the model paged the file in ranges instead.)
|
|
212
|
+
*/
|
|
213
|
+
export async function recordWrite(ctx, absPath, focus) {
|
|
214
|
+
const prev = ctx.reads.get(absPath);
|
|
215
|
+
markScope(ctx, absPath);
|
|
216
|
+
const base = { full: false, touchedAt: nextTouch(), focus: addFocus(prev?.focus, focus) };
|
|
217
|
+
try {
|
|
218
|
+
const st = await fs.stat(absPath);
|
|
219
|
+
ctx.reads.set(absPath, { mtimeMs: st.mtimeMs, size: st.size, ...base });
|
|
220
|
+
}
|
|
221
|
+
catch {
|
|
222
|
+
ctx.reads.set(absPath, { mtimeMs: 0, size: 0, ...base });
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
//# sourceMappingURL=paths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.js","sourceRoot":"","sources":["../../src/tools/paths.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,QAAQ,IAAI,UAAU,EAAE,MAAM,SAAS,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7E,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAGtC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,cAAc,GAAG,SAAS,CAAC,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CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* posixShell.ts — which shell runs a command on macOS/Linux, and what to say when
|
|
3
|
+
* the one we got can't do what the model asked for.
|
|
4
|
+
*
|
|
5
|
+
* THE PROBLEM THIS FIXES. Commands used to run under a hardcoded `/bin/sh`. On
|
|
6
|
+
* Debian and Ubuntu — the most common Linux family by a wide margin — `/bin/sh` is
|
|
7
|
+
* `dash`, a deliberately minimal POSIX shell. Models are overwhelmingly bash-trained,
|
|
8
|
+
* so a perfectly ordinary command like `if [[ -f x ]]; then …` is a SYNTAX ERROR
|
|
9
|
+
* there, and the model gets back a terse dash complaint with no indication that the
|
|
10
|
+
* shell, not the command, is the problem.
|
|
11
|
+
*
|
|
12
|
+
* Windows already had both halves of this handled: it runs PowerShell (a real shell,
|
|
13
|
+
* not the most minimal one available) and `shellLint.ts` tells the model when it has
|
|
14
|
+
* written a bash-ism. POSIX had neither. This module is the missing half.
|
|
15
|
+
*
|
|
16
|
+
* THE FIX, IN TWO LAYERS:
|
|
17
|
+
* 1. Prefer bash. Nearly every macOS and Linux box has it, so the mismatch simply
|
|
18
|
+
* stops existing. This is the cause, and it is fixed rather than reported.
|
|
19
|
+
* 2. When only a minimal `sh` exists (Alpine, slim containers, busybox), fall back
|
|
20
|
+
* to it and lint — the residue is rare, but it should still explain itself
|
|
21
|
+
* instead of failing cryptically.
|
|
22
|
+
*
|
|
23
|
+
* Deciding once, here, is also what keeps the knowledge in one place: before this,
|
|
24
|
+
* "which shell" was a string literal in the middle of a request builder.
|
|
25
|
+
*/
|
|
26
|
+
import { accessSync, constants } from "node:fs";
|
|
27
|
+
// `posix.join` deliberately, not the platform-default `join`: every path this module
|
|
28
|
+
// builds is a POSIX path, so it must use forward slashes even when the code is being
|
|
29
|
+
// developed or tested on Windows. The platform-default version silently produced
|
|
30
|
+
// backslashed paths that could never match anything, which is a bug that would only
|
|
31
|
+
// have shown up on the machine least likely to run it.
|
|
32
|
+
import { delimiter, posix } from "node:path";
|
|
33
|
+
/**
|
|
34
|
+
* Where bash lives, in preference order, before falling back to a PATH lookup.
|
|
35
|
+
* `/bin/bash` covers mainstream Linux and macOS; `/usr/bin/bash` covers distributions
|
|
36
|
+
* that keep it there; `/opt/homebrew/bin/bash` is where a modern bash lands on Apple
|
|
37
|
+
* Silicon (macOS itself still ships bash 3.2, which is fine for our purposes but not
|
|
38
|
+
* everyone's). A PATH lookup then catches NixOS and anything unusual.
|
|
39
|
+
*/
|
|
40
|
+
const BASH_CANDIDATES = ["/bin/bash", "/usr/bin/bash", "/usr/local/bin/bash", "/opt/homebrew/bin/bash"];
|
|
41
|
+
/** Last resort. POSIX guarantees a shell here, whatever it turns out to be. */
|
|
42
|
+
const FALLBACK_SH = "/bin/sh";
|
|
43
|
+
/**
|
|
44
|
+
* Choose a shell from a candidate list. Pure — `isExecutable` is injected so this is
|
|
45
|
+
* testable on any platform, including the Windows box this is usually developed on.
|
|
46
|
+
*/
|
|
47
|
+
export function pickShell(candidates, pathDirs, isExecutable) {
|
|
48
|
+
for (const bin of candidates) {
|
|
49
|
+
if (isExecutable(bin))
|
|
50
|
+
return { bin, isBash: true };
|
|
51
|
+
}
|
|
52
|
+
for (const dir of pathDirs) {
|
|
53
|
+
const bin = posix.join(dir, "bash");
|
|
54
|
+
if (isExecutable(bin))
|
|
55
|
+
return { bin, isBash: true };
|
|
56
|
+
}
|
|
57
|
+
return { bin: FALLBACK_SH, isBash: false };
|
|
58
|
+
}
|
|
59
|
+
/** Is this path a file we can actually execute? Existence is not enough on POSIX: a
|
|
60
|
+
* readable-but-not-executable file, or a directory, would pass and then fail to spawn. */
|
|
61
|
+
export function isExecutableFile(path) {
|
|
62
|
+
try {
|
|
63
|
+
accessSync(path, constants.X_OK);
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
let cached = null;
|
|
71
|
+
/** The shell this machine will use, resolved once. */
|
|
72
|
+
export function posixShell() {
|
|
73
|
+
if (cached)
|
|
74
|
+
return cached;
|
|
75
|
+
const pathDirs = (process.env.PATH || "").split(delimiter).filter(Boolean);
|
|
76
|
+
cached = pickShell(BASH_CANDIDATES, pathDirs, isExecutableFile);
|
|
77
|
+
return cached;
|
|
78
|
+
}
|
|
79
|
+
/** Test seam: forget the resolved shell so the next call re-detects. */
|
|
80
|
+
export function resetPosixShellCache() {
|
|
81
|
+
cached = null;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Bash-only constructs that are GUARANTEED syntax errors in a strict POSIX shell.
|
|
85
|
+
*
|
|
86
|
+
* Deliberately conservative, exactly like `shellLint.ts`: every entry here must be
|
|
87
|
+
* something dash genuinely cannot parse, because the cost of a false positive is
|
|
88
|
+
* nagging the model about a command that would have worked. Constructs that merely
|
|
89
|
+
* behave differently are left alone.
|
|
90
|
+
*/
|
|
91
|
+
const BASHISMS = [
|
|
92
|
+
{ pattern: /\[\[|\]\]/, what: "[[ ]] tests", fix: "use [ ] instead" },
|
|
93
|
+
{ pattern: /<\(|>\(/, what: "process substitution <( )", fix: "use a pipe or a temp file" },
|
|
94
|
+
{ pattern: /(^|\s)source\s/, what: "`source`", fix: "use `.` (dot)" },
|
|
95
|
+
{ pattern: /(^|\s)function\s+\w+\s*(\(\s*\))?\s*\{/, what: "the `function` keyword", fix: "write `name() { … }`" },
|
|
96
|
+
{ pattern: /\$\{?RANDOM\b/, what: "$RANDOM", fix: "use $$ or awk" },
|
|
97
|
+
{ pattern: /\{\d+\.\.\d+\}/, what: "brace ranges like {1..5}", fix: "use seq or a while loop" },
|
|
98
|
+
{ pattern: /&>/, what: "&> redirection", fix: "use > file 2>&1" },
|
|
99
|
+
{ pattern: /\w+\+=/, what: "+= append", fix: "use var=\"$var…\"" },
|
|
100
|
+
{ pattern: /\$\{\w+\[/, what: "arrays", fix: "use separate variables or a delimited string" },
|
|
101
|
+
{ pattern: /(^|\s)echo\s+-e\b/, what: "echo -e", fix: "use printf" },
|
|
102
|
+
];
|
|
103
|
+
/**
|
|
104
|
+
* Warn when a command needs bash but this machine only has a minimal `sh`.
|
|
105
|
+
*
|
|
106
|
+
* Returns null on the overwhelmingly common path — either bash is present (so
|
|
107
|
+
* anything goes) or the command is portable. The note is only for the rare box where
|
|
108
|
+
* the command genuinely cannot run, and it names the construct and the fix rather
|
|
109
|
+
* than leaving the model to interpret a one-line dash error.
|
|
110
|
+
*/
|
|
111
|
+
export function shellMismatchNote(command, shell = posixShell()) {
|
|
112
|
+
if (shell.isBash)
|
|
113
|
+
return null;
|
|
114
|
+
// Ignore quoted substrings so a bash-ism mentioned inside a string isn't flagged.
|
|
115
|
+
const bare = command.replace(/'[^']*'/g, " ").replace(/"[^"]*"/g, " ");
|
|
116
|
+
const hits = BASHISMS.filter((b) => b.pattern.test(bare));
|
|
117
|
+
if (hits.length === 0)
|
|
118
|
+
return null;
|
|
119
|
+
const list = hits.map((h) => `${h.what} (${h.fix})`).join("; ");
|
|
120
|
+
return (`[This machine has no bash, so commands run under ${shell.bin}, which is a strict POSIX shell. ` +
|
|
121
|
+
`That command uses ${list}. Rewrite it in portable shell syntax.]`);
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=posixShell.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"posixShell.js","sourceRoot":"","sources":["../../src/tools/posixShell.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAChD,qFAAqF;AACrF,qFAAqF;AACrF,iFAAiF;AACjF,oFAAoF;AACpF,uDAAuD;AACvD,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAU7C;;;;;;GAMG;AACH,MAAM,eAAe,GAAG,CAAC,WAAW,EAAE,eAAe,EAAE,qBAAqB,EAAE,wBAAwB,CA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