ai-spector 0.3.6 → 0.3.7

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.
Files changed (35) hide show
  1. package/dist/commands/prototype.d.ts.map +1 -1
  2. package/dist/commands/prototype.js +4 -1
  3. package/dist/commands/prototype.js.map +1 -1
  4. package/dist/graph/doc-extract.d.ts.map +1 -1
  5. package/dist/graph/doc-extract.js +115 -102
  6. package/dist/graph/doc-extract.js.map +1 -1
  7. package/dist/markdown/parse.d.ts +25 -0
  8. package/dist/markdown/parse.d.ts.map +1 -0
  9. package/dist/markdown/parse.js +100 -0
  10. package/dist/markdown/parse.js.map +1 -0
  11. package/dist/prototype/config.d.ts +2 -0
  12. package/dist/prototype/config.d.ts.map +1 -1
  13. package/dist/prototype/config.js +35 -6
  14. package/dist/prototype/config.js.map +1 -1
  15. package/dist/types.d.ts +1 -1
  16. package/dist/types.d.ts.map +1 -1
  17. package/dist/visualize/html.d.ts.map +1 -1
  18. package/dist/visualize/html.js +492 -282
  19. package/dist/visualize/html.js.map +1 -1
  20. package/package.json +7 -2
  21. package/scaffold/.ai-spector/.docflow/config/prototype.config.json +1 -2
  22. package/scaffold/cursor/WORKFLOW.md +2 -2
  23. package/scaffold/cursor/commands/_workflow.md +3 -3
  24. package/scaffold/cursor/mcp.json +1 -15
  25. package/scaffold/cursor/skills/ai-spector/references/cli-failures.md +3 -32
  26. package/scaffold/cursor/skills/ai-spector/references/generate-graph.md +49 -70
  27. package/scaffold/cursor/skills/ai-spector/references/generate-workflow.md +1 -1
  28. package/scaffold/cursor/skills/ai-spector/references/graph.md +0 -1
  29. package/scaffold/cursor/skills/ai-spector-generate-prototype/SKILL.md +6 -5
  30. package/scaffold/cursor/skills/ai-spector-generate-prototype/references/runbook.md +30 -10
  31. package/scaffold/cursor/skills/ai-spector-generate-srs/references/runbook.md +1 -1
  32. package/scaffold/cursor/skills/ai-spector-graph/references/analyze.md +18 -44
  33. package/scaffold/cursor/skills/ai-spector-graph/references/graph-commands.md +1 -4
  34. package/scaffold/cursor/skills/ai-spector-graph/references/index.md +6 -14
  35. package/scaffold/prototype/README.md +4 -2
@@ -1 +1 @@
1
- {"version":3,"file":"html.js","sourceRoot":"","sources":["../../src/visualize/html.ts"],"names":[],"mappings":"AAaA,SAAS,mBAAmB,CAAC,IAAa;IACxC,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;AACvD,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,OAAyB;IAC9D,MAAM,QAAQ,GAAG,mBAAmB,CAAC,OAAO,CAAC,CAAC;IAE9C,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iDA4KwC,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAsWjD,CAAC;AACT,CAAC"}
1
+ {"version":3,"file":"html.js","sourceRoot":"","sources":["../../src/visualize/html.ts"],"names":[],"mappings":"AAaA,SAAS,mBAAmB,CAAC,IAAa;IACxC,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;AACvD,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,OAAyB;IAC9D,MAAM,QAAQ,GAAG,mBAAmB,CAAC,OAAO,CAAC,CAAC;IAE9C,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iDAqPwC,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA+ejD,CAAC;AACT,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-spector",
3
- "version": "0.3.6",
3
+ "version": "0.3.7",
4
4
  "description": "Cursor-first documentation workflow: traceability graph, SRS/basic/detail design templates, and ai-spector CLI",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -56,9 +56,14 @@
56
56
  "ai-spector": "node dist/cli.js"
57
57
  },
58
58
  "dependencies": {
59
+ "@types/mdast": "^4.0.4",
59
60
  "ajv": "^8.17.1",
60
61
  "ajv-formats": "^3.0.1",
61
- "commander": "^12.1.0"
62
+ "commander": "^12.1.0",
63
+ "remark-gfm": "^4.0.1",
64
+ "remark-parse": "^11.0.0",
65
+ "unified": "^11.0.5",
66
+ "unist-util-visit": "^5.1.0"
62
67
  },
63
68
  "devDependencies": {
64
69
  "@types/node": "^22.10.0",
@@ -5,6 +5,5 @@
5
5
  "screenDetailDir": "docs/basic-design/screens/",
6
6
  "prototypeDir": "prototype",
7
7
  "srcDir": "prototype/src",
8
- "slugFrom": "screenName",
9
- "defaultTheme": "vercel"
8
+ "slugFrom": "screenName"
10
9
  }
@@ -17,7 +17,7 @@ Add files under `docs/data-source/`, open the project in Cursor, **reload MCP**
17
17
 
18
18
  | You want to… | Say (examples) | Skill | Agent runs (summary) |
19
19
  |--------------|----------------|-------|----------------------|
20
- | Ingest sources | “analyze my data source”, “build the knowledge graph” | `ai-spector-graph` | `analyze` → Graphify → merge knowledge → validate |
20
+ | Ingest sources | “analyze my data source”, “build the knowledge graph” | `ai-spector-graph` | `analyze` → read markdown → merge knowledge → validate |
21
21
  | Check graph | “validate the graph”, “graph errors” | `ai-spector-graph` | `graph validate` |
