archik 0.19.5 → 0.21.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.
@@ -1,84 +1,84 @@
1
1
  ---
2
- description: Finish a migration — back-fill the artifacts the migrator flagged
2
+ description: Finish a migration — check the result and fix what the migrator flagged
3
3
  ---
4
4
 
5
- # /archik:migrate — back-fill what the deterministic migration couldn't
5
+ # /archik:migrate — check what the deterministic migration did
6
6
 
7
- `archik upgrade --migrate` already ran the **deterministic** migration:
8
- it archived the old project, moved files into the current layout,
9
- validated, and advanced `.archik/.version`. It then flagged the parts
10
- that need **judgment** — usually: *the project has an architecture but no
11
- use cases / sequence diagrams.* Your job is to back-fill those, grounded
12
- in **both** the current model and the **archived original**.
7
+ `archik migrate` (or `archik upgrade --migrate`, which runs it through
8
+ the newly installed version) already ran the **deterministic** migration:
9
+ it archived the old project, ran each pending step, validated, and
10
+ advanced `.archik/.version`. The current steps are:
13
11
 
14
- The deterministic steps are done. Do NOT redo them. You author the
15
- missing artifacts; `archik validate` is your gate.
12
+ - **#1** — move a legacy root `architecture.archik.yaml` into
13
+ `.archik/main.archik.yaml`.
14
+ - **#3** — strip retired node fields (`stereotype`, `seqFiles`) from the
15
+ model files.
16
+ - **#4** — move retired use-case, sequence, actor, alpha and trace files
17
+ to `.archik/retired/`, strip retired fields from pending suggestions,
18
+ and flag code, CI and scripts that still use removed features.
16
19
 
17
- ## CLI-only for architecture; direct-write for the Jacobson files
20
+ (#2, the old use-case back-fill, is retired and never runs.)
18
21
 
19
- Interact with the architecture diagram only through `npx archik`. Actors,
20
- use cases, and sequence diagrams are **direct-write** files (no sidecar) —
21
- author them with `Write`, then `npx archik validate`. Never edit
22
- `.archik/main.archik.yaml` by hand. **Never delete `.archik.archive/`** —
23
- it is the developer's only copy of the pre-migration project.
22
+ The deterministic steps are done. Do NOT redo them. Your job is to check
23
+ the result against the **archived original** and fix anything the
24
+ migrator printed as needing judgment. `archik validate` is your gate.
25
+
26
+ ## CLI-only for architecture
27
+
28
+ Interact with the architecture diagram only through `npx archik`. Never
29
+ edit `.archik/main.archik.yaml` by hand — changes go through
30
+ `suggest set` → `accept`. **Never delete `.archik.archive/`** — it is the
31
+ developer's only copy of the pre-migration project.
24
32
 
25
33
  ## Steps
26
34
 
27
- 1. **See exactly what's missing.** The migrator's `needsJudgment` hint is
28
- printed once and not re-derivable, so check the project directly:
29
- ```bash
30
- npx archik q usecases # empty → use cases need back-filling
31
- npx archik q actors # empty → actors needed first (use cases reference them)
32
- npx archik q sequences # which flows already have a seq diagram
33
- ```
35
+ 1. **Read the migrator's output.** Any `ⓘ` line it printed is a task for
36
+ you. If it printed none, the steps below are a quick check only.
37
+ The usual ones from 0.19 and older:
38
+ - **moved N retired files to `.archik/retired/`** — tell the user
39
+ they are kept only as history. Ask before deleting them. If a use
40
+ case explains *why* a structure exists, offer to capture that as a
41
+ decision record with the next `/archik:suggest` touching that area.
42
+ - **pending suggestion … has no decision record** — read it with
43
+ `npx archik suggest show`, then either re-stage it with a decision
44
+ record (`/archik:suggest`) or ask the user to reject it.
45
+ - **code imports `archik/trace`** — the recorder is gone. Remove the
46
+ `trace(...)` calls and the import from those test files; keep the
47
+ tests' real assertions. Run the tests afterwards.
48
+ - **workflow uses `trace-fail-on`** — replace it with
49
+ `smells-fail: true` (or drop it). On existing code, offer
50
+ `npx archik smells --update-baseline` first so CI fails only on
51
+ new smells.
52
+ - **package.json scripts call a removed command** — remove the
53
+ script or replace it (`archik smells`, `archik drift`).
34
54
 
35
- 2. **Read the archived original — this is the migration's whole point.**
36
- Find the newest archive and read the old project's intent (descriptions,
37
- any notes, the old structure) so the back-fill reflects what the
38
- developer actually built, not a generic guess:
55
+ 2. **Find the archived original.**
39
56
  ```bash
40
57
  ls -t .archik.archive/ # newest timestamp dir is the pre-migration copy
41
58
  ```
