@odarino/haren 1.4.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/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
  ```
@@ -182,6 +182,7 @@ every repo.
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
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. |
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>`.
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
@@ -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
@@ -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
 
@@ -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`
@@ -38,8 +38,29 @@ Run through each criterion:
38
38
  - 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
39
  - If the app cannot run, say so in the review and compare the code with the mockup
40
40
  - A difference from the chosen mockup is a fail unless the session log records a reason the user approved
41
+ - Read `ui.mockups` in `manifest.yaml`. On `ask`, follow the offer in the visual-companion skill
42
+ - 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
43
+ - ASCII mode: compare as above in the terminal
44
+ - 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`.
45
+ - Both modes: run the `ui-review` skill on each screenshot. Add the findings table to the review
46
+ - An open blocker (no fix and not 'accepted by user') is a fail.
41
47
  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
48
 
49
+ ### Migration mode only
50
+
51
+ For each unit of the module:
52
+
53
+ 1. Run the Parity checklist of `artifacts/02-discovery/units/<unit>/spec.md`.
54
+ 2. If `migration.liveLegacy` is `true`, compare on both systems. Use the same user, tenant and locale on both.
55
+ 3. Close each difference only by one of these:
56
+ - a fix in the target code
57
+ - a parity evidence file at `artifacts/06-evaluation/parity-evidence/<unit>-<n>.md` (template `parity-evidence.md`)
58
+ - an `approved` row in `artifacts/03-modules/deviation-log.md`
59
+ 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.
60
+ 5. After the BA signs off, run `haren track unit <module> <unit> parity-signed`.
61
+
62
+ Set the module to `completed` only after all its units are `parity-signed`.
63
+
43
64
  ## Output
44
65
 
45
66
  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.
@@ -20,11 +20,19 @@ Generate ASCII wireframes for UI screens described in specs or designs. Output i
20
20
  - Key UI elements (components, fields, actions)
21
21
  - Layout hints (sidebar, modal, table, form, tabs, etc.)
22
22
 
23
- ## Modes
23
+ ## Wireframe modes
24
24
 
25
25
  - **Single** (default): one wireframe for one screen
26
26
  - **Options**: 2-3 labeled variants of one screen, for the user to compare and pick. The plan skill uses this mode
27
27
 
28
+ ### UI mode (ui.mockups)
29
+
30
+ Read `ui.mockups` in `manifest.yaml`. If the key is missing, use `ask`.
31
+
32
+ - `ascii`: use the ASCII steps in this skill only.
33
+ - `browser`: write the ASCII wireframes into design.md as before. Also push one options screen with the visual-companion skill. Use `.options` or `.cards`, with one `.mockup` per option. Build each mockup from the HTML mock elements of the visual-companion skill. Read the click from `state_dir/events`. After the pick, write the chosen option as ASCII into design.md.
34
+ - `ask`: follow the offer in the visual-companion skill. Then use the `ascii` or the `browser` path.
35
+
28
36
  ### Options mode
29
37
 
30
38
  1. Make 2-3 variants of the same screen. Label them `Option A`, `Option B`, `Option C`. Each variant must differ in a real decision (layout, grouping, navigation, density), not only in style
@@ -32,14 +40,13 @@ Generate ASCII wireframes for UI screens described in specs or designs. Output i
32
40
  3. Mark one variant as recommended and say why in one sentence
33
41
  4. Show the variants side by side in one message (see Output Format). If the terminal is narrow, show them one under the other
34
42
  5. Ask the user to pick one. Do not continue to the next screen before the pick
35
- 6. Optional browser view: if the user asks, or if the screens are hard to read as ASCII, write `artifacts/04-plans/{module}/mockups/{screen-slug}.html`. The file shows the options side by side in columns, with the label and the trade-off over each. Use plain HTML and inline CSS only, with no external scripts. Tell the user the file path to open in a browser
36
- 7. Use only synthetic data in mockups (for example "Alex Sample", `user@example.com`). Never copy real third-party personal data
43
+ 6. Use only synthetic data in mockups (for example "Alex Sample", `user@example.com`). Never copy real third-party personal data
37
44
 
38
45
  ## ASCII Wireframe Conventions
39
46
 
40
47
  ```
41
48
  ┌─────────────────────────────────────────────┐ ← outer border
42
- │ Page Title [Button] │ ← header bar
49
+ │ Page Title [Button] │ ← header bar
43
50
  ├─────────────────────────────────────────────┤ ← divider
44
51
  │ ┌──────────┐ ┌───────────────────────────┐ │ ← two-column
45
52
  │ │ Sidebar │ │ Main Content │ │
@@ -165,7 +172,8 @@ After the pick, put the chosen wireframe and the option table in the `## Screens
165
172
  - Keep wireframes simple — communicate layout, not pixel-perfect design
166
173
  - Use placeholder text: `[Field Label]`, `[Button Text]`, `Row data`
167
174
  - Show realistic column counts and proportions
