ai-spector 0.8.6 → 0.8.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-spector",
3
- "version": "0.8.6",
3
+ "version": "0.8.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",
@@ -13,86 +13,88 @@ description: "Runs AI Spector traceability graph operations: analyze data-source
13
13
  - "what's the impact of my changes", "what should I regenerate"
14
14
  - "visualize the graph"
15
15
 
16
- ## Workflow
16
+ ## Invocation rule
17
17
 
18
- ```
19
- 1. Identify intent → pick runbook below
20
- 2. Run CLI from project root (npx ai-spector)
21
- 3. On failure: show output, offer fix/workaround/pause
22
- 4. If the tool or workflow caused friction (even if recovered): offer to write a feedback report to docs/feedback/
23
- ```
18
+ Use **MCP tools** when `ai-spector` server is configured. CLI is fallback only.
24
19
 
25
20
  ## Runbooks by intent
26
21
 
27
22
  ### Analyze (ingest data-source)
28
23
 
29
- ```bash
30
- npx ai-spector analyze
24
+ ```
25
+ analyze({}) # MCP — prepare graph scaffold
26
+ # agent extracts entities → writes knowledge.json
27
+ knowledge_validate({}) # MCP — validate before merge
28
+ knowledge_status({}) # MCP — confirm entity counts
29
+ graph_merge({ fromKnowledge: true }) # MCP — commit to graph
30
+ graph_validate({}) # MCP — verify result
31
31
  ```
32
32
 
33
- Reads `docs/data-source/`, builds knowledge graph, writes `.ai-spector/graph/`. Run after adding or changing source files.
33
+ CLI fallback: `npx ai-spector analyze` `npx ai-spector graph merge --from-knowledge` `npx ai-spector graph validate`
34
34
 
35
35
  ### Index (refresh after doc edits)
36
36
 
37
- ```bash
38
- npx ai-spector index
39
37
  ```
38
+ index({ cocoindexSync: true }) # MCP — refresh graph + embeddings
39
+ ```
40
+
41
+ CLI fallback: `npx ai-spector index && npx ai-spector cocoindex index`
40
42
 
41
- Updates fingerprints, reconciles translation queue. Run after any doc edit. **Always run index before checking translation status.**
43
+ **Always run index before checking translation status.**
42
44
 
43
45
  ### Validate
44
46
 
45
- ```bash
46
- npx ai-spector graph validate
47
+ ```
48
+ graph_validate({}) # MCP
49
+ graph_report({}) # MCP — layer health audit
47
50
  ```
48
51
 
49
- Reports broken references, missing nodes, DAG errors. Fix errors before generating docs.
52
+ CLI fallback: `npx ai-spector graph validate`
50
53
 
51
54
  ### Impact (what to regenerate)
52
55
 
53
- ```bash
54
- # Current git diff (most common)
55
- npx ai-spector graph impact --git --change content_change --json
56
-
57
- # Specific file
58
- npx ai-spector graph impact --file <repo-relative-path> --json
59
-
60
- # Specific node
61
- npx ai-spector graph impact <originId> --change content_change --json
56
+ ```
57
+ graph_impact({ git: true, change: "content_change" }) # git diff
58
+ graph_impact({ originId: "<id>", change: "content_change" }) # specific node
59
+ graph_impact({ file: "<path>", change: "content_change" }) # specific file
62
60
  ```
63
61
 
64
- Output buckets: `regenerate` (must redo), `review` (may need update).
65
- - `noTraceabilityImpact: true` → changed files not in graph (config, source code, etc.) — no doc regen needed
66
- - `truncated: true` → BFS hit propagation cap — results may be incomplete, warn user
62
+ CLI fallback: `npx ai-spector graph impact --git --change content_change --json`
67
63
 
68
- Report the table with `projectionPath`. For each `regenerate` entry, suggest the appropriate generate skill.
64
+ Output buckets: `regenerate` (must redo), `review` (may need update), `semanticSuggestions` (CocoIndex).
65
+ - `noTraceabilityImpact: true` → changed files not in graph — no doc regen needed
66
+ - `truncated: true` → BFS hit cap — results may be incomplete, warn user
69
67
 
