@odarino/haren 1.4.0 → 1.7.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.
Files changed (37) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/LICENSE +1 -1
  3. package/README.md +108 -9
  4. package/content/agents/architect.md +1 -1
  5. package/content/agents/developer.md +4 -3
  6. package/content/agents/planner.md +3 -1
  7. package/content/agents/reviewer.md +2 -0
  8. package/content/skills/audit-workspace/SKILL.md +2 -1
  9. package/content/skills/collect-components/SKILL.md +81 -0
  10. package/content/skills/decompose/SKILL.md +10 -16
  11. package/content/skills/discover/SKILL.md +6 -2
  12. package/content/skills/discover/blueprint.md +1 -0
  13. package/content/skills/discover/explore.md +1 -0
  14. package/content/skills/discover/inherit.md +1 -0
  15. package/content/skills/discover/migration.md +38 -0
  16. package/content/skills/evaluate/SKILL.md +24 -0
  17. package/content/skills/extract/SKILL.md +43 -0
  18. package/content/skills/generate-mockup/SKILL.md +41 -5
  19. package/content/skills/ideate/SKILL.md +2 -0
  20. package/content/skills/implement/SKILL.md +20 -11
  21. package/content/skills/plan/SKILL.md +57 -9
  22. package/content/skills/read-context/SKILL.md +12 -1
  23. package/content/skills/resolve-next-id/SKILL.md +9 -1
  24. package/content/skills/ui-review/SKILL.md +64 -0
  25. package/content/skills/update-tracking/SKILL.md +11 -1
  26. package/content/skills/validate-artifact/SKILL.md +34 -0
  27. package/content/skills/visual-companion/SKILL.md +285 -0
  28. package/content/templates/checklist.md +26 -0
  29. package/content/templates/component-catalog.md +41 -0
  30. package/content/templates/design.md +15 -0
  31. package/content/templates/deviation-log.md +13 -0
  32. package/content/templates/legacy-semantics.md +11 -0
  33. package/content/templates/parity-evidence.md +32 -0
  34. package/content/templates/unit-map.md +20 -0
  35. package/content/templates/unit-spec.md +43 -0
  36. package/dist/index.js +2681 -120
  37. package/package.json +4 -3
package/CHANGELOG.md ADDED
@@ -0,0 +1,18 @@
1
+ # Changelog
2
+
3
+ Each section lists what changed in one release. `haren upgrade` prints the sections between your old version and the new one.
4
+
5
+ ## 1.7.0
6
+
7
+ ### New
8
+ - **Component catalog** (`collect-components` skill): one file, `artifacts/03-modules/component-catalog.md`, lists the common UI components (with a short ASCII sketch), shared services and shared functions of your repos. The plan reads it before it designs new code. Implement updates it after each task.
9
+ - **Implementation checklist**: the plan writes `checklist.md` next to `tasks.md`, with concrete checks per task (tests, reuse, files, contract, edge cases). Implement ticks only what it verified. A difference from the plan is written as `— changed: {what and why}`, and a skip as `— skipped: {reason}`. Evaluate checks each tick.
10
+ - **Choose the mockup format**: with `ui.mockups: ask`, `generate-mockup` asks before the first mockup: ASCII, Claude Artifact or a local browser tab.
11
+ - **`artifact` UI mode**: `haren track ui-mode artifact` shows mockup options as a private Claude Artifact page (Claude Code with claude.ai only).
12
+ - **`haren track commit <module> <repoKey> --remove`** removes a stale repo key from `progress.json`.
13
+ - **What's new**: `haren upgrade` prints this changelog for the versions you skipped.
14
+
15
+ ### Fixed
16
+ - `haren track status` no longer crashes on a module status from an old `progress.json` (for example `specified`). Such a module can move to `decomposed` or `planned`.
17
+ - `track status --repos`, `track commit` and `track check` use the same repo key rule. When `manifest.yaml` has no `repos`, the key is `default`.
18
+ - The brainstorm gate no longer blocks writes to files outside the workspace.
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2026 Phung Vu
3
+ Copyright (c) 2026 odarino
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -163,7 +163,7 @@ haren is its own repo next to the code repos.
163
163
  workspace/ (no .git)
164
164
  ├── backend/ (.git)
165
165
  ├── frontend/ (.git)
166
- ├── cmis_ai_rules/ (.git — the haren repo, any folder name)
166
+ ├── haren-rules/ (.git — the haren repo, any folder name)
167
167
  ├── CLAUDE.md # generated per machine, not versioned
168
168
  └── .claude/ # generated per machine, not versioned
169
169
  ```
@@ -180,8 +180,9 @@ every repo.
180
180
  | Command | What it does |
181
181
  | --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
182
182
  | `haren init` | Set up haren in the current directory: scaffold a new haren folder, or set up a cloned one. Interactive, or pass flags (below). |
183
- | `haren upgrade` | Update framework files in an existing haren folder to the installed version, and migrate old `manifest.yaml` / `progress.json`. It also restores missing plugins from `plugins.json`. Use `--yes` to accept plugins from unofficial sources. |
183
+ | `haren upgrade` | Update framework files in an existing haren folder to the installed version, and migrate old `manifest.yaml` / `progress.json`. It also restores missing plugins from `plugins.json`, and prints what's new since your old version (from [CHANGELOG.md](CHANGELOG.md)). Use `--yes` to accept plugins from unofficial sources. |
184
184
  | `haren plugin` | Manage plugins: `add <name\|source>`, `remove <name>`, `list`, `doctor`, `run <hook>`. See [PLUGINS.md](PLUGINS.md). |
185
+ | `haren migrate` | Migration mode only: `inventory [--module m]`, `extract <unit>`, `gate <unit> [--approve]`. It runs the adapter commands. See [Migration mode](#migration-mode). |
185
186
  | `haren agent` | Manage the local agent bridge _(experimental — for the in-progress Haren Portal)_. |
186
187
 
187
188
  `haren agent` works in both layouts. It uses the git remote of the haren repo as
@@ -194,7 +195,7 @@ Run `haren` with no arguments for help.
194
195
  ```bash
