archik 0.7.7 → 0.9.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.
@@ -102,8 +102,16 @@ any file under `.archik/`.
102
102
  - Preserve every existing node id you keep — only add or remove
103
103
  ids, never rename. Renames break diff and require the user to
104
104
  manually re-link references in code.
105
- - Don't drop `description`, `responsibilities`, or `notes`
106
- fields the user authored. Carry them over verbatim.
105
+ - Don't drop `description`, `responsibilities`, `notes`, or
106
+ `sourcePath` fields the user authored. Carry them over verbatim.
107
+ - Every new code-bearing node (`service`, `function`, `worker`,
108
+ `module`, `page`, `component`, `store`, `hook`) needs a
109
+ `sourcePath:` that exists on disk — the validator rejects
110
+ fabricated paths. If the refactor proposes a not-yet-built
111
+ module (e.g. extracting a `payments` context that doesn't have
112
+ a directory yet), describe it in prose for the user to
113
+ consider, then either skip that node or move the work to a
114
+ `*.archik.discussion.yaml` file via `--main`.
107
115
  - Every change should be motivated by step 3, not by aesthetics.
108
116
 
109
117
  If `suggest set` reports validation errors, re-run with the
@@ -89,7 +89,28 @@ archik suggest set` stages it.
89
89
  When unsure, pick the closest fit and add a `notes:` entry
90
90
  explaining the inference rather than picking `custom`.
91
91
 
92
- 6. **Nest by structure**, mirroring the directories.
92
+ 6. **Attach `sourcePath` to every code-bearing node.** This is
93
+ non-negotiable in a normal/suggested file — the validator rejects
94
+ any `service`, `function`, `worker`, `module`, `page`, `component`,
95
+ `store`, or `hook` without a `sourcePath` that points at an
96
+ existing file or directory. The whole point of `spawn` is "mirror
97
+ the source tree", so the path you used to discover the node is
98
+ exactly what goes into `sourcePath:`. Verify each path with `ls`
99
+ before authoring; do not paste a path you haven't seen on disk.
100
+
101
+ ```yaml
102
+ - id: orders-api
103
+ kind: service
104
+ name: Orders API
105
+ stack: Fastify
106
+ sourcePath: services/orders/api # must exist on disk
107
+ ```
108
+
109
+ For non-code-bearing kinds (`external`, `database`, `queue`,
110
+ `cloud`, etc.) `sourcePath` is optional — they typically map to
111
+ third-party systems or infra rather than checked-in files.
112
+
113
+ 7. **Nest by structure**, mirroring the directories.
93
114
  - Top-level grouping dir (e.g. `services/`) → a `module` container.
94
115
  - Each child dir → a node with `parentId` pointing at the container.
95
116
  - If a node has substantial internal structure (e.g.
@@ -98,7 +119,7 @@ archik suggest set` stages it.
98
119
  sub-file. Don't nest beyond two levels in the main file —
99
120
  drill-down is what `archikFile` is for.
100
121
 
101
- 7. **Wire the edges.** Be conservative — only add an edge when you
122
+ 8. **Wire the edges.** Be conservative — only add an edge when you
102
123
  have actual evidence:
103
124
  - Cross-package imports → `depends_on` or a more specific
104
125
  relationship (`uses`, `invokes`).
@@ -112,7 +133,7 @@ archik suggest set` stages it.
112
133
  When in doubt, leave the edge out. The user will add it via
113
134
  `/archik:suggest` later.
114
135
 
115
- 8. **Stage the draft.** Pipe the YAML straight into `npx archik
136
+ 9. **Stage the draft.** Pipe the YAML straight into `npx archik
116
137
  suggest set -` via a heredoc — no temp files, no `/tmp/` paths.
117
138
  Sub-files come first because the main draft references them via
118
139
  `archikFile`, and `suggest set` validates that those targets
