specweave 1.0.198 → 1.0.199

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/CLAUDE.md CHANGED
@@ -1,4 +1,4 @@
1
- <!-- SW:META template="claude" version="1.0.197" sections="header,start,autodetect,metarule,rules,workflow,reflect,context,structure,taskformat,secrets,syncing,testing,tdd,api,limits,troubleshooting,lazyloading,principles,linking,mcp,auto,docs" -->
1
+ <!-- SW:META template="claude" version="1.0.198" sections="header,start,autodetect,metarule,rules,workflow,reflect,context,structure,taskformat,secrets,syncing,testing,tdd,api,limits,troubleshooting,lazyloading,principles,linking,mcp,auto,docs" -->
2
2
 
3
3
  <!-- SW:SECTION:hook-priority version="1.0.171" -->
4
4
  ## ⛔ ABSOLUTE PRIORITY: Hook Instructions Are Mandatory
@@ -53,7 +53,7 @@ Hooks exist to enforce workflow discipline. If you ignore them:
53
53
  **This is non-negotiable. No exceptions. No "just this once".**
54
54
  <!-- SW:END:hook-priority -->
55
55
 
56
- <!-- SW:SECTION:header version="1.0.197" -->
56
+ <!-- SW:SECTION:header version="1.0.198" -->
57
57
  **Framework**: SpecWeave | **Truth**: `spec.md` + `tasks.md`
58
58
  <!-- SW:END:header -->
59
59
 
@@ -277,7 +277,7 @@ SpecWeave's `user-prompt-submit.sh` hook auto-installs LSP plugins with **projec
277
277
 
