@nithin554/code-crawler 0.0.0 → 0.1.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/LICENSE +21 -0
- package/README.md +226 -45
- package/dist/config.d.ts +13 -0
- package/dist/config.js +32 -0
- package/dist/config.js.map +1 -0
- package/dist/crawler.d.ts +46 -0
- package/dist/crawler.js +303 -0
- package/dist/crawler.js.map +1 -0
- package/dist/graph/queries.d.ts +111 -0
- package/dist/graph/queries.js +265 -0
- package/dist/graph/queries.js.map +1 -0
- package/dist/graph/schema.d.ts +63 -0
- package/dist/graph/schema.js +54 -0
- package/dist/graph/schema.js.map +1 -0
- package/dist/graph/store.d.ts +66 -0
- package/dist/graph/store.js +251 -0
- package/dist/graph/store.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +133 -0
- package/dist/index.js.map +1 -0
- package/dist/parser/language.d.ts +111 -0
- package/dist/parser/language.js +13 -0
- package/dist/parser/language.js.map +1 -0
- package/dist/parser/languages/index.d.ts +5 -0
- package/dist/parser/languages/index.js +31 -0
- package/dist/parser/languages/index.js.map +1 -0
- package/dist/parser/languages/java.d.ts +10 -0
- package/dist/parser/languages/java.js +334 -0
- package/dist/parser/languages/java.js.map +1 -0
- package/dist/parser/treeSitter.d.ts +28 -0
- package/dist/parser/treeSitter.js +114 -0
- package/dist/parser/treeSitter.js.map +1 -0
- package/dist/resolver/javaResolver.d.ts +20 -0
- package/dist/resolver/javaResolver.js +253 -0
- package/dist/resolver/javaResolver.js.map +1 -0
- package/dist/resolver/types.d.ts +45 -0
- package/dist/resolver/types.js +80 -0
- package/dist/resolver/types.js.map +1 -0
- package/dist/server.d.ts +15 -0
- package/dist/server.js +282 -0
- package/dist/server.js.map +1 -0
- package/package.json +44 -7
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Nithin
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,45 +1,226 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
-
|
|
33
|
-
-
|
|
34
|
-
|
|
35
|
-
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
1
|
+
# Code-Crawler
|
|
2
|
+
|
|
3
|
+
**Static call tracing MCP server backed by a persistent property graph of your codebase.**
|
|
4
|
+
|
|
5
|
+
Code-Crawler indexes a project into a SQLite-backed property graph — files, packages,
|
|
6
|
+
classes, methods, fields, imports, and **call edges** — then exposes that graph to LLM
|
|
7
|
+
clients as MCP tools: find callers, trace call paths, explore neighborhoods, and search
|
|
8
|
+
symbols across the whole codebase.
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
┌─────────────────────── MCP (stdio) ───────────────────────┐
|
|
12
|
+
│ crawl_project search_symbols get_callers get_callees │
|
|
13
|
+
│ trace_path get_subgraph get_node get_schema ... │
|
|
14
|
+
└───────────────┬──────────────────────────────┬───────────────┘
|
|
15
|
+
│ │
|
|
16
|
+
┌──────▼───────┐ ┌────────▼────────┐
|
|
17
|
+
│ crawler │ │ graph queries │
|
|
18
|
+
│ parse+resolve│ │ recursive CTEs │
|
|
19
|
+
└──────┬───────┘ └────────┬────────┘
|
|
20
|
+
│ │
|
|
21
|
+
┌──────▼──────────────────────────────▼──────┐
|
|
22
|
+
│ SQLite property graph (WAL) │
|
|
23
|
+
│ nodes (kind, fqn, props) + edges (kind) │
|
|
24
|
+
└─────────────────────────────────────────────┘
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Why a graph?
|
|
28
|
+
|
|
29
|
+
Plain-text grep can't answer questions like:
|
|
30
|
+
|
|
31
|
+
- *"Who transitively calls `OrderRepository#create`?"*
|
|
32
|
+
- *"Is there a static path from `Main#main` to `Tracking#dispatch`?"*
|
|
33
|
+
- *"What is the impact radius of changing `OrderService#place`?"*
|
|
34
|
+
|
|
35
|
+
These need graph traversal. Code-Crawler builds the graph once (idempotently, file-by-file)
|
|
36
|
+
and answers them instantly with bounded recursive SQL queries.
|
|
37
|
+
|
|
38
|
+
## Features
|
|
39
|
+
|
|
40
|
+
- **Java-first** via the `tree-sitter-java` grammar (WASM — no native build step).
|
|
41
|
+
The parser/resolver layer is designed so more languages plug in per-language config modules.
|
|
42
|
+
- **Call resolution heuristics** that go beyond naive string matching:
|
|
43
|
+
receiver types inferred from locals, parameters, fields, `new T()` expressions,
|
|
44
|
+
bare/`this`/`super` calls, static/qualified calls, and superclass chains.
|
|
45
|
+
Unresolvable calls become `unknown_symbol` phantom nodes with `resolved:false` edges,
|
|
46
|
+
so the graph stays traversable.
|
|
47
|
+
- **Idempotent, file-scoped indexing** — re-crawling refreshes changed files and removes
|
|
48
|
+
stale ones without duplicating the graph.
|
|
49
|
+
- **Self-contained**: single SQLite file, no external services.
|
|
50
|
+
- **LLM-friendly**: every tool returns structured JSON, unknown symbols come back with
|
|
51
|
+
fuzzy search suggestions.
|
|
52
|
+
|
|
53
|
+
## Install & build
|
|
54
|
+
|
|
55
|
+
Requires Node.js ≥ 20.
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
npm install
|
|
59
|
+
npm run build # tsc → dist/
|
|
60
|
+
npm test # vitest (53 tests)
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## CLI
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
codecrawler crawl <path> # index a project
|
|
67
|
+
codecrawler status # index summary
|
|
68
|
+
codecrawler query <symbol> # fuzzy-lookup a symbol
|
|
69
|
+
codecrawler serve # start the MCP server over stdio (default)
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Environment variables:
|
|
73
|
+
|
|
74
|
+
| Variable | Default | Purpose |
|
|
75
|
+
| --- | --- | --- |
|
|
76
|
+
| `CODECRAWLER_DB` | `~/.code-crawler/index.db` | Database path |
|
|
77
|
+
| `CODECRAWLER_EXCLUDE_DIRS` | `.git,node_modules,dist,build,target,...` | Dirs skipped during crawl |
|
|
78
|
+
| `CODECRAWLER_DEFAULT_LIMIT` | `50` | Default result cap |
|
|
79
|
+
| `CODECRAWLER_MAX_DEPTH` | `10` | Traversal depth cap |
|
|
80
|
+
|
|
81
|
+
## CI & publishing
|
|
82
|
+
|
|
83
|
+
GitHub Actions runs on every pull request (`pull-request.yml`): `npm ci` →
|
|
84
|
+
typecheck → tests → build → smoke-test of the built CLI.
|
|
85
|
+
|
|
86
|
+
Merges to `main` trigger `publish.yml`, which re-runs the same checks and then,
|
|
87
|
+
if green, **auto-releases**:
|
|
88
|
+
|
|
89
|
+
1. Reads the most recent `v*` tag (or `package.json` version on the first run),
|
|
90
|
+
computes the next patch version, and pushes a `vX.Y.Z` tag.
|
|
91
|
+
2. Creates a matching GitHub release.
|
|
92
|
+
3. Publishes the package to the npm registry with **provenance** (OIDC
|
|
93
|
+
trusted publishing) — no token or repository secret is needed.
|
|
94
|
+
|
|
95
|
+
To enable npm publishing, enable **Trusted Publishing** for the package on
|
|
96
|
+
npmjs.com (npmjs.com/settings → Packages → your package → "Trusted Publishing"),
|
|
97
|
+
pointing at this repository and the `npmjs-publish` environment. Optionally add
|
|
98
|
+
approval rules to that environment to gate releases.
|
|
99
|
+
|
|
100
|
+
## Using as an MCP server
|
|
101
|
+
|
|
102
|
+
### Claude Desktop
|
|
103
|
+
|
|
104
|
+
`claude_desktop_config.json`:
|
|
105
|
+
|
|
106
|
+
```json
|
|
107
|
+
{
|
|
108
|
+
"mcpServers": {
|
|
109
|
+
"code-crawler": {
|
|
110
|
+
"command": "node",
|
|
111
|
+
"args": ["/absolute/path/to/code-crawler/dist/index.js", "serve"],
|
|
112
|
+
"env": { "CODECRAWLER_DB": "/absolute/path/to/your/index.db" }
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Cursor / other stdio MCP clients
|
|
119
|
+
|
|
120
|
+
Point the client at the same command. The typical flow for an LLM agent:
|
|
121
|
+
|
|
122
|
+
1. `crawl_project` the repo once.
|
|
123
|
+
2. `search_symbols` to locate the symbol of interest.
|
|
124
|
+
3. `get_callers` / `get_callees` / `trace_path` to reason about the call graph.
|
|
125
|
+
|
|
126
|
+
## MCP surface
|
|
127
|
+
|
|
128
|
+
**Tools**
|
|
129
|
+
|
|
130
|
+
| Tool | Purpose |
|
|
131
|
+
| --- | --- |
|
|
132
|
+
| `crawl_project` | Index a directory (idempotent) |
|
|
133
|
+
| `index_status` | Node/edge/file counts + last crawl |
|
|
134
|
+
| `search_symbols` | Fuzzy lookup by name or FQN, optional kind filter |
|
|
135
|
+
| `get_node` | Metadata + source location for one symbol |
|
|
136
|
+
| `get_callers` | Direct or transitive callers (depth-bounded) |
|
|
137
|
+
| `get_callees` | Direct or transitive callees (depth-bounded) |
|
|
138
|
+
| `trace_path` | Static call paths between two symbols (BFS, shortest first) |
|
|
139
|
+
| `get_subgraph` | Neighborhood extraction for visualization |
|
|
140
|
+
| `get_schema` | Describe the graph model |
|
|
141
|
+
| `clear_index` | Reset the database |
|
|
142
|
+
|
|
143
|
+
**Resources**: `codecrawler://schema`, `codecrawler://status`
|
|
144
|
+
**Prompt**: `trace-call-path(from, to)`
|
|
145
|
+
|
|
146
|
+
## Graph model
|
|
147
|
+
|
|
148
|
+
**Nodes** — `kind` is one of `file | package | class | interface | enum | method |
|
|
149
|
+
constructor | field | import | unknown_symbol`. Every node has a globally unique
|
|
150
|
+
`qualifiedName` and a JSON `properties` blob (signature, modifiers, lines, ...).
|
|
151
|
+
|
|
152
|
+
**Edges** — `kind` is one of `CALLS | DECLARED_IN | CONTAINS | IMPLEMENTS | EXTENDS |
|
|
153
|
+
IMPORTS | REFERENCES`. `CALLS` edges carry `line`, `resolved`, and `confidence`.
|
|
154
|
+
|
|
155
|
+
Id scheme:
|
|
156
|
+
|
|
157
|
+
| Symbol | Example |
|
|
158
|
+
| --- | --- |
|
|
159
|
+
| type | `com.acme.OrderService` |
|
|
160
|
+
| method | `com.acme.OrderService#place` |
|
|
161
|
+
| constructor | `com.acme.OrderService#<init>` |
|
|
162
|
+
| field | `com.acme.OrderService$repo` |
|
|
163
|
+
| import | `__import__:java.util.List` |
|
|
164
|
+
| unresolved call | `__unknown__:System.out.println` |
|
|
165
|
+
|
|
166
|
+
## Java resolution heuristics
|
|
167
|
+
|
|
168
|
+
1. **Constructor calls** (`new Foo(...)`) → resolve `Foo` → `#<init>` (default ctor if implicit).
|
|
169
|
+
2. **Bare / `this.` / `super.` calls** → enclosing type + superclass chain.
|
|
170
|
+
3. **Type-qualified calls** (`com.acme.Foo.bar`) → resolve the type directly.
|
|
171
|
+
4. **Instance calls** (`x.method()`) → infer receiver type from locals → params → fields,
|
|
172
|
+
then search that type and its ancestors.
|
|
173
|
+
5. **Otherwise** → phantom `unknown_symbol` node, `resolved:false`, with the inference
|
|
174
|
+
failure reason attached to the edge.
|
|
175
|
+
|
|
176
|
+
Each resolved edge carries a `confidence` score and a human-readable `reason` trace
|
|
177
|
+
(e.g. `via local orders: OrderService`), so LLM clients can weigh how much to trust it.
|
|
178
|
+
|
|
179
|
+
## Roadmap: multi-language
|
|
180
|
+
|
|
181
|
+
The parsing layer is language-agnostic. Adding a language requires:
|
|
182
|
+
|
|
183
|
+
1. `src/parser/languages/<lang>.ts` — a `LanguageConfig` implementing `parseFile`
|
|
184
|
+
(package/module extraction, type/member extraction, raw call sites, local type tables).
|
|
185
|
+
2. Register it in `src/parser/languages/index.ts`.
|
|
186
|
+
3. `src/resolver/<lang>Resolver.ts` — translate raw call sites into resolved targets
|
|
187
|
+
using the shared `TypeIndex`.
|
|
188
|
+
|
|
189
|
+
Natural next targets: **Python** (native AST or tree-sitter-python), **TypeScript/JavaScript**
|
|
190
|
+
(tree-sitter-typescript), and **Go** (tree-sitter-go). The graph schema, store, traversal
|
|
191
|
+
queries, and MCP surface all stay the same.
|
|
192
|
+
|
|
193
|
+
Planned enhancements:
|
|
194
|
+
|
|
195
|
+
- Package-level dependency graphs (module boundaries, cycle detection).
|
|
196
|
+
- Global call-graph analytics: hotspots (most-called methods), dead-code candidates
|
|
197
|
+
(methods with no incoming CALLS edges), fan-in/fan-out metrics.
|
|
198
|
+
- Test coverage mapping (which tests exercise a given symbol).
|
|
199
|
+
- Incremental crawling (watch mode) and git-blame aware invalidation.
|
|
200
|
+
|
|
201
|
+
## Architecture
|
|
202
|
+
|
|
203
|
+
```
|
|
204
|
+
src/
|
|
205
|
+
├── index.ts CLI (crawl | status | query | serve)
|
|
206
|
+
├── server.ts MCP server: tools, resources, prompt (thin handlers)
|
|
207
|
+
├── crawler.ts file discovery → parse → index → resolve → persist
|
|
208
|
+
├── config.ts env-overridable configuration
|
|
209
|
+
├── graph/
|
|
210
|
+
│ ├── schema.ts node/edge kinds, id scheme, property shapes
|
|
211
|
+
│ ├── store.ts better-sqlite3 schema + idempotent file-scoped upserts
|
|
212
|
+
│ └── queries.ts recursive-CTE traversal (callers/callees/path/subgraph)
|
|
213
|
+
├── parser/
|
|
214
|
+
│ ├── language.ts LanguageConfig contract
|
|
215
|
+
│ ├── treeSitter.ts WASM runtime + grammar loading + CST walk helpers
|
|
216
|
+
│ └── languages/
|
|
217
|
+
│ ├── index.ts language registry
|
|
218
|
+
│ └── java.ts Java structural extraction
|
|
219
|
+
└── resolver/
|
|
220
|
+
├── types.ts TypeIndex (global name/method index) + ResolvedCall
|
|
221
|
+
└── javaResolver.ts Java call-target resolution heuristics
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
## License
|
|
225
|
+
|
|
226
|
+
MIT
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface Config {
|
|
2
|
+
/** Path to the SQLite property-graph database. */
|
|
3
|
+
dbPath: string;
|
|
4
|
+
/** Directory names excluded during crawling. */
|
|
5
|
+
excludeDirs: string[];
|
|
6
|
+
/** Default number of results for list-returning tools. */
|
|
7
|
+
defaultLimit: number;
|
|
8
|
+
/** Cap on transitive traversal depth to keep queries bounded. */
|
|
9
|
+
maxDepth: number;
|
|
10
|
+
/** When true, errors include symbol-search suggestions. */
|
|
11
|
+
helpfulErrors: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare function loadConfig(): Config;
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import os from "node:os";
|
|
3
|
+
/**
|
|
4
|
+
* Global configuration for code-crawler.
|
|
5
|
+
*
|
|
6
|
+
* All values can be overridden via environment variables so MCP clients can
|
|
7
|
+
* point the server at different databases without code changes.
|
|
8
|
+
*/
|
|
9
|
+
const DEFAULT_DB_PATH = path.join(os.homedir(), ".code-crawler", "index.db");
|
|
10
|
+
function envStr(name, fallback) {
|
|
11
|
+
const v = process.env[name];
|
|
12
|
+
return v && v.length > 0 ? v : fallback;
|
|
13
|
+
}
|
|
14
|
+
function envBool(name, fallback) {
|
|
15
|
+
const v = process.env[name];
|
|
16
|
+
if (v === undefined)
|
|
17
|
+
return fallback;
|
|
18
|
+
return v === "1" || v.toLowerCase() === "true";
|
|
19
|
+
}
|
|
20
|
+
export function loadConfig() {
|
|
21
|
+
return {
|
|
22
|
+
dbPath: envStr("CODECRAWLER_DB", DEFAULT_DB_PATH),
|
|
23
|
+
excludeDirs: envStr("CODECRAWLER_EXCLUDE_DIRS", ".git,node_modules,dist,build,target,.idea,.venv,.gradle,out,.next,coverage")
|
|
24
|
+
.split(",")
|
|
25
|
+
.map((s) => s.trim())
|
|
26
|
+
.filter((s) => s.length > 0),
|
|
27
|
+
defaultLimit: Number(envStr("CODECRAWLER_DEFAULT_LIMIT", "50")),
|
|
28
|
+
maxDepth: Number(envStr("CODECRAWLER_MAX_DEPTH", "10")),
|
|
29
|
+
helpfulErrors: envBool("CODECRAWLER_HELPFUL_ERRORS", true),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,SAAS,CAAC;AAEzB;;;;;GAKG;AAEH,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,eAAe,EAAE,UAAU,CAAC,CAAC;AAE7E,SAAS,MAAM,CAAC,IAAY,EAAE,QAAgB;IAC5C,MAAM,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC5B,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;AAC1C,CAAC;AAED,SAAS,OAAO,CAAC,IAAY,EAAE,QAAiB;IAC9C,MAAM,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC5B,IAAI,CAAC,KAAK,SAAS;QAAE,OAAO,QAAQ,CAAC;IACrC,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,WAAW,EAAE,KAAK,MAAM,CAAC;AACjD,CAAC;AAeD,MAAM,UAAU,UAAU;IACxB,OAAO;QACL,MAAM,EAAE,MAAM,CAAC,gBAAgB,EAAE,eAAe,CAAC;QACjD,WAAW,EAAE,MAAM,CACjB,0BAA0B,EAC1B,4EAA4E,CAC7E;aACE,KAAK,CAAC,GAAG,CAAC;aACV,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;aACpB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;QAC9B,YAAY,EAAE,MAAM,CAAC,MAAM,CAAC,2BAA2B,EAAE,IAAI,CAAC,CAAC;QAC/D,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,uBAAuB,EAAE,IAAI,CAAC,CAAC;QACvD,aAAa,EAAE,OAAO,CAAC,4BAA4B,EAAE,IAAI,CAAC;KAC3D,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { GraphStore } from "./graph/store.js";
|
|
2
|
+
import type { GraphEdge, GraphNode } from "./graph/schema.js";
|
|
3
|
+
import type { ParsedFile } from "./parser/language.js";
|
|
4
|
+
import { buildTypeIndex } from "./resolver/types.js";
|
|
5
|
+
/**
|
|
6
|
+
* Project crawler: discover source files, parse them, build a global type
|
|
7
|
+
* index, resolve call targets, and persist an idempotent file-scoped graph.
|
|
8
|
+
*/
|
|
9
|
+
export interface CrawlOptions {
|
|
10
|
+
/** Force a specific language regardless of extension. */
|
|
11
|
+
language?: string;
|
|
12
|
+
/** Optional include filter: path must contain this substring. */
|
|
13
|
+
fileFilter?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface CrawlResult {
|
|
16
|
+
projectPath: string;
|
|
17
|
+
filesScanned: number;
|
|
18
|
+
filesParsed: number;
|
|
19
|
+
filesRemoved: number;
|
|
20
|
+
nodes: number;
|
|
21
|
+
edges: number;
|
|
22
|
+
resolvedCalls: number;
|
|
23
|
+
unresolvedCalls: number;
|
|
24
|
+
languages: string[];
|
|
25
|
+
durationMs: number;
|
|
26
|
+
}
|
|
27
|
+
/** Discover source files under a project, respecting exclusion dirs. */
|
|
28
|
+
export declare function discoverSourceFiles(projectPath: string, excludeDirs: string[], language?: string): string[];
|
|
29
|
+
/** Convert a ParsedFile into graph nodes + edges (declarations only). */
|
|
30
|
+
export declare function buildDeclarationGraph(parsed: ParsedFile): {
|
|
31
|
+
nodes: GraphNode[];
|
|
32
|
+
edges: GraphEdge[];
|
|
33
|
+
};
|
|
34
|
+
/** Resolve call sites for a parsed file into CALLS edges + phantom nodes. */
|
|
35
|
+
export declare function buildCallEdges(parsed: ParsedFile, index: ReturnType<typeof buildTypeIndex>, knownNodeIds: Set<string>): {
|
|
36
|
+
edges: GraphEdge[];
|
|
37
|
+
phantomNodes: GraphNode[];
|
|
38
|
+
resolved: number;
|
|
39
|
+
unresolved: number;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Crawl a project directory and index it into the store.
|
|
43
|
+
* Idempotent: re-crawling refreshes the graph; files that disappeared are
|
|
44
|
+
* removed from the index.
|
|
45
|
+
*/
|
|
46
|
+
export declare function crawlProject(store: GraphStore, projectPath: string, excludeDirs: string[], options?: CrawlOptions): Promise<CrawlResult>;
|