baldart 3.9.0 → 3.10.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.
- package/CHANGELOG.md +36 -0
- package/README.md +6 -2
- package/VERSION +1 -1
- package/framework/.claude/agents/REGISTRY.md +1 -1
- package/framework/.claude/agents/codebase-architect.md +8 -0
- package/framework/.claude/skills/bug/SKILL.md +5 -1
- package/framework/.claude/skills/context-primer/SKILL.md +4 -0
- package/framework/.claude/skills/lsp-bootstrap/SKILL.md +113 -0
- package/framework/.claude/skills/new/SKILL.md +1 -1
- package/framework/.claude/skills/prd/SKILL.md +3 -1
- package/framework/.claude/skills/simplify/SKILL.md +6 -0
- package/framework/agents/code-search-protocol.md +126 -0
- package/framework/agents/index.md +2 -0
- package/framework/docs/LSP-LAYER.md +405 -0
- package/framework/docs/PROJECT-CONFIGURATION.md +17 -0
- package/framework/templates/baldart.config.template.yml +22 -0
- package/framework/templates/overlays/agents/codebase-architect.lsp-example.md +53 -0
- package/package.json +1 -1
- package/src/commands/configure.js +48 -0
- package/src/commands/doctor.js +55 -0
- package/src/utils/lsp-adapters/go.js +29 -0
- package/src/utils/lsp-adapters/index.js +49 -0
- package/src/utils/lsp-adapters/python.js +42 -0
- package/src/utils/lsp-adapters/ruby.js +30 -0
- package/src/utils/lsp-adapters/rust.js +26 -0
- package/src/utils/lsp-adapters/typescript.js +54 -0
- package/src/utils/lsp-installer.js +118 -0
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,42 @@ All notable changes to BALDART will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [3.10.0] - 2026-05-23
|
|
9
|
+
|
|
10
|
+
BALDART grows an **LSP symbol-search layer**. When enabled, `codebase-architect` and the code-exploration skills (`context-primer`, `bug`, `prd`, `new`, `simplify`) prefer LSP `find-references` / `go-to-definition` over Grep for identifier-shaped queries. The filtering happens **before** Claude reads files — a function-name search that previously returned thousands of textual matches now resolves to the actual callsites of the same symbol. Grep remains the fallback for free-text queries and when the LSP layer is unavailable, so existing flows degrade gracefully.
|
|
11
|
+
|
|
12
|
+
The layer is opt-in: at install / update / configure, BALDART asks "Enable LSP symbol-search layer?" and (on yes) detects the project's languages and installs the matching language servers — npm devDeps for TypeScript and Python, system commands printed for Go, Rust, Ruby.
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
|
|
16
|
+
- **`baldart.config.yml` → `features.has_lsp_layer`** — new boolean (default `false`). Gates the LSP retrieval tier in agents and skills. When `true`, also populates the new `lsp` section with the installed language servers.
|
|
17
|
+
- **`baldart.config.yml` → `lsp.installed_servers` + `lsp.auto_verify`** — new top-level section tracking which language servers are recorded for the project and whether `baldart doctor` should re-verify them on every run.
|
|
18
|
+
- **`framework/agents/code-search-protocol.md`** — new protocol module defining the retrieval hierarchy (RAG hybrid → LSP for symbols → Grep → Git), query-type discrimination, LSP budget (max 3 calls/task), and fallback rules. Referenced from `framework/agents/index.md`.
|
|
19
|
+
- **`framework/.claude/skills/lsp-bootstrap/SKILL.md`** — new invokable skill (`/lsp-bootstrap`) that runs the install + verify flow as a standalone workflow. Refuses to run when `features.has_lsp_layer: false`. Idempotent.
|
|
20
|
+
- **`src/utils/lsp-adapters/`** — new pluggable adapter registry (TypeScript, Python via Pyright, Go via gopls, Rust via rust-analyzer, Ruby via ruby-lsp). Each adapter exposes `detect(cwd)`, `installCommand()`, `verifyCommand()`, and `claudePluginId()`. Same pattern as `src/utils/tool-adapters/`. Add a new language by dropping in a `<lang>.js` file and registering it in `index.js`.
|
|
21
|
+
- **`src/utils/lsp-installer.js`** — high-level installer used by `configure.js` and the `doctor` LSP step. `detectLanguages()` / `recommend()` / `installServers()` / `verifyServers()`. Pure detection has no side effects; install ops respect `--non-interactive`.
|
|
22
|
+
- **`src/commands/configure.js` LSP block** — when the user opts in, autodetects languages, prompts per server, installs npm-mode adapters in-process, prints system-mode install commands, verifies binaries, and persists `lsp.installed_servers`. Re-running configure on an existing project re-detects and updates the list.
|
|
23
|
+
- **`src/commands/doctor.js` LSP step** — new "LSP layer" line in the diagnostic table + a `lsp-fix` action that reinstalls broken servers. Surfaces missing binaries without breaking other doctor flows.
|
|
24
|
+
- **`framework/templates/overlays/agents/codebase-architect.lsp-example.md`** — starter overlay demonstrating how to add project-specific LSP tuning (monorepo quirks, generated-code exclusions, callsite thresholds) on top of the shipped protocol.
|
|
25
|
+
|
|
26
|
+
### Changed
|
|
27
|
+
|
|
28
|
+
- **`framework/.claude/agents/codebase-architect.md`** — Investigation Protocol step 3 now points at `agents/code-search-protocol.md` for LSP escalation. Behavior under `features.has_lsp_layer: false` is unchanged.
|
|
29
|
+
- **`framework/.claude/agents/REGISTRY.md`** — `codebase-architect` row gains "LSP symbol resolution (when `features.has_lsp_layer: true`)" as a specialization.
|
|
30
|
+
- **`framework/.claude/skills/context-primer/SKILL.md`** — step 3 of the retrieval loop redirects to the code-search protocol for symbol-shaped queries when the flag is on.
|
|
31
|
+
- **`framework/.claude/skills/bug/SKILL.md`** — Phase 0 step 3 references the protocol; `codebase-architect` now automatically uses LSP for symbol lookups during code-path mapping.
|
|
32
|
+
- **`framework/.claude/skills/simplify/SKILL.md`** — deduplication step 3 uses LSP `find-references` to confirm callsites before recommending consolidation; eliminates false positives from textual name collisions and dead-code candidates.
|
|
33
|
+
- **`framework/.claude/skills/prd/SKILL.md` / `new/SKILL.md`** — one-line note that LSP usage is transitive via `context-primer` / `codebase-architect` when the flag is on.
|
|
34
|
+
- **`framework/templates/baldart.config.template.yml`** — adds `features.has_lsp_layer` and the new `lsp:` block with inline documentation.
|
|
35
|
+
- **`framework/docs/PROJECT-CONFIGURATION.md`** — new § 4.5 row for `has_lsp_layer` and a new § 4.6 documenting the `lsp.*` keys, per-adapter install modes, and the fallback contract.
|
|
36
|
+
|
|
37
|
+
### Notes
|
|
38
|
+
|
|
39
|
+
- **Schema-change propagation** (matches the `v3.9.0` pattern): the new key is wired into the template, the configure prompt, the update-detector, the doctor table, the relevant skills, and the changelog.
|
|
40
|
+
- **Backwards-compatible.** Pre-v3.10 consumers running `npx baldart update` see the standard "new config keys" warning (`has_lsp_layer`) and are offered `configure`. Agents and skills behave exactly as before when the flag is absent or `false`.
|
|
41
|
+
- **Fallback contract.** When the layer is enabled but a server is missing, broken, or returns no references for a known symbol, agents silently fall back to Grep. Code search never fails because of LSP issues; `baldart doctor` surfaces the mismatch.
|
|
42
|
+
- **Languages out of scope** (Java, C/C++, PHP, Elixir, …) can be added by dropping a new file under `src/utils/lsp-adapters/`. No core change required.
|
|
43
|
+
|
|
8
44
|
## [3.9.0] - 2026-05-22
|
|
9
45
|
|
|
10
46
|
`worktree-manager` (`/mw`) gains a configurable merge strategy. The previous flow forced every consumer through `gh pr create` + `gh pr merge`; in repos where `develop` is not protected on GitHub, that roundtrip is unnecessary and was observed to stall (PR opened, never merged). The new `git.merge_strategy` key lets each project pick its lane.
|
package/README.md
CHANGED
|
@@ -183,18 +183,22 @@ Skills always-ask when required keys are missing — never silently default.
|
|
|
183
183
|
never overwrites your file. Full guide:
|
|
184
184
|
[`framework/docs/PROJECT-CONFIGURATION.md`](framework/docs/PROJECT-CONFIGURATION.md).
|
|
185
185
|
|
|
186
|
-
### Skills (
|
|
186
|
+
### Skills (23 portable skills)
|
|
187
187
|
|
|
188
188
|
Skills live under `.claude/skills/` and are auto-discovered by Claude Code.
|
|
189
189
|
Bundled skills:
|
|
190
190
|
|
|
191
191
|
- **Workflow**: `new`, `prd`, `prd-add`, `bug`, `simplify`, `worktree-manager`, `issue-review`, `context-primer`
|
|
192
|
-
- **Code quality**: `skill-creator`, `find-skills`, `webapp-testing`, `playwright-skill`
|
|
192
|
+
- **Code quality**: `skill-creator`, `find-skills`, `webapp-testing`, `playwright-skill`, `lsp-bootstrap` (v3.10.0)
|
|
193
193
|
- **Design**: `frontend-design`, `ui-design`, `motion-design`, `gamification-design`
|
|
194
194
|
- **Product**: `seo-audit`, `copywriting`, `api-design-principles`
|
|
195
195
|
- **Knowledge**: `doc-writing-for-rag`, `capture` (LLM wiki overlay)
|
|
196
196
|
- **Integration**: `kie-ai`, `remotion-best-practices`
|
|
197
197
|
|
|
198
|
+
### LSP Symbol Search Layer (new in v3.10.0)
|
|
199
|
+
|
|
200
|
+
When `features.has_lsp_layer: true`, `codebase-architect` and the code-exploration skills (`context-primer`, `bug`, `prd`, `new`, `simplify`) prefer LSP `find-references` / `go-to-definition` over Grep for identifier-shaped queries — the filtering happens **before** Claude reads files, so a common function name no longer dumps thousands of textual matches into context. Opt-in at `baldart configure`; BALDART installs the matching language servers (npm devDeps for TypeScript/Python, system commands printed for Go/Rust/Ruby). Grep remains the fallback for free-text queries and degraded states. See [`framework/agents/code-search-protocol.md`](framework/agents/code-search-protocol.md).
|
|
201
|
+
|
|
198
202
|
### Commands
|
|
199
203
|
|
|
200
204
|
- **/new**: Batch orchestrator with QA validation, production readiness checklist, and context recovery (also available as a skill)
|
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
3.
|
|
1
|
+
3.10.0
|
|
@@ -8,7 +8,7 @@ Quick-reference for all custom agents. Use this to route tasks to the right spec
|
|
|
8
8
|
|
|
9
9
|
| Agent | Category | When to Use | Specialization | Can Edit Code | Key Tools |
|
|
10
10
|
|-------|----------|-------------|----------------|---------------|-----------|
|
|
11
|
-
| **codebase-architect** | Architecture | **MANDATORY** before planning/implementing changes | Platform analysis, system design, canonical-source resolution via Linking Protocol v1 | No | Code navigation, pattern tracing |
|
|
11
|
+
| **codebase-architect** | Architecture | **MANDATORY** before planning/implementing changes | Platform analysis, system design, canonical-source resolution via Linking Protocol v1, LSP symbol resolution (when `features.has_lsp_layer: true`) | No | Code navigation, pattern tracing, LSP find-references / go-to-definition |
|
|
12
12
|
| **plan-auditor** | Architecture | Review implementation plans before coding begins | Risk assessment, gap detection | Yes | Multi-persona review (eng/security/SRE) |
|
|
13
13
|
| **doc-reviewer** | Architecture | Audit/write docs after feature implementation | Macro feature identification, SSOT sync, linking-protocol resolution, doc debt tracking, gap analysis | Yes | Doc writing, TaskCreate (doc debt), token optimization |
|
|
14
14
|
| **wiki-curator** | Documentation | Maintain the derived LLM wiki overlay under `docs/wiki/` (concept pages, syntheses, dashboards, reading guides) without creating new canonicals. See `agents/llm-wiki-methodology.md`. | Synthesis pages, provenance hygiene, freshness, derived-link checks, auto-learning loop | Yes | `docs/wiki/`, wiki lint, reindex follow-up |
|
|
@@ -163,6 +163,14 @@ Before providing any architectural guidance or implementation advice, follow thi
|
|
|
163
163
|
3. **Targeted grep** (only if RAG was weak/empty): grep for 2-3 specific identifiers
|
|
164
164
|
(function names, file patterns), NOT broad keyword sweeps across the entire codebase.
|
|
165
165
|
|
|
166
|
+
**LSP escalation (since v3.10.0):** when `features.has_lsp_layer: true` in
|
|
167
|
+
`baldart.config.yml` AND the query is a symbol/identifier (function, type, class,
|
|
168
|
+
variable name), prefer LSP `find-references` / `go-to-definition` over Grep — it
|
|
169
|
+
filters textual collisions before you read anything. Cap at 3 LSP calls per task,
|
|
170
|
+
then escalate to direct file reads. Falls back to Grep silently when the LSP tool
|
|
171
|
+
isn't loaded or returns nothing. See `framework/agents/code-search-protocol.md`
|
|
172
|
+
for the full hierarchy and query-type discrimination.
|
|
173
|
+
|
|
166
174
|
4. **Targeted verification** — DO NOT read entire files. Instead:
|
|
167
175
|
- For files **<200 lines**: read in full.
|
|
168
176
|
- For files **200-500 lines**: read the first 50 lines (imports + exports) + the
|
|
@@ -38,7 +38,11 @@ Argument: optional bug description (e.g., `/bug feature X is not saving`).
|
|
|
38
38
|
- **Data/Firestore** → MCP Firestore tools + transaction tracing
|
|
39
39
|
- **Auth** → authMiddleware.ts + auth error codes
|
|
40
40
|
- **Build/Deploy** → Vercel logs + build output
|
|
41
|
-
3. Launch `codebase-architect` agent to map the affected code paths — do NOT start debugging blind
|
|
41
|
+
3. Launch `codebase-architect` agent to map the affected code paths — do NOT start debugging blind.
|
|
42
|
+
When `features.has_lsp_layer: true` and the symptom names a concrete symbol
|
|
43
|
+
(function/type/handler), `codebase-architect` will use LSP find-references /
|
|
44
|
+
go-to-definition to locate the exact callsites instead of grepping. See
|
|
45
|
+
`framework/agents/code-search-protocol.md`.
|
|
42
46
|
4. Search doc-rag for related patterns: `mcp__doc-rag__search_docs` with bug keywords
|
|
43
47
|
- always use `mode="hybrid"` (vector + knowledge graph) for richer context retrieval
|
|
44
48
|
- if results come from Obsidian, treat them as context only and verify runtime behavior against repo docs/code before fixing
|
|
@@ -78,6 +78,10 @@ SEARCH STRATEGY — RAG-first, verify-only-if-needed:
|
|
|
78
78
|
|
|
79
79
|
3. ONLY IF RAG was empty — broader search:
|
|
80
80
|
a. Grep the project's source root for 2-3 specific identifiers from steps 1-2.
|
|
81
|
+
When `features.has_lsp_layer: true` AND the identifier is a symbol (function /
|
|
82
|
+
type / class name, not a free-text phrase), prefer LSP `find-references` /
|
|
83
|
+
`go-to-definition` over Grep — it filters textual collisions before any file
|
|
84
|
+
read. Cap at 3 LSP calls, then fall back. See `framework/agents/code-search-protocol.md`.
|
|
81
85
|
b. Read key file headers (first 50 lines) to identify structure.
|
|
82
86
|
DO NOT read `${paths.prd_dir}/` or `${paths.references_dir}/` files in full —
|
|
83
87
|
RAG already indexes them. Only read a specific doc section if RAG
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: lsp-bootstrap
|
|
3
|
+
description: >
|
|
4
|
+
Install, verify, and document the LSP symbol-search layer for this project.
|
|
5
|
+
Detects languages (TypeScript, Python, Go, Rust, Ruby), installs the matching
|
|
6
|
+
language servers (npm devDep where possible, system command otherwise),
|
|
7
|
+
verifies binaries are reachable, and writes lsp.installed_servers to
|
|
8
|
+
baldart.config.yml. Use when the user says /lsp-bootstrap, "install LSP",
|
|
9
|
+
"set up symbol search", or after enabling features.has_lsp_layer for the
|
|
10
|
+
first time. Idempotent — re-running on an already-configured project
|
|
11
|
+
re-verifies and reports drift.
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
# LSP Bootstrap
|
|
15
|
+
|
|
16
|
+
Set up the LSP (Language Server Protocol) layer that lets agents and skills
|
|
17
|
+
search by symbol instead of by string. Without this layer, code search burns
|
|
18
|
+
context on textual collisions; with it, references resolve to the same symbol
|
|
19
|
+
**before** Claude reads any file.
|
|
20
|
+
|
|
21
|
+
## Project Context
|
|
22
|
+
|
|
23
|
+
**Reads from `baldart.config.yml`:** `features.has_lsp_layer`, `lsp.installed_servers`, `lsp.auto_verify`.
|
|
24
|
+
**Gated by features:** `features.has_lsp_layer` — this skill refuses to run when the flag is `false`, prompting the user to flip it via `npx baldart configure` first.
|
|
25
|
+
**Overlay:** loads `.baldart/overlays/lsp-bootstrap.md` if present — project-specific install commands (e.g. a system-managed pyright via uv, a non-standard gopls path).
|
|
26
|
+
**On missing keys:** ask the user; do not assume defaults. See `framework/agents/project-context.md` § 3.
|
|
27
|
+
|
|
28
|
+
## What This Skill Does
|
|
29
|
+
|
|
30
|
+
1. Reads `baldart.config.yml` and confirms `features.has_lsp_layer: true`.
|
|
31
|
+
2. Probes the cwd via `src/utils/lsp-adapters/` to detect which languages are
|
|
32
|
+
present (markers: `tsconfig.json`, `pyproject.toml`, `go.mod`, `Cargo.toml`,
|
|
33
|
+
`Gemfile`, plus heuristic fallbacks).
|
|
34
|
+
3. For each detected language:
|
|
35
|
+
- **npm-dev** adapters (TypeScript, Python via pyright): runs `npm install
|
|
36
|
+
--save-dev <pkg>` with user confirmation.
|
|
37
|
+
- **system** adapters (Go gopls, Rust rust-analyzer, Ruby ruby-lsp): prints
|
|
38
|
+
the install command for the user to run in a separate terminal. Does NOT
|
|
39
|
+
execute system-level installs automatically.
|
|
40
|
+
4. Verifies each binary is reachable (`<binary> --version`).
|
|
41
|
+
5. Updates `lsp.installed_servers` in `baldart.config.yml` with the verified
|
|
42
|
+
set. System-mode servers are recorded even if not yet reachable (the user
|
|
43
|
+
may have a pending install) — `baldart doctor` will flag the mismatch.
|
|
44
|
+
6. Prints a summary table and points the user to
|
|
45
|
+
`framework/agents/code-search-protocol.md` for runtime behavior.
|
|
46
|
+
|
|
47
|
+
## Workflow
|
|
48
|
+
|
|
49
|
+
1. **Refusal check.** If `features.has_lsp_layer: false` (or missing):
|
|
50
|
+
```
|
|
51
|
+
This project hasn't opted in to the LSP layer yet.
|
|
52
|
+
Run `npx baldart configure` and answer YES to "Enable LSP symbol-search layer?"
|
|
53
|
+
then re-run /lsp-bootstrap.
|
|
54
|
+
```
|
|
55
|
+
Stop here. Do not proceed.
|
|
56
|
+
|
|
57
|
+
2. **Probe.** Call the BALDART installer (internally `src/utils/lsp-installer.js`):
|
|
58
|
+
```
|
|
59
|
+
node -e 'const L=require("./.framework/src/utils/lsp-installer"); console.log(JSON.stringify(new L().recommend(),null,2))'
|
|
60
|
+
```
|
|
61
|
+
Show the detected languages with their `installMode`.
|
|
62
|
+
|
|
63
|
+
3. **Confirm per server.** For each recommended server, ask the user. Skip the
|
|
64
|
+
ones already in `lsp.installed_servers` unless they fail verify.
|
|
65
|
+
|
|
66
|
+
4. **Install.** Run the appropriate `installCommand()`. Capture failures into a
|
|
67
|
+
"Skipped" bucket — never abort the whole skill on one failure.
|
|
68
|
+
|
|
69
|
+
5. **Verify.** For each installed server, call its `verifyCommand()`. Mark the
|
|
70
|
+
results.
|
|
71
|
+
|
|
72
|
+
6. **Persist.** Update `baldart.config.yml`:
|
|
73
|
+
```yaml
|
|
74
|
+
lsp:
|
|
75
|
+
installed_servers: [typescript, python]
|
|
76
|
+
auto_verify: true
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
7. **Output.** A compact one-line status, in the project's `identity.language`
|
|
80
|
+
from `baldart.config.yml` (English default). Matches the brevity of
|
|
81
|
+
`/cont` rather than its specific Italian phrasing.
|
|
82
|
+
|
|
83
|
+
## Output Contract
|
|
84
|
+
|
|
85
|
+
A single short status block — never a multi-page report. Format:
|
|
86
|
+
|
|
87
|
+
```
|
|
88
|
+
LSP bootstrap:
|
|
89
|
+
✓ typescript-language-server (npm devDep, verified)
|
|
90
|
+
✓ pyright (npm devDep, verified)
|
|
91
|
+
⚠ gopls — run `go install golang.org/x/tools/gopls@latest`, then `baldart doctor`
|
|
92
|
+
· ruby — not detected (no Gemfile)
|
|
93
|
+
Config updated: baldart.config.yml lsp.installed_servers = [typescript, python, go]
|
|
94
|
+
Next: codebase-architect will now prefer LSP find-references over Grep for symbols.
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Notes
|
|
98
|
+
|
|
99
|
+
- This skill never edits source code or installs binaries that aren't language
|
|
100
|
+
servers — its only side effect is `npm install --save-dev <lsp-package>` and a
|
|
101
|
+
YAML write to `baldart.config.yml`.
|
|
102
|
+
- For Claude Code users: in addition to the binaries, you may need to load a
|
|
103
|
+
code-intelligence plugin (`/plugin` in Claude Code). That step is documented
|
|
104
|
+
in the printed output when applicable, but the skill does NOT manage Claude
|
|
105
|
+
Code plugins directly.
|
|
106
|
+
- Re-run safely. The skill diffs the current `lsp.installed_servers` against
|
|
107
|
+
recommended + verified, so additions / removals / repairs are all idempotent.
|
|
108
|
+
|
|
109
|
+
## See Also
|
|
110
|
+
|
|
111
|
+
- `framework/agents/code-search-protocol.md` — runtime fallback rules
|
|
112
|
+
- `src/utils/lsp-adapters/` — per-language install/verify recipes
|
|
113
|
+
- `src/commands/configure.js` — same install flow when first enabling the flag
|
|
@@ -236,7 +236,7 @@ For each card, execute these phases in order:
|
|
|
236
236
|
- If NOT `DONE` → HALT: log in `## Issues & Flags` and ask the user: "Card <CARD-ID> depends on <DEP-ID> which is `<status>`. Proceed anyway, or wait?" Do not start implementation until the user responds explicitly.
|
|
237
237
|
- If `DONE` → continue.
|
|
238
238
|
3. Update `${paths.references_dir}/project-status.md` Active Code Context (skip when the file does not exist in the project).
|
|
239
|
-
4. Invoke the **codebase-architect** agent (MUST per AGENTS.md) to understand the relevant codebase area, existing patterns, and architecture before any implementation.
|
|
239
|
+
4. Invoke the **codebase-architect** agent (MUST per AGENTS.md) to understand the relevant codebase area, existing patterns, and architecture before any implementation. When `features.has_lsp_layer: true`, the architect uses LSP find-references for any identifier-shaped lookups inside the card (transitive via `agents/code-search-protocol.md`).
|
|
240
240
|
4b. **Plan-auditor grounding check** — invoke the **plan-auditor** agent in QUICK mode with this prompt:
|
|
241
241
|
```
|
|
242
242
|
Quick grounding check only (not a full audit). Verify this backlog card's requirements are grounded in the actual codebase.
|
|
@@ -148,7 +148,9 @@ Before entering the discovery loop, load codebase context using the **context-pr
|
|
|
148
148
|
2. Invoke the `Skill` tool with `skill: "context-primer"` passing the keywords
|
|
149
149
|
(e.g., `args: "prize scanning scratch card wheel"`).
|
|
150
150
|
3. The context-primer launches `codebase-architect` which searches RAG, docs,
|
|
151
|
-
backlog, source code, and git history — returning a compact summary.
|
|
151
|
+
backlog, source code, and git history — returning a compact summary. When
|
|
152
|
+
`features.has_lsp_layer: true`, the symbol-lookup tier is automatically used
|
|
153
|
+
for identifier-shaped queries (transitive via `agents/code-search-protocol.md`).
|
|
152
154
|
4. Additionally, use `search_docs` MCP tool (if available) with `mode: "hybrid"` for the feature domain
|
|
153
155
|
to surface related PRDs, ADRs, and specs not covered by context-primer. The
|
|
154
156
|
active retrieval layer is Obsidian-first LightRAG; use Obsidian hits for
|
|
@@ -39,6 +39,12 @@ For each new piece of code in the diff:
|
|
|
39
39
|
1. **Start with `${paths.references_dir}/component-registry.md`** — the authoritative inventory of all UI primitives, shared components, hooks, and utility modules. Scan the relevant tables before grepping. Then search for existing utilities and helpers that could replace newly written code in the project's utility roots (e.g. `${paths.components_root}/shared/`, `${paths.components_primitives}/`, and `src/lib/`, `src/hooks/` if they exist), and files adjacent to the changed ones.
|
|
40
40
|
2. **For each new component**, Grep the codebase for components with similar names, similar prop signatures, or similar JSX structure. Check for copy-pasted layout components (`layout.tsx` files with near-identical structure).
|
|
41
41
|
3. **For each new function/hook**, search for functions with similar signatures or logic patterns elsewhere. Check for duplicated page-level patterns (similar data fetching, similar error boundaries, similar loading states).
|
|
42
|
+
When `features.has_lsp_layer: true`, run LSP `find-references` on each new exported
|
|
43
|
+
symbol before grepping — it tells you exactly which callsites would need to migrate
|
|
44
|
+
if you replaced the new code with an existing utility (textual grep over identifier
|
|
45
|
+
names overcounts because of collisions). See `framework/agents/code-search-protocol.md`.
|
|
46
|
+
Also use LSP `find-references` on candidate "existing" utilities to confirm they're
|
|
47
|
+
really in use and not abandoned dead code before recommending them as the canonical version.
|
|
42
48
|
4. **Flag components that wrap the same underlying element** with minor style/prop differences.
|
|
43
49
|
|
|
44
50
|
Classify each finding as:
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# Code Search Protocol
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
Define a deterministic retrieval hierarchy for agents and skills that need to
|
|
6
|
+
find code (identifiers, references, definitions, similar patterns) inside the
|
|
7
|
+
consumer repo. The goal is to filter noise **before** Claude reads files, not
|
|
8
|
+
after — Grep on a common function name returns thousands of textual matches and
|
|
9
|
+
burns context; LSP returns only the references that point to the same symbol.
|
|
10
|
+
|
|
11
|
+
## Scope
|
|
12
|
+
|
|
13
|
+
**In**: How agents/skills should choose between RAG, LSP, Grep, and Git when
|
|
14
|
+
searching for code. Fallback rules when a tier is unavailable.
|
|
15
|
+
**Out**: Documentation search (see `agents/llm-wiki-methodology.md`), test
|
|
16
|
+
discovery (see `agents/testing.md`).
|
|
17
|
+
|
|
18
|
+
## Gating
|
|
19
|
+
|
|
20
|
+
This protocol is **conditional** on `features.has_lsp_layer: true` in
|
|
21
|
+
`baldart.config.yml`. When the flag is `false` or missing, agents fall back to
|
|
22
|
+
the legacy RAG → Grep → Git flow and skip the LSP tier entirely.
|
|
23
|
+
|
|
24
|
+
Adapters for installed servers live under `src/utils/lsp-adapters/`; the
|
|
25
|
+
current set of servers BALDART has wired in this project is recorded at
|
|
26
|
+
`lsp.installed_servers` in `baldart.config.yml`.
|
|
27
|
+
|
|
28
|
+
## Retrieval Hierarchy (in order)
|
|
29
|
+
|
|
30
|
+
1. **RAG hybrid** — `search_docs(query, mode: "hybrid")` via the doc-rag MCP if
|
|
31
|
+
available. Best for free-text and conceptual queries ("how does session
|
|
32
|
+
token storage work").
|
|
33
|
+
2. **LSP symbol search** — when the query is an identifier (function, type,
|
|
34
|
+
class, variable name) and `features.has_lsp_layer: true`. Use the LSP tool
|
|
35
|
+
(`ToolSearch("LSP")` in Claude Code) for:
|
|
36
|
+
- **find references**: every callsite of a symbol across the project.
|
|
37
|
+
- **go to definition**: the single authoritative declaration.
|
|
38
|
+
- **type info / hover**: signature, parameters, return type.
|
|
39
|
+
- **document/workspace symbols**: enumerate top-level symbols.
|
|
40
|
+
3. **Grep** — for textual patterns that aren't symbols (a comment, a magic
|
|
41
|
+
string, a regex match, a config key, a TODO marker). Also the fallback when
|
|
42
|
+
LSP is unavailable or returns nothing for a symbol that clearly exists.
|
|
43
|
+
4. **Git log** — `git log --oneline -20 --grep="keyword"` to find when and why
|
|
44
|
+
code changed. Last resort, but cheap when you suspect a regression.
|
|
45
|
+
|
|
46
|
+
## Query-type discrimination
|
|
47
|
+
|
|
48
|
+
Before picking a tier, classify the query:
|
|
49
|
+
|
|
50
|
+
| Query shape | Start with |
|
|
51
|
+
|----------------------------------------|------------|
|
|
52
|
+
| `handleSubmit`, `UserSchema`, `useAuth`| LSP |
|
|
53
|
+
| `"TODO: encrypt tokens"` | Grep |
|
|
54
|
+
| `/api/v1/users` route handler | Grep then LSP on the handler name |
|
|
55
|
+
| "how is auth wired" | RAG hybrid |
|
|
56
|
+
| "when did we change session storage" | Git log |
|
|
57
|
+
| Mixed (refactor a function used in 5 places) | RAG → LSP find-references |
|
|
58
|
+
|
|
59
|
+
## Budget
|
|
60
|
+
|
|
61
|
+
- **LSP**: up to **3 calls per task** for symbol resolution. If after 3 calls
|
|
62
|
+
the picture is still unclear, escalate to RAG or read the file directly —
|
|
63
|
+
don't keep ping-ponging through references.
|
|
64
|
+
- **Grep**: existing project budget (typically 15–25 calls per agent).
|
|
65
|
+
- **RAG / Git**: no hard budget, but verify the verdict (`rag_telemetry.verdict`
|
|
66
|
+
for RAG) before relying on it.
|
|
67
|
+
|
|
68
|
+
## Fallback rules
|
|
69
|
+
|
|
70
|
+
- LSP tool not loaded / plugin missing → silently fall back to Grep with the
|
|
71
|
+
symbol name. Do **not** prompt the user mid-task — the missing tool is a
|
|
72
|
+
setup concern surfaced by `baldart doctor`.
|
|
73
|
+
- LSP returns zero references for a symbol you know exists → fall back to
|
|
74
|
+
Grep; the symbol may live in a file the LSP server hasn't indexed yet (e.g.
|
|
75
|
+
a path excluded by `tsconfig.json`).
|
|
76
|
+
- LSP times out (>8s) → fall back to Grep for this query, log the symptom in
|
|
77
|
+
the agent's reasoning so the user can re-run doctor.
|
|
78
|
+
|
|
79
|
+
## Examples
|
|
80
|
+
|
|
81
|
+
### Refactor: rename a function used across the repo
|
|
82
|
+
|
|
83
|
+
1. RAG hybrid: confirm the function is the right one and not a name collision.
|
|
84
|
+
2. LSP find-references on the symbol → exact callsite list (file + line +
|
|
85
|
+
column).
|
|
86
|
+
3. Read each callsite, propose the rename, apply edits.
|
|
87
|
+
|
|
88
|
+
Why this beats Grep: a project with both `handleSubmit` in a form component
|
|
89
|
+
and `handleSubmit` in a CLI utility gets two semantically distinct sets from
|
|
90
|
+
LSP, but a single conflated list from Grep.
|
|
91
|
+
|
|
92
|
+
### Bug: trace where a value originates
|
|
93
|
+
|
|
94
|
+
1. RAG hybrid on the symptom (free text).
|
|
95
|
+
2. LSP go-to-definition on the suspect variable → authoritative source.
|
|
96
|
+
3. LSP find-references back from the definition → call graph upstream.
|
|
97
|
+
4. Grep only if LSP cannot resolve (e.g. the value passes through a
|
|
98
|
+
dynamically-typed boundary).
|
|
99
|
+
|
|
100
|
+
### Cleanup: remove a deprecated helper
|
|
101
|
+
|
|
102
|
+
1. LSP find-references on the helper. Zero hits → safe to delete.
|
|
103
|
+
2. Non-zero hits → migrate callsites first, then delete.
|
|
104
|
+
|
|
105
|
+
Skip Grep here: textual matches inside string literals or comments are not
|
|
106
|
+
true callsites and would falsely block the deletion.
|
|
107
|
+
|
|
108
|
+
## When to skip LSP entirely
|
|
109
|
+
|
|
110
|
+
- Query is a phrase or comment, not a symbol.
|
|
111
|
+
- The project's `lsp.installed_servers` is empty for the relevant language.
|
|
112
|
+
- You are reading a single small file (under 200 lines) — direct Read is
|
|
113
|
+
cheaper than a tool call.
|
|
114
|
+
|
|
115
|
+
## Maintenance
|
|
116
|
+
|
|
117
|
+
When adding a new language to `src/utils/lsp-adapters/`, no change is required
|
|
118
|
+
here unless the new language has special tooling caveats (e.g. multi-root
|
|
119
|
+
workspaces, monorepos). In that case, append a subsection below.
|
|
120
|
+
|
|
121
|
+
## See also
|
|
122
|
+
|
|
123
|
+
- `framework/.claude/skills/lsp-bootstrap/SKILL.md` — install + verify flow.
|
|
124
|
+
- `framework/agents/project-context.md` — always-ask / never-assume contract.
|
|
125
|
+
- `framework/.claude/agents/codebase-architect.md` — primary consumer of this
|
|
126
|
+
protocol.
|
|
@@ -14,6 +14,7 @@ Route agents to the right module with minimal reading.
|
|
|
14
14
|
|
|
15
15
|
- **MANDATORY pre-read for any skill/agent that touches project-specific paths, identity, stack, or feature toggles** -> read `agents/project-context.md`. Skills consult `baldart.config.yml` + `.baldart/overlays/<skill>.md` instead of hard-coded paths; missing keys MUST be asked, never assumed.
|
|
16
16
|
- If needing to understand codebase structure, existing patterns, or architecture before planning -> MUST invoke `codebase-architect` agent (via Task tool) first; do not proceed without architectural understanding.
|
|
17
|
+
- If searching for a function/type/symbol (identifier-shaped query, not free text) and `features.has_lsp_layer: true` -> read `agents/code-search-protocol.md` and prefer LSP `find-references` / `go-to-definition` over Grep. Falls back to Grep when LSP is unavailable or the query is textual.
|
|
17
18
|
- If touching API endpoints or request/response shape -> read `agents/api-contracts.md` and `${paths.references_dir}/api/index.md` (then specific API module for your domain).
|
|
18
19
|
- If touching database schema or fields -> read `agents/data-model.md` and `${paths.references_dir}/data-model.md`.
|
|
19
20
|
- If touching UI pages/routes or flows -> read `${paths.references_dir}/ui/index.md` (then specific UI module for your domain).
|
|
@@ -57,6 +58,7 @@ When adding or updating agents, update REGISTRY.md — not this file.
|
|
|
57
58
|
- `agents/skills-mapping.md`
|
|
58
59
|
- `agents/llm-wiki-methodology.md` — LLM wiki overlay methodology + auto-learning loop (since v2.0.0)
|
|
59
60
|
- `agents/project-context.md` — Project context protocol: `baldart.config.yml` + overlays + missing-key handling (since v3.0.0)
|
|
61
|
+
- `agents/code-search-protocol.md` — Retrieval hierarchy for code search: RAG → LSP → Grep → Git (since v3.10.0, gated on `features.has_lsp_layer`)
|
|
60
62
|
|
|
61
63
|
## Where to Document (Decision Tree)
|
|
62
64
|
|