aicm 0.14.4 → 0.14.5

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.
Files changed (46) hide show
  1. package/dist/commands/install.js +5 -5
  2. package/package.json +1 -1
  3. package/dist/api_v2.d.ts +0 -9
  4. package/dist/api_v2.js +0 -12
  5. package/dist/bin/aicm_v2.d.ts +0 -2
  6. package/dist/bin/aicm_v2.js +0 -8
  7. package/dist/cli_v2.d.ts +0 -2
  8. package/dist/cli_v2.js +0 -94
  9. package/dist/commands/install/install-package.d.ts +0 -53
  10. package/dist/commands/install/install-package.js +0 -122
  11. package/dist/commands/install/install-single-package.d.ts +0 -53
  12. package/dist/commands/install/install-single-package.js +0 -139
  13. package/dist/commands/install/install-workspaces.d.ts +0 -9
  14. package/dist/commands/install/install-workspaces.js +0 -172
  15. package/dist/commands/install_new.d.ts +0 -17
  16. package/dist/commands/install_new.js +0 -457
  17. package/dist/commands/install_v2.d.ts +0 -52
  18. package/dist/commands/install_v2.js +0 -505
  19. package/dist/commands/install_/327/2242.d.ts +0 -59
  20. package/dist/commands/install_/327/2242.js +0 -546
  21. package/dist/commands/workspaces/discovery.d.ts +0 -7
  22. package/dist/commands/workspaces/discovery.js +0 -50
  23. package/dist/commands/workspaces/workspaces-install.d.ts +0 -9
  24. package/dist/commands/workspaces/workspaces-install.js +0 -48
  25. package/dist/index.d.ts +0 -2
  26. package/dist/index.js +0 -76
  27. package/dist/types/index.d.ts +0 -64
  28. package/dist/types/index.js +0 -2
  29. package/dist/utils/config_new.d.ts +0 -64
  30. package/dist/utils/config_new.js +0 -228
  31. package/dist/utils/config_v2.d.ts +0 -64
  32. package/dist/utils/config_v2.js +0 -250
  33. package/dist/utils/glob-handler.d.ts +0 -35
  34. package/dist/utils/glob-handler.js +0 -125
  35. package/dist/utils/mcp-writer.d.ts +0 -14
  36. package/dist/utils/mcp-writer.js +0 -69
  37. package/dist/utils/mdc-parser.d.ts +0 -9
  38. package/dist/utils/mdc-parser.js +0 -59
  39. package/dist/utils/rule-collector.d.ts +0 -33
  40. package/dist/utils/rule-collector.js +0 -169
  41. package/dist/utils/rule-detector.d.ts +0 -4
  42. package/dist/utils/rule-detector.js +0 -31
  43. package/dist/utils/rule-status.d.ts +0 -8
  44. package/dist/utils/rule-status.js +0 -53
  45. package/dist/utils/rule-writer.d.ts +0 -6
  46. package/dist/utils/rule-writer.js +0 -118
