@specverse/engines 6.7.8 → 6.16.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.
Files changed (47) hide show
  1. package/dist/ai/behavior-ai-service.js +2 -2
  2. package/dist/ai/behavior-ai-service.js.map +1 -1
  3. package/dist/inference/core/specly-converter.d.ts.map +1 -1
  4. package/dist/inference/core/specly-converter.js +20 -0
  5. package/dist/inference/core/specly-converter.js.map +1 -1
  6. package/dist/inference/index.d.ts.map +1 -1
  7. package/dist/inference/index.js +72 -22
  8. package/dist/inference/index.js.map +1 -1
  9. package/dist/inference/logical/generators/controller-generator.d.ts.map +1 -1
  10. package/dist/inference/logical/generators/controller-generator.js +26 -4
  11. package/dist/inference/logical/generators/controller-generator.js.map +1 -1
  12. package/dist/libs/instance-factories/applications/templates/generic/backend-package-json-generator.js +22 -5
  13. package/dist/libs/instance-factories/controllers/templates/fastify/routes-generator.js +50 -15
  14. package/dist/libs/instance-factories/controllers/templates/fastify/server-generator.js +26 -6
  15. package/dist/libs/instance-factories/services/postgres-native-services.yaml +90 -0
  16. package/dist/libs/instance-factories/services/templates/_shared/step-matching.js +44 -0
  17. package/dist/libs/instance-factories/services/templates/mongodb-native/controller-generator.js +68 -13
  18. package/dist/libs/instance-factories/services/templates/mongodb-native/step-conventions.js +515 -0
  19. package/dist/libs/instance-factories/services/templates/postgres-native/client-generator.js +165 -0
  20. package/dist/libs/instance-factories/services/templates/postgres-native/controller-generator.js +300 -0
  21. package/dist/libs/instance-factories/services/templates/postgres-native/ddl-generator.js +169 -0
  22. package/dist/libs/instance-factories/services/templates/postgres-native/service-generator.js +65 -0
  23. package/dist/libs/instance-factories/services/templates/postgres-native/step-conventions.js +433 -0
  24. package/dist/libs/instance-factories/services/templates/prisma/ai-behaviors-generator.js +27 -4
  25. package/dist/libs/instance-factories/services/templates/prisma/step-conventions.js +7 -34
  26. package/dist/parser/processors/ExecutableProcessor.d.ts.map +1 -1
  27. package/dist/parser/processors/ExecutableProcessor.js +14 -1
  28. package/dist/parser/processors/ExecutableProcessor.js.map +1 -1
  29. package/dist/realize/index.d.ts.map +1 -1
  30. package/dist/realize/index.js +30 -3
  31. package/dist/realize/index.js.map +1 -1
  32. package/libs/instance-factories/applications/templates/generic/backend-package-json-generator.ts +46 -24
  33. package/libs/instance-factories/controllers/templates/fastify/routes-generator.ts +80 -21
  34. package/libs/instance-factories/controllers/templates/fastify/server-generator.ts +48 -7
  35. package/libs/instance-factories/services/postgres-native-services.yaml +90 -0
  36. package/libs/instance-factories/services/templates/_shared/step-matching.ts +103 -0
  37. package/libs/instance-factories/services/templates/mongodb-native/controller-generator.ts +97 -23
  38. package/libs/instance-factories/services/templates/mongodb-native/step-conventions.ts +691 -0
  39. package/libs/instance-factories/services/templates/postgres-native/__tests__/controller-generator.test.ts +193 -0
  40. package/libs/instance-factories/services/templates/postgres-native/client-generator.ts +178 -0
  41. package/libs/instance-factories/services/templates/postgres-native/controller-generator.ts +372 -0
  42. package/libs/instance-factories/services/templates/postgres-native/ddl-generator.ts +236 -0
  43. package/libs/instance-factories/services/templates/postgres-native/service-generator.ts +84 -0
  44. package/libs/instance-factories/services/templates/postgres-native/step-conventions.ts +539 -0
  45. package/libs/instance-factories/services/templates/prisma/ai-behaviors-generator.ts +61 -7
  46. package/libs/instance-factories/services/templates/prisma/step-conventions.ts +21 -68
  47. package/package.json +4 -3
@@ -3,45 +3,25 @@
3
3
  *
4
4
  * Each convention maps a natural language step pattern to generated code.
5
5
  * Patterns are tried in order; first match wins. Unmatched steps get stubs.