278
278
  **Reference**: [Official Docs](https://code.claude.com/docs/en/discover-plugins#install-plugins) | [Settings Scopes](https://code.claude.com/docs/en/settings#configuration-scopes)
279
279
 
280
- <!-- SW:SECTION:start version="1.0.197" -->
280
+ <!-- SW:SECTION:start version="1.0.198" -->
281
281
  ## Getting Started
282
282
 
283
283
  **Initial increment**: `0001-project-setup` (auto-created by `specweave init`)
@@ -287,7 +287,7 @@ SpecWeave's `user-prompt-submit.sh` hook auto-installs LSP plugins with **projec
287
287
  2. **Customize**: Edit spec.md and use for setup tasks
288
288
  <!-- SW:END:start -->
289
289
 
290
- <!-- SW:SECTION:autodetect version="1.0.197" -->
290
+ <!-- SW:SECTION:autodetect version="1.0.198" -->
291
291
  ## Auto-Detection
292
292
 
293
293
  SpecWeave auto-detects product descriptions and routes to `/sw:increment`:
@@ -297,7 +297,7 @@ SpecWeave auto-detects product descriptions and routes to `/sw:increment`:
297
297
  **Opt-out phrases**: "Just brainstorm first" | "Don't plan yet" | "Quick discussion" | "Let's explore ideas"
298
298
  <!-- SW:END:autodetect -->
299
299
 
300
- <!-- SW:SECTION:metarule version="1.0.197" -->
300
+ <!-- SW:SECTION:metarule version="1.0.198" -->
301
301
  ## Meta-Rule: Think-Before-Act
302
302
 
303
303
  **Satisfy dependencies BEFORE dependent operations.**
@@ -308,7 +308,7 @@ SpecWeave auto-detects product descriptions and routes to `/sw:increment`:
308
308
  ```
309
309
  <!-- SW:END:metarule -->
310
310
 
311
- <!-- SW:SECTION:rules version="1.0.197" -->
311
+ <!-- SW:SECTION:rules version="1.0.198" -->
312
312
  ## Rules
313
313
 
314
314
  1. **Files** → `.specweave/increments/####-name/` (see Structure section for details)
@@ -324,7 +324,7 @@ SpecWeave auto-detects product descriptions and routes to `/sw:increment`:
324
324
  Use next available number. **NEVER create duplicate prefixes.**
325
325
  <!-- SW:END:rules -->
326
326
 
327
- <!-- SW:SECTION:workflow version="1.0.197" -->
327
+ <!-- SW:SECTION:workflow version="1.0.198" -->
328
328
  ## Workflow
329
329
 
330
330
  `/sw:increment "X"` → `/sw:do` → `/sw:progress` → `/sw:done 0001`
@@ -338,7 +338,6 @@ SpecWeave auto-detects product descriptions and routes to `/sw:increment`:
338
338
  | `/sw:cancel-auto` | ⚠️ EMERGENCY ONLY manual cancel |
339
339
  | `/sw:validate` | Quality check |
340
340
  | `/sw:done` | Close |
341
- | `/sw:reconcile` | Fix ID collisions after merge (multi-dev) |
342
341
  | `/sw-github:sync` | GitHub sync |
343
342
  | `/sw-jira:sync` | Jira sync |
344
343
 
@@ -371,24 +370,14 @@ project/
371
370
  **NEVER assume single-repo mode without scanning first!**
372
371
  <!-- SW:END:save-nested-repos -->
373
372
 
374
- <!-- SW:SECTION:reflect version="1.0.197" -->
373
+ <!-- SW:SECTION:reflect version="1.0.198" -->
375
374
  ## Skill Memories
376
375
 
377
376
  SpecWeave learns from corrections. Learnings saved here automatically. Edit or delete as needed.
378
377
 
379
378
  **Disable**: Set `"reflect": { "enabled": false }` in `.specweave/config.json`
380
-
381
- ### Devops
382
- - **2026-01-29**: LSP requires setup (see "LSP Setup" section)
383
-
384
- ### Logging
385
- - **2026-01-29**: Do NOT verify immediately - show dialog instead
386
-
387
- ### General
388
- - **2026-01-29**: Always check for credentials FIRST (presence only - never display values)
389
379
  <!-- SW:END:reflect -->
390
380
 
391
-
392
381
  ## Skill Memories
393
382
 
394
383
  <!-- Auto-captured by SpecWeave reflect. Edit or delete as needed. -->
@@ -396,7 +385,7 @@ SpecWeave learns from corrections. Learnings saved here automatically. Edit or d
396
385
  ### Pm
397
386
  - **2026-02-01**: Enable interview process during increment creation for SpecWeave projects
398
387
 
399
- <!-- SW:SECTION:context version="1.0.197" -->
388
+ <!-- SW:SECTION:context version="1.0.198" -->
400
389
  ## Context
401
390
 
402
391
  **Before implementing**: Check ADRs at `.specweave/docs/internal/architecture/adr/`
@@ -404,7 +393,7 @@ SpecWeave learns from corrections. Learnings saved here automatically. Edit or d
404
393
  **Load context**: `/sw:context <topic>` loads relevant living docs into conversation
405
394
  <!-- SW:END:context -->
406
395
 
407
- <!-- SW:SECTION:structure version="1.0.197" -->
396
+ <!-- SW:SECTION:structure version="1.0.198" -->
408
397
  ## Structure
409
398
 
410
399
  ```
@@ -419,7 +408,7 @@ SpecWeave learns from corrections. Learnings saved here automatically. Edit or d
419
408
  **Everything else → subfolders**: `reports/` | `logs/` | `scripts/` | `backups/`
420
409
  <!-- SW:END:structure -->
421
410
 
422
- <!-- SW:SECTION:taskformat version="1.0.197" -->
411
+ <!-- SW:SECTION:taskformat version="1.0.198" -->
423
412
  ## Task Format
424
413
 
425
414
  ```markdown
@@ -429,7 +418,7 @@ SpecWeave learns from corrections. Learnings saved here automatically. Edit or d
429
418
  ```
430
419
  <!-- SW:END:taskformat -->
431
420
 
432
- <!-- SW:SECTION:secrets version="1.0.197" -->
421
+ <!-- SW:SECTION:secrets version="1.0.198" -->
433
422
  ## Secrets Check
434
423
 
435
424
  **BEFORE CLI tools**: Check existing config first!
@@ -443,7 +432,7 @@ gh auth status
443
432
  **SECURITY**: NEVER use `grep TOKEN .env` without `-q` flag - it exposes credentials in terminal!
444
433
  <!-- SW:END:secrets -->
445
434
 
446
- <!-- SW:SECTION:syncing version="1.0.197" -->
435
+ <!-- SW:SECTION:syncing version="1.0.198" -->
447
436
  ## External Sync (GitHub/JIRA/ADO)
448
437
 
449
438
  **Commands**: `/sw-github:sync {id}` (issues) | `/sw:sync-specs` (living docs only)
@@ -453,7 +442,7 @@ gh auth status
453
442
  **Config**: Set `sync.github.enabled: true` + `canUpdateExternalItems: true` in config.json
454
443
  <!-- SW:END:syncing -->
455
444
 
456
- <!-- SW:SECTION:testing version="1.0.197" -->
445
+ <!-- SW:SECTION:testing version="1.0.198" -->
457
446
  ## Testing
458
447
 
459
448
  BDD in tasks.md | Unit >80% | `.test.ts` (Vitest)
@@ -465,7 +454,7 @@ vi.mock('./module', () => ({ func: mockFn }));
465
454
  ```
466
455
  <!-- SW:END:testing -->
467
456
 
468
- <!-- SW:SECTION:tdd version="1.0.197" -->
457
+ <!-- SW:SECTION:tdd version="1.0.198" -->
469
458
  ## TDD Mode (Test-Driven Development)
470
459
 
471
460
  **When `testing.defaultTestMode: "TDD"` is configured**, follow RED-GREEN-REFACTOR discipline:
@@ -526,7 +515,7 @@ When TDD is enabled, tasks include phase markers:
526
515
  **Rule**: Complete dependencies BEFORE dependent tasks (RED before GREEN).
527
516
  <!-- SW:END:tdd -->
528
517
 
529
- <!-- SW:SECTION:api version="1.0.197" -->
518
+ <!-- SW:SECTION:api version="1.0.198" -->
530
519
  ## API Development (OpenAPI-First)
531
520
 
532
521
  **For API projects only.** Commands: `/sw:api-docs --all` | `--openapi` | `--postman` | `--validate`
@@ -534,72 +523,13 @@ When TDD is enabled, tasks include phase markers:
534
523
  Enable in config: `{"apiDocs":{"enabled":true,"openApiPath":"openapi.yaml"}}`
535
524
  <!-- SW:END:api -->
536
525
 
537
- <!-- SW:SECTION:limits version="1.0.197" -->
526
+ <!-- SW:SECTION:limits version="1.0.198" -->
538
527
  ## Limits
539
528
 
540
529
  **Max 1500 lines/file** — extract before adding
541
530
  <!-- SW:END:limits -->
542
531
 
543
- <!-- SW:SECTION:multidev version="1.0.197" -->
544
- ## Multi-Developer Workflows
545
-
546
- **For teams with 2+ developers working on same project.**
547
-
548
- ### How It Works
549
-
550
- 1. **Each developer works on their branch** - create increments freely
551
- 2. **Merge to main** - git handles folder merges naturally
552
- 3. **Run `/sw:reconcile` after merge** - fixes any ID collisions
553
-
554
- ### Post-Merge Reconciliation
555
-
556
- When two developers create increments with same ID (e.g., both create `0001E-feature` from JIRA import):
557
-
558
- ```bash
559
- # After merging branches to main
560
- /sw:reconcile
561
-
562
- # What it does:
563
- # 1. Scans ALL increment folders (active, _archive, _abandoned, _paused)
564
- # 2. Detects ID collisions (same base number in multiple folders)
565
- # 3. Uses file modification dates to determine chronological order
566
- # 4. Renumbers "later" increments to next available IDs
567
- # 5. Updates metadata.json, living docs references, and sync links
568
- ```
569
-
570
- ### Example Scenario
571
-
572
- ```
573
- Branch A creates: 0001E-auth-feature (closed, synced to JIRA)
574
- Branch B creates: 0001E-payment-feature (closed, synced to JIRA)
575
-
576
- After merge to main:
577
- .specweave/increments/
578
- ├── 0001E-auth-feature/ # From branch A (modified Jan 15)
579
- └── 0001E-payment-feature/ # From branch B (modified Jan 20) ← COLLISION
580
-
581
- After /sw:reconcile:
582
- .specweave/increments/
583
- ├── 0001E-auth-feature/ # Kept as 0001E (earlier)
584
- └── 0002E-payment-feature/ # Renumbered to 0002E (later)
585
- ```
586
-
587
- ### Merge Conflict Strategy
588
-
589
- | File | Strategy | Notes |
590
- |------|----------|-------|
591
- | `spec.md`, `tasks.md` | Manual merge | Essential content |
592
- | `metadata.json` | Union merge | Auto via `.gitattributes` |
593
- | `.specweave/state/*` | Gitignored | Local state, no conflicts |
594
-
595
- ### Best Practices
596
-
597
- 1. **Different increment names** - even with same ID, different names merge fine
598
- 2. **Run `/sw:reconcile` after merge** - always, to catch any ID collisions
599
- 3. **Commit reconcile results** - the renumbering is a git commit
600
- <!-- SW:END:multidev -->
601
-
602
- <!-- SW:SECTION:troubleshooting version="1.0.197" -->
532
+ <!-- SW:SECTION:troubleshooting version="1.0.198" -->
603
533
  ## Troubleshooting
604
534
 
605
535
  | Issue | Fix |
@@ -616,7 +546,7 @@ After /sw:reconcile:
616
546
  | Docs folder collisions | Check: `ls docs/ \| grep -E '^[0-9]{2}-' \| cut -d'-' -f1 \| sort \| uniq -d` |
617
547
  <!-- SW:END:troubleshooting -->
618
548
 
619
- <!-- SW:SECTION:lazyloading version="1.0.197" -->
549
+ <!-- SW:SECTION:lazyloading version="1.0.198" -->
620
550
  ## Plugin Auto-Loading
621
551
 
622
552
  Plugins load automatically based on project type and keywords. Manual install if needed:
@@ -630,7 +560,7 @@ export SPECWEAVE_DISABLE_AUTO_LOAD=1 # Disable auto-load
630
560
  **Token savings**: Core ~3-5K tokens vs all plugins ~60K+
631
561
  <!-- SW:END:lazyloading -->
632
562
 
633
- <!-- SW:SECTION:principles version="1.0.197" -->
563
+ <!-- SW:SECTION:principles version="1.0.198" -->
634
564
  ## Principles
635
565
 
636
566
  1. **Spec-first**: `/sw:increment` before coding
@@ -639,7 +569,7 @@ export SPECWEAVE_DISABLE_AUTO_LOAD=1 # Disable auto-load
639
569
  4. **Traceable**: All work → specs → ACs
640
570
  <!-- SW:END:principles -->
641
571
 
642
- <!-- SW:SECTION:linking version="1.0.197" -->
572
+ <!-- SW:SECTION:linking version="1.0.198" -->
643
573
  ## Bidirectional Linking
644
574
 
645
575
  Tasks ↔ User Stories auto-linked via AC-IDs: `AC-US1-01` → `US-001`
@@ -647,7 +577,7 @@ Tasks ↔ User Stories auto-linked via AC-IDs: `AC-US1-01` → `US-001`
647
577
  Task format: `**AC**: AC-US1-01, AC-US1-02` (CRITICAL for linking)
648
578
  <!-- SW:END:linking -->
649
579
 
650
- <!-- SW:SECTION:mcp version="1.0.197" -->
580
+ <!-- SW:SECTION:mcp version="1.0.198" -->
651
581
  ## External Services
652
582
 
653
583
  **Priority**: CLI tools first (simpler) → MCP for complex integrations
@@ -669,7 +599,7 @@ claude mcp add --transport stdio postgres -- npx -y @modelcontextprotocol/server
669
599
  MCP supports lazy-loading (auto mode) - tools load on-demand when >10% context.
670
600
  <!-- SW:END:mcp -->
671
601
 
672
- <!-- SW:SECTION:auto version="1.0.197" -->
602
+ <!-- SW:SECTION:auto version="1.0.198" -->
673
603
  ## Auto Mode
674
604
 
675
605
  **Commands**: `/sw:auto` (start) | `/sw:auto-status` (check) | `/sw:cancel-auto` (emergency only)
@@ -686,7 +616,7 @@ MCP supports lazy-loading (auto mode) - tools load on-demand when >10% context.
686
616
  **STOP & ASK** if: Spec conflicts | Task unnecessary | Requirement ambiguous
687
617
  <!-- SW:END:auto -->
688
618
 
689
- <!-- SW:SECTION:docs version="1.0.197" -->
619
+ <!-- SW:SECTION:docs version="1.0.198" -->
690
620
  ## Docs
691
621
 
692
622
  [spec-weave.com](https://spec-weave.com)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "specweave",
3
- "version": "1.0.198",
3
+ "version": "1.0.199",
4
4
  "description": "Spec-driven development framework for Claude Code. AI-native workflow with living documentation, intelligent agents, and multilingual support (9 languages). Enterprise-grade traceability with permanent specs and temporary increments.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -172,6 +172,39 @@ output_approve_with_context() {
172
172
  printf '{"hookSpecificOutput":{"hookEventName":"UserPromptSubmit","additionalContext":"%s"}}\n' "$escaped"
173
173
  }
174
174
 
175
+ # Helper: Get skill memory content for injection (v1.0.198)
176
+ # Reads .specweave/skill-memories/{skill}.md and extracts learnings.
177
+ # Args: $1=full skill name (e.g., "sw:pm", "sw-frontend:frontend-architect")
178
+ # Returns: Formatted memory content on stdout, or empty string if not found
179
+ get_skill_memory_context() {
180
+ local full_skill="$1"
181
+ local project_root="${PROJECT_ROOT:-$(pwd)}"
182
+
183
+ # Extract skill name (part after colon, or whole string if no colon)
184
+ local skill_name="${full_skill##*:}"
185
+
186
+ local memory_file="$project_root/.specweave/skill-memories/${skill_name}.md"
187
+
188
+ if [[ ! -f "$memory_file" ]]; then
189
+ return 0
190
+ fi
191
+
192
+ # Read the file and extract learnings section
193
+ local content
194
+ content=$(cat "$memory_file" 2>/dev/null)
195
+
196
+ # Extract lines between "## Learnings" and next heading or EOF
197
+ local learnings
198
+ learnings=$(echo "$content" | sed -n '/^## Learnings$/,/^## /{ /^## Learnings$/d; /^## /d; p; }' | sed '/^$/d')
199
+
200
+ if [[ -z "$learnings" ]]; then
201
+ return 0
202
+ fi
203
+
204
+ # Format for injection
205
+ printf '📚 **Skill Memory for %s**:\\n%s' "$skill_name" "$learnings"
206
+ }
207
+
175
208
  # Helper: Check if plugin is installed by reading installed_plugins.json (v1.0.175)
176
209
  # This is the SOURCE OF TRUTH - more reliable than `claude plugin list` which can have timing issues.
177
210
  # Args: $1=plugin name (e.g., "sw-frontend"), $2=marketplace (e.g., "specweave")
@@ -837,12 +870,25 @@ if [[ "${SPECWEAVE_DISABLE_AUTO_LOAD:-0}" != "1" ]] && [[ "${SPECWEAVE_DISABLE_H
837
870
  # Build agent spawn directive if routing skills available (v1.0.155)
838
871
  AGENT_DIRECTIVE=""
839
872
  # v1.0.168: Skill invocation directive (takes precedence over routing)
873
+ # v1.0.198: Added skill memory injection
840
874
  if [[ -n "$SKILL_INVOCATION" ]]; then
875
+ # Get skill memory for injection (v1.0.198)
876
+ SKILL_MEMORY=""
877
+ SKILL_MEMORY_RAW=$(get_skill_memory_context "$SKILL_INVOCATION")
878
+ if [[ -n "$SKILL_MEMORY_RAW" ]]; then
879
+ SKILL_MEMORY="
880
+
881
+ ${SKILL_MEMORY_RAW}
882
+
883
+ ---
884
+ "
885
+ fi
886
+
841
887
  if [[ "$SKILL_MANDATORY" == "true" ]]; then
842
888
  AGENT_DIRECTIVE="
843
889
 
844
890
  ---
845
-
891
+ ${SKILL_MEMORY}
846
892
  <skill_invocation_required>
847
893
  ### 🎯 MANDATORY: Use ${SKILL_INVOCATION} Skill
848
894
 
@@ -862,7 +908,7 @@ ${SKILL_REASON:-This skill provides specialized support for your task.}
862
908
  AGENT_DIRECTIVE="
863
909
 
864
910
  ---
865
-
911
+ ${SKILL_MEMORY}
866
912
  ### 💡 Recommended: Use ${SKILL_INVOCATION} Skill
867
913
 
868
914
  Consider invoking this skill for better results:
@@ -926,7 +972,18 @@ Continue interviewing until requirements are crystal clear (10-40+ questions for
926
972
  "
927
973
  fi
928
974
 
929
- MSG="${AUTOLOAD_PREFIX}╔══════════════════════════════════════════════════════════════════════════════╗
975
+ # v1.0.198: Get skill memory for increment-planner
976
+ INC_PLANNER_MEMORY=""
977
+ INC_PLANNER_MEMORY_RAW=$(get_skill_memory_context "sw:increment-planner")
978
+ if [[ -n "$INC_PLANNER_MEMORY_RAW" ]]; then
979
+ INC_PLANNER_MEMORY="
980
+ ${INC_PLANNER_MEMORY_RAW}
981
+
982
+ ---
983
+ "
984
+ fi
985
+
986
+ MSG="${AUTOLOAD_PREFIX}${INC_PLANNER_MEMORY}╔══════════════════════════════════════════════════════════════════════════════╗
930
987
  ║ 🎯 SKILL FIRST - Call Skill tool BEFORE implementation ║
931
988
  ╚══════════════════════════════════════════════════════════════════════════════╝
932
989
 
@@ -1,35 +1,27 @@
1
1
  ---
2
2
  name: lsp
3
3
  description: >
4
- MANDATORY: When user says "LSP", "findReferences", "find references", "go to definition",
5
- "where defined", "show type", "list symbols", "what uses", or "who calls" - YOU MUST use
6
- specweave lsp commands via Bash (NOT grep). This skill provides the commands to use.
4
+ Code navigation with LSP. When user says "find references", "go to definition",
5
+ "where defined", "show type", "list symbols", "what uses", or "who calls" -
6
+ use native LSP tools if available, otherwise fall back to specweave lsp commands.
7
7
  ---
8
8
 
9
9
  # LSP Code Intelligence
10
10
 
11
- Use SpecWeave's LSP CLI for semantic code navigation and analysis.
11
+ Semantic code navigation and analysis.
12
12
 
13
- ## IMPORTANT: File Path Required
13
+ ## Priority Order
14
14
 
15
- **If the user does NOT specify a file path, you MUST first find the file:**
15
+ **1. Native LSP (if plugins installed via hooks)**
16
16
 
17
- ```bash
18
- # Step 1: Find which file(s) contain the symbol
19
- grep -rn --include="*.ts" "function symbolName\|class symbolName" .
20
-
21
- # Step 2: Then use LSP on the found file
22
- specweave lsp refs <found-file> <symbol>
23
- ```
17
+ If you have native LSP tools available (goToDefinition, findReferences, hover, etc.),
18
+ use those directly - they're faster and more integrated.
24
19
 
25
- **Example:**
26
- User says: "Find references to sayHello"
27
- 1. First: `grep -rn --include="*.ts" "function sayHello" .` → finds `src/utils.ts`
28
- 2. Then: `specweave lsp refs src/utils.ts sayHello`
20
+ Check: Native LSP requires `ENABLE_LSP_TOOL=1` and LSP plugins installed by hooks.
29
21
 
30
- ## How to Use
22
+ **2. SpecWeave CLI (fallback)**
31
23
 
32
- **Use Bash tool with `specweave lsp` commands:**
24
+ If native LSP is unavailable or not working, use `specweave lsp` commands:
33
25
 
34
26
  ```bash
35
27
  # Find all references to a symbol
@@ -48,174 +40,46 @@ specweave lsp symbols <file>
48
40
  specweave lsp search <query>
49
41
  ```
50
42
 
51
- ## Command Reference
52
-
53
- | Command | Purpose | Example |
54
- |---------|---------|---------|
55
- | `lsp refs` | Find all usages of a symbol | `specweave lsp refs src/api.ts handleRequest` |
56
- | `lsp def` | Navigate to symbol definition | `specweave lsp def src/utils.ts formatDate` |
57
- | `lsp hover` | Get type signature and docs | `specweave lsp hover src/models.ts User` |
58
- | `lsp symbols` | List all symbols in file | `specweave lsp symbols src/index.ts` |
59
- | `lsp search` | Find symbols across workspace | `specweave lsp search Controller` |
43
+ ## When to Use Which
60
44
 
61
- ## When to Use LSP vs Grep
62
-
63
- | Task | Use LSP | Use Grep |
64
- |------|---------|----------|
65
- | Find function usages | `lsp refs` | |
66
- | Navigate to definition | `lsp def` | |
67
- | Get type information | ✅ `lsp hover` | ❌ |
68
- | Search text patterns | ❌ | ✅ `Grep tool` |
69
- | Find in comments | ❌ | ✅ `Grep tool` |
70
- | Case-insensitive search | ❌ | ✅ `Grep -i` |
71
-
72
- **Rule of thumb**: Use LSP for symbols, Grep for text patterns.
73
-
74
- ## Examples
75
-
76
- ### Example 1: Find All References Before Refactoring
77
-
78
- User: "Find all references to handleAutoCommand"
79
-
80
- ```bash
81
- specweave lsp refs src/cli/commands/auto.ts handleAutoCommand
82
- ```
83
-
84
- Output:
85
- ```
86
- References to 'handleAutoCommand':
87
-
88
- bin/specweave.js:473:1
89
- bin/specweave.js:474:1
90
- src/cli/commands/auto.ts:82:5
91
- src/cli/commands/auto.ts:96:24
92
-
93
- Total: 4 references
94
- ```
95
-
96
- ### Example 2: Go to Definition
97
-
98
- User: "Where is processArgs defined?"
99
-
100
- ```bash
101
- specweave lsp def src/cli/commands/auto.ts processArgs
102
- ```
103
-
104
- ### Example 3: Get Type Information
105
-
106
- User: "What's the type signature of handleAutoCommand?"
107
-
108
- ```bash
109
- specweave lsp hover src/cli/commands/auto.ts handleAutoCommand
110
- ```
45
+ | Situation | Use |
46
+ |-----------|-----|
47
+ | Native LSP tools available | Native tools (faster) |
48
+ | Native LSP unavailable | `specweave lsp` commands |
49
+ | CI/CD or scripts | `specweave lsp` commands |
50
+ | User explicitly asks for specweave | `specweave lsp` commands |
111
51
 
112
- ### Example 4: List All Exports
52
+ ## File Path Required (for CLI fallback)
113
53
 
114
- User: "What functions are exported from lsp.ts?"
54
+ If using `specweave lsp` and user doesn't specify a file path, find it first:
115
55
 
116
56
  ```bash
117
- specweave lsp symbols src/cli/commands/lsp.ts
118
- ```
119
-
120
- ### Example 5: Search Workspace
121
-
122
- User: "Find all Command classes"
123
-
124
- ```bash
125
- specweave lsp search Command
126
- ```
127
-
128
- ## Supported Languages
129
-
130
- | Language | Server Required | Auto-detected by |
131
- |----------|-----------------|------------------|
132
- | TypeScript/JS | `typescript-language-server` | `tsconfig.json`, `package.json` |
133
- | Python | `pyright` or `pylsp` | `requirements.txt`, `pyproject.toml` |
134
- | C#/.NET | `csharp-ls` | `*.csproj`, `*.sln` |
135
- | Go | `gopls` | `go.mod` |
136
- | Rust | `rust-analyzer` | `Cargo.toml` |
137
-
138
- ## Fallback Behavior
139
-
140
- If LSP is unavailable (server not installed, timeout, etc.):
141
- 1. Commands automatically fall back to grep-based search
142
- 2. Results show "(grep fallback)" in output
143
- 3. Still functional, but less precise for symbol resolution
144
-
145
- ## Requirements
146
-
147
- Language servers must be installed globally:
148
-
149
- ```bash
150
- # TypeScript (most common)
151
- npm install -g typescript-language-server typescript
152
-
153
- # Python
154
- pip install pyright
155
-
156
- # Go
157
- go install golang.org/x/tools/gopls@latest
158
-
159
- # Rust
160
- rustup component add rust-analyzer
161
- ```
162
-
163
- ## Decision Tree for Claude
57
+ # Step 1: Find which file(s) contain the symbol
58
+ grep -rn --include="*.ts" "function symbolName\|class symbolName" .
164
59
 
60
+ # Step 2: Then use LSP on the found file
61
+ specweave lsp refs <found-file> <symbol>
165
62
  ```
166
- User asks about code navigation?
167
-
168
- ├─ "Find references to X" or "What uses X" or "Who calls X"
169
- │ └─ Use: specweave lsp refs <file> <symbol>
170
-
171
- ├─ "Go to definition" or "Where is X defined"
172
- │ └─ Use: specweave lsp def <file> <symbol>
173
-
174
- ├─ "What type is X" or "Show signature of X"
175
- │ └─ Use: specweave lsp hover <file> <symbol>
176
-
177
- ├─ "List symbols in file" or "What's exported"
178
- │ └─ Use: specweave lsp symbols <file>
179
-
180
- ├─ "Find symbol X in workspace" or "Search for X"
181
- │ └─ Use: specweave lsp search <query>
182
-
183
- └─ Text search, patterns, comments
184
- └─ Use: Grep tool (not LSP)
185
- ```
186
-
187
- ## Why This Exists
188
-
189
- **This is SpecWeave's OWN LSP CLI - separate from Claude Code's native LSP!**
190
-
191
- | System | What It Is | Requires ENABLE_LSP_TOOL? |
192
- |--------|------------|---------------------------|
193
- | **SpecWeave LSP CLI** (this skill) | Commands like `specweave lsp refs/def/hover` | **NO** - works standalone |
194
- | **Claude Code Native LSP** | Background code intelligence via plugins | **YES** - requires env var |
195
63
 
196
- ### SpecWeave LSP CLI (This Skill)
197
- - Uses `specweave lsp` commands via Bash
198
- - Directly calls language servers (typescript-language-server, pyright, etc.)
199
- - Works independently of Claude Code's plugin system
200
- - Falls back to grep if language server unavailable
64
+ ## How Plugin Installation Works
201
65
 
202
- ### Claude Code Native LSP (Separate)
203
- - Requires `export ENABLE_LSP_TOOL=1` in shell config
204
- - Requires working LSP plugins from `boostvolt/claude-code-lsps` marketplace
205
- - Official marketplace plugins (`@claude-plugins-official`) are broken (Issue #15148)
206
- - Provides background enhancement when editing code
66
+ SpecWeave hooks auto-install LSP plugins per project:
67
+ - `vtsls@claude-code-lsps` for TypeScript/JavaScript
68
+ - `pyright@claude-code-lsps` for Python
69
+ - `rust-analyzer@claude-code-lsps` for Rust
207
70
 
208
- **Bottom line**: Use this skill's commands (`specweave lsp refs/def/hover`) - they work
209
- without any additional setup beyond having the language server installed.
71
+ These require `ENABLE_LSP_TOOL=1` in the environment.
210
72
 
211
- ## Project-Specific Learnings
73
+ ## Why SpecWeave CLI Still Exists
212
74
 
213
- **Before starting work, check for project-specific learnings:**
214
-
215
- ```bash
216
- # Check if skill memory exists for this skill
217
- cat .specweave/skill-memories/lsp.md 2>/dev/null || echo "No project learnings yet"
218
- ```
75
+ 1. **Fallback** when plugins unavailable or broken
76
+ 2. **CI/CD** environments without Claude Code
77
+ 3. **Direct user access** to LSP functionality
78
+ 4. **Living docs generation** uses it internally
219
79
 
220
- Project learnings are automatically captured by the reflection system when corrections or patterns are identified during development. These learnings help you understand project-specific conventions and past decisions.
80
+ ## Performance
221
81
 
82
+ SpecWeave's TsServerClient (used by both systems) is **52x faster** than grep:
83
+ - Uses direct tsserver protocol (not typescript-language-server)
84
+ - Semantic analysis vs text matching
85
+ - 226 fewer false positives in typical searches