@aroman22/codegraph-vba 1.15.0 → 1.16.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 (49) hide show
  1. package/dist/bin/daemon-release.d.ts +7 -0
  2. package/dist/db/queries.d.ts +30 -0
  3. package/dist/extraction/access-erd-extractor.d.ts +57 -0
  4. package/dist/extraction/extraction-version.d.ts +1 -1
  5. package/dist/extraction/grammars.d.ts +20 -0
  6. package/dist/extraction/index.d.ts +1 -0
  7. package/dist/extraction/parse-pool.d.ts +8 -3
  8. package/dist/extraction/sql-query-extractor.d.ts +16 -14
  9. package/dist/extraction/sql-table-scan.d.ts +184 -0
  10. package/dist/extraction/tree-sitter.d.ts +10 -1
  11. package/dist/extraction/vba/call-sweep.d.ts +2 -7
  12. package/dist/extraction/vba/calls.d.ts +24 -4
  13. package/dist/extraction/vba/constants.d.ts +7 -14
  14. package/dist/extraction/vba/context.d.ts +443 -7
  15. package/dist/extraction/vba/controls.d.ts +18 -1
  16. package/dist/extraction/vba/declarations.d.ts +1 -6
  17. package/dist/extraction/vba/dims.d.ts +11 -7
  18. package/dist/extraction/vba/docmd.d.ts +29 -2
  19. package/dist/extraction/vba/enums-consts.d.ts +7 -14
  20. package/dist/extraction/vba/error-channel.d.ts +57 -0
  21. package/dist/extraction/vba/errors.d.ts +64 -0
  22. package/dist/extraction/vba/filesystem-statements.d.ts +23 -0
  23. package/dist/extraction/vba/implements.d.ts +1 -6
  24. package/dist/extraction/vba/labels.d.ts +26 -0
  25. package/dist/extraction/vba/module-vars.d.ts +36 -0
  26. package/dist/extraction/vba/options.d.ts +88 -0
  27. package/dist/extraction/vba/parameters.d.ts +35 -0
  28. package/dist/extraction/vba/procedures.d.ts +1 -9
  29. package/dist/extraction/vba/rules.d.ts +10 -5
  30. package/dist/extraction/vba/runtime-objects.d.ts +59 -0
  31. package/dist/extraction/vba/signature.d.ts +57 -0
  32. package/dist/extraction/vba/sql-wrapper.d.ts +76 -3
  33. package/dist/extraction/vba/text-utils.d.ts +62 -2
  34. package/dist/extraction/vba-extractor.d.ts +18 -1
  35. package/dist/extraction/vba-form-extractor.d.ts +28 -14
  36. package/dist/extraction/vba-preprocess.d.ts +89 -3
  37. package/dist/extraction/vba-source.d.ts +0 -10
  38. package/dist/extraction/vba-test-manifest-extractor.d.ts +0 -6
  39. package/dist/mcp/daemon-paths.d.ts +6 -0
  40. package/dist/mcp/daemon-registry.d.ts +82 -7
  41. package/dist/mcp/daemon-watchdog.d.ts +12 -0
  42. package/dist/mcp/daemon.d.ts +20 -1
  43. package/dist/mcp/proxy.d.ts +32 -0
  44. package/dist/project-config.d.ts +43 -2
  45. package/dist/resolution/index.d.ts +47 -2
  46. package/dist/resolution/name-matcher.d.ts +25 -0
  47. package/dist/resolution/vba-runtime-objects.d.ts +11 -11
  48. package/dist/types.d.ts +13 -5
  49. package/package.json +7 -7
@@ -58,6 +58,35 @@ export declare function runProxy(socketPath: string, expectedVersion?: string):
58
58
  * owns the socket. Used by the local-handshake proxy's background connect.
59
59
  */
60
60
  export declare function connectWithHello(socketPath: string, expectedVersion?: string): Promise<net.Socket | 'version-mismatch' | null>;
