@c-d-cc/reap 0.3.4 → 0.3.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/dist/cli.js CHANGED
@@ -10147,7 +10147,7 @@ async function fixProject(projectRoot) {
10147
10147
 
10148
10148
  // src/cli/index.ts
10149
10149
  import { join as join8 } from "path";
10150
- program.name("reap").description("REAP — Recursive Evolutionary Autonomous Pipeline").version("0.3.4");
10150
+ program.name("reap").description("REAP — Recursive Evolutionary Autonomous Pipeline").version("0.3.5");
10151
10151
  program.command("init").description("Initialize a new REAP project (Genesis)").argument("[project-name]", "Project name (defaults to current directory name)").option("-m, --mode <mode>", "Entry mode: greenfield, migration, adoption", "greenfield").option("-p, --preset <preset>", "Bootstrap with a genome preset (e.g., bun-hono-react)").action(async (projectName, options) => {
10152
10152
  try {
10153
10153
  const cwd = process.cwd();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@c-d-cc/reap",
3
- "version": "0.3.4",
3
+ "version": "0.3.5",
4
4
  "description": "Recursive Evolutionary Autonomous Pipeline — AI and humans evolve software across generations",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -23,7 +23,8 @@
23
23
  "reap": "dist/cli.js"
24
24
  },
25
25
  "files": [
26
- "dist/"
26
+ "dist/",
27
+ "scripts/postinstall.cjs"
27
28
  ],
28
29
  "engines": {
29
30
  "node": ">=18"
@@ -31,6 +32,7 @@
31
32
  "scripts": {
32
33
  "dev": "bun run src/cli/index.ts",
33
34
  "build": "node scripts/build.js",
35
+ "postinstall": "node scripts/postinstall.cjs",
34
36
  "prepublishOnly": "npm run build",
35
37
  "test": "bun test"
36
38
  },
@@ -0,0 +1,56 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * postinstall — install REAP slash commands to detected AI agents.
4
+ * Runs after `npm install -g @c-d-cc/reap`.
5
+ * Graceful: never fails npm install (always exits 0).
6
+ */
7
+ const { execSync } = require("child_process");
8
+ const { readdirSync, readFileSync, writeFileSync, mkdirSync, existsSync } = require("fs");
9
+ const { join, dirname } = require("path");
10
+ const { homedir } = require("os");
11
+
12
+ const AGENTS = [
13
+ { name: "Claude Code", bin: "claude", commandsDir: join(homedir(), ".claude", "commands") },
14
+ { name: "OpenCode", bin: "opencode", commandsDir: join(homedir(), ".config", "opencode", "commands") },
15
+ ];
16
+
17
+ function isInstalled(bin) {
18
+ try {
19
+ execSync(`which ${bin}`, { stdio: "ignore" });
20
+ return true;
21
+ } catch {
22
+ return false;
23
+ }
24
+ }
25
+
26
+ try {
27
+ // Resolve commands source: dist/templates/commands/ relative to this script
28
+ const commandsSource = join(dirname(__dirname), "dist", "templates", "commands");
29
+ if (!existsSync(commandsSource)) {
30
+ // During development or if dist not built yet, skip silently
31
+ process.exit(0);
32
+ }
33
+
34
+ const commandFiles = readdirSync(commandsSource).filter(f => f.endsWith(".md"));
35
+ if (commandFiles.length === 0) process.exit(0);
36
+
37
+ let installed = 0;
38
+ for (const agent of AGENTS) {
39
+ if (!isInstalled(agent.bin)) continue;
40
+
41
+ mkdirSync(agent.commandsDir, { recursive: true });
42
+ for (const file of commandFiles) {
43
+ const src = readFileSync(join(commandsSource, file), "utf-8");
44
+ writeFileSync(join(agent.commandsDir, file), src);
45
+ }
46
+ installed++;
47
+ console.log(` reap: ${agent.name} — ${commandFiles.length} slash commands installed`);
48
+ }
49
+
50
+ if (installed === 0) {
51
+ console.log(" reap: no supported AI agents detected (claude, opencode). Run 'reap update' after installing one.");
52
+ }
53
+ } catch (err) {
54
+ // Graceful failure — never break npm install
55
+ console.warn(" reap: postinstall warning —", err.message);
56
+ }