@aroman22/codegraph-vba 1.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +855 -0
- package/dist/bin/codegraph.d.ts +26 -0
- package/dist/bin/command-supervision.d.ts +12 -0
- package/dist/bin/fatal-handler.d.ts +20 -0
- package/dist/bin/node-version-check.d.ts +37 -0
- package/dist/bin/uninstall.d.ts +14 -0
- package/dist/context/formatter.d.ts +30 -0
- package/dist/context/index.d.ts +119 -0
- package/dist/context/markers.d.ts +19 -0
- package/dist/db/index.d.ts +122 -0
- package/dist/db/migrations.d.ts +44 -0
- package/dist/db/queries.d.ts +402 -0
- package/dist/db/sqlite-adapter.d.ts +53 -0
- package/dist/directory.d.ts +179 -0
- package/dist/errors.d.ts +136 -0
- package/dist/extraction/astro-extractor.d.ts +79 -0
- package/dist/extraction/dfm-extractor.d.ts +31 -0
- package/dist/extraction/extraction-version.d.ts +25 -0
- package/dist/extraction/function-ref.d.ts +118 -0
- package/dist/extraction/generated-detection.d.ts +30 -0
- package/dist/extraction/grammars.d.ts +128 -0
- package/dist/extraction/index.d.ts +187 -0
- package/dist/extraction/languages/c-cpp.d.ts +12 -0
- package/dist/extraction/languages/csharp.d.ts +25 -0
- package/dist/extraction/languages/dart.d.ts +3 -0
- package/dist/extraction/languages/go.d.ts +3 -0
- package/dist/extraction/languages/index.d.ts +10 -0
- package/dist/extraction/languages/java.d.ts +3 -0
- package/dist/extraction/languages/javascript.d.ts +3 -0
- package/dist/extraction/languages/kotlin.d.ts +3 -0
- package/dist/extraction/languages/lua.d.ts +3 -0
- package/dist/extraction/languages/luau.d.ts +3 -0
- package/dist/extraction/languages/objc.d.ts +3 -0
- package/dist/extraction/languages/pascal.d.ts +3 -0
- package/dist/extraction/languages/php.d.ts +3 -0
- package/dist/extraction/languages/python.d.ts +3 -0
- package/dist/extraction/languages/r.d.ts +3 -0
- package/dist/extraction/languages/ruby.d.ts +3 -0
- package/dist/extraction/languages/rust.d.ts +3 -0
- package/dist/extraction/languages/scala.d.ts +3 -0
- package/dist/extraction/languages/swift.d.ts +3 -0
- package/dist/extraction/languages/typescript.d.ts +16 -0
- package/dist/extraction/liquid-extractor.d.ts +59 -0
- package/dist/extraction/mybatis-extractor.d.ts +48 -0
- package/dist/extraction/parse-pool.d.ts +126 -0
- package/dist/extraction/parse-worker.d.ts +8 -0
- package/dist/extraction/razor-extractor.d.ts +42 -0
- package/dist/extraction/sql-query-extractor.d.ts +25 -0
- package/dist/extraction/svelte-extractor.d.ts +56 -0
- package/dist/extraction/tree-sitter-helpers.d.ts +28 -0
- package/dist/extraction/tree-sitter-types.d.ts +239 -0
- package/dist/extraction/tree-sitter.d.ts +647 -0
- package/dist/extraction/vba-extractor.d.ts +394 -0
- package/dist/extraction/vba-form-extractor.d.ts +89 -0
- package/dist/extraction/vba-preprocess.d.ts +81 -0
- package/dist/extraction/vue-extractor.d.ts +51 -0
- package/dist/extraction/wasm-runtime-flags.d.ts +38 -0
- package/dist/graph/index.d.ts +8 -0
- package/dist/graph/queries.d.ts +106 -0
- package/dist/graph/traversal.d.ts +127 -0
- package/dist/index.d.ts +563 -0
- package/dist/installer/config-writer.d.ts +28 -0
- package/dist/installer/index.d.ts +100 -0
- package/dist/installer/instructions-template.d.ts +41 -0
- package/dist/installer/targets/antigravity.d.ts +57 -0
- package/dist/installer/targets/claude.d.ts +62 -0
- package/dist/installer/targets/codex.d.ts +18 -0
- package/dist/installer/targets/cursor.d.ts +35 -0
- package/dist/installer/targets/gemini.d.ts +26 -0
- package/dist/installer/targets/hermes.d.ts +18 -0
- package/dist/installer/targets/kiro.d.ts +27 -0
- package/dist/installer/targets/opencode.d.ts +38 -0
- package/dist/installer/targets/registry.d.ts +35 -0
- package/dist/installer/targets/shared.d.ts +101 -0
- package/dist/installer/targets/toml.d.ts +52 -0
- package/dist/installer/targets/types.d.ts +108 -0
- package/dist/mcp/daemon-manager.d.ts +42 -0
- package/dist/mcp/daemon-paths.d.ts +73 -0
- package/dist/mcp/daemon-registry.d.ts +47 -0
- package/dist/mcp/daemon.d.ts +258 -0
- package/dist/mcp/dynamic-boundaries.d.ts +41 -0
- package/dist/mcp/engine.d.ts +122 -0
- package/dist/mcp/index.d.ts +113 -0
- package/dist/mcp/liveness-watchdog.d.ts +18 -0
- package/dist/mcp/ppid-watchdog.d.ts +62 -0
- package/dist/mcp/proxy.d.ts +87 -0
- package/dist/mcp/query-pool.d.ts +94 -0
- package/dist/mcp/query-worker.d.ts +24 -0
- package/dist/mcp/server-instructions.d.ts +34 -0
- package/dist/mcp/session.d.ts +79 -0
- package/dist/mcp/stdin-teardown.d.ts +27 -0
- package/dist/mcp/tools.d.ts +591 -0
- package/dist/mcp/transport.d.ts +188 -0
- package/dist/mcp/version.d.ts +19 -0
- package/dist/project-config.d.ts +56 -0
- package/dist/reasoning/config.d.ts +45 -0
- package/dist/reasoning/credentials.d.ts +5 -0
- package/dist/reasoning/login.d.ts +21 -0
- package/dist/reasoning/reasoner.d.ts +43 -0
- package/dist/resolution/c-fnptr-synthesizer.d.ts +5 -0
- package/dist/resolution/callback-synthesizer.d.ts +15 -0
- package/dist/resolution/frameworks/astro.d.ts +9 -0
- package/dist/resolution/frameworks/cargo-workspace.d.ts +18 -0
- package/dist/resolution/frameworks/csharp.d.ts +8 -0
- package/dist/resolution/frameworks/drupal.d.ts +51 -0
- package/dist/resolution/frameworks/expo-modules.d.ts +3 -0
- package/dist/resolution/frameworks/express.d.ts +8 -0
- package/dist/resolution/frameworks/fabric.d.ts +3 -0
- package/dist/resolution/frameworks/go.d.ts +8 -0
- package/dist/resolution/frameworks/goframe.d.ts +41 -0
- package/dist/resolution/frameworks/index.d.ts +50 -0
- package/dist/resolution/frameworks/java.d.ts +8 -0
- package/dist/resolution/frameworks/laravel.d.ts +13 -0
- package/dist/resolution/frameworks/nestjs.d.ts +26 -0
- package/dist/resolution/frameworks/play.d.ts +19 -0
- package/dist/resolution/frameworks/python.d.ts +10 -0
- package/dist/resolution/frameworks/react-native.d.ts +3 -0
- package/dist/resolution/frameworks/react.d.ts +8 -0
- package/dist/resolution/frameworks/ruby.d.ts +8 -0
- package/dist/resolution/frameworks/rust.d.ts +8 -0
- package/dist/resolution/frameworks/svelte.d.ts +9 -0
- package/dist/resolution/frameworks/swift-objc.d.ts +37 -0
- package/dist/resolution/frameworks/swift.d.ts +10 -0
- package/dist/resolution/frameworks/vue.d.ts +9 -0
- package/dist/resolution/go-module.d.ts +26 -0
- package/dist/resolution/goframe-synthesizer.d.ts +28 -0
- package/dist/resolution/import-resolver.d.ts +78 -0
- package/dist/resolution/index.d.ts +196 -0
- package/dist/resolution/lru-cache.d.ts +24 -0
- package/dist/resolution/name-matcher.d.ts +93 -0
- package/dist/resolution/path-aliases.d.ts +68 -0
- package/dist/resolution/strip-comments.d.ts +27 -0
- package/dist/resolution/swift-objc-bridge.d.ts +134 -0
- package/dist/resolution/types.d.ts +233 -0
- package/dist/resolution/workspace-packages.d.ts +48 -0
- package/dist/search/query-parser.d.ts +57 -0
- package/dist/search/query-utils.d.ts +87 -0
- package/dist/sync/git-hooks.d.ts +45 -0
- package/dist/sync/index.d.ts +19 -0
- package/dist/sync/watch-policy.d.ts +48 -0
- package/dist/sync/watcher.d.ts +358 -0
- package/dist/sync/worktree.d.ts +54 -0
- package/dist/telemetry/index.d.ts +143 -0
- package/dist/types.d.ts +409 -0
- package/dist/ui/glyphs.d.ts +42 -0
- package/dist/ui/shimmer-progress.d.ts +11 -0
- package/dist/ui/shimmer-worker.d.ts +2 -0
- package/dist/ui/types.d.ts +17 -0
- package/dist/upgrade/index.d.ts +132 -0
- package/dist/utils.d.ts +224 -0
- package/npm-sdk.js +75 -0
- package/npm-shim.js +246 -0
- package/package.json +32 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* CodeGraph CLI
|
|
4
|
+
*
|
|
5
|
+
* Command-line interface for CodeGraph code intelligence.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* codegraph Run interactive installer (when no args)
|
|
9
|
+
* codegraph install Run interactive installer
|
|
10
|
+
* codegraph uninstall Remove CodeGraph from your agents
|
|
11
|
+
* codegraph init [path] Initialize CodeGraph in a project
|
|
12
|
+
* codegraph uninit [path] Remove CodeGraph from a project
|
|
13
|
+
* codegraph index [path] Index all files in the project
|
|
14
|
+
* codegraph sync [path] Sync changes since last index
|
|
15
|
+
* codegraph status [path] Show index status
|
|
16
|
+
* codegraph query <search> Search for symbols
|
|
17
|
+
* codegraph files [options] Show project file structure
|
|
18
|
+
* codegraph context <task> Build context for a task
|
|
19
|
+
* codegraph callers <symbol> Find what calls a function/method
|
|
20
|
+
* codegraph callees <symbol> Find what a function/method calls
|
|
21
|
+
* codegraph impact <symbol> Analyze what code is affected by changing a symbol
|
|
22
|
+
* codegraph affected [files] Find test files affected by changes
|
|
23
|
+
* codegraph upgrade [version] Update CodeGraph to the latest release
|
|
24
|
+
*/
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=codegraph.d.ts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface CommandSupervision {
|
|
2
|
+
/** Tear down both watchdogs. Idempotent; call when the command finishes. */
|
|
3
|
+
stop(): void;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Install the liveness + PPID watchdogs for the duration of a CLI command.
|
|
7
|
+
* `label` is used in the shutdown notice (e.g. `"index"`). Returns a handle
|
|
8
|
+
* whose `stop()` must be called when the command completes so neither watchdog
|
|
9
|
+
* outlives it.
|
|
10
|
+
*/
|
|
11
|
+
export declare function installCommandSupervision(label: string): CommandSupervision;
|
|
12
|
+
//# sourceMappingURL=command-supervision.d.ts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Render an uncaught value for the last-resort log WITHOUT triggering stack
|
|
3
|
+
* formatting. Pure and total — never throws, never touches `.stack`.
|
|
4
|
+
*/
|
|
5
|
+
export declare function describeFatal(value: unknown): string;
|
|
6
|
+
/** Injectable seams so the wiring is testable without registering real handlers. */
|
|
7
|
+
export interface FatalHandlerDeps {
|
|
8
|
+
/** Event target to attach to. Defaults to `process`. */
|
|
9
|
+
target?: NodeJS.EventEmitter;
|
|
10
|
+
/** How to terminate. Defaults to `process.exit`. */
|
|
11
|
+
exit?: (code: number) => void;
|
|
12
|
+
/** How to emit the bounded line. Defaults to a synchronous fd-2 write. */
|
|
13
|
+
write?: (line: string) => void;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Install the uncaught-exception / unhandled-rejection handlers. Both log a
|
|
17
|
+
* bounded line and then exit non-zero (Node's default fatal semantics).
|
|
18
|
+
*/
|
|
19
|
+
export declare function installFatalHandlers(deps?: FatalHandlerDeps): void;
|
|
20
|
+
//# sourceMappingURL=fatal-handler.d.ts.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node.js version compatibility check.
|
|
3
|
+
*
|
|
4
|
+
* Node 25.x has a V8 turboshaft WASM JIT Zone allocator bug that
|
|
5
|
+
* reliably crashes CodeGraph with `Fatal process out of memory: Zone`
|
|
6
|
+
* during tree-sitter grammar compilation. This module owns the
|
|
7
|
+
* user-facing banner shown before exit. Kept side-effect-free so it's
|
|
8
|
+
* safe to import from tests without triggering CLI bootstrap.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Build the bordered banner shown when CodeGraph detects an
|
|
12
|
+
* unsupported Node.js major version (currently 25+). Pinned via unit
|
|
13
|
+
* test so the recovery commands and override instructions can't be
|
|
14
|
+
* silently stripped by future edits.
|
|
15
|
+
*
|
|
16
|
+
* Uses ASCII glyphs to stay readable on Windows OEM-codepage consoles
|
|
17
|
+
* (see ../ui/glyphs.ts for the rationale).
|
|
18
|
+
*/
|
|
19
|
+
export declare function buildNode25BlockBanner(nodeVersion: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* Lowest supported Node.js major version. Matches the `engines` floor in
|
|
22
|
+
* package.json. Below this, CodeGraph relies on language features / native APIs
|
|
23
|
+
* that aren't present, and the combination is untested. `engines` alone only
|
|
24
|
+
* *warns* on install (unless the user set `engine-strict`), so the CLI bootstrap
|
|
25
|
+
* also hard-blocks here to actually enforce the floor.
|
|
26
|
+
*/
|
|
27
|
+
export declare const MIN_NODE_MAJOR = 20;
|
|
28
|
+
/**
|
|
29
|
+
* Build the bordered banner shown when CodeGraph detects a Node.js major below
|
|
30
|
+
* {@link MIN_NODE_MAJOR}. Pinned via unit test so the recovery commands and the
|
|
31
|
+
* override env var can't be silently stripped by future edits.
|
|
32
|
+
*
|
|
33
|
+
* Uses ASCII glyphs to stay readable on Windows OEM-codepage consoles
|
|
34
|
+
* (see ../ui/glyphs.ts for the rationale).
|
|
35
|
+
*/
|
|
36
|
+
export declare function buildNodeTooOldBanner(nodeVersion: string): string;
|
|
37
|
+
//# sourceMappingURL=node-version-check.d.ts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* CodeGraph preuninstall cleanup script
|
|
4
|
+
*
|
|
5
|
+
* Runs automatically when `npm uninstall -g @colbymchenry/codegraph`
|
|
6
|
+
* is called. Loops over every known agent target's `uninstall(loc)`
|
|
7
|
+
* for the global location only — local-location entries live inside
|
|
8
|
+
* project working trees and aren't ours to nuke at npm-uninstall
|
|
9
|
+
* time.
|
|
10
|
+
*
|
|
11
|
+
* This script must never throw — a failed cleanup must not block
|
|
12
|
+
* uninstall.
|
|
13
|
+
*/
|
|
14
|
+
//# sourceMappingURL=uninstall.d.ts.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Context Formatter
|
|
3
|
+
*
|
|
4
|
+
* Formats TaskContext as markdown or JSON for consumption by Claude.
|
|
5
|
+
*/
|
|
6
|
+
import { Node, TaskContext, Subgraph } from '../types';
|
|
7
|
+
/**
|
|
8
|
+
* Format context as markdown
|
|
9
|
+
*
|
|
10
|
+
* Creates a compact markdown document optimized for Claude with minimal context usage:
|
|
11
|
+
* - Brief summary
|
|
12
|
+
* - Entry points with locations
|
|
13
|
+
* - Code blocks only for key symbols
|
|
14
|
+
*/
|
|
15
|
+
export declare function formatContextAsMarkdown(context: TaskContext): string;
|
|
16
|
+
/**
|
|
17
|
+
* Format context as JSON
|
|
18
|
+
*
|
|
19
|
+
* Returns a structured JSON representation suitable for programmatic use.
|
|
20
|
+
*/
|
|
21
|
+
export declare function formatContextAsJson(context: TaskContext): string;
|
|
22
|
+
/**
|
|
23
|
+
* Format a subgraph as an ASCII tree structure
|
|
24
|
+
*/
|
|
25
|
+
export declare function formatSubgraphTree(subgraph: Subgraph, entryPoints: Node[]): string;
|
|
26
|
+
/**
|
|
27
|
+
* Format bytes as human-readable string
|
|
28
|
+
*/
|
|
29
|
+
export declare function formatBytes(bytes: number): string;
|
|
30
|
+
//# sourceMappingURL=formatter.d.ts.map
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Context Builder
|
|
3
|
+
*
|
|
4
|
+
* Builds rich context for tasks by combining FTS search with graph traversal.
|
|
5
|
+
* Outputs structured context ready to inject into Claude.
|
|
6
|
+
*/
|
|
7
|
+
import { Subgraph, TaskContext, TaskInput, BuildContextOptions, FindRelevantContextOptions } from '../types';
|
|
8
|
+
import { QueryBuilder } from '../db/queries';
|
|
9
|
+
import { GraphTraverser } from '../graph';
|
|
10
|
+
export { LOW_CONFIDENCE_MARKER } from './markers';
|
|
11
|
+
/**
|
|
12
|
+
* Context Builder
|
|
13
|
+
*
|
|
14
|
+
* Coordinates semantic search and graph traversal to build
|
|
15
|
+
* comprehensive context for tasks.
|
|
16
|
+
*/
|
|
17
|
+
export declare class ContextBuilder {
|
|
18
|
+
private projectRoot;
|
|
19
|
+
private queries;
|
|
20
|
+
private traverser;
|
|
21
|
+
constructor(projectRoot: string, queries: QueryBuilder, traverser: GraphTraverser);
|
|
22
|
+
/**
|
|
23
|
+
* Build context for a task
|
|
24
|
+
*
|
|
25
|
+
* Pipeline:
|
|
26
|
+
* 1. Parse task input (string or {title, description})
|
|
27
|
+
* 2. Run semantic search to find entry points
|
|
28
|
+
* 3. Expand graph around entry points
|
|
29
|
+
* 4. Extract code blocks for key nodes
|
|
30
|
+
* 5. Format output for Claude
|
|
31
|
+
*
|
|
32
|
+
* @param input - Task description or object with title/description
|
|
33
|
+
* @param options - Build options
|
|
34
|
+
* @returns TaskContext (structured) or formatted string
|
|
35
|
+
*/
|
|
36
|
+
buildContext(input: TaskInput, options?: BuildContextOptions): Promise<TaskContext | string>;
|
|
37
|
+
/**
|
|
38
|
+
* Honest handoff appended when retrieval confidence is low (the query matched
|
|
39
|
+
* mostly common words). Instead of the usual "this covers the surface" framing
|
|
40
|
+
* — which, when wrong, sends the agent off to Read/Grep — it admits the
|
|
41
|
+
* uncertainty and routes the agent to the precise tools (explore with real
|
|
42
|
+
* symbol names, search, or files to browse the closest areas we *did* surface).
|
|
43
|
+
*/
|
|
44
|
+
private buildLowConfidenceNote;
|
|
45
|
+
/**
|
|
46
|
+
* Surface short call-paths among the symbols this context already found,
|
|
47
|
+
* derived in-memory from the subgraph's `calls` edges (no extra queries).
|
|
48
|
+
*
|
|
49
|
+
* This bakes the value of path-finding INTO the always-loaded `context` tool.
|
|
50
|
+
* Agents reliably read context's output but do NOT discover/adopt a standalone
|
|
51
|
+
* trace tool (in deferred-MCP harnesses they only ToolSearch-select tools they
|
|
52
|
+
* already know). Delivering the flow here means "how does X reach Y" is
|
|
53
|
+
* answered without the agent needing to find, load, or choose a new tool.
|
|
54
|
+
* Chains stop where the static call graph ends (e.g. dynamic dispatch) — that
|
|
55
|
+
* truncation is honest, and the agent can codegraph_node the last hop to bridge.
|
|
56
|
+
*/
|
|
57
|
+
private buildCallPathsSection;
|
|
58
|
+
/**
|
|
59
|
+
* Find relevant subgraph for a query
|
|
60
|
+
*
|
|
61
|
+
* Uses hybrid search combining exact symbol lookup with semantic search:
|
|
62
|
+
* 1. Extract potential symbol names from query
|
|
63
|
+
* 2. Look up exact matches for those symbols (high confidence)
|
|
64
|
+
* 3. Use semantic search for concept matching
|
|
65
|
+
* 4. Merge results, prioritizing exact matches
|
|
66
|
+
* 5. Traverse graph from entry points
|
|
67
|
+
*
|
|
68
|
+
* @param query - Natural language query
|
|
69
|
+
* @param options - Search and traversal options
|
|
70
|
+
* @returns Subgraph of relevant nodes and edges
|
|
71
|
+
*/
|
|
72
|
+
findRelevantContext(query: string, options?: FindRelevantContextOptions): Promise<Subgraph>;
|
|
73
|
+
/**
|
|
74
|
+
* Get the source code for a node
|
|
75
|
+
*
|
|
76
|
+
* Reads the file and extracts the code between startLine and endLine.
|
|
77
|
+
*
|
|
78
|
+
* @param nodeId - ID of the node
|
|
79
|
+
* @returns Code string or null if not found
|
|
80
|
+
*/
|
|
81
|
+
getCode(nodeId: string): Promise<string | null>;
|
|
82
|
+
/**
|
|
83
|
+
* Extract code from a node's source file
|
|
84
|
+
*/
|
|
85
|
+
private extractNodeCode;
|
|
86
|
+
/**
|
|
87
|
+
* Get entry points from a subgraph (the root nodes)
|
|
88
|
+
*/
|
|
89
|
+
private getEntryPoints;
|
|
90
|
+
/**
|
|
91
|
+
* Extract code blocks for key nodes in the subgraph
|
|
92
|
+
*/
|
|
93
|
+
private extractCodeBlocks;
|
|
94
|
+
/**
|
|
95
|
+
* Get unique files from a subgraph
|
|
96
|
+
*/
|
|
97
|
+
private getRelatedFiles;
|
|
98
|
+
/**
|
|
99
|
+
* Generate a summary of the context
|
|
100
|
+
*/
|
|
101
|
+
private generateSummary;
|
|
102
|
+
/**
|
|
103
|
+
* Resolve import/export nodes to their actual definitions
|
|
104
|
+
*
|
|
105
|
+
* When search returns `import { TerminalPanel }`, users want the TerminalPanel
|
|
106
|
+
* class definition, not the import statement. This follows the `imports` edge
|
|
107
|
+
* to find and return the actual definition instead.
|
|
108
|
+
*
|
|
109
|
+
* @param results - Search results that may include import/export nodes
|
|
110
|
+
* @returns Results with imports resolved to definitions where possible
|
|
111
|
+
*/
|
|
112
|
+
private resolveImportsToDefinitions;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Create a context builder
|
|
116
|
+
*/
|
|
117
|
+
export declare function createContextBuilder(projectRoot: string, queries: QueryBuilder, traverser: GraphTraverser): ContextBuilder;
|
|
118
|
+
export { formatContextAsMarkdown, formatContextAsJson } from './formatter';
|
|
119
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stable sentinel strings shared between the context builder (which emits them
|
|
3
|
+
* into its markdown) and the MCP layer (which detects them to adjust framing).
|
|
4
|
+
*
|
|
5
|
+
* Intentionally a dependency-free leaf module: the MCP tool layer imports this
|
|
6
|
+
* to recognise a low-confidence response, and routing that recognition through
|
|
7
|
+
* the full context module would drag its dependencies onto the cold-start path.
|
|
8
|
+
* Keep this file import-free.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Heading that leads the honest low-confidence handoff appended to a context
|
|
12
|
+
* response when the query resolved only to weak/isolated matches. The MCP layer
|
|
13
|
+
* checks for it to suppress the contradictory "this is comprehensive, don't call
|
|
14
|
+
* explore" small-repo footer. Changing the text is a breaking sentinel change —
|
|
15
|
+
* both the emitter (`ContextBuilder`) and the detector (`src/mcp/tools.ts`)
|
|
16
|
+
* import this constant, so they stay in sync automatically.
|
|
17
|
+
*/
|
|
18
|
+
export declare const LOW_CONFIDENCE_MARKER = "### \u26A0\uFE0F Low-confidence match";
|
|
19
|
+
//# sourceMappingURL=markers.d.ts.map
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Database Layer
|
|
3
|
+
*
|
|
4
|
+
* Handles SQLite database initialization and connection management.
|
|
5
|
+
*/
|
|
6
|
+
import { SqliteDatabase, SqliteBackend } from './sqlite-adapter';
|
|
7
|
+
import { SchemaVersion } from '../types';
|
|
8
|
+
export { SqliteDatabase, SqliteBackend } from './sqlite-adapter';
|
|
9
|
+
/**
|
|
10
|
+
* Database connection wrapper with lifecycle management
|
|
11
|
+
*/
|
|
12
|
+
export declare class DatabaseConnection {
|
|
13
|
+
private db;
|
|
14
|
+
private dbPath;
|
|
15
|
+
private backend;
|
|
16
|
+
/**
|
|
17
|
+
* `dev:ino` of the DB file at the moment we opened it (or null when the
|
|
18
|
+
* platform/filesystem reports no usable inode). Lets us notice when the file
|
|
19
|
+
* we hold open has been unlinked and REPLACED by a new file at the same path
|
|
20
|
+
* — a git worktree removed and re-added, or `.codegraph/` deleted and
|
|
21
|
+
* re-`init`ed under a long-lived server — at which point our fd reads a now
|
|
22
|
+
* dead inode forever (#925). See `isReplacedOnDisk`.
|
|
23
|
+
*/
|
|
24
|
+
private openedInode;
|
|
25
|
+
private constructor();
|
|
26
|
+
/**
|
|
27
|
+
* Initialize a new database at the given path
|
|
28
|
+
*/
|
|
29
|
+
static initialize(dbPath: string): DatabaseConnection;
|
|
30
|
+
/**
|
|
31
|
+
* Open an existing database
|
|
32
|
+
*/
|
|
33
|
+
static open(dbPath: string): DatabaseConnection;
|
|
34
|
+
/**
|
|
35
|
+
* Get the underlying database instance
|
|
36
|
+
*/
|
|
37
|
+
getDb(): SqliteDatabase;
|
|
38
|
+
/**
|
|
39
|
+
* Get the SQLite backend serving this connection. Per-instance so
|
|
40
|
+
* MCP cross-project queries report the right backend even when
|
|
41
|
+
* multiple project DBs are open in the same process.
|
|
42
|
+
*/
|
|
43
|
+
getBackend(): SqliteBackend;
|
|
44
|
+
/**
|
|
45
|
+
* Get database file path
|
|
46
|
+
*/
|
|
47
|
+
getPath(): string;
|
|
48
|
+
/**
|
|
49
|
+
* The journal mode actually in effect (e.g. 'wal', 'delete').
|
|
50
|
+
*
|
|
51
|
+
* SQLite silently keeps the prior mode if WAL can't be enabled — e.g. on
|
|
52
|
+
* filesystems without shared-memory support (some network/virtualized mounts,
|
|
53
|
+
* WSL2 /mnt). So the effective mode can differ
|
|
54
|
+
* from what `configureConnection` requested. Surfaced in `codegraph status` so
|
|
55
|
+
* a "database is locked" report is triageable: 'wal' ⇒ readers never block on a
|
|
56
|
+
* writer; anything else ⇒ they can. See issue #238.
|
|
57
|
+
*/
|
|
58
|
+
getJournalMode(): string;
|
|
59
|
+
/**
|
|
60
|
+
* Get current schema version
|
|
61
|
+
*/
|
|
62
|
+
getSchemaVersion(): SchemaVersion | null;
|
|
63
|
+
/**
|
|
64
|
+
* Execute a function within a transaction
|
|
65
|
+
*/
|
|
66
|
+
transaction<T>(fn: () => T): T;
|
|
67
|
+
/**
|
|
68
|
+
* Get database file size in bytes
|
|
69
|
+
*/
|
|
70
|
+
getSize(): number;
|
|
71
|
+
/**
|
|
72
|
+
* Optimize database (vacuum and analyze)
|
|
73
|
+
*/
|
|
74
|
+
optimize(): void;
|
|
75
|
+
/**
|
|
76
|
+
* Lightweight, non-blocking maintenance to run after bulk writes
|
|
77
|
+
* (indexAll, sync). Two operations:
|
|
78
|
+
*
|
|
79
|
+
* - `PRAGMA optimize` — incremental ANALYZE; SQLite only re-analyzes
|
|
80
|
+
* tables whose row counts changed materially since the last
|
|
81
|
+
* ANALYZE. Without it, the query planner has no statistics on the
|
|
82
|
+
* freshly-bulk-loaded tables and can pick suboptimal indexes.
|
|
83
|
+
*
|
|
84
|
+
* - `PRAGMA wal_checkpoint(PASSIVE)` — fold pending WAL pages back
|
|
85
|
+
* into the main database file so the WAL file doesn't grow
|
|
86
|
+
* unboundedly between automatic checkpoints (auto-fires at 1000
|
|
87
|
+
* pages by default; large indexAll runs blow past that).
|
|
88
|
+
*
|
|
89
|
+
* Both operations are silently swallowed on failure — they're a
|
|
90
|
+
* best-effort optimization, never load-bearing for correctness.
|
|
91
|
+
*/
|
|
92
|
+
runMaintenance(): void;
|
|
93
|
+
/**
|
|
94
|
+
* Close the database connection
|
|
95
|
+
*/
|
|
96
|
+
close(): void;
|
|
97
|
+
/**
|
|
98
|
+
* Check if the database connection is open
|
|
99
|
+
*/
|
|
100
|
+
isOpen(): boolean;
|
|
101
|
+
/**
|
|
102
|
+
* True when the DB file at our path has been REPLACED on disk since we opened
|
|
103
|
+
* it — a different inode now lives at the same path, so the fd we still hold
|
|
104
|
+
* points at a now-unlinked inode that can never receive new writes (#925).
|
|
105
|
+
* The trigger is removing and recreating `.codegraph/` at the same path under
|
|
106
|
+
* a long-lived process (`git worktree remove` + re-add, or `rm -rf
|
|
107
|
+
* .codegraph` + `codegraph init`). Returns false when the inode is unchanged,
|
|
108
|
+
* when the file is momentarily absent (mid-recreate — nothing to reopen onto
|
|
109
|
+
* yet), or when the platform doesn't report a usable inode (Windows can't
|
|
110
|
+
* unlink an open file and its st_ino is unreliable, so this never fires there).
|
|
111
|
+
*/
|
|
112
|
+
isReplacedOnDisk(): boolean;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Default database filename
|
|
116
|
+
*/
|
|
117
|
+
export declare const DATABASE_FILENAME = "codegraph.db";
|
|
118
|
+
/**
|
|
119
|
+
* Get the default database path for a project
|
|
120
|
+
*/
|
|
121
|
+
export declare function getDatabasePath(projectRoot: string): string;
|
|
122
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Database Migrations
|
|
3
|
+
*
|
|
4
|
+
* Schema versioning and migration support.
|
|
5
|
+
*/
|
|
6
|
+
import { SqliteDatabase } from './sqlite-adapter';
|
|
7
|
+
/**
|
|
8
|
+
* Current schema version
|
|
9
|
+
*/
|
|
10
|
+
export declare const CURRENT_SCHEMA_VERSION = 5;
|
|
11
|
+
/**
|
|
12
|
+
* Migration definition
|
|
13
|
+
*/
|
|
14
|
+
interface Migration {
|
|
15
|
+
version: number;
|
|
16
|
+
description: string;
|
|
17
|
+
up: (db: SqliteDatabase) => void;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Get the current schema version from the database
|
|
21
|
+
*/
|
|
22
|
+
export declare function getCurrentVersion(db: SqliteDatabase): number;
|
|
23
|
+
/**
|
|
24
|
+
* Run all pending migrations
|
|
25
|
+
*/
|
|
26
|
+
export declare function runMigrations(db: SqliteDatabase, fromVersion: number): void;
|
|
27
|
+
/**
|
|
28
|
+
* Check if the database needs migration
|
|
29
|
+
*/
|
|
30
|
+
export declare function needsMigration(db: SqliteDatabase): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Get list of pending migrations
|
|
33
|
+
*/
|
|
34
|
+
export declare function getPendingMigrations(db: SqliteDatabase): Migration[];
|
|
35
|
+
/**
|
|
36
|
+
* Get migration history from database
|
|
37
|
+
*/
|
|
38
|
+
export declare function getMigrationHistory(db: SqliteDatabase): Array<{
|
|
39
|
+
version: number;
|
|
40
|
+
appliedAt: number;
|
|
41
|
+
description: string | null;
|
|
42
|
+
}>;
|
|
43
|
+
export {};
|
|
44
|
+
//# sourceMappingURL=migrations.d.ts.map
|