61
+ type JsonRpc = Record<string, unknown>;
62
+ type ProxyWrite = (obj: JsonRpc | string) => void;
63
+ /** Tracks request order across the proxy's pending-before-connect and in-flight phases. */
64
+ export declare class ProxyRequestBarrier {
65
+ private readonly pending;
66
+ private readonly inflight;
67
+ private readonly drainWaiters;
68
+ private track;
69
+ private requestId;
70
+ private resolveDrain;
71
+ buffer(line: string): void;
72
+ forward(line: string, send: (line: string) => void): void;
73
+ flush(send: (line: string) => void): void;
74
+ settle(id: unknown): void;
75
+ settleLine(line: string): void;
76
+ inflightLines(): string[];
77
+ pendingCount(): number;
78
+ inflightCount(): number;
79
+ drain(): Promise<void>;
80
+ }
81
+ /** Per-proxy barrier for intentional release of the project this session owns. */
82
+ export declare class ProxyReleaseCoordinator {
83
+ private readonly drainEarlierRequests;
84
+ private readonly entries;
85
+ private readonly sessionKey;
86
+ constructor(sessionRoot: string, drainEarlierRequests?: () => Promise<void>);
87
+ getState(root?: string): 'active' | 'releasing' | 'released';
88
+ handle(msg: JsonRpc, enabled: boolean, releaseProject: ((root: string) => Promise<unknown>) | undefined, write: ProxyWrite): boolean;
89
+ }
61
90
  /** Dependencies the local-handshake proxy needs, injected by MCPServer (which
62
91
  * owns the daemon-spawn machinery and the engine factory). */
63
92
  export interface LocalHandshakeDeps {
@@ -69,6 +98,8 @@ export interface LocalHandshakeDeps {
69
98
  makeEngine(): MCPEngine;
70
99
  /** Project root for the fallback engine's lazy init. */
71
100
  root: string;
101
+ /** Release one root locally so the proxy can suppress watchdog respawn first. */
102
+ releaseProject?(root: string): Promise<unknown>;
72
103
  }
73
104
  /**
74
105
  * Local-handshake proxy (the cold-start fix).
@@ -84,4 +115,5 @@ export interface LocalHandshakeDeps {
84
115
  * never costs the old fall-back-to-direct robustness.
85
116
  */
86
117
  export declare function runLocalHandshakeProxy(deps: LocalHandshakeDeps): Promise<void>;
118
+ export {};
87
119
  //# sourceMappingURL=proxy.d.ts.map
@@ -46,6 +46,39 @@ export interface ProjectConfig {
46
46
  * `true`.
47
47
  */
48
48
  dysflowExport?: boolean;
49
+ /**
50
+ * Extra receiver names that execute SQL, so table references inside the
51
+ * SQL they run are still found (#244). Two entry forms are accepted:
52
+ *
53
+ * - a bare identifier fragment — `"getdb"` reaches `getdb()`,
54
+ * `getdbHPS()` and `getdbExpedientes()`;
55
+ * - an explicit `receiver.method` pair — `"cnn.Execute"`.
56
+ *
57
+ * Raw regular expressions are deliberately NOT accepted: these patterns
58
+ * run against every line of every VBA file, where a user-supplied regex
59
+ * is a catastrophic-backtracking hazard. Entries EXTEND the built-in
60
+ * list (`db`, `getdb`, `CurrentDb`, `DBEngine`, the DAO `QueryDef`
61
+ * receivers, `DoCmd.RunSQL` and the ADO pair) — they never replace it.
62
+ * A non-array value, or an entry that is not one of the two forms,
63
+ * warns and is ignored.
64
+ */
65
+ sqlWrappers?: string[];
66
+ /**
67
+ * Issue #261 — extra module-level variable names this project uses as its
68
+ * error channel: the field a failing procedure writes and its caller
69
+ * reads, which is how an error message actually travels in an Access
70
+ * codebase of this shape (VBA's own mechanism unwinds one frame and is
71
+ * used for that, not for the message).
72
+ *
73
+ * Bare VBA identifiers only, matched as WHOLE names — `"lastFailure"`
74
+ * flags `lastFailure` and never `lastFailureCount`. Raw regular
75
+ * expressions are deliberately NOT accepted, for the same reason
76
+ * `sqlWrappers` refuses them: these names are tested against every
77
+ * identifier of every line of every VBA file. Entries EXTEND the built-in
78
+ * list (`m_Error`, `p_Error`, `g_Error`, `Error`) — they never replace
79
+ * it. A non-array value, or a non-identifier entry, warns and is ignored.
80
+ */
81
+ errorChannel?: string[];
49
82
  };
50
83
  /**
51
84
  * Gitignore-style patterns for first-party source to force INTO the index even
@@ -62,11 +95,19 @@ export interface ProjectConfig {
62
95
  */
63
96
  include?: string[];
64
97
  }
