@colbymchenry/codegraph 0.8.0 → 0.9.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 +23 -7
- package/npm-shim.js +43 -0
- package/package.json +13 -51
- package/LICENSE +0 -21
- package/dist/bin/codegraph.d.ts +0 -21
- package/dist/bin/codegraph.d.ts.map +0 -1
- package/dist/bin/codegraph.js +0 -1257
- package/dist/bin/codegraph.js.map +0 -1
- package/dist/bin/node-version-check.d.ts +0 -20
- package/dist/bin/node-version-check.d.ts.map +0 -1
- package/dist/bin/node-version-check.js +0 -42
- package/dist/bin/node-version-check.js.map +0 -1
- package/dist/bin/uninstall.d.ts +0 -14
- package/dist/bin/uninstall.d.ts.map +0 -1
- package/dist/bin/uninstall.js +0 -36
- package/dist/bin/uninstall.js.map +0 -1
- package/dist/config.d.ts +0 -51
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js +0 -321
- package/dist/config.js.map +0 -1
- package/dist/context/formatter.d.ts +0 -30
- package/dist/context/formatter.d.ts.map +0 -1
- package/dist/context/formatter.js +0 -244
- package/dist/context/formatter.js.map +0 -1
- package/dist/context/index.d.ts +0 -97
- package/dist/context/index.d.ts.map +0 -1
- package/dist/context/index.js +0 -1050
- package/dist/context/index.js.map +0 -1
- package/dist/db/index.d.ts +0 -72
- package/dist/db/index.d.ts.map +0 -1
- package/dist/db/index.js +0 -200
- package/dist/db/index.js.map +0 -1
- package/dist/db/migrations.d.ts +0 -44
- package/dist/db/migrations.d.ts.map +0 -1
- package/dist/db/migrations.js +0 -131
- package/dist/db/migrations.js.map +0 -1
- package/dist/db/queries.d.ts +0 -253
- package/dist/db/queries.d.ts.map +0 -1
- package/dist/db/queries.js +0 -1207
- package/dist/db/queries.js.map +0 -1
- package/dist/db/schema.sql +0 -151
- package/dist/db/sqlite-adapter.d.ts +0 -52
- package/dist/db/sqlite-adapter.d.ts.map +0 -1
- package/dist/db/sqlite-adapter.js +0 -237
- package/dist/db/sqlite-adapter.js.map +0 -1
- package/dist/directory.d.ts +0 -57
- package/dist/directory.d.ts.map +0 -1
- package/dist/directory.js +0 -264
- package/dist/directory.js.map +0 -1
- package/dist/errors.d.ts +0 -136
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js +0 -219
- package/dist/errors.js.map +0 -1
- package/dist/extraction/dfm-extractor.d.ts +0 -31
- package/dist/extraction/dfm-extractor.d.ts.map +0 -1
- package/dist/extraction/dfm-extractor.js +0 -151
- package/dist/extraction/dfm-extractor.js.map +0 -1
- package/dist/extraction/grammars.d.ts +0 -78
- package/dist/extraction/grammars.d.ts.map +0 -1
- package/dist/extraction/grammars.js +0 -322
- package/dist/extraction/grammars.js.map +0 -1
- package/dist/extraction/index.d.ts +0 -130
- package/dist/extraction/index.d.ts.map +0 -1
- package/dist/extraction/index.js +0 -1305
- package/dist/extraction/index.js.map +0 -1
- package/dist/extraction/languages/c-cpp.d.ts +0 -4
- package/dist/extraction/languages/c-cpp.d.ts.map +0 -1
- package/dist/extraction/languages/c-cpp.js +0 -126
- package/dist/extraction/languages/c-cpp.js.map +0 -1
- package/dist/extraction/languages/csharp.d.ts +0 -3
- package/dist/extraction/languages/csharp.d.ts.map +0 -1
- package/dist/extraction/languages/csharp.js +0 -72
- package/dist/extraction/languages/csharp.js.map +0 -1
- package/dist/extraction/languages/dart.d.ts +0 -3
- package/dist/extraction/languages/dart.d.ts.map +0 -1
- package/dist/extraction/languages/dart.js +0 -192
- package/dist/extraction/languages/dart.js.map +0 -1
- package/dist/extraction/languages/go.d.ts +0 -3
- package/dist/extraction/languages/go.d.ts.map +0 -1
- package/dist/extraction/languages/go.js +0 -58
- package/dist/extraction/languages/go.js.map +0 -1
- package/dist/extraction/languages/index.d.ts +0 -10
- package/dist/extraction/languages/index.d.ts.map +0 -1
- package/dist/extraction/languages/index.js +0 -45
- package/dist/extraction/languages/index.js.map +0 -1
- package/dist/extraction/languages/java.d.ts +0 -3
- package/dist/extraction/languages/java.d.ts.map +0 -1
- package/dist/extraction/languages/java.js +0 -64
- package/dist/extraction/languages/java.js.map +0 -1
- package/dist/extraction/languages/javascript.d.ts +0 -3
- package/dist/extraction/languages/javascript.d.ts.map +0 -1
- package/dist/extraction/languages/javascript.js +0 -90
- package/dist/extraction/languages/javascript.js.map +0 -1
- package/dist/extraction/languages/kotlin.d.ts +0 -3
- package/dist/extraction/languages/kotlin.d.ts.map +0 -1
- package/dist/extraction/languages/kotlin.js +0 -253
- package/dist/extraction/languages/kotlin.js.map +0 -1
- package/dist/extraction/languages/pascal.d.ts +0 -3
- package/dist/extraction/languages/pascal.d.ts.map +0 -1
- package/dist/extraction/languages/pascal.js +0 -66
- package/dist/extraction/languages/pascal.js.map +0 -1
- package/dist/extraction/languages/php.d.ts +0 -3
- package/dist/extraction/languages/php.d.ts.map +0 -1
- package/dist/extraction/languages/php.js +0 -107
- package/dist/extraction/languages/php.js.map +0 -1
- package/dist/extraction/languages/python.d.ts +0 -3
- package/dist/extraction/languages/python.d.ts.map +0 -1
- package/dist/extraction/languages/python.js +0 -56
- package/dist/extraction/languages/python.js.map +0 -1
- package/dist/extraction/languages/ruby.d.ts +0 -3
- package/dist/extraction/languages/ruby.d.ts.map +0 -1
- package/dist/extraction/languages/ruby.js +0 -114
- package/dist/extraction/languages/ruby.js.map +0 -1
- package/dist/extraction/languages/rust.d.ts +0 -3
- package/dist/extraction/languages/rust.d.ts.map +0 -1
- package/dist/extraction/languages/rust.js +0 -109
- package/dist/extraction/languages/rust.js.map +0 -1
- package/dist/extraction/languages/scala.d.ts +0 -3
- package/dist/extraction/languages/scala.d.ts.map +0 -1
- package/dist/extraction/languages/scala.js +0 -139
- package/dist/extraction/languages/scala.js.map +0 -1
- package/dist/extraction/languages/swift.d.ts +0 -3
- package/dist/extraction/languages/swift.d.ts.map +0 -1
- package/dist/extraction/languages/swift.js +0 -91
- package/dist/extraction/languages/swift.js.map +0 -1
- package/dist/extraction/languages/typescript.d.ts +0 -3
- package/dist/extraction/languages/typescript.d.ts.map +0 -1
- package/dist/extraction/languages/typescript.js +0 -129
- package/dist/extraction/languages/typescript.js.map +0 -1
- package/dist/extraction/liquid-extractor.d.ts +0 -52
- package/dist/extraction/liquid-extractor.d.ts.map +0 -1
- package/dist/extraction/liquid-extractor.js +0 -313
- package/dist/extraction/liquid-extractor.js.map +0 -1
- package/dist/extraction/parse-worker.d.ts +0 -8
- package/dist/extraction/parse-worker.d.ts.map +0 -1
- package/dist/extraction/parse-worker.js +0 -94
- package/dist/extraction/parse-worker.js.map +0 -1
- package/dist/extraction/svelte-extractor.d.ts +0 -56
- package/dist/extraction/svelte-extractor.d.ts.map +0 -1
- package/dist/extraction/svelte-extractor.js +0 -272
- package/dist/extraction/svelte-extractor.js.map +0 -1
- package/dist/extraction/tree-sitter-helpers.d.ts +0 -28
- package/dist/extraction/tree-sitter-helpers.d.ts.map +0 -1
- package/dist/extraction/tree-sitter-helpers.js +0 -103
- package/dist/extraction/tree-sitter-helpers.js.map +0 -1
- package/dist/extraction/tree-sitter-types.d.ts +0 -179
- package/dist/extraction/tree-sitter-types.d.ts.map +0 -1
- package/dist/extraction/tree-sitter-types.js +0 -10
- package/dist/extraction/tree-sitter-types.js.map +0 -1
- package/dist/extraction/tree-sitter.d.ts +0 -233
- package/dist/extraction/tree-sitter.d.ts.map +0 -1
- package/dist/extraction/tree-sitter.js +0 -2393
- package/dist/extraction/tree-sitter.js.map +0 -1
- package/dist/extraction/vue-extractor.d.ts +0 -36
- package/dist/extraction/vue-extractor.d.ts.map +0 -1
- package/dist/extraction/vue-extractor.js +0 -163
- package/dist/extraction/vue-extractor.js.map +0 -1
- package/dist/extraction/wasm/tree-sitter-pascal.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-scala.wasm +0 -0
- package/dist/graph/index.d.ts +0 -8
- package/dist/graph/index.d.ts.map +0 -1
- package/dist/graph/index.js +0 -13
- package/dist/graph/index.js.map +0 -1
- package/dist/graph/queries.d.ts +0 -106
- package/dist/graph/queries.d.ts.map +0 -1
- package/dist/graph/queries.js +0 -366
- package/dist/graph/queries.js.map +0 -1
- package/dist/graph/traversal.d.ts +0 -127
- package/dist/graph/traversal.d.ts.map +0 -1
- package/dist/graph/traversal.js +0 -493
- package/dist/graph/traversal.js.map +0 -1
- package/dist/index.d.ts +0 -447
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -825
- package/dist/index.js.map +0 -1
- package/dist/installer/claude-md-template.d.ts +0 -14
- package/dist/installer/claude-md-template.d.ts.map +0 -1
- package/dist/installer/claude-md-template.js +0 -21
- package/dist/installer/claude-md-template.js.map +0 -1
- package/dist/installer/config-writer.d.ts +0 -29
- package/dist/installer/config-writer.d.ts.map +0 -1
- package/dist/installer/config-writer.js +0 -111
- package/dist/installer/config-writer.js.map +0 -1
- package/dist/installer/index.d.ts +0 -65
- package/dist/installer/index.d.ts.map +0 -1
- package/dist/installer/index.js +0 -406
- package/dist/installer/index.js.map +0 -1
- package/dist/installer/instructions-template.d.ts +0 -28
- package/dist/installer/instructions-template.d.ts.map +0 -1
- package/dist/installer/instructions-template.js +0 -64
- package/dist/installer/instructions-template.js.map +0 -1
- package/dist/installer/targets/claude.d.ts +0 -31
- package/dist/installer/targets/claude.d.ts.map +0 -1
- package/dist/installer/targets/claude.js +0 -308
- package/dist/installer/targets/claude.js.map +0 -1
- package/dist/installer/targets/codex.d.ts +0 -18
- package/dist/installer/targets/codex.d.ts.map +0 -1
- package/dist/installer/targets/codex.js +0 -185
- package/dist/installer/targets/codex.js.map +0 -1
- package/dist/installer/targets/cursor.d.ts +0 -35
- package/dist/installer/targets/cursor.d.ts.map +0 -1
- package/dist/installer/targets/cursor.js +0 -229
- package/dist/installer/targets/cursor.js.map +0 -1
- package/dist/installer/targets/opencode.d.ts +0 -30
- package/dist/installer/targets/opencode.d.ts.map +0 -1
- package/dist/installer/targets/opencode.js +0 -235
- package/dist/installer/targets/opencode.js.map +0 -1
- package/dist/installer/targets/registry.d.ts +0 -35
- package/dist/installer/targets/registry.d.ts.map +0 -1
- package/dist/installer/targets/registry.js +0 -83
- package/dist/installer/targets/registry.js.map +0 -1
- package/dist/installer/targets/shared.d.ts +0 -77
- package/dist/installer/targets/shared.d.ts.map +0 -1
- package/dist/installer/targets/shared.js +0 -246
- package/dist/installer/targets/shared.js.map +0 -1
- package/dist/installer/targets/toml.d.ts +0 -52
- package/dist/installer/targets/toml.d.ts.map +0 -1
- package/dist/installer/targets/toml.js +0 -147
- package/dist/installer/targets/toml.js.map +0 -1
- package/dist/installer/targets/types.d.ts +0 -116
- package/dist/installer/targets/types.d.ts.map +0 -1
- package/dist/installer/targets/types.js +0 -16
- package/dist/installer/targets/types.js.map +0 -1
- package/dist/mcp/index.d.ts +0 -94
- package/dist/mcp/index.d.ts.map +0 -1
- package/dist/mcp/index.js +0 -453
- package/dist/mcp/index.js.map +0 -1
- package/dist/mcp/server-instructions.d.ts +0 -19
- package/dist/mcp/server-instructions.d.ts.map +0 -1
- package/dist/mcp/server-instructions.js +0 -71
- package/dist/mcp/server-instructions.js.map +0 -1
- package/dist/mcp/tools.d.ts +0 -257
- package/dist/mcp/tools.d.ts.map +0 -1
- package/dist/mcp/tools.js +0 -1633
- package/dist/mcp/tools.js.map +0 -1
- package/dist/mcp/transport.d.ts +0 -106
- package/dist/mcp/transport.d.ts.map +0 -1
- package/dist/mcp/transport.js +0 -233
- package/dist/mcp/transport.js.map +0 -1
- package/dist/resolution/frameworks/cargo-workspace.d.ts +0 -18
- package/dist/resolution/frameworks/cargo-workspace.d.ts.map +0 -1
- package/dist/resolution/frameworks/cargo-workspace.js +0 -225
- package/dist/resolution/frameworks/cargo-workspace.js.map +0 -1
- package/dist/resolution/frameworks/csharp.d.ts +0 -8
- package/dist/resolution/frameworks/csharp.d.ts.map +0 -1
- package/dist/resolution/frameworks/csharp.js +0 -213
- package/dist/resolution/frameworks/csharp.js.map +0 -1
- package/dist/resolution/frameworks/express.d.ts +0 -8
- package/dist/resolution/frameworks/express.d.ts.map +0 -1
- package/dist/resolution/frameworks/express.js +0 -225
- package/dist/resolution/frameworks/express.js.map +0 -1
- package/dist/resolution/frameworks/go.d.ts +0 -8
- package/dist/resolution/frameworks/go.d.ts.map +0 -1
- package/dist/resolution/frameworks/go.js +0 -158
- package/dist/resolution/frameworks/go.js.map +0 -1
- package/dist/resolution/frameworks/index.d.ts +0 -42
- package/dist/resolution/frameworks/index.d.ts.map +0 -1
- package/dist/resolution/frameworks/index.js +0 -133
- package/dist/resolution/frameworks/index.js.map +0 -1
- package/dist/resolution/frameworks/java.d.ts +0 -8
- package/dist/resolution/frameworks/java.d.ts.map +0 -1
- package/dist/resolution/frameworks/java.js +0 -177
- package/dist/resolution/frameworks/java.js.map +0 -1
- package/dist/resolution/frameworks/laravel.d.ts +0 -13
- package/dist/resolution/frameworks/laravel.d.ts.map +0 -1
- package/dist/resolution/frameworks/laravel.js +0 -248
- package/dist/resolution/frameworks/laravel.js.map +0 -1
- package/dist/resolution/frameworks/nestjs.d.ts +0 -26
- package/dist/resolution/frameworks/nestjs.d.ts.map +0 -1
- package/dist/resolution/frameworks/nestjs.js +0 -374
- package/dist/resolution/frameworks/nestjs.js.map +0 -1
- package/dist/resolution/frameworks/python.d.ts +0 -10
- package/dist/resolution/frameworks/python.d.ts.map +0 -1
- package/dist/resolution/frameworks/python.js +0 -278
- package/dist/resolution/frameworks/python.js.map +0 -1
- package/dist/resolution/frameworks/react.d.ts +0 -8
- package/dist/resolution/frameworks/react.d.ts.map +0 -1
- package/dist/resolution/frameworks/react.js +0 -272
- package/dist/resolution/frameworks/react.js.map +0 -1
- package/dist/resolution/frameworks/ruby.d.ts +0 -8
- package/dist/resolution/frameworks/ruby.d.ts.map +0 -1
- package/dist/resolution/frameworks/ruby.js +0 -198
- package/dist/resolution/frameworks/ruby.js.map +0 -1
- package/dist/resolution/frameworks/rust.d.ts +0 -8
- package/dist/resolution/frameworks/rust.d.ts.map +0 -1
- package/dist/resolution/frameworks/rust.js +0 -207
- package/dist/resolution/frameworks/rust.js.map +0 -1
- package/dist/resolution/frameworks/svelte.d.ts +0 -9
- package/dist/resolution/frameworks/svelte.d.ts.map +0 -1
- package/dist/resolution/frameworks/svelte.js +0 -249
- package/dist/resolution/frameworks/svelte.js.map +0 -1
- package/dist/resolution/frameworks/swift.d.ts +0 -10
- package/dist/resolution/frameworks/swift.d.ts.map +0 -1
- package/dist/resolution/frameworks/swift.js +0 -376
- package/dist/resolution/frameworks/swift.js.map +0 -1
- package/dist/resolution/frameworks/vue.d.ts +0 -9
- package/dist/resolution/frameworks/vue.d.ts.map +0 -1
- package/dist/resolution/frameworks/vue.js +0 -306
- package/dist/resolution/frameworks/vue.js.map +0 -1
- package/dist/resolution/import-resolver.d.ts +0 -40
- package/dist/resolution/import-resolver.d.ts.map +0 -1
- package/dist/resolution/import-resolver.js +0 -663
- package/dist/resolution/import-resolver.js.map +0 -1
- package/dist/resolution/index.d.ts +0 -106
- package/dist/resolution/index.d.ts.map +0 -1
- package/dist/resolution/index.js +0 -709
- package/dist/resolution/index.js.map +0 -1
- package/dist/resolution/name-matcher.d.ts +0 -32
- package/dist/resolution/name-matcher.d.ts.map +0 -1
- package/dist/resolution/name-matcher.js +0 -384
- package/dist/resolution/name-matcher.js.map +0 -1
- package/dist/resolution/path-aliases.d.ts +0 -68
- package/dist/resolution/path-aliases.d.ts.map +0 -1
- package/dist/resolution/path-aliases.js +0 -238
- package/dist/resolution/path-aliases.js.map +0 -1
- package/dist/resolution/strip-comments.d.ts +0 -27
- package/dist/resolution/strip-comments.d.ts.map +0 -1
- package/dist/resolution/strip-comments.js +0 -441
- package/dist/resolution/strip-comments.js.map +0 -1
- package/dist/resolution/types.d.ts +0 -172
- package/dist/resolution/types.d.ts.map +0 -1
- package/dist/resolution/types.js +0 -8
- package/dist/resolution/types.js.map +0 -1
- package/dist/search/query-parser.d.ts +0 -57
- package/dist/search/query-parser.d.ts.map +0 -1
- package/dist/search/query-parser.js +0 -177
- package/dist/search/query-parser.js.map +0 -1
- package/dist/search/query-utils.d.ts +0 -53
- package/dist/search/query-utils.d.ts.map +0 -1
- package/dist/search/query-utils.js +0 -350
- package/dist/search/query-utils.js.map +0 -1
- package/dist/sync/git-hooks.d.ts +0 -45
- package/dist/sync/git-hooks.d.ts.map +0 -1
- package/dist/sync/git-hooks.js +0 -223
- package/dist/sync/git-hooks.js.map +0 -1
- package/dist/sync/index.d.ts +0 -17
- package/dist/sync/index.d.ts.map +0 -1
- package/dist/sync/index.js +0 -28
- package/dist/sync/index.js.map +0 -1
- package/dist/sync/watch-policy.d.ts +0 -48
- package/dist/sync/watch-policy.d.ts.map +0 -1
- package/dist/sync/watch-policy.js +0 -124
- package/dist/sync/watch-policy.js.map +0 -1
- package/dist/sync/watcher.d.ts +0 -81
- package/dist/sync/watcher.d.ts.map +0 -1
- package/dist/sync/watcher.js +0 -194
- package/dist/sync/watcher.js.map +0 -1
- package/dist/types.d.ts +0 -423
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -256
- package/dist/types.js.map +0 -1
- package/dist/ui/glyphs.d.ts +0 -42
- package/dist/ui/glyphs.d.ts.map +0 -1
- package/dist/ui/glyphs.js +0 -78
- package/dist/ui/glyphs.js.map +0 -1
- package/dist/ui/shimmer-progress.d.ts +0 -11
- package/dist/ui/shimmer-progress.d.ts.map +0 -1
- package/dist/ui/shimmer-progress.js +0 -90
- package/dist/ui/shimmer-progress.js.map +0 -1
- package/dist/ui/shimmer-worker.d.ts +0 -2
- package/dist/ui/shimmer-worker.d.ts.map +0 -1
- package/dist/ui/shimmer-worker.js +0 -118
- package/dist/ui/shimmer-worker.js.map +0 -1
- package/dist/ui/types.d.ts +0 -17
- package/dist/ui/types.d.ts.map +0 -1
- package/dist/ui/types.js +0 -3
- package/dist/ui/types.js.map +0 -1
- package/dist/utils.d.ts +0 -205
- package/dist/utils.d.ts.map +0 -1
- package/dist/utils.js +0 -549
- package/dist/utils.js.map +0 -1
- package/scripts/agent-eval/audit.sh +0 -68
- package/scripts/agent-eval/itrun.sh +0 -107
- package/scripts/agent-eval/parse-run.mjs +0 -45
- package/scripts/agent-eval/parse-session.mjs +0 -93
- package/scripts/agent-eval/run-agent.sh +0 -34
- package/scripts/agent-eval/run-all.sh +0 -67
- package/scripts/extract-release-notes.mjs +0 -130
- package/scripts/local-install.sh +0 -41
- package/scripts/patch-tree-sitter-dart.js +0 -112
- package/scripts/release.sh +0 -68
package/dist/index.js
DELETED
|
@@ -1,825 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* CodeGraph
|
|
4
|
-
*
|
|
5
|
-
* A local-first code intelligence system that builds a semantic
|
|
6
|
-
* knowledge graph from any codebase.
|
|
7
|
-
*/
|
|
8
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
-
if (k2 === undefined) k2 = k;
|
|
10
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
-
}
|
|
14
|
-
Object.defineProperty(o, k2, desc);
|
|
15
|
-
}) : (function(o, m, k, k2) {
|
|
16
|
-
if (k2 === undefined) k2 = k;
|
|
17
|
-
o[k2] = m[k];
|
|
18
|
-
}));
|
|
19
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
20
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
21
|
-
}) : function(o, v) {
|
|
22
|
-
o["default"] = v;
|
|
23
|
-
});
|
|
24
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
-
var ownKeys = function(o) {
|
|
26
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
-
var ar = [];
|
|
28
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
-
return ar;
|
|
30
|
-
};
|
|
31
|
-
return ownKeys(o);
|
|
32
|
-
};
|
|
33
|
-
return function (mod) {
|
|
34
|
-
if (mod && mod.__esModule) return mod;
|
|
35
|
-
var result = {};
|
|
36
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
-
__setModuleDefault(result, mod);
|
|
38
|
-
return result;
|
|
39
|
-
};
|
|
40
|
-
})();
|
|
41
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
42
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
43
|
-
};
|
|
44
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
-
exports.CodeGraph = exports.MCPServer = exports.FileWatcher = exports.MemoryMonitor = exports.throttle = exports.debounce = exports.processInBatches = exports.FileLock = exports.Mutex = exports.defaultLogger = exports.silentLogger = exports.getLogger = exports.setLogger = exports.ConfigError = exports.VectorError = exports.SearchError = exports.DatabaseError = exports.ParseError = exports.FileError = exports.CodeGraphError = exports.loadAllGrammars = exports.loadGrammarsForLanguages = exports.initGrammars = exports.getSupportedLanguages = exports.isGrammarLoaded = exports.isLanguageSupported = exports.detectLanguage = exports.CODEGRAPH_DIR = exports.findNearestCodeGraphRoot = exports.isInitialized = exports.getCodeGraphDir = exports.getConfigPath = exports.getDatabasePath = void 0;
|
|
46
|
-
const path = __importStar(require("path"));
|
|
47
|
-
const db_1 = require("./db");
|
|
48
|
-
const queries_1 = require("./db/queries");
|
|
49
|
-
const config_1 = require("./config");
|
|
50
|
-
const directory_1 = require("./directory");
|
|
51
|
-
const extraction_1 = require("./extraction");
|
|
52
|
-
const resolution_1 = require("./resolution");
|
|
53
|
-
const graph_1 = require("./graph");
|
|
54
|
-
const context_1 = require("./context");
|
|
55
|
-
const utils_1 = require("./utils");
|
|
56
|
-
const sync_1 = require("./sync");
|
|
57
|
-
// Re-export types for consumers
|
|
58
|
-
__exportStar(require("./types"), exports);
|
|
59
|
-
var db_2 = require("./db");
|
|
60
|
-
Object.defineProperty(exports, "getDatabasePath", { enumerable: true, get: function () { return db_2.getDatabasePath; } });
|
|
61
|
-
var config_2 = require("./config");
|
|
62
|
-
Object.defineProperty(exports, "getConfigPath", { enumerable: true, get: function () { return config_2.getConfigPath; } });
|
|
63
|
-
var directory_2 = require("./directory");
|
|
64
|
-
Object.defineProperty(exports, "getCodeGraphDir", { enumerable: true, get: function () { return directory_2.getCodeGraphDir; } });
|
|
65
|
-
Object.defineProperty(exports, "isInitialized", { enumerable: true, get: function () { return directory_2.isInitialized; } });
|
|
66
|
-
Object.defineProperty(exports, "findNearestCodeGraphRoot", { enumerable: true, get: function () { return directory_2.findNearestCodeGraphRoot; } });
|
|
67
|
-
Object.defineProperty(exports, "CODEGRAPH_DIR", { enumerable: true, get: function () { return directory_2.CODEGRAPH_DIR; } });
|
|
68
|
-
var extraction_2 = require("./extraction");
|
|
69
|
-
Object.defineProperty(exports, "detectLanguage", { enumerable: true, get: function () { return extraction_2.detectLanguage; } });
|
|
70
|
-
Object.defineProperty(exports, "isLanguageSupported", { enumerable: true, get: function () { return extraction_2.isLanguageSupported; } });
|
|
71
|
-
Object.defineProperty(exports, "isGrammarLoaded", { enumerable: true, get: function () { return extraction_2.isGrammarLoaded; } });
|
|
72
|
-
Object.defineProperty(exports, "getSupportedLanguages", { enumerable: true, get: function () { return extraction_2.getSupportedLanguages; } });
|
|
73
|
-
Object.defineProperty(exports, "initGrammars", { enumerable: true, get: function () { return extraction_2.initGrammars; } });
|
|
74
|
-
Object.defineProperty(exports, "loadGrammarsForLanguages", { enumerable: true, get: function () { return extraction_2.loadGrammarsForLanguages; } });
|
|
75
|
-
Object.defineProperty(exports, "loadAllGrammars", { enumerable: true, get: function () { return extraction_2.loadAllGrammars; } });
|
|
76
|
-
var errors_1 = require("./errors");
|
|
77
|
-
Object.defineProperty(exports, "CodeGraphError", { enumerable: true, get: function () { return errors_1.CodeGraphError; } });
|
|
78
|
-
Object.defineProperty(exports, "FileError", { enumerable: true, get: function () { return errors_1.FileError; } });
|
|
79
|
-
Object.defineProperty(exports, "ParseError", { enumerable: true, get: function () { return errors_1.ParseError; } });
|
|
80
|
-
Object.defineProperty(exports, "DatabaseError", { enumerable: true, get: function () { return errors_1.DatabaseError; } });
|
|
81
|
-
Object.defineProperty(exports, "SearchError", { enumerable: true, get: function () { return errors_1.SearchError; } });
|
|
82
|
-
Object.defineProperty(exports, "VectorError", { enumerable: true, get: function () { return errors_1.VectorError; } });
|
|
83
|
-
Object.defineProperty(exports, "ConfigError", { enumerable: true, get: function () { return errors_1.ConfigError; } });
|
|
84
|
-
Object.defineProperty(exports, "setLogger", { enumerable: true, get: function () { return errors_1.setLogger; } });
|
|
85
|
-
Object.defineProperty(exports, "getLogger", { enumerable: true, get: function () { return errors_1.getLogger; } });
|
|
86
|
-
Object.defineProperty(exports, "silentLogger", { enumerable: true, get: function () { return errors_1.silentLogger; } });
|
|
87
|
-
Object.defineProperty(exports, "defaultLogger", { enumerable: true, get: function () { return errors_1.defaultLogger; } });
|
|
88
|
-
var utils_2 = require("./utils");
|
|
89
|
-
Object.defineProperty(exports, "Mutex", { enumerable: true, get: function () { return utils_2.Mutex; } });
|
|
90
|
-
Object.defineProperty(exports, "FileLock", { enumerable: true, get: function () { return utils_2.FileLock; } });
|
|
91
|
-
Object.defineProperty(exports, "processInBatches", { enumerable: true, get: function () { return utils_2.processInBatches; } });
|
|
92
|
-
Object.defineProperty(exports, "debounce", { enumerable: true, get: function () { return utils_2.debounce; } });
|
|
93
|
-
Object.defineProperty(exports, "throttle", { enumerable: true, get: function () { return utils_2.throttle; } });
|
|
94
|
-
Object.defineProperty(exports, "MemoryMonitor", { enumerable: true, get: function () { return utils_2.MemoryMonitor; } });
|
|
95
|
-
var sync_2 = require("./sync");
|
|
96
|
-
Object.defineProperty(exports, "FileWatcher", { enumerable: true, get: function () { return sync_2.FileWatcher; } });
|
|
97
|
-
var mcp_1 = require("./mcp");
|
|
98
|
-
Object.defineProperty(exports, "MCPServer", { enumerable: true, get: function () { return mcp_1.MCPServer; } });
|
|
99
|
-
/**
|
|
100
|
-
* Main CodeGraph class
|
|
101
|
-
*
|
|
102
|
-
* Provides the primary interface for interacting with the code knowledge graph.
|
|
103
|
-
*/
|
|
104
|
-
class CodeGraph {
|
|
105
|
-
db;
|
|
106
|
-
queries;
|
|
107
|
-
config;
|
|
108
|
-
projectRoot;
|
|
109
|
-
orchestrator;
|
|
110
|
-
resolver;
|
|
111
|
-
graphManager;
|
|
112
|
-
traverser;
|
|
113
|
-
contextBuilder;
|
|
114
|
-
// Mutex for preventing concurrent indexing operations (in-process)
|
|
115
|
-
indexMutex = new utils_1.Mutex();
|
|
116
|
-
// File lock for preventing concurrent writes across processes (CLI, MCP, git hooks)
|
|
117
|
-
fileLock;
|
|
118
|
-
// File watcher for auto-sync on file changes
|
|
119
|
-
watcher = null;
|
|
120
|
-
constructor(db, queries, config, projectRoot) {
|
|
121
|
-
this.db = db;
|
|
122
|
-
this.queries = queries;
|
|
123
|
-
this.config = config;
|
|
124
|
-
this.projectRoot = projectRoot;
|
|
125
|
-
this.fileLock = new utils_1.FileLock(path.join(projectRoot, '.codegraph', 'codegraph.lock'));
|
|
126
|
-
this.orchestrator = new extraction_1.ExtractionOrchestrator(projectRoot, config, queries);
|
|
127
|
-
this.resolver = (0, resolution_1.createResolver)(projectRoot, queries);
|
|
128
|
-
this.graphManager = new graph_1.GraphQueryManager(queries);
|
|
129
|
-
this.traverser = new graph_1.GraphTraverser(queries);
|
|
130
|
-
this.contextBuilder = (0, context_1.createContextBuilder)(projectRoot, queries, this.traverser);
|
|
131
|
-
}
|
|
132
|
-
// ===========================================================================
|
|
133
|
-
// Lifecycle Methods
|
|
134
|
-
// ===========================================================================
|
|
135
|
-
/**
|
|
136
|
-
* Initialize a new CodeGraph project
|
|
137
|
-
*
|
|
138
|
-
* Creates the .CodeGraph directory, database, and configuration.
|
|
139
|
-
*
|
|
140
|
-
* @param projectRoot - Path to the project root directory
|
|
141
|
-
* @param options - Initialization options
|
|
142
|
-
* @returns A new CodeGraph instance
|
|
143
|
-
*/
|
|
144
|
-
static async init(projectRoot, options = {}) {
|
|
145
|
-
await (0, extraction_1.initGrammars)();
|
|
146
|
-
const resolvedRoot = path.resolve(projectRoot);
|
|
147
|
-
// Check if already initialized
|
|
148
|
-
if ((0, directory_1.isInitialized)(resolvedRoot)) {
|
|
149
|
-
throw new Error(`CodeGraph already initialized in ${resolvedRoot}`);
|
|
150
|
-
}
|
|
151
|
-
// Create directory structure
|
|
152
|
-
(0, directory_1.createDirectory)(resolvedRoot);
|
|
153
|
-
// Create and save configuration
|
|
154
|
-
const config = (0, config_1.createDefaultConfig)(resolvedRoot);
|
|
155
|
-
if (options.config) {
|
|
156
|
-
Object.assign(config, options.config);
|
|
157
|
-
}
|
|
158
|
-
(0, config_1.saveConfig)(resolvedRoot, config);
|
|
159
|
-
// Initialize database
|
|
160
|
-
const dbPath = (0, db_1.getDatabasePath)(resolvedRoot);
|
|
161
|
-
const db = db_1.DatabaseConnection.initialize(dbPath);
|
|
162
|
-
const queries = new queries_1.QueryBuilder(db.getDb());
|
|
163
|
-
const instance = new CodeGraph(db, queries, config, resolvedRoot);
|
|
164
|
-
// Run initial indexing if requested
|
|
165
|
-
if (options.index) {
|
|
166
|
-
await instance.indexAll({ onProgress: options.onProgress });
|
|
167
|
-
}
|
|
168
|
-
return instance;
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* Initialize synchronously (without indexing)
|
|
172
|
-
*/
|
|
173
|
-
static initSync(projectRoot, options = {}) {
|
|
174
|
-
const resolvedRoot = path.resolve(projectRoot);
|
|
175
|
-
// Check if already initialized
|
|
176
|
-
if ((0, directory_1.isInitialized)(resolvedRoot)) {
|
|
177
|
-
throw new Error(`CodeGraph already initialized in ${resolvedRoot}`);
|
|
178
|
-
}
|
|
179
|
-
// Create directory structure
|
|
180
|
-
(0, directory_1.createDirectory)(resolvedRoot);
|
|
181
|
-
// Create and save configuration
|
|
182
|
-
const config = (0, config_1.createDefaultConfig)(resolvedRoot);
|
|
183
|
-
if (options.config) {
|
|
184
|
-
Object.assign(config, options.config);
|
|
185
|
-
}
|
|
186
|
-
(0, config_1.saveConfig)(resolvedRoot, config);
|
|
187
|
-
// Initialize database
|
|
188
|
-
const dbPath = (0, db_1.getDatabasePath)(resolvedRoot);
|
|
189
|
-
const db = db_1.DatabaseConnection.initialize(dbPath);
|
|
190
|
-
const queries = new queries_1.QueryBuilder(db.getDb());
|
|
191
|
-
return new CodeGraph(db, queries, config, resolvedRoot);
|
|
192
|
-
}
|
|
193
|
-
/**
|
|
194
|
-
* Open an existing CodeGraph project
|
|
195
|
-
*
|
|
196
|
-
* @param projectRoot - Path to the project root directory
|
|
197
|
-
* @param options - Open options
|
|
198
|
-
* @returns A CodeGraph instance
|
|
199
|
-
*/
|
|
200
|
-
static async open(projectRoot, options = {}) {
|
|
201
|
-
await (0, extraction_1.initGrammars)();
|
|
202
|
-
const resolvedRoot = path.resolve(projectRoot);
|
|
203
|
-
// Check if initialized
|
|
204
|
-
if (!(0, directory_1.isInitialized)(resolvedRoot)) {
|
|
205
|
-
throw new Error(`CodeGraph not initialized in ${resolvedRoot}. Run init() first.`);
|
|
206
|
-
}
|
|
207
|
-
// Validate directory structure
|
|
208
|
-
const validation = (0, directory_1.validateDirectory)(resolvedRoot);
|
|
209
|
-
if (!validation.valid) {
|
|
210
|
-
throw new Error(`Invalid CodeGraph directory: ${validation.errors.join(', ')}`);
|
|
211
|
-
}
|
|
212
|
-
// Load configuration
|
|
213
|
-
const config = (0, config_1.loadConfig)(resolvedRoot);
|
|
214
|
-
// Open database
|
|
215
|
-
const dbPath = (0, db_1.getDatabasePath)(resolvedRoot);
|
|
216
|
-
const db = db_1.DatabaseConnection.open(dbPath);
|
|
217
|
-
const queries = new queries_1.QueryBuilder(db.getDb());
|
|
218
|
-
const instance = new CodeGraph(db, queries, config, resolvedRoot);
|
|
219
|
-
// Sync if requested
|
|
220
|
-
if (options.sync) {
|
|
221
|
-
await instance.sync();
|
|
222
|
-
}
|
|
223
|
-
return instance;
|
|
224
|
-
}
|
|
225
|
-
/**
|
|
226
|
-
* Open synchronously (without sync)
|
|
227
|
-
*/
|
|
228
|
-
static openSync(projectRoot) {
|
|
229
|
-
const resolvedRoot = path.resolve(projectRoot);
|
|
230
|
-
// Check if initialized
|
|
231
|
-
if (!(0, directory_1.isInitialized)(resolvedRoot)) {
|
|
232
|
-
throw new Error(`CodeGraph not initialized in ${resolvedRoot}. Run init() first.`);
|
|
233
|
-
}
|
|
234
|
-
// Validate directory structure
|
|
235
|
-
const validation = (0, directory_1.validateDirectory)(resolvedRoot);
|
|
236
|
-
if (!validation.valid) {
|
|
237
|
-
throw new Error(`Invalid CodeGraph directory: ${validation.errors.join(', ')}`);
|
|
238
|
-
}
|
|
239
|
-
// Load configuration
|
|
240
|
-
const config = (0, config_1.loadConfig)(resolvedRoot);
|
|
241
|
-
// Open database
|
|
242
|
-
const dbPath = (0, db_1.getDatabasePath)(resolvedRoot);
|
|
243
|
-
const db = db_1.DatabaseConnection.open(dbPath);
|
|
244
|
-
const queries = new queries_1.QueryBuilder(db.getDb());
|
|
245
|
-
return new CodeGraph(db, queries, config, resolvedRoot);
|
|
246
|
-
}
|
|
247
|
-
/**
|
|
248
|
-
* Check if a directory has been initialized as a CodeGraph project
|
|
249
|
-
*/
|
|
250
|
-
static isInitialized(projectRoot) {
|
|
251
|
-
return (0, directory_1.isInitialized)(path.resolve(projectRoot));
|
|
252
|
-
}
|
|
253
|
-
/**
|
|
254
|
-
* Close the CodeGraph instance and release resources
|
|
255
|
-
*/
|
|
256
|
-
close() {
|
|
257
|
-
this.unwatch();
|
|
258
|
-
// Release file lock if held
|
|
259
|
-
this.fileLock.release();
|
|
260
|
-
this.db.close();
|
|
261
|
-
}
|
|
262
|
-
// ===========================================================================
|
|
263
|
-
// Configuration
|
|
264
|
-
// ===========================================================================
|
|
265
|
-
/**
|
|
266
|
-
* Get the current configuration
|
|
267
|
-
*/
|
|
268
|
-
getConfig() {
|
|
269
|
-
return { ...this.config };
|
|
270
|
-
}
|
|
271
|
-
/**
|
|
272
|
-
* Update configuration
|
|
273
|
-
*/
|
|
274
|
-
updateConfig(updates) {
|
|
275
|
-
Object.assign(this.config, updates);
|
|
276
|
-
(0, config_1.saveConfig)(this.projectRoot, this.config);
|
|
277
|
-
// Recreate orchestrator and resolver with new config
|
|
278
|
-
this.orchestrator = new extraction_1.ExtractionOrchestrator(this.projectRoot, this.config, this.queries);
|
|
279
|
-
this.resolver = (0, resolution_1.createResolver)(this.projectRoot, this.queries);
|
|
280
|
-
}
|
|
281
|
-
/**
|
|
282
|
-
* Get the project root directory
|
|
283
|
-
*/
|
|
284
|
-
getProjectRoot() {
|
|
285
|
-
return this.projectRoot;
|
|
286
|
-
}
|
|
287
|
-
// ===========================================================================
|
|
288
|
-
// Indexing
|
|
289
|
-
// ===========================================================================
|
|
290
|
-
/**
|
|
291
|
-
* Index all files in the project
|
|
292
|
-
*
|
|
293
|
-
* Uses a mutex to prevent concurrent indexing operations.
|
|
294
|
-
*/
|
|
295
|
-
async indexAll(options = {}) {
|
|
296
|
-
return this.indexMutex.withLock(async () => {
|
|
297
|
-
try {
|
|
298
|
-
this.fileLock.acquire();
|
|
299
|
-
}
|
|
300
|
-
catch {
|
|
301
|
-
return { success: false, filesIndexed: 0, filesSkipped: 0, filesErrored: 0, nodesCreated: 0, edgesCreated: 0, errors: [{ message: 'Could not acquire file lock - another process may be indexing', severity: 'error' }], durationMs: 0 };
|
|
302
|
-
}
|
|
303
|
-
try {
|
|
304
|
-
const result = await this.orchestrator.indexAll(options.onProgress, options.signal, options.verbose);
|
|
305
|
-
// Resolve references to create call/import/extends edges
|
|
306
|
-
if (result.success && result.filesIndexed > 0) {
|
|
307
|
-
// Get count without loading all refs into memory
|
|
308
|
-
const unresolvedCount = this.queries.getUnresolvedReferencesCount();
|
|
309
|
-
options.onProgress?.({
|
|
310
|
-
phase: 'resolving',
|
|
311
|
-
current: 0,
|
|
312
|
-
total: unresolvedCount,
|
|
313
|
-
});
|
|
314
|
-
await this.resolveReferencesBatched((current, total) => {
|
|
315
|
-
options.onProgress?.({
|
|
316
|
-
phase: 'resolving',
|
|
317
|
-
current,
|
|
318
|
-
total,
|
|
319
|
-
});
|
|
320
|
-
});
|
|
321
|
-
}
|
|
322
|
-
return result;
|
|
323
|
-
}
|
|
324
|
-
finally {
|
|
325
|
-
this.fileLock.release();
|
|
326
|
-
}
|
|
327
|
-
});
|
|
328
|
-
}
|
|
329
|
-
/**
|
|
330
|
-
* Index specific files
|
|
331
|
-
*
|
|
332
|
-
* Uses a mutex to prevent concurrent indexing operations.
|
|
333
|
-
*/
|
|
334
|
-
async indexFiles(filePaths) {
|
|
335
|
-
return this.indexMutex.withLock(async () => {
|
|
336
|
-
try {
|
|
337
|
-
this.fileLock.acquire();
|
|
338
|
-
}
|
|
339
|
-
catch {
|
|
340
|
-
return { success: false, filesIndexed: 0, filesSkipped: 0, filesErrored: 0, nodesCreated: 0, edgesCreated: 0, errors: [{ message: 'Could not acquire file lock - another process may be indexing', severity: 'error' }], durationMs: 0 };
|
|
341
|
-
}
|
|
342
|
-
try {
|
|
343
|
-
return this.orchestrator.indexFiles(filePaths);
|
|
344
|
-
}
|
|
345
|
-
finally {
|
|
346
|
-
this.fileLock.release();
|
|
347
|
-
}
|
|
348
|
-
});
|
|
349
|
-
}
|
|
350
|
-
/**
|
|
351
|
-
* Sync with current file state (incremental update)
|
|
352
|
-
*
|
|
353
|
-
* Uses a mutex to prevent concurrent indexing operations.
|
|
354
|
-
*/
|
|
355
|
-
async sync(options = {}) {
|
|
356
|
-
return this.indexMutex.withLock(async () => {
|
|
357
|
-
try {
|
|
358
|
-
this.fileLock.acquire();
|
|
359
|
-
}
|
|
360
|
-
catch {
|
|
361
|
-
return { filesChecked: 0, filesAdded: 0, filesModified: 0, filesRemoved: 0, nodesUpdated: 0, durationMs: 0 };
|
|
362
|
-
}
|
|
363
|
-
try {
|
|
364
|
-
const result = await this.orchestrator.sync(options.onProgress);
|
|
365
|
-
// Resolve references if files were updated
|
|
366
|
-
if (result.filesAdded > 0 || result.filesModified > 0) {
|
|
367
|
-
if (result.changedFilePaths) {
|
|
368
|
-
// Scope resolution to changed files (git fast path — bounded set)
|
|
369
|
-
const unresolvedRefs = this.queries.getUnresolvedReferencesByFiles(result.changedFilePaths);
|
|
370
|
-
options.onProgress?.({
|
|
371
|
-
phase: 'resolving',
|
|
372
|
-
current: 0,
|
|
373
|
-
total: unresolvedRefs.length,
|
|
374
|
-
});
|
|
375
|
-
this.resolver.resolveAndPersist(unresolvedRefs, (current, total) => {
|
|
376
|
-
options.onProgress?.({
|
|
377
|
-
phase: 'resolving',
|
|
378
|
-
current,
|
|
379
|
-
total,
|
|
380
|
-
});
|
|
381
|
-
});
|
|
382
|
-
}
|
|
383
|
-
else {
|
|
384
|
-
// No git info — use batched resolution to avoid OOM
|
|
385
|
-
const unresolvedCount = this.queries.getUnresolvedReferencesCount();
|
|
386
|
-
options.onProgress?.({
|
|
387
|
-
phase: 'resolving',
|
|
388
|
-
current: 0,
|
|
389
|
-
total: unresolvedCount,
|
|
390
|
-
});
|
|
391
|
-
await this.resolveReferencesBatched((current, total) => {
|
|
392
|
-
options.onProgress?.({
|
|
393
|
-
phase: 'resolving',
|
|
394
|
-
current,
|
|
395
|
-
total,
|
|
396
|
-
});
|
|
397
|
-
});
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
return result;
|
|
401
|
-
}
|
|
402
|
-
finally {
|
|
403
|
-
this.fileLock.release();
|
|
404
|
-
}
|
|
405
|
-
});
|
|
406
|
-
}
|
|
407
|
-
/**
|
|
408
|
-
* Check if an indexing operation is currently in progress
|
|
409
|
-
*/
|
|
410
|
-
isIndexing() {
|
|
411
|
-
return this.indexMutex.isLocked();
|
|
412
|
-
}
|
|
413
|
-
// ===========================================================================
|
|
414
|
-
// File Watching
|
|
415
|
-
// ===========================================================================
|
|
416
|
-
/**
|
|
417
|
-
* Start watching for file changes and auto-syncing.
|
|
418
|
-
*
|
|
419
|
-
* Uses native OS file events (FSEvents on macOS, inotify on Linux 19+,
|
|
420
|
-
* ReadDirectoryChangesW on Windows) with debouncing to avoid thrashing.
|
|
421
|
-
*
|
|
422
|
-
* @param options - Watch options (debounce delay, callbacks)
|
|
423
|
-
* @returns true if watching started successfully
|
|
424
|
-
*/
|
|
425
|
-
watch(options = {}) {
|
|
426
|
-
if (this.watcher?.isActive())
|
|
427
|
-
return true;
|
|
428
|
-
this.watcher = new sync_1.FileWatcher(this.projectRoot, this.config, async () => {
|
|
429
|
-
const result = await this.sync();
|
|
430
|
-
const filesChanged = result.filesAdded + result.filesModified + result.filesRemoved;
|
|
431
|
-
return { filesChanged, durationMs: result.durationMs };
|
|
432
|
-
}, options);
|
|
433
|
-
return this.watcher.start();
|
|
434
|
-
}
|
|
435
|
-
/**
|
|
436
|
-
* Stop watching for file changes.
|
|
437
|
-
*/
|
|
438
|
-
unwatch() {
|
|
439
|
-
if (this.watcher) {
|
|
440
|
-
this.watcher.stop();
|
|
441
|
-
this.watcher = null;
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
/**
|
|
445
|
-
* Check if the file watcher is active.
|
|
446
|
-
*/
|
|
447
|
-
isWatching() {
|
|
448
|
-
return this.watcher?.isActive() ?? false;
|
|
449
|
-
}
|
|
450
|
-
/**
|
|
451
|
-
* Get files that have changed since last index
|
|
452
|
-
*/
|
|
453
|
-
getChangedFiles() {
|
|
454
|
-
return this.orchestrator.getChangedFiles();
|
|
455
|
-
}
|
|
456
|
-
/**
|
|
457
|
-
* Extract nodes and edges from source code (without storing)
|
|
458
|
-
*/
|
|
459
|
-
extractFromSource(filePath, source) {
|
|
460
|
-
return (0, extraction_1.extractFromSource)(filePath, source);
|
|
461
|
-
}
|
|
462
|
-
// ===========================================================================
|
|
463
|
-
// Reference Resolution
|
|
464
|
-
// ===========================================================================
|
|
465
|
-
/**
|
|
466
|
-
* Resolve unresolved references and create edges
|
|
467
|
-
*
|
|
468
|
-
* This method takes unresolved references from extraction and attempts
|
|
469
|
-
* to resolve them using multiple strategies:
|
|
470
|
-
* - Framework-specific patterns (React, Express, Laravel)
|
|
471
|
-
* - Import-based resolution
|
|
472
|
-
* - Name-based symbol matching
|
|
473
|
-
*/
|
|
474
|
-
resolveReferences(onProgress) {
|
|
475
|
-
// Get all unresolved references from the database
|
|
476
|
-
const unresolvedRefs = this.queries.getUnresolvedReferences();
|
|
477
|
-
return this.resolver.resolveAndPersist(unresolvedRefs, onProgress);
|
|
478
|
-
}
|
|
479
|
-
/**
|
|
480
|
-
* Resolve references in batches to keep memory bounded on large codebases.
|
|
481
|
-
* Processes chunks of unresolved refs, persisting results after each batch.
|
|
482
|
-
*/
|
|
483
|
-
async resolveReferencesBatched(onProgress) {
|
|
484
|
-
return this.resolver.resolveAndPersistBatched(onProgress);
|
|
485
|
-
}
|
|
486
|
-
/**
|
|
487
|
-
* Get detected frameworks in the project
|
|
488
|
-
*/
|
|
489
|
-
getDetectedFrameworks() {
|
|
490
|
-
return this.resolver.getDetectedFrameworks();
|
|
491
|
-
}
|
|
492
|
-
/**
|
|
493
|
-
* Re-initialize the resolver (useful after adding new files)
|
|
494
|
-
*/
|
|
495
|
-
reinitializeResolver() {
|
|
496
|
-
this.resolver.initialize();
|
|
497
|
-
}
|
|
498
|
-
// ===========================================================================
|
|
499
|
-
// Graph Statistics
|
|
500
|
-
// ===========================================================================
|
|
501
|
-
/**
|
|
502
|
-
* Get statistics about the knowledge graph
|
|
503
|
-
*/
|
|
504
|
-
getStats() {
|
|
505
|
-
const stats = this.queries.getStats();
|
|
506
|
-
stats.dbSizeBytes = this.db.getSize();
|
|
507
|
-
return stats;
|
|
508
|
-
}
|
|
509
|
-
/**
|
|
510
|
-
* Active SQLite backend for this project's connection. `wasm` means
|
|
511
|
-
* the native better-sqlite3 install failed and the WASM fallback is
|
|
512
|
-
* serving requests at 5-10x the latency. Surfaced via `codegraph
|
|
513
|
-
* status` and the `codegraph_status` MCP tool.
|
|
514
|
-
*/
|
|
515
|
-
getBackend() {
|
|
516
|
-
return this.db.getBackend();
|
|
517
|
-
}
|
|
518
|
-
// ===========================================================================
|
|
519
|
-
// Node Operations
|
|
520
|
-
// ===========================================================================
|
|
521
|
-
/**
|
|
522
|
-
* Get a node by ID
|
|
523
|
-
*/
|
|
524
|
-
getNode(id) {
|
|
525
|
-
return this.queries.getNodeById(id);
|
|
526
|
-
}
|
|
527
|
-
/**
|
|
528
|
-
* Get all nodes in a file
|
|
529
|
-
*/
|
|
530
|
-
getNodesInFile(filePath) {
|
|
531
|
-
return this.queries.getNodesByFile(filePath);
|
|
532
|
-
}
|
|
533
|
-
/**
|
|
534
|
-
* Get all nodes of a specific kind
|
|
535
|
-
*/
|
|
536
|
-
getNodesByKind(kind) {
|
|
537
|
-
return this.queries.getNodesByKind(kind);
|
|
538
|
-
}
|
|
539
|
-
/**
|
|
540
|
-
* Search nodes by text
|
|
541
|
-
*/
|
|
542
|
-
searchNodes(query, options) {
|
|
543
|
-
return this.queries.searchNodes(query, options);
|
|
544
|
-
}
|
|
545
|
-
// ===========================================================================
|
|
546
|
-
// Edge Operations
|
|
547
|
-
// ===========================================================================
|
|
548
|
-
/**
|
|
549
|
-
* Get outgoing edges from a node
|
|
550
|
-
*/
|
|
551
|
-
getOutgoingEdges(nodeId) {
|
|
552
|
-
return this.queries.getOutgoingEdges(nodeId);
|
|
553
|
-
}
|
|
554
|
-
/**
|
|
555
|
-
* Get incoming edges to a node
|
|
556
|
-
*/
|
|
557
|
-
getIncomingEdges(nodeId) {
|
|
558
|
-
return this.queries.getIncomingEdges(nodeId);
|
|
559
|
-
}
|
|
560
|
-
// ===========================================================================
|
|
561
|
-
// File Operations
|
|
562
|
-
// ===========================================================================
|
|
563
|
-
/**
|
|
564
|
-
* Get a file record by path
|
|
565
|
-
*/
|
|
566
|
-
getFile(filePath) {
|
|
567
|
-
return this.queries.getFileByPath(filePath);
|
|
568
|
-
}
|
|
569
|
-
/**
|
|
570
|
-
* Get all tracked files
|
|
571
|
-
*/
|
|
572
|
-
getFiles() {
|
|
573
|
-
return this.queries.getAllFiles();
|
|
574
|
-
}
|
|
575
|
-
// ===========================================================================
|
|
576
|
-
// Graph Query Methods
|
|
577
|
-
// ===========================================================================
|
|
578
|
-
/**
|
|
579
|
-
* Get the context for a node (ancestors, children, references)
|
|
580
|
-
*
|
|
581
|
-
* Returns comprehensive context about a node including its containment
|
|
582
|
-
* hierarchy, children, incoming/outgoing references, type information,
|
|
583
|
-
* and relevant imports.
|
|
584
|
-
*
|
|
585
|
-
* @param nodeId - ID of the focal node
|
|
586
|
-
* @returns Context object with all related information
|
|
587
|
-
*/
|
|
588
|
-
getContext(nodeId) {
|
|
589
|
-
return this.graphManager.getContext(nodeId);
|
|
590
|
-
}
|
|
591
|
-
/**
|
|
592
|
-
* Traverse the graph from a starting node
|
|
593
|
-
*
|
|
594
|
-
* Uses breadth-first search by default. Supports filtering by edge types,
|
|
595
|
-
* node types, and traversal direction.
|
|
596
|
-
*
|
|
597
|
-
* @param startId - Starting node ID
|
|
598
|
-
* @param options - Traversal options
|
|
599
|
-
* @returns Subgraph containing traversed nodes and edges
|
|
600
|
-
*/
|
|
601
|
-
traverse(startId, options) {
|
|
602
|
-
return this.traverser.traverseBFS(startId, options);
|
|
603
|
-
}
|
|
604
|
-
/**
|
|
605
|
-
* Get the call graph for a function
|
|
606
|
-
*
|
|
607
|
-
* Returns both callers (functions that call this function) and
|
|
608
|
-
* callees (functions called by this function) up to the specified depth.
|
|
609
|
-
*
|
|
610
|
-
* @param nodeId - ID of the function/method node
|
|
611
|
-
* @param depth - Maximum depth in each direction (default: 2)
|
|
612
|
-
* @returns Subgraph containing the call graph
|
|
613
|
-
*/
|
|
614
|
-
getCallGraph(nodeId, depth = 2) {
|
|
615
|
-
return this.traverser.getCallGraph(nodeId, depth);
|
|
616
|
-
}
|
|
617
|
-
/**
|
|
618
|
-
* Get the type hierarchy for a class/interface
|
|
619
|
-
*
|
|
620
|
-
* Returns both ancestors (types this extends/implements) and
|
|
621
|
-
* descendants (types that extend/implement this).
|
|
622
|
-
*
|
|
623
|
-
* @param nodeId - ID of the class/interface node
|
|
624
|
-
* @returns Subgraph containing the type hierarchy
|
|
625
|
-
*/
|
|
626
|
-
getTypeHierarchy(nodeId) {
|
|
627
|
-
return this.traverser.getTypeHierarchy(nodeId);
|
|
628
|
-
}
|
|
629
|
-
/**
|
|
630
|
-
* Find all usages of a symbol
|
|
631
|
-
*
|
|
632
|
-
* Returns all nodes that reference the specified symbol through
|
|
633
|
-
* any edge type (calls, references, type_of, etc.).
|
|
634
|
-
*
|
|
635
|
-
* @param nodeId - ID of the symbol node
|
|
636
|
-
* @returns Array of nodes and edges that reference this symbol
|
|
637
|
-
*/
|
|
638
|
-
findUsages(nodeId) {
|
|
639
|
-
return this.traverser.findUsages(nodeId);
|
|
640
|
-
}
|
|
641
|
-
/**
|
|
642
|
-
* Get callers of a function/method
|
|
643
|
-
*
|
|
644
|
-
* @param nodeId - ID of the function/method node
|
|
645
|
-
* @param maxDepth - Maximum depth to traverse (default: 1)
|
|
646
|
-
* @returns Array of nodes that call this function
|
|
647
|
-
*/
|
|
648
|
-
getCallers(nodeId, maxDepth = 1) {
|
|
649
|
-
return this.traverser.getCallers(nodeId, maxDepth);
|
|
650
|
-
}
|
|
651
|
-
/**
|
|
652
|
-
* Get callees of a function/method
|
|
653
|
-
*
|
|
654
|
-
* @param nodeId - ID of the function/method node
|
|
655
|
-
* @param maxDepth - Maximum depth to traverse (default: 1)
|
|
656
|
-
* @returns Array of nodes called by this function
|
|
657
|
-
*/
|
|
658
|
-
getCallees(nodeId, maxDepth = 1) {
|
|
659
|
-
return this.traverser.getCallees(nodeId, maxDepth);
|
|
660
|
-
}
|
|
661
|
-
/**
|
|
662
|
-
* Calculate the impact radius of a node
|
|
663
|
-
*
|
|
664
|
-
* Returns all nodes that could be affected by changes to this node.
|
|
665
|
-
*
|
|
666
|
-
* @param nodeId - ID of the node
|
|
667
|
-
* @param maxDepth - Maximum depth to traverse (default: 3)
|
|
668
|
-
* @returns Subgraph containing potentially impacted nodes
|
|
669
|
-
*/
|
|
670
|
-
getImpactRadius(nodeId, maxDepth = 3) {
|
|
671
|
-
return this.traverser.getImpactRadius(nodeId, maxDepth);
|
|
672
|
-
}
|
|
673
|
-
/**
|
|
674
|
-
* Find the shortest path between two nodes
|
|
675
|
-
*
|
|
676
|
-
* @param fromId - Starting node ID
|
|
677
|
-
* @param toId - Target node ID
|
|
678
|
-
* @param edgeKinds - Edge types to consider (all if empty)
|
|
679
|
-
* @returns Array of nodes and edges forming the path, or null if no path exists
|
|
680
|
-
*/
|
|
681
|
-
findPath(fromId, toId, edgeKinds) {
|
|
682
|
-
return this.traverser.findPath(fromId, toId, edgeKinds);
|
|
683
|
-
}
|
|
684
|
-
/**
|
|
685
|
-
* Get ancestors of a node in the containment hierarchy
|
|
686
|
-
*
|
|
687
|
-
* @param nodeId - ID of the node
|
|
688
|
-
* @returns Array of ancestor nodes from immediate parent to root
|
|
689
|
-
*/
|
|
690
|
-
getAncestors(nodeId) {
|
|
691
|
-
return this.traverser.getAncestors(nodeId);
|
|
692
|
-
}
|
|
693
|
-
/**
|
|
694
|
-
* Get immediate children of a node
|
|
695
|
-
*
|
|
696
|
-
* @param nodeId - ID of the node
|
|
697
|
-
* @returns Array of child nodes
|
|
698
|
-
*/
|
|
699
|
-
getChildren(nodeId) {
|
|
700
|
-
return this.traverser.getChildren(nodeId);
|
|
701
|
-
}
|
|
702
|
-
/**
|
|
703
|
-
* Get dependencies of a file
|
|
704
|
-
*
|
|
705
|
-
* @param filePath - Path to the file
|
|
706
|
-
* @returns Array of file paths this file depends on
|
|
707
|
-
*/
|
|
708
|
-
getFileDependencies(filePath) {
|
|
709
|
-
return this.graphManager.getFileDependencies(filePath);
|
|
710
|
-
}
|
|
711
|
-
/**
|
|
712
|
-
* Get dependents of a file
|
|
713
|
-
*
|
|
714
|
-
* @param filePath - Path to the file
|
|
715
|
-
* @returns Array of file paths that depend on this file
|
|
716
|
-
*/
|
|
717
|
-
getFileDependents(filePath) {
|
|
718
|
-
return this.graphManager.getFileDependents(filePath);
|
|
719
|
-
}
|
|
720
|
-
/**
|
|
721
|
-
* Find circular dependencies in the codebase
|
|
722
|
-
*
|
|
723
|
-
* @returns Array of cycles, each cycle is an array of file paths
|
|
724
|
-
*/
|
|
725
|
-
findCircularDependencies() {
|
|
726
|
-
return this.graphManager.findCircularDependencies();
|
|
727
|
-
}
|
|
728
|
-
/**
|
|
729
|
-
* Find dead code (unreferenced symbols)
|
|
730
|
-
*
|
|
731
|
-
* @param kinds - Node kinds to check (default: functions, methods, classes)
|
|
732
|
-
* @returns Array of unreferenced nodes
|
|
733
|
-
*/
|
|
734
|
-
findDeadCode(kinds) {
|
|
735
|
-
return this.graphManager.findDeadCode(kinds);
|
|
736
|
-
}
|
|
737
|
-
/**
|
|
738
|
-
* Get complexity metrics for a node
|
|
739
|
-
*
|
|
740
|
-
* @param nodeId - ID of the node
|
|
741
|
-
* @returns Object containing various complexity metrics
|
|
742
|
-
*/
|
|
743
|
-
getNodeMetrics(nodeId) {
|
|
744
|
-
return this.graphManager.getNodeMetrics(nodeId);
|
|
745
|
-
}
|
|
746
|
-
// ===========================================================================
|
|
747
|
-
// Context Building
|
|
748
|
-
// ===========================================================================
|
|
749
|
-
/**
|
|
750
|
-
* Get the source code for a node
|
|
751
|
-
*
|
|
752
|
-
* Reads the file and extracts the code between startLine and endLine.
|
|
753
|
-
*
|
|
754
|
-
* @param nodeId - ID of the node
|
|
755
|
-
* @returns Code string or null if not found
|
|
756
|
-
*/
|
|
757
|
-
async getCode(nodeId) {
|
|
758
|
-
return this.contextBuilder.getCode(nodeId);
|
|
759
|
-
}
|
|
760
|
-
/**
|
|
761
|
-
* Find relevant subgraph for a query
|
|
762
|
-
*
|
|
763
|
-
* Combines semantic search with graph traversal to find the most
|
|
764
|
-
* relevant nodes and their relationships for a given query.
|
|
765
|
-
*
|
|
766
|
-
* @param query - Natural language query describing the task
|
|
767
|
-
* @param options - Search and traversal options
|
|
768
|
-
* @returns Subgraph of relevant nodes and edges
|
|
769
|
-
*/
|
|
770
|
-
async findRelevantContext(query, options) {
|
|
771
|
-
return this.contextBuilder.findRelevantContext(query, options);
|
|
772
|
-
}
|
|
773
|
-
/**
|
|
774
|
-
* Build context for a task
|
|
775
|
-
*
|
|
776
|
-
* Creates comprehensive context by:
|
|
777
|
-
* 1. Running FTS search to find entry points
|
|
778
|
-
* 2. Expanding the graph around entry points
|
|
779
|
-
* 3. Extracting code blocks for key nodes
|
|
780
|
-
* 4. Formatting output for Claude
|
|
781
|
-
*
|
|
782
|
-
* @param input - Task description (string or {title, description})
|
|
783
|
-
* @param options - Build options (maxNodes, includeCode, format, etc.)
|
|
784
|
-
* @returns TaskContext object or formatted string (markdown/JSON)
|
|
785
|
-
*/
|
|
786
|
-
async buildContext(input, options) {
|
|
787
|
-
return this.contextBuilder.buildContext(input, options);
|
|
788
|
-
}
|
|
789
|
-
// ===========================================================================
|
|
790
|
-
// Database Management
|
|
791
|
-
// ===========================================================================
|
|
792
|
-
/**
|
|
793
|
-
* Optimize the database (vacuum and analyze)
|
|
794
|
-
*/
|
|
795
|
-
optimize() {
|
|
796
|
-
this.db.optimize();
|
|
797
|
-
}
|
|
798
|
-
/**
|
|
799
|
-
* Clear all data from the graph
|
|
800
|
-
*/
|
|
801
|
-
clear() {
|
|
802
|
-
this.queries.clear();
|
|
803
|
-
}
|
|
804
|
-
/**
|
|
805
|
-
* Alias for close() for backwards compatibility.
|
|
806
|
-
* @deprecated Use close() instead
|
|
807
|
-
*/
|
|
808
|
-
destroy() {
|
|
809
|
-
this.close();
|
|
810
|
-
}
|
|
811
|
-
/**
|
|
812
|
-
* Completely remove CodeGraph from the project.
|
|
813
|
-
* This closes the database and deletes the .CodeGraph directory.
|
|
814
|
-
*
|
|
815
|
-
* WARNING: This permanently deletes all CodeGraph data for the project.
|
|
816
|
-
*/
|
|
817
|
-
uninitialize() {
|
|
818
|
-
this.close();
|
|
819
|
-
(0, directory_1.removeDirectory)(this.projectRoot);
|
|
820
|
-
}
|
|
821
|
-
}
|
|
822
|
-
exports.CodeGraph = CodeGraph;
|
|
823
|
-
// Default export
|
|
824
|
-
exports.default = CodeGraph;
|
|
825
|
-
//# sourceMappingURL=index.js.map
|