@c-d-cc/reap 0.7.2 → 0.7.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/cli.js CHANGED
@@ -9137,6 +9137,29 @@ async function syncGenomeFromProject(projectRoot, genomePath, onProgress) {
9137
9137
  await writeTextFile2(join4(genomePath, "principles.md"), generatePrinciples(scan));
9138
9138
  log("Generating source-map.md...");
9139
9139
  await writeTextFile2(join4(genomePath, "source-map.md"), generateSourceMap(scan));
9140
+ const { mkdir: mkdir3 } = await import("fs/promises");
9141
+ const domainDir = join4(genomePath, "domain");
9142
+ await mkdir3(domainDir, { recursive: true });
9143
+ const domainReadme = join4(domainDir, "README.md");
9144
+ if (!await fileExists(domainReadme)) {
9145
+ await writeTextFile2(domainReadme, [
9146
+ "# Domain Rules",
9147
+ "",
9148
+ "> This directory stores business rules that cannot be derived from code structure alone.",
9149
+ "> Run `/reap.sync` to scan source code for domain knowledge and auto-generate domain files.",
9150
+ "",
9151
+ "Examples of domain rules:",
9152
+ "- State machines and status transitions",
9153
+ "- Policy rules with thresholds or conditions",
9154
+ "- Classification logic driven by business categories",
9155
+ "- Hardcoded domain constants with business meaning",
9156
+ "- Workflow orchestration sequences",
9157
+ "",
9158
+ "Each file should follow the domain-guide template (`~/.reap/templates/domain-guide.md`).",
9159
+ ""
9160
+ ].join(`
9161
+ `));
9162
+ }
9140
9163
  }