65
- export declare function loadVbaConfig(rootDir: string): {
98
+ /**
99
+ * Parsed, validated view of the `vba` block. Named (rather than repeated
100
+ * inline at each of its five use sites) so adding a knob — `sqlWrappers` in
101
+ * #244 — is one edit instead of five that can silently drift apart.
102
+ */
103
+ export interface VbaConfig {
66
104
  targets?: Record<string, boolean>;
67
105
  maxRaiseFanout?: number;
68
106
  dysflowExport?: boolean;
69
- };
107
+ sqlWrappers?: string[];
108
+ errorChannel?: string[];
109
+ }
110
+ export declare function loadVbaConfig(rootDir: string): VbaConfig;
70
111
  /**
71
112
  * Load the validated `vba.dysflowExport` flag for a project, mtime-cached
72
113
  * (issue #154). Returns `true` when the flag is absent — the default keeps
@@ -302,10 +302,55 @@ export declare class ReferenceResolver {
302
302
  * (enum, class, interface, struct, type_alias). Exactly one match →
303
303
  * repoint; zero or 2+ → decline (leave the stub as-is).
304
304
  *
305
- * Duplicate `(source, target, 'references')` rows after repointing are
306
- * collapsed the same way `resolveVbaCallStubs` handles F1 duplicates.
305
+ * Duplicate `(source, target, kind)` rows after repointing are collapsed the
306
+ * same way `resolveVbaCallStubs` handles F1 duplicates.
307
+ *
308
+ * Issue #257: `type_of` edges are repointed alongside `references` ones.
309
+ * They share the stub by construction (`emitTypeOf` and `emitReference` both
310
+ * go through `ensureSynthTypeNode`), and the stub is DELETED at the end of
311
+ * each iteration — with `ON DELETE CASCADE` on both endpoint columns, an
312
+ * un-repointed `type_of` edge would be silently destroyed rather than
313
+ * resolved. The de-duplication key carries the edge kind so a module's
314
+ * `references` edge and its parameter's `type_of` edge onto the same type
315
+ * cannot collapse into each other.
307
316
  */
308
317
  resolveVbaReferenceStubs(): number;
