Commit a6fcaef
authored
Closes #109. Sub-issues #110, #111, #112, #113, #114, #115 all closed.
## Summary
Refactor `@forgeplan/web` for multi-instance use:
1. **citty-based CLI** — `bin/forgeplan-web.mjs` shrinks 367→5 lines;
subcommands live in `bin/commands/{init,update,start}.mjs`; helpers in
`bin/lib/`. Single allow-listed dep (`citty@0.2.2`) per amended rule 23.
2. **`--scope user|project` flag** — init writes to
`<cwd>/.forgeplan-web/` or `~/.forgeplan-web/`. `init -y` keeps
defaulting to project (compat); interactive prompt picks user as the new
default. Non-TTY without flag fails clearly.
3. **`start` resolution chain** — project → user → prompt-init. Explicit
`--scope` short-circuits the chain.
4. **Global instance registry** at `~/.forgeplan-web/instances.json` —
incremental ports, pid + heartbeat liveness, atomic tmp+rename writes,
stale sweep on every start. New `/api/instances` readonly endpoint
mirrors the registry to the UI.
5. **Combobox primitive** in `template/src/shared/ui/combobox/` (bits-ui
2.18.1; default + mono variants × sm/md sizes; showcased on /playground;
rule-24 clean).
6. **HealthBar instance switcher** — when ≥2 instances are running, the
project label becomes a Combobox; selecting another instance navigates
the browser to `http://host:port`. Single-instance behavior unchanged.
## Why
Original issue: install `forgeplan-web` once per user (not per project),
run several instances simultaneously, switch between them from any
instance's UI. Refined plan keeps backwards compat (`--scope project` is
still the `init -y` default) so existing setups don't break.
## Forgeplan artifacts (all `active`, R_eff > 0)
- ADR-003 — amend rule 23 to permit citty in `bin/`
- ADR-004 — registry path + JSON format + atomic writes
- PRD-024 + RFC-020 — citty integration
- PRD-025 + RFC-021 — `--scope` flag + user-scope path
- PRD-026 + RFC-022 — start resolution chain
- PRD-027 + RFC-023 + SPEC-003 — instance registry
- PRD-028 + RFC-024 — Combobox primitive
- PRD-029 + RFC-025 — HealthBar switcher
- EVID-029..034 — smoke + svelte-check + manual scenarios per PRD
Rules touched (each via dedicated PRD/ADR):
- `.claude/rules/20-init-host-isolation.md` — user-scope writes are
gitignore-silent (PRD-025)
- `.claude/rules/22-readonly-proxy.md` — `/api/instances` allow-list
extension (PRD-027)
- `.claude/rules/23-bin-zero-deps.md` — citty named exception (ADR-003)
## Test plan
- [x] `npm run smoke` — PASS at every wave (citty refactor, scope
wiring, registry, HealthBar)
- [x] `npm run build` — svelte-check 1056 files / 0 errors / 0 warnings
- [x] Manual: `init -y --scope user` writes only to `~/.forgeplan-web/`,
host `.gitignore` untouched
- [x] Manual: `init -y` (no flag) defaults to project (compat preserved)
- [x] Manual: Two instances on 5174 + 5175 (or first free pair); both
register; SIGKILL on one swept on next start; heartbeat ticks at ~30s;
deregister within 2s of SIGTERM
- [x] Manual: HealthBar shows Combobox when ≥2 instances;
single-instance fallback verified
- [x] Manual: `/api/instances` returns standard envelope `{ ok, data: {
instances }, cmd: "registry:read" }`
- [x] `forgeplan health` clean post-Wave-7
- [x] Rule 23 verifier exits 0 (only `citty` + `node:*` + relative
siblings in `bin/`)
- [x] Rule 24 grep clean (no upper-layer `:global()` reaches into
Combobox internals)
- [ ] CI matrix (ubuntu/macos/windows × Node 22) — runs on PR open
## Out of scope (deferred follow-ups)
- Cross-host federation (talking to instances on other machines)
- Auth / per-instance access control
- Migration tool for existing project-scope `.forgeplan-web/` →
user-scope
- Full XDG compliance (`XDG_CONFIG_HOME` etc.) — RFC-021 keeps
`~/.forgeplan-web/` for predictability
- Smoke coverage for `--scope user` path + multi-instance scenario
(current smoke covers single project-scope instance only)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
55 files changed
Lines changed: 7624 additions & 429 deletions
File tree
- .claude/rules
- .forgeplan
- adrs
- evidence
- prds
- rfcs
- specs
- bin
- commands
- lib
- template/src
- entities/instance
- api
- model
- routes
- api/instances
- playground
- widgets/health-bar/ui
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
| 3 | + | |
| 4 | + | |
7 | 5 | | |
8 | | - | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
9 | 21 | | |
10 | 22 | | |
11 | 23 | | |
12 | 24 | | |
13 | 25 | | |
14 | 26 | | |
15 | 27 | | |
16 | | - | |
17 | | - | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
18 | 33 | | |
19 | 34 | | |
20 | 35 | | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
25 | 45 | | |
26 | 46 | | |
27 | 47 | | |
| |||
46 | 66 | | |
47 | 67 | | |
48 | 68 | | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
57 | 80 | | |
58 | 81 | | |
| 82 | + | |
| 83 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
| 32 | + | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
55 | 89 | | |
56 | 90 | | |
57 | 91 | | |
| |||
97 | 131 | | |
98 | 132 | | |
99 | 133 | | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
10 | 15 | | |
11 | 16 | | |
12 | 17 | | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
18 | 33 | | |
19 | 34 | | |
20 | 35 | | |
21 | 36 | | |
22 | 37 | | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
29 | 48 | | |
30 | 49 | | |
31 | 50 | | |
| |||
43 | 62 | | |
44 | 63 | | |
45 | 64 | | |
46 | | - | |
47 | | - | |
| 65 | + | |
| 66 | + | |
48 | 67 | | |
49 | 68 | | |
50 | 69 | | |
| |||
53 | 72 | | |
54 | 73 | | |
55 | 74 | | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
60 | 82 | | |
61 | 83 | | |
62 | 84 | | |
| |||
67 | 89 | | |
68 | 90 | | |
69 | 91 | | |
70 | | - | |
71 | | - | |
72 | | - | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
73 | 97 | | |
74 | 98 | | |
75 | 99 | | |
76 | 100 | | |
77 | | - | |
78 | | - | |
79 | | - | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
80 | 105 | | |
81 | 106 | | |
82 | | - | |
| 107 | + | |
| 108 | + | |
83 | 109 | | |
84 | | - | |
| 110 | + | |
85 | 111 | | |
86 | 112 | | |
87 | | - | |
| 113 | + | |
88 | 114 | | |
89 | | - | |
| 115 | + | |
90 | 116 | | |
91 | | - | |
| 117 | + | |
92 | 118 | | |
93 | 119 | | |
94 | | - | |
95 | | - | |
96 | | - | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
97 | 139 | | |
0 commit comments