ahhc 1.0.0 → 1.1.0
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/package.json +1 -1
- package/src/bin.js +47 -13
package/package.json
CHANGED
package/src/bin.js
CHANGED
|
@@ -1,27 +1,61 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
const { execSync } = require("child_process");
|
|
4
|
+
const fs = require("fs");
|
|
5
|
+
const os = require("os");
|
|
6
|
+
const path = require("path");
|
|
4
7
|
|
|
5
8
|
const REPO = "ahueee/ahhc";
|
|
6
|
-
const
|
|
9
|
+
const RAW_BASE = `https://raw.githubusercontent.com/${REPO}/main`;
|
|
10
|
+
|
|
11
|
+
// Each target is installed only if its directory already exists on the machine.
|
|
12
|
+
// skillsCmd: command to install skills for this provider, or null if not supported.
|
|
13
|
+
const TARGETS = [
|
|
14
|
+
{ dir: "~/.claude", file: "CLAUDE.md", skillsCmd: `npx openskills install ${REPO} --global -y` },
|
|
15
|
+
{ dir: "~/.gemini", file: "GEMINI.md", skillsCmd: null },
|
|
16
|
+
{ dir: "~/.codex", file: "AGENTS.md", skillsCmd: null },
|
|
17
|
+
{ dir: "~/.factory", file: "AGENTS.md", skillsCmd: null },
|
|
18
|
+
{ dir: "~/.openclaw", file: "AGENTS.md", skillsCmd: null },
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
function expand(p) {
|
|
22
|
+
return p.startsWith("~") ? path.join(os.homedir(), p.slice(1)) : p;
|
|
23
|
+
}
|
|
7
24
|
|
|
8
25
|
const commands = {
|
|
9
26
|
install: () => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
27
|
+
for (const { dir, file, skillsCmd } of TARGETS) {
|
|
28
|
+
const absDir = expand(dir);
|
|
29
|
+
if (!fs.existsSync(absDir)) {
|
|
30
|
+
console.log(`Skipping ${dir}/${file} (directory not found)`);
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
if (skillsCmd) {
|
|
34
|
+
console.log(`Installing skills for ${dir}...`);
|
|
35
|
+
execSync(skillsCmd, { stdio: "inherit" });
|
|
36
|
+
}
|
|
37
|
+
const dest = path.join(absDir, file);
|
|
38
|
+
const url = `${RAW_BASE}/${file}`;
|
|
39
|
+
console.log(`Installing ${dir}/${file}...`);
|
|
40
|
+
try {
|
|
41
|
+
execSync(`curl -sf -o "${dest}" "${url}"`, { stdio: "inherit" });
|
|
42
|
+
} catch {
|
|
43
|
+
console.log(` (no ${file} found in repo, skipping)`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
18
46
|
console.log("Done!");
|
|
19
47
|
},
|
|
20
48
|
uninstall: () => {
|
|
21
49
|
console.log("Removing skills...");
|
|
22
50
|
execSync("rm -rf ~/.claude/skills/*", { stdio: "inherit" });
|
|
23
|
-
|
|
24
|
-
|
|
51
|
+
|
|
52
|
+
for (const { dir, file } of TARGETS) {
|
|
53
|
+
const dest = path.join(expand(dir), file);
|
|
54
|
+
if (fs.existsSync(dest)) {
|
|
55
|
+
console.log(`Removing ${dir}/${file}...`);
|
|
56
|
+
fs.unlinkSync(dest);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
25
59
|
console.log("Done!");
|
|
26
60
|
},
|
|
27
61
|
};
|
|
@@ -29,8 +63,8 @@ const commands = {
|
|
|
29
63
|
const aliases = { i: "install", u: "uninstall" };
|
|
30
64
|
const cmd = aliases[process.argv[2]] || process.argv[2];
|
|
31
65
|
if (!cmd || cmd === "-h" || cmd === "--help" || !commands[cmd]) {
|
|
32
|
-
console.log("Usage:
|
|
66
|
+
console.log("Usage: ahhc <install|uninstall> (i, u)");
|
|
33
67
|
process.exit(0);
|
|
34
68
|
}
|
|
35
69
|
|
|
36
|
-
commands[cmd]();
|
|
70
|
+
commands[cmd]();
|