22
22
  | Refresh after edits | “re-index”, “sync the graph” | `ai-spector-graph` | `ai-spector index` |
23
23
  | Write SRS | “generate SRS”, “write use cases” | `ai-spector-generate-srs` | DAG waves → docs/srs → merge → index |
@@ -54,7 +54,7 @@ analyze → validate graph → generate SRS → index
54
54
 
55
55
  | Symptom | What to say / do |
56
56
  |---------|------------------|
57
- | Analyze failed | Agent offers fix vs workaround; say **1** to retry or “analyze again” after fixing data-source / Graphify |
57
+ | Analyze failed | Agent offers fix vs workaround; say **1** to retry or “analyze again” after fixing data-source |
58
58
  | Validate errors | “validate the graph” — agent explains each error |
59
59
  | Empty SRS | “analyze” then “generate SRS” — not bulk-read all docs |
60
60
  | Unsure what regen | “what’s the impact of my changes” |
@@ -11,7 +11,7 @@ npm install ai-spector
11
11
  npx ai-spector init
12
12
  ```
13
13
 
14
- Add source material under `docs/data-source/`, open the project in Cursor, **reload MCP** (Graphify is in `.cursor/mcp.json` from `init`), and **enable all ai-spector skills** under `.cursor/skills/` (see `.cursor/skills/README.md`).
14
+ Add source material under `docs/data-source/`, open the project in Cursor, and **enable all ai-spector skills** under `.cursor/skills/` (see `.cursor/skills/README.md`).
15
15
 
16
16
  Skills auto-route for natural language; **slash commands stay the source of truth** for step-by-step work (see [commands/README.md](./README.md)). Slash commands win over skills when both apply.
17
17
 
@@ -19,11 +19,11 @@ Skills auto-route for natural language; **slash commands stay the source of trut
19
19
 
20
20
  | Step | You run | Agent runs (CLI) |
21
21
  |------|---------|------------------|
22
- | 1 | **`/analyze`** | `ai-spector analyze` → `ai-spector graphify update` (sidecar) semantic extract → `graph merge --from-knowledge` → `graph validate` → optional `graph visualize --open` |
22
+ | 1 | **`/analyze`** | `ai-spector analyze` → read markdown from `docs/data-source/` → `graph merge --from-knowledge` → `graph validate` → optional `graph visualize --open` |
23
23
  | 2 | **`/validate-graph`** | `ai-spector graph validate` |
24
24
  | 3 | **`/generate-srs`** [paths or request] — all, listed files, or described scope (**confirm** if described) → waves → merge (see `generate-srs.md`) |
25
25
  | 4 | **`/summary srs`** (optional) | Doc summaries under `.ai-spector/index/` (fallback browse; graph is primary) |
26
- | — | **`/index`** | After manual edits or **`/generate-srs`**: `ai-spector index` (structure + knowledge merge + **SRS body extract** + Graphify on changed paths + doc indexes) |
26
+ | — | **`/index`** | After manual edits or **`/generate-srs`**: `ai-spector index` (structure + knowledge merge + **SRS body extract** + doc indexes) |
27
27
  | 5 | **`/generate-basic-design`** [paths or request] — same targeting + waves as SRS (`generate-basic-design.md`) |
28
28
  | 6 | **`/generate-detail-design`** | same `graph query` pattern |
29
29
  | 7 | **`/generate-prototype`** [--theme name] | `ai-spector prototype setup --theme …` → agent writes `prototype/src/*.html` → `prototype manifest` → `prototype validate --strict` |
@@ -1,17 +1,3 @@
1
1
  {
2
- "mcpServers": {
3
- "graphify": {
4
- "command": "uv",
5
- "args": [
6
- "tool",
7
- "run",
8
- "--from",
9
- "graphifyy",
10
- "python",
11
- "-m",
12
- "graphify.serve",
13
- "${workspaceFolder}/.ai-spector/.docflow/graph/graphify-out/graph.json"
14
- ]
15
- }
16
- }
2
+ "mcpServers": {}
17
3
  }
@@ -95,8 +95,6 @@ Use only when the user chooses **2** or explicitly accepts the trade-off. Prefer
95
95
  | `graph query` OK but thin `nodes` | Read only `projectionPaths` + cited `docs/data-source/**` | Named paths only; no `docs/srs/**` glob | `graph merge` + `validate` after draft |
96
96
  | `graph validate` — one bad id/edge | Patch **single** node/edge; re-validate | No mass graph surgery | `validate` must pass before next wave |
97
97
  | `graph merge` — one bad `listedInSection` | Fix id in `knowledge.json`; re-merge | No hand-merge of full graph | Same |
98
- | Graphify MCP down mid-**analyze** | Continue with existing `knowledge.json` + user sources | User accepts stale extract; document in reply | Re-run **analyze** when MCP is back |
99
- | `graphify update` on markdown-only path | Skip (expected); use **index** for doc semantics | Do not treat as hard failure | **index** on schedule per command doc |
100
98
  | `index` fails on one path | Skip that path if command allows; fix path and re-index | Do not skip required wave index without user OK | Re-run **index** for skipped paths |
101
99
  | Optional visualize fails | Skip open; continue pipeline | User chose workaround | None |
102
100
  | Terminal/env (not git, missing `uv`) | Agent runs install/init steps user approves | No destructive deletes without ask | Re-run failed CLI |
@@ -126,7 +124,7 @@ After any workaround that wrote docs or graph patches: **`graph validate`** (and
126
124
  ### `graph merge` — `No domain entries in knowledge.json`
127
125
 
128
126
  - **Means:** Analyze extract did not populate staging.
129
- - **Fix:** Re-run Graphify extract in analyze; ensure `docs/data-source/` has real files; fill `knowledge.json` with at least one `useCase` or `feature`.
127
+ - **Fix:** Re-run `/analyze`; ensure `docs/data-source/` has real markdown files with UC/F/actor content; fill `knowledge.json` with at least one `useCase` or `feature`.
130
128
  - **Workaround (user OK):** Manually add minimal entries to `knowledge.json` then re-merge.
131
129
 
132
130
  ### `graph merge` — `Merge edge missing target node` / section id
@@ -154,27 +152,6 @@ After any workaround that wrote docs or graph patches: **`graph validate`** (and
154
152
  - **Means:** CLI crashed or wrong cwd.
155
153
  - **Fix:** Re-run from project root; if repeat, report as tool bug with full stderr.
156
154
 
157
- ### Graphify MCP unavailable
158
-
159
- - **Means:** Analyze cannot extract.
160
- - **Fix:** User enables Graphify in Cursor; reload MCP.
161
- - **Workaround (user OK):** Proceed with existing `knowledge.json` and data-source reads; schedule re-analyze.
162
-
163
- ### `graphify update` — `unknown option: --graph`
164
-
165
- - **Means:** Agent used `graphify update <path> --graph <file>`. The `update` subcommand does **not** accept `--graph` (only `query`, `explain`, `path`, `cluster-only` do).
166
- - **Fix:** Run **`ai-spector graphify update`** (sets absolute `GRAPHIFY_OUT` and project-root cwd). Do not pass `--graph` on `update`.
167
-
168
- ### `graphify update` — `No code files found` (exit 1) on `docs/srs` / `docs/basic-design`
169
-
170
- - **Means:** Those paths are empty or markdown-only; Graphify `update` AST-indexes **code** extensions (`.py`, `.ts`, `.js`, …), not SRS markdown alone.
171
- - **Fix:** **`ai-spector index`** / **`ai-spector graphify update`** skip empty and markdown-only sources automatically (success, not failure). Use **`docs/data-source`** for code Graphify indexing; SRS/basic-design semantics come from index doc-extract, not `graphify update`.
172
-
173
- ### `graphify update` — output under `docs/data-source/.ai-spector/...`
174
-
175
- - **Means:** `GRAPHIFY_OUT` was a **relative** path and Graphify resolved it from the **source directory** (`docs/data-source`), not the repo root.
176
- - **Fix:** Run **`ai-spector graphify update`** from the project root. Delete mistaken `docs/data-source/graphify-out/` or `docs/data-source/.ai-spector/.docflow/graph/graphify-out/` if present.
177
-
178
155
  ### `graph impact --git` — not a git repository / no changes
179
156
 
180
157
  - **Means:** `--git` needs a git working tree with staged or unstaged diffs.
@@ -188,13 +165,7 @@ After any workaround that wrote docs or graph patches: **`graph validate`** (and
188
165
  ### Stale graph or indexes after manual edits or generate SRS
189
166
 
190
167
  - **Means:** User changed `docs/data-source/`, SRS outputs, or templates without re-running ingest; graph still shows template-only domain nodes.
191
- - **Fix:** Run **`ai-spector index`**. Use **`--force-graphify`** if Graphify output must rebuild entirely.
192
- - **Still stale domain detail?** Re-run **analyze** for Graphify MCP → fresh `knowledge.json`.
193
-
194
- ### Graphify wrote `docs/data-source/graphify-out/` or `docs/data-source/.ai-spector/.../graphify-out/`
195
-
196
- - **Means:** `graphify update` ran without absolute `GRAPHIFY_OUT` from project root (or used a relative env path).
197
- - **Fix:** Run **`ai-spector graphify update`** (absolute `GRAPHIFY_OUT`, cwd = project root, removes stale folders). Do not copy files manually unless CLI failed and user approved workaround.
168
+ - **Fix:** Run **`ai-spector index`**. For fully stale domain detail, re-run **`/analyze`** → fresh `knowledge.json`.
198
169
 
199
170
  ---
200
171
 
@@ -203,7 +174,7 @@ After any workaround that wrote docs or graph patches: **`graph validate`** (and
203
174
  - Create missing parent dirs under `.ai-spector/` if `init` was incomplete.
204
175
  - Correct a **single** typo in `knowledge.json` id or `listedInSection` then re-run `graph merge`.
205
176
  - Re-run the **same** failed command once after an obvious fix (e.g. `cd` to project root).
206
- - Wrong CLI flags the agent introduced (e.g. `graphify update --graph`) — fix and retry immediately.
177
+ - Wrong CLI flags the agent introduced — fix and retry immediately.
207
178
 
208
179
  ## Agent must ask user before
209
180
 
@@ -3,21 +3,28 @@
3
3
  Used by **SRS**, **basic design**, and **detail design** generation skills.
4
4
 
5
5
  | Orchestration (scope, confirm, wave checklist, finish) | [generate-workflow.md](./generate-workflow.md) |
6
- | Per-command DAG + intent tables | `generate-srs.md`, `generate-basic-design.md`, `generate-detail-design.md` |
6
+ | Per-command DAG + intent tables | each skill's `references/runbook.md` |
7
7
 
8
8
  **Principle:** Accuracy over speed. The graph is the planner, context loader, and registry of what was written.
9
9
 
10
- **Parallelism:** Allowed **only inside a DAG wave** — targets that do not depend on each other (and whose dependencies are already ingested + indexed when required). Never parallelize across waves.
10
+ **Parallelism:** Allowed **only inside a DAG wave**. Never across waves.
11
11
 
12
- ## Agent rules (non-negotiable)
12
+ ## Edge presets (use these in queries — don't copy-paste long lists)
13
13
 
14
- 1. **Plan from DAG + graph** build **waves** from `dag.*.json` (see § Waves); map each node to a graph seed via `dag.*.graph-seeds.json`.
15
- 2. **Context before write** — for **every** target (batch or single), run CLI queries below; read `projectionPaths` and domain `nodes`/`edges`. No invented UC/F text.
16
- 3. **Dependencies before write** — for each target’s `dependsOn`, `graph query` dependency seeds and **read existing markdown** when `rendersTo` exists.
17
- 4. **Ingest before next wave** — after each file (or after a whole wave), merge `rendersTo` + `dependsOn` (see § Ingest), then `graph validate`. The next wave must see upstream `rendersTo` edges.
18
- 5. **No shortcuts** — no glob `docs/srs/**`, no skipping validate/query, no index-first generation, no batching targets that have a DAG dependency on each other.
14
+ | Preset name | Edges | Use for |
15
+ |-------------|-------|---------|
16
+ | `CONTEXT` | `listedIn,definedIn,describedIn,satisfies,dependsOn,rendersTo,partOf,contains` | Target neighborhood what exists and where it lives |
17
+ | `DEPS` | `rendersTo,dependsOn,listedIn,satisfies,partOf,contains` | Dependency context what upstream docs look like |
18
+ | `IMPACT` | `satisfies,tracesTo,dependsOn,references,relatesTo` | What a change would affect |
19
19
 
20
- ## CLI workflow per target
20
+ ## Agent rules
21
+
22
+ 1. **Plan from DAG** — build waves from `dag.*.json`; map each DAG node → graph seed via `dag.*.graph-seeds.json`.
23
+ 2. **Context before write** — for **every** target run the CONTEXT query; read `projectionPaths`. No invented UC/F text.
24
+ 3. **Merge once per wave, not per file** — write all files in a wave, then do one batch merge + one validate. Do not merge after every file.
25
+ 4. **No shortcuts** — no glob `docs/srs/**`, no skipping validate, no batching targets that have a DAG dependency on each other.
26
+
27
+ ## CLI workflow
21
28
 
22
29
  ### A. Gate (once per command)
23
30
 
@@ -25,75 +32,52 @@ Used by **SRS**, **basic design**, and **detail design** generation skills.
25
32
  ai-spector graph validate
26
33
  ```
27
34
 
28
- ### B. Plan
29
-
30
- - Load `dag.srs.json` (or matching DAG).
31
- - Load `dag.srs.graph-seeds.json` for `document` seeds.
32
- - Build **waves** (below).
33
- - Skip `good` files unless user asked to regenerate; use `graph impact` when replacing content.
34
-
35
- #### Waves (when batch is allowed)
35
+ ### B. Plan — waves
36
36
 
37
37
  Assign each DAG node to wave `0`, `1`, `2`, …:
38
38
 
39
- - **Wave 0:** nodes with empty `dependsOn`.
40
- - **Wave k:** nodes whose `dependsOn` are all in waves `< k` (not in the same wave).
41
-
42
- **Same wave = safe to generate in parallel** (no target in the wave depends on another target in that wave).
43
-
44
- **Example** (`dag.srs.json`): after `srs.feature-details`, both `srs.data-requirements` and `srs.external-interfaces` are in the **same wave** (each depends on feature-details only, not on each other) → may generate both in one batch.
45
-
46
- **Forbidden batch:** `srs.use-cases` + `srs.features-list` (features-list depends on use-cases).
47
-
48
- **User asks for specific files** (case 2): map paths → DAG nodes; include dependency closure; batch only within same wave.
39
+ - **Wave 0:** nodes with empty `dependsOn`
40
+ - **Wave k:** nodes whose `dependsOn` are all in waves `< k`
49
41
 
50
- **User describes scope in words** (case 3): [generate-workflow.md](./generate-workflow.md) § Case 3 confirm before write; intent phrase tables stay in each `generate-*.md`.
42
+ **Same wave = parallel OK.** Example: after `srs.feature-details`, both `srs.data-requirements` and `srs.external-interfaces` are in the same wave generate both in one batch.
51
43
 
52
44
  Present plan as:
53
45
 
54
- | Wave | DAG ids (parallel OK within row) | Seeds | Blocked until |
55
- |------|----------------------------------|-------|---------------|
46
+ | Wave | DAG ids (parallel OK) | Seeds | Blocked until |
47
+ |------|----------------------|-------|---------------|
56
48
  | 0 | … | … | — |
57
49
  | 1 | … | … | wave 0 merged + validate |
58
50
 
59
- ### C. Before writing file `T`
51
+ ### C. Before writing each target
60
52
 
61
- **1. Dependency context** (each DAG `dependsOn` id → graph seed):
53
+ **Dependency context** (once per wave, for each DAG `dependsOn`):
62
54
 
63
55
  ```bash
64
- ai-spector graph query <depSeedId> --direction both --depth 2 --edges rendersTo,dependsOn,listedIn,satisfies,definedIn,partOf,contains --json
56
+ ai-spector graph query <depSeedId> --direction both --depth 2 --edges DEPS --json
65
57
  ```
66
58
 
67
- Open existing `projectionPaths` from the JSON (already-generated SRS chapters).
68
-
69
- **2. Target neighborhood** (domain + structure):
59
+ **Target neighborhood:**
70
60
 
71
61
  ```bash
72
- ai-spector graph query <targetSeedId> --direction both --depth 4 --edges listedIn,definedIn,describedIn,satisfies,dependsOn,references,rendersTo,partOf,contains --json
62
+ ai-spector graph query <targetSeedId> --direction both --depth 4 --edges CONTEXT --json
73
63
  ```
74
64
 
75
- **3. Impact scope** (when regenerating or unsure):
65
+ **When regenerating** (unsure what changed):
76
66
 
77
67
  ```bash
78
68
  ai-spector graph impact <targetSeedId> --change content_change --json
79
69
  ```
80
70
 
81
- Respect `regenerate` / `review` buckets; do not rewrite unrelated chapters.
82
-
83
- **4. Data-source supplement** — only for gaps after graph query succeeds; cite paths in the doc.
84
-
85
71
  ### D. Write
86
72
 
87
- - **Read the template** from `.ai-spector/templates/` (path = DAG `template` value, e.g. `srs/3-use-cases.md`, `basic_design/list-api-template.md`). If missing, stop and ask the user to run `npx ai-spector init`.
88
- - Fill that template for the target only keep all required headings/sections; replace placeholders with graph-backed content.
73
+ - Read template from `.ai-spector/templates/` (DAG `template` field). If missing stop and ask user to run `npx ai-spector init`.
74
+ - Fill for this target only; keep all required headings; replace placeholders with graph-backed content.
89
75
  - Cross-check every UC/F reference against `nodes` from query JSON.
90
76
  - Add section anchors `<!-- section:sec.... -->` where templates expect them.
91
77
 
92
- ### E. Ingest (mandatory per file or per wave)
93
-
94
- After **each file**, or once at **end of a parallel wave** (single patch listing all files in that wave):
78
+ ### E. Ingest (once per wave not per file)
95
79
 
96
- Write `.ai-spector/.docflow/extract/projection-patch.json`:
80
+ After **all files in a wave** are written, write a single patch covering the whole wave:
97
81
 
98
82
  ```json
99
83
  {
@@ -101,51 +85,46 @@ Write `.ai-spector/.docflow/extract/projection-patch.json`:
101
85
  "nodes": [],
102
86
  "edges": [
103
87
  { "type": "rendersTo", "from": "doc.srs.3-use-cases", "to": "docs/srs/3-use-cases.md" },
104
- { "type": "dependsOn", "from": "doc.srs.3-use-cases", "to": "doc.srs.1-introduction" },
105
- { "type": "dependsOn", "from": "doc.srs.3-use-cases", "to": "doc.srs.2-overall-description" }
88
+ { "type": "dependsOn", "from": "doc.srs.3-use-cases", "to": "doc.srs.1-introduction" }
106
89
  ]
107
90
  }
108
91
  ```
109
92
 
110
- Then:
111
-
112
93
  ```bash
113
94
  ai-spector graph merge .ai-spector/.docflow/extract/projection-patch.json
114
95
  ai-spector graph validate
115
96
  ```
116
97
 
117
- - `rendersTo`: `from` = graph `document` (or section) id, `to` = repo-relative markdown path.
118
- - `dependsOn`: mirror DAG edges between **document** ids (downstream queries use these for context).
119
- - Per-domain files (`UC-01`, `F-01`): also link `definedIn` from domain node to detail sections if applicable.
98
+ Then for SRS and basic-design waves run index before starting the next wave:
120
99
 
121
- **Wave rule:** finish all writes in wave `k`, merge **all** `rendersTo` / `dependsOn` for that wave, `graph validate`, then **`ai-spector index`** (basic design and SRS generation — see command files), then start wave `k+1`.
100
+ ```bash
101
+ ai-spector index
102
+ ```
122
103
 
123
- Alternative repair: **`/sync-graph`** not a substitute for merge between waves.
104
+ **Exception:** if a file within the wave is a dependency for another file in the **same** wave (unusual — check the DAG), merge that file's `rendersTo` before writing the dependent. For standard DAGs this never happens within a wave.
124
105
 
125
106
  ### F. Per-domain detail files
126
107
 
127
- For `mode: perFeature` / `perDomain` DAG nodes (SRS):
108
+ For `mode: perFeature` / `perDomain` (SRS):
128
109
 
129
110
  - Seed = domain id (`UC-01`, `F-01`), not only chapter document.
130
- - Query with `--depth 4`; include inbound `satisfies` / `dependsOn`.
131
- - `rendersTo` from resolved output path (e.g. `docs/srs/03-use-cases/uc-01-....md`).
111
+ - Query with `--depth 4` + CONTEXT edges; include inbound `satisfies`.
112
+ - Batch all per-domain files in their wave; merge all `rendersTo` once at wave end.
132
113
 
133
- For `mode: perEndpoint` / `perScreen` (basic design — `dag.basic-design.graph-seeds.json`):
114
+ For `mode: perEndpoint` / `perScreen` (basic design):
134
115
 
135
- - **Do not** expand one file per `F-xx` feature.
136
- - **perEndpoint:** read `docs/basic-design/api-list.md` §3 Endpoint Summary; one markdown file per table row under `docs/basic-design/api/<slug>.md` (`slug` from method + path, e.g. `post-resource-id`).
137
- - **perScreen:** read `docs/basic-design/list-screens.md` §4 Screen Index; one file per screen under `docs/basic-design/screens/<slug>.md`.
138
- - List chapter lives at `docs/basic-design/list-screens.md` (not under `screens/`).
139
- - Query SRS + related `F-xx` for context on each endpoint/screen; ingest `doc.bd.api-*` / `doc.bd.screen-*` with `contains` from list chapter.
116
+ - **perEndpoint:** read `docs/basic-design/api-list.md` §3; one file per row under `docs/basic-design/api/<slug>.md`.
117
+ - **perScreen:** read `docs/basic-design/list-screens.md` §4; one file per screen under `docs/basic-design/screens/<slug>.md`.
118
+ - Ingest `doc.bd.api-*` / `doc.bd.screen-*` with `contains` from list chapter in the wave-end merge.
140
119
 
141
- ## Accuracy checklist (before marking target done)
120
+ ## Accuracy checklist
142
121
 
143
122
  - [ ] `graph query` run for target and every DAG dependency with existing files
144
123
  - [ ] All UC/F ids in markdown exist as graph nodes
145
- - [ ] `rendersTo` + `dependsOn` merged for this file
146
- - [ ] `graph validate` passes
124
+ - [ ] Wave-end `rendersTo` + `dependsOn` merged in one patch
125
+ - [ ] `graph validate` passes before next wave
147
126
  - [ ] No placeholder lorem / empty tables unless marked TBD in `gaps.json`
148
127
 
149
128
  ## On CLI failure
150
129
 
151
- [cli-failures.md](./cli-failures.md) — pause; offer fix / workaround / pause; do not generate from memory without user-approved workaround.
130
+ [cli-failures.md](./cli-failures.md) — pause; offer fix / workaround / pause; do not generate from memory.
@@ -104,7 +104,7 @@ Append one line per target to `.ai-spector/.docflow/logs/generate-<layer>.log` (
104
104
  3. Suggest the command doc’s summary command (`/summary srs`, `/summary basic-design`, …) when listed there
105
105
  4. Optional: `/visualize-graph` for review
106
106
 
107
- Index flags: `--skip-graphify` when only markdown under `docs/` changed; `--force-graphify` when `docs/data-source/` must rebuild.
107
+ Index flags: `--skip-doc-semantics` to skip UC/F body parsing; `--graph-only` for structure + merge only.
108
108
 
109
109
  ## Guardrails
110
110
 
@@ -14,7 +14,6 @@ Run from project root: `npx ai-spector …` if needed.
14
14
 
15
15
  ```bash
16
16
  ai-spector analyze
17
- ai-spector graphify update
18
17
  ai-spector graph merge --from-knowledge
19
18
  ai-spector graph validate
20
19
  ai-spector graph visualize [--open]
@@ -2,9 +2,9 @@
2
2
  name: ai-spector-generate-prototype
3
3
  description: >-
4
4
  Generates static HTML/CSS/JS screen prototypes from basic-design screen specs and bundled UI themes.
5
- Use when the user asks for HTML prototype, screen mockups, prototype/src files, or to pick a theme
6
- (vercel, stripe, etc.). Do not use for markdown SRS/basic/detail design only, or graph operations
7
- without HTML output.
5
+ Use when the user asks for HTML prototype, screen mockups, or prototype/src files. Asks user to
6
+ choose a theme if none is stored; uses stored preference on subsequent runs. Do not use for
7
+ markdown SRS/basic/detail design only, or graph operations without HTML output.
8
8
  paths:
9
9
  - "prototype/**"
10
10
  ---
@@ -15,13 +15,14 @@ paths:
15
15
 
16
16
  ## Required reading
17
17
 
18
- [references/runbook.md](references/runbook.md) — theme setup, manifest, HTML rules.
18
+ [references/runbook.md](references/runbook.md) — theme resolution (no upfront picker), manifest, HTML rules.
19
19
 
20
20
  ## Checklist
21
21
 
22
22
  ```
23
23
  - [ ] list-screens + screen detail docs exist
24
- - [ ] prototype setup --theme <name>
24
+ - [ ] theme resolved (request → theme.json → manifest → prototype.config.json → **ask user if none stored**)
25
+ - [ ] prototype setup (with --theme when needed; persists when user named a theme)
25
26
  - [ ] one .html per screen; prototypeStem from manifest
26
27
  - [ ] prototype manifest && prototype validate --strict
27
28
  ```
@@ -7,7 +7,7 @@ Generate **static HTML** prototypes from basic-design screen specs. All setup an
7
7
  ## Philosophy
8
8
 
9
9
  - **Screen design is source of truth** — `docs/basic-design/list-screens.md` + `docs/basic-design/screens/<slug>.md`
10
- - **Theme is chosen up front** — design tokens live in `prototype/DESIGN.md` (copied from bundled `assets/themes/<name>/`)
10
+ - **Theme must be confirmed before generating** — if no theme is stored, ask the user to choose one before running setup. Once the user has chosen (stored in `prototype/theme.json` or `prototype.config.json`), never ask again.
11
11
  - **One HTML per screen** — `prototype/src/<prototypeStem>.html` must match `prototype/manifest.json`
12
12
  - **Static only** — HTML/CSS/JS under `prototype/`; no frameworks, no CDN unless the theme DESIGN allows it
13
13
 
@@ -26,21 +26,39 @@ Generate **static HTML** prototypes from basic-design screen specs. All setup an
26
26
 
27
27
  ## Required behavior (agent runs CLI)
28
28
 
29
- ### 1. Choose theme and setup workspace
29
+ ### 1. Resolve theme and setup workspace
30
30
 
31
- List themes if the user did not specify one:
31
+ **Resolution order** (first match wins):
32
32
 
33
- ```bash
34
- ai-spector prototype themes
33
+ 1. Theme named in this request (`--theme`, “use stripe theme”, etc.)
34
+ 2. `prototype/theme.json` → `themeName`
35
+ 3. `prototype/manifest.json` → `themeName` (non-empty)
36
+ 4. `.ai-spector/.docflow/config/prototype.config.json` → `defaultTheme`
37
+
38
+ **If no stored theme is found**, ask the user to choose before proceeding:
39
+
40
+ ```
41
+ No theme is saved yet. Which UI theme would you like for your prototype?
42
+ Run `ai-spector prototype themes` to see all options, or name one (e.g. vercel, stripe, notion, linear.app).
35
43
  ```
36
44
 
45
+ Wait for the user's answer — do **not** silently default to `vercel`. Once the user names a theme, proceed with setup; the choice is persisted and will not be asked again.
46
+
37
47
  Setup (creates `prototype/`, copies `DESIGN.md`, seeds manifest when `list-screens.md` exists):
38
48
 
39
49
  ```bash
40
- ai-spector prototype setup --theme <name>
50
+ ai-spector prototype setup --theme <resolved-name>
41
51
  ```
42
52
 
43
- Default theme: `vercel` (override with `--theme` or user preference).
53
+ Omit `--theme` only when setup can infer the same name from stored files (the CLI reads `theme.json` / config automatically).
54
+
55
+ **Persist** when the user explicitly names a theme in this session: `prototype setup --theme <name>` updates `prototype/theme.json` and saves `defaultTheme` in `prototype.config.json` for later runs.
56
+
57
+ List themes when the user asks (“what themes?”, “list prototype themes”):
58
+
59
+ ```bash
60
+ ai-spector prototype themes
61
+ ```
44
62
 
45
63
  ### 2. Plan screens
46
64
 
@@ -76,13 +94,15 @@ git commit -m "chore(prototype): add HTML screens (<theme>)"
76
94
 
77
95
  | User says | Action |
78
96
  |-----------|--------|
79
- | “use stripe theme”, `--theme stripe` | `prototype setup --theme stripe --force-design` if switching theme mid-branch |
97
+ | “use stripe theme”, `--theme stripe` | `prototype setup --theme stripe` (persists preference); add `--force-design` if switching theme mid-branch |
80
98
  | “what themes?” | `ai-spector prototype themes` |
81
- | no preference | `vercel` or project default from `prototype.config.json` |
99
+ | no theme in message, no stored theme | **Ask the user** to name a theme before proceeding |
100
+ | no theme in message, stored theme found | Use stored theme — do not ask |
82
101
 
83
102
  ## Accuracy checklist
84
103
 
85
- - [ ] `prototype setup` run with agreed theme
104
+ - [ ] Theme resolved without blocking theme picker (unless user asked to list themes)
105
+ - [ ] `prototype setup` run with resolved theme
86
106
  - [ ] Every generated file name matches `prototypeStem` in manifest
87
107
  - [ ] Wireframe/layout from screen detail doc reflected in HTML
88
108
  - [ ] Tokens from `prototype/DESIGN.md` only (no random CDN)
@@ -60,7 +60,7 @@ After last wave ([generate-workflow.md](../../ai-spector/references/generate-wor
60
60
  ai-spector index
61
61
  ```
62
62
 
63
- `index` parses UC/F/actor ids and adds `doc.srs.uc-*` / `doc.srs.f-*` document + section nodes. Use `--force-graphify` only when data-source hashes must rebuild.
63
+ `index` parses UC/F/actor ids from markdown bodies and adds `doc.srs.uc-*` / `doc.srs.f-*` document + section nodes.
64
64
 
65
65
  Suggest `/summary srs` after index. Log: `.ai-spector/.docflow/logs/generate-srs.log`.
66
66
 
@@ -18,7 +18,7 @@ The agent runs all CLI steps below — see [WORKFLOW.md](../../WORKFLOW.md).
18
18
 
19
19
  ## Required Behavior
20
20
 
21
- ### 0. Prepare graph structure (CLI — agent runs first)
21
+ ### 0. Prepare graph structure
22
22
 
23
23
  ```bash
24
24
  ai-spector analyze
@@ -26,38 +26,27 @@ ai-spector analyze
26
26
 
27
27
  Creates section/document nodes from templates. Do not ask the user to run this separately.
28
28
 
29
- ### A. Extract (semantic-first; Graphify sidecar)
29
+ ### A. Extract from markdown sources
30
30
 
31
- 1. Load `data-source.json`, `analyze.graphify.json`.
32
- 2. **Graphify paths (from `ai-spector init`):**
33
- - Output dir: `.ai-spector/.docflow/graph/graphify-out` (`GRAPHIFY_OUT`)
34
- - Graph file: `.ai-spector/.docflow/graph/graphify-out/graph.json` (MCP + queries use `--graph` only on `graphify query`, not on `update`)
35
- 3. **Code ingest sidecar (CLI — agent runs):**
31
+ 1. Load `data-source.json` to resolve the data-source root (default: `docs/data-source/`).
32
+ 2. **Read all markdown files** under that root directly — each file is well-structured markdown with headings, tables, and labeled fields.
33
+ 3. Extract the following entities, mapping them to their canonical ids and fields:
36
34
 
37
- ```bash
38
- ai-spector graphify update
39
- ```
40
-
41
- This runs `graphify update docs/data-source` with `GRAPHIFY_OUT` set. **Forbidden:** `graphify update --graph …` (`unknown option: --graph`).
42
-
43
- Fallback if needed:
44
-
45
- ```bash
46
- GRAPHIFY_OUT=.ai-spector/.docflow/graph/graphify-out graphify update docs/data-source
47
- ```
48
-
49
- The command removes stale `docs/data-source/graphify-out/` if Graphify created it by mistake.
35
+ | Entity | `id` | Required fields | Links |
36
+ |--------|------|-----------------|-------|
37
+ | use case | `UC-01` | `title` | — |
38
+ | feature | `F-01` | `title` | `satisfies`: `["UC-01"]` |
39
+ | actor | `actor.customer` | `name` or `title` | |
40
+ | functional requirement | `FR-01` | `title` | `tracesTo` optional |
41
+ | NFR | `NFR-01` | `title` | — |
42
+ | data entity | `ENT-Order` | `name` | — |
50
43
 
51
- 4. **Semantic extract (Graphify MCP)** — query profiles in `analyze.graphify.json`; use graph at `graphJsonPath` for `graphify query "…" --graph .ai-spector/.docflow/graph/graphify-out/graph.json`.
52
- 5. Resolve paths → `scope.json` → `sources`.
53
- 6. Query / fallback to extract:
54
- - actors, useCases, features, functionalRequirements, nfrs, entities, interfaces, constraints, openQuestions
55
- 7. Persist staging (canonical for AI Spector):
56
- - `.ai-spector/.docflow/analysis/knowledge.json` (see package `schemas/schema.knowledge.json`)
44
+ 4. Persist staging (canonical for AI Spector):
45
+ - `.ai-spector/.docflow/analysis/knowledge.json` (schema: `schemas/schema.knowledge.json`)
57
46
  - `.ai-spector/.docflow/analysis/gaps.json`
58
47
  - `.ai-spector/.docflow/analysis/scope.json`
59
48
 
60
- ### B. Commit to graph (CLI — agent runs; no hand-edited graph JSON)
49
+ ### B. Commit to graph
61
50
 
62
51
  ```bash
63
52
  ai-spector graph merge --from-knowledge
@@ -70,18 +59,6 @@ Optional for the user:
70
59
  ai-spector graph visualize --open
71
60
  ```
72
61
 
73
- Or suggest **`/visualize-graph`**.
74
-
75
- **`knowledge.json` minimum fields:**
76
-
77
- | Entity | `id` | `title` / `name` | `listedInSection` (optional) | Links |
78
- |--------|------|------------------|------------------------------|-------|
79
- | use case | `UC-01` | required | defaults to §3.2 list section | — |
80
- | feature | `F-01` | required | defaults to §4.2 list section | `satisfies`: `["UC-01"]` |
81
- | actor | `actor.customer` | `name` or `title` | defaults to §2.2 user classes | — |
82
- | requirement | `REQ-01` | required | section id | `tracesTo` optional |
83
- | entity | `ENT-Order` | `name` | defaults to §5.2 logical model | — |
84
-
85
62
  ### C. State
86
63
 
87
64
  Update `state.json`: `analysis.lastRunAt`, `analysis.dataSource`, scope hash. Merge sets `analysis.graphMergedAt`.
@@ -94,19 +71,16 @@ Update `state.json`: `analysis.lastRunAt`, `analysis.dataSource`, scope hash. Me
94
71
 
95
72
  ## CLI steps — stop on first failure
96
73
 
97
- Run in order. If any step fails, **pause** and use [cli-failures.md](../../ai-spector/references/cli-failures.md) (show full CLI output; offer fix / workaround / pause). Do not skip to merge, validate, or generate SRS without user choice.
98
-
99
74
  | Step | Command |
100
75
  |------|---------|
101
76
  | 0 | `ai-spector analyze` |
102
77
  | B | `ai-spector graph merge --from-knowledge` |
103
78
  | B | `ai-spector graph validate` |
104
79
 
105
- Graphify indexing is **sidecar** for code-aware context. Markdown-only or empty sources may skip Graphify and continue.
106
- Only block if semantic extract / `knowledge.json` generation fails.
80
+ If any step fails, **pause** and use [cli-failures.md](../../ai-spector/references/cli-failures.md). Do not skip to generate SRS without user choice.
107
81
 
108
82
  ## If blocked
109
83
 
110
- Use the **Blocked** template in [cli-failures.md](../../ai-spector/references/cli-failures.md). Include which step failed, exit code, verbatim CLI output, fix steps, optional workaround, and **1 / 2 / 3** choices. Offer to apply small fixes (e.g. one bad `listedInSection`) then re-run the same step.
84
+ Use the **Blocked** template in [cli-failures.md](../../ai-spector/references/cli-failures.md). Include which step failed, exit code, verbatim CLI output, fix steps, and **1 / 2 / 3** choices.
111
85
 
112
86
  **Do not:** hand-edit the full graph, generate SRS, or read all of `docs/srs/` as a workaround.