@specverse/engines 6.39.3 → 6.40.7
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/services/templates/prisma/controller-generator.js +39 -20
- package/dist/libs/instance-factories/services/templates/prisma/service-generator.js +14 -5
- package/dist/libs/instance-factories/services/templates/prisma/step-conventions.js +10 -1
- package/dist/realize/index.d.ts.map +1 -1
- package/dist/realize/index.js +91 -13
- package/dist/realize/index.js.map +1 -1
- package/dist/realize/per-owner-emit.d.ts +101 -0
- package/dist/realize/per-owner-emit.d.ts.map +1 -0
- package/dist/realize/per-owner-emit.js +351 -0
- package/dist/realize/per-owner-emit.js.map +1 -0
- package/dist/realize/per-owner-runner.d.ts +105 -0
- package/dist/realize/per-owner-runner.d.ts.map +1 -0
- package/dist/realize/per-owner-runner.js +336 -0
- package/dist/realize/per-owner-runner.js.map +1 -0
- package/dist/realize/runtime-emitters/library.d.ts.map +1 -1
- package/dist/realize/runtime-emitters/library.js +17 -1
- package/dist/realize/runtime-emitters/library.js.map +1 -1
- package/libs/instance-factories/services/templates/_shared/step-matching.d.ts +39 -0
- package/libs/instance-factories/services/templates/_shared/step-matching.d.ts.map +1 -0
- package/libs/instance-factories/services/templates/_shared/step-matching.js +90 -0
- package/libs/instance-factories/services/templates/_shared/step-matching.js.map +1 -0
- package/libs/instance-factories/services/templates/prisma/__tests__/step-conventions-return.test.ts +124 -0
- package/libs/instance-factories/services/templates/prisma/controller-generator.ts +70 -22
- package/libs/instance-factories/services/templates/prisma/service-generator.ts +52 -6
- package/libs/instance-factories/services/templates/prisma/step-conventions.ts +33 -1
- package/package.json +1 -1
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-owner LLM emit hook — Phase 1 of the 2026-05-11-PER-OWNER-VS-PER-ACTION
|
|
3
|
+
* proposal.
|
|
4
|
+
*
|
|
5
|
+
* Sibling of `per-action-llm-emit.ts`. SAME structural-validator and
|
|
6
|
+
* parse-check infrastructure, DIFFERENT granularity: one LLM call per
|
|
7
|
+
* controller / service instead of one per action. Restores the
|
|
8
|
+
* class-level context (constructor injection, shared helpers, sibling
|
|
9
|
+
* methods) that per-action emission engineered out and that surfaced
|
|
10
|
+
* empirically as the 31% LLM-decline rate on idle-meta sonnet (the
|
|
11
|
+
* LLM correctly refused to invent imports it couldn't see were
|
|
12
|
+
* available).
|
|
13
|
+
*
|
|
14
|
+
* Three quality gates run on the emitted file:
|
|
15
|
+
* 1. Markdown extraction — pull the ```typescript fenced block out
|
|
16
|
+
* of the LLM response. Empty / missing block → null (caller
|
|
17
|
+
* falls through to per-action emit OR engine γ-stub).
|
|
18
|
+
* 2. Structural preservation (DR3) — every pre-baked snippet from
|
|
19
|
+
* every action's per-step matches must appear verbatim somewhere
|
|
20
|
+
* in the emitted file. A rewritten snippet is a loud failure;
|
|
21
|
+
* we throw with a diff.
|
|
22
|
+
* 3. esbuild parse check — the file must be syntactically valid TS.
|
|
23
|
+
* Surgical retry once on parse failure; if it fails again we
|
|
24
|
+
* return null (caller falls through).
|
|
25
|
+
*
|
|
26
|
+
* The realize-owner.prompt.yaml asset ships at:
|
|
27
|
+
* `@specverse/assets/prompts/core/standard/default/realize-owner.prompt.yaml`.
|
|
28
|
+
* Until assets is republished with it, a filesystem fallback under
|
|
29
|
+
* `specverse-self/assets/` is searched.
|
|
30
|
+
*/
|
|
31
|
+
import { readFileSync, existsSync } from 'fs';
|
|
32
|
+
import { dirname, join, resolve } from 'path';
|
|
33
|
+
import { fileURLToPath } from 'url';
|
|
34
|
+
import { createRequire } from 'module';
|
|
35
|
+
import yaml from 'js-yaml';
|
|
36
|
+
import { loadPrompt, runPrompt as runPromptFn, assembleSystem, assembleUser, } from '../ai/prompt-runner.js';
|
|
37
|
+
import { validateLlmOutputPreservesConventions, } from './structural-validator.js';
|
|
38
|
+
import { extractTypescriptBlock } from './per-action-llm-emit.js';
|
|
39
|
+
const require = createRequire(import.meta.url);
|
|
40
|
+
/**
|
|
41
|
+
* Build a {@link PerOwnerEmitFn} for use in per-owner realize emission.
|
|
42
|
+
*
|
|
43
|
+
* Returned function:
|
|
44
|
+
* 1. Builds the prompt input from the per-owner request.
|
|
45
|
+
* 2. Calls runPrompt({ operation: 'realize-owner', ... }).
|
|
46
|
+
* 3. Extracts the ```typescript block from the response.
|
|
47
|
+
* 4. Runs the structural validator (DR3); throws on rewrite.
|
|
48
|
+
* 5. Runs an esbuild parse check; surgical-retries once on failure.
|
|
49
|
+
* 6. Returns the file contents string, or null when all attempts
|
|
50
|
+
* fail (caller falls through).
|
|
51
|
+
*/
|
|
52
|
+
export function createRealizeOwnerLlmEmit(opts = {}) {
|
|
53
|
+
const runPrompt = opts.runPromptOverride ?? runPromptFn;
|
|
54
|
+
const loadPromptResolved = opts.loadPromptOverride ?? loadRealizeOwnerPrompt;
|
|
55
|
+
const parseCheck = opts.parseCheckOverride ?? esbuildFileParseCheck;
|
|
56
|
+
return async (request) => {
|
|
57
|
+
// 1. Pre-bake snippets across all actions for the structural
|
|
58
|
+
// validator. Each matched step from any action contributes.
|
|
59
|
+
const prebakedSnippets = [];
|
|
60
|
+
for (const action of request.actions) {
|
|
61
|
+
action.perStepMatches.forEach((match, idx) => {
|
|
62
|
+
if (match?.matched && match.call) {
|
|
63
|
+
prebakedSnippets.push({
|
|
64
|
+
stepNum: idx + 1,
|
|
65
|
+
stepText: action.spec.steps[idx] ?? '',
|
|
66
|
+
snippet: match.call,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
// 2. Build prompt values.
|
|
72
|
+
const promptValues = buildPromptValues(request);
|
|
73
|
+
// 3. Surgical retry loop (cap at 1).
|
|
74
|
+
const maxAttempts = opts.disableSurgicalRetry ? 1 : 2;
|
|
75
|
+
let lastParseError = null;
|
|
76
|
+
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
77
|
+
const userPrefix = lastParseError
|
|
78
|
+
? buildSurgicalRetryPrefix(lastParseError, request.ownerName)
|
|
79
|
+
: '';
|
|
80
|
+
let runResult;
|
|
81
|
+
try {
|
|
82
|
+
// Per-owner calls produce whole-file emissions (5-15K tokens
|
|
83
|
+
// per call vs 1.5-3K per-action) and routinely run 60-180s
|
|
84
|
+
// for big owners on sonnet. The default 5-minute timeout was
|
|
85
|
+
// sufficient for per-action but cut off large per-owner emits
|
|
86
|
+
// (the 2026-05-11 trial saw GamesV3Controller, 6 actions,
|
|
87
|
+
// time out at exactly 300s). Bump the default to 15min for
|
|
88
|
+
// per-owner; callers can still tighten via opts.timeoutMs.
|
|
89
|
+
const timeoutMs = opts.timeoutMs ?? 900_000;
|
|
90
|
+
const runOpts = {
|
|
91
|
+
operation: 'realize-owner',
|
|
92
|
+
values: promptValues,
|
|
93
|
+
model: opts.model,
|
|
94
|
+
timeoutMs,
|
|
95
|
+
userPrefix,
|
|
96
|
+
};
|
|
97
|
+
runResult = await callRunPromptWithFallback(runPrompt, runOpts, loadPromptResolved);
|
|
98
|
+
}
|
|
99
|
+
catch (e) {
|
|
100
|
+
if (process.env.SPECVERSE_VERBOSE) {
|
|
101
|
+
const cls = (e && e.constructor && e.constructor.name) || 'Error';
|
|
102
|
+
const msg = (e && e.message) || String(e);
|
|
103
|
+
const head = String(msg).slice(0, 240).replace(/\s+/g, ' ');
|
|
104
|
+
console.error(` ✗ per-owner LLM emit threw for ${request.ownerName} [${cls}]: ${head}`);
|
|
105
|
+
}
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
// 4. Extract the ```typescript fenced block.
|
|
109
|
+
const fileContents = extractTypescriptBlock(runResult.text);
|
|
110
|
+
if (!fileContents || fileContents.trim().length === 0) {
|
|
111
|
+
if (process.env.SPECVERSE_VERBOSE) {
|
|
112
|
+
const reason = fileContents === undefined || fileContents === null
|
|
113
|
+
? 'no typescript code block in LLM response'
|
|
114
|
+
: 'typescript block was empty';
|
|
115
|
+
console.error(` ✗ per-owner LLM emit empty for ${request.ownerName}: ${reason}`);
|
|
116
|
+
}
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
// 5. Structural validator — DR3. A rewritten pre-baked snippet
|
|
120
|
+
// is a LOUD failure (not a silent retry).
|
|
121
|
+
const structural = validateLlmOutputPreservesConventions(fileContents, prebakedSnippets);
|
|
122
|
+
if (structural.ok === false) {
|
|
123
|
+
throw new Error(`[realize-owner] structural-preservation failed for ${request.ownerName}:\n${structural.reason}`);
|
|
124
|
+
}
|
|
125
|
+
// 6. esbuild parse check — surgical retry once on parse failure.
|
|
126
|
+
const parseError = await parseCheck(fileContents);
|
|
127
|
+
if (parseError === null) {
|
|
128
|
+
// All gates green — return the file.
|
|
129
|
+
return fileContents;
|
|
130
|
+
}
|
|
131
|
+
lastParseError = parseError;
|
|
132
|
+
}
|
|
133
|
+
// Exhausted retries — fall through.
|
|
134
|
+
if (process.env.SPECVERSE_VERBOSE) {
|
|
135
|
+
const head = String(lastParseError ?? 'unknown').slice(0, 240).replace(/\s+/g, ' ');
|
|
136
|
+
console.error(` ✗ per-owner LLM emit parse-failed after ${maxAttempts} attempt(s) for ${request.ownerName}: ${head}`);
|
|
137
|
+
}
|
|
138
|
+
return null;
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
// ─── Prompt loading + assets fallback ────────────────────────────────
|
|
142
|
+
/** Default prompt loader. Tries the installed @specverse/assets path
|
|
143
|
+
* first; falls back to the in-repo specverse-self/assets/ tree for
|
|
144
|
+
* dev cycles where assets isn't yet republished. Mirrors the
|
|
145
|
+
* per-action emitter's fallback strategy. */
|
|
146
|
+
function loadRealizeOwnerPrompt() {
|
|
147
|
+
// Installed path: shipped from @specverse/assets via loadPrompt.
|
|
148
|
+
try {
|
|
149
|
+
return loadPrompt('realize-owner');
|
|
150
|
+
}
|
|
151
|
+
catch (e) {
|
|
152
|
+
// Try filesystem fallbacks below.
|
|
153
|
+
}
|
|
154
|
+
const fallback = loadRealizeOwnerPromptFromFallback();
|
|
155
|
+
if (fallback)
|
|
156
|
+
return fallback;
|
|
157
|
+
throw new Error('realize-owner.prompt.yaml not found in @specverse/assets nor the ' +
|
|
158
|
+
'specverse-self/assets/ filesystem fallback. Has the assets ' +
|
|
159
|
+
'package been republished since 2026-05-11?');
|
|
160
|
+
}
|
|
161
|
+
/** Filesystem fallback search for the realize-owner prompt. Mirrors
|
|
162
|
+
* per-action-llm-emit.ts:loadRealizeActionPromptFromFallback's three-
|
|
163
|
+
* tier search: @specverse/assets package path, engine-bundled assets,
|
|
164
|
+
* worktree-sibling specverse-self/assets. */
|
|
165
|
+
export function loadRealizeOwnerPromptFromFallback() {
|
|
166
|
+
const candidates = [];
|
|
167
|
+
// 1. @specverse/assets package (covers the post-publish case).
|
|
168
|
+
try {
|
|
169
|
+
const pkg = require.resolve('@specverse/assets/package.json');
|
|
170
|
+
candidates.push(join(dirname(pkg), 'prompts/core/standard/default/realize-owner.prompt.yaml'), join(dirname(pkg), 'prompts/core/standard/v9/realize-owner.prompt.yaml'));
|
|
171
|
+
}
|
|
172
|
+
catch {
|
|
173
|
+
/* assets not installed */
|
|
174
|
+
}
|
|
175
|
+
// 2. Engine-bundled assets (engines ≤ 6.0.2-style layouts).
|
|
176
|
+
try {
|
|
177
|
+
const enginesPkg = require.resolve('@specverse/engines/package.json');
|
|
178
|
+
candidates.push(join(dirname(enginesPkg), 'assets/prompts/core/standard/default/realize-owner.prompt.yaml'), join(dirname(enginesPkg), 'assets/prompts/core/standard/v9/realize-owner.prompt.yaml'));
|
|
179
|
+
}
|
|
180
|
+
catch {
|
|
181
|
+
/* engines not installed at this path */
|
|
182
|
+
}
|
|
183
|
+
// 3. @specverse/self package (covers the post-publish case where
|
|
184
|
+
// self has the prompts bundled but @specverse/assets doesn't yet).
|
|
185
|
+
// Per-owner ships to specverse-self/assets/ first during the trial.
|
|
186
|
+
try {
|
|
187
|
+
const selfPkg = require.resolve('@specverse/self/package.json');
|
|
188
|
+
candidates.push(join(dirname(selfPkg), 'assets/prompts/core/standard/default/realize-owner.prompt.yaml'), join(dirname(selfPkg), 'assets/prompts/core/standard/v9/realize-owner.prompt.yaml'));
|
|
189
|
+
}
|
|
190
|
+
catch {
|
|
191
|
+
/* self not installed at this path */
|
|
192
|
+
}
|
|
193
|
+
// 4. Worktree fallback — specverse-self lives next to specverse-engines.
|
|
194
|
+
try {
|
|
195
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
196
|
+
candidates.push(resolve(here, '../../../../specverse-self/assets/prompts/core/standard/default/realize-owner.prompt.yaml'), resolve(here, '../../../../specverse-self/assets/prompts/core/standard/v9/realize-owner.prompt.yaml'), resolve(here, '../../../../../specverse-self/assets/prompts/core/standard/default/realize-owner.prompt.yaml'), resolve(here, '../../../../../specverse-self/assets/prompts/core/standard/v9/realize-owner.prompt.yaml'));
|
|
197
|
+
}
|
|
198
|
+
catch {
|
|
199
|
+
/* import.meta.url unavailable */
|
|
200
|
+
}
|
|
201
|
+
for (const p of candidates) {
|
|
202
|
+
if (existsSync(p)) {
|
|
203
|
+
try {
|
|
204
|
+
return yaml.load(readFileSync(p, 'utf-8'));
|
|
205
|
+
}
|
|
206
|
+
catch {
|
|
207
|
+
/* try next */
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
return null;
|
|
212
|
+
}
|
|
213
|
+
/** Wrap runPrompt with the assets-fallback prompt-loading strategy.
|
|
214
|
+
* Mirrors per-action-llm-emit's same-named helper: first try
|
|
215
|
+
* runPrompt's own loadPrompt path; on `prompt file not found`,
|
|
216
|
+
* fall back to the filesystem-loaded prompt and call ai-sdk
|
|
217
|
+
* generateText directly so we don't need a `prompt: PromptYaml`
|
|
218
|
+
* field on RunPromptOptions. */
|
|
219
|
+
async function callRunPromptWithFallback(runPromptImpl, opts, fallbackLoader) {
|
|
220
|
+
// First try: let runPrompt do its own loadPrompt.
|
|
221
|
+
try {
|
|
222
|
+
return await runPromptImpl(opts);
|
|
223
|
+
}
|
|
224
|
+
catch (e) {
|
|
225
|
+
const msg = e?.message ?? String(e);
|
|
226
|
+
if (!/prompt file not found for "realize-owner"/i.test(msg)) {
|
|
227
|
+
throw e;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
// Second try: load via fallback + call ai-sdk directly.
|
|
231
|
+
const prompt = fallbackLoader();
|
|
232
|
+
const system = assembleSystem(prompt);
|
|
233
|
+
const baseUser = assembleUser(prompt, opts.values);
|
|
234
|
+
const user = (opts.userPrefix || '') + baseUser;
|
|
235
|
+
if (typeof opts.onAssembled === 'function') {
|
|
236
|
+
opts.onAssembled({ system, user });
|
|
237
|
+
}
|
|
238
|
+
const aiSdk = await import('ai');
|
|
239
|
+
const { resolveModel } = await import('../ai/model-resolver.js');
|
|
240
|
+
const model = opts.model ?? resolveModel({ ...(opts.modelOptions ?? {}), timeout: opts.timeoutMs ?? 300_000 });
|
|
241
|
+
const t0 = Date.now();
|
|
242
|
+
const result = await aiSdk.generateText({
|
|
243
|
+
model,
|
|
244
|
+
system,
|
|
245
|
+
prompt: user,
|
|
246
|
+
abortSignal: AbortSignal.timeout(opts.timeoutMs ?? 300_000),
|
|
247
|
+
});
|
|
248
|
+
const duration_ms = Date.now() - t0;
|
|
249
|
+
return {
|
|
250
|
+
text: result.text,
|
|
251
|
+
tokens: {
|
|
252
|
+
input: result.usage?.inputTokens?.total ?? null,
|
|
253
|
+
output: result.usage?.outputTokens?.total ?? null,
|
|
254
|
+
},
|
|
255
|
+
duration_ms,
|
|
256
|
+
system,
|
|
257
|
+
user,
|
|
258
|
+
providerId: model.provider,
|
|
259
|
+
modelId: model.modelId,
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
// ─── Prompt input builder ────────────────────────────────────────────
|
|
263
|
+
/** Build the prompt-values map that the realize-owner.prompt.yaml
|
|
264
|
+
* user template references. */
|
|
265
|
+
function buildPromptValues(request) {
|
|
266
|
+
const ownerSpecYaml = yamlDumpOwner(request.ownerSpec, request.ownerName);
|
|
267
|
+
const perActionScaffolding = buildPerActionScaffolding(request.actions);
|
|
268
|
+
return {
|
|
269
|
+
ownerName: request.ownerName,
|
|
270
|
+
ownerKind: request.ownerKind,
|
|
271
|
+
ownerSpec: ownerSpecYaml,
|
|
272
|
+
perActionScaffolding,
|
|
273
|
+
availableClients: request.availableClients ?? '(none)',
|
|
274
|
+
availableCapabilities: request.availableCapabilities ?? '(none — only `input: any` is available)',
|
|
275
|
+
processContext: request.processContext ?? '(no related processes)',
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
/** Render the owner's spec body as YAML. Top-level key = the owner
|
|
279
|
+
* name; nested body = the spec object (actions / operations / etc.). */
|
|
280
|
+
function yamlDumpOwner(ownerSpec, ownerName) {
|
|
281
|
+
return yaml.dump({ [ownerName]: ownerSpec }, { lineWidth: 100, noRefs: true });
|
|
282
|
+
}
|
|
283
|
+
/** Build the per-action scaffolding block. One section per action,
|
|
284
|
+
* listing its steps with [PRE-BAKED] / [WRITE] markers. */
|
|
285
|
+
function buildPerActionScaffolding(actions) {
|
|
286
|
+
if (actions.length === 0)
|
|
287
|
+
return '(no actions on this owner)';
|
|
288
|
+
const sections = [];
|
|
289
|
+
for (const action of actions) {
|
|
290
|
+
sections.push(`### ${action.actionName}`);
|
|
291
|
+
if (!action.spec.steps?.length) {
|
|
292
|
+
sections.push(' (no steps declared — emit a bare body that fulfils the spec)');
|
|
293
|
+
sections.push('');
|
|
294
|
+
continue;
|
|
295
|
+
}
|
|
296
|
+
for (let i = 0; i < action.spec.steps.length; i++) {
|
|
297
|
+
const stepText = action.spec.steps[i] ?? '';
|
|
298
|
+
const match = action.perStepMatches[i];
|
|
299
|
+
if (match?.matched && match.call) {
|
|
300
|
+
sections.push(` ${i + 1}. [PRE-BAKED] "${stepText}" →`);
|
|
301
|
+
const snippetLines = match.call.split('\n');
|
|
302
|
+
for (const snippetLine of snippetLines) {
|
|
303
|
+
sections.push(` ${snippetLine}`);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
else {
|
|
307
|
+
sections.push(` ${i + 1}. [WRITE] "${stepText}"`);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
sections.push('');
|
|
311
|
+
}
|
|
312
|
+
return sections.join('\n');
|
|
313
|
+
}
|
|
314
|
+
/** File-level esbuild parse check. Distinct from
|
|
315
|
+
* per-action-llm-emit's `esbuildParseCheck` which wraps the body in
|
|
316
|
+
* a function (correct for action-body emission but wrong for
|
|
317
|
+
* whole-file emission with top-of-file imports). Here we parse the
|
|
318
|
+
* file as a TS module directly. Returns null on success, an error
|
|
319
|
+
* message string on failure. */
|
|
320
|
+
async function esbuildFileParseCheck(fileContents) {
|
|
321
|
+
try {
|
|
322
|
+
const esbuild = await import('esbuild');
|
|
323
|
+
await esbuild.transform(fileContents, {
|
|
324
|
+
loader: 'ts',
|
|
325
|
+
format: 'esm',
|
|
326
|
+
target: 'es2022',
|
|
327
|
+
});
|
|
328
|
+
return null;
|
|
329
|
+
}
|
|
330
|
+
catch (err) {
|
|
331
|
+
const msg = err?.errors?.[0]?.text || err?.message || 'unknown parse error';
|
|
332
|
+
return msg;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
/** Render the surgical-retry prefix that frames the parse error for
|
|
336
|
+
* the LLM. Reuses the per-action-llm-emit convention. */
|
|
337
|
+
function buildSurgicalRetryPrefix(parseError, ownerName) {
|
|
338
|
+
const trimmed = parseError.split('\n').slice(0, 4).join('\n');
|
|
339
|
+
return [
|
|
340
|
+
`Your previous emission for ${ownerName} failed an esbuild parse check:`,
|
|
341
|
+
'',
|
|
342
|
+
trimmed,
|
|
343
|
+
'',
|
|
344
|
+
'Re-emit the entire file with the parse error corrected. Preserve',
|
|
345
|
+
'all [PRE-BAKED] snippets verbatim. If a specific action cannot be',
|
|
346
|
+
'implemented coherently, use the γ-stub form for THAT action while',
|
|
347
|
+
'keeping the others fully implemented.',
|
|
348
|
+
'',
|
|
349
|
+
].join('\n');
|
|
350
|
+
}
|
|
351
|
+
//# sourceMappingURL=per-owner-emit.js.map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B;IACrE,MAAM,OAAO,GAAG,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC9D,OAAO;QACL,8BAA8B,SAAS,iCAAiC;QACxE,EAAE;QACF,OAAO;QACP,EAAE;QACF,kEAAkE;QAClE,mEAAmE;QACnE,mEAAmE;QACnE,uCAAuC;QACvC,EAAE;KACH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-owner realize runner — Phase 1 of the 2026-05-11-PER-OWNER-VS-PER-ACTION
|
|
3
|
+
* proposal.
|
|
4
|
+
*
|
|
5
|
+
* Sibling of `per-action-runner.ts`. SAME spec-walking + owner-grouping
|
|
6
|
+
* logic, DIFFERENT emission granularity: instead of calling
|
|
7
|
+
* `emitActionBody` once per action, this runner calls the per-owner
|
|
8
|
+
* LLM emit hook ONCE per owner and writes the resulting whole-file
|
|
9
|
+
* content as `<Owner>.ai.ts`.
|
|
10
|
+
*
|
|
11
|
+
* Why this exists: the per-action emitter (Realize L3 Phase 3) gave
|
|
12
|
+
* the LLM narrow context — one action's steps, no class shell, no
|
|
13
|
+
* sibling methods, no manifest capabilities. Empirically on
|
|
14
|
+
* idle-meta sonnet, that produced 29 of 94 actions as throw-stubs
|
|
15
|
+
* because the LLM correctly refused to invent imports it couldn't
|
|
16
|
+
* see were available. Per-owner restores the holistic context.
|
|
17
|
+
*
|
|
18
|
+
* Same `<Owner>.ai.ts` output shape (exported async functions per
|
|
19
|
+
* action) → no consumer-interface change. The downstream controller
|
|
20
|
+
* still does `import * as aiBehaviors from '../behaviors/X.ai.js'`.
|
|
21
|
+
*/
|
|
22
|
+
import { buildAvailableClientsByOwner } from './per-action-runner.js';
|
|
23
|
+
import type { MatcherFn, SharedConvention } from './per-action-emitter.js';
|
|
24
|
+
import type { PerOwnerEmitFn } from './per-owner-emit.js';
|
|
25
|
+
/** Options for {@link runPerOwnerEmission}. */
|
|
26
|
+
export interface RunPerOwnerEmissionOptions {
|
|
27
|
+
/** Full inferred spec. */
|
|
28
|
+
spec: any;
|
|
29
|
+
/** Output directory — `.ai.ts` files go under `${outputDir}/backend/src/behaviors/`. */
|
|
30
|
+
outputDir: string;
|
|
31
|
+
/** Convention matcher (default: `matchAgainstConventions`). */
|
|
32
|
+
matcher?: MatcherFn;
|
|
33
|
+
/** Convention array for the matcher. */
|
|
34
|
+
conventions?: ReadonlyArray<SharedConvention>;
|
|
35
|
+
/** Per-owner LLM emit hook. Required — the whole point of this
|
|
36
|
+
* runner is to drive it once per owner. */
|
|
37
|
+
perOwnerEmit: PerOwnerEmitFn;
|
|
38
|
+
/** Pre-built availableClients map (from buildAvailableClientsByOwner). */
|
|
39
|
+
availableClientsByOwner?: Map<string, string>;
|
|
40
|
+
/** Manifest capability mappings text (NEW vs per-action runner).
|
|
41
|
+
* Format: pre-rendered string listing each mapping, e.g.
|
|
42
|
+
* " - orm.client → PrismaClient (orms/prisma)\n - jwt.signer → ..." */
|
|
43
|
+
availableCapabilities?: string;
|
|
44
|
+
/** Process context string per owner (optional). */
|
|
45
|
+
processContextByOwner?: Map<string, string>;
|
|
46
|
+
/** Skip the per-owner ✅ console.log lines (used by harness runs). */
|
|
47
|
+
silent?: boolean;
|
|
48
|
+
/** Test hook: don't write files to disk; just return the emission
|
|
49
|
+
* result for assertion. */
|
|
50
|
+
dryRun?: boolean;
|
|
51
|
+
}
|
|
52
|
+
/** Result of {@link runPerOwnerEmission}. */
|
|
53
|
+
export interface RunPerOwnerEmissionResult {
|
|
54
|
+
/** Per-owner emission records (file contents + outcome). */
|
|
55
|
+
owners: PerOwnerOutcome[];
|
|
56
|
+
/** Absolute paths of files written (empty when dryRun). */
|
|
57
|
+
filesWritten: string[];
|
|
58
|
+
/** Aggregate counters. */
|
|
59
|
+
totals: {
|
|
60
|
+
/** Number of owners walked. */
|
|
61
|
+
ownerCount: number;
|
|
62
|
+
/** Number of actions across all owners. */
|
|
63
|
+
actionCount: number;
|
|
64
|
+
/** Owners whose LLM emit produced a usable file. */
|
|
65
|
+
ownersEmittedByLLM: number;
|
|
66
|
+
/** Owners whose LLM emit failed; runner fell back to a
|
|
67
|
+
* deterministic placeholder file. */
|
|
68
|
+
ownersFellBack: number;
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/** Per-owner emission outcome. */
|
|
72
|
+
export interface PerOwnerOutcome {
|
|
73
|
+
ownerName: string;
|
|
74
|
+
/** Number of actions on this owner. */
|
|
75
|
+
actionCount: number;
|
|
76
|
+
/** True when LLM produced a usable file. */
|
|
77
|
+
llmEmitted: boolean;
|
|
78
|
+
/** File contents written. Empty string when LLM declined entirely
|
|
79
|
+
* and the runner emitted a deterministic placeholder. */
|
|
80
|
+
fileContents: string;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Run per-owner LLM emission across every controller / service the
|
|
84
|
+
* spec declares. For each owner:
|
|
85
|
+
* 1. Collect its actions and resolve per-step matcher results.
|
|
86
|
+
* 2. Call the perOwnerEmit hook with the whole owner's context.
|
|
87
|
+
* 3. Write the returned file contents to disk (or fall back to a
|
|
88
|
+
* placeholder file containing one γ stub per action when emit
|
|
89
|
+
* returned null).
|
|
90
|
+
*/
|
|
91
|
+
export declare function runPerOwnerEmission(opts: RunPerOwnerEmissionOptions): Promise<RunPerOwnerEmissionResult>;
|
|
92
|
+
/** Build the availableCapabilities string consumed by the per-owner
|
|
93
|
+
* prompt's `availableCapabilities` slot. Walks the manifest's
|
|
94
|
+
* capabilityMappings and renders one line per mapping with a brief
|
|
95
|
+
* hint about what the factory provides. Exported so the realize
|
|
96
|
+
* caller can build it once and feed it to every owner.
|
|
97
|
+
*
|
|
98
|
+
* Format example:
|
|
99
|
+
* - orm.client → PrismaORM (provides Prisma's typed query API)
|
|
100
|
+
* - jwt.signer → JsonWebToken (jsonwebtoken.sign / verify)
|
|
101
|
+
* - event.bus → InMemoryEventBus (publish / subscribe)
|
|
102
|
+
*/
|
|
103
|
+
export declare function buildAvailableCapabilitiesString(manifest: any): string;
|
|
104
|
+
export { buildAvailableClientsByOwner };
|
|
105
|
+
//# sourceMappingURL=per-owner-runner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"per-owner-runner.d.ts","sourceRoot":"","sources":["../../src/realize/per-owner-runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAIH,OAAO,EAEL,4BAA4B,EAE7B,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAGV,SAAS,EACT,gBAAgB,EAGjB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EACV,cAAc,EAEf,MAAM,qBAAqB,CAAC;AAE7B,+CAA+C;AAC/C,MAAM,WAAW,0BAA0B;IACzC,0BAA0B;IAC1B,IAAI,EAAE,GAAG,CAAC;IACV,wFAAwF;IACxF,SAAS,EAAE,MAAM,CAAC;IAClB,+DAA+D;IAC/D,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,wCAAwC;IACxC,WAAW,CAAC,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAAC;IAC9C;gDAC4C;IAC5C,YAAY,EAAE,cAAc,CAAC;IAC7B,0EAA0E;IAC1E,uBAAuB,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9C;;gFAE4E;IAC5E,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,mDAAmD;IACnD,qBAAqB,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5C,qEAAqE;IACrE,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;gCAC4B;IAC5B,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,6CAA6C;AAC7C,MAAM,WAAW,yBAAyB;IACxC,4DAA4D;IAC5D,MAAM,EAAE,eAAe,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