@c-d-cc/reap 0.10.2 → 0.10.3

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/README.ja.md CHANGED
@@ -13,7 +13,7 @@
13
13
 
14
14
  <table align="center">
15
15
  <tr>
16
- <td align="center"><strong>Genome</strong><br><sub>設計とナレッジ</sub></td>
16
+ <td align="center"><strong>Knowledge Base</strong><br><sub>Genome + Environment</sub></td>
17
17
  <td align="center">→</td>
18
18
  <td align="center"><strong>Evolution</strong><br><sub>世代を超えた進化</sub></td>
19
19
  <td align="center">→</td>
@@ -21,7 +21,7 @@
21
21
  </tr>
22
22
  </table>
23
23
 
24
- REAPはアプリケーションの遺伝情報(Genome)を定義し、各世代で目標を設定して実装し、その過程で発見したGenomeの欠陥を次のステージにフィードバックします。世代を重ねるごとにGenomeが進化し、Source Code(Civilization)が成長します。
24
+ REAPはアプリケーションの設計知識 — Genome(アーキテクチャ、コンベンション、制約)とEnvironment(外部API、インフラ) — を記録し、各世代で目標を設定して実装します。その過程で発見した欠陥はKnowledge Baseにフィードバックされます。世代を重ねるごとに知識が進化し、Source Code(Civilization)が成長します。
25
25
 
26
26
  ## 目次
27
27
 
package/README.ko.md CHANGED
@@ -13,7 +13,7 @@
13
13
 
14
14
  <table align="center">
15
15
  <tr>
16
- <td align="center"><strong>Genome</strong><br><sub>설계와 지식</sub></td>
16
+ <td align="center"><strong>Knowledge Base</strong><br><sub>Genome + Environment</sub></td>
17
17
  <td align="center">→</td>
18
18
  <td align="center"><strong>Evolution</strong><br><sub>세대를 거친 진화</sub></td>
19
19
  <td align="center">→</td>
@@ -21,7 +21,7 @@
21
21
  </tr>
22
22
  </table>
23
23
 
24
- REAP은 Application의 유전 정보(Genome) 정의하고, 각 세대에서 목표를 설정하여 구현하고, 그 과정에서 발견한 Genome 결함을 다음 단계에서 반영합니다. 세대를 거듭하며 Genome이 진화하고, Source Code(Civilization)가 성장합니다.
24
+ REAP은 Application의 설계 지식 — Genome(아키텍처, 컨벤션, 제약사항) Environment(외부 API, 인프라) — 을 기록하고, 각 세대에서 목표를 설정하여 구현합니다. 그 과정에서 발견한 결함은 Knowledge Base에 반영됩니다. 세대를 거듭하며 지식이 진화하고, Source Code(Civilization)가 성장합니다.
25
25
 
26
26
  ## 목차
27
27
 
package/README.md CHANGED
@@ -13,7 +13,7 @@
13
13
 
14
14
  <table align="center">
15
15
  <tr>
16
- <td align="center"><strong>Genome</strong><br><sub>Design & Knowledge</sub></td>
16
+ <td align="center"><strong>Knowledge Base</strong><br><sub>Genome + Environment</sub></td>
17
17
  <td align="center">→</td>
18
18
  <td align="center"><strong>Evolution</strong><br><sub>Generational Progress</sub></td>
19
19
  <td align="center">→</td>
@@ -21,7 +21,7 @@
21
21
  </tr>
22
22
  </table>
23
23
 
24
- REAP defines an application's genetic information (Genome), sets objectives for each generation to implement, and feeds back any Genome defects discovered along the way into subsequent stages. As generations accumulate, the Genome evolves and the Source Code (Civilization) grows.
24
+ REAP captures an application's design knowledge — the Genome (architecture, conventions, constraints) and Environment (external APIs, infrastructure) — then sets objectives for each generation to implement. Defects discovered along the way feed back into the Knowledge Base. As generations accumulate, knowledge evolves and the Source Code (Civilization) grows.
25
25
 
26
26
  ## Table of Contents
27
27
 
package/README.zh-CN.md CHANGED
@@ -13,7 +13,7 @@
13
13
 
14
14
  <table align="center">
15
15
  <tr>
16
- <td align="center"><strong>Genome</strong><br><sub>设计与知识</sub></td>
16
+ <td align="center"><strong>Knowledge Base</strong><br><sub>Genome + Environment</sub></td>
17
17
  <td align="center">→</td>
18
18
  <td align="center"><strong>Evolution</strong><br><sub>代际进化</sub></td>
19
19
  <td align="center">→</td>
@@ -21,7 +21,7 @@
21
21
  </tr>
22
22
  </table>
23
23
 
24
- REAP定义应用程序的遗传信息(Genome),为每个世代设定目标进行实现,并将过程中发现的Genome缺陷反馈到后续阶段。随着世代的积累,Genome不断进化,Source Code(Civilization)持续成长。
24
+ REAP记录应用程序的设计知识 — Genome(架构、约定、约束)和Environment(外部API、基础设施) — 并在每个世代设定目标进行实现。过程中发现的缺陷反馈到Knowledge Base。随着世代的积累,知识不断进化,Source Code(Civilization)持续成长。
25
25
 