318
+ /**
319
+ * Promote Access ERD table declarations to canonical and repoint the
320
+ * SQL-derived placeholders onto them (#257, half B).
321
+ *
322
+ * Two extractors already synthesize a `class` placeholder for every table
323
+ * name they see in SQL text (`vba-sql-table` from in-code SQL,
324
+ * `sql-query-table` from a saved query), each keyed on the REFERENCING file.
325
+ * `AccessErdExtractor` emits its own table node keyed on the ERD document.
326
+ * Left alone, `TbAnexos` from the ERD and `TbAnexos` from a `SELECT` in a
327
+ * `.cls` are two unrelated nodes — the fields land on one, the references on
328
+ * the other, and the whole feature buys nothing.
329
+ *
330
+ * This pass is the convergence step, and it reuses the mechanism
331
+ * `resolveVbaCallStubs` already proved: repoint the incoming edges onto the
332
+ * canonical node, collapse would-be duplicates, delete the emptied
333
+ * placeholder, and stamp `metadata.repointDecision` on every edge it touched
334
+ * so the outcome is auditable (same vocabulary as `docs/vba-stub-repoint-
335
+ * decision.md`).
336
+ *
337
+ * Three deliberate declines:
338
+ * - **No ERD declares this name** → leave the placeholder exactly as it is.
339
+ * That is the no-ERD project, and its behavior must not change at all.
340
+ * - **Two ERD files declare the same name** (two backends, same table) →
341
+ * `declined-ambiguous`. Repoint nothing and keep both declarations; which
342
+ * backend a bare `SELECT` meant is not something to guess.
343
+ * - **The placeholder still has other edges** → keep the node. Only a
344
+ * placeholder whose every edge has moved is deleted.
345
+ *
346
+ * Runs BEFORE `resolveVbaReferenceStubs` so this explicit, decision-stamping
347
+ * pass owns the outcome rather than the generic stub resolver silently
348
+ * arriving at half of it. Idempotent: a repointed placeholder is gone, so a
349
+ * second pass finds nothing to do.
350
+ *
351
+ * @returns the number of edges repointed onto an ERD table node.
352
+ */
353
+ resolveAccessErdTableNodes(): number;
309
354
  /**
310
355
  * Resolve a single VBA call-stub node to its real target, or `null` when
311
356
  * unresolvable/ambiguous. See `resolveVbaCallStubs` for the two-step
@@ -7,6 +7,31 @@ import { Node } from '../types';
7
7
  import { UnresolvedRef, ResolvedRef, ResolutionContext } from './types';
8
8
  /** Resolve Me.<Control> only inside the extractor-declared sibling layout. */
9
9
  export declare function matchVbaMeControl(ref: UnresolvedRef, context: ResolutionContext): ResolvedRef | null;
10
+ /**
11
+ * Resolve a module-level variable read/write to that variable's node in
12
+ * the SAME file (issue #251).
13
+ *
14
+ * The binding is file-scoped and never falls through to global name
15
+ * matching. `m_count`, `strSQL` and `blnOk` are declared privately in
16
+ * dozens of modules of a typical Access project; a global match would
17
+ * pick one of them at random and claim a coupling between two modules
18
+ * that never reference each other. The extractor only emits these refs
19
+ * for names it already registered as module-level variables of the file
20
+ * being scanned, so the answer, when there is one, is always in that file.
21
+ */
22
+ export declare function matchVbaModuleVariable(ref: UnresolvedRef, context: ResolutionContext): ResolvedRef | null;
23
+ /**
24
+ * Issue #253: resolve a saved-query name to the `query` node that
25
+ * `SqlQueryExtractor` builds from `queries/<Name>.sql`.
26
+ *
27
+ * Query-kind only, and a miss DECLINES rather than falling through to global
28
+ * name matching. That is the whole point of the gate: a name matching neither
29
+ * a query nor a table must stay a `failed` reference, because a fallback that
30
+ * invented a table placeholder would turn "this query does not exist" into a
31
+ * confident, wrong answer — and a fallback to generic name matching could bind
32
+ * the name to an unrelated same-named class or procedure.
33
+ */
34
+ export declare function matchVbaQueryName(ref: UnresolvedRef, context: ResolutionContext): ResolvedRef | null;
10
35
  /** Resolve Access SourceObject embeddings only to a unique real layout node. */
11
36
  export declare function matchVbaSourceObject(ref: UnresolvedRef, context: ResolutionContext): ResolvedRef | null;
12
37
  /** Keep a layout's sibling-code binding from resolving back to the layout. */