6
+ *
7
+ * The match-walker + toMethod/toVar identifier helpers live in
8
+ * `../_shared/step-matching.ts` so the same machinery powers
9
+ * `mongodb-native/step-conventions.ts`. This file is now (almost
10
+ * entirely) the prisma-specific conventions array. (#43K-D)
6
11
  */
7
12
 
8
- export interface StepConvention {
9
- name: string;
10
- pattern: RegExp;
11
- generateCall: (match: RegExpMatchArray, ctx: StepContext) => string;
12
- generateMethod?: (match: RegExpMatchArray, ctx: StepContext) => string;
13
- }
14
-
15
- export interface StepContext {
16
- modelName: string;
17
- prismaModel: string;
18
- serviceName: string;
19
- operationName: string;
20
- stepNum: number;
21
- /** Parameter names from the action (e.g., ['pollId', 'optionId']) */
22
- parameterNames?: string[];
23
- /** Variables already declared (to avoid redeclaration) */
24
- declaredVars?: Set<string>;
25
- /** Named result variable (from spec's `as:` clause) */
26
- resultName?: string;
27
- }
13
+ import {
14
+ toMethod,
15
+ toVar,
16
+ matchAgainstConventions,
17
+ type SharedConvention,
18
+ type SharedStepContext,
19
+ } from '../_shared/step-matching.js';
28
20
 
29
- function toVar(name: string): string {
30
- return name.charAt(0).toLowerCase() + name.slice(1);
31
- }
21
+ export type StepConvention = SharedConvention<StepContext>;
32
22
 
33
- function toMethod(words: string): string {
34
- // Split on whitespace AND non-identifier chars (hyphens, commas, equals,
35
- // parens, etc.) so step text like "Compile via expr-eval Parser" yields
36
- // "compileViaExprEvalParser", not "compileViaExpr-evalParser" (which is
37
- // not a valid TypeScript identifier and breaks esbuild downstream).
38
- const cleaned = words.trim().replace(/[^A-Za-z0-9\s]+/g, ' ');
39
- const camel = cleaned.replace(/\s+(.)/g, (_, c) => c.toUpperCase()).replace(/^\w/, c => c.toLowerCase());
40
- // Strip any remaining non-identifier chars (digits at start, etc.) and
41
- // ensure the result is a valid TS identifier. If the input collapses to
42
- // the empty string, fall back to a generic name.
43
- const safe = camel.replace(/[^A-Za-z0-9_$]/g, '');
44
- return safe || 'unnamedStep';
23
+ export interface StepContext extends SharedStepContext {
24
+ prismaModel: string;
45
25
  }
46
26
 
47
27
  /**
@@ -367,37 +347,10 @@ export function matchStep(
367
347
  inputs?: string[];
368
348
  resultVar?: string;
369
349
  } {
370
- for (const convention of STEP_CONVENTIONS) {
371
- const match = step.match(convention.pattern);
372
- if (match) {
373
- return {
374
- call: convention.generateCall(match, ctx),
375
- helperMethod: convention.generateMethod?.(match, ctx),
376
- matched: true,
377
- };
378
- }
379
- }
380
-
381
- // No match — pure AI function call
382
- // Inputs = all variables declared by previous steps + operation parameters
383
- const functionName = toMethod(step);
384
- const declared = Array.from(ctx.declaredVars || []);
385
- const paramNames = ctx.parameterNames || [];
386
- const inputs = [...paramNames, ...declared];
387
-
388
- // Use named result from spec (`as:`) or default to stepNResult
389
- const resultVar = ctx.resultName || `step${ctx.stepNum}Result`;
390
- const inputObj = inputs.length > 0 ? `{ ${inputs.join(', ')} }` : '{}';
391
-
392
- // Register the result variable so subsequent steps can reference it
393
- if (ctx.declaredVars) ctx.declaredVars.add(resultVar);
394
-
395
- return {
396
- call: ` // Step ${ctx.stepNum}: ${step} [AI-generated — pure function]
397
- const ${resultVar} = await aiBehaviors.${functionName}(${inputObj});`,
398
- matched: false,
399
- functionName,
400
- inputs,
401
- resultVar,
402
- };
350
+ // Prisma's AI-fallback uses plain field shorthand `{ a, b, c }` (no
351
+ // `args.X` indirection — the controller-generator destructures params
352
+ // at function entry).
353
+ const aiArgsExpr = (inputs: string[], _paramNames: string[]) =>
354
+ inputs.length > 0 ? `{ ${inputs.join(', ')} }` : '{}';
355
+ return matchAgainstConventions(step, ctx, STEP_CONVENTIONS, aiArgsExpr);
403
356
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@specverse/engines",
3
- "version": "6.7.8",
3
+ "version": "6.16.0",
4
4
  "description": "SpecVerse toolchain — parser, inference, realize, generators, AI, registry, bundles",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -61,8 +61,9 @@
61
61
  "@ai-sdk/anthropic": "^3.0.71",
62
62
  "@ai-sdk/openai-compatible": "^2.0.41",
63
63
  "@ai-sdk/provider": "^3.0.8",
64
- "@specverse/assets": "^1.6.0",
65
- "@specverse/entities": "^5.1.0",
64
+ "@specverse/assets": "^1.10.2",
65
+ "@specverse/engines": "^6.15.0",
66
+ "@specverse/entities": "^5.2.2",
66
67
  "@specverse/runtime": "^5.0.1",
67
68
  "@specverse/types": "^5.1.0",
68
69
  "ai": "^6.0.168",