175
+ - Alignment: Every row in a box has the same width as its border. Pad cells with spaces. Check the column widths before you output the wireframe. Count the characters of each row when you are not sure.
168
176
  - Max width: 60 characters for wireframe content (30 characters per option when options are side by side)
169
177
  - If a screen has tabs or states, show the primary state unless asked
170
178
  - **Ask the user** if the layout looks right before moving to the next screen
171
- - Wireframes go into `design.md`. The only separate file is the optional HTML view in options mode
179
+ - Wireframes go into `design.md`. Do not write separate mockup files
@@ -139,6 +139,8 @@ Review research findings for significant problems:
139
139
  }
140
140
  ```
141
141
 
142
+ For a visual question (screen flow, layout, diagram), use the visual-companion skill. Decide per question.
143
+
142
144
  ## Output
143
145
 
144
146
  - Research artifacts: `artifacts/01-research/RESEARCH-{NNN}-{slug}.md` (1-3 per ideation)
@@ -27,6 +27,12 @@ Execute the implementation plan for a module, one feature at a time.
27
27
  - If the module depends on a module that is not merged yet, follow skill.md "Dependent modules" for the base branch
28
28
  - If the module status is `planned`, set it to `implementing` with `haren track status <module> implementing`
29
29
 
30
+ ### Migration mode only
31
+
32
+ - Read `artifacts/03-modules/deviation-log.md` before each task.
33
+ - Never change behavior that has an `approved` deviation row back to the legacy behavior.
34
+ - After all tasks of a unit pass, run `haren track unit <module> <unit> built`.
35
+
30
36
  ## Implementation Loop
31
37
 
32
38
  For each feature:
@@ -17,6 +17,25 @@ Create a complete, actionable plan for implementing a single module.
17
17
  4. Read context brief: `artifacts/02-discovery/context-brief.md`
18
18
  5. Read any relevant research: `artifacts/01-research/`
19
19
  6. Check dependencies: are dependent modules' interfaces defined?
20
+ 7. **Migration mode only** (`mode: migration` in manifest.yaml):
21
+ - Read the unit specs of the module: `artifacts/02-discovery/units/<unit>/spec.md`
22
+ - Read `artifacts/03-modules/deviation-log.md`
23
+ - The reuse inventory (Step 4) includes every table and side effect in the Writes section of each legacy unit
24
+ - Each task references its unit IDs (for example SCR_A001) as well as its STORY-IDs
25
+
26
+ ### Step 4: Reuse inventory (before decisions and tasks)
27
+
28
+ <HARD-GATE>
29
+ Do not write design.md or tasks.md before the reuse inventory is done.
30
+ A plan that builds behavior which already exists in a target repo is a defect.
31
+ </HARD-GATE>
32
+
33
+ 1. List every table the module writes and every side effect it triggers (notification, SMS, mail, file, external API, audit log, numbering)
34
+ 2. For each item, search ALL target repos in manifest.yaml `repos`. Do not stop at the module's own package or at class names that match the screen name. Search by table name, by side effect (for example `send`, `notify`, `mail`), and by the shared service folders
35
+ 3. Record each hit with `file:line` and one verdict: reuse, extend, supersede or duplicate. Record "none found" with the search command that you ran
36
+ 4. Read the hits that are a shared service. Check its doc comment for a caller/shared split
37
+ 5. Put the result in the `## Existing Code` section of design.md. Tasks must use the verdicts: no task builds a "reuse" item again
38
+ 6. If the inventory is large, also write it as a research artifact `artifacts/01-research/{module}-reuse-audit.md` and link it from the design
20
39
 
21
40
  ### Step 5: Gather decisions BEFORE writing artifacts
22
41
 
@@ -46,11 +65,16 @@ mockup option per changed screen before you write the spec or the design.
46
65
  5. Document each decision in the design artifact with rationale
47
66
 
48
67
  **UI decisions (only if the module adds or changes screens):**
49
- 1. List the changed screens from the spec, the module definition and the stories
50
- 2. For each screen, use the `generate-mockup` skill in options mode. Make 2-3 labeled options (A, B, C). Give each option a one-line trade-off and mark your recommendation
51
- 3. Show the options side by side in one message. If the user wants a browser view, also write the HTML file that the skill describes
52
- 4. Ask the user to pick one option. One screen at a time
53
- 5. Record the chosen option and the rejected options with the reason in the `## Screens` section of the design. Add the same to the `## Screens` section of the spec, and add a Changelog row for that spec edit
68
+ 1. Read `ui.mockups` in `manifest.yaml` (`ask` | `ascii` | `browser`, default `ask`). On `ask`, follow the offer in the visual-companion skill
69
+ 2. List the changed screens from the spec, the module definition and the stories
70
+ 3. For each screen, use the `generate-mockup` skill in options mode. Make 2-3 labeled options (A, B, C). Give each option a one-line trade-off and mark your recommendation
71
+ 4. Show the options:
72
+ - ASCII path: show the options side by side in one message
73
+ - Browser path: push the options screen with the visual-companion skill. Read the click from `state_dir/events`. Confirm the choice with the user in the terminal
74
+ 5. ASCII path: ask the user to pick one option. Both paths: one screen at a time
75
+ 6. Record the chosen option and the rejected options with the reason in the `## Screens` section of the design. Add the same to the `## Screens` section of the spec, and add a Changelog row for that spec edit
76
+ 7. After the choice, run the `ui-review` skill on the chosen option. Write the findings table under `## UI Review` in the design. In the browser path, also push the `.findings` screen
77
+ 8. **Caution:** a blocker stops the module. Fix each blocker in the mockup and run the `ui-review` skill again, or write "accepted by user" in the Fix column, before the module goes to `planned`
54
78
 