@@ -172,7 +193,7 @@ archik suggest set` stages it.
172
193
  c. If `suggest set` reports validation errors, re-run with the
173
194
  corrected YAML. Never edit the sidecar by hand.
174
195
 
175
- 9. **Tell the user how to review and what's next.** Surface the
196
+ 10. **Tell the user how to review and what's next.** Surface the
176
197
  canvas URL plus the natural follow-up:
177
198
  - "📝 Initial diagram staged from source tree — open the
178
199
  canvas at <URL> and use Review to see the proposed nodes."
@@ -58,7 +58,16 @@ the contract with the user.
58
58
  `npx archik suggest set -` via a heredoc — no temp file, no
59
59
  `/tmp/` paths. The CLI validates the schema, checks cross-file
60
60
  references, stamps `metadata.suggestion`, and atomically writes
61
- `.archik/main.archik.suggested.yaml`:
61
+ `.archik/main.archik.suggested.yaml`.
62
+
63
+ **Every new code-bearing node** (`service`, `function`, `worker`,
64
+ `module`, `page`, `component`, `store`, `hook`) must declare a
65
+ `sourcePath:` that you have verified exists on disk. The
66
+ validator rejects fabricated paths. If the source doesn't exist
67
+ yet (you're proposing a not-yet-built component), suggest the
68
+ user run with `--main .archik/<name>.archik.discussion.yaml`
69
+ instead — discussion files relax the sourcePath rule for
70
+ greenfield drafts.
62
71
 
63
72
  ```bash
64
73
  npx archik suggest set --note "$ARGUMENTS" - <<'YAML'
@@ -27,6 +27,25 @@ You MUST NOT use `Read`, `Write`, or `Edit` against any file under `.archik/`, a
27
27
 
28
28
  If `npx archik` is unreachable (offline, sandboxed, missing), STOP and tell the user. Do NOT fall back to reading or editing YAML by hand.
29
29
 
30
+ ## File modes — pick the right one before authoring
31
+
32
+ Archik files have **three modes**, selected by filename suffix. Validation strictness differs per mode — picking the wrong one will either reject your draft or pollute the canonical architecture with greenfield speculation.
33
+
34
+ | Suffix | Mode | When to use | sourcePath rule |
35
+ | ---------------------------------- | ------------ | ---------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- |
36
+ | `*.archik.yaml` | **normal** | The canonical architecture of code that exists. | Required for code-bearing kinds; **must exist on disk** (validated). |
37
+ | `*.archik.suggested.yaml` | **suggested**| A pending change to a normal file. Owned by `suggest set`. Becomes normal on `suggest accept`. | Same rules as normal — it'll become normal when accepted. |
38
+ | `*.archik.discussion.yaml` | **discussion**| Greenfield / exploratory drafts: a brand-new project, an "what if we built X?" sketch, an option. | `sourcePath` is **optional**, and may point at paths that don't exist yet. |
39
+
40
+ **Code-bearing kinds** (those that must declare `sourcePath` in normal/suggested files): `service`, `function`, `worker`, `module`, `page`, `component`, `store`, `hook`. Other kinds (`external`, `cloud`, `prompt`, `llm`, `route`, `interface`, `adapter`, `port`, `database`, `cache`, `queue`, `topic`, `stream`, `gateway`, `cdn`, `agent`, `frontend`, `vectordb`, `storage`, `auth`, `observability`, `tool`, `custom`) are exempt.
41
+
42
+ **Picking the mode:**
43
+ - Are you describing real code that exists in this repo? → **normal** (or **suggested** if proposing a change).
44
+ - Are you sketching a not-yet-built system, or proposing an architecture for a new project? → **discussion**. Don't pollute the main file with speculation.
45
+ - Are you adding a `sourcePath` for a node whose code is going to be created soon? → **discussion**, then move to **normal** once the code exists.
46
+
47
+ If `suggest set` rejects your draft with a `sourcePath` error, the right answer is usually one of: (a) fix the path to point at real code, (b) move the work into `*.archik.discussion.yaml`, or (c) use a non-code-bearing kind (e.g., `external` for a third-party service).
48
+
30
49
  ## Slash commands (user-facing entry points)
31
50
 
32
51
  | Command | Purpose |
@@ -68,6 +87,8 @@ Then `ls -F . src/ services/ packages/ apps/ 2>/dev/null` for the source tree. B
68
87
 
69
88
  When the user asks "where would I add X?", you should already have the answer because you ran the queries above.
70
89
 
90
+ **Every code-bearing node you propose for a normal/suggested file must declare a `sourcePath` that you have verified exists on disk** (e.g. `ls src/payments/worker.ts` before authoring `sourcePath: src/payments/worker.ts`). The validator rejects fabricated paths — and the rejection is non-negotiable, exactly so hallucinated nodes can't slip into the canonical architecture. If the source doesn't exist yet, draft in `*.archik.discussion.yaml` first.
91
+
71
92
  ## Authoring drafts (sidecar workflow)
72
93
 
73
94
  When work introduces, removes, or rewires components, you stage a proposal as a sidecar via the CLI. The user reviews on the canvas and accepts / rejects.