aicm 0.6.4 → 0.7.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 CHANGED
@@ -30,7 +30,6 @@ In your project's `aicm.json`, reference the package and the specific rule:
30
30
 
31
31
  ```json
32
32
  {
33
- "ides": ["cursor"],
34
33
  "rules": {
35
34
  "typescript": "@myteam/ai-tools/rules/typescript.mdc",
36
35
  "react": "@myteam/ai-tools/rules/react.mdc"
@@ -80,7 +79,6 @@ In your project's `aicm.json`, reference the preset by its npm package or direct
80
79
 
81
80
  ```json
82
81
  {
83
- "ides": ["cursor"],
84
82
  "presets": ["@myteam/ai-tools"]
85
83
  }
86
84
  ```
@@ -132,10 +130,7 @@ npm install --save-dev pirate-coding
132
130
  2. Create an `aicm.json` file in your project
133
131
 
134
132
  ```bash
135
- echo '{
136
- "ides": ["cursor"],
137
- "presets": ["pirate-coding"]
138
- }' > aicm.json
133
+ echo '{ "presets": ["pirate-coding"] }' > aicm.json
139
134
  ```
140
135
 
141
136
  3. Install all rules & mcps from your configuration
@@ -179,6 +174,9 @@ Example `aicm.json`:
179
174
  - **ides**: Array of IDE names where rules should be installed. Currently supported values:
180
175
 
181
176
  - `"cursor"`: For the Cursor IDE
177
+ - `"windsurf"`: For the Windsurf IDE
178
+
179
+ > **Note:** The 'ides' field is default to `["cursor"]` if not specified.
182
180
 
183
181
  - **rules**: Object containing rule configurations
184
182
 
@@ -276,7 +274,6 @@ const customConfig = {
276
274
  install({
277
275
  config: customConfig,
278
276
  cwd: "/path/to/project",
279
- silent: true,
280
277
  }).then((result) => {
281
278
  // Handle result
282
279
  });
@@ -292,7 +289,6 @@ Installs rules and MCP servers based on configuration.
292
289
 
293
290
  - `cwd`: Base directory to use instead of `process.cwd()`
294
291
  - `config`: Custom config object to use instead of loading from file
295
- - `silent`: Whether to suppress console output
296
292
 
297
293
  **Returns:**
298
294
 
@@ -11,10 +11,6 @@ export interface InstallOptions {
11
11
  * Custom config object to use instead of loading from file
12
12
  */
13
13
  config?: Config;
14
- /**
15
- * Whether to log progress to console
16
- */
17
- silent?: boolean;
18
14
  }
19
15
  /**
20
16
  * Result of the install operation
@@ -40,23 +40,14 @@ function writeMcpServersToTargets(mcpServers, ides, cwd) {
40
40
  */
41
41
  async function install(options = {}) {
42
42
  const cwd = options.cwd || process.cwd();
43
- const silent = options.silent || false;
44
- const log = silent ? () => { } : console.log;
45
- const error = silent ? () => { } : console.error;
46
43
  try {
47
- // Save original process.cwd() and change to the specified cwd
48
44
  const originalCwd = process.cwd();
49
45
  if (cwd !== originalCwd) {
50
46
  process.chdir(cwd);
51
47
  }
52
- // Initialize rule collection
53
48
  const ruleCollection = (0, rule_collector_1.initRuleCollection)();
54
- // Use provided config or load from file
55
49
  const config = options.config || (0, config_1.getConfig)();
56
- // If config doesn't exist, return error
57
50
  if (!config) {
58
- error("Configuration file not found!");
59
- // Restore original cwd
60
51
  if (cwd !== originalCwd) {
61
52
  process.chdir(originalCwd);
62
53
  }
@@ -70,8 +61,6 @@ async function install(options = {}) {
70
61
  if (!config.rules || Object.keys(config.rules).length === 0) {
71
62
  // If there are no presets defined either, show a message
72
63
  if (!config.presets || config.presets.length === 0) {
73
- error("No rules defined in configuration.");
74
- // Restore original cwd
75
64
  if (cwd !== originalCwd) {
76
65
  process.chdir(originalCwd);
77
66
  }
@@ -104,24 +93,20 @@ async function install(options = {}) {
104
93
  ruleContent = (0, rule_collector_1.collectLocalRule)(name, source, ruleBasePath);
105
94
  break;
106
95
  default:
107
- error(`Unknown rule type: ${ruleType}`);
108
96
  errorMessages.push(`Unknown rule type: ${ruleType}`);
109
97
  continue;
110
98
  }
111
- // Add rule to collection
112
99
  (0, rule_collector_1.addRuleToCollection)(ruleCollection, ruleContent, config.ides);
113
100
  installedRuleCount++;
114
101
  }
115
102
  catch (e) {
116
103
  hasErrors = true;
117
104
  const errorMessage = `Error processing rule ${name}: ${e instanceof Error ? e.message : String(e)}`;
118
- error(errorMessage);
119
105
  errorMessages.push(errorMessage);
120
106
  }
121
107
  }
122
108
  // If there were errors, exit with error
123
109
  if (hasErrors) {
124
- // Restore original cwd
125
110
  if (cwd !== originalCwd) {
126
111
  process.chdir(originalCwd);
127
112
  }
@@ -139,7 +124,6 @@ async function install(options = {}) {
139
124
  const filteredMcpServers = Object.fromEntries(Object.entries(config.mcpServers).filter(([, v]) => v !== false));
140
125
  writeMcpServersToTargets(filteredMcpServers, config.ides, cwd);
141
126
  }
142
- log("Rules installation completed");
143
127
  // Restore original cwd
144
128
  if (cwd !== originalCwd) {
145
129
  process.chdir(originalCwd);
@@ -150,8 +134,7 @@ async function install(options = {}) {
150
134
  };
151
135
  }
152
136
  catch (e) {
153
- const errorMessage = `Error during rule installation: ${e instanceof Error ? e.message : String(e)}`;
154
- error(errorMessage);
137
+ const errorMessage = e instanceof Error ? e.message : String(e);
155
138
  // If cwd was changed, restore it
156
139
  if (cwd !== process.cwd()) {
157
140
  process.chdir(cwd);
@@ -165,14 +148,17 @@ async function install(options = {}) {
165
148
  }
166
149
  async function installCommand() {
167
150
  try {
168
- const result = await install({ silent: false });
151
+ const result = await install();
169
152
  if (!result.success) {
170
153
  console.error(chalk_1.default.red(result.error));
171
154
  process.exit(1);
172
155
  }
156
+ else {
157
+ console.log("Rules installation completed");
158
+ }
173
159
  }
174
160
  catch (error) {
175
- console.error(chalk_1.default.red(`Error during rule installation: ${error instanceof Error ? error.message : String(error)}`));
161
+ console.error(chalk_1.default.red(error instanceof Error ? error.message : String(error)));
176
162
  process.exit(1);
177
163
  }
178
164
  }
@@ -24,9 +24,9 @@ function listCommand() {
24
24
  console.log(chalk_1.default.dim("─".repeat(50)));
25
25
  for (const [ruleName, source] of Object.entries(config.rules)) {
26
26
  if (source === false)
27
- continue; // skip canceled rules
27
+ continue;
28
28
  const ruleType = (0, rule_detector_1.detectRuleType)(source);
29
- const status = (0, rule_status_1.checkRuleStatus)(ruleName, ruleType, config.ides);
29
+ const status = (0, rule_status_1.checkRuleStatus)(ruleName, config.ides);
30
30
  const statusColor = status
31
31
  ? chalk_1.default.green("Installed")
32
32
  : chalk_1.default.yellow("Not installed");
@@ -21,13 +21,13 @@ function getFullPresetPath(presetPath) {
21
21
  let absolutePresetPath;
22
22
  if (presetPath.endsWith(".json")) {
23
23
  absolutePresetPath = require.resolve(presetPath, {
24
- paths: [process.cwd()],
24
+ paths: [__dirname, process.cwd()],
25
25
  });
26
26
  }
27
27
  else {
28
28
  const presetPathWithConfig = node_path_1.default.join(presetPath, "aicm.json");
29
29
  absolutePresetPath = require.resolve(presetPathWithConfig, {
30
- paths: [process.cwd()],
30
+ paths: [__dirname, process.cwd()],
31
31
  });
32
32
  }
33
33
  return fs_extra_1.default.existsSync(absolutePresetPath) ? absolutePresetPath : null;
@@ -42,7 +42,7 @@ function getFullPresetPath(presetPath) {
42
42
  function loadPreset(presetPath) {
43
43
  const fullPresetPath = getFullPresetPath(presetPath);
44
44
  if (!fullPresetPath) {
45
- throw new Error(`Error loading preset: File not found: ${presetPath}. Make sure the package is installed in your project.`);
45
+ throw new Error(`Error loading preset: "${presetPath}". Make sure the package is installed in your project.`);
46
46
  }
47
47
  const presetContent = fs_extra_1.default.readFileSync(fullPresetPath, "utf8");
48
48
  let preset;
@@ -133,11 +133,12 @@ function loadAicmConfigCosmiconfig() {
133
133
  const config = result.config;
134
134
  if (!config.rules)
135
135
  config.rules = {};
136
+ if (!config.ides)
137
+ config.ides = ["cursor"];
136
138
  return config;
137
139
  }
138
140
  catch (error) {
139
- console.error("Error loading aicm config via cosmiconfig:", error);
140
- return null;
141
+ throw new Error(`Error loading aicm config: ${error instanceof Error ? error.message : String(error)}`);
141
142
  }
142
143
  }
143
144
  /**
@@ -145,8 +146,9 @@ function loadAicmConfigCosmiconfig() {
145
146
  */
146
147
  function getConfig() {
147
148
  const config = loadAicmConfigCosmiconfig();
148
- if (!config)
149
- return null;
149
+ if (!config) {
150
+ throw new Error(`No config found in ${process.cwd()}, create one using "aicm init"`);
151
+ }
150
152
  processPresets(config);
151
153
  return config;
152
154
  }
@@ -22,7 +22,7 @@ function detectRuleType(source) {
22
22
  }
23
23
  try {
24
24
  const packageName = source.split(/[/\\]/)[0];
25
- require.resolve(packageName, { paths: [process.cwd()] });
25
+ require.resolve(packageName, { paths: [__dirname, process.cwd()] });
26
26
  return "npm";
27
27
  }
28
28
  catch (_a) {
@@ -5,4 +5,4 @@ export declare function getIdePaths(): Record<string, string>;
5
5
  /**
6
6
  * Check if a rule is installed in the specified IDEs
7
7
  */
8
- export declare function checkRuleStatus(ruleName: string, ruleType: string, ides: string[]): boolean;
8
+ export declare function checkRuleStatus(ruleName: string, ides: string[]): boolean;
@@ -20,7 +20,7 @@ function getIdePaths() {
20
20
  /**
21
21
  * Check if a rule is installed in the specified IDEs
22
22
  */
23
- function checkRuleStatus(ruleName, ruleType, ides) {
23
+ function checkRuleStatus(ruleName, ides) {
24
24
  const idePaths = getIdePaths();
25
25
  return ides.every((ide) => {
26
26
  if (!idePaths[ide]) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aicm",
3
- "version": "0.6.4",
3
+ "version": "0.7.0",
4
4
  "description": "A TypeScript CLI tool for managing AI IDE rules across different projects and teams",
5
5
  "main": "dist/api.js",
6
6
  "types": "dist/api.d.ts",