70
- **Run this after every doc edit**, then run `npx ai-spector index`.
68
+ **Run after every doc edit**, then `index({ cocoindexSync: true })`.
71
69
 
72
- ### Visualize
70
+ ### Query a node
73
71
 
74
- ```bash
75
- npx ai-spector graph visualize --open
72
+ ```
73
+ graph_query({ seedId: "<id>" }) # MCP — walk subgraph
74
+ graph_query_fuzzy({ query: "…" }) # MCP — natural language lookup
76
75
  ```
77
76
 
78
- ### Query a node
77
+ CLI fallback: `npx ai-spector graph query <id> --json`
78
+
79
+ ### Visualize
79
80
 
80
81
  ```bash
81
- npx ai-spector graph query <id-or-text> --json
82
+ npx ai-spector graph visualize --open # CLI only — no MCP equivalent
82
83
  ```
83
84
 
84
85
  ## Checklist
85
86
 
86
87
  ```
87
88
  - [ ] Identified correct runbook
88
- - [ ] Ran CLI from project root
89
+ - [ ] Used MCP tools (not CLI) when ai-spector server is configured
90
+ - [ ] After doc edits: graph_impact + index({ cocoindexSync: true })
89
91
  - [ ] Presented output to user (impact table, validate errors, etc.)
90
- - [ ] After doc edits: ran impact + index
91
92
  - [ ] On failure: showed output, offered fix/workaround
92
93
  ```
93
94
 
94
95
  ## Rules
95
96
 
96
- - Do not implement impact BFS manually — always use CLI
97
- - Do not invent regen lists if impact CLI failed
98
- - Do not run whole-repo regen outside CLI buckets
97
+ - Do not implement impact BFS manually — always use MCP or CLI tool
98
+ - Do not invent regen lists if impact tool failed
99
+ - Do not run whole-repo regen outside tool buckets
100
+ - Never skip `cocoindexSync` when CocoIndex is configured and docs changed
@@ -21,14 +21,23 @@ If only one language: reply "Only one language configured — nothing to compare
21
21
 
22
22
  ### 2. Refresh the index first (MANDATORY)
23
23
 
24
- ```bash
25
- npx ai-spector index
24
+ ```
25
+ index({}) # MCP preferred
26
+ npx ai-spector index # CLI fallback
26
27
  ```
27
28
 
28
29
  The queue is only accurate after indexing. **Never skip this step** — reading `pending.json` without indexing shows stale data.
29
30
 
30
31
  ### 3. Read the queue
31
32
 
33
+ **MCP (preferred):**
34
+ ```
35
+ lang_queue({}) # pending + summary
36
+ lang_queue({ status: "failed" }) # failed jobs
37
+ lang_queue({ lang: "jp" }) # filter by language
38
+ ```
39
+
40
+ **CLI fallback:**
32
41
  ```bash
33
42
  npx ai-spector lang queue pending --json
34
43
  npx ai-spector lang queue failed --json
@@ -70,9 +79,9 @@ If queue is empty or missing after index, fall back to git mtime comparison acro
70
79
 
71
80
  ```
72
81
  - [ ] Read docflow.config.json → languages[]
73
- - [ ] Ran npx ai-spector index (mandatory before queue read)
74
- - [ ] Ran lang queue pending --json
75
- - [ ] Ran lang queue failed --json
82
+ - [ ] Ran index({}) MCP (or npx ai-spector index) mandatory before queue read
83
+ - [ ] Ran lang_queue({}) MCP (or lang queue pending --json)
84
+ - [ ] Ran lang_queue({ status: "failed" }) MCP (or lang queue failed --json)
76
85
  - [ ] Rendered pending + failed tables
77
86
  - [ ] Offered resolve-translation if pending jobs exist
78
87
  ```
@@ -30,33 +30,46 @@ npx ai-spector index # CLI fallback
30
30
 
31
31
  Then read the queue. **Never read `.ai-spector/.docflow/translation-queue/pending.json` without running index first** — the queue is only accurate after indexing.
32
32
 
33
- ### 3. Check impact before finishing any doc edit
33
+ ### 3. Check impact and refresh embeddings after any doc edit
34
34
 
35
- After editing any file under `docs/srs/`, `docs/basic-design/`, or `docs/detail-design/`, run impact before closing the task:
35
+ After editing any file under `docs/srs/`, `docs/basic-design/`, or `docs/detail-design/`:
36
36
 
37
+ **a) Impact:**
37
38
  ```