@@ -1,169 +0,0 @@
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.findPackageRoot = findPackageRoot;
7
- exports.initRuleCollection = initRuleCollection;
8
- exports.addRuleToCollection = addRuleToCollection;
9
- exports.collectLocalRule = collectLocalRule;
10
- exports.collectNpmRule = collectNpmRule;
11
- const fs_extra_1 = __importDefault(require("fs-extra"));
12
- const node_path_1 = __importDefault(require("node:path"));
13
- const mdc_parser_1 = require("./mdc-parser");
14
- /**
15
- * Find the root directory of a package by name
16
- * @param packageName The name of the package
17
- * @returns The absolute path to the package's root directory
18
- */
19
- function findPackageRoot(packageName) {
20
- try {
21
- // Method 1: Try to use require.resolve
22
- const packageEntry = require.resolve(packageName, {
23
- paths: [process.cwd()],
24
- });
25
- // Navigate up until we find a package.json or reach a reasonable limit
26
- let currentDir = node_path_1.default.dirname(packageEntry);
27
- let iterations = 0;
28
- const maxIterations = 3; // Prevent infinite loops
29
- while (iterations < maxIterations) {
30
- // If we found the package.json, this is likely the package root
31
- if (fs_extra_1.default.existsSync(node_path_1.default.join(currentDir, "package.json"))) {
32
- return currentDir;
33
- }
34
- // Move up one directory
35
- const parentDir = node_path_1.default.dirname(currentDir);
36
- // If we've reached the root or haven't changed directory, stop
37
- if (parentDir === currentDir) {
38
- break;
39
- }
40
- currentDir = parentDir;
41
- iterations++;
42
- }
43
- // If we couldn't find package.json, use the directory of the entry point
44
- return node_path_1.default.dirname(packageEntry);
45
- }
46
- catch (_a) {
47
- // Method 2: Fall back to direct node_modules resolution
48
- const nodeModulesPath = node_path_1.default.resolve(process.cwd(), "node_modules", packageName);
49
- if (!fs_extra_1.default.existsSync(nodeModulesPath)) {
50
- throw new Error(`Package '${packageName}' not found in node_modules.`);
51
- }
52
- return nodeModulesPath;
53
- }
54
- }
55
- /**
56
- * Initialize an empty rule collection
57
- */
58
- function initRuleCollection() {
59
- return {
60
- cursor: [],
61
- windsurf: [],
62
- codex: [],
63
- };
64
- }
65
- /**
66
- * Add a rule to the collection
67
- * @param collection The rule collection to add to
68
- * @param rule The rule content to add
69
- * @param ides The IDEs to add the rule for
70
- */
71
- function addRuleToCollection(collection, rule, ides) {
72
- for (const ide of ides) {
73
- if (ide === "cursor" &&
74
- !collection.cursor.some((r) => r.name === rule.name)) {
75
- collection.cursor.push(rule);
76
- }
77
- else if (ide === "windsurf" &&
78
- !collection.windsurf.some((r) => r.name === rule.name)) {
79
- collection.windsurf.push(rule);
80
- }
81
- else if (ide === "codex" &&
82
- !collection.codex.some((r) => r.name === rule.name)) {
83
- collection.codex.push(rule);
84
- }
85
- }
86
- }
87
- /**
88
- * Collect a rule from a local file source
89
- * @param ruleName The name of the rule
90
- * @param source The source path (relative or absolute)
91
- * @param ruleBasePath Optional base path for resolving relative paths
92
- * @returns The rule content
93
- */
94
- function collectLocalRule(ruleName, source, ruleBasePath) {
95
- if (source === false)
96
- throw new Error(`Rule '${ruleName}' is canceled and should not be processed.`);
97
- // Resolve path relative to base path or current directory
98
- let sourcePath = source;
99
- if (!node_path_1.default.isAbsolute(source)) {
100
- if (ruleBasePath) {
101
- // If a base path is provided (e.g., for presets), resolve relative to that
102
- sourcePath = node_path_1.default.resolve(node_path_1.default.dirname(ruleBasePath), source);
103
- }
104
- else {
105
- // Otherwise resolve relative to current directory
106
- sourcePath = node_path_1.default.resolve(process.cwd(), source);
107
- }
108
- }
109
- if (!fs_extra_1.default.existsSync(sourcePath)) {
110
- throw new Error(`Source file ${sourcePath} not found.`);
111
- }
112
- // Parse the MDC file to extract metadata and content
113
- const { metadata, content } = (0, mdc_parser_1.parseMdcFile)(sourcePath);
114
- return {
115
- name: ruleName,
116
- content,
117
- metadata,
118
- sourcePath,
119
- };
120
- }
121
- /**
122
- * Collect a rule from an npm package
123
- * @param ruleName The name of the rule
124
- * @param source The npm package source (can include path)
125
- * @returns The rule content
126
- */
127
- function collectNpmRule(ruleName, source) {
128
- if (source === false)
129
- throw new Error(`Rule '${ruleName}' is canceled and should not be processed.`);
130
- // Parse source into package and file path
131
- let packageName;
132
- let packagePath;
133
- if (source.includes("/") && !source.startsWith("@")) {
134
- // Format: "package-name/path/to/file.mdc"
135
- const firstSlash = source.indexOf("/");
136
- packageName = source.substring(0, firstSlash);
137
- packagePath = source.substring(firstSlash + 1);
138
- }
139
- else if (source.startsWith("@")) {
140
- // Format: "@scope/package/path/to/file.mdc"
141
- const parts = source.split("/");
142
- // @scope/package
143
- packageName = `${parts[0]}/${parts[1]}`;
144
- // Remaining path, if any
145
- packagePath = parts.slice(2).join("/");
146
- }
147
- else {
148
- // Format: "package-name" (whole package)
149
- packageName = source;
150
- packagePath = "";
151
- }
152
- // Try to find the package and get its root directory
153
- const packageRoot = findPackageRoot(packageName);
154
- // Resolve the full path to the rule file
155
- const ruleFile = packagePath
156
- ? node_path_1.default.join(packageRoot, packagePath)
157
- : packageRoot;
158
- if (!fs_extra_1.default.existsSync(ruleFile)) {
159
- throw new Error(`Rule file not found in package: ${ruleFile}`);
160
- }
161
- // Parse the MDC file to extract metadata and content
162
- const { metadata, content } = (0, mdc_parser_1.parseMdcFile)(ruleFile);
163
- return {
164
- name: ruleName,
165
- content,
166
- metadata,
167
- sourcePath: ruleFile,
168
- };
169
- }
@@ -1,4 +0,0 @@
1
- /**
2
- * Detects the rule type from the source string
3
- */
4
- export declare function detectRuleType(source: string): "npm" | "local";
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.detectRuleType = detectRuleType;
4
- /**
5
- * Detects the rule type from the source string
6
- */
7
- function detectRuleType(source) {
8
- if (source.startsWith("http://") || source.startsWith("https://")) {
9
- throw new Error("URL-based rules are not supported due to security concerns. Please use npm packages or local files instead.");
10
- }
11
- // Check if it's a local file path
12
- if (source.startsWith("/") ||
13
- source.startsWith("./") ||
14
- source.startsWith("../") ||
15
- source.startsWith("\\") ||
16
- source.startsWith(".\\") ||
17
- (source.includes(":\\") && source.includes("\\")) || // Windows absolute path with backslash
18
- (source.includes(":") &&
19
- (source.startsWith("file:") || source.includes(":\\"))) // Path with protocol or Windows drive letter
20
- ) {
21
- return "local";
22
- }
23
- try {
24
- const packageName = source.split(/[/\\]/)[0];
25
- require.resolve(packageName, { paths: [__dirname, process.cwd()] });
26
- return "npm";
27
- }
28
- catch (_a) {
29
- return "local";
30
- }
31
- }
@@ -1,8 +0,0 @@
1
- /**
2
- * Get the IDE-specific rule installation paths
3
- */
4
- export declare function getIdePaths(): Record<string, string>;
5
- /**
6
- * Check if a rule is installed in the specified IDEs
7
- */
8
- export declare function checkRuleStatus(ruleName: string, ides: string[]): boolean;
@@ -1,53 +0,0 @@
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.getIdePaths = getIdePaths;
7
- exports.checkRuleStatus = checkRuleStatus;
8
- const fs_extra_1 = __importDefault(require("fs-extra"));
9
- const node_path_1 = __importDefault(require("node:path"));
10
- /**
11
- * Get the IDE-specific rule installation paths
12
- */
13
- function getIdePaths() {
14
- const projectDir = process.cwd(); // Get current working directory (project root)
15
- return {
16
- cursor: node_path_1.default.join(projectDir, ".cursor", "rules", "aicm"),
17
- windsurf: node_path_1.default.join(projectDir, ".aicm"),
18
- codex: node_path_1.default.join(projectDir, ".aicm"),
19
- };
20
- }
21
- /**
22
- * Check if a rule is installed in the specified IDEs
23
- */
24
- function checkRuleStatus(ruleName, ides) {
25
- const idePaths = getIdePaths();
26
- return ides.every((ide) => {
27
- if (!idePaths[ide]) {
28
- return false;
29
- }
30
- if (ide === "cursor") {
31
- return fs_extra_1.default.existsSync(node_path_1.default.join(idePaths[ide], `${ruleName}.mdc`));
32
- }
33
- if (ide === "windsurf") {
34
- const ruleExists = fs_extra_1.default.existsSync(node_path_1.default.join(idePaths[ide], `${ruleName}.md`));
35
- const windsurfRulesPath = node_path_1.default.join(process.cwd(), ".windsurfrules");
36
- if (fs_extra_1.default.existsSync(windsurfRulesPath)) {
37
- const windsurfRulesContent = fs_extra_1.default.readFileSync(windsurfRulesPath, "utf8");
38
- return (ruleExists && windsurfRulesContent.includes(`.aicm/${ruleName}.md`));
39
- }
40
- return false;
41
- }
42
- if (ide === "codex") {
43
- const ruleExists = fs_extra_1.default.existsSync(node_path_1.default.join(idePaths[ide], `${ruleName}.md`));
44
- const codexFilePath = node_path_1.default.join(process.cwd(), "AGENTS.md");
45
- if (fs_extra_1.default.existsSync(codexFilePath)) {
46
- const codexContent = fs_extra_1.default.readFileSync(codexFilePath, "utf8");
47
- return ruleExists && codexContent.includes(`.aicm/${ruleName}.md`);
48
- }
49
- return false;
50
- }
51
- return false;
52
- });
53
- }
@@ -1,6 +0,0 @@
1
- import { RuleCollection } from "../types";
2
- /**
3
- * Write all collected rules to their respective IDE targets
4
- * @param collection The collection of rules to write
5
- */
6
- export declare function writeRulesToTargets(collection: RuleCollection): void;
@@ -1,118 +0,0 @@
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.writeRulesToTargets = writeRulesToTargets;
7
- const fs_extra_1 = __importDefault(require("fs-extra"));
8
- const node_path_1 = __importDefault(require("node:path"));
9
- const rules_file_writer_1 = require("./rules-file-writer");
10
- /**
11
- * Write all collected rules to their respective IDE targets
12
- * @param collection The collection of rules to write
13
- */
14
- function writeRulesToTargets(collection) {
15
- // Write Cursor rules
16
- if (collection.cursor.length > 0) {
17
- writeCursorRules(collection.cursor, ".cursor/rules/aicm");
18
- }
19
- // Write Windsurf rules
20
- if (collection.windsurf.length > 0) {
21
- writeRulesForFile(collection.windsurf, ".aicm", ".windsurfrules");
22
- }
23
- if (collection.codex.length > 0) {
24
- writeRulesForFile(collection.codex, ".aicm", "AGENTS.md");
25
- }
26
- }
27
- /**
28
- * Extract a normalized namespace from a preset path
29
- * @param presetPath The original preset path
30
- * @returns An array of path segments to use for namespacing
31
- */
32
- function extractNamespaceFromPresetPath(presetPath) {
33
- // Special case: npm package names always use forward slashes, regardless of platform
34
- if (presetPath.startsWith("@")) {
35
- // For scoped packages like @scope/package/subdir, create nested directories
36
- return presetPath.split("/");
37
- }
38
- // Handle both Unix and Windows style path separators
39
- const parts = presetPath.split(/[/\\]/);
40
- return parts.filter((part) => part.length > 0); // Filter out empty segments
41
- }
42
- /**
43
- * Write rules to Cursor's rules directory
44
- * @param rules The rules to write
45
- * @param cursorRulesDir The path to Cursor's rules directory
46
- */
47
- function writeCursorRules(rules, cursorRulesDir) {
48
- fs_extra_1.default.emptyDirSync(cursorRulesDir);
49
- for (const rule of rules) {
50
- let rulePath;
51
- // Parse rule name into path segments using platform-specific path separator
52
- const ruleNameParts = rule.name.split(/[/\\]/).filter(Boolean);
53
- if (rule.presetPath) {
54
- // For rules from presets, create a namespaced directory structure
55
- const namespace = extractNamespaceFromPresetPath(rule.presetPath);
56
- // Path will be: cursorRulesDir/namespace/rule-name.mdc
57
- rulePath = node_path_1.default.join(cursorRulesDir, ...namespace, ...ruleNameParts);
58
- }
59
- else {
60
- // For local rules, maintain the original flat structure
61
- rulePath = node_path_1.default.join(cursorRulesDir, ...ruleNameParts);
62
- }
63
- const ruleFile = rulePath + ".mdc";
64
- fs_extra_1.default.ensureDirSync(node_path_1.default.dirname(ruleFile));
65
- if (fs_extra_1.default.existsSync(rule.sourcePath)) {
66
- fs_extra_1.default.copyFileSync(rule.sourcePath, ruleFile);
67
- }
68
- else {
69
- const mdcContent = `---\n${JSON.stringify(rule.metadata, null, 2)}\n---\n\n${rule.content}`;
70
- fs_extra_1.default.writeFileSync(ruleFile, mdcContent);
71
- }
72
- }
73
- }
74
- /**
75
- * Write rules to a shared directory and update the given rules file
76
- * @param rules The rules to write
77
- */
78
- function writeRulesForFile(rules, ruleDir, rulesFile) {
79
- fs_extra_1.default.emptyDirSync(ruleDir);
80
- const ruleFiles = rules.map((rule) => {
81
- let rulePath;
82
- // Parse rule name into path segments using platform-specific path separator
83
- const ruleNameParts = rule.name.split(/[/\\]/).filter(Boolean);
84
- if (rule.presetPath) {
85
- // For rules from presets, create a namespaced directory structure
86
- const namespace = extractNamespaceFromPresetPath(rule.presetPath);
87
- // Path will be: ruleDir/namespace/rule-name.md
88
- rulePath = node_path_1.default.join(ruleDir, ...namespace, ...ruleNameParts);
89
- }
90
- else {
91
- // For local rules, maintain the original flat structure
92
- rulePath = node_path_1.default.join(ruleDir, ...ruleNameParts);
93
- }
94
- const physicalRulePath = rulePath + ".md";
95
- fs_extra_1.default.ensureDirSync(node_path_1.default.dirname(physicalRulePath));
96
- fs_extra_1.default.writeFileSync(physicalRulePath, rule.content);
97
- const relativeRuleDir = node_path_1.default.basename(ruleDir); // Gets '.rules'
98
- // For the rules file, maintain the same structure
99
- let windsurfPath;
100
- if (rule.presetPath) {
101
- const namespace = extractNamespaceFromPresetPath(rule.presetPath);
102
- windsurfPath =
103
- node_path_1.default.join(relativeRuleDir, ...namespace, ...ruleNameParts) + ".md";
104
- }
105
- else {
106
- windsurfPath = node_path_1.default.join(relativeRuleDir, ...ruleNameParts) + ".md";
107
- }
108
- // Normalize to POSIX style for cross-platform compatibility in .windsurfrules
109
- const windsurfPathPosix = windsurfPath.replace(/\\/g, "/");
110
- return {
111
- name: rule.name,
112
- path: windsurfPathPosix,
113
- metadata: rule.metadata,
114
- };
115
- });
116
- const windsurfRulesContent = (0, rules_file_writer_1.generateRulesFileContent)(ruleFiles);
117
- (0, rules_file_writer_1.writeRulesFile)(windsurfRulesContent, node_path_1.default.join(process.cwd(), rulesFile));
118
- }