42
59
  Read the files under that dir with the `Read` tool (the archive is a
43
60
  plain backup, not a live archik doc — reading it directly is correct).
61
+ Note any old use case, sequence, or stereotype files there: their
62
+ content is no longer modelled. Do not recreate them.
44
63
 
45
- 3. **Ground the use cases in the current model.** Combine the archive's
46
- intent with the live structure:
47
- ```bash
48
- npx archik q stats
49
- npx archik q list
50
- npx archik q edges
51
- ```
52
-
53
- 4. **Author actors first** (if `q actors` was empty). Use cases reference
54
- actors by id, and validate rejects a use case whose `primaryActor`
55
- isn't in the actor index. Direct-write `.archik/actors.archik.actors.yaml`
56
- (schema: `npx archik schema actors`), then `npx archik validate`.
57
-
58
- 5. **Author one use case per real flow.** Direct-write
59
- `.archik/usecases/<id>.archik.uc.yaml` (schema: `npx archik schema uc`).
60
- Mark each slice `status: proposed` and give it `tests:` paths only if
61
- those files exist on disk — otherwise omit `tests` (active slices
62
- require on-disk tests). Validate after each:
63
- `npx archik validate .archik/main.archik.yaml`.
64
-
65
- 6. **Author a sequence diagram per primary slice.** Direct-write
66
- `.archik/<usecase>.<slice>.archik.seq.yaml` (schema: `npx archik schema seq`).
67
- Every participant `nodeId` must be a real node; add a `realizes` block
68
- AND point the slice's `realization.seqFile` back at the file
69
- (bidirectional). Add the seq to each participating node's `seqFiles`
70
- via the normal `suggest set` → `accept` workflow.
71
-
72
- 7. **Verify and report.** Then propose the natural next step (write the
73
- tests the slices name, flip them to `active`), don't end on "done":
64
+ 3. **Check the live model.**
74
65
  ```bash
75
66
  npx archik validate .archik/main.archik.yaml
76
- npx archik trace
67
+ npx archik q stats
77
68
  npx archik drift
69
+ npx archik smells
78
70
  ```
71
+ If `validate` reports `unrecognized key … removed in archik 0.20`,
72
+ the migration did not run with the new version — run
73
+ `npx archik migrate` and check again.
74
+
75
+ 4. **Fix gaps through the normal workflow.** If drift or the archive
76
+ shows structure the model misses (a node, an edge, a `parentId`
77
+ container), stage it with `/archik:suggest`. Don't bulk-restructure.
79
78
 
80
79
  ## Done when
81
80
 
82
- `archik validate` is clean and `archik q usecases` lists the back-filled
83
- use cases, each primary slice realising a sequence diagram. The archive
84
- stays untouched as the developer's rollback.
81
+ `archik validate` is clean, every `ⓘ` line from the migrator is
82
+ handled, and you proposed the natural next step (fix drift, cut a folder
83
+ loop that `smells` found). The archive stays untouched as the
84
+ developer's rollback.
@@ -35,8 +35,9 @@ Never `Read`/`Write`/`Edit` files under `.archik/`.
35
35
  No feedback signal = no evolution loop; help them find one first.
36
36
 
37
37
  3. **Ground in the current diagram** (`npx archik q stats`, `q list`).
38
- If the project is empty, model the *base system* first — actors,
39
- then one use case to ship, per the normal archik opening move.
38
+ If the project is empty, model the *base system* first — the
39
+ smallest structure for one thing to ship, per the normal archik
40
+ opening move.
40
41
 
41
42
  4. **Map the idea onto the loop.** For each stage, name the concrete
42
43
  component in THEIR system:
@@ -54,12 +55,12 @@ Never `Read`/`Write`/`Edit` files under `.archik/`.
54
55
  (stages the blueprint as `status: proposed` nodes), then refine
55
56
  ids/names with a follow-up `suggest set`.
56
57
  - Tailored: author the full end-state and stage via
57
- `npx archik suggest set --note '…' - <<'YAML' … YAML`.
58
+ `npx archik suggest set --note '…' - <<'YAML' … YAML`, with a
59
+ decision record under `metadata.suggestion.decision` (required).
58
60
 
59
- 6. **Wire the requirements.** Author a use case for the loop itself
60
- (`/archik:usecase` conventions): slices like "corrections are
61
- recorded", "insights become proposals", "approved change applies",
62
- each naming test paths.
61
+ 6. **Wire the tests.** Name one test per loop step: "corrections are
62
+ recorded", "insights become proposals", "approved change applies".
63
+ Add them to the build plan after accept.
63
64
 