9141
9164
  var init_genome_sync = __esm(() => {
9142
9165
  init_fs();
@@ -9350,16 +9373,6 @@ class ClaudeCodeAdapter {
9350
9373
  const dest = join2(ReapPaths.userReapCommands, `${cmd}.md`);
9351
9374
  await writeTextFile(dest, await readTextFileOrThrow(src));
9352
9375
  }
9353
- await mkdir(this.commandsDir, { recursive: true });
9354
- for (const cmd of commandNames) {
9355
- const dest = join2(this.commandsDir, `${cmd}.md`);
9356
- const redirectContent = `---
9357
- description: "REAP — redirected to ~/.reap/commands/"
9358
- ---
9359
- Read \`~/.reap/commands/${cmd}.md\` and follow the instructions there.
9360
- `;
9361
- await writeTextFile(dest, redirectContent);
9362
- }
9363
9376
  }
9364
9377
  async removeStaleCommands(validNames) {
9365
9378
  try {
@@ -9581,16 +9594,6 @@ class OpenCodeAdapter {
9581
9594
  const dest = join3(ReapPaths.userReapCommands, `${cmd}.md`);
9582
9595
  await writeTextFile(dest, await readTextFileOrThrow(src));
9583
9596
  }
9584
- await mkdir2(this.commandsDir, { recursive: true });
9585
- for (const cmd of commandNames) {
9586
- const dest = join3(this.commandsDir, `${cmd}.md`);
9587
- const redirectContent = `---
9588
- description: "REAP — redirected to ~/.reap/commands/"
9589
- ---
9590
- Read \`~/.reap/commands/${cmd}.md\` and follow the instructions there.
9591
- `;
9592
- await writeTextFile(dest, redirectContent);
9593
- }
9594
9597
  }
9595
9598
  async removeStaleCommands(validNames) {
9596
9599
  try {
@@ -10683,32 +10686,21 @@ async function updateProject(projectRoot, dryRun = false) {
10683
10686
  }
10684
10687
  for (const adapter of adapters) {
10685
10688
  const agentCmdDir = adapter.getCommandsDir();
10686
- const label = `${adapter.displayName}`;
10687
- for (const file of commandFiles) {
10688
- if (!file.endsWith(".md"))
10689
- continue;
10690
- const cmdName = file.replace(/\.md$/, "");
10691
- const redirectContent = `---
10692
- description: "REAP redirected to ~/.reap/commands/"
10693
- ---
10694
- Read \`~/.reap/commands/${cmdName}.md\` and follow the instructions there.
10695
- `;
10696
- const dest = join10(agentCmdDir, file);
10697
- const existingContent = await readTextFile(dest);
10698
- if (existingContent !== null && existingContent === redirectContent) {
10699
- result.skipped.push(`[${label}] commands/${file}`);
10700
- } else {
10701
- if (!dryRun) {
10702
- await mkdir6(agentCmdDir, { recursive: true });
10703
- await writeTextFile(dest, redirectContent);
10689
+ const label = adapter.displayName;
10690
+ try {
10691
+ const existing = await readdir9(agentCmdDir);
10692
+ for (const file of existing) {
10693
+ if (!file.startsWith("reap.") || !file.endsWith(".md"))
10694
+ continue;
10695
+ const filePath = join10(agentCmdDir, file);
10696
+ const content = await readTextFile(filePath);
10697
+ if (content !== null && content.includes("redirected to ~/.reap/commands/")) {
10698
+ if (!dryRun)
10699
+ await unlink3(filePath);
10700
+ result.removed.push(`[${label}] commands/${file} (Phase 2: redirect removed)`);
10704
10701
  }
10705
- result.updated.push(`[${label}] commands/${file}`);
10706
10702
  }
10707
- }
10708
- const validCommandFiles = new Set(commandFiles);
10709
- if (!dryRun) {
10710
- await adapter.removeStaleCommands(validCommandFiles);
10711
- }
10703
+ } catch {}
10712
10704
  }
10713
10705
  await mkdir6(ReapPaths.userReapTemplates, { recursive: true });
10714
10706
  const artifactFiles = ["01-objective.md", "02-planning.md", "03-implementation.md", "04-validation.md", "05-completion.md"];
@@ -10947,7 +10939,7 @@ async function fixProject(projectRoot) {
10947
10939
  // src/cli/index.ts
10948
10940
  init_fs();
10949
10941
  import { join as join11 } from "path";
10950
- program.name("reap").description("REAP — Recursive Evolutionary Autonomous Pipeline").version("0.7.2");
10942
+ program.name("reap").description("REAP — Recursive Evolutionary Autonomous Pipeline").version("0.7.4");
10951
10943
  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) => {
10952
10944
  try {
10953
10945
  const cwd = process.cwd();
@@ -46,12 +46,26 @@ Scan the project to understand its current state:
46
46
  - Environment requirements, runtime constraints
47
47
  - External service dependencies
48
48
 
49
+ **Domain Knowledge** (→ `genome/domain/`):
50
+ - Read `~/.reap/templates/domain-guide.md` for domain file writing principles
51
+ - Scan source code for business rules NOT derivable from infrastructure analysis:
52
+ - State machines and status transitions (e.g., post lifecycle, order states)
53
+ - Policy rules with thresholds, limits, or conditions (e.g., rate limits, scoring criteria)
54
+ - Classification/branching logic driven by business categories (e.g., template selection by type)
55
+ - Hardcoded domain constants (keyword lists, prompt templates, magic numbers with business meaning)
56
+ - Workflow orchestration sequences (e.g., approval flows, pipeline stages)
57
+ - For each discovered domain rule cluster, evaluate:
58
+ - "Would an agent implementing this feature ask 'where is this rule?'" → YES = create domain file
59
+ - "Does a single item in an upper-level genome file require 3+ lines of explanation?" → YES = extract to domain file
60
+ - Even if `genome/domain/` is currently empty, treat it as "not yet created" rather than "not needed"
61
+
49
62
  ### 3. Diff Analysis
50
63
  Compare source analysis with current Genome and identify:
51
64
  - **Additions**: Things in code but not in Genome
52
65
  - **Changes**: Things in Genome that no longer match code
53
66
  - **Removals**: Things in Genome that no longer exist in code
54
67
  - **Gaps**: Areas where Genome has placeholders but code has established patterns
68
+ - **Domain gaps**: Business rules in code that have no corresponding `domain/` file
55
69
 
56
70
  ### 4. Report to Human
57
71
  Present a structured diff report:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@c-d-cc/reap",
3
- "version": "0.7.2",
3
+ "version": "0.7.4",
4
4
  "description": "Recursive Evolutionary Autonomous Pipeline — AI and humans evolve software across generations",
5
5
  "type": "module",
6
6
  "license": "MIT",