@specverse/engines 6.33.0 → 6.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/libs/instance-factories/communication/rabbitmq-events.yaml +11 -0
- package/dist/libs/instance-factories/controllers/fastify.yaml +11 -0
- package/dist/libs/instance-factories/managed/stripe-rest-sdk.yaml +78 -0
- package/dist/libs/instance-factories/managed/templates/stripe/stripe-client-generator.js +8 -0
- package/dist/libs/instance-factories/orms/prisma.yaml +11 -0
- package/dist/realize/index.d.ts.map +1 -1
- package/dist/realize/index.js +261 -4
- package/dist/realize/index.js.map +1 -1
- package/dist/realize/library/loader.d.ts.map +1 -1
- package/dist/realize/library/loader.js +81 -1
- package/dist/realize/library/loader.js.map +1 -1
- package/dist/realize/per-action-emitter.d.ts +9 -0
- package/dist/realize/per-action-emitter.d.ts.map +1 -1
- package/dist/realize/per-action-emitter.js.map +1 -1
- package/dist/realize/per-action-llm-emit.d.ts.map +1 -1
- package/dist/realize/per-action-llm-emit.js +5 -1
- package/dist/realize/per-action-llm-emit.js.map +1 -1
- package/dist/realize/per-action-runner.d.ts +45 -0
- package/dist/realize/per-action-runner.d.ts.map +1 -1
- package/dist/realize/per-action-runner.js +132 -0
- package/dist/realize/per-action-runner.js.map +1 -1
- package/dist/realize/resolver/index.d.ts +157 -0
- package/dist/realize/resolver/index.d.ts.map +1 -0
- package/dist/realize/resolver/index.js +307 -0
- package/dist/realize/resolver/index.js.map +1 -0
- package/dist/realize/runtime-emitters/dispatcher.d.ts +176 -0
- package/dist/realize/runtime-emitters/dispatcher.d.ts.map +1 -0
- package/dist/realize/runtime-emitters/dispatcher.js +76 -0
- package/dist/realize/runtime-emitters/dispatcher.js.map +1 -0
- package/dist/realize/runtime-emitters/executable.d.ts +57 -0
- package/dist/realize/runtime-emitters/executable.d.ts.map +1 -0
- package/dist/realize/runtime-emitters/executable.js +316 -0
- package/dist/realize/runtime-emitters/executable.js.map +1 -0
- package/dist/realize/runtime-emitters/library.d.ts +52 -0
- package/dist/realize/runtime-emitters/library.d.ts.map +1 -0
- package/dist/realize/runtime-emitters/library.js +349 -0
- package/dist/realize/runtime-emitters/library.js.map +1 -0
- package/dist/realize/runtime-emitters/managed.d.ts +44 -0
- package/dist/realize/runtime-emitters/managed.d.ts.map +1 -0
- package/dist/realize/runtime-emitters/managed.js +283 -0
- package/dist/realize/runtime-emitters/managed.js.map +1 -0
- package/dist/realize/runtime-emitters/messaging.d.ts +77 -0
- package/dist/realize/runtime-emitters/messaging.d.ts.map +1 -0
- package/dist/realize/runtime-emitters/messaging.js +423 -0
- package/dist/realize/runtime-emitters/messaging.js.map +1 -0
- package/dist/realize/runtime-emitters/service.d.ts +42 -0
- package/dist/realize/runtime-emitters/service.d.ts.map +1 -0
- package/dist/realize/runtime-emitters/service.js +355 -0
- package/dist/realize/runtime-emitters/service.js.map +1 -0
- package/dist/realize/types/instance-factory.d.ts +1 -1
- package/dist/realize/types/instance-factory.d.ts.map +1 -1
- package/libs/instance-factories/communication/rabbitmq-events.yaml +11 -0
- package/libs/instance-factories/controllers/fastify.yaml +11 -0
- package/libs/instance-factories/managed/stripe-rest-sdk.yaml +78 -0
- package/libs/instance-factories/managed/templates/stripe/stripe-client-generator.ts +26 -0
- package/libs/instance-factories/orms/prisma.yaml +11 -0
- package/package.json +1 -1
|
@@ -66,6 +66,7 @@ export async function runPerActionEmission(opts) {
|
|
|
66
66
|
for (const [ownerName, actions] of ownerGroups) {
|
|
67
67
|
const bodies = new Map();
|
|
68
68
|
const specs = new Map();
|
|
69
|
+
const availableClients = opts.availableClientsByOwner?.get(ownerName);
|
|
69
70
|
for (const collectedAction of actions) {
|
|
70
71
|
const realizeCtx = {
|
|
71
72
|
componentName: ownerName,
|
|
@@ -75,6 +76,7 @@ export async function runPerActionEmission(opts) {
|
|
|
75
76
|
aiArgsExpr: opts.aiArgsExpr,
|
|
76
77
|
llmEmit: opts.llmEmit,
|
|
77
78
|
canCallLLM: opts.canCallLLM,
|
|
79
|
+
availableClients,
|
|
78
80
|
};
|
|
79
81
|
const body = await emitActionBody(collectedAction.spec, realizeCtx);
|
|
80
82
|
bodies.set(collectedAction.actionName, body);
|
|
@@ -266,4 +268,134 @@ ${body}
|
|
|
266
268
|
}
|
|
267
269
|
`;
|
|
268
270
|
}
|
|
271
|
+
// ─── V2 imports → availableClients string (Round 3 follow-up) ────────
|
|
272
|
+
/**
|
|
273
|
+
* Convert a V2 `import: from:` provider name to the client identifier
|
|
274
|
+
* the runtime aggregator (`clients/index.ts`) exposes via `v2Clients`.
|
|
275
|
+
*
|
|
276
|
+
* Mirrors the `toClientName` logic in
|
|
277
|
+
* `engines/src/realize/runtime-emitters/library.ts` so the prompt's
|
|
278
|
+
* advertised name matches the actual client constant the consumer
|
|
279
|
+
* spreads into `deps`. Kept local (rather than imported) because the
|
|
280
|
+
* library emitter's helper is private and the conversion is a tiny
|
|
281
|
+
* pure function — duplication is cheaper than a public re-export.
|
|
282
|
+
*/
|
|
283
|
+
function toClientName(fromName) {
|
|
284
|
+
// Mirrors the library emitter's toWords: scope-strip, slash → dash,
|
|
285
|
+
// split on camelCase boundary AND non-alphanumeric runs, lowercase.
|
|
286
|
+
const normalised = fromName.replace(/^@/, '').replace(/\//g, '-');
|
|
287
|
+
const words = normalised
|
|
288
|
+
.replace(/([a-z])([A-Z])/g, '$1 $2')
|
|
289
|
+
.replace(/[^a-zA-Z0-9]+/g, ' ')
|
|
290
|
+
.trim()
|
|
291
|
+
.split(' ')
|
|
292
|
+
.filter(Boolean)
|
|
293
|
+
.map((w) => w.toLowerCase());
|
|
294
|
+
if (words.length === 0)
|
|
295
|
+
return 'unknownClient';
|
|
296
|
+
return (words[0] +
|
|
297
|
+
words
|
|
298
|
+
.slice(1)
|
|
299
|
+
.map((w) => w.charAt(0).toUpperCase() + w.slice(1))
|
|
300
|
+
.join(''));
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Build a single component's `availableClients` prompt string from its
|
|
304
|
+
* V2 `import:` block.
|
|
305
|
+
*
|
|
306
|
+
* Output shape (one line per importable operation):
|
|
307
|
+
* - deps.<clientName>.<operation>(input) // from <fromName> (<topology>)
|
|
308
|
+
* - deps.<clientName> // bare entity export from <fromName> (<topology>)
|
|
309
|
+
*
|
|
310
|
+
* Topology is included when known (caller can pass a resolver-result
|
|
311
|
+
* lookup); when unknown, we omit the parenthetical. The Round-3 wire-up
|
|
312
|
+
* in `realize/index.ts` runs BEFORE the V2 imports loop has resolved
|
|
313
|
+
* factories, so most calls today omit topology — fine. The slot is
|
|
314
|
+
* forward-compatible: a future revision can pass topology by name and
|
|
315
|
+
* we'll surface it.
|
|
316
|
+
*
|
|
317
|
+
* Returns `null` when the component has no imports (caller should not
|
|
318
|
+
* set `availableClients` at all in that case so the LLM hook falls
|
|
319
|
+
* back to its "(none)" default).
|
|
320
|
+
*/
|
|
321
|
+
export function buildAvailableClientsForComponent(component, topologyByFrom) {
|
|
322
|
+
const imports = Array.isArray(component?.import) ? component.import : [];
|
|
323
|
+
if (imports.length === 0)
|
|
324
|
+
return null;
|
|
325
|
+
const lines = [];
|
|
326
|
+
for (const entry of imports) {
|
|
327
|
+
const fromName = entry?.from ?? entry?.package ?? entry?.file ?? '';
|
|
328
|
+
if (!fromName)
|
|
329
|
+
continue;
|
|
330
|
+
const select = Array.isArray(entry?.select) ? entry.select : [];
|
|
331
|
+
if (select.length === 0)
|
|
332
|
+
continue;
|
|
333
|
+
const clientName = toClientName(fromName);
|
|
334
|
+
const topology = topologyByFrom?.get(fromName);
|
|
335
|
+
const topoSuffix = topology ? ` (${topology})` : '';
|
|
336
|
+
for (const sel of select) {
|
|
337
|
+
const dotIndex = sel.indexOf('.');
|
|
338
|
+
if (dotIndex === -1) {
|
|
339
|
+
// Bare entity export: full interface, LLM picks the operation.
|
|
340
|
+
lines.push(` - deps.${clientName} // bare entity export ${sel} from ${fromName}${topoSuffix}`);
|
|
341
|
+
}
|
|
342
|
+
else {
|
|
343
|
+
// Dotted: <Entity>.<operation> — surface the operation directly.
|
|
344
|
+
const operation = sel.slice(dotIndex + 1);
|
|
345
|
+
lines.push(` - deps.${clientName}.${operation}(input) // from ${fromName}${topoSuffix}`);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
if (lines.length === 0)
|
|
350
|
+
return null;
|
|
351
|
+
return ['Available imported clients (V2 imports):', ...lines].join('\n');
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Walk a parsed spec and build the per-owner `availableClients` map the
|
|
355
|
+
* per-action runner threads into `RealizeContext.availableClients`.
|
|
356
|
+
*
|
|
357
|
+
* Resolution: each `spec.components[i]` carries an `import:` block AND
|
|
358
|
+
* a set of contained controllers + services. Every controller / service
|
|
359
|
+
* inside the component sees the same `availableClients` string (V2
|
|
360
|
+
* imports are component-scoped; per-action filtering via `Action.uses`
|
|
361
|
+
* is a future refinement).
|
|
362
|
+
*
|
|
363
|
+
* Components-without-imports do not contribute entries — owners in
|
|
364
|
+
* those components won't have `availableClients` set, and the LLM hook
|
|
365
|
+
* falls back to its "(none)" default. This keeps the prompt clean for
|
|
366
|
+
* specs that don't use V2 imports at all.
|
|
367
|
+
*/
|
|
368
|
+
export function buildAvailableClientsByOwner(spec, topologyByFrom) {
|
|
369
|
+
const out = new Map();
|
|
370
|
+
const components = Array.isArray(spec?.components)
|
|
371
|
+
? spec.components
|
|
372
|
+
: Object.values(spec?.components ?? {});
|
|
373
|
+
for (const component of components) {
|
|
374
|
+
const clientsString = buildAvailableClientsForComponent(component, topologyByFrom);
|
|
375
|
+
if (!clientsString)
|
|
376
|
+
continue;
|
|
377
|
+
// Each contained controller and service shares this component's
|
|
378
|
+
// imports. Controllers are shaped `{ Name: { ... } }` or
|
|
379
|
+
// `[{ name, ... }]`; same for services.
|
|
380
|
+
const controllerEntries = Array.isArray(component?.controllers)
|
|
381
|
+
? component.controllers.map((c) => [c?.name ?? '', c])
|
|
382
|
+
: Object.entries(component?.controllers ?? {});
|
|
383
|
+
for (const [keyName, c] of controllerEntries) {
|
|
384
|
+
const ownerName = c?.name || keyName;
|
|
385
|
+
if (!ownerName)
|
|
386
|
+
continue;
|
|
387
|
+
out.set(ownerName, clientsString);
|
|
388
|
+
}
|
|
389
|
+
const serviceEntries = Array.isArray(component?.services)
|
|
390
|
+
? component.services.map((s) => [s?.name ?? '', s])
|
|
391
|
+
: Object.entries(component?.services ?? {});
|
|
392
|
+
for (const [keyName, s] of serviceEntries) {
|
|
393
|
+
const ownerName = s?.name || keyName;
|
|
394
|
+
if (!ownerName)
|
|
395
|
+
continue;
|
|
396
|
+
out.set(ownerName, clientsString);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
return out;
|
|
400
|
+
}
|
|
269
401
|
//# sourceMappingURL=per-action-runner.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"per-action-runner.js","sourceRoot":"","sources":["../../src/realize/per-action-runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EACL,cAAc,GAOf,MAAM,yBAAyB,CAAC;AAoEjC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,IAAiC;IAEjC,MAAM,SAAS,GAAG,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5C,MAAM,WAAW,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC;IAE5C,MAAM,MAAM,GAA0B,EAAE,CAAC;IACzC,MAAM,YAAY,GAAa,EAAE,CAAC;IAClC,MAAM,MAAM,GAAG;QACb,WAAW,EAAE,CAAC;QACd,UAAU,EAAE,CAAC;QACb,SAAS,EAAE,CAAC;QACZ,QAAQ,EAAE,CAA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AAG,CAAC,GAAG,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;QACpC,CAAC;QAED,MAAM,cAAc,GAAyB,KAAK,CAAC,OAAO,CAAC,SAAS,EAAE,QAAQ,CAAC;YAC7E,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;YACxD,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,EAAE,QAAQ,IAAI,EAAE,CAAC,CAAC;QAC9C,KAAK,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,cAAc,EAAE,CAAC;YAC1C,MAAM,SAAS,GAAI,CAAC,EAAE,IAAe,IAAI,OAAO,CAAC;YACjD,IAAI,CAAC,SAAS;gBAAE,SAAS;YACzB,GAAG,CAAC,GAAG,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;QACpC,CAAC;IACH,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* V2 Dependency Resolver — Phase 3 (Round 1)
|
|
3
|
+
*
|
|
4
|
+
* 4-step lookup chain for `import[].from` references:
|
|
5
|
+
* 1. Local component in same spec
|
|
6
|
+
* 2. Local npm package (node_modules/<name>/package.json)
|
|
7
|
+
* 3. Registry library (Library.type: component) — HTTP stubbed for Round 1
|
|
8
|
+
* 4. Registry factory (Library.type: factory) — HTTP stubbed for Round 1
|
|
9
|
+
*
|
|
10
|
+
* Decision points applied:
|
|
11
|
+
* D1: version defaults to ^latest (per-realize-run cache)
|
|
12
|
+
* Offline mode: skips steps 3 + 4, fails loudly if unresolvable
|
|
13
|
+
* Cache: <cacheDir>/registry-cache/ (default .specverse/registry-cache/)
|
|
14
|
+
* Fail-loud: throws DependencyResolutionError when nothing resolves
|
|
15
|
+
*
|
|
16
|
+
* @see docs/proposals/2026-05-08-COMPONENT-DEPENDENCIES-V2.md — "Realize bridge — Resolver"
|
|
17
|
+
*/
|
|
18
|
+
import type { SpecVerseAST, ComponentSpec } from '@specverse/types';
|
|
19
|
+
/**
|
|
20
|
+
* A spec that has been resolved from a `from:` reference.
|
|
21
|
+
* For Round 1 registry paths, `spec` is a minimal stub generated from
|
|
22
|
+
* the registry Library record.
|
|
23
|
+
*/
|
|
24
|
+
export interface ResolvedComponent {
|
|
25
|
+
/** The original `from:` value from the import entry that produced this. */
|
|
26
|
+
fromName: string;
|
|
27
|
+
/** Which step of the 4-step chain produced this result. */
|
|
28
|
+
source: 'local' | 'npm' | 'registry-component' | 'registry-factory';
|
|
29
|
+
/**
|
|
30
|
+
* The resolved SpecVerse spec. For local + npm sources this is the full
|
|
31
|
+
* parsed spec. For registry sources (stubs in Round 1) this is a minimal
|
|
32
|
+
* object bearing at least the component's `name` and `version`.
|
|
33
|
+
*/
|
|
34
|
+
spec: PartialSpec;
|
|
35
|
+
/**
|
|
36
|
+
* The resolved provider name (component name for local, npm package name
|
|
37
|
+
* for npm, registry library/factory name for registry-*).
|
|
38
|
+
*/
|
|
39
|
+
resolvedName: string;
|
|
40
|
+
/**
|
|
41
|
+
* Pinned version after ^latest expansion (or the version from the local
|
|
42
|
+
* spec / npm package.json). Optional because some local components may
|
|
43
|
+
* not declare a version field.
|
|
44
|
+
*/
|
|
45
|
+
resolvedVersion?: string;
|
|
46
|
+
/**
|
|
47
|
+
* For source = 'npm' or 'registry-*': the package specifier to use in
|
|
48
|
+
* generated `import` statements (e.g. '@stripe/stripe-js' or 'profit-calc').
|
|
49
|
+
* For source = 'local': not populated; callers compute relative paths
|
|
50
|
+
* from outputDir + resolvedName.
|
|
51
|
+
*/
|
|
52
|
+
packageSpecifier?: string;
|
|
53
|
+
/**
|
|
54
|
+
* For source = 'local': relative path from the consumer's outputDir to
|
|
55
|
+
* the provider's emitted module. Optional — when absent, callers fall
|
|
56
|
+
* back to `../{resolvedName}` or similar convention.
|
|
57
|
+
*/
|
|
58
|
+
localRelativePath?: string;
|
|
59
|
+
/**
|
|
60
|
+
* Registry coordinates when source is 'registry-component' or 'registry-factory'.
|
|
61
|
+
*/
|
|
62
|
+
registryRef?: {
|
|
63
|
+
name: string;
|
|
64
|
+
version: string;
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* A factory reference returned when the registry resolves a capability match
|
|
69
|
+
* (step 4).
|
|
70
|
+
*/
|
|
71
|
+
export interface FactoryReference {
|
|
72
|
+
name: string;
|
|
73
|
+
version: string;
|
|
74
|
+
/** Factory metadata from registry — partial in Round 1 (HTTP is stubbed). */
|
|
75
|
+
metadata?: Record<string, unknown>;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Options passed to each `resolve()` call. The full spec + workspace context
|
|
79
|
+
* allow the local-component and npm-package steps to work without extra
|
|
80
|
+
* configuration.
|
|
81
|
+
*/
|
|
82
|
+
export interface ResolveOptions {
|
|
83
|
+
/** The spec being realized — used for local-component lookup (step 1). */
|
|
84
|
+
spec: SpecVerseAST;
|
|
85
|
+
/**
|
|
86
|
+
* Absolute path to the workspace root. Used to locate node_modules for
|
|
87
|
+
* step 2. Defaults to `process.cwd()`.
|
|
88
|
+
*/
|
|
89
|
+
workspaceRoot?: string;
|
|
90
|
+
/**
|
|
91
|
+
* When true, steps 3 and 4 (registry) are skipped. If a `from:` reference
|
|
92
|
+
* cannot be resolved via steps 1–2, throws `DependencyResolutionError`.
|
|
93
|
+
*/
|
|
94
|
+
offline?: boolean;
|
|
95
|
+
/**
|
|
96
|
+
* Directory where registry responses are cached.
|
|
97
|
+
* Defaults to `.specverse/registry-cache/` inside `workspaceRoot`.
|
|
98
|
+
*/
|
|
99
|
+
cacheDir?: string;
|
|
100
|
+
/**
|
|
101
|
+
* When true, treats the registry cache as stale and re-fetches even if a
|
|
102
|
+
* cached entry exists. Equivalent to the `--refresh-registry` flag.
|
|
103
|
+
* Can also be set via the `SPECVERSE_REFRESH_REGISTRY=1` environment variable.
|
|
104
|
+
*/
|
|
105
|
+
refreshRegistry?: boolean;
|
|
106
|
+
}
|
|
107
|
+
export interface DependencyResolver {
|
|
108
|
+
/**
|
|
109
|
+
* Resolve a `from:` reference to a component spec.
|
|
110
|
+
*
|
|
111
|
+
* Steps (in order):
|
|
112
|
+
* 1. Local component in spec.components
|
|
113
|
+
* 2. node_modules/<from>/package.json
|
|
114
|
+
* 3. GET /api/libraries/<from> (Registry, Library.type: component) — STUBBED
|
|
115
|
+
* 4. GET /api/libraries?type=factory&capability=<from> — STUBBED
|
|
116
|
+
*
|
|
117
|
+
* @param from The `from:` value from the import entry.
|
|
118
|
+
* @param version Semver range or pin. Defaults to `^latest` (D1).
|
|
119
|
+
* @param options Resolve-time context.
|
|
120
|
+
* @returns ResolvedComponent or null when offline + not locally found.
|
|
121
|
+
* @throws DependencyResolutionError when nothing resolves (not offline) or
|
|
122
|
+
* when offline and no local resolution is possible.
|
|
123
|
+
*/
|
|
124
|
+
resolve(from: string, version?: string, options?: ResolveOptions): Promise<ResolvedComponent | null>;
|
|
125
|
+
/**
|
|
126
|
+
* Resolve a capability tag to a factory reference.
|
|
127
|
+
* Used by realize emitters that need to find which factory covers a given
|
|
128
|
+
* capability string.
|
|
129
|
+
*
|
|
130
|
+
* Delegates to step 4 of the chain.
|
|
131
|
+
*
|
|
132
|
+
* @throws DependencyResolutionError when no factory matches and not offline.
|
|
133
|
+
*/
|
|
134
|
+
resolveCapability(capability: string, options?: ResolveOptions): Promise<FactoryReference | null>;
|
|
135
|
+
}
|
|
136
|
+
export declare class DependencyResolutionError extends Error {
|
|
137
|
+
readonly from: string;
|
|
138
|
+
readonly triedSteps: string[];
|
|
139
|
+
constructor(message: string, from: string, triedSteps: string[]);
|
|
140
|
+
}
|
|
141
|
+
/** Minimal spec shape accepted from all resolution sources. */
|
|
142
|
+
export interface PartialSpec {
|
|
143
|
+
name?: string;
|
|
144
|
+
version?: string;
|
|
145
|
+
components?: ComponentSpec[];
|
|
146
|
+
[key: string]: unknown;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Create a `DependencyResolver` instance.
|
|
150
|
+
*
|
|
151
|
+
* The resolver is stateless between realize runs. A new instance should be
|
|
152
|
+
* created per-run (or per test) to avoid cross-run cache pollution in memory.
|
|
153
|
+
* On-disk cache in `<cacheDir>/registry-cache/` persists across runs and is
|
|
154
|
+
* shared across instances that use the same directory.
|
|
155
|
+
*/
|
|
156
|
+
export declare function createDependencyResolver(): DependencyResolver;
|
|
157
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/realize/resolver/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAIH,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAMpE;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,2EAA2E;IAC3E,QAAQ,EAAE,MAAM,CAAC;IACjB,2DAA2D;IAC3D,MAAM,EAAE,OAAO,GAAG,KAAK,GAAG,oBAAoB,GAAG,kBAAkB,CAAC;IACpE;;;;OAIG;IACH,IAAI,EAAE,WAAW,CAAC;IAClB;;;OAGG;IACH,YAAY,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;OAEG;IACH,WAAW,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CACjD;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,6EAA6E;IAC7E,QAA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 1)
|
|
3
|
+
*
|
|
4
|
+
* 4-step lookup chain for `import[].from` references:
|
|
5
|
+
* 1. Local component in same spec
|
|
6
|
+
* 2. Local npm package (node_modules/<name>/package.json)
|
|
7
|
+
* 3. Registry library (Library.type: component) — HTTP stubbed for Round 1
|
|
8
|
+
* 4. Registry factory (Library.type: factory) — HTTP stubbed for Round 1
|
|
9
|
+
*
|
|
10
|
+
* Decision points applied:
|
|
11
|
+
* D1: version defaults to ^latest (per-realize-run cache)
|
|
12
|
+
* Offline mode: skips steps 3 + 4, fails loudly if unresolvable
|
|
13
|
+
* Cache: <cacheDir>/registry-cache/ (default .specverse/registry-cache/)
|
|
14
|
+
* Fail-loud: throws DependencyResolutionError when nothing resolves
|
|
15
|
+
*
|
|
16
|
+
* @see docs/proposals/2026-05-08-COMPONENT-DEPENDENCIES-V2.md — "Realize bridge — Resolver"
|
|
17
|
+
*/
|
|
18
|
+
import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'fs';
|
|
19
|
+
import { join, resolve } from 'path';
|
|
20
|
+
// ============================================================================
|
|
21
|
+
// Error
|
|
22
|
+
// ============================================================================
|
|
23
|
+
export class DependencyResolutionError extends Error {
|
|
24
|
+
from;
|
|
25
|
+
triedSteps;
|
|
26
|
+
constructor(message, from, triedSteps) {
|
|
27
|
+
super(message);
|
|
28
|
+
this.from = from;
|
|
29
|
+
this.triedSteps = triedSteps;
|
|
30
|
+
this.name = 'DependencyResolutionError';
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
// ============================================================================
|
|
34
|
+
// Registry HTTP stub
|
|
35
|
+
// ============================================================================
|
|
36
|
+
/**
|
|
37
|
+
* Round-1 stub for registry component lookup.
|
|
38
|
+
*
|
|
39
|
+
* TODO: Replace with real HTTP fetch:
|
|
40
|
+
* GET <registryBase>/api/libraries/<name>
|
|
41
|
+
* Expected response shape (Library.type: component):
|
|
42
|
+
* { name, version, type: 'component', specContent: '<yaml>' }
|
|
43
|
+
*
|
|
44
|
+
* @returns null — no registry data in Round 1 (real HTTP not yet wired).
|
|
45
|
+
*/
|
|
46
|
+
async function fetchRegistryComponent(name, _version) {
|
|
47
|
+
// TODO(v2-p3-round2): implement real HTTP fetch to specverse registry.
|
|
48
|
+
// Endpoint: GET /api/libraries/<name>
|
|
49
|
+
// Auth: anonymous reads; OAuth for publish
|
|
50
|
+
// Filtering: check Library.type === 'component'
|
|
51
|
+
void name;
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Round-1 stub for registry factory lookup by capability.
|
|
56
|
+
*
|
|
57
|
+
* TODO: Replace with real HTTP fetch:
|
|
58
|
+
* GET <registryBase>/api/libraries?type=factory&capability=<capability>
|
|
59
|
+
* Expected response shape (array of Library.type: factory records):
|
|
60
|
+
* [{ name, version, type: 'factory', metadata: { topology, protocol, ... } }]
|
|
61
|
+
*
|
|
62
|
+
* @returns null — no registry data in Round 1.
|
|
63
|
+
*/
|
|
64
|
+
async function fetchRegistryFactory(_capability) {
|
|
65
|
+
// TODO(v2-p3-round2): implement real HTTP fetch to specverse registry.
|
|
66
|
+
// Endpoint: GET /api/libraries?type=factory&capability=<capability>
|
|
67
|
+
// Auth: anonymous reads
|
|
68
|
+
// Selection: pick highest semver-matching version
|
|
69
|
+
void _capability;
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
// ============================================================================
|
|
73
|
+
// Resolver implementation
|
|
74
|
+
// ============================================================================
|
|
75
|
+
/**
|
|
76
|
+
* Default semver range when the spec author omits `version:` (D1).
|
|
77
|
+
*/
|
|
78
|
+
const DEFAULT_VERSION = '^latest';
|
|
79
|
+
/**
|
|
80
|
+
* Resolve an effective cache directory from options + environment.
|
|
81
|
+
*/
|
|
82
|
+
function resolveCacheDir(options) {
|
|
83
|
+
if (options.cacheDir)
|
|
84
|
+
return options.cacheDir;
|
|
85
|
+
const root = options.workspaceRoot ?? process.cwd();
|
|
86
|
+
return join(root, '.specverse', 'registry-cache');
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Determine whether the registry cache should be refreshed.
|
|
90
|
+
* Checks:
|
|
91
|
+
* 1. `options.refreshRegistry` flag
|
|
92
|
+
* 2. `SPECVERSE_REFRESH_REGISTRY` environment variable
|
|
93
|
+
*/
|
|
94
|
+
function shouldRefreshRegistry(options) {
|
|
95
|
+
if (options.refreshRegistry)
|
|
96
|
+
return true;
|
|
97
|
+
return process.env['SPECVERSE_REFRESH_REGISTRY'] === '1';
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Read a cache entry if it exists (and we are not refreshing).
|
|
101
|
+
*/
|
|
102
|
+
function readCache(cacheDir, key, refresh) {
|
|
103
|
+
if (refresh)
|
|
104
|
+
return null;
|
|
105
|
+
const filePath = join(cacheDir, `${key}.json`);
|
|
106
|
+
if (!existsSync(filePath))
|
|
107
|
+
return null;
|
|
108
|
+
try {
|
|
109
|
+
const raw = readFileSync(filePath, 'utf-8');
|
|
110
|
+
return JSON.parse(raw);
|
|
111
|
+
}
|
|
112
|
+
catch {
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Write a cache entry. Creates the cache directory if it doesn't exist.
|
|
118
|
+
*/
|
|
119
|
+
function writeCache(cacheDir, key, entry) {
|
|
120
|
+
try {
|
|
121
|
+
if (!existsSync(cacheDir)) {
|
|
122
|
+
mkdirSync(cacheDir, { recursive: true });
|
|
123
|
+
}
|
|
124
|
+
const filePath = join(cacheDir, `${key}.json`);
|
|
125
|
+
writeFileSync(filePath, JSON.stringify(entry, null, 2), 'utf-8');
|
|
126
|
+
}
|
|
127
|
+
catch {
|
|
128
|
+
// Cache write failure is non-fatal — resolution can continue without it.
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Sanitise a `from:` value so it's safe as a filesystem key.
|
|
133
|
+
* Converts `@scope/pkg` → `scope__pkg`, slashes → `__`.
|
|
134
|
+
*/
|
|
135
|
+
function cacheKey(from) {
|
|
136
|
+
return from.replace(/^@/, '').replace(/\//g, '__');
|
|
137
|
+
}
|
|
138
|
+
class DependencyResolverImpl {
|
|
139
|
+
async resolve(from, version, options = { spec: { components: [], deployments: [], manifests: [] } }) {
|
|
140
|
+
const effectiveVersion = version ?? DEFAULT_VERSION;
|
|
141
|
+
const triedSteps = [];
|
|
142
|
+
// ── Step 1: Local component in same spec ────────────────────────────────
|
|
143
|
+
triedSteps.push('local-component');
|
|
144
|
+
const localMatch = (options.spec?.components ?? []).find((c) => c.name === from);
|
|
145
|
+
if (localMatch) {
|
|
146
|
+
return {
|
|
147
|
+
fromName: from,
|
|
148
|
+
source: 'local',
|
|
149
|
+
spec: { name: localMatch.name, version: localMatch.version, components: [localMatch] },
|
|
150
|
+
resolvedName: localMatch.name,
|
|
151
|
+
resolvedVersion: localMatch.version,
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
// ── Step 2: Local npm package ────────────────────────────────────────────
|
|
155
|
+
triedSteps.push('npm-package');
|
|
156
|
+
const workspaceRoot = resolve(options.workspaceRoot ?? process.cwd());
|
|
157
|
+
const pkgJsonPath = join(workspaceRoot, 'node_modules', from, 'package.json');
|
|
158
|
+
if (existsSync(pkgJsonPath)) {
|
|
159
|
+
try {
|
|
160
|
+
const pkgJson = JSON.parse(readFileSync(pkgJsonPath, 'utf-8'));
|
|
161
|
+
const pkgName = pkgJson['name'] ?? from;
|
|
162
|
+
const pkgVersion = pkgJson['version'] ?? effectiveVersion;
|
|
163
|
+
return {
|
|
164
|
+
fromName: from,
|
|
165
|
+
source: 'npm',
|
|
166
|
+
spec: { name: pkgName, version: pkgVersion },
|
|
167
|
+
resolvedName: pkgName,
|
|
168
|
+
resolvedVersion: pkgVersion,
|
|
169
|
+
packageSpecifier: pkgName,
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
catch {
|
|
173
|
+
// Malformed package.json — fall through to registry steps.
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
// ── Offline fence ────────────────────────────────────────────────────────
|
|
177
|
+
if (options.offline) {
|
|
178
|
+
throw new DependencyResolutionError(`Cannot resolve "${from}": not found as a local component or npm package, ` +
|
|
179
|
+
`and offline mode prevents registry lookup.\n` +
|
|
180
|
+
` Tried: ${triedSteps.join(', ')}`, from, triedSteps);
|
|
181
|
+
}
|
|
182
|
+
const cacheDir = resolveCacheDir(options);
|
|
183
|
+
const refresh = shouldRefreshRegistry(options);
|
|
184
|
+
const key = cacheKey(from);
|
|
185
|
+
// ── Step 3: Registry library (Library.type: component) ───────────────────
|
|
186
|
+
triedSteps.push('registry-component');
|
|
187
|
+
const cachedComponent = readCache(cacheDir, key, refresh);
|
|
188
|
+
if (cachedComponent && cachedComponent.source === 'registry-component') {
|
|
189
|
+
return {
|
|
190
|
+
fromName: from,
|
|
191
|
+
source: 'registry-component',
|
|
192
|
+
spec: { name: cachedComponent.name, version: cachedComponent.version },
|
|
193
|
+
resolvedName: cachedComponent.name,
|
|
194
|
+
resolvedVersion: cachedComponent.version,
|
|
195
|
+
packageSpecifier: cachedComponent.name,
|
|
196
|
+
registryRef: { name: cachedComponent.name, version: cachedComponent.version },
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
const registryComponentResult = await fetchRegistryComponent(from, effectiveVersion);
|
|
200
|
+
if (registryComponentResult) {
|
|
201
|
+
const entry = {
|
|
202
|
+
cachedAt: new Date().toISOString(),
|
|
203
|
+
source: 'registry-component',
|
|
204
|
+
name: registryComponentResult.name,
|
|
205
|
+
version: registryComponentResult.version,
|
|
206
|
+
data: registryComponentResult,
|
|
207
|
+
};
|
|
208
|
+
writeCache(cacheDir, key, entry);
|
|
209
|
+
return {
|
|
210
|
+
fromName: from,
|
|
211
|
+
source: 'registry-component',
|
|
212
|
+
spec: { name: registryComponentResult.name, version: registryComponentResult.version },
|
|
213
|
+
resolvedName: registryComponentResult.name,
|
|
214
|
+
resolvedVersion: registryComponentResult.version,
|
|
215
|
+
packageSpecifier: registryComponentResult.name,
|
|
216
|
+
registryRef: { name: registryComponentResult.name, version: registryComponentResult.version },
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
// ── Step 4: Registry factory (Library.type: factory) ─────────────────────
|
|
220
|
+
triedSteps.push('registry-factory');
|
|
221
|
+
const factoryKey = `factory__${key}`;
|
|
222
|
+
const cachedFactory = readCache(cacheDir, factoryKey, refresh);
|
|
223
|
+
if (cachedFactory && cachedFactory.source === 'registry-factory') {
|
|
224
|
+
return {
|
|
225
|
+
fromName: from,
|
|
226
|
+
source: 'registry-factory',
|
|
227
|
+
spec: { name: cachedFactory.name, version: cachedFactory.version },
|
|
228
|
+
resolvedName: cachedFactory.name,
|
|
229
|
+
resolvedVersion: cachedFactory.version,
|
|
230
|
+
packageSpecifier: cachedFactory.name,
|
|
231
|
+
registryRef: { name: cachedFactory.name, version: cachedFactory.version },
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
const registryFactoryResult = await fetchRegistryFactory(from);
|
|
235
|
+
if (registryFactoryResult) {
|
|
236
|
+
const entry = {
|
|
237
|
+
cachedAt: new Date().toISOString(),
|
|
238
|
+
source: 'registry-factory',
|
|
239
|
+
name: registryFactoryResult.name,
|
|
240
|
+
version: registryFactoryResult.version,
|
|
241
|
+
data: registryFactoryResult,
|
|
242
|
+
};
|
|
243
|
+
writeCache(cacheDir, factoryKey, entry);
|
|
244
|
+
return {
|
|
245
|
+
fromName: from,
|
|
246
|
+
source: 'registry-factory',
|
|
247
|
+
spec: { name: registryFactoryResult.name, version: registryFactoryResult.version },
|
|
248
|
+
resolvedName: registryFactoryResult.name,
|
|
249
|
+
resolvedVersion: registryFactoryResult.version,
|
|
250
|
+
packageSpecifier: registryFactoryResult.name,
|
|
251
|
+
registryRef: { name: registryFactoryResult.name, version: registryFactoryResult.version },
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
// ── Nothing resolved ─────────────────────────────────────────────────────
|
|
255
|
+
throw new DependencyResolutionError(`Cannot resolve "${from}" (version: "${effectiveVersion}"): ` +
|
|
256
|
+
`exhausted all 4 lookup steps with no match.\n` +
|
|
257
|
+
` Tried: ${triedSteps.join(' → ')}\n` +
|
|
258
|
+
` Hint: check the component name, npm package name, or registry entry for "${from}".`, from, triedSteps);
|
|
259
|
+
}
|
|
260
|
+
async resolveCapability(capability, options = { spec: { components: [], deployments: [], manifests: [] } }) {
|
|
261
|
+
if (options.offline) {
|
|
262
|
+
// In offline mode we cannot query the registry for capability matches.
|
|
263
|
+
return null;
|
|
264
|
+
}
|
|
265
|
+
const cacheDir = resolveCacheDir(options);
|
|
266
|
+
const refresh = shouldRefreshRegistry(options);
|
|
267
|
+
const key = `capability__${cacheKey(capability)}`;
|
|
268
|
+
// Check cache first.
|
|
269
|
+
const cached = readCache(cacheDir, key, refresh);
|
|
270
|
+
if (cached && cached.source === 'registry-factory') {
|
|
271
|
+
return {
|
|
272
|
+
name: cached.name,
|
|
273
|
+
version: cached.version,
|
|
274
|
+
metadata: cached.data,
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
// TODO(v2-p3-round2): real HTTP call stubbed below.
|
|
278
|
+
const result = await fetchRegistryFactory(capability);
|
|
279
|
+
if (result) {
|
|
280
|
+
const entry = {
|
|
281
|
+
cachedAt: new Date().toISOString(),
|
|
282
|
+
source: 'registry-factory',
|
|
283
|
+
name: result.name,
|
|
284
|
+
version: result.version,
|
|
285
|
+
data: result,
|
|
286
|
+
};
|
|
287
|
+
writeCache(cacheDir, key, entry);
|
|
288
|
+
return { name: result.name, version: result.version, metadata: result.metadata };
|
|
289
|
+
}
|
|
290
|
+
return null;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
// ============================================================================
|
|
294
|
+
// Factory function (public API)
|
|
295
|
+
// ============================================================================
|
|
296
|
+
/**
|
|
297
|
+
* Create a `DependencyResolver` instance.
|
|
298
|
+
*
|
|
299
|
+
* The resolver is stateless between realize runs. A new instance should be
|
|
300
|
+
* created per-run (or per test) to avoid cross-run cache pollution in memory.
|
|
301
|
+
* On-disk cache in `<cacheDir>/registry-cache/` persists across runs and is
|
|
302
|
+
* shared across instances that use the same directory.
|
|
303
|
+
*/
|
|
304
|
+
export function createDependencyResolver() {
|
|
305
|
+
return new DependencyResolverImpl();
|
|
306
|
+
}
|
|
307
|
+
//# sourceMappingURL=index.js.map
|