aicm 0.13.0 → 0.13.1

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/cli.js CHANGED
@@ -45,7 +45,7 @@ async function runCli() {
45
45
  await (0, install_1.installCommand)(args["--ci"], args["--verbose"]);
46
46
  break;
47
47
  case "list":
48
- (0, list_1.listCommand)();
48
+ await (0, list_1.listCommand)();
49
49
  break;
50
50
  default:
51
51
  showHelp();
@@ -20,7 +20,7 @@ const glob_handler_1 = require("../../utils/glob-handler");
20
20
  async function installPackage(options = {}) {
21
21
  const cwd = options.cwd || process.cwd();
22
22
  return (0, working_directory_1.withWorkingDirectory)(cwd, async () => {
23
- const config = options.config || (0, config_1.getConfig)();
23
+ const config = options.config || (await (0, config_1.getConfig)());
24
24
  const ruleCollection = (0, rule_collector_1.initRuleCollection)();
25
25
  if (!config) {
26
26
  return {
@@ -39,7 +39,7 @@ async function discoverPackagesWithAicm(rootDir) {
39
39
  const relativePath = node_path_1.default.relative(rootDir, packageDir);
40
40
  // Normalize to forward slashes for cross-platform compatibility
41
41
  const normalizedRelativePath = relativePath.replace(/\\/g, "/");
42
- const config = (0, config_1.getConfig)(packageDir);
42
+ const config = await (0, config_1.getConfig)(packageDir);
43
43
  if (config) {
44
44
  packages.push({
45
45
  relativePath: normalizedRelativePath || ".",
@@ -42,7 +42,7 @@ async function install(options = {}) {
42
42
  };
43
43
  }
44
44
  return (0, working_directory_1.withWorkingDirectory)(cwd, async () => {
45
- const config = options.config || (0, config_1.getConfig)();
45
+ const config = options.config || (await (0, config_1.getConfig)());
46
46
  if (config === null || config === void 0 ? void 0 : config.workspaces) {
47
47
  return await (0, install_workspaces_1.installWorkspaces)(cwd, installOnCI, options.verbose);
48
48
  }
@@ -1 +1 @@
1
- export declare function listCommand(): void;
1
+ export declare function listCommand(): Promise<void>;
@@ -8,8 +8,8 @@ const chalk_1 = __importDefault(require("chalk"));
8
8
  const config_1 = require("../utils/config");
9
9
  const rule_status_1 = require("../utils/rule-status");
10
10
  const rule_detector_1 = require("../utils/rule-detector");
11
- function listCommand() {
12
- const config = (0, config_1.getConfig)();
11
+ async function listCommand() {
12
+ const config = await (0, config_1.getConfig)();
13
13
  if (!config) {
14
14
  console.log(chalk_1.default.red("Configuration file not found!"));
15
15
  console.log(`Run ${chalk_1.default.blue("npx aicm init")} to create one.`);
@@ -22,14 +22,14 @@ export declare function loadPreset(presetPath: string, cwd?: string): {
22
22
  presets?: string[];
23
23
  } | null;
24
24
  /**
25
- * Load the aicm config using cosmiconfigSync, supporting both aicm.json and package.json.
25
+ * Load the aicm config using cosmiconfig, supporting both aicm.json and package.json.
26
26
  * Returns the config object or null if not found.
27
27
  */
28
- export declare function loadAicmConfigCosmiconfig(searchFrom?: string): NormalizedConfig | null;
28
+ export declare function loadAicmConfigCosmiconfig(searchFrom?: string): Promise<NormalizedConfig | null>;
29
29
  /**
30
30
  * Get the configuration from aicm.json or package.json (using cosmiconfigSync) and merge with any presets
31
31
  */
32
- export declare function getConfig(cwd?: string): NormalizedConfig | null;
32
+ export declare function getConfig(cwd?: string): Promise<NormalizedConfig | null>;
33
33
  /**
34
34
  * Get the source preset path for a rule if it came from a preset
35
35
  */
@@ -14,6 +14,7 @@ exports.saveConfig = saveConfig;
14
14
  const fs_extra_1 = __importDefault(require("fs-extra"));
15
15
  const node_path_1 = __importDefault(require("node:path"));
16
16
  const cosmiconfig_1 = require("cosmiconfig");
17
+ const glob_handler_1 = require("./glob-handler");
17
18
  const CONFIG_FILE = "aicm.json";
18
19
  function normalizeRules(rules) {
19
20
  if (!rules)
@@ -108,7 +109,7 @@ const processedPresets = new Set();
108
109
  /**
109
110
  * Process presets and return a new config with merged rules and metadata
110
111
  */
111
- function processPresets(config, cwd) {
112
+ async function processPresets(config, cwd) {
112
113
  // Create a deep copy of the config to avoid mutations
113
114
  const newConfig = JSON.parse(JSON.stringify(config));
114
115
  const metadata = {
@@ -117,12 +118,12 @@ function processPresets(config, cwd) {
117
118
  };
118
119
  // Clear processed presets tracking set when starting from the top level
119
120
  processedPresets.clear();
120
- return processPresetsInternal(newConfig, metadata, cwd);
121
+ return await processPresetsInternal(newConfig, metadata, cwd);
121
122
  }
122
123
  /**
123
124
  * Internal function to process presets recursively
124
125
  */
125
- function processPresetsInternal(config, metadata, cwd) {
126
+ async function processPresetsInternal(config, metadata, cwd) {
126
127
  if (!config.presets || !Array.isArray(config.presets)) {
127
128
  return { config, metadata };
128
129
  }
@@ -141,6 +142,10 @@ function processPresetsInternal(config, metadata, cwd) {
141
142
  const preset = loadPreset(presetPath, cwd);
142
143
  if (!preset)
143
144
  continue;
145
+ // Expand glob patterns within the preset using its base directory
146
+ const presetDir = node_path_1.default.dirname(pathInfo.fullPath);
147
+ const expansion = await (0, glob_handler_1.expandRulesGlobPatterns)(preset.rules, presetDir);
148
+ preset.rules = expansion.expandedRules;
144
149
  // Process nested presets first (depth-first)
145
150
  if (preset.presets && preset.presets.length > 0) {
146
151
  // Create a temporary config with just the presets from this preset
@@ -150,7 +155,7 @@ function processPresetsInternal(config, metadata, cwd) {
150
155
  ides: [],
151
156
  };
152
157
  // Recursively process the nested presets
153
- const { config: nestedConfig } = processPresetsInternal(presetConfig, metadata, cwd);
158
+ const { config: nestedConfig } = await processPresetsInternal(presetConfig, metadata, cwd);
154
159
  Object.assign(preset.rules, nestedConfig.rules);
155
160
  }
156
161
  const { updatedConfig, updatedMetadata } = mergePresetRules(config, preset.rules, pathInfo, metadata);
@@ -213,15 +218,15 @@ function mergePresetMcpServers(configMcpServers, presetMcpServers) {
213
218
  return newMcpServers;
214
219
  }
215
220
  /**
216
- * Load the aicm config using cosmiconfigSync, supporting both aicm.json and package.json.
221
+ * Load the aicm config using cosmiconfig, supporting both aicm.json and package.json.
217
222
  * Returns the config object or null if not found.
218
223
  */
219
- function loadAicmConfigCosmiconfig(searchFrom) {
220
- const explorer = (0, cosmiconfig_1.cosmiconfigSync)("aicm", {
224
+ async function loadAicmConfigCosmiconfig(searchFrom) {
225
+ const explorer = (0, cosmiconfig_1.cosmiconfig)("aicm", {
221
226
  searchPlaces: ["package.json", "aicm.json"],
222
227
  });
223
228
  try {
224
- const result = explorer.search(searchFrom);
229
+ const result = await explorer.search(searchFrom);
225
230
  if (!result || !result.config)
226
231
  return null;
227
232
  const rawConfig = result.config;
@@ -240,13 +245,13 @@ function loadAicmConfigCosmiconfig(searchFrom) {
240
245
  /**
241
246
  * Get the configuration from aicm.json or package.json (using cosmiconfigSync) and merge with any presets
242
247
  */
243
- function getConfig(cwd) {
248
+ async function getConfig(cwd) {
244
249
  const workingDir = cwd || process.cwd();
245
- const config = loadAicmConfigCosmiconfig(workingDir);
250
+ const config = await loadAicmConfigCosmiconfig(workingDir);
246
251
  if (!config) {
247
252
  throw new Error(`No config found in ${workingDir}, create one using "aicm init"`);
248
253
  }
249
- const { config: processedConfig, metadata } = processPresets(config, workingDir);
254
+ const { config: processedConfig, metadata } = await processPresets(config, workingDir);
250
255
  // Store metadata for later access
251
256
  currentMetadata = metadata;
252
257
  return processedConfig;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aicm",
3
- "version": "0.13.0",
3
+ "version": "0.13.1",
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,6 +12,9 @@
12
12
  "README.md",
13
13
  "LICENSE"
14
14
  ],
15
+ "np": {
16
+ "tests": false
17
+ },
15
18
  "keywords": [
16
19
  "ai",
17
20
  "ide",