@saluzi/codegraph 0.1.0 → 0.2.0
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 +885 -0
- package/package.json +42 -10
- package/scripts/add-lang/bench.sh +60 -0
- package/scripts/add-lang/check-grammar.mjs +75 -0
- package/scripts/add-lang/dump-ast.mjs +103 -0
- package/scripts/add-lang/verify-extraction.mjs +70 -0
- package/scripts/agent-eval/ab-adoption.sh +91 -0
- package/scripts/agent-eval/ab-hook.sh +86 -0
- package/scripts/agent-eval/ab-impl.sh +78 -0
- package/scripts/agent-eval/ab-new-vs-baseline.sh +102 -0
- package/scripts/agent-eval/ab-sufficiency.sh +78 -0
- package/scripts/agent-eval/arms-F.sh +21 -0
- package/scripts/agent-eval/arms-matrix.sh +37 -0
- package/scripts/agent-eval/audit.sh +68 -0
- package/scripts/agent-eval/bench-readme.sh +28 -0
- package/scripts/agent-eval/bench-why-repo.sh +22 -0
- package/scripts/agent-eval/block-read-hook.sh +19 -0
- package/scripts/agent-eval/hook-settings.json +15 -0
- package/scripts/agent-eval/itrun.sh +120 -0
- package/scripts/agent-eval/offload-eval-3arm.sh +72 -0
- package/scripts/agent-eval/offload-eval-cost.mjs +133 -0
- package/scripts/agent-eval/offload-eval-effort.mjs +108 -0
- package/scripts/agent-eval/offload-eval-frontload-matrix.sh +25 -0
- package/scripts/agent-eval/offload-eval-frontload.sh +47 -0
- package/scripts/agent-eval/offload-eval-ground-truth.json +18 -0
- package/scripts/agent-eval/offload-eval-hook.mjs +84 -0
- package/scripts/agent-eval/offload-eval-judge.mjs +103 -0
- package/scripts/agent-eval/offload-eval-matrix.sh +20 -0
- package/scripts/agent-eval/offload-eval-metrics.mjs +94 -0
- package/scripts/agent-eval/offload-eval-refs1.sh +50 -0
- package/scripts/agent-eval/offload-eval-setup.sh +24 -0
- package/scripts/agent-eval/offload-eval-styles.sh +72 -0
- package/scripts/agent-eval/offload-eval-summarize.mjs +68 -0
- package/scripts/agent-eval/offload-eval.md +76 -0
- package/scripts/agent-eval/parse-arms.mjs +116 -0
- package/scripts/agent-eval/parse-bench-readme.mjs +84 -0
- package/scripts/agent-eval/parse-run.mjs +45 -0
- package/scripts/agent-eval/parse-session.mjs +93 -0
- package/scripts/agent-eval/probe-context.mjs +21 -0
- package/scripts/agent-eval/probe-explore.mjs +40 -0
- package/scripts/agent-eval/probe-node.mjs +20 -0
- package/scripts/agent-eval/probe-sweep.mjs +119 -0
- package/scripts/agent-eval/probe-trace.mjs +20 -0
- package/scripts/agent-eval/redirect-read-hook.sh +38 -0
- package/scripts/agent-eval/repro-concurrent-explore.mjs +119 -0
- package/scripts/agent-eval/repro-daemon-clients.mjs +125 -0
- package/scripts/agent-eval/run-agent.sh +34 -0
- package/scripts/agent-eval/run-all.sh +75 -0
- package/scripts/agent-eval/run-arms.sh +56 -0
- package/scripts/agent-eval/seq-matrix.mjs +137 -0
- package/scripts/build-bundle.sh +123 -0
- package/scripts/extract-release-notes.mjs +130 -0
- package/scripts/local-install.sh +41 -0
- package/scripts/npm-sdk.js +75 -0
- package/scripts/npm-shim.js +275 -0
- package/scripts/pack-npm.sh +119 -0
- package/scripts/prepare-release.mjs +270 -0
- package/dist/bin/codegraph.d.ts +0 -25
- package/dist/bin/node-version-check.d.ts +0 -37
- package/dist/bin/uninstall.d.ts +0 -14
- package/dist/context/formatter.d.ts +0 -33
- package/dist/context/formatter.js +0 -244
- package/dist/context/index.d.ts +0 -117
- package/dist/context/index.js +0 -1050
- package/dist/db/index.d.ts +0 -101
- package/dist/db/index.js +0 -250
- package/dist/db/migrations.d.ts +0 -47
- package/dist/db/migrations.js +0 -131
- package/dist/db/queries.d.ts +0 -291
- package/dist/db/queries.js +0 -1349
- package/dist/db/schema.sql +0 -151
- package/dist/db/sqlite-adapter.d.ts +0 -49
- package/dist/db/sqlite-adapter.js +0 -141
- package/dist/directory.d.ts +0 -62
- package/dist/directory.js +0 -264
- package/dist/errors.d.ts +0 -149
- package/dist/errors.js +0 -219
- package/dist/extraction/dfm-extractor.d.ts +0 -31
- package/dist/extraction/dfm-extractor.js +0 -151
- package/dist/extraction/grammars.d.ts +0 -94
- package/dist/extraction/grammars.js +0 -357
- package/dist/extraction/index.d.ts +0 -148
- package/dist/extraction/index.js +0 -1286
- package/dist/extraction/languages/c-cpp.d.ts +0 -4
- package/dist/extraction/languages/c-cpp.js +0 -126
- package/dist/extraction/languages/csharp.d.ts +0 -3
- package/dist/extraction/languages/csharp.js +0 -72
- package/dist/extraction/languages/dart.d.ts +0 -3
- package/dist/extraction/languages/dart.js +0 -192
- package/dist/extraction/languages/go.d.ts +0 -3
- package/dist/extraction/languages/go.js +0 -58
- package/dist/extraction/languages/index.d.ts +0 -10
- package/dist/extraction/languages/index.js +0 -49
- package/dist/extraction/languages/java.d.ts +0 -3
- package/dist/extraction/languages/java.js +0 -64
- package/dist/extraction/languages/javascript.d.ts +0 -3
- package/dist/extraction/languages/javascript.js +0 -90
- package/dist/extraction/languages/kotlin.d.ts +0 -3
- package/dist/extraction/languages/kotlin.js +0 -253
- package/dist/extraction/languages/lua.d.ts +0 -3
- package/dist/extraction/languages/lua.js +0 -150
- package/dist/extraction/languages/luau.d.ts +0 -3
- package/dist/extraction/languages/luau.js +0 -37
- package/dist/extraction/languages/pascal.d.ts +0 -3
- package/dist/extraction/languages/pascal.js +0 -66
- package/dist/extraction/languages/php.d.ts +0 -3
- package/dist/extraction/languages/php.js +0 -107
- package/dist/extraction/languages/python.d.ts +0 -3
- package/dist/extraction/languages/python.js +0 -56
- package/dist/extraction/languages/ruby.d.ts +0 -3
- package/dist/extraction/languages/ruby.js +0 -114
- package/dist/extraction/languages/rust.d.ts +0 -3
- package/dist/extraction/languages/rust.js +0 -109
- package/dist/extraction/languages/scala.d.ts +0 -3
- package/dist/extraction/languages/scala.js +0 -139
- package/dist/extraction/languages/swift.d.ts +0 -3
- package/dist/extraction/languages/swift.js +0 -91
- package/dist/extraction/languages/typescript.d.ts +0 -3
- package/dist/extraction/languages/typescript.js +0 -129
- package/dist/extraction/liquid-extractor.d.ts +0 -52
- package/dist/extraction/liquid-extractor.js +0 -313
- package/dist/extraction/parse-worker.d.ts +0 -8
- package/dist/extraction/parse-worker.js +0 -94
- package/dist/extraction/svelte-extractor.d.ts +0 -56
- package/dist/extraction/svelte-extractor.js +0 -272
- package/dist/extraction/tree-sitter-helpers.d.ts +0 -39
- package/dist/extraction/tree-sitter-helpers.js +0 -103
- package/dist/extraction/tree-sitter-types.d.ts +0 -191
- package/dist/extraction/tree-sitter-types.js +0 -10
- package/dist/extraction/tree-sitter.d.ts +0 -238
- package/dist/extraction/tree-sitter.js +0 -2430
- package/dist/extraction/vue-extractor.d.ts +0 -36
- package/dist/extraction/vue-extractor.js +0 -163
- package/dist/extraction/wasm/tree-sitter-c.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-c_sharp.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-cpp.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-dart.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-go.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-java.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-javascript.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-kotlin.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-lua.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-luau.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-pascal.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-php.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-python.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-ruby.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-rust.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-scala.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-swift.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-tsx.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-typescript.wasm +0 -0
- package/dist/extraction/wasm-runtime-flags.d.ts +0 -46
- package/dist/extraction/wasm-runtime-flags.js +0 -105
- package/dist/graph/index.d.ts +0 -8
- package/dist/graph/index.js +0 -13
- package/dist/graph/queries.d.ts +0 -109
- package/dist/graph/queries.js +0 -366
- package/dist/graph/traversal.d.ts +0 -137
- package/dist/graph/traversal.js +0 -528
- package/dist/index.d.ts +0 -509
- package/dist/index.js +0 -800
- package/dist/installer/claude-md-template.d.ts +0 -19
- package/dist/installer/config-writer.d.ts +0 -29
- package/dist/installer/index.d.ts +0 -140
- package/dist/installer/instructions-template.d.ts +0 -30
- package/dist/installer/targets/claude.d.ts +0 -55
- package/dist/installer/targets/codex.d.ts +0 -18
- package/dist/installer/targets/cursor.d.ts +0 -35
- package/dist/installer/targets/hermes.d.ts +0 -18
- package/dist/installer/targets/opencode.d.ts +0 -30
- package/dist/installer/targets/registry.d.ts +0 -38
- package/dist/installer/targets/shared.d.ts +0 -92
- package/dist/installer/targets/toml.d.ts +0 -64
- package/dist/installer/targets/types.d.ts +0 -122
- package/dist/mcp/index.d.ts +0 -98
- package/dist/mcp/server-instructions.d.ts +0 -20
- package/dist/mcp/tools.d.ts +0 -269
- package/dist/mcp/transport.d.ts +0 -117
- package/dist/resolution/frameworks/cargo-workspace.d.ts +0 -20
- package/dist/resolution/frameworks/cargo-workspace.js +0 -225
- package/dist/resolution/frameworks/csharp.d.ts +0 -8
- package/dist/resolution/frameworks/csharp.js +0 -213
- package/dist/resolution/frameworks/drupal.d.ts +0 -51
- package/dist/resolution/frameworks/drupal.js +0 -335
- package/dist/resolution/frameworks/express.d.ts +0 -8
- package/dist/resolution/frameworks/express.js +0 -225
- package/dist/resolution/frameworks/go.d.ts +0 -8
- package/dist/resolution/frameworks/go.js +0 -158
- package/dist/resolution/frameworks/index.d.ts +0 -52
- package/dist/resolution/frameworks/index.js +0 -137
- package/dist/resolution/frameworks/java.d.ts +0 -8
- package/dist/resolution/frameworks/java.js +0 -177
- package/dist/resolution/frameworks/laravel.d.ts +0 -13
- package/dist/resolution/frameworks/laravel.js +0 -248
- package/dist/resolution/frameworks/nestjs.d.ts +0 -26
- package/dist/resolution/frameworks/nestjs.js +0 -374
- package/dist/resolution/frameworks/python.d.ts +0 -10
- package/dist/resolution/frameworks/python.js +0 -278
- package/dist/resolution/frameworks/react.d.ts +0 -8
- package/dist/resolution/frameworks/react.js +0 -272
- package/dist/resolution/frameworks/ruby.d.ts +0 -8
- package/dist/resolution/frameworks/ruby.js +0 -198
- package/dist/resolution/frameworks/rust.d.ts +0 -8
- package/dist/resolution/frameworks/rust.js +0 -207
- package/dist/resolution/frameworks/svelte.d.ts +0 -9
- package/dist/resolution/frameworks/svelte.js +0 -249
- package/dist/resolution/frameworks/swift.d.ts +0 -10
- package/dist/resolution/frameworks/swift.js +0 -376
- package/dist/resolution/frameworks/vue.d.ts +0 -9
- package/dist/resolution/frameworks/vue.js +0 -306
- package/dist/resolution/import-resolver.d.ts +0 -61
- package/dist/resolution/import-resolver.js +0 -663
- package/dist/resolution/index.d.ts +0 -118
- package/dist/resolution/index.js +0 -744
- package/dist/resolution/lru-cache.d.ts +0 -24
- package/dist/resolution/lru-cache.js +0 -62
- package/dist/resolution/name-matcher.d.ts +0 -50
- package/dist/resolution/name-matcher.js +0 -384
- package/dist/resolution/path-aliases.d.ts +0 -72
- package/dist/resolution/path-aliases.js +0 -238
- package/dist/resolution/strip-comments.d.ts +0 -40
- package/dist/resolution/strip-comments.js +0 -441
- package/dist/resolution/types.d.ts +0 -181
- package/dist/resolution/types.js +0 -8
- package/dist/search/query-parser.d.ts +0 -61
- package/dist/search/query-parser.js +0 -177
- package/dist/search/query-utils.d.ts +0 -59
- package/dist/search/query-utils.js +0 -383
- package/dist/sync/git-hooks.d.ts +0 -54
- package/dist/sync/git-hooks.js +0 -223
- package/dist/sync/index.d.ts +0 -25
- package/dist/sync/index.js +0 -28
- package/dist/sync/watch-policy.d.ts +0 -51
- package/dist/sync/watch-policy.js +0 -124
- package/dist/sync/watcher.d.ts +0 -83
- package/dist/sync/watcher.js +0 -192
- package/dist/types.d.ts +0 -433
- package/dist/types.js +0 -75
- package/dist/ui/glyphs.d.ts +0 -42
- package/dist/ui/shimmer-progress.d.ts +0 -11
- package/dist/ui/shimmer-worker.d.ts +0 -2
- package/dist/ui/types.d.ts +0 -20
- package/dist/utils.d.ts +0 -231
- package/dist/utils.js +0 -549
package/dist/errors.d.ts
DELETED
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CodeGraph Error Classes
|
|
3
|
-
*
|
|
4
|
-
* Custom error types for better error handling and debugging.
|
|
5
|
-
*
|
|
6
|
-
* @module errors
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```typescript
|
|
10
|
-
* import { FileError, ParseError, setLogger, silentLogger } from 'codegraph';
|
|
11
|
-
*
|
|
12
|
-
* // Catch specific error types
|
|
13
|
-
* try {
|
|
14
|
-
* await cg.indexAll();
|
|
15
|
-
* } catch (error) {
|
|
16
|
-
* if (error instanceof FileError) {
|
|
17
|
-
* console.log(`File error at ${error.filePath}: ${error.message}`);
|
|
18
|
-
* } else if (error instanceof ParseError) {
|
|
19
|
-
* console.log(`Parse error at ${error.filePath}:${error.line}`);
|
|
20
|
-
* }
|
|
21
|
-
* }
|
|
22
|
-
*
|
|
23
|
-
* // Disable logging for tests
|
|
24
|
-
* setLogger(silentLogger);
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
|
-
/**
|
|
28
|
-
* Base error class for all CodeGraph errors.
|
|
29
|
-
*
|
|
30
|
-
* All CodeGraph-specific errors extend this class, allowing you to catch
|
|
31
|
-
* all CodeGraph errors with a single catch block.
|
|
32
|
-
*
|
|
33
|
-
* @example
|
|
34
|
-
* ```typescript
|
|
35
|
-
* try {
|
|
36
|
-
* await cg.indexAll();
|
|
37
|
-
* } catch (error) {
|
|
38
|
-
* if (error instanceof CodeGraphError) {
|
|
39
|
-
* console.log(`CodeGraph error [${error.code}]: ${error.message}`);
|
|
40
|
-
* }
|
|
41
|
-
* }
|
|
42
|
-
* ```
|
|
43
|
-
*/
|
|
44
|
-
export declare class CodeGraphError extends Error {
|
|
45
|
-
/** Error code for categorization (e.g., 'FILE_ERROR', 'PARSE_ERROR') */
|
|
46
|
-
readonly code: string
|
|
47
|
-
/** Additional context about the error */
|
|
48
|
-
readonly context?: Record<string, unknown>
|
|
49
|
-
constructor(message: string, code: string, context?: Record<string, unknown>)
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Error reading or accessing files
|
|
53
|
-
*/
|
|
54
|
-
export declare class FileError extends CodeGraphError {
|
|
55
|
-
readonly filePath: string
|
|
56
|
-
constructor(message: string, filePath: string, cause?: Error)
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Error parsing source code
|
|
60
|
-
*/
|
|
61
|
-
export declare class ParseError extends CodeGraphError {
|
|
62
|
-
readonly filePath: string
|
|
63
|
-
readonly line?: number
|
|
64
|
-
readonly column?: number
|
|
65
|
-
constructor(
|
|
66
|
-
message: string,
|
|
67
|
-
filePath: string,
|
|
68
|
-
options?: {
|
|
69
|
-
line?: number
|
|
70
|
-
column?: number
|
|
71
|
-
cause?: Error
|
|
72
|
-
},
|
|
73
|
-
)
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Error with database operations
|
|
77
|
-
*/
|
|
78
|
-
export declare class DatabaseError extends CodeGraphError {
|
|
79
|
-
readonly operation: string
|
|
80
|
-
constructor(message: string, operation: string, cause?: Error)
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Error with search operations
|
|
84
|
-
*/
|
|
85
|
-
export declare class SearchError extends CodeGraphError {
|
|
86
|
-
readonly query: string
|
|
87
|
-
constructor(message: string, query: string, cause?: Error)
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Error with vector/embedding operations
|
|
91
|
-
*/
|
|
92
|
-
export declare class VectorError extends CodeGraphError {
|
|
93
|
-
constructor(message: string, operation: string, cause?: Error)
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Error with configuration
|
|
97
|
-
*/
|
|
98
|
-
export declare class ConfigError extends CodeGraphError {
|
|
99
|
-
constructor(message: string, details?: Record<string, unknown>)
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Simple logger for CodeGraph operations
|
|
103
|
-
*
|
|
104
|
-
* By default, logs to console.warn for warnings and console.error for errors.
|
|
105
|
-
* Can be configured to use custom logging.
|
|
106
|
-
*/
|
|
107
|
-
export interface Logger {
|
|
108
|
-
debug(message: string, context?: Record<string, unknown>): void
|
|
109
|
-
warn(message: string, context?: Record<string, unknown>): void
|
|
110
|
-
error(message: string, context?: Record<string, unknown>): void
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Default console-based logger
|
|
114
|
-
*/
|
|
115
|
-
export declare const defaultLogger: Logger
|
|
116
|
-
/**
|
|
117
|
-
* Silent logger (no output) - useful for tests
|
|
118
|
-
*/
|
|
119
|
-
export declare const silentLogger: Logger
|
|
120
|
-
/**
|
|
121
|
-
* Set the global logger
|
|
122
|
-
*/
|
|
123
|
-
export declare function setLogger(logger: Logger): void
|
|
124
|
-
/**
|
|
125
|
-
* Get the current logger
|
|
126
|
-
*/
|
|
127
|
-
export declare function getLogger(): Logger
|
|
128
|
-
/**
|
|
129
|
-
* Log a debug message
|
|
130
|
-
*/
|
|
131
|
-
export declare function logDebug(
|
|
132
|
-
message: string,
|
|
133
|
-
context?: Record<string, unknown>,
|
|
134
|
-
): void
|
|
135
|
-
/**
|
|
136
|
-
* Log a warning message
|
|
137
|
-
*/
|
|
138
|
-
export declare function logWarn(
|
|
139
|
-
message: string,
|
|
140
|
-
context?: Record<string, unknown>,
|
|
141
|
-
): void
|
|
142
|
-
/**
|
|
143
|
-
* Log an error message
|
|
144
|
-
*/
|
|
145
|
-
export declare function logError(
|
|
146
|
-
message: string,
|
|
147
|
-
context?: Record<string, unknown>,
|
|
148
|
-
): void
|
|
149
|
-
//# sourceMappingURL=errors.d.ts.map
|
package/dist/errors.js
DELETED
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* CodeGraph Error Classes
|
|
4
|
-
*
|
|
5
|
-
* Custom error types for better error handling and debugging.
|
|
6
|
-
*
|
|
7
|
-
* @module errors
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```typescript
|
|
11
|
-
* import { FileError, ParseError, setLogger, silentLogger } from 'codegraph';
|
|
12
|
-
*
|
|
13
|
-
* // Catch specific error types
|
|
14
|
-
* try {
|
|
15
|
-
* await cg.indexAll();
|
|
16
|
-
* } catch (error) {
|
|
17
|
-
* if (error instanceof FileError) {
|
|
18
|
-
* console.log(`File error at ${error.filePath}: ${error.message}`);
|
|
19
|
-
* } else if (error instanceof ParseError) {
|
|
20
|
-
* console.log(`Parse error at ${error.filePath}:${error.line}`);
|
|
21
|
-
* }
|
|
22
|
-
* }
|
|
23
|
-
*
|
|
24
|
-
* // Disable logging for tests
|
|
25
|
-
* setLogger(silentLogger);
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.silentLogger = exports.defaultLogger = exports.ConfigError = exports.VectorError = exports.SearchError = exports.DatabaseError = exports.ParseError = exports.FileError = exports.CodeGraphError = void 0;
|
|
30
|
-
exports.setLogger = setLogger;
|
|
31
|
-
exports.getLogger = getLogger;
|
|
32
|
-
exports.logDebug = logDebug;
|
|
33
|
-
exports.logWarn = logWarn;
|
|
34
|
-
exports.logError = logError;
|
|
35
|
-
/**
|
|
36
|
-
* Base error class for all CodeGraph errors.
|
|
37
|
-
*
|
|
38
|
-
* All CodeGraph-specific errors extend this class, allowing you to catch
|
|
39
|
-
* all CodeGraph errors with a single catch block.
|
|
40
|
-
*
|
|
41
|
-
* @example
|
|
42
|
-
* ```typescript
|
|
43
|
-
* try {
|
|
44
|
-
* await cg.indexAll();
|
|
45
|
-
* } catch (error) {
|
|
46
|
-
* if (error instanceof CodeGraphError) {
|
|
47
|
-
* console.log(`CodeGraph error [${error.code}]: ${error.message}`);
|
|
48
|
-
* }
|
|
49
|
-
* }
|
|
50
|
-
* ```
|
|
51
|
-
*/
|
|
52
|
-
class CodeGraphError extends Error {
|
|
53
|
-
/** Error code for categorization (e.g., 'FILE_ERROR', 'PARSE_ERROR') */
|
|
54
|
-
code;
|
|
55
|
-
/** Additional context about the error */
|
|
56
|
-
context;
|
|
57
|
-
constructor(message, code, context) {
|
|
58
|
-
super(message);
|
|
59
|
-
this.name = 'CodeGraphError';
|
|
60
|
-
this.code = code;
|
|
61
|
-
this.context = context;
|
|
62
|
-
// Maintain proper stack trace for V8
|
|
63
|
-
if (Error.captureStackTrace) {
|
|
64
|
-
Error.captureStackTrace(this, this.constructor);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
exports.CodeGraphError = CodeGraphError;
|
|
69
|
-
/**
|
|
70
|
-
* Error reading or accessing files
|
|
71
|
-
*/
|
|
72
|
-
class FileError extends CodeGraphError {
|
|
73
|
-
filePath;
|
|
74
|
-
constructor(message, filePath, cause) {
|
|
75
|
-
super(message, 'FILE_ERROR', { filePath, cause: cause?.message });
|
|
76
|
-
this.name = 'FileError';
|
|
77
|
-
this.filePath = filePath;
|
|
78
|
-
if (cause) {
|
|
79
|
-
this.cause = cause;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
exports.FileError = FileError;
|
|
84
|
-
/**
|
|
85
|
-
* Error parsing source code
|
|
86
|
-
*/
|
|
87
|
-
class ParseError extends CodeGraphError {
|
|
88
|
-
filePath;
|
|
89
|
-
line;
|
|
90
|
-
column;
|
|
91
|
-
constructor(message, filePath, options) {
|
|
92
|
-
super(message, 'PARSE_ERROR', {
|
|
93
|
-
filePath,
|
|
94
|
-
line: options?.line,
|
|
95
|
-
column: options?.column,
|
|
96
|
-
cause: options?.cause?.message,
|
|
97
|
-
});
|
|
98
|
-
this.name = 'ParseError';
|
|
99
|
-
this.filePath = filePath;
|
|
100
|
-
this.line = options?.line;
|
|
101
|
-
this.column = options?.column;
|
|
102
|
-
if (options?.cause) {
|
|
103
|
-
this.cause = options.cause;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
exports.ParseError = ParseError;
|
|
108
|
-
/**
|
|
109
|
-
* Error with database operations
|
|
110
|
-
*/
|
|
111
|
-
class DatabaseError extends CodeGraphError {
|
|
112
|
-
operation;
|
|
113
|
-
constructor(message, operation, cause) {
|
|
114
|
-
super(message, 'DATABASE_ERROR', { operation, cause: cause?.message });
|
|
115
|
-
this.name = 'DatabaseError';
|
|
116
|
-
this.operation = operation;
|
|
117
|
-
if (cause) {
|
|
118
|
-
this.cause = cause;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
exports.DatabaseError = DatabaseError;
|
|
123
|
-
/**
|
|
124
|
-
* Error with search operations
|
|
125
|
-
*/
|
|
126
|
-
class SearchError extends CodeGraphError {
|
|
127
|
-
query;
|
|
128
|
-
constructor(message, query, cause) {
|
|
129
|
-
super(message, 'SEARCH_ERROR', { query, cause: cause?.message });
|
|
130
|
-
this.name = 'SearchError';
|
|
131
|
-
this.query = query;
|
|
132
|
-
if (cause) {
|
|
133
|
-
this.cause = cause;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
exports.SearchError = SearchError;
|
|
138
|
-
/**
|
|
139
|
-
* Error with vector/embedding operations
|
|
140
|
-
*/
|
|
141
|
-
class VectorError extends CodeGraphError {
|
|
142
|
-
constructor(message, operation, cause) {
|
|
143
|
-
super(message, 'VECTOR_ERROR', { operation, cause: cause?.message });
|
|
144
|
-
this.name = 'VectorError';
|
|
145
|
-
if (cause) {
|
|
146
|
-
this.cause = cause;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
exports.VectorError = VectorError;
|
|
151
|
-
/**
|
|
152
|
-
* Error with configuration
|
|
153
|
-
*/
|
|
154
|
-
class ConfigError extends CodeGraphError {
|
|
155
|
-
constructor(message, details) {
|
|
156
|
-
super(message, 'CONFIG_ERROR', details);
|
|
157
|
-
this.name = 'ConfigError';
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
exports.ConfigError = ConfigError;
|
|
161
|
-
/**
|
|
162
|
-
* Default console-based logger
|
|
163
|
-
*/
|
|
164
|
-
exports.defaultLogger = {
|
|
165
|
-
debug(message, context) {
|
|
166
|
-
if (process.env.CODEGRAPH_DEBUG) {
|
|
167
|
-
console.debug(`[CodeGraph] ${message}`, context ?? '');
|
|
168
|
-
}
|
|
169
|
-
},
|
|
170
|
-
warn(message, context) {
|
|
171
|
-
console.warn(`[CodeGraph] ${message}`, context ?? '');
|
|
172
|
-
},
|
|
173
|
-
error(message, context) {
|
|
174
|
-
console.error(`[CodeGraph] ${message}`, context ?? '');
|
|
175
|
-
},
|
|
176
|
-
};
|
|
177
|
-
/**
|
|
178
|
-
* Silent logger (no output) - useful for tests
|
|
179
|
-
*/
|
|
180
|
-
exports.silentLogger = {
|
|
181
|
-
debug() { },
|
|
182
|
-
warn() { },
|
|
183
|
-
error() { },
|
|
184
|
-
};
|
|
185
|
-
/**
|
|
186
|
-
* Current logger instance (can be replaced)
|
|
187
|
-
*/
|
|
188
|
-
let currentLogger = exports.defaultLogger;
|
|
189
|
-
/**
|
|
190
|
-
* Set the global logger
|
|
191
|
-
*/
|
|
192
|
-
function setLogger(logger) {
|
|
193
|
-
currentLogger = logger;
|
|
194
|
-
}
|
|
195
|
-
/**
|
|
196
|
-
* Get the current logger
|
|
197
|
-
*/
|
|
198
|
-
function getLogger() {
|
|
199
|
-
return currentLogger;
|
|
200
|
-
}
|
|
201
|
-
/**
|
|
202
|
-
* Log a debug message
|
|
203
|
-
*/
|
|
204
|
-
function logDebug(message, context) {
|
|
205
|
-
currentLogger.debug(message, context);
|
|
206
|
-
}
|
|
207
|
-
/**
|
|
208
|
-
* Log a warning message
|
|
209
|
-
*/
|
|
210
|
-
function logWarn(message, context) {
|
|
211
|
-
currentLogger.warn(message, context);
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* Log an error message
|
|
215
|
-
*/
|
|
216
|
-
function logError(message, context) {
|
|
217
|
-
currentLogger.error(message, context);
|
|
218
|
-
}
|
|
219
|
-
//# sourceMappingURL=errors.js.map
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { ExtractionResult } from '../types'
|
|
2
|
-
/**
|
|
3
|
-
* Custom extractor for Delphi DFM/FMX form files.
|
|
4
|
-
*
|
|
5
|
-
* DFM/FMX files describe the visual component hierarchy and event handler
|
|
6
|
-
* bindings. They use a simple text format (object/end blocks) that we parse
|
|
7
|
-
* with regex — no tree-sitter grammar exists for this format.
|
|
8
|
-
*
|
|
9
|
-
* Extracted information:
|
|
10
|
-
* - Components as NodeKind `component`
|
|
11
|
-
* - Nesting as EdgeKind `contains`
|
|
12
|
-
* - Event handlers (OnClick = MethodName) as UnresolvedReference → EdgeKind `references`
|
|
13
|
-
*/
|
|
14
|
-
export declare class DfmExtractor {
|
|
15
|
-
private filePath
|
|
16
|
-
private source
|
|
17
|
-
private nodes
|
|
18
|
-
private edges
|
|
19
|
-
private unresolvedReferences
|
|
20
|
-
private errors
|
|
21
|
-
constructor(filePath: string, source: string)
|
|
22
|
-
/**
|
|
23
|
-
* Extract components and event handler references from DFM/FMX source
|
|
24
|
-
*/
|
|
25
|
-
extract(): ExtractionResult
|
|
26
|
-
/** Create a file node for the DFM form file */
|
|
27
|
-
private createFileNode
|
|
28
|
-
/** Parse object/end blocks and extract components + event handlers */
|
|
29
|
-
private parseComponents
|
|
30
|
-
}
|
|
31
|
-
//# sourceMappingURL=dfm-extractor.d.ts.map
|
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DfmExtractor = void 0;
|
|
4
|
-
const tree_sitter_helpers_1 = require("./tree-sitter-helpers");
|
|
5
|
-
/**
|
|
6
|
-
* Custom extractor for Delphi DFM/FMX form files.
|
|
7
|
-
*
|
|
8
|
-
* DFM/FMX files describe the visual component hierarchy and event handler
|
|
9
|
-
* bindings. They use a simple text format (object/end blocks) that we parse
|
|
10
|
-
* with regex — no tree-sitter grammar exists for this format.
|
|
11
|
-
*
|
|
12
|
-
* Extracted information:
|
|
13
|
-
* - Components as NodeKind `component`
|
|
14
|
-
* - Nesting as EdgeKind `contains`
|
|
15
|
-
* - Event handlers (OnClick = MethodName) as UnresolvedReference → EdgeKind `references`
|
|
16
|
-
*/
|
|
17
|
-
class DfmExtractor {
|
|
18
|
-
filePath;
|
|
19
|
-
source;
|
|
20
|
-
nodes = [];
|
|
21
|
-
edges = [];
|
|
22
|
-
unresolvedReferences = [];
|
|
23
|
-
errors = [];
|
|
24
|
-
constructor(filePath, source) {
|
|
25
|
-
this.filePath = filePath;
|
|
26
|
-
this.source = source;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Extract components and event handler references from DFM/FMX source
|
|
30
|
-
*/
|
|
31
|
-
extract() {
|
|
32
|
-
const startTime = Date.now();
|
|
33
|
-
try {
|
|
34
|
-
const fileNode = this.createFileNode();
|
|
35
|
-
this.parseComponents(fileNode.id);
|
|
36
|
-
}
|
|
37
|
-
catch (error) {
|
|
38
|
-
this.errors.push({
|
|
39
|
-
message: `DFM extraction error: ${error instanceof Error ? error.message : String(error)}`,
|
|
40
|
-
severity: 'error',
|
|
41
|
-
code: 'parse_error',
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
return {
|
|
45
|
-
nodes: this.nodes,
|
|
46
|
-
edges: this.edges,
|
|
47
|
-
unresolvedReferences: this.unresolvedReferences,
|
|
48
|
-
errors: this.errors,
|
|
49
|
-
durationMs: Date.now() - startTime,
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
/** Create a file node for the DFM form file */
|
|
53
|
-
createFileNode() {
|
|
54
|
-
const lines = this.source.split('\n');
|
|
55
|
-
const id = (0, tree_sitter_helpers_1.generateNodeId)(this.filePath, 'file', this.filePath, 1);
|
|
56
|
-
const fileNode = {
|
|
57
|
-
id,
|
|
58
|
-
kind: 'file',
|
|
59
|
-
name: this.filePath.split('/').pop() || this.filePath,
|
|
60
|
-
qualifiedName: this.filePath,
|
|
61
|
-
filePath: this.filePath,
|
|
62
|
-
language: 'pascal',
|
|
63
|
-
startLine: 1,
|
|
64
|
-
endLine: lines.length,
|
|
65
|
-
startColumn: 0,
|
|
66
|
-
endColumn: lines[lines.length - 1]?.length || 0,
|
|
67
|
-
updatedAt: Date.now(),
|
|
68
|
-
};
|
|
69
|
-
this.nodes.push(fileNode);
|
|
70
|
-
return fileNode;
|
|
71
|
-
}
|
|
72
|
-
/** Parse object/end blocks and extract components + event handlers */
|
|
73
|
-
parseComponents(fileNodeId) {
|
|
74
|
-
const lines = this.source.split('\n');
|
|
75
|
-
const stack = [fileNodeId];
|
|
76
|
-
const objectPattern = /^\s*(object|inherited|inline)\s+(\w+)\s*:\s*(\w+)/;
|
|
77
|
-
const eventPattern = /^\s*(On\w+)\s*=\s*(\w+)\s*$/;
|
|
78
|
-
const endPattern = /^\s*end\s*$/;
|
|
79
|
-
const multiLineStart = /=\s*\(\s*$/;
|
|
80
|
-
const multiLineItemStart = /=\s*<\s*$/;
|
|
81
|
-
let inMultiLine = false;
|
|
82
|
-
let multiLineEndChar = ')';
|
|
83
|
-
for (let i = 0; i < lines.length; i++) {
|
|
84
|
-
const line = lines[i];
|
|
85
|
-
const lineNum = i + 1;
|
|
86
|
-
// Skip multi-line properties
|
|
87
|
-
if (inMultiLine) {
|
|
88
|
-
if (line.trimEnd().endsWith(multiLineEndChar))
|
|
89
|
-
inMultiLine = false;
|
|
90
|
-
continue;
|
|
91
|
-
}
|
|
92
|
-
if (multiLineStart.test(line)) {
|
|
93
|
-
inMultiLine = true;
|
|
94
|
-
multiLineEndChar = ')';
|
|
95
|
-
continue;
|
|
96
|
-
}
|
|
97
|
-
if (multiLineItemStart.test(line)) {
|
|
98
|
-
inMultiLine = true;
|
|
99
|
-
multiLineEndChar = '>';
|
|
100
|
-
continue;
|
|
101
|
-
}
|
|
102
|
-
// Component declaration
|
|
103
|
-
const objMatch = line.match(objectPattern);
|
|
104
|
-
if (objMatch) {
|
|
105
|
-
const [, , name, typeName] = objMatch;
|
|
106
|
-
const nodeId = (0, tree_sitter_helpers_1.generateNodeId)(this.filePath, 'component', name, lineNum);
|
|
107
|
-
this.nodes.push({
|
|
108
|
-
id: nodeId,
|
|
109
|
-
kind: 'component',
|
|
110
|
-
name: name,
|
|
111
|
-
qualifiedName: `${this.filePath}#${name}`,
|
|
112
|
-
filePath: this.filePath,
|
|
113
|
-
language: 'pascal',
|
|
114
|
-
startLine: lineNum,
|
|
115
|
-
endLine: lineNum,
|
|
116
|
-
startColumn: 0,
|
|
117
|
-
endColumn: line.length,
|
|
118
|
-
signature: typeName,
|
|
119
|
-
updatedAt: Date.now(),
|
|
120
|
-
});
|
|
121
|
-
this.edges.push({
|
|
122
|
-
source: stack[stack.length - 1],
|
|
123
|
-
target: nodeId,
|
|
124
|
-
kind: 'contains',
|
|
125
|
-
});
|
|
126
|
-
stack.push(nodeId);
|
|
127
|
-
continue;
|
|
128
|
-
}
|
|
129
|
-
// Event handler
|
|
130
|
-
const eventMatch = line.match(eventPattern);
|
|
131
|
-
if (eventMatch) {
|
|
132
|
-
const [, , methodName] = eventMatch;
|
|
133
|
-
this.unresolvedReferences.push({
|
|
134
|
-
fromNodeId: stack[stack.length - 1],
|
|
135
|
-
referenceName: methodName,
|
|
136
|
-
referenceKind: 'references',
|
|
137
|
-
line: lineNum,
|
|
138
|
-
column: 0,
|
|
139
|
-
});
|
|
140
|
-
continue;
|
|
141
|
-
}
|
|
142
|
-
// Block end
|
|
143
|
-
if (endPattern.test(line)) {
|
|
144
|
-
if (stack.length > 1)
|
|
145
|
-
stack.pop();
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
exports.DfmExtractor = DfmExtractor;
|
|
151
|
-
//# sourceMappingURL=dfm-extractor.js.map
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Grammar Loading and Caching
|
|
3
|
-
*
|
|
4
|
-
* Uses web-tree-sitter (WASM) for universal cross-platform support.
|
|
5
|
-
* Grammars are loaded lazily — only languages actually present in the project
|
|
6
|
-
* are compiled, keeping V8 WASM memory pressure low on large codebases.
|
|
7
|
-
*/
|
|
8
|
-
import { Parser } from 'web-tree-sitter'
|
|
9
|
-
import { Language } from '../types'
|
|
10
|
-
export type GrammarLanguage = Exclude<
|
|
11
|
-
Language,
|
|
12
|
-
'svelte' | 'vue' | 'liquid' | 'yaml' | 'twig' | 'unknown'
|
|
13
|
-
>
|
|
14
|
-
/**
|
|
15
|
-
* File extension to Language mapping
|
|
16
|
-
*/
|
|
17
|
-
export declare const EXTENSION_MAP: Record<string, Language>
|
|
18
|
-
/**
|
|
19
|
-
* Whether a file is one CodeGraph can parse, based purely on its extension.
|
|
20
|
-
* This is the single source of truth for "should we index this file" — derived
|
|
21
|
-
* from EXTENSION_MAP so parser support and indexing selection never drift.
|
|
22
|
-
*/
|
|
23
|
-
export declare function isSourceFile(filePath: string): boolean
|
|
24
|
-
/**
|
|
25
|
-
* Initialize the tree-sitter WASM runtime. Must be called before loading grammars.
|
|
26
|
-
* Does NOT load any grammar WASM files — use loadGrammarsForLanguages() for that.
|
|
27
|
-
* Idempotent — safe to call multiple times.
|
|
28
|
-
*/
|
|
29
|
-
export declare function initGrammars(): Promise<void>
|
|
30
|
-
/**
|
|
31
|
-
* Load grammar WASM files for specific languages only.
|
|
32
|
-
* Skips languages that are already loaded or have no WASM grammar.
|
|
33
|
-
* Must be called after initGrammars().
|
|
34
|
-
*/
|
|
35
|
-
export declare function loadGrammarsForLanguages(
|
|
36
|
-
languages: Language[],
|
|
37
|
-
): Promise<void>
|
|
38
|
-
/**
|
|
39
|
-
* Load ALL grammar WASM files. Convenience function for tests and
|
|
40
|
-
* backward compatibility. Prefer loadGrammarsForLanguages() in production.
|
|
41
|
-
*/
|
|
42
|
-
export declare function loadAllGrammars(): Promise<void>
|
|
43
|
-
/**
|
|
44
|
-
* Check if grammars have been initialized
|
|
45
|
-
*/
|
|
46
|
-
export declare function isGrammarsInitialized(): boolean
|
|
47
|
-
/**
|
|
48
|
-
* Get a parser for the specified language.
|
|
49
|
-
* Returns synchronously from pre-loaded cache.
|
|
50
|
-
*/
|
|
51
|
-
export declare function getParser(language: Language): Parser | null
|
|
52
|
-
/**
|
|
53
|
-
* Detect language from file extension
|
|
54
|
-
*/
|
|
55
|
-
export declare function detectLanguage(
|
|
56
|
-
filePath: string,
|
|
57
|
-
source?: string,
|
|
58
|
-
): Language
|
|
59
|
-
/**
|
|
60
|
-
* Check if a language is supported (has a grammar defined).
|
|
61
|
-
* Returns true if the grammar exists, even if not yet loaded.
|
|
62
|
-
*/
|
|
63
|
-
export declare function isLanguageSupported(language: Language): boolean
|
|
64
|
-
/**
|
|
65
|
-
* Check if a grammar has been loaded and is ready for parsing.
|
|
66
|
-
*/
|
|
67
|
-
export declare function isGrammarLoaded(language: Language): boolean
|
|
68
|
-
/**
|
|
69
|
-
* Get all supported languages (those with grammar definitions).
|
|
70
|
-
*/
|
|
71
|
-
export declare function getSupportedLanguages(): Language[]
|
|
72
|
-
/**
|
|
73
|
-
* Reset the cached parser for a language to reclaim WASM heap memory.
|
|
74
|
-
* The tree-sitter WASM runtime accumulates fragmented memory over thousands
|
|
75
|
-
* of parses. Deleting and recreating the Parser instance forces the WASM
|
|
76
|
-
* heap to reset, preventing "memory access out of bounds" crashes in
|
|
77
|
-
* large repos.
|
|
78
|
-
*/
|
|
79
|
-
export declare function resetParser(language: Language): void
|
|
80
|
-
/**
|
|
81
|
-
* Clear parser/grammar caches (useful for testing)
|
|
82
|
-
*/
|
|
83
|
-
export declare function clearParserCache(): void
|
|
84
|
-
/**
|
|
85
|
-
* Report grammars that failed to load.
|
|
86
|
-
*/
|
|
87
|
-
export declare function getUnavailableGrammarErrors(): Partial<
|
|
88
|
-
Record<Language, string>
|
|
89
|
-
>
|
|
90
|
-
/**
|
|
91
|
-
* Get language display name
|
|
92
|
-
*/
|
|
93
|
-
export declare function getLanguageDisplayName(language: Language): string
|
|
94
|
-
//# sourceMappingURL=grammars.d.ts.map
|