baldart 4.19.0 → 4.21.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.
Files changed (45) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/README.md +15 -9
  3. package/VERSION +1 -1
  4. package/framework/.claude/agents/REGISTRY.md +3 -2
  5. package/framework/.claude/agents/api-perf-cost-auditor.md +2 -3
  6. package/framework/.claude/agents/code-reviewer.md +2 -2
  7. package/framework/.claude/agents/codebase-architect.md +31 -52
  8. package/framework/.claude/agents/coder.md +1 -2
  9. package/framework/.claude/agents/doc-graph-aligner.md +72 -0
  10. package/framework/.claude/agents/doc-reviewer.md +3 -39
  11. package/framework/.claude/agents/plan-auditor.md +2 -3
  12. package/framework/.claude/agents/prd-card-writer.md +1 -1
  13. package/framework/.claude/agents/qa-sentinel.md +1 -2
  14. package/framework/.claude/agents/security-reviewer.md +2 -3
  15. package/framework/.claude/agents/senior-researcher.md +2 -3
  16. package/framework/.claude/agents/wiki-curator.md +19 -74
  17. package/framework/.claude/commands/codexreview.md +5 -6
  18. package/framework/.claude/skills/bug/SKILL.md +9 -8
  19. package/framework/.claude/skills/capture/SKILL.md +12 -14
  20. package/framework/.claude/skills/context-primer/SKILL.md +21 -69
  21. package/framework/.claude/skills/graph-align/SKILL.md +80 -0
  22. package/framework/.claude/skills/graphify-bootstrap/SKILL.md +125 -0
  23. package/framework/.claude/skills/issue-review/SKILL.md +1 -1
  24. package/framework/.claude/skills/new/SKILL.md +1 -1
  25. package/framework/.claude/skills/new/references/implement.md +1 -1
  26. package/framework/.claude/skills/prd/SKILL.md +11 -10
  27. package/framework/.claude/skills/prd/references/discovery-phase.md +4 -5
  28. package/framework/.claude/skills/simplify/SKILL.md +3 -0
  29. package/framework/agents/code-graph-protocol.md +108 -0
  30. package/framework/agents/code-search-protocol.md +27 -21
  31. package/framework/agents/index.md +4 -2
  32. package/framework/agents/llm-wiki-methodology.md +42 -78
  33. package/framework/docs/CODE-GRAPH-LAYER.md +104 -0
  34. package/framework/docs/LSP-LAYER.md +6 -6
  35. package/framework/docs/MCP-INTEGRATION.md +4 -4
  36. package/framework/docs/PROJECT-CONFIGURATION.md +11 -0
  37. package/framework/routines/doc-graph-align.routine.yml +53 -0
  38. package/framework/routines/index.yml +14 -4
  39. package/framework/routines/wiki-review.routine.yml +8 -5
  40. package/framework/templates/baldart.config.template.yml +32 -5
  41. package/package.json +1 -1
  42. package/src/commands/configure.js +67 -1
  43. package/src/commands/doctor.js +91 -0
  44. package/src/commands/update.js +6 -0
  45. package/src/utils/graphify-installer.js +239 -0
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: wiki-curator
3
- description: "Maintain the derived LLM wiki surface under ${paths.wiki_dir}/. Use when the team needs compiled concept pages, synthesis pages, dashboards, or reading guides that sit on top of canonical SSOT docs (and optionally an Obsidian vault + RAG layer) without becoming canonical themselves."
3
+ description: "Maintain the derived LLM wiki surface under ${paths.wiki_dir}/. Use when the team needs compiled concept pages, synthesis pages, dashboards, or reading guides that sit on top of canonical SSOT docs (and optionally an Obsidian vault) without becoming canonical themselves."
4
4
  model: sonnet
5
5
  color: blue
6
6
  ---
@@ -18,7 +18,6 @@ Maintain the derived wiki overlay without weakening SSOT discipline.
18
18
  - Prefer compact synthesis over duplication.
19
19
  - Preserve explicit provenance and canonical references on every page.
20
20
  - Keep pages small enough to recompile quickly.
21
- - Mark wiki changes for the project's RAG layer (e.g. LightRAG) reindex after edits, if any.
22
21
 
23
22
  ## Rules
24
23
 
@@ -28,34 +27,6 @@ Maintain the derived wiki overlay without weakening SSOT discipline.
28
27
  4. If a wiki page conflicts with SSOT, the SSOT wins and the wiki must be rewritten.
29
28
  5. If a topic needs human vault visibility, coordinate with an external knowledge-sync agent (if the project ships one) after the derived repo page is stable.
30
29
 
31
- ## RAG Instrumentation (tap point of the auto-learning loop)
32
-
33
- If the project ships a RAG/search layer with telemetry, every call you make to
34
- the project's `search_docs` (or equivalent) MUST pass an invoker tag so
35
- telemetry attributes wiki-curation queries to this agent. After each call,
36
- inspect the telemetry verdict: if it is `weak`, `empty`, or `fallback_degraded`,
37
- append one entry to a log file under your wiki overlay (typically
38
- `${paths.wiki_dir}/log.md`) via the project's log helper (e.g. `tools/<rag-impl>/wiki_log.py`).
39
-
40
- Example call shape:
41
-
42
- ```python
43
- from wiki_log import append_entry # project-specific helper
44
- append_entry(entry_type="query", title=<query_short>, agent="wiki-curator",
45
- context={"verdict": verdict, "top_score": top_score,
46
- "count": count},
47
- refs=[], outcome=verdict)
48
- ```
49
-
50
- This is the feedback loop the wiki overlay depends on: weak queries become
51
- candidates for new synthesis pages in the nightly wiki-review. If the project
52
- has no RAG layer or no telemetry, skip this section.
53
-
54
- **Graceful degrade (MANDATORY)**: if the log helper import fails, the module
55
- is missing, or `append_entry` raises for any reason, emit ONE stderr line
56
- `wiki_log unavailable: <reason>` and CONTINUE. Never abort curation work —
57
- observational telemetry failures must not block wiki page writes.
58
-
59
30
  ## Anchor Slug Validation
