codebase-context 1.7.0 → 1.8.1
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/README.md +149 -90
- package/dist/analyzers/angular/index.d.ts.map +1 -1
- package/dist/analyzers/angular/index.js +85 -39
- package/dist/analyzers/angular/index.js.map +1 -1
- package/dist/analyzers/generic/index.d.ts.map +1 -1
- package/dist/analyzers/generic/index.js +5 -4
- package/dist/analyzers/generic/index.js.map +1 -1
- package/dist/cli-formatters.d.ts +47 -0
- package/dist/cli-formatters.d.ts.map +1 -0
- package/dist/cli-formatters.js +803 -0
- package/dist/cli-formatters.js.map +1 -0
- package/dist/cli-memory.d.ts +5 -0
- package/dist/cli-memory.d.ts.map +1 -0
- package/dist/cli-memory.js +218 -0
- package/dist/cli-memory.js.map +1 -0
- package/dist/cli.d.ts +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +168 -178
- package/dist/cli.js.map +1 -1
- package/dist/core/auto-refresh.d.ts +16 -0
- package/dist/core/auto-refresh.d.ts.map +1 -0
- package/dist/core/auto-refresh.js +25 -0
- package/dist/core/auto-refresh.js.map +1 -0
- package/dist/core/file-watcher.d.ts +15 -0
- package/dist/core/file-watcher.d.ts.map +1 -0
- package/dist/core/file-watcher.js +59 -0
- package/dist/core/file-watcher.js.map +1 -0
- package/dist/core/index-meta.d.ts +3 -0
- package/dist/core/index-meta.d.ts.map +1 -1
- package/dist/core/index-meta.js +9 -1
- package/dist/core/index-meta.js.map +1 -1
- package/dist/core/indexer.d.ts.map +1 -1
- package/dist/core/indexer.js +74 -15
- package/dist/core/indexer.js.map +1 -1
- package/dist/core/reranker.d.ts.map +1 -1
- package/dist/core/reranker.js +3 -0
- package/dist/core/reranker.js.map +1 -1
- package/dist/core/search-quality.js +2 -2
- package/dist/core/search-quality.js.map +1 -1
- package/dist/core/search.d.ts.map +1 -1
- package/dist/core/search.js +20 -7
- package/dist/core/search.js.map +1 -1
- package/dist/core/symbol-references.d.ts +2 -3
- package/dist/core/symbol-references.d.ts.map +1 -1
- package/dist/core/symbol-references.js +111 -16
- package/dist/core/symbol-references.js.map +1 -1
- package/dist/embeddings/index.d.ts +8 -0
- package/dist/embeddings/index.d.ts.map +1 -1
- package/dist/embeddings/index.js +17 -2
- package/dist/embeddings/index.js.map +1 -1
- package/dist/embeddings/openai.d.ts +1 -1
- package/dist/embeddings/openai.d.ts.map +1 -1
- package/dist/embeddings/openai.js +3 -1
- package/dist/embeddings/openai.js.map +1 -1
- package/dist/embeddings/transformers.d.ts +6 -0
- package/dist/embeddings/transformers.d.ts.map +1 -1
- package/dist/embeddings/transformers.js +12 -5
- package/dist/embeddings/transformers.js.map +1 -1
- package/dist/embeddings/types.d.ts +1 -0
- package/dist/embeddings/types.d.ts.map +1 -1
- package/dist/embeddings/types.js +7 -1
- package/dist/embeddings/types.js.map +1 -1
- package/dist/grammars/manifest.d.ts.map +1 -1
- package/dist/grammars/manifest.js +2 -1
- package/dist/grammars/manifest.js.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +46 -3
- package/dist/index.js.map +1 -1
- package/dist/patterns/semantics.d.ts +2 -1
- package/dist/patterns/semantics.d.ts.map +1 -1
- package/dist/patterns/semantics.js +0 -2
- package/dist/patterns/semantics.js.map +1 -1
- package/dist/storage/index.d.ts +4 -1
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/index.js +2 -2
- package/dist/storage/index.js.map +1 -1
- package/dist/storage/lancedb.d.ts +2 -0
- package/dist/storage/lancedb.d.ts.map +1 -1
- package/dist/storage/lancedb.js +20 -4
- package/dist/storage/lancedb.js.map +1 -1
- package/dist/storage/types.d.ts +4 -1
- package/dist/storage/types.d.ts.map +1 -1
- package/dist/storage/types.js.map +1 -1
- package/dist/tools/detect-circular-dependencies.d.ts.map +1 -1
- package/dist/tools/detect-circular-dependencies.js.map +1 -1
- package/dist/tools/get-team-patterns.d.ts.map +1 -1
- package/dist/tools/get-team-patterns.js +37 -14
- package/dist/tools/get-team-patterns.js.map +1 -1
- package/dist/tools/search-codebase.d.ts.map +1 -1
- package/dist/tools/search-codebase.js +296 -189
- package/dist/tools/search-codebase.js.map +1 -1
- package/dist/tools/types.d.ts +193 -1
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/types/index.d.ts +73 -11
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +0 -1
- package/dist/types/index.js.map +1 -1
- package/dist/utils/language-detection.d.ts.map +1 -1
- package/dist/utils/language-detection.js +6 -1
- package/dist/utils/language-detection.js.map +1 -1
- package/dist/utils/tree-sitter.d.ts +11 -0
- package/dist/utils/tree-sitter.d.ts.map +1 -1
- package/dist/utils/tree-sitter.js +111 -0
- package/dist/utils/tree-sitter.js.map +1 -1
- package/dist/utils/usage-tracker.d.ts +30 -40
- package/dist/utils/usage-tracker.d.ts.map +1 -1
- package/dist/utils/usage-tracker.js +66 -8
- package/dist/utils/usage-tracker.js.map +1 -1
- package/docs/capabilities.md +22 -8
- package/docs/cli.md +196 -0
- package/grammars/tree-sitter-kotlin.wasm +0 -0
- package/package.json +9 -6
- package/dist/tools/get-component-usage.d.ts +0 -5
- package/dist/tools/get-component-usage.d.ts.map +0 -1
- package/dist/tools/get-component-usage.js +0 -83
- package/dist/tools/get-component-usage.js.map +0 -1
package/docs/capabilities.md
CHANGED
|
@@ -4,14 +4,15 @@ Technical reference for what `codebase-context` ships today. For the user-facing
|
|
|
4
4
|
|
|
5
5
|
## CLI Reference
|
|
6
6
|
|
|
7
|
-
All
|
|
7
|
+
All shipped capabilities are available locally via the CLI (human-readable by default, `--json` for automation).
|
|
8
|
+
For a “gallery” of commands and examples, see `docs/cli.md`.
|
|
8
9
|
|
|
9
10
|
| Command | Flags | Maps to |
|
|
10
11
|
|---|---|---|
|
|
11
12
|
| `search --query <q>` | `--intent explore\|edit\|refactor\|migrate`, `--limit <n>`, `--lang <l>`, `--framework <f>`, `--layer <l>` | `search_codebase` |
|
|
12
13
|
| `metadata` | — | `get_codebase_metadata` |
|
|
13
14
|
| `status` | — | `get_indexing_status` |
|
|
14
|
-
| `reindex` | `--incremental`, `--reason <r>` | `refresh_index` |
|
|
15
|
+
| `reindex` | `--incremental`, `--reason <r>` | equivalent to `refresh_index` |
|
|
15
16
|
| `style-guide` | `--query <q>`, `--category <c>` | `get_style_guide` |
|
|
16
17
|
| `patterns` | `--category all\|di\|state\|testing\|libraries` | `get_team_patterns` |
|
|
17
18
|
| `refs --symbol <name>` | `--limit <n>` | `get_symbol_references` |
|
|
@@ -41,7 +42,7 @@ npx codebase-context reindex --incremental
|
|
|
41
42
|
| ----------------------- | ----------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
42
43
|
| `search_codebase` | `query`, optional `intent`, `limit`, `filters`, `includeSnippets` | Ranked results (`file`, `summary`, `score`, `type`, `trend`, `patternWarning`, `relationships`, `hints`) + `searchQuality` + decision card (`ready`, `nextAction`, `patterns`, `bestExample`, `impact`, `whatWouldHelp`) when `intent="edit"`. Hints capped at 3 per category. |
|
|
43
44
|
| `get_team_patterns` | optional `category` | Pattern frequencies, trends, golden files, conflicts |
|
|
44
|
-
| `get_symbol_references` | `symbol`, optional `limit` | Concrete symbol usage evidence: `usageCount` + top usage snippets + `confidence` + `isComplete`. `confidence: "syntactic"` means static/source-based only (no runtime or dynamic dispatch). Replaces the removed `get_component_usage`. |
|
|
45
|
+
| `get_symbol_references` | `symbol`, optional `limit` | Concrete symbol usage evidence: `usageCount` + top usage snippets + `confidence` + `isComplete`. `confidence: "syntactic"` means static/source-based only (no runtime or dynamic dispatch). When Tree-sitter + file content are available, comments and string literals are excluded from the scan — the count reflects real identifier nodes only. Replaces the removed `get_component_usage`. |
|
|
45
46
|
| `remember` | `type`, `category`, `memory`, `reason` | Persists to `.codebase-context/memory.json` |
|
|
46
47
|
| `get_memory` | optional `category`, `type`, `query`, `limit` | Memories with confidence decay scoring |
|
|
47
48
|
|
|
@@ -75,7 +76,7 @@ Ordered by execution:
|
|
|
75
76
|
|
|
76
77
|
- **Chunk size**: 50 lines, 0 overlap
|
|
77
78
|
- **Reranker trigger**: activates when top-3 results are within 0.08 score of each other
|
|
78
|
-
- **Embedding model**:
|
|
79
|
+
- **Embedding model**: `Xenova/bge-small-en-v1.5` (512 token context, fast, local-first) via `@huggingface/transformers`. Override: `EMBEDDING_MODEL=onnx-community/granite-embedding-small-english-r2-ONNX` for Granite (8192 ctx, slower).
|
|
79
80
|
- **Vector DB**: LanceDB with cosine distance
|
|
80
81
|
|
|
81
82
|
## Decision Card (Edit Intent)
|
|
@@ -95,13 +96,16 @@ Returned as `preflight` when search `intent` is `edit`, `refactor`, or `migrate`
|
|
|
95
96
|
};
|
|
96
97
|
bestExample?: string; // Top 1 golden file (path format)
|
|
97
98
|
impact?: {
|
|
98
|
-
coverage
|
|
99
|
-
files
|
|
99
|
+
coverage?: string; // "X/Y callers in results"
|
|
100
|
+
files?: string[]; // Back-compat: top impact candidates (paths only)
|
|
101
|
+
details?: Array<{ file: string; line?: number; hop: 1 | 2 }>; // When available
|
|
100
102
|
};
|
|
101
103
|
whatWouldHelp?: string[]; // Concrete next steps (max 4) when ready=false
|
|
102
104
|
}
|
|
103
105
|
```
|
|
104
106
|
|
|
107
|
+
Impact is 2-hop transitive: direct importers (hop 1) and their importers (hop 2), each labeled with distance. Capped at 20 files to avoid noise.
|
|
108
|
+
|
|
105
109
|
**Fields explained:**
|
|
106
110
|
|
|
107
111
|
- `ready`: boolean, whether evidence is sufficient to proceed
|
|
@@ -111,7 +115,8 @@ Returned as `preflight` when search `intent` is `edit`, `refactor`, or `migrate`
|
|
|
111
115
|
- `patterns.avoid`: declining patterns, ranked by % (useful for migrations)
|
|
112
116
|
- `bestExample`: exemplar file for the area under edit
|
|
113
117
|
- `impact.coverage`: shows caller visibility ("3/5 callers in results" means 2 callers weren't searched yet)
|
|
114
|
-
- `impact.
|
|
118
|
+
- `impact.details`: richer impact candidates with optional `line` and hop distance (1 = direct, 2 = transitive)
|
|
119
|
+
- `impact.files`: back-compat list of impact candidate paths (when details aren’t available)
|
|
115
120
|
- `whatWouldHelp`: specific next searches, tool calls, or files to check that would close evidence gaps
|
|
116
121
|
|
|
117
122
|
### How `ready` is determined
|
|
@@ -141,10 +146,11 @@ Returned as `preflight` when search `intent` is `edit`, `refactor`, or `migrate`
|
|
|
141
146
|
|
|
142
147
|
- Initial: full scan → chunking (50 lines, 0 overlap) → embedding → vector DB (LanceDB) + keyword index (Fuse.js)
|
|
143
148
|
- Incremental: SHA-256 manifest diffing, selective embed/delete, full intelligence regeneration
|
|
149
|
+
- Auto-refresh (MCP server mode only): chokidar file watcher triggers incremental reindex after a debounce on any source file change — `node_modules/`, `.git/`, `dist/`, and `.codebase-context/` are excluded. One-shot CLI runs skip the watcher entirely.
|
|
144
150
|
- Version gating: `index-meta.json` tracks format version; mismatches trigger automatic rebuild
|
|
145
151
|
- Crash-safe rebuilds: full rebuilds write to `.staging/` and swap atomically only on success
|
|
146
152
|
- Auto-heal: corrupted index triggers automatic full re-index on next search
|
|
147
|
-
- Relationships sidecar: `relationships.json` contains file import graph and symbol
|
|
153
|
+
- Relationships sidecar: `relationships.json` contains file import graph, symbol export index, and per-edge import details (`importDetails`: line number + imported symbol names where available)
|
|
148
154
|
- Storage: `.codebase-context/` directory (memory.json + generated files)
|
|
149
155
|
|
|
150
156
|
## Analyzers
|
|
@@ -167,3 +173,11 @@ Reproducible evaluation is shipped as a CLI entrypoint backed by shared scoring/
|
|
|
167
173
|
- `tests/fixtures/eval-angular-spotify.json` (real-world)
|
|
168
174
|
- `tests/fixtures/eval-controlled.json` + `tests/fixtures/codebases/eval-controlled/` (offline controlled)
|
|
169
175
|
- **Reported metrics:** Top-1 accuracy, Top-3 recall, spec contamination rate, and a gate pass/fail
|
|
176
|
+
|
|
177
|
+
## Limitations
|
|
178
|
+
|
|
179
|
+
- **Symbol refs are not a call-graph.** `get_symbol_references` counts identifier-node occurrences in the AST (comments/strings excluded via Tree-sitter). It does not distinguish call sites from type annotations, variable assignments, or imports. Full call-site-specific analysis (`call_expression` nodes only) is a roadmap item.
|
|
180
|
+
- **Impact is 2-hop max.** `computeImpactCandidates` walks direct importers then their importers. Full BFS reachability is on the roadmap.
|
|
181
|
+
- **Angular is the only framework with a rich dedicated analyzer.** All other languages go through the Generic analyzer (30+ languages, chunking + import graph, no framework-specific signal extraction).
|
|
182
|
+
- **Default embedding model is `bge-small-en-v1.5` (512-token context).** Granite (8192 context) is opt-in via `EMBEDDING_MODEL`. OpenAI is opt-in via `EMBEDDING_PROVIDER=openai` — sends code externally.
|
|
183
|
+
- **Patterns are file-level frequency counts.** Not semantic clustering. Rising/Declining trend is derived from git commit recency for files using each pattern, not from usage semantics.
|
package/docs/cli.md
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
# CLI Gallery (Human-readable)
|
|
2
|
+
|
|
3
|
+
`codebase-context` exposes its MCP tools as a local CLI so humans can:
|
|
4
|
+
|
|
5
|
+
- Onboard themselves onto an unfamiliar repo
|
|
6
|
+
- Debug what the MCP server is doing
|
|
7
|
+
- Use outputs in CI/scripts (via `--json`)
|
|
8
|
+
|
|
9
|
+
> Output depends on the repo you run it against. The examples below are illustrative (paths, counts, and detected frameworks will vary).
|
|
10
|
+
|
|
11
|
+
## How to run
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
# Run from a repo root, or set CODEBASE_ROOT explicitly:
|
|
15
|
+
CODEBASE_ROOT=/path/to/repo npx -y codebase-context status
|
|
16
|
+
|
|
17
|
+
# Every command supports --json (machine output). Human mode is default.
|
|
18
|
+
npx -y codebase-context patterns --json
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### ASCII fallback
|
|
22
|
+
|
|
23
|
+
If your terminal doesn’t render Unicode box-drawing cleanly:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
CODEBASE_CONTEXT_ASCII=1 npx -y codebase-context patterns
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Commands
|
|
30
|
+
|
|
31
|
+
- `metadata` — tech stack overview
|
|
32
|
+
- `patterns` — team conventions + adoption/trends
|
|
33
|
+
- `search --query <q>` — ranked results; add `--intent edit` for a preflight card
|
|
34
|
+
- `refs --symbol <name>` — concrete reference evidence
|
|
35
|
+
- `cycles` — circular dependency detection
|
|
36
|
+
- `status` — index status/progress
|
|
37
|
+
- `reindex` — rebuild index (full or incremental)
|
|
38
|
+
- `style-guide` — find style guide sections in docs
|
|
39
|
+
- `memory list|add|remove` — manage team memory (stored in `.codebase-context/memory.json`)
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## `metadata`
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
npx -y codebase-context metadata
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Example output:
|
|
50
|
+
|
|
51
|
+
```text
|
|
52
|
+
┌─ codebase-context [monorepo] ────────────────────────────────────────┐
|
|
53
|
+
│ │
|
|
54
|
+
│ Framework: Angular unknown Architecture: mixed │
|
|
55
|
+
│ 130 files · 24,211 lines · 1077 components │
|
|
56
|
+
│ │
|
|
57
|
+
│ Dependencies: @huggingface/transformers · @lancedb/lancedb · │
|
|
58
|
+
│ @modelcontextprotocol/sdk · @typescript-eslint/typescript-estree · │
|
|
59
|
+
│ chokidar · fuse.js (+14 more) │
|
|
60
|
+
│ │
|
|
61
|
+
└──────────────────────────────────────────────────────────────────────┘
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## `patterns`
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
npx -y codebase-context patterns
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Example output (truncated):
|
|
71
|
+
|
|
72
|
+
```text
|
|
73
|
+
┌─ Team Patterns ──────────────────────────────────────────────────────┐
|
|
74
|
+
│ │
|
|
75
|
+
│ UNIT TEST FRAMEWORK │
|
|
76
|
+
│ USE: Vitest – 96% adoption │
|
|
77
|
+
│ alt CAUTION: Jest – 4% minority pattern │
|
|
78
|
+
│ │
|
|
79
|
+
│ STATE MANAGEMENT │
|
|
80
|
+
│ PREFER: RxJS – 63% adoption │
|
|
81
|
+
│ alt Redux-style store – 25% │
|
|
82
|
+
│ │
|
|
83
|
+
└──────────────────────────────────────────────────────────────────────┘
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## `search`
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
npx -y codebase-context search --query "file watcher" --intent edit --limit 3
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Example output (truncated):
|
|
93
|
+
|
|
94
|
+
```text
|
|
95
|
+
┌─ Search: "file watcher" ─── intent: edit ────────────────────────────┐
|
|
96
|
+
│ Quality: ok (1.00) │
|
|
97
|
+
│ Ready to edit: YES │
|
|
98
|
+
│ │
|
|
99
|
+
│ Best example: index.ts │
|
|
100
|
+
└──────────────────────────────────────────────────────────────────────┘
|
|
101
|
+
|
|
102
|
+
1. src/core/file-watcher.ts:44-74
|
|
103
|
+
confidence: ██████████ 1.18
|
|
104
|
+
typescript module in file-watcher.ts: startFileWatcher :: (...)
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## `refs`
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
npx -y codebase-context refs --symbol "startFileWatcher" --limit 10
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Example output (truncated):
|
|
114
|
+
|
|
115
|
+
```text
|
|
116
|
+
┌─ startFileWatcher ─── 11 references ─── static analysis ─────────────┐
|
|
117
|
+
│ │
|
|
118
|
+
│ startFileWatcher │
|
|
119
|
+
│ │ │
|
|
120
|
+
│ ├─ file-watcher.test.ts:5 │
|
|
121
|
+
│ │ import { startFileWatcher } from '../src/core/file-watcher.... │
|
|
122
|
+
│ │
|
|
123
|
+
└──────────────────────────────────────────────────────────────────────┘
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## `cycles`
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
npx -y codebase-context cycles --scope src
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Example output:
|
|
133
|
+
|
|
134
|
+
```text
|
|
135
|
+
┌─ Circular Dependencies ──────────────────────────────────────────────┐
|
|
136
|
+
│ │
|
|
137
|
+
│ No cycles found · 98 files · 260 edges · 2.7 avg deps │
|
|
138
|
+
│ │
|
|
139
|
+
└──────────────────────────────────────────────────────────────────────┘
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## `status`
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
npx -y codebase-context status
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
Example output:
|
|
149
|
+
|
|
150
|
+
```text
|
|
151
|
+
┌─ Index Status ───────────────────────────────────────────────────────┐
|
|
152
|
+
│ │
|
|
153
|
+
│ State: ready │
|
|
154
|
+
│ Root: /path/to/repo │
|
|
155
|
+
│ │
|
|
156
|
+
│ → Run `reindex` to re-index (`--incremental` skips unchanged). │
|
|
157
|
+
│ │
|
|
158
|
+
└──────────────────────────────────────────────────────────────────────┘
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## `reindex`
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
npx -y codebase-context reindex
|
|
165
|
+
npx -y codebase-context reindex --incremental --reason "changed watcher logic"
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
> **MCP server mode**: if you're running codebase-context as an MCP server (long-running process), the index auto-refreshes via a file watcher — you don't need to call `reindex` between edits. Use `reindex` for one-shot CLI runs or to force a full rebuild.
|
|
169
|
+
|
|
170
|
+
## `style-guide`
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
npx -y codebase-context style-guide --query "naming"
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
Example output:
|
|
177
|
+
|
|
178
|
+
```text
|
|
179
|
+
No style guides found.
|
|
180
|
+
Hint: Try broader terms like 'naming', 'patterns', 'testing', 'components'
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## `memory`
|
|
184
|
+
|
|
185
|
+
```bash
|
|
186
|
+
npx -y codebase-context memory list
|
|
187
|
+
npx -y codebase-context memory list --query "watcher"
|
|
188
|
+
|
|
189
|
+
npx -y codebase-context memory add \
|
|
190
|
+
--type gotcha \
|
|
191
|
+
--category tooling \
|
|
192
|
+
--memory "Use pnpm, not npm" \
|
|
193
|
+
--reason "Workspace support and speed"
|
|
194
|
+
|
|
195
|
+
npx -y codebase-context memory remove <id>
|
|
196
|
+
```
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codebase-context",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "Second brain for AI agents working on your codebase - team coding patterns detection, persistent memory,
|
|
3
|
+
"version": "1.8.1",
|
|
4
|
+
"description": "Second brain for AI agents working on your codebase - team coding patterns detection, persistent memory, edit readiness checks, and hybrid search with evidence scoring. Local-first MCP server",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/lib.js",
|
|
7
7
|
"types": "./dist/lib.d.ts",
|
|
@@ -39,7 +39,8 @@
|
|
|
39
39
|
"grammars",
|
|
40
40
|
"README.md",
|
|
41
41
|
"LICENSE",
|
|
42
|
-
"docs"
|
|
42
|
+
"docs/cli.md",
|
|
43
|
+
"docs/capabilities.md"
|
|
43
44
|
],
|
|
44
45
|
"engines": {
|
|
45
46
|
"node": ">=18.0.0"
|
|
@@ -103,11 +104,12 @@
|
|
|
103
104
|
"dependencies": {
|
|
104
105
|
"@huggingface/transformers": "^3.8.1",
|
|
105
106
|
"@lancedb/lancedb": "^0.4.0",
|
|
106
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
107
|
+
"@modelcontextprotocol/sdk": "^1.27.1",
|
|
107
108
|
"@typescript-eslint/typescript-estree": "^7.0.0",
|
|
109
|
+
"chokidar": "^3.6.0",
|
|
108
110
|
"fuse.js": "^7.0.0",
|
|
109
111
|
"glob": "^10.3.10",
|
|
110
|
-
"hono": "^4.
|
|
112
|
+
"hono": "^4.12.5",
|
|
111
113
|
"ignore": "^5.3.1",
|
|
112
114
|
"typescript": "^5.3.3",
|
|
113
115
|
"uuid": "^9.0.1",
|
|
@@ -125,11 +127,12 @@
|
|
|
125
127
|
"eslint-config-prettier": "^10.1.8",
|
|
126
128
|
"eslint-plugin-import": "^2.32.0",
|
|
127
129
|
"globals": "^17.0.0",
|
|
130
|
+
"husky": "^9.1.7",
|
|
128
131
|
"prettier": "^3.7.4",
|
|
129
132
|
"tree-sitter-wasms": "^0.1.13",
|
|
130
133
|
"tsx": "^4.21.0",
|
|
131
134
|
"typescript-eslint": "^8.51.0",
|
|
132
|
-
"vitest": "^4.0.
|
|
135
|
+
"vitest": "^4.0.18"
|
|
133
136
|
},
|
|
134
137
|
"scripts": {
|
|
135
138
|
"preinstall": "npx only-allow pnpm",
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
-
import type { ToolContext, ToolResponse } from './types.js';
|
|
3
|
-
export declare const definition: Tool;
|
|
4
|
-
export declare function handle(args: Record<string, unknown>, ctx: ToolContext): Promise<ToolResponse>;
|
|
5
|
-
//# sourceMappingURL=get-component-usage.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-component-usage.d.ts","sourceRoot":"","sources":["../../src/tools/get-component-usage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAE/D,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE5D,eAAO,MAAM,UAAU,EAAE,IAiBxB,CAAC;AAEF,wBAAsB,MAAM,CAC1B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,GAAG,EAAE,WAAW,GACf,OAAO,CAAC,YAAY,CAAC,CAiFvB"}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { promises as fs } from 'fs';
|
|
2
|
-
export const definition = {
|
|
3
|
-
name: 'get_component_usage',
|
|
4
|
-
description: 'Find WHERE a library or component is used in the codebase. ' +
|
|
5
|
-
"This is 'Find Usages' - returns all files that import a given package/module. " +
|
|
6
|
-
"Example: get_component_usage('@mycompany/utils') -> shows all files using it.",
|
|
7
|
-
inputSchema: {
|
|
8
|
-
type: 'object',
|
|
9
|
-
properties: {
|
|
10
|
-
name: {
|
|
11
|
-
type: 'string',
|
|
12
|
-
description: "Import source to find usages for (e.g., 'primeng/table', '@mycompany/ui/button', 'lodash')"
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
|
-
required: ['name']
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
export async function handle(args, ctx) {
|
|
19
|
-
const { name: componentName } = args;
|
|
20
|
-
try {
|
|
21
|
-
const intelligencePath = ctx.paths.intelligence;
|
|
22
|
-
const content = await fs.readFile(intelligencePath, 'utf-8');
|
|
23
|
-
const intelligence = JSON.parse(content);
|
|
24
|
-
const importGraph = intelligence.importGraph || {};
|
|
25
|
-
const usages = importGraph.usages || {};
|
|
26
|
-
// Find matching usages (exact match or partial match)
|
|
27
|
-
let matchedUsage = usages[componentName];
|
|
28
|
-
// Try partial match if exact match not found
|
|
29
|
-
if (!matchedUsage) {
|
|
30
|
-
const matchingKeys = Object.keys(usages).filter((key) => key.includes(componentName) || componentName.includes(key));
|
|
31
|
-
if (matchingKeys.length > 0) {
|
|
32
|
-
matchedUsage = usages[matchingKeys[0]];
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
if (matchedUsage) {
|
|
36
|
-
return {
|
|
37
|
-
content: [
|
|
38
|
-
{
|
|
39
|
-
type: 'text',
|
|
40
|
-
text: JSON.stringify({
|
|
41
|
-
status: 'success',
|
|
42
|
-
component: componentName,
|
|
43
|
-
usageCount: matchedUsage.usageCount,
|
|
44
|
-
usedIn: matchedUsage.usedIn
|
|
45
|
-
}, null, 2)
|
|
46
|
-
}
|
|
47
|
-
]
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
// Show top used as alternatives
|
|
52
|
-
const topUsed = importGraph.topUsed || [];
|
|
53
|
-
return {
|
|
54
|
-
content: [
|
|
55
|
-
{
|
|
56
|
-
type: 'text',
|
|
57
|
-
text: JSON.stringify({
|
|
58
|
-
status: 'not_found',
|
|
59
|
-
component: componentName,
|
|
60
|
-
message: `No usages found for '${componentName}'.`,
|
|
61
|
-
suggestions: topUsed.slice(0, 10)
|
|
62
|
-
}, null, 2)
|
|
63
|
-
}
|
|
64
|
-
]
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
catch (error) {
|
|
69
|
-
return {
|
|
70
|
-
content: [
|
|
71
|
-
{
|
|
72
|
-
type: 'text',
|
|
73
|
-
text: JSON.stringify({
|
|
74
|
-
status: 'error',
|
|
75
|
-
message: 'Failed to get component usage. Run indexing first.',
|
|
76
|
-
error: error instanceof Error ? error.message : String(error)
|
|
77
|
-
}, null, 2)
|
|
78
|
-
}
|
|
79
|
-
]
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
//# sourceMappingURL=get-component-usage.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-component-usage.js","sourceRoot":"","sources":["../../src/tools/get-component-usage.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,IAAI,CAAC;AAGpC,MAAM,CAAC,MAAM,UAAU,GAAS;IAC9B,IAAI,EAAE,qBAAqB;IAC3B,WAAW,EACT,6DAA6D;QAC7D,gFAAgF;QAChF,+EAA+E;IACjF,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,IAAI,EAAE;gBACJ,IAAI,EAAE,QAAQ;gBACd,WAAW,EACT,4FAA4F;aAC/F;SACF;QACD,QAAQ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