38
39
  graph_impact({ git: true, change: "content_change" }) # MCP preferred
39
40
  npx ai-spector graph impact --git --change content_change --json # CLI fallback
40
41
  ```
41
42
 
42
- Then refresh index:
43
+ **b) Re-index + embeddings (mandatory when CocoIndex is configured):**
44
+ ```
45
+ index({ cocoindexSync: true }) # preferred — refreshes graph + embeddings in one call
46
+ ```
43
47
 
48
+ Or separately:
44
49
  ```
45
50
  index({})
51
+ cocoindex_index({})
46
52
  ```
47
53
 
48
- Skip only when the user explicitly says it was a typo-only fix with no traceability concern.
54
+ CLI fallback: `npx ai-spector index && npx ai-spector cocoindex index`
55
+
56
+ Skip impact/index only when the user explicitly says it was a typo-only fix with no traceability concern. **Never skip `cocoindexSync` when CocoIndex is configured** — semantic search goes stale silently.
49
57
 
50
58
  ### 4. Use MCP/graph — not file search
51
59
 
52
60
  | Need | MCP (preferred) | CLI fallback |
53
61
  |------|-----------------|--------------|
62
+ | Prepare graph scaffold | `analyze({})` | `npx ai-spector analyze` |
63
+ | Check knowledge.json before merge | `knowledge_status({})` · `knowledge_validate({})` | *(no CLI)* |
64
+ | Merge knowledge → graph | `graph_merge({ fromKnowledge: true })` | `npx ai-spector graph merge --from-knowledge` |
54
65
  | Find what needs regeneration | `graph_impact({ git: true, change: "content_change" })` | `npx ai-spector graph impact --git --json` |
55
- | Find node by exact ID | `graph_query({ id: "…" })` | `npx ai-spector graph query <id> --json` |
56
- | Find node by concept | `graph_query_fuzzy(query: "…")` — requires CocoIndex | — |
57
- | Search docs by meaning | `docs_search(query: "…")` — requires CocoIndex | — |
58
- | Check graph health | `graph_validate({})` | `npx ai-spector graph validate` |
59
- | See pending translations | *(CLI only)* | `npx ai-spector lang queue pending --json` (after index) |
66
+ | Find node by exact ID | `graph_query({ seedId: "…" })` | `npx ai-spector graph query <id> --json` |
67
+ | Find node by concept | `graph_query_fuzzy({ query: "…" })` — requires CocoIndex | — |
68
+ | Search docs by meaning | `docs_search({ query: "…" })` — requires CocoIndex | — |
69
+ | Check graph health | `graph_validate({})` · `graph_report({})` | `npx ai-spector graph validate` |
70
+ | Translation queue | `lang_queue({})` | `npx ai-spector lang queue pending --json` (after index) |
71
+ | CocoIndex readiness | `cocoindex_status({})` | `npx ai-spector setup --check` |
72
+ | Rebuild embeddings | `cocoindex_index({})` or `index({ cocoindexSync: true })` | `npx ai-spector cocoindex index` |
60
73
 
61
74
  **Only fall back to `grep` or `Read` when the tool returns no results or you need raw file content for editing.**
62
75
 
@@ -83,11 +96,21 @@ Skip only when the user explicitly says it was a typo-only fix with no traceabil
83
96
 
84
97
  | Tool | Purpose |
85
98
  |------|---------|
86
- | `index({})` | Refresh fingerprints + translation queue |
99
+ | `analyze({})` | Prepare graph scaffold from templates |
100
+ | `knowledge_status({})` | Check knowledge.json entity counts |
101
+ | `knowledge_validate({})` | Validate knowledge.json schema |
87
102
  | `graph_merge({ fromKnowledge: true })` | Merge knowledge.json into graph |
88
103
  | `graph_validate({})` | Check graph integrity |
89
- | `graph_impact({ git: true, change: "content_change" })` | Impact of current git diff |
90
- | `graph_query({ id: "…" })` | Walk graph from a node |
104
+ | `graph_report({})` | Graph layer health audit |
105
+ | `graph_impact({ git: true, change: "…" })` | Impact of current git diff |
106
+ | `graph_query({ seedId: "…" })` | Walk graph from a node |
107
+ | `index({})` | Refresh graph + translation queue |
108
+ | `index({ cocoindexSync: true })` | Refresh graph + translation queue + embeddings |
109
+ | `lang_queue({})` | Translation queue status |
110
+ | `cocoindex_status({})` | CocoIndex readiness check |
111
+ | `cocoindex_index({})` | Rebuild semantic embeddings |
112
+ | `docs_search({ query })` | Semantic doc search (CocoIndex) |
113
+ | `graph_query_fuzzy({ query })` | Natural language graph lookup (CocoIndex) |
91
114
 
92
115
  ### CLI (fallback / MCP-unavailable or no tool equivalent)
93
116
 
@@ -1,6 +1,6 @@
1
1
  # AI Spector workflow
2
2
 
3
- **You describe what you need in chat.** Cursor picks the right **skill**; the agent runs **`npx ai-spector`** CLI. You do not need to memorize command names.
3
+ **You describe what you need in chat.** Cursor picks the right **skill**; the agent calls **MCP tools** (when `ai-spector` server is configured) or falls back to **`npx ai-spector`** CLI. You do not need to memorize command names.
4
4
 
5
5
  Enable all skills under `.cursor/skills/` (see [skills/README.md](./skills/README.md)). On CLI or tool failure: agent pauses, shows output, and offers fix / workaround / pause — [cli-failures](./skills/ai-spector/references/cli-failures.md).
6
6
 
@@ -21,24 +21,24 @@ Then: add files under `docs/data-source/`, enable **all** skills under `.cursor/
21
21
 
