aws-runtime-bridge 1.0.0
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/README.md +56 -0
- package/dist/adapter/AdapterRegistry.d.ts +53 -0
- package/dist/adapter/AdapterRegistry.d.ts.map +1 -0
- package/dist/adapter/AdapterRegistry.js +100 -0
- package/dist/adapter/AdapterRegistry.test.d.ts +5 -0
- package/dist/adapter/AdapterRegistry.test.d.ts.map +1 -0
- package/dist/adapter/AdapterRegistry.test.js +109 -0
- package/dist/adapter/ClaudeSdkAdapter.d.ts +120 -0
- package/dist/adapter/ClaudeSdkAdapter.d.ts.map +1 -0
- package/dist/adapter/ClaudeSdkAdapter.js +1140 -0
- package/dist/adapter/ClaudeSdkAdapter.test.d.ts +2 -0
- package/dist/adapter/ClaudeSdkAdapter.test.d.ts.map +1 -0
- package/dist/adapter/ClaudeSdkAdapter.test.js +95 -0
- package/dist/adapter/CodexSdkAdapter.d.ts +48 -0
- package/dist/adapter/CodexSdkAdapter.d.ts.map +1 -0
- package/dist/adapter/CodexSdkAdapter.js +750 -0
- package/dist/adapter/CodexSdkAdapter.test.d.ts +2 -0
- package/dist/adapter/CodexSdkAdapter.test.d.ts.map +1 -0
- package/dist/adapter/CodexSdkAdapter.test.js +245 -0
- package/dist/adapter/OpencodeSdkAdapter.d.ts +45 -0
- package/dist/adapter/OpencodeSdkAdapter.d.ts.map +1 -0
- package/dist/adapter/OpencodeSdkAdapter.js +622 -0
- package/dist/adapter/OpencodeSdkAdapter.test.d.ts +2 -0
- package/dist/adapter/OpencodeSdkAdapter.test.d.ts.map +1 -0
- package/dist/adapter/OpencodeSdkAdapter.test.js +14 -0
- package/dist/adapter/SdkProviderSpi.d.ts +15 -0
- package/dist/adapter/SdkProviderSpi.d.ts.map +1 -0
- package/dist/adapter/SdkProviderSpi.js +46 -0
- package/dist/adapter/adapter.test.d.ts +5 -0
- package/dist/adapter/adapter.test.d.ts.map +1 -0
- package/dist/adapter/adapter.test.js +180 -0
- package/dist/adapter/index.d.ts +11 -0
- package/dist/adapter/index.d.ts.map +1 -0
- package/dist/adapter/index.js +10 -0
- package/dist/adapter/types.d.ts +278 -0
- package/dist/adapter/types.d.ts.map +1 -0
- package/dist/adapter/types.js +278 -0
- package/dist/adapter/types.test.d.ts +2 -0
- package/dist/adapter/types.test.d.ts.map +1 -0
- package/dist/adapter/types.test.js +59 -0
- package/dist/adapters/cc-switch/common.d.ts +52 -0
- package/dist/adapters/cc-switch/common.d.ts.map +1 -0
- package/dist/adapters/cc-switch/common.js +61 -0
- package/dist/adapters/cc-switch/index.d.ts +25 -0
- package/dist/adapters/cc-switch/index.d.ts.map +1 -0
- package/dist/adapters/cc-switch/index.js +51 -0
- package/dist/adapters/cc-switch/mcp-claude.d.ts +15 -0
- package/dist/adapters/cc-switch/mcp-claude.d.ts.map +1 -0
- package/dist/adapters/cc-switch/mcp-claude.js +88 -0
- package/dist/adapters/cc-switch/mcp-claudecode.d.ts +15 -0
- package/dist/adapters/cc-switch/mcp-claudecode.d.ts.map +1 -0
- package/dist/adapters/cc-switch/mcp-claudecode.js +77 -0
- package/dist/adapters/cc-switch/mcp-codex.d.ts +17 -0
- package/dist/adapters/cc-switch/mcp-codex.d.ts.map +1 -0
- package/dist/adapters/cc-switch/mcp-codex.js +248 -0
- package/dist/adapters/cc-switch/mcp-codex.test.d.ts +2 -0
- package/dist/adapters/cc-switch/mcp-codex.test.d.ts.map +1 -0
- package/dist/adapters/cc-switch/mcp-codex.test.js +125 -0
- package/dist/adapters/cc-switch/mcp-opencode.d.ts +23 -0
- package/dist/adapters/cc-switch/mcp-opencode.d.ts.map +1 -0
- package/dist/adapters/cc-switch/mcp-opencode.js +100 -0
- package/dist/adapters/cc-switch/mcp-placeholder.d.ts +14 -0
- package/dist/adapters/cc-switch/mcp-placeholder.d.ts.map +1 -0
- package/dist/adapters/cc-switch/mcp-placeholder.js +19 -0
- package/dist/adapters/cc-switch/skill-claude.d.ts +15 -0
- package/dist/adapters/cc-switch/skill-claude.d.ts.map +1 -0
- package/dist/adapters/cc-switch/skill-claude.js +91 -0
- package/dist/adapters/cc-switch/skill-claudecode.d.ts +15 -0
- package/dist/adapters/cc-switch/skill-claudecode.d.ts.map +1 -0
- package/dist/adapters/cc-switch/skill-claudecode.js +91 -0
- package/dist/adapters/cc-switch/skill-opencode.d.ts +15 -0
- package/dist/adapters/cc-switch/skill-opencode.d.ts.map +1 -0
- package/dist/adapters/cc-switch/skill-opencode.js +95 -0
- package/dist/adapters/cc-switch/skill-placeholder.d.ts +14 -0
- package/dist/adapters/cc-switch/skill-placeholder.d.ts.map +1 -0
- package/dist/adapters/cc-switch/skill-placeholder.js +19 -0
- package/dist/config.d.ts +76 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +109 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +503 -0
- package/dist/middleware/auth.d.ts +12 -0
- package/dist/middleware/auth.d.ts.map +1 -0
- package/dist/middleware/auth.js +18 -0
- package/dist/routes/ai-sources.d.ts +2 -0
- package/dist/routes/ai-sources.d.ts.map +1 -0
- package/dist/routes/ai-sources.js +136 -0
- package/dist/routes/ai-sources.test.d.ts +2 -0
- package/dist/routes/ai-sources.test.d.ts.map +1 -0
- package/dist/routes/ai-sources.test.js +148 -0
- package/dist/routes/aws-mcp.d.ts +10 -0
- package/dist/routes/aws-mcp.d.ts.map +1 -0
- package/dist/routes/aws-mcp.js +74 -0
- package/dist/routes/aws-mcp.test.d.ts +2 -0
- package/dist/routes/aws-mcp.test.d.ts.map +1 -0
- package/dist/routes/aws-mcp.test.js +42 -0
- package/dist/routes/file-browser.d.ts +7 -0
- package/dist/routes/file-browser.d.ts.map +1 -0
- package/dist/routes/file-browser.js +227 -0
- package/dist/routes/file-browser.test.d.ts +5 -0
- package/dist/routes/file-browser.test.d.ts.map +1 -0
- package/dist/routes/file-browser.test.js +88 -0
- package/dist/routes/git.d.ts +7 -0
- package/dist/routes/git.d.ts.map +1 -0
- package/dist/routes/git.js +470 -0
- package/dist/routes/git.test.d.ts +5 -0
- package/dist/routes/git.test.d.ts.map +1 -0
- package/dist/routes/git.test.js +87 -0
- package/dist/routes/instance.d.ts +3 -0
- package/dist/routes/instance.d.ts.map +1 -0
- package/dist/routes/instance.js +170 -0
- package/dist/routes/instance.test.d.ts +5 -0
- package/dist/routes/instance.test.d.ts.map +1 -0
- package/dist/routes/instance.test.js +64 -0
- package/dist/routes/mcp.d.ts +2 -0
- package/dist/routes/mcp.d.ts.map +1 -0
- package/dist/routes/mcp.js +171 -0
- package/dist/routes/mcp.test.d.ts +5 -0
- package/dist/routes/mcp.test.d.ts.map +1 -0
- package/dist/routes/mcp.test.js +84 -0
- package/dist/routes/memory.d.ts +13 -0
- package/dist/routes/memory.d.ts.map +1 -0
- package/dist/routes/memory.js +429 -0
- package/dist/routes/processes.d.ts +7 -0
- package/dist/routes/processes.d.ts.map +1 -0
- package/dist/routes/processes.js +245 -0
- package/dist/routes/properties.d.ts +7 -0
- package/dist/routes/properties.d.ts.map +1 -0
- package/dist/routes/properties.js +72 -0
- package/dist/routes/properties.test.d.ts +5 -0
- package/dist/routes/properties.test.d.ts.map +1 -0
- package/dist/routes/properties.test.js +72 -0
- package/dist/routes/sessions.d.ts +7 -0
- package/dist/routes/sessions.d.ts.map +1 -0
- package/dist/routes/sessions.js +808 -0
- package/dist/routes/sessions.test.d.ts +5 -0
- package/dist/routes/sessions.test.d.ts.map +1 -0
- package/dist/routes/sessions.test.js +70 -0
- package/dist/routes/skills.d.ts +2 -0
- package/dist/routes/skills.d.ts.map +1 -0
- package/dist/routes/skills.js +162 -0
- package/dist/routes/skills.test.d.ts +5 -0
- package/dist/routes/skills.test.d.ts.map +1 -0
- package/dist/routes/skills.test.js +42 -0
- package/dist/routes/terminal.d.ts +18 -0
- package/dist/routes/terminal.d.ts.map +1 -0
- package/dist/routes/terminal.js +663 -0
- package/dist/routes/terminal.test.d.ts +2 -0
- package/dist/routes/terminal.test.d.ts.map +1 -0
- package/dist/routes/terminal.test.js +91 -0
- package/dist/routes/yml.d.ts +7 -0
- package/dist/routes/yml.d.ts.map +1 -0
- package/dist/routes/yml.js +223 -0
- package/dist/routes/yml.test.d.ts +5 -0
- package/dist/routes/yml.test.d.ts.map +1 -0
- package/dist/routes/yml.test.js +58 -0
- package/dist/services/agent-process-manager.d.ts +241 -0
- package/dist/services/agent-process-manager.d.ts.map +1 -0
- package/dist/services/agent-process-manager.js +762 -0
- package/dist/services/auto-register.d.ts +94 -0
- package/dist/services/auto-register.d.ts.map +1 -0
- package/dist/services/auto-register.js +510 -0
- package/dist/services/aws-client-agent-mcp.d.ts +26 -0
- package/dist/services/aws-client-agent-mcp.d.ts.map +1 -0
- package/dist/services/aws-client-agent-mcp.js +142 -0
- package/dist/services/aws-client-agent-mcp.test.d.ts +2 -0
- package/dist/services/aws-client-agent-mcp.test.d.ts.map +1 -0
- package/dist/services/aws-client-agent-mcp.test.js +89 -0
- package/dist/services/aws-mcp-http.d.ts +11 -0
- package/dist/services/aws-mcp-http.d.ts.map +1 -0
- package/dist/services/aws-mcp-http.js +225 -0
- package/dist/services/aws-mcp-http.test.d.ts +2 -0
- package/dist/services/aws-mcp-http.test.d.ts.map +1 -0
- package/dist/services/aws-mcp-http.test.js +27 -0
- package/dist/services/cc-switch-sdk.d.ts +18 -0
- package/dist/services/cc-switch-sdk.d.ts.map +1 -0
- package/dist/services/cc-switch-sdk.js +117 -0
- package/dist/services/easytier-manager.d.ts +106 -0
- package/dist/services/easytier-manager.d.ts.map +1 -0
- package/dist/services/easytier-manager.js +331 -0
- package/dist/services/easytier-manager.test.d.ts +5 -0
- package/dist/services/easytier-manager.test.d.ts.map +1 -0
- package/dist/services/easytier-manager.test.js +98 -0
- package/dist/services/instance-init-service.d.ts +35 -0
- package/dist/services/instance-init-service.d.ts.map +1 -0
- package/dist/services/instance-init-service.js +190 -0
- package/dist/services/instance-service.d.ts +88 -0
- package/dist/services/instance-service.d.ts.map +1 -0
- package/dist/services/instance-service.js +236 -0
- package/dist/services/instance-state.d.ts +36 -0
- package/dist/services/instance-state.d.ts.map +1 -0
- package/dist/services/instance-state.js +79 -0
- package/dist/services/instance-state.test.d.ts +2 -0
- package/dist/services/instance-state.test.d.ts.map +1 -0
- package/dist/services/instance-state.test.js +213 -0
- package/dist/services/memory-service.d.ts +195 -0
- package/dist/services/memory-service.d.ts.map +1 -0
- package/dist/services/memory-service.js +650 -0
- package/dist/services/orphan-monitor.d.ts +94 -0
- package/dist/services/orphan-monitor.d.ts.map +1 -0
- package/dist/services/orphan-monitor.js +321 -0
- package/dist/services/process-detector.d.ts +175 -0
- package/dist/services/process-detector.d.ts.map +1 -0
- package/dist/services/process-detector.js +992 -0
- package/dist/services/process-registry.d.ts +208 -0
- package/dist/services/process-registry.d.ts.map +1 -0
- package/dist/services/process-registry.js +354 -0
- package/dist/services/session-lookup.d.ts +20 -0
- package/dist/services/session-lookup.d.ts.map +1 -0
- package/dist/services/session-lookup.js +43 -0
- package/dist/services/session-output.d.ts +56 -0
- package/dist/services/session-output.d.ts.map +1 -0
- package/dist/services/session-output.js +122 -0
- package/dist/services/session-output.test.d.ts +5 -0
- package/dist/services/session-output.test.d.ts.map +1 -0
- package/dist/services/session-output.test.js +68 -0
- package/dist/services/terminal-persistence.d.ts +51 -0
- package/dist/services/terminal-persistence.d.ts.map +1 -0
- package/dist/services/terminal-persistence.js +125 -0
- package/dist/services/terminal-persistence.test.d.ts +5 -0
- package/dist/services/terminal-persistence.test.d.ts.map +1 -0
- package/dist/services/terminal-persistence.test.js +88 -0
- package/dist/services/tool-installer.d.ts +15 -0
- package/dist/services/tool-installer.d.ts.map +1 -0
- package/dist/services/tool-installer.js +297 -0
- package/dist/services/tool-installer.test.d.ts +2 -0
- package/dist/services/tool-installer.test.d.ts.map +1 -0
- package/dist/services/tool-installer.test.js +102 -0
- package/dist/services/user-api-key-service.d.ts +28 -0
- package/dist/services/user-api-key-service.d.ts.map +1 -0
- package/dist/services/user-api-key-service.js +75 -0
- package/dist/services/workspace-files.d.ts +85 -0
- package/dist/services/workspace-files.d.ts.map +1 -0
- package/dist/services/workspace-files.js +224 -0
- package/dist/services/workspace-files.test.d.ts +2 -0
- package/dist/services/workspace-files.test.d.ts.map +1 -0
- package/dist/services/workspace-files.test.js +117 -0
- package/dist/types.d.ts +233 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -0
- package/dist/utils/file-utils.d.ts +13 -0
- package/dist/utils/file-utils.d.ts.map +1 -0
- package/dist/utils/file-utils.js +140 -0
- package/dist/utils/file-utils.test.d.ts +2 -0
- package/dist/utils/file-utils.test.d.ts.map +1 -0
- package/dist/utils/file-utils.test.js +201 -0
- package/dist/utils/logger.d.ts +39 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +110 -0
- package/dist/utils/logger.test.d.ts +2 -0
- package/dist/utils/logger.test.d.ts.map +1 -0
- package/dist/utils/logger.test.js +93 -0
- package/dist/utils/mcp-utils.d.ts +73 -0
- package/dist/utils/mcp-utils.d.ts.map +1 -0
- package/dist/utils/mcp-utils.js +165 -0
- package/dist/utils/path-utils.d.ts +24 -0
- package/dist/utils/path-utils.d.ts.map +1 -0
- package/dist/utils/path-utils.js +44 -0
- package/dist/utils/validation.d.ts +23 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/validation.js +53 -0
- package/dist/utils/validation.test.d.ts +2 -0
- package/dist/utils/validation.test.d.ts.map +1 -0
- package/dist/utils/validation.test.js +88 -0
- package/dist/utils/yaml-utils.d.ts +73 -0
- package/dist/utils/yaml-utils.d.ts.map +1 -0
- package/dist/utils/yaml-utils.js +309 -0
- package/dist/utils/yaml-utils.test.d.ts +2 -0
- package/dist/utils/yaml-utils.test.d.ts.map +1 -0
- package/dist/utils/yaml-utils.test.js +363 -0
- package/package/aws-client-agent-mcp/README.md +288 -0
- package/package/aws-client-agent-mcp/dist/activity-reporter.d.ts +150 -0
- package/package/aws-client-agent-mcp/dist/activity-reporter.d.ts.map +1 -0
- package/package/aws-client-agent-mcp/dist/activity-reporter.js +353 -0
- package/package/aws-client-agent-mcp/dist/activity-reporter.js.map +1 -0
- package/package/aws-client-agent-mcp/dist/activity-reporter.test.d.ts +2 -0
- package/package/aws-client-agent-mcp/dist/activity-reporter.test.d.ts.map +1 -0
- package/package/aws-client-agent-mcp/dist/activity-reporter.test.js +75 -0
- package/package/aws-client-agent-mcp/dist/activity-reporter.test.js.map +1 -0
- package/package/aws-client-agent-mcp/dist/activity-types.d.ts +96 -0
- package/package/aws-client-agent-mcp/dist/activity-types.d.ts.map +1 -0
- package/package/aws-client-agent-mcp/dist/activity-types.js +141 -0
- package/package/aws-client-agent-mcp/dist/activity-types.js.map +1 -0
- package/package/aws-client-agent-mcp/dist/agent-client.d.ts +165 -0
- package/package/aws-client-agent-mcp/dist/agent-client.d.ts.map +1 -0
- package/package/aws-client-agent-mcp/dist/agent-client.js +588 -0
- package/package/aws-client-agent-mcp/dist/agent-client.js.map +1 -0
- package/package/aws-client-agent-mcp/dist/agent-client.test.d.ts +2 -0
- package/package/aws-client-agent-mcp/dist/agent-client.test.d.ts.map +1 -0
- package/package/aws-client-agent-mcp/dist/agent-client.test.js +534 -0
- package/package/aws-client-agent-mcp/dist/agent-client.test.js.map +1 -0
- package/package/aws-client-agent-mcp/dist/config.d.ts +21 -0
- package/package/aws-client-agent-mcp/dist/config.d.ts.map +1 -0
- package/package/aws-client-agent-mcp/dist/config.js +67 -0
- package/package/aws-client-agent-mcp/dist/config.js.map +1 -0
- package/package/aws-client-agent-mcp/dist/config.test.d.ts +2 -0
- package/package/aws-client-agent-mcp/dist/config.test.d.ts.map +1 -0
- package/package/aws-client-agent-mcp/dist/config.test.js +139 -0
- package/package/aws-client-agent-mcp/dist/config.test.js.map +1 -0
- package/package/aws-client-agent-mcp/dist/constants.d.ts +15 -0
- package/package/aws-client-agent-mcp/dist/constants.d.ts.map +1 -0
- package/package/aws-client-agent-mcp/dist/constants.js +19 -0
- package/package/aws-client-agent-mcp/dist/constants.js.map +1 -0
- package/package/aws-client-agent-mcp/dist/http-client.d.ts +27 -0
- package/package/aws-client-agent-mcp/dist/http-client.d.ts.map +1 -0
- package/package/aws-client-agent-mcp/dist/http-client.js +65 -0
- package/package/aws-client-agent-mcp/dist/http-client.js.map +1 -0
- package/package/aws-client-agent-mcp/dist/http-client.test.d.ts +2 -0
- package/package/aws-client-agent-mcp/dist/http-client.test.d.ts.map +1 -0
- package/package/aws-client-agent-mcp/dist/http-client.test.js +228 -0
- package/package/aws-client-agent-mcp/dist/http-client.test.js.map +1 -0
- package/package/aws-client-agent-mcp/dist/index.d.ts +14 -0
- package/package/aws-client-agent-mcp/dist/index.d.ts.map +1 -0
- package/package/aws-client-agent-mcp/dist/index.js +30 -0
- package/package/aws-client-agent-mcp/dist/index.js.map +1 -0
- package/package/aws-client-agent-mcp/dist/logger.d.ts +7 -0
- package/package/aws-client-agent-mcp/dist/logger.d.ts.map +1 -0
- package/package/aws-client-agent-mcp/dist/logger.js +19 -0
- package/package/aws-client-agent-mcp/dist/logger.js.map +1 -0
- package/package/aws-client-agent-mcp/dist/mcp-server.d.ts +77 -0
- package/package/aws-client-agent-mcp/dist/mcp-server.d.ts.map +1 -0
- package/package/aws-client-agent-mcp/dist/mcp-server.js +427 -0
- package/package/aws-client-agent-mcp/dist/mcp-server.js.map +1 -0
- package/package/aws-client-agent-mcp/dist/mcp-server.test.d.ts +2 -0
- package/package/aws-client-agent-mcp/dist/mcp-server.test.d.ts.map +1 -0
- package/package/aws-client-agent-mcp/dist/mcp-server.test.js +624 -0
- package/package/aws-client-agent-mcp/dist/mcp-server.test.js.map +1 -0
- package/package/aws-client-agent-mcp/dist/mcp-tools.d.ts +78 -0
- package/package/aws-client-agent-mcp/dist/mcp-tools.d.ts.map +1 -0
- package/package/aws-client-agent-mcp/dist/mcp-tools.js +420 -0
- package/package/aws-client-agent-mcp/dist/mcp-tools.js.map +1 -0
- package/package/aws-client-agent-mcp/dist/memory-store.d.ts +61 -0
- package/package/aws-client-agent-mcp/dist/memory-store.d.ts.map +1 -0
- package/package/aws-client-agent-mcp/dist/memory-store.js +268 -0
- package/package/aws-client-agent-mcp/dist/memory-store.js.map +1 -0
- package/package/aws-client-agent-mcp/dist/memory-store.test.d.ts +2 -0
- package/package/aws-client-agent-mcp/dist/memory-store.test.d.ts.map +1 -0
- package/package/aws-client-agent-mcp/dist/memory-store.test.js +164 -0
- package/package/aws-client-agent-mcp/dist/memory-store.test.js.map +1 -0
- package/package/aws-client-agent-mcp/dist/message-buffer.d.ts +74 -0
- package/package/aws-client-agent-mcp/dist/message-buffer.d.ts.map +1 -0
- package/package/aws-client-agent-mcp/dist/message-buffer.js +159 -0
- package/package/aws-client-agent-mcp/dist/message-buffer.js.map +1 -0
- package/package/aws-client-agent-mcp/dist/message-buffer.test.d.ts +2 -0
- package/package/aws-client-agent-mcp/dist/message-buffer.test.d.ts.map +1 -0
- package/package/aws-client-agent-mcp/dist/message-buffer.test.js +44 -0
- package/package/aws-client-agent-mcp/dist/message-buffer.test.js.map +1 -0
- package/package/aws-client-agent-mcp/dist/messageContent.d.ts +53 -0
- package/package/aws-client-agent-mcp/dist/messageContent.d.ts.map +1 -0
- package/package/aws-client-agent-mcp/dist/messageContent.js +125 -0
- package/package/aws-client-agent-mcp/dist/messageContent.js.map +1 -0
- package/package/aws-client-agent-mcp/dist/orchestration-tools.d.ts +19 -0
- package/package/aws-client-agent-mcp/dist/orchestration-tools.d.ts.map +1 -0
- package/package/aws-client-agent-mcp/dist/orchestration-tools.js +317 -0
- package/package/aws-client-agent-mcp/dist/orchestration-tools.js.map +1 -0
- package/package/aws-client-agent-mcp/dist/status-reporter.d.ts +66 -0
- package/package/aws-client-agent-mcp/dist/status-reporter.d.ts.map +1 -0
- package/package/aws-client-agent-mcp/dist/status-reporter.js +220 -0
- package/package/aws-client-agent-mcp/dist/status-reporter.js.map +1 -0
- package/package/aws-client-agent-mcp/dist/status-reporter.test.d.ts +2 -0
- package/package/aws-client-agent-mcp/dist/status-reporter.test.d.ts.map +1 -0
- package/package/aws-client-agent-mcp/dist/status-reporter.test.js +45 -0
- package/package/aws-client-agent-mcp/dist/status-reporter.test.js.map +1 -0
- package/package/aws-client-agent-mcp/dist/types.d.ts +286 -0
- package/package/aws-client-agent-mcp/dist/types.d.ts.map +1 -0
- package/package/aws-client-agent-mcp/dist/types.js +9 -0
- package/package/aws-client-agent-mcp/dist/types.js.map +1 -0
- package/package/aws-client-agent-mcp/dist/user-config-reader.d.ts +63 -0
- package/package/aws-client-agent-mcp/dist/user-config-reader.d.ts.map +1 -0
- package/package/aws-client-agent-mcp/dist/user-config-reader.js +161 -0
- package/package/aws-client-agent-mcp/dist/user-config-reader.js.map +1 -0
- package/package/aws-client-agent-mcp/dist/websocket-client.d.ts +94 -0
- package/package/aws-client-agent-mcp/dist/websocket-client.d.ts.map +1 -0
- package/package/aws-client-agent-mcp/dist/websocket-client.js +316 -0
- package/package/aws-client-agent-mcp/dist/websocket-client.js.map +1 -0
- package/package/aws-client-agent-mcp/dist/websocket-client.test.d.ts +2 -0
- package/package/aws-client-agent-mcp/dist/websocket-client.test.d.ts.map +1 -0
- package/package/aws-client-agent-mcp/dist/websocket-client.test.js +191 -0
- package/package/aws-client-agent-mcp/dist/websocket-client.test.js.map +1 -0
- package/package/aws-client-agent-mcp/package.json +51 -0
- package/package/cc-switch-sdk/README.md +541 -0
- package/package/cc-switch-sdk/dist/adapters/common.d.ts +38 -0
- package/package/cc-switch-sdk/dist/adapters/common.d.ts.map +1 -0
- package/package/cc-switch-sdk/dist/adapters/common.js +47 -0
- package/package/cc-switch-sdk/dist/adapters/index.d.ts +5 -0
- package/package/cc-switch-sdk/dist/adapters/index.d.ts.map +1 -0
- package/package/cc-switch-sdk/dist/adapters/index.js +28 -0
- package/package/cc-switch-sdk/dist/adapters/mcp-claude.d.ts +10 -0
- package/package/cc-switch-sdk/dist/adapters/mcp-claude.d.ts.map +1 -0
- package/package/cc-switch-sdk/dist/adapters/mcp-claude.js +39 -0
- package/package/cc-switch-sdk/dist/adapters/mcp-claudecode.d.ts +10 -0
- package/package/cc-switch-sdk/dist/adapters/mcp-claudecode.d.ts.map +1 -0
- package/package/cc-switch-sdk/dist/adapters/mcp-claudecode.js +40 -0
- package/package/cc-switch-sdk/dist/adapters/mcp-opencode.d.ts +18 -0
- package/package/cc-switch-sdk/dist/adapters/mcp-opencode.d.ts.map +1 -0
- package/package/cc-switch-sdk/dist/adapters/mcp-opencode.js +63 -0
- package/package/cc-switch-sdk/dist/adapters/mcp-opencode.test.d.ts +2 -0
- package/package/cc-switch-sdk/dist/adapters/mcp-opencode.test.d.ts.map +1 -0
- package/package/cc-switch-sdk/dist/adapters/mcp-opencode.test.js +86 -0
- package/package/cc-switch-sdk/dist/adapters/mcp-placeholder.d.ts +9 -0
- package/package/cc-switch-sdk/dist/adapters/mcp-placeholder.d.ts.map +1 -0
- package/package/cc-switch-sdk/dist/adapters/mcp-placeholder.js +14 -0
- package/package/cc-switch-sdk/dist/adapters/skill-claude.d.ts +10 -0
- package/package/cc-switch-sdk/dist/adapters/skill-claude.d.ts.map +1 -0
- package/package/cc-switch-sdk/dist/adapters/skill-claude.js +51 -0
- package/package/cc-switch-sdk/dist/adapters/skill-claudecode.d.ts +10 -0
- package/package/cc-switch-sdk/dist/adapters/skill-claudecode.d.ts.map +1 -0
- package/package/cc-switch-sdk/dist/adapters/skill-claudecode.js +51 -0
- package/package/cc-switch-sdk/dist/adapters/skill-opencode.d.ts +10 -0
- package/package/cc-switch-sdk/dist/adapters/skill-opencode.d.ts.map +1 -0
- package/package/cc-switch-sdk/dist/adapters/skill-opencode.js +51 -0
- package/package/cc-switch-sdk/dist/adapters/skill-placeholder.d.ts +9 -0
- package/package/cc-switch-sdk/dist/adapters/skill-placeholder.d.ts.map +1 -0
- package/package/cc-switch-sdk/dist/adapters/skill-placeholder.js +14 -0
- package/package/cc-switch-sdk/dist/constants.d.ts +9 -0
- package/package/cc-switch-sdk/dist/constants.d.ts.map +1 -0
- package/package/cc-switch-sdk/dist/constants.js +54 -0
- package/package/cc-switch-sdk/dist/errors.d.ts +6 -0
- package/package/cc-switch-sdk/dist/errors.d.ts.map +1 -0
- package/package/cc-switch-sdk/dist/errors.js +8 -0
- package/package/cc-switch-sdk/dist/index.d.ts +11 -0
- package/package/cc-switch-sdk/dist/index.d.ts.map +1 -0
- package/package/cc-switch-sdk/dist/index.js +9 -0
- package/package/cc-switch-sdk/dist/schemas.d.ts +8 -0
- package/package/cc-switch-sdk/dist/schemas.d.ts.map +1 -0
- package/package/cc-switch-sdk/dist/schemas.js +37 -0
- package/package/cc-switch-sdk/dist/sdk.d.ts +91 -0
- package/package/cc-switch-sdk/dist/sdk.d.ts.map +1 -0
- package/package/cc-switch-sdk/dist/sdk.js +427 -0
- package/package/cc-switch-sdk/dist/services/ai-config-service.d.ts +75 -0
- package/package/cc-switch-sdk/dist/services/ai-config-service.d.ts.map +1 -0
- package/package/cc-switch-sdk/dist/services/ai-config-service.js +280 -0
- package/package/cc-switch-sdk/dist/services/instance-service.d.ts +78 -0
- package/package/cc-switch-sdk/dist/services/instance-service.d.ts.map +1 -0
- package/package/cc-switch-sdk/dist/services/instance-service.js +180 -0
- package/package/cc-switch-sdk/dist/services/mcp-model.d.ts +17 -0
- package/package/cc-switch-sdk/dist/services/mcp-model.d.ts.map +1 -0
- package/package/cc-switch-sdk/dist/services/mcp-model.js +34 -0
- package/package/cc-switch-sdk/dist/services/mcp-service.d.ts +18 -0
- package/package/cc-switch-sdk/dist/services/mcp-service.d.ts.map +1 -0
- package/package/cc-switch-sdk/dist/services/mcp-service.js +9 -0
- package/package/cc-switch-sdk/dist/services/skill-model.d.ts +17 -0
- package/package/cc-switch-sdk/dist/services/skill-model.d.ts.map +1 -0
- package/package/cc-switch-sdk/dist/services/skill-model.js +38 -0
- package/package/cc-switch-sdk/dist/services/skill-service.d.ts +17 -0
- package/package/cc-switch-sdk/dist/services/skill-service.d.ts.map +1 -0
- package/package/cc-switch-sdk/dist/services/skill-service.js +9 -0
- package/package/cc-switch-sdk/dist/state.d.ts +4 -0
- package/package/cc-switch-sdk/dist/state.d.ts.map +1 -0
- package/package/cc-switch-sdk/dist/state.js +19 -0
- package/package/cc-switch-sdk/dist/types.d.ts +75 -0
- package/package/cc-switch-sdk/dist/types.d.ts.map +1 -0
- package/package/cc-switch-sdk/dist/types.js +1 -0
- package/package/cc-switch-sdk/dist/utils/fs.d.ts +10 -0
- package/package/cc-switch-sdk/dist/utils/fs.d.ts.map +1 -0
- package/package/cc-switch-sdk/dist/utils/fs.js +91 -0
- package/package/cc-switch-sdk/dist/utils/id.d.ts +4 -0
- package/package/cc-switch-sdk/dist/utils/id.d.ts.map +1 -0
- package/package/cc-switch-sdk/dist/utils/id.js +12 -0
- package/package/cc-switch-sdk/package.json +31 -0
- package/package.json +73 -0
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* YAML 处理工具函数
|
|
3
|
+
*
|
|
4
|
+
* 提供 YAML 配置文件的读取、解析、生成和路径匹配功能
|
|
5
|
+
*/
|
|
6
|
+
import path from 'node:path';
|
|
7
|
+
import { promises as fs } from 'node:fs';
|
|
8
|
+
import * as yaml from 'js-yaml';
|
|
9
|
+
import { createLogger } from './logger.js';
|
|
10
|
+
const log = createLogger('yaml-utils');
|
|
11
|
+
/**
|
|
12
|
+
* 检查 YAML 配置中是否有 agent 的 path 匹配目标路径
|
|
13
|
+
* path 字段格式支持:modules\x 或 modules/x
|
|
14
|
+
*
|
|
15
|
+
* @param yamlContent - YAML 内容
|
|
16
|
+
* @param targetRelativePath - 目标相对路径
|
|
17
|
+
* @returns 匹配的 agent path,无匹配则返回 null
|
|
18
|
+
*/
|
|
19
|
+
export function hasMatchingAgentPath(yamlContent, targetRelativePath) {
|
|
20
|
+
try {
|
|
21
|
+
const parsed = yaml.load(yamlContent);
|
|
22
|
+
if (!parsed || typeof parsed !== 'object') {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
const agents = parsed['agent'];
|
|
26
|
+
if (!Array.isArray(agents)) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
// 标准化目标路径(统一使用 / 分隔符)
|
|
30
|
+
const normalizedTarget = targetRelativePath.replace(/\\/g, '/');
|
|
31
|
+
for (const agent of agents) {
|
|
32
|
+
if (!agent || typeof agent !== 'object') {
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
const agentPath = agent['path'];
|
|
36
|
+
if (typeof agentPath !== 'string') {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
// 标准化配置中的 path
|
|
40
|
+
const normalizedAgentPath = agentPath.replace(/\\/g, '/');
|
|
41
|
+
// 匹配逻辑:
|
|
42
|
+
// 1. 精确匹配
|
|
43
|
+
// 2. 如果目标是 "."(当前目录),配置中 path 为 "." 或空字符串也算匹配
|
|
44
|
+
if (normalizedAgentPath === normalizedTarget) {
|
|
45
|
+
return agentPath;
|
|
46
|
+
}
|
|
47
|
+
// 特殊处理:当前目录匹配
|
|
48
|
+
if (normalizedTarget === '.' && (normalizedAgentPath === '.' || normalizedAgentPath === '')) {
|
|
49
|
+
return agentPath;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* 从 YAML 配置中提取匹配的 agent 配置,或生成模板
|
|
60
|
+
*
|
|
61
|
+
* @param yamlContent - YAML 内容
|
|
62
|
+
* @param targetRelativePath - 目标相对路径
|
|
63
|
+
* @returns 提取结果
|
|
64
|
+
*/
|
|
65
|
+
export function extractAgentConfigOrTemplate(yamlContent, targetRelativePath) {
|
|
66
|
+
try {
|
|
67
|
+
const parsed = yaml.load(yamlContent);
|
|
68
|
+
if (!parsed || typeof parsed !== 'object') {
|
|
69
|
+
return { content: yamlContent, isTemplate: false, projectFromSibling: null };
|
|
70
|
+
}
|
|
71
|
+
const agents = parsed['agent'];
|
|
72
|
+
if (!Array.isArray(agents)) {
|
|
73
|
+
return { content: yamlContent, isTemplate: false, projectFromSibling: null };
|
|
74
|
+
}
|
|
75
|
+
// 标准化目标路径(统一使用 "/" 分隔符)
|
|
76
|
+
const normalizedTarget = targetRelativePath.replace(/\\/g, '/');
|
|
77
|
+
// 查找匹配的 agent
|
|
78
|
+
for (const agent of agents) {
|
|
79
|
+
if (!agent || typeof agent !== 'object') {
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
const agentObj = agent;
|
|
83
|
+
const agentPath = agentObj['path'];
|
|
84
|
+
if (typeof agentPath !== 'string') {
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
const normalizedAgentPath = agentPath.replace(/\\/g, '/');
|
|
88
|
+
// 匹配逻辑:
|
|
89
|
+
// 1. 精确匹配
|
|
90
|
+
// 2. 如果目标是 "."(当前目录),配置中 path 为 "." 或空字符串也算匹配
|
|
91
|
+
const isMatch = normalizedAgentPath === normalizedTarget ||
|
|
92
|
+
(normalizedTarget === '.' && (normalizedAgentPath === '.' || normalizedAgentPath === ''));
|
|
93
|
+
if (isMatch) {
|
|
94
|
+
// 找到匹配的 agent,只返回这一项(确保 path 使用 "/" 分隔符)
|
|
95
|
+
const normalizedAgentObj = { ...agentObj, path: normalizedAgentPath };
|
|
96
|
+
const singleAgentYaml = yaml.dump({ agent: [normalizedAgentObj] }, {
|
|
97
|
+
indent: 2,
|
|
98
|
+
lineWidth: -1,
|
|
99
|
+
quotingType: '"',
|
|
100
|
+
forceQuotes: false,
|
|
101
|
+
});
|
|
102
|
+
return { content: singleAgentYaml, isTemplate: false, projectFromSibling: null };
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
// 没有匹配的 agent,生成模板
|
|
106
|
+
// 先尝试从兄弟项获取 project 值
|
|
107
|
+
let projectValue = null;
|
|
108
|
+
for (const agent of agents) {
|
|
109
|
+
if (!agent || typeof agent !== 'object') {
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
const agentObj = agent;
|
|
113
|
+
if (typeof agentObj['project'] === 'string') {
|
|
114
|
+
projectValue = agentObj['project'];
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
// 生成模板(path 使用 "/" 分隔符)
|
|
119
|
+
const template = {
|
|
120
|
+
agent: [
|
|
121
|
+
{
|
|
122
|
+
name: '',
|
|
123
|
+
path: normalizedTarget,
|
|
124
|
+
project: projectValue || '',
|
|
125
|
+
description: '',
|
|
126
|
+
prompt: '',
|
|
127
|
+
},
|
|
128
|
+
],
|
|
129
|
+
};
|
|
130
|
+
const templateYaml = yaml.dump(template, {
|
|
131
|
+
indent: 2,
|
|
132
|
+
lineWidth: -1,
|
|
133
|
+
quotingType: '"',
|
|
134
|
+
forceQuotes: false,
|
|
135
|
+
});
|
|
136
|
+
return { content: templateYaml, isTemplate: true, projectFromSibling: projectValue };
|
|
137
|
+
}
|
|
138
|
+
catch {
|
|
139
|
+
return { content: yamlContent, isTemplate: false, projectFromSibling: null };
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* 生成空模板
|
|
144
|
+
* 注意:path 字段留空,在写入时根据工作目录自动计算
|
|
145
|
+
*
|
|
146
|
+
* @param _targetRelativePath - 目标相对路径(未使用)
|
|
147
|
+
* @returns 空模板 YAML 内容
|
|
148
|
+
*/
|
|
149
|
+
export function generateEmptyTemplate(_targetRelativePath) {
|
|
150
|
+
const template = {
|
|
151
|
+
agent: [
|
|
152
|
+
{
|
|
153
|
+
name: '',
|
|
154
|
+
path: '', // 留空,写入时自动计算
|
|
155
|
+
project: '',
|
|
156
|
+
description: '',
|
|
157
|
+
prompt: '',
|
|
158
|
+
},
|
|
159
|
+
],
|
|
160
|
+
};
|
|
161
|
+
return yaml.dump(template, {
|
|
162
|
+
indent: 2,
|
|
163
|
+
lineWidth: -1,
|
|
164
|
+
quotingType: '"',
|
|
165
|
+
forceQuotes: false,
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* 自动填充 YAML 配置中的 path 字段
|
|
170
|
+
* 如果 path 为空、未填写或只有空白字符,则使用工作目录相对于项目根目录的路径
|
|
171
|
+
*
|
|
172
|
+
* @param ymlContent - YAML 配置内容
|
|
173
|
+
* @param workspaceRelativePath - 工作目录相对于项目根目录的路径
|
|
174
|
+
* @returns 处理后的 YAML 内容
|
|
175
|
+
*/
|
|
176
|
+
export function autoFillPathInYml(ymlContent, workspaceRelativePath) {
|
|
177
|
+
try {
|
|
178
|
+
const parsed = yaml.load(ymlContent);
|
|
179
|
+
if (!parsed || typeof parsed !== 'object') {
|
|
180
|
+
return ymlContent;
|
|
181
|
+
}
|
|
182
|
+
const config = parsed;
|
|
183
|
+
if (!config.agent || !Array.isArray(config.agent)) {
|
|
184
|
+
return ymlContent;
|
|
185
|
+
}
|
|
186
|
+
let modified = false;
|
|
187
|
+
for (const agent of config.agent) {
|
|
188
|
+
if (agent) {
|
|
189
|
+
// 检查 path 是否为空、未定义或只有空白字符
|
|
190
|
+
const pathValue = agent.path;
|
|
191
|
+
const isPathEmpty = pathValue === undefined ||
|
|
192
|
+
pathValue === null ||
|
|
193
|
+
String(pathValue).trim() === '';
|
|
194
|
+
if (isPathEmpty) {
|
|
195
|
+
agent.path = workspaceRelativePath;
|
|
196
|
+
modified = true;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
if (modified) {
|
|
201
|
+
return yaml.dump(config, {
|
|
202
|
+
indent: 2,
|
|
203
|
+
lineWidth: -1,
|
|
204
|
+
quotingType: '"',
|
|
205
|
+
forceQuotes: false,
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
return ymlContent;
|
|
209
|
+
}
|
|
210
|
+
catch {
|
|
211
|
+
// 解析失败,返回原内容
|
|
212
|
+
return ymlContent;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* 向上查找并加载 YAML 配置文件
|
|
217
|
+
*
|
|
218
|
+
* 查找逻辑:
|
|
219
|
+
* 1. 先检查工作目录下是否有配置文件,检查 path 是否匹配
|
|
220
|
+
* 2. 如果不匹配,向上查找父目录的配置文件,检查 path 是否匹配
|
|
221
|
+
* 3. 找到匹配的配置 → 使用该配置
|
|
222
|
+
* 4. 所有层级都没有匹配的配置 → 使用最后一个找到的配置(或在工作目录创建)
|
|
223
|
+
*
|
|
224
|
+
* 例如:工作目录 D:\a\b\c\d,相对路径 vibe-coding/my.yml
|
|
225
|
+
* 第1次查找:D:\a\b\c\d\vibe-coding\my.yml,匹配 path="."
|
|
226
|
+
* 第2次查找:D:\a\b\c\vibe-coding\my.yml,匹配 path="d"
|
|
227
|
+
* 第3次查找:D:\a\b\vibe-coding\my.yml,匹配 path="c/d"
|
|
228
|
+
* ...
|
|
229
|
+
*/
|
|
230
|
+
export async function loadYmlWithUpwardSearch(workspacePath, relativePath) {
|
|
231
|
+
const normalizedWorkspace = path.resolve(workspacePath);
|
|
232
|
+
const normalizedRelative = relativePath.replace(/\//g, path.sep);
|
|
233
|
+
const absoluteInitialPath = path.resolve(normalizedWorkspace, normalizedRelative);
|
|
234
|
+
// 记录最后一次找到的配置文件(用于所有层级都不匹配时回退)
|
|
235
|
+
let lastFoundConfig = null;
|
|
236
|
+
// 首先尝试从工作目录读取
|
|
237
|
+
try {
|
|
238
|
+
const content = await fs.readFile(absoluteInitialPath, 'utf-8');
|
|
239
|
+
log.debug(`工作目录下找到配置: ${absoluteInitialPath}`);
|
|
240
|
+
// 当前目录的配置文件,工作目录相对于自己的相对路径是 "."
|
|
241
|
+
const workspaceRelativeToSelf = '.';
|
|
242
|
+
const matchedPath = hasMatchingAgentPath(content, workspaceRelativeToSelf);
|
|
243
|
+
if (matchedPath) {
|
|
244
|
+
// 找到匹配的 path,直接使用
|
|
245
|
+
log.debug(`当前目录配置匹配 path: ${matchedPath}`);
|
|
246
|
+
return { content, resolvedPath: absoluteInitialPath, foundInParent: false, matchedAgentPath: matchedPath };
|
|
247
|
+
}
|
|
248
|
+
// 当前目录配置不匹配,记录下来继续向上查找
|
|
249
|
+
log.debug(`当前目录配置不匹配,继续向上查找`);
|
|
250
|
+
lastFoundConfig = { content, resolvedPath: absoluteInitialPath };
|
|
251
|
+
}
|
|
252
|
+
catch (err) {
|
|
253
|
+
const error = err;
|
|
254
|
+
if (error?.code !== 'ENOENT') {
|
|
255
|
+
throw err;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
// 从工作目录的父目录开始向上查找
|
|
259
|
+
let currentDir = normalizedWorkspace;
|
|
260
|
+
const root = path.parse(currentDir).root;
|
|
261
|
+
while (currentDir && currentDir !== root) {
|
|
262
|
+
const parentDir = path.dirname(currentDir);
|
|
263
|
+
if (parentDir === currentDir) {
|
|
264
|
+
break; // 已到达根目录
|
|
265
|
+
}
|
|
266
|
+
// 计算工作目录相对于父目录的相对路径(即 agent 的 path 字段值)
|
|
267
|
+
const workspaceRelativeToParent = path.relative(parentDir, normalizedWorkspace);
|
|
268
|
+
const candidatePath = path.join(parentDir, normalizedRelative);
|
|
269
|
+
try {
|
|
270
|
+
const content = await fs.readFile(candidatePath, 'utf-8');
|
|
271
|
+
log.debug(`上层找到配置文件: ${candidatePath}`);
|
|
272
|
+
// 检查是否有匹配的 agent path
|
|
273
|
+
const matchedPath = hasMatchingAgentPath(content, workspaceRelativeToParent);
|
|
274
|
+
log.debug(`相对路径: ${workspaceRelativeToParent}, 匹配的agent path: ${matchedPath || '无'}`);
|
|
275
|
+
if (matchedPath) {
|
|
276
|
+
// 找到匹配的配置,返回
|
|
277
|
+
return {
|
|
278
|
+
content,
|
|
279
|
+
resolvedPath: candidatePath,
|
|
280
|
+
foundInParent: true,
|
|
281
|
+
matchedAgentPath: matchedPath,
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
// 不匹配,记录下来继续向上查找
|
|
285
|
+
lastFoundConfig = { content, resolvedPath: candidatePath };
|
|
286
|
+
}
|
|
287
|
+
catch (err) {
|
|
288
|
+
const error = err;
|
|
289
|
+
if (error?.code !== 'ENOENT') {
|
|
290
|
+
throw err;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
currentDir = parentDir;
|
|
294
|
+
}
|
|
295
|
+
// 所有层级都没有找到匹配的配置
|
|
296
|
+
if (lastFoundConfig) {
|
|
297
|
+
// 使用最后一个找到的配置文件(需要入驻)
|
|
298
|
+
log.debug(`所有层级都不匹配,使用最后找到的配置: ${lastFoundConfig.resolvedPath}`);
|
|
299
|
+
return {
|
|
300
|
+
content: lastFoundConfig.content,
|
|
301
|
+
resolvedPath: lastFoundConfig.resolvedPath,
|
|
302
|
+
foundInParent: lastFoundConfig.resolvedPath !== absoluteInitialPath,
|
|
303
|
+
matchedAgentPath: null,
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
// 完全没有配置文件,将在工作目录下创建
|
|
307
|
+
log.debug(`未找到配置,将在工作目录创建: ${absoluteInitialPath}`);
|
|
308
|
+
return { content: null, resolvedPath: absoluteInitialPath, foundInParent: false, matchedAgentPath: null };
|
|
309
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"yaml-utils.test.d.ts","sourceRoot":"","sources":["../../src/utils/yaml-utils.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { promises as fs } from 'node:fs';
|
|
4
|
+
import os from 'node:os';
|
|
5
|
+
import { hasMatchingAgentPath, extractAgentConfigOrTemplate, generateEmptyTemplate, autoFillPathInYml, loadYmlWithUpwardSearch, } from './yaml-utils.js';
|
|
6
|
+
describe('yaml-utils', () => {
|
|
7
|
+
describe('hasMatchingAgentPath', () => {
|
|
8
|
+
it('should return null for invalid YAML content', () => {
|
|
9
|
+
expect(hasMatchingAgentPath('invalid yaml [[', 'test')).toBeNull();
|
|
10
|
+
});
|
|
11
|
+
it('should return null for empty content', () => {
|
|
12
|
+
expect(hasMatchingAgentPath('', 'test')).toBeNull();
|
|
13
|
+
});
|
|
14
|
+
it('should return null when no agent key exists', () => {
|
|
15
|
+
const yaml = `
|
|
16
|
+
other:
|
|
17
|
+
- name: test
|
|
18
|
+
`;
|
|
19
|
+
expect(hasMatchingAgentPath(yaml, 'test')).toBeNull();
|
|
20
|
+
});
|
|
21
|
+
it('should return null when agent is not an array', () => {
|
|
22
|
+
const yaml = `
|
|
23
|
+
agent:
|
|
24
|
+
name: single
|
|
25
|
+
`;
|
|
26
|
+
expect(hasMatchingAgentPath(yaml, 'test')).toBeNull();
|
|
27
|
+
});
|
|
28
|
+
it('should return null when agent has no path', () => {
|
|
29
|
+
const yaml = `
|
|
30
|
+
agent:
|
|
31
|
+
- name: test
|
|
32
|
+
description: no path
|
|
33
|
+
`;
|
|
34
|
+
expect(hasMatchingAgentPath(yaml, 'test')).toBeNull();
|
|
35
|
+
});
|
|
36
|
+
it('should match exact path', () => {
|
|
37
|
+
const yaml = `
|
|
38
|
+
agent:
|
|
39
|
+
- name: test
|
|
40
|
+
path: src/modules
|
|
41
|
+
`;
|
|
42
|
+
expect(hasMatchingAgentPath(yaml, 'src/modules')).toBe('src/modules');
|
|
43
|
+
});
|
|
44
|
+
it('should match path with different separators (backslash)', () => {
|
|
45
|
+
const yaml = `
|
|
46
|
+
agent:
|
|
47
|
+
- name: test
|
|
48
|
+
path: src/modules
|
|
49
|
+
`;
|
|
50
|
+
expect(hasMatchingAgentPath(yaml, 'src\\modules')).toBe('src/modules');
|
|
51
|
+
});
|
|
52
|
+
it('should match path with forward slash when yaml has backslash', () => {
|
|
53
|
+
const yaml = `
|
|
54
|
+
agent:
|
|
55
|
+
- name: test
|
|
56
|
+
path: src\\modules
|
|
57
|
+
`;
|
|
58
|
+
expect(hasMatchingAgentPath(yaml, 'src/modules')).toBe('src\\modules');
|
|
59
|
+
});
|
|
60
|
+
it('should match current directory "." path', () => {
|
|
61
|
+
const yaml = `
|
|
62
|
+
agent:
|
|
63
|
+
- name: test
|
|
64
|
+
path: .
|
|
65
|
+
`;
|
|
66
|
+
expect(hasMatchingAgentPath(yaml, '.')).toBe('.');
|
|
67
|
+
});
|
|
68
|
+
it('should match empty path when target is "."', () => {
|
|
69
|
+
const yaml = `
|
|
70
|
+
agent:
|
|
71
|
+
- name: test
|
|
72
|
+
path: ''
|
|
73
|
+
`;
|
|
74
|
+
expect(hasMatchingAgentPath(yaml, '.')).toBe('');
|
|
75
|
+
});
|
|
76
|
+
it('should return null when no matching path found', () => {
|
|
77
|
+
const yaml = `
|
|
78
|
+
agent:
|
|
79
|
+
- name: test
|
|
80
|
+
path: other/path
|
|
81
|
+
`;
|
|
82
|
+
expect(hasMatchingAgentPath(yaml, 'different/path')).toBeNull();
|
|
83
|
+
});
|
|
84
|
+
it('should return first matching path from multiple agents', () => {
|
|
85
|
+
const yaml = `
|
|
86
|
+
agent:
|
|
87
|
+
- name: first
|
|
88
|
+
path: first/path
|
|
89
|
+
- name: second
|
|
90
|
+
path: second/path
|
|
91
|
+
`;
|
|
92
|
+
expect(hasMatchingAgentPath(yaml, 'first/path')).toBe('first/path');
|
|
93
|
+
expect(hasMatchingAgentPath(yaml, 'second/path')).toBe('second/path');
|
|
94
|
+
});
|
|
95
|
+
it('should handle complex YAML with nested objects', () => {
|
|
96
|
+
const yaml = `
|
|
97
|
+
agent:
|
|
98
|
+
- name: complex
|
|
99
|
+
path: complex/path
|
|
100
|
+
project: my-project
|
|
101
|
+
prompt: |
|
|
102
|
+
This is a multi-line
|
|
103
|
+
prompt
|
|
104
|
+
`;
|
|
105
|
+
expect(hasMatchingAgentPath(yaml, 'complex/path')).toBe('complex/path');
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
describe('extractAgentConfigOrTemplate', () => {
|
|
109
|
+
it('should return original content for invalid YAML', () => {
|
|
110
|
+
const invalidYaml = 'invalid: [[[';
|
|
111
|
+
const result = extractAgentConfigOrTemplate(invalidYaml, 'test');
|
|
112
|
+
expect(result.content).toBe(invalidYaml);
|
|
113
|
+
expect(result.isTemplate).toBe(false);
|
|
114
|
+
});
|
|
115
|
+
it('should return matching agent config', () => {
|
|
116
|
+
const yaml = `
|
|
117
|
+
agent:
|
|
118
|
+
- name: my-agent
|
|
119
|
+
path: src/modules
|
|
120
|
+
project: my-project
|
|
121
|
+
prompt: test prompt
|
|
122
|
+
`;
|
|
123
|
+
const result = extractAgentConfigOrTemplate(yaml, 'src/modules');
|
|
124
|
+
expect(result.isTemplate).toBe(false);
|
|
125
|
+
expect(result.content).toContain('my-agent');
|
|
126
|
+
expect(result.content).toContain('src/modules');
|
|
127
|
+
expect(result.content).toContain('my-project');
|
|
128
|
+
});
|
|
129
|
+
it('should generate template when no matching agent found', () => {
|
|
130
|
+
const yaml = `
|
|
131
|
+
agent:
|
|
132
|
+
- name: other-agent
|
|
133
|
+
path: other/path
|
|
134
|
+
project: existing-project
|
|
135
|
+
`;
|
|
136
|
+
const result = extractAgentConfigOrTemplate(yaml, 'new/path');
|
|
137
|
+
expect(result.isTemplate).toBe(true);
|
|
138
|
+
expect(result.projectFromSibling).toBe('existing-project');
|
|
139
|
+
expect(result.content).toContain('new/path');
|
|
140
|
+
});
|
|
141
|
+
it('should generate template with empty project when no agents have project', () => {
|
|
142
|
+
const yaml = `
|
|
143
|
+
agent:
|
|
144
|
+
- name: agent1
|
|
145
|
+
path: path1
|
|
146
|
+
`;
|
|
147
|
+
const result = extractAgentConfigOrTemplate(yaml, 'new/path');
|
|
148
|
+
expect(result.isTemplate).toBe(true);
|
|
149
|
+
expect(result.projectFromSibling).toBeNull();
|
|
150
|
+
expect(result.content).toContain('project: ""');
|
|
151
|
+
});
|
|
152
|
+
it('should match current directory "." path', () => {
|
|
153
|
+
const yaml = `
|
|
154
|
+
agent:
|
|
155
|
+
- name: root-agent
|
|
156
|
+
path: .
|
|
157
|
+
project: root-project
|
|
158
|
+
`;
|
|
159
|
+
const result = extractAgentConfigOrTemplate(yaml, '.');
|
|
160
|
+
expect(result.isTemplate).toBe(false);
|
|
161
|
+
expect(result.content).toContain('root-agent');
|
|
162
|
+
});
|
|
163
|
+
it('should normalize path separators in output', () => {
|
|
164
|
+
const yaml = `
|
|
165
|
+
agent:
|
|
166
|
+
- name: test
|
|
167
|
+
path: src\\modules
|
|
168
|
+
`;
|
|
169
|
+
const result = extractAgentConfigOrTemplate(yaml, 'src/modules');
|
|
170
|
+
expect(result.isTemplate).toBe(false);
|
|
171
|
+
expect(result.content).toContain('src/modules');
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
describe('generateEmptyTemplate', () => {
|
|
175
|
+
it('should generate valid YAML with empty agent', () => {
|
|
176
|
+
const template = generateEmptyTemplate('any/path');
|
|
177
|
+
expect(template).toContain('agent:');
|
|
178
|
+
expect(template).toContain('name: ""');
|
|
179
|
+
expect(template).toContain('path: ""'); // path is intentionally empty
|
|
180
|
+
expect(template).toContain('project: ""');
|
|
181
|
+
});
|
|
182
|
+
it('should generate consistent output regardless of input path', () => {
|
|
183
|
+
const template1 = generateEmptyTemplate('path1');
|
|
184
|
+
const template2 = generateEmptyTemplate('path2');
|
|
185
|
+
// path is always empty in generated template
|
|
186
|
+
expect(template1).toBe(template2);
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
describe('autoFillPathInYml', () => {
|
|
190
|
+
it('should return original content for invalid YAML', () => {
|
|
191
|
+
const invalidYaml = 'invalid: [[[';
|
|
192
|
+
expect(autoFillPathInYml(invalidYaml, 'test/path')).toBe(invalidYaml);
|
|
193
|
+
});
|
|
194
|
+
it('should return original content when no agent key', () => {
|
|
195
|
+
const yaml = `
|
|
196
|
+
other:
|
|
197
|
+
- name: test
|
|
198
|
+
`;
|
|
199
|
+
expect(autoFillPathInYml(yaml, 'test/path')).toBe(yaml);
|
|
200
|
+
});
|
|
201
|
+
it('should fill empty path', () => {
|
|
202
|
+
const yaml = `
|
|
203
|
+
agent:
|
|
204
|
+
- name: test
|
|
205
|
+
path: ''
|
|
206
|
+
project: my-project
|
|
207
|
+
`;
|
|
208
|
+
const result = autoFillPathInYml(yaml, 'new/path');
|
|
209
|
+
expect(result).toContain('new/path');
|
|
210
|
+
expect(result).not.toContain("path: ''");
|
|
211
|
+
});
|
|
212
|
+
it('should fill undefined path', () => {
|
|
213
|
+
const yaml = `
|
|
214
|
+
agent:
|
|
215
|
+
- name: test
|
|
216
|
+
project: my-project
|
|
217
|
+
`;
|
|
218
|
+
const result = autoFillPathInYml(yaml, 'new/path');
|
|
219
|
+
expect(result).toContain('new/path');
|
|
220
|
+
});
|
|
221
|
+
it('should fill null path', () => {
|
|
222
|
+
const yaml = `
|
|
223
|
+
agent:
|
|
224
|
+
- name: test
|
|
225
|
+
path: null
|
|
226
|
+
`;
|
|
227
|
+
const result = autoFillPathInYml(yaml, 'new/path');
|
|
228
|
+
expect(result).toContain('new/path');
|
|
229
|
+
});
|
|
230
|
+
it('should fill whitespace-only path', () => {
|
|
231
|
+
const yaml = `
|
|
232
|
+
agent:
|
|
233
|
+
- name: test
|
|
234
|
+
path: ' '
|
|
235
|
+
`;
|
|
236
|
+
const result = autoFillPathInYml(yaml, 'new/path');
|
|
237
|
+
expect(result).toContain('new/path');
|
|
238
|
+
});
|
|
239
|
+
it('should not modify existing non-empty path', () => {
|
|
240
|
+
const yaml = `
|
|
241
|
+
agent:
|
|
242
|
+
- name: test
|
|
243
|
+
path: existing/path
|
|
244
|
+
`;
|
|
245
|
+
const result = autoFillPathInYml(yaml, 'new/path');
|
|
246
|
+
expect(result).toContain('existing/path');
|
|
247
|
+
expect(result).not.toContain('new/path');
|
|
248
|
+
});
|
|
249
|
+
it('should handle multiple agents', () => {
|
|
250
|
+
const yaml = `
|
|
251
|
+
agent:
|
|
252
|
+
- name: agent1
|
|
253
|
+
path: ''
|
|
254
|
+
- name: agent2
|
|
255
|
+
path: existing/path
|
|
256
|
+
- name: agent3
|
|
257
|
+
`;
|
|
258
|
+
const result = autoFillPathInYml(yaml, 'new/path');
|
|
259
|
+
// agent1 should have path filled
|
|
260
|
+
expect(result).toContain('new/path');
|
|
261
|
+
});
|
|
262
|
+
it('should return original content when no modification needed', () => {
|
|
263
|
+
const yaml = `
|
|
264
|
+
agent:
|
|
265
|
+
- name: test
|
|
266
|
+
path: existing/path
|
|
267
|
+
`;
|
|
268
|
+
const result = autoFillPathInYml(yaml, 'new/path');
|
|
269
|
+
expect(result).toBe(yaml);
|
|
270
|
+
});
|
|
271
|
+
});
|
|
272
|
+
describe('loadYmlWithUpwardSearch', () => {
|
|
273
|
+
const tempRoot = path.join(os.tmpdir(), `aws-yaml-test-${Date.now()}`);
|
|
274
|
+
const workspacePath = path.join(tempRoot, 'project', 'module', 'src');
|
|
275
|
+
const relativePath = 'vibe-coding/my.yml';
|
|
276
|
+
beforeEach(async () => {
|
|
277
|
+
// 创建目录结构
|
|
278
|
+
await fs.mkdir(workspacePath, { recursive: true });
|
|
279
|
+
await fs.mkdir(path.join(tempRoot, 'project', 'module', relativePath.split('/')[0]), {
|
|
280
|
+
recursive: true,
|
|
281
|
+
});
|
|
282
|
+
await fs.mkdir(path.join(tempRoot, 'project', relativePath.split('/')[0]), {
|
|
283
|
+
recursive: true,
|
|
284
|
+
});
|
|
285
|
+
await fs.mkdir(path.join(tempRoot, relativePath.split('/')[0]), { recursive: true });
|
|
286
|
+
});
|
|
287
|
+
afterEach(async () => {
|
|
288
|
+
await fs.rm(tempRoot, { recursive: true, force: true });
|
|
289
|
+
});
|
|
290
|
+
it('should return null content when no config file exists', async () => {
|
|
291
|
+
const result = await loadYmlWithUpwardSearch(workspacePath, relativePath);
|
|
292
|
+
expect(result.content).toBeNull();
|
|
293
|
+
expect(result.foundInParent).toBe(false);
|
|
294
|
+
expect(result.matchedAgentPath).toBeNull();
|
|
295
|
+
});
|
|
296
|
+
it('should load config from workspace directory with matching path "."', async () => {
|
|
297
|
+
const configPath = path.join(workspacePath, relativePath);
|
|
298
|
+
await fs.mkdir(path.dirname(configPath), { recursive: true });
|
|
299
|
+
await fs.writeFile(configPath, `
|
|
300
|
+
agent:
|
|
301
|
+
- name: local-agent
|
|
302
|
+
path: .
|
|
303
|
+
project: local-project
|
|
304
|
+
`, 'utf-8');
|
|
305
|
+
const result = await loadYmlWithUpwardSearch(workspacePath, relativePath);
|
|
306
|
+
expect(result.content).not.toBeNull();
|
|
307
|
+
expect(result.content).toContain('local-agent');
|
|
308
|
+
expect(result.foundInParent).toBe(false);
|
|
309
|
+
expect(result.matchedAgentPath).toBe('.');
|
|
310
|
+
});
|
|
311
|
+
it('should find matching config in parent directory', async () => {
|
|
312
|
+
// 在 project/module 目录创建配置,匹配 src 路径
|
|
313
|
+
const parentConfigPath = path.join(tempRoot, 'project', 'module', relativePath);
|
|
314
|
+
await fs.mkdir(path.dirname(parentConfigPath), { recursive: true });
|
|
315
|
+
await fs.writeFile(parentConfigPath, `
|
|
316
|
+
agent:
|
|
317
|
+
- name: module-agent
|
|
318
|
+
path: src
|
|
319
|
+
project: module-project
|
|
320
|
+
`, 'utf-8');
|
|
321
|
+
const result = await loadYmlWithUpwardSearch(workspacePath, relativePath);
|
|
322
|
+
expect(result.content).not.toBeNull();
|
|
323
|
+
expect(result.content).toContain('module-agent');
|
|
324
|
+
expect(result.foundInParent).toBe(true);
|
|
325
|
+
expect(result.matchedAgentPath).toBe('src');
|
|
326
|
+
});
|
|
327
|
+
it('should use last found config when no matching path', async () => {
|
|
328
|
+
// 在 project/module 目录创建配置,但不匹配 src 路径
|
|
329
|
+
const parentConfigPath = path.join(tempRoot, 'project', 'module', relativePath);
|
|
330
|
+
await fs.mkdir(path.dirname(parentConfigPath), { recursive: true });
|
|
331
|
+
await fs.writeFile(parentConfigPath, `
|
|
332
|
+
agent:
|
|
333
|
+
- name: other-agent
|
|
334
|
+
path: other/path
|
|
335
|
+
`, 'utf-8');
|
|
336
|
+
const result = await loadYmlWithUpwardSearch(workspacePath, relativePath);
|
|
337
|
+
expect(result.content).not.toBeNull();
|
|
338
|
+
expect(result.content).toContain('other-agent');
|
|
339
|
+
expect(result.matchedAgentPath).toBeNull();
|
|
340
|
+
});
|
|
341
|
+
it('should prioritize closer matching config', async () => {
|
|
342
|
+
// 在 workspace 目录创建匹配的配置
|
|
343
|
+
const localConfigPath = path.join(workspacePath, relativePath);
|
|
344
|
+
await fs.mkdir(path.dirname(localConfigPath), { recursive: true });
|
|
345
|
+
await fs.writeFile(localConfigPath, `
|
|
346
|
+
agent:
|
|
347
|
+
- name: local-agent
|
|
348
|
+
path: .
|
|
349
|
+
`, 'utf-8');
|
|
350
|
+
// 在 parent 目录也创建配置
|
|
351
|
+
const parentConfigPath = path.join(tempRoot, 'project', 'module', relativePath);
|
|
352
|
+
await fs.writeFile(parentConfigPath, `
|
|
353
|
+
agent:
|
|
354
|
+
- name: parent-agent
|
|
355
|
+
path: src
|
|
356
|
+
`, 'utf-8');
|
|
357
|
+
const result = await loadYmlWithUpwardSearch(workspacePath, relativePath);
|
|
358
|
+
// 应该使用 local 的配置,因为更近且匹配
|
|
359
|
+
expect(result.content).toContain('local-agent');
|
|
360
|
+
expect(result.foundInParent).toBe(false);
|
|
361
|
+
});
|
|
362
|
+
});
|
|
363
|
+
});
|