55
79
  **Example flow:**
56
80
  ```
@@ -91,9 +115,11 @@ Write to: `artifacts/04-plans/{module}/design.md` (master — always written her
91
115
 
92
116
  Using `templates/design.md`:
93
117
  - Architecture overview
118
+ - **Existing code** (from the reuse inventory in Step 4)
94
119
  - Data model
95
120
  - **Key technical decisions with rationale** (from step 5 — include what was chosen and why)
96
121
  - **Screens** (if the module adds or changes screens): the chosen mockup per screen and the rejected options with the reason
122
+ - **UI Review** (if screens): the findings table from the `ui-review` skill
97
123
  - File structure plan
98
124
  - External dependencies
99
125
 
@@ -107,6 +133,14 @@ Using `templates/tasks.md`:
107
133
  - Tasks should be small enough for one implementation session
108
134
  - Include test tasks alongside implementation tasks
109
135
 
136
+ #### Register the drafts
137
+
138
+ Register each artifact right after you write it, before the user approves it. Then `haren track check` passes while you wait for the approval:
139
+
140
+ - `haren track artifact <id> --type design --path artifacts/04-plans/{module}/design.md --module <module> --status draft`
141
+ - `haren track artifact <id> --type tasks --path <path of tasks.md> --module <module> --status draft`
142
+ - If you wrote spec.md: `haren track artifact <id> --type spec --path artifacts/03-modules/{module}/spec.md --module <module> --status draft`
143
+
110
144
  ### Step 7: Review with user
111
145
 
112
146
  **Small module:** the module has 3 tasks or fewer, each task changes about 30 lines or fewer, it adds no new external dependency and it has no schema migration. For a small module, show the design and the tasks in one message and ask for one approval. Write "Size: small" in the design. The implement skill then uses its fast path.
@@ -118,8 +152,8 @@ The user can always ask for the full path. Then review section by section.
118
152
 
119
153
  ### Step 8: Finalize
120
154
 
121
- 1. Validate all three artifacts with validate-artifact skill
122
- 2. Register each new artifact: `haren track artifact <id> --type <type> --path <path> --module <module>`
155
+ 1. Validate all three artifacts with validate-artifact skill. This runs `haren track check`
156
+ 2. After the user approves an artifact, run the same `haren track artifact <id> ...` command with `--status approved`. Register an artifact that has no row yet in the same way
123
157
  3. Set the module status: `haren track status <module> planned`. Never edit progress.json by hand
124
158
  4. If `plugins.json` exists in the haren folder, run `haren plugin run after-plan --payload '{"module":"<module>","tasksFile":"<path of tasks.md relative to the haren folder>"}'` and show its output lines. A warning does not block the plan. The CLI adds the missing features to progress.json, so do not add them yourself
125
159
 
@@ -151,12 +185,13 @@ After creating the master spec and design, and after all tasks are defined:
151
185
  - Planned deliverables: the tasks for this iteration
152
186
  - Demo script: outline of what can be demonstrated
153
187
 
154
- 5. **Update progress.json**: Ensure `currentIteration` is set to 1 (should already be set by init)
188
+ 5. **Check progress.json**: Check that `currentIteration` in progress.json is 1. If it is not, tell the user. Do not edit the file by hand.
155
189
 
156
190
  ## Rules
157
191
 
158
192
  - **Never silently pick a technology** — present options, let the user choose
159
193
  - **Never silently pick a screen layout** — show 2-3 mockup options, let the user choose
194
+ - Never skip the UI review for a changed screen.
160
195
  - **One question at a time** — don't overwhelm with multiple decisions
161
196
  - The spec is the contract the evaluator checks against — be precise and testable
162
197
  - Tasks should reference exact file paths in the target repo
@@ -164,3 +199,4 @@ After creating the master spec and design, and after all tasks are defined:
164
199
  - Include edge cases and error scenarios in the spec
165
200
  - The design must document every decision with "chosen: X, alternatives: Y/Z, rationale: ..."
166
201
  - If unsure about anything, ask — don't guess
202
+ - **Never plan new code before the reuse inventory** — search all target repos for existing writers and callers first