22
22
  ## What to say → skill → agent does
23
23
 
24
- | You want to… | Say (examples) | Skill | Agent runs (summary) |
25
- |--------------|----------------|-------|----------------------|
24
+ | You want to… | Say (examples) | Skill | Agent runs (MCP preferred) |
25
+ |--------------|----------------|-------|---------------------------|
26
26
  | **Setup project** | “setup ai-spector”, “initialize project”, “get started” | `ai-spector-setup` | `setup --check` → `setup -y` → enable skills checklist |
27
- | Ingest sources | “analyze my data source”, “build the knowledge graph” | `ai-spector-graph` | `analyze` → read markdownmerge knowledgevalidate |
28
- | Check graph | “validate the graph”, “graph errors” | `ai-spector-graph` | `graph validate` |
29
- | Refresh after edits | “re-index”, “sync the graph” | `ai-spector-graph` | `npx ai-spector index` |
30
- | Write SRS | “generate SRS”, “write use cases” | `ai-spector-generate-srs` | DAG waves → docs/srs → merge → index |
31
- | Basic design | “screen list”, “API design”, “wireframes” | `ai-spector-generate-basic-design` | docs/basic-design → merge → index each wave |
27
+ | Ingest sources | “analyze my data source”, “build the knowledge graph” | `ai-spector-graph` | `analyze({})` → agent extracts`knowledge_validate` `graph_merge` `graph_validate` |
28
+ | Check graph health | “validate the graph”, “graph errors”, “graph report” | `ai-spector-graph` | `graph_validate({})` · `graph_report({})` |
29
+ | Refresh after edits | “re-index”, “sync the graph” | `ai-spector-graph` | `index({ cocoindexSync: true })` (or `index({})` if no CocoIndex) |
30
+ | Write SRS | “generate SRS”, “write use cases” | `ai-spector-generate-srs` | DAG waves → docs/srs → `graph_merge``index({ cocoindexSync: true })` |
31
+ | Basic design | “screen list”, “API design”, “wireframes” | `ai-spector-generate-basic-design` | docs/basic-design → `graph_merge``index({ cocoindexSync: true })` each wave |
32
32
  | Detail design | “detail design for checkout” | `ai-spector-generate-detail-design` | docs/detail-design |
