aicm 0.6.2 → 0.6.4
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/utils/config.d.ts
CHANGED
|
@@ -2,9 +2,6 @@ import { Config, Rules } from "../types";
|
|
|
2
2
|
interface ConfigWithMeta extends Config {
|
|
3
3
|
__ruleSources?: Record<string, string>;
|
|
4
4
|
}
|
|
5
|
-
/**
|
|
6
|
-
* Get the full path to a preset file
|
|
7
|
-
*/
|
|
8
5
|
export declare function getFullPresetPath(presetPath: string): string | null;
|
|
9
6
|
/**
|
|
10
7
|
* Load a preset file and return its rules and mcpServers
|
package/dist/utils/config.js
CHANGED
|
@@ -11,49 +11,28 @@ exports.getRuleSource = getRuleSource;
|
|
|
11
11
|
exports.saveConfig = saveConfig;
|
|
12
12
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
13
13
|
const node_path_1 = __importDefault(require("node:path"));
|
|
14
|
-
const rule_detector_1 = require("./rule-detector");
|
|
15
14
|
const cosmiconfig_1 = require("cosmiconfig");
|
|
16
15
|
const CONFIG_FILE = "aicm.json";
|
|
17
|
-
/**
|
|
18
|
-
* Get the full path to a preset file
|
|
19
|
-
*/
|
|
20
16
|
function getFullPresetPath(presetPath) {
|
|
17
|
+
if (presetPath.endsWith(".json") && fs_extra_1.default.pathExistsSync(presetPath)) {
|
|
18
|
+
return presetPath;
|
|
19
|
+
}
|
|
21
20
|
try {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
fullPresetPath = require.resolve(presetPath, {
|
|
28
|
-
paths: [process.cwd()],
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
catch (_a) {
|
|
32
|
-
// If not a file, check if it's a directory in node_modules
|
|
33
|
-
const directPath = node_path_1.default.join(process.cwd(), "node_modules", presetPath);
|
|
34
|
-
if (fs_extra_1.default.existsSync(directPath)) {
|
|
35
|
-
// If it's a directory, look for aicm.json inside
|
|
36
|
-
const aicmJsonPath = node_path_1.default.join(directPath, "aicm.json");
|
|
37
|
-
if (fs_extra_1.default.existsSync(aicmJsonPath)) {
|
|
38
|
-
fullPresetPath = aicmJsonPath;
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
// If aicm.json doesn't exist, treat the directory as invalid
|
|
42
|
-
return null;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
return null;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
21
|
+
let absolutePresetPath;
|
|
22
|
+
if (presetPath.endsWith(".json")) {
|
|
23
|
+
absolutePresetPath = require.resolve(presetPath, {
|
|
24
|
+
paths: [process.cwd()],
|
|
25
|
+
});
|
|
49
26
|
}
|
|
50
27
|
else {
|
|
51
|
-
|
|
52
|
-
|
|
28
|
+
const presetPathWithConfig = node_path_1.default.join(presetPath, "aicm.json");
|
|
29
|
+
absolutePresetPath = require.resolve(presetPathWithConfig, {
|
|
30
|
+
paths: [process.cwd()],
|
|
31
|
+
});
|
|
53
32
|
}
|
|
54
|
-
return fs_extra_1.default.existsSync(
|
|
33
|
+
return fs_extra_1.default.existsSync(absolutePresetPath) ? absolutePresetPath : null;
|
|
55
34
|
}
|
|
56
|
-
catch (
|
|
35
|
+
catch (_a) {
|
|
57
36
|
return null;
|
|
58
37
|
}
|
|
59
38
|
}
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.detectRuleType = detectRuleType;
|
|
7
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
-
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
9
4
|
/**
|
|
10
5
|
* Detects the rule type from the source string
|
|
11
6
|
*/
|
|
@@ -25,18 +20,12 @@ function detectRuleType(source) {
|
|
|
25
20
|
) {
|
|
26
21
|
return "local";
|
|
27
22
|
}
|
|
28
|
-
// Check if it's an npm package with a direct node_modules reference
|
|
29
|
-
const packageName = source.split(/[/\\]/)[0]; // Support both slash types
|
|
30
|
-
if (fs_extra_1.default.existsSync(node_path_1.default.resolve(process.cwd(), "node_modules", packageName))) {
|
|
31
|
-
return "npm";
|
|
32
|
-
}
|
|
33
|
-
// Try to interpret as npm package
|
|
34
23
|
try {
|
|
24
|
+
const packageName = source.split(/[/\\]/)[0];
|
|
35
25
|
require.resolve(packageName, { paths: [process.cwd()] });
|
|
36
26
|
return "npm";
|
|
37
27
|
}
|
|
38
28
|
catch (_a) {
|
|
39
|
-
// If we couldn't resolve it as an npm package, assume it's a local path
|
|
40
29
|
return "local";
|
|
41
30
|
}
|
|
42
31
|
}
|
package/package.json
CHANGED
|
@@ -1,84 +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.checkUpdates = void 0;
|
|
7
|
-
exports.checkNpmPackageUpdates = checkNpmPackageUpdates;
|
|
8
|
-
const commander_1 = require("commander");
|
|
9
|
-
const config_1 = require("../utils/config");
|
|
10
|
-
const rule_detector_1 = require("../utils/rule-detector");
|
|
11
|
-
const semver_1 = __importDefault(require("semver"));
|
|
12
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
13
|
-
const child_process_1 = require("child_process");
|
|
14
|
-
const fs_1 = require("fs");
|
|
15
|
-
const path_1 = require("path");
|
|
16
|
-
exports.checkUpdates = new commander_1.Command("check-updates")
|
|
17
|
-
.description("Check for updates to installed rules")
|
|
18
|
-
.option("-a, --auto-sync", "Automatically sync updates if available")
|
|
19
|
-
.action(async (options) => {
|
|
20
|
-
const config = await (0, config_1.getConfig)();
|
|
21
|
-
if (!config) {
|
|
22
|
-
console.error("No configuration file found. Run 'rules-manager init' first.");
|
|
23
|
-
process.exit(1);
|
|
24
|
-
}
|
|
25
|
-
const updates = [];
|
|
26
|
-
const errors = [];
|
|
27
|
-
// Check each rule for updates
|
|
28
|
-
for (const [ruleName, source] of Object.entries(config.rules)) {
|
|
29
|
-
try {
|
|
30
|
-
const ruleType = (0, rule_detector_1.detectRuleType)(source);
|
|
31
|
-
if (ruleType === "npm") {
|
|
32
|
-
const { currentVersion, latestVersion } = await checkNpmPackageUpdates(source.split("/")[0] // Get package name from source
|
|
33
|
-
);
|
|
34
|
-
if (latestVersion && semver_1.default.gt(latestVersion, currentVersion)) {
|
|
35
|
-
updates.push({
|
|
36
|
-
name: ruleName,
|
|
37
|
-
current: currentVersion,
|
|
38
|
-
latest: latestVersion,
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
catch (error) {
|
|
44
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
45
|
-
errors.push(`Error checking updates for ${ruleName}: ${errorMessage}`);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
// Display results
|
|
49
|
-
if (updates.length > 0) {
|
|
50
|
-
console.log(chalk_1.default.yellow("\nUpdates available:"));
|
|
51
|
-
updates.forEach((update) => {
|
|
52
|
-
console.log(chalk_1.default.yellow(` ${update.name}: ${update.current} → ${update.latest}`));
|
|
53
|
-
});
|
|
54
|
-
if (options.autoSync) {
|
|
55
|
-
console.log(chalk_1.default.blue("\nAuto-syncing updates..."));
|
|
56
|
-
// Trigger install command with updated versions
|
|
57
|
-
// This will be implemented in the install command
|
|
58
|
-
process.exit(0);
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
console.log(chalk_1.default.blue("\nRun 'rules-manager install --update' to install updates"));
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
console.log(chalk_1.default.green("All rules are up to date!"));
|
|
66
|
-
}
|
|
67
|
-
if (errors.length > 0) {
|
|
68
|
-
console.error(chalk_1.default.red("\nErrors:"));
|
|
69
|
-
errors.forEach((error) => console.error(chalk_1.default.red(` ${error}`)));
|
|
70
|
-
process.exit(1);
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
async function checkNpmPackageUpdates(packageName) {
|
|
74
|
-
// Get current version from package.json
|
|
75
|
-
const packageJsonPath = (0, path_1.join)(process.cwd(), "node_modules", packageName, "package.json");
|
|
76
|
-
const packageJson = JSON.parse((0, fs_1.readFileSync)(packageJsonPath, "utf-8"));
|
|
77
|
-
const currentVersion = packageJson.version;
|
|
78
|
-
// Get latest version from npm registry
|
|
79
|
-
const stdout = (0, child_process_1.execSync)(`npm view ${packageName} version`, {
|
|
80
|
-
encoding: "utf-8",
|
|
81
|
-
});
|
|
82
|
-
const latestVersion = stdout.trim();
|
|
83
|
-
return { currentVersion, latestVersion };
|
|
84
|
-
}
|