@c-d-cc/reap 0.8.0 → 0.9.1
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 +57 -1
- package/dist/templates/commands/reap.objective.md +5 -16
- package/dist/templates/commands/reap.report.md +127 -0
- package/dist/templates/commands/reap.start.md +5 -1
- 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/reap-guide.md +6 -0
- 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,8 +9767,11 @@ 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",
|
|
9774
|
+
"reap.report",
|
|
9763
9775
|
"reap.merge.start",
|
|
9764
9776
|
"reap.merge.detect",
|
|
9765
9777
|
"reap.merge.mate",
|
|
@@ -9789,15 +9801,27 @@ async function initProject(projectRoot, projectName, entryMode, preset, onProgre
|
|
|
9789
9801
|
await mkdir3(paths.genome, { recursive: true });
|
|
9790
9802
|
await mkdir3(paths.domain, { recursive: true });
|
|
9791
9803
|
await mkdir3(paths.environment, { recursive: true });
|
|
9804
|
+
await mkdir3(join5(paths.environment, "docs"), { recursive: true });
|
|
9805
|
+
await mkdir3(join5(paths.environment, "resources"), { recursive: true });
|
|
9792
9806
|
await mkdir3(paths.life, { recursive: true });
|
|
9793
9807
|
await mkdir3(paths.backlog, { recursive: true });
|
|
9794
9808
|
await mkdir3(paths.lineage, { recursive: true });
|
|
9795
9809
|
log("Writing config.yml...");
|
|
9810
|
+
let hasGhCli = false;
|
|
9811
|
+
try {
|
|
9812
|
+
const { execSync } = await import("child_process");
|
|
9813
|
+
execSync("which gh", { stdio: "ignore" });
|
|
9814
|
+
hasGhCli = true;
|
|
9815
|
+
} catch {}
|
|
9816
|
+
if (!hasGhCli) {
|
|
9817
|
+
log("GitHub CLI(gh) not found. Install from https://cli.github.com for auto issue reporting.");
|
|
9818
|
+
}
|
|
9796
9819
|
const config = {
|
|
9797
9820
|
version: "0.1.0",
|
|
9798
9821
|
project: projectName,
|
|
9799
9822
|
entryMode,
|
|
9800
9823
|
autoUpdate: true,
|
|
9824
|
+
autoIssueReport: hasGhCli,
|
|
9801
9825
|
...preset && { preset }
|
|
9802
9826
|
};
|
|
9803
9827
|
await ConfigManager.write(paths, config);
|
|
@@ -10738,6 +10762,9 @@ async function migrateLineage(paths) {
|
|
|
10738
10762
|
function selfUpgrade() {
|
|
10739
10763
|
try {
|
|
10740
10764
|
const installed = execSync2("reap --version", { encoding: "utf-8", timeout: 5000 }).trim();
|
|
10765
|
+
if (installed.includes("+dev")) {
|
|
10766
|
+
return { upgraded: false };
|
|
10767
|
+
}
|
|
10741
10768
|
const latest = execSync2("npm view @c-d-cc/reap version", { encoding: "utf-8", timeout: 1e4 }).trim();
|
|
10742
10769
|
if (installed === latest) {
|
|
10743
10770
|
return { upgraded: false };
|
|
@@ -10843,6 +10870,35 @@ async function updateProject(projectRoot, dryRun = false) {
|
|
|
10843
10870
|
}
|
|
10844
10871
|
}
|
|
10845
10872
|
if (await paths.isReapProject()) {
|
|
10873
|
+
const projectClaudeCommands = join10(paths.projectRoot, ".claude", "commands");
|
|
10874
|
+
await mkdir6(projectClaudeCommands, { recursive: true });
|
|
10875
|
+
const reapCmdFiles = (await readdir9(ReapPaths.userReapCommands)).filter((f) => f.startsWith("reap.") && f.endsWith(".md"));
|
|
10876
|
+
let cmdInstalled = 0;
|
|
10877
|
+
for (const file of reapCmdFiles) {
|
|
10878
|
+
const src = await readTextFileOrThrow(join10(ReapPaths.userReapCommands, file));
|
|
10879
|
+
const destPath = join10(projectClaudeCommands, file);
|
|
10880
|
+
try {
|
|
10881
|
+
const s = await import("fs/promises").then((m) => m.lstat(destPath));
|
|
10882
|
+
if (s.isSymbolicLink()) {
|
|
10883
|
+
if (!dryRun)
|
|
10884
|
+
await unlink3(destPath);
|
|
10885
|
+
} else {
|
|
10886
|
+
const existing = await readTextFile(destPath);
|
|
10887
|
+
if (existing !== null && existing === src)
|
|
10888
|
+
continue;
|
|
10889
|
+
if (!dryRun)
|
|
10890
|
+
await unlink3(destPath);
|
|
10891
|
+
}
|
|
10892
|
+
} catch {}
|
|
10893
|
+
if (!dryRun)
|
|
10894
|
+
await writeTextFile(destPath, src);
|
|
10895
|
+
cmdInstalled++;
|
|
10896
|
+
}
|
|
10897
|
+
if (cmdInstalled > 0) {
|
|
10898
|
+
result.updated.push(`.claude/commands/ (${cmdInstalled} synced)`);
|
|
10899
|
+
} else {
|
|
10900
|
+
result.skipped.push(`.claude/commands/ (${reapCmdFiles.length} unchanged)`);
|
|
10901
|
+
}
|
|
10846
10902
|
await migrateLegacyFiles(paths, dryRun, result);
|
|
10847
10903
|
if (await needsMigration(paths)) {
|
|
10848
10904
|
if (!dryRun) {
|
|
@@ -11014,7 +11070,7 @@ async function fixProject(projectRoot) {
|
|
|
11014
11070
|
// src/cli/index.ts
|
|
11015
11071
|
init_fs();
|
|
11016
11072
|
import { join as join12 } from "path";
|
|
11017
|
-
program.name("reap").description("REAP — Recursive Evolutionary Autonomous Pipeline").version("0.
|
|
11073
|
+
program.name("reap").description("REAP — Recursive Evolutionary Autonomous Pipeline").version("0.9.1");
|
|
11018
11074
|
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
11075
|
try {
|
|
11020
11076
|
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,127 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: "REAP Report — Report a bug or issue to the REAP project"
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Report
|
|
6
|
+
|
|
7
|
+
Report a bug, malfunction, or feedback to the REAP project via GitHub Issue.
|
|
8
|
+
**Language**: All user-facing messages must follow the user's configured language setting (see REAP Guide § Language).
|
|
9
|
+
|
|
10
|
+
## Gate (Preconditions)
|
|
11
|
+
- Check if `gh` CLI is available: `which gh`
|
|
12
|
+
- If not available: inform user that GitHub CLI is required (https://cli.github.com), then `gh auth login`. **STOP**
|
|
13
|
+
- Check if authenticated: `gh auth status`
|
|
14
|
+
- If not authenticated: inform user to run `gh auth login`. **STOP**
|
|
15
|
+
- Read `.reap/config.yml` — check `autoIssueReport` is not explicitly `false`
|
|
16
|
+
- If `autoIssueReport: false`: inform user that issue reporting is disabled and how to enable it in config.yml. **STOP**
|
|
17
|
+
|
|
18
|
+
## Mode Detection
|
|
19
|
+
|
|
20
|
+
**Auto mode** (called by agent when malfunction detected):
|
|
21
|
+
- The agent provides error context as arguments
|
|
22
|
+
- Skip to Step 2 with pre-filled context
|
|
23
|
+
|
|
24
|
+
**Manual mode** (user calls `/reap.report` directly):
|
|
25
|
+
- Ask the user what they want to report:
|
|
26
|
+
- Bug / malfunction
|
|
27
|
+
- Feature request
|
|
28
|
+
- Other feedback
|
|
29
|
+
- Gather description from the user
|
|
30
|
+
|
|
31
|
+
## Steps
|
|
32
|
+
|
|
33
|
+
### 1. Collect Context
|
|
34
|
+
Automatically gather (do NOT ask the user for these):
|
|
35
|
+
- REAP version: `reap --version`
|
|
36
|
+
- Node version: `node --version`
|
|
37
|
+
- OS: `uname -sr`
|
|
38
|
+
- Agent: detect from environment (Claude Code, OpenCode, etc.)
|
|
39
|
+
- Generation state: read `.reap/life/current.yml` (id, stage — if active)
|
|
40
|
+
- Genome hash: compute from `.reap/genome/`
|
|
41
|
+
- Config: read `.reap/config.yml`
|
|
42
|
+
|
|
43
|
+
### 2. Draft Issue
|
|
44
|
+
|
|
45
|
+
<PRIVACY_GATE>
|
|
46
|
+
**BEFORE writing any issue content, apply these rules:**
|
|
47
|
+
- Do NOT include: file contents, source code, environment variables, API keys,
|
|
48
|
+
tokens, passwords, usernames, email addresses, IP addresses, domain names,
|
|
49
|
+
database URLs, project-specific business logic, or any proprietary information.
|
|
50
|
+
- ONLY include: REAP version, Node version, OS, generation ID, stage name,
|
|
51
|
+
command name, genome hash, generic error messages, and REAP config structure
|
|
52
|
+
(with all values masked).
|
|
53
|
+
- When in doubt, OMIT the information rather than include it.
|
|
54
|
+
</PRIVACY_GATE>
|
|
55
|
+
|
|
56
|
+
Draft the issue using this template (issue body is always in English for the public repo):
|
|
57
|
+
|
|
58
|
+
```markdown
|
|
59
|
+
## {Bug Report / Feature Request / Feedback} (Auto-generated by REAP)
|
|
60
|
+
|
|
61
|
+
**REAP Version**: v{version}
|
|
62
|
+
**Node Version**: v{nodeVersion}
|
|
63
|
+
**OS**: {os}
|
|
64
|
+
**Agent**: {agentName}
|
|
65
|
+
|
|
66
|
+
### Context
|
|
67
|
+
- **Generation**: {genId or "none"} (stage: {stage or "n/a"})
|
|
68
|
+
- **Command**: {command that triggered the issue}
|
|
69
|
+
- **Genome Hash**: {genomeHash}
|
|
70
|
+
|
|
71
|
+
### Description
|
|
72
|
+
{user description or auto-detected malfunction description}
|
|
73
|
+
|
|
74
|
+
### Expected Behavior
|
|
75
|
+
{what should have happened}
|
|
76
|
+
|
|
77
|
+
### Actual Behavior
|
|
78
|
+
{what actually happened}
|
|
79
|
+
|
|
80
|
+
### Steps to Reproduce
|
|
81
|
+
1. {step}
|
|
82
|
+
|
|
83
|
+
### Config
|
|
84
|
+
```yaml
|
|
85
|
+
version: {version}
|
|
86
|
+
project: {projectName}
|
|
87
|
+
strict: {on/off}
|
|
88
|
+
autoUpdate: {on/off}
|
|
89
|
+
# all other values masked
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
*Auto-reported by REAP agent. Repository: c-d-cc/reap*
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### 3. Post-format Sanitization
|
|
97
|
+
Scan the drafted issue body and mask/remove:
|
|
98
|
+
- Email patterns: `*@*.*` → `[REDACTED_EMAIL]`
|
|
99
|
+
- API key/token patterns: `sk-*`, `ghp_*`, `Bearer *`, `token:*` → `[REDACTED]`
|
|
100
|
+
- URLs with credentials: `https://user:pass@` → `https://[REDACTED]@`
|
|
101
|
+
- Environment variable values: `KEY=value` → `KEY=[REDACTED]`
|
|
102
|
+
- User paths: `/Users/{name}/` or `/home/{name}/` → `/Users/***/`
|
|
103
|
+
- IP addresses: digit patterns like `\d+\.\d+\.\d+\.\d+` → `[REDACTED_IP]`
|
|
104
|
+
- Source code blocks: if any project source code is included, remove it
|
|
105
|
+
|
|
106
|
+
### 4. User Confirmation
|
|
107
|
+
Show the sanitized issue to the user (in user's language):
|
|
108
|
+
- Explain that this report greatly helps improve the REAP project
|
|
109
|
+
- Ask the user to verify no sensitive information is included
|
|
110
|
+
- Present the full issue body
|
|
111
|
+
- Ask: yes / no / edit
|
|
112
|
+
- **yes**: proceed to Step 5
|
|
113
|
+
- **no**: report cancelled
|
|
114
|
+
- **edit**: let user modify, then re-run Step 3 sanitization and re-confirm
|
|
115
|
+
|
|
116
|
+
### 5. Submit
|
|
117
|
+
- Determine labels (comma-separated, always include `auto-reported`):
|
|
118
|
+
- Bug: `bug,auto-reported`
|
|
119
|
+
- Feature request: `enhancement,auto-reported`
|
|
120
|
+
- Feedback: `feedback,auto-reported`
|
|
121
|
+
- Add context labels if applicable: `lifecycle`, `genome`, `cli`
|
|
122
|
+
- Run: `gh issue create --repo c-d-cc/reap --title "{title}" --label "{labels}" --body "{sanitized body}"`
|
|
123
|
+
- Show the issue URL to the user
|
|
124
|
+
- Thank the user for their contribution to improving REAP
|
|
125
|
+
|
|
126
|
+
## Completion
|
|
127
|
+
- "Issue #{number} reported: {url}"
|
|
@@ -21,7 +21,11 @@ description: "REAP Start — Start a new Generation"
|
|
|
21
21
|
|
|
22
22
|
1. Ask the human for the goal of this generation (or use selected backlog item's goal)
|
|
23
23
|
2. Count existing generations in `.reap/lineage/` to determine the genomeVersion
|
|
24
|
-
3. Generate the next generation ID
|
|
24
|
+
3. Generate the next generation ID:
|
|
25
|
+
- Format: `gen-{NNN}-{hash}` (e.g. `gen-042-a3f8c2`)
|
|
26
|
+
- `{NNN}`: zero-padded 3-digit sequence (existing count + 1)
|
|
27
|
+
- `{hash}`: 6-character hex (0-9a-f only) — first 6 chars of `sha256(JSON.stringify({parents, goal, genomeHash, machineId, startedAt}))`
|
|
28
|
+
- Generate: `node -e "const c=require('crypto'),o=require('os');console.log(c.createHash('sha256').update(JSON.stringify({parents:[],goal:'YOUR_GOAL',genomeHash:'',machineId:o.hostname(),startedAt:new Date().toISOString()})).digest('hex').slice(0,6))"`
|
|
25
29
|
4. **If a backlog item was selected in Step 0**: now mark it as `status: consumed` and add `consumedBy: gen-XXX-{hash}` (using the ID just generated)
|
|
26
30
|
6. Write the following to `current.yml`:
|
|
27
31
|
```yaml
|
|
@@ -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
|
|
@@ -58,6 +58,11 @@ Objective → Planning → Implementation ⟷ Validation → Completion
|
|
|
58
58
|
### Generation
|
|
59
59
|
A single generation. Carries one goal through the Life Cycle. State is tracked in `life/current.yml`.
|
|
60
60
|
|
|
61
|
+
**Generation ID format**: `gen-{NNN}-{hash}` (e.g. `gen-042-a3f8c2`)
|
|
62
|
+
- `{hash}`: 6-char hex from sha256. **MUST be real hex (0-9a-f), NEVER words/slugs.**
|
|
63
|
+
- Lineage directory appends a goal slug: `gen-042-a3f8c2-fix-login-bug`
|
|
64
|
+
- See `/reap.start` for generation details.
|
|
65
|
+
|
|
61
66
|
### Backlog
|
|
62
67
|
All items to be carried forward to the next generation are stored in `.reap/life/backlog/`. Each item uses markdown + frontmatter format:
|
|
63
68
|
- `type: genome-change` — Applied to genome during Completion (genome defects discovered mid-generation)
|
|
@@ -199,3 +204,4 @@ When `strict: true` is set in `.reap/config.yml`, the AI agent enforces code mod
|
|
|
199
204
|
3. **ALL development work MUST follow the REAP lifecycle.** Do NOT bypass it unless the human explicitly asks.
|
|
200
205
|
4. **Genome is the authoritative source of truth.** When making any decision about architecture, conventions, constraints, or domain rules, ALWAYS consult the Genome first. If you observe code that contradicts the Genome, flag it as a potential `genome-change` backlog item. Do NOT silently ignore discrepancies.
|
|
201
206
|
5. **Keep Genome fresh.** If you notice the Genome is missing information about current code patterns, or contains outdated information, inform the human and suggest `/reap.sync`. The human may choose to defer sync — respect that choice, but always flag the staleness.
|
|
207
|
+
6. **Report malfunctions.** If you detect unexpected behavior during REAP operations (state inconsistency, command failure, corrupted files), suggest `/reap.report` to the user. This helps improve REAP for everyone.
|
|
@@ -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: {
|