@a1st/aix-core 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/backup.d.ts +12 -0
- package/dist/backup.d.ts.map +1 -0
- package/dist/backup.js +70 -0
- package/dist/backup.js.map +1 -0
- package/dist/cache/cleanup.d.ts +14 -0
- package/dist/cache/cleanup.d.ts.map +1 -0
- package/dist/cache/cleanup.js +61 -0
- package/dist/cache/cleanup.js.map +1 -0
- package/dist/cache/clear.d.ts +10 -0
- package/dist/cache/clear.d.ts.map +1 -0
- package/dist/cache/clear.js +30 -0
- package/dist/cache/clear.js.map +1 -0
- package/dist/cache/index.d.ts +5 -0
- package/dist/cache/index.d.ts.map +1 -0
- package/dist/cache/index.js +5 -0
- package/dist/cache/index.js.map +1 -0
- package/dist/cache/paths.d.ts +57 -0
- package/dist/cache/paths.d.ts.map +1 -0
- package/dist/cache/paths.js +86 -0
- package/dist/cache/paths.js.map +1 -0
- package/dist/cache/status.d.ts +21 -0
- package/dist/cache/status.d.ts.map +1 -0
- package/dist/cache/status.js +67 -0
- package/dist/cache/status.js.map +1 -0
- package/dist/discovery.d.ts +14 -0
- package/dist/discovery.d.ts.map +1 -0
- package/dist/discovery.js +96 -0
- package/dist/discovery.js.map +1 -0
- package/dist/editors/adapters/base.d.ts +101 -0
- package/dist/editors/adapters/base.d.ts.map +1 -0
- package/dist/editors/adapters/base.js +399 -0
- package/dist/editors/adapters/base.js.map +1 -0
- package/dist/editors/adapters/claude-code.d.ts +27 -0
- package/dist/editors/adapters/claude-code.d.ts.map +1 -0
- package/dist/editors/adapters/claude-code.js +46 -0
- package/dist/editors/adapters/claude-code.js.map +1 -0
- package/dist/editors/adapters/codex.d.ts +30 -0
- package/dist/editors/adapters/codex.d.ts.map +1 -0
- package/dist/editors/adapters/codex.js +56 -0
- package/dist/editors/adapters/codex.js.map +1 -0
- package/dist/editors/adapters/cursor.d.ts +23 -0
- package/dist/editors/adapters/cursor.d.ts.map +1 -0
- package/dist/editors/adapters/cursor.js +39 -0
- package/dist/editors/adapters/cursor.js.map +1 -0
- package/dist/editors/adapters/index.d.ts +8 -0
- package/dist/editors/adapters/index.d.ts.map +1 -0
- package/dist/editors/adapters/index.js +8 -0
- package/dist/editors/adapters/index.js.map +1 -0
- package/dist/editors/adapters/vscode.d.ts +23 -0
- package/dist/editors/adapters/vscode.d.ts.map +1 -0
- package/dist/editors/adapters/vscode.js +36 -0
- package/dist/editors/adapters/vscode.js.map +1 -0
- package/dist/editors/adapters/windsurf.d.ts +23 -0
- package/dist/editors/adapters/windsurf.d.ts.map +1 -0
- package/dist/editors/adapters/windsurf.js +38 -0
- package/dist/editors/adapters/windsurf.js.map +1 -0
- package/dist/editors/adapters/zed.d.ts +29 -0
- package/dist/editors/adapters/zed.d.ts.map +1 -0
- package/dist/editors/adapters/zed.js +61 -0
- package/dist/editors/adapters/zed.js.map +1 -0
- package/dist/editors/import.d.ts +31 -0
- package/dist/editors/import.d.ts.map +1 -0
- package/dist/editors/import.js +271 -0
- package/dist/editors/import.js.map +1 -0
- package/dist/editors/index.d.ts +6 -0
- package/dist/editors/index.d.ts.map +1 -0
- package/dist/editors/index.js +4 -0
- package/dist/editors/index.js.map +1 -0
- package/dist/editors/install.d.ts +33 -0
- package/dist/editors/install.d.ts.map +1 -0
- package/dist/editors/install.js +186 -0
- package/dist/editors/install.js.map +1 -0
- package/dist/editors/strategies/claude-code/hooks.d.ts +13 -0
- package/dist/editors/strategies/claude-code/hooks.d.ts.map +1 -0
- package/dist/editors/strategies/claude-code/hooks.js +61 -0
- package/dist/editors/strategies/claude-code/hooks.js.map +1 -0
- package/dist/editors/strategies/claude-code/index.d.ts +5 -0
- package/dist/editors/strategies/claude-code/index.d.ts.map +1 -0
- package/dist/editors/strategies/claude-code/index.js +5 -0
- package/dist/editors/strategies/claude-code/index.js.map +1 -0
- package/dist/editors/strategies/claude-code/mcp.d.ts +10 -0
- package/dist/editors/strategies/claude-code/mcp.d.ts.map +1 -0
- package/dist/editors/strategies/claude-code/mcp.js +17 -0
- package/dist/editors/strategies/claude-code/mcp.js.map +1 -0
- package/dist/editors/strategies/claude-code/prompts.d.ts +18 -0
- package/dist/editors/strategies/claude-code/prompts.d.ts.map +1 -0
- package/dist/editors/strategies/claude-code/prompts.js +42 -0
- package/dist/editors/strategies/claude-code/prompts.js.map +1 -0
- package/dist/editors/strategies/claude-code/rules.d.ts +17 -0
- package/dist/editors/strategies/claude-code/rules.d.ts.map +1 -0
- package/dist/editors/strategies/claude-code/rules.js +61 -0
- package/dist/editors/strategies/claude-code/rules.js.map +1 -0
- package/dist/editors/strategies/codex/index.d.ts +4 -0
- package/dist/editors/strategies/codex/index.d.ts.map +1 -0
- package/dist/editors/strategies/codex/index.js +4 -0
- package/dist/editors/strategies/codex/index.js.map +1 -0
- package/dist/editors/strategies/codex/mcp.d.ts +18 -0
- package/dist/editors/strategies/codex/mcp.d.ts.map +1 -0
- package/dist/editors/strategies/codex/mcp.js +93 -0
- package/dist/editors/strategies/codex/mcp.js.map +1 -0
- package/dist/editors/strategies/codex/prompts.d.ts +37 -0
- package/dist/editors/strategies/codex/prompts.d.ts.map +1 -0
- package/dist/editors/strategies/codex/prompts.js +82 -0
- package/dist/editors/strategies/codex/prompts.js.map +1 -0
- package/dist/editors/strategies/codex/rules.d.ts +17 -0
- package/dist/editors/strategies/codex/rules.d.ts.map +1 -0
- package/dist/editors/strategies/codex/rules.js +35 -0
- package/dist/editors/strategies/codex/rules.js.map +1 -0
- package/dist/editors/strategies/cursor/hooks.d.ts +13 -0
- package/dist/editors/strategies/cursor/hooks.d.ts.map +1 -0
- package/dist/editors/strategies/cursor/hooks.js +54 -0
- package/dist/editors/strategies/cursor/hooks.js.map +1 -0
- package/dist/editors/strategies/cursor/index.d.ts +4 -0
- package/dist/editors/strategies/cursor/index.d.ts.map +1 -0
- package/dist/editors/strategies/cursor/index.js +4 -0
- package/dist/editors/strategies/cursor/index.js.map +1 -0
- package/dist/editors/strategies/cursor/prompts.d.ts +18 -0
- package/dist/editors/strategies/cursor/prompts.d.ts.map +1 -0
- package/dist/editors/strategies/cursor/prompts.js +67 -0
- package/dist/editors/strategies/cursor/prompts.js.map +1 -0
- package/dist/editors/strategies/cursor/rules.d.ts +17 -0
- package/dist/editors/strategies/cursor/rules.d.ts.map +1 -0
- package/dist/editors/strategies/cursor/rules.js +41 -0
- package/dist/editors/strategies/cursor/rules.js.map +1 -0
- package/dist/editors/strategies/index.d.ts +9 -0
- package/dist/editors/strategies/index.d.ts.map +1 -0
- package/dist/editors/strategies/index.js +10 -0
- package/dist/editors/strategies/index.js.map +1 -0
- package/dist/editors/strategies/shared/global-mcp.d.ts +74 -0
- package/dist/editors/strategies/shared/global-mcp.d.ts.map +1 -0
- package/dist/editors/strategies/shared/global-mcp.js +85 -0
- package/dist/editors/strategies/shared/global-mcp.js.map +1 -0
- package/dist/editors/strategies/shared/index.d.ts +8 -0
- package/dist/editors/strategies/shared/index.d.ts.map +1 -0
- package/dist/editors/strategies/shared/index.js +8 -0
- package/dist/editors/strategies/shared/index.js.map +1 -0
- package/dist/editors/strategies/shared/native-skills.d.ts +19 -0
- package/dist/editors/strategies/shared/native-skills.d.ts.map +1 -0
- package/dist/editors/strategies/shared/native-skills.js +72 -0
- package/dist/editors/strategies/shared/native-skills.js.map +1 -0
- package/dist/editors/strategies/shared/no-hooks.d.ts +13 -0
- package/dist/editors/strategies/shared/no-hooks.d.ts.map +1 -0
- package/dist/editors/strategies/shared/no-hooks.js +19 -0
- package/dist/editors/strategies/shared/no-hooks.js.map +1 -0
- package/dist/editors/strategies/shared/no-mcp.d.ts +16 -0
- package/dist/editors/strategies/shared/no-mcp.d.ts.map +1 -0
- package/dist/editors/strategies/shared/no-mcp.js +21 -0
- package/dist/editors/strategies/shared/no-mcp.js.map +1 -0
- package/dist/editors/strategies/shared/no-prompts.d.ts +17 -0
- package/dist/editors/strategies/shared/no-prompts.d.ts.map +1 -0
- package/dist/editors/strategies/shared/no-prompts.js +24 -0
- package/dist/editors/strategies/shared/no-prompts.js.map +1 -0
- package/dist/editors/strategies/shared/pointer-skills.d.ts +17 -0
- package/dist/editors/strategies/shared/pointer-skills.d.ts.map +1 -0
- package/dist/editors/strategies/shared/pointer-skills.js +72 -0
- package/dist/editors/strategies/shared/pointer-skills.js.map +1 -0
- package/dist/editors/strategies/shared/standard-mcp.d.ts +16 -0
- package/dist/editors/strategies/shared/standard-mcp.d.ts.map +1 -0
- package/dist/editors/strategies/shared/standard-mcp.js +68 -0
- package/dist/editors/strategies/shared/standard-mcp.js.map +1 -0
- package/dist/editors/strategies/types.d.ts +126 -0
- package/dist/editors/strategies/types.d.ts.map +1 -0
- package/dist/editors/strategies/types.js +2 -0
- package/dist/editors/strategies/types.js.map +1 -0
- package/dist/editors/strategies/vscode/index.d.ts +4 -0
- package/dist/editors/strategies/vscode/index.d.ts.map +1 -0
- package/dist/editors/strategies/vscode/index.js +4 -0
- package/dist/editors/strategies/vscode/index.js.map +1 -0
- package/dist/editors/strategies/vscode/mcp.d.ts +17 -0
- package/dist/editors/strategies/vscode/mcp.d.ts.map +1 -0
- package/dist/editors/strategies/vscode/mcp.js +85 -0
- package/dist/editors/strategies/vscode/mcp.js.map +1 -0
- package/dist/editors/strategies/vscode/prompts.d.ts +18 -0
- package/dist/editors/strategies/vscode/prompts.d.ts.map +1 -0
- package/dist/editors/strategies/vscode/prompts.js +81 -0
- package/dist/editors/strategies/vscode/prompts.js.map +1 -0
- package/dist/editors/strategies/vscode/rules.d.ts +17 -0
- package/dist/editors/strategies/vscode/rules.d.ts.map +1 -0
- package/dist/editors/strategies/vscode/rules.js +38 -0
- package/dist/editors/strategies/vscode/rules.js.map +1 -0
- package/dist/editors/strategies/windsurf/hooks.d.ts +13 -0
- package/dist/editors/strategies/windsurf/hooks.d.ts.map +1 -0
- package/dist/editors/strategies/windsurf/hooks.js +61 -0
- package/dist/editors/strategies/windsurf/hooks.js.map +1 -0
- package/dist/editors/strategies/windsurf/index.d.ts +6 -0
- package/dist/editors/strategies/windsurf/index.d.ts.map +1 -0
- package/dist/editors/strategies/windsurf/index.js +6 -0
- package/dist/editors/strategies/windsurf/index.js.map +1 -0
- package/dist/editors/strategies/windsurf/mcp.d.ts +8 -0
- package/dist/editors/strategies/windsurf/mcp.d.ts.map +1 -0
- package/dist/editors/strategies/windsurf/mcp.js +99 -0
- package/dist/editors/strategies/windsurf/mcp.js.map +1 -0
- package/dist/editors/strategies/windsurf/prompts.d.ts +18 -0
- package/dist/editors/strategies/windsurf/prompts.d.ts.map +1 -0
- package/dist/editors/strategies/windsurf/prompts.js +68 -0
- package/dist/editors/strategies/windsurf/prompts.js.map +1 -0
- package/dist/editors/strategies/windsurf/rules.d.ts +17 -0
- package/dist/editors/strategies/windsurf/rules.d.ts.map +1 -0
- package/dist/editors/strategies/windsurf/rules.js +55 -0
- package/dist/editors/strategies/windsurf/rules.js.map +1 -0
- package/dist/editors/strategies/windsurf/skills.d.ts +9 -0
- package/dist/editors/strategies/windsurf/skills.d.ts.map +1 -0
- package/dist/editors/strategies/windsurf/skills.js +11 -0
- package/dist/editors/strategies/windsurf/skills.js.map +1 -0
- package/dist/editors/strategies/zed/index.d.ts +4 -0
- package/dist/editors/strategies/zed/index.d.ts.map +1 -0
- package/dist/editors/strategies/zed/index.js +4 -0
- package/dist/editors/strategies/zed/index.js.map +1 -0
- package/dist/editors/strategies/zed/mcp.d.ts +17 -0
- package/dist/editors/strategies/zed/mcp.d.ts.map +1 -0
- package/dist/editors/strategies/zed/mcp.js +68 -0
- package/dist/editors/strategies/zed/mcp.js.map +1 -0
- package/dist/editors/strategies/zed/prompts.d.ts +18 -0
- package/dist/editors/strategies/zed/prompts.d.ts.map +1 -0
- package/dist/editors/strategies/zed/prompts.js +25 -0
- package/dist/editors/strategies/zed/prompts.js.map +1 -0
- package/dist/editors/strategies/zed/rules.d.ts +17 -0
- package/dist/editors/strategies/zed/rules.d.ts.map +1 -0
- package/dist/editors/strategies/zed/rules.js +33 -0
- package/dist/editors/strategies/zed/rules.js.map +1 -0
- package/dist/editors/types.d.ts +164 -0
- package/dist/editors/types.d.ts.map +1 -0
- package/dist/editors/types.js +2 -0
- package/dist/editors/types.js.map +1 -0
- package/dist/env/ci.d.ts +6 -0
- package/dist/env/ci.d.ts.map +1 -0
- package/dist/env/ci.js +22 -0
- package/dist/env/ci.js.map +1 -0
- package/dist/env/index.d.ts +2 -0
- package/dist/env/index.d.ts.map +1 -0
- package/dist/env/index.js +2 -0
- package/dist/env/index.js.map +1 -0
- package/dist/errors.d.ts +44 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +68 -0
- package/dist/errors.js.map +1 -0
- package/dist/format-error.d.ts +18 -0
- package/dist/format-error.d.ts.map +1 -0
- package/dist/format-error.js +113 -0
- package/dist/format-error.js.map +1 -0
- package/dist/fs/safe-rm.d.ts +20 -0
- package/dist/fs/safe-rm.d.ts.map +1 -0
- package/dist/fs/safe-rm.js +129 -0
- package/dist/fs/safe-rm.js.map +1 -0
- package/dist/git-loader.d.ts +21 -0
- package/dist/git-loader.d.ts.map +1 -0
- package/dist/git-loader.js +61 -0
- package/dist/git-loader.js.map +1 -0
- package/dist/global/comparison.d.ts +16 -0
- package/dist/global/comparison.d.ts.map +1 -0
- package/dist/global/comparison.js +52 -0
- package/dist/global/comparison.js.map +1 -0
- package/dist/global/index.d.ts +5 -0
- package/dist/global/index.d.ts.map +1 -0
- package/dist/global/index.js +4 -0
- package/dist/global/index.js.map +1 -0
- package/dist/global/processor.d.ts +26 -0
- package/dist/global/processor.d.ts.map +1 -0
- package/dist/global/processor.js +318 -0
- package/dist/global/processor.js.map +1 -0
- package/dist/global/tracking.d.ts +109 -0
- package/dist/global/tracking.d.ts.map +1 -0
- package/dist/global/tracking.js +193 -0
- package/dist/global/tracking.js.map +1 -0
- package/dist/global/types.d.ts +54 -0
- package/dist/global/types.d.ts.map +1 -0
- package/dist/global/types.js +2 -0
- package/dist/global/types.js.map +1 -0
- package/dist/import-writer.d.ts +37 -0
- package/dist/import-writer.d.ts.map +1 -0
- package/dist/import-writer.js +129 -0
- package/dist/import-writer.js.map +1 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/inheritance.d.ts +9 -0
- package/dist/inheritance.d.ts.map +1 -0
- package/dist/inheritance.js +133 -0
- package/dist/inheritance.js.map +1 -0
- package/dist/json.d.ts +75 -0
- package/dist/json.d.ts.map +1 -0
- package/dist/json.js +123 -0
- package/dist/json.js.map +1 -0
- package/dist/loader.d.ts +35 -0
- package/dist/loader.d.ts.map +1 -0
- package/dist/loader.js +147 -0
- package/dist/loader.js.map +1 -0
- package/dist/mcp/env.d.ts +28 -0
- package/dist/mcp/env.d.ts.map +1 -0
- package/dist/mcp/env.js +47 -0
- package/dist/mcp/env.js.map +1 -0
- package/dist/mcp/index.d.ts +4 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +4 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/normalize.d.ts +33 -0
- package/dist/mcp/normalize.d.ts.map +1 -0
- package/dist/mcp/normalize.js +29 -0
- package/dist/mcp/normalize.js.map +1 -0
- package/dist/mcp/templates.d.ts +18 -0
- package/dist/mcp/templates.d.ts.map +1 -0
- package/dist/mcp/templates.js +66 -0
- package/dist/mcp/templates.js.map +1 -0
- package/dist/merge.d.ts +29 -0
- package/dist/merge.d.ts.map +1 -0
- package/dist/merge.js +154 -0
- package/dist/merge.js.map +1 -0
- package/dist/npm/index.d.ts +2 -0
- package/dist/npm/index.d.ts.map +1 -0
- package/dist/npm/index.js +2 -0
- package/dist/npm/index.js.map +1 -0
- package/dist/npm/resolve.d.ts +16 -0
- package/dist/npm/resolve.d.ts.map +1 -0
- package/dist/npm/resolve.js +42 -0
- package/dist/npm/resolve.js.map +1 -0
- package/dist/prompts/index.d.ts +2 -0
- package/dist/prompts/index.d.ts.map +1 -0
- package/dist/prompts/index.js +2 -0
- package/dist/prompts/index.js.map +1 -0
- package/dist/prompts/loader.d.ts +23 -0
- package/dist/prompts/loader.d.ts.map +1 -0
- package/dist/prompts/loader.js +115 -0
- package/dist/prompts/loader.js.map +1 -0
- package/dist/remote-loader.d.ts +29 -0
- package/dist/remote-loader.d.ts.map +1 -0
- package/dist/remote-loader.js +208 -0
- package/dist/remote-loader.js.map +1 -0
- package/dist/rules/index.d.ts +6 -0
- package/dist/rules/index.d.ts.map +1 -0
- package/dist/rules/index.js +6 -0
- package/dist/rules/index.js.map +1 -0
- package/dist/rules/interpolate.d.ts +27 -0
- package/dist/rules/interpolate.d.ts.map +1 -0
- package/dist/rules/interpolate.js +48 -0
- package/dist/rules/interpolate.js.map +1 -0
- package/dist/rules/loader.d.ts +27 -0
- package/dist/rules/loader.d.ts.map +1 -0
- package/dist/rules/loader.js +94 -0
- package/dist/rules/loader.js.map +1 -0
- package/dist/rules/merger.d.ts +37 -0
- package/dist/rules/merger.d.ts.map +1 -0
- package/dist/rules/merger.js +93 -0
- package/dist/rules/merger.js.map +1 -0
- package/dist/rules/skill-rules.d.ts +13 -0
- package/dist/rules/skill-rules.d.ts.map +1 -0
- package/dist/rules/skill-rules.js +70 -0
- package/dist/rules/skill-rules.js.map +1 -0
- package/dist/rules/utils.d.ts +36 -0
- package/dist/rules/utils.d.ts.map +1 -0
- package/dist/rules/utils.js +82 -0
- package/dist/rules/utils.js.map +1 -0
- package/dist/skills/cache.d.ts +10 -0
- package/dist/skills/cache.d.ts.map +1 -0
- package/dist/skills/cache.js +20 -0
- package/dist/skills/cache.js.map +1 -0
- package/dist/skills/index.d.ts +9 -0
- package/dist/skills/index.d.ts.map +1 -0
- package/dist/skills/index.js +9 -0
- package/dist/skills/index.js.map +1 -0
- package/dist/skills/parser.d.ts +6 -0
- package/dist/skills/parser.d.ts.map +1 -0
- package/dist/skills/parser.js +28 -0
- package/dist/skills/parser.js.map +1 -0
- package/dist/skills/reference-parser.d.ts +23 -0
- package/dist/skills/reference-parser.d.ts.map +1 -0
- package/dist/skills/reference-parser.js +162 -0
- package/dist/skills/reference-parser.js.map +1 -0
- package/dist/skills/resolve.d.ts +21 -0
- package/dist/skills/resolve.d.ts.map +1 -0
- package/dist/skills/resolve.js +43 -0
- package/dist/skills/resolve.js.map +1 -0
- package/dist/skills/resolvers/git.d.ts +8 -0
- package/dist/skills/resolvers/git.d.ts.map +1 -0
- package/dist/skills/resolvers/git.js +43 -0
- package/dist/skills/resolvers/git.js.map +1 -0
- package/dist/skills/resolvers/local.d.ts +7 -0
- package/dist/skills/resolvers/local.d.ts.map +1 -0
- package/dist/skills/resolvers/local.js +16 -0
- package/dist/skills/resolvers/local.js.map +1 -0
- package/dist/skills/resolvers/npm.d.ts +12 -0
- package/dist/skills/resolvers/npm.d.ts.map +1 -0
- package/dist/skills/resolvers/npm.js +28 -0
- package/dist/skills/resolvers/npm.js.map +1 -0
- package/dist/skills/validate.d.ts +11 -0
- package/dist/skills/validate.d.ts.map +1 -0
- package/dist/skills/validate.js +43 -0
- package/dist/skills/validate.js.map +1 -0
- package/dist/updater.d.ts +23 -0
- package/dist/updater.d.ts.map +1 -0
- package/dist/updater.js +100 -0
- package/dist/updater.js.map +1 -0
- package/dist/url-parsing.d.ts +121 -0
- package/dist/url-parsing.d.ts.map +1 -0
- package/dist/url-parsing.js +199 -0
- package/dist/url-parsing.js.map +1 -0
- package/package.json +41 -0
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
import { mkdir, readFile, writeFile, copyFile } from 'node:fs/promises';
|
|
2
|
+
import { existsSync } from 'node:fs';
|
|
3
|
+
import { homedir } from 'node:os';
|
|
4
|
+
import { join, dirname } from 'pathe';
|
|
5
|
+
import { GlobalTrackingService, makeTrackingKey } from './tracking.js';
|
|
6
|
+
import { mcpConfigsMatch, promptsMatch } from './comparison.js';
|
|
7
|
+
import { isCI } from '../env/ci.js';
|
|
8
|
+
import { getTransport } from '../mcp/normalize.js';
|
|
9
|
+
/** Set of global config paths that have been backed up in this session */
|
|
10
|
+
const backedUpPaths = new Set();
|
|
11
|
+
/**
|
|
12
|
+
* Backup a global config file before modifying it.
|
|
13
|
+
* Backups are stored in ~/.aix/backups/ with timestamps.
|
|
14
|
+
* Only backs up once per path per session to avoid excessive backups.
|
|
15
|
+
*/
|
|
16
|
+
async function backupGlobalConfig(globalPath) {
|
|
17
|
+
if (!existsSync(globalPath) || backedUpPaths.has(globalPath)) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const backupDir = join(homedir(), '.aix', 'backups'), timestamp = new Date().toISOString().replace(/[:.]/g, '-'),
|
|
21
|
+
// Include relative path from home to preserve context (e.g., .codeium/windsurf/mcp_config.json)
|
|
22
|
+
relativePath = globalPath.replace(homedir(), '').replace(/^\//, ''), safeRelativePath = relativePath.replace(/\//g, '_'), backupPath = join(backupDir, `${safeRelativePath}.${timestamp}.bak`);
|
|
23
|
+
try {
|
|
24
|
+
await mkdir(backupDir, { recursive: true });
|
|
25
|
+
await copyFile(globalPath, backupPath);
|
|
26
|
+
backedUpPaths.add(globalPath);
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
// Silently fail backup - don't block the operation
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Analyze global-only features and determine what changes are needed.
|
|
34
|
+
* This does NOT modify any files - it just builds a list of change requests.
|
|
35
|
+
*/
|
|
36
|
+
export async function analyzeGlobalChanges(editor, editorConfig, mcpStrategy, promptsStrategy) {
|
|
37
|
+
const changes = [];
|
|
38
|
+
// Analyze MCP servers if strategy is global-only
|
|
39
|
+
if (mcpStrategy.isGlobalOnly?.() && Object.keys(editorConfig.mcp).length > 0) {
|
|
40
|
+
const globalPath = join(homedir(), mcpStrategy.getGlobalMcpConfigPath() ?? '');
|
|
41
|
+
// Read existing global config
|
|
42
|
+
let existingMcp = {};
|
|
43
|
+
if (existsSync(globalPath)) {
|
|
44
|
+
try {
|
|
45
|
+
const content = await readFile(globalPath, 'utf-8'), { mcp } = mcpStrategy.parseGlobalMcpConfig(content);
|
|
46
|
+
existingMcp = mcp;
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
// Ignore parse errors - treat as empty
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
// Check each MCP server
|
|
53
|
+
for (const [name, config] of Object.entries(editorConfig.mcp)) {
|
|
54
|
+
const existing = existingMcp[name];
|
|
55
|
+
if (existing) {
|
|
56
|
+
// Server exists - check if configs match
|
|
57
|
+
if (mcpConfigsMatch(config, existing)) {
|
|
58
|
+
changes.push({
|
|
59
|
+
editor,
|
|
60
|
+
type: 'mcp',
|
|
61
|
+
name,
|
|
62
|
+
action: 'skip',
|
|
63
|
+
skipReason: 'Already configured identically',
|
|
64
|
+
globalPath,
|
|
65
|
+
mcpConfig: config,
|
|
66
|
+
existingMcpConfig: existing,
|
|
67
|
+
configsMatch: true,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
// Configs differ - skip and warn
|
|
72
|
+
changes.push({
|
|
73
|
+
editor,
|
|
74
|
+
type: 'mcp',
|
|
75
|
+
name,
|
|
76
|
+
action: 'skip',
|
|
77
|
+
skipReason: 'Existing config differs from ai.json - not modifying',
|
|
78
|
+
globalPath,
|
|
79
|
+
mcpConfig: config,
|
|
80
|
+
existingMcpConfig: existing,
|
|
81
|
+
configsMatch: false,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
// Server doesn't exist - needs to be added
|
|
87
|
+
changes.push({
|
|
88
|
+
editor,
|
|
89
|
+
type: 'mcp',
|
|
90
|
+
name,
|
|
91
|
+
action: 'add',
|
|
92
|
+
globalPath,
|
|
93
|
+
mcpConfig: config,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
// Analyze prompts if strategy is global-only
|
|
99
|
+
if (promptsStrategy.isGlobalOnly?.() && editorConfig.prompts.length > 0) {
|
|
100
|
+
const globalPromptsPath = promptsStrategy.getGlobalPromptsPath();
|
|
101
|
+
if (globalPromptsPath) {
|
|
102
|
+
const promptChanges = await analyzeGlobalPrompts(editor, editorConfig.prompts, globalPromptsPath, promptsStrategy);
|
|
103
|
+
changes.push(...promptChanges);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return changes;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Analyze global prompts and determine what changes are needed.
|
|
110
|
+
*/
|
|
111
|
+
async function analyzeGlobalPrompts(editor, prompts, globalPromptsPath, promptsStrategy) {
|
|
112
|
+
const changes = [], globalDir = join(homedir(), globalPromptsPath), ext = promptsStrategy.getFileExtension();
|
|
113
|
+
for (const prompt of prompts) {
|
|
114
|
+
const promptPath = join(globalDir, `${prompt.name}${ext}`), formattedContent = promptsStrategy.formatPrompt(prompt);
|
|
115
|
+
// eslint-disable-next-line no-await-in-loop -- Sequential file reads for prompts
|
|
116
|
+
const change = await analyzePromptChange(editor, prompt.name, promptPath, formattedContent);
|
|
117
|
+
changes.push(change);
|
|
118
|
+
}
|
|
119
|
+
return changes;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Analyze a single prompt and determine what change is needed.
|
|
123
|
+
*/
|
|
124
|
+
async function analyzePromptChange(editor, name, promptPath, formattedContent) {
|
|
125
|
+
if (!existsSync(promptPath)) {
|
|
126
|
+
return {
|
|
127
|
+
editor,
|
|
128
|
+
type: 'prompt',
|
|
129
|
+
name,
|
|
130
|
+
action: 'add',
|
|
131
|
+
globalPath: promptPath,
|
|
132
|
+
promptContent: formattedContent,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
// Prompt exists - check if content matches
|
|
136
|
+
try {
|
|
137
|
+
const existingContent = await readFile(promptPath, 'utf-8'), configsMatch = promptsMatch(formattedContent, existingContent);
|
|
138
|
+
return {
|
|
139
|
+
editor,
|
|
140
|
+
type: 'prompt',
|
|
141
|
+
name,
|
|
142
|
+
action: 'skip',
|
|
143
|
+
skipReason: configsMatch
|
|
144
|
+
? 'Already configured identically'
|
|
145
|
+
: 'Existing prompt differs from ai.json - not modifying',
|
|
146
|
+
globalPath: promptPath,
|
|
147
|
+
promptContent: formattedContent,
|
|
148
|
+
existingPromptContent: existingContent,
|
|
149
|
+
configsMatch,
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
catch {
|
|
153
|
+
// Can't read - treat as needing add
|
|
154
|
+
return {
|
|
155
|
+
editor,
|
|
156
|
+
type: 'prompt',
|
|
157
|
+
name,
|
|
158
|
+
action: 'add',
|
|
159
|
+
globalPath: promptPath,
|
|
160
|
+
promptContent: formattedContent,
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Apply approved global changes. Writes files and updates tracking.
|
|
166
|
+
*/
|
|
167
|
+
export async function applyGlobalChanges(changes, options) {
|
|
168
|
+
const tracking = new GlobalTrackingService(), applied = [], skipped = [], warnings = [];
|
|
169
|
+
// Check if in CI - skip all global changes
|
|
170
|
+
if (await isCI()) {
|
|
171
|
+
for (const change of changes) {
|
|
172
|
+
if (change.action === 'add') {
|
|
173
|
+
skipped.push({
|
|
174
|
+
...change,
|
|
175
|
+
action: 'skip',
|
|
176
|
+
skipReason: 'Skipped in CI environment',
|
|
177
|
+
});
|
|
178
|
+
warnings.push(`[${change.editor}] Skipped global ${change.type} "${change.name}" - CI environment detected`);
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
skipped.push(change);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return { applied, skipped, warnings };
|
|
185
|
+
}
|
|
186
|
+
// Process each change
|
|
187
|
+
for (const change of changes) {
|
|
188
|
+
if (change.action === 'skip') {
|
|
189
|
+
skipped.push(change);
|
|
190
|
+
// Only warn if configs don't match (not just "already configured")
|
|
191
|
+
if (!change.configsMatch) {
|
|
192
|
+
warnings.push(`[${change.editor}] ${change.type} "${change.name}": ${change.skipReason}`);
|
|
193
|
+
}
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
196
|
+
// Skip if skipGlobal option is set
|
|
197
|
+
if (options.skipGlobal) {
|
|
198
|
+
skipped.push({
|
|
199
|
+
...change,
|
|
200
|
+
action: 'skip',
|
|
201
|
+
skipReason: 'Global changes disabled',
|
|
202
|
+
});
|
|
203
|
+
continue;
|
|
204
|
+
}
|
|
205
|
+
// Apply the change
|
|
206
|
+
if (!options.dryRun) {
|
|
207
|
+
try {
|
|
208
|
+
if (change.type === 'mcp' && change.mcpConfig) {
|
|
209
|
+
// For MCP, we need to merge with existing config
|
|
210
|
+
// eslint-disable-next-line no-await-in-loop -- Sequential for atomic operations
|
|
211
|
+
await applyMcpChange(change);
|
|
212
|
+
}
|
|
213
|
+
else if (change.type === 'prompt' && change.promptContent) {
|
|
214
|
+
// Backup before modifying
|
|
215
|
+
// eslint-disable-next-line no-await-in-loop -- Sequential for atomic operations
|
|
216
|
+
await backupGlobalConfig(change.globalPath);
|
|
217
|
+
// For prompts, just write the file
|
|
218
|
+
// eslint-disable-next-line no-await-in-loop -- Sequential for atomic operations
|
|
219
|
+
await mkdir(dirname(change.globalPath), { recursive: true });
|
|
220
|
+
// eslint-disable-next-line no-await-in-loop -- Sequential for atomic operations
|
|
221
|
+
await writeFile(change.globalPath, change.promptContent, 'utf-8');
|
|
222
|
+
}
|
|
223
|
+
// Update tracking
|
|
224
|
+
const key = makeTrackingKey(change.editor, change.type, change.name);
|
|
225
|
+
// eslint-disable-next-line no-await-in-loop -- Sequential for atomic operations
|
|
226
|
+
await tracking.addProjectDependency(key, { type: change.type, editor: change.editor, name: change.name }, options.projectPath);
|
|
227
|
+
}
|
|
228
|
+
catch (error) {
|
|
229
|
+
warnings.push(`[${change.editor}] Failed to apply ${change.type} "${change.name}": ${error.message}`);
|
|
230
|
+
skipped.push({
|
|
231
|
+
...change,
|
|
232
|
+
action: 'skip',
|
|
233
|
+
skipReason: `Failed: ${error.message}`,
|
|
234
|
+
});
|
|
235
|
+
continue;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
applied.push(change);
|
|
239
|
+
}
|
|
240
|
+
return { applied, skipped, warnings };
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Apply an MCP change by merging with existing config.
|
|
244
|
+
*/
|
|
245
|
+
async function applyMcpChange(change) {
|
|
246
|
+
const globalPath = change.globalPath;
|
|
247
|
+
let existingConfig = {};
|
|
248
|
+
// Backup before modifying
|
|
249
|
+
await backupGlobalConfig(globalPath);
|
|
250
|
+
// Read existing config if it exists
|
|
251
|
+
if (existsSync(globalPath)) {
|
|
252
|
+
try {
|
|
253
|
+
const content = await readFile(globalPath, 'utf-8');
|
|
254
|
+
existingConfig = JSON.parse(content);
|
|
255
|
+
}
|
|
256
|
+
catch {
|
|
257
|
+
// Start fresh if parse fails
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
// Merge the new server into existing config
|
|
261
|
+
const mcpServers = (existingConfig.mcpServers ?? {});
|
|
262
|
+
if (change.mcpConfig) {
|
|
263
|
+
const transport = getTransport(change.mcpConfig), serverConfig = {};
|
|
264
|
+
if (transport.type === 'stdio') {
|
|
265
|
+
serverConfig.command = transport.command;
|
|
266
|
+
serverConfig.args = transport.args ?? [];
|
|
267
|
+
if (transport.env && Object.keys(transport.env).length > 0) {
|
|
268
|
+
serverConfig.env = transport.env;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
else if (transport.type === 'http') {
|
|
272
|
+
serverConfig.url = transport.url;
|
|
273
|
+
}
|
|
274
|
+
// Include disabledTools if present
|
|
275
|
+
if ('disabledTools' in change.mcpConfig && Array.isArray(change.mcpConfig.disabledTools)) {
|
|
276
|
+
serverConfig.disabledTools = change.mcpConfig.disabledTools;
|
|
277
|
+
}
|
|
278
|
+
mcpServers[change.name] = serverConfig;
|
|
279
|
+
}
|
|
280
|
+
existingConfig.mcpServers = mcpServers;
|
|
281
|
+
// Write back
|
|
282
|
+
await mkdir(dirname(globalPath), { recursive: true });
|
|
283
|
+
await writeFile(globalPath, JSON.stringify(existingConfig, null, 2) + '\n', 'utf-8');
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Get a summary of global changes for display to the user.
|
|
287
|
+
*/
|
|
288
|
+
export function summarizeGlobalChanges(changes) {
|
|
289
|
+
const toAdd = changes.filter((c) => c.action === 'add'), toSkip = changes.filter((c) => c.action === 'skip' && !c.configsMatch), alreadyConfigured = changes.filter((c) => c.action === 'skip' && c.configsMatch);
|
|
290
|
+
return { toAdd, toSkip, alreadyConfigured };
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Remove an MCP server from a global config file.
|
|
294
|
+
* Returns true if the server was removed, false if it didn't exist.
|
|
295
|
+
*/
|
|
296
|
+
export async function removeFromGlobalMcpConfig(globalPath, serverName) {
|
|
297
|
+
if (!existsSync(globalPath)) {
|
|
298
|
+
return false;
|
|
299
|
+
}
|
|
300
|
+
try {
|
|
301
|
+
const content = await readFile(globalPath, 'utf-8'), config = JSON.parse(content), mcpServers = config.mcpServers;
|
|
302
|
+
if (!mcpServers || !(serverName in mcpServers)) {
|
|
303
|
+
return false;
|
|
304
|
+
}
|
|
305
|
+
// Backup before modifying
|
|
306
|
+
await backupGlobalConfig(globalPath);
|
|
307
|
+
// Remove the server
|
|
308
|
+
delete mcpServers[serverName];
|
|
309
|
+
config.mcpServers = mcpServers;
|
|
310
|
+
// Write back
|
|
311
|
+
await writeFile(globalPath, JSON.stringify(config, null, 2) + '\n', 'utf-8');
|
|
312
|
+
return true;
|
|
313
|
+
}
|
|
314
|
+
catch {
|
|
315
|
+
return false;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
//# sourceMappingURL=processor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"processor.js","sourceRoot":"","sources":["../../src/global/processor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,E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U,GAAG,UAAU,CAAC;QAE/B,aAAa;QACb,MAAM,SAAS,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE,OAAO,CAAC,CAAC;QAC7E,OAAO,IAAI,CAAC;IACf,CAAC;IAAC,MAAM,CAAC;QACN,OAAO,KAAK,CAAC;IAChB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A single entry in the global tracking file, representing a global config item that aix manages.
|
|
3
|
+
*/
|
|
4
|
+
export interface GlobalTrackingEntry {
|
|
5
|
+
/** Type of global config (mcp or prompt) */
|
|
6
|
+
type: 'mcp' | 'prompt';
|
|
7
|
+
/** Editor this entry belongs to */
|
|
8
|
+
editor: string;
|
|
9
|
+
/** Name of the config item (e.g., MCP server name, prompt name) */
|
|
10
|
+
name: string;
|
|
11
|
+
/** Absolute paths of projects that depend on this global config */
|
|
12
|
+
projects: string[];
|
|
13
|
+
/** ISO timestamp when this entry was first added */
|
|
14
|
+
addedAt: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Structure of the global tracking file at ~/.aix/global-tracking.json
|
|
18
|
+
*/
|
|
19
|
+
export interface GlobalTrackingFile {
|
|
20
|
+
version: 1;
|
|
21
|
+
entries: Record<string, GlobalTrackingEntry>;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Generate a unique key for a global tracking entry.
|
|
25
|
+
*/
|
|
26
|
+
export declare function makeTrackingKey(editor: string, type: 'mcp' | 'prompt', name: string): string;
|
|
27
|
+
/**
|
|
28
|
+
* Get the path to the global tracking file.
|
|
29
|
+
*/
|
|
30
|
+
export declare function getTrackingFilePath(): string;
|
|
31
|
+
/**
|
|
32
|
+
* Service for managing the global tracking file. Tracks which aix projects depend on global
|
|
33
|
+
* configuration entries (MCP servers, prompts) that were installed by aix.
|
|
34
|
+
*
|
|
35
|
+
* The tracking file is stored at ~/.aix/global-tracking.json and is used to:
|
|
36
|
+
* 1. Know which projects depend on a global config entry
|
|
37
|
+
* 2. Inform users when they can safely remove a global config (no projects depend on it)
|
|
38
|
+
* 3. Detect orphaned entries (tracking says it exists but no projects use it)
|
|
39
|
+
*
|
|
40
|
+
* **Robustness**: This service does NOT verify that the actual global config still exists.
|
|
41
|
+
* Callers should verify global config existence before trusting tracking data.
|
|
42
|
+
*/
|
|
43
|
+
export declare class GlobalTrackingService {
|
|
44
|
+
private readonly filePath;
|
|
45
|
+
constructor(filePath?: string);
|
|
46
|
+
/**
|
|
47
|
+
* Load the tracking file. Creates an empty file if it doesn't exist.
|
|
48
|
+
*/
|
|
49
|
+
load(): Promise<GlobalTrackingFile>;
|
|
50
|
+
/**
|
|
51
|
+
* Save the tracking file.
|
|
52
|
+
*/
|
|
53
|
+
save(data: GlobalTrackingFile): Promise<void>;
|
|
54
|
+
/**
|
|
55
|
+
* Add a project dependency to a global config entry. Creates the entry if it doesn't exist.
|
|
56
|
+
*
|
|
57
|
+
* @param key - Unique key for the entry (use makeTrackingKey)
|
|
58
|
+
* @param entry - Entry metadata (type, editor, name)
|
|
59
|
+
* @param projectPath - Absolute path to the project
|
|
60
|
+
*/
|
|
61
|
+
addProjectDependency(key: string, entry: Omit<GlobalTrackingEntry, 'projects' | 'addedAt'>, projectPath: string): Promise<void>;
|
|
62
|
+
/**
|
|
63
|
+
* Remove a project dependency from a global config entry.
|
|
64
|
+
*
|
|
65
|
+
* @returns The remaining projects that still depend on this entry, or empty array if entry
|
|
66
|
+
* doesn't exist or was removed.
|
|
67
|
+
*/
|
|
68
|
+
removeProjectDependency(key: string, projectPath: string): Promise<string[]>;
|
|
69
|
+
/**
|
|
70
|
+
* Get a single entry by key.
|
|
71
|
+
*/
|
|
72
|
+
getEntry(key: string): Promise<GlobalTrackingEntry | null>;
|
|
73
|
+
/**
|
|
74
|
+
* Check if a project is registered as depending on an entry.
|
|
75
|
+
*/
|
|
76
|
+
hasProjectDependency(key: string, projectPath: string): Promise<boolean>;
|
|
77
|
+
/**
|
|
78
|
+
* List all entries in the tracking file.
|
|
79
|
+
*/
|
|
80
|
+
listEntries(): Promise<GlobalTrackingEntry[]>;
|
|
81
|
+
/**
|
|
82
|
+
* List entries for a specific editor.
|
|
83
|
+
*/
|
|
84
|
+
listEntriesForEditor(editor: string): Promise<GlobalTrackingEntry[]>;
|
|
85
|
+
/**
|
|
86
|
+
* Get orphaned entries - entries with no projects depending on them.
|
|
87
|
+
* This can happen if tracking gets out of sync (e.g., project deleted without running aix).
|
|
88
|
+
*/
|
|
89
|
+
getOrphanedEntries(): Promise<GlobalTrackingEntry[]>;
|
|
90
|
+
/**
|
|
91
|
+
* Remove an entry entirely from tracking by its key.
|
|
92
|
+
*/
|
|
93
|
+
removeEntry(key: string): Promise<boolean>;
|
|
94
|
+
/**
|
|
95
|
+
* Get entries for a specific project.
|
|
96
|
+
*/
|
|
97
|
+
getEntriesForProject(projectPath: string): Promise<GlobalTrackingEntry[]>;
|
|
98
|
+
/**
|
|
99
|
+
* Remove all entries for a project (used when uninstalling aix from a project).
|
|
100
|
+
*
|
|
101
|
+
* @returns Keys of entries that were removed entirely (no other projects depend on them)
|
|
102
|
+
*/
|
|
103
|
+
removeAllForProject(projectPath: string): Promise<string[]>;
|
|
104
|
+
/**
|
|
105
|
+
* Normalize a project path for consistent comparison.
|
|
106
|
+
*/
|
|
107
|
+
private normalizePath;
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=tracking.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tracking.d.ts","sourceRoot":"","sources":["../../src/global/tracking.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,MAAM,WAAW,mBAAmB;IACjC,4CAA4C;IAC5C,IAAI,EAAE,KAAK,GAAG,QAAQ,CAAC;IACvB,mCAAmC;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,mEAAmE;IACnE,IAAI,EAAE,MAAM,CAAC;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AAmB,EAAE,CAAC;IAMnD;;OAEG;IACG,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,EAAE,CAAC;IAM1E;;;OAGG;IACG,kBAAkB,IAAI,OAAO,CAAC,mBAAmB,EAAE,CAAC;IAM1D;;OAEG;IACG,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAYhD;;OAEG;IACG,oBAAoB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,EAAE,CAAC;IAO/E;;;;OAIG;IACG,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAkBjE;;OAEG;IACH,OAAO,CAAC,aAAa;CAIvB"}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
2
|
+
import { existsSync } from 'node:fs';
|
|
3
|
+
import { homedir } from 'node:os';
|
|
4
|
+
import { join, dirname } from 'pathe';
|
|
5
|
+
/**
|
|
6
|
+
* Generate a unique key for a global tracking entry.
|
|
7
|
+
*/
|
|
8
|
+
export function makeTrackingKey(editor, type, name) {
|
|
9
|
+
return `${editor}:${type}:${name}`;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Get the path to the global tracking file.
|
|
13
|
+
*/
|
|
14
|
+
export function getTrackingFilePath() {
|
|
15
|
+
return join(homedir(), '.aix', 'global-tracking.json');
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Service for managing the global tracking file. Tracks which aix projects depend on global
|
|
19
|
+
* configuration entries (MCP servers, prompts) that were installed by aix.
|
|
20
|
+
*
|
|
21
|
+
* The tracking file is stored at ~/.aix/global-tracking.json and is used to:
|
|
22
|
+
* 1. Know which projects depend on a global config entry
|
|
23
|
+
* 2. Inform users when they can safely remove a global config (no projects depend on it)
|
|
24
|
+
* 3. Detect orphaned entries (tracking says it exists but no projects use it)
|
|
25
|
+
*
|
|
26
|
+
* **Robustness**: This service does NOT verify that the actual global config still exists.
|
|
27
|
+
* Callers should verify global config existence before trusting tracking data.
|
|
28
|
+
*/
|
|
29
|
+
export class GlobalTrackingService {
|
|
30
|
+
filePath;
|
|
31
|
+
constructor(filePath) {
|
|
32
|
+
this.filePath = filePath ?? getTrackingFilePath();
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Load the tracking file. Creates an empty file if it doesn't exist.
|
|
36
|
+
*/
|
|
37
|
+
async load() {
|
|
38
|
+
if (!existsSync(this.filePath)) {
|
|
39
|
+
return { version: 1, entries: {} };
|
|
40
|
+
}
|
|
41
|
+
try {
|
|
42
|
+
const content = await readFile(this.filePath, 'utf-8'), data = JSON.parse(content);
|
|
43
|
+
// Validate version
|
|
44
|
+
if (data.version !== 1) {
|
|
45
|
+
throw new Error(`Unsupported tracking file version: ${data.version}`);
|
|
46
|
+
}
|
|
47
|
+
return data;
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
if (error instanceof SyntaxError) {
|
|
51
|
+
// Corrupted file - return empty and let next save fix it
|
|
52
|
+
return { version: 1, entries: {} };
|
|
53
|
+
}
|
|
54
|
+
throw error;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Save the tracking file.
|
|
59
|
+
*/
|
|
60
|
+
async save(data) {
|
|
61
|
+
await mkdir(dirname(this.filePath), { recursive: true });
|
|
62
|
+
await writeFile(this.filePath, JSON.stringify(data, null, 2) + '\n', 'utf-8');
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Add a project dependency to a global config entry. Creates the entry if it doesn't exist.
|
|
66
|
+
*
|
|
67
|
+
* @param key - Unique key for the entry (use makeTrackingKey)
|
|
68
|
+
* @param entry - Entry metadata (type, editor, name)
|
|
69
|
+
* @param projectPath - Absolute path to the project
|
|
70
|
+
*/
|
|
71
|
+
async addProjectDependency(key, entry, projectPath) {
|
|
72
|
+
const data = await this.load(), normalizedPath = this.normalizePath(projectPath);
|
|
73
|
+
if (data.entries[key]) {
|
|
74
|
+
// Entry exists - add project if not already present
|
|
75
|
+
if (!data.entries[key].projects.includes(normalizedPath)) {
|
|
76
|
+
data.entries[key].projects.push(normalizedPath);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
// Create new entry
|
|
81
|
+
data.entries[key] = {
|
|
82
|
+
...entry,
|
|
83
|
+
projects: [normalizedPath],
|
|
84
|
+
addedAt: new Date().toISOString(),
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
await this.save(data);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Remove a project dependency from a global config entry.
|
|
91
|
+
*
|
|
92
|
+
* @returns The remaining projects that still depend on this entry, or empty array if entry
|
|
93
|
+
* doesn't exist or was removed.
|
|
94
|
+
*/
|
|
95
|
+
async removeProjectDependency(key, projectPath) {
|
|
96
|
+
const data = await this.load(), entry = data.entries[key];
|
|
97
|
+
if (!entry) {
|
|
98
|
+
return [];
|
|
99
|
+
}
|
|
100
|
+
const normalizedPath = this.normalizePath(projectPath);
|
|
101
|
+
entry.projects = entry.projects.filter((p) => p !== normalizedPath);
|
|
102
|
+
// If no projects remain, remove the entry entirely
|
|
103
|
+
if (entry.projects.length === 0) {
|
|
104
|
+
delete data.entries[key];
|
|
105
|
+
}
|
|
106
|
+
await this.save(data);
|
|
107
|
+
return entry.projects;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Get a single entry by key.
|
|
111
|
+
*/
|
|
112
|
+
async getEntry(key) {
|
|
113
|
+
const data = await this.load();
|
|
114
|
+
return data.entries[key] ?? null;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Check if a project is registered as depending on an entry.
|
|
118
|
+
*/
|
|
119
|
+
async hasProjectDependency(key, projectPath) {
|
|
120
|
+
const entry = await this.getEntry(key);
|
|
121
|
+
if (!entry) {
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
const normalizedPath = this.normalizePath(projectPath);
|
|
125
|
+
return entry.projects.includes(normalizedPath);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* List all entries in the tracking file.
|
|
129
|
+
*/
|
|
130
|
+
async listEntries() {
|
|
131
|
+
const data = await this.load();
|
|
132
|
+
return Object.values(data.entries);
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* List entries for a specific editor.
|
|
136
|
+
*/
|
|
137
|
+
async listEntriesForEditor(editor) {
|
|
138
|
+
const entries = await this.listEntries();
|
|
139
|
+
return entries.filter((e) => e.editor === editor);
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Get orphaned entries - entries with no projects depending on them.
|
|
143
|
+
* This can happen if tracking gets out of sync (e.g., project deleted without running aix).
|
|
144
|
+
*/
|
|
145
|
+
async getOrphanedEntries() {
|
|
146
|
+
const entries = await this.listEntries();
|
|
147
|
+
return entries.filter((e) => e.projects.length === 0);
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Remove an entry entirely from tracking by its key.
|
|
151
|
+
*/
|
|
152
|
+
async removeEntry(key) {
|
|
153
|
+
const data = await this.load();
|
|
154
|
+
if (!data.entries[key]) {
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
delete data.entries[key];
|
|
158
|
+
await this.save(data);
|
|
159
|
+
return true;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Get entries for a specific project.
|
|
163
|
+
*/
|
|
164
|
+
async getEntriesForProject(projectPath) {
|
|
165
|
+
const entries = await this.listEntries(), normalizedPath = this.normalizePath(projectPath);
|
|
166
|
+
return entries.filter((e) => e.projects.includes(normalizedPath));
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Remove all entries for a project (used when uninstalling aix from a project).
|
|
170
|
+
*
|
|
171
|
+
* @returns Keys of entries that were removed entirely (no other projects depend on them)
|
|
172
|
+
*/
|
|
173
|
+
async removeAllForProject(projectPath) {
|
|
174
|
+
const data = await this.load(), normalizedPath = this.normalizePath(projectPath), removedKeys = [];
|
|
175
|
+
for (const [key, entry] of Object.entries(data.entries)) {
|
|
176
|
+
entry.projects = entry.projects.filter((p) => p !== normalizedPath);
|
|
177
|
+
if (entry.projects.length === 0) {
|
|
178
|
+
delete data.entries[key];
|
|
179
|
+
removedKeys.push(key);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
await this.save(data);
|
|
183
|
+
return removedKeys;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Normalize a project path for consistent comparison.
|
|
187
|
+
*/
|
|
188
|
+
normalizePath(projectPath) {
|
|
189
|
+
// Remove trailing slashes and normalize
|
|
190
|
+
return projectPath.replace(/\/+$/, '');
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
//# sourceMappingURL=tracking.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tracking.js","sourceRoot":"","sources":["../../src/global/tracking.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AA0BtC;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,MAAc,EAAE,IAAsB,EAAE,IAAY;IACjF,OAAO,GAAG,MAAM,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC;AACtC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB;IAChC,OAAO,IAAI,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,sBAAsB,CAAC,CAAC;AAC1D,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,qBAAqB;IACd,QAAQ,CAAS;IA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