archik 0.15.1 → 0.16.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/README.md CHANGED
@@ -5,8 +5,7 @@
5
5
  <h1 align="center">archik</h1>
6
6
 
7
7
  <p align="center">
8
- <em>Architecture-as-code your AI editor actually reads —<br/>
9
- with use cases, sequence diagrams, and tests wired end-to-end.</em>
8
+ <em>Architecture-as-code in plain YAML — validated in CI, rendered in the browser, and read directly by your AI editor.</em>
10
9
  </p>
11
10
 
12
11
  <p align="center">
@@ -19,85 +18,71 @@
19
18
  </p>
20
19
 
21
20
  <p align="center">
22
- <img src="https://cdn.jsdelivr.net/npm/archik/docs/hero.svg?v=2" alt="Sample Archik diagram" width="780">
21
+ <img src="https://cdn.jsdelivr.net/npm/archik/docs/hero.svg?v=2" alt="Sample archik diagram" width="780">
23
22
  </p>
24
23
 
25
24
  ---
26
25
 
27
26
  ## What is archik?
28
27
 
29
- Your architecture lives in **plain YAML**. A **CLI** is the only way to edit it, a **validator** rejects every drift before merge, and a **live canvas** renders it in the browser. AI agents (Claude Code, or anything that speaks MCP) read the same YAML as their map of your system — so they reason about structure instead of guessing from filenames.
28
+ Your architecture lives in **plain YAML**. You edit it through a **CLI**, a **validator** rejects drift before it merges, and a **live canvas** renders it in the browser. AI agents — Claude Code, or anything that speaks MCP — read the same YAML as the map of your system, so they reason about structure instead of guessing from filenames.
30
29
 
31
- One chain runs from a stakeholder request all the way to a passing test, and every link is mechanically checked:
30
+ One chain runs from a stakeholder request to a passing test, and every link is checked mechanically:
32
31
 
33
32
  ```
34
- Actor → Use case → Slice → Tests on disk → Seq diagram → Nodes → Source code on disk
33
+ Actor → Use case → Slice → Tests → Sequence diagram → Nodes → Source
35
34
  ```
36
35
 
37
- ## Features
36
+ Nothing in that chain can quietly fall out of sync with the code.
38
37
 
