aicm 0.10.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -5
- package/dist/commands/install.js +2 -24
- package/dist/utils/mcp-writer.d.ts +14 -0
- package/dist/utils/mcp-writer.js +69 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
> Agentic IDE Configuration Manager
|
|
4
4
|
|
|
5
|
-
A CLI tool for
|
|
5
|
+
A CLI tool for managing Agentic IDE configurations across projects
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
https://github.com/user-attachments/assets/e80dedbc-89c4-4747-9acf-b7ecb7493fcc
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
## Why
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
With the rise of Agentic IDEs, we have an opportunity to enforce best practices through rules. However, these rules are typically isolated within individual projects.
|
|
12
|
+
**aicm** is a CLI tool for distributing Agentic IDE configurations, rules, and MCPs across projects. It leverages node package managers, copy configurations from node_modules to the correct locations in your file system.
|
|
12
13
|
|
|
13
14
|
## Getting Started
|
|
14
15
|
|
|
@@ -33,6 +34,11 @@ In your project's `aicm.json`, reference the package and the specific rule:
|
|
|
33
34
|
"rules": {
|
|
34
35
|
"typescript": "@myteam/ai-tools/rules/typescript.mdc",
|
|
35
36
|
"react": "@myteam/ai-tools/rules/react.mdc"
|
|
37
|
+
},
|
|
38
|
+
"mcpServers": {
|
|
39
|
+
"my-mcp": {
|
|
40
|
+
"url": "https://example.com/sse"
|
|
41
|
+
}
|
|
36
42
|
}
|
|
37
43
|
}
|
|
38
44
|
```
|
|
@@ -47,7 +53,7 @@ In your project's `aicm.json`, reference the package and the specific rule:
|
|
|
47
53
|
}
|
|
48
54
|
```
|
|
49
55
|
|
|
50
|
-
Now the rules will be
|
|
56
|
+
Now, when you run `npm install`, the rules will be added to `.cursor/rules/aicm/` and the mcps to `.cursor/mcp.json`.
|
|
51
57
|
|
|
52
58
|
### Using Presets
|
|
53
59
|
|
package/dist/commands/install.js
CHANGED
|
@@ -10,11 +10,10 @@ const config_1 = require("../utils/config");
|
|
|
10
10
|
const rule_detector_1 = require("../utils/rule-detector");
|
|
11
11
|
const rule_collector_1 = require("../utils/rule-collector");
|
|
12
12
|
const rule_writer_1 = require("../utils/rule-writer");
|
|
13
|
-
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
14
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
15
13
|
const ci_info_1 = require("ci-info");
|
|
16
14
|
const discovery_1 = require("./workspaces/discovery");
|
|
17
15
|
const workspaces_install_1 = require("./workspaces/workspaces-install");
|
|
16
|
+
const mcp_writer_1 = require("../utils/mcp-writer");
|
|
18
17
|
/**
|
|
19
18
|
* Helper function to execute a function within a specific working directory
|
|
20
19
|
* and ensure the original directory is always restored
|
|
@@ -33,27 +32,6 @@ async function withWorkingDirectory(targetDir, fn) {
|
|
|
33
32
|
}
|
|
34
33
|
}
|
|
35
34
|
}
|
|
36
|
-
/**
|
|
37
|
-
* Write MCP servers configuration to IDE targets
|
|
38
|
-
* @param mcpServers The MCP servers configuration
|
|
39
|
-
* @param ides The IDEs to write to
|
|
40
|
-
* @param cwd The current working directory
|
|
41
|
-
*/
|
|
42
|
-
function writeMcpServersToTargets(mcpServers, ides, cwd) {
|
|
43
|
-
if (!mcpServers)
|
|
44
|
-
return;
|
|
45
|
-
for (const ide of ides) {
|
|
46
|
-
let mcpPath = null;
|
|
47
|
-
if (ide === "cursor") {
|
|
48
|
-
mcpPath = node_path_1.default.join(cwd, ".cursor", "mcp.json");
|
|
49
|
-
fs_extra_1.default.ensureDirSync(node_path_1.default.dirname(mcpPath));
|
|
50
|
-
}
|
|
51
|
-
// Windsurf does not support project mcpServers, so skip
|
|
52
|
-
if (mcpPath) {
|
|
53
|
-
fs_extra_1.default.writeJsonSync(mcpPath, { mcpServers }, { spaces: 2 });
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
35
|
/**
|
|
58
36
|
* Checks if the current environment is a CI environment
|
|
59
37
|
* This function respects any explicit settings in process.env.CI
|
|
@@ -223,7 +201,7 @@ async function install(options = {}) {
|
|
|
223
201
|
if (config.mcpServers) {
|
|
224
202
|
// Filter out canceled servers
|
|
225
203
|
const filteredMcpServers = Object.fromEntries(Object.entries(config.mcpServers).filter(([, v]) => v !== false));
|
|
226
|
-
writeMcpServersToTargets(filteredMcpServers, config.ides, cwd);
|
|
204
|
+
(0, mcp_writer_1.writeMcpServersToTargets)(filteredMcpServers, config.ides, cwd);
|
|
227
205
|
}
|
|
228
206
|
return {
|
|
229
207
|
success: true,
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Config } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Write MCP servers configuration to IDE targets
|
|
4
|
+
* @param mcpServers The MCP servers configuration
|
|
5
|
+
* @param ides The IDEs to write to
|
|
6
|
+
* @param cwd The current working directory
|
|
7
|
+
*/
|
|
8
|
+
export declare function writeMcpServersToTargets(mcpServers: Config["mcpServers"], ides: string[], cwd: string): void;
|
|
9
|
+
/**
|
|
10
|
+
* Write MCP servers configuration to a specific file
|
|
11
|
+
* @param mcpServers The MCP servers configuration
|
|
12
|
+
* @param mcpPath The path to the mcp.json file
|
|
13
|
+
*/
|
|
14
|
+
export declare function writeMcpServersToFile(mcpServers: Config["mcpServers"], mcpPath: string): void;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.writeMcpServersToTargets = writeMcpServersToTargets;
|
|
7
|
+
exports.writeMcpServersToFile = writeMcpServersToFile;
|
|
8
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
9
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
10
|
+
/**
|
|
11
|
+
* Write MCP servers configuration to IDE targets
|
|
12
|
+
* @param mcpServers The MCP servers configuration
|
|
13
|
+
* @param ides The IDEs to write to
|
|
14
|
+
* @param cwd The current working directory
|
|
15
|
+
*/
|
|
16
|
+
function writeMcpServersToTargets(mcpServers, ides, cwd) {
|
|
17
|
+
if (!mcpServers)
|
|
18
|
+
return;
|
|
19
|
+
for (const ide of ides) {
|
|
20
|
+
if (ide === "cursor") {
|
|
21
|
+
const mcpPath = node_path_1.default.join(cwd, ".cursor", "mcp.json");
|
|
22
|
+
writeMcpServersToFile(mcpServers, mcpPath);
|
|
23
|
+
}
|
|
24
|
+
// Windsurf does not support project mcpServers, so skip
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Write MCP servers configuration to a specific file
|
|
29
|
+
* @param mcpServers The MCP servers configuration
|
|
30
|
+
* @param mcpPath The path to the mcp.json file
|
|
31
|
+
*/
|
|
32
|
+
function writeMcpServersToFile(mcpServers, mcpPath) {
|
|
33
|
+
var _a;
|
|
34
|
+
if (!mcpServers)
|
|
35
|
+
return;
|
|
36
|
+
fs_extra_1.default.ensureDirSync(node_path_1.default.dirname(mcpPath));
|
|
37
|
+
const existingConfig = fs_extra_1.default.existsSync(mcpPath)
|
|
38
|
+
? fs_extra_1.default.readJsonSync(mcpPath)
|
|
39
|
+
: {};
|
|
40
|
+
const existingMcpServers = (_a = existingConfig === null || existingConfig === void 0 ? void 0 : existingConfig.mcpServers) !== null && _a !== void 0 ? _a : {};
|
|
41
|
+
// Filter out any existing aicm-managed servers (with aicm: true)
|
|
42
|
+
// This removes stale aicm servers that are no longer in the configuration
|
|
43
|
+
const userMcpServers = {};
|
|
44
|
+
for (const [key, value] of Object.entries(existingMcpServers)) {
|
|
45
|
+
if (typeof value === "object" && value !== null && value.aicm !== true) {
|
|
46
|
+
userMcpServers[key] = value;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
// Mark new aicm servers as managed and filter out canceled servers
|
|
50
|
+
const aicmMcpServers = {};
|
|
51
|
+
for (const [key, value] of Object.entries(mcpServers)) {
|
|
52
|
+
if (value !== false) {
|
|
53
|
+
aicmMcpServers[key] = {
|
|
54
|
+
...value,
|
|
55
|
+
aicm: true,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
// Merge user servers with aicm servers (aicm servers override user servers with same key)
|
|
60
|
+
const mergedMcpServers = {
|
|
61
|
+
...userMcpServers,
|
|
62
|
+
...aicmMcpServers,
|
|
63
|
+
};
|
|
64
|
+
const mergedConfig = {
|
|
65
|
+
...existingConfig,
|
|
66
|
+
mcpServers: mergedMcpServers,
|
|
67
|
+
};
|
|
68
|
+
fs_extra_1.default.writeJsonSync(mcpPath, mergedConfig, { spaces: 2 });
|
|
69
|
+
}
|