@mycelish/cli 0.1.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/LICENSE +21 -0
- package/dist/__tests__/init-auto.test.d.ts +2 -0
- package/dist/__tests__/init-auto.test.d.ts.map +1 -0
- package/dist/__tests__/init-auto.test.js +60 -0
- package/dist/__tests__/init-auto.test.js.map +1 -0
- package/dist/commands/add.d.ts +20 -0
- package/dist/commands/add.d.ts.map +1 -0
- package/dist/commands/add.js +99 -0
- package/dist/commands/add.js.map +1 -0
- package/dist/commands/add.test.d.ts +25 -0
- package/dist/commands/add.test.d.ts.map +1 -0
- package/dist/commands/add.test.js +574 -0
- package/dist/commands/add.test.js.map +1 -0
- package/dist/commands/disable.d.ts +33 -0
- package/dist/commands/disable.d.ts.map +1 -0
- package/dist/commands/disable.js +201 -0
- package/dist/commands/disable.js.map +1 -0
- package/dist/commands/disable.test.d.ts +6 -0
- package/dist/commands/disable.test.d.ts.map +1 -0
- package/dist/commands/disable.test.js +290 -0
- package/dist/commands/disable.test.js.map +1 -0
- package/dist/commands/doctor.d.ts +11 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +33 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/doctor.test.d.ts +17 -0
- package/dist/commands/doctor.test.d.ts.map +1 -0
- package/dist/commands/doctor.test.js +691 -0
- package/dist/commands/doctor.test.js.map +1 -0
- package/dist/commands/enable.d.ts +33 -0
- package/dist/commands/enable.d.ts.map +1 -0
- package/dist/commands/enable.js +199 -0
- package/dist/commands/enable.js.map +1 -0
- package/dist/commands/enable.test.d.ts +6 -0
- package/dist/commands/enable.test.d.ts.map +1 -0
- package/dist/commands/enable.test.js +301 -0
- package/dist/commands/enable.test.js.map +1 -0
- package/dist/commands/health-checks/config-check.d.ts +34 -0
- package/dist/commands/health-checks/config-check.d.ts.map +1 -0
- package/dist/commands/health-checks/config-check.js +267 -0
- package/dist/commands/health-checks/config-check.js.map +1 -0
- package/dist/commands/health-checks/formatter.d.ts +13 -0
- package/dist/commands/health-checks/formatter.d.ts.map +1 -0
- package/dist/commands/health-checks/formatter.js +72 -0
- package/dist/commands/health-checks/formatter.js.map +1 -0
- package/dist/commands/health-checks/index.d.ts +8 -0
- package/dist/commands/health-checks/index.d.ts.map +1 -0
- package/dist/commands/health-checks/index.js +7 -0
- package/dist/commands/health-checks/index.js.map +1 -0
- package/dist/commands/health-checks/mcp-check.d.ts +9 -0
- package/dist/commands/health-checks/mcp-check.d.ts.map +1 -0
- package/dist/commands/health-checks/mcp-check.js +37 -0
- package/dist/commands/health-checks/mcp-check.js.map +1 -0
- package/dist/commands/health-checks/memory-check.d.ts +15 -0
- package/dist/commands/health-checks/memory-check.d.ts.map +1 -0
- package/dist/commands/health-checks/memory-check.js +92 -0
- package/dist/commands/health-checks/memory-check.js.map +1 -0
- package/dist/commands/health-checks/runner.d.ts +9 -0
- package/dist/commands/health-checks/runner.d.ts.map +1 -0
- package/dist/commands/health-checks/runner.js +74 -0
- package/dist/commands/health-checks/runner.js.map +1 -0
- package/dist/commands/health-checks/tool-version-check.d.ts +9 -0
- package/dist/commands/health-checks/tool-version-check.d.ts.map +1 -0
- package/dist/commands/health-checks/tool-version-check.js +35 -0
- package/dist/commands/health-checks/tool-version-check.js.map +1 -0
- package/dist/commands/health-checks/types.d.ts +16 -0
- package/dist/commands/health-checks/types.d.ts.map +1 -0
- package/dist/commands/health-checks/types.js +2 -0
- package/dist/commands/health-checks/types.js.map +1 -0
- package/dist/commands/init.d.ts +120 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +436 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/init.test.d.ts +16 -0
- package/dist/commands/init.test.d.ts.map +1 -0
- package/dist/commands/init.test.js +286 -0
- package/dist/commands/init.test.js.map +1 -0
- package/dist/commands/marketplace.d.ts +13 -0
- package/dist/commands/marketplace.d.ts.map +1 -0
- package/dist/commands/marketplace.js +85 -0
- package/dist/commands/marketplace.js.map +1 -0
- package/dist/commands/marketplace.test.d.ts +2 -0
- package/dist/commands/marketplace.test.d.ts.map +1 -0
- package/dist/commands/marketplace.test.js +78 -0
- package/dist/commands/marketplace.test.js.map +1 -0
- package/dist/commands/migrate.d.ts +15 -0
- package/dist/commands/migrate.d.ts.map +1 -0
- package/dist/commands/migrate.js +179 -0
- package/dist/commands/migrate.js.map +1 -0
- package/dist/commands/migrate.test.d.ts +2 -0
- package/dist/commands/migrate.test.d.ts.map +1 -0
- package/dist/commands/migrate.test.js +109 -0
- package/dist/commands/migrate.test.js.map +1 -0
- package/dist/commands/preset.d.ts +11 -0
- package/dist/commands/preset.d.ts.map +1 -0
- package/dist/commands/preset.js +99 -0
- package/dist/commands/preset.js.map +1 -0
- package/dist/commands/preset.test.d.ts +2 -0
- package/dist/commands/preset.test.d.ts.map +1 -0
- package/dist/commands/preset.test.js +106 -0
- package/dist/commands/preset.test.js.map +1 -0
- package/dist/commands/remote.d.ts +9 -0
- package/dist/commands/remote.d.ts.map +1 -0
- package/dist/commands/remote.js +212 -0
- package/dist/commands/remote.js.map +1 -0
- package/dist/commands/remote.test.d.ts +2 -0
- package/dist/commands/remote.test.d.ts.map +1 -0
- package/dist/commands/remote.test.js +125 -0
- package/dist/commands/remote.test.js.map +1 -0
- package/dist/commands/remove.d.ts +34 -0
- package/dist/commands/remove.d.ts.map +1 -0
- package/dist/commands/remove.js +296 -0
- package/dist/commands/remove.js.map +1 -0
- package/dist/commands/remove.test.d.ts +2 -0
- package/dist/commands/remove.test.d.ts.map +1 -0
- package/dist/commands/remove.test.js +109 -0
- package/dist/commands/remove.test.js.map +1 -0
- package/dist/commands/serve.d.ts +3 -0
- package/dist/commands/serve.d.ts.map +1 -0
- package/dist/commands/serve.js +29 -0
- package/dist/commands/serve.js.map +1 -0
- package/dist/commands/serve.test.d.ts +2 -0
- package/dist/commands/serve.test.d.ts.map +1 -0
- package/dist/commands/serve.test.js +74 -0
- package/dist/commands/serve.test.js.map +1 -0
- package/dist/commands/status.d.ts +49 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +272 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/status.test.d.ts +11 -0
- package/dist/commands/status.test.d.ts.map +1 -0
- package/dist/commands/status.test.js +334 -0
- package/dist/commands/status.test.js.map +1 -0
- package/dist/commands/sync.d.ts +38 -0
- package/dist/commands/sync.d.ts.map +1 -0
- package/dist/commands/sync.js +286 -0
- package/dist/commands/sync.js.map +1 -0
- package/dist/commands/sync.test.d.ts +6 -0
- package/dist/commands/sync.test.d.ts.map +1 -0
- package/dist/commands/sync.test.js +341 -0
- package/dist/commands/sync.test.js.map +1 -0
- package/dist/commands/teams.d.ts +18 -0
- package/dist/commands/teams.d.ts.map +1 -0
- package/dist/commands/teams.js +68 -0
- package/dist/commands/teams.js.map +1 -0
- package/dist/commands/teams.test.d.ts +2 -0
- package/dist/commands/teams.test.d.ts.map +1 -0
- package/dist/commands/teams.test.js +94 -0
- package/dist/commands/teams.test.js.map +1 -0
- package/dist/core/adapter-base.d.ts +51 -0
- package/dist/core/adapter-base.d.ts.map +1 -0
- package/dist/core/adapter-base.js +89 -0
- package/dist/core/adapter-base.js.map +1 -0
- package/dist/core/add-helpers.d.ts +55 -0
- package/dist/core/add-helpers.d.ts.map +1 -0
- package/dist/core/add-helpers.js +273 -0
- package/dist/core/add-helpers.js.map +1 -0
- package/dist/core/agent-teams.d.ts +10 -0
- package/dist/core/agent-teams.d.ts.map +1 -0
- package/dist/core/agent-teams.js +40 -0
- package/dist/core/agent-teams.js.map +1 -0
- package/dist/core/agent-teams.test.d.ts +2 -0
- package/dist/core/agent-teams.test.d.ts.map +1 -0
- package/dist/core/agent-teams.test.js +64 -0
- package/dist/core/agent-teams.test.js.map +1 -0
- package/dist/core/auto-adapter.d.ts +27 -0
- package/dist/core/auto-adapter.d.ts.map +1 -0
- package/dist/core/auto-adapter.js +324 -0
- package/dist/core/auto-adapter.js.map +1 -0
- package/dist/core/auto-adapter.test.d.ts +2 -0
- package/dist/core/auto-adapter.test.d.ts.map +1 -0
- package/dist/core/auto-adapter.test.js +125 -0
- package/dist/core/auto-adapter.test.js.map +1 -0
- package/dist/core/config-merger.d.ts +33 -0
- package/dist/core/config-merger.d.ts.map +1 -0
- package/dist/core/config-merger.js +238 -0
- package/dist/core/config-merger.js.map +1 -0
- package/dist/core/config-merger.test.d.ts +10 -0
- package/dist/core/config-merger.test.d.ts.map +1 -0
- package/dist/core/config-merger.test.js +406 -0
- package/dist/core/config-merger.test.js.map +1 -0
- package/dist/core/conflict-detector.d.ts +23 -0
- package/dist/core/conflict-detector.d.ts.map +1 -0
- package/dist/core/conflict-detector.js +58 -0
- package/dist/core/conflict-detector.js.map +1 -0
- package/dist/core/conflict-detector.test.d.ts +2 -0
- package/dist/core/conflict-detector.test.d.ts.map +1 -0
- package/dist/core/conflict-detector.test.js +40 -0
- package/dist/core/conflict-detector.test.js.map +1 -0
- package/dist/core/env-template.d.ts +22 -0
- package/dist/core/env-template.d.ts.map +1 -0
- package/dist/core/env-template.js +125 -0
- package/dist/core/env-template.js.map +1 -0
- package/dist/core/env-template.test.d.ts +2 -0
- package/dist/core/env-template.test.d.ts.map +1 -0
- package/dist/core/env-template.test.js +145 -0
- package/dist/core/env-template.test.js.map +1 -0
- package/dist/core/fs-helpers.d.ts +8 -0
- package/dist/core/fs-helpers.d.ts.map +1 -0
- package/dist/core/fs-helpers.js +26 -0
- package/dist/core/fs-helpers.js.map +1 -0
- package/dist/core/fs-helpers.test.d.ts +2 -0
- package/dist/core/fs-helpers.test.d.ts.map +1 -0
- package/dist/core/fs-helpers.test.js +51 -0
- package/dist/core/fs-helpers.test.js.map +1 -0
- package/dist/core/machine-overrides.d.ts +13 -0
- package/dist/core/machine-overrides.d.ts.map +1 -0
- package/dist/core/machine-overrides.js +155 -0
- package/dist/core/machine-overrides.js.map +1 -0
- package/dist/core/machine-overrides.test.d.ts +2 -0
- package/dist/core/machine-overrides.test.d.ts.map +1 -0
- package/dist/core/machine-overrides.test.js +160 -0
- package/dist/core/machine-overrides.test.js.map +1 -0
- package/dist/core/marketplace-registry.d.ts +14 -0
- package/dist/core/marketplace-registry.d.ts.map +1 -0
- package/dist/core/marketplace-registry.js +215 -0
- package/dist/core/marketplace-registry.js.map +1 -0
- package/dist/core/marketplace-registry.test.d.ts +2 -0
- package/dist/core/marketplace-registry.test.d.ts.map +1 -0
- package/dist/core/marketplace-registry.test.js +232 -0
- package/dist/core/marketplace-registry.test.js.map +1 -0
- package/dist/core/marketplace-sources.d.ts +39 -0
- package/dist/core/marketplace-sources.d.ts.map +1 -0
- package/dist/core/marketplace-sources.js +199 -0
- package/dist/core/marketplace-sources.js.map +1 -0
- package/dist/core/marketplace.d.ts +18 -0
- package/dist/core/marketplace.d.ts.map +1 -0
- package/dist/core/marketplace.js +211 -0
- package/dist/core/marketplace.js.map +1 -0
- package/dist/core/marketplace.test.d.ts +2 -0
- package/dist/core/marketplace.test.d.ts.map +1 -0
- package/dist/core/marketplace.test.js +177 -0
- package/dist/core/marketplace.test.js.map +1 -0
- package/dist/core/mcp-injector.d.ts +43 -0
- package/dist/core/mcp-injector.d.ts.map +1 -0
- package/dist/core/mcp-injector.js +164 -0
- package/dist/core/mcp-injector.js.map +1 -0
- package/dist/core/mcp-injector.test.d.ts +6 -0
- package/dist/core/mcp-injector.test.d.ts.map +1 -0
- package/dist/core/mcp-injector.test.js +315 -0
- package/dist/core/mcp-injector.test.js.map +1 -0
- package/dist/core/mcp-registry.d.ts +17 -0
- package/dist/core/mcp-registry.d.ts.map +1 -0
- package/dist/core/mcp-registry.js +52 -0
- package/dist/core/mcp-registry.js.map +1 -0
- package/dist/core/mcp-registry.test.d.ts +2 -0
- package/dist/core/mcp-registry.test.d.ts.map +1 -0
- package/dist/core/mcp-registry.test.js +78 -0
- package/dist/core/mcp-registry.test.js.map +1 -0
- package/dist/core/mcp-router.d.ts +21 -0
- package/dist/core/mcp-router.d.ts.map +1 -0
- package/dist/core/mcp-router.js +67 -0
- package/dist/core/mcp-router.js.map +1 -0
- package/dist/core/mcp-router.test.d.ts +2 -0
- package/dist/core/mcp-router.test.d.ts.map +1 -0
- package/dist/core/mcp-router.test.js +40 -0
- package/dist/core/mcp-router.test.js.map +1 -0
- package/dist/core/memory-scoper.d.ts +43 -0
- package/dist/core/memory-scoper.d.ts.map +1 -0
- package/dist/core/memory-scoper.js +165 -0
- package/dist/core/memory-scoper.js.map +1 -0
- package/dist/core/memory-scoper.test.d.ts +6 -0
- package/dist/core/memory-scoper.test.d.ts.map +1 -0
- package/dist/core/memory-scoper.test.js +467 -0
- package/dist/core/memory-scoper.test.js.map +1 -0
- package/dist/core/migrator/executor.d.ts +9 -0
- package/dist/core/migrator/executor.d.ts.map +1 -0
- package/dist/core/migrator/executor.js +233 -0
- package/dist/core/migrator/executor.js.map +1 -0
- package/dist/core/migrator/index.d.ts +8 -0
- package/dist/core/migrator/index.d.ts.map +1 -0
- package/dist/core/migrator/index.js +12 -0
- package/dist/core/migrator/index.js.map +1 -0
- package/dist/core/migrator/manifest.d.ts +8 -0
- package/dist/core/migrator/manifest.d.ts.map +1 -0
- package/dist/core/migrator/manifest.js +83 -0
- package/dist/core/migrator/manifest.js.map +1 -0
- package/dist/core/migrator/planner.d.ts +6 -0
- package/dist/core/migrator/planner.d.ts.map +1 -0
- package/dist/core/migrator/planner.js +112 -0
- package/dist/core/migrator/planner.js.map +1 -0
- package/dist/core/migrator/scanners.d.ts +19 -0
- package/dist/core/migrator/scanners.d.ts.map +1 -0
- package/dist/core/migrator/scanners.js +612 -0
- package/dist/core/migrator/scanners.js.map +1 -0
- package/dist/core/migrator/scanners.test.d.ts +2 -0
- package/dist/core/migrator/scanners.test.d.ts.map +1 -0
- package/dist/core/migrator/scanners.test.js +257 -0
- package/dist/core/migrator/scanners.test.js.map +1 -0
- package/dist/core/migrator.test.d.ts +2 -0
- package/dist/core/migrator.test.d.ts.map +1 -0
- package/dist/core/migrator.test.js +451 -0
- package/dist/core/migrator.test.js.map +1 -0
- package/dist/core/plugin-scanner.d.ts +30 -0
- package/dist/core/plugin-scanner.d.ts.map +1 -0
- package/dist/core/plugin-scanner.js +174 -0
- package/dist/core/plugin-scanner.js.map +1 -0
- package/dist/core/plugin-scanner.test.d.ts +2 -0
- package/dist/core/plugin-scanner.test.d.ts.map +1 -0
- package/dist/core/plugin-scanner.test.js +279 -0
- package/dist/core/plugin-scanner.test.js.map +1 -0
- package/dist/core/presets.d.ts +55 -0
- package/dist/core/presets.d.ts.map +1 -0
- package/dist/core/presets.js +84 -0
- package/dist/core/presets.js.map +1 -0
- package/dist/core/presets.test.d.ts +2 -0
- package/dist/core/presets.test.d.ts.map +1 -0
- package/dist/core/presets.test.js +40 -0
- package/dist/core/presets.test.js.map +1 -0
- package/dist/core/skill-parser.d.ts +21 -0
- package/dist/core/skill-parser.d.ts.map +1 -0
- package/dist/core/skill-parser.js +53 -0
- package/dist/core/skill-parser.js.map +1 -0
- package/dist/core/skill-parser.test.d.ts +2 -0
- package/dist/core/skill-parser.test.d.ts.map +1 -0
- package/dist/core/skill-parser.test.js +83 -0
- package/dist/core/skill-parser.test.js.map +1 -0
- package/dist/core/smart-memory.d.ts +22 -0
- package/dist/core/smart-memory.d.ts.map +1 -0
- package/dist/core/smart-memory.js +72 -0
- package/dist/core/smart-memory.js.map +1 -0
- package/dist/core/smart-memory.test.d.ts +2 -0
- package/dist/core/smart-memory.test.d.ts.map +1 -0
- package/dist/core/smart-memory.test.js +114 -0
- package/dist/core/smart-memory.test.js.map +1 -0
- package/dist/core/snapshot.d.ts +6 -0
- package/dist/core/snapshot.d.ts.map +1 -0
- package/dist/core/snapshot.js +179 -0
- package/dist/core/snapshot.js.map +1 -0
- package/dist/core/snapshot.test.d.ts +2 -0
- package/dist/core/snapshot.test.d.ts.map +1 -0
- package/dist/core/snapshot.test.js +132 -0
- package/dist/core/snapshot.test.js.map +1 -0
- package/dist/core/symlink-manager.d.ts +78 -0
- package/dist/core/symlink-manager.d.ts.map +1 -0
- package/dist/core/symlink-manager.js +227 -0
- package/dist/core/symlink-manager.js.map +1 -0
- package/dist/core/symlink-manager.test.d.ts +8 -0
- package/dist/core/symlink-manager.test.d.ts.map +1 -0
- package/dist/core/symlink-manager.test.js +354 -0
- package/dist/core/symlink-manager.test.js.map +1 -0
- package/dist/core/sync-writer.d.ts +20 -0
- package/dist/core/sync-writer.d.ts.map +1 -0
- package/dist/core/sync-writer.js +150 -0
- package/dist/core/sync-writer.js.map +1 -0
- package/dist/core/sync-writer.test.d.ts +2 -0
- package/dist/core/sync-writer.test.d.ts.map +1 -0
- package/dist/core/sync-writer.test.js +134 -0
- package/dist/core/sync-writer.test.js.map +1 -0
- package/dist/core/toml-helpers.d.ts +9 -0
- package/dist/core/toml-helpers.d.ts.map +1 -0
- package/dist/core/toml-helpers.js +33 -0
- package/dist/core/toml-helpers.js.map +1 -0
- package/dist/core/tool-adapter.d.ts +24 -0
- package/dist/core/tool-adapter.d.ts.map +1 -0
- package/dist/core/tool-adapter.js +156 -0
- package/dist/core/tool-adapter.js.map +1 -0
- package/dist/core/tool-adapter.test.d.ts +2 -0
- package/dist/core/tool-adapter.test.d.ts.map +1 -0
- package/dist/core/tool-adapter.test.js +264 -0
- package/dist/core/tool-adapter.test.js.map +1 -0
- package/dist/core/tool-detector.d.ts +31 -0
- package/dist/core/tool-detector.d.ts.map +1 -0
- package/dist/core/tool-detector.js +67 -0
- package/dist/core/tool-detector.js.map +1 -0
- package/dist/core/tool-detector.test.d.ts +2 -0
- package/dist/core/tool-detector.test.d.ts.map +1 -0
- package/dist/core/tool-detector.test.js +126 -0
- package/dist/core/tool-detector.test.js.map +1 -0
- package/dist/core/watcher.d.ts +22 -0
- package/dist/core/watcher.d.ts.map +1 -0
- package/dist/core/watcher.js +68 -0
- package/dist/core/watcher.js.map +1 -0
- package/dist/core/watcher.test.d.ts +2 -0
- package/dist/core/watcher.test.d.ts.map +1 -0
- package/dist/core/watcher.test.js +26 -0
- package/dist/core/watcher.test.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +47 -0
- package/dist/index.js.map +1 -0
- package/dist/routes/async-handler.d.ts +6 -0
- package/dist/routes/async-handler.d.ts.map +1 -0
- package/dist/routes/async-handler.js +9 -0
- package/dist/routes/async-handler.js.map +1 -0
- package/dist/routes/marketplace.d.ts +3 -0
- package/dist/routes/marketplace.d.ts.map +1 -0
- package/dist/routes/marketplace.js +51 -0
- package/dist/routes/marketplace.js.map +1 -0
- package/dist/routes/migrate.d.ts +3 -0
- package/dist/routes/migrate.d.ts.map +1 -0
- package/dist/routes/migrate.js +22 -0
- package/dist/routes/migrate.js.map +1 -0
- package/dist/routes/plugin-map.d.ts +11 -0
- package/dist/routes/plugin-map.d.ts.map +1 -0
- package/dist/routes/plugin-map.js +37 -0
- package/dist/routes/plugin-map.js.map +1 -0
- package/dist/routes/plugins.d.ts +3 -0
- package/dist/routes/plugins.d.ts.map +1 -0
- package/dist/routes/plugins.js +51 -0
- package/dist/routes/plugins.js.map +1 -0
- package/dist/routes/remove.d.ts +3 -0
- package/dist/routes/remove.d.ts.map +1 -0
- package/dist/routes/remove.js +27 -0
- package/dist/routes/remove.js.map +1 -0
- package/dist/routes/state.d.ts +3 -0
- package/dist/routes/state.d.ts.map +1 -0
- package/dist/routes/state.js +177 -0
- package/dist/routes/state.js.map +1 -0
- package/dist/routes/sync.d.ts +3 -0
- package/dist/routes/sync.d.ts.map +1 -0
- package/dist/routes/sync.js +12 -0
- package/dist/routes/sync.js.map +1 -0
- package/dist/server.d.ts +4 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +59 -0
- package/dist/server.js.map +1 -0
- package/package.json +48 -0
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Config Merger Module
|
|
3
|
+
*
|
|
4
|
+
* Merges configurations from three levels:
|
|
5
|
+
* - Global (~/.mycelium/) - base configuration
|
|
6
|
+
* - Machine (~/.mycelium/machines/{hostname}/) - hardware-specific overrides
|
|
7
|
+
* - Project (.mycelium/ in project root) - project-specific overrides
|
|
8
|
+
*
|
|
9
|
+
* Priority: Project > Machine > Global
|
|
10
|
+
*/
|
|
11
|
+
import * as fs from "node:fs/promises";
|
|
12
|
+
import * as os from "node:os";
|
|
13
|
+
import * as path from "node:path";
|
|
14
|
+
/**
|
|
15
|
+
* Default empty memory config
|
|
16
|
+
*/
|
|
17
|
+
function getDefaultMemoryConfig() {
|
|
18
|
+
return {
|
|
19
|
+
scopes: {
|
|
20
|
+
shared: {
|
|
21
|
+
syncTo: [],
|
|
22
|
+
path: "",
|
|
23
|
+
files: [],
|
|
24
|
+
},
|
|
25
|
+
coding: {
|
|
26
|
+
syncTo: [],
|
|
27
|
+
path: "",
|
|
28
|
+
files: [],
|
|
29
|
+
},
|
|
30
|
+
personal: {
|
|
31
|
+
syncTo: [],
|
|
32
|
+
path: "",
|
|
33
|
+
files: [],
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Create an empty merged config
|
|
40
|
+
*/
|
|
41
|
+
function createEmptyMergedConfig() {
|
|
42
|
+
return {
|
|
43
|
+
mcps: {},
|
|
44
|
+
skills: {},
|
|
45
|
+
memory: getDefaultMemoryConfig(),
|
|
46
|
+
sources: {},
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Merge MCP configs from multiple levels
|
|
51
|
+
* Priority: Project > Machine > Global
|
|
52
|
+
*/
|
|
53
|
+
export function mergeConfigs(globalConfig, machineConfig, projectConfig) {
|
|
54
|
+
const result = createEmptyMergedConfig();
|
|
55
|
+
// Start with global MCPs
|
|
56
|
+
if (globalConfig?.mcps) {
|
|
57
|
+
for (const [name, config] of Object.entries(globalConfig.mcps)) {
|
|
58
|
+
result.mcps[name] = { ...config };
|
|
59
|
+
result.sources[name] = "global";
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
// Apply machine overrides (higher priority than global)
|
|
63
|
+
if (machineConfig?.mcps) {
|
|
64
|
+
for (const [name, config] of Object.entries(machineConfig.mcps)) {
|
|
65
|
+
if (result.mcps[name]) {
|
|
66
|
+
// Merge with existing config - machine takes priority
|
|
67
|
+
result.mcps[name] = mergeMcpServerConfig(result.mcps[name], config);
|
|
68
|
+
result.sources[name] = "machine";
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
// Add new MCP from machine config
|
|
72
|
+
result.mcps[name] = { ...config };
|
|
73
|
+
result.sources[name] = "machine";
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
// Apply project overrides (highest priority)
|
|
78
|
+
if (projectConfig?.mcps) {
|
|
79
|
+
for (const [name, config] of Object.entries(projectConfig.mcps)) {
|
|
80
|
+
if (result.mcps[name]) {
|
|
81
|
+
// Merge with existing config - project takes priority
|
|
82
|
+
result.mcps[name] = mergeMcpServerConfig(result.mcps[name], config);
|
|
83
|
+
result.sources[name] = "project";
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
// Add new MCP from project config
|
|
87
|
+
result.mcps[name] = { ...config };
|
|
88
|
+
result.sources[name] = "project";
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
// Merge skills (similar priority logic)
|
|
93
|
+
if (globalConfig?.skills) {
|
|
94
|
+
for (const [name, skill] of Object.entries(globalConfig.skills)) {
|
|
95
|
+
result.skills[name] = { ...skill };
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (machineConfig?.skills) {
|
|
99
|
+
for (const [name, skill] of Object.entries(machineConfig.skills)) {
|
|
100
|
+
result.skills[name] = { ...skill };
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
if (projectConfig?.skills) {
|
|
104
|
+
for (const [name, skill] of Object.entries(projectConfig.skills)) {
|
|
105
|
+
result.skills[name] = { ...skill };
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
// Merge memory config
|
|
109
|
+
if (globalConfig?.memory) {
|
|
110
|
+
result.memory = { ...globalConfig.memory };
|
|
111
|
+
}
|
|
112
|
+
if (machineConfig?.memory) {
|
|
113
|
+
result.memory = mergeMemoryConfig(result.memory, machineConfig.memory);
|
|
114
|
+
}
|
|
115
|
+
if (projectConfig?.memory) {
|
|
116
|
+
result.memory = mergeMemoryConfig(result.memory, projectConfig.memory);
|
|
117
|
+
}
|
|
118
|
+
return result;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Merge two MCP server configs, with source taking priority
|
|
122
|
+
*/
|
|
123
|
+
function mergeMcpServerConfig(target, source) {
|
|
124
|
+
return {
|
|
125
|
+
command: source.command ?? target.command,
|
|
126
|
+
args: source.args ?? target.args,
|
|
127
|
+
env: source.env !== undefined ? source.env : target.env,
|
|
128
|
+
enabled: source.enabled !== undefined ? source.enabled : target.enabled,
|
|
129
|
+
tools: source.tools ?? target.tools,
|
|
130
|
+
excludeTools: source.excludeTools ?? target.excludeTools,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Merge memory configs
|
|
135
|
+
*/
|
|
136
|
+
function mergeMemoryConfig(target, source) {
|
|
137
|
+
const result = { ...target };
|
|
138
|
+
if (source.scopes) {
|
|
139
|
+
result.scopes = {
|
|
140
|
+
...target.scopes,
|
|
141
|
+
...source.scopes,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
return result;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Check if a file exists
|
|
148
|
+
*/
|
|
149
|
+
async function fileExists(filePath) {
|
|
150
|
+
try {
|
|
151
|
+
await fs.access(filePath);
|
|
152
|
+
return true;
|
|
153
|
+
}
|
|
154
|
+
catch {
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Load and parse a JSON config file
|
|
160
|
+
*/
|
|
161
|
+
async function loadJsonConfig(filePath) {
|
|
162
|
+
try {
|
|
163
|
+
const content = await fs.readFile(filePath, "utf-8");
|
|
164
|
+
return JSON.parse(content);
|
|
165
|
+
}
|
|
166
|
+
catch {
|
|
167
|
+
return null;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Load global config from ~/.mycelium/
|
|
172
|
+
*/
|
|
173
|
+
export async function loadGlobalConfig() {
|
|
174
|
+
const home = os.homedir();
|
|
175
|
+
const globalPath = path.join(home, ".mycelium");
|
|
176
|
+
const mcpsPath = path.join(globalPath, "mcps.json");
|
|
177
|
+
const result = {
|
|
178
|
+
mcps: {},
|
|
179
|
+
skills: {},
|
|
180
|
+
};
|
|
181
|
+
if (await fileExists(mcpsPath)) {
|
|
182
|
+
const mcpsConfig = await loadJsonConfig(mcpsPath);
|
|
183
|
+
if (mcpsConfig?.mcps) {
|
|
184
|
+
result.mcps = mcpsConfig.mcps;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return result;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Load project config from .mycelium/ in project root
|
|
191
|
+
*/
|
|
192
|
+
export async function loadProjectConfig(projectRoot) {
|
|
193
|
+
const projectPath = path.join(projectRoot, ".mycelium");
|
|
194
|
+
const mcpsPath = path.join(projectPath, "mcps.json");
|
|
195
|
+
const result = {
|
|
196
|
+
mcps: {},
|
|
197
|
+
skills: {},
|
|
198
|
+
};
|
|
199
|
+
if (await fileExists(mcpsPath)) {
|
|
200
|
+
const mcpsConfig = await loadJsonConfig(mcpsPath);
|
|
201
|
+
if (mcpsConfig?.mcps) {
|
|
202
|
+
result.mcps = mcpsConfig.mcps;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
return result;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Load machine-specific config from ~/.mycelium/machines/{hostname}/
|
|
209
|
+
*/
|
|
210
|
+
export async function loadMachineConfig() {
|
|
211
|
+
const home = os.homedir();
|
|
212
|
+
const hostname = os.hostname();
|
|
213
|
+
const machinePath = path.join(home, ".mycelium", "machines", hostname);
|
|
214
|
+
const mcpsPath = path.join(machinePath, "mcps.json");
|
|
215
|
+
const result = {
|
|
216
|
+
mcps: {},
|
|
217
|
+
skills: {},
|
|
218
|
+
};
|
|
219
|
+
if (await fileExists(mcpsPath)) {
|
|
220
|
+
const mcpsConfig = await loadJsonConfig(mcpsPath);
|
|
221
|
+
if (mcpsConfig?.mcps) {
|
|
222
|
+
result.mcps = mcpsConfig.mcps;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
return result;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Load and merge all config levels for a project
|
|
229
|
+
*/
|
|
230
|
+
export async function loadAndMergeAllConfigs(projectRoot) {
|
|
231
|
+
const [globalConfig, machineConfig, projectConfig] = await Promise.all([
|
|
232
|
+
loadGlobalConfig(),
|
|
233
|
+
loadMachineConfig(),
|
|
234
|
+
loadProjectConfig(projectRoot),
|
|
235
|
+
]);
|
|
236
|
+
return mergeConfigs(globalConfig, machineConfig, projectConfig);
|
|
237
|
+
}
|
|
238
|
+
//# sourceMappingURL=config-merger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-merger.js","sourceRoot":"","sources":["../../src/core/config-merger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AASlC;;GAEG;AACH,SAAS,sBAAsB;IAC7B,OAAO;QACL,MAAM,EAAE;YACN,MAAM,EAAE;gBACN,MAAM,EAAE,EAAE;gBACV,IAAI,EAAE,EAAE;gBACR,KAAK,EAAE,EAAE;aACV;YACD,MAAM,EAAE;gBACN,MAAM,EAAE,EAAE;gBACV,IAAI,EAAE,EAAE;gBACR,KAAK,EAAE,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,CAAC;IACvE,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;IAErD,MAAM,MAAM,GAA0B;QACpC,IAAI,EAAE,EAAE;QACR,MAAM,EAAE,EAAE;KACX,CAAC;IAEF,IAAI,MAAM,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC/B,MAAM,UAAU,GAAG,MAAM,cAAc,CAA4C,QAAQ,CAAC,CAAC;QAC7F,IAAI,UAAU,EAAE,IAAI,EAAE,CAAC;YACrB,MAAM,CAAC,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC;QAChC,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,WAAmB;IAEnB,MAAM,CAAC,YAAY,EAAE,aAAa,EAAE,aAAa,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QACrE,gBAAgB,EAAE;QAClB,iBAAiB,EAAE;QACnB,iBAAiB,CAAC,WAAW,CAAC;KAC/B,CAAC,CAAC;IAEH,OAAO,YAAY,CAAC,YAAY,EAAE,aAAa,EAAE,aAAa,CAAC,CAAC;AAClE,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for config-merger module - written FIRST following TDD
|
|
3
|
+
*
|
|
4
|
+
* Config merge priority: Project > Machine > Global
|
|
5
|
+
* - Global provides base set of skills/mcps/memory
|
|
6
|
+
* - Machine can add/override for hardware-specific needs
|
|
7
|
+
* - Project can add/override/DISABLE specific items (enabled: false)
|
|
8
|
+
*/
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=config-merger.test.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-merger.test.d.ts","sourceRoot":"","sources":["../../src/core/config-merger.test.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG"}
|
|
@@ -0,0 +1,406 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for config-merger module - written FIRST following TDD
|
|
3
|
+
*
|
|
4
|
+
* Config merge priority: Project > Machine > Global
|
|
5
|
+
* - Global provides base set of skills/mcps/memory
|
|
6
|
+
* - Machine can add/override for hardware-specific needs
|
|
7
|
+
* - Project can add/override/DISABLE specific items (enabled: false)
|
|
8
|
+
*/
|
|
9
|
+
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
10
|
+
import * as os from "node:os";
|
|
11
|
+
import * as path from "node:path";
|
|
12
|
+
// Mock fs module
|
|
13
|
+
vi.mock("node:fs/promises", () => ({
|
|
14
|
+
readFile: vi.fn(),
|
|
15
|
+
access: vi.fn(),
|
|
16
|
+
}));
|
|
17
|
+
describe("mergeConfigs", () => {
|
|
18
|
+
it("merges global and project MCP configs", async () => {
|
|
19
|
+
const { mergeConfigs } = await import("./config-merger.js");
|
|
20
|
+
const globalConfig = {
|
|
21
|
+
mcps: {
|
|
22
|
+
"context7": {
|
|
23
|
+
command: "npx",
|
|
24
|
+
args: ["-y", "@context7/mcp"],
|
|
25
|
+
enabled: true,
|
|
26
|
+
},
|
|
27
|
+
"filesystem": {
|
|
28
|
+
command: "npx",
|
|
29
|
+
args: ["-y", "@modelcontextprotocol/server-filesystem"],
|
|
30
|
+
enabled: true,
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
const projectConfig = {
|
|
35
|
+
mcps: {
|
|
36
|
+
"project-specific": {
|
|
37
|
+
command: "node",
|
|
38
|
+
args: ["./local-mcp.js"],
|
|
39
|
+
enabled: true,
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
const result = mergeConfigs(globalConfig, undefined, projectConfig);
|
|
44
|
+
// Should have all MCPs from both configs
|
|
45
|
+
expect(result.mcps).toHaveProperty("context7");
|
|
46
|
+
expect(result.mcps).toHaveProperty("filesystem");
|
|
47
|
+
expect(result.mcps).toHaveProperty("project-specific");
|
|
48
|
+
// Global MCPs should be preserved
|
|
49
|
+
expect(result.mcps["context7"].command).toBe("npx");
|
|
50
|
+
expect(result.mcps["filesystem"].command).toBe("npx");
|
|
51
|
+
// Project MCP should be added
|
|
52
|
+
expect(result.mcps["project-specific"].command).toBe("node");
|
|
53
|
+
});
|
|
54
|
+
it("project can override specific MCP args", async () => {
|
|
55
|
+
const { mergeConfigs } = await import("./config-merger.js");
|
|
56
|
+
const globalConfig = {
|
|
57
|
+
mcps: {
|
|
58
|
+
"context7": {
|
|
59
|
+
command: "npx",
|
|
60
|
+
args: ["-y", "@context7/mcp"],
|
|
61
|
+
env: { DEFAULT_ENV: "value" },
|
|
62
|
+
enabled: true,
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
const projectConfig = {
|
|
67
|
+
mcps: {
|
|
68
|
+
"context7": {
|
|
69
|
+
command: "npx",
|
|
70
|
+
args: ["-y", "@context7/mcp", "--custom-flag"],
|
|
71
|
+
enabled: true,
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
const result = mergeConfigs(globalConfig, undefined, projectConfig);
|
|
76
|
+
// Args should be overridden by project
|
|
77
|
+
expect(result.mcps["context7"].args).toEqual(["-y", "@context7/mcp", "--custom-flag"]);
|
|
78
|
+
// Command should remain from project (or global if not overridden)
|
|
79
|
+
expect(result.mcps["context7"].command).toBe("npx");
|
|
80
|
+
});
|
|
81
|
+
it("project can disable global MCPs with enabled: false", async () => {
|
|
82
|
+
const { mergeConfigs } = await import("./config-merger.js");
|
|
83
|
+
const globalConfig = {
|
|
84
|
+
mcps: {
|
|
85
|
+
"context7": {
|
|
86
|
+
command: "npx",
|
|
87
|
+
args: ["-y", "@context7/mcp"],
|
|
88
|
+
enabled: true,
|
|
89
|
+
},
|
|
90
|
+
"filesystem": {
|
|
91
|
+
command: "npx",
|
|
92
|
+
args: ["-y", "@modelcontextprotocol/server-filesystem"],
|
|
93
|
+
enabled: true,
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
const projectConfig = {
|
|
98
|
+
mcps: {
|
|
99
|
+
"context7": {
|
|
100
|
+
command: "npx",
|
|
101
|
+
args: ["-y", "@context7/mcp"],
|
|
102
|
+
enabled: false, // Disable this MCP for the project
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
const result = mergeConfigs(globalConfig, undefined, projectConfig);
|
|
107
|
+
// context7 should be disabled
|
|
108
|
+
expect(result.mcps["context7"].enabled).toBe(false);
|
|
109
|
+
// filesystem should remain enabled
|
|
110
|
+
expect(result.mcps["filesystem"].enabled).toBe(true);
|
|
111
|
+
});
|
|
112
|
+
it("project can add new MCPs not in global", async () => {
|
|
113
|
+
const { mergeConfigs } = await import("./config-merger.js");
|
|
114
|
+
const globalConfig = {
|
|
115
|
+
mcps: {
|
|
116
|
+
"context7": {
|
|
117
|
+
command: "npx",
|
|
118
|
+
args: ["-y", "@context7/mcp"],
|
|
119
|
+
enabled: true,
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
const projectConfig = {
|
|
124
|
+
mcps: {
|
|
125
|
+
"custom-db": {
|
|
126
|
+
command: "node",
|
|
127
|
+
args: ["./db-mcp.js"],
|
|
128
|
+
env: { DB_URL: "postgres://localhost" },
|
|
129
|
+
enabled: true,
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
const result = mergeConfigs(globalConfig, undefined, projectConfig);
|
|
134
|
+
// Both should be present
|
|
135
|
+
expect(result.mcps).toHaveProperty("context7");
|
|
136
|
+
expect(result.mcps).toHaveProperty("custom-db");
|
|
137
|
+
// New MCP should have correct config
|
|
138
|
+
expect(result.mcps["custom-db"].command).toBe("node");
|
|
139
|
+
expect(result.mcps["custom-db"].env).toEqual({ DB_URL: "postgres://localhost" });
|
|
140
|
+
});
|
|
141
|
+
it("machine configs merge between global and project", async () => {
|
|
142
|
+
const { mergeConfigs } = await import("./config-merger.js");
|
|
143
|
+
const globalConfig = {
|
|
144
|
+
mcps: {
|
|
145
|
+
"context7": {
|
|
146
|
+
command: "npx",
|
|
147
|
+
args: ["-y", "@context7/mcp"],
|
|
148
|
+
enabled: true,
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
};
|
|
152
|
+
const machineConfig = {
|
|
153
|
+
mcps: {
|
|
154
|
+
"context7": {
|
|
155
|
+
command: "npx",
|
|
156
|
+
args: ["-y", "@context7/mcp"],
|
|
157
|
+
env: { MACHINE_SPECIFIC: "gpu-optimized" },
|
|
158
|
+
enabled: true,
|
|
159
|
+
},
|
|
160
|
+
"machine-gpu": {
|
|
161
|
+
command: "cuda-mcp",
|
|
162
|
+
args: ["--gpu=0"],
|
|
163
|
+
enabled: true,
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
};
|
|
167
|
+
const projectConfig = {
|
|
168
|
+
mcps: {
|
|
169
|
+
"project-specific": {
|
|
170
|
+
command: "node",
|
|
171
|
+
args: ["./local.js"],
|
|
172
|
+
enabled: true,
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
};
|
|
176
|
+
const result = mergeConfigs(globalConfig, machineConfig, projectConfig);
|
|
177
|
+
// All MCPs should be present
|
|
178
|
+
expect(result.mcps).toHaveProperty("context7");
|
|
179
|
+
expect(result.mcps).toHaveProperty("machine-gpu");
|
|
180
|
+
expect(result.mcps).toHaveProperty("project-specific");
|
|
181
|
+
// Machine-specific env should be present (merged from machine config)
|
|
182
|
+
expect(result.mcps["context7"].env).toEqual({ MACHINE_SPECIFIC: "gpu-optimized" });
|
|
183
|
+
});
|
|
184
|
+
it("tracks source of each config item", async () => {
|
|
185
|
+
const { mergeConfigs } = await import("./config-merger.js");
|
|
186
|
+
const globalConfig = {
|
|
187
|
+
mcps: {
|
|
188
|
+
"global-mcp": {
|
|
189
|
+
command: "npx",
|
|
190
|
+
args: ["global"],
|
|
191
|
+
enabled: true,
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
};
|
|
195
|
+
const machineConfig = {
|
|
196
|
+
mcps: {
|
|
197
|
+
"machine-mcp": {
|
|
198
|
+
command: "machine",
|
|
199
|
+
args: ["machine"],
|
|
200
|
+
enabled: true,
|
|
201
|
+
},
|
|
202
|
+
},
|
|
203
|
+
};
|
|
204
|
+
const projectConfig = {
|
|
205
|
+
mcps: {
|
|
206
|
+
"project-mcp": {
|
|
207
|
+
command: "project",
|
|
208
|
+
args: ["project"],
|
|
209
|
+
enabled: true,
|
|
210
|
+
},
|
|
211
|
+
},
|
|
212
|
+
};
|
|
213
|
+
const result = mergeConfigs(globalConfig, machineConfig, projectConfig);
|
|
214
|
+
// Sources should track where each MCP came from
|
|
215
|
+
expect(result.sources["global-mcp"]).toBe("global");
|
|
216
|
+
expect(result.sources["machine-mcp"]).toBe("machine");
|
|
217
|
+
expect(result.sources["project-mcp"]).toBe("project");
|
|
218
|
+
});
|
|
219
|
+
it("project overrides take precedence over machine overrides", async () => {
|
|
220
|
+
const { mergeConfigs } = await import("./config-merger.js");
|
|
221
|
+
const globalConfig = {
|
|
222
|
+
mcps: {
|
|
223
|
+
"shared-mcp": {
|
|
224
|
+
command: "global-cmd",
|
|
225
|
+
args: ["global"],
|
|
226
|
+
enabled: true,
|
|
227
|
+
},
|
|
228
|
+
},
|
|
229
|
+
};
|
|
230
|
+
const machineConfig = {
|
|
231
|
+
mcps: {
|
|
232
|
+
"shared-mcp": {
|
|
233
|
+
command: "machine-cmd",
|
|
234
|
+
args: ["machine"],
|
|
235
|
+
enabled: true,
|
|
236
|
+
},
|
|
237
|
+
},
|
|
238
|
+
};
|
|
239
|
+
const projectConfig = {
|
|
240
|
+
mcps: {
|
|
241
|
+
"shared-mcp": {
|
|
242
|
+
command: "project-cmd",
|
|
243
|
+
args: ["project"],
|
|
244
|
+
enabled: true,
|
|
245
|
+
},
|
|
246
|
+
},
|
|
247
|
+
};
|
|
248
|
+
const result = mergeConfigs(globalConfig, machineConfig, projectConfig);
|
|
249
|
+
// Project should win
|
|
250
|
+
expect(result.mcps["shared-mcp"].command).toBe("project-cmd");
|
|
251
|
+
expect(result.mcps["shared-mcp"].args).toEqual(["project"]);
|
|
252
|
+
expect(result.sources["shared-mcp"]).toBe("project");
|
|
253
|
+
});
|
|
254
|
+
it("handles undefined configs gracefully", async () => {
|
|
255
|
+
const { mergeConfigs } = await import("./config-merger.js");
|
|
256
|
+
const globalConfig = {
|
|
257
|
+
mcps: {
|
|
258
|
+
"only-global": {
|
|
259
|
+
command: "npx",
|
|
260
|
+
args: ["test"],
|
|
261
|
+
enabled: true,
|
|
262
|
+
},
|
|
263
|
+
},
|
|
264
|
+
};
|
|
265
|
+
const result = mergeConfigs(globalConfig, undefined, undefined);
|
|
266
|
+
expect(result.mcps).toHaveProperty("only-global");
|
|
267
|
+
expect(result.mcps["only-global"].command).toBe("npx");
|
|
268
|
+
});
|
|
269
|
+
});
|
|
270
|
+
describe("loadGlobalConfig", () => {
|
|
271
|
+
beforeEach(() => {
|
|
272
|
+
vi.resetAllMocks();
|
|
273
|
+
});
|
|
274
|
+
it("loads from ~/.mycelium/", async () => {
|
|
275
|
+
const fs = await import("node:fs/promises");
|
|
276
|
+
const { loadGlobalConfig } = await import("./config-merger.js");
|
|
277
|
+
const mockMcpsConfig = {
|
|
278
|
+
mcps: {
|
|
279
|
+
"test-mcp": {
|
|
280
|
+
command: "npx",
|
|
281
|
+
args: ["-y", "test-mcp"],
|
|
282
|
+
enabled: true,
|
|
283
|
+
},
|
|
284
|
+
},
|
|
285
|
+
};
|
|
286
|
+
vi.mocked(fs.access).mockResolvedValue(undefined);
|
|
287
|
+
vi.mocked(fs.readFile).mockResolvedValue(JSON.stringify(mockMcpsConfig));
|
|
288
|
+
const result = await loadGlobalConfig();
|
|
289
|
+
const home = os.homedir();
|
|
290
|
+
expect(fs.readFile).toHaveBeenCalledWith(path.join(home, ".mycelium", "mcps.json"), "utf-8");
|
|
291
|
+
expect(result.mcps).toHaveProperty("test-mcp");
|
|
292
|
+
});
|
|
293
|
+
it("returns empty config if global config does not exist", async () => {
|
|
294
|
+
const fs = await import("node:fs/promises");
|
|
295
|
+
const { loadGlobalConfig } = await import("./config-merger.js");
|
|
296
|
+
vi.mocked(fs.access).mockRejectedValue(new Error("ENOENT"));
|
|
297
|
+
const result = await loadGlobalConfig();
|
|
298
|
+
expect(result.mcps).toEqual({});
|
|
299
|
+
});
|
|
300
|
+
});
|
|
301
|
+
describe("loadProjectConfig", () => {
|
|
302
|
+
beforeEach(() => {
|
|
303
|
+
vi.resetAllMocks();
|
|
304
|
+
});
|
|
305
|
+
it("loads from .mycelium/ in project root", async () => {
|
|
306
|
+
const fs = await import("node:fs/promises");
|
|
307
|
+
const { loadProjectConfig } = await import("./config-merger.js");
|
|
308
|
+
const mockMcpsConfig = {
|
|
309
|
+
mcps: {
|
|
310
|
+
"project-mcp": {
|
|
311
|
+
command: "node",
|
|
312
|
+
args: ["./mcp.js"],
|
|
313
|
+
enabled: true,
|
|
314
|
+
},
|
|
315
|
+
},
|
|
316
|
+
};
|
|
317
|
+
vi.mocked(fs.access).mockResolvedValue(undefined);
|
|
318
|
+
vi.mocked(fs.readFile).mockResolvedValue(JSON.stringify(mockMcpsConfig));
|
|
319
|
+
const result = await loadProjectConfig("/home/user/my-project");
|
|
320
|
+
expect(fs.readFile).toHaveBeenCalledWith("/home/user/my-project/.mycelium/mcps.json", "utf-8");
|
|
321
|
+
expect(result.mcps).toHaveProperty("project-mcp");
|
|
322
|
+
});
|
|
323
|
+
it("returns empty config if project config does not exist", async () => {
|
|
324
|
+
const fs = await import("node:fs/promises");
|
|
325
|
+
const { loadProjectConfig } = await import("./config-merger.js");
|
|
326
|
+
vi.mocked(fs.access).mockRejectedValue(new Error("ENOENT"));
|
|
327
|
+
const result = await loadProjectConfig("/home/user/no-config-project");
|
|
328
|
+
expect(result.mcps).toEqual({});
|
|
329
|
+
});
|
|
330
|
+
});
|
|
331
|
+
describe("loadMachineConfig", () => {
|
|
332
|
+
beforeEach(() => {
|
|
333
|
+
vi.resetAllMocks();
|
|
334
|
+
});
|
|
335
|
+
it("loads from ~/.mycelium/machines/{hostname}/", async () => {
|
|
336
|
+
const fs = await import("node:fs/promises");
|
|
337
|
+
const { loadMachineConfig } = await import("./config-merger.js");
|
|
338
|
+
const mockMcpsConfig = {
|
|
339
|
+
mcps: {
|
|
340
|
+
"machine-mcp": {
|
|
341
|
+
command: "cuda-mcp",
|
|
342
|
+
args: ["--gpu"],
|
|
343
|
+
enabled: true,
|
|
344
|
+
},
|
|
345
|
+
},
|
|
346
|
+
};
|
|
347
|
+
vi.mocked(fs.access).mockResolvedValue(undefined);
|
|
348
|
+
vi.mocked(fs.readFile).mockResolvedValue(JSON.stringify(mockMcpsConfig));
|
|
349
|
+
const result = await loadMachineConfig();
|
|
350
|
+
const home = os.homedir();
|
|
351
|
+
const hostname = os.hostname();
|
|
352
|
+
expect(fs.readFile).toHaveBeenCalledWith(path.join(home, ".mycelium", "machines", hostname, "mcps.json"), "utf-8");
|
|
353
|
+
expect(result.mcps).toHaveProperty("machine-mcp");
|
|
354
|
+
});
|
|
355
|
+
it("returns empty config if machine config does not exist", async () => {
|
|
356
|
+
const fs = await import("node:fs/promises");
|
|
357
|
+
const { loadMachineConfig } = await import("./config-merger.js");
|
|
358
|
+
vi.mocked(fs.access).mockRejectedValue(new Error("ENOENT"));
|
|
359
|
+
const result = await loadMachineConfig();
|
|
360
|
+
expect(result.mcps).toEqual({});
|
|
361
|
+
});
|
|
362
|
+
});
|
|
363
|
+
describe("loadAndMergeAllConfigs", () => {
|
|
364
|
+
beforeEach(() => {
|
|
365
|
+
vi.resetAllMocks();
|
|
366
|
+
});
|
|
367
|
+
it("loads and merges all config levels", async () => {
|
|
368
|
+
const fs = await import("node:fs/promises");
|
|
369
|
+
const { loadAndMergeAllConfigs } = await import("./config-merger.js");
|
|
370
|
+
const globalMcps = {
|
|
371
|
+
mcps: {
|
|
372
|
+
"global-mcp": { command: "global", args: [], enabled: true },
|
|
373
|
+
},
|
|
374
|
+
};
|
|
375
|
+
const machineMcps = {
|
|
376
|
+
mcps: {
|
|
377
|
+
"machine-mcp": { command: "machine", args: [], enabled: true },
|
|
378
|
+
},
|
|
379
|
+
};
|
|
380
|
+
const projectMcps = {
|
|
381
|
+
mcps: {
|
|
382
|
+
"project-mcp": { command: "project", args: [], enabled: true },
|
|
383
|
+
},
|
|
384
|
+
};
|
|
385
|
+
const home = os.homedir();
|
|
386
|
+
const hostname = os.hostname();
|
|
387
|
+
vi.mocked(fs.access).mockResolvedValue(undefined);
|
|
388
|
+
vi.mocked(fs.readFile).mockImplementation(async (filePath) => {
|
|
389
|
+
const pathStr = filePath.toString();
|
|
390
|
+
if (pathStr.includes("machines")) {
|
|
391
|
+
return JSON.stringify(machineMcps);
|
|
392
|
+
}
|
|
393
|
+
else if (pathStr.includes(".mycelium/mcps.json") && !pathStr.includes("my-project")) {
|
|
394
|
+
return JSON.stringify(globalMcps);
|
|
395
|
+
}
|
|
396
|
+
else {
|
|
397
|
+
return JSON.stringify(projectMcps);
|
|
398
|
+
}
|
|
399
|
+
});
|
|
400
|
+
const result = await loadAndMergeAllConfigs("/home/user/my-project");
|
|
401
|
+
expect(result.mcps).toHaveProperty("global-mcp");
|
|
402
|
+
expect(result.mcps).toHaveProperty("machine-mcp");
|
|
403
|
+
expect(result.mcps).toHaveProperty("project-mcp");
|
|
404
|
+
});
|
|
405
|
+
});
|
|
406
|
+
//# sourceMappingURL=config-merger.test.js.map
|