195
196
  haren init \
196
197
  --project "my-app" \
197
- --mode blueprint \ # blueprint | explore | inherit | undecided
198
+ --mode blueprint \ # blueprint | explore | inherit | migration | undecided
198
199
  --language English \
199
200
  --editor both \ # claude-code | cursor | both
200
201
  --iterations \ # enable iteration-based planning
@@ -220,7 +221,7 @@ Layout and folder flags:
220
221
  ```
221
222
  Plan:
222
223
  /path/to/workspace/
223
- ├── cmis_ai_rules/ + create (git init, own repo)
224
+ ├── haren-rules/ + create (git init, own repo)
224
225
  │ ├── manifest.yaml + create layout: workspace
225
226
  │ ├── artifacts/ + create
226
227
  │ └── hooks/ + create
@@ -245,8 +246,8 @@ generated per machine and are not versioned. If you already have content in
245
246
  The haren repo is the source of truth. A teammate does not run a full init.
246
247
 
247
248
  ```bash
248
- git clone <haren-repo-url> workspace/cmis_ai_rules
249
- cd workspace/cmis_ai_rules
249
+ git clone <haren-repo-url> workspace/haren-rules
250
+ cd workspace/haren-rules
250
251
  haren init
251
252
  ```
252
253
 
@@ -271,6 +272,45 @@ A skill for a new developer or a new workspace. It does three things:
271
272
  It never clones and never changes git state. To clone a missing repo, run
272
273
  `haren init`.
273
274
 
275
+ ### Migration mode
276
+
277
+ Use `--mode migration` to rewrite a legacy system when parity with the old system is the bar.
278
+ The legacy repo has `role: legacy` and `readOnly: true` in `manifest.yaml`. The code gate blocks all Edit and Write calls into it. The gate override does not lift this block.
279
+ For Bash commands, the guard is best effort: it blocks common writes (redirects, `sed -i`, `rm`, `git commit`, and so on), but a shell can hide a write. Also make the legacy repo read-only at the filesystem or git level where possible, for example a read-only checkout or a clone with no push access.
280
+
281
+ The unit is the work item, for example one screen. Each unit has a status: `inventoried`, `extracted`, `spec-draft`, `spec-approved`, `built`, `verified`, `parity-signed`. The side statuses are `blocked` and `static-review-only`. Use `haren track unit <module> <unit> <status>` to move it. A module cannot pass a stage while a unit is below it.
282
+
283
+ An adapter plugin reads the legacy format. Install one with `haren plugin add <source>`. Then run:
284
+
285
+ ```bash
286
+ haren migrate inventory [--module m] # list units, write unit-map.md
287
+ haren migrate extract <unit> # extract the unit, then write the spec
288
+ haren migrate gate <unit> [--approve] # run the spec gate; --approve records the human approval
289
+ haren track check # also checks unit rules in migration mode
290
+ ```
291
+
292
+ `haren migrate gate` exit codes: 0 = the gate passed and the spec is approved. 1 = a gate FAIL or an adapter error. 3 = the gate passed but the spec is not approved yet (no TTY and no `--approve`). Exit 3 is not a failure: review the spec, then re-run with `--approve`. An agent must ask the user on exit 3. With a TTY, declining the approval prompt exits 0 with "Not approved". Exit 3 is only the no-TTY case without `--approve`.
293
+
294
+ A gate FAIL and an adapter error are different results. An adapter error changes no status. A gate FAIL on a `spec-approved` unit moves it back to `spec-draft`. An adapter command stops after 300 seconds by default. Set `HAREN_ADAPTER_TIMEOUT_MS` to change the limit.
295
+
296
+ #### Write an adapter
297
+
298
+ An adapter is a plugin with `harenApi: "2"` and an `adapter` block in `haren-plugin.json`. The block has `unitKind`, `commands` (`inventory`, `extract`, `gate`), `skills.spec`, and an optional `semantics` file.
299
+ Each command is a string. The CLI splits it into arguments and does not use a shell. It replaces these placeholders: `{legacyRoot}`, `{unit}`, `{unitDir}`, `{specPath}`.
300
+ Each command prints one JSON object on stdout. The CLI checks the shape:
301
+
302
+ ```jsonc
303
+ // inventory
304
+ { "units": [ { "id": "SCR_A001", "parent": null, "family": "order", "title": "Order list" } ] }
305
+ // extract
306
+ { "unit": "SCR_A001", "files": ["ir.xml", "view.txt"] }
307
+ // gate
308
+ { "unit": "SCR_A001", "pass": false,
309
+ "findings": [ { "severity": "error", "rule": "missing-binding", "message": "..." } ] }
310
+ ```
311
+
312
+ A non-zero exit code or a wrong shape is an adapter error. See `examples/adapters/sample` for a working adapter with a fake screen format and a fixture legacy repo.
313
+
274
314
  ### `haren track`
275
315
 
276
316
  Use `haren track` to update `progress.json`, the artifact index, and
@@ -279,20 +319,25 @@ The command finds the haren folder from the current folder. Use `--haren-dir <pa
279
319
  or `HAREN_DIR` to choose one. It keeps all other keys in `progress.json`.
280
320
 
