@c-d-cc/reap 0.8.0 → 0.9.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/dist/cli.js +46 -1
- package/dist/templates/commands/reap.objective.md +5 -16
- package/dist/templates/commands/reap.sync.environment.md +84 -0
- package/dist/templates/commands/reap.sync.genome.md +109 -0
- package/dist/templates/commands/reap.sync.md +9 -101
- package/dist/templates/hooks/session-start.cjs +10 -2
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -9224,6 +9224,15 @@ class ReapPaths {
|
|
|
9224
9224
|
get environment() {
|
|
9225
9225
|
return join(this.root, "environment");
|
|
9226
9226
|
}
|
|
9227
|
+
get environmentSummary() {
|
|
9228
|
+
return join(this.environment, "summary.md");
|
|
9229
|
+
}
|
|
9230
|
+
get environmentDocs() {
|
|
9231
|
+
return join(this.environment, "docs");
|
|
9232
|
+
}
|
|
9233
|
+
get environmentResources() {
|
|
9234
|
+
return join(this.environment, "resources");
|
|
9235
|
+
}
|
|
9227
9236
|
get life() {
|
|
9228
9237
|
return join(this.root, "life");
|
|
9229
9238
|
}
|
|
@@ -9758,6 +9767,8 @@ var COMMAND_NAMES = [
|
|
|
9758
9767
|
"reap.abort",
|
|
9759
9768
|
"reap.status",
|
|
9760
9769
|
"reap.sync",
|
|
9770
|
+
"reap.sync.genome",
|
|
9771
|
+
"reap.sync.environment",
|
|
9761
9772
|
"reap.help",
|
|
9762
9773
|
"reap.update",
|
|
9763
9774
|
"reap.merge.start",
|
|
@@ -9789,6 +9800,8 @@ async function initProject(projectRoot, projectName, entryMode, preset, onProgre
|
|
|
9789
9800
|
await mkdir3(paths.genome, { recursive: true });
|
|
9790
9801
|
await mkdir3(paths.domain, { recursive: true });
|
|
9791
9802
|
await mkdir3(paths.environment, { recursive: true });
|
|
9803
|
+
await mkdir3(join5(paths.environment, "docs"), { recursive: true });
|
|
9804
|
+
await mkdir3(join5(paths.environment, "resources"), { recursive: true });
|
|
9792
9805
|
await mkdir3(paths.life, { recursive: true });
|
|
9793
9806
|
await mkdir3(paths.backlog, { recursive: true });
|
|
9794
9807
|
await mkdir3(paths.lineage, { recursive: true });
|
|
@@ -10738,6 +10751,9 @@ async function migrateLineage(paths) {
|
|
|
10738
10751
|
function selfUpgrade() {
|
|
10739
10752
|
try {
|
|
10740
10753
|
const installed = execSync2("reap --version", { encoding: "utf-8", timeout: 5000 }).trim();
|
|
10754
|
+
if (installed.includes("+dev")) {
|
|
10755
|
+
return { upgraded: false };
|
|
10756
|
+
}
|
|
10741
10757
|
const latest = execSync2("npm view @c-d-cc/reap version", { encoding: "utf-8", timeout: 1e4 }).trim();
|
|
10742
10758
|
if (installed === latest) {
|
|
10743
10759
|
return { upgraded: false };
|
|
@@ -10843,6 +10859,35 @@ async function updateProject(projectRoot, dryRun = false) {
|
|
|
10843
10859
|
}
|
|
10844
10860
|
}
|
|
10845
10861
|
if (await paths.isReapProject()) {
|
|
10862
|
+
const projectClaudeCommands = join10(paths.projectRoot, ".claude", "commands");
|
|
10863
|
+
await mkdir6(projectClaudeCommands, { recursive: true });
|
|
10864
|
+
const reapCmdFiles = (await readdir9(ReapPaths.userReapCommands)).filter((f) => f.startsWith("reap.") && f.endsWith(".md"));
|
|
10865
|
+
let cmdInstalled = 0;
|
|
10866
|
+
for (const file of reapCmdFiles) {
|
|
10867
|
+
const src = await readTextFileOrThrow(join10(ReapPaths.userReapCommands, file));
|
|
10868
|
+
const destPath = join10(projectClaudeCommands, file);
|
|
10869
|
+
try {
|
|
10870
|
+
const s = await import("fs/promises").then((m) => m.lstat(destPath));
|
|
10871
|
+
if (s.isSymbolicLink()) {
|
|
10872
|
+
if (!dryRun)
|
|
10873
|
+
await unlink3(destPath);
|
|
10874
|
+
} else {
|
|
10875
|
+
const existing = await readTextFile(destPath);
|
|
10876
|
+
if (existing !== null && existing === src)
|
|
10877
|
+
continue;
|
|
10878
|
+
if (!dryRun)
|
|
10879
|
+
await unlink3(destPath);
|
|
10880
|
+
}
|
|
10881
|
+
} catch {}
|
|
10882
|
+
if (!dryRun)
|
|
10883
|
+
await writeTextFile(destPath, src);
|
|
10884
|
+
cmdInstalled++;
|
|
10885
|
+
}
|
|
10886
|
+
if (cmdInstalled > 0) {
|
|
10887
|
+
result.updated.push(`.claude/commands/ (${cmdInstalled} synced)`);
|
|
10888
|
+
} else {
|
|
10889
|
+
result.skipped.push(`.claude/commands/ (${reapCmdFiles.length} unchanged)`);
|
|
10890
|
+
}
|
|
10846
10891
|
await migrateLegacyFiles(paths, dryRun, result);
|
|
10847
10892
|
if (await needsMigration(paths)) {
|
|
10848
10893
|
if (!dryRun) {
|
|
@@ -11014,7 +11059,7 @@ async function fixProject(projectRoot) {
|
|
|
11014
11059
|
// src/cli/index.ts
|
|
11015
11060
|
init_fs();
|
|
11016
11061
|
import { join as join12 } from "path";
|
|
11017
|
-
program.name("reap").description("REAP — Recursive Evolutionary Autonomous Pipeline").version("0.
|
|
11062
|
+
program.name("reap").description("REAP — Recursive Evolutionary Autonomous Pipeline").version("0.9.0");
|
|
11018
11063
|
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) => {
|
|
11019
11064
|
try {
|
|
11020
11065
|
const cwd = process.cwd();
|
|
@@ -25,22 +25,11 @@ Brainstorming is triggered based on goal complexity — simple tasks skip it, co
|
|
|
25
25
|
|
|
26
26
|
## Steps
|
|
27
27
|
|
|
28
|
-
### 1. Environment
|
|
29
|
-
- Read
|
|
30
|
-
-
|
|
31
|
-
- **If empty
|
|
32
|
-
|
|
33
|
-
> "Environment is where we record information **external to this project** — things that affect development but are outside the project's direct control.
|
|
34
|
-
> Unlike the Genome (design and knowledge the team decides), Environment captures the **constraints and context from the outside world**:
|
|
35
|
-
> connected systems, infrastructure, organizational rules, external API specs, etc."
|
|
36
|
-
2. **Ask questions interactively** (one at a time, skip if not applicable):
|
|
37
|
-
- "Are there any **connected systems**? (other services, external APIs, legacy systems, etc.)"
|
|
38
|
-
- "What is the **infrastructure/deployment environment**? (cloud, on-premise, containers, etc.)"
|
|
39
|
-
- "Are there **organizational rules or guidelines** to follow? (company standards, coding policies, security policies, regulatory compliance, etc.)"
|
|
40
|
-
- "Are there **external reference documents** to incorporate? (API specs, system architecture diagrams, integration guides, etc.)"
|
|
41
|
-
3. **Save collected information** to `.reap/environment/` as structured markdown files (e.g., `integrations.md`, `infrastructure.md`, `org-guidelines.md`)
|
|
42
|
-
4. If the human has nothing to add, that's fine — Environment is optional
|
|
43
|
-
- If files already exist, review them and ask if any updates are needed
|
|
28
|
+
### 1. Environment Check
|
|
29
|
+
- Read `.reap/environment/summary.md`
|
|
30
|
+
- If summary.md exists: review it for relevant context to this generation's goal
|
|
31
|
+
- **If empty or missing**: inform the user — "Environment가 설정되지 않았습니다. `/reap.sync.environment`로 외부 환경 정보를 설정할 수 있습니다."
|
|
32
|
+
- Do NOT block — proceed with the objective. Environment is optional but recommended.
|
|
44
33
|
|
|
45
34
|
### 2. Previous Generation Reference
|
|
46
35
|
- If a `05-completion.md` exists for the most recent generation in `.reap/lineage/`, read it
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: "REAP Sync Environment — Discover and document external environment dependencies"
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Sync Environment
|
|
6
|
+
|
|
7
|
+
Discover external systems, APIs, infrastructure, and constraints that affect this project. Populate the `.reap/environment/` 3-layer structure.
|
|
8
|
+
|
|
9
|
+
## Gate (Preconditions)
|
|
10
|
+
- Read `.reap/life/current.yml`
|
|
11
|
+
- If active Generation exists: switch to **Backlog Mode** (record as `type: environment-change`)
|
|
12
|
+
- If no active Generation: proceed with **Sync Mode** (modify environment directly after human confirmation)
|
|
13
|
+
|
|
14
|
+
## Environment 3-Layer Structure
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
.reap/environment/
|
|
18
|
+
├── summary.md # Session context (~100 lines max)
|
|
19
|
+
├── docs/ # Main reference docs (agent reads these)
|
|
20
|
+
└── resources/ # Raw materials (user-managed)
|
|
21
|
+
├── *.pdf, *.md # Original documents
|
|
22
|
+
└── links.md # External URLs + summaries
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
- **summary.md**: Auto-generated overview of all docs/. Loaded into session context.
|
|
26
|
+
- **docs/**: One file per environment topic. ~100 lines each. AI + human maintained.
|
|
27
|
+
- **resources/**: User-provided originals. No line limit. AI reads when deeper detail needed.
|
|
28
|
+
|
|
29
|
+
## Steps
|
|
30
|
+
|
|
31
|
+
### 1. Source Code Scan
|
|
32
|
+
Detect hints of external dependencies from:
|
|
33
|
+
- `package.json` / `requirements.txt` / `go.mod` — SDK/client libraries (e.g., `discord.js`, `@aws-sdk/*`, `stripe`)
|
|
34
|
+
- Config files — `.env`, `.env.example`, `wrangler.toml`, `docker-compose.yml`, `vercel.json`
|
|
35
|
+
- API client code — HTTP clients, webhook handlers, OAuth configs
|
|
36
|
+
- Infrastructure — Dockerfile, CI/CD configs, deployment scripts
|
|
37
|
+
|
|
38
|
+
Present findings:
|
|
39
|
+
```
|
|
40
|
+
🔍 Detected external dependencies:
|
|
41
|
+
- discord.js → Discord Bot API
|
|
42
|
+
- @supabase/supabase-js → Supabase (DB + Auth)
|
|
43
|
+
- wrangler.toml → Cloudflare Workers
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### 2. User Interview
|
|
47
|
+
Ask the user to confirm and expand. Goal: **capture ALL external systems** that affect this project.
|
|
48
|
+
|
|
49
|
+
Questions (one at a time, skip if already covered):
|
|
50
|
+
1. "감지된 외부 서비스들이 맞나요? 추가/수정할 것이 있나요?"
|
|
51
|
+
2. "그 외에 연동되는 외부 서비스, API, 시스템이 있나요?"
|
|
52
|
+
3. "배포/인프라 환경을 알려주세요 (호스팅, CI/CD, 도메인 등)"
|
|
53
|
+
4. "따라야 하는 조직 규칙이나 외부 제약이 있나요? (보안 정책, 규제 등)"
|
|
54
|
+
5. "참고해야 할 외부 문서나 링크가 있나요? (API docs, 스펙 등)"
|
|
55
|
+
|
|
56
|
+
For each confirmed item:
|
|
57
|
+
- Ask: "관련 문서/링크가 있으면 알려주세요 (없으면 skip)"
|
|
58
|
+
- If provided: save to `resources/` (file or `links.md` entry)
|
|
59
|
+
|
|
60
|
+
### 3. Generate docs/
|
|
61
|
+
For each confirmed environment topic, create a file in `docs/`:
|
|
62
|
+
- File name: `{topic-slug}.md` (e.g., `discord-api.md`, `infrastructure.md`)
|
|
63
|
+
- Content: structured markdown with key info the agent needs during implementation
|
|
64
|
+
- Sections: Overview, Key Constraints, API/Config Details, References (→ resources/)
|
|
65
|
+
- ~100 lines max per file
|
|
66
|
+
|
|
67
|
+
### 4. Generate summary.md
|
|
68
|
+
Aggregate all docs/ into a concise summary:
|
|
69
|
+
- One section per environment topic
|
|
70
|
+
- Key constraints and gotchas highlighted
|
|
71
|
+
- Links to docs/ files for detail
|
|
72
|
+
- **~100 lines max** (this gets loaded into every session)
|
|
73
|
+
|
|
74
|
+
### 5. Verify
|
|
75
|
+
- List all created/updated files
|
|
76
|
+
- Show summary.md content to user for confirmation
|
|
77
|
+
- Ask: "빠진 환경 정보가 있나요?"
|
|
78
|
+
|
|
79
|
+
## Backlog Mode (active Generation)
|
|
80
|
+
- Record each discovered environment item as `type: environment-change` in `.reap/life/backlog/`
|
|
81
|
+
- "Environment 변경사항이 backlog에 기록되었습니다. Completion에서 적용됩니다."
|
|
82
|
+
|
|
83
|
+
## Completion
|
|
84
|
+
- "Environment synced. {N} docs created, summary.md updated."
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: "REAP Sync Genome — Synchronize Genome with current source code"
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Sync Genome
|
|
6
|
+
|
|
7
|
+
Analyze the current source code and update the Genome to reflect reality.
|
|
8
|
+
|
|
9
|
+
<HARD-GATE>
|
|
10
|
+
If an active Generation exists (`.reap/life/current.yml` has content), do NOT modify Genome directly.
|
|
11
|
+
Instead, record discovered differences as `type: genome-change` items in `.reap/life/backlog/` and inform the human.
|
|
12
|
+
Only proceed with direct Genome modification when NO active Generation exists.
|
|
13
|
+
</HARD-GATE>
|
|
14
|
+
|
|
15
|
+
## Gate (Preconditions)
|
|
16
|
+
- Read `.reap/life/current.yml`
|
|
17
|
+
- If active Generation exists: switch to **Backlog Mode** (record differences, do not modify Genome)
|
|
18
|
+
- If no active Generation: proceed with **Sync Mode** (modify Genome directly after human confirmation)
|
|
19
|
+
|
|
20
|
+
## Steps
|
|
21
|
+
|
|
22
|
+
### 1. Read Current Genome
|
|
23
|
+
- Read all files in `.reap/genome/` (principles.md, conventions.md, constraints.md, domain/)
|
|
24
|
+
- Note current genomeVersion from the most recent generation in `.reap/lineage/`
|
|
25
|
+
|
|
26
|
+
### 2. Analyze Source Code
|
|
27
|
+
Scan the project to understand its current state:
|
|
28
|
+
|
|
29
|
+
**Tech Stack & Dependencies**:
|
|
30
|
+
- package.json, tsconfig.json, Dockerfile, docker-compose.yml, etc.
|
|
31
|
+
- New dependencies added, removed, or version-changed since Genome was last updated
|
|
32
|
+
|
|
33
|
+
**Architecture & Structure**:
|
|
34
|
+
- Directory structure and patterns (layers, modules, services)
|
|
35
|
+
- Entry points, routing, API structure
|
|
36
|
+
- Database, ORM, migration setup
|
|
37
|
+
|
|
38
|
+
**Conventions**:
|
|
39
|
+
- Linter/formatter configs (.eslintrc, .prettierrc, biome.json, etc.)
|
|
40
|
+
- Test setup and patterns (test framework, file naming, coverage config)
|
|
41
|
+
- Git hooks, CI/CD config
|
|
42
|
+
- Code patterns observed in the source (naming, error handling, etc.)
|
|
43
|
+
|
|
44
|
+
**Constraints**:
|
|
45
|
+
- Build commands, test commands, validation commands
|
|
46
|
+
- Environment requirements, runtime constraints
|
|
47
|
+
- External service dependencies
|
|
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
|
+
|
|
62
|
+
### 3. Diff Analysis
|
|
63
|
+
Compare source analysis with current Genome and identify:
|
|
64
|
+
- **Additions**: Things in code but not in Genome
|
|
65
|
+
- **Changes**: Things in Genome that no longer match code
|
|
66
|
+
- **Removals**: Things in Genome that no longer exist in code
|
|
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
|
|
69
|
+
|
|
70
|
+
### 4. Report to Human
|
|
71
|
+
Present a structured diff report:
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
🔄 Genome Sync Report
|
|
75
|
+
━━━━━━━━━━━━━━━━━━━━━
|
|
76
|
+
|
|
77
|
+
📝 principles.md
|
|
78
|
+
+ [New] API-first design pattern observed
|
|
79
|
+
~ [Changed] Layer structure: added shared/ directory
|
|
80
|
+
|
|
81
|
+
📝 conventions.md
|
|
82
|
+
+ [New] Biome used for linting (replacing ESLint)
|
|
83
|
+
~ [Changed] Test pattern: using vitest instead of jest
|
|
84
|
+
|
|
85
|
+
📝 constraints.md
|
|
86
|
+
+ [New] Validation command: bun test
|
|
87
|
+
~ [Changed] Runtime: Node.js compatible (was Bun-only)
|
|
88
|
+
|
|
89
|
+
📁 domain/
|
|
90
|
+
+ [Suggest] Create lifecycle-rules.md for REAP lifecycle logic
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### 5. Apply Changes
|
|
94
|
+
|
|
95
|
+
**Sync Mode** (no active Generation):
|
|
96
|
+
- For each difference, ask the human: "Apply this change? (yes/no/modify)"
|
|
97
|
+
- Apply confirmed changes to the corresponding Genome files
|
|
98
|
+
- Follow Genome writing principles:
|
|
99
|
+
- Each file ≤ 100 lines
|
|
100
|
+
- If exceeding, extract to `domain/`
|
|
101
|
+
- Follow `~/.reap/templates/domain-guide.md` for domain files
|
|
102
|
+
|
|
103
|
+
**Backlog Mode** (active Generation):
|
|
104
|
+
- Record each difference as a `type: genome-change` backlog item in `.reap/life/backlog/`
|
|
105
|
+
- Inform: "Genome changes recorded in backlog. They will be applied at the Completion stage."
|
|
106
|
+
|
|
107
|
+
## Completion
|
|
108
|
+
- **Sync Mode**: "Genome synchronized. [N] changes applied."
|
|
109
|
+
- **Backlog Mode**: "Genome differences recorded as [N] backlog items. Apply during Completion."
|
|
@@ -1,109 +1,17 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: "REAP Sync — Synchronize Genome with current
|
|
2
|
+
description: "REAP Sync — Synchronize both Genome and Environment with current state"
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
# Sync (
|
|
5
|
+
# Sync (Full)
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
<HARD-GATE>
|
|
10
|
-
If an active Generation exists (`.reap/life/current.yml` has content), do NOT modify Genome directly.
|
|
11
|
-
Instead, record discovered differences as `type: genome-change` items in `.reap/life/backlog/` and inform the human.
|
|
12
|
-
Only proceed with direct Genome modification when NO active Generation exists.
|
|
13
|
-
</HARD-GATE>
|
|
14
|
-
|
|
15
|
-
## Gate (Preconditions)
|
|
16
|
-
- Read `.reap/life/current.yml`
|
|
17
|
-
- If active Generation exists: switch to **Backlog Mode** (record differences, do not modify Genome)
|
|
18
|
-
- If no active Generation: proceed with **Sync Mode** (modify Genome directly after human confirmation)
|
|
7
|
+
Run both Genome and Environment synchronization.
|
|
19
8
|
|
|
20
9
|
## Steps
|
|
21
10
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
- Note current genomeVersion from the most recent generation in `.reap/lineage/`
|
|
25
|
-
|
|
26
|
-
### 2. Analyze Source Code
|
|
27
|
-
Scan the project to understand its current state:
|
|
28
|
-
|
|
29
|
-
**Tech Stack & Dependencies**:
|
|
30
|
-
- package.json, tsconfig.json, Dockerfile, docker-compose.yml, etc.
|
|
31
|
-
- New dependencies added, removed, or version-changed since Genome was last updated
|
|
32
|
-
|
|
33
|
-
**Architecture & Structure**:
|
|
34
|
-
- Directory structure and patterns (layers, modules, services)
|
|
35
|
-
- Entry points, routing, API structure
|
|
36
|
-
- Database, ORM, migration setup
|
|
37
|
-
|
|
38
|
-
**Conventions**:
|
|
39
|
-
- Linter/formatter configs (.eslintrc, .prettierrc, biome.json, etc.)
|
|
40
|
-
- Test setup and patterns (test framework, file naming, coverage config)
|
|
41
|
-
- Git hooks, CI/CD config
|
|
42
|
-
- Code patterns observed in the source (naming, error handling, etc.)
|
|
43
|
-
|
|
44
|
-
**Constraints**:
|
|
45
|
-
- Build commands, test commands, validation commands
|
|
46
|
-
- Environment requirements, runtime constraints
|
|
47
|
-
- External service dependencies
|
|
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
|
-
|
|
62
|
-
### 3. Diff Analysis
|
|
63
|
-
Compare source analysis with current Genome and identify:
|
|
64
|
-
- **Additions**: Things in code but not in Genome
|
|
65
|
-
- **Changes**: Things in Genome that no longer match code
|
|
66
|
-
- **Removals**: Things in Genome that no longer exist in code
|
|
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
|
|
69
|
-
|
|
70
|
-
### 4. Report to Human
|
|
71
|
-
Present a structured diff report:
|
|
72
|
-
|
|
73
|
-
```
|
|
74
|
-
🔄 Genome Sync Report
|
|
75
|
-
━━━━━━━━━━━━━━━━━━━━━
|
|
76
|
-
|
|
77
|
-
📝 principles.md
|
|
78
|
-
+ [New] API-first design pattern observed
|
|
79
|
-
~ [Changed] Layer structure: added shared/ directory
|
|
80
|
-
|
|
81
|
-
📝 conventions.md
|
|
82
|
-
+ [New] Biome used for linting (replacing ESLint)
|
|
83
|
-
~ [Changed] Test pattern: using vitest instead of jest
|
|
84
|
-
|
|
85
|
-
📝 constraints.md
|
|
86
|
-
+ [New] Validation command: bun test
|
|
87
|
-
~ [Changed] Runtime: Node.js compatible (was Bun-only)
|
|
88
|
-
|
|
89
|
-
📁 domain/
|
|
90
|
-
+ [Suggest] Create lifecycle-rules.md for REAP lifecycle logic
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
### 5. Apply Changes
|
|
94
|
-
|
|
95
|
-
**Sync Mode** (no active Generation):
|
|
96
|
-
- For each difference, ask the human: "Apply this change? (yes/no/modify)"
|
|
97
|
-
- Apply confirmed changes to the corresponding Genome files
|
|
98
|
-
- Follow Genome writing principles:
|
|
99
|
-
- Each file ≤ 100 lines
|
|
100
|
-
- If exceeding, extract to `domain/`
|
|
101
|
-
- Follow `~/.reap/templates/domain-guide.md` for domain files
|
|
102
|
-
|
|
103
|
-
**Backlog Mode** (active Generation):
|
|
104
|
-
- Record each difference as a `type: genome-change` backlog item in `.reap/life/backlog/`
|
|
105
|
-
- Inform: "Genome changes recorded in backlog. They will be applied at the Completion stage."
|
|
11
|
+
1. Execute `/reap.sync.genome` — synchronize Genome with source code
|
|
12
|
+
2. Execute `/reap.sync.environment` — discover and document external environment
|
|
106
13
|
|
|
107
|
-
##
|
|
108
|
-
-
|
|
109
|
-
-
|
|
14
|
+
## Usage
|
|
15
|
+
- `/reap.sync` — full sync (recommended after init or major changes)
|
|
16
|
+
- `/reap.sync.genome` — genome only
|
|
17
|
+
- `/reap.sync.environment` — environment only
|
|
@@ -79,7 +79,9 @@ let updateAvailableMessage = '';
|
|
|
79
79
|
const { configContent } = gl.parseConfig(configFile);
|
|
80
80
|
const installed = gl.exec('reap --version');
|
|
81
81
|
const latest = gl.exec('npm view @c-d-cc/reap version');
|
|
82
|
-
if (installed &&
|
|
82
|
+
if (installed && installed.includes('+dev')) {
|
|
83
|
+
// Local dev build — skip version check entirely
|
|
84
|
+
} else if (installed && latest && installed !== latest) {
|
|
83
85
|
const autoUpdate = configContent ? /^autoUpdate:\s*true/m.test(configContent) : false;
|
|
84
86
|
if (autoUpdate) {
|
|
85
87
|
const updated = gl.exec('npm update -g @c-d-cc/reap');
|
|
@@ -100,6 +102,10 @@ const reapGuide = gl.readFile(guideFile) || '';
|
|
|
100
102
|
log('Loading Genome...');
|
|
101
103
|
const { content: genomeContent, l1Lines } = gl.loadGenome(genomeDir);
|
|
102
104
|
|
|
105
|
+
// Step 3b: Load Environment summary
|
|
106
|
+
const envSummaryFile = path.join(reapDir, 'environment', 'summary.md');
|
|
107
|
+
const envSummary = gl.readFile(envSummaryFile) || '';
|
|
108
|
+
|
|
103
109
|
// Step 4: Check Genome staleness
|
|
104
110
|
log('Checking sync...');
|
|
105
111
|
const { genomeStaleWarning, commitsSince } = gl.detectStaleness(projectRoot);
|
|
@@ -160,7 +166,9 @@ const sessionInitDisplay = initFormat
|
|
|
160
166
|
// Step 6: Output JSON
|
|
161
167
|
log('Done. Injecting context.');
|
|
162
168
|
|
|
163
|
-
const
|
|
169
|
+
const envSection = envSummary ? `\n\n---\n\n## Environment (External Context)\n${envSummary}` : '';
|
|
170
|
+
|
|
171
|
+
const reapContext = `<REAP_WORKFLOW>\n${reapGuide}\n\n---\n\n## Genome (Project Knowledge — treat as authoritative source of truth)\n${genomeContent}${envSection}\n\n---\n\n## Current State\n${generationContext}${staleSection}${strictSection}${updateSection}\n\n## Session Init (display to user on first message)\n${sessionInitDisplay}\n\n## Rules\n1. ALL development work MUST follow the REAP lifecycle. Do NOT bypass it.\n2. Before writing any code, check if a Generation is active and what stage it is in.\n3. If a Generation is active, use \`${nextCmd}\` to proceed with the current stage.\n4. If no Generation is active, use \`/reap.start\` to start a new one.\n5. Do NOT implement features, fix bugs, or make changes outside of the REAP lifecycle unless the user explicitly asks to bypass it.\n6. When the user says "reap evolve", "next stage", "proceed", or similar — invoke the appropriate REAP skill.\n7. **Genome is the authoritative knowledge source.** When making decisions about architecture, conventions, or constraints, ALWAYS reference the Genome first. If code contradicts Genome, flag it as a potential genome-change backlog item.\n8. If you notice the Genome is outdated or missing information relevant to your current task, inform the user and suggest running \`/reap.sync\`.\n</REAP_WORKFLOW>`;
|
|
164
172
|
|
|
165
173
|
process.stdout.write(JSON.stringify({
|
|
166
174
|
hookSpecificOutput: {
|