aicm 0.12.1 → 0.12.2

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
@@ -223,7 +223,15 @@ Example `aicm.json`:
223
223
 
224
224
  > **Note:** The 'ides' field is default to `["cursor"]` if not specified.
225
225
 
226
- - **rules**: Object containing rule configurations
226
+ - **rules**: Object containing rule configurations.
227
+ If you want to install every rule from a single directory, you can also use a
228
+ string as a shortcut:
229
+
230
+ ```json
231
+ {
232
+ "rules": "./rules/*"
233
+ }
234
+ ```
227
235
 
228
236
  - **rule-name**: A unique identifier for the rule. Can include a directory path to install the rule to a specific directory.
229
237
  - **source-location**: Location of the rule file (path within an npm package or local path). Supports glob patterns for automatic file discovery.
@@ -398,3 +406,9 @@ npm run test:unit
398
406
  # Run only E2E tests
399
407
  npm run test:e2e
400
408
  ```
409
+
410
+ ### Publishing
411
+
412
+ ```bash
413
+ npm run release
414
+ ```
package/dist/api.d.ts CHANGED
@@ -5,4 +5,4 @@ import { InstallOptions, InstallResult } from "./commands/install";
5
5
  * @returns Result of the install operation
6
6
  */
7
7
  export declare function install(options?: InstallOptions): Promise<InstallResult>;
8
- export { Config, Rule, Rules, RuleMetadata, RuleContent, RuleCollection, } from "./types";
8
+ export { Config, NormalizedConfig, Rule, Rules, RuleMetadata, RuleContent, RuleCollection, } from "./types";
@@ -1,4 +1,4 @@
1
- import { Config } from "../types";
1
+ import { NormalizedConfig } from "../types";
2
2
  /**
3
3
  * Options for the installCore function
4
4
  */
@@ -10,7 +10,7 @@ export interface InstallOptions {
10
10
  /**
11
11
  * Custom config object to use instead of loading from file
12
12
  */
13
- config?: Config;
13
+ config?: NormalizedConfig;
14
14
  /**
15
15
  * allow installation on CI environments
16
16
  */
@@ -17,12 +17,16 @@ export interface MCPServers {
17
17
  [serverName: string]: MCPServer;
18
18
  }
19
19
  export interface Config {
20
- ides: string[];
21
- rules: Rules;
20
+ ides?: string[];
21
+ rules?: Rules | string;
22
22
  presets?: string[];
23
23
  mcpServers?: MCPServers;
24
24
  installOnCI?: boolean;
25
25
  }
26
+ export interface NormalizedConfig extends Omit<Config, "rules"> {
27
+ ides: string[];
28
+ rules: Rules;
29
+ }
26
30
  export interface RuleMetadata {
27
31
  type?: string;
28
32
  alwaysApply?: boolean | string;
@@ -45,7 +49,7 @@ export interface RuleCollection {
45
49
  export interface PackageInfo {
46
50
  relativePath: string;
47
51
  absolutePath: string;
48
- config: Config;
52
+ config: NormalizedConfig;
49
53
  }
50
54
  export interface WorkspacesInstallResult {
51
55
  success: boolean;
@@ -1,12 +1,13 @@
1
- import { Config, Rules } from "../types";
1
+ import { Config, NormalizedConfig, Rules } from "../types";
2
2
  export interface RuleMetadata {
3
3
  ruleSources: Record<string, string>;
4
4
  originalPresetPaths: Record<string, string>;
5
5
  }
6
6
  export interface ConfigResult {
7
- config: Config;
7
+ config: NormalizedConfig;
8
8
  metadata: RuleMetadata;
9
9
  }
10
+ export declare function normalizeRules(rules: Rules | string | undefined): Rules;
10
11
  export interface PresetPathInfo {
11
12
  fullPath: string;
12
13
  originalPath: string;
@@ -24,19 +25,19 @@ export declare function loadPreset(presetPath: string, cwd?: string): {
24
25
  * Load the aicm config using cosmiconfigSync, supporting both aicm.json and package.json.
25
26
  * Returns the config object or null if not found.
26
27
  */
27
- export declare function loadAicmConfigCosmiconfig(searchFrom?: string): Config | null;
28
+ export declare function loadAicmConfigCosmiconfig(searchFrom?: string): NormalizedConfig | null;
28
29
  /**
29
30
  * Get the configuration from aicm.json or package.json (using cosmiconfigSync) and merge with any presets
30
31
  */
31
- export declare function getConfig(cwd?: string): Config | null;
32
+ export declare function getConfig(cwd?: string): NormalizedConfig | null;
32
33
  /**
33
34
  * Get the source preset path for a rule if it came from a preset
34
35
  */
35
- export declare function getRuleSource(config: Config, ruleName: string): string | undefined;
36
+ export declare function getRuleSource(config: NormalizedConfig, ruleName: string): string | undefined;
36
37
  /**
37
38
  * Get the original preset path for a rule if it came from a preset
38
39
  */
39
- export declare function getOriginalPresetPath(config: Config, ruleName: string): string | undefined;
40
+ export declare function getOriginalPresetPath(config: NormalizedConfig, ruleName: string): string | undefined;
40
41
  /**
41
42
  * Save the configuration to the aicm.json file
42
43
  */
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.normalizeRules = normalizeRules;
6
7
  exports.getFullPresetPath = getFullPresetPath;
7
8
  exports.loadPreset = loadPreset;
8
9
  exports.loadAicmConfigCosmiconfig = loadAicmConfigCosmiconfig;
@@ -14,6 +15,14 @@ const fs_extra_1 = __importDefault(require("fs-extra"));
14
15
  const node_path_1 = __importDefault(require("node:path"));
15
16
  const cosmiconfig_1 = require("cosmiconfig");
16
17
  const CONFIG_FILE = "aicm.json";
18
+ function normalizeRules(rules) {
19
+ if (!rules)
20
+ return {};
21
+ if (typeof rules === "string") {
22
+ return { "/": rules };
23
+ }
24
+ return rules;
25
+ }
17
26
  function getFullPresetPath(presetPath, cwd) {
18
27
  const workingDir = cwd || process.cwd();
19
28
  // If it's a local file with .json extension, check relative to the working directory
@@ -82,11 +91,12 @@ function loadPreset(presetPath, cwd) {
82
91
  const parseError = error;
83
92
  throw new Error(`Error loading preset: Invalid JSON in ${presetPath}: ${parseError.message}`);
84
93
  }
85
- if (!preset.rules || typeof preset.rules !== "object") {
94
+ if (!preset.rules) {
86
95
  throw new Error(`Error loading preset: Invalid format in ${presetPath} - missing or invalid 'rules' object`);
87
96
  }
97
+ const normalizedRules = normalizeRules(preset.rules);
88
98
  return {
89
- rules: preset.rules,
99
+ rules: normalizedRules,
90
100
  mcpServers: preset.mcpServers,
91
101
  presets: preset.presets,
92
102
  };
@@ -214,11 +224,13 @@ function loadAicmConfigCosmiconfig(searchFrom) {
214
224
  const result = explorer.search(searchFrom);
215
225
  if (!result || !result.config)
216
226
  return null;
217
- const config = result.config;
218
- if (!config.rules)
219
- config.rules = {};
220
- if (!config.ides)
221
- config.ides = ["cursor"];
227
+ const rawConfig = result.config;
228
+ const normalizedRules = normalizeRules(rawConfig.rules);
229
+ const config = {
230
+ ...rawConfig,
231
+ ides: rawConfig.ides || ["cursor"],
232
+ rules: normalizedRules,
233
+ };
222
234
  return config;
223
235
  }
224
236
  catch (error) {
@@ -1,14 +1,14 @@
1
- import { Config } from "../types";
1
+ import { NormalizedConfig } from "../types";
2
2
  /**
3
3
  * Write MCP servers configuration to IDE targets
4
4
  * @param mcpServers The MCP servers configuration
5
5
  * @param ides The IDEs to write to
6
6
  * @param cwd The current working directory
7
7
  */
8
- export declare function writeMcpServersToTargets(mcpServers: Config["mcpServers"], ides: string[], cwd: string): void;
8
+ export declare function writeMcpServersToTargets(mcpServers: NormalizedConfig["mcpServers"], ides: string[], cwd: string): void;
9
9
  /**
10
10
  * Write MCP servers configuration to a specific file
11
11
  * @param mcpServers The MCP servers configuration
12
12
  * @param mcpPath The path to the mcp.json file
13
13
  */
14
- export declare function writeMcpServersToFile(mcpServers: Config["mcpServers"], mcpPath: string): void;
14
+ export declare function writeMcpServersToFile(mcpServers: NormalizedConfig["mcpServers"], mcpPath: string): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aicm",
3
- "version": "0.12.1",
3
+ "version": "0.12.2",
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",
@@ -12,22 +12,6 @@
12
12
  "README.md",
13
13
  "LICENSE"
14
14
  ],
15
- "scripts": {
16
- "build": "tsc",
17
- "watch": "tsc --watch",
18
- "start": "node dist/index.js",
19
- "dev": "ts-node src/index.ts",
20
- "test": "jest",
21
- "test:watch": "jest --watch",
22
- "test:all": "npm run build && npm run test",
23
- "test:unit": "jest --config jest.unit.config.js",
24
- "test:e2e": "jest tests/e2e",
25
- "format": "prettier --write .",
26
- "format:check": "prettier --check .",
27
- "lint": "eslint",
28
- "prepare": "husky install && npx ts-node src/index.ts install",
29
- "version": "auto-changelog -p && git add CHANGELOG.md"
30
- },
31
15
  "keywords": [
32
16
  "ai",
33
17
  "ide",
@@ -58,6 +42,7 @@
58
42
  "lint-staged": "^15.2.0",
59
43
  "mock-fs": "^5.2.0",
60
44
  "nock": "^13.3.8",
45
+ "np": "^10.2.0",
61
46
  "prettier": "^3.1.0",
62
47
  "rimraf": "^5.0.5",
63
48
  "ts-jest": "^29.1.1",
@@ -68,5 +53,21 @@
68
53
  "lint-staged": {
69
54
  "*.{js,ts,json,md,mjs}": "prettier --write",
70
55
  "*.ts": "eslint"
56
+ },
57
+ "scripts": {
58
+ "build": "tsc",
59
+ "watch": "tsc --watch",
60
+ "start": "node dist/index.js",
61
+ "dev": "ts-node src/index.ts",
62
+ "test": "jest",
63
+ "test:watch": "jest --watch",
64
+ "test:all": "npm run build && npm run test",
65
+ "test:unit": "jest --config jest.unit.config.js",
66
+ "test:e2e": "jest tests/e2e",
67
+ "format": "prettier --write .",
68
+ "format:check": "prettier --check .",
69
+ "lint": "eslint",
70
+ "version": "auto-changelog -p && git add CHANGELOG.md",
71
+ "release": "np"
71
72
  }
72
- }
73
+ }