33
33
  | HTML prototype | “HTML mockup”, “prototype with stripe theme” | `ai-spector-generate-prototype` | auth picker (if needed) → theme picker → setup → HTML → validate |
34
- | Pick / preview UI theme | “help me pick a theme”, “show me themes”, “what fits my app?” | `ai-spector-generate-prototype` | read project context → recommend 3 → `prototype preview` ×3 |
35
- | What to redo | “what’s impacted”, “what should I regenerate” | `ai-spector-graph` | `graph impact` / git diff — includes semantic suggestions if CocoIndex configured |
36
- | Find docs by concept | “find all mentions of rate limiting”, “which docs describe login?” | `ai-spector-search` | `docs_search` MCP tool or `cocoindex search --query` |
37
- | Find graph node by name | “show graph for user login” (node ID unknown) | `ai-spector-search` | `graph_query_fuzzy` MCP tool |
38
- | Translation status | “what’s stale in JP”, “pending translations” | `ai-spector-lang-status` | `lang queue pending` |
39
- | Sync translations | “resolve translations”, “update JP from EN” | `ai-spector-resolve-translation` | read queue → translate → `index` |
34
+ | Pick / preview UI theme | “help me pick a theme”, “show me themes | `ai-spector-generate-prototype` | read project context → recommend 3 → `prototype preview` ×3 |
35
+ | What to redo | “what’s impacted”, “what should I regenerate” | `ai-spector-graph` | `graph_impact({ git: true, change: “…” })` — includes `semanticSuggestions` when CocoIndex ready |
36
+ | Find docs by concept | “find all mentions of rate limiting”, “which docs describe login?” | `ai-spector-search` | `docs_search({ query })` MCP |
37
+ | Find graph node by name | “show graph for user login” (node ID unknown) | `ai-spector-search` | `graph_query_fuzzy({ query })` MCP |
38
+ | Translation status | “what’s stale in JP”, “pending translations” | `ai-spector-lang-status` | `lang_queue({})` MCP |
39
+ | Sync translations | “resolve translations”, “update JP from EN” | `ai-spector-resolve-translation` | read queue → translate → `index({ cocoindexSync: true })` |
40
40
  | Review comments | “resolve comments”, “fix C-001” | `ai-spector-resolve-comments` | inbox → plan → edit → commit |
41
- | Explore graph | “show the graph” | `ai-spector-graph` | `graph visualize --open` |
41
+ | Explore graph | “show the graph” | `ai-spector-graph` | `npx ai-spector graph visualize --open` (no MCP equivalent) |
42
42
 
43
43
  Unsure? The agent uses [skills/_skill-router.md](./skills/_skill-router.md) or asks one clarifying question.
44
44
 
