archik 0.6.21 → 0.7.1

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.
@@ -0,0 +1,21 @@
1
+ ---
2
+ description: Apply the pending suggestion
3
+ ---
4
+
5
+ # /archik:accept — apply the pending suggestion
6
+
7
+ The user wants to accept the pending architecture suggestion.
8
+
9
+ Run the CLI — do NOT edit any archik file by hand:
10
+
11
+ ```
12
+ npx archik suggest accept
13
+ ```
14
+
15
+ If it exits 0, also run `npx archik validate` to confirm the new main
16
+ file is clean, and tell the user it's applied.
17
+
18
+ If it exits non-zero (no sidecar present, or the sidecar fails to
19
+ parse), surface the error to the user verbatim and stop. Do not
20
+ attempt to fix the sidecar by editing it; ask the user how they
21
+ want to proceed.
@@ -0,0 +1,28 @@
1
+ ---
2
+ description: Explain a node and its connections
3
+ argument-hint: <node-id>
4
+ ---
5
+
6
+ # /archik:describe — explain a node from the archik diagram
7
+
8
+ The user wants details about the node with id **$ARGUMENTS**.
9
+
10
+ Use the query CLI — do NOT `cat` or read any archik YAML directly:
11
+
12
+ ```
13
+ npx archik q describe $ARGUMENTS
14
+ ```
15
+
16
+ If you need adjacent context, also run:
17
+
18
+ ```
19
+ npx archik q deps $ARGUMENTS
20
+ npx archik q dependents $ARGUMENTS
21
+ ```
22
+
23
+ Summarize what came back in plain prose: the node's kind and stack,
24
+ what it depends on, what depends on it, and any responsibilities or
25
+ notes. Don't dump the raw CLI output unless the user asks for it.
26
+
27
+ If the CLI exits 1 (unknown id), tell the user and offer to run
28
+ `npx archik q list` to find the right id.
@@ -0,0 +1,24 @@
1
+ ---
2
+ description: Start the live canvas in the browser
3
+ ---
4
+
5
+ # /archik:dev — open the archik canvas
6
+
7
+ The user wants the live archik canvas running so they can see the
8
+ diagram and review suggestions visually.
9
+
10
+ Run the CLI — do NOT spawn dev servers any other way:
11
+
12
+ ```
13
+ npx archik status
14
+ ```
15
+
16
+ If nothing is running for this project, start it detached:
17
+
18
+ ```
19
+ npx archik start
20
+ ```
21
+
22
+ Surface the URL it prints (or the existing URL from `status`) so the
23
+ user can click straight to it. Do not try to open the browser
24
+ yourself.
@@ -0,0 +1,127 @@
1
+ ---
2
+ description: Propose a cleaner modular architecture
3
+ argument-hint: [optional focus area, e.g. "payments domain"]
4
+ ---
5
+
6
+ # /archik:evolve — propose a cleaner, bounded architecture
7
+
8
+ The user wants you to look at the current diagram with a critical
9
+ eye and **propose a refactor toward a cleaner modular architecture
10
+ with clear bounded contexts**. Stage the proposal as a sidecar so
11
+ the diff overlay highlights what would change, then **wait for the
12
+ user to discuss before they accept** — evolve is a conversation,
13
+ not a one-shot.
14
+
15
+ If `$ARGUMENTS` is non-empty, treat it as the area to focus on
16
+ (e.g. *"payments domain"*, *"the orders module"*, *"async wiring
17
+ between services"*). If empty, evaluate the whole diagram.
18
+
19
+ ## CLI-only — do not touch archik files directly
20
+
21
+ You MUST interact with archik exclusively through the `npx archik`
22
+ CLI. Drafts go to a workspace temp file, then `npx archik suggest
23
+ set` stages them. Do NOT use `Read`, `Write`, or `Edit` against
24
+ any file under `.archik/`.
25
+
26
+ ## Steps
27
+
28
+ 1. **Make sure the canvas is running**: `npx archik status` →
29
+ `npx archik start` if needed. Note the URL for step 6.
30
+
31
+ 2. **Ground yourself in the current shape** via the query CLI:
32
+ ```
33
+ npx archik q stats
34
+ npx archik q list
35
+ npx archik q edges
36
+ ```
37
+ If `$ARGUMENTS` names a specific area, also:
38
+ ```
39
+ npx archik q describe <id>
40
+ npx archik q deps <id>
41
+ npx archik q dependents <id>
42
+ npx archik q impact <id>
43
+ ```
44
+ Refuse politely and stop if the diagram has fewer than 3 nodes
45
+ — there's nothing meaningful to evolve. Suggest `/archik:spawn`
46
+ first.
47
+
48
+ 3. **Identify smells and missing structure.** Don't propose change
49
+ for change's sake — every modification should fix one of:
50
+
51
+ - **Bounded contexts unclear.** Several services share a
52
+ domain language but aren't grouped → wrap in a `module`
53
+ container per context.
54
+ - **God service.** One node owns too many responsibilities or
55
+ reaches into too many domains → split along bounded
56
+ contexts, with the original kept only as the API surface
57
+ facing the outside.
58
+ - **Leaky boundaries.** Cross-context `reads` / `writes`
59
+ directly on another context's database → introduce a `port`
60
+ + `adapter` pair, or replace with `publishes` / `subscribes`
61
+ events.
62
+ - **Missing hexagonal structure** at external boundaries.
63
+ Direct `http_call` to Stripe / OpenAI / payment processor →
64
+ introduce a `port` (the abstract contract) and an `adapter`
65
+ (the concrete impl), with `implements` between them.
66
+ - **Cyclic dependencies** between modules — should be inverted
67
+ (events) or broken (extract shared kernel).
68
+ - **Anaemic queues.** Two services connected by `http_call`
69
+ for what's clearly an async fire-and-forget → introduce a
70
+ `queue` or `topic` and rewire to `publishes` / `subscribes`.
71
+
72
+ Aim for 3–8 changes — enough to be meaningful, few enough that
73
+ the user can reason about each. If you'd need more, propose
74
+ the highest-impact subset and tell the user the rest is round
75
+ two.
76
+
77
+ 4. **Author the full proposed end-state** in a workspace temp file:
78
+ `/tmp/archik-evolve-<short-id>.yaml`. Constraints:
79
+
80
+ - Preserve every existing node id you keep — only add or remove
81
+ ids, never rename. Renames break diff and require the user to
82
+ manually re-link references in code.
83
+ - Don't drop `description`, `responsibilities`, or `notes`
84
+ fields the user authored. Carry them over verbatim.
85
+ - Every change should be motivated by step 3, not by aesthetics.
86
+
87
+ 5. **Stage the draft via the CLI**:
88
+ ```
89
+ npx archik suggest set --note "evolve: <one-line summary>" /tmp/archik-evolve-<id>.yaml
90
+ ```
91
+ Fix and re-run on validation errors. Never patch the sidecar
92
+ directly.
93
+
94
+ 6. **Open the discussion.** Print, in this order:
95
+
96
+ a. The canvas URL with: *"📝 Evolved diagram staged — open
97
+ <URL> and toggle Review to see green / red / amber overlays."*
98
+ b. A numbered, plain-English summary of the proposed changes,
99
+ grouped by motivation (e.g. *"1. Extract a `payments`
100
+ bounded context from `orders`. Why: payment logic was leaking
101
+ into order placement…"*). Keep each item to 2–3 sentences.
102
+ c. An explicit invitation: *"Tell me what you'd like to keep,
103
+ drop, or rework before you accept. I can re-stage with
104
+ changes — `/archik:accept` is whenever you're ready."*
105
+
106
+ **Do NOT auto-accept.** Even if the user said "evolve and apply"
107
+ in shorthand, evolve always stops at the staged sidecar so the
108
+ diff is reviewable.
109
+
110
+ ## Iterating
111
+
112
+ If the user pushes back on specific items ("keep the orders
113
+ service whole; only fix the Stripe integration"), update the
114
+ draft in the same temp file and re-run `npx archik suggest set` —
115
+ it overwrites the previous sidecar. Acknowledge what you changed
116
+ since the last round so the user doesn't have to re-read the
117
+ whole diff.
118
+
119
+ ## Notes
120
+
121
+ - Evolve is bounded-context-aware but doesn't blindly apply DDD.
122
+ If the project is genuinely small and a single service is the
123
+ right answer, say so and stage no changes — better than
124
+ inventing structure for its own sake.
125
+ - If you'd need to look at code (not just the diagram) to make a
126
+ responsible recommendation, say so up front and ask for
127
+ permission to read specific files. Don't silently expand scope.
@@ -0,0 +1,16 @@
1
+ ---
2
+ description: Discard the pending suggestion
3
+ ---
4
+
5
+ # /archik:reject — discard the pending suggestion
6
+
7
+ The user wants to throw away the pending architecture suggestion.
8
+
9
+ Run the CLI — do NOT delete files manually:
10
+
11
+ ```
12
+ npx archik suggest reject
13
+ ```
14
+
15
+ Surface the result to the user. If there was no pending sidecar, the
16
+ command will say so — pass that through unchanged.
@@ -0,0 +1,144 @@
1
+ ---
2
+ description: Bootstrap the diagram from the source tree
3
+ ---
4
+
5
+ # /archik:spawn — mirror the codebase as an archik diagram
6
+
7
+ The user wants a first-pass archik diagram that **reflects the
8
+ project as it actually is right now**, not as it should be. Read
9
+ the source tree, infer the components and the wiring, stage the
10
+ result as a suggestion sidecar so the user can review it on the
11
+ canvas before accepting.
12
+
13
+ Use `/archik:evolve` afterwards if they want a cleaner version.
14
+ Spawn = mirror. Evolve = improve.
15
+
16
+ ## CLI-only — do not touch archik files directly
17
+
18
+ You MUST interact with archik exclusively through the `npx archik`
19
+ CLI. Do NOT use `Read`, `Write`, or `Edit` on any file under
20
+ `.archik/`. Your draft goes to a workspace temp file, then `npx
21
+ archik suggest set` stages it.
22
+
23
+ ## Steps
24
+
25
+ 1. **Make sure the canvas is running** so the user can review:
26
+ ```
27
+ npx archik status
28
+ ```
29
+ If nothing is running, start it detached: `npx archik start`.
30
+ Note the URL.
31
+
32
+ 2. **Check what's already there** — if the project already has a
33
+ meaningful archik file, this command will *replace* it via the
34
+ suggestion workflow. Confirm with the user before proceeding
35
+ when the diagram has substance:
36
+ ```
37
+ npx archik q stats
38
+ ```
39
+ - 0 nodes / starter scaffold (web + api + db, the `archik init`
40
+ default) → proceed silently.
41
+ - Real content → tell the user "I'm about to replace the
42
+ current diagram with a fresh one mirroring the source tree —
43
+ this will produce a sidecar you can review or reject. Want me
44
+ to continue?" Wait for confirmation.
45
+
46
+ 3. **Map the source tree.** Walk the project from cwd, paying
47
+ attention to conventional layouts. Don't recurse into
48
+ `node_modules`, `dist`, `build`, `.git`, `.next`,
49
+ `target`, `venv`, `.venv`, or `vendor`.
50
+
51
+ Useful signals (apply only if they fit the project — never
52
+ invent structure):
53
+ - **Top-level dirs**: `apps/`, `services/`, `packages/`, `src/`,
54
+ `cmd/`, `internal/`, `lambdas/`, `workers/`, `agents/`.
55
+ Each child usually maps to one node.
56
+ - **Manifest files**: `package.json` `name`, `Cargo.toml`,
57
+ `go.mod`, `pyproject.toml` give canonical component names.
58
+ - **`README` / `description`**: pull a one-line summary if
59
+ present; otherwise omit `description` rather than fabricate.
60
+ - **Stack hints**: `package.json` deps (Next.js, Express, Fastify,
61
+ Hono → service/frontend), `go.mod`, `requirements.txt`,
62
+ `Gemfile`. Set `stack` only when the signal is clear.
63
+ - **Datastores**: a `migrations/` folder, a `schema.sql`,
64
+ `prisma/`, `drizzle/`, `flyway/`, references to Postgres /
65
+ MySQL / Redis / Mongo / S3 / Pinecone / pgvector in deps or
66
+ env files → corresponding `database` / `cache` / `vectordb` /
67
+ `storage` node.
68
+ - **Queues / streams**: SQS / RabbitMQ / Kafka / Kinesis client
69
+ deps or config → `queue` / `topic` / `stream` node.
70
+ - **External APIs**: Stripe, OpenAI, Anthropic, Twilio, GitHub
71
+ SDKs in deps → `external` (or `llm` for OpenAI / Anthropic)
72
+ nodes.
73
+ - **Frontends**: `apps/web`, `apps/mobile`, `client/`,
74
+ `packages/ui` apps that ship a UI → `frontend`.
75
+
76
+ 4. **Choose the kind for each node.** Default: `service`. Use the
77
+ taxonomy from the skill — `function` for serverless, `worker`
78
+ for background consumers, `agent` for LLM-driven agents, etc.
79
+ When unsure, pick the closest fit and add a `notes:` entry
80
+ explaining the inference rather than picking `custom`.
81
+
82
+ 5. **Nest by structure**, mirroring the directories.
83
+ - Top-level grouping dir (e.g. `services/`) → a `module` container.
84
+ - Each child dir → a node with `parentId` pointing at the container.
85
+ - If a node has substantial internal structure (e.g.
86
+ `services/orders/{api,domain,db}`), emit a stub
87
+ `archikFile: .archik/<id>.archik.yaml` and *also* draft that
88
+ sub-file. Don't nest beyond two levels in the main file —
89
+ drill-down is what `archikFile` is for.
90
+
91
+ 6. **Wire the edges.** Be conservative — only add an edge when you
92
+ have actual evidence:
93
+ - Cross-package imports → `depends_on` or a more specific
94
+ relationship (`uses`, `invokes`).
95
+ - HTTP route handlers calling another service's endpoint →
96
+ `http_call`.
97
+ - DB client usage → `reads` / `writes`.
98
+ - Queue producer / consumer code → `publishes` / `subscribes`.
99
+ - Webhook handlers (e.g. `/webhooks/stripe`) → `webhook` from
100
+ the external node.
101
+
102
+ When in doubt, leave the edge out. The user will add it via
103
+ `/archik:suggest` later.
104
+
105
+ 7. **Stage the draft.** Write the full proposed end-state to
106
+ `/tmp/archik-spawn-<short-id>.yaml`. If you generated sub-files,
107
+ write each one to its own temp file (`/tmp/archik-spawn-<sub>-<id>.yaml`)
108
+ and `suggest set` them too — but only the main file becomes a
109
+ sidecar. The sub-files need to live at their final
110
+ `.archik/<id>.archik.yaml` paths *before* you stage the main
111
+ draft, otherwise cross-file validation fails. So:
112
+
113
+ a. For each `archikFile: .archik/<id>.archik.yaml` you reference,
114
+ stage that sub-file first with its own
115
+ `npx archik suggest set` … then accept it immediately
116
+ (`npx archik suggest accept`) so the file is on disk under
117
+ `.archik/<id>.archik.yaml`. Yes, this is a chain of
118
+ micro-commits — that's the only CLI-blessed way to land
119
+ sub-files.
120
+ b. After all sub-files exist, stage the main draft:
121
+ ```
122
+ npx archik suggest set --note "spawn: mirror source tree" /tmp/archik-spawn-<id>.yaml
123
+ ```
124
+ c. If `suggest set` reports validation errors, fix the temp
125
+ file and re-run. Never edit the sidecar by hand.
126
+
127
+ 8. **Tell the user how to review.** Surface the canvas URL plus:
128
+ - "📝 Initial diagram staged from source tree — open the
129
+ canvas at <URL> and use Review to see the proposed nodes."
130
+ - "Looks wrong? Run `/archik:reject` and we'll iterate. Or run
131
+ `/archik:evolve` after accepting if you want a cleaner
132
+ bounded-context version."
133
+
134
+ ## Notes
135
+
136
+ - Spawn is descriptive, not prescriptive. Don't reorganize, split,
137
+ or merge components — just mirror what's there. Cleanup is
138
+ `/archik:evolve`'s job.
139
+ - Don't fabricate edges to fill gaps in the diagram. An incomplete
140
+ but accurate diagram is more useful than a complete-looking but
141
+ wrong one.
142
+ - If the source tree is one big monolith with no obvious
143
+ decomposition, output a single node and tell the user — don't
144
+ invent fake sub-services.
@@ -0,0 +1,73 @@
1
+ ---
2
+ description: Propose diagram changes from a feature description
3
+ argument-hint: <feature description>
4
+ ---
5
+
6
+ # /archik:suggest — propose architecture changes
7
+
8
+ The user wants you to capture the structural impact of a feature in
9
+ the archik diagram. The user-facing description is:
10
+
11
+ **$ARGUMENTS**
12
+
13
+ This slash command IS the user's confirmation that they want a
14
+ sidecar suggestion. Skip the "want me to update the YAML?" question
15
+ and produce one now.
16
+
17
+ ## CLI-only — do not touch archik files directly
18
+
19
+ You MUST interact with archik exclusively through the `npx archik`
20
+ CLI. Do NOT use Read, Write, or Edit on any file under `.archik/`,
21
+ on `architecture.archik.yaml`, or on any sidecar. The CLI is the
22
+ sanctioned interface; everything else is a manual edit and breaks
23
+ the contract with the user.
24
+
25
+ ## Steps
26
+
27
+ 1. **Make sure the canvas is running** so the user can review:
28
+ ```
29
+ npx archik status
30
+ ```
31
+ If nothing is running for this project, start it detached:
32
+ ```
33
+ npx archik start
34
+ ```
35
+ Note the URL it prints — you'll surface it at the end.
36
+
37
+ 2. **Ground yourself in the current diagram** using the query CLI
38
+ (do not `cat` the YAML):
39
+ ```
40
+ npx archik q stats
41
+ npx archik q list
42
+ ```
43
+ If `$ARGUMENTS` mentions a specific node by name, also run
44
+ `npx archik q describe <id>` for it.
45
+
46
+ 3. **Author the draft** in a workspace temp file (NOT under
47
+ `.archik/`). Use the path `/tmp/archik-draft-<short-id>.yaml`.
48
+ The draft is the *full proposed end-state* of the document — every
49
+ node and edge, not just the delta. Follow the schema, kinds, and
50
+ relationships documented in the archik skill.
51
+
52
+ 4. **Stage the draft as the sidecar via the CLI**:
53
+ ```
54
+ npx archik suggest set /tmp/archik-draft-<id>.yaml --note "$ARGUMENTS"
55
+ ```
56
+ This validates the schema, checks cross-file references, stamps
57
+ `metadata.suggestion`, and atomically renames it into place. If
58
+ the command exits non-zero, fix the reported errors in the temp
59
+ file and re-run — never edit the sidecar directly.
60
+
61
+ 5. **Tell the user how to review**. Surface the canvas URL from
62
+ step 1 plus the terminal options:
63
+ - "📝 Suggestion ready — open the canvas at <URL> and use the
64
+ **Review** banner to see added/removed/changed nodes."
65
+ - "Or from the terminal: `npx archik suggest show` /
66
+ `npx archik suggest accept` / `npx archik suggest reject`."
67
+
68
+ ## Notes
69
+
70
+ - If a sidecar already exists, `suggest set` overwrites it. Mention
71
+ to the user that you replaced their previous pending suggestion.
72
+ - If `npx archik` is unreachable (offline, sandboxed), STOP and tell
73
+ the user. Do not fall back to writing YAML by hand.