64
65
  7. **Hand over.** Show the canvas URL, summarize which patterns you
65
66
  used and why, and point at `npx archik evolution enable` if they
package/commands/spawn.md CHANGED
@@ -87,30 +87,12 @@ archik suggest set` stages it.
87
87
  - **Frontends**: `apps/web`, `apps/mobile`, `client/`,
88
88
  `packages/ui` apps that ship a UI → `frontend`.
89
89
 
90
- 5. **Choose the kind and ECB stereotype for each node.** Default
90
+ 5. **Choose the kind for each node.** Default
91
91
  kind: `service`. Use the taxonomy from the skill — `function`
92
92
  for serverless, `worker` for background consumers, `agent` for
93
93
  LLM-driven agents, etc. When unsure, pick the closest fit and
94
94
  add a `notes:` entry explaining the inference.
95
95
 
96
- For every node that faces a user or external system, also infer
97
- its ECB `stereotype`:
98
- - `stereotype: boundary` — accepts requests from actors / external
99
- systems: API handlers, gateways, adapters, webhook endpoints,
100
- BFF layers. Rule of thumb: the first thing an actor touches.
101
- - `stereotype: control` — orchestrates use-case logic: services
102
- that coordinate domain objects, use-case handlers, workflow
103
- engines. Rule of thumb: knows *what* to do but delegates *how*.
104
- - `stereotype: entity` — stores or represents domain data:
105
- repositories, domain models, DB-backed modules, caches.
106
- Rule of thumb: knows the data and its invariants.
107
-
108
- If a node's role is purely infrastructure (`database`, `queue`,
109
- `external`, `cloud`, etc.) or genuinely ambiguous, omit
110
- `stereotype` — don't guess. The field is optional and the
111
- validator only enforces ECB transition rules on seq diagrams
112
- that carry a `realizes` block.
113
-
114
96
  6. **Attach `sourcePath` to every code-bearing node.** This is
115
97
  non-negotiable in a normal/suggested file — the validator rejects
116
98
  any `service`, `function`, `worker`, `module`, `page`, `component`,
@@ -173,6 +155,13 @@ archik suggest set` stages it.
173
155
  name: <Id> Internals
174
156
  nodes: [ ... ]
175
157
  edges: [ ... ]
158
+ metadata:
159
+ suggestion:
160
+ decision:
161
+ context: <why this split is needed>
162
+ decision: <what you chose>
163
+ alternatives: [<option not chosen>]
164
+ consequences: <what gets easier and harder>
176
165
  YAML
177
166
  # mechanical: puts sub-file on disk so the main draft's
178
167
  # archikFile: pointer validates. NOT the user's review gate
@@ -209,9 +198,21 @@ archik suggest set` stages it.
209
198
  # full proposed end-state, with archikFile pointers
210
199
  edges:
211
200
  # ...
201
+ metadata:
202
+ suggestion:
203
+ decision:
204
+ context: <what the source tree shows and why it is split this way>
205
+ decision: <what you chose>
206
+ alternatives: [<option not chosen>]
207
+ consequences: <what gets easier and harder>
212
208
  YAML
213
209
  ```
214
210
 
211
+ Every draft needs its decision record — `suggest set` refuses
212
+ one without it. For a spawn, the context is what the source
213
+ tree shows; the alternatives are other ways to cut it (one
214
+ flat file, a different grouping).
215
+
215
216
  c. If `suggest set` reports validation errors, re-run with the
216
217
  corrected YAML. Never edit the sidecar by hand.
217
218
 
@@ -223,27 +224,24 @@ archik suggest set` stages it.
223
224
  `/archik:evolve` after accepting if you want a cleaner
224
225
  bounded-context version."
225
226
 
226
- **Offer the Jacobson-chain follow-up at the end of this step**
227
- (not after accept — you won't be there). Check what's missing
228
- before framing the offer:
227
+ **Offer a smells check at the end of this step** (not after
228
+ accept — you won't be there). Run it now so the offer is concrete:
229
229
  ```
