@happyvertical/smrt-scanner 0.51.32 → 0.51.35

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EACL,KAAK,2BAA2B,EAChC,0BAA0B,EAC1B,KAAK,0BAA0B,EAC/B,iBAAiB,EACjB,mBAAmB,EACnB,KAAK,sBAAsB,EAC3B,wBAAwB,EACxB,wBAAwB,EACxB,kBAAkB,EAClB,sBAAsB,EACtB,4BAA4B,GAC7B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,mBAAmB,EACnB,uBAAuB,EACvB,iBAAiB,EACjB,KAAK,sBAAsB,GAC5B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EACL,wBAAwB,EACxB,oBAAoB,EACpB,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EACzB,qCAAqC,EACrC,oBAAoB,GACrB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,SAAS,EACT,WAAW,GACZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,cAAc,YAAY,CAAC;AAC3B,OAAO,EACL,KAAK,iCAAiC,EACtC,KAAK,gCAAgC,EACrC,KAAK,oBAAoB,EACzB,0BAA0B,GAC3B,MAAM,0BAA0B,CAAC"}
@@ -0,0 +1,226 @@
1
+ /**
2
+ * Inheritance Resolver
3
+ *
4
+ * Resolves class inheritance chains using in-memory class map.
5
+ * Handles STI (Single Table Inheritance) detection and field merging.
6
+ */
7
+ import type { ExternalManifest, RawClassDefinition, RawFieldDefinition, ResolvedClassDefinition } from './types.js';
8
+ /**
9
+ * Resolves class inheritance chains and STI hierarchies from raw OXC scan output.
10
+ *
11
+ * After {@link OxcScanner} parses files, `InheritanceResolver` builds a
12
+ * class map from the raw definitions and walks each class's `extends` chain
13
+ * to produce fully-resolved {@link ResolvedClassDefinition} objects.
14
+ *
15
+ * Key responsibilities:
16
+ * - Walking extends chains across local classes and external package manifests.
17
+ * - Detecting which classes participate in STI (Single Table Inheritance).
18
+ * - Merging fields from ancestor classes for STI subclasses (base fields first).
19
+ * - Caching resolved chains to avoid repeated traversals.
20
+ *
21
+ * Framework base classes (`SmrtObject`, `SmrtClass`, `SmrtCollection`) are
22
+ * recognized without needing to appear in source files.
23
+ *
24
+ * @example
25
+ * ```typescript
26
+ * import { InheritanceResolver } from '@happyvertical/smrt-scanner';
27
+ *
28
+ * const resolver = new InheritanceResolver({ baseClasses: ['MyBaseClass'] });
29
+ * resolver.addClasses(rawClasses);
30
+ * const resolved = resolver.resolveAll();
31
+ * ```
32
+ *
33
+ * @see {@link OxcScanner} which owns and drives this resolver internally.
34
+ */
35
+ export declare class InheritanceResolver {
36
+ /** Map of className -> RawClassDefinition */
37
+ private classMap;
38
+ /** External package manifests for cross-package resolution */
39
+ private externalManifests;
40
+ /** Known base classes (user-provided) */
41
+ private knownBaseClasses;
42
+ /** Cache of resolved inheritance chains */
43
+ private chainCache;
44
+ /**
45
+ * Create a new `InheritanceResolver`.
46
+ *
47
+ * @param options.baseClasses - Additional class names to treat as known
48
+ * framework base classes (beyond the built-in `SmrtObject`, `SmrtClass`,
49
+ * and `SmrtCollection`).
50
+ * @param options.externalManifests - Pre-loaded external package manifests
51
+ * keyed by package name, used for cross-package parent class resolution.
52
+ */
53
+ constructor(options?: {
54
+ baseClasses?: string[];
55
+ externalManifests?: Map<string, ExternalManifest>;
56
+ });
57
+ /**
58
+ * Register raw class definitions from a scan pass.
59
+ *
60
+ * Adds each class to the internal class map by `className`. Calling this
61
+ * clears the inheritance chain cache so subsequent calls to
62
+ * {@link resolveAll} or {@link resolveInheritanceChain} reflect the new
63
+ * classes.
64
+ *
65
+ * @param classes - Array of {@link RawClassDefinition} objects from
66
+ * {@link ScanResults.classes}.
67
+ */
68
+ addClasses(classes: RawClassDefinition[]): void;
69
+ /**
70
+ * Register an external package manifest for cross-package base class resolution.
71
+ *
72
+ * Clears the chain cache after registration so re-resolution picks up the
73
+ * new definitions.
74
+ *
75
+ * @param manifest - External package manifest providing class definitions
76
+ * that may appear as base classes in the local project.
77
+ *
78
+ * @see {@link ExternalManifest}
79
+ */
80
+ addExternalManifest(manifest: ExternalManifest): void;
81
+ /**
82
+ * Resolve all registered classes and return fully-resolved definitions.
83
+ *
84
+ * A class is included in the output if it either:
85
+ * 1. Has an `@smrt()` decorator, or
86
+ * 2. Directly or transitively extends a framework base class
87
+ * (`SmrtObject`, `SmrtClass`, `SmrtCollection`) — this captures
88
+ * collection classes such as `class MeetingCollection extends
89
+ * SmrtCollection<Meeting>` that do not carry `@smrt()` themselves.
90
+ *
91
+ * @returns An array of {@link ResolvedClassDefinition} — one entry per
92
+ * eligible class, with inheritance chain, STI metadata, and merged fields
93
+ * populated.
94
+ *
95
+ * @see {@link resolve} to resolve a single class definition.
96
+ */
97
+ resolveAll(): ResolvedClassDefinition[];
98
+ /**
99
+ * Check if a class extends a framework base class
100
+ * (SmrtObject, SmrtClass, or SmrtCollection)
101
+ */
102
+ private extendsFrameworkBase;
103
+ /**
104
+ * Resolve a single raw class definition into a fully-resolved definition.
105
+ *
106
+ * Computes the inheritance chain, determines the effective table strategy,
107
+ * detects STI membership, and merges ancestor fields for STI classes.
108
+ *
109
+ * @param classDef - The raw class definition to resolve.
110
+ * @returns A {@link ResolvedClassDefinition} with all inherited metadata
111
+ * applied. The `packageName` field is left as `null` and must be set by
112
+ * the caller (e.g. {@link ManifestAdapter}).
113
+ *
114
+ * @see {@link resolveAll} to resolve every registered class at once.
115
+ */
116
+ resolve(classDef: RawClassDefinition): ResolvedClassDefinition;
117
+ /**
118
+ * Resolve the full inheritance chain for a named class, from the root base
119
+ * class down to the named class itself.
120
+ *
121
+ * Results are memoised in an internal cache that is cleared whenever
122
+ * {@link addClasses} or {@link addExternalManifest} is called.
123
+ *
124
+ * @param className - Name of the class to resolve.
125
+ * @returns An ordered array of class names starting from the furthest
126
+ * ancestor and ending with `className`.
127
+ *
128
+ * @example
129
+ * ```typescript
130
+ * // Given: class Article extends Content, class Content extends SmrtObject
131
+ * resolver.resolveInheritanceChain('Article');
132
+ * // => ['SmrtObject', 'Content', 'Article']
133
+ * ```
134
+ */
135
+ resolveInheritanceChain(className: string): string[];
136
+ /**
137
+ * Look up a class definition by name, searching in priority order:
138
+ * 1. Local classes added via {@link addClasses}.
139
+ * 2. External package manifests added via {@link addExternalManifest}.
140
+ * 3. Built-in framework base classes (`SmrtObject`, `SmrtClass`,
141
+ * `SmrtCollection`) — returns a minimal stub definition so chain walking
142
+ * can terminate cleanly.
143
+ *
144
+ * @param className - Class name to look up.
145
+ * @returns The {@link RawClassDefinition} if found, or `null` if the class
146
+ * is unknown to the resolver.
147
+ */
148
+ findClassDefinition(className: string): RawClassDefinition | null;
149
+ /**
150
+ * Find the STI root class in a resolved inheritance chain.
151
+ *
152
+ * Walks the chain from base to leaf and returns the name of the first class
153
+ * whose `@smrt()` decorator explicitly declares `tableStrategy: 'sti'`.
154
+ *
155
+ * @param chain - Ordered inheritance chain (base → leaf) as returned by
156
+ * {@link resolveInheritanceChain}.
157
+ * @returns The class name of the STI root, or `null` if no class in the
158
+ * chain uses `tableStrategy: 'sti'`.
159
+ */
160
+ findSTIBase(chain: string[]): string | null;
161
+ /**
162
+ * Determine the effective table strategy (`'sti'` or `'cti'`) for a class.
163
+ *
164
+ * Resolution order:
165
+ * 1. The class's own `@smrt({ tableStrategy })` declaration, if present.
166
+ * 2. The nearest ancestor that declares `tableStrategy: 'sti'` — STI is
167
+ * inherited automatically by all subclasses.
168
+ * 3. Defaults to `'cti'` if no STI ancestor is found.
169
+ *
170
+ * @param classDef - Raw class definition whose strategy is being determined.
171
+ * @param chain - Pre-resolved inheritance chain for `classDef` (base → leaf).
172
+ * @returns `'sti'` or `'cti'`.
173
+ */
174
+ determineTableStrategy(classDef: RawClassDefinition, chain: string[]): 'sti' | 'cti';
175
+ /**
176
+ * Merge fields from all classes in an STI inheritance chain.
177
+ *
178
+ * Iterates from the root base class to the leaf class so that base class
179
+ * fields appear first in the returned array. If a field name is declared in
180
+ * both an ancestor and a descendant, the ancestor's definition takes
181
+ * precedence (first-seen wins), preserving the base-class column layout.
182
+ *
183
+ * @param chain - Ordered inheritance chain (base → leaf) as returned by
184
+ * {@link resolveInheritanceChain}.
185
+ * @returns A deduplicated, ordered array of {@link RawFieldDefinition}
186
+ * covering every field in the STI hierarchy.
187
+ */
188
+ mergeFieldsForSTI(chain: string[]): RawFieldDefinition[];
189
+ /**
190
+ * Return all known descendants of a class.
191
+ *
192
+ * Useful for STI schema generation where the base table must accommodate
193
+ * columns from every subclass.
194
+ *
195
+ * @param className - The ancestor class name to search from.
196
+ * @returns An array of class names (local classes only) whose resolved
197
+ * inheritance chain includes `className`. Does not include `className`
198
+ * itself.
199
+ */
200
+ getDescendants(className: string): string[];
201
+ /**
202
+ * Check whether a class participates in an STI hierarchy.
203
+ *
204
+ * @param className - Name of the class to check.
205
+ * @returns `true` if any class in the resolved inheritance chain declares
206
+ * `tableStrategy: 'sti'`, `false` otherwise.
207
+ */
208
+ isSTIClass(className: string): boolean;
209
+ /**
210
+ * Return aggregate statistics about the classes registered with this resolver.
211
+ *
212
+ * @returns An object with:
213
+ * - `totalClasses` — total number of classes in the class map.
214
+ * - `smrtClasses` — classes that carry `@smrt()`.
215
+ * - `stiClasses` — `@smrt()` classes in an STI hierarchy.
216
+ * - `maxInheritanceDepth` — length of the deepest inheritance chain among
217
+ * `@smrt()` classes.
218
+ */
219
+ getStats(): {
220
+ totalClasses: number;
221
+ smrtClasses: number;
222
+ stiClasses: number;
223
+ maxInheritanceDepth: number;
224
+ };
225
+ }
226
+ //# sourceMappingURL=inheritance-resolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inheritance-resolver.d.ts","sourceRoot":"","sources":["../src/inheritance-resolver.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EAClB,uBAAuB,EACxB,MAAM,YAAY,CAAC;AAiCpB;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,qBAAa,mBAAmB;IAC9B,6CAA6C;IAC7C,OAAO,CAAC,QAAQ,CAA8C;IAE9D,8DAA8D;IAC9D,OAAO,CAAC,iBAAiB,CAA4C;IAErE,yCAAyC;IACzC,OAAO,CAAC,gBAAgB,CAAc;IAEtC,2CAA2C;IAC3C,OAAO,CAAC,UAAU,CAAoC;IAEtD;;;;;;;;OAQG;gBAED,OAAO,GAAE;QACP,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;QACvB,iBAAiB,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;KAC9C;IASR;;;;;;;;;;OAUG;IACH,UAAU,CAAC,OAAO,EAAE,kBAAkB,EAAE,GAAG,IAAI;IAQ/C;;;;;;;;;;OAUG;IACH,mBAAmB,CAAC,QAAQ,EAAE,gBAAgB,GAAG,IAAI;IAKrD;;;;;;;;;;;;;;;OAeG;IACH,UAAU,IAAI,uBAAuB,EAAE;IAgBvC;;;OAGG;IACH,OAAO,CAAC,oBAAoB;IAc5B;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,QAAQ,EAAE,kBAAkB,GAAG,uBAAuB;IAiC9D;;;;;;;;;;;;;;;;;OAiBG;IACH,uBAAuB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE;IA6BpD;;;;;;;;;;;OAWG;IACH,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,kBAAkB,GAAG,IAAI;IA+BjE;;;;;;;;;;OAUG;IACH,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,IAAI;IAU3C;;;;;;;;;;;;OAYG;IACH,sBAAsB,CACpB,QAAQ,EAAE,kBAAkB,EAC5B,KAAK,EAAE,MAAM,EAAE,GACd,KAAK,GAAG,KAAK;IAmBhB;;;;;;;;;;;;OAYG;IACH,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,kBAAkB,EAAE;IAoBxD;;;;;;;;;;OAUG;IACH,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE;IAe3C;;;;;;OAMG;IACH,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;IAKtC;;;;;;;;;OASG;IACH,QAAQ,IAAI;QACV,YAAY,EAAE,MAAM,CAAC;QACrB,WAAW,EAAE,MAAM,CAAC;QACpB,UAAU,EAAE,MAAM,CAAC;QACnB,mBAAmB,EAAE,MAAM,CAAC;KAC7B;CAyBF"}
@@ -0,0 +1,48 @@
1
+ import type { DomainKnowledgeModuleDoc } from '@happyvertical/smrt-types';
2
+ export interface ScopedPackageDirectory {
3
+ /** Scope entry name; consumers may select by alias rather than manifest name. */
4
+ name: string;
5
+ /** Original node_modules path, retained for workspace-relative reporting. */
6
+ directory: string;
7
+ /** Resolved path for identity comparisons or absolute snapshot links. */
8
+ realDirectory: string;
9
+ }
10
+ /**
11
+ * Enumerate scope entries without descending into pnpm's linked dependency graph.
12
+ * Selection, workspace discovery and enrichment remain caller policies.
13
+ */
14
+ export declare function discoverScopedPackageDirectories(scopeDirectories: string[]): ScopedPackageDirectory[];
15
+ /** Read authored docs only; never load artifacts, package code or object scans. */
16
+ export declare function readPackageAgentDoc(directory: string, options?: {
17
+ inspectAdapter?: boolean;
18
+ }): {
19
+ hasAgentsMd: boolean;
20
+ hasClaudeMd: boolean;
21
+ hasClaudeShim: boolean;
22
+ agentsContent: string;
23
+ claudeContent: string;
24
+ source: "AGENTS.md" | "CLAUDE.md" | null;
25
+ content: string | null;
26
+ };
27
+ /** `sourceHashes` key prefix for a linked module doc, e.g. `moduleDoc:agents/crm.md`. */
28
+ export declare const MODULE_DOC_HASH_PREFIX = "moduleDoc:";
29
+ /**
30
+ * `sourceHashes` key prefix for a module declaring a view intent or playbook,
31
+ * e.g. `agentSurface:src/lib/orders.intents.ts` (#2591).
32
+ */
33
+ export declare const AGENT_SURFACE_HASH_PREFIX = "agentSurface:";
34
+ /**
35
+ * Module doc paths linked from a package's `AGENTS.md`, relative to the package
36
+ * root and in document order.
37
+ *
38
+ * Instruction chains are additive (see `scripts/check-agents-chain.mjs`), so an
39
+ * oversized package doc is split into `packages/<pkg>/agents/<module>.md` siblings
40
+ * instead of nested `AGENTS.md` files. Only links resolving to an existing file
41
+ * INSIDE the package are accepted — a cross-package reference such as
42
+ * `packages/affiliates/MIGRATION.md` belongs to that package's own chain and is
43
+ * ignored here.
44
+ */
45
+ export declare function resolveAgentModuleDocPaths(rootDir: string, agentDoc: string | undefined): string[];
46
+ /** {@link resolveAgentModuleDocPaths}, with each doc's contents read. */
47
+ export declare function readAgentModuleDocs(rootDir: string, agentDoc: string | undefined): DomainKnowledgeModuleDoc[];
48
+ //# sourceMappingURL=knowledge-discovery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"knowledge-discovery.d.ts","sourceRoot":"","sources":["../src/knowledge-discovery.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAE1E,MAAM,WAAW,sBAAsB;IACrC,iFAAiF;IACjF,IAAI,EAAE,MAAM,CAAC;IACb,6EAA6E;IAC7E,SAAS,EAAE,MAAM,CAAC;IAClB,yEAAyE;IACzE,aAAa,EAAE,MAAM,CAAC;CACvB;AAED;;;GAGG;AACH,wBAAgB,gCAAgC,CAC9C,gBAAgB,EAAE,MAAM,EAAE,GACzB,sBAAsB,EAAE,CAwB1B;AAED,mFAAmF;AACnF,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE;IAAE,cAAc,CAAC,EAAE,OAAO,CAAA;CAAO;;;;;;;;EA0B3C;AAWD,yFAAyF;AACzF,eAAO,MAAM,sBAAsB,eAAe,CAAC;AAEnD;;;GAGG;AACH,eAAO,MAAM,yBAAyB,kBAAkB,CAAC;AAEzD;;;;;;;;;;GAUG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,GAAG,SAAS,GAC3B,MAAM,EAAE,CAgBV;AAED,yEAAyE;AACzE,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,GAAG,SAAS,GAC3B,wBAAwB,EAAE,CAM5B"}
@@ -0,0 +1,113 @@
1
+ /**
2
+ * Cross-package knowledge graph (#2863).
3
+ *
4
+ * Each package's own `smrt-knowledge.json` (see `knowledge.ts`) is a
5
+ * per-package projection. Nothing merges them, so cross-package invariants
6
+ * that the scanner manifest already carries — `@crossPackageRef` targets, STI
7
+ * parent/child pairs, junction/hierarchical/polymorphic base usage, and
8
+ * `_smrt_` system-table ownership — live only as prose in the root
9
+ * `AGENTS.md`. This module builds the merged, deterministic root artifact
10
+ * (`.smrt/smrt-knowledge-graph.json`) from whichever per-package artifacts
11
+ * are present, and checks it for staleness the same way `knowledge.ts` checks
12
+ * a package artifact: by comparing recorded `sourceHashes` against the
13
+ * current file content.
14
+ *
15
+ * This module never invents an edge: every edge is a direct read of a field
16
+ * already emitted into a package's `DomainKnowledgeManifest` (`related`,
17
+ * `tableStrategy`, `extends`, `relationshipFeatures`, `tableName`).
18
+ */
19
+ import type { DomainKnowledgeManifest } from '@happyvertical/smrt-types';
20
+ /**
21
+ * Discovers every currently-buildable per-package artifact path under
22
+ * `<rootDir>/packages/*`, preferring the published `dist/smrt-knowledge.json`
23
+ * over the local dev `.smrt/smrt-knowledge.json` when both exist. Shared by
24
+ * the generator (which needs the manifest content) and the freshness check
25
+ * (which only needs to know whether the current SET of artifacts matches
26
+ * what the graph was built from — a newly built package, or a package that
27
+ * newly started exporting `./smrt-knowledge.json`, must mark the graph stale
28
+ * even though every artifact the graph already knows about is unchanged).
29
+ */
30
+ export declare function discoverKnowledgeArtifactPaths(rootDir: string): string[];
31
+ /** One package's `smrt-knowledge.json`, located relative to the graph root. */
32
+ export interface KnowledgeGraphInput {
33
+ /** Path to the artifact, relative to the repo root, POSIX-separated. */
34
+ artifactPath: string;
35
+ manifest: DomainKnowledgeManifest;
36
+ }
37
+ export interface KnowledgeGraphPackageNode {
38
+ name: string;
39
+ version?: string;
40
+ artifactPath: string;
41
+ tags: string[];
42
+ risks: string[];
43
+ summary?: string;
44
+ objectCount: number;
45
+ }
46
+ export interface KnowledgeGraphObjectNode {
47
+ /** `<packageName>#<qualifiedName-or-name>`, this graph's stable object id. */
48
+ id: string;
49
+ packageName: string;
50
+ name: string;
51
+ qualifiedName?: string;
52
+ collection: string;
53
+ tableName?: string;
54
+ tableStrategy?: 'cti' | 'sti';
55
+ extends?: string;
56
+ }
57
+ export type KnowledgeGraphEdgeType = 'crossPackageRef' | 'sti' | 'junction' | 'hierarchical' | 'polymorphic' | 'systemTable';
58
+ export interface KnowledgeGraphEdge {
59
+ type: KnowledgeGraphEdgeType;
60
+ /** Object id (or `<packageName>#<extends>`-style unresolved target) this edge starts from. */
61
+ from: string;
62
+ /**
63
+ * Object id the edge points to when resolvable against a scanned object;
64
+ * otherwise the raw declared target (e.g. a qualified name this run did
65
+ * not scan), so the edge is still readable rather than dropped.
66
+ */
67
+ to?: string;
68
+ /** Declaring field name, for `crossPackageRef` edges. */
69
+ field?: string;
70
+ }
71
+ export interface SmrtKnowledgeGraph {
72
+ schemaVersion: 1;
73
+ generatedAt: string;
74
+ /** `artifactPath -> sha256(content)`, sorted by key; the freshness input. */
75
+ sourceHashes: Record<string, string>;
76
+ packages: KnowledgeGraphPackageNode[];
77
+ objects: KnowledgeGraphObjectNode[];
78
+ edges: KnowledgeGraphEdge[];
79
+ }
80
+ export interface BuildKnowledgeGraphOptions {
81
+ /**
82
+ * The graph currently on disk, when regenerating. `generatedAt` is
83
+ * preserved from it rather than reset to the clock whenever the rebuilt
84
+ * graph is otherwise semantically identical — the same pattern
85
+ * `preserveKnowledgeGeneratedAt` uses for per-package artifacts
86
+ * (`packages/core/src/vite-plugin/index.ts`) — so re-running the generator
87
+ * with nothing merged actually changed does not churn the file (#2872
88
+ * review).
89
+ */
90
+ previousGraph?: SmrtKnowledgeGraph;
91
+ }
92
+ /** Builds the merged graph. Deterministic: every array is sorted. */
93
+ export declare function buildKnowledgeGraph(inputs: KnowledgeGraphInput[], options?: BuildKnowledgeGraphOptions): SmrtKnowledgeGraph;
94
+ /** Deterministic `JSON.stringify` — object keys are sorted at every level. */
95
+ export declare function stableStringify(value: unknown): string;
96
+ export interface KnowledgeGraphFreshnessIssue {
97
+ severity: 'error' | 'warning';
98
+ code: 'missing-knowledge-graph' | 'stale-knowledge-graph' | 'knowledge-graph-source-missing';
99
+ message: string;
100
+ file?: string;
101
+ }
102
+ /**
103
+ * Checks the merged graph's recorded `sourceHashes` against the current
104
+ * content of each per-package artifact it was built from — the same pattern
105
+ * `knowledge.ts`/`smrt-dev-mcp` use for a single package's `sourceHashes`.
106
+ *
107
+ * `graphPath` and each `artifactPath` in the graph are resolved relative to
108
+ * `rootDir` (the repo root).
109
+ */
110
+ export declare function checkKnowledgeGraphFreshness(rootDir: string, graphPath: string, options?: {
111
+ requireArtifact?: boolean;
112
+ }): KnowledgeGraphFreshnessIssue[];
113
+ //# sourceMappingURL=knowledge-graph.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"knowledge-graph.d.ts","sourceRoot":"","sources":["../src/knowledge-graph.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAKH,OAAO,KAAK,EACV,uBAAuB,EAExB,MAAM,2BAA2B,CAAC;AAEnC;;;;;;;;;GASG;AACH,wBAAgB,8BAA8B,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAexE;AAED,+EAA+E;AAC/E,MAAM,WAAW,mBAAmB;IAClC,wEAAwE;IACxE,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,uBAAuB,CAAC;CACnC;AAED,MAAM,WAAW,yBAAyB;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,wBAAwB;IACvC,8EAA8E;IAC9E,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,MAAM,sBAAsB,GAC9B,iBAAiB,GACjB,KAAK,GACL,UAAU,GACV,cAAc,GACd,aAAa,GACb,aAAa,CAAC;AAElB,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,sBAAsB,CAAC;IAC7B,8FAA8F;IAC9F,IAAI,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,yDAAyD;IACzD,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,kBAAkB;IACjC,aAAa,EAAE,CAAC,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,6EAA6E;IAC7E,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,QAAQ,EAAE,yBAAyB,EAAE,CAAC;IACtC,OAAO,EAAE,wBAAwB,EAAE,CAAC;IACpC,KAAK,EAAE,kBAAkB,EAAE,CAAC;CAC7B;AAUD,MAAM,WAAW,0BAA0B;IACzC;;;;;;;;OAQG;IACH,aAAa,CAAC,EAAE,kBAAkB,CAAC;CACpC;AAED,qEAAqE;AACrE,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,mBAAmB,EAAE,EAC7B,OAAO,GAAE,0BAA+B,GACvC,kBAAkB,CAoKpB;AAOD,8EAA8E;AAC9E,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAEtD;AA+BD,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,EAAE,OAAO,GAAG,SAAS,CAAC;IAC9B,IAAI,EACA,yBAAyB,GACzB,uBAAuB,GACvB,gCAAgC,CAAC;IACrC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE;IAAE,eAAe,CAAC,EAAE,OAAO,CAAA;CAAO,GAC1C,4BAA4B,EAAE,CA0FhC"}
@@ -0,0 +1,3 @@
1
+ export { AGENT_SURFACE_HASH_PREFIX, discoverScopedPackageDirectories, MODULE_DOC_HASH_PREFIX, readAgentModuleDocs, readPackageAgentDoc, resolveAgentModuleDocPaths, type ScopedPackageDirectory, } from './knowledge-discovery.js';
2
+ export { type BuildKnowledgeGraphOptions, buildKnowledgeGraph, checkKnowledgeGraphFreshness, discoverKnowledgeArtifactPaths, type KnowledgeGraphEdge, type KnowledgeGraphEdgeType, type KnowledgeGraphFreshnessIssue, type KnowledgeGraphInput, type KnowledgeGraphObjectNode, type KnowledgeGraphPackageNode, type SmrtKnowledgeGraph, stableStringify, } from './knowledge-graph.js';
3
+ //# sourceMappingURL=knowledge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"knowledge.d.ts","sourceRoot":"","sources":["../src/knowledge.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,gCAAgC,EAChC,sBAAsB,EACtB,mBAAmB,EACnB,mBAAmB,EACnB,0BAA0B,EAC1B,KAAK,sBAAsB,GAC5B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,KAAK,0BAA0B,EAC/B,mBAAmB,EACnB,4BAA4B,EAC5B,8BAA8B,EAC9B,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,EAC3B,KAAK,4BAA4B,EACjC,KAAK,mBAAmB,EACxB,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,EAC9B,KAAK,kBAAkB,EACvB,eAAe,GAChB,MAAM,sBAAsB,CAAC"}