@happyvertical/smrt-core 0.51.7 → 0.51.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -0
- package/agents/build-knowledge.md +13 -0
- package/dist/consumer-plugin/index.d.ts.map +1 -1
- package/dist/consumer-plugin/index.js +141 -49
- package/dist/consumer-plugin/index.js.map +1 -1
- package/dist/manifest/discover-smrt-packages.d.ts +3 -2
- package/dist/manifest/discover-smrt-packages.d.ts.map +1 -1
- package/dist/manifest/discover-smrt-packages.js +34 -15
- package/dist/manifest/discover-smrt-packages.js.map +1 -1
- package/dist/manifest/package-manifest-exports.d.ts +34 -0
- package/dist/manifest/package-manifest-exports.d.ts.map +1 -0
- package/dist/manifest/package-manifest-exports.js +144 -0
- package/dist/manifest/package-manifest-exports.js.map +1 -0
- package/dist/manifest/static-manifest.js +1 -1
- package/dist/manifest/static-manifest.js.map +1 -1
- package/dist/manifest/store.js +1 -1
- package/dist/manifest.json +1 -1
- package/dist/smrt-knowledge.json +5 -5
- package/dist/vite-plugin/index.d.ts.map +1 -1
- package/dist/vite-plugin/index.js +93 -3
- package/dist/vite-plugin/index.js.map +1 -1
- package/package.json +4 -4
package/dist/smrt-knowledge.json
CHANGED
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
"sensitiveFieldsExcluded": true,
|
|
4
4
|
"generatedAt": "1970-01-01T00:00:00.000Z",
|
|
5
5
|
"packageName": "@happyvertical/smrt-core",
|
|
6
|
-
"packageVersion": "0.51.
|
|
6
|
+
"packageVersion": "0.51.9",
|
|
7
7
|
"sourceManifestPath": "dist/manifest.json",
|
|
8
8
|
"agentDocPath": "AGENTS.md",
|
|
9
9
|
"sourceHashes": {
|
|
10
|
-
"manifest": "
|
|
11
|
-
"packageJson": "
|
|
10
|
+
"manifest": "f7ac109fd4e3a480aebd752f22df8b4c61b09964ce9ed9a44fe42b43bea9af19",
|
|
11
|
+
"packageJson": "6732bb61daa56124dfe8eaa672404caaf192e9e48782eff57e62244256e98f29",
|
|
12
12
|
"agents": "7e27a7c52729c302d80e9c36bf068fe1811a7ae51eccf66c6a5f9498aaec3318",
|
|
13
13
|
"moduleDoc:agents/object-runtime.md": "34a4e740c109467cd5486c4af0e3bf4b63915697721ab584df0e5506ea9290ca",
|
|
14
14
|
"moduleDoc:agents/revision-guard.md": "aa6b1ddb5b6b49fa27ebbe575ec7fcd6d5ceb35ee25acc702f877a226eb9a99a",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"moduleDoc:agents/change-feed.md": "3600fd344bc49f2ec50d375f432c7fd18ef54050a4fcabd3e3e89a2f02198fb6",
|
|
20
20
|
"moduleDoc:agents/change-signals.md": "d9cb6a5541728ffea46607a6b1d4fa61d4621849f2b4ea86a0645fbb0af892e9",
|
|
21
21
|
"moduleDoc:agents/generators.md": "87e0203be47d70b6493851cbac421e8a4a6232a0e47af3e1146c63cdc3d39235",
|
|
22
|
-
"moduleDoc:agents/build-knowledge.md": "
|
|
22
|
+
"moduleDoc:agents/build-knowledge.md": "804fb47dfbdef4fa3ac7b66fafc825917a474d8c91b1675e647fe646df474c6b",
|
|
23
23
|
"moduleDoc:agents/memory.md": "a86bdf370403d08ecad3be86e341eb322dfe6e6b7a4e8806a6f8be9bf3421da5",
|
|
24
24
|
"moduleDoc:agents/system-diagnostics.md": "b7ccae18ee312bf788d5470f95fa78d3535f1789247d5372e40ca86538290772",
|
|
25
25
|
"moduleDoc:agents/registry-snapshot.md": "6234aa540427396d1dda1825a4641b1072e247187d5ddf413ae46c691344ee30"
|
|
@@ -1097,7 +1097,7 @@
|
|
|
1097
1097
|
{
|
|
1098
1098
|
"path": "agents/build-knowledge.md",
|
|
1099
1099
|
"module": "build-knowledge",
|
|
1100
|
-
"content": "# Decorators, build integration, and knowledge\n\nKey options: `tableName`, `tableStrategy` ('cti'|'sti'), `conflictColumns`, `indexes` (declared multi-column indexes; see [schema-paths.md](schema-paths.md)), `api`/`mcp`/`cli` (generation config), `ai` (callable methods), `hooks` (beforeSave/afterSave/beforeDelete/afterDelete), `embeddings` (auto-generate), `tenantScoped`, `agent`, `ui` (`{ icon, label, description }` — nav/help hints round-tripped through the manifest as plain data; `description` is the object-level seed for form-level help, #2046).\n\nRegistration sets `SMRT_TABLE_NAME` static property (survives minification).\n\n## @field() UI hints (#2046)\n\n`@field({ ui: { basic, group, order, locked } })` — a static, presentation-only\nseed for the field-policy rail (epic #2045). Carried in the manifest under the\nfield's `_meta.ui` (never a top-level `FieldDefinition` key), readable at\nruntime via `getAllFields()` at `field._meta.ui`, and emitted (sanitized) with\n`description` into generated web-collection definitions and browser MCP tool\nschemas. No schema/persistence/security effect — `sensitive`/`readPermission`\nstay the security rail, and `sensitive`/`transient` fields never emit to the\nclient at all.\n\n## Lightweight discovery\n\n`src/knowledge-discovery.ts`, exported through `smrt-core/knowledge`, enumerates\ninstalled scope directories and reads canonical AGENTS/legacy CLAUDE docs without\nloading package code, artifacts, or scanning objects. CLI snapshots and MCP share\nthese primitives. Callers retain selection policy: snapshots resolve links and\nfall back to `packages/*` only when no installed SMRT package loads; MCP preserves\nnode_modules paths, deduplicates realpaths, excludes authored workspace links,\nand then enriches the selected packages. Workspace-root/glob discovery remains\nowned by each consumer.\n\n## Domain Knowledge Artifacts\n\n`smrtPlugin()` writes runtime manifests and agent/developer knowledge artifacts:\n\n- local dev/build: `.smrt/manifest.json` and `.smrt/smrt-knowledge.json`\n- package build: `dist/manifest.json` and `dist/smrt-knowledge.json`\n\nKeep `manifest.json` runtime-focused. `smrt-knowledge.json` is the deterministic\nagent contract for downstream review and architecture tools.\n\nThe schema-version-1 object projection is additive and high-signal: it retains\nnormalized tenant mode/field, explicit `cti`/`sti` strategy, conflict columns,\nmethod signatures, and field defaults/constraints/readonly/transient flags.\nSensitive fields are removed before both `fields` and `relationships` are\nderived, including legacy flags stored under `_meta`; matching field and\nsnake-case column names are also removed from projected conflict columns, and a\nsensitive custom tenant field is omitted while retaining scope and mode.\nGenerated artifacts assert this boundary with `sensitiveFieldsExcluded: true`;\nthe optional marker keeps schema version 1 additive while letting readers\nidentify older artifacts that require raw-manifest corroboration.\n\nConfig precedence for knowledge is defaults → top-level `knowledge` in\n`smrt.config.ts` → `packages[packageName].knowledge` → plugin option →\nobject-level `@smrt({ knowledge })`.\n\nObject-level `knowledge: false` excludes an object from authored context only;\nit must not change runtime manifest registration. Use\n`knowledge: { tags, summary, risks }` for review-sensitive domain objects.\n\nHTTP knowledge routes are disabled by default. If `knowledge.api.enabled` is\ntrue, generated SvelteKit routes must stay GET-only and guarded by dev mode or\nadmin auth.\n\n\n## Vite Plugin\n\n```typescript\n// vite.config.ts — required for @smrt() decorators (Vite 8+, oxc transform)\nexport default defineConfig({\n oxc: {\n decorator: {\n legacy: true,\n emitDecoratorMetadata: true,\n },\n },\n});\n```\n\nUnder Vite 8 the oxc transform does not honor the pre-Vite-8 `esbuild.tsconfigRaw`\nrecipe (or tsconfig `experimentalDecorators` reached through SvelteKit's\n`extends \"./.svelte-kit/tsconfig.json\"` chain), so that recipe throws\n`SyntaxError: Invalid or unexpected token` on the first SSR request. Configure\ndecorators through `oxc.decorator` instead. Consumers still pinned on vite<8 need\nthe legacy `esbuild.tsconfigRaw` form with `experimentalDecorators: true,\nemitDecoratorMetadata: true`.\n\nFor independent CI invocations, both `smrtPlugin()` and `smrtConsumer()` accept\nthe same `generationSnapshot: { path, sha256, provenance, sourceRoot }`. The\nschema-v1 snapshot produced by `serializeSmrtGenerationSnapshot()` contains the\nmerged project/dependency manifest, portable source paths, and source-file\ndigests; each plugin selects its own view. Reuse mode fails closed on\nbyte/provenance/path/content drift, skips scans and manifest writes, and still\ngenerates routes, types, registration, and virtual modules. Omit it for normal\nlocal development and watch mode.\n"
|
|
1100
|
+
"content": "# Decorators, build integration, and knowledge\n\nKey options: `tableName`, `tableStrategy` ('cti'|'sti'), `conflictColumns`, `indexes` (declared multi-column indexes; see [schema-paths.md](schema-paths.md)), `api`/`mcp`/`cli` (generation config), `ai` (callable methods), `hooks` (beforeSave/afterSave/beforeDelete/afterDelete), `embeddings` (auto-generate), `tenantScoped`, `agent`, `ui` (`{ icon, label, description }` — nav/help hints round-tripped through the manifest as plain data; `description` is the object-level seed for form-level help, #2046).\n\nRegistration sets `SMRT_TABLE_NAME` static property (survives minification).\n\n## @field() UI hints (#2046)\n\n`@field({ ui: { basic, group, order, locked } })` — a static, presentation-only\nseed for the field-policy rail (epic #2045). Carried in the manifest under the\nfield's `_meta.ui` (never a top-level `FieldDefinition` key), readable at\nruntime via `getAllFields()` at `field._meta.ui`, and emitted (sanitized) with\n`description` into generated web-collection definitions and browser MCP tool\nschemas. No schema/persistence/security effect — `sensitive`/`readPermission`\nstay the security rail, and `sensitive`/`transient` fields never emit to the\nclient at all.\n\n## Lightweight discovery\n\n`src/knowledge-discovery.ts`, exported through `smrt-core/knowledge`, enumerates\ninstalled scope directories and reads canonical AGENTS/legacy CLAUDE docs without\nloading package code, artifacts, or scanning objects. CLI snapshots and MCP share\nthese primitives. Callers retain selection policy: snapshots resolve links and\nfall back to `packages/*` only when no installed SMRT package loads; MCP preserves\nnode_modules paths, deduplicates realpaths, excludes authored workspace links,\nand then enriches the selected packages. Workspace-root/glob discovery remains\nowned by each consumer.\n\n## Domain Knowledge Artifacts\n\n`smrtPlugin()` writes runtime manifests and agent/developer knowledge artifacts:\n\n- local dev/build: `.smrt/manifest.json` and `.smrt/smrt-knowledge.json`\n- package build: `dist/manifest.json` and `dist/smrt-knowledge.json`\n\nKeep `manifest.json` runtime-focused. `smrt-knowledge.json` is the deterministic\nagent contract for downstream review and architecture tools.\n\nThe CLI's schema-command gate reads that same merged file: a pure-consumer\nproject (0 local objects) qualifies on the consumed packages its manifest\nrecords, so a clobbered `objects` map is what made `smrt db:migrate` report\n`missing_local_manifest` (#2925).\n\n`.smrt/manifest.json` has two writers and neither owns all of it: `smrtPlugin()`\ncontributes the project's scanned objects and `smrtConsumer()` the consumed\npackages' entries. Both writes are merge-preserving, keyed on each entry's\nrecorded `packageName` — a plain overwrite in either direction silently drops\nthe other's objects, and the last pass of a multi-environment build is not\nreliably the aggregating one (#1760, #2925). `dist/manifest.json` stays\nlocal-only: a published package must not carry its dependencies' objects.\n\nThe schema-version-1 object projection is additive and high-signal: it retains\nnormalized tenant mode/field, explicit `cti`/`sti` strategy, conflict columns,\nmethod signatures, and field defaults/constraints/readonly/transient flags.\nSensitive fields are removed before both `fields` and `relationships` are\nderived, including legacy flags stored under `_meta`; matching field and\nsnake-case column names are also removed from projected conflict columns, and a\nsensitive custom tenant field is omitted while retaining scope and mode.\nGenerated artifacts assert this boundary with `sensitiveFieldsExcluded: true`;\nthe optional marker keeps schema version 1 additive while letting readers\nidentify older artifacts that require raw-manifest corroboration.\n\nConfig precedence for knowledge is defaults → top-level `knowledge` in\n`smrt.config.ts` → `packages[packageName].knowledge` → plugin option →\nobject-level `@smrt({ knowledge })`.\n\nObject-level `knowledge: false` excludes an object from authored context only;\nit must not change runtime manifest registration. Use\n`knowledge: { tags, summary, risks }` for review-sensitive domain objects.\n\nHTTP knowledge routes are disabled by default. If `knowledge.api.enabled` is\ntrue, generated SvelteKit routes must stay GET-only and guarded by dev mode or\nadmin auth.\n\n\n## Vite Plugin\n\n```typescript\n// vite.config.ts — required for @smrt() decorators (Vite 8+, oxc transform)\nexport default defineConfig({\n oxc: {\n decorator: {\n legacy: true,\n emitDecoratorMetadata: true,\n },\n },\n});\n```\n\nUnder Vite 8 the oxc transform does not honor the pre-Vite-8 `esbuild.tsconfigRaw`\nrecipe (or tsconfig `experimentalDecorators` reached through SvelteKit's\n`extends \"./.svelte-kit/tsconfig.json\"` chain), so that recipe throws\n`SyntaxError: Invalid or unexpected token` on the first SSR request. Configure\ndecorators through `oxc.decorator` instead. Consumers still pinned on vite<8 need\nthe legacy `esbuild.tsconfigRaw` form with `experimentalDecorators: true,\nemitDecoratorMetadata: true`.\n\nFor independent CI invocations, both `smrtPlugin()` and `smrtConsumer()` accept\nthe same `generationSnapshot: { path, sha256, provenance, sourceRoot }`. The\nschema-v1 snapshot produced by `serializeSmrtGenerationSnapshot()` contains the\nmerged project/dependency manifest, portable source paths, and source-file\ndigests; each plugin selects its own view. Reuse mode fails closed on\nbyte/provenance/path/content drift, skips scans and manifest writes, and still\ngenerates routes, types, registration, and virtual modules. Omit it for normal\nlocal development and watch mode.\n"
|
|
1101
1101
|
},
|
|
1102
1102
|
{
|
|
1103
1103
|
"path": "agents/memory.md",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vite-plugin/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EACV,2BAA2B,EAC3B,qBAAqB,EAEtB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,MAAM,EAAiC,MAAM,MAAM,CAAC;AAClE,OAAO,EAEL,KAAK,6BAA6B,EACnC,MAAM,2BAA2B,CAAC;AAQnC,OAAO,EAEL,KAAK,mBAAmB,EACzB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,EACV,mBAAmB,EACnB,aAAa,EACd,MAAM,4BAA4B,CAAC;AA8BpC,OAAO,EACL,kCAAkC,EAClC,KAAK,sCAAsC,EAC3C,KAAK,8BAA8B,EACnC,KAAK,6BAA6B,EAClC,KAAK,0BAA0B,EAC/B,+BAA+B,EAC/B,4BAA4B,GAC7B,MAAM,2BAA2B,CAAC;AACnC,YAAY,EACV,wBAAwB,EACxB,gBAAgB,GACjB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,6BAA6B,EAC7B,uBAAuB,EACvB,iBAAiB,EACjB,2BAA2B,EAC3B,mBAAmB,EACnB,4BAA4B,GAC7B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAalE,MAAM,WAAW,iBAAiB;IAChC,yEAAyE;IACzE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,kBAAkB,CAAC,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AAE,MAAM,EACnB,oBAAoB,EAAE,MAAM,GAC3B,OAAO,CAAC,IAAI,CAAC,CA6Zf"}
|
|
@@ -185,6 +185,84 @@ function generateInlineRegisterModule(manifest) {
|
|
|
185
185
|
""
|
|
186
186
|
].join("\n");
|
|
187
187
|
}
|
|
188
|
+
/**
|
|
189
|
+
* Decide whether a `.smrt/manifest.json` entry belongs to this project's own
|
|
190
|
+
* scan rather than to a consumed package aggregated into the same file by
|
|
191
|
+
* `smrtConsumer()`.
|
|
192
|
+
*
|
|
193
|
+
* Ownership is read from the entry's recorded `packageName`: the scanner
|
|
194
|
+
* stamps every locally scanned object with the project's own package name
|
|
195
|
+
* (issue #713), and the consumer plugin stamps every aggregated entry with
|
|
196
|
+
* its source package. An entry with no recorded owner can only have come from
|
|
197
|
+
* the local write, because the consumer always records one.
|
|
198
|
+
*
|
|
199
|
+
* `localPackageNames` carries every name this project has written under, not
|
|
200
|
+
* just its current one. Renaming the project's `package.json#name` would
|
|
201
|
+
* otherwise orphan the entries stamped with the old name: they stop matching
|
|
202
|
+
* the current name, get classified as another package's, and survive every
|
|
203
|
+
* later write — so a local object deleted or renamed in the same change stays
|
|
204
|
+
* in the manifest schema commands read. The previous write's own top-level
|
|
205
|
+
* `packageName` supplies that prior name (`saveAggregatedManifest()` keeps it
|
|
206
|
+
* as the local project's), and it is the only other name a local entry can
|
|
207
|
+
* carry.
|
|
208
|
+
*/
|
|
209
|
+
function isLocallyOwnedManifestEntry(entry, localPackageNames) {
|
|
210
|
+
const owner = entry?.packageName;
|
|
211
|
+
if (typeof owner !== "string" || owner.length === 0) return true;
|
|
212
|
+
return localPackageNames.has(owner);
|
|
213
|
+
}
|
|
214
|
+
/** Read a manifest's `smrtDependencies`, tolerating an untrusted on-disk shape. */
|
|
215
|
+
function readManifestDependencies(manifest) {
|
|
216
|
+
if (!Array.isArray(manifest?.smrtDependencies)) return [];
|
|
217
|
+
return manifest.smrtDependencies.filter((dependency) => typeof dependency === "string" && dependency.length > 0);
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Union a freshly scanned local manifest with the consumed-package state
|
|
221
|
+
* already present in `.smrt/manifest.json` (issue #2925).
|
|
222
|
+
*
|
|
223
|
+
* The local scan is authoritative for the objects it owns — a deleted local
|
|
224
|
+
* object must disappear from the file — so only entries owned by another
|
|
225
|
+
* package are carried forward, and a local entry wins any key collision. As
|
|
226
|
+
* with the consumer plugin's merge, `.smrt/` is a build cache: dropping a
|
|
227
|
+
* package from `smrtConsumer()` leaves its stale entries until the directory
|
|
228
|
+
* is removed and the project rebuilt.
|
|
229
|
+
*
|
|
230
|
+
* `smrtDependencies` is merged the same way and for the same reason. The
|
|
231
|
+
* consumer writer owns that list too — `aggregateTypeManifests()` seeds it
|
|
232
|
+
* from `smrtConsumer()`'s explicit `packages` — while the local scan derives
|
|
233
|
+
* its own from the dependency tree, and the two need not agree: a configured
|
|
234
|
+
* package the local discovery does not return would keep its objects here but
|
|
235
|
+
* lose its declaration. The CLI's schema gate reads exactly that list to
|
|
236
|
+
* admit a zero-local-object project, so dropping it reintroduces the
|
|
237
|
+
* `missing_local_manifest` failure this change fixes.
|
|
238
|
+
*/
|
|
239
|
+
function mergeExternalManifestEntries(manifest, manifestPath) {
|
|
240
|
+
if (!existsSync(manifestPath)) return manifest;
|
|
241
|
+
let existing;
|
|
242
|
+
try {
|
|
243
|
+
existing = JSON.parse(readFileSync(manifestPath, "utf-8"));
|
|
244
|
+
} catch {
|
|
245
|
+
return manifest;
|
|
246
|
+
}
|
|
247
|
+
if (!existing?.objects || typeof existing.objects !== "object") return manifest;
|
|
248
|
+
const localPackageNames = /* @__PURE__ */ new Set();
|
|
249
|
+
if (manifest.packageName) localPackageNames.add(manifest.packageName);
|
|
250
|
+
if (typeof existing.packageName === "string" && existing.packageName) localPackageNames.add(existing.packageName);
|
|
251
|
+
const preserved = {};
|
|
252
|
+
for (const [name, entry] of Object.entries(existing.objects)) if (!isLocallyOwnedManifestEntry(entry, localPackageNames)) preserved[name] = entry;
|
|
253
|
+
const scannedDependencies = new Set(readManifestDependencies(manifest));
|
|
254
|
+
const mergedDependencies = /* @__PURE__ */ new Set([...scannedDependencies, ...readManifestDependencies(existing)]);
|
|
255
|
+
const carriesExtraDependency = mergedDependencies.size > scannedDependencies.size;
|
|
256
|
+
if (Object.keys(preserved).length === 0 && !carriesExtraDependency) return manifest;
|
|
257
|
+
return {
|
|
258
|
+
...manifest,
|
|
259
|
+
objects: {
|
|
260
|
+
...preserved,
|
|
261
|
+
...manifest.objects
|
|
262
|
+
},
|
|
263
|
+
...mergedDependencies.size > 0 ? { smrtDependencies: [...mergedDependencies].sort() } : {}
|
|
264
|
+
};
|
|
265
|
+
}
|
|
188
266
|
function smrtPlugin(options = {}) {
|
|
189
267
|
const { projectRoot: configuredProjectRoot, generationSnapshot, include = ["src/**/*.ts", "src/**/*.js"], exclude = [
|
|
190
268
|
"**/*.test.ts",
|
|
@@ -275,6 +353,16 @@ function smrtPlugin(options = {}) {
|
|
|
275
353
|
* Write manifest to .smrt/manifest.json for CLI discovery.
|
|
276
354
|
* This ensures `smrt db:migrate`, `smrt db:status`, etc. can find
|
|
277
355
|
* locally-defined SMRT objects in non-library builds (Issue #963).
|
|
356
|
+
*
|
|
357
|
+
* Merge-preserving, symmetrically with `smrtConsumer()`'s
|
|
358
|
+
* `saveAggregatedManifest()` (issue #1760): both plugins write this one
|
|
359
|
+
* file, and neither owns all of it. This hook runs once per Vite build
|
|
360
|
+
* pass/environment, while the consumer's aggregation runs in `buildStart`
|
|
361
|
+
* and does not run on every pass — so a SvelteKit `adapter-node` build ends
|
|
362
|
+
* with this write, and a plain overwrite here drops every consumed
|
|
363
|
+
* package's objects from the file the CLI then reads (issue #2925). For a
|
|
364
|
+
* pure-consumer app (0 local objects, the shape `template-sveltekit`
|
|
365
|
+
* documents) that left `objects: {}` on disk and broke `smrt db:migrate`.
|
|
278
366
|
*/
|
|
279
367
|
async function writeLocalManifest(m, rootDir) {
|
|
280
368
|
try {
|
|
@@ -283,10 +371,12 @@ function smrtPlugin(options = {}) {
|
|
|
283
371
|
const smrtDir = resolve(rootDir, ".smrt");
|
|
284
372
|
mkdirSync(smrtDir, { recursive: true });
|
|
285
373
|
const manifestPath = resolve(smrtDir, "manifest.json");
|
|
286
|
-
|
|
287
|
-
|
|
374
|
+
const merged = mergeExternalManifestEntries(m, manifestPath);
|
|
375
|
+
writeFileSync(manifestPath, JSON.stringify(merged, null, 2), "utf-8");
|
|
376
|
+
await writeDomainKnowledgeArtifact(merged, rootDir, resolve(smrtDir, "smrt-knowledge.json"), manifestPath);
|
|
288
377
|
const objectCount = Object.keys(m.objects).length;
|
|
289
|
-
|
|
378
|
+
const preservedCount = Object.keys(merged.objects).length - objectCount;
|
|
379
|
+
console.log(preservedCount > 0 ? `[smrt] Wrote local manifest with ${objectCount} objects to .smrt/manifest.json (preserved ${preservedCount} consumed package objects)` : `[smrt] Wrote local manifest with ${objectCount} objects to .smrt/manifest.json`);
|
|
290
380
|
} catch (error) {
|
|
291
381
|
console.error("[smrt] Error writing local manifest:", error);
|
|
292
382
|
}
|