@colbymchenry/codegraph 1.1.6 → 1.3.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/README.md +95 -2
- package/dist/bin/codegraph.d.ts +1 -1
- package/dist/db/migrations.d.ts +1 -1
- package/dist/db/queries.d.ts +51 -0
- package/dist/directory.d.ts +9 -5
- package/dist/extraction/cfml-extractor.d.ts +107 -0
- package/dist/extraction/grammars.d.ts +9 -0
- package/dist/extraction/index.d.ts +46 -1
- package/dist/extraction/languages/arkts.d.ts +3 -0
- package/dist/extraction/languages/c-cpp.d.ts +59 -0
- package/dist/extraction/languages/cfquery.d.ts +12 -0
- package/dist/extraction/languages/cfscript.d.ts +3 -0
- package/dist/extraction/languages/cobol.d.ts +33 -0
- package/dist/extraction/languages/erlang.d.ts +3 -0
- package/dist/extraction/languages/nix.d.ts +3 -0
- package/dist/extraction/languages/solidity.d.ts +3 -0
- package/dist/extraction/languages/terraform.d.ts +3 -0
- package/dist/extraction/languages/vbnet.d.ts +11 -0
- package/dist/extraction/mybatis-extractor.d.ts +30 -10
- package/dist/extraction/tree-sitter-types.d.ts +20 -1
- package/dist/extraction/tree-sitter.d.ts +38 -0
- package/dist/index.d.ts +63 -1
- package/dist/mcp/daemon.d.ts +25 -3
- package/dist/mcp/early-ppid.d.ts +26 -0
- package/dist/mcp/startup-handshake.d.ts +44 -0
- package/dist/mcp/tools.d.ts +22 -0
- package/dist/project-config.d.ts +38 -0
- package/dist/resolution/callback-synthesizer.d.ts +1 -1
- package/dist/resolution/cooperative-yield.d.ts +32 -0
- package/dist/resolution/frameworks/cics.d.ts +20 -0
- package/dist/resolution/frameworks/terraform.d.ts +38 -0
- package/dist/resolution/import-resolver.d.ts +7 -0
- package/dist/resolution/index.d.ts +44 -2
- package/dist/resolution/name-matcher.d.ts +22 -3
- package/dist/resolution/strip-comments.d.ts +1 -1
- package/dist/resolution/types.d.ts +20 -0
- package/dist/resolution/workspace-packages.d.ts +10 -0
- package/dist/search/identifier-segments.d.ts +60 -0
- package/dist/sync/watcher.d.ts +10 -5
- package/dist/types.d.ts +19 -1
- package/npm-shim.js +9 -2
- package/package.json +7 -7
- package/dist/reasoning/config.d.ts +0 -45
- package/dist/reasoning/credentials.d.ts +0 -5
- package/dist/reasoning/login.d.ts +0 -21
- package/dist/reasoning/reasoner.d.ts +0 -43
|
@@ -27,6 +27,9 @@ export declare class ReferenceResolver {
|
|
|
27
27
|
private nameCache;
|
|
28
28
|
private lowerNameCache;
|
|
29
29
|
private qualifiedNameCache;
|
|
30
|
+
private fileLinesCache;
|
|
31
|
+
private methodMatchCache;
|
|
32
|
+
private nodesByKindCache;
|
|
30
33
|
private knownNames;
|
|
31
34
|
private knownFiles;
|
|
32
35
|
private cachesWarmed;
|
|
@@ -58,6 +61,8 @@ export declare class ReferenceResolver {
|
|
|
58
61
|
* Clear internal caches
|
|
59
62
|
*/
|
|
60
63
|
clearCaches(): void;
|
|
64
|
+
/** `readFile` through the LRU content cache (null = read failed, also cached). */
|
|
65
|
+
private readFileCached;
|
|
61
66
|
/**
|
|
62
67
|
* Create the resolution context
|
|
63
68
|
*/
|
|
@@ -103,7 +108,21 @@ export declare class ReferenceResolver {
|
|
|
103
108
|
* (re-resolving an already-resolved ref is a no-op since it's been deleted).
|
|
104
109
|
* Returns the number of newly-created edges.
|
|
105
110
|
*/
|
|
106
|
-
resolveChainedCallsViaConformance(): number
|
|
111
|
+
resolveChainedCallsViaConformance(): Promise<number>;
|
|
112
|
+
/**
|
|
113
|
+
* Resolve one batch with a yield checkpoint between EVERY ref so the #850
|
|
114
|
+
* liveness heartbeat can fire on a slow/dense batch (#1091). The checkpoint
|
|
115
|
+
* granularity is per-ref — not per-N-refs — because per-ref cost is unbounded
|
|
116
|
+
* in the worst case (a collision-heavy method name whose candidate set misses
|
|
117
|
+
* the LRU re-fetches tens of thousands of rows): any fixed N multiplies that
|
|
118
|
+
* worst case into the watchdog window, which is how v1.2.0 still got killed
|
|
119
|
+
* at "Resolving refs" on large Java monorepos (#1122). `maybeYield()` is a
|
|
120
|
+
* ~ns time check when under budget, so per-ref checkpoints cost nothing.
|
|
121
|
+
* Behaviourally identical to `resolveAll(batch)`: `warmCaches()` is
|
|
122
|
+
* idempotent (guarded) and `resolveOne` is independent per ref, so yielding
|
|
123
|
+
* between refs changes only timing, never which edges get created.
|
|
124
|
+
*/
|
|
125
|
+
private resolveBatchYielding;
|
|
107
126
|
/**
|
|
108
127
|
* Resolve and persist in batches to keep memory bounded.
|
|
109
128
|
* Processes unresolved references in chunks, persisting edges and cleaning
|
|
@@ -152,6 +171,29 @@ export declare class ReferenceResolver {
|
|
|
152
171
|
* through to name-matching).
|
|
153
172
|
*/
|
|
154
173
|
private resolveRazorUsing;
|
|
174
|
+
/**
|
|
175
|
+
* Resolve a CFML inheritance reference written as a component path (#1152).
|
|
176
|
+
* Two forms exist in real code:
|
|
177
|
+
*
|
|
178
|
+
* - Dotted: `extends="coldbox.system.web.Controller"` — dots are directory
|
|
179
|
+
* separators from the webroot or a CFML mapping. Mappings live in server
|
|
180
|
+
* config / Application.cfc, so the leading segments may not exist in the
|
|
181
|
+
* repo at all (in the coldbox repo itself the path is `system/web/
|
|
182
|
+
* Controller.cfc` — the `coldbox.` root IS the repo). Matched by final
|
|
183
|
+
* segment (the class), corroborated right-to-left against the candidate's
|
|
184
|
+
* parent directories.
|
|
185
|
+
* - Relative: `extends="../base"` / `extends="./base"` (the FW/1 style) —
|
|
186
|
+
* resolved against the referencing file's own directory.
|
|
187
|
+
*
|
|
188
|
+
* Conservative by design: a candidate needs at least one corroborating
|
|
189
|
+
* directory segment (a dotted path whose only same-named class sits in an
|
|
190
|
+
* unrelated directory is almost always an out-of-repo library supertype —
|
|
191
|
+
* mxunit/testbox/coldbox-as-dependency), and a corroboration tie yields no
|
|
192
|
+
* edge. Directory comparison is case-insensitive (CFML path resolution is);
|
|
193
|
+
* the class segment itself is matched exactly, which real code satisfies —
|
|
194
|
+
* dotted paths are written to match the on-disk file name.
|
|
195
|
+
*/
|
|
196
|
+
private resolveCfmlComponentPath;
|
|
155
197
|
/**
|
|
156
198
|
* Resolve a `this.<member>` function-as-value reference (#756/#808) to the
|
|
157
199
|
* ENCLOSING CLASS's own member — never a same-named symbol elsewhere. The
|
|
@@ -172,7 +214,7 @@ export declare class ReferenceResolver {
|
|
|
172
214
|
* Mirrors resolveChainedCallsViaConformance's lifecycle. Returns the number
|
|
173
215
|
* of newly-created edges.
|
|
174
216
|
*/
|
|
175
|
-
resolveDeferredThisMemberRefs(): number
|
|
217
|
+
resolveDeferredThisMemberRefs(): Promise<number>;
|
|
176
218
|
private gateLanguage;
|
|
177
219
|
/**
|
|
178
220
|
* Drop a FRAMEWORK-strategy resolution that crosses two *known* language
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Handles symbol name matching for reference resolution.
|
|
5
5
|
*/
|
|
6
|
+
import { Node } from '../types';
|
|
6
7
|
import { UnresolvedRef, ResolvedRef, ResolutionContext } from './types';
|
|
7
8
|
/**
|
|
8
9
|
* Try to resolve a path-like reference (e.g., "snippets/drawer-menu.liquid")
|
|
@@ -47,6 +48,27 @@ export declare function matchByExactName(ref: UnresolvedRef, context: Resolution
|
|
|
47
48
|
* Try to resolve by qualified name
|
|
48
49
|
*/
|
|
49
50
|
export declare function matchByQualifiedName(ref: UnresolvedRef, context: ResolutionContext): ResolvedRef | null;
|
|
51
|
+
/**
|
|
52
|
+
* When a symbol name is ambiguous across files, prefer the candidate(s) declared
|
|
53
|
+
* in the call site's own file, keeping the rest in their original order (#1079).
|
|
54
|
+
* A same-file definition is the strongest language-agnostic signal for which of
|
|
55
|
+
* several same-named symbols a call means; without it, resolution collapses onto
|
|
56
|
+
* whichever was indexed first, so a call in `b/svc` wrongly targets `a/svc`.
|
|
57
|
+
* No-op when there are <2 candidates or none share the call site's file.
|
|
58
|
+
*/
|
|
59
|
+
export declare function preferCallSiteFile(nodes: Node[], callSiteFile: string): Node[];
|
|
60
|
+
export declare function resolveMethodOnType(typeName: string, methodName: string, ref: UnresolvedRef, context: ResolutionContext, confidence: number, resolvedBy: ResolvedRef['resolvedBy'],
|
|
61
|
+
/**
|
|
62
|
+
* Optional FQN that identifies WHICH class declaration `typeName`
|
|
63
|
+
* refers to in the caller's file. When multiple candidates share
|
|
64
|
+
* the same qualifiedName (`FooConverter::convert` in both
|
|
65
|
+
* `dao/converter/` and `service/converter/`), the FQN's
|
|
66
|
+
* file-path-suffix picks the right one — the disambiguation
|
|
67
|
+
* signal Java imports carry but the call site doesn't (#314).
|
|
68
|
+
*/
|
|
69
|
+
preferredFqn?: string,
|
|
70
|
+
/** Recursion guard for the supertype/conformance walk. */
|
|
71
|
+
depth?: number): ResolvedRef | null;
|
|
50
72
|
/**
|
|
51
73
|
* Resolve a C++ chained call whose receiver is itself a call — encoded by the
|
|
52
74
|
* extractor as `<innerCallee>().<method>` (#645). The receiver's type is what
|
|
@@ -86,8 +108,5 @@ export declare function matchMethodCall(ref: UnresolvedRef, context: ResolutionC
|
|
|
86
108
|
* Fuzzy match - last resort with lower confidence
|
|
87
109
|
*/
|
|
88
110
|
export declare function matchFuzzy(ref: UnresolvedRef, context: ResolutionContext): ResolvedRef | null;
|
|
89
|
-
/**
|
|
90
|
-
* Match all strategies in order of confidence
|
|
91
|
-
*/
|
|
92
111
|
export declare function matchReference(ref: UnresolvedRef, context: ResolutionContext): ResolvedRef | null;
|
|
93
112
|
//# sourceMappingURL=name-matcher.d.ts.map
|
|
@@ -22,6 +22,6 @@
|
|
|
22
22
|
* `path(...)`, `Route::get(...)`, `app.get(...)` style patterns that
|
|
23
23
|
* framework extractors scan for.
|
|
24
24
|
*/
|
|
25
|
-
export type CommentLang = 'python' | 'javascript' | 'typescript' | 'php' | 'ruby' | 'java' | 'csharp' | 'swift' | 'go' | 'rust' | 'c' | 'cpp';
|
|
25
|
+
export type CommentLang = 'python' | 'javascript' | 'typescript' | 'php' | 'ruby' | 'java' | 'csharp' | 'swift' | 'go' | 'rust' | 'c' | 'cpp' | 'erlang';
|
|
26
26
|
export declare function stripCommentsForRegex(content: string, lang: CommentLang): string;
|
|
27
27
|
//# sourceMappingURL=strip-comments.d.ts.map
|
|
@@ -70,6 +70,26 @@ export interface ResolutionContext {
|
|
|
70
70
|
fileExists(filePath: string): boolean;
|
|
71
71
|
/** Read file content */
|
|
72
72
|
readFile(filePath: string): string | null;
|
|
73
|
+
/**
|
|
74
|
+
* `readFile(filePath)` split into lines, LRU-cached per file. Receiver-type
|
|
75
|
+
* inference scans source lines for EVERY `receiver.method()` ref; splitting
|
|
76
|
+
* the whole file per ref made that O(refs-in-file × file-size) — ~20% of
|
|
77
|
+
* total index CPU on a Java-heavy repo and a driver of the #1122 watchdog
|
|
78
|
+
* kill on large ones. Optional so external/test contexts compile without it;
|
|
79
|
+
* callers fall back to splitting `readFile` themselves.
|
|
80
|
+
*/
|
|
81
|
+
getFileLines?(filePath: string): string[] | null;
|
|
82
|
+
/**
|
|
83
|
+
* The method-definition nodes matching `typeName::methodName` in `language` —
|
|
84
|
+
* exactly `resolveMethodOnType`'s kind/language/qualifiedName-suffix filter,
|
|
85
|
+
* LRU-cached per (language, type, method). The uncached path re-fetches every
|
|
86
|
+
* node sharing the METHOD name (unbounded — tens of thousands on a collision-
|
|
87
|
+
* heavy Java repo) and re-scans it per ref, the dominant term in the #1122
|
|
88
|
+
* watchdog kill. Cached entries hold only the small filtered result; per-ref
|
|
89
|
+
* disambiguation (import FQN, call-site file) stays in the caller so a cached
|
|
90
|
+
* entry is valid from any call site. Optional for external/test contexts.
|
|
91
|
+
*/
|
|
92
|
+
getMethodMatches?(typeName: string, methodName: string, language: Language): Node[];
|
|
73
93
|
/** Get project root */
|
|
74
94
|
getProjectRoot(): string;
|
|
75
95
|
/** Get all files */
|
|
@@ -26,6 +26,16 @@
|
|
|
26
26
|
export interface WorkspacePackages {
|
|
27
27
|
/** Member package `name` → directory relative to projectRoot (posix). */
|
|
28
28
|
byName: Map<string, string>;
|
|
29
|
+
/**
|
|
30
|
+
* Member package `name` → its declared ENTRY FILE relative to projectRoot
|
|
31
|
+
* (posix), when the member's manifest names one (ohpm's oh-package.json5
|
|
32
|
+
* `"main": "Index.ets"`). Lets a bare `import { X } from "data"` resolve to
|
|
33
|
+
* the member's real barrel even when it doesn't follow an index-file
|
|
34
|
+
* convention — and independent of the CONSUMER's language (a `.ts` file
|
|
35
|
+
* importing an `.ets` barrel resolves without `.ets` in the TS candidate
|
|
36
|
+
* list). Absent for npm/pnpm members (their index conventions cover it).
|
|
37
|
+
*/
|
|
38
|
+
entryByName?: Map<string, string>;
|
|
29
39
|
}
|
|
30
40
|
/**
|
|
31
41
|
* Load workspace member packages for `projectRoot`. Returns `null` when
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Identifier-segment utilities for the prompt hook's graph-derived gate
|
|
3
|
+
* (name_segment_vocab): symbol names split into the words a human would use
|
|
4
|
+
* for them in prose, and prompt prose normalized into candidate words to look
|
|
5
|
+
* those segments up with.
|
|
6
|
+
*
|
|
7
|
+
* "OrderStateMachine" → order / state / machine — so the French prompt
|
|
8
|
+
* "comment marche la state machine des commandes ?" (or any language's prose
|
|
9
|
+
* naming the concept in Latin script) can be verified against the graph
|
|
10
|
+
* without a keyword list ever knowing the words. The FTS index can't serve
|
|
11
|
+
* this — its tokenizer keeps camelCase names as single tokens — which is why
|
|
12
|
+
* segments are materialized at index time instead (see schema.sql,
|
|
13
|
+
* name_segment_vocab).
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Split a symbol or file name into lowercase word segments.
|
|
17
|
+
*
|
|
18
|
+
* Handles camelCase / PascalCase (inner lower→Upper), acronym runs
|
|
19
|
+
* ("HTMLParser" → html/parser), snake_case / kebab-case / dotted file names
|
|
20
|
+
* (non-alphanumerics separate), and keeps digits glued to their word
|
|
21
|
+
* ("base64Encode" → base64/encode). Digit-only fragments are dropped.
|
|
22
|
+
*/
|
|
23
|
+
export declare function splitIdentifierSegments(name: string): string[];
|
|
24
|
+
/**
|
|
25
|
+
* Normalize a prose word for segment lookup: lowercase + strip diacritics
|
|
26
|
+
* (NFD, drop combining marks), so "références" matches the segment
|
|
27
|
+
* "references" and "résolution" matches "resolution". Identifier segments are
|
|
28
|
+
* overwhelmingly ASCII, so this is what buys Latin-script languages their
|
|
29
|
+
* cross-lingual reach on loanwords.
|
|
30
|
+
*/
|
|
31
|
+
export declare function normalizeProseWord(word: string): string;
|
|
32
|
+
/**
|
|
33
|
+
* Candidate words from a prompt for segment-vocabulary lookup, in order of
|
|
34
|
+
* appearance: Unicode letter/digit runs, normalized via
|
|
35
|
+
* {@link normalizeProseWord}, length-bounded, digit-only dropped,
|
|
36
|
+
* {@link ENGLISH_PROSE_STOPWORDS} dropped, deduped, capped. Everything that
|
|
37
|
+
* survives is judged per-repo by the rarity and co-occurrence rules in
|
|
38
|
+
* CodeGraph.getSegmentMatches — there is no domain-word list.
|
|
39
|
+
*/
|
|
40
|
+
export declare function extractProseCandidates(prompt: string): string[];
|
|
41
|
+
/**
|
|
42
|
+
* Lookup variants for a prose word: the word itself plus light plural folding
|
|
43
|
+
* ("services" → service, "dependencies" → dependencie/dependency is NOT
|
|
44
|
+
* attempted — only a trailing s/es strip), so common plurals still hit their
|
|
45
|
+
* singular segment. Returned variants map back to the same original word.
|
|
46
|
+
*
|
|
47
|
+
* The strips are keyed on English plural spelling (#1145), in three classes:
|
|
48
|
+
* - UNAMBIGUOUS `-es` (after x/sh/ss/zz: boxes, hashes, classes, quizzes) —
|
|
49
|
+
* strip 2 only. Stripping 1 minted a bogus sibling ("classes" → classe).
|
|
50
|
+
* - AMBIGUOUS endings (`-ches`/`-ses`/`-zes`/`-oes`): spelling alone can't
|
|
51
|
+
* split patches(+es) from caches(+s), lenses from databases, heroes from
|
|
52
|
+
* shoes — emit BOTH candidate keys and let the vocab lookup decide; a miss
|
|
53
|
+
* is an ignored key, a wrong exclusive guess would LOSE the real match.
|
|
54
|
+
* - Everything else ending in `-s` — a bare `-s` plural (services, machines,
|
|
55
|
+
* cookies): strip 1 only. Stripping 2 minted "services" → servic.
|
|
56
|
+
* A trailing `-ss` is a singular (class, process), not a plural: no strip —
|
|
57
|
+
* that used to mint "class" → clas.
|
|
58
|
+
*/
|
|
59
|
+
export declare function segmentLookupVariants(word: string): string[];
|
|
60
|
+
//# sourceMappingURL=identifier-segments.d.ts.map
|
package/dist/sync/watcher.d.ts
CHANGED
|
@@ -63,8 +63,9 @@ export interface WatchOptions {
|
|
|
63
63
|
onSyncError?: (error: Error) => void;
|
|
64
64
|
/**
|
|
65
65
|
* Callback fired ONCE when live watching degrades permanently and auto-sync
|
|
66
|
-
* is disabled — OS watch-resource exhaustion (EMFILE/ENFILE),
|
|
67
|
-
* held past the retry budget
|
|
66
|
+
* is disabled — OS watch-resource exhaustion (EMFILE/ENFILE), a write lock
|
|
67
|
+
* held past the retry budget, or a generic sync failure that persists past
|
|
68
|
+
* the retry budget (#1127). The string is an actionable, human-readable
|
|
68
69
|
* reason. Lets a host (MCP server, daemon, CLI) tell the user that the index
|
|
69
70
|
* will no longer auto-update instead of silently serving stale results.
|
|
70
71
|
*/
|
|
@@ -139,12 +140,15 @@ export declare class FileWatcher {
|
|
|
139
140
|
private inotifyLimitWarned;
|
|
140
141
|
/**
|
|
141
142
|
* One-way latch: the reason live watching was permanently disabled at runtime
|
|
142
|
-
* (watch-resource exhaustion,
|
|
143
|
-
*
|
|
143
|
+
* (watch-resource exhaustion, lock contention past the retry budget, or a
|
|
144
|
+
* persistent generic sync failure past the retry budget), or null while
|
|
145
|
+
* healthy. Set by {@link degrade}; cleared only by a fresh start().
|
|
144
146
|
*/
|
|
145
147
|
private degradedReason;
|
|
146
148
|
/** Consecutive lock-contention retries for watcher-triggered syncs. */
|
|
147
149
|
private lockRetryCount;
|
|
150
|
+
/** Consecutive generic (non-lock) sync failures; reset only by a clean sync. */
|
|
151
|
+
private syncFailureRetryCount;
|
|
148
152
|
/** Test-only inert mode: started, but with no OS watcher installed. */
|
|
149
153
|
private inert;
|
|
150
154
|
private debounceTimer;
|
|
@@ -248,7 +252,8 @@ export declare class FileWatcher {
|
|
|
248
252
|
private shouldIgnoreDir;
|
|
249
253
|
/**
|
|
250
254
|
* Permanently disable live watching after a terminal runtime failure
|
|
251
|
-
* (watch-resource exhaustion,
|
|
255
|
+
* (watch-resource exhaustion, lock contention past the retry budget, or a
|
|
256
|
+
* persistent generic sync failure past the retry budget).
|
|
252
257
|
* Idempotent: logs one actionable warning, fires {@link WatchOptions.onDegraded}
|
|
253
258
|
* once, and stops the watcher. A subsequent start() clears the latch.
|
|
254
259
|
*/
|
package/dist/types.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export type EdgeKind = 'contains' | 'calls' | 'imports' | 'exports' | 'extends'
|
|
|
20
20
|
* Supported programming languages. See NODE_KINDS for why this is a
|
|
21
21
|
* runtime-iterable const array.
|
|
22
22
|
*/
|
|
23
|
-
export declare const LANGUAGES: readonly ["typescript", "javascript", "tsx", "jsx", "python", "go", "rust", "java", "c", "cpp", "csharp", "razor", "php", "ruby", "swift", "kotlin", "dart", "svelte", "vue", "astro", "liquid", "pascal", "scala", "lua", "luau", "objc", "r", "yaml", "twig", "xml", "properties", "unknown"];
|
|
23
|
+
export declare const LANGUAGES: readonly ["typescript", "javascript", "tsx", "jsx", "arkts", "python", "go", "rust", "java", "c", "cpp", "csharp", "razor", "php", "ruby", "swift", "kotlin", "dart", "svelte", "vue", "astro", "liquid", "pascal", "scala", "lua", "luau", "objc", "r", "solidity", "nix", "yaml", "twig", "xml", "properties", "cfml", "cfscript", "cfquery", "cobol", "vbnet", "erlang", "terraform", "unknown"];
|
|
24
24
|
export type Language = (typeof LANGUAGES)[number];
|
|
25
25
|
/**
|
|
26
26
|
* A node in the knowledge graph representing a code symbol
|
|
@@ -245,6 +245,24 @@ export interface SearchResult {
|
|
|
245
245
|
/** Matched text snippets for highlighting */
|
|
246
246
|
highlights?: string[];
|
|
247
247
|
}
|
|
248
|
+
/**
|
|
249
|
+
* A symbol whose name-segments match prose words from a prompt — the
|
|
250
|
+
* graph-derived signal behind the front-load hook's medium tier
|
|
251
|
+
* (CodeGraph.getSegmentMatches). Always verified to exist in `nodes` at the
|
|
252
|
+
* time it is returned.
|
|
253
|
+
*/
|
|
254
|
+
export interface SegmentMatch {
|
|
255
|
+
/** Symbol name as indexed (e.g. `OrderStateMachine`). */
|
|
256
|
+
name: string;
|
|
257
|
+
/** Kind of the representative definition. */
|
|
258
|
+
kind: NodeKind;
|
|
259
|
+
/** File of the representative definition. */
|
|
260
|
+
filePath: string;
|
|
261
|
+
/** 1-based start line of the representative definition. */
|
|
262
|
+
startLine: number;
|
|
263
|
+
/** The prompt words (normalized) that matched this name's segments. */
|
|
264
|
+
matchedWords: string[];
|
|
265
|
+
}
|
|
248
266
|
/**
|
|
249
267
|
* Context information for code understanding
|
|
250
268
|
*/
|
package/npm-shim.js
CHANGED
|
@@ -45,7 +45,14 @@ async function main() {
|
|
|
45
45
|
// Happy path: the npm-installed optional dependency. Fall back to a download
|
|
46
46
|
// when the registry didn't deliver it.
|
|
47
47
|
var resolved = resolveInstalledBundle() || (await selfHealBundle());
|
|
48
|
-
|
|
48
|
+
// Thread the MCP host's pid (our parent) down to the bundled server so its
|
|
49
|
+
// orphan watchdog can poll the host directly. Without this, the server can
|
|
50
|
+
// only watch THIS shim — and a shim killed during the server's first ~100ms
|
|
51
|
+
// of startup used to leave the server orphaned forever (issue #1185). An
|
|
52
|
+
// already-set value (an outer launcher) wins.
|
|
53
|
+
var env = Object.assign({}, process.env);
|
|
54
|
+
if (!env.CODEGRAPH_HOST_PPID) env.CODEGRAPH_HOST_PPID = String(process.ppid);
|
|
55
|
+
var res = childProcess.spawnSync(resolved.command, resolved.args, { stdio: 'inherit', windowsHide: true, env: env });
|
|
49
56
|
if (res.error) {
|
|
50
57
|
process.stderr.write('codegraph: ' + res.error.message + '\n');
|
|
51
58
|
process.exit(1);
|
|
@@ -222,7 +229,7 @@ function extract(archive, destDir) {
|
|
|
222
229
|
var args = isWindows
|
|
223
230
|
? ['-xf', archive, '-C', destDir, '--strip-components=1']
|
|
224
231
|
: ['-xzf', archive, '-C', destDir, '--strip-components=1'];
|
|
225
|
-
var res = childProcess.spawnSync('tar', args, { stdio: 'ignore' });
|
|
232
|
+
var res = childProcess.spawnSync('tar', args, { stdio: 'ignore', windowsHide: true });
|
|
226
233
|
if (res.error) throw new Error('tar unavailable: ' + res.error.message);
|
|
227
234
|
if (res.status !== 0) throw new Error('tar exited ' + res.status);
|
|
228
235
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@colbymchenry/codegraph",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Local-first code intelligence for AI agents (MCP). Self-contained — bundles its own runtime.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"codegraph": "npm-shim.js"
|
|
@@ -15,12 +15,12 @@
|
|
|
15
15
|
"./package.json": "./package.json"
|
|
16
16
|
},
|
|
17
17
|
"optionalDependencies": {
|
|
18
|
-
"@colbymchenry/codegraph-darwin-arm64": "1.
|
|
19
|
-
"@colbymchenry/codegraph-darwin-x64": "1.
|
|
20
|
-
"@colbymchenry/codegraph-linux-arm64": "1.
|
|
21
|
-
"@colbymchenry/codegraph-linux-x64": "1.
|
|
22
|
-
"@colbymchenry/codegraph-win32-arm64": "1.
|
|
23
|
-
"@colbymchenry/codegraph-win32-x64": "1.
|
|
18
|
+
"@colbymchenry/codegraph-darwin-arm64": "1.3.0",
|
|
19
|
+
"@colbymchenry/codegraph-darwin-x64": "1.3.0",
|
|
20
|
+
"@colbymchenry/codegraph-linux-arm64": "1.3.0",
|
|
21
|
+
"@colbymchenry/codegraph-linux-x64": "1.3.0",
|
|
22
|
+
"@colbymchenry/codegraph-win32-arm64": "1.3.0",
|
|
23
|
+
"@colbymchenry/codegraph-win32-x64": "1.3.0"
|
|
24
24
|
},
|
|
25
25
|
"files": [
|
|
26
26
|
"npm-shim.js",
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/** Managed tier ("CodeGraph AI") — the metered gateway used when logged in. */
|
|
2
|
-
export declare const MANAGED_DEFAULT_URL = "https://ai.getcodegraph.com/v1";
|
|
3
|
-
/** The gateway's public model id (it translates this to the upstream provider id). */
|
|
4
|
-
export declare const MANAGED_DEFAULT_MODEL = "openai/gpt-oss-120b";
|
|
5
|
-
export interface OffloadConfig {
|
|
6
|
-
/** Managed tier: route through CodeGraph AI (metered) with the logged-in org token. */
|
|
7
|
-
managed?: boolean;
|
|
8
|
-
/** OpenAI-compatible base URL ending in `/v1` (e.g. https://api.cerebras.ai/v1). */
|
|
9
|
-
url?: string;
|
|
10
|
-
/** Model id to request (default `gpt-oss-120b` BYO, `openai/gpt-oss-120b` managed). */
|
|
11
|
-
model?: string;
|
|
12
|
-
/** Name of the env var holding the provider API key (never persisted). BYO only. */
|
|
13
|
-
keyEnv?: string;
|
|
14
|
-
/** reasoning_effort: low | medium | high (default `low`). */
|
|
15
|
-
effort?: string;
|
|
16
|
-
/** Output style: plain | report (default `plain`). */
|
|
17
|
-
style?: string;
|
|
18
|
-
}
|
|
19
|
-
export interface ResolvedOffload {
|
|
20
|
-
/** True when the offload is usable (endpoint present; for managed, a token too). */
|
|
21
|
-
enabled: boolean;
|
|
22
|
-
/** Managed tier (CodeGraph AI, metered) vs BYO endpoint. */
|
|
23
|
-
managed: boolean;
|
|
24
|
-
url?: string;
|
|
25
|
-
model: string;
|
|
26
|
-
/** Resolved API key / org token (from env, the configured `keyEnv`, or login), if any. */
|
|
27
|
-
apiKey?: string;
|
|
28
|
-
/** Where the key/token came from (for `status` display) — never the secret itself. */
|
|
29
|
-
keySource?: string;
|
|
30
|
-
effort: string;
|
|
31
|
-
style: string;
|
|
32
|
-
timeoutMs: number;
|
|
33
|
-
maxTokens: number;
|
|
34
|
-
strip: boolean;
|
|
35
|
-
debug: boolean;
|
|
36
|
-
/** Where the endpoint came from — drives `codegraph offload status`. */
|
|
37
|
-
origin: 'env' | 'config' | 'none';
|
|
38
|
-
}
|
|
39
|
-
/** The persisted offload block (empty object if none). */
|
|
40
|
-
export declare function readOffloadConfig(): OffloadConfig;
|
|
41
|
-
/** Persist (or, with `null`, clear) the offload block, leaving other config keys intact. */
|
|
42
|
-
export declare function writeOffloadConfig(offload: OffloadConfig | null): void;
|
|
43
|
-
/** Merge the persisted config with `CODEGRAPH_OFFLOAD_*` env overrides (env wins). */
|
|
44
|
-
export declare function resolveOffload(env?: NodeJS.ProcessEnv): ResolvedOffload;
|
|
45
|
-
//# sourceMappingURL=config.d.ts.map
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
/** The stored managed-offload org token, if the machine is logged in. */
|
|
2
|
-
export declare function readOffloadToken(): string | undefined;
|
|
3
|
-
/** Persist (or, with `null`, clear) the managed-offload org token at `0600`. */
|
|
4
|
-
export declare function writeOffloadToken(token: string | null): void;
|
|
5
|
-
//# sourceMappingURL=credentials.d.ts.map
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/** Dashboard base for the device-login endpoints; override for testing via CODEGRAPH_LOGIN_URL. */
|
|
2
|
-
export declare function loginBaseUrl(): string;
|
|
3
|
-
/** The dashboard's response to a device-authorization start request. */
|
|
4
|
-
export interface DeviceStart {
|
|
5
|
-
device_code: string;
|
|
6
|
-
user_code: string;
|
|
7
|
-
verification_uri: string;
|
|
8
|
-
/** Same URL with the code prefilled, for one-click open. */
|
|
9
|
-
verification_uri_complete?: string;
|
|
10
|
-
/** Seconds the CLI should wait between polls. */
|
|
11
|
-
interval?: number;
|
|
12
|
-
/** Seconds until the request expires. */
|
|
13
|
-
expires_in?: number;
|
|
14
|
-
}
|
|
15
|
-
/** Begin a device-authorization request. */
|
|
16
|
-
export declare function startDeviceLogin(): Promise<DeviceStart>;
|
|
17
|
-
/** Poll until the user approves in the browser; resolves with the org token. */
|
|
18
|
-
export declare function pollForToken(deviceCode: string, intervalSec: number, expiresInSec: number): Promise<string>;
|
|
19
|
-
/** Best-effort: open a URL in the default browser. Never throws — the URL is also printed. */
|
|
20
|
-
export declare function openBrowser(url: string): Promise<void>;
|
|
21
|
-
//# sourceMappingURL=login.d.ts.map
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
interface SynthArgs {
|
|
2
|
-
query: string;
|
|
3
|
-
context: string;
|
|
4
|
-
}
|
|
5
|
-
/** True when a reasoning offload endpoint is configured (env or `~/.codegraph/config.json`). */
|
|
6
|
-
export declare function isOffloadEnabled(): boolean;
|
|
7
|
-
export interface OffloadUsage {
|
|
8
|
-
plan?: string;
|
|
9
|
-
allowance?: number;
|
|
10
|
-
used?: number;
|
|
11
|
-
overage?: number;
|
|
12
|
-
remaining?: number;
|
|
13
|
-
periodEnd?: number;
|
|
14
|
-
unlimited?: boolean;
|
|
15
|
-
banned?: boolean;
|
|
16
|
-
tokensLast30?: number;
|
|
17
|
-
callsLast30?: number;
|
|
18
|
-
creditsLast30?: number;
|
|
19
|
-
models?: string[];
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* GET `/v1/usage` from the configured (managed) endpoint → the org's credit
|
|
23
|
-
* balance/usage, or null on any failure. Drives `codegraph offload status`.
|
|
24
|
-
*/
|
|
25
|
-
export declare function fetchUsage(): Promise<OffloadUsage | null>;
|
|
26
|
-
/**
|
|
27
|
-
* Strip sections of the explore output addressed to the AGENT (not useful to a
|
|
28
|
-
* reasoning model): the "Not shown above" pointer list, the completeness signal,
|
|
29
|
-
* the explore-budget note, the trimmed/truncation notices, and the redundant
|
|
30
|
-
* "## Exploration:/Found N symbols" header (the query is sent separately). Left
|
|
31
|
-
* in, some models regurgitate them ("We have 2 explore calls. Let's explore…")
|
|
32
|
-
* and they add noise. Source code, blast radius, relationships, and flow stay.
|
|
33
|
-
* Opt-in (`CODEGRAPH_OFFLOAD_STRIP=1`) — default off (it also removes the "Not
|
|
34
|
-
* shown above" pointers, which can be useful navigation).
|
|
35
|
-
*/
|
|
36
|
-
export declare function stripAgentDirectives(context: string): string;
|
|
37
|
-
/**
|
|
38
|
-
* Offload reasoning over the retrieved `context` to the configured model and
|
|
39
|
-
* return its synthesized answer, or null to signal "fall back to local source".
|
|
40
|
-
*/
|
|
41
|
-
export declare function synthesizeOffload({ query, context }: SynthArgs): Promise<string | null>;
|
|
42
|
-
export {};
|
|
43
|
-
//# sourceMappingURL=reasoner.d.ts.map
|