@odarino/haren 1.6.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.
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/README.md CHANGED
@@ -180,7 +180,7 @@ 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
185
  | `haren migrate` | Migration mode only: `inventory [--module m]`, `extract <unit>`, `gate <unit> [--approve]`. It runs the adapter commands. See [Migration mode](#migration-mode). |
186
186
  | `haren agent` | Manage the local agent bridge _(experimental — for the in-progress Haren Portal)_. |
@@ -397,7 +397,7 @@ Skills also write these types with `haren track event`: `ideate-complete`,
397
397
  ### Visual companion
398
398
 
399
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>`.
400
+ when the UI mode allows it. Choose the UI mode with `haren track ui-mode <ask|ascii|browser|artifact>`.
401
401
  The mode is stored in `manifest.yaml` as `ui.mockups`. The default is `ask`.
402
402
 
403
403
  | Mode | What happens |
@@ -486,7 +486,8 @@ model behaves like the right specialist at the right time.
486
486
 
487
487
  Skills are the procedures the agent follows — `discover` (brainstorming),
488
488
  `research`, `decompose`, `plan`, `implement`, `evaluate`, `extract-stories`,
489
- `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
490
491
  (`create-artifact`, `validate-artifact`, `search-artifact`, `update-tracking`,
491
492
  and more).
492
493
 
@@ -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
 
@@ -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
@@ -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,7 +40,8 @@ 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
41
- - Read `ui.mockups` in `manifest.yaml`. On `ask`, follow the offer in the visual-companion skill
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
42
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
43
46
  - ASCII mode: compare as above in the terminal
44
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`.
@@ -31,7 +31,35 @@ Read `ui.mockups` in `manifest.yaml`. If the key is missing, use `ask`.
31
31
 
32
32
  - `ascii`: use the ASCII steps in this skill only.
33
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.
34
+ - `artifact`: write the ASCII wireframes into design.md as before. Also publish the options as a Claude Artifact page. See "Artifact mode".
35
+ - `ask`: ask the user before the first mockup of the session. See "Ask the user".
36
+
37
+ ### Ask the user
38
+
39
+ <HARD-GATE>
40
+ On `ask`, do not draw the first mockup of the session before the user picks a format. Never fall back to ASCII without asking.
41
+ </HARD-GATE>
42
+
43
+ Send the offer as its own message, with nothing else. List only the formats that work here: list Claude Artifact only if you have the `Artifact` tool, and the browser tab only if `haren companion` can run.
44
+
45
+ > How do you want to see the mockups? (1) ASCII in the terminal and in design.md, (2) Claude Artifact: a private web page on claude.ai, (3) local browser tab with clickable options. Add "always" to save the choice.
46
+
47
+ - With "always": run `haren track ui-mode <ascii|artifact|browser>`. Without it: use the choice for this session only.
48
+ - If only ASCII works here, say so in one line and use ASCII. Do not ask.
49
+
50
+ ### Artifact mode
51
+
52
+ Needs the `Artifact` tool (Claude Code with claude.ai). If the tool is missing, tell the user and use ASCII.
53
+
54
+ Use a plain HTML page, not an Artifact type such as Design or Slides, and skip the quickstart for a type. The page file must stay in `artifacts/04-plans/{module}/mockups/`. Give the page a `<title>` of 2-4 words (for example `Checkout Layout Options`) and the icon `layout`.
55
+
56
+ 1. Draw the ASCII options first (Options mode below). They stay the source of truth in design.md.
57
+ 2. Build one HTML page: one card per option, side by side on wide screens and stacked on phones. Label each card `Option A`/`B`/`C` and show its trade-off line. Mark the recommended option. Use synthetic data only.
58
+ 3. Render each option as a real UI mock (HTML/CSS), not as ASCII in a `<pre>`. Follow the artifact-design skill for the page rules.
59
+ 4. Write the page to `artifacts/04-plans/{module}/mockups/{screen}.html` and publish it with the `Artifact` tool. Publish again from the same path for a new round, so the URL stays the same. Do not register the page with `haren track artifact`: the `.html` files in `mockups/` are working files, and `haren track check` only checks `.md` files. design.md is the registered record
60
+ 5. Give the user the link. Tell the user that the page is private until they share it. Ask for the pick in the terminal.
61
+ 6. After the pick, write the chosen option as ASCII into design.md `## Screens`. Put the link under `**Chosen:**` in this format: `**Mockup page:** <url> (Claude Artifact, private)`.
62
+ 7. If the pick is not the recommended option, check that it does not change a reuse verdict or a task. If it does, update `## Existing Code`, tasks.md and checklist.md, and tell the user what changed.
35
63
 
36
64
  ### Options mode
37
65
 
@@ -15,12 +15,13 @@ Execute the implementation plan for a module, one feature at a time.
15
15
  ## Pre-Implementation (every session)
16
16
 
17
17
  1. Run read-context skill to orient
18
- 2. Read tasks from the **active plan path** (see skill.md Plan Paths convention)
19
- 3. Read `progress.json` to find current feature status
20
- 4. Read `artifacts/05-implementation/{module}/task-{N}-{slug}.md` if it exists for the target feature (previous session context)
21
- 5. If iterations enabled, also read the **master plan path** for broader module context if needed
22
- 6. Pick the highest-priority feature in "pending" status
23
- 7. Set up the module branch. Follow skill.md "Repos and Git":
18
+ 2. Read tasks and `checklist.md` from the **active plan path** (see skill.md Plan Paths convention). If checklist.md is missing, tell the user and ask to run the plan skill or continue without it
19
+ 3. Read `artifacts/03-modules/component-catalog.md` if it exists. Use its entries before you write new UI components, services or functions
20
+ 4. Read `progress.json` to find current feature status
21
+ 5. Read `artifacts/05-implementation/{module}/task-{N}-{slug}.md` if it exists for the target feature (previous session context)
22
+ 6. If iterations enabled, also read the **master plan path** for broader module context if needed
23
+ 7. Pick the highest-priority feature in "pending" status
24
+ 8. Set up the module branch. Follow skill.md "Repos and Git":
24
25
  - Read the module's repos from the `repos:` front matter of `artifacts/03-modules/{module}/module.md`. If it lists no repos, follow "No repos listed" in skill.md "Repos and Git"
25
26
  - For each repo: if it has uncommitted changes, stop and ask the user what to do. Changes inside the haren folder do not count as uncommitted changes for this check
26
27
  - For each repo: if the branch `feat/{module-slug}` does not exist, create it from the repo's `default_branch`, or from the current branch if `default_branch` is not set. Then switch to it
@@ -40,14 +41,16 @@ For each feature:
40
41
  1. Update feature status: `haren track feature <module> <feature> in-progress`
41
42
  2. Choose the path by task size (see "Fast path" below):
42
43
  - **Small task:** implement it directly in the main session with superpowers:test-driven-development
43
- - **Other tasks:** delegate to superpowers:subagent-driven-development. Pass the full task description from tasks.md and the design context from design.md. Ensure TDD discipline via superpowers:test-driven-development
44
- 3. After implementation:
44
+ - **Other tasks:** delegate to superpowers:subagent-driven-development. Pass the full task description from tasks.md, the checklist section of the task and the design context from design.md. Ensure TDD discipline via superpowers:test-driven-development
45
+ 3. Before the code commit, go through the task's section in `checklist.md`. Tick an item (`- [x]`) only when you verified it in the code or in a test run. Do not tick from the design alone. If the code differs from the item, keep it unticked and add `— changed: {what and why}`. If an item does not apply or you cannot do it, keep it unticked and add `— skipped: {reason}`. Do not commit while an item is unticked without a reason. The main session ticks the items, also when a subagent wrote the code
46
+ 4. After implementation:
45
47
  - (a) Commit the code in each repo that the feature changed: `git -C <repo> commit` with a descriptive message. In the monorepo layout, make one code commit for all repo keys; see skill.md "Repos and Git"
46
- - (b) Record each new commit SHA in `lastCommit.<repoKey>`: `haren track commit <module> <repoKey> <sha>`
48
+ - (b) Record each new commit SHA in `lastCommit.<repoKey>`. The repo key is a key of manifest.yaml `repos`, or `default` when `repos` is empty. Never guess a key such as `backend`: `haren track commit <module> <repoKey> <sha>`
49
+ - Run the collect-components skill in incremental mode on the new code commits. It updates `artifacts/03-modules/component-catalog.md`
47
50
  - Update feature status: `haren track feature <module> <feature> evaluating`
48
51
  - Append to task session log (`task-{N}-{slug}.md`): what was done, decisions made, any deviations from plan, and the commit SHA for each repo
49
52
  - Append the "feature-ready" event: `haren track event feature-ready --module <module> --phase implement --feature <feature>`
50
- - (c) Commit the haren files (session log, `progress.json` and `events/events.jsonl`) in the haren repo. List the code commits in the message, for example `docs(checkout): task 2 session log — backend@abc1234, frontend@def5678`. 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.
53
+ - (c) Commit the haren files (session log, `checklist.md`, `component-catalog.md`, `progress.json` and `events/events.jsonl`) in the haren repo. List the code commits in the message, for example `docs(checkout): task 2 session log — backend@abc1234, frontend@def5678`. 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.
51
54
  - Never push
52
55
 
53
56
  ## Fast path
@@ -83,5 +86,5 @@ If iterations are enabled (check manifest.yaml for `iterations` block), include
83
86
  - Always write tests before implementation (TDD)
84
87
  - If blocked, run `haren track feature <module> <feature> blocked` and surface to user — don't guess
85
88
  - If you need to deviate from the plan, document why in the session log
86
- - Never modify files in the haren folder except session logs. Change `progress.json` and `events/events.jsonl` only with `haren track` (see update-tracking skill). Never edit them with sed or jq
89
+ - 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` (see update-tracking skill). Never edit them with sed or jq
87
90
  - Never push. Never create pull requests unless the user asks
@@ -30,11 +30,12 @@ Do not write design.md or tasks.md before the reuse inventory is done.
30
30
  A plan that builds behavior which already exists in a target repo is a defect.
31
31
  </HARD-GATE>
32
32
 
33
+ 0. Read `artifacts/03-modules/component-catalog.md`. If it does not exist and a target repo has code, run the collect-components skill (full scan) first. Use the catalog entries as the first candidates for reuse
33
34
  1. List every table the module writes and every side effect it triggers (notification, SMS, mail, file, external API, audit log, numbering)
34
35
  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
36
  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
37
  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
+ 5. List the UI components, shared services and shared functions from the catalog that the module will use. Put the result in the `## Existing Code` section of design.md. Tasks must use the verdicts: no task builds a "reuse" item again
38
39
  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
39
40
 
40
41
  ### Step 5: Gather decisions BEFORE writing artifacts
@@ -65,7 +66,7 @@ mockup option per changed screen before you write the spec or the design.
65
66
  5. Document each decision in the design artifact with rationale
66
67
 
67
68
  **UI decisions (only if the module adds or changes screens):**
68
- 1. Read `ui.mockups` in `manifest.yaml` (`ask` | `ascii` | `browser`, default `ask`). On `ask`, follow the offer in the visual-companion skill
69
+ 1. Read `ui.mockups` in `manifest.yaml` (`ask` | `ascii` | `browser` | `artifact`, default `ask`). On `ask`, follow the offer in the generate-mockup skill
69
70
  2. List the changed screens from the spec, the module definition and the stories
70
71
  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
72
  4. Show the options:
@@ -133,17 +134,27 @@ Using `templates/tasks.md`:
133
134
  - Tasks should be small enough for one implementation session
134
135
  - Include test tasks alongside implementation tasks
135
136
 
137
+ #### Checklist (implementation checklist)
138
+ Write to: the active plan path, next to tasks.md, as `checklist.md`. When iterations are enabled, write it in Step 9 for each iteration, not at the root level.
139
+
140
+ Using `templates/checklist.md`:
141
+ - One `## Task N` section per task in tasks.md, with the same number and title
142
+ - Each item is a concrete check, not a generic one. Name the test file and cases, the catalog entries to reuse, the files, the contract and the edge cases of that task
143
+ - The Reuse item takes its entries from `## Existing Code` and the component catalog
144
+ - Add project-specific items from the design (for example i18n, audit log, migration rollback)
145
+
136
146
  #### Register the drafts
137
147
 
138
148
  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
149
 
140
150
  - `haren track artifact <id> --type design --path artifacts/04-plans/{module}/design.md --module <module> --status draft`
141
151
  - `haren track artifact <id> --type tasks --path <path of tasks.md> --module <module> --status draft`
152
+ - `haren track artifact <id> --type checklist --path <path of checklist.md> --module <module> --status draft`
142
153
  - If you wrote spec.md: `haren track artifact <id> --type spec --path artifacts/03-modules/{module}/spec.md --module <module> --status draft`
143
154
 
144
155
  ### Step 7: Review with user
145
156
 
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.
157
+ **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, the tasks and the checklist in one message and ask for one approval. Write "Size: small" in the design. The implement skill then uses its fast path.
147
158
 
148
159
  **Other modules:** present each artifact section by section. Ask "does this look right?" after each.
149
160
  Only proceed to the next artifact after the current one is approved.
@@ -152,7 +163,7 @@ The user can always ask for the full path. Then review section by section.
152
163
 
153
164
  ### Step 8: Finalize
154
165
 
155
- 1. Validate all three artifacts with validate-artifact skill. This runs `haren track check`
166
+ 1. Validate all plan artifacts (spec, design, tasks, checklist) with validate-artifact skill. This runs `haren track check`
156
167
  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
157
168
  3. Set the module status: `haren track status <module> planned`. Never edit progress.json by hand
158
169
  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
@@ -177,6 +188,7 @@ After creating the master spec and design, and after all tasks are defined:
177
188
  - Create `artifacts/04-plans/{module}/iteration-{N}/design.md` — filtered subset of master design containing only decisions relevant to this iteration's tasks
178
189
  - Create `artifacts/04-plans/{module}/iteration-{N}/tasks.md` — only the tasks assigned to this iteration, each referencing STORY-IDs
179
190
  - Each scoped design must include: `Master: artifacts/04-plans/{module}/design.md` as a cross-reference
191
+ - Create `artifacts/04-plans/{module}/iteration-{N}/checklist.md` — the checklist sections of the tasks in this iteration
180
192
  - Each scoped tasks file must include: `Spec: artifacts/03-modules/{module}/spec.md` as a cross-reference
181
193
  - Note: iteration-scoped specs are NOT created — the spec in `03-modules/` is the single source of truth (BA-owned)
182
194
 
@@ -12,7 +12,7 @@ Orient yourself at the start of every session or before taking any action.
12
12
 
13
13
  1. **Read manifest.yaml**
14
14
  - Project name, mode, repos, sources
15
- - The ui mode: `ui.mockups` (`ask` | `ascii` | `browser`). If the key is missing, report `ask`
15
+ - The ui mode: `ui.mockups` (`ask` | `ascii` | `browser` | `artifact`). If the key is missing, report `ask`
16
16
  - Resolve each repo folder as in skill.md "Repos and Git". Warn if a folder is missing, and suggest `haren init` (it clones missing repos)
17
17
 
18
18
  2. **Read progress.json**
@@ -22,6 +22,7 @@ Run every command from the haren folder.
22
22
  | Add a feature (status `pending`) | `haren track feature <module> <feature>` |
23
23
  | Set feature status | `haren track feature <module> <feature> <status>` |
24
24
  | Record a commit | `haren track commit <module> <repoKey> <sha>` |
25
+ | Remove a stale repo key | `haren track commit <module> <repoKey> --remove` |
25
26
  | Register an artifact | `haren track artifact <id> --type <type> --path <path> [--module <m>] [--status <s>]` |
26
27
  | Append another event | `haren track event <type> [--module m] [--phase p] [--feature f] [--data '<json>']` |
27
28
  | Open the code gate for a user request | `haren track override on --reason "<text>" [--hours <n>]` |
@@ -53,6 +53,19 @@ Required:
53
53
  - [ ] Each task has: title, description, files
54
54
  - [ ] Tasks are ordered
55
55
 
56
+ ### Checklist (04-plans)
57
+ Required:
58
+ - [ ] One `## Task N` section for each task in tasks.md of the same plan path, with the same number
59
+ - [ ] Each section has a Tests item and a Reuse item. Generic items only ("write tests") → FAIL
60
+ - [ ] After implement: each unticked item has `— skipped: {reason}` or `— changed: {what and why}`
61
+ - [ ] The Reuse items name entries that exist in `## Existing Code` or in `artifacts/03-modules/component-catalog.md`, or say "none"
62
+
63
+ ### Component Catalog (03-modules)
64
+ Required:
65
+ - [ ] Front matter `updated:` and `last_scan:`
66
+ - [ ] Each entry has Kind, Path (`repoKey:file:line`), API, Use for, Used by
67
+ - [ ] Each Path exists in the repo
68
+
56
69
  ### Iteration-Scoped Design (04-plans, iterations only)
57
70
  Iteration-scoped designs are filtered subsets of the master design. Relaxed checks:
58
71
  - [ ] Architecture overview (can reference master for full detail)
@@ -35,14 +35,11 @@ A question about a UI topic is not automatically a visual question. "What kind o
35
35
  Read `ui.mockups` in `manifest.yaml`.
36
36
 
37
37
  - `ascii`: never use the browser. Use ASCII wireframes (see generate-mockup/).
38
+ - `artifact`: do not start the companion. Use a Claude Artifact page (see "Artifact mode" in generate-mockup/).
38
39
  - `browser`: use the browser for visual questions. Do not ask first.
39
40
  - `ask`: at the first visual question in a session, send the offer as its own message, with nothing else:
40
41
 
41
- > This next part is easier to show than to describe. I can open a browser tab with mockups and options. Choose: (1) this time, (2) always, (3) no, use ASCII.
42
-
43
- - On (1): use the browser for this session.
44
- - On (2): run `haren track ui-mode browser`, then use the browser.
45
- - On (3): ask "Always use ASCII?". If yes, run `haren track ui-mode ascii`. Use ASCII.
42
+ use the offer in the generate-mockup skill ("Ask the user"). It lists ASCII, Claude Artifact and the browser tab.
46
43
 
47
44
  ## How It Works
48
45
 
@@ -0,0 +1,26 @@
1
+ ---
2
+ module: {module name}
3
+ date: {date}
4
+ tasks: {path of tasks.md}
5
+ owner: Dev
6
+ ---
7
+
8
+ # Implementation Checklist: {module name}
9
+
10
+ The developer ticks each item before the code commit of the task. The reviewer checks each ticked item against the code. An item that is not ticked and has no reason is a finding.
11
+
12
+ Tick an item only after you verify it in the code or a test run. If the code differs from the item, keep it unticked and add `— changed: {what and why}`. To skip an item, keep it unticked and add `— skipped: {reason}`.
13
+
14
+ ## Task 1: {title}
15
+
16
+ - [ ] Tests: {test file and the cases to cover, from the acceptance criteria of STORY-NNN}
17
+ - [ ] Reuse: {catalog entries or `## Existing Code` items to use, for example `Button`, `NotificationService.send`}. No new copy of them
18
+ - [ ] Files: {files to create or modify, from tasks.md}
19
+ - [ ] Contract: {interface, API shape or schema that must match the spec}
20
+ - [ ] Edge cases: {error, empty and permission cases from the spec}
21
+ - [ ] UI states (screens only): {loading, empty, error, matches the chosen mockup}
22
+ - [ ] Quality: lint, type check and the full test suite pass
23
+ - [ ] {project-specific item, for example i18n keys, audit log, migration rollback}
24
+
25
+ ## Task 2: {title}
26
+ ...
@@ -0,0 +1,41 @@
1
+ ---
2
+ title: Component Catalog
3
+ updated: {date}
4
+ last_scan: {full | incremental <repoKey>@<sha>, ...}
5
+ owner: Dev
6
+ ---
7
+
8
+ # Component Catalog
9
+
10
+ Common UI components, shared services and shared functions of the target repos. The collect-components skill updates this file. The plan skill reads it before the reuse inventory.
11
+
12
+ ## UI Components
13
+
14
+ ### {Name}
15
+ - **Kind:** UI component
16
+ - **Path:** `{repoKey}:{file}:{line}`
17
+ - **API:** {props, variants, states}
18
+ - **Use for:** {when to pick this}
19
+ - **Used by:** {modules}
20
+ - **Sketch:**
21
+ ```
22
+ {ASCII sketch, 8 lines or fewer}
23
+ ```
24
+
25
+ ## Shared Services
26
+
27
+ ### {Name}
28
+ - **Kind:** Shared service
29
+ - **Path:** `{repoKey}:{file}:{line}`
30
+ - **API:** {public methods, side effects, tables it writes}
31
+ - **Use for:** {when to pick this}
32
+ - **Used by:** {modules}
33
+
34
+ ## Shared Functions
35
+
36
+ ### {Name}
37
+ - **Kind:** Shared function
38
+ - **Path:** `{repoKey}:{file}:{line}`
39
+ - **API:** {signature → return}
40
+ - **Use for:** {when to pick this}
41
+ - **Used by:** {modules}
@@ -29,6 +29,7 @@ date: {date}
29
29
 
30
30
  ### Screen: {screen name}
31
31
  **Chosen:** option {A|B|C}
32
+ **Mockup page:** {url} (Claude Artifact, private) <!-- only in artifact mode -->
32
33
 
33
34
  ```
34
35
  {ASCII wireframe of the chosen option}
package/dist/index.js CHANGED
@@ -534,6 +534,9 @@ async function main() {
534
534
 
535
535
  if (process.env.HAREN_GATE === "off") allow();
536
536
 
537
+ // A file outside the workspace (another project, temp files) is not ours to gate.
538
+ if (target && !inside(target, workspaceDir)) allow();
539
+
537
540
  const progressFile = Bun.file(resolve(harenDir, "progress.json"));
538
541
  if (!(await progressFile.exists())) allow();
539
542
 
@@ -553,8 +556,8 @@ async function main() {
553
556
  deny(message);
554
557
  }
555
558
 
556
- // No file path, or a file outside the workspace (temp files): legacy rule.
557
- if (!target || !inside(target, workspaceDir)) allow();
559
+ // No file path: legacy rule.
560
+ if (!target) allow();
558
561
 
559
562
  const repos = await readRepos();
560
563
  const roots: string[] = [];
@@ -749,7 +752,7 @@ language: ${yamlScalar(o.language)}
749
752
 
750
753
  ${renderReposBlock(o.repos)}${o.mode === "migration" ? MIGRATION_SCAFFOLD(Object.keys(o.repos).length === 0) : ""}
751
754
  ui:
752
- mockups: ask # ask | ascii | browser
755
+ mockups: ask # ask | ascii | browser | artifact
753
756
 
754
757
  sources:
755
758
  # Mode-specific inputs
@@ -837,7 +840,7 @@ var init_manifest = __esm(() => {
837
840
  ];
838
841
  YAML_KEYWORDS = /^(true|false|null|yes|no|on|off|~)$/i;
839
842
  YAML_SPECIAL_FLOAT = /^[-+]?\.(inf|nan)$/i;
840
- UI_MODES = ["ask", "ascii", "browser"];
843
+ UI_MODES = ["ask", "ascii", "browser", "artifact"];
841
844
  });
842
845
 
843
846
  // src/plugins/paths.ts
@@ -1725,9 +1728,11 @@ function updateModuleStatus(progress, moduleName, newStatus) {
1725
1728
  if (!mod) {
1726
1729
  throw new Error(`Module '${moduleName}' not found in progress`);
1727
1730
  }
1728
- const allowed = VALID_MODULE_TRANSITIONS[mod.status];
1731
+ const known = Object.hasOwn(VALID_MODULE_TRANSITIONS, mod.status);
1732
+ const allowed = known ? VALID_MODULE_TRANSITIONS[mod.status] : LEGACY_MODULE_EXITS;
1729
1733
  if (!allowed.includes(newStatus)) {
1730
- throw new Error(`Invalid module transition: ${mod.status} \u2192 ${newStatus}. Allowed: ${allowed.join(", ")}`);
1734
+ const from = known ? mod.status : `${mod.status} (unknown status from an old progress file)`;
1735
+ throw new Error(`Invalid module transition: ${from} \u2192 ${newStatus}. Allowed: ${allowed.join(", ")}`);
1731
1736
  }
1732
1737
  return {
1733
1738
  ...progress,
@@ -1751,7 +1756,7 @@ function updateFeatureStatus(progress, moduleName, featureName, newStatus) {
1751
1756
  if (currentStatus === undefined) {
1752
1757
  throw new Error(`Feature '${featureName}' not found in module '${moduleName}'`);
1753
1758
  }
1754
- const allowed = VALID_FEATURE_TRANSITIONS[currentStatus];
1759
+ const allowed = Object.hasOwn(VALID_FEATURE_TRANSITIONS, currentStatus) ? VALID_FEATURE_TRANSITIONS[currentStatus] : LEGACY_FEATURE_EXITS;
1755
1760
  if (!allowed.includes(newStatus)) {
1756
1761
  throw new Error(`Invalid feature transition: ${currentStatus} \u2192 ${newStatus}. Allowed: ${allowed.join(", ")}`);
1757
1762
  }
@@ -1836,7 +1841,7 @@ function migrateProgress(raw, repoKeyFor) {
1836
1841
  }
1837
1842
  return { progress: { ...data, version: PROGRESS_VERSION, modules }, changed: true };
1838
1843
  }
1839
- var UNIT_LINE, UNIT_STATUSES, MODULE_STATUSES, FEATURE_STATUSES, VALID_MODULE_TRANSITIONS, STATUS_TO_PHASE, VALID_FEATURE_TRANSITIONS, VALID_UNIT_TRANSITIONS, PROGRESS_VERSION = 3;
1844
+ var UNIT_LINE, UNIT_STATUSES, MODULE_STATUSES, FEATURE_STATUSES, VALID_MODULE_TRANSITIONS, LEGACY_MODULE_EXITS, STATUS_TO_PHASE, LEGACY_FEATURE_EXITS, VALID_FEATURE_TRANSITIONS, VALID_UNIT_TRANSITIONS, PROGRESS_VERSION = 3;
1840
1845
  var init_progress = __esm(() => {
1841
1846
  UNIT_LINE = [
1842
1847
  "inventoried",
@@ -1876,6 +1881,7 @@ var init_progress = __esm(() => {
1876
1881
  released: [],
1877
1882
  blocked: ["implementing", "planned"]
1878
1883
  };
1884
+ LEGACY_MODULE_EXITS = ["decomposed", "planned"];
1879
1885
  STATUS_TO_PHASE = {
1880
1886
  discovered: "discover",
1881
1887
  decomposed: "decompose",
@@ -1886,6 +1892,7 @@ var init_progress = __esm(() => {
1886
1892
  released: "release",
1887
1893
  blocked: "blocked"
1888
1894
  };
1895
+ LEGACY_FEATURE_EXITS = ["pending", "in-progress"];
1889
1896
  VALID_FEATURE_TRANSITIONS = {
1890
1897
  pending: ["in-progress"],
1891
1898
  "in-progress": ["evaluating"],
@@ -2369,6 +2376,7 @@ function getDirectories(iterations) {
2369
2376
  "skills/generate-mockup",
2370
2377
  "skills/visual-companion",
2371
2378
  "skills/ui-review",
2379
+ "skills/collect-components",
2372
2380
  "skills/onboard",
2373
2381
  "artifacts/_registry",
2374
2382
  "artifacts/00-baseline",
@@ -2490,7 +2498,7 @@ You are operating within the Haren agentic SDLC framework.
2490
2498
  - Rewrite of a legacy system with parity as the bar \u2192 \`migration\`
2491
2499
  6. Suggest next action based on current state
2492
2500
 
2493
- Visual questions follow the ui mode in manifest.yaml (\`ui.mockups\`: ask | ascii | browser). See the visual-companion skill.
2501
+ Visual questions follow the ui mode in manifest.yaml (\`ui.mockups\`: ask | ascii | browser | artifact). See the visual-companion skill.
2494
2502
 
2495
2503
  ## Available Actions
2496
2504
 
@@ -2511,6 +2519,7 @@ Visual questions follow the ui mode in manifest.yaml (\`ui.mockups\`: ask | asci
2511
2519
  | Draw a UI wireframe or compare screen options | generate-mockup/ | \u2014 |
2512
2520
  | Show mockups or options in a browser tab | visual-companion/ (\`haren companion\`) | \u2014 |
2513
2521
  | Review a screen against UX heuristics | ui-review/ | \u2014 |
2522
+ | Catalog common UI components, shared services and functions | collect-components/ | Developer |
2514
2523
  | Update status, artifacts, events | update-tracking/ (\`haren track\`) | \u2014 |
2515
2524
  | Onboard to the project / check the workspace | onboard/ (\`/haren-onboard\`) | \u2014 |
2516
2525
 
@@ -2546,6 +2555,8 @@ Change \`progress.json\`, \`events/events.jsonl\` and \`artifacts/_registry/arti
2546
2555
  | Module definition | Discover phase | \`artifacts/03-modules/{module}/module.md\` |
2547
2556
  | Design (architecture) | Dev | \`artifacts/04-plans/{module}/design.md\` |
2548
2557
  | Tasks (implementation) | Dev | \`artifacts/04-plans/{module}/[iteration-{N}/]tasks.md\` |
2558
+ | Implementation checklist | Dev | \`artifacts/04-plans/{module}/[iteration-{N}/]checklist.md\` |
2559
+ | Component catalog | Dev | \`artifacts/03-modules/component-catalog.md\` |
2549
2560
 
2550
2561
  ## Plan Paths
2551
2562
 
@@ -2563,7 +2574,7 @@ All skills that read or write plan artifacts MUST resolve paths using this conve
2563
2574
  - The plan skill writes to BOTH master and active paths (it is the only skill that does this)
2564
2575
 
2565
2576
  **If no \`iterations\` block in manifest.yaml:**
2566
- - **Active plan path:** \`artifacts/04-plans/{module}/\` \u2014 contains design.md, tasks.md
2577
+ - **Active plan path:** \`artifacts/04-plans/{module}/\` \u2014 contains design.md, tasks.md, checklist.md
2567
2578
  - **Master plan path:** (same as active)
2568
2579
 
2569
2580
  When a skill says "read the spec", it means from \`artifacts/03-modules/{module}/spec.md\`.
@@ -3014,13 +3025,59 @@ var init_init = __esm(() => {
3014
3025
  };
3015
3026
  });
3016
3027
 
3028
+ // src/lib/changelog.ts
3029
+ import { existsSync as existsSync13, readFileSync as readFileSync2 } from "fs";
3030
+ import { resolve as resolve10 } from "path";
3031
+ function readChangelog(candidates) {
3032
+ const probes = candidates ?? [
3033
+ resolve10(import.meta.dir, "..", "CHANGELOG.md"),
3034
+ resolve10(import.meta.dir, "..", "..", "..", "..", "CHANGELOG.md")
3035
+ ];
3036
+ for (const path of probes) {
3037
+ if (existsSync13(path))
3038
+ return readFileSync2(path, "utf-8");
3039
+ }
3040
+ return null;
3041
+ }
3042
+ function compareVersions(a, b) {
3043
+ const pa = a.split(".").map((n) => Number.parseInt(n, 10) || 0);
3044
+ const pb = b.split(".").map((n) => Number.parseInt(n, 10) || 0);
3045
+ for (let i = 0;i < 3; i++) {
3046
+ const d = (pa[i] ?? 0) - (pb[i] ?? 0);
3047
+ if (d !== 0)
3048
+ return d;
3049
+ }
3050
+ return 0;
3051
+ }
3052
+ function parseChangelog(text) {
3053
+ const sections = [];
3054
+ let current = null;
3055
+ for (const line of text.split(/\r?\n/)) {
3056
+ const m = /^##\s+\[?v?(\d+\.\d+\.\d+)\]?/.exec(line);
3057
+ if (m) {
3058
+ current = { version: m[1], body: "" };
3059
+ sections.push(current);
3060
+ } else if (current) {
3061
+ current.body += `${line}
3062
+ `;
3063
+ }
3064
+ }
3065
+ for (const s of sections)
3066
+ s.body = s.body.trim();
3067
+ return sections;
3068
+ }
3069
+ function whatsNew(text, from, to) {
3070
+ return parseChangelog(text).filter((s) => compareVersions(s.version, to) <= 0).filter((s) => from ? compareVersions(s.version, from) > 0 : compareVersions(s.version, to) === 0).sort((a, b) => compareVersions(b.version, a.version));
3071
+ }
3072
+ var init_changelog = () => {};
3073
+
3017
3074
  // src/commands/upgrade.ts
3018
3075
  import { mkdir as mkdir7, readdir as readdir5, copyFile as copyFile2, readFile as readFile9, stat as stat2, writeFile as writeFile6 } from "fs/promises";
3019
- import { join as join11, resolve as resolve10 } from "path";
3020
- import { existsSync as existsSync13 } from "fs";
3076
+ import { join as join11, resolve as resolve11 } from "path";
3077
+ import { existsSync as existsSync14 } from "fs";
3021
3078
  async function moduleRepoKey(harenDir, moduleName) {
3022
3079
  const path = join11(harenDir, "artifacts", "03-modules", moduleName, "module.md");
3023
- if (!existsSync13(path))
3080
+ if (!existsSync14(path))
3024
3081
  return;
3025
3082
  const match = (await readFile9(path, "utf-8")).match(/^repos:\s*\[([^\]]*)\]/m);
3026
3083
  return match?.[1].split(",")[0]?.trim().replace(/^["']|["']$/g, "") || undefined;
@@ -3044,7 +3101,7 @@ async function planMigration(location) {
3044
3101
  const map = {};
3045
3102
  let foundRemote = false;
3046
3103
  for (const [key, entry] of Object.entries(current)) {
3047
- const remote = entry.remote ?? (layout === "workspace" ? await getRemoteUrl(resolve10(harenDir, entry.path)) : null);
3104
+ const remote = entry.remote ?? (layout === "workspace" ? await getRemoteUrl(resolve11(harenDir, entry.path)) : null);
3048
3105
  if (remote && !entry.remote)
3049
3106
  foundRemote = true;
3050
3107
  map[key] = remote ? { ...entry, remote } : entry;
@@ -3061,7 +3118,7 @@ async function planMigration(location) {
3061
3118
  });
3062
3119
  let progress = null;
3063
3120
  const progressPath = join11(harenDir, "progress.json");
3064
- if (existsSync13(progressPath)) {
3121
+ if (existsSync14(progressPath)) {
3065
3122
  const before = await readFile9(progressPath, "utf-8");
3066
3123
  let raw;
3067
3124
  try {
@@ -3096,12 +3153,13 @@ async function planMigration(location) {
3096
3153
  gitignore,
3097
3154
  layout,
3098
3155
  editor,
3099
- steps
3156
+ steps,
3157
+ fromVersion: hasMarker(manifest) ? String(manifest.haren?.version) : undefined
3100
3158
  };
3101
3159
  }
3102
3160
  async function planGitignore(harenDir) {
3103
3161
  const path = join11(harenDir, ".gitignore");
3104
- const before = existsSync13(path) ? await readFile9(path, "utf-8") : "";
3162
+ const before = existsSync14(path) ? await readFile9(path, "utf-8") : "";
3105
3163
  const lines = new Set(before.split(/\r?\n/).map((l) => l.trim()));
3106
3164
  const missing = IGNORED.filter((f) => !lines.has(f));
3107
3165
  if (missing.length === 0)
@@ -3233,11 +3291,31 @@ async function upgrade(args) {
3233
3291
  console.log(` \x1B[32m\u2713\x1B[0m Upgraded ${totalFiles + 2} framework files.`);
3234
3292
  console.log(` \x1B[2mYour artifacts are untouched. Manifest and progress were migrated if needed.\x1B[0m`);
3235
3293
  console.log("");
3294
+ printWhatsNew(migration.fromVersion, HAREN_VERSION);
3295
+ }
3296
+ function printWhatsNew(from, to, text = readChangelog(), log = console.log) {
3297
+ if (!text || from === to)
3298
+ return;
3299
+ const sections = whatsNew(text, from, to);
3300
+ if (!sections.length)
3301
+ return;
3302
+ log(`\x1B[36m What's new${from ? ` since ${from}` : ""}\x1B[0m`);
3303
+ for (const s of sections) {
3304
+ log("");
3305
+ log(` \x1B[1m${s.version}\x1B[0m`);
3306
+ for (const line of s.body.split(`
3307
+ `))
3308
+ log(line ? ` ${line}` : "");
3309
+ }
3310
+ log("");
3311
+ log(" \x1B[2mFull changelog: https://github.com/odarino/haren/blob/main/CHANGELOG.md\x1B[0m");
3312
+ log("");
3236
3313
  }
3237
3314
  var IGNORED, FRAMEWORK_DIRS, USER_FILES;
3238
3315
  var init_upgrade = __esm(() => {
3239
3316
  init_content_dir();
3240
3317
  init_version();
3318
+ init_changelog();
3241
3319
  init_git();
3242
3320
  init_detect();
3243
3321
  init_manifest();
@@ -3913,7 +3991,7 @@ var init_updates = __esm(() => {
3913
3991
  });
3914
3992
 
3915
3993
  // src/plugins/runner.ts
3916
- import { existsSync as existsSync14 } from "fs";
3994
+ import { existsSync as existsSync15 } from "fs";
3917
3995
  import { appendFile as appendFile2, mkdir as mkdir8, readFile as readFile11 } from "fs/promises";
3918
3996
  import { isAbsolute as isAbsolute3, join as join16 } from "path";
3919
3997
  function tasksPath(input, harenDir) {
@@ -3923,11 +4001,11 @@ function tasksPath(input, harenDir) {
3923
4001
  }
3924
4002
  async function loadPlannedTasks(input, harenDir) {
3925
4003
  const path = tasksPath(input, harenDir);
3926
- if (!path || !existsSync14(path))
4004
+ if (!path || !existsSync15(path))
3927
4005
  return [];
3928
4006
  const tasks = parseTasksFile(await readFile11(path, "utf-8"));
3929
4007
  const progressPath = join16(harenDir, "progress.json");
3930
- if (typeof input.module !== "string" || !existsSync14(progressPath))
4008
+ if (typeof input.module !== "string" || !existsSync15(progressPath))
3931
4009
  return tasks;
3932
4010
  try {
3933
4011
  const mod = (await readProgress(progressPath)).modules[input.module];
@@ -3947,7 +4025,7 @@ async function buildPayload(hook, input, harenDir) {
3947
4025
  }
3948
4026
  async function addPlannedFeatures(input, harenDir) {
3949
4027
  const progressPath = join16(harenDir, "progress.json");
3950
- if (typeof input.module !== "string" || !existsSync14(progressPath))
4028
+ if (typeof input.module !== "string" || !existsSync15(progressPath))
3951
4029
  return;
3952
4030
  const tasks = await loadPlannedTasks(input, harenDir);
3953
4031
  const progress = await readProgress(progressPath);
@@ -4098,7 +4176,7 @@ async function runHookAndApply(hook, input, o) {
4098
4176
  }
4099
4177
  try {
4100
4178
  const progressPath = join16(o.harenDir, "progress.json");
4101
- if (updates.length > 0 && existsSync14(progressPath)) {
4179
+ if (updates.length > 0 && existsSync15(progressPath)) {
4102
4180
  const result = applyUpdates(await readProgress(progressPath), updates);
4103
4181
  if (result.applied.length > 0)
4104
4182
  await writeProgress(progressPath, result.progress);
@@ -4281,7 +4359,7 @@ var init_plugin = __esm(() => {
4281
4359
  });
4282
4360
 
4283
4361
  // src/plugins/adapter-read.ts
4284
- import { existsSync as existsSync15 } from "fs";
4362
+ import { existsSync as existsSync16 } from "fs";
4285
4363
  import { join as join18 } from "path";
4286
4364
  function adapterMissingMessage(name) {
4287
4365
  return `Adapter '${name}' is named in manifest.yaml but not installed. Run \`haren plugin add <source>\`, or remove migration.adapter to work by hand.`;
@@ -4291,7 +4369,7 @@ async function readAdapter(harenDir, name) {
4291
4369
  if (!plugins[name])
4292
4370
  return null;
4293
4371
  const dir = pluginDir(harenDir, name);
4294
- if (!existsSync15(join18(dir, "haren-plugin.json")))
4372
+ if (!existsSync16(join18(dir, "haren-plugin.json")))
4295
4373
  return null;
4296
4374
  try {
4297
4375
  return (await readInstalledManifest(dir)).adapter ?? null;
@@ -4305,7 +4383,7 @@ var init_adapter_read = __esm(() => {
4305
4383
  });
4306
4384
 
4307
4385
  // src/commands/track.ts
4308
- import { existsSync as existsSync16 } from "fs";
4386
+ import { existsSync as existsSync17 } from "fs";
4309
4387
  import { mkdir as mkdir9, readdir as readdir7, readFile as readFile13, writeFile as writeFile7 } from "fs/promises";
4310
4388
  import { dirname as dirname5, join as join19, relative as relative4, sep as sep4 } from "path";
4311
4389
  function parseTrackArgs(args) {
@@ -4316,6 +4394,10 @@ function parseTrackArgs(args) {
4316
4394
  if (arg.startsWith("--")) {
4317
4395
  const eq = arg.indexOf("=");
4318
4396
  const name = eq === -1 ? arg : arg.slice(0, eq);
4397
+ if (BOOL_FLAGS.includes(name) && eq === -1) {
4398
+ flags[name.slice(2)] = "true";
4399
+ continue;
4400
+ }
4319
4401
  if (!VALUE_FLAGS.includes(name))
4320
4402
  throw new Error(`Unknown option: ${name}`);
4321
4403
  const value = eq === -1 ? args[++i] : arg.slice(eq + 1);
@@ -4353,7 +4435,7 @@ function requireModule(progress, name) {
4353
4435
  }
4354
4436
  }
4355
4437
  async function loadProgress(paths) {
4356
- if (!existsSync16(paths.progress))
4438
+ if (!existsSync17(paths.progress))
4357
4439
  throw new Error(`No progress.json in ${paths.harenDir}`);
4358
4440
  return readProgress(paths.progress);
4359
4441
  }
@@ -4379,7 +4461,7 @@ async function track(args, cwd = process.cwd()) {
4379
4461
  case "unit":
4380
4462
  return trackUnit(paths, rest);
4381
4463
  case "commit":
4382
- return trackCommit(paths, rest);
4464
+ return trackCommit(paths, rest, flags);
4383
4465
  case "depends":
4384
4466
  return trackDepends(paths, rest);
4385
4467
  case "artifact":
@@ -4403,7 +4485,7 @@ async function trackUiMode(paths, rest) {
4403
4485
  throw new Error(`Invalid ui mode '${mode}'. Use ${UI_MODES.join(", ")}.`);
4404
4486
  }
4405
4487
  const manifestPath = join19(paths.harenDir, "manifest.yaml");
4406
- if (!existsSync16(manifestPath))
4488
+ if (!existsSync17(manifestPath))
4407
4489
  throw new Error(`No manifest.yaml in ${paths.harenDir}`);
4408
4490
  const text = await readFile13(manifestPath, "utf-8");
4409
4491
  await writeFile7(manifestPath, setUiModeText(text, mode));
@@ -4412,7 +4494,7 @@ async function trackUiMode(paths, rest) {
4412
4494
  }
4413
4495
  async function loadMigration(paths) {
4414
4496
  const manifestPath = join19(paths.harenDir, "manifest.yaml");
4415
- if (!existsSync16(manifestPath))
4497
+ if (!existsSync17(manifestPath))
4416
4498
  return null;
4417
4499
  return readMigrationConfig(parseManifest(await readFile13(manifestPath, "utf-8")));
4418
4500
  }
@@ -4464,17 +4546,25 @@ async function moduleMeta(paths, flags) {
4464
4546
  if (!repos.length)
4465
4547
  throw new Error(`Missing --repos <key1,key2>.
4466
4548
  ${TRACK_USAGE}`);
4467
- const manifestPath = join19(paths.harenDir, "manifest.yaml");
4468
- const manifest = existsSync16(manifestPath) ? parseManifest(await readFile13(manifestPath, "utf-8")) : {};
4469
- const declared = Object.keys(normalizeRepos(manifest.repos));
4470
- const unknown = repos.filter((r) => !declared.includes(r));
4471
- if (unknown.length) {
4472
- throw new Error(`Unknown repo key: ${unknown.join(", ")}. manifest.yaml repos: ${declared.length ? declared.join(", ") : "(none)"}`);
4473
- }
4549
+ await checkRepoKeys(paths, repos);
4474
4550
  meta.repos = repos;
4475
4551
  }
4476
4552
  return meta;
4477
4553
  }
4554
+ async function allowedRepoKeys(paths) {
4555
+ const manifestPath = join19(paths.harenDir, "manifest.yaml");
4556
+ const manifest = existsSync17(manifestPath) ? parseManifest(await readFile13(manifestPath, "utf-8")) : {};
4557
+ const declared = Object.keys(normalizeRepos(manifest.repos));
4558
+ return { allowed: declared.length ? declared : ["default"], empty: !declared.length };
4559
+ }
4560
+ async function checkRepoKeys(paths, keys) {
4561
+ const { allowed, empty } = await allowedRepoKeys(paths);
4562
+ const declared = empty ? [] : allowed;
4563
+ const unknown = keys.filter((k) => !allowed.includes(k));
4564
+ if (unknown.length) {
4565
+ throw new Error(`Unknown repo key: ${unknown.join(", ")}. Allowed: ${allowed.join(", ")}${declared.length ? "" : " (manifest.yaml repos is empty)"}`);
4566
+ }
4567
+ }
4478
4568
  async function trackStatus(paths, rest, flags) {
4479
4569
  const module = need(rest[0], "<module>");
4480
4570
  const to = need(rest[1], "<status>");
@@ -4565,10 +4655,13 @@ async function trackFeature(paths, rest) {
4565
4655
  await emit(paths, { type: "feature-status", module, feature, from, to: status });
4566
4656
  console.log(` ${module}/${feature}: ${from ?? "(new)"} \u2192 ${status}`);
4567
4657
  }
4568
- async function trackCommit(paths, rest) {
4658
+ async function trackCommit(paths, rest, flags = {}) {
4569
4659
  const module = need(rest[0], "<module>");
4570
4660
  const repo = need(rest[1], "<repoKey>");
4661
+ if (flags.remove)
4662
+ return removeCommitKey(paths, module, repo);
4571
4663
  const sha = need(rest[2], "<sha>");
4664
+ await checkRepoKeys(paths, [repo]);
4572
4665
  const progress = await loadProgress(paths);
4573
4666
  requireModule(progress, module);
4574
4667
  const mod = progress.modules[module];
@@ -4590,6 +4683,31 @@ async function trackCommit(paths, rest) {
4590
4683
  await emit(paths, { type: "commit", module, repo, sha });
4591
4684
  console.log(` ${module}: lastCommit.${repo} = ${sha}`);
4592
4685
  }
4686
+ async function removeCommitKey(paths, module, repo) {
4687
+ const progress = await loadProgress(paths);
4688
+ requireModule(progress, module);
4689
+ const mod = progress.modules[module];
4690
+ const lastCommit = { ...mod.lastCommit ?? {} };
4691
+ const had = Object.hasOwn(lastCommit, repo) || (mod.repos ?? []).includes(repo);
4692
+ if (!had)
4693
+ throw new Error(`Module '${module}' has no repo key '${repo}'.`);
4694
+ delete lastCommit[repo];
4695
+ const next = {
4696
+ ...progress,
4697
+ modules: {
4698
+ ...progress.modules,
4699
+ [module]: {
4700
+ ...mod,
4701
+ lastCommit,
4702
+ repos: (mod.repos ?? []).filter((r) => r !== repo),
4703
+ lastUpdated: new Date().toISOString()
4704
+ }
4705
+ }
4706
+ };
4707
+ await writeProgress(paths.progress, next);
4708
+ await emit(paths, { type: "commit", module, repo, sha: null, removed: true });
4709
+ console.log(` ${module}: removed repo key ${repo}`);
4710
+ }
4593
4711
  function findCycle(graph, module, deps) {
4594
4712
  const next = { ...graph, [module]: deps };
4595
4713
  const visited = new Set([module]);
@@ -4665,7 +4783,7 @@ async function trackArtifact(paths, rest, flags) {
4665
4783
  const progress = await loadProgress(paths);
4666
4784
  requireModule(progress, flags.module);
4667
4785
  }
4668
- const existing = existsSync16(paths.registry) ? await readFile13(paths.registry, "utf-8") : "";
4786
+ const existing = existsSync17(paths.registry) ? await readFile13(paths.registry, "utf-8") : "";
4669
4787
  await mkdir9(dirname5(paths.registry), { recursive: true });
4670
4788
  await writeFile7(paths.registry, upsertArtifactRow(existing, [id, artifactType, module, status, path]));
4671
4789
  await emit(paths, {
@@ -4729,7 +4847,7 @@ async function trackOverride(paths, rest, flags) {
4729
4847
  }
4730
4848
  }
4731
4849
  async function listArtifactFiles(artifactsDir) {
4732
- if (!existsSync16(artifactsDir))
4850
+ if (!existsSync17(artifactsDir))
4733
4851
  return [];
4734
4852
  const out = [];
4735
4853
  const walk = async (dir) => {
@@ -4771,13 +4889,14 @@ async function checkWorkspace(paths) {
4771
4889
  const warnings = [];
4772
4890
  const progress = await loadProgress(paths);
4773
4891
  const manifestPath = join19(paths.harenDir, "manifest.yaml");
4774
- const manifest = existsSync16(manifestPath) ? parseManifest(await readFile13(manifestPath, "utf-8")) : {};
4775
- const declared = new Set(Object.keys(normalizeRepos(manifest.repos)));
4892
+ const manifest = existsSync17(manifestPath) ? parseManifest(await readFile13(manifestPath, "utf-8")) : {};
4893
+ const { allowed: allowedKeys, empty: noRepos } = await allowedRepoKeys(paths);
4894
+ const declared = new Set(allowedKeys);
4776
4895
  for (const [name, mod] of Object.entries(progress.modules)) {
4777
4896
  const used = new Set([...mod.repos ?? [], ...Object.keys(mod.lastCommit ?? {})]);
4778
4897
  for (const key of used) {
4779
4898
  if (!declared.has(key)) {
4780
- errors.push(`module '${name}' uses repo '${key}', but manifest.yaml has no repos.${key} entry`);
4899
+ errors.push(`module '${name}' uses repo '${key}', but ${noRepos ? "manifest.yaml repos is empty, so the only key is 'default'" : `manifest.yaml has no repos.${key} entry`}. Remove a stale key with: haren track commit ${name} ${key} --remove`);
4781
4900
  }
4782
4901
  }
4783
4902
  }
@@ -4824,7 +4943,7 @@ async function checkWorkspace(paths) {
4824
4943
  }
4825
4944
  }
4826
4945
  }
4827
- const registryText = existsSync16(paths.registry) ? await readFile13(paths.registry, "utf-8") : "";
4946
+ const registryText = existsSync17(paths.registry) ? await readFile13(paths.registry, "utf-8") : "";
4828
4947
  const rows = parseRegistryRows(registryText);
4829
4948
  const indexed = new Set(rows.map((r) => normalizeArtifactPath(r.path)));
4830
4949
  const artifactsDir = join19(paths.harenDir, "artifacts");
@@ -4836,7 +4955,7 @@ async function checkWorkspace(paths) {
4836
4955
  }
4837
4956
  for (const row of rows) {
4838
4957
  const rel = normalizeArtifactPath(row.path);
4839
- if (!existsSync16(join19(artifactsDir, rel))) {
4958
+ if (!existsSync17(join19(artifactsDir, rel))) {
4840
4959
  errors.push(`index row ${row.id} points to missing file artifacts/${rel}`);
4841
4960
  }
4842
4961
  }
@@ -4864,14 +4983,15 @@ var TRACK_USAGE = `Usage:
4864
4983
  haren track feature <module> <feature> [status]
4865
4984
  haren track unit <module> <unit> <status>
4866
4985
  haren track commit <module> <repoKey> <sha>
4986
+ haren track commit <module> <repoKey> --remove
4867
4987
  haren track depends <module> [dep ...]
4868
4988
  haren track artifact <id> --type <type> --path <path> [--module <m>] [--status <s>]
4869
4989
  haren track event <type> [--module m] [--phase p] [--feature f] [--data '<json object>']
4870
4990
  haren track override on --reason "<text>" [--hours <n>]
4871
4991
  haren track override off
4872
- haren track ui-mode <ask|ascii|browser>
4992
+ haren track ui-mode <ask|ascii|browser|artifact>
4873
4993
  haren track check
4874
- Options: --haren-dir <path>`, VALUE_FLAGS, REGISTRY_HEADER = `| ID | Type | Module | Status | Path |
4994
+ Options: --haren-dir <path>`, BOOL_FLAGS, VALUE_FLAGS, REGISTRY_HEADER = `| ID | Type | Module | Status | Path |
4875
4995
  |----|------|--------|--------|------|`, UNTRACKED_DIRS;
4876
4996
  var init_track = __esm(() => {
4877
4997
  init_manifest();
@@ -4879,6 +4999,7 @@ var init_track = __esm(() => {
4879
4999
  init_progress();
4880
5000
  init_adapter_read();
4881
5001
  init_resolve();
5002
+ BOOL_FLAGS = ["--remove"];
4882
5003
  VALUE_FLAGS = [
4883
5004
  "--haren-dir",
4884
5005
  "--type",
@@ -4959,9 +5080,9 @@ var init_adapter_run = __esm(() => {
4959
5080
  });
4960
5081
 
4961
5082
  // src/commands/migrate.ts
4962
- import { existsSync as existsSync17 } from "fs";
5083
+ import { existsSync as existsSync18 } from "fs";
4963
5084
  import { mkdir as mkdir10, readFile as readFile14, writeFile as writeFile8 } from "fs/promises";
4964
- import { dirname as dirname6, join as join20, resolve as resolve11 } from "path";
5085
+ import { dirname as dirname6, join as join20, resolve as resolve12 } from "path";
4965
5086
  function parseMigrateArgs(args) {
4966
5087
  const positional = [];
4967
5088
  const flags = {};
@@ -5068,7 +5189,7 @@ async function loadContext(harenDir) {
5068
5189
  migration,
5069
5190
  adapterName: migration.adapter,
5070
5191
  adapter,
5071
- legacyRoot: resolve11(harenDir, legacy[1].path)
5192
+ legacyRoot: resolve12(harenDir, legacy[1].path)
5072
5193
  };
5073
5194
  }
5074
5195
  async function migrate(args, cwd = process.cwd()) {
@@ -5104,7 +5225,7 @@ async function inventory(ctx, moduleFlag) {
5104
5225
  const out = { units: raw.units.filter((u) => ctx.migration.unitId.test(u.id)) };
5105
5226
  const mapRel = "artifacts/02-discovery/unit-map.md";
5106
5227
  const mapPath = join20(ctx.paths.harenDir, mapRel);
5107
- const previous = existsSync17(mapPath) ? await readFile14(mapPath, "utf-8") : "";
5228
+ const previous = existsSync18(mapPath) ? await readFile14(mapPath, "utf-8") : "";
5108
5229
  const known = parseUnitMap(previous);
5109
5230
  const moduleOf = {};
5110
5231
  const units = [];
@@ -5148,7 +5269,7 @@ async function inventory(ctx, moduleFlag) {
5148
5269
  for (const [module, unit] of added) {
5149
5270
  await emit(ctx.paths, { type: "unit-status", module, unit, from: null, to: "inventoried" });
5150
5271
  }
5151
- const registry = existsSync17(ctx.paths.registry) ? await readFile14(ctx.paths.registry, "utf-8") : "";
5272
+ const registry = existsSync18(ctx.paths.registry) ? await readFile14(ctx.paths.registry, "utf-8") : "";
5152
5273
  if (!/^\|\s*UNITMAP-001\s*\|/m.test(registry)) {
5153
5274
  await mkdir10(dirname6(ctx.paths.registry), { recursive: true });
5154
5275
  await writeFile8(ctx.paths.registry, upsertArtifactRow(registry, ["UNITMAP-001", "unit-map", "-", "draft", mapRel]));
@@ -5191,7 +5312,7 @@ async function gate(ctx, unit, approve) {
5191
5312
  const module = moduleOfUnit(progress, unit);
5192
5313
  const unitDir = unitDirFor(ctx, unit);
5193
5314
  const specPath = join20(unitDir, "spec.md");
5194
- if (!existsSync17(specPath))
5315
+ if (!existsSync18(specPath))
5195
5316
  throw new Error(`No spec at ${specPath}. Write the spec first.`);
5196
5317
  const from = progress.modules[module].units[unit];
5197
5318
  if (from !== "spec-draft" && from !== "spec-approved") {
@@ -5676,11 +5797,11 @@ import { randomBytes, timingSafeEqual } from "crypto";
5676
5797
  import {
5677
5798
  appendFileSync,
5678
5799
  chmodSync,
5679
- existsSync as existsSync18,
5800
+ existsSync as existsSync19,
5680
5801
  lstatSync,
5681
5802
  mkdirSync,
5682
5803
  readdirSync,
5683
- readFileSync as readFileSync2,
5804
+ readFileSync as readFileSync3,
5684
5805
  realpathSync as realpathSync2,
5685
5806
  rmSync,
5686
5807
  statSync,
@@ -5771,7 +5892,7 @@ async function startCompanion(opts) {
5771
5892
  const stoppedFile = join21(stateDir, "server-stopped");
5772
5893
  const eventsFile = join21(stateDir, "events");
5773
5894
  rmSync(stoppedFile, { force: true });
5774
- if (existsSync18(eventsFile))
5895
+ if (existsSync19(eventsFile))
5775
5896
  chmodSync(eventsFile, 384);
5776
5897
  const key = opts.key ?? randomBytes(16).toString("hex");
5777
5898
  const idleTimeoutMs = opts.idleTimeoutMs ?? 240 * 60000;
@@ -5818,7 +5939,7 @@ async function startCompanion(opts) {
5818
5939
  return respond("Not found", "text/plain", 404, extra);
5819
5940
  if (url.pathname === "/") {
5820
5941
  const screen = newestScreen(contentDir);
5821
- const raw = screen ? readFileSync2(screen, "utf-8") : null;
5942
+ const raw = screen ? readFileSync3(screen, "utf-8") : null;
5822
5943
  const html = raw === null ? wrapInFrame(WAITING_CONTENT) : isFullDocument(raw) ? injectHelper(raw) : wrapInFrame(raw);
5823
5944
  return respond(html, "text/html; charset=utf-8", 200, extra);
5824
5945
  }
@@ -5837,7 +5958,7 @@ async function startCompanion(opts) {
5837
5958
  return respond("Not found", "text/plain", 404, extra);
5838
5959
  }
5839
5960
  const type = MIME_TYPES[extname(fp).toLowerCase()] ?? "application/octet-stream";
5840
- return respond(readFileSync2(fp), type, 200, extra);
5961
+ return respond(readFileSync3(fp), type, 200, extra);
5841
5962
  }
5842
5963
  return respond("Not found", "text/plain", 404, extra);
5843
5964
  },
@@ -5915,7 +6036,7 @@ async function startCompanion(opts) {
5915
6036
  if (idleTimer)
5916
6037
  clearTimeout(idleTimer);
5917
6038
  clearInterval(poll);
5918
- if (existsSync18(stateDir)) {
6039
+ if (existsSync19(stateDir)) {
5919
6040
  writeFileSync(stoppedFile, `${JSON.stringify({ reason })}
5920
6041
  `);
5921
6042
  }
@@ -5958,16 +6079,16 @@ var init_server = __esm(() => {
5958
6079
  // src/commands/companion.ts
5959
6080
  import { randomBytes as randomBytes2 } from "crypto";
5960
6081
  import {
5961
- existsSync as existsSync19,
6082
+ existsSync as existsSync20,
5962
6083
  readdirSync as readdirSync2,
5963
- readFileSync as readFileSync3,
6084
+ readFileSync as readFileSync4,
5964
6085
  renameSync,
5965
6086
  rmSync as rmSync2,
5966
6087
  statSync as statSync2,
5967
6088
  writeFileSync as writeFileSync2
5968
6089
  } from "fs";
5969
6090
  import { spawnSync } from "child_process";
5970
- import { join as join22, resolve as resolve12 } from "path";
6091
+ import { join as join22, resolve as resolve13 } from "path";
5971
6092
  function flag(args, name) {
5972
6093
  const i = args.indexOf(name);
5973
6094
  if (i === -1)
@@ -5979,7 +6100,7 @@ function flag(args, name) {
5979
6100
  }
5980
6101
  function readJson(path) {
5981
6102
  try {
5982
- return JSON.parse(readFileSync3(path, "utf-8"));
6103
+ return JSON.parse(readFileSync4(path, "utf-8"));
5983
6104
  } catch {
5984
6105
  return null;
5985
6106
  }
@@ -5998,7 +6119,7 @@ function pidAlive(pid) {
5998
6119
  }
5999
6120
  function readPid(dir) {
6000
6121
  try {
6001
- const n = Number.parseInt(readFileSync3(join22(dir, "state", "pid"), "utf-8").trim(), 10);
6122
+ const n = Number.parseInt(readFileSync4(join22(dir, "state", "pid"), "utf-8").trim(), 10);
6002
6123
  return Number.isFinite(n) && n > 0 ? n : null;
6003
6124
  } catch {
6004
6125
  return null;
@@ -6008,7 +6129,7 @@ function sessionOf(dir) {
6008
6129
  const stateDir = join22(dir, "state");
6009
6130
  const info = readJson(join22(stateDir, "server-info")) ?? readJson(join22(stateDir, "server-info.prev"));
6010
6131
  const pid = readPid(dir);
6011
- const running = info !== null && !existsSync19(join22(stateDir, "server-stopped")) && pid !== null && pidAlive(pid);
6132
+ const running = info !== null && !existsSync20(join22(stateDir, "server-stopped")) && pid !== null && pidAlive(pid);
6012
6133
  return { dir, info, running };
6013
6134
  }
6014
6135
  function latestSession(harenDir) {
@@ -6046,7 +6167,7 @@ async function portFree(port, host) {
6046
6167
  function cliEntry() {
6047
6168
  const here = import.meta.path;
6048
6169
  if (/[\\/]commands[\\/]companion\.ts$/.test(here))
6049
- return resolve12(import.meta.dir, "..", "index.ts");
6170
+ return resolve13(import.meta.dir, "..", "index.ts");
6050
6171
  return here;
6051
6172
  }
6052
6173
  function openBrowser(url) {
@@ -6149,7 +6270,7 @@ async function serve(args) {
6149
6270
  if (keyFile && !key)
6150
6271
  throw new Error(`No key in ${keyFile}`);
6151
6272
  key ??= randomBytes2(16).toString("hex");
6152
- if (!keyFile || resolve12(keyFile) !== resolve12(keyPath))
6273
+ if (!keyFile || resolve13(keyFile) !== resolve13(keyPath))
6153
6274
  writePrivateFile(keyPath, `${key}
6154
6275
  `);
6155
6276
  const opts = {
@@ -6199,7 +6320,7 @@ async function serve(args) {
6199
6320
  return;
6200
6321
  }
6201
6322
  }
6202
- if (existsSync19(stopFile))
6323
+ if (existsSync20(stopFile))
6203
6324
  finish();
6204
6325
  }, 100);
6205
6326
  process.on("SIGTERM", onSignal);
@@ -6209,14 +6330,14 @@ async function serve(args) {
6209
6330
  }
6210
6331
  function readKey(path) {
6211
6332
  try {
6212
- return readFileSync3(path, "utf-8").trim() || undefined;
6333
+ return readFileSync4(path, "utf-8").trim() || undefined;
6213
6334
  } catch {
6214
6335
  return;
6215
6336
  }
6216
6337
  }
6217
6338
  function restoreInfo(dir) {
6218
6339
  const infoPath = join22(dir, "state", "server-info");
6219
- if (!existsSync19(infoPath) && existsSync19(`${infoPath}.prev`))
6340
+ if (!existsSync20(infoPath) && existsSync20(`${infoPath}.prev`))
6220
6341
  renameSync(`${infoPath}.prev`, infoPath);
6221
6342
  }
6222
6343
  function keyOf(url) {
@@ -6298,7 +6419,7 @@ async function start(harenDir, args) {
6298
6419
  const stoppedAt = mtimeOf(join22(stateDir, "server-stopped"));
6299
6420
  rmSync2(join22(stateDir, "server-stopped"), { force: true });
6300
6421
  const infoPath = join22(stateDir, "server-info");
6301
- if (existsSync19(infoPath))
6422
+ if (existsSync20(infoPath))
6302
6423
  renameSync(infoPath, `${infoPath}.prev`);
6303
6424
  archiveScreens(join22(dir, "content"), stoppedAt);
6304
6425
  }
@@ -6329,7 +6450,7 @@ async function start(harenDir, args) {
6329
6450
  if (foreground) {
6330
6451
  const infoFile = join22(stateDir, "server-info");
6331
6452
  const printer = setInterval(() => {
6332
- if (existsSync19(infoFile)) {
6453
+ if (existsSync20(infoFile)) {
6333
6454
  const info = readJson(infoFile);
6334
6455
  if (!info)
6335
6456
  return;
@@ -6354,7 +6475,7 @@ async function start(harenDir, args) {
6354
6475
  const deadline = Date.now() + companionDeps.startTimeoutMs;
6355
6476
  while (Date.now() < deadline) {
6356
6477
  const s = sessionOf(dir);
6357
- if (s.info && s.running && existsSync19(join22(stateDir, "server-info"))) {
6478
+ if (s.info && s.running && existsSync20(join22(stateDir, "server-info"))) {
6358
6479
  succeed(s.info);
6359
6480
  console.log(JSON.stringify(s.info));
6360
6481
  return;
@@ -6406,7 +6527,7 @@ state_dir ${s.info.state_dir}`);
6406
6527
  }
6407
6528
  function markStopped(dir) {
6408
6529
  const stopped = join22(dir, "state", "server-stopped");
6409
- if (existsSync19(join22(dir, "state")) && !existsSync19(stopped))
6530
+ if (existsSync20(join22(dir, "state")) && !existsSync20(stopped))
6410
6531
  writeFileSync2(stopped, `${JSON.stringify({ reason: "stop" })}
6411
6532
  `);
6412
6533
  }
@@ -6562,7 +6683,7 @@ async function main() {
6562
6683
  console.log(" artifact <id> --type <type> --path <path> [--module <m>] [--status <s>]");
6563
6684
  console.log(" event <type> [--module m] [--phase p] [--feature f] [--data '<json>']");
6564
6685
  console.log(" unit <module> <unit> <status> (migration mode)");
6565
- console.log(" ui-mode <ask|ascii|browser>");
6686
+ console.log(" ui-mode <ask|ascii|browser|artifact>");
6566
6687
  console.log(' override on --reason "<text>" [--hours <n>] | override off');
6567
6688
  console.log(" haren migrate Run the migration adapter:");
6568
6689
  console.log(" inventory [--module <m>] | extract <unit> | gate <unit> [--approve]");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odarino/haren",
3
- "version": "1.6.0",
3
+ "version": "1.7.0",
4
4
  "description": "Minimal skill-based agentic SDLC framework",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -33,7 +33,8 @@
33
33
  },
34
34
  "files": [
35
35
  "dist",
36
- "content"
36
+ "content",
37
+ "CHANGELOG.md"
37
38
  ],
38
39
  "publishConfig": {
39
40
  "access": "public"