@happyvertical/smrt-scanner 0.51.32 → 0.51.33

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,301 @@
1
+ import { existsSync, readFileSync, readdirSync, realpathSync, statSync } from "node:fs";
2
+ import { basename, join, relative, resolve, sep } from "node:path";
3
+ import { createHash } from "node:crypto";
4
+ //#region src/knowledge-discovery.ts
5
+ function discoverScopedPackageDirectories(scopeDirectories) {
6
+ const packages = [];
7
+ for (const scopeDirectory of new Set(scopeDirectories)) {
8
+ let entries;
9
+ try {
10
+ entries = readdirSync(scopeDirectory, { withFileTypes: true });
11
+ } catch {
12
+ continue;
13
+ }
14
+ for (const entry of entries) {
15
+ if (!entry.isDirectory() && !entry.isSymbolicLink()) continue;
16
+ const directory = join(scopeDirectory, entry.name);
17
+ try {
18
+ packages.push({
19
+ name: entry.name,
20
+ directory,
21
+ realDirectory: realpathSync(directory)
22
+ });
23
+ } catch {}
24
+ }
25
+ }
26
+ return packages;
27
+ }
28
+ function readPackageAgentDoc(directory, options = {}) {
29
+ const agentsPath = join(directory, "AGENTS.md");
30
+ const claudePath = join(directory, "CLAUDE.md");
31
+ const hasAgentsMd = existsSync(agentsPath);
32
+ const hasClaudeMd = existsSync(claudePath);
33
+ const agentsContent = hasAgentsMd ? readFileSync(agentsPath, "utf8") : "";
34
+ const claudeContent = hasClaudeMd && (!hasAgentsMd || options.inspectAdapter) ? readFileSync(claudePath, "utf8") : "";
35
+ const hasClaudeShim = hasClaudeMd && claudeContent.trim() === "@AGENTS.md";
36
+ const source = hasAgentsMd ? "AGENTS.md" : hasClaudeMd && !hasClaudeShim ? "CLAUDE.md" : null;
37
+ return {
38
+ hasAgentsMd,
39
+ hasClaudeMd,
40
+ hasClaudeShim,
41
+ agentsContent,
42
+ claudeContent,
43
+ source,
44
+ content: hasAgentsMd ? agentsContent : source ? claudeContent : null
45
+ };
46
+ }
47
+ var MARKDOWN_MD_LINK = /\[[^\]]*\]\(\s*([^)\s#]+\.md)(?:#[^)\s]*)?(?:\s+"[^"]*")?\s*\)/g;
48
+ var MODULE_DOC_HASH_PREFIX = "moduleDoc:";
49
+ var AGENT_SURFACE_HASH_PREFIX = "agentSurface:";
50
+ function resolveAgentModuleDocPaths(rootDir, agentDoc) {
51
+ if (!agentDoc) return [];
52
+ const root = resolve(rootDir);
53
+ const paths = [];
54
+ for (const match of agentDoc.matchAll(MARKDOWN_MD_LINK)) {
55
+ const target = match[1];
56
+ if (target.includes("://")) continue;
57
+ const absolute = resolve(root, target);
58
+ if (absolute !== root && !absolute.startsWith(root + sep)) continue;
59
+ const relativePath = relative(root, absolute).split(sep).join("/");
60
+ if (relativePath === "AGENTS.md" || relativePath === "CLAUDE.md") continue;
61
+ if (paths.includes(relativePath)) continue;
62
+ if (!existsSync(absolute) || !statSync(absolute).isFile()) continue;
63
+ paths.push(relativePath);
64
+ }
65
+ return paths;
66
+ }
67
+ function readAgentModuleDocs(rootDir, agentDoc) {
68
+ return resolveAgentModuleDocPaths(rootDir, agentDoc).map((path) => ({
69
+ path,
70
+ module: basename(path, ".md"),
71
+ content: readFileSync(join(rootDir, path), "utf8")
72
+ }));
73
+ }
74
+ //#endregion
75
+ //#region src/knowledge-graph.ts
76
+ function discoverKnowledgeArtifactPaths(rootDir) {
77
+ const packagesDir = join(rootDir, "packages");
78
+ if (!existsSync(packagesDir)) return [];
79
+ const paths = [];
80
+ for (const entry of readdirSync(packagesDir, { withFileTypes: true })) {
81
+ if (!entry.isDirectory()) continue;
82
+ const packageDir = join(packagesDir, entry.name);
83
+ const found = [join(packageDir, "dist", "smrt-knowledge.json"), join(packageDir, ".smrt", "smrt-knowledge.json")].find((path) => existsSync(path));
84
+ if (found) paths.push(relative(rootDir, found).split("\\").join("/"));
85
+ }
86
+ return paths.sort();
87
+ }
88
+ function hashContent(content) {
89
+ return createHash("sha256").update(content).digest("hex");
90
+ }
91
+ function objectId(packageName, object) {
92
+ return `${packageName}#${object.qualifiedName ?? object.name}`;
93
+ }
94
+ function buildKnowledgeGraph(inputs, options = {}) {
95
+ const sortedInputs = [...inputs].sort((a, b) => a.artifactPath.localeCompare(b.artifactPath));
96
+ const sourceHashes = {};
97
+ const packages = [];
98
+ const objects = [];
99
+ const edges = [];
100
+ const idByQualifiedName = /* @__PURE__ */ new Map();
101
+ const idBySimpleName = /* @__PURE__ */ new Map();
102
+ const idBySimpleNamePerPackage = /* @__PURE__ */ new Map();
103
+ for (const input of sortedInputs) {
104
+ const manifestPackageName = input.manifest.packageName ?? input.artifactPath;
105
+ for (const object of input.manifest.objects) {
106
+ const packageName = object.packageName ?? manifestPackageName;
107
+ const perPackage = idBySimpleNamePerPackage.get(packageName) ?? /* @__PURE__ */ new Map();
108
+ const id = objectId(packageName, object);
109
+ idByQualifiedName.set(object.qualifiedName ?? id, id);
110
+ const bySimple = idBySimpleName.get(object.name) ?? /* @__PURE__ */ new Set();
111
+ bySimple.add(id);
112
+ idBySimpleName.set(object.name, bySimple);
113
+ perPackage.set(object.name, id);
114
+ idBySimpleNamePerPackage.set(packageName, perPackage);
115
+ }
116
+ }
117
+ const resolveTarget = (raw, declaringPackageName) => {
118
+ if (!raw) return void 0;
119
+ if (idByQualifiedName.has(raw)) return idByQualifiedName.get(raw);
120
+ if (declaringPackageName) {
121
+ const sameId = idBySimpleNamePerPackage.get(declaringPackageName)?.get(raw);
122
+ if (sameId) return sameId;
123
+ }
124
+ const bySimple = idBySimpleName.get(raw);
125
+ if (bySimple && bySimple.size === 1) return [...bySimple][0];
126
+ };
127
+ const seenObjectIds = /* @__PURE__ */ new Set();
128
+ for (const input of sortedInputs) {
129
+ sourceHashes[input.artifactPath] = hashContent(stableStringify(input.manifest));
130
+ const packageName = input.manifest.packageName ?? input.artifactPath;
131
+ packages.push({
132
+ name: packageName,
133
+ version: input.manifest.packageVersion,
134
+ artifactPath: input.artifactPath,
135
+ tags: [...input.manifest.tags].sort(),
136
+ risks: [...input.manifest.risks].sort(),
137
+ summary: input.manifest.summary,
138
+ objectCount: input.manifest.objects.length
139
+ });
140
+ for (const object of input.manifest.objects) {
141
+ const objectPackageName = object.packageName ?? packageName;
142
+ const id = objectId(objectPackageName, object);
143
+ if (!seenObjectIds.has(id)) {
144
+ seenObjectIds.add(id);
145
+ objects.push({
146
+ id,
147
+ packageName: objectPackageName,
148
+ name: object.name,
149
+ qualifiedName: object.qualifiedName,
150
+ collection: object.collection,
151
+ tableName: object.tableName,
152
+ tableStrategy: object.tableStrategy,
153
+ extends: object.extends
154
+ });
155
+ }
156
+ for (const field of object.relationships) {
157
+ if (field.type !== "crossPackageRef") continue;
158
+ edges.push({
159
+ type: "crossPackageRef",
160
+ from: id,
161
+ to: resolveTarget(field.related) ?? field.related,
162
+ field: field.name
163
+ });
164
+ }
165
+ if (object.tableStrategy === "sti" && object.extends) edges.push({
166
+ type: "sti",
167
+ from: id,
168
+ to: resolveTarget(object.extends, objectPackageName) ?? `${objectPackageName}#${object.extends}`
169
+ });
170
+ for (const feature of object.relationshipFeatures) if (feature === "SmrtJunction") edges.push({
171
+ type: "junction",
172
+ from: id
173
+ });
174
+ else if (feature === "SmrtHierarchical") edges.push({
175
+ type: "hierarchical",
176
+ from: id
177
+ });
178
+ else if (feature === "SmrtPolymorphicAssociation") edges.push({
179
+ type: "polymorphic",
180
+ from: id
181
+ });
182
+ if (object.tableName?.startsWith("_smrt_")) edges.push({
183
+ type: "systemTable",
184
+ from: id,
185
+ to: object.tableName
186
+ });
187
+ }
188
+ }
189
+ packages.sort((a, b) => a.name.localeCompare(b.name));
190
+ objects.sort((a, b) => a.id.localeCompare(b.id));
191
+ edges.sort((a, b) => {
192
+ const key = (edge) => `${edge.type}|${edge.from}|${edge.to ?? ""}|${edge.field ?? ""}`;
193
+ return key(a).localeCompare(key(b));
194
+ });
195
+ const graph = {
196
+ schemaVersion: 1,
197
+ generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
198
+ sourceHashes: sortRecord(sourceHashes),
199
+ packages,
200
+ objects,
201
+ edges
202
+ };
203
+ const { previousGraph } = options;
204
+ if (previousGraph && semanticGraphJson(previousGraph) === semanticGraphJson(graph)) return {
205
+ ...graph,
206
+ generatedAt: previousGraph.generatedAt
207
+ };
208
+ return graph;
209
+ }
210
+ function semanticGraphJson(graph) {
211
+ const { generatedAt: _generatedAt, ...rest } = graph;
212
+ return stableStringify(rest);
213
+ }
214
+ function stableStringify(value) {
215
+ return JSON.stringify(sortValue(value));
216
+ }
217
+ function sortValue(value) {
218
+ if (Array.isArray(value)) return value.map(sortValue);
219
+ if (value && typeof value === "object") {
220
+ const sorted = /* @__PURE__ */ Object.create(null);
221
+ for (const key of Object.keys(value).sort()) sorted[key] = sortValue(value[key]);
222
+ return sorted;
223
+ }
224
+ return value;
225
+ }
226
+ function sortRecord(record) {
227
+ const sorted = {};
228
+ for (const key of Object.keys(record).sort()) sorted[key] = record[key];
229
+ return sorted;
230
+ }
231
+ function checkKnowledgeGraphFreshness(rootDir, graphPath, options = {}) {
232
+ const issues = [];
233
+ const absoluteGraphPath = `${rootDir}/${graphPath}`;
234
+ if (!existsSync(absoluteGraphPath)) {
235
+ if (!options.requireArtifact) return issues;
236
+ issues.push({
237
+ severity: "error",
238
+ code: "missing-knowledge-graph",
239
+ message: `${graphPath} does not exist; run \`pnpm knowledge:graph\``,
240
+ file: graphPath
241
+ });
242
+ return issues;
243
+ }
244
+ let graph;
245
+ try {
246
+ graph = JSON.parse(readFileSync(absoluteGraphPath, "utf8"));
247
+ } catch (error) {
248
+ issues.push({
249
+ severity: "error",
250
+ code: "stale-knowledge-graph",
251
+ message: `${graphPath} is not valid JSON: ${error instanceof Error ? error.message : String(error)}`,
252
+ file: graphPath
253
+ });
254
+ return issues;
255
+ }
256
+ const recordedPaths = Object.keys(graph.sourceHashes ?? {});
257
+ for (const [artifactPath, expectedHash] of Object.entries(graph.sourceHashes ?? {})) {
258
+ const absoluteArtifactPath = `${rootDir}/${artifactPath}`;
259
+ if (!existsSync(absoluteArtifactPath)) {
260
+ issues.push({
261
+ severity: "error",
262
+ code: "knowledge-graph-source-missing",
263
+ message: `${artifactPath} used to build ${graphPath} no longer exists`,
264
+ file: graphPath
265
+ });
266
+ continue;
267
+ }
268
+ let manifest;
269
+ try {
270
+ manifest = JSON.parse(readFileSync(absoluteArtifactPath, "utf8"));
271
+ } catch (error) {
272
+ issues.push({
273
+ severity: "error",
274
+ code: "stale-knowledge-graph",
275
+ message: `${artifactPath} is not valid JSON (${error instanceof Error ? error.message : String(error)}); run \`pnpm knowledge:graph\``,
276
+ file: graphPath
277
+ });
278
+ continue;
279
+ }
280
+ if (hashContent(stableStringify(manifest)) !== expectedHash) issues.push({
281
+ severity: "error",
282
+ code: "stale-knowledge-graph",
283
+ message: `${artifactPath} changed since ${graphPath} was generated; run \`pnpm knowledge:graph\``,
284
+ file: graphPath
285
+ });
286
+ }
287
+ const currentPaths = discoverKnowledgeArtifactPaths(rootDir);
288
+ const recordedSet = new Set(recordedPaths);
289
+ const newPaths = currentPaths.filter((path) => !recordedSet.has(path));
290
+ if (newPaths.length > 0) issues.push({
291
+ severity: "error",
292
+ code: "stale-knowledge-graph",
293
+ message: `${newPaths.join(", ")} ${newPaths.length === 1 ? "is a new package artifact" : "are new package artifacts"} not yet merged into ${graphPath}; run \`pnpm knowledge:graph\``,
294
+ file: graphPath
295
+ });
296
+ return issues;
297
+ }
298
+ //#endregion
299
+ export { AGENT_SURFACE_HASH_PREFIX, MODULE_DOC_HASH_PREFIX, buildKnowledgeGraph, checkKnowledgeGraphFreshness, discoverKnowledgeArtifactPaths, discoverScopedPackageDirectories, readAgentModuleDocs, readPackageAgentDoc, resolveAgentModuleDocPaths, stableStringify };
300
+
301
+ //# sourceMappingURL=knowledge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"knowledge.js","names":[],"sources":["../src/knowledge-discovery.ts","../src/knowledge-graph.ts"],"sourcesContent":["/** Filesystem-only discovery shared by docs snapshots and knowledge indexing. */\nimport type { Dirent } from 'node:fs';\nimport {\n existsSync,\n readdirSync,\n readFileSync,\n realpathSync,\n statSync,\n} from 'node:fs';\nimport { basename, join, relative, resolve, sep } from 'node:path';\nimport type { DomainKnowledgeModuleDoc } from '@happyvertical/smrt-types';\n\nexport interface ScopedPackageDirectory {\n /** Scope entry name; consumers may select by alias rather than manifest name. */\n name: string;\n /** Original node_modules path, retained for workspace-relative reporting. */\n directory: string;\n /** Resolved path for identity comparisons or absolute snapshot links. */\n realDirectory: string;\n}\n\n/**\n * Enumerate scope entries without descending into pnpm's linked dependency graph.\n * Selection, workspace discovery and enrichment remain caller policies.\n */\nexport function discoverScopedPackageDirectories(\n scopeDirectories: string[],\n): ScopedPackageDirectory[] {\n const packages: ScopedPackageDirectory[] = [];\n for (const scopeDirectory of new Set(scopeDirectories)) {\n let entries: Dirent[];\n try {\n entries = readdirSync(scopeDirectory, { withFileTypes: true });\n } catch {\n continue;\n }\n for (const entry of entries) {\n if (!entry.isDirectory() && !entry.isSymbolicLink()) continue;\n const directory = join(scopeDirectory, entry.name);\n try {\n packages.push({\n name: entry.name,\n directory,\n realDirectory: realpathSync(directory),\n });\n } catch {\n // Dangling links are not installed packages.\n }\n }\n }\n return packages;\n}\n\n/** Read authored docs only; never load artifacts, package code or object scans. */\nexport function readPackageAgentDoc(\n directory: string,\n options: { inspectAdapter?: boolean } = {},\n) {\n const agentsPath = join(directory, 'AGENTS.md');\n const claudePath = join(directory, 'CLAUDE.md');\n const hasAgentsMd = existsSync(agentsPath);\n const hasClaudeMd = existsSync(claudePath);\n const agentsContent = hasAgentsMd ? readFileSync(agentsPath, 'utf8') : '';\n const claudeContent =\n hasClaudeMd && (!hasAgentsMd || options.inspectAdapter)\n ? readFileSync(claudePath, 'utf8')\n : '';\n const hasClaudeShim = hasClaudeMd && claudeContent.trim() === '@AGENTS.md';\n const source: 'AGENTS.md' | 'CLAUDE.md' | null = hasAgentsMd\n ? 'AGENTS.md'\n : hasClaudeMd && !hasClaudeShim\n ? 'CLAUDE.md'\n : null;\n return {\n hasAgentsMd,\n hasClaudeMd,\n hasClaudeShim,\n agentsContent,\n claudeContent,\n source,\n content: hasAgentsMd ? agentsContent : source ? claudeContent : null,\n };\n}\n\n/**\n * Markdown inline links whose target is a `.md` file — `[label](agents/x.md)`,\n * tolerating an `#anchor` and a `\"title\"`. This is how a package registers a\n * sibling module doc (#2108): the link in `AGENTS.md` IS the registration, so\n * there is no separate index to drift out of sync.\n */\nconst MARKDOWN_MD_LINK =\n /\\[[^\\]]*\\]\\(\\s*([^)\\s#]+\\.md)(?:#[^)\\s]*)?(?:\\s+\"[^\"]*\")?\\s*\\)/g;\n\n/** `sourceHashes` key prefix for a linked module doc, e.g. `moduleDoc:agents/crm.md`. */\nexport const MODULE_DOC_HASH_PREFIX = 'moduleDoc:';\n\n/**\n * `sourceHashes` key prefix for a module declaring a view intent or playbook,\n * e.g. `agentSurface:src/lib/orders.intents.ts` (#2591).\n */\nexport const AGENT_SURFACE_HASH_PREFIX = 'agentSurface:';\n\n/**\n * Module doc paths linked from a package's `AGENTS.md`, relative to the package\n * root and in document order.\n *\n * Instruction chains are additive (see `scripts/check-agents-chain.mjs`), so an\n * oversized package doc is split into `packages/<pkg>/agents/<module>.md` siblings\n * instead of nested `AGENTS.md` files. Only links resolving to an existing file\n * INSIDE the package are accepted — a cross-package reference such as\n * `packages/affiliates/MIGRATION.md` belongs to that package's own chain and is\n * ignored here.\n */\nexport function resolveAgentModuleDocPaths(\n rootDir: string,\n agentDoc: string | undefined,\n): string[] {\n if (!agentDoc) return [];\n const root = resolve(rootDir);\n const paths: string[] = [];\n for (const match of agentDoc.matchAll(MARKDOWN_MD_LINK)) {\n const target = match[1];\n if (target.includes('://')) continue;\n const absolute = resolve(root, target);\n if (absolute !== root && !absolute.startsWith(root + sep)) continue;\n const relativePath = relative(root, absolute).split(sep).join('/');\n if (relativePath === 'AGENTS.md' || relativePath === 'CLAUDE.md') continue;\n if (paths.includes(relativePath)) continue;\n if (!existsSync(absolute) || !statSync(absolute).isFile()) continue;\n paths.push(relativePath);\n }\n return paths;\n}\n\n/** {@link resolveAgentModuleDocPaths}, with each doc's contents read. */\nexport function readAgentModuleDocs(\n rootDir: string,\n agentDoc: string | undefined,\n): DomainKnowledgeModuleDoc[] {\n return resolveAgentModuleDocPaths(rootDir, agentDoc).map((path) => ({\n path,\n module: basename(path, '.md'),\n content: readFileSync(join(rootDir, path), 'utf8'),\n }));\n}\n","/**\n * Cross-package knowledge graph (#2863).\n *\n * Each package's own `smrt-knowledge.json` (see `knowledge.ts`) is a\n * per-package projection. Nothing merges them, so cross-package invariants\n * that the scanner manifest already carries — `@crossPackageRef` targets, STI\n * parent/child pairs, junction/hierarchical/polymorphic base usage, and\n * `_smrt_` system-table ownership — live only as prose in the root\n * `AGENTS.md`. This module builds the merged, deterministic root artifact\n * (`.smrt/smrt-knowledge-graph.json`) from whichever per-package artifacts\n * are present, and checks it for staleness the same way `knowledge.ts` checks\n * a package artifact: by comparing recorded `sourceHashes` against the\n * current file content.\n *\n * This module never invents an edge: every edge is a direct read of a field\n * already emitted into a package's `DomainKnowledgeManifest` (`related`,\n * `tableStrategy`, `extends`, `relationshipFeatures`, `tableName`).\n */\n\nimport { createHash } from 'node:crypto';\nimport { existsSync, readdirSync, readFileSync } from 'node:fs';\nimport { join, relative } from 'node:path';\nimport type {\n DomainKnowledgeManifest,\n DomainKnowledgeObject,\n} from '@happyvertical/smrt-types';\n\n/**\n * Discovers every currently-buildable per-package artifact path under\n * `<rootDir>/packages/*`, preferring the published `dist/smrt-knowledge.json`\n * over the local dev `.smrt/smrt-knowledge.json` when both exist. Shared by\n * the generator (which needs the manifest content) and the freshness check\n * (which only needs to know whether the current SET of artifacts matches\n * what the graph was built from — a newly built package, or a package that\n * newly started exporting `./smrt-knowledge.json`, must mark the graph stale\n * even though every artifact the graph already knows about is unchanged).\n */\nexport function discoverKnowledgeArtifactPaths(rootDir: string): string[] {\n const packagesDir = join(rootDir, 'packages');\n if (!existsSync(packagesDir)) return [];\n const paths: string[] = [];\n for (const entry of readdirSync(packagesDir, { withFileTypes: true })) {\n if (!entry.isDirectory()) continue;\n const packageDir = join(packagesDir, entry.name);\n const candidates = [\n join(packageDir, 'dist', 'smrt-knowledge.json'),\n join(packageDir, '.smrt', 'smrt-knowledge.json'),\n ];\n const found = candidates.find((path) => existsSync(path));\n if (found) paths.push(relative(rootDir, found).split('\\\\').join('/'));\n }\n return paths.sort();\n}\n\n/** One package's `smrt-knowledge.json`, located relative to the graph root. */\nexport interface KnowledgeGraphInput {\n /** Path to the artifact, relative to the repo root, POSIX-separated. */\n artifactPath: string;\n manifest: DomainKnowledgeManifest;\n}\n\nexport interface KnowledgeGraphPackageNode {\n name: string;\n version?: string;\n artifactPath: string;\n tags: string[];\n risks: string[];\n summary?: string;\n objectCount: number;\n}\n\nexport interface KnowledgeGraphObjectNode {\n /** `<packageName>#<qualifiedName-or-name>`, this graph's stable object id. */\n id: string;\n packageName: string;\n name: string;\n qualifiedName?: string;\n collection: string;\n tableName?: string;\n tableStrategy?: 'cti' | 'sti';\n extends?: string;\n}\n\nexport type KnowledgeGraphEdgeType =\n | 'crossPackageRef'\n | 'sti'\n | 'junction'\n | 'hierarchical'\n | 'polymorphic'\n | 'systemTable';\n\nexport interface KnowledgeGraphEdge {\n type: KnowledgeGraphEdgeType;\n /** Object id (or `<packageName>#<extends>`-style unresolved target) this edge starts from. */\n from: string;\n /**\n * Object id the edge points to when resolvable against a scanned object;\n * otherwise the raw declared target (e.g. a qualified name this run did\n * not scan), so the edge is still readable rather than dropped.\n */\n to?: string;\n /** Declaring field name, for `crossPackageRef` edges. */\n field?: string;\n}\n\nexport interface SmrtKnowledgeGraph {\n schemaVersion: 1;\n generatedAt: string;\n /** `artifactPath -> sha256(content)`, sorted by key; the freshness input. */\n sourceHashes: Record<string, string>;\n packages: KnowledgeGraphPackageNode[];\n objects: KnowledgeGraphObjectNode[];\n edges: KnowledgeGraphEdge[];\n}\n\nfunction hashContent(content: string): string {\n return createHash('sha256').update(content).digest('hex');\n}\n\nfunction objectId(packageName: string, object: DomainKnowledgeObject): string {\n return `${packageName}#${object.qualifiedName ?? object.name}`;\n}\n\nexport interface BuildKnowledgeGraphOptions {\n /**\n * The graph currently on disk, when regenerating. `generatedAt` is\n * preserved from it rather than reset to the clock whenever the rebuilt\n * graph is otherwise semantically identical — the same pattern\n * `preserveKnowledgeGeneratedAt` uses for per-package artifacts\n * (`packages/core/src/vite-plugin/index.ts`) — so re-running the generator\n * with nothing merged actually changed does not churn the file (#2872\n * review).\n */\n previousGraph?: SmrtKnowledgeGraph;\n}\n\n/** Builds the merged graph. Deterministic: every array is sorted. */\nexport function buildKnowledgeGraph(\n inputs: KnowledgeGraphInput[],\n options: BuildKnowledgeGraphOptions = {},\n): SmrtKnowledgeGraph {\n const sortedInputs = [...inputs].sort((a, b) =>\n a.artifactPath.localeCompare(b.artifactPath),\n );\n\n const sourceHashes: Record<string, string> = {};\n const packages: KnowledgeGraphPackageNode[] = [];\n const objects: KnowledgeGraphObjectNode[] = [];\n const edges: KnowledgeGraphEdge[] = [];\n\n // Qualified-name -> object id, so a crossPackageRef/STI target declared in\n // one package can be resolved to the node emitted by whichever package\n // scanned it, regardless of scan order.\n const idByQualifiedName = new Map<string, string>();\n // Distinct ids per simple name, not a plain array: the same external\n // object can appear in more than one input (e.g. a package artifact and a\n // smrtConsumer aggregate that also scanned it), and counting the\n // duplicate would make resolveTarget's `.length === 1` uniqueness check\n // see a false ambiguity for an otherwise-unique name (#2872 review).\n const idBySimpleName = new Map<string, Set<string>>();\n // A `tableStrategy: 'sti'` object's `extends` is an unqualified simple name\n // (its own package's base class, never a cross-package reference — STI\n // shares one table within a package), so a same-package simple-name match\n // must win over an ambiguous or wrong-package GLOBAL simple-name match:\n // two packages both declaring `Account` must not point one package's\n // subclass at the other package's `Account` (#2863 review).\n const idBySimpleNamePerPackage = new Map<string, Map<string, string>>();\n\n for (const input of sortedInputs) {\n const manifestPackageName =\n input.manifest.packageName ?? input.artifactPath;\n for (const object of input.manifest.objects) {\n // A merged consumer manifest (`smrtConsumer`) aggregates objects\n // scanned from multiple external packages under one local artifact;\n // each object then carries its own `packageName` and that must own\n // the id, or every external object misattributes to the local\n // project and edges resolve to the wrong node (#2872 review).\n const packageName = object.packageName ?? manifestPackageName;\n const perPackage =\n idBySimpleNamePerPackage.get(packageName) ?? new Map<string, string>();\n const id = objectId(packageName, object);\n idByQualifiedName.set(object.qualifiedName ?? id, id);\n const bySimple = idBySimpleName.get(object.name) ?? new Set<string>();\n bySimple.add(id);\n idBySimpleName.set(object.name, bySimple);\n perPackage.set(object.name, id);\n idBySimpleNamePerPackage.set(packageName, perPackage);\n }\n }\n\n const resolveTarget = (\n raw: string | undefined,\n declaringPackageName?: string,\n ): string | undefined => {\n if (!raw) return undefined;\n if (idByQualifiedName.has(raw)) return idByQualifiedName.get(raw);\n if (declaringPackageName) {\n const sameId = idBySimpleNamePerPackage\n .get(declaringPackageName)\n ?.get(raw);\n if (sameId) return sameId;\n }\n const bySimple = idBySimpleName.get(raw);\n if (bySimple && bySimple.size === 1) return [...bySimple][0];\n return undefined;\n };\n\n const seenObjectIds = new Set<string>();\n for (const input of sortedInputs) {\n sourceHashes[input.artifactPath] = hashContent(\n stableStringify(input.manifest),\n );\n const packageName = input.manifest.packageName ?? input.artifactPath;\n\n packages.push({\n name: packageName,\n version: input.manifest.packageVersion,\n artifactPath: input.artifactPath,\n tags: [...input.manifest.tags].sort(),\n risks: [...input.manifest.risks].sort(),\n summary: input.manifest.summary,\n objectCount: input.manifest.objects.length,\n });\n\n for (const object of input.manifest.objects) {\n // See the id-map pass above: an aggregated consumer manifest attributes\n // each object to its own scanned package, not the local project.\n const objectPackageName = object.packageName ?? packageName;\n const id = objectId(objectPackageName, object);\n if (!seenObjectIds.has(id)) {\n seenObjectIds.add(id);\n objects.push({\n id,\n packageName: objectPackageName,\n name: object.name,\n qualifiedName: object.qualifiedName,\n collection: object.collection,\n tableName: object.tableName,\n tableStrategy: object.tableStrategy,\n extends: object.extends,\n });\n }\n\n for (const field of object.relationships) {\n if (field.type !== 'crossPackageRef') continue;\n edges.push({\n type: 'crossPackageRef',\n from: id,\n to: resolveTarget(field.related) ?? field.related,\n field: field.name,\n });\n }\n\n if (object.tableStrategy === 'sti' && object.extends) {\n edges.push({\n type: 'sti',\n from: id,\n to:\n resolveTarget(object.extends, objectPackageName) ??\n `${objectPackageName}#${object.extends}`,\n });\n }\n\n for (const feature of object.relationshipFeatures) {\n if (feature === 'SmrtJunction') {\n edges.push({ type: 'junction', from: id });\n } else if (feature === 'SmrtHierarchical') {\n edges.push({ type: 'hierarchical', from: id });\n } else if (feature === 'SmrtPolymorphicAssociation') {\n edges.push({ type: 'polymorphic', from: id });\n }\n }\n\n if (object.tableName?.startsWith('_smrt_')) {\n edges.push({ type: 'systemTable', from: id, to: object.tableName });\n }\n }\n }\n\n packages.sort((a, b) => a.name.localeCompare(b.name));\n objects.sort((a, b) => a.id.localeCompare(b.id));\n edges.sort((a, b) => {\n const key = (edge: KnowledgeGraphEdge) =>\n `${edge.type}|${edge.from}|${edge.to ?? ''}|${edge.field ?? ''}`;\n return key(a).localeCompare(key(b));\n });\n\n const graph: SmrtKnowledgeGraph = {\n schemaVersion: 1,\n generatedAt: new Date().toISOString(),\n sourceHashes: sortRecord(sourceHashes),\n packages,\n objects,\n edges,\n };\n\n const { previousGraph } = options;\n if (\n previousGraph &&\n semanticGraphJson(previousGraph) === semanticGraphJson(graph)\n ) {\n return { ...graph, generatedAt: previousGraph.generatedAt };\n }\n return graph;\n}\n\nfunction semanticGraphJson(graph: SmrtKnowledgeGraph): string {\n const { generatedAt: _generatedAt, ...rest } = graph;\n return stableStringify(rest);\n}\n\n/** Deterministic `JSON.stringify` — object keys are sorted at every level. */\nexport function stableStringify(value: unknown): string {\n return JSON.stringify(sortValue(value));\n}\n\nfunction sortValue(value: unknown): unknown {\n if (Array.isArray(value)) return value.map(sortValue);\n if (value && typeof value === 'object') {\n // Null-prototype target: on an ordinary `{}`, assigning the key\n // `\"__proto__\"` through bracket notation invokes `Object.prototype`'s\n // `__proto__` accessor instead of creating an own property, so that key\n // silently vanishes from the result and `JSON.stringify()` never emits\n // it — two inputs that differ only by an own `\"__proto__\"` key (which\n // `JSON.parse()` does create as a real own property) then serialize\n // identically. An object with no prototype has no such accessor to\n // shadow the assignment, so every own key — including `\"__proto__\"` —\n // becomes a real own data property. `JSON.stringify()` does not care\n // about an object's prototype, only its own enumerable properties, so\n // this changes no other output.\n const sorted: Record<string, unknown> = Object.create(null);\n for (const key of Object.keys(value as Record<string, unknown>).sort()) {\n sorted[key] = sortValue((value as Record<string, unknown>)[key]);\n }\n return sorted;\n }\n return value;\n}\n\nfunction sortRecord(record: Record<string, string>): Record<string, string> {\n const sorted: Record<string, string> = {};\n for (const key of Object.keys(record).sort()) sorted[key] = record[key];\n return sorted;\n}\n\nexport interface KnowledgeGraphFreshnessIssue {\n severity: 'error' | 'warning';\n code:\n | 'missing-knowledge-graph'\n | 'stale-knowledge-graph'\n | 'knowledge-graph-source-missing';\n message: string;\n file?: string;\n}\n\n/**\n * Checks the merged graph's recorded `sourceHashes` against the current\n * content of each per-package artifact it was built from — the same pattern\n * `knowledge.ts`/`smrt-dev-mcp` use for a single package's `sourceHashes`.\n *\n * `graphPath` and each `artifactPath` in the graph are resolved relative to\n * `rootDir` (the repo root).\n */\nexport function checkKnowledgeGraphFreshness(\n rootDir: string,\n graphPath: string,\n options: { requireArtifact?: boolean } = {},\n): KnowledgeGraphFreshnessIssue[] {\n const issues: KnowledgeGraphFreshnessIssue[] = [];\n const absoluteGraphPath = `${rootDir}/${graphPath}`;\n if (!existsSync(absoluteGraphPath)) {\n if (!options.requireArtifact) return issues;\n issues.push({\n severity: 'error',\n code: 'missing-knowledge-graph',\n message: `${graphPath} does not exist; run \\`pnpm knowledge:graph\\``,\n file: graphPath,\n });\n return issues;\n }\n\n let graph: SmrtKnowledgeGraph;\n try {\n graph = JSON.parse(readFileSync(absoluteGraphPath, 'utf8'));\n } catch (error) {\n issues.push({\n severity: 'error',\n code: 'stale-knowledge-graph',\n message: `${graphPath} is not valid JSON: ${\n error instanceof Error ? error.message : String(error)\n }`,\n file: graphPath,\n });\n return issues;\n }\n\n const recordedPaths = Object.keys(graph.sourceHashes ?? {});\n for (const [artifactPath, expectedHash] of Object.entries(\n graph.sourceHashes ?? {},\n )) {\n const absoluteArtifactPath = `${rootDir}/${artifactPath}`;\n if (!existsSync(absoluteArtifactPath)) {\n issues.push({\n severity: 'error',\n code: 'knowledge-graph-source-missing',\n message: `${artifactPath} used to build ${graphPath} no longer exists`,\n file: graphPath,\n });\n continue;\n }\n let manifest: unknown;\n try {\n manifest = JSON.parse(readFileSync(absoluteArtifactPath, 'utf8'));\n } catch (error) {\n issues.push({\n severity: 'error',\n code: 'stale-knowledge-graph',\n message: `${artifactPath} is not valid JSON (${\n error instanceof Error ? error.message : String(error)\n }); run \\`pnpm knowledge:graph\\``,\n file: graphPath,\n });\n continue;\n }\n const actualHash = hashContent(stableStringify(manifest));\n if (actualHash !== expectedHash) {\n issues.push({\n severity: 'error',\n code: 'stale-knowledge-graph',\n message: `${artifactPath} changed since ${graphPath} was generated; run \\`pnpm knowledge:graph\\``,\n file: graphPath,\n });\n }\n }\n\n // A per-key hash comparison alone cannot see an ADDED artifact: a package\n // that just finished its first build, or just started exporting\n // `./smrt-knowledge.json`, contributes a path the graph never recorded, so\n // every recorded hash still matches. Compare the current discoverable SET\n // against the recorded set to catch that (#2863 review).\n const currentPaths = discoverKnowledgeArtifactPaths(rootDir);\n const recordedSet = new Set(recordedPaths);\n const newPaths = currentPaths.filter((path) => !recordedSet.has(path));\n if (newPaths.length > 0) {\n issues.push({\n severity: 'error',\n code: 'stale-knowledge-graph',\n message: `${newPaths.join(', ')} ${\n newPaths.length === 1\n ? 'is a new package artifact'\n : 'are new package artifacts'\n } not yet merged into ${graphPath}; run \\`pnpm knowledge:graph\\``,\n file: graphPath,\n });\n }\n\n return issues;\n}\n"],"mappings":";;;;AAyBO,SAAS,iCACd,k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IAAI;GACF,WAAW,KAAK,MAAM,aAAa,sBAAsB,MAAM,CAAC;EAClE,SAAS,OAAO;GACd,OAAO,KAAK;IACV,UAAU;IACV,MAAM;IACN,SAAS,GAAG,aAAY,sBACtB,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,EACvD;IACA,MAAM;GACR,CAAC;GACD;EACF;EAEA,IADmB,YAAY,gBAAgB,QAAQ,CACnD,MAAe,cACjB,OAAO,KAAK;GACV,UAAU;GACV,MAAM;GACN,SAAS,GAAG,aAAY,iBAAkB,UAAS;GACnD,MAAM;EACR,CAAC;CAEL;CAOA,MAAM,eAAe,+BAA+B,OAAO;CAC3D,MAAM,cAAc,IAAI,IAAI,aAAa;CACzC,MAAM,WAAW,aAAa,QAAQ,SAAS,CAAC,YAAY,IAAI,IAAI,CAAC;CACrE,IAAI,SAAS,SAAS,GACpB,OAAO,KAAK;EACV,UAAU;EACV,MAAM;EACN,SAAS,GAAG,SAAS,KAAK,IAAI,EAAC,GAC7B,SAAS,WAAW,IAChB,8BACA,4BACN,uBAAwB,UAAS;EACjC,MAAM;CACR,CAAC;CAGH,OAAO;AACT"}
@@ -0,0 +1,297 @@
1
+ /**
2
+ * Manifest Adapter
3
+ *
4
+ * Converts OXC scanner output to smrt-core manifest format.
5
+ * Ensures compatibility with existing manifest consumers.
6
+ */
7
+ import type { FieldTypeInference, ParameterTypeBranch, RawFieldDefinition, RawMethodDefinition, ResolvedClassDefinition } from './types.js';
8
+ /**
9
+ * Qualified class name format: "@package/name:ClassName"
10
+ * Uniquely identifies classes across packages.
11
+ */
12
+ type QualifiedClassName = `${string}:${string}`;
13
+ interface FieldDefinition {
14
+ type: 'text' | 'decimal' | 'boolean' | 'integer' | 'datetime' | 'json' | 'foreignKey' | 'crossPackageRef' | 'oneToMany' | 'manyToMany' | 'meta';
15
+ required?: boolean;
16
+ default?: unknown;
17
+ min?: number;
18
+ max?: number;
19
+ maxLength?: number;
20
+ minLength?: number;
21
+ related?: string;
22
+ description?: string;
23
+ _meta?: Record<string, unknown>;
24
+ transient?: boolean;
25
+ /** Sensitive value — excluded from public serialization + where filtering. */
26
+ sensitive?: boolean;
27
+ /** Read-only over generated write surfaces — stripped from create/update bodies. */
28
+ readonly?: boolean;
29
+ /** Permission slug required before the field is included in public reads. */
30
+ readPermission?: string;
31
+ }
32
+ interface MethodDefinition {
33
+ name: string;
34
+ async: boolean;
35
+ parameters: Array<{
36
+ name: string;
37
+ type: string;
38
+ optional: boolean;
39
+ default?: unknown;
40
+ /** See `RawParameterDefinition.typeUnresolved` (#2686). */
41
+ typeUnresolved?: boolean;
42
+ /** See `RawParameterDefinition.memberTypes` (#2686). */
43
+ memberTypes?: string[];
44
+ /** See `RawParameterDefinition.unionBranches` (#2686). */
45
+ unionBranches?: ParameterTypeBranch[];
46
+ }>;
47
+ returnType: string;
48
+ description?: string;
49
+ isStatic: boolean;
50
+ isPublic: boolean;
51
+ /** Config of an `@method()` decorator on this method (#2686). */
52
+ decoratorConfig?: Record<string, unknown>;
53
+ }
54
+ interface SmartObjectConfig {
55
+ tableStrategy?: 'sti' | 'cti';
56
+ idType?: 'uuid' | 'text';
57
+ features?: Record<string, {
58
+ defaultEnabled: boolean;
59
+ label?: string;
60
+ description?: string;
61
+ metadata?: Record<string, unknown>;
62
+ }>;
63
+ api?: {
64
+ include?: string[];
65
+ exclude?: string[];
66
+ };
67
+ cli?: boolean | {
68
+ include?: string[];
69
+ exclude?: string[];
70
+ skipApiCheck?: boolean | string[];
71
+ http?: boolean;
72
+ };
73
+ mcp?: {
74
+ include?: string[];
75
+ exclude?: string[];
76
+ };
77
+ [key: string]: unknown;
78
+ }
79
+ interface SmartObjectDefinition {
80
+ name: string;
81
+ className: string;
82
+ qualifiedName?: QualifiedClassName;
83
+ collection: string;
84
+ filePath: string;
85
+ packageName?: string;
86
+ packageVersion?: string;
87
+ importPath?: string;
88
+ modulePath?: string;
89
+ exportName?: string;
90
+ collectionExportName?: string;
91
+ fields: Record<string, FieldDefinition>;
92
+ methods: Record<string, MethodDefinition>;
93
+ decoratorConfig: SmartObjectConfig;
94
+ extends?: string;
95
+ extendsTypeArg?: string;
96
+ staticProperties?: Record<string, unknown>;
97
+ }
98
+ interface SmartObjectManifest {
99
+ version: string;
100
+ /** Always {@link MANIFEST_TIMESTAMP}: build output must be reproducible. */
101
+ timestamp: number;
102
+ packageName?: string;
103
+ packageVersion?: string;
104
+ objects: Record<string, SmartObjectDefinition>;
105
+ moduleType?: string;
106
+ smrtDependencies?: string[];
107
+ }
108
+ /**
109
+ * Converts OXC scanner output into the smrt-core `SmartObjectManifest` format
110
+ * consumed by code generators, the Vitest plugin, and the SMRT CLI.
111
+ *
112
+ * The adapter handles field type inference (applying the `0` vs `0.0` integer /
113
+ * decimal heuristic), decorator interpretation (`@foreignKey`, `@oneToMany`,
114
+ * `@manyToMany`, `@field`), type alias resolution, STI `Meta<T>` unwrapping,
115
+ * static property capture (`uiSlots`, `adminRoutes`), and qualified name
116
+ * generation for namespace isolation across packages.
117
+ *
118
+ * @example
119
+ * ```typescript
120
+ * import { OxcScanner, ManifestAdapter } from '@happyvertical/smrt-scanner';
121
+ *
122
+ * const scanner = new OxcScanner({ cwd: process.cwd() });
123
+ * const { results, resolved } = await scanner.scanAndResolve();
124
+ *
125
+ * const adapter = new ManifestAdapter();
126
+ * const manifest = adapter.toManifest(resolved, {
127
+ * packageName: '@my-org/my-package',
128
+ * packageVersion: '1.0.0',
129
+ * typeAliases: results.typeAliases,
130
+ * });
131
+ * ```
132
+ *
133
+ * @see {@link OxcScanner} for producing the `ResolvedClassDefinition[]` input.
134
+ * @see {@link ResolvedClassDefinition} for the shape of each input element.
135
+ */
136
+ export declare class ManifestAdapter {
137
+ private typeAliases;
138
+ private _aliasDepth?;
139
+ /**
140
+ * Convert an array of resolved class definitions into a `SmartObjectManifest`.
141
+ *
142
+ * Each class is converted to a `SmartObjectDefinition` via
143
+ * {@link toSmartObjectDefinition} and stored under its qualified name key
144
+ * (e.g. `@my-org/my-package:MyClass`) when `packageName` is provided, or
145
+ * under its lowercased class name otherwise.
146
+ *
147
+ * @param resolved - Resolved class definitions from {@link OxcScanner.resolve}
148
+ * or {@link OxcScanner.scanAndResolve}.
149
+ * @param options.packageName - npm package name used to generate qualified
150
+ * class names for namespace isolation across multi-package projects.
151
+ * @param options.packageVersion - Package version recorded in the manifest
152
+ * metadata.
153
+ * @param options.typeAliases - Map of type alias names to their resolved type
154
+ * strings (from {@link ScanResults.typeAliases}). Used to resolve custom
155
+ * types like `type Status = 'active' | 'inactive'` during field inference.
156
+ * @returns A complete `SmartObjectManifest` ready for serialisation.
157
+ *
158
+ * @example
159
+ * ```typescript
160
+ * const manifest = adapter.toManifest(resolved, {
161
+ * packageName: '@my-org/my-package',
162
+ * packageVersion: '1.0.0',
163
+ * typeAliases: results.typeAliases,
164
+ * });
165
+ * fs.writeFileSync('manifest.json', JSON.stringify(manifest, null, 2));
166
+ * ```
167
+ */
168
+ toManifest(resolved: ResolvedClassDefinition[], options?: {
169
+ packageName?: string;
170
+ packageVersion?: string;
171
+ typeAliases?: Record<string, string>;
172
+ }): SmartObjectManifest;
173
+ /**
174
+ * Convert a single resolved class definition to a `SmartObjectDefinition`.
175
+ *
176
+ * Handles:
177
+ * - Static property capture (`uiSlots`, `adminRoutes`) with child-wins
178
+ * semantics for overridden statics.
179
+ * - Field conversion (non-static public fields only) via {@link convertField}.
180
+ * - Method conversion (public instance/static methods) via {@link convertMethod}.
181
+ * - Collection name pluralisation.
182
+ * - Qualified name generation when `packageName` is supplied.
183
+ *
184
+ * @param classDef - A fully-resolved class definition.
185
+ * @param options.packageName - Package name used to build the qualified class
186
+ * name (`@pkg:ClassName`).
187
+ * @param options.packageVersion - Package version (informational, stored in
188
+ * the definition).
189
+ * @returns A `SmartObjectDefinition` ready to be stored in a manifest.
190
+ *
191
+ * @see {@link toManifest} for the bulk conversion entry point.
192
+ */
193
+ toSmartObjectDefinition(classDef: ResolvedClassDefinition, options?: {
194
+ packageName?: string;
195
+ packageVersion?: string;
196
+ }): SmartObjectDefinition;
197
+ /**
198
+ * Framework internal fields that should NOT be included in manifests
199
+ * These are SmrtObject internals used by the framework, not user-defined fields
200
+ */
201
+ private static readonly FRAMEWORK_INTERNAL_FIELDS;
202
+ /**
203
+ * Convert a single raw field definition to a manifest `FieldDefinition`.
204
+ *
205
+ * Returns `null` for fields that should be omitted from the manifest:
206
+ * - `private` or `protected` fields.
207
+ * - Framework-internal fields (`_tableName`, `_db`, `_ai`, etc.).
208
+ *
209
+ * Delegates type inference to {@link inferFieldType} and applies additional
210
+ * post-processing:
211
+ * - Marks fields with `Function` type annotation as `transient`.
212
+ * - Marks fields with `@field({ transient: true })` decorator as `transient`.
213
+ * - Populates `_meta.underlyingType` for STI `Meta<T>` fields.
214
+ *
215
+ * @param field - Raw field definition from a scanned class.
216
+ * @returns A `FieldDefinition` for the manifest, or `null` if the field
217
+ * should be excluded.
218
+ *
219
+ * @see {@link inferFieldType} for the type inference logic.
220
+ */
221
+ convertField(field: RawFieldDefinition): FieldDefinition | null;
222
+ /**
223
+ * Infer the SMRT field type and required flag from a raw field definition.
224
+ *
225
+ * Inference is attempted in the following priority order:
226
+ * 1. **Field helper call in initializer** — currently always returns `null`
227
+ * (field helpers removed); reserved for future use.
228
+ * 2. **Decorator** — `@foreignKey`, `@oneToMany`, `@manyToMany`, `@field({ type })`.
229
+ * 3. **Type annotation** — `string` → `text`, `number` with `0` vs `0.0`
230
+ * heuristic → `integer` / `decimal`, `boolean`, `Date` → `datetime`,
231
+ * arrays → `json`, `Record<>` / `object` → `json`, union types with
232
+ * `null`, inline string/number literal unions, `Meta<T>` wrapper,
233
+ * and type alias resolution (up to depth 5).
234
+ * 4. **Numeric literal without annotation** — `version = 1` → `integer`.
235
+ * 5. **Boolean literal without annotation** — `isRead = false` → `boolean`.
236
+ * 6. **Default** — falls back to `text`.
237
+ *
238
+ * @param field - The raw field definition to analyse.
239
+ * @returns A {@link FieldTypeInference} describing the inferred type,
240
+ * required flag, default value, related class name (for relationships),
241
+ * and the inference source for debugging.
242
+ *
243
+ * @see {@link FieldTypeInference} for the result shape.
244
+ * @see {@link InferredFieldType} for valid type values.
245
+ */
246
+ inferFieldType(field: RawFieldDefinition): FieldTypeInference;
247
+ /**
248
+ * Infer type from field helper call (removed)
249
+ *
250
+ * Field helpers have been removed in favor of decorators and TypeScript types:
251
+ * - Use TypeScript types: name: string = '', price: number = 0.0
252
+ * - Use @field() decorator for constraints: @field({ required: true })
253
+ * - Use @foreignKey(), @oneToMany(), @manyToMany() decorators for relationships
254
+ */
255
+ private inferFromHelper;
256
+ /**
257
+ * Infer type from field decorator
258
+ */
259
+ private inferFromDecorator;
260
+ private extractFieldDecoratorOptions;
261
+ private parseReportFieldDecorator;
262
+ private parseFieldDecoratorOptions;
263
+ private normalizeFieldType;
264
+ /**
265
+ * Infer type from TypeScript type annotation
266
+ */
267
+ private inferFromAnnotation;
268
+ /**
269
+ * Parse default value from initializer string
270
+ */
271
+ private parseDefaultValue;
272
+ /**
273
+ * Convert a raw method definition to a manifest `MethodDefinition`.
274
+ *
275
+ * Returns `null` for `private` or `protected` methods, which are excluded
276
+ * from the manifest. Parameters are mapped to the manifest parameter shape
277
+ * and default values are parsed via `parseDefaultValue`.
278
+ *
279
+ * @param method - Raw method definition from a scanned class.
280
+ * @returns A manifest-compatible `MethodDefinition`, or `null` if the method
281
+ * should be excluded.
282
+ */
283
+ convertMethod(method: RawMethodDefinition): MethodDefinition | null;
284
+ /**
285
+ * Simple pluralization for collection names.
286
+ *
287
+ * This produces the manifest's `collection` label only; the authoritative DDL
288
+ * table name is derived independently by core (`classnameToTablename` →
289
+ * the `pluralize` library), so this needs to stay self-consistent rather than
290
+ * cover every irregular plural. Note the `y → ies` rule fires only after a
291
+ * consonant, so vowel+y words pluralise correctly (`Day` → `days`, not
292
+ * `daies`).
293
+ */
294
+ private pluralize;
295
+ }
296
+ export {};
297
+ //# sourceMappingURL=manifest-adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":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