@@ -18,14 +18,40 @@ When the `ai-spector` MCP server is enabled (`.cursor/mcp.json` or `.mcp.json` l
18
18
 
19
19
  | Operation | MCP tool | CLI fallback |
20
20
  |-----------|----------|--------------|
21
- | Re-index project | `index({})` | `npx ai-spector index` |
21
+ | Prepare graph scaffold | `analyze({})` | `npx ai-spector analyze` |
22
+ | Check knowledge.json entity counts | `knowledge_status({})` | *(no CLI equivalent)* |
23
+ | Validate knowledge.json schema | `knowledge_validate({})` | *(no CLI equivalent)* |
22
24
  | Merge knowledge → graph | `graph_merge({ fromKnowledge: true })` | `npx ai-spector graph merge --from-knowledge` |
23
25
  | Validate graph | `graph_validate({})` | `npx ai-spector graph validate` |
26
+ | Graph layer health audit | `graph_report({})` | `npx ai-spector graph report --json` |
24
27
  | Impact analysis | `graph_impact({ originId, change })` | `npx ai-spector graph impact …` |
25
- | Walk graph from node | `graph_query({ id, })` | `npx ai-spector graph query <id> --json` |
26
- | **Analyze data-source** | *(no MCP tool — CLI only)* | `npx ai-spector analyze` |
28
+ | Walk graph from node | `graph_query({ seedId })` | `npx ai-spector graph query <id> --json` |
29
+ | Re-index project | `index({})` | `npx ai-spector index` |
30
+ | Re-index + refresh embeddings | `index({ cocoindexSync: true })` | `npx ai-spector index && npx ai-spector cocoindex index` |
31
+ | Translation queue status | `lang_queue({})` | `npx ai-spector lang queue pending --json` |
32
+ | CocoIndex readiness | `cocoindex_status({})` | `npx ai-spector setup --check` |
33
+ | Rebuild semantic embeddings | `cocoindex_index({})` | `npx ai-spector cocoindex index` |
34
+ | Semantic doc search | `docs_search({ query })` | `npx ai-spector cocoindex search --query …` |
35
+ | Natural language graph lookup | `graph_query_fuzzy({ query })` | *(no CLI equivalent)* |
36
+ | **Visualize graph** | *(no MCP tool)* | `npx ai-spector graph visualize --open` |
37
+
38
+ Use CLI **only** when: MCP server is not configured, the tool errors, or no MCP equivalent exists (visualize, `lang add`, template mutations).
39
+
40
+ ### After any batch of doc edits
41
+
42
+ When you finish editing files under `docs/` — always close out with:
43
+
44
+ ```
45
+ index({ cocoindexSync: true }) # preferred: refreshes graph + embeddings in one call
46
+ ```
47
+
48
+ Or if CocoIndex is not configured:
49
+
50
+ ```
51
+ index({})
52
+ ```
27
53
 
28
- Use CLI **only** when: MCP server is not configured, the tool errors and MCP is unavailable, or the operation has no MCP equivalent (e.g. `analyze`).
54
+ **Never skip the embedding refresh** when CocoIndex is set up semantic search and `graph_impact` `semanticSuggestions` go stale silently.
29
55
 
30
56
  ## CLI and tool failure (non-negotiable)
31
57
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Ingest `docs/data-source/` and commit knowledge into the traceability graph.
4
4
 
5
- Step 0 (`npx ai-spector analyze`) is **CLI-only** — no MCP equivalent. Steps B (merge, validate) use **MCP when available**.
5
+ All steps have MCP equivalents. Use MCP when the `ai-spector` server is configured.
6
6
 
7
7
  ## Usage
8
8
 
@@ -20,6 +20,12 @@ Step 0 (`npx ai-spector analyze`) is **CLI-only** — no MCP equivalent. Steps B
20
20
 
21
21
  ### 0. Prepare graph structure
22
22
 
23
+ **MCP (preferred):**
24
+ ```
25
+ analyze({})
26
+ ```
27
+
28
+ **CLI fallback:**
23
29
  ```bash
24
30
  npx ai-spector analyze
25
31
  ```
@@ -82,7 +88,10 @@ Update `state.json`: `analysis.lastRunAt`, `analysis.dataSource`, scope hash. Me
82
88
 
83
89
  | Step | MCP (preferred) | CLI fallback |
84
90
  |------|-----------------|--------------|
85
- | 0 | *(CLI only — no MCP tool)* | `npx ai-spector analyze` |
91
+ | 0 prepare | `analyze({})` | `npx ai-spector analyze` |
92
+ | A extraction | Agent writes `knowledge.json` | Agent writes `knowledge.json` |
93
+ | A verify | `knowledge_status({})` → check `ready: true` | *(no CLI)* |
94
+ | A validate | `knowledge_validate({})` → check `valid: true` | *(no CLI)* |
86
95
  | B merge | `graph_merge({ fromKnowledge: true })` | `npx ai-spector graph merge --from-knowledge` |
87
96
  | B validate | `graph_validate({})` | `npx ai-spector graph validate` |
88
97
 
@@ -20,14 +20,24 @@ paths:
20
20
 
21
21
  2. **Refresh the index first** — the queue is only accurate after indexing:
22
22
 
23
- ```bash
24
- npx ai-spector index
25
23
  ```
24
+ index({}) # MCP preferred
25
+ npx ai-spector index # CLI fallback
26
+ ```
27
+
28
+ Skip only if the user explicitly says they just ran it.
26
29
 
27
- This scans all doc files, updates fingerprints, and reconciles pending/resolved jobs in the translation queue. Skip only if the user explicitly says they just ran it.
30
+ 3. Read the translation queue (primary source of truth):
28
31
 
29
- 3. Run the translation queue CLI (primary source of truth):
32
+ **MCP (preferred):**
33
+ ```
34
+ lang_queue({}) # pending jobs + summary
35
+ lang_queue({ status: "failed" }) # failed jobs
36
+ lang_queue({ status: "all" }) # everything
37
+ lang_queue({ lang: "jp" }) # filter by language
38
+ ```
30
39
 
40
+ **CLI fallback:**
31
41
  ```bash
32
42
  npx ai-spector lang queue pending --json
33
43
  npx ai-spector lang queue failed --json
@@ -113,7 +123,7 @@ List actionable items per job:
113
123
 
114
124
  ## After any file edit (outside of generate skills)
115
125
 
116
- When the user edits any language file directly, run `npx ai-spector index` (or `lang queue scan`). The queue enqueues section-level sync jobs automatically — no manual stale notes needed.
126
+ When the user edits any language file directly, run `index({})` (MCP) or `npx ai-spector index`. The queue enqueues section-level sync jobs automatically — no manual stale notes needed.
117
127
 
118
128
  If the user defers translation, the job stays in `pending.json` until processed.
119
129
 
@@ -35,15 +35,16 @@ surface related docs that have no formal graph edge.
35
35
 
36
36
  Find all document sections about a concept:
37
37
 
38
- ```bash
39
- npx ai-spector cocoindex search --query "rate limiting" --json
40
- ```
41
-
42
- Or via MCP:
38
+ **MCP (preferred):**
43
39
  ```
44
40
  docs_search(query: "rate limiting", limit: 5)
45
41
  ```
46
42
 
43
+ **CLI fallback:**
44
+ ```bash
45
+ npx ai-spector cocoindex search --query "rate limiting" --json
46
+ ```
47
+
47
48
  Response includes `graphNodeId` when the matched section maps to a traceability node.
48
49
  Use that to run `graph_query` for full context.
49
50
 
@@ -109,19 +110,37 @@ No code change needed — chain two MCP calls:
109
110
 
110
111
  ## Setup check
111
112
 
112
- Before using any semantic workflow, verify CocoIndex is configured:
113
+ Before using any semantic workflow, verify CocoIndex is ready:
114
+
115
+ **MCP (preferred):**
116
+ ```
117
+ cocoindex_status({})
118
+ ```
119
+
120
+ Check `ready: true`. If any issue is listed, fix it before searching.
113
121
 
122
+ **CLI fallback:**
114
123
  ```bash
115
124
  npx ai-spector setup --check
116
125
  ```
117
126
 
118
- If CocoIndex is missing:
119
- ```bash
120
- npx ai-spector cocoindex setup
121
- cd .ai-spector/.docflow/cocoindex
122
- cp .env.example .env # edit if needed
123
- pip install -r requirements.txt
124
- python pipeline.py cocoindex update
127
+ If CocoIndex is missing, run `npx ai-spector cocoindex setup` (or ask agent to set it up via `ai-spector-setup` skill).
128
+
129
+ ---
130
+
131
+ ## Rebuild embeddings after doc edits
132
+
133
+ Semantic search goes stale when docs change. After any batch of doc edits:
134
+
135
+ **Preferred — one call:**
136
+ ```
137
+ index({ cocoindexSync: true })
138
+ ```
139
+
140
+ **Or separately:**
141
+ ```
142
+ cocoindex_index({})
143
+ index({})
125
144
  ```
126
145
 
127
146
  ---
@@ -129,8 +148,8 @@ python pipeline.py cocoindex update
129
148
  ## Checklist
130
149
 
131
150
  ```
132
- - [ ] CocoIndex configured (pipeline.py present)
133
- - [ ] Embeddings up to date (run pipeline.py cocoindex update after doc edits)
151
+ - [ ] cocoindex_status({}) ready: true (or setup done)
152
+ - [ ] Embeddings refreshed after doc edits: index({ cocoindexSync: true })
134
153
  - [ ] Used graph_query_fuzzy when node ID is unknown (not graph_query with a guess)
135
154
  - [ ] Treated semanticSuggestions as "review recommended", not "must regenerate"
136
155
  ```