60
31
 
61
32
  For every wiki page you create or edit, validate internal anchor links against heading slugs:
@@ -71,9 +42,25 @@ During nightly wiki-review, scan recent ADRs and PRDs (last 14 days):
71
42
 
72
43
  - For ADRs with significant architectural impact (touches >3 modules, marked as architectural pivot, or under categories: provider swap / DB schema / auth / API contract) → propose a synthesis page candidate.
73
44
  - For PRD-led multi-card epics (≥4 cards in same parent epic) → propose an overview synthesis.
74
- - For RAG queries with `verdict=weak|empty` repeated ≥3 times in `${paths.wiki_dir}/log.md` → the topic is a documentation gap, propose synthesis.
75
45
  - Output candidates by appending to `${paths.wiki_dir}/log.md` with `entry_type: synthesis_candidate` and including: title, source refs, expected scope, agent who triggered.
76
46
 
47
+ ### Graph-fed candidates (Graphify — when `features.has_code_graph: true`)
48
+
49
+ If the project has the code graph layer, read Graphify's native
50
+ `${graph.output_dir}/GRAPH_REPORT.md` (default `graphify-out/GRAPH_REPORT.md`)
51
+ and cross-check against existing pages under `${paths.wiki_dir}/syntheses/`:
52
+
53
+ - **God nodes** (highest-degree core abstractions) with no synthesis/concept page
54
+ → propose one (these are the architecture's load-bearing pieces).
55
+ - **Communities** (Leiden clusters) with no overview page → propose a cluster synthesis.
56
+ - **Suggested questions** (auto-generated in the report) that no page answers →
57
+ candidate concept pages.
58
+
59
+ This is the auto-learning gap signal (offline, replaces the removed RAG verdicts).
60
+ The graph is **never canonical** — proposed pages must still cite repo SSOT and
61
+ carry `canonicality: derived`. If Graphify is absent, skip this section silently.
62
+ Provenance: cite the graph node/community id in the candidate payload.
63
+
77
64
  ## Frontmatter Discipline
78
65
 
79
66
  All wiki pages MUST have:
@@ -92,46 +79,6 @@ When invoked for a nightly wiki-review, also run the project's drift validators
92
79
  (typically `npm run validate:frontmatter`, `npm run audit:full-sweep`, or
93
80
  equivalent). Include any findings in your output's `unresolved drift` section.
94
81
 
95
- ## Graph Community Synthesis (optional layer)
96
-
97
- If the project has a community-detection layer (e.g. Leiden/Louvain) on top of
98
- the RAG entity graph, clusters and their summaries are typically produced
99
- weekly (e.g. `python -m tools.<rag-impl>.graph_communities --rebuild`) and
100
- exposed via dedicated MCP tools alongside `search_docs`:
101
-
102
- - `search_synthesis(question, level="global")` — community-summary retrieval.
103
- Use for **relational / cross-cutting** questions where the answer involves
104
- multiple modules at once. Examples:
105
- - "How does auth interact with `<feature-X>`?"
106
- - "What touches the `<entity>` collection/table?"
107
- - "Which areas share the `<shared-pattern>` (e.g. a theming/layout) pattern?"
108
- - `search_synthesis(question, level="local")` — entity-centric retrieval
109
- (delegates to the existing `local` mode). Use for **specific lookups** —
110
- "what is `<authWrapper>`?", "show me the `<DomainType>` type definition".
111
- - `search_docs(query, mode="drift")` (or the dedicated `search_drift` tool) —
112
- the GraphRAG DRIFT pattern: first pick candidate communities via `global`,
113
- then run a scoped `local` retrieval for each. Use when a question is both
114
- cross-cutting AND you want concrete chunks (file/line evidence) back.
115
-
116
- Routing heuristic (apply in order):
117
-
118
- 1. Specific identifier in the query (function name, file path, type
119
- name) → `search_docs(mode="hybrid")` or `search_synthesis(level="local")`.
120
- 2. Cross-cutting "how does X interact with Y?" / "what touches Z?" /
121
- "which areas share pattern P?" → `search_synthesis(level="global")`.
122
- 3. Cross-cutting **and** evidence-seeking → `search_docs(mode="drift")` or
123
- `search_drift(...)`.
124
- 4. When `level="global"` returns `verdict: weak` or `verdict: empty`, escalate
125
- to `mode="drift"` before falling back to `mode="hybrid"`.
126
-
127
- Telemetry parity: pass `invoker_agent: "wiki-curator"` on every call; the
128
- existing `wiki_log` weak-verdict instrumentation applies unchanged.
129
-
130
- The community detector also appends `entry_type: graph_community_candidate`
131
- entries to `${paths.wiki_dir}/log.md` for newly-detected clusters (≥10 entities) that
132
- do not yet have a synthesis page. These are first-class candidates for the
133
- next nightly wiki-review.
134
-
135
82
  ## Output
136
83
 
137
84
  Return:
@@ -140,6 +87,4 @@ Return:
140
87
  - pages updated
141
88
  - source references used
142
89
  - unresolved drift (including any anchor slug or frontmatter issues)
143
- - synthesis candidates identified (including any from
144
- `graph_community_candidate` log entries you acted on)
145
- - reindex follow-up
90
+ - synthesis candidates identified
@@ -137,7 +137,6 @@ Every Task tool invocation in this Step MUST include this exact block at the end
137
137
  ## Budget for this run
138
138
  - file_reads: <N>
139
139
  - bash_calls: <N>
140
- - search_docs: <N>
141
140
  - scope: <list of files passed by orchestrator (review_scope_files)>
142
141
 
143
142
  Respect this budget strictly. If approaching limits, summarize and emit findings on what you have rather than reading new files.
@@ -145,11 +144,11 @@ Respect this budget strictly. If approaching limits, summarize and emit findings
145
144
 
146
145
  Defaults per agent (override only if scope is unusually small/large):
147
146
 
148
- | Agent | file_reads | bash_calls | search_docs |
149
- |---|---|---|---|
150
- | `code-reviewer` | 15 | 25 | 5 |
151
- | `api-perf-cost-auditor` | 15 | 25 | 5 |
152
- | `doc-reviewer` | 20 | 25 | 8 |
147
+ | Agent | file_reads | bash_calls |
148
+ |---|---|---|
149
+ | `code-reviewer` | 15 | 25 |
150
+ | `api-perf-cost-auditor` | 15 | 25 |
151
+ | `doc-reviewer` | 20 | 25 |
153
152
 
154
153
  Codex (agent #4, via Bash + companion script) does NOT receive this block — it manages its own context.
155
154
 
@@ -8,7 +8,7 @@ description: >
8
8
  Enforces a disciplined 5-phase debugging protocol that prevents blind guessing:
9
9
  (1) Reproduce & observe, (2) Enhanced logging if stuck, (3) Data-driven analysis,
10
10
  (4) Hypothesis & minimal fix, (5) Verify. Leverages Playwright MCP for browser capture,
11
- codebase-architect for code path tracing, doc-rag for known patterns, git bisect for regressions.
11
+ codebase-architect for code path tracing, `rg` over docs for known patterns, git bisect for regressions.
12
12
  ---
13
13
 
14
14
  # /bug — Structured Bug Investigation
@@ -17,7 +17,7 @@ Argument: optional bug description (e.g., `/bug feature X is not saving`).
17
17
 
18
18
  ## Project Context
19
19
 
20
- **Reads from `baldart.config.yml`:** `paths.design_system`, `paths.references_dir`, `paths.wiki_dir` (Phase 0 doc-rag `rg` fallback target).
20
+ **Reads from `baldart.config.yml`:** `paths.design_system`, `paths.references_dir`, `paths.wiki_dir` (Phase 0 `rg` lookup target).
21
21
  **Gated by features:** `features.has_design_system` (when `true`, Phase 4's design-system reads become BLOCKING for UI-touching bugs).
22
22
  **Overlay:** loads `.baldart/overlays/bug.md` if present — project-specific debug entry points (e.g. SWR debug switches, env summary helpers, error-code modules). The base skill stays generic; project-specific code paths live in the overlay.
23
23
  **On missing/empty keys:** ask the user; do not assume defaults. See `framework/agents/project-context.md` § 3.
@@ -39,7 +39,6 @@ See [framework/docs/MCP-INTEGRATION.md](../../../docs/MCP-INTEGRATION.md) for th
39
39
  - `mcp__playwright__browser_*` (`browser_navigate`, `browser_take_screenshot`, `browser_console_messages`, `browser_network_requests`, `browser_evaluate`) — Phase 1 reproduction for **UI/Client** bugs. Without it the skill cannot capture deterministic state and Phase 1 degrades to "ask the user to reproduce manually and paste console logs". Phase 2's client-side `window.fetch` interception is impossible without `browser_evaluate`.
40
40
 
41
41
  **Optional** (the skill benefits if present, has a documented fallback):
42
- - `mcp__doc-rag__search_docs` — Phase 0 lookup for known patterns and error codes. Fallback: targeted `rg` over the project's error-code module (path listed in `.baldart/overlays/bug.md`) and `${paths.wiki_dir}/`.
43
42
  - `mcp__plugin_firebase_firebase__firestore_*` (or the project's DB MCP, when `stack.database.primary` is set) — Phase 1 inspection of runtime data state for **Data** bugs. Fallback: ask the user for a document export, or read the relevant code path and infer.
44
43
  - `codebase-architect` agent (always available, listed for completeness) — Phase 0 code-path mapping. Not an MCP per se but is treated as a required dependency by this skill.
45
44
 
@@ -64,10 +63,12 @@ See [framework/docs/MCP-INTEGRATION.md](../../../docs/MCP-INTEGRATION.md) for th
64
63
  When `features.has_lsp_layer: true` and the symptom names a concrete symbol
65
64
  (function/type/handler), `codebase-architect` will use LSP find-references /
66
65
  go-to-definition to locate the exact callsites instead of grepping. See
67
- `framework/agents/code-search-protocol.md`.
68
- 4. Search doc-rag for related patterns: `mcp__doc-rag__search_docs` with bug keywords
69
- - always use `mode="hybrid"` (vector + knowledge graph) for richer context retrieval
70
- - if results come from Obsidian, treat them as context only and verify runtime behavior against repo docs/code before fixing
66
+ `framework/agents/code-search-protocol.md`. When `features.has_code_graph: true`,
67
+ it can also trace blast-radius with `graphify affected "<symbol>"` (what breaks
68
+ if this changes) see `framework/agents/code-graph-protocol.md`.
69
+ 4. Search for related patterns: `rg` over the project's error-code module (path
70
+ listed in `.baldart/overlays/bug.md`) and `${paths.wiki_dir}/` with bug keywords.
71
+ Verify any doc hit against repo docs/code before fixing.
71
72
  5. Check git history for recent changes in affected area:
72
73
  ```
73
74
  git log --oneline -20 --all -- <affected-files>
@@ -217,7 +218,7 @@ If the project exposes an env-summary helper (listed in `.baldart/overlays/bug.m
217
218
  | Tool | When | Purpose |
218
219
  |------|------|---------|
219
220
  | `codebase-architect` agent | Phase 0 | Map affected code paths |
220
- | `mcp__doc-rag__search_docs` | Phase 0 | Search known patterns/errors (`hybrid` mode — vector + knowledge graph; if MCP available) |
221
+ | `rg` over docs / error-code module | Phase 0 | Search known patterns/errors |
221
222
  | `mcp__playwright__browser_*` | Phase 1-5 | Navigate, screenshot, console, network |
222
223
  | Project DB MCP (if available) | Phase 1 | Inspect storage state (e.g. firestore/postgres tools) |
223
224
  | `git log/blame/bisect` | Phase 0, 3 | Find regression commits |
@@ -7,7 +7,7 @@ version: 0.1.0
7
7
 
8
8
  # /capture — Synthesis Capture Skill
9
9
 
10
- Turns a recent multi-turn synthesis (cross-document reasoning done by the assistant) into a durable **synthesis page** under `${paths.wiki_dir}/syntheses/<slug>.md`. Part of the LLM wiki auto-learning loop weak RAG queries and recurring synthesis patterns feed back into stable wiki pages so future agents can retrieve consolidated context instead of re-deriving it every time.
10
+ Turns a recent multi-turn synthesis (cross-document reasoning done by the assistant) into a durable **synthesis page** under `${paths.wiki_dir}/syntheses/<slug>.md`. Recurring cross-document reasoning is captured into stable wiki pages so future agents can retrieve consolidated context instead of re-deriving it every time.
11
11
 
12
12
  ## Project Context
13
13
 
@@ -100,25 +100,18 @@ reason.
100
100
 
101
101
  ### Step 5 — Write + log (accepted)
102
102
 
103
- If the project ships a wiki-log helper, call it with an `entry_type='capture'` entry referencing the new synthesis file and the source refs. The exact import path is listed in `.baldart/overlays/capture.md` (typically `tools/<rag-impl>/wiki_log.py`). If no helper exists, append a markdown bullet to `${paths.wiki_dir}/log.md` by hand. Example:
104
-
105
- ```bash
106
- python3 -c "import sys; sys.path.insert(0, 'tools/<rag-impl>'); \
107
- from wiki_log import append_entry; \
108
- append_entry(entry_type='capture', title='<slug>', \
109
- agent='capture-skill', \
110
- context={'mode': '<manual|proactive>', 'confidence': '<low|medium|high>'}, \
111
- refs=['${paths.wiki_dir}/syntheses/<slug>.md', '<source ref 1>', '<source ref 2>'], \
112
- outcome='created')"
113
- ```
103
+ After writing the synthesis page, append a markdown bullet to
104
+ `${paths.wiki_dir}/log.md` by hand recording the capture: the new synthesis file
105
+ path, the source refs, the mode (manual/proactive), and `outcome=created`.
114
106
 
115
107
  If the synthesis was surfaced from the queue, delete (or move to
116
108
  `.processed/`) the candidate file after write.
117
109
 
118
110
  ### Step 6 — Rejection
119
111
 
120
- Log the rejection (same helper as Step 5 with `outcome='rejected'`). Also
121
- delete the candidate file from the queue so it does not resurface.
112
+ Log the rejection (a markdown bullet in `${paths.wiki_dir}/log.md` with
113
+ `outcome='rejected'`). Also delete the candidate file from the queue so it does
114
+ not resurface.
122
115
 
123
116
  ## Notes
124
117
 
@@ -128,6 +121,11 @@ delete the candidate file from the queue so it does not resurface.
128
121
  See `.claude/capture-queue/.disabled.example`.
129
122
  - **Anti-spam**: the detection hook refuses to write when ≥10 unprocessed
130
123
  candidates already exist. See `.claude/hooks/capture-detect.sh`.
124
+ - **Graph-fed candidates** (when `features.has_code_graph: true`): the nightly
125
+ `wiki-review` / `doc-graph-align` routines surface synthesis candidates from
126
+ Graphify's `GRAPH_REPORT.md` (god nodes / communities without a page). When
127
+ one is queued, `/capture` distils it into a synthesis page like any other
128
+ candidate. See `framework/agents/code-graph-protocol.md`.
131
129
 
132
130
  ## Related
133
131
 
@@ -16,7 +16,7 @@ Load structured, task-adaptive context about a topic into the conversation befor
16
16
 
17
17
  ## Project Context
18
18
 
19
- **Reads from `baldart.config.yml`:** `paths.backlog_dir`, `paths.references_dir`, `paths.prd_dir`, `paths.wiki_dir`, `paths.adrs_dir`, `paths.wiki_log`.
19
+ **Reads from `baldart.config.yml`:** `paths.backlog_dir`, `paths.references_dir`, `paths.prd_dir`, `paths.wiki_dir`, `paths.adrs_dir`.
20
20
  **Gated by features:** `features.has_backlog` (skip backlog grep when `false`), `features.has_wiki_overlay` (skip wiki search AND the wiki-log instrumentation tap), `features.has_adrs` (skip ADR includes), `features.has_prd_workflow` (skip PRD reads).
21
21
  **Overlay:** loads `.baldart/overlays/context-primer.md` if present — project-specific topic vocabulary, must-include canonical docs.
22
22
  **On missing/empty keys:** ask the user; do not assume defaults. See `framework/agents/project-context.md` § 3.
@@ -61,64 +61,50 @@ precedence caveats: `framework/agents/effort-protocol.md`.
61
61
  Load context about: {keywords}
62
62
  Task type: {task_type}
63
63
 
64
- TOKEN BUDGET: stay under 15K tokens total. Prefer RAG over file reads.
64
+ TOKEN BUDGET: stay under 15K tokens total. Prefer the canonical router + targeted reads over broad file scans.
65
65
 
66
- SEARCH STRATEGY — RAG-first, verify-only-if-needed:
66
+ SEARCH STRATEGY — canonical-router-first, verify-only-if-needed:
67
67
 
68
- 1. Call search_docs(query="{keywords}", mode="hybrid", invoker_agent="context-primer").
69
- Pass invoker_agent="context-primer" this OVERRIDES your own default
70
- (codebase-architect) for every call you make on behalf of this skill,
71
- so telemetry attributes the query to the initiating skill, not the subagent.
68
+ 1. Resolve the topic to its canonical source. Read `${paths.references_dir}/ssot-registry.md`
69
+ to route `{keywords}` to the owning reference doc / ADR, then read only the matched
70
+ section(s). If the topic is documentation-heavy and `features.has_wiki_overlay: true`,
71
+ also consult `${paths.wiki_dir}/index.md` and any must-include docs listed in
72
+ `.baldart/overlays/context-primer.md` (verify wiki claims against canonical docs).
72
73
 
73
- NOTE: the search_docs MCP tool and its rag_telemetry.verdict field only
74
- exist when a RAG/Obsidian doc-search layer is connected. If search_docs is
75
- NOT available (no MCP tool), or it returns no rag_telemetry block, treat the
76
- verdict as "empty" and go straight to the full manual search (steps 2-3) —
77
- do NOT fabricate a verdict or stall waiting for a field that will never
78
- appear. Emit no error; this is the normal no-RAG path.
79
-
80
- When the field IS present, check rag_telemetry.verdict in the response:
81
- - "useful" → RAG is your PRIMARY source. Go to step 4.
82
- - "weak"/"fallback_degraded" → supplement with steps 2-3.
83
- - "empty" → full manual search (steps 2-3).
84
-
85
- If the topic is documentation-heavy and `features.has_wiki_overlay: true`,
86
- include `${paths.wiki_dir}/index.md` and the project's wiki-overlay ADR
87
- (in `${paths.adrs_dir}/`) in the search set, plus any must-include docs
88
- listed in `.baldart/overlays/context-primer.md`.
89
-
90
- 2. ONLY IF RAG was weak/empty — targeted searches:
74
+ 2. Targeted searches:
91
75
  a. Agent memory: grep MEMORY.md index for topic match, read ONLY
92
76
  matching files (skip files >20KB unless filename matches keywords).
93
77
  b. Backlog (when `features.has_backlog: true`): grep `${paths.backlog_dir}/*.yml` for card titles matching keywords.
94
78
  Read only the matching cards, not all cards.
95
79
  c. Git: `git log --oneline -10 --grep="{keywords}"` (10 results max).
96
80
 
97
- 3. ONLY IF RAG was empty broader search:
81
+ 3. Broader search (when steps 1-2 are thin):
98
82
  a. Grep the project's source root for 2-3 specific identifiers from steps 1-2.
99
83
  When `features.has_lsp_layer: true` AND the identifier is a symbol (function /
100
84
  type / class name, not a free-text phrase), prefer LSP `find-references` /
101
85
  `go-to-definition` over Grep — it filters textual collisions before any file
102
86
  read. Cap at 3 LSP calls, then fall back. See `framework/agents/code-search-protocol.md`.
87
+ When `features.has_code_graph: true` AND the question is structural/relational
88
+ (how X connects to Y, impact, clusters), prefer the Graphify code graph
89
+ (`graphify query`/`path`/`affected`) — see `framework/agents/code-graph-protocol.md`.
103
90
  b. Read key file headers (first 50 lines) to identify structure.
104
91
  DO NOT read `${paths.prd_dir}/` or `${paths.references_dir}/` files in full —
105
- RAG already indexes them. Only read a specific doc section if RAG
106
- pointed to it but the preview was insufficient.
92
+ route via the registry and read only the specific section you need.
107
93
 
108
94
  4. Targeted verification (ALL cases):
109
- - Verify ONLY runtime-sensitive claims from Obsidian results (auth
110
- patterns, API contracts, current schema) against actual code.
95
+ - Verify ONLY runtime-sensitive claims (auth patterns, API contracts,
96
+ current schema) against actual code.
111
97
  - Files <200 lines: read in full.
112
98
  - Files 200-500 lines: read first 50 lines + specific section.
113
99
  - Files >500 lines: grep for key exports/functions, read only those.
114
100
  - NEVER read agent memory files >20KB in full.
115
101
 
116
102
  TASK-ADAPTIVE RULES:
117
- - "query": RAG + memory only. Skip source code unless code-specific.
118
- - "bug-fix": RAG + recent git changes + error-related code. Skip arch docs.
119
- - "new-feature": RAG + patterns in same domain + ADRs. Skip unrelated areas.
120
- - "refactor": RAG + affected files + dependency refs. Skip design rationale.
121
- - "doc-update": RAG + SSOT registry. Skip source code.
103
+ - "query": canonical docs + memory only. Skip source code unless code-specific.
104
+ - "bug-fix": canonical docs + recent git changes + error-related code. Skip arch docs.
105
+ - "new-feature": canonical docs + patterns in same domain + ADRs. Skip unrelated areas.
106
+ - "refactor": canonical docs + affected files + dependency refs. Skip design rationale.
107
+ - "doc-update": SSOT registry. Skip source code.
122
108
 
123
109
  WIKI OVERLAY ROUTING:
124
110
  - If the topic is about synthesized knowledge, dashboards, reading guides, or
@@ -150,45 +136,11 @@ Return output in this EXACT XML format (30-50 lines max):
150
136
  <note acquired="YYYY-MM-DD">Note content</note>
151
137
  <note acquired="YYYY-MM-DD" stale="true">Old note [STALE — verify]</note>
152
138
  </memory_notes>
153
- <!-- If no RAG layer was available, set verdict="unavailable" count="0" mode="none" -->
154
- <rag_quality verdict="{rag_telemetry.verdict}" count="{count}" mode="{mode}"/>
155
139
  </context_primer>
156
140
 
157
- WIKI LOG INSTRUMENTATION (FEAT-0805 — tap point of the auto-learning loop):
158
- This tap is GATED. Only attempt it when `features.has_wiki_overlay: true` AND
159
- `paths.wiki_log` is set in `baldart.config.yml` (it points at the project's
160
- wiki-log tap MODULE FILE, e.g. `tools/doc-rag/wiki_log.py` — there is no
161
- hardcoded `tools/doc-rag` default; that path is one consumer's layout and does
162
- not resolve elsewhere). If either is absent, SKIP the tap entirely and emit a
163
- single stderr WARNING
164
- "wiki_log skipped: features.has_wiki_overlay/paths.wiki_log not configured" —
165
- never silently no-op, and never assume a default path.
166
-
167
- When enabled: after every search_docs call, inspect the returned
168
- rag_telemetry.verdict. If verdict ∈ {"weak", "empty", "fallback_degraded"},
169
- log one entry to the wiki log so the nightly wiki-review can detect coverage
170
- gaps. Resolve `<wiki_log_dir>` as the PARENT DIRECTORY of `paths.wiki_log`
171
- (i.e. `dirname` — the importable package dir; `paths.wiki_log` itself is the
172
- `wiki_log.py` file):
173
-
174
- python3 -c "import sys; sys.path.insert(0, '<wiki_log_dir>'); \
175
- from wiki_log import append_entry; \
176
- append_entry(entry_type='query', title='<query_short>', \
177
- agent='context-primer', \
178
- context={'verdict': '<verdict>', 'top_score': <top_score>, \
179
- 'count': <count>}, \
180
- refs=[], outcome='<verdict>')"
181
-
182
- GRACEFUL DEGRADE (MANDATORY): if the import fails, the file is missing, or
183
- append_entry raises for any reason, emit a SINGLE line to stderr of the form
184
- "wiki_log unavailable: <reason>" and CONTINUE the primary task. NEVER abort,
185
- retry, or let the exception bubble. The loop is observational; its failure
186
- must never block orientation.
187
-
188
141
  CRITICAL OUTPUT RULES:
189
142
  - Constraints section MUST come FIRST (research: primacy effect +30%)
190
143
  - Keep total output under 50 lines — dense beats verbose
191
- - Include <rag_quality> tag so the caller can track RAG usefulness
192
144
  - Every memory_notes entry MUST have an acquired date
193
145
  - If a memory item file was modified >7 days ago AND refers to current
194
146
  state (not permanent decisions), mark it stale="true"
@@ -0,0 +1,80 @@
1
+ ---
2
+ name: graph-align
3
+ effort: medium
4
+ description: >
5
+ On-demand documentation alignment via the Graphify code knowledge graph.
6
+ Rebuilds the graph offline (graphify update .), then cross-checks graph
7
+ structure against the docs + wiki overlay to surface (1) core code (god nodes /
8
+ communities) with no doc coverage, (2) docs referencing code no longer in the
9
+ graph (stale), (3) drift vs the SSOT registry — emitting a report + synthesis
10
+ candidates. The interactive twin of the nightly doc-graph-align routine. Use
11
+ when the user says /graph-align, "allinea la documentazione", "doc graph align",
12
+ "check doc coverage", or wants an on-demand graph/doc reconciliation. Gated on
13
+ features.has_code_graph.
14
+ ---
15
+
16
+ # /graph-align — Doc ↔ Code-Graph Alignment
17
+
18
+ Reconcile documentation with the **real** code structure on demand. This is the
19
+ manually-invoked twin of the nightly `doc-graph-align` routine; both delegate to
20
+ the `doc-graph-aligner` agent. It does NOT duplicate Graphify's native `/graphify`
21
+ query skill — it orchestrates a doc-alignment pass on top of the graph.
22
+
23
+ ## Project Context
24
+
25
+ **Reads from `baldart.config.yml`:** `features.has_code_graph`, `graph.output_dir`, `paths.wiki_dir`, `paths.references_dir`, `paths.docs_dir`.
26
+ **Gated by features:** `features.has_code_graph` — refuses to run when the flag is `false` (point the user to `/graphify-bootstrap`).
27
+ **Overlay:** loads `.baldart/overlays/graph-align.md` if present.
28
+ **On missing keys:** ask the user; do not assume defaults. See `framework/agents/project-context.md` § 3.
29
+
30
+ ## Effort
31
+
32
+ **Baseline:** `effort: medium` (frontmatter). **Inline override:** pass
33
+ `effort=<low|medium|high|xhigh|max>` anywhere in the invocation to scale
34
+ reasoning depth — detect once at kickoff, strip the token before consuming input.
35
+ See `framework/agents/effort-protocol.md`.
36
+
37
+ ## Workflow
38
+
39
+ 1. **Refusal check.** If `features.has_code_graph: false`/missing, or `graphify`
40
+ is not installed:
41
+ ```
42
+ The code graph layer isn't set up. Run /graphify-bootstrap first.
43
+ ```
44
+ Stop. (If the flag is true but the binary is missing, suggest `baldart doctor`.)
45
+
46
+ 2. **Delegate to the agent.** Invoke the `doc-graph-aligner` agent (via Task tool,
47
+ `mode: "bypassPermissions"`). It refreshes the graph (`graphify update .`),
48
+ reads `${graph.output_dir}/GRAPH_REPORT.md`, and cross-checks graph → docs.
49
+
50
+ 3. **Surface results.** Present the agent's report: uncovered core code (proposed
51
+ synthesis candidates), stale docs (for `doc-reviewer`), registry drift. Offer
52
+ to act on the top candidates via `/capture` (synthesis pages) — never auto-write
53
+ canonical docs.
54
+
55
+ ## Output Contract
56
+
57
+ A compact summary (not a multi-page dump), in `identity.language` (English
58
+ default):
59
+
60
+ ```
61
+ Graph align (graphify-out, built @ <commit>):
62
+ Uncovered core code: 3 god nodes / 1 community without a page → synthesis candidates queued
63
+ Stale docs: 2 references to deleted symbols (docs/references/foo.md) → doc-reviewer
64
+ Registry drift: 1 community with no ssot-registry entry
65
+ Next: run /capture to distil the queued candidates; hand stale-doc findings to doc-reviewer.
66
+ ```
67
+
68
+ ## Notes
69
+
70
+ - Offline / 0 API cost for the structural pass (graph + GRAPH_REPORT.md).
71
+ - Propose, don't author: the skill never rewrites canonical SSOT or wiki pages
72
+ directly — it queues candidates and hands drift to `doc-reviewer`.
73
+ - The graph is never canonical; candidates cite repo SSOT (`canonicality: derived`).
74
+
75
+ ## See Also
76
+
77
+ - `framework/.claude/agents/doc-graph-aligner.md` — the agent this skill drives
78
+ - `framework/routines/doc-graph-align.routine.yml` — the scheduled twin
79
+ - `framework/agents/code-graph-protocol.md` — graph retrieval contract
80
+ - `framework/agents/llm-wiki-methodology.md` — how the graph feeds the wiki
@@ -0,0 +1,125 @@
1
+ ---
2
+ name: graphify-bootstrap
3
+ effort: medium
4
+ description: >
5
+ Install, verify, and wire the Graphify code-knowledge-graph layer for this
6
+ project. Installs the Graphify CLI (pipx install graphifyy), builds the graph
7
+ offline (graphify update .), installs the native post-commit auto-rebuild git
8
+ hook, wires Graphify's always-on mode into the enabled AI tools, and optionally
9
+ registers the graphify-mcp MCP server. Use when the user says /graphify-bootstrap,
10
+ "install graphify", "set up the code graph", or after enabling
11
+ features.has_code_graph for the first time. Idempotent — re-running re-verifies
12
+ and rebuilds a stale graph.
13
+ ---
14
+
15
+ # Graphify Bootstrap
16
+
17
+ Set up the code knowledge graph that lets agents answer **structural / relational**
18
+ questions (what connects X to Y, blast-radius, clusters) and feeds the LLM-wiki
19
+ overlay (Karpathy loop) from Graphify's native `GRAPH_REPORT.md`. This is the
20
+ explicit install path — `baldart configure` only installs Graphify in its
21
+ interactive branch, so this skill (and `baldart doctor`) cover CI / first-run.
22
+
23
+ ## Project Context
24
+
25
+ **Reads from `baldart.config.yml`:** `features.has_code_graph`, `graph.output_dir`, `graph.auto_rebuild_hook`, `graph.register_mcp`, `tools.enabled`.
26
+ **Gated by features:** `features.has_code_graph` — this skill refuses to run when the flag is `false`, prompting the user to flip it via `npx baldart configure` first.
27
+ **Overlay:** loads `.baldart/overlays/graphify-bootstrap.md` if present — project-specific build flags (e.g. `--mode deep`, a non-default output dir, an LLM backend for `--wiki`/community naming).
28
+ **On missing keys:** ask the user; do not assume defaults. See `framework/agents/project-context.md` § 3.
29
+
30
+ ## Effort
31
+
32
+ **Baseline:** `effort: medium` (frontmatter). **Inline override:** pass
33
+ `effort=<low|medium|high|xhigh|max>` anywhere in the invocation to scale
34
+ reasoning depth for this run — detect it once at kickoff and strip the token
35
+ before consuming user input. Level→behavior mapping, parsing contract, and
36
+ precedence caveats: `framework/agents/effort-protocol.md`.
37
+
38
+ ## What This Skill Does
39
+
40
+ Graphify is a SINGLE language-agnostic tool (tree-sitter, 28 languages,
41
+ local/offline) — there is no per-language step. This skill composes Graphify's
42
+ own native commands via `src/utils/graphify-installer.js`:
43
+
44
+ 1. Confirms `features.has_code_graph: true`.
45
+ 2. Installs the CLI: `pipx install graphifyy` (fallback `pip install --user graphifyy`).
46
+ Provides binaries `graphify` + `graphify-mcp`.
47
+ 3. Builds the graph **offline** (no API cost): `graphify update .` →
48
+ `${graph.output_dir}/{graph.json, GRAPH_REPORT.md, graph.html}`.
49
+ 4. Wires Graphify's **always-on mode** into each tool in `tools.enabled`
50
+ (`graphify claude install`, `graphify codex install`, …) — writes a graph-first
51
+ section to the tool's instruction file + a pre-tool hook.
52
+ 5. Installs the native **post-commit git hook** (`graphify hook install`) when
53
+ `graph.auto_rebuild_hook: true`, so the graph never goes stale.
54
+ 6. Optionally registers the MCP server (`graph.register_mcp: true`) via
55
+ best-effort `claude mcp add graphify -- graphify-mcp <graph.json>`.
56
+ 7. Confirms `graphify-out/` is in `.gitignore` (generated artifact, never versioned).
57
+
58
+ ## Workflow
59
+
60
+ 1. **Refusal check.** If `features.has_code_graph: false` (or missing):
61
+ ```
62
+ This project hasn't opted in to the code graph layer yet.
63
+ Run `npx baldart configure` and answer YES to "Enable Graphify code-knowledge-graph layer?"
64
+ then re-run /graphify-bootstrap.
65
+ ```
66
+ Stop here. Do not proceed.
67
+
68
+ 2. **Probe + install.** Use the BALDART installer (internally
69
+ `src/utils/graphify-installer.js`):
70
+ ```
71
+ node -e 'const G=require("./.framework/src/utils/graphify-installer"); const g=new G(); if(!g.detect()){console.log(JSON.stringify(g.install()))} else {console.log(JSON.stringify(g.verify()))}'
72
+ ```
73
+ If install fails, print `pipx install graphifyy` for the user and stop with a
74
+ clear message (do not proceed to build).
75
+
76
+ 3. **Build the graph.** `graphify update .` (offline). For LLM-named communities /
77
+ wiki pages, `graphify label .` or `graphify update . --wiki` (needs an LLM key;
78
+ optional — skip silently if no key).
79
+
80
+ 4. **Wire always-on + hook.** Run `graphify <tool> install` for each enabled tool
81
+ and `graphify hook install` (when `auto_rebuild_hook`). Capture failures into a
82
+ "Skipped" bucket — never abort the whole skill on one failure.
83
+
84
+ 5. **Optional MCP.** When `graph.register_mcp: true` and the `claude` CLI is
85
+ present, register `graphify-mcp`; otherwise note the CLI path works without it.
86
+
87
+ 6. **Confirm `.gitignore`.** Ensure `graphify-out/` is ignored; add it if missing.
88
+
89
+ 7. **Output.** A compact one-line status block, in the project's
90
+ `identity.language` from `baldart.config.yml` (English default).
91
+
92
+ ## Output Contract
93
+
94
+ A single short status block — never a multi-page report. Format:
95
+
96
+ ```
97
+ Graphify bootstrap:
98
+ ✓ graphify 0.8.x installed (pipx) — binaries graphify + graphify-mcp
99
+ ✓ graph built — 571 nodes · 873 edges · 24 communities (graphify-out/, offline)
100
+ ✓ always-on wired: claude, codex
101
+ ✓ git hook installed (auto-rebuild on commit)
102
+ · MCP: CLI path active (register_mcp: false)
103
+ ✓ .gitignore covers graphify-out/
104
+ Next: codebase-architect prefers the graph for structural queries; wiki-curator
105
+ feeds synthesis candidates from GRAPH_REPORT.md. See code-graph-protocol.md.
106
+ ```
107
+
108
+ ## Notes
109
+
110
+ - The structural graph is **offline / 0 API cost**. Only `--wiki` /
111
+ community-naming (`label`) need an LLM API key — both optional.
112
+ - This skill never edits source code. Side effects: a Python package install,
113
+ the `graphify-out/` artifact, Graphify's own instruction-file sections + hooks,
114
+ and a `.gitignore` line.
115
+ - Re-run safely. `graphify update .` is incremental; always-on / hook installs are
116
+ idempotent.
117
+ - If the graph goes stale later (built from an older commit), `baldart doctor`
118
+ flags it and offers `graph-rebuild` — or the post-commit hook handles it.
119
+
120
+ ## See Also
121
+
122
+ - `framework/agents/code-graph-protocol.md` — runtime retrieval + fallback rules
123
+ - `framework/docs/CODE-GRAPH-LAYER.md` — lifecycle, schema, invariants
124
+ - `src/utils/graphify-installer.js` — the native-command wrapper this skill drives
125
+ - `src/commands/configure.js` — same install flow when first enabling the flag
@@ -25,7 +25,7 @@ If the user mentions `/issue-review` without a number, ask for the GitHub issue
25
25
 
26
26
  ### Phase 0 — Documentation Context
27
27
 
28
- Before triaging, use `search_docs` MCP tool (if available) with `mode: "hybrid"` to find related PRDs, ADRs, and reference docs for the issue's domain. The active retrieval layer is Obsidian-first LightRAG: use Obsidian for concept context, then verify implementation/stateful claims against repo docs/code. If MCP is unavailable, fall back to targeted canonical docs plus `rg` over `${paths.references_dir}/`, `${paths.backlog_dir}/`, and `.claude/agents/`. Check `${paths.references_dir}/traceability-matrix.md` for source-to-doc mappings.
28
+ Before triaging, route through `${paths.references_dir}/ssot-registry.md` and `rg` over `${paths.references_dir}/`, `${paths.backlog_dir}/`, and `.claude/agents/` to find related PRDs, ADRs, and reference docs for the issue's domain. Verify implementation/stateful claims against repo docs/code. Check `${paths.references_dir}/traceability-matrix.md` for source-to-doc mappings.
29
29
 
30
30
  ### Phase 1 — Triage
31
31
 
@@ -19,7 +19,7 @@ description: >
19
19
 
20
20
  ## Project Context
21
21
 
22
- **Reads from `baldart.config.yml`:** `paths.backlog_dir`, `paths.references_dir`, `git.trunk_branch` (integration trunk; autodetected from `origin/HEAD` when the key is absent — see Phase 0 step 0), `git.merge_strategy`, `paths.high_risk_modules` (risk-detector path list), `paths.metrics` (default `docs/metrics`), `stack.language` / `stack.database` / `stack.deployment` (gate guards), and `features.has_e2e_review` / `features.has_design_system` / `features.has_lsp_layer`.
22
+ **Reads from `baldart.config.yml`:** `paths.backlog_dir`, `paths.references_dir`, `git.trunk_branch` (integration trunk; autodetected from `origin/HEAD` when the key is absent — see Phase 0 step 0), `git.merge_strategy`, `paths.high_risk_modules` (risk-detector path list), `paths.metrics` (default `docs/metrics`), `stack.language` / `stack.database` / `stack.deployment` (gate guards), and `features.has_e2e_review` / `features.has_design_system` / `features.has_lsp_layer` / `features.has_code_graph`.
23
23
  **Gated by features:** `features.has_backlog` (skill REFUSES to run when `false` — this orchestrator operates on backlog cards by definition).
24
24
  **Overlay:** loads `.baldart/overlays/new.md` if present — project-specific canonical-docs registry (e.g. ssot-registry, linking-protocol guides), tooling paths (e.g. validation scripts).
25
25
  **On missing/empty keys:** ask the user; do not assume defaults. See `framework/agents/project-context.md` § 3.