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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/bin.js +47 -13
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ahhc",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Hai-Ching's Claude Code Skill CLI",
5
5
  "bin": {
6
6
  "ahhc": "./src/bin.js"
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 CLAUDE_MD_URL = `https://raw.githubusercontent.com/${REPO}/main/CLAUDE.md`;
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
- console.log("Installing skills...");
11
- execSync(`npx openskills install ${REPO} --global -y`, {
12
- stdio: "inherit",
13
- });
14
- console.log("Installing global CLAUDE.md...");
15
- execSync(`curl -o ~/.claude/CLAUDE.md ${CLAUDE_MD_URL}`, {
16
- stdio: "inherit",
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
- console.log("Removing global CLAUDE.md...");
24
- execSync("rm -f ~/.claude/CLAUDE.md", { stdio: "inherit" });
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: aaiii <install|uninstall> (i, u)");
66
+ console.log("Usage: ahhc <install|uninstall> (i, u)");
33
67
  process.exit(0);
34
68
  }
35
69
 
36
- commands[cmd]();
70
+ commands[cmd]();