39
- - 📐 **Plain-YAML diagrams** — no DSL, no coordinates; layout is computed by [ELK](https://eclipse.dev/elk/) on every render, so diffs stay meaningful
40
- - 🖥️ **Live canvas** — `archik dev` opens a browser canvas that reloads on every file change; headless SVG render for docs and CI
41
- - 🤖 **AI-native** — installable Claude Code skill + 12 slash commands, and an MCP server for Cursor, Windsurf, Copilot, Claude Desktop, Zed
42
- - ✅ **Validator, not convention** — schema, cross-file references, `sourcePath` existence, use-case/actor/seq integrity, ECB rules
43
- - 🔍 **Traceability** — `archik trace` proves which use case slices are tested and realized; `--fail-on` gates CI
44
- - 🌿 **Git-aware** — `archik diff origin/main` shows what a branch changes architecturally; `archik affected` maps changed files to nodes, slices, and tests (`--run` executes them); `archik hooks install` gates every commit
45
- - 🤝 **Team-ready** — semantic merge driver for YAML, node ownership with CODEOWNERS sync, and governance constraints (architecture fitness rules)
46
- - 🔬 **Verified at every altitude** — `validate` proves the model is consistent, `drift --edges` proves it matches the code's import graph, `otel check` proves it matches production traffic
47
- - 🧬 **Self-evolving** — opt-in `archik evolution` loop (observe → reflect → propose → validate → apply → measure) learns from your accepts, rejects, and failures and proposes its own upgrades behind a human approval gate; `archik patterns` ships the same design patterns for your systems
48
- - 🚀 **Fast adoption** — `archik import compose` / `import mermaid` bootstrap a diagram from what you already have; `/archik:spawn` mirrors an existing source tree
49
- - 📦 **Zero runtime dependencies** in the published package
50
-
51
- ## Installation
38
+ ## Install
52
39
 
53
40
  Requires **Node.js ≥ 20**.
54
41
 
55
42
  ```bash
56
- npx archik@latest init # scaffolds .archik/main.archik.yaml
57
- # + installs the Claude skill and /archik:* commands
43
+ npx archik@latest init
58
44
  ```
59
45
 
60
- Or as a Claude Code plugin:
46
+ `init` scaffolds `.archik/main.archik.yaml` and installs the Claude Code skill and `/archik:*` slash commands. As a Claude Code plugin instead:
61
47
 
62
48
  ```
63
49
  /plugin marketplace add bacharSalleh/archik
64
50
  /plugin install archik@archik
65
51
  ```
66
52
 
67
- Both paths install the same skill and slash commands. The plugin still uses the `archik` npm binary, so Node is needed either way.
53
+ Both paths install the same skill and commands and use the `archik` npm binary, so Node is required either way.
68
54
 
69
55
  ## Quick start
70
56
 
71
57
  ```bash
72
- npx archik init # 1. scaffold
73
- npx archik start # 2. open the live canvas (http://localhost:5173)
58
+ npx archik init # scaffold
59
+ npx archik start # live canvas at http://localhost:5173
74
60
  ```
75
61
 
76
- Then, in Claude Code:
62
+ Then, in Claude Code, start every project with:
77
63
 
78
64
  ```
79
- /archik:bootstrap # 3. always your first message — detects project
80
- # state and routes to the right next step
65
+ /archik:bootstrap # detects project state, routes to the next step
81
66
  ```
82
67
 
83
- Day-to-day:
68
+ Day to day:
84
69
 
85
70
  | You type | You get |
86
71
  | --- | --- |
87
- | `/archik:suggest <feature>` | A staged diagram change, shown as a green/red diff overlay on the canvas — accept or reject |
72
+ | `/archik:suggest <feature>` | A staged diagram change, shown as a green/red diff on the canvas — accept or reject |
88
73
  | `/archik:usecase <name>` | A use case with flows, slices, and test paths |
89
- | `/archik:trace` | "Are we done?" — the coverage matrix |
74
+ | `/archik:trace` | The coverage matrix — "are we done?" |
90
75
 
91
- **Already have docker-compose or Mermaid diagrams?** Skip the blank canvas:
76
+ Already have docker-compose or Mermaid? Bootstrap from it instead of a blank canvas:
92
77
 
93
78
  ```bash
94
79
  npx archik import compose --out .archik/main.archik.yaml
95
80
  npx archik import mermaid docs/architecture.mmd --out .archik/main.archik.yaml
96
81
  ```
97
82
 
98
- Compose services become nodes (postgres → `database`, redis → `cache`, kafka → `stream`, …), build contexts become `sourcePath`s, and `depends_on` becomes edges. The Mermaid importer parses the flowchart subset: shaped nodes map to kinds, subgraphs become module parents, arrows become labelled edges.
83
+ Compose services become nodes (`postgres` → `database`, `kafka` → `stream`, …), build contexts become `sourcePath`s, and `depends_on` becomes edges.
99
84
 
100
- ## The YAML
85
+ ## The model
101
86
 
102
87
  ```yaml
103
88
  version: "1.0"
@@ -120,53 +105,44 @@ edges:
120
105
  relationship: invokes
121
106
  ```
122
107
 
123
- One file per layer, every link cross-checked by the validator:
108
+ There are no coordinates — layout is computed by [ELK](https://eclipse.dev/elk/) on every render, so diffs stay meaningful. Each concern is a separate file, cross-checked by the validator:
124
109
 
125
110
  | Layer | File | Captures |
126
111
  | --- | --- | --- |
127
112
  | Structure | `.archik/main.archik.yaml` | Services, databases, queues, agents, LLMs, edges |
128
113
  | Actors | `*.archik.actors.yaml` | Who initiates use cases |
129
- | Requirements | `.archik/usecases/*.archik.uc.yaml` | Flows + slices that name **test paths** |
114
+ | Requirements | `.archik/usecases/*.archik.uc.yaml` | Flows and slices that name **test paths** |
130
115
  | Behaviour | `*.archik.seq.yaml` | UML-subset sequence diagrams |
131
116
  | Progress | `*.archik.alphas.yaml` | Essence/SEMAT alphas, machine-verified |
132
117
 
133
118
  Full schema: `npx archik schema` (also `schema seq | uc | actors`).
134
119
 
135
- ## Everyday workflow
136
-
137
- ```bash
138
- # What am I touching on this branch? Which tests cover it?
139
- npx archik affected --since main
140
-
141
- # …and run exactly those tests (vitest/jest/playwright/mocha auto-detected)
142
- npx archik affected --since main --run
143
-
144
- # What does this branch change architecturally?
145
- npx archik diff origin/main # add --out diff.svg for the visual
146
-
147
- # Is the diagram still telling the truth?
148
- npx archik validate && npx archik drift
120
+ ## Keeping the model honest
149
121
 
150
- # Do the EDGES match the code? (TS/JS import-graph verification)
151
- npx archik drift --edges # shadow + phantom edge detection
122
+ A set of commands prove the diagram still matches reality, at every altitude:
152
123
 
153
- # Are we done?
154
- npx archik trace
124
+ ```bash
125
+ npx archik validate # schema + cross-file integrity + governance constraints
126
+ npx archik drift # nodes/tests vs the source tree
127
+ npx archik drift --edges # edges vs the TS/JS import graph (shadow + phantom edges)
128
+ npx archik affected --since main --run # changed files → nodes → slices → run their tests
129
+ npx archik trace --fail-on partial # coverage matrix; gate CI on incomplete traceability
130
+ npx archik otel check --graph deps.json # edges vs a production service-dependency graph
155
131
  ```
156
132
 
157
- `affected` walks the chain backwards: changed files → nodes (via `sourcePath`) → use case slices (via tests and sequence-diagram participants) → tests to run — and flags changed files no node or test claims.
158
-
159
- `drift --edges` scans the imports under every node's `sourcePath` and reports **shadow edges** (code imports across nodes with no declared edge) and **phantom edges** (structural edges with no import in either direction). Gate every commit locally with:
133
+ `validate` proves the model is internally consistent, `drift` that it matches the code, and `otel check` that it matches production traffic. Gate every commit locally:
160
134
 
161
135
  ```bash
162
- npx archik hooks install # pre-commit: archik validate
136
+ npx archik hooks install # pre-commit: archik validate
163
137
  ```
164
138
 
139
+ Large models stay readable: `archik complexity` flags over-large files, hub nodes, and deep nesting with a concrete fix for each, and `archik q neighbors <id>` / `archik render --focus <id>` show one node's neighbourhood instead of the whole map.
140
+
165
141
  ## AI integration
166
142
 
167
- **Claude Code** (deepest integration): `archik init` installs a skill that enforces one hard rule — *Claude talks to archik only through the CLI*, never by editing YAML directly. Reads go through `archik q`, writes through `archik suggest set`, and you approve every structural change on the canvas.
143
+ **Claude Code.** `archik init` installs a skill that enforces one rule — *Claude talks to archik only through the CLI*, never by editing YAML directly. Reads go through `archik q`, writes through `archik suggest set`, and you approve every structural change on the canvas.
168
144
 
169
- **Everything else** (MCP): `archik mcp` runs a stdio [Model Context Protocol](https://modelcontextprotocol.io) server exposing the same contract — 20 tools covering schema, queries, trace, validate, drift, affected, and the suggestion lifecycle, plus **resources** (`archik://schema`, `archik://stats`, `archik://trace`, `archik://validate`, `archik://drift`) and **prompts** (`propose-change`, `review-architecture`) that encode the same working loop the Claude Code skill teaches:
145
+ **Everything else (MCP).** `archik mcp` runs a stdio [Model Context Protocol](https://modelcontextprotocol.io) server exposing the same contract — tools for schema, queries, trace, validate, drift, and the suggestion lifecycle, plus resources (`archik://schema`, `archik://stats`, `archik://trace`) and prompts that encode the same loop:
170
146
 
171
147
  ```jsonc
172
148
  // .cursor/mcp.json, claude_desktop_config.json, etc.
@@ -177,19 +153,11 @@ npx archik hooks install # pre-commit: archik validate
177
153
  }
178
154
  ```
179
155
 
180
- ## Team workflow
156
+ ## Teams and governance
181
157
 
182
- **Semantic merges.** Stop resolving line-based YAML conflicts — nodes and edges are id-keyed, so most merges are mechanical:
183
-
184
- ```bash
185
- npx archik merge-driver --install # once per clone; .gitattributes line is committed
186
- ```
187
-
188
- Both branches added nodes → keep both. One side changed a field → take it. Same field changed differently, or modify-vs-delete → a real conflict, reported precisely.
189
-
190
- **Ownership.** `owner: team-billing` on a node answers "who do I talk to": `archik q describe payments-db`, `archik q list --owner team-billing`. And `archik owners sync` writes one CODEOWNERS rule per owned node into a managed block (hand-authored rules untouched), with `archik owners check` as the CI gate so review routing can't drift from the model.
191
-
192
- **Governance constraints.** Architecture fitness rules, enforced by `archik validate` on every run:
158
+ - **Semantic merges.** Nodes and edges are id-keyed, so most YAML merges are mechanical instead of line-based conflicts: `archik merge-driver --install`.
159
+ - **Ownership.** `owner:` on a node answers "who do I talk to" (`archik q list --owner team-billing`), and `archik owners sync` writes one CODEOWNERS rule per owned node into a managed block.
160
+ - **Governance constraints.** Architecture fitness rules enforced by `archik validate`:
193
161
 
194
162
  ```yaml
195
163
  constraints:
@@ -206,54 +174,9 @@ constraints:
206
174
 
207
175
  Intentional exceptions are grandfathered by id in an `except` list — visible in review, never silent.
208
176
 
209
- ## Verified against production
210
-
211
- Map nodes to your tracing backend's service names (`metadata.otelService`, node id as the fallback), export the service-dependency graph, and let archik compare:
212
-
213
- ```bash
214
- curl -s "http://jaeger:16686/api/dependencies?endTs=$(date +%s)000&lookback=86400000" > deps.json
215
- npx archik otel check --graph deps.json
216
- ```
217
-
218
- Undeclared production calls — traffic the diagram doesn't admit to — fail the check; declared wire edges that saw no traffic are reported informationally. That completes the truth chain: `validate` proves the model is consistent, `drift --edges` proves it matches the code, `otel check` proves it matches production.
219
-
220
- ## Self-evolution
221
-
222
- Archik can learn from how you use it. Everything is opt-in, local-only, and human-gated:
223
-
224
- ```bash
225
- archik evolution enable # start observing (events stay on your machine)
226
- # ... normal work: suggestions accepted/rejected, validate/drift runs ...
227
- archik evolution reflect # recurring friction → pending proposals with evidence
228
- archik evolution proposals # read them
229
- archik evolution approve <id># apply: a learned.md note, or a sidecar diff you still review
230
- archik evolution report # did it help? last 7 days vs the 7 before
231
- ```
232
-
233
- Approved lessons land in `.archik/evolution/learned.md` — the Claude skill reads it at session start (and MCP agents via `archik://learned`), so the AI gets smarter across sessions without anyone editing prompts. Rejecting a proposal is recorded too; the loop learns from "no".
234
-
235
- Building a self-evolving system of your own? The same patterns ship as a library:
236
-
237
- ```bash
238
- archik patterns list # evolution-loop, sidecar-approval-gate,
239
- archik patterns show evolution-loop # learned-overlay, truth-chain, feedback-pipeline
240
- archik patterns apply evolution-loop # stage the blueprint into YOUR diagram (gated)
241
- ```
242
-
243
- Deep dives in [docs/advanced-topics](./docs/advanced-topics/README.md). In Claude Code: `/archik:self-evolving <your idea>`.
244
-
245
177
  ## CI
246
178
 
247
- Plain commands:
248
-
249
- ```bash
250
- archik validate # schema + cross-file integrity + constraints
251
- archik drift # diagram vs source tree
252
- archik trace --fail-on partial # block merge on incomplete traceability
253
- archik render --theme light --out docs/architecture.svg
254
- ```
255
-
256
- Or the GitHub Action, which runs all three and posts a sticky PR comment with the architecture diff vs the base branch:
179
+ Run the commands directly, or use the GitHub Action, which validates, checks drift and traceability, and posts a sticky PR comment with the architecture diff against the base branch:
257
180
 
258
181
  ```yaml
259
182
  # .github/workflows/archik.yml
@@ -269,11 +192,15 @@ jobs:
269
192
  - uses: actions/checkout@v4
270
193
  - uses: bacharSalleh/archik@main
271
194
  with:
272
- trace-fail-on: partial # optional gate; omit for report-only
195
+ trace-fail-on: partial # optional gate; omit for report-only
273
196
  ```
274
197
 
275
198
  Inputs: `path`, `working-directory`, `validate`, `drift`, `trace-fail-on`, `compare-ref`, `comment`, `github-token`, `version`.
276
199
 
200
+ ## Self-evolution
201
+
202
+ Opt-in, local-only, and human-gated: `archik evolution` observes how you use it (accepts, rejects, validate/drift runs), turns recurring friction into proposals you review, and records approved lessons in `.archik/evolution/learned.md` — which the Claude skill reads at session start, so the AI improves across sessions without anyone editing prompts. The same designs ship as a reusable library via `archik patterns`. See [docs/advanced-topics](./docs/advanced-topics/README.md).
203
+
277
204
  ## CLI reference
278
205
 
279
206
  Every command supports `--help`; agent-facing commands support `--json`.
@@ -283,33 +210,32 @@ Every command supports `--help`; agent-facing commands support `--json`.
283
210
  | `archik init` | Scaffold + install the Claude skill and slash commands |
284
211
  | `archik dev` / `start` / `stop` / `status` | Live canvas lifecycle (foreground / detached) |
285
212
  | `archik validate [path]` | Schema + cross-file + constraints (exit 1 on error) |
286
- | `archik render --out <svg>` | Headless SVG render (`--seq <path>` for sequence diagrams) |
213
+ | `archik complexity [path]` | Flag over-large files, hub nodes, deep nesting (`--fail-on-warn` to gate) |
214
+ | `archik render --out <svg>` | Headless SVG render (`--seq <path>`, `--focus <id>`, `--hide-structural`) |
287
215
  | `archik watch` | Re-render SVG on every change |
288
- | `archik q <sub>` | Query: `describe` `deps` `dependents` `impact` `list` `edges` `stats` `usecases` `describe-usecase` `actors` `sequences` |
216
+ | `archik q <sub>` | Query: `describe` `deps` `dependents` `neighbors` `impact` `list` `edges` `stats` `usecases` `describe-usecase` `actors` `sequences` |
289
217
  | `archik diff <a> [b]` | Diff two files **or git refs**; one arg = that ref vs working tree |
290
- | `archik affected` | Changed files → nodes, slices, tests to run (`--since <ref>`, `--files`, `--run` to execute them) |
218
+ | `archik affected` | Changed files → nodes, slices, tests (`--since <ref>`, `--files`, `--run`) |
291
219
  | `archik trace` | Coverage matrix (`--fail-on partial\|none` for CI) |
292
- | `archik drift` | sourcePath / test-path gaps vs the source tree (`--edges` verifies edges vs the TS/JS import graph) |
220
+ | `archik drift` | sourcePath / test-path gaps (`--edges` verifies edges vs the import graph) |
293
221
  | `archik otel check --graph <f>` | Verify edges against a production service-dependency graph |
294
222
  | `archik suggest <sub>` | Suggestion sidecar lifecycle: `show` `set` `accept` `reject` |
295
- | `archik alpha <sub>` | Essence alphas: `show`, `promote` (machine-checked), `demote` |
296
- | `archik evolution <sub>` | Self-evolution loop: `enable` `status` `reflect` `proposals` `propose` `approve` `reject` `report` |
297
- | `archik patterns <sub>` | Self-evolution pattern library: `list` `show <id>` `apply <id>` |
298
- | `archik import compose\|mermaid [file]` | Bootstrap a document from docker-compose or a Mermaid flowchart |
223
+ | `archik alpha <sub>` | Essence alphas: `show`, `promote`, `demote` |
224
+ | `archik evolution <sub>` | Self-evolution loop: `enable` `reflect` `proposals` `approve` `reject` `report` |
225
+ | `archik patterns <sub>` | Pattern library: `list` `show <id>` `apply <id>` |
226
+ | `archik import compose\|mermaid [file]` | Bootstrap from docker-compose or a Mermaid flowchart |
299
227
  | `archik merge-driver --install` | Semantic git merge for `*.archik.yaml` |
300
228
  | `archik hooks install` | Pre-commit hook running `archik validate` (`--with-drift` optional) |
301
229
  | `archik owners sync\|check` | Keep CODEOWNERS in step with node owners |
302
- | `archik mcp` | MCP server over stdio (tools + resources + prompts) for non-Claude-Code agents |
230
+ | `archik mcp` | MCP server over stdio for non-Claude-Code agents |
303
231
  | `archik schema [seq\|uc\|actors]` | Print the document schemas |
304
232
  | `archik upgrade` | Upgrade + refresh installed skill/commands |
305
233
 
306
- Default file resolution: `.archik/main.archik.yaml`, falling back to the legacy `architecture.archik.yaml` (both present = error).
307
-
308
- ## When to use it (and when not to)
234
+ Default file resolution: `.archik/main.archik.yaml`, falling back to the legacy `architecture.archik.yaml` (both present is an error).
309
235
 
310
- **Use archik when** your project has more than ~5 components, you ship with an AI agent and want it to reason about structure, you want "are we done?" to be mechanically answerable, or you want CI to fail on architectural drift.
236
+ ## When to use it
311
237
 
312
- **Skip it when** it's a one-file script, the diagram is for a slide deck (use Mermaid), or you have no build step or CI.
238
+ Reach for archik when a project has more than a handful of components, ships with an AI agent you want reasoning about structure, needs "are we done?" to be mechanically answerable, or wants CI to fail on architectural drift. Skip it for one-file scripts, slide-deck diagrams (use Mermaid), or projects with no build or CI.
313
239
 
314
240
  | | archik | Mermaid / PlantUML | Structurizr |
315
241
  | --- | --- | --- | --- |
@@ -322,7 +248,7 @@ Default file resolution: `.archik/main.archik.yaml`, falling back to the legacy
322
248
 
323
249
  ## Contributing
324
250
 
325
- See [CONTRIBUTING.md](./CONTRIBUTING.md). Development:
251
+ See [CONTRIBUTING.md](./CONTRIBUTING.md).
326
252
 
327
253
  ```bash
328
254
  npm install