26
26
  ## 目录
27
27
 
package/dist/cli.js CHANGED
@@ -9817,7 +9817,7 @@ async function initProject(projectRoot, projectName, entryMode, preset, onProgre
9817
9817
  log("GitHub CLI(gh) not found. Install from https://cli.github.com for auto issue reporting.");
9818
9818
  }
9819
9819
  const config = {
9820
- version: "0.10.2",
9820
+ version: "0.10.3",
9821
9821
  project: projectName,
9822
9822
  entryMode,
9823
9823
  autoUpdate: true,
@@ -10992,7 +10992,7 @@ async function updateProject(projectRoot, dryRun = false) {
10992
10992
  result.skipped.push(`.claude/commands/ (${reapCmdFiles.length} unchanged)`);
10993
10993
  }
10994
10994
  await migrateLegacyFiles(paths, dryRun, result);
10995
- const currentVersion = "0.10.2";
10995
+ const currentVersion = "0.10.3";
10996
10996
  const migrationResult = await MigrationRunner.run(paths, currentVersion, dryRun);
10997
10997
  for (const m of migrationResult.migrated) {
10998
10998
  result.updated.push(`[migration] ${m}`);
@@ -11169,7 +11169,7 @@ async function fixProject(projectRoot) {
11169
11169
  // src/cli/index.ts
11170
11170
  init_fs();
11171
11171
  import { join as join12 } from "path";
11172
- program.name("reap").description("REAP — Recursive Evolutionary Autonomous Pipeline").version("0.10.2");
11172
+ program.name("reap").description("REAP — Recursive Evolutionary Autonomous Pipeline").version("0.10.3");
11173
11173
  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) => {
11174
11174
  try {
11175
11175
  const cwd = process.cwd();
@@ -46,17 +46,11 @@ description: "REAP Back — Return to a previous lifecycle stage"
46
46
  ```
47
47
 
48
48
  ### Hook Execution (Regression)
49
- 7. Scan `.reap/hooks/` for files matching `onLifeRegretted.*`
50
- - For each matched file (sorted by `order` from frontmatter, then alphabetically):
51
- 1. Read the frontmatter (`condition`, `order`)
52
- 2. Evaluate `condition` by running `.reap/hooks/conditions/{condition}.sh` (exit 0 = met, non-zero = skip):
53
- - If `condition` is absent: treat as `always`
54
- - If the condition script doesn't exist: warn and skip the hook
55
- - Default conditions: `always`, `has-code-changes`, `version-bumped`
56
- - Users can add custom conditions by placing scripts in `.reap/hooks/conditions/`
57
- 3. Execute based on file extension:
58
- - `.md`: read the file content (after frontmatter) as AI prompt and follow the instructions
59
- - `.sh`: run as shell script in the project root directory
49
+ 7. Execute hooks for event `onLifeRegretted` following the Hook System protocol:
50
+ - Scan `.reap/hooks/` for `onLifeRegretted.*` files
51
+ - Sort by frontmatter `order`, then alphabetically
52
+ - Evaluate `condition`, execute `.md` (AI prompt) or `.sh` (shell script)
53
+ - All hooks run BEFORE any commit (hook outputs included in the same commit)
60
54
 
61
55
  ## Completion
62
56
  - "Returned to [stage] stage. Proceed with `/reap.[stage]`."
@@ -1,5 +1,5 @@
1
1
  ---
2
- description: "REAP Completion — Retrospect, evolve the Genome, and finalize the Generation"
2
+ description: "REAP Completion — Retrospect, evolve the Genome, archive, and finalize the Generation"
3
3
  ---
4
4
 
5
5
  # Completion
@@ -81,10 +81,15 @@ Do NOT finalize Genome changes without running Validation Commands.
81
81
  a. **Describe the pattern**: "최근 N개 generation에서 '[작업 설명]'이 반복적으로 수행되었습니다."
82
82
  b. **Ask if it should be a hook**: "이 작업을 hook으로 자동화할까요? (yes/no)"
83
83
  c. If yes, ask **event**: "어떤 이벤트에서 실행할까요?"
84
- - `onLifeCompleted` generation 완료 후
85
- - `onLifeTransited` — stage 전환
86
- - `onLifeStarted` — generation 시작
87
- - `onLifeRegretted` — stage 회귀
84
+ - Normal lifecycle events (8개):
85
+ - `onLifeStarted` — generation 시작
86
+ - `onLifeObjected` — objective 완료
87
+ - `onLifePlanned` — planning 완료
88
+ - `onLifeImplemented` — implementation 완료 시
89
+ - `onLifeValidated` — validation 완료 시
90
+ - `onLifeCompleted` — generation 완료 시 (archiving 전, 커밋 전)
91
+ - `onLifeTransited` — stage 전환 시
92
+ - `onLifeRegretted` — stage 회귀 시
88
93
  d. Ask **condition**: "실행 조건은 무엇인가요?"
89
94
  - `always` — 항상
90
95
  - `has-code-changes` — src/ 변경이 있을 때
@@ -123,6 +128,47 @@ Do NOT finalize Genome changes without running Validation Commands.
123
128
  24. Report compression results: "Compressed N generations (Level 1: X, Level 2: Y)"
124
129
  - If no compression needed: skip silently
125
130
 
131
+ ### Phase 7: Hook Execution + Archiving + Commit
132
+
133
+ **This phase replaces what `reap.next` previously did when advancing from completion.**
134
+
135
+ 25. **Hook Execution** (before archiving, before commit):
136
+ Execute hooks for event `onLifeCompleted` following the Hook System protocol:
137
+ - Scan `.reap/hooks/` for `onLifeCompleted.*` files
138
+ - Sort by frontmatter `order`, then alphabetically
139
+ - Evaluate `condition`, execute `.md` (AI prompt) or `.sh` (shell script)
140
+ - All hook outputs are included in the same generation commit
141
+
142
+ 26. **Archiving**:
143
+ - Add the current timestamp to `completedAt` in `current.yml`
144
+ - Create the lineage directory: `.reap/lineage/[gen-id]-[goal-slug]/`
145
+ - Goal slug: lowercase, non-alphanumeric/hangul replaced with `-`, max 30 chars
146
+ - **Write `meta.yml`** in the lineage directory with DAG metadata:
147
+ ```yaml
148
+ id: [gen-id]
149
+ type: normal
150
+ parents: [parent generation IDs from current.yml]
151
+ goal: [goal from current.yml]
152
+ genomeHash: [genomeHash from current.yml, or compute from .reap/genome/]
153
+ startedAt: [startedAt from current.yml]
154
+ completedAt: [current ISO 8601]
155
+ ```
156
+ - Move artifact files (`01-*.md` through `05-*.md`) from `.reap/life/` to the lineage directory
157
+ - Process backlog files from `.reap/life/backlog/`:
158
+ - Create `.reap/lineage/[gen-id]-[goal-slug]/backlog/` directory
159
+ - Files with `status: consumed` → move to `.reap/lineage/[gen-id]-[goal-slug]/backlog/`
160
+ - Files with `status: pending` or no status field → copy to `.reap/lineage/[gen-id]-[goal-slug]/backlog/` for record, then carry over to new `.reap/life/backlog/`
161
+ - Clear `current.yml` (write empty content)
162
+ - Recreate `.reap/life/backlog/` directory (with carried-over pending items already in place)
163
+
164
+ 27. **Commit all changes** (code + `.reap/` artifacts together):
165
+ - **Submodule check**: If any git submodule has uncommitted changes (e.g., `tests/`), commit and push inside the submodule first, then stage the updated submodule pointer in the parent repo
166
+ - Stage all changed files: code changes from this generation + `.reap/` directory + submodule pointers
167
+ - Commit message format: `feat(gen-NNN): [generation goal summary]`
168
+ - Use `feat` for feature generations, `fix` for bugfix generations, `chore` for maintenance
169
+ - Include both code and REAP artifacts in the same commit
170
+ - If there are no code changes (REAP-only generation), use `chore(reap): [goal summary]`
171
+
126
172
  ## Self-Verification
127
173
  Before saving the artifact, verify:
128
174
  - [ ] Are lessons concrete and applicable to the next generation? (No vague "do better next time")
@@ -144,5 +190,5 @@ Before saving the artifact, verify:
144
190
  - The artifact should reflect the current state of completion work at all times
145
191
 
146
192
  ## Completion
147
- - **If called from `/reap.evolve`** (Autonomous Override active): Proceed automatically to `/reap.next`.
148
- - **If called standalone**: "Finalize the generation with `/reap.next`. Lineage archiving will be performed automatically."
193
+ - **If called from `/reap.evolve`** (Autonomous Override active): Execute Phase 7 (Hook + Archiving + Commit) automatically. Report: "Generation [id] complete and archived."
194
+ - **If called standalone**: Execute Phase 7 (Hook + Archiving + Commit). Report: "Generation [id] complete and archived. Run `/reap.start` to begin a new generation."
@@ -31,6 +31,17 @@ When `/reap.evolve` calls each stage command, the following overrides apply:
31
31
  - **Escalation sections still apply**: If a stage's Escalation rules trigger, STOP and ask.
32
32
  - This override does NOT apply when stages are invoked standalone (e.g., user runs `/reap.objective` directly).
33
33
 
34
+ ## Hook Auto-Execution
35
+ Each stage command automatically executes its own hook at completion:
36
+ - `/reap.objective` → `onLifeObjected`
37
+ - `/reap.planning` → `onLifePlanned`
38
+ - `/reap.implementation` → `onLifeImplemented`
39
+ - `/reap.validation` → `onLifeValidated`
40
+ - `/reap.completion` → `onLifeCompleted` (before archiving and commit)
41
+
42
+ `/reap.next` only handles stage transitions — it does NOT execute hooks or archiving.
43
+ `/reap.completion` handles archiving and the final commit.
44
+
34
45
  ## Lifecycle Loop
35
46
 
36
47
  Execute the following loop until the generation is complete:
@@ -42,14 +53,14 @@ Execute the following loop until the generation is complete:
42
53
  - `implementation` → `/reap.implementation`
43
54
  - `validation` → `/reap.validation`
44
55
  - `completion` → `/reap.completion`
45
- 3. When the stage command completes, run `/reap.next` to advance
46
- 4. If `/reap.next` archives the generation (from completion), the loop ends
47
- 5. Otherwise, return to step 1
56
+ 3. When the stage command completes (hooks already executed by the stage command):
57
+ - If the current stage is `completion`: `/reap.completion` handles archiving and commit internally. The loop ends.
58
+ - Otherwise: run `/reap.next` to advance, then return to step 1.
48
59
 
49
60
  ## Handling Issues
50
61
  - If validation fails: `/reap.back` to return to implementation (or earlier), then resume the loop
51
62
  - If the human wants to pause: stop the loop, the generation state is preserved in `current.yml`
52
- - If the human wants to skip a stage: advance with `/reap.next` without running the stage command
63
+ - If the human wants to skip a stage: advance with `/reap.next` without running the stage command (note: hooks for skipped stages will NOT run)
53
64
 
54
65
  ## Completion
55
66
  - "Generation [id] completed. All artifacts archived to lineage."
@@ -97,6 +97,13 @@ In the following situations, **STOP and ask the human**:
97
97
  - By the time all tasks are done, the artifact should already be complete — no separate "generation" step is needed
98
98
  - Add Implementation Notes at the end summarizing notable decisions
99
99
 
100
+ ## Hook Execution
101
+ Execute hooks for event `onLifeImplemented` following the Hook System protocol:
102
+ - Scan `.reap/hooks/` for `onLifeImplemented.*` files
103
+ - Sort by frontmatter `order`, then alphabetically
104
+ - Evaluate `condition`, execute `.md` (AI prompt) or `.sh` (shell script)
105
+ - All hooks run BEFORE any commit (hook outputs included in the same commit)
106
+
100
107
  ## Completion
101
108
  - "Proceed to the Validation stage with `/reap.next`."
102
109
  - "If issues are found during Validation, you can return with `/reap.back`."
@@ -1,5 +1,5 @@
1
1
  ---
2
- description: "REAP Merge Completion — Finalize the merge generation"
2
+ description: "REAP Merge Completion — Finalize the merge generation with archiving"
3
3
  ---
4
4
 
5
5
  # Merge Completion
@@ -12,9 +12,48 @@ Finalize the merge generation after validation passes.
12
12
 
13
13
  ## Steps
14
14
 
15
- 1. Commit the merged source + genome changes
16
- 2. Write `06-completion.md` with:
15
+ 1. Write `06-completion.md` with:
17
16
  - Summary of what was merged
18
17
  - Genome changes applied
19
18
  - Lessons learned
20
- 3. Proceed with `/reap.next` to archive
19
+
20
+ ### Hook Execution + Archiving + Commit
21
+
22
+ **This phase handles hook execution, archiving, and commit (previously done by `reap.next`).**
23
+
24
+ 2. **Hook Execution** (before archiving, before commit):
25
+ Execute hooks for event `onMergeCompleted` following the Hook System protocol:
26
+ - Scan `.reap/hooks/` for `onMergeCompleted.*` files
27
+ - Sort by frontmatter `order`, then alphabetically
28
+ - Evaluate `condition`, execute `.md` (AI prompt) or `.sh` (shell script)
29
+ - All hook outputs are included in the same generation commit
30
+
31
+ 3. **Archiving**:
32
+ - Add the current timestamp to `completedAt` in `current.yml`
33
+ - Create the lineage directory: `.reap/lineage/[gen-id]-[goal-slug]/`
34
+ - Goal slug: lowercase, non-alphanumeric/hangul replaced with `-`, max 30 chars
35
+ - **Write `meta.yml`** in the lineage directory with DAG metadata:
36
+ ```yaml
37
+ id: [gen-id]
38
+ type: merge
39
+ parents: [parent generation IDs from current.yml]
40
+ goal: [goal from current.yml]
41
+ genomeHash: [genomeHash from current.yml, or compute from .reap/genome/]
42
+ startedAt: [startedAt from current.yml]
43
+ completedAt: [current ISO 8601]
44
+ ```
45
+ - Move artifact files (`01-*.md` through `06-*.md`) from `.reap/life/` to the lineage directory
46
+ - Process backlog files from `.reap/life/backlog/`:
47
+ - Create `.reap/lineage/[gen-id]-[goal-slug]/backlog/` directory
48
+ - Files with `status: consumed` → move to lineage backlog
49
+ - Files with `status: pending` or no status field → copy to lineage backlog, carry over to `.reap/life/backlog/`
50
+ - Clear `current.yml` (write empty content)
51
+ - Recreate `.reap/life/backlog/` directory (with carried-over pending items)
52
+
53
+ 4. **Commit** (source + archiving in a single commit):
54
+ - **Submodule check**: If any git submodule has uncommitted changes, commit and push inside the submodule first, then stage the updated submodule pointer in the parent repo
55
+ - Stage all changed files (merged source + genome changes + `.reap/` artifacts + hook outputs)
56
+ - Commit message format: `merge(gen-NNN-hash): [generation goal summary]`
57
+
58
+ ## Completion
59
+ - "Merge generation [id] complete and archived. Run `/reap.start` to begin a new generation."
@@ -17,4 +17,11 @@ Analyze the divergence between the current branch and the target branch.
17
17
  - Genome changes on each side
18
18
  - Conflicts (WRITE-WRITE, CROSS-FILE)
19
19
  3. If the detect needs to be re-run, use `reap merge {branch}` again
20
- 4. When satisfied, proceed with `/reap.next`
20
+ 4. When satisfied, execute hooks and proceed with `/reap.next`
21
+
22
+ ### Hook Execution
23
+ Execute hooks for event `onMergeDetected` following the Hook System protocol:
24
+ - Scan `.reap/hooks/` for `onMergeDetected.*` files
25
+ - Sort by frontmatter `order`, then alphabetically
26
+ - Evaluate `condition`, execute `.md` (AI prompt) or `.sh` (shell script)
27
+ - All hooks run BEFORE any commit (hook outputs included in the same commit)
@@ -9,6 +9,18 @@ Run the entire merge lifecycle from the current stage to completion.
9
9
  ## Gate
10
10
  - Verify current generation is type: merge
11
11
 
12
+ ## Hook Auto-Execution
13
+ Each merge stage command automatically executes its own hook at completion:
14
+ - `/reap.merge.detect` → `onMergeDetected`
15
+ - `/reap.merge.mate` → `onMergeMated`
16
+ - `/reap.merge.merge` → `onMergeMerged`
17
+ - `/reap.merge.sync` → `onMergeSynced`
18
+ - `/reap.merge.validation` → `onMergeValidated`
19
+ - `/reap.merge.completion` → `onMergeCompleted` (before archiving and commit)
20
+
21
+ `/reap.next` only handles stage transitions — it does NOT execute hooks or archiving.
22
+ `/reap.merge.completion` handles archiving and the final commit.
23
+
12
24
  ## Steps
13
25
 
14
26
  Execute the merge lifecycle loop:
@@ -20,8 +32,9 @@ Execute the merge lifecycle loop:
20
32
  - `sync` → `/reap.merge.sync`
21
33
  - `validation` → `/reap.merge.validation`
22
34
  - `completion` → `/reap.merge.completion`
23
- 3. After each stage, run `/reap.next`
24
- 4. If `/reap.next` archives the generation, the loop ends
35
+ 3. When a stage command completes (hooks already executed by the stage command):
36
+ - If the current stage is `completion`: `/reap.merge.completion` handles archiving and commit internally. The loop ends.
37
+ - Otherwise: run `/reap.next` to advance, then return to step 1.
25
38
 
26
39
  ## Autonomous Override
27
40
  Same rules as `/reap.evolve` — skip routine confirmations, stop only when genuinely blocked.
@@ -20,7 +20,14 @@ Resolve genome conflicts identified in the detect stage. The genome must be full
20
20
  - Show the changes and ask if they are logically compatible
21
21
  4. Apply the resolved genome to `.reap/genome/`
22
22
  5. Record all decisions in `02-mate.md`
23
- 6. Proceed with `/reap.next`
23
+ 6. Execute hooks and proceed with `/reap.next`
24
+
25
+ ### Hook Execution
26
+ Execute hooks for event `onMergeMated` following the Hook System protocol:
27
+ - Scan `.reap/hooks/` for `onMergeMated.*` files
28
+ - Sort by frontmatter `order`, then alphabetically
29
+ - Evaluate `condition`, execute `.md` (AI prompt) or `.sh` (shell script)
30
+ - All hooks run BEFORE any commit (hook outputs included in the same commit)
24
31
 
25
32
  ## Escalation
26
33
  - If conflicts are complex or ambiguous, STOP and ask the human
@@ -19,4 +19,11 @@ Merge the source code from the target branch, using the finalized genome as the
19
19
  3. If no git conflicts:
20
20
  - Check for semantic conflicts (code that compiles but contradicts the genome)
21
21
  4. Do NOT commit yet — sync and validation must pass first
22
- 5. Proceed with `/reap.next`
22
+ 5. Execute hooks and proceed with `/reap.next`
23
+
24
+ ### Hook Execution
25
+ Execute hooks for event `onMergeMerged` following the Hook System protocol:
26
+ - Scan `.reap/hooks/` for `onMergeMerged.*` files
27
+ - Sort by frontmatter `order`, then alphabetically
28
+ - Evaluate `condition`, execute `.md` (AI prompt) or `.sh` (shell script)
29
+ - All hooks run BEFORE any commit (hook outputs included in the same commit)
@@ -20,3 +20,10 @@ Start a merge generation by specifying a target branch to merge into the current
20
20
  5. Report: parents, common ancestor, conflict count
21
21
  6. If genome conflicts exist: proceed to `/reap.merge.mate`
22
22
  7. If no genome conflicts: mate can auto-pass, proceed to `/reap.merge.merge`
23
+
24
+ ### Hook Execution
25
+ Execute hooks for event `onMergeStarted` following the Hook System protocol:
26
+ - Scan `.reap/hooks/` for `onMergeStarted.*` files
27
+ - Sort by frontmatter `order`, then alphabetically
28
+ - Evaluate `condition`, execute `.md` (AI prompt) or `.sh` (shell script)
29
+ - All hooks run BEFORE any commit (hook outputs included in the same commit)
@@ -24,7 +24,14 @@ Verify that the merged source code is consistent with the finalized genome. This
24
24
  - Ask: fix the source, update the genome, or accept as-is with rationale
25
25
  - Record the decision in `04-sync.md`
26
26
  4. If no inconsistencies: record "All consistent" in `04-sync.md`
27
- 5. Proceed with `/reap.next`
27
+ 5. Execute hooks and proceed with `/reap.next`
28
+
29
+ ### Hook Execution
30
+ Execute hooks for event `onMergeSynced` following the Hook System protocol:
31
+ - Scan `.reap/hooks/` for `onMergeSynced.*` files
32
+ - Sort by frontmatter `order`, then alphabetically
33
+ - Evaluate `condition`, execute `.md` (AI prompt) or `.sh` (shell script)
34
+ - All hooks run BEFORE any commit (hook outputs included in the same commit)
28
35
 
29
36
  ## Escalation
30
37
  - **Every inconsistency requires user confirmation** — do NOT auto-resolve
@@ -18,8 +18,16 @@ Run all validation commands to verify the merged code works correctly. Same as n
18
18
  - Type check (`bunx tsc --noEmit`)
19
19
  - Build (`npm run build`)
20
20
  3. Record results in `05-validation.md`
21
- 4. If all pass: proceed with `/reap.next`
21
+ 4. If all pass: execute hooks and proceed with `/reap.next`
22
22
  5. If any fail:
23
23
  - Analyze the failure
24
24
  - `/reap.back merge` to fix source issues
25
25
  - Or `/reap.back mate` if the genome needs adjustment
26
+
27
+ ### Hook Execution
28
+ Execute hooks for event `onMergeValidated` following the Hook System protocol:
29
+ - Scan `.reap/hooks/` for `onMergeValidated.*` files
30
+ - Sort by frontmatter `order`, then alphabetically
31
+ - Evaluate `condition`, execute `.md` (AI prompt) or `.sh` (shell script)
32
+ - All hooks run BEFORE any commit (hook outputs included in the same commit)
33
+ - **Only execute on pass** — do NOT execute hooks if validation fails
@@ -13,7 +13,8 @@ This command is the **ONLY legitimate way** to advance the lifecycle stage. All
13
13
  ## Steps
14
14
 
15
15
  ### Stage Transition
16
- - Stage order: objective → planning → implementation → validation → completion
16
+ - Stage order (normal): objective → planning → implementation → validation → completion
17
+ - Stage order (merge): detect → mate → merge → sync → validation → completion
17
18
  - Update the `stage` in `current.yml` to the next stage
18
19
  - Add an entry to `timeline`:
19
20
  ```yaml
@@ -22,70 +23,14 @@ This command is the **ONLY legitimate way** to advance the lifecycle stage. All
22
23
  ```
23
24
  - Immediately create the next stage's artifact file from template (empty, ready to fill)
24
25
 
25
- ### Hook Execution (Stage Transition)
26
- Execute two sets of hooks in order:
26
+ **Note**: Stage-specific hooks (e.g., `onLifeObjected`) are handled by each stage command at its own completion, NOT by this command. Archiving is handled by `reap.completion` (normal) or `reap.merge.completion` (merge).
27
27
 
28
- 1. **Stage-specific hook** — based on the stage that just completed:
29
- - objective planning: `onLifeObjected.*`
30
- - planning implementation: `onLifePlanned.*`
31
- - implementation → validation: `onLifeImplemented.*`
32
- - validation → completion: `onLifeValidated.*`
28
+ ### Hook Execution (Transition)
29
+ After updating `current.yml`, execute the generic transition hook based on generation type:
30
+ - If `type` is `merge` (or current stage is a merge stage): execute hooks for event `onMergeTransited`
31
+ - Otherwise (normal): execute hooks for event `onLifeTransited`
33
32
 
34
- 2. **Generic transition hook** `onLifeTransited.*` (fires on every transition)
35
-
36
- For each matched file (sorted by `order` from frontmatter, then alphabetically):
37
- 1. Read the frontmatter (`condition`, `order`)
38
- 2. Evaluate `condition` by running `.reap/hooks/conditions/{condition}.sh` (exit 0 = met, non-zero = skip):
39
- - If `condition` is absent: treat as `always`
40
- - If the condition script doesn't exist: warn and skip the hook
41
- - Default conditions: `always`, `has-code-changes`, `version-bumped`
42
- - Users can add custom conditions by placing scripts in `.reap/hooks/conditions/`
43
- 3. Execute based on file extension:
44
- - `.md`: read the file content (after frontmatter) as AI prompt and follow the instructions
45
- - `.sh`: run as shell script in the project root directory
46
-
47
- ### When Advancing from Completion (Archiving)
48
- - Add the current timestamp to `completedAt` in `current.yml`
49
- - Create the lineage directory: `.reap/lineage/[gen-id]-[goal-slug]/`
50
- - Goal slug: lowercase, non-alphanumeric/hangul replaced with `-`, max 30 chars
51
- - **Write `meta.yml`** in the lineage directory with DAG metadata:
52
- ```yaml
53
- id: [gen-id]
54
- type: [normal or merge]
55
- parents: [parent generation IDs from current.yml]
56
- goal: [goal from current.yml]
57
- genomeHash: [genomeHash from current.yml, or compute from .reap/genome/]
58
- startedAt: [startedAt from current.yml]
59
- completedAt: [current ISO 8601]
60
- ```
61
- - Move artifact files (`01-*.md` through `05-*.md`) from `.reap/life/` to the lineage directory
62
- - Process backlog files from `.reap/life/backlog/`:
63
- - Create `.reap/lineage/[gen-id]-[goal-slug]/backlog/` directory
64
- - Files with `status: consumed` → move to `.reap/lineage/[gen-id]-[goal-slug]/backlog/`
65
- - Files with `status: pending` or no status field → copy to `.reap/lineage/[gen-id]-[goal-slug]/backlog/` for record, then carry over to new `.reap/life/backlog/`
66
- - Clear `current.yml` (write empty content)
67
- - Recreate `.reap/life/backlog/` directory (with carried-over pending items already in place)
68
- - **Commit all changes** (code + `.reap/` artifacts together):
69
- - Stage all changed files: code changes from this generation + `.reap/` directory
70
- - Commit message format: `feat(gen-NNN): [generation goal summary]`
71
- - Use `feat` for feature generations, `fix` for bugfix generations, `chore` for maintenance
72
- - Include both code and REAP artifacts in the same commit
73
- - If there are no code changes (REAP-only generation), use `chore(reap): [goal summary]`
74
-
75
- ### Hook Execution (Generation Complete)
76
- - Scan `.reap/hooks/` for files matching `onLifeCompleted.*`
77
- - For each matched file (sorted by `order` from frontmatter, then alphabetically):
78
- 1. Read the frontmatter (`condition`, `order`)
79
- 2. Evaluate `condition` by running `.reap/hooks/conditions/{condition}.sh` (exit 0 = met, non-zero = skip):
80
- - If `condition` is absent: treat as `always`
81
- - If the condition script doesn't exist: warn and skip the hook
82
- - Default conditions: `always`, `has-code-changes`, `version-bumped`
83
- - Users can add custom conditions by placing scripts in `.reap/hooks/conditions/`
84
- 3. Execute based on file extension:
85
- - `.md`: read the file content (after frontmatter) as AI prompt and follow the instructions
86
- - `.sh`: run as shell script in the project root directory
87
- - Note: hooks run AFTER the commit, so any changes from hooks will be uncommitted
33
+ Scan `.reap/hooks/` for `{event}.*` files, sort by frontmatter `order` then alphabetically, evaluate `condition`, execute `.md` (AI prompt) or `.sh` (shell script).
88
34
 
89
35
  ## Completion
90
- - If archived: "Generation [id] complete and archived. Run `/reap.start` to begin a new generation."
91
- - Otherwise: "Advanced to [next stage]. Proceed with `/reap.[next stage]`."
36
+ - "Advanced to [next stage]. Proceed with `/reap.[next stage]`."
@@ -196,7 +196,7 @@ When entering brainstorming, follow the structured brainstorming process below t
196
196
  ---
197
197
  type: genome-change
198
198
  status: pending
199
- target: genome/domain/{topic}.md
199
+ target: genome/{file}
200
200
  ---
201
201
  # [Title]
202
202
  [Specifically what is lacking and how it should be changed]
@@ -250,7 +250,14 @@ Before saving the artifact, verify:
250
250
  - The artifact should reflect the **current state of work at all times**
251
251
  - Do NOT wait until the end to write the artifact
252
252
 
253
+ ## Hook Execution
254
+ Execute hooks for event `onLifeObjected` following the Hook System protocol:
255
+ - Scan `.reap/hooks/` for `onLifeObjected.*` files
256
+ - Sort by frontmatter `order`, then alphabetically
257
+ - Evaluate `condition`, execute `.md` (AI prompt) or `.sh` (shell script)
258
+ - All hooks run BEFORE any commit (hook outputs included in the same commit)
259
+
253
260
  ## Completion
254
- - **If called from `/reap.evolve`** (Autonomous Override active): Save the artifact and proceed automatically. Do NOT pause for human confirmation.
255
- - **If called standalone**: Show the artifact to the human and get confirmation.
261
+ - **If called from `/reap.evolve`** (Autonomous Override active): Save the artifact, execute hooks, and proceed automatically. Do NOT pause for human confirmation.
262
+ - **If called standalone**: Show the artifact to the human and get confirmation. Then execute hooks.
256
263
  - After confirmation or auto-proceed: "Proceed to the Planning stage with `/reap.next`."
@@ -95,7 +95,14 @@ Before saving the artifact, verify:
95
95
  - The artifact is a **living document** during the stage — it should reflect the current state of work at all times
96
96
  - Do NOT wait until the end to write the artifact
97
97
 
98
+ ## Hook Execution
99
+ Execute hooks for event `onLifePlanned` following the Hook System protocol:
100
+ - Scan `.reap/hooks/` for `onLifePlanned.*` files
101
+ - Sort by frontmatter `order`, then alphabetically
102
+ - Evaluate `condition`, execute `.md` (AI prompt) or `.sh` (shell script)
103
+ - All hooks run BEFORE any commit (hook outputs included in the same commit)
104
+
98
105
  ## Completion
99
- - **If called from `/reap.evolve`** (Autonomous Override active): Save the artifact and proceed automatically. Do NOT pause for human confirmation.
100
- - **If called standalone**: Show the artifact to the human and get confirmation.
106
+ - **If called from `/reap.evolve`** (Autonomous Override active): Save the artifact, execute hooks, and proceed automatically. Do NOT pause for human confirmation.
107
+ - **If called standalone**: Show the artifact to the human and get confirmation. Then execute hooks.
101
108
  - After confirmation or auto-proceed: "Proceed to the Implementation stage with `/reap.next`."
@@ -41,17 +41,12 @@ description: "REAP Start — Start a new Generation"
41
41
  7. Immediately create `.reap/life/01-objective.md` from the artifact template with the Goal section filled in
42
42
 
43
43
  ### Hook Execution (Generation Start)
44
- 8. Scan `.reap/hooks/` for files matching `onLifeStarted.*`
45
- - For each matched file (sorted by `order` from frontmatter, then alphabetically):
46
- 1. Read the frontmatter (`condition`, `order`)
47
- 2. Evaluate `condition` by running `.reap/hooks/conditions/{condition}.sh` (exit 0 = met, non-zero = skip):
48
- - If `condition` is absent: treat as `always`
49
- - If the condition script doesn't exist: warn and skip the hook
50
- - Default conditions: `always`, `has-code-changes`, `version-bumped`
51
- - Users can add custom conditions by placing scripts in `.reap/hooks/conditions/`
52
- 3. Execute based on file extension:
53
- - `.md`: read the file content (after frontmatter) as AI prompt and follow the instructions
54
- - `.sh`: run as shell script in the project root directory
44
+ 8. Execute hooks for event `onLifeStarted` following the Hook System protocol:
45
+ - Scan `.reap/hooks/` for `onLifeStarted.*` files
46
+ - Sort by frontmatter `order`, then alphabetically
47
+ - Evaluate `condition`, execute `.md` (AI prompt) or `.sh` (shell script)
48
+ - All hooks run BEFORE any commit (hook outputs included in the same commit)
49
+ - **Order**: This runs AFTER backlog consumed marking (Step 4) and current.yml creation (Step 6)
55
50
 
56
51
  ## Completion
57
52
  - "Generation gen-XXX-{hash} started. Proceed with `/reap.objective` to define the goal, or `/reap.evolve` to run the full lifecycle."
@@ -80,6 +80,13 @@ Do NOT make claims without evidence. This is non-negotiable.
80
80
  - After Step 5 (Verdict) → update the Result field to pass / partial / fail
81
81
  - The artifact should reflect the current validation progress at all times
82
82
 
83
+ ## Hook Execution
84
+ Execute hooks for event `onLifeValidated` following the Hook System protocol:
85
+ - Scan `.reap/hooks/` for `onLifeValidated.*` files
86
+ - Sort by frontmatter `order`, then alphabetically
87
+ - Evaluate `condition`, execute `.md` (AI prompt) or `.sh` (shell script)
88
+ - All hooks run BEFORE any commit (hook outputs included in the same commit)
89
+
83
90
  ## Completion
84
- - pass/partial: "Proceed to the Completion stage with `/reap.next`."
85
- - fail: Provide regression guidance
91
+ - pass/partial: Execute hooks, then "Proceed to the Completion stage with `/reap.next`."
92
+ - fail: Provide regression guidance (do NOT execute hooks on fail)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@c-d-cc/reap",
3
- "version": "0.10.2",
3
+ "version": "0.10.3",
4
4
  "description": "Recursive Evolutionary Autonomous Pipeline — AI and humans evolve software across generations",
5
5
  "type": "module",
6
6
  "license": "MIT",