@colbymchenry/codegraph 1.2.0 → 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.
Files changed (44) hide show
  1. package/README.md +94 -1
  2. package/dist/bin/codegraph.d.ts +1 -1
  3. package/dist/db/migrations.d.ts +1 -1
  4. package/dist/db/queries.d.ts +51 -0
  5. package/dist/directory.d.ts +9 -5
  6. package/dist/extraction/cfml-extractor.d.ts +107 -0
  7. package/dist/extraction/grammars.d.ts +9 -0
  8. package/dist/extraction/index.d.ts +46 -1
  9. package/dist/extraction/languages/arkts.d.ts +3 -0
  10. package/dist/extraction/languages/c-cpp.d.ts +42 -0
  11. package/dist/extraction/languages/cfquery.d.ts +12 -0
  12. package/dist/extraction/languages/cfscript.d.ts +3 -0
  13. package/dist/extraction/languages/cobol.d.ts +33 -0
  14. package/dist/extraction/languages/erlang.d.ts +3 -0
  15. package/dist/extraction/languages/nix.d.ts +3 -0
  16. package/dist/extraction/languages/solidity.d.ts +3 -0
  17. package/dist/extraction/languages/terraform.d.ts +3 -0
  18. package/dist/extraction/languages/vbnet.d.ts +11 -0
  19. package/dist/extraction/mybatis-extractor.d.ts +30 -10
  20. package/dist/extraction/tree-sitter-types.d.ts +3 -1
  21. package/dist/extraction/tree-sitter.d.ts +38 -0
  22. package/dist/index.d.ts +63 -1
  23. package/dist/mcp/daemon.d.ts +25 -3
  24. package/dist/mcp/early-ppid.d.ts +26 -0
  25. package/dist/mcp/startup-handshake.d.ts +44 -0
  26. package/dist/mcp/tools.d.ts +22 -0
  27. package/dist/project-config.d.ts +38 -0
  28. package/dist/resolution/frameworks/cics.d.ts +20 -0
  29. package/dist/resolution/frameworks/terraform.d.ts +38 -0
  30. package/dist/resolution/import-resolver.d.ts +7 -0
  31. package/dist/resolution/index.d.ts +39 -6
  32. package/dist/resolution/name-matcher.d.ts +0 -3
  33. package/dist/resolution/strip-comments.d.ts +1 -1
  34. package/dist/resolution/types.d.ts +20 -0
  35. package/dist/resolution/workspace-packages.d.ts +10 -0
  36. package/dist/search/identifier-segments.d.ts +60 -0
  37. package/dist/sync/watcher.d.ts +10 -5
  38. package/dist/types.d.ts +19 -1
  39. package/npm-shim.js +8 -1
  40. package/package.json +7 -7
  41. package/dist/reasoning/config.d.ts +0 -45
  42. package/dist/reasoning/credentials.d.ts +0 -5
  43. package/dist/reasoning/login.d.ts +0 -21
  44. package/dist/reasoning/reasoner.d.ts +0 -43
@@ -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
@@ -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), or a write lock
67
- * held past the retry budget. The string is an actionable, human-readable
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, or lock contention past the retry budget), or
143
- * null while healthy. Set by {@link degrade}; cleared only by a fresh start().
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, or lock contention past the retry budget).
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
- var res = childProcess.spawnSync(resolved.command, resolved.args, { stdio: 'inherit', windowsHide: true });
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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@colbymchenry/codegraph",
3
- "version": "1.2.0",
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.2.0",
19
- "@colbymchenry/codegraph-darwin-x64": "1.2.0",
20
- "@colbymchenry/codegraph-linux-arm64": "1.2.0",
21
- "@colbymchenry/codegraph-linux-x64": "1.2.0",
22
- "@colbymchenry/codegraph-win32-arm64": "1.2.0",
23
- "@colbymchenry/codegraph-win32-x64": "1.2.0"
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