281
321
  ```bash
282
- haren track status <module> <status>
322
+ haren track status <module> <status> [--branch <name>] [--repos <key1,key2>]
283
323
  haren track feature <module> <feature> [status]
284
324
  haren track commit <module> <repoKey> <sha>
285
325
  haren track artifact <id> --type <type> --path <path> [--module <m>] [--status <s>]
286
326
  haren track event <type> [--module m] [--phase p] [--feature f] [--data '<json object>']
327
+ haren track unit <module> <unit> <status> # migration mode only
328
+ haren track depends <module> [dep ...] # set module dependencies; rejects a cycle
287
329
  haren track override on --reason "<text>" [--hours <n>]
288
330
  haren track override off
331
+ haren track check # manifest repos + artifact index consistency; exits 1 on FAIL
289
332
  ```
290
333
 
291
334
  - `status` checks the module transition. It creates a missing module only at
292
335
  `discovered` or `decomposed`. Transitions:
293
336
  `discovered → decomposed → planned → implementing → evaluating → completed → released`.
294
337
  `implementing` and `evaluating` can go to `blocked`. `blocked` goes back to
295
- `implementing` or `planned`.
338
+ `implementing` or `planned`. `--branch` sets the module branch. `--repos` sets the module
339
+ repos. Each repo key must exist in `manifest.yaml`. With the same status as the module,
340
+ the command only updates the branch and repos.
296
341
  - `feature` without a status adds the feature as `pending`. With a status it checks
297
342
  the transition: `pending → in-progress → evaluating → passing | fixing | blocked`,
298
343
  `fixing → evaluating`, `blocked → in-progress`.
@@ -349,6 +394,59 @@ Skills also write these types with `haren track event`: `ideate-complete`,
349
394
  `discover-complete`, `feature-ready`, `escalate-human`, `iteration-complete`,
350
395
  `release-step`. Any other type is accepted.
351
396
 
