@petersobhy/ai-toolkit 1.12.3 → 1.12.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.
- package/index.js +16 -4
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -10,6 +10,7 @@ const BRANCH = 'main';
|
|
|
10
10
|
const SKILLS_PATH = 'skills';
|
|
11
11
|
const INSTALL_DIR = path.join(os.homedir(), '.claude', 'commands');
|
|
12
12
|
const SCRIPTS_DIR = path.join(os.homedir(), '.ai-toolkit', 'scripts');
|
|
13
|
+
const MANIFEST_FILE = path.join(os.homedir(), '.ai-toolkit', 'installed.json');
|
|
13
14
|
|
|
14
15
|
const RAW_BASE = `https://raw.githubusercontent.com/${REPO}/${BRANCH}`;
|
|
15
16
|
const API_BASE = `https://api.github.com/repos/${REPO}/contents`;
|
|
@@ -47,11 +48,18 @@ async function listAvailable() {
|
|
|
47
48
|
.map(e => e.name);
|
|
48
49
|
}
|
|
49
50
|
|
|
51
|
+
function readInstalledManifest() {
|
|
52
|
+
if (!fs.existsSync(MANIFEST_FILE)) return {};
|
|
53
|
+
try { return JSON.parse(fs.readFileSync(MANIFEST_FILE, 'utf8')); } catch { return {}; }
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function writeInstalledManifest(manifest) {
|
|
57
|
+
fs.mkdirSync(path.dirname(MANIFEST_FILE), { recursive: true });
|
|
58
|
+
fs.writeFileSync(MANIFEST_FILE, JSON.stringify(manifest, null, 2));
|
|
59
|
+
}
|
|
60
|
+
|
|
50
61
|
function listInstalled() {
|
|
51
|
-
|
|
52
|
-
return fs.readdirSync(INSTALL_DIR)
|
|
53
|
-
.filter(f => f.endsWith('.md'))
|
|
54
|
-
.map(f => f.replace(/\.md$/, ''));
|
|
62
|
+
return Object.keys(readInstalledManifest());
|
|
55
63
|
}
|
|
56
64
|
|
|
57
65
|
// Fetch skill folder contents from GitHub API
|
|
@@ -97,6 +105,10 @@ async function installSkill(name, manifest = {}) {
|
|
|
97
105
|
}
|
|
98
106
|
|
|
99
107
|
const version = manifest[name]?.version;
|
|
108
|
+
const installed = readInstalledManifest();
|
|
109
|
+
installed[name] = { installedAt: new Date().toISOString(), version: version || null };
|
|
110
|
+
writeInstalledManifest(installed);
|
|
111
|
+
|
|
100
112
|
console.log(` ✓ ${name}${version ? ` v${version}` : ''}`);
|
|
101
113
|
return true;
|
|
102
114
|
}
|