@@ -1,3 +1,4 @@
1
+ import { isRuntimeObject as canonicalIsRuntimeObject } from '../extraction/vba/runtime-objects';
1
2
  /**
2
3
  * Canonical list of VBA/Access runtime objects and singletons whose
3
4
  * `Receiver.Member` calls are NEVER user-defined code — DAO, FileSystemObject
@@ -18,14 +19,15 @@
18
19
  * only falls back to this list when no real target exists, so a shadow
19
20
  * declaration is repointed exactly like any other real symbol (FR-2.1).
20
21
  *
21
- * NOTE — this is complementary to, NOT a duplicate of, the VBA extractor's
22
- * own `RUNTIME_RECEIVER_BLACKLIST` (`src/extraction/vba/constants.ts`). That
23
- * set is case-sensitive PascalCase and suppresses stub SYNTHESIS for the
24
- * common receivers at extraction time; this set is lowercased and catches the
25
- * runtime-object stubs that still reached the graph (lowercase receivers,
26
- * `Dim x As DAO.*` typed locals whose receiver survives as raw text, etc.).
27
- * The extractor blacklist deliberately stays untouched (AC-4: `src/extraction`
28
- * has 0 diff); the two layers are independent by design.
22
+ * Issue #245 — this used to be a SECOND literal, complementary to the VBA
23
+ * extractor's `RUNTIME_RECEIVER_BLACKLIST`. The two drifted: the extractor
24
+ * list omitted `VBA`, `fso`, `Collection` and `ListBox`, so those receivers
25
+ * kept synthesizing stub function NODES even though the resolver already
26
+ * declined their edges. Both sets now derive from one literal in
27
+ * `src/extraction/vba/runtime-objects.ts` (a leaf module `src/extraction`
28
+ * must not import from `src/resolution`, so the canonical set lives on the
29
+ * extraction side and is re-exported here). Every existing
30
+ * `from '../src/resolution/vba-runtime-objects'` import keeps working.
29
31
  *
30
32
  * Entries are lowercased so matching is case-insensitive against a stub's
31
33
  * receiver.
@@ -36,9 +38,7 @@ export declare const RUNTIME_OBJECTS: ReadonlySet<string>;
36
38
  * Leading/trailing brackets and surrounding whitespace are stripped
37
39
  * defensively so a bracketed receiver (`[DAO]`) still matches.
38
40
  */
39
- export declare function isRuntimeObject(receiver: string | null | undefined): boolean;
40
- /** Canonical VBA and Access built-in functions that never resolve to project code. */
41
- export declare const VBA_STDLIB_FUNCTIONS: ReadonlySet<string>;
41
+ export declare const isRuntimeObject: typeof canonicalIsRuntimeObject;
42
42
  export declare function isVbaStdlibFunction(name: string | null | undefined): boolean;
43
43
  /**
44
44
  * Issue #188 — VBA intrinsic constants and DAO enum values reach
package/dist/types.d.ts CHANGED
@@ -10,12 +10,12 @@
10
10
  * of truth backs both the TS type and any runtime validation
11
11
  * (e.g. the search query parser).
12
12
  */
13
- export declare const NODE_KINDS: readonly ["file", "module", "class", "struct", "interface", "trait", "protocol", "function", "method", "property", "field", "variable", "constant", "enum", "enum_member", "event", "type", "type_member", "declare", "type_alias", "namespace", "parameter", "import", "export", "route", "component", "query", "form-layout", "form-instance-control", "report-layout"];
13
+ export declare const NODE_KINDS: readonly ["file", "module", "class", "struct", "interface", "trait", "protocol", "function", "method", "property", "field", "variable", "constant", "enum", "enum_member", "event", "type", "type_member", "declare", "type_alias", "namespace", "parameter", "import", "export", "route", "component", "query", "form-layout", "form-instance-control", "report-layout", "label"];
14
14
  export type NodeKind = (typeof NODE_KINDS)[number];
15
15
  /**
16
16
  * Types of edges (relationships) between nodes
17
17
  */