397
+ ### Visual companion
398
+
399
+ The visual companion shows UI mockups in a browser. The plan and evaluate phases use it
400
+ when the UI mode allows it. Choose the UI mode with `haren track ui-mode <ask|ascii|browser|artifact>`.
401
+ The mode is stored in `manifest.yaml` as `ui.mockups`. The default is `ask`.
402
+
403
+ | Mode | What happens |
404
+ | --------- | ------------------------------------------------------------------ |
405
+ | `ask` | The agent offers the browser before it shows a screen. |
406
+ | `ascii` | The agent shows ASCII wireframes in the terminal only. |
407
+ | `browser` | The agent shows option screens in the browser. You click a choice. |
408
+
409
+ ```bash
410
+ haren companion start [--open] [--foreground] [--host <h>] [--url-host <h>] \
411
+ [--idle-timeout-minutes <n>] [--port <n>] [--key <k>] [--no-owner-watch] \
412
+ [--owner-grace-minutes <n>]
413
+ haren companion status # exit 0 when a server runs, 1 when not
414
+ haren companion stop
415
+ ```
416
+
417
+ - `start` prints one JSON line:
418
+ `{"type":"server-started","port","url","screen_dir","state_dir"}`.
419
+ - A restart of a stopped session reuses its folder, key and port. It also reuses
420
+ `--host`, `--url-host`, `--idle-timeout-minutes` and `--owner-grace-minutes` from `state/options.json`. If the
421
+ port is busy, the server takes a new port and prints a note on stderr.
422
+ - When the agent process that started the server exits, a grace period starts
423
+ (default 10 minutes, `--owner-grace-minutes <n>`). The server stops after the grace
424
+ period only when no browser tab is connected and no request came in. Use
425
+ `--no-owner-watch` to keep it running. Both minute flags must be positive integers.
426
+ With `--open` in a print-mode run, the browser tab stays connected, so the server keeps
427
+ running until the user closes the tab (then the grace period applies) or runs `haren companion stop`.
428
+ - A restart moves old screens to `content/archive/<epoch>/`.
429
+ - `stop` with no running server prints `No companion server is running.` and exits 0.
430
+ - Session files are in `<haren folder>/.companion/<pid>-<epoch>/`. The agent writes
431
+ HTML screens to `content/`. Your clicks go to `state/events` as JSON lines:
432
+ `{"type":"click","choice","text","timestamp"}`.
433
+ - The `visual-companion` skill drives the server. The `ui-review` skill checks a
434
+ screen against a rubric. The plan, evaluate and generate-mockup skills use the mode.
435
+
436
+ Security notes:
437
+
438
+ - The server binds to `127.0.0.1`.
439
+ - A secret key is in the URL. The server then sets a `SameSite=Strict` cookie.
440
+ The key is in `state/key` (mode 0600). The key is not on the server command line.
441
+ - The session folders are mode 0700. The state files are mode 0600.
442
+ - The server sends `Referrer-Policy: no-referrer`.
443
+ - The `/files` route serves only the `content/` folder.
444
+ - `.companion/` is in `.gitignore`. Do not commit it.
445
+
446
+ The companion server is adapted from the visual companion in
447
+ [Superpowers](https://github.com/obra/superpowers) by Jesse Vincent (MIT license).
448
+ See `apps/cli/src/companion/NOTICE`.
449
+
352
450
  ---
353
451
 
354
452
  ## How it works
@@ -388,7 +486,8 @@ model behaves like the right specialist at the right time.
388
486
 
389
487
  Skills are the procedures the agent follows — `discover` (brainstorming),
390
488
  `research`, `decompose`, `plan`, `implement`, `evaluate`, `extract-stories`,
391
- `generate-mockup`, and a set of artifact-management helpers
489
+ `generate-mockup`, `collect-components` (catalog of common UI components,
490
+ shared services and functions, updated after each task), and a set of artifact-management helpers
392
491
  (`create-artifact`, `validate-artifact`, `search-artifact`, `update-tracking`,
393
492
  and more).
394
493
 
@@ -68,5 +68,5 @@ are foundational — wrong splits cascade through the entire project.
68
68
  5. Prefer smaller modules over larger ones — each should be independently plannable
69
69
  6. If a module spans multiple repos, document which parts go where
70
70
  7. **Never finalize boundaries without user approval** — present, discuss, then write
71
- 8. Record module dependencies in progress.json `dependencies`. They set the branch base, the merge order and the release order (see skill.md "Dependent modules")
71
+ 8. Record module dependencies with `haren track depends <module> <dep> [<dep> ...]`. They set the branch base, the merge order and the release order (see skill.md "Dependent modules")
72
72
  9. **One decision at a time** — don't dump the entire decomposition in one message
@@ -54,12 +54,13 @@ At the beginning of each session, present the pending features and ask:
54
54
  5. Delegate to superpowers:subagent-driven-development for execution. Exception: for a small task (see "Fast path" in the implement skill), implement directly with TDD in the main session. If the user asks for the full path, always delegate
55
55
  6. At the start of each session, set up the branch `feat/{module-slug}` in every repo the module touches (see skill.md "Repos and Git" and the implement skill). Ask the user first if a repo has uncommitted changes. Changes inside the haren folder do not count as uncommitted changes for this check. Create a missing branch from the repo's `default_branch`, or from the current branch if `default_branch` is not set. If the module lists no repos, follow the skill.md "Repos and Git" "No repos listed" fallback (the key `default`). If the module depends on a module that is not merged yet, follow skill.md "Dependent modules". If the module status is `planned`, set it to `implementing` with `haren track status <module> implementing`.
56
56
  7. After each feature:
57
+ - Before the code commit, tick each item of the task's section in `checklist.md` (active plan path) only after you verify it in the code or a test run, not from the design. An item the code does not match stays unticked with `— changed: {what and why}`. An item that does not apply stays unticked with `— skipped: {reason}`
57
58
  - (a) Commit the code in each repo that changed, with a descriptive message. In the monorepo layout, make one code commit for all repo keys; see skill.md "Repos and Git"
58
- - (b) Record each commit SHA in `lastCommit.<repoKey>` with `haren track commit <module> <repoKey> <sha>`. Set the feature status with `haren track feature <module> <feature> evaluating`
59
+ - (b) Record each commit SHA in `lastCommit.<repoKey>` with `haren track commit <module> <repoKey> <sha>`. Run the collect-components skill in incremental mode on the new code commits. Set the feature status with `haren track feature <module> <feature> evaluating`
59
60
  - Append to the task's session log (`task-{N}-{slug}.md`) with what was done, decisions made, and the commit SHA per repo. If iterations are enabled (manifest.yaml has `iterations` block), include the **Iteration:** field in the session log header; if not enabled, omit it
60
61
  - Append the "feature-ready" event: `haren track event feature-ready --module <module> --phase implement --feature <feature>`
61
- - (c) Commit the haren files (session log, `progress.json` and `events/events.jsonl`) in the haren repo, listing the code commits in the message. In the monorepo layout the haren folder is in the same repo, so (a) and (c) are two commits on the same branch: the code commit first, then the haren commit. In the workspace layout, commit the haren files on the haren repo's current branch. Do not create a module branch in the haren repo.
62
- 8. Never modify files in the haren folder except session logs. Change `progress.json` and `events/events.jsonl` only with `haren track`. Never edit them with sed or jq. Never push. Never create pull requests unless the user asks.
62
+ - (c) Commit the haren files (session log, `checklist.md`, `component-catalog.md`, `progress.json` and `events/events.jsonl`) in the haren repo, listing the code commits in the message. In the monorepo layout the haren folder is in the same repo, so (a) and (c) are two commits on the same branch: the code commit first, then the haren commit. In the workspace layout, commit the haren files on the haren repo's current branch. Do not create a module branch in the haren repo.
63
+ 8. Never modify files in the haren folder except session logs, the ticks in `checklist.md` and `component-catalog.md` (through the collect-components skill). Change `progress.json` and `events/events.jsonl` only with `haren track`. Never edit them with sed or jq. Never push. Never create pull requests unless the user asks.
63
64
  9. If blocked, run `haren track feature <module> <feature> blocked` and surface to user
64
65
  10. **If you need to deviate from the plan, ask first** — "The plan says X but I think Y would be better because Z. Should I deviate?" Don't deviate silently.
65
66
  11. At session end, ask: "Should I continue with the next feature, or pause here?"
@@ -32,10 +32,12 @@ You are a technical planner within the Haren framework. Your job is to create de
32
32
  ## Outputs
33
33
 
34
34
  - `artifacts/04-plans/{module}/design.md` — master design (full module scope)
35
- - When iterations disabled: `artifacts/04-plans/{module}/tasks.md` — full task breakdown
35
+ - When iterations disabled: `artifacts/04-plans/{module}/tasks.md` — full task breakdown, and `checklist.md` — implementation checklist per task
36
36
  - When iterations enabled:
37
37
  - `artifacts/04-plans/{module}/iteration-{N}/design.md` — scoped subset per iteration
38
38
  - `artifacts/04-plans/{module}/iteration-{N}/tasks.md` — tasks for that iteration only
39
+ - `artifacts/04-plans/{module}/iteration-{N}/checklist.md` — implementation checklist for those tasks
40
+ - Read `artifacts/03-modules/component-catalog.md` before the reuse inventory (collect-components skill)
39
41
  - `artifacts/07-iterations/iteration-{N}.md` — iteration goal, deliverables, demo script
40
42
 
41
43
  ## Decision Protocol
@@ -49,6 +49,8 @@ You are a code reviewer and evaluator within the Haren framework. Your job is to
49
49
 
50
50
  - [ ] Each acceptance criterion tested
51
51
  - [ ] All tests run and pass
52
+ - [ ] Each ticked item in the task's `checklist.md` section is true in the code; unticked items have a `skipped:` or `changed:` reason, and no `changed:` item breaks the spec
53
+ - [ ] No new code duplicates an entry in `component-catalog.md`
52
54
  - [ ] Changed screens match the chosen mockup in the spec (screenshot evidence when the app can run)
53
55
  - [ ] Fixtures, examples, seeds and screenshots use synthetic data, with no real third-party personal data
54
56
 
@@ -130,7 +130,8 @@ Cross-check `_registry/artifact-index.md` against actual files:
130
130
 
131
131
  - Every file in `02-discovery/` through `07-iterations/` should have a registry entry
132
132
  - Every registry entry should point to an existing file
133
- - **Report:** unregistered files as WARN, broken registry entries as FAIL
133
+ - Run `haren track check` for this check. It also fails when progress.json uses a repo key that manifest.yaml does not declare
134
+ - **Report:** unregistered files, broken registry entries and undeclared repo keys as FAIL
134
135
 
135
136
  ### 7. Progress.json ↔ Tasks.md Consistency
136
137
 
@@ -0,0 +1,81 @@
1
+ ---
2
+ name: collect-components
3
+ description: Collect the common UI components, shared services and shared functions of the target repos into one component catalog
4
+ type: utility
5
+ ---
6
+
7
+ # Collect Components
8
+
9
+ Keep one catalog of the common building blocks in the target repos. The plan skill reads it before it designs new code. The implement skill updates it after each task.
10
+
11
+ **Output:** `artifacts/03-modules/component-catalog.md` (template: `templates/component-catalog.md`).
12
+
13
+ ## When to Use
14
+
15
+ - **Incremental:** the implement skill runs it after the code commit of each task. Scan only the files that the task commits changed.
16
+ - **Full scan:** the catalog does not exist yet, the user asks for it, or the plan skill starts the reuse inventory (Step 4) on a repo that has code but no catalog. Scan all target repos in manifest.yaml `repos`.
17
+
18
+ ## What Is Common
19
+
20
+ Add an item when one of these is true:
21
+
22
+ 1. It is in a shared location: a `shared/`, `common/`, `components/ui/`, `lib/`, `utils/`, `core/` folder, or a shared package of the monorepo.
23
+ 2. Two or more modules or features import it.
24
+ 3. The design marks it as a reuse target ("reuse" or "extend" verdict in `## Existing Code`).
25
+
26
+ Do not add page-level screens, one-off helpers that one file uses, tests, generated code, or vendored code.
27
+
28
+ ## Kinds
29
+
30
+ | Kind | Examples | API to record |
31
+ |------|----------|---------------|
32
+ | UI component | Button, DataTable, FormField, Modal, layout shell | Props (name, type, required, default), slots/children, variants, states |
33
+ | Shared service | API client, auth, notification, mail, file storage, audit log, numbering | Public methods with signature, side effects, tables it writes |
34
+ | Shared function | date/number/currency format, validation, mapping, hooks | Signature, return value, one-line purpose |
35
+
36
+ A route guard or a wrapper that renders JSX (for example `RoleGuard`) is a UI component. A client state store (Zustand, Redux slice, Pinia) is a shared service. A hook that only computes values is a shared function.
37
+
38
+ ## Process
39
+
40
+ 1. Read `artifacts/03-modules/component-catalog.md`. If it does not exist, create it from `templates/component-catalog.md` and do a full scan.
41
+ 2. Get the repo keys from manifest.yaml `repos`. If `repos` is empty (common in the monorepo layout), use the key `default` for the repo that holds the haren folder (see skill.md "No repos listed"). Do not make up keys. If an existing entry uses a key that breaks this rule (for example `backend` when `repos` is empty), re-key every entry in one pass, then continue
42
+ 3. Get the files to scan:
43
+ - Incremental: `git -C <repo> show --name-only --format= <sha>` for each code commit SHA of the task
44
+ - Full scan: list the source files of each repo. Skip `node_modules`, build output, tests and generated folders
45
+ 4. For each candidate, apply "What Is Common". To count importers, search all target repos for the import path or the symbol name
46
+ 5. For each common item, write or update its entry (see "Entry format")
47
+ 6. Remove an entry when its file or symbol no longer exists. If it moved, update the path. Search for the symbol name before you remove it
48
+ 7. Update `Used by` from the import search, not from memory
49
+ 8. On every run, re-sort each whole kind section A-Z, not only the new entries. Sort by the `### ` heading name, case-insensitive (Combobox before ConfirmationDialog, ResizableTable before RichTextEditor). Check the order of every section before you save
50
+ 9. Update the front matter `updated:` date and the `last_scan:` line: `full`, or `incremental <repoKey>@<sha>, ...`
51
+ 10. Register the catalog once: `haren track artifact component-catalog --type component-catalog --path artifacts/03-modules/component-catalog.md --status approved`. Run it again only if the row is missing
52
+
53
+ ## Entry Format
54
+
55
+ Each entry is one self-contained block. Keep entries sorted by kind, then by name (A-Z). Then two developers who add different entries do not touch the same lines.
56
+
57
+ ````markdown
58
+ ### Button
59
+ - **Kind:** UI component
60
+ - **Path:** `frontend:src/components/ui/Button.tsx:12`
61
+ - **API:** `variant: "primary" | "secondary" | "danger" = "primary"`, `size: "sm" | "md"`, `loading?: boolean`, `onClick`
62
+ - **Use for:** every action button. Do not style a raw `<button>`
63
+ - **Used by:** checkout, profile
64
+ - **Sketch:**
65
+ ```
66
+ [ Save ] [ Cancel ] [ ⟳ Saving… ]
67
+ primary secondary loading
68
+ ```
69
+ ````
70
+
71
+ - **Path** uses the repo key from manifest.yaml (`default` when `repos` is empty), then the file and the line of the declaration
72
+ - **Use for** is one rule that tells a developer when to pick this item over writing new code
73
+ - **Sketch** is for UI components only. Draw a small ASCII sketch of the variants and states, 8 lines or fewer. Follow the alignment rule of the generate-mockup skill. Omit it for a component with no visual part (a provider, a context)
74
+ - **Screenshot** (optional): only when the user asks and the app can run. Save it under `artifacts/03-modules/components/<name>.png` and link it from the entry. Never take screenshots in the incremental run
75
+
76
+ ## Rules
77
+
78
+ - Do not change code in the target repos. This skill reads code and writes only the catalog
79
+ - One entry per item. If two items do the same job, keep both entries and add `**Duplicate of:** <name>` to the newer one, so the plan can merge them
80
+ - Record what the code does now, not what the plan intends
81
+ - Keep each entry short. The catalog is an index, not documentation
@@ -47,26 +47,19 @@ These decisions affect ALL modules and must be resolved first.
47
47
  - `artifacts/03-modules/module-map.md` (use create-artifact skill)
48
48
  - `artifacts/03-modules/{module}/module.md` for each module (use create-artifact skill) — each module gets its own folder so that `spec.md` (BA-owned) can sit alongside it later
49
49
  9. Validate with validate-artifact skill (checks for cycles, missing interfaces)
50
- 10. Update progress.json — each module gets "decomposed" status. Write every module with this shape:
51
- ```json
52
- "<module>": {
53
- "status": "decomposed",
54
- "currentPhase": "decompose",
55
- "features": {},
56
- "lastCommit": {},
57
- "branch": "feat/<module>",
58
- "repos": ["<repo key from manifest>"],
59
- "lastUpdated": "<ISO 8601 timestamp>"
60
- }
61
- ```
62
- `features` stays `{}` until the plan phase adds tasks. `branch` and `repos` are optional. Without `branch`, haren uses `feat/<module>`.
63
- Write this initial shape once, when the modules are new. After that, change module status only with `haren track status <module> <status>` (see update-tracking skill).
64
- 11. Record dependencies in the top-level `dependencies` map of progress.json: `"<module>": ["<module it depends on>"]`. The implement skill and skill.md "Dependent modules" use this map to choose the base branch and the merge order. The release skill uses it for the release order
65
- 12. Register each artifact: `haren track artifact <id> --type <type> --path <path>`
50
+ 10. Register each module with `haren track status <module> decomposed --branch feat/<module> --repos <key1,key2>`. Use the repo keys from `manifest.yaml`. The CLI rejects a key that is not in the manifest. `--branch` is optional: without it, haren uses `feat/<module>`. To change the branch or repos later, run the same command with the same status. Never edit progress.json by hand. The plan phase adds the features.
51
+ 11. Record the dependencies of each module with `haren track depends <module> <dep> [<dep> ...]`. Run it with no `<dep>` to clear them. The command checks that the modules exist and rejects a cycle. Do not edit progress.json by hand. The implement skill and skill.md "Dependent modules" use this map to choose the base branch and the merge order. The release skill uses it for the release order
52
+ 12. Migration mode only (`mode: migration`): the modules come from the Module column of `artifacts/02-discovery/unit-map.md`.
53
+ 1. Make sure each module in the column is registered as in step 10. Do not run `haren track status <module> decomposed` again without `--repos` or `--branch`: the module is already `decomposed` and the CLI rejects the move. Run it with `--repos` or `--branch` only to change them.
54
+ 2. Run `haren migrate inventory` once, with no `--module` flag. It reads the Module column of each known unit and registers the unit as `inventoried` in that module. The `--module` flag only sets the module of units that are new to the map.
55
+ 3. Check the output for a `warning: skipped` line. Fix the module name or create the module, then run inventory again.
56
+ 4. Run `haren track check`.
57
+ 13. Register each artifact: `haren track artifact <id> --type <type> --path <path>`
66
58
 
67
59
  ## Module Map Format
68
60
 
69
61
  The module-map.md should contain:
62
+
70
63
  - Overview of all modules
71
64
  - Dependency graph (mermaid diagram)
72
65
  - Suggested implementation order (topological sort of dependencies)
@@ -75,6 +68,7 @@ The module-map.md should contain:
75
68
  ## Module Definition Format
76
69
 
77
70
  Each module .md file should follow `templates/module.md`:
71
+
78
72
  - Frontmatter: name, repos, dependencies
79
73
  - Description and responsibilities
80
74
  - Interfaces (exposed)
@@ -28,6 +28,7 @@ Before starting discovery, determine the intent:
28
28
  - **explore** mode: routes through brainstorming for collaborative design (preserved for users who explicitly set `mode: explore` in manifest.yaml — the default path for new ideas is now through `ideate`)
29
29
  - **blueprint** mode: if baseline docs exist in `artifacts/00-baseline/`, the existing blueprint strategy processes them first. Brainstorming triggers only for new features not covered by baseline docs.
30
30
  - **inherit** mode: existing codebase analysis runs first. Brainstorming triggers for new features on top of the existing code.
31
+ - **migration** mode: a rewrite of a legacy system with parity as the bar. The unit inventory runs first. After `decompose`, the `extract` skill makes one approved spec per unit before `plan`.
31
32
  - **undecided** mode: brainstorming helps determine the mode as part of the discovery process
32
33
 
33
34
  ## Process
@@ -37,10 +38,13 @@ Before starting discovery, determine the intent:
37
38
  - `blueprint` → read `skills/discover/blueprint.md`
38
39
  - `explore` → read `skills/discover/explore.md`
39
40
  - `inherit` → read `skills/discover/inherit.md`
41
+ - `migration` → read `skills/discover/migration.md`
40
42
  3. Follow the strategy to produce a context brief
41
43
  4. Write output using create-artifact skill: `artifacts/02-discovery/context-brief.md`
42
44
  5. Validate output with validate-artifact skill
43
- 6. Register the context brief: `haren track artifact <id> --type context-brief --path artifacts/02-discovery/context-brief.md`. Append the phase event: `haren track event discover-complete --phase discover`
45
+ 6. Register the context brief. Get the next artifact ID with the `resolve-next-id` skill. Run `haren track artifact <id> --type context-brief --path artifacts/02-discovery/context-brief.md`. Append the phase event: `haren track event discover-complete --phase discover`
46
+
47
+ For a visual question (screen flow, layout, diagram), use the visual-companion skill. Decide per question.
44
48
 
45
49
  ## Output
46
50
 
@@ -52,4 +56,4 @@ A single `context-brief.md` that contains:
52
56
  - Screens: the main screens that users see, as a list with one line each. Do not draw them here. The plan phase makes 2-3 mockup options per changed screen with the `generate-mockup` skill
53
57
  - Suggested module boundaries (high-level, refined in Decompose)
54
58
 
55
- All three modes produce the same output format — the strategy only changes how the information is gathered.
59
+ All modes produce the same output format — the strategy only changes how the information is gathered.
@@ -19,6 +19,7 @@ You have existing documentation to work from.
19
19
  3. Identify gaps — requirements that are mentioned but not detailed
20
20
  4. Ask the user to clarify gaps (one question at a time)
21
21
  5. Synthesize into context-brief.md format
22
+ 6. discover/SKILL.md step 6 registers the context brief. Do not register it again.
22
23
 
23
24
  ## Tips
24
25
 
@@ -25,6 +25,7 @@ After brainstorming completes, register all output artifacts using the create-ar
25
25
  3. After brainstorming produces the design, register artifacts via create-artifact skill
26
26
  4. Validate output with validate-artifact skill
27
27
  5. Synthesize into context-brief.md format if brainstorming didn't produce one directly
28
+ 6. discover/SKILL.md step 6 registers the context brief. Do not register it again.
28
29
 
29
30
  ## Tips
30
31
 
@@ -26,6 +26,7 @@ Existing codebase plus documentation — understand what exists before planning
26
26
  - What's been built but isn't in the docs?
27
27
  5. Ask the user to clarify goals for the next phase of work
28
28
  6. Synthesize into context-brief.md format
29
+ 7. discover/SKILL.md step 6 registers the context brief. Do not register it again.
29
30
 
30
31
  ## Tips
31
32
 
@@ -0,0 +1,38 @@
1
+ ---
2
+ name: migration
3
+ description: Discovery strategy for a rewrite of a legacy system with parity as the bar
4
+ ---
5
+
6
+ # Migration Mode
7
+
8
+ A rewrite of a legacy system. The bar is parity with the legacy system, plus approved deviations.
9
+
10
+ The legacy repo is read-only. Do not write to it.
11
+
12
+ In this file, `<haren>` is the haren folder. The adapter plugin is the plugin that `migration.adapter` names.
13
+
14
+ ## Process
15
+
16
+ 1. Read `manifest.yaml`. Find the `migration` block and the legacy repo. Resolve repo paths in manifest.yaml from the haren folder, not from the workspace root.
17
+ 2. Make the unit inventory:
18
+ - With an adapter plugin (`migration.adapter` is set): run `haren migrate inventory`. It writes `artifacts/02-discovery/unit-map.md`. No module exists yet, so it registers no unit status. The decompose phase does that.
19
+ - Without an adapter plugin: list the units from the legacy source. Write `unit-map.md` from the `unit-map.md` template. Do not run `haren track unit` yet: the modules do not exist before the decompose phase.
20
+ 3. Group the units into modules:
21
+ - Put units of the same family in the same module.
22
+ - Put units that write the same tables in the same module.
23
+ - A parent unit travels with its popups. Never split a popup from its parent.
24
+ 4. Write the module of each unit into the Module column of `unit-map.md`. Do not run `haren migrate inventory` again here. The decompose phase creates the modules and registers the units.
25
+ 5. Record the shared components (tables and routines that units in more than one module use).
26
+ 6. Make sure that the semantics rulebook exists:
27
+ - If `artifacts/01-research/legacy-semantics.md` is missing, copy the semantics file from the installed adapter plugin: `<haren>/.plugins/<adapter>/<adapter.semantics>`. Read the `adapter.semantics` path in `<haren>/.plugins/<adapter>/haren-plugin.json`. Do not copy from the adapter source folder.
28
+ - If there is no adapter plugin, start from the `legacy-semantics.md` template.
29
+ - Use the ID `LSEM-NNN` (see the `resolve-next-id` skill). Register it: `haren track artifact <id> --type legacy-semantics --path artifacts/01-research/legacy-semantics.md`.
30
+ 7. Write the context brief. Include the legacy stack, the unit counts per family, the shared components, and the suggested modules.
31
+ - discover/SKILL.md step 6 registers the context brief. Do not register it again.
32
+ 8. After step 6 of `discover/SKILL.md` registers the context brief, run `haren track check`. Then go to the `decompose` phase.
33
+
34
+ ## Output
35
+
36
+ - `artifacts/02-discovery/unit-map.md`
37
+ - `artifacts/02-discovery/context-brief.md`
38
+ - `artifacts/01-research/legacy-semantics.md`
@@ -28,6 +28,8 @@ Run through each criterion:
28
28
  - Check edge cases mentioned in the spec
29
29
  2. **Completeness**: Are all spec requirements addressed?
30
30
  - Cross-reference spec checklist against implementation
31
+ - Read the task's section in `checklist.md` (active plan path). Treat each tick as a claim, not as evidence. Check it in the code. A false tick, or an unticked item without a `skipped:` or `changed:` reason, is a finding. Check each `changed:` item against the spec: a change that breaks the spec is a finding
32
+ - Reuse: if the code adds a UI component, service or function that duplicates an entry in `artifacts/03-modules/component-catalog.md`, that is a finding
31
33
  3. **Correctness**: Do tests pass?
32
34
  - Run the test suite
33
35
  - Check test coverage for the feature
@@ -38,8 +40,30 @@ Run through each criterion:
38
40
  - If the app can run, start it and take a screenshot of each changed screen. Save it under `artifacts/06-evaluation/{module}/screens/` and link it in the review
39
41
  - If the app cannot run, say so in the review and compare the code with the mockup
40
42
  - A difference from the chosen mockup is a fail unless the session log records a reason the user approved
43
+ - Read `ui.mockups` in `manifest.yaml`. On `ask`, follow the offer in the generate-mockup skill
44
+ - Artifact mode (`ui.mockups` is `artifact`, or the user chose a Claude Artifact): publish one private Artifact page per changed screen with the chosen mockup and the screenshot side by side (see "Artifact mode" in the generate-mockup skill). Ask the user for the pass or fail verdict in the terminal
45
+ - Browser mode (`ui.mockups` is `browser`, or the user chose the browser): push one `.compare` screen per changed screen with the visual-companion skill (chosen mockup | screenshot). Rebuild the chosen option from the ASCII wireframe in design.md with the HTML mock elements. Read the `pass` or `fail` click from `state_dir/events`. Confirm the verdict with the user in the terminal
46
+ - ASCII mode: compare as above in the terminal
47
+ - No screenshot (the app cannot run): use the ASCII path. Run the `ui-review` skill on the screen derived from the code, or record in the review that the screen check was skipped and why. Do not push `.compare`.
48
+ - Both modes: run the `ui-review` skill on each screenshot. Add the findings table to the review
49
+ - An open blocker (no fix and not 'accepted by user') is a fail.
41
50
  6. **Privacy**: fixtures, examples, seeds, test data and screenshots contain no real third-party personal data (names, emails, phone numbers, addresses, handles, photos). Synthetic data only. Real personal data is a fail
42
51
 
52
+ ### Migration mode only
53
+
54
+ For each unit of the module:
55
+
56
+ 1. Run the Parity checklist of `artifacts/02-discovery/units/<unit>/spec.md`.
57
+ 2. If `migration.liveLegacy` is `true`, compare on both systems. Use the same user, tenant and locale on both.
58
+ 3. Close each difference only by one of these:
59
+ - a fix in the target code
60
+ - a parity evidence file at `artifacts/06-evaluation/parity-evidence/<unit>-<n>.md` (template `parity-evidence.md`)
61
+ - an `approved` row in `artifacts/03-modules/deviation-log.md`
62
+ 4. When all differences are closed, run `haren track unit <module> <unit> verified`. If you did not use the live legacy system, set `static-review-only` instead.
63
+ 5. After the BA signs off, run `haren track unit <module> <unit> parity-signed`.
64
+
65
+ Set the module to `completed` only after all its units are `parity-signed`.
66
+
43
67
  ## Output
44
68
 
45
69
  Each task gets its own evaluation files using a per-task naming convention:
@@ -0,0 +1,43 @@
1
+ ---
2
+ name: extract
3
+ description: Extract each legacy unit into a technical spec and pass the spec gate
4
+ type: sequential
5
+ agent: researcher
6
+ ---
7
+
8
+ # Extract
9
+
10
+ Turn each legacy unit into an approved unit spec. Run this phase after `decompose` and before `plan`.
11
+
12
+ <HARD-GATE>
13
+ Never set `spec-approved` without user approval.
14
+ </HARD-GATE>
15
+
16
+ ## Process
17
+
18
+ Resolve repo paths in manifest.yaml from the haren folder, not from the workspace root.
19
+
20
+ Do these steps for each unit of the module:
21
+
22
+ 1. Get the legacy source of the unit:
23
+ - With an adapter: run `haren migrate extract <unit>`. The files go to `artifacts/02-discovery/units/<unit>/`.
24
+ - Without an adapter: read the legacy source. Run `haren track unit <module> <unit> extracted`.
25
+ 2. Read `artifacts/01-research/legacy-semantics.md` first.
26
+ 3. Write `artifacts/02-discovery/units/<unit>/spec.md`:
27
+ - With an adapter: use the adapter skill named in the plugin's `haren-plugin.json`, key `adapter.skills.spec`.
28
+ - Without an adapter: use the `unit-spec.md` template.
29
+ 4. Run `haren track unit <module> <unit> spec-draft`. Use the ID `UNITSPEC-<unit>` (see the `resolve-next-id` skill). Register the spec now, before approval: `haren track artifact <id> --type unit-spec --path artifacts/02-discovery/units/<unit>/spec.md --module <module>`. Then `haren track check` passes while the unit waits for approval.
30
+ 5. Run `haren migrate gate <unit>`. Fix the spec for each finding. Run the gate again until it shows PASS. Exit code 3 means the gate passed but the user did not approve yet. Go to step 6. Do not treat it as a failure.
31
+ 6. Show the spec and the gate result to the user. Wait for approval.
32
+ 7. Only after the user approves:
33
+ - With an adapter: run `haren migrate gate <unit> --approve`.
34
+ - Without an adapter: tick the Manual gate section of the spec. Then run `haren track unit <module> <unit> spec-approved`.
35
+ 8. Update the artifact row: run the same `haren track artifact <id> ...` command with `--status approved`.
36
+
37
+ ## Rules
38
+
39
+ - A unit in `blocked` status skips the `gate.json` check in `haren track check`. Before approval work, move the unit back to its previous status with `haren track unit <module> <unit> <status>`.
40
+ - Never write into the legacy repo (`readOnly: true`). The gate blocks Edit and Write there. For Bash commands, the guard is best effort only, so do not use the shell to change legacy files. Keep the legacy repo read-only at the filesystem or git level where possible.
41
+ - When you find a new platform trap, add a row to `legacy-semantics.md`.
42
+ - The module spec links the unit specs. It does not restate them.
43
+ - Do not write code in this phase.