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.
@@ -9,8 +9,9 @@ description: Use whenever .archik/main.archik.yaml or architecture.archik.yaml e
9
9
 
10
10
  - **The YAML is the source of truth.** `.archik/main.archik.yaml` (and any `*.archik.yaml` sub-files) describe the system the user is building. The browser canvas is just a stateless projection of that file.
11
11
  - **The CLI is your only interface to it.** You never read, write, or edit archik files directly. Every read goes through `npx archik q ...`; every write goes through `npx archik suggest set` → user accepts via `/archik:accept`.
12
+ - **Every change says why.** A draft carries a short decision record (context, decision, alternatives, consequences). Accept writes it to `.archik/decisions/NNNN-<slug>.md`. The diagram is the *what*; the records are the *why*. Read past records before you change a structure they explain — they are plain markdown, so reading them directly is fine (the "CLI only" rule is about the YAML model files).
12
13
  - **Two command surfaces:** the user types `/archik:*` slash commands; you run `npx archik ...` directly. They're not interchangeable — see the tables below.
13
- - **Actors first, one use case to ship.** When a user hands you a brief on a fresh project, the right opening move is *model the actors, then propose the first use case to ship* — never "let me sketch your whole system." Actors-first because you can't validate a use case without knowing who initiates it. Pick exactly one because forcing priorities into the open before any code lands is the entire point of the loop. "To ship" because the use case names its test paths from message one — slices start `status: proposed` (the tests don't exist on disk yet) and flip to `status: active` automatically when the tests land in BUILD. The project's commitments live in the YAML, not in the chat log.
14
+ - **One change to ship, not the whole system.** When a user hands you a brief on a fresh project, never say "let me sketch your whole system." Propose the smallest structure that delivers the first piece of value. New code-bearing nodes start `status: proposed` (the code doesn't exist on disk yet) and flip to `status: active` when the code lands in BUILD. The project's commitments live in the YAML, not in the chat log.
14
15
  - **Read the learned overlay at session start.** If `.archik/evolution/learned.md` exists, read it (with the Read tool — it is docs, not an archik YAML) before your first archik action and treat every note as binding guidance. Each note is a lesson this project's evolution loop gathered from real usage and a human approved. After a suggestion of yours is rejected, run `npx archik evolution reflect` — repeated rejections become proposals the user can review.
15
16
 
16
17
  ## Command surfaces
@@ -21,7 +22,7 @@ These are the user's entry points. They're triggered by the user typing `/archik
21
22
 
22
23
  | Slash command | What the user is asking for |
23
24
  | --------------------------------- | ----------------------------------------------------------------- |
24
- | `/archik:bootstrap` | **Start here on a new project.** Detect state (fresh / has-code / already-modelled) and route to the right next action — ask for a brief, suggest `/archik:spawn`, or surface trace status. |
25
+ | `/archik:bootstrap` | **Start here on a new project.** Detect state (fresh / has-code / already-modelled) and route to the right next action — ask for a brief, suggest `/archik:spawn`, or surface drift and smells. |
25
26
  | `/archik:spawn` | Mirror the source tree as a first-pass diagram (descriptive) |
26
27
  | `/archik:evolve` | Propose a cleaner bounded-context refactor (prescriptive) |
27
28
  | `/archik:suggest <…>` | Apply one feature-sized change from a description (targeted) |
@@ -29,10 +30,6 @@ These are the user's entry points. They're triggered by the user typing `/archik
29
30
  | `/archik:dev` | Open the live canvas |
30
31
  | `/archik:accept` | Apply the pending sidecar suggestion |
31
32
  | `/archik:reject` | Discard the pending sidecar suggestion |
32
- | `/archik:actor <id>` | Add or update an actor in the actor index (direct-write) |
33
- | `/archik:usecase <name>` | Author a use case — flows + slices + tests (direct-write) |
34
- | `/archik:trace` | Coverage matrix + concrete next action |
35
- | `/archik:alpha [show \| promote]` | Read or move project alphas with a machine-checked criteria |
36
33
  | `/archik:self-evolving <idea>` | Design a self-evolving architecture for the user's idea, using the pattern library |
37
34
 
38
35
  The full protocol for each lives at `commands/<name>.md` in the repo (or `.claude/commands/archik/<name>.md` once installed in a project). Follow it when invoked.
@@ -48,22 +45,16 @@ These are the verbs you reach for during the loop. Default to `npx archik` (no g
48
45
  | Look up one node | `npx archik q describe <id>` |
49
46
  | Find dependencies / impact | `npx archik q deps \| dependents \| impact <id>` |
50
47
  | See one node + its neighbors | `npx archik q neighbors <id> [--depth N]` |
51
- | List use cases (filter by actor) | `npx archik q usecases [--actor <id>]` |
52
- | Describe one use case | `npx archik q describe-usecase <id>` |
53
- | List actors | `npx archik q actors` |
54
- | List concrete run traces | `npx archik q traces [--usecase <id>] [--slice <id>]` |
55
- | Use case coverage matrix | `npx archik trace [--json] [--fail-on partial\|none]` |
56
48
  | Map changed files onto the model | `npx archik affected [--since <ref>] [--files <list>] [--json]` |
57
- | Run the tests a change touches | `npx archik affected --run [--runner '<cmd>']` |
58
49
  | Verify edges against the code | `npx archik drift --edges [--json]` |
59
- | Alpha state snapshot | `npx archik alpha show [--json]` |
60
- | Promote / demote an alpha state | `npx archik alpha promote\|demote <alpha> <state>` |
61
50
  | Validate a file | `npx archik validate <path>` |
62
51
  | Spot over-complex files / hubs | `npx archik complexity [--fail-on-warn]` |
52
+ | Find folder loops / oversized files | `npx archik smells [dir] [--json] [--fail-on-warn]` |
53
+ | Accept today's smells as known debt | `npx archik smells --update-baseline` (commit `.archik/smells-baseline.json`) |
63
54
  | Stage a proposed change | `npx archik suggest set --note '…' - <<'YAML' … YAML` |
64
55
  | Show / accept / reject pending | `npx archik suggest show \| accept \| reject` |
65
56
  | Render an SVG | `npx archik render --out diagram.svg` |
66
- | Render a slice / drop weak edges | `npx archik render --focus <id>` / `--hide-structural` |
57
+ | Render one area / drop weak edges | `npx archik render --focus <id>` / `--hide-structural` |
67
58
  | Diff two files or git refs | `npx archik diff a.yaml b.yaml` / `npx archik diff origin/main` |
68
59
  | Detect drift vs source tree | `npx archik drift` |
69
60
  | Open the live canvas (foreground) | `npx archik dev` |
@@ -80,12 +71,6 @@ You MUST NOT use `Read`, `Write`, or `Edit` against any file under `.archik/`, a
80
71
 
81
72
  If `npx archik` is unreachable (offline, sandboxed, missing), STOP and tell the user. Do NOT fall back to reading or editing YAML by hand.
82
73
 
83
- **Exception:** four file types have **no sidecar workflow** — create or edit them directly with `Write` / `Edit`, then validate via `npx archik validate`:
84
- - `*.archik.seq.yaml` — sequence diagrams (see "Sequence diagrams" below)
85
- - `*.archik.actors.yaml` — actor definitions (see "Actors" below)
86
- - `*.archik.uc.yaml` — use cases (see "Use cases and slices" below)
87
- - `*.archik.alphas.yaml` — Essence alpha snapshot (see "Alpha state" below)
88
-
89
74
  ## The engineering loop (how archik fits into delivering work)
90
75
 
91
76
  Every structural change runs the loop. Don't skip phases; don't silently retry on rejection; don't paper over a wrong design mid-build — go back.
@@ -96,9 +81,9 @@ Every structural change runs the loop. Don't skip phases; don't silently retry o
96
81
  └─────┬──────┘ exists.
97
82
  │
98
83
  ┌─────▼──────┐ Frame intent in one line + 1–3 sharp clarifying Qs.
99
- │ DESIGN │ Stage sidecar (`suggest set`) with rationale:
100
- │ │ bounded contexts, sync vs async, composition,
101
- └─────┬──────┘ alternatives rejected. ◄── reject + reason ──┐
84
+ │ DESIGN │ Stage sidecar (`suggest set`) with its decision
85
+ │ │ record: context, decision, alternatives,
86
+ └─────┬──────┘ consequences. ◄── reject + reason ──┐
102
87
  │ │
103
88
  ┌─────▼──────┐ Canvas diff: accept | reject (why?) | revise. │
104
89
  │ DECIDE │ ───────────────────────────────────────────────────►┤
@@ -117,11 +102,11 @@ Every structural change runs the loop. Don't skip phases; don't silently retry o
117
102
 
118
103
  | Phase | Driver | Tool you reach for |
119
104
  | -------- | ------------- | --------------------------------------------------- |
120
- | Discover | Claude | `npx archik q ...` + `q usecases` + `q actors` + `npx archik affected` + `ls` |
121
- | Design | Claude → User | actors / uc files (direct-write) + sidecar via `suggest set` |
122
- | Decide | User | `/archik:accept` or `/archik:reject` (HITL gate) |
123
- | Build | Claude → User | numbered plan (HITL approval), then small commits |
124
- | Verify | Claude | `npx archik validate` + `archik trace` + tests + `drift` + SVG regen |
105
+ | Discover | Claude | `npx archik q ...` + `npx archik affected` + `npx archik smells` + `ls` + past records in `.archik/decisions/` |
106
+ | Design | Claude → User | sidecar via `suggest set`, with its decision record |
107
+ | Decide | User | `/archik:accept` or `/archik:reject` (HITL gate) — one-way doors alone, two-way doors together with the plan |
108
+ | Build | Claude → User | numbered plan (own HITL approval for one-way doors), then small commits |
109
+ | Verify | Claude | `npx archik validate` + tests + `drift` + `smells` + SVG regen |
125
110
 
126
111
  **Two non-obvious feedback edges:**
127
112
 
@@ -189,9 +174,37 @@ edges:
189
174
  from: payments-worker
190
175
  to: order-events
191
176
  relationship: subscribes
177
+ metadata:
178
+ suggestion:
179
+ decision:
180
+ context: Orders-api charges Stripe inline, so a slow Stripe call blocks checkout and a Stripe outage fails orders.
181
+ decision: Move charging to a payments worker that subscribes to order.placed on the order-events stream.
182
+ alternatives:
183
+ - Keep the inline call with a shorter timeout and retries
184
+ - Call a payments service synchronously over HTTP
185
+ consequences: Checkout no longer waits on Stripe; payment becomes eventually consistent, so the UI must show a "payment pending" state.
186
+ crossCutting:
187
+ security: The worker alone holds the Stripe key (secret store); events carry order ids, not card data.
188
+ observability: Consumer lag and failed-charge count on the payments dashboard, alert on lag over 5 minutes.
189
+ rollback: A flag switches checkout back to the inline call; the stream is additive.
192
190
  YAML
193
191
  ```
194
192
 
193
+ **The decision record is required** — `suggest set` refuses a draft without it, and accept writes it to `.archik/decisions/`. Write it for the reader who arrives in a year:
194
+
195
+ - **context** — the problem and the forces (load, failure modes, team limits). Facts, not the solution.
196
+ - **decision** — what you chose, in one or two sentences.
197
+ - **alternatives** — real options you weighed and did not choose. At least one. "Do nothing" counts when it was a real option.
198
+ - **consequences** — what gets easier AND what gets harder. A record with only upsides is not finished.
199
+ - **crossCutting** — required when the change adds data, an outside system or public traffic (the CLI tells you). **security**: who can reach it, secrets, data exposure. **observability**: the signal that shows it working or failing. **rollback**: how to undo it safely. Real answers — the build plan must land them.
200
+ - **supersedes** (optional) — record numbers this one replaces, e.g. `["0003"]`. Old records are never edited.
201
+
202
+ **One-way vs two-way doors.** `suggest set` and `suggest show` label each change. A **one-way door** (hard to undo) adds a data store, queue/stream, external system, gateway/auth/cdn, cloud or LLM node, a new edge to an external system or a top-level module, or removes a built node, or moves one to another parent. Hand it off alone and say why it is hard to undo; the build plan gets its own approval after accept. A **two-way door** is everything else — show the build plan in the same hand-off, and one `/archik:accept` approves both. Never skip review of a one-way door to save time.
203
+
204
+ **Model only what you know.** On a new project, model the first milestone in detail and the rest as coarse `proposed` module placeholders; detail each area when its milestone starts.
205
+
206
+ For a mechanical change (flip `proposed → active` after code lands), keep it short: context = what landed, decision = mark it active, alternative = keep it proposed until deploy, consequence = drift now checks it.
207
+
195
208
  The CLI parses, schema-validates, checks cross-file references, stamps `metadata.suggestion`, and atomically writes the sidecar. If it exits non-zero, the error includes a hint pointing at the wrong field — fix the heredoc and re-run. **Never edit the sidecar by hand.**
196
209
 
197
210
  ```bash
@@ -205,14 +218,16 @@ The CLI parses, schema-validates, checks cross-file references, stamps `metadata
205
218
  ```bash
206
219
  npx archik validate .archik/main.archik.yaml # schema + cross-file + constraints
207
220
  npx archik drift # diagram vs source tree
208
- npx archik affected --json # what did this change touch? which tests?
221
+ npx archik affected --json # what did this change touch? who depends on it?
222
+ npx archik smells # folder loops + oversized files, from the code
223
+ # (with a baseline, only NEW findings count)
209
224
  npx archik render --out docs/architecture.svg # if the project commits an SVG
210
225
  ```
211
226
 
212
227
  `affected` is also the right opener in DISCOVER when work starts from
213
228
  an existing branch: `npx archik affected --since origin/main --json`
214
- tells you which nodes, use case slices, and tests the branch already
215
- touches — ground your plan in that instead of re-deriving it.
229
+ tells you which nodes, and which dependents of those nodes, the branch
230
+ already touches — ground your plan in that instead of re-deriving it.
216
231
 
217
232
  ### 4. Sub-architecture (a brand-new `archikFile`)
218
233
 
@@ -227,6 +242,9 @@ version: "1.0"
227
242
  name: Payments internals
228
243
  nodes: [ ... ]
229
244
  edges: [ ... ]
245
+ metadata:
246
+ suggestion:
247
+ decision: { context: ..., decision: ..., alternatives: [...], consequences: ... }
230
248
  YAML
231
249
  npx archik suggest accept .archik/payments.archik.yaml
232
250
 
@@ -241,51 +259,20 @@ nodes:
241
259
  ... (every other node)
242
260
  edges:
243
261
  ... (every edge)
262
+ metadata:
263
+ suggestion:
264
+ decision: { context: ..., decision: ..., alternatives: [...], consequences: ... }
244
265
  YAML
245
266
  ```
246
267
 
247
268
  When you auto-accept the sub-file, **narrate the rationale** so the user can tell you're not bypassing their `/archik:accept` review on the main draft. The main draft is always left as a sidecar.
248
269
 
249
- ### 5. Sequence diagrams (direct-write, no sidecar)
250
-
251
- Sequence diagrams live in `.archik/` as `*.archik.seq.yaml` files and document a specific runtime flow at the call level. They are the **only** archik file mode you write directly.
252
-
253
- ```bash
254
- # 1. Write the seq file directly with the Write tool
255
- # 2. Validate (this also checks every seqFiles reference)
256
- npx archik validate .archik/main.archik.yaml
257
-
258
- # 3. Link it from an architecture node via `suggest set` (sidecar workflow)
259
- npx archik suggest set --note "link login-flow seq diagram to api-gateway" - <<'YAML'
260
- version: "1.0"
261
- name: My Architecture
262
- nodes:
263
- - id: api-gateway
264
- ...
265
- seqFiles:
266
- - .archik/login-flow.archik.seq.yaml
267
- ... (every other node)
268
- edges: [ ... ]
269
- YAML
270
-
271
- # 4. Render to SVG (optional, useful for CI / docs)
272
- npx archik render --seq .archik/login-flow.archik.seq.yaml --out login-flow.svg
273
- ```
274
-
275
- `seqFiles` is a non-empty array of relative paths from project root. The validator checks each path exists.
276
-
277
- The seq schema (UML subset) is documented at the bottom of this file under "Sequence diagram schema reference".
278
-
279
270
  ## File modes — two modes, picked by filename
280
271
 
281
272
  | Suffix | Mode | When to use |
282
273
  | --------------------------- | ------------- | ----------------------------------------------------------------------------------- |
283
274
  | `*.archik.yaml` | **normal** | The canonical architecture of code that exists. |
284
275
  | `*.archik.suggested.yaml` | **suggested** | A pending change to a normal file. Owned by `suggest set`. Becomes normal on accept. |
285
- | `*.archik.seq.yaml` | **sequence** | A runtime flow diagram. Direct-write. No sidecar. |
286
- | `*.archik.actors.yaml` | **actors** | Who acts on the system (human / external-system / time / device). Direct-write. |
287
- | `*.archik.uc.yaml` | **use case** | One use case: flows + slices + test paths. Lives under `.archik/usecases/`. Direct-write. |
288
- | `*.archik.alphas.yaml` | **alphas** | Project-wide Essence alpha state snapshot. Direct-write. |
289
276
 
290
277
  There is no separate "discussion" file mode. Greenfield / exploratory work is expressed via `status: proposed` on the affected nodes and edges (see Lifecycle below). The diagram stays canonical.
291
278
 
@@ -325,18 +312,6 @@ Both **nodes and edges** carry an optional `status`. Same enum, same defaults, s
325
312
 
326
313
  For edges, `status: proposed` expresses "this dependency is planned" (e.g. *"orders-api will start subscribing to `payments.completed` next sprint"*). `archik drift` and the validator both respect lifecycle so proposed nodes don't trigger missing-source warnings before they're built.
327
314
 
328
- ### Node stereotype — ECB classification
329
-
330
- Nodes that participate in a use case flow may carry an optional `stereotype` field:
331
-
332
- ```yaml
333
- stereotype: boundary # accepts requests from actors / external systems
334
- stereotype: control # orchestrates; implements the use case logic
335
- stereotype: entity # stores data; domain model
336
- ```
337
-
338
- The validator enforces the ECB transition rules on **seq diagrams that carry a `realizes` block**: actors call boundaries, boundaries call controls, controls call entities or other controls. Direct actor→entity or entity→boundary messages are errors. Untagged nodes are silently skipped so adoption is incremental.
339
-
340
315
  ### Node owner — who to talk to
341
316
 
342
317
  Nodes may carry `owner: <team-or-person>` (free text — match the
@@ -373,7 +348,7 @@ constraints:
373
348
  maxDependencies: { node: { kind: service }, max: 6 }
374
349
  ```
375
350
 
376
- - Selectors: `{ id?, kind?, parent?, notParent?, stereotype? }` — all
351
+ - Selectors: `{ id?, kind?, parent?, notParent? }` — all
377
352
  set fields must match; `parent`/`notParent` walk the whole parentId
378
353
  chain.
379
354
  - Exactly one rule per constraint: `forbidEdge`, `requireOwner`,
@@ -405,10 +380,10 @@ Run a candidate through this checklist before staging a sidecar. Each item is a
405
380
  - **Bounded contexts.** Name the context this change belongs to. A change spanning two contexts usually means a missing third (orchestrator, port, gateway).
406
381
  - **Async at context boundaries.** Default cross-context coupling to `publishes` / `subscribes` over a stream/queue. `http_call` across contexts is allowed but should be justified (sync-required RPC, query for read-side data).
407
382
  - **Composition over sprawl.** Group related nodes under a `module` parent via `parentId`. Flat top-level lists past ~8 nodes are a smell. Run `npx archik complexity` to catch this objectively — it flags over-large files, over-stuffed containers, hub nodes, and deep nesting, each with a concrete fix.
383
+ - **No folder loops.** Dependencies between sibling folders should flow one way. Run `npx archik smells` — it reads the code (no model needed) and reports folder loops with the real `file imports "specifier"` lines as evidence, plus the cheapest import to cut. Name smells by that evidence; don't invent labels.
408
384
  - **Ports & adapters at the edge.** External integrations sit behind an `external` node, never inline in a service. Port (interface) + adapter (concrete) is preferred when the integration could swap.
409
385
  - **Public traffic → gateway/auth upstream.** Anything user-facing routes through a `gateway`/`auth` node, not directly to a service.
410
386
  - **Failure modes.** Async producers imply DLQ/retry on the consumer; `http_call` implies timeout + circuit. Don't draw the happy path alone.
411
- - **Use case participation → ECB classification.** If a node appears in any active use case slice (check `npx archik q usecases` or trace output), it needs a `stereotype: boundary | control | entity` before the seq diagram is authored. An unclassified node in a `realizes`-linked seq passes structurally but defeats ECB rule enforcement. Classify now; the validator will catch violations at seq-authoring time, not at code-review time.
412
387
  - **Lifecycle honesty.** Code-bearing node without code on disk → `status: proposed`. About to be removed → `status: deprecated`.
413
388
 
414
389
  ## Keep views small
@@ -417,7 +392,7 @@ A big model isn't read by staring at one giant map — it's read one question at
417
392
 
418
393
  - **Answer questions with a query, not the whole diagram.** "What does X talk to?" → `npx archik q neighbors X` (or `q describe X`). Don't render the full map to answer a local question.
419
394
  - **Let `complexity` tell you when to split.** Run `npx archik complexity` (advisory; `--fail-on-warn` for CI/hooks). When it flags a file or container, decompose: move a subsystem into its own `archikFile`, or group nodes under a `module` parent via `parentId`. Strict default limits — 15 nodes/file, 20 edges/file, 6 children/container, degree 6, nesting depth 3. These are hints, not blockers.
420
- - **Slice when rendering.** `npx archik render --focus <id> [--depth N]` renders only a node's neighborhood; `--hide-structural` (or `--hide-rel`/`--only-rel`) drops weak edges (`uses`, `depends_on`, `has_a`, `implements`, `extends`) so the runtime shape stands out.
395
+ - **Focus when rendering.** `npx archik render --focus <id> [--depth N]` renders only a node's neighborhood; `--hide-structural` (or `--hide-rel`/`--only-rel`) drops weak edges (`uses`, `depends_on`, `has_a`, `implements`, `extends`) so the runtime shape stands out.
421
396
  - **For humans on the canvas:** the live canvas has matching controls — collapse/expand containers, hide weak edges, and focus mode (select a node → "Focus on this node", with a depth stepper, Esc to exit). These are view-only and never change the YAML.
422
397
 
423
398
  ## When to propose, when to defer
@@ -472,211 +447,6 @@ The loop is self-contained, but these sharpen specific phases when the user has
472
447
  | | `superpowers:requesting-code-review` |
473
448
  | Verify | `superpowers:verification-before-completion` |
474
449
 
475
- ## Actors
476
-
477
- Actors live in `.archik/actors.archik.actors.yaml` (one file per project). Direct-write — no sidecar. Schema: `npx archik schema actors`.
478
-
479
- ```yaml
480
- version: "1.0"
481
- actors:
482
- - id: customer
483
- kind: human # human | external-system | time | device
484
- description: End-user buying products.
485
- goals: [place-orders, view-history] # optional free text
486
- - id: payments-gw
487
- kind: external-system
488
- description: Stripe — charges cards and issues refunds.
489
- ```
490
-
491
- Use cases reference actors by `id`. The validator rejects a use case whose `primaryActor` isn't in the actor index.
492
-
493
- ## Use cases and slices
494
-
495
- One file per use case under `.archik/usecases/<id>.archik.uc.yaml`. Direct-write — no sidecar. Schema: `npx archik schema uc`.
496
-
497
- ```yaml
498
- version: "1.0"
499
- id: place-order
500
- kind: useCase
501
- name: Place an order
502
- status: active
503
- primaryActor: customer
504
- secondaryActors: [payments-gw]
505
- goal: Customer pays for items in cart and receives confirmation.
506
- flows:
507
- basic:
508
- steps:
509
- - Customer submits cart.
510
- - System reserves inventory.
511
- - System charges payment method.
512
- - System persists order and emits OrderPlaced.
513
- alternates:
514
- - id: payment-declined
515
- branchFrom: basic.3
516
- steps: [Payment gateway returns decline, System releases inventory.]
517
- slices:
518
- - id: happy-path
519
- description: Full successful purchase.
520
- flows: [basic]
521
- tests: [tests/e2e/place-order.happy.spec.ts] # must exist on disk for active slices
522
- realization:
523
- seqFile: .archik/place-order.happy.archik.seq.yaml
524
- - id: declined
525
- description: Payment gateway declines.
526
- flows: [basic, payment-declined]
527
- tests: [tests/e2e/place-order.declined.spec.ts]
528
- ```
529
-
530
- **Validation rules:**
531
- - `primaryActor` and `secondaryActors` must resolve in the actor index.
532
- - Active slice `tests` paths must exist on disk (same discipline as `sourcePath`).
533
- - If `realization.seqFile` is set, the named seq file must exist AND carry a matching `realizes` block (bidirectional).
534
- - `flows.basic` is required; `alternates[].branchFrom` must reference an existing flow + step number.
535
-
536
- Query: `npx archik q usecases [--actor <id>]` | `npx archik q describe-usecase <id>`
537
-
538
- ## Concrete run traces
539
-
540
- A sequence diagram is the **abstract** flow (boxes and arrows, no values). A **concrete trace** is one real run of a slice with the **actual data at each step** — captured from the slice's tests and shown on the canvas as an expandable dataflow **timeline** (each step's real in/out values, expandable to the full JSON). It's the concrete counterpart to the slice's abstract seq diagram (a bound trace links to that diagram; it doesn't redraw onto it). Use it when someone asks to *see a real example of a use case running, with the data at each step*.
541
-
542
- - **Tests record it via the `archik/trace` recorder** (a zero-dep import archik ships). Add it to the slice's test:
543
- ```ts
544
- import { trace } from "archik/trace";
545
- const t = trace({
546
- useCase: "place-order",
547
- slice: "happy-path",
548
- seqFile: ".archik/place-order.happy.archik.seq.yaml", // optional → binds to the diagram
549
- });
550
- t.step({ id: "m1", from: "browser", to: "api", label: "POST /orders", in: cart, out: res });
551
- t.step({ id: "m2", from: "api", to: "db", label: "insert order", in: order });
552
- // auto-flushes on process exit → .archik/traces/place-order.happy-path.archik.trace.json
553
- ```
554
- When `seqFile` is set, `id`/`from`/`to` must match the diagram's message + participant ids (so the run is checked against the declared flow); omit `seqFile` for a standalone trace.
555
- - **Passive — archik never runs your tests.** Run them however you like (`npm test`, `archik affected --run`); the recorder writes the file, archik only reads it. The canvas shows a "Concrete run" affordance on each slice that has one.
556
- - **Query / shape:** `npx archik q traces [--usecase <id>] [--slice <id>]` lists captured runs; `npx archik schema trace` prints the schema (the file is JSON, machine-generated — never hand-author it).
557
- - **Validated:** `npx archik validate` checks each trace — its use case/slice resolves, and (when bound) its step ids + participants exist in the seq diagram; seq steps the run didn't exercise are reported informationally, not as errors.
558
-
559
- **Two different "trace"s — don't confuse them:** `npx archik trace` is the use-case **coverage matrix** (use case × slice × test × seq). **Concrete run traces** are `*.archik.trace.json` files captured by the recorder and listed by `npx archik q traces`.
560
-
561
- ## Alpha state
562
-
563
- One file per project: `<name>.archik.alphas.yaml`. Direct-write. Tracks four Essence alphas that archik can directly evidence: **stakeholders**, **requirements**, **softwareSystem**, **work**.
564
-
565
- ```yaml
566
- version: "1.0"
567
- alphas:
568
- stakeholders:
569
- state: represented # conceived | recognised | represented | involved | in-agreement | satisfied
570
- evidence: ["developer (human) + claude (external-system) in actors file"]
571
- requirements:
572
- state: acceptable # conceived | bounded | coherent | acceptable | addressed | fulfilled
573
- note: "All active slices test-backed; rejected slice still needs a realization seq."
574
- softwareSystem:
575
- state: usable # architecture-selected | demonstrable | usable | ready | operational | retired
576
- work:
577
- state: under-control # initiated | prepared | started | under-control | concluded | closed
578
- ```
579
-
580
- Manage states with:
581
- ```bash
582
- npx archik alpha show # verification badges: ✓ verified | ✗ over-claimed | ? subjective
583
- npx archik alpha promote requirements addressed # runs machine check before writing
584
- npx archik alpha demote softwareSystem usable # no check on demote
585
- ```
586
-
587
- The validator checks machine-checkable states (e.g. `requirements.acceptable` requires every active slice to have on-disk tests). Over-claimed states are flagged `✗` — downgrade or fix the artifacts.
588
-
589
- ## Sequence diagram schema reference
590
-
591
- ```yaml
592
- version: "1.0" # required, literal
593
- name: "Login flow" # required, non-empty
594
- description: "..." # optional
595
-
596
- realizes: # optional — links this seq to a use case slice
597
- useCase: place-order # use case id (must exist in .archik/usecases/)
598
- slice: happy-path # slice id within that use case
599
- # validator enforces bidirectional integrity:
600
- # the slice's realization.seqFile must name THIS file
601
-
602
- participants: # required, at least one
603
- - id: browser # participant ref id (used in steps)
604
- nodeId: frontend # architecture node id this participant maps to
605
- # node's kind drives the participant header icon/color
606
- label: Browser # optional display label (defaults to nodeId)
607
- status: proposed # optional — proposed | active | deprecated
608
-
609
- steps: # ordered list of messages, notes, groups
610
- # --- message ---
611
- - type: message
612
- id: m1
613
- from: browser # participant id
614
- to: api # participant id
615
- label: POST /login
616
- arrow: sync # sync | async | return | create | destroy
617
- activate: true # optional — draws activation box on receiver
618
- status: proposed # optional
619
-
620
- # --- note ---
621
- - type: note
622
- id: n1
623
- position: over # over | left_of | right_of
624
- participants: [api] # list of participant ids the note spans
625
- text: "JWT issued here"
626
- status: proposed # optional
627
-
628
- # --- group (alt / opt / loop / par / break / ref) ---
629
- - type: group
630
- id: g1
631
- kind: alt
632
- condition: "[authenticated]" # optional — shown in group header
633
- branches:
634
- - label: "[success]" # optional branch label
635
- steps:
636
- - type: message
637
- id: m2
638
- from: api
639
- to: browser
640
- label: "200 OK"
641
- arrow: return
642
- - label: "[failure]"
643
- steps:
644
- - type: message
645
- id: m3
646
- from: api
647
- to: browser
648
- label: "401 Unauthorized"
649
- arrow: return
650
- status: proposed # optional
651
-
652
- # --- ref group (drill-down to another seq file) ---
653
- - type: group
654
- id: g2
655
- kind: ref
656
- label: "checkout flow"
657
- seqFile: .archik/checkout-flow.archik.seq.yaml
658
- # makes the frame clickable in the UI
659
- branches: [] # required (can be empty for ref)
660
- ```
661
-
662
- **Arrow types:**
663
-
664
- | arrow | meaning |
665
- | --------- | ----------------------------------------------------------- |
666
- | `sync` | synchronous call (solid line, filled arrowhead) |
667
- | `async` | fire-and-forget (solid line, open arrowhead) |
668
- | `return` | return value (dashed line, open arrowhead) |
669
- | `create` | object creation (dashed line, filled arrowhead + `«create»`) |
670
- | `destroy` | object destruction (solid line, × marker at target) |
671
-
672
- **Group kinds:** `alt` (conditional), `opt` (optional), `loop`, `par` (parallel), `break`, `ref` (reference)
673
-
674
- **Validator checks for seq diagrams:**
675
- - All seq files referenced in `seqFiles` exist on disk.
676
- - Each seq file parses as valid YAML and matches the seq schema.
677
- - Participant `nodeId` fields reference real node ids from the architecture.
678
- - No duplicate step ids within a seq file.
679
-
680
450
  ## Full CLI reference
681
451
 
682
452
  Run `npx archik <cmd> --help` for the per-command surface.
@@ -684,48 +454,33 @@ Run `npx archik <cmd> --help` for the per-command surface.
684
454
  ```
685
455
  npx archik schema # the document shape (start here when authoring)
686
456
  --json # structured shape for piping into jq
687
- --seq # seq diagram schema instead of arch schema
688
- uc # use case schema
689
- actors # actors schema
690
- trace # concrete run-trace schema
691
457
 
692
458
  npx archik q describe <id> | deps <id> | dependents <id>
693
459
  list | edges | impact <id> | stats
694
460
  neighbors <id> [--depth <n>] # node + everything within N hops (default 1)
695
- sequences [--node <id>] # list seq diagrams; --node filters to flows involving a node
696
- usecases [--actor <id>] # list use cases; filter by actor
697
- describe-usecase <id> # one use case in detail
698
- actors # list actors
699
- traces [--usecase <id>] [--slice <id>] # concrete run traces (.archik.trace.json)
700
461
  --json # stable machine-readable shape
701
462
 
702
- npx archik trace [--json] # coverage matrix: use case × slice × test × seq × ECB
703
- --use-case <id> # filter to one use case
704
- --actor <id> # filter by actor
705
- --status active|proposed|deprecated
706
- --coverage full|partial|none
707
- --fail-on partial|none # exit 1 for CI gates
708
-
709
- npx archik alpha show [--json] # alpha state snapshot with verification badges
710
- alpha promote <alpha> <state> [--note <text>] # runs machine check first
711
- alpha demote <alpha> <state>
712
-
713
463
  npx archik validate <path> [--json] # schema + cross-file + governance constraints
714
464
  # prints an advisory complexity-hint count (never fails on it)
715
465
  npx archik complexity [path] [--json] # advisory report: over-large files, hub nodes, deep nesting
716
466
  [--fail-on-warn] # exit 1 if any finding (CI / pre-commit gate)
717
467
  [--max-nodes N] [--max-edges N] [--max-children N]
718
468
  [--max-degree N] [--max-depth N] # override the strict defaults
469
+ npx archik smells [dir] [--json] # folder loops + oversized files, read from TS/JS code
470
+ [--fail-on-warn] # exit 1 on findings (only NEW ones if a baseline exists)
471
+ [--update-baseline] # save today's findings to .archik/smells-baseline.json
472
+ [--baseline <file>] # use another baseline file
473
+ [--max-file-lines N] # line limit per file (default 500)
474
+ [--fail-on-warn] # exit 1 if any smell (CI gate)
719
475
  npx archik render --out diagram.svg --theme light|dark
720
- render --seq <path> --out seq.svg --theme light|dark
721
476
  render --focus <id> [--depth N] # render only a node's neighborhood
722
477
  render --hide-structural | --hide-rel <a,b> | --only-rel <a,b> # filter edges
723
478
  npx archik diff <a> [b] [--out diff.svg] [--json]
724
479
  # each side: YAML file OR git ref;
725
480
  # one arg = that ref vs working tree
726
481
  npx archik affected [--since <ref>] [--files <list>] [--json]
727
- # changed files → nodes / slices / tests
728
- [--run] [--runner '<cmd>'] # …and execute those tests
482
+ # changed files → nodes / dependents /
483
+ # model files / unmapped
729
484
  npx archik drift [--json] [--ignore <file>] # diagram vs source tree
730
485
  [--edges] # + verify edges vs the TS/JS import
731
486
  # graph (shadow / phantom edges)
@@ -735,11 +490,16 @@ npx archik otel check --graph <deps.json> [--json]
735
490
 
736
491
  npx archik suggest show [--json]
737
492
  suggest set <draft|-> # validate + stage a sidecar
738
- --note '<text>' # set metadata.suggestion.note
493
+ # (draft needs metadata.suggestion.decision)
494
+ --note '<text>' # set metadata.suggestion.note (record title)
739
495
  --main <path> # override main file detection
740
496
  --allow-orphan # permit a sidecar with no main on disk
741
497
  --json # structured output
742
- suggest accept | reject
498
+ suggest accept | reject # accept writes .archik/decisions/NNNN-*.md
499
+
500
+ npx archik migrate [--dry-run] # bring this project's archik files up to the
501
+ # installed version; if validate says a key
502
+ # was "removed in archik 0.20", run this
743
503
 
744
504
  npx archik dev | start | stop | status # canvas server lifecycle
745
505
  npx archik watch # re-render to SVG on save
package/commands/actor.md DELETED
@@ -1,89 +0,0 @@
1
- ---
2
- description: Add or update an actor in the actor index
3
- argument-hint: <actor id> [— description]
4
- ---
5
-
6
- # /archik:actor — author an entry in `*.archik.actors.yaml`
7
-
8
- The user wants you to add (or update) an actor in the project's actor
9
- index. Actors are *who* initiates use cases — humans (end users,
10
- operators, customers) or non-human systems (other services, schedulers,
11
- external APIs). The user-facing description is:
12
-
13
- **$ARGUMENTS**
14
-
15
- This slash command IS the user's confirmation. Skip "want me to add
16
- this?" and produce the change now.
17
-
18
- ## Direct-write — not the sidecar workflow
19
-
20
- Actors live in `.archik/actors.archik.actors.yaml` (one file per
21
- project, conventionally). Authored with `Write` / `Edit` directly,
22
- then validated via `npx archik validate`.
23
-
24
- ## Steps
25
-
26
- 0. **Frame.** Restate the user's intent in one sentence and ask 1–2
27
- sharp questions only if any of these are unclear:
28
- - **Actor kind** — `human` (end user / operator / customer),
29
- `external-system` (third-party service we don't own),
30
- `time` (scheduler / cron), or `device` (sensor / hardware)?
31
- - **Goals** — one short sentence per goal the actor pursues
32
- against this system. Optional but useful.
33
-
34
- Skip questions `$ARGUMENTS` already answers.
35
-
36
- 1. **Ground in current actors:**
37
- ```
38
- npx archik q actors
39
- ```
40
- If the id already exists, this is an UPDATE — read the existing
41
- entry's fields and preserve everything the user didn't ask to
42
- change. Otherwise it's a NEW addition.
43
-
44
- 2. **Lock in the schema:**
45
- ```
46
- npx archik schema actors
47
- ```
48
- Required: `id`, `kind`, `description`. Optional: `goals`.
49
-
50
- 3. **Edit the file.** If `.archik/actors.archik.actors.yaml` doesn't
51
- exist yet, `Write` a new file with the standard header. If it
52
- exists, `Edit` to add/update the one actor you're touching — do
53
- NOT rewrite the whole file unless you're consolidating.
54
-
55
- ```yaml
56
- version: "1.0"
57
- actors:
58
- - id: <kebab-id>
59
- kind: human # human | external-system | time | device
60
- description: One sentence — who they are and why they touch the system.
61
- goals:
62
- - "Verb-first short outcome they pursue."
63
- ```
64
-
65
- 4. **Validate:**
66
- ```
67
- npx archik validate
68
- ```
69
- Common failures:
70
- - Duplicate `id` across actor files
71
- - Missing `description` (required, non-empty)
72
- - `kind` not in the allowed enum
73
-
74
- 5. **Confirm inline.** Print the actor's id, kind, and description.
75
- Ask: "Looks right? Want me to author a use case (`/archik:usecase`)
76
- that has this actor as `primaryActor`?"
77
-
78
- Don't auto-proceed. Inline-review gate.
79
-
80
- ## Notes
81
-
82
- - Actors must exist BEFORE any use case can reference them. The
83
- use case validator rejects dangling `primaryActor` / `secondaryActors`
84
- references with the actor id named in the error.
85
- - The `external` node kind in the structural model is for third-party
86
- systems that participate in the *runtime* graph. The `external-system`
87
- actor kind is for systems that *initiate* use cases. They overlap
88
- conceptually but live in different files — actor file for "who acts
89
- on us", structural file for "what we integrate with".