18
- export type EdgeKind = 'contains' | 'calls' | 'imports' | 'exports' | 'extends' | 'implements' | 'references' | 'type_of' | 'returns' | 'instantiates' | 'overrides' | 'decorates' | 'event-handler' | 'opens-form' | 'opens-report' | 'raises-event' | 'subscribes-event' | 'type-member';
18
+ export type EdgeKind = 'contains' | 'calls' | 'imports' | 'exports' | 'extends' | 'implements' | 'references' | 'type_of' | 'returns' | 'instantiates' | 'overrides' | 'decorates' | 'event-handler' | 'opens-form' | 'opens-report' | 'raises-event' | 'subscribes-event' | 'type-member' | 'handles-error';
19
19
  /**
20
20
  * Supported programming languages. See NODE_KINDS for why this is a
21
21
  * runtime-iterable const array.
@@ -175,7 +175,11 @@ export interface ExtractionError {
175
175
  * layer. The legacy `EdgeKind` literal `'references'` is preserved as
176
176
  * `references` here via `EdgeKind` — back-compat for any push site this
177
177
  * round does not reclassify (e.g. the Implements emitter). New literals:
178
- * - `calls` paren-form `Name(...)` or statement-form Sub call
178
+ * - `calls` paren-form `Name(...)`, or a statement-form Sub call
179
+ * whose syntax rules out a `Const` read (issue #265):
180
+ * `Call Escribir` (the `Call` keyword is only valid on
181
+ * a procedure) and `Escribir 1, 2` (a constant takes no
182
+ * argument list)
179
183
  * - `qualified-call` `Receiver.Member(...)` (qualified-paren) or
180
184
  * `Receiver.Member args` (qualified-statement)
181
185
  * - `property-get` `Me.Name` (dot access, read)
@@ -183,9 +187,13 @@ export interface ExtractionError {
183
187
  * - `bang-get` `Me!SubCtl` (bang read) or
184
188
  * `Forms!FormX!Ctl` / `Forms("FormX")!Ctl` (cross-form)
185
189
  * - `bang-set` `Me!SubCtl = value` (bang assignment)
186
- * - `unqualified-ident` bare identifier without `(` after; default for
190
+ * - `unqualified-ident` bare identifier with no `(` after it, no `Call`
191
+ * keyword and no argument list; default for
187
192
  * `HayErrorEnRiesgo`-style hits — Const-read takes
188
- * priority via FR-3.1 disambiguation
193
+ * priority via FR-3.1 disambiguation. That shape is
194
+ * genuinely ambiguous between a no-argument Sub call
195
+ * and a `Const` read, which is why it stays here while
196
+ * the two unambiguous statement forms are `calls`
189
197
  * - `member-with` `.Member` inside a `With <receiver>` block
190
198
  * - `dao-query` `DoCmd.OpenQuery "X"` argument
191
199
  * `dao-field-get` / `dao-field-set` are deliberately deferred to round-4.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aroman22/codegraph-vba",
3
- "version": "1.15.0",
3
+ "version": "1.16.0",
4
4
  "description": "Local-first code intelligence for AI agents (MCP). Self-contained — bundles its own runtime.",
5
5
  "bin": {
6
6
  "codegraph-vba": "npm-shim.js"
@@ -15,12 +15,12 @@
15
15
  "./package.json": "./package.json"
16
16
  },
17
17
  "optionalDependencies": {
18
- "@aroman22/codegraph-vba-darwin-arm64": "1.15.0",
19
- "@aroman22/codegraph-vba-darwin-x64": "1.15.0",
20
- "@aroman22/codegraph-vba-linux-arm64": "1.15.0",
21
- "@aroman22/codegraph-vba-linux-x64": "1.15.0",
22
- "@aroman22/codegraph-vba-win32-arm64": "1.15.0",
23
- "@aroman22/codegraph-vba-win32-x64": "1.15.0"
18
+ "@aroman22/codegraph-vba-darwin-arm64": "1.16.0",
19
+ "@aroman22/codegraph-vba-darwin-x64": "1.16.0",
20
+ "@aroman22/codegraph-vba-linux-arm64": "1.16.0",
21
+ "@aroman22/codegraph-vba-linux-x64": "1.16.0",
22
+ "@aroman22/codegraph-vba-win32-arm64": "1.16.0",
23
+ "@aroman22/codegraph-vba-win32-x64": "1.16.0"
24
24
  },
25
25
  "files": [
26
26
  "npm-shim.js",