230
- npx archik q actors
231
- npx archik q usecases
230
+ npx archik smells
232
231
  ```
233
- Then close with one of these follow-up lines, whichever fits:
234
- - No actors, diagram has boundary nodes / user-facing components:
235
- *"Once you accept, ask me to author a `*.archik.actors.yaml`
236
- — that's the starting point for use-case coverage."*
237
- - Actors exist but no use cases:
238
- *"Once you accept, ask me to stub `*.archik.uc.yaml` files for
239
- the key flows."*
240
- - Both exist already:
241
- *"Run `/archik:evolve` after accepting for ECB and coverage
242
- gap suggestions."*
243
-
244
- Do NOT author actors or use cases here — that requires the
245
- structural diagram to be accepted first and is a separate ask
246
- from the user. This note is a prompt, not an action.
232
+ If it finds folder loops or oversized files, close with:
233
+ *"Once you accept, want me to look at the folder loop between
234
+ `<a>` and `<b>`? The cheapest cut is `<file imports "specifier">`."*
235
+ If it finds none, skip this line.
236
+
237
+ Existing code almost always has some debt. Also offer the
238
+ baseline so CI can gate on *new* smells from now on: *"Want me to
239
+ save today's findings as the baseline (`npx archik smells
240
+ --update-baseline`, commit `.archik/smells-baseline.json`)? Then
241
+ `--fail-on-warn` only fails on new loops or growing files."*
242
+
243
+ Do NOT fix smells here — spawn is descriptive, and the fix is a
244
+ separate ask from the user. This note is a prompt, not an action.
247
245
 
248
246
  ## Notes
249
247
 
@@ -26,7 +26,7 @@ the contract with the user.
26
26
 
27
27
  The skill defines a 5-phase loop: **Discover → Design → Decide → Build
28
28
  → Verify**. This command covers Discover (grounding) and Design
29
- (staging the sidecar with rationale), then hands off to the user's
29
+ (staging the sidecar with its decision record), then hands off to the user's
30
30
  review and the explicit Decide gate (`/archik:accept` or
31
31
  `/archik:reject`). Don't skip clarification just because a slash
32
32
  command was typed — clarification is what makes the draft good. Don't
@@ -37,10 +37,6 @@ start Build phase here; that's gated on accept.
37
37
  0. **Frame + clarify (entering DESIGN).** Before any CLI call, restate
38
38
  the user's intent in one sentence and list 1–3 sharp clarifying
39
39
  questions if any of these are ambiguous in `$ARGUMENTS`:
40
- - **Actor + use case** — which actor initiates this? Does an
41
- existing use case cover it, or is this a new user-visible
42
- behaviour? (Check `npx archik q actors` and `q usecases` in
43
- step 2 before asking if the answer isn't obvious from the brief.)
44
40
  - **Boundary** — which existing context owns this, or is it a new
45
41
  one? (data ownership = bounded context)
46
42
  - **Sync vs async** — request/response (`http_call`) or
@@ -57,15 +53,6 @@ start Build phase here; that's gated on accept.
57
53
  don't ask questions for the sake of asking.** When in doubt, ask
58
54
  the user "you decide?" so they can defer back if they want.
59
55
 
60
- **Before the structural sidecar, check if the feature needs
61
- requirements artifacts first:**
62
- - New human-facing flow or actor? Create/update
63
- `*.archik.actors.yaml` (direct-write) before staging the sidecar.
64
- - New user-visible behaviour? Author a `*.archik.uc.yaml` under
65
- `.archik/usecases/` (direct-write) with the flow and at least one
66
- slice before staging the sidecar. The structural model references
67
- what the use case requires.
68
-
69
56
  1. **Make sure the canvas is running** so the user can review:
70
57
  ```
71
58
  npx archik status
@@ -85,23 +72,6 @@ start Build phase here; that's gated on accept.
85
72
  If `$ARGUMENTS` mentions a specific node by name, also run
86
73
  `npx archik q describe <id>` for it.
87
74
 
88
- If the change is **non-trivial** (new actor, new user-visible
89
- behaviour, boundary impact, more than one node affected) also
90
- ground in the requirements model:
91
- ```
92
- npx archik q actors
93
- npx archik q usecases
94
- ```
95
- If any use case looks related, run
96
- `npx archik q describe-usecase <id>` to see its slices and
97
- check whether the proposed change extends, modifies, or
98
- introduces a UC — that determines whether you need to update
99
- a `*.archik.uc.yaml` before staging the structural sidecar.
100
-
101
- If step 0 already determined the change is trivially small
102
- (one node, one edge, no boundary or UC impact), skip the
103
- actor/UC queries and go straight to step 3.
104
-
105
75
  3. **Lock in the schema.** Run this before drafting any YAML —
106
76
  the prose in this file describes the workflow, not the field
107
77
  shapes. The CLI is the schema:
@@ -135,18 +105,6 @@ start Build phase here; that's gated on accept.
135
105
  not just its kind or name. Empty / missing descriptions are
136
106
  rejected by the validator.
137
107
 
138
- **For nodes that participate in a use case flow**, add a
139
- `stereotype` field to classify their role in the ECB model:
140
- - `stereotype: boundary` — accepts requests from actors / external
141
- systems (adapters, gateways, API handlers)
142
- - `stereotype: control` — orchestrates the use case logic (services,
143
- use-case handlers, orchestrators)
144
- - `stereotype: entity` — stores or represents domain data (repos,
145
- domain models, DB-backed modules)
146
-
147
- The validator enforces ECB transition rules on seq diagrams that
148
- carry a `realizes` block — tag the nodes now so the rules can fire.
149
-
150
108
  ```bash
151
109
  npx archik suggest set --note "$ARGUMENTS" - <<'YAML'
152
110
  version: "1.0"
@@ -155,23 +113,51 @@ start Build phase here; that's gated on accept.
155
113
  # full proposed end-state — every node, not just the delta
156
114
  edges:
157
115
  # full proposed end-state — every edge, not just the delta
116
+ metadata:
117
+ suggestion:
118
+ decision:
119
+ context: <the problem and the forces — facts, not the solution>
120
+ decision: <what you chose, 1–2 sentences>
121
+ alternatives:
122
+ - <a real option you weighed and did not choose>
123
+ consequences: <what gets easier AND what gets harder>
124
+ # crossCutting: # REQUIRED when the change adds data, an
125
+ # security: ... # outside system or public traffic
126
+ # observability: ...
127
+ # rollback: ...
128
+ # supersedes: ["0003"] # only when this reverses an earlier record
158
129
  YAML
159
130
  ```
160
131
 
132
+ The decision record is required — `suggest set` refuses a draft
133
+ without it, and accept writes it to
134
+ `.archik/decisions/NNNN-<slug>.md`. Before writing it, read the
135
+ past records for the area (`ls .archik/decisions/`, they are plain
136
+ markdown). If your change reverses one, list it in `supersedes`.
137
+
138
+ `suggest set` prints whether the change is a **one-way door** (hard
139
+ to undo: a new data store, queue/stream, external system,
140
+ gateway/auth/cdn, cloud or LLM node, a new edge to an external
141
+ system, a new top-level module, a removal, a boundary move) or a
142
+ **two-way door**. If it adds data, an outside system or public
143
+ traffic it refuses the draft until `crossCutting` says how it is
144
+ **secured** (who can reach it, secrets, data exposure),
145
+ **observed** (the signal that shows it working or failing) and
146
+ **rolled back** (how to undo it safely). Write real answers, not
147
+ placeholders — the plan must later land what you promise here.
148
+
161
149
  If the command exits non-zero, re-run with the corrected YAML.
162
150
  Never write a draft file under `.archik/` and never edit the
163
151
  sidecar directly.
164
152
 
165
- 5. **Narrate the design rationale** in 2–4 short bullets before
166
- handing off to review. The user needs to see *why* this shape, not
167
- just *what* it is. Cover:
168
- - Which **bounded context(s)** the change touches and why those
169
- boundaries.
170
- - The **separation of concerns** — what each new node owns and why
171
- it's its own node (not folded into an existing one).
172
- - **Async vs sync** choice and the reason (cross-context coupling
173
- should default to async).
174
- - Any **alternative you rejected** and the trade-off.
153
+ 5. **Summarise the decision record** in 2–4 short bullets before
154
+ handing off to review — the same content the record holds, so the
155
+ user can judge the *why* next to the diagram (the canvas also shows
156
+ it under **Why** on the review banner). Make sure it covers:
157
+ - Which **boundaries** the change touches and why those boundaries.
158
+ - What each new node owns and why it is its own node.
159
+ - **Async vs sync** choice and the reason.
160
+ - The **alternatives** you rejected and what the choice costs.
175
161
 
176
162
  Keep it tight — bullets, not paragraphs. The diagram does the rest.
177
163
 
@@ -183,6 +169,14 @@ start Build phase here; that's gated on accept.
183
169
  **reject** and tell me what didn't fit (boundary? relationship?
184
170
  scope? naming? composition? lifecycle?) so I can revise."
185
171
 
172
+ Match the gate to the door:
173
+ - **One-way door** — say so ("This is hard to undo: <reasons>")
174
+ and hand off the sidecar alone. The build plan comes after
175
+ accept, as its own approval gate.
176
+ - **Two-way door** — include the numbered build plan in this same
177
+ hand-off, and say that `/archik:accept` approves both the model
178
+ change and the plan.
179
+
186
180
  Do NOT pre-emptively start implementing. Wait for `/archik:accept`.
187
181
 
188
182
  ## Notes