lsp-intelligence 0.3.0 → 0.3.3
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-plugin/marketplace.json +18 -0
- package/.claude-plugin/plugin.json +11 -0
- package/CLAUDE.md +75 -0
- package/README.md +15 -38
- package/hooks/hooks.json +29 -0
- package/hooks/post-edit-check.sh +23 -0
- package/package.json +19 -5
- package/scripts/ensure-deps.mjs +24 -0
- package/scripts/launch.mjs +29 -0
- package/skills/api-check/SKILL.md +34 -0
- package/skills/check/SKILL.md +25 -0
- package/skills/context/SKILL.md +24 -0
- package/skills/diff/SKILL.md +27 -0
- package/skills/find/SKILL.md +63 -0
- package/skills/impact/SKILL.md +21 -0
- package/skills/verify/SKILL.md +54 -0
- package/skills/why/SKILL.md +31 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "lsp-intelligence-marketplace",
|
|
3
|
+
"description": "Official marketplace for the lsp-intelligence Claude Code plugin",
|
|
4
|
+
"owner": {
|
|
5
|
+
"name": "Peri Levy"
|
|
6
|
+
},
|
|
7
|
+
"plugins": [
|
|
8
|
+
{
|
|
9
|
+
"name": "lsp-intelligence",
|
|
10
|
+
"description": "Local code intelligence for TypeScript/JavaScript — Find code, explain failures, guard API contracts, simulate changes.",
|
|
11
|
+
"source": {
|
|
12
|
+
"source": "npm",
|
|
13
|
+
"package": "lsp-intelligence",
|
|
14
|
+
"version": "0.3.3"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "lsp-intelligence",
|
|
3
|
+
"description": "Local code intelligence for TypeScript/JavaScript — Find code, explain failures, guard API contracts, simulate changes.",
|
|
4
|
+
"version": "0.3.3",
|
|
5
|
+
"mcpServers": {
|
|
6
|
+
"lsp-intelligence": {
|
|
7
|
+
"command": "node",
|
|
8
|
+
"args": ["${CLAUDE_PLUGIN_ROOT}/scripts/launch.mjs"]
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
}
|
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# LSP Intelligence — Agent Instructions
|
|
2
|
+
|
|
3
|
+
Local code intelligence for real engineering workflows. **Find** code, **explain** failures, **guard** API contracts.
|
|
4
|
+
|
|
5
|
+
> **Note:** The first query in a new session may take a few seconds while the TypeScript engine warms up. The workspace index is persisted and loads instantly on repeat sessions. Subsequent queries are 100-300ms.
|
|
6
|
+
|
|
7
|
+
## Primary tools
|
|
8
|
+
|
|
9
|
+
| Workflow | Tool | Skill |
|
|
10
|
+
|----------|------|-------|
|
|
11
|
+
| Find code by intent | `find_code` | `/find` |
|
|
12
|
+
| Find structural patterns | `find_pattern` | — |
|
|
13
|
+
| Trace root cause of an error | `root_cause_trace` | `/why` |
|
|
14
|
+
| Check API contract changes | `api_guard` | `/api-check` |
|
|
15
|
+
| Full pre-merge verification | `verify_changes` | `/verify` |
|
|
16
|
+
|
|
17
|
+
## When to use LSP tools
|
|
18
|
+
|
|
19
|
+
| You want to... | Instead of... | Use |
|
|
20
|
+
|----------------|---------------|-----|
|
|
21
|
+
| Find where an API is used | `grep "symbolName"` | `find_code` or `find_references` |
|
|
22
|
+
| Find implementations by concept | Multiple greps | `find_code` (auto-routes to behavior search) |
|
|
23
|
+
| Find structural patterns | Manual code reading | `find_code` or `find_pattern` |
|
|
24
|
+
| Find config/route/flag definitions | Grepping JSON/YAML | `find_code` with config focus |
|
|
25
|
+
| Jump to a definition | Reading imports | `goto_definition` |
|
|
26
|
+
| Understand a type signature | Reading the source file | `hover` |
|
|
27
|
+
| See what a file contains | `read` on the whole file | `outline` |
|
|
28
|
+
| Know what breaks if you change something | Manual tracing | `impact_trace` |
|
|
29
|
+
| Prepare context for a coding task | Reading 5-10 files | `gather_context` |
|
|
30
|
+
| Check for type errors after editing | Running `tsc` | `live_diagnostics` |
|
|
31
|
+
| Understand a TypeScript error | Reading error + source | `explain_error` / `/why` |
|
|
32
|
+
| Review what you changed semantically | `git diff` | `semantic_diff` |
|
|
33
|
+
|
|
34
|
+
## When to still use grep
|
|
35
|
+
|
|
36
|
+
- Searching for string literals in comments or logs
|
|
37
|
+
- Searching non-code files where LSP has no coverage
|
|
38
|
+
- Simple text matching where code-aware ranking isn't needed
|
|
39
|
+
|
|
40
|
+
## Workflow patterns
|
|
41
|
+
|
|
42
|
+
### Before modifying code
|
|
43
|
+
1. `outline` — understand structure without reading everything
|
|
44
|
+
2. `impact_trace` — know the blast radius
|
|
45
|
+
3. `gather_context` — get only relevant code, token-budgeted
|
|
46
|
+
4. `find_test_files` — know which tests to update
|
|
47
|
+
|
|
48
|
+
### While implementing
|
|
49
|
+
- `hover` to check types before writing
|
|
50
|
+
- `auto_import` to get import paths right
|
|
51
|
+
- `goto_definition` to navigate to source
|
|
52
|
+
- `find_references` to verify you're not missing usages
|
|
53
|
+
|
|
54
|
+
### After editing
|
|
55
|
+
- `live_diagnostics` on every file you changed
|
|
56
|
+
- If errors: `explain_error` or `/why` for root cause
|
|
57
|
+
- `semantic_diff` before committing
|
|
58
|
+
- `api_guard` or `/api-check` if exports changed
|
|
59
|
+
|
|
60
|
+
## Symbol-name input
|
|
61
|
+
|
|
62
|
+
All tools accept symbol names directly: `{ "symbol": "UserService" }`. You don't need file paths and line numbers. Only fall back to position-based input when the symbol name is ambiguous across packages.
|
|
63
|
+
|
|
64
|
+
## Skills
|
|
65
|
+
|
|
66
|
+
| Skill | Purpose |
|
|
67
|
+
|-------|---------|
|
|
68
|
+
| `/find <query>` | Guided code search with follow-up actions |
|
|
69
|
+
| `/why <file:line>` | Root cause trace with evidence chain |
|
|
70
|
+
| `/api-check` | API contract guard with semver verdict |
|
|
71
|
+
| `/verify` | Full pre-merge: types + API + test coverage |
|
|
72
|
+
| `/check <files>` | Type check with error explanations |
|
|
73
|
+
| `/impact <symbol>` | Transitive usage trace |
|
|
74
|
+
| `/context <symbols>` | Token-budgeted context extraction |
|
|
75
|
+
| `/diff` | Semantic diff with blast radius |
|
package/README.md
CHANGED
|
@@ -36,52 +36,35 @@ Or get a file overview without reading it:
|
|
|
36
36
|
|
|
37
37
|
## Installation
|
|
38
38
|
|
|
39
|
-
Requires **Node.js 20+**.
|
|
40
|
-
|
|
41
|
-
### Option 1: CLI (recommended)
|
|
39
|
+
Requires **Node.js 20+**.
|
|
42
40
|
|
|
43
|
-
|
|
41
|
+
### Plugin install (recommended)
|
|
44
42
|
|
|
45
|
-
```
|
|
43
|
+
```
|
|
46
44
|
/plugin marketplace add perilevy/lsp-intelligence
|
|
47
|
-
/plugin install lsp-intelligence
|
|
45
|
+
/plugin install lsp-intelligence
|
|
48
46
|
/reload-plugins
|
|
49
47
|
```
|
|
50
48
|
|
|
51
|
-
|
|
49
|
+
That's it. The plugin installs the MCP server, skills, hooks, and agent context in one step. No separate runtime install, no manual `.mcp.json` edits.
|
|
50
|
+
|
|
51
|
+
### MCP server only (advanced)
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
For non-Claude Code agents or manual MCP configuration:
|
|
54
54
|
|
|
55
55
|
```json
|
|
56
56
|
{
|
|
57
|
-
"
|
|
57
|
+
"mcpServers": {
|
|
58
58
|
"lsp-intelligence": {
|
|
59
|
-
"
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
59
|
+
"command": "npx",
|
|
60
|
+
"args": ["-y", "lsp-intelligence"],
|
|
61
|
+
"env": { "LSP_WORKSPACE_ROOT": "${workspaceFolder}" }
|
|
63
62
|
}
|
|
64
|
-
},
|
|
65
|
-
"enabledPlugins": {
|
|
66
|
-
"lsp-intelligence@lsp-intelligence": true
|
|
67
63
|
}
|
|
68
64
|
}
|
|
69
65
|
```
|
|
70
66
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
Use npm source in `marketplace.json` for version pinning and built-in dependency resolution:
|
|
74
|
-
|
|
75
|
-
```json
|
|
76
|
-
{
|
|
77
|
-
"name": "lsp-intelligence",
|
|
78
|
-
"source": {
|
|
79
|
-
"source": "npm",
|
|
80
|
-
"package": "lsp-intelligence",
|
|
81
|
-
"version": "0.2.0"
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
```
|
|
67
|
+
This gives you the raw MCP tools only — no skills or hooks.
|
|
85
68
|
|
|
86
69
|
## Capabilities
|
|
87
70
|
|
|
@@ -260,10 +243,7 @@ Add to your `.mcp.json`:
|
|
|
260
243
|
"mcpServers": {
|
|
261
244
|
"lsp": {
|
|
262
245
|
"command": "npx",
|
|
263
|
-
"args": ["-y", "lsp-intelligence"]
|
|
264
|
-
"env": {
|
|
265
|
-
"LSP_WORKSPACE_ROOT": "${CLAUDE_PROJECT_DIR}"
|
|
266
|
-
}
|
|
246
|
+
"args": ["-y", "lsp-intelligence"]
|
|
267
247
|
}
|
|
268
248
|
}
|
|
269
249
|
}
|
|
@@ -286,10 +266,7 @@ Then in `.mcp.json`:
|
|
|
286
266
|
"mcpServers": {
|
|
287
267
|
"lsp": {
|
|
288
268
|
"command": "node",
|
|
289
|
-
"args": ["/absolute/path/to/lsp-intelligence/dist/index.js"]
|
|
290
|
-
"env": {
|
|
291
|
-
"LSP_WORKSPACE_ROOT": "${CLAUDE_PROJECT_DIR}"
|
|
292
|
-
}
|
|
269
|
+
"args": ["/absolute/path/to/lsp-intelligence/dist/index.js"]
|
|
293
270
|
}
|
|
294
271
|
}
|
|
295
272
|
}
|
package/hooks/hooks.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"hooks": {
|
|
3
|
+
"SessionStart": [
|
|
4
|
+
{
|
|
5
|
+
"hooks": [
|
|
6
|
+
{
|
|
7
|
+
"type": "command",
|
|
8
|
+
"command": "node -e \"const v=process.version.slice(1).split('.').map(Number);if(v[0]<20){console.error('lsp-intelligence requires Node 20+, found '+process.version);process.exit(1)}\""
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"type": "command",
|
|
12
|
+
"command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/ensure-deps.mjs\""
|
|
13
|
+
}
|
|
14
|
+
]
|
|
15
|
+
}
|
|
16
|
+
],
|
|
17
|
+
"PostToolUse": [
|
|
18
|
+
{
|
|
19
|
+
"matcher": "Edit|Write|MultiEdit",
|
|
20
|
+
"hooks": [
|
|
21
|
+
{
|
|
22
|
+
"type": "command",
|
|
23
|
+
"command": "\"${CLAUDE_PLUGIN_ROOT}/hooks/post-edit-check.sh\""
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
]
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Post-edit hook: only emit diagnostic prompt for TS/JS files in the workspace.
|
|
3
|
+
# Reads tool input from stdin as JSON.
|
|
4
|
+
FILE_PATH=$(cat /dev/stdin | node -e "process.stdin.setEncoding('utf8');let d='';process.stdin.on('data',c=>d+=c);process.stdin.on('end',()=>{try{console.log(JSON.parse(d).tool_input.file_path||'')}catch{}})")
|
|
5
|
+
|
|
6
|
+
# Skip non-TS/JS files
|
|
7
|
+
case "$FILE_PATH" in
|
|
8
|
+
*.ts|*.tsx|*.js|*.jsx) ;;
|
|
9
|
+
*) exit 0 ;;
|
|
10
|
+
esac
|
|
11
|
+
|
|
12
|
+
# Skip files outside the workspace (e.g. editing other projects)
|
|
13
|
+
WORKSPACE="${LSP_WORKSPACE_ROOT:-$PWD}"
|
|
14
|
+
case "$FILE_PATH" in
|
|
15
|
+
"$WORKSPACE"*) ;;
|
|
16
|
+
*) exit 0 ;;
|
|
17
|
+
esac
|
|
18
|
+
|
|
19
|
+
echo "A TypeScript/JavaScript file was edited: $FILE_PATH
|
|
20
|
+
1. Run live_diagnostics on it to check for new type errors
|
|
21
|
+
2. If errors are found, run explain_error on each to provide fix suggestions
|
|
22
|
+
3. If the file contains export statements, note that the exported API may have changed — consider running api_guard if the user is working on a cross-package change
|
|
23
|
+
4. If no errors, say nothing"
|
package/package.json
CHANGED
|
@@ -1,26 +1,39 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lsp-intelligence",
|
|
3
|
-
"version": "0.3.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.3.3",
|
|
4
|
+
"description": "Local code intelligence for TypeScript/JavaScript — Find code, explain failures, guard API contracts, simulate changes.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"lsp-intelligence": "./dist/index.js"
|
|
8
8
|
},
|
|
9
9
|
"files": [
|
|
10
10
|
"dist",
|
|
11
|
+
".claude-plugin",
|
|
12
|
+
"skills",
|
|
13
|
+
"hooks",
|
|
14
|
+
"scripts",
|
|
15
|
+
"CLAUDE.md",
|
|
11
16
|
"README.md",
|
|
12
17
|
"LICENSE"
|
|
13
18
|
],
|
|
14
19
|
"scripts": {
|
|
15
20
|
"clean": "rm -rf dist",
|
|
16
21
|
"build": "rm -rf dist && tsc",
|
|
17
|
-
"
|
|
22
|
+
"prepublishOnly": "rm -rf dist && tsc",
|
|
18
23
|
"start": "tsx src/index.ts",
|
|
19
24
|
"test": "vitest run",
|
|
20
25
|
"test:watch": "vitest",
|
|
21
26
|
"typecheck": "tsc --noEmit",
|
|
22
27
|
"bench": "tsx benchmarks/run.ts",
|
|
23
|
-
"bench:e2e": "tsx benchmarks/run.ts --e2e"
|
|
28
|
+
"bench:e2e": "tsx benchmarks/run.ts --e2e",
|
|
29
|
+
"bench:api-guard": "tsx benchmarks/run-api-guard.ts",
|
|
30
|
+
"bench:root-cause": "tsx benchmarks/run-root-cause.ts",
|
|
31
|
+
"test:overlay": "tsx benchmarks/test-overlay.ts",
|
|
32
|
+
"test:program": "tsx benchmarks/test-program.ts",
|
|
33
|
+
"test:typestate": "tsx benchmarks/test-typestate.ts",
|
|
34
|
+
"test:simulate": "tsx benchmarks/test-simulate.ts",
|
|
35
|
+
"test:workflows": "tsx benchmarks/test-workflows.ts",
|
|
36
|
+
"test:cache": "tsx benchmarks/test-cache.ts"
|
|
24
37
|
},
|
|
25
38
|
"dependencies": {
|
|
26
39
|
"@ast-grep/napi": "^0.42.0",
|
|
@@ -43,5 +56,6 @@
|
|
|
43
56
|
"publishConfig": {
|
|
44
57
|
"registry": "https://registry.npmjs.org",
|
|
45
58
|
"access": "public"
|
|
46
|
-
}
|
|
59
|
+
},
|
|
60
|
+
"packageManager": "yarn@1.22.22+sha1.ac34549e6aa8e7ead463a7407e1c7390f61a6610"
|
|
47
61
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Ensure the plugin's npm dependencies are installed.
|
|
4
|
+
*
|
|
5
|
+
* Claude Code extracts the npm tarball but does not run `npm install`
|
|
6
|
+
* for the package's dependencies. This script fills that gap — it runs
|
|
7
|
+
* once on first SessionStart and is a no-op on every subsequent start.
|
|
8
|
+
*
|
|
9
|
+
* Marker: node_modules/@modelcontextprotocol (core dep, always present
|
|
10
|
+
* after a successful install).
|
|
11
|
+
*/
|
|
12
|
+
import { existsSync } from 'fs';
|
|
13
|
+
import { join, dirname } from 'path';
|
|
14
|
+
import { fileURLToPath } from 'url';
|
|
15
|
+
import { execSync } from 'child_process';
|
|
16
|
+
|
|
17
|
+
const pluginRoot = join(dirname(fileURLToPath(import.meta.url)), '..');
|
|
18
|
+
const marker = join(pluginRoot, 'node_modules', '@modelcontextprotocol');
|
|
19
|
+
|
|
20
|
+
if (!existsSync(marker)) {
|
|
21
|
+
console.error('[lsp-intelligence] Installing dependencies (first run)...');
|
|
22
|
+
execSync('npm install --ignore-scripts', { cwd: pluginRoot, stdio: 'inherit' });
|
|
23
|
+
console.error('[lsp-intelligence] Dependencies ready.');
|
|
24
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* lsp-intelligence plugin launcher.
|
|
4
|
+
*
|
|
5
|
+
* Runs from the plugin-installed package directory.
|
|
6
|
+
* Fast: no network, no install, no dependency resolution.
|
|
7
|
+
* Just finds dist/index.js and spawns it.
|
|
8
|
+
*
|
|
9
|
+
* LSP_WORKSPACE_ROOT defaults to process.cwd() which Claude Code sets to
|
|
10
|
+
* the current workspace when starting MCP servers.
|
|
11
|
+
*/
|
|
12
|
+
import { spawn } from 'child_process';
|
|
13
|
+
import { join, dirname } from 'path';
|
|
14
|
+
import { fileURLToPath } from 'url';
|
|
15
|
+
|
|
16
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
17
|
+
const serverPath = join(__dirname, '..', 'dist', 'index.js');
|
|
18
|
+
|
|
19
|
+
const child = spawn(process.execPath, [serverPath], {
|
|
20
|
+
stdio: 'inherit',
|
|
21
|
+
env: {
|
|
22
|
+
...process.env,
|
|
23
|
+
LSP_WORKSPACE_ROOT: process.env.LSP_WORKSPACE_ROOT ?? process.cwd(),
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
child.on('exit', (code) => process.exit(code ?? 0));
|
|
28
|
+
process.on('SIGTERM', () => child.kill('SIGTERM'));
|
|
29
|
+
process.on('SIGINT', () => child.kill('SIGINT'));
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: api-check
|
|
3
|
+
description: Check for breaking API changes — what exports changed, who consumes them, and semver impact
|
|
4
|
+
argument-hint: [--base <branch>] [--scope changed|all]
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# API Guard
|
|
8
|
+
|
|
9
|
+
Check the public API surface for breaking changes before merging.
|
|
10
|
+
|
|
11
|
+
## Steps
|
|
12
|
+
|
|
13
|
+
1. Parse the user's input:
|
|
14
|
+
- If `--base <branch>`: use that as the comparison base
|
|
15
|
+
- If `--scope all`: check all files, not just changed ones
|
|
16
|
+
- Default: changed files only, base auto-detected from main/master
|
|
17
|
+
|
|
18
|
+
2. Run `api_guard` with the parsed arguments
|
|
19
|
+
|
|
20
|
+
3. Present the result:
|
|
21
|
+
- **Semver verdict**: MAJOR (breaking), MINOR (additive), PATCH (internal)
|
|
22
|
+
- **Breaking changes**: list with structural diffs and consumer counts
|
|
23
|
+
- **Risky changes**: changes that might break consumers
|
|
24
|
+
- **Safe changes**: additive or internal-only
|
|
25
|
+
|
|
26
|
+
4. For each breaking change, highlight:
|
|
27
|
+
- What exactly changed (enum member added, param now required, etc.)
|
|
28
|
+
- How many cross-package consumers are affected
|
|
29
|
+
- Sample consumer files
|
|
30
|
+
|
|
31
|
+
5. If breaking changes exist:
|
|
32
|
+
- Suggest running `/impact` on the most impactful symbol
|
|
33
|
+
- Ask if the breaking change is intentional
|
|
34
|
+
- Offer to run `/check` on consumer files to verify they compile
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: check
|
|
3
|
+
description: Run type checking on files — catch errors immediately after edits
|
|
4
|
+
argument-hint: [file-path ...]
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Type Check
|
|
8
|
+
|
|
9
|
+
Check for type errors after edits and explain any issues found.
|
|
10
|
+
|
|
11
|
+
## Steps
|
|
12
|
+
|
|
13
|
+
1. Determine which files to check:
|
|
14
|
+
- If the user specified file paths, use those
|
|
15
|
+
- Otherwise, run `git diff --name-only` in the workspace to find changed TypeScript files
|
|
16
|
+
- If no git changes found, ask the user which files to check
|
|
17
|
+
2. Run `live_diagnostics` on each file
|
|
18
|
+
3. For each file:
|
|
19
|
+
- If clean: report "no errors"
|
|
20
|
+
- If errors found: run `explain_error` on each error location to get actionable context
|
|
21
|
+
4. Present a summary:
|
|
22
|
+
- **Clean files**: list them briefly
|
|
23
|
+
- **Files with errors**: show each error with the explanation and suggested fix
|
|
24
|
+
- **Total**: "X files checked, Y errors found"
|
|
25
|
+
5. If errors were found, offer to fix them
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: context
|
|
3
|
+
description: Gather token-budgeted context for a coding task — only the code you need, nothing you don't
|
|
4
|
+
argument-hint: <symbol-name or task description> [--tokens <number>]
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Gather Context
|
|
8
|
+
|
|
9
|
+
Build a minimal, complete context for the task the user described.
|
|
10
|
+
|
|
11
|
+
## Steps
|
|
12
|
+
|
|
13
|
+
1. Identify entry symbols:
|
|
14
|
+
- If the user provided a symbol name, use it directly
|
|
15
|
+
- If the user described a task (e.g. "add a new status type"), extract likely symbol names from the description and use `workspace_symbols` to resolve them
|
|
16
|
+
2. Run `gather_context` with the entry symbols. Set `max_tokens`:
|
|
17
|
+
- If the user passed `--tokens <number>`, use that value
|
|
18
|
+
- Otherwise, consider your remaining context window — the default is 100k but reduce it if the conversation is already long
|
|
19
|
+
3. Present the result to the user organized as:
|
|
20
|
+
- **Must modify**: files with full code bodies — these need changes
|
|
21
|
+
- **Verify only**: files shown as signatures — check these still work after changes
|
|
22
|
+
- **Skip**: files listed by name — update these later (usually tests)
|
|
23
|
+
4. Ask the user: "Does this look right? Should I include more files or adjust the scope?"
|
|
24
|
+
5. If the user wants more detail on a specific file, run `outline` on it
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: diff
|
|
3
|
+
description: Semantic diff — see what symbols changed and their blast radius before committing
|
|
4
|
+
argument-hint: [--base <branch>]
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Semantic Diff
|
|
8
|
+
|
|
9
|
+
Analyze the current branch's changes semantically — not just lines changed, but which symbols changed and what might break.
|
|
10
|
+
|
|
11
|
+
## Steps
|
|
12
|
+
|
|
13
|
+
1. Determine the base branch:
|
|
14
|
+
- If the user passed `--base <branch>`, use it
|
|
15
|
+
- Otherwise, try `git rev-parse --verify main` — if it exists, use `main`
|
|
16
|
+
- If not, try `master`
|
|
17
|
+
- If neither exists, ask the user for the base branch
|
|
18
|
+
Run `semantic_diff` with the resolved base
|
|
19
|
+
2. For each changed symbol with risk 🔴 (HIGH — >10 references):
|
|
20
|
+
- Run `find_test_files` to check if tests exist for it
|
|
21
|
+
- If no tests: flag as "untested change — high risk"
|
|
22
|
+
3. Present results:
|
|
23
|
+
- **High risk** (🔴): symbols with many references — review carefully
|
|
24
|
+
- **Medium risk** (🟡): symbols with some references — verify
|
|
25
|
+
- **Safe** (🟢): symbols with no external references — low risk
|
|
26
|
+
4. If any high-risk changes lack tests, suggest running `/impact` on those symbols
|
|
27
|
+
5. If everything looks clean, confirm: "Changes look safe to commit"
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: find
|
|
3
|
+
description: Search code by natural language — finds implementations, API usage, structural patterns, configs, and likely roots
|
|
4
|
+
argument-hint: <query>
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Code Search
|
|
8
|
+
|
|
9
|
+
Find code using natural language. Automatically routes to the right search backend.
|
|
10
|
+
|
|
11
|
+
## Steps
|
|
12
|
+
|
|
13
|
+
1. Parse the user's query:
|
|
14
|
+
- If the user provided a query argument, use it directly
|
|
15
|
+
- Otherwise, ask what they're looking for
|
|
16
|
+
|
|
17
|
+
2. Call `find_code` with the query:
|
|
18
|
+
- Let focus default to `auto`
|
|
19
|
+
- If the user mentioned a specific directory or package, pass it in `paths`
|
|
20
|
+
- If the user wants test files included, set `include_tests: true`
|
|
21
|
+
- If the user is debugging search quality, set `debug: true`
|
|
22
|
+
|
|
23
|
+
3. Interpret the results based on confidence:
|
|
24
|
+
|
|
25
|
+
**High confidence** (strong matches from multiple sources):
|
|
26
|
+
- Show the top 3 candidates with file path, symbol name, and why it matched
|
|
27
|
+
- For the #1 candidate, show the snippet and enclosing function/component
|
|
28
|
+
- If the result has graph evidence, mention what was promoted/demoted
|
|
29
|
+
- Automatically call `gather_context` on the #1 candidate's symbol to provide ready-to-use context
|
|
30
|
+
|
|
31
|
+
**Medium confidence** (reasonable matches, single source):
|
|
32
|
+
- Show top 3 candidates with evidence
|
|
33
|
+
- Suggest the user refine their query or try a more specific term
|
|
34
|
+
- Offer to run `find_pattern` if the query has a structural shape
|
|
35
|
+
- Note any warnings (scope capped, partial results)
|
|
36
|
+
|
|
37
|
+
**Low confidence** (weak or no matches):
|
|
38
|
+
- Explain what was searched and why it didn't match well
|
|
39
|
+
- Check the IR: suggest using the exact function name if only NL tokens were used
|
|
40
|
+
- Offer to try `find_pattern` with an AST pattern instead
|
|
41
|
+
- If scope was capped, mention it and suggest narrowing with `paths`
|
|
42
|
+
|
|
43
|
+
4. Offer follow-up actions:
|
|
44
|
+
- "Want me to read the top result?" → Read the file
|
|
45
|
+
- "Want more context?" → Call `gather_context` on the top candidate's symbol
|
|
46
|
+
- "What calls this?" → Call `call_hierarchy` on the symbol
|
|
47
|
+
- "What breaks if I change this?" → Call `impact_trace` on the symbol
|
|
48
|
+
- "Is the API safe?" → Call `api_guard` on the file
|
|
49
|
+
|
|
50
|
+
5. If `stats.partialResult` is true or `warnings` is non-empty, mention it clearly so the user knows the search was incomplete.
|
|
51
|
+
|
|
52
|
+
## Examples
|
|
53
|
+
|
|
54
|
+
| Query | What happens |
|
|
55
|
+
|-------|-------------|
|
|
56
|
+
| `/find useEffect` | Identifier search → all useEffect call sites |
|
|
57
|
+
| `/find useEffect that returns cleanup conditionally` | Structural → useEffect with conditional cleanup |
|
|
58
|
+
| `/find useEffect that sets state based on previous state` | React recipe → functional state updater pattern |
|
|
59
|
+
| `/find where do we validate permissions` | Behavior → permission validation entrypoints |
|
|
60
|
+
| `/find where is the feature flag configured` | Config → JSON/YAML/env entries |
|
|
61
|
+
| `/find where is this endpoint defined` | Route → route definitions + handler code |
|
|
62
|
+
| `/find switch without default` | Structural → switch statements missing default |
|
|
63
|
+
| `/find retry logic` in packages/core | Scoped behavior search |
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: impact
|
|
3
|
+
description: Trace the blast radius of changing a symbol — find every file, reference, and affected test
|
|
4
|
+
argument-hint: <symbol-name> [--depth <number>]
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Impact Analysis
|
|
8
|
+
|
|
9
|
+
Analyze the full impact of changing the symbol the user specified.
|
|
10
|
+
|
|
11
|
+
## Steps
|
|
12
|
+
|
|
13
|
+
1. Run `impact_trace` with the user's symbol name. If the user passed `--depth <number>`, use that as `max_depth`; otherwise default to 3. If it returns no results, run `workspace_symbols` with the same query to suggest similar names — the user may have a typo or the symbol may live in a non-TS file.
|
|
14
|
+
2. Run `find_test_files` with the same symbol to identify tests that need updating
|
|
15
|
+
3. Present a summary:
|
|
16
|
+
- **Severity**: LOW (< 5 refs), MEDIUM (5-20 refs), HIGH (> 20 refs)
|
|
17
|
+
- **Direct references**: files that import/call the symbol directly
|
|
18
|
+
- **Transitive references**: files affected through type aliases or re-exports
|
|
19
|
+
- **Affected tests**: test/spec/stories files that reference the symbol
|
|
20
|
+
4. If severity is HIGH, suggest running `gather_context` on the most affected files before proceeding
|
|
21
|
+
5. If the user wants to continue, offer to run `outline` on the files they'll need to modify
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: verify
|
|
3
|
+
description: Full pre-merge verification — diagnostics, API contract, test coverage, verdict
|
|
4
|
+
argument-hint: [--base <branch>]
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Verify Changes
|
|
8
|
+
|
|
9
|
+
Full pre-commit/pre-PR verification in one command. Orchestrates diagnostics, API contract analysis, and test coverage into a single structured verdict.
|
|
10
|
+
|
|
11
|
+
## Steps
|
|
12
|
+
|
|
13
|
+
1. Call `verify_changes` with the user's base branch (if specified):
|
|
14
|
+
- If `--base <branch>` provided, pass it
|
|
15
|
+
- Otherwise, let the tool auto-detect the merge base
|
|
16
|
+
|
|
17
|
+
2. Present the result in this order:
|
|
18
|
+
|
|
19
|
+
**Changed files** — list what was modified
|
|
20
|
+
|
|
21
|
+
**Type errors** — if `totalErrors > 0`:
|
|
22
|
+
- Show each file with its error count
|
|
23
|
+
- Show the first 3 errors per file with line and message
|
|
24
|
+
- Offer to run `/why` on the first error for root cause
|
|
25
|
+
|
|
26
|
+
**API changes** — if `api` is not null:
|
|
27
|
+
- Show semver verdict: MAJOR / MINOR / PATCH
|
|
28
|
+
- If breaking > 0: list breaking changes with details
|
|
29
|
+
- If risky > 0: list risky changes
|
|
30
|
+
- Offer to run `/api-check` for full details
|
|
31
|
+
|
|
32
|
+
**Test gaps** — if any `testGaps` have `hasTests: false`:
|
|
33
|
+
- List untested high-risk symbols with reference counts
|
|
34
|
+
- Offer to run `/impact <symbol>` for blast radius
|
|
35
|
+
|
|
36
|
+
**Verdict** — show the final verdict prominently:
|
|
37
|
+
- "safe to merge" — all clear
|
|
38
|
+
- "needs attention" — breaking API changes or untested high-risk symbols
|
|
39
|
+
- "has errors" — type errors must be fixed first
|
|
40
|
+
|
|
41
|
+
3. If there are warnings, show them at the bottom.
|
|
42
|
+
|
|
43
|
+
4. Offer follow-up actions based on verdict:
|
|
44
|
+
- **has errors**: "Want me to fix the errors?" or `/why <file:line>`
|
|
45
|
+
- **needs attention**: "Want me to check the breaking changes?" or `/api-check`
|
|
46
|
+
- **safe to merge**: "Ready to commit?" or `/diff` to review
|
|
47
|
+
|
|
48
|
+
## Examples
|
|
49
|
+
|
|
50
|
+
| Command | What happens |
|
|
51
|
+
|---------|-------------|
|
|
52
|
+
| `/verify` | Auto-detect base, check all changed files |
|
|
53
|
+
| `/verify --base main` | Compare against main branch |
|
|
54
|
+
| `/verify --base develop` | Compare against develop branch |
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: why
|
|
3
|
+
description: Trace the root cause of a TypeScript error — find what declaration change actually broke it
|
|
4
|
+
argument-hint: <file:line> or <file>
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Root Cause Trace
|
|
8
|
+
|
|
9
|
+
Trace the root cause of a TypeScript error. Don't just fix the symptom — find what changed upstream.
|
|
10
|
+
|
|
11
|
+
## Steps
|
|
12
|
+
|
|
13
|
+
1. Parse the user's input:
|
|
14
|
+
- If `file:line` format: use both
|
|
15
|
+
- If just a file: let the tool find the first error
|
|
16
|
+
- If no input: check files edited in the current conversation for errors
|
|
17
|
+
|
|
18
|
+
2. Run `root_cause_trace` with the file path and optional line
|
|
19
|
+
|
|
20
|
+
3. Present the result:
|
|
21
|
+
- **The error**: what diagnostic, where
|
|
22
|
+
- **The root cause**: which declaration changed and why it caused this
|
|
23
|
+
- **Evidence chain**: definition → change → impact
|
|
24
|
+
- **Suggested fix**: if the tool provides one
|
|
25
|
+
- **Other candidates**: if the top result has low confidence
|
|
26
|
+
|
|
27
|
+
4. If confidence is low, suggest:
|
|
28
|
+
- Running `/check` on related files to find more errors
|
|
29
|
+
- Running `/impact` on the suspected symbol to see full blast radius
|
|
30
|
+
|
|
31
|
+
5. If the user wants to fix it, use `gather_context` on the root cause file to get the relevant code
|