@metaobjectsdev/codegen-ts 0.23.2 → 0.24.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/generator.d.ts +9 -0
- package/dist/generator.d.ts.map +1 -1
- package/dist/generator.js.map +1 -1
- package/dist/generators/api-field-shape.js +1 -1
- package/dist/generators/api-field-shape.js.map +1 -1
- package/dist/generators/api-model.d.ts.map +1 -1
- package/dist/generators/api-model.js +71 -42
- package/dist/generators/api-model.js.map +1 -1
- package/dist/generators/docs-data-builder.d.ts.map +1 -1
- package/dist/generators/docs-data-builder.js +36 -1
- package/dist/generators/docs-data-builder.js.map +1 -1
- package/dist/generators/docs-data.d.ts +14 -0
- package/dist/generators/docs-data.d.ts.map +1 -1
- package/dist/generators/docs-file.d.ts.map +1 -1
- package/dist/generators/docs-file.js +13 -4
- package/dist/generators/docs-file.js.map +1 -1
- package/dist/generators/extractor-file.d.ts.map +1 -1
- package/dist/generators/extractor-file.js +7 -11
- package/dist/generators/extractor-file.js.map +1 -1
- package/dist/generators/index.d.ts +4 -0
- package/dist/generators/index.d.ts.map +1 -1
- package/dist/generators/index.js +5 -0
- package/dist/generators/index.js.map +1 -1
- package/dist/generators/output-parser-file.d.ts.map +1 -1
- package/dist/generators/output-parser-file.js +12 -7
- package/dist/generators/output-parser-file.js.map +1 -1
- package/dist/generators/output-prompt-file.d.ts.map +1 -1
- package/dist/generators/output-prompt-file.js +14 -24
- package/dist/generators/output-prompt-file.js.map +1 -1
- package/dist/generators/requirement-tests.d.ts +44 -0
- package/dist/generators/requirement-tests.d.ts.map +1 -0
- package/dist/generators/requirement-tests.js +127 -0
- package/dist/generators/requirement-tests.js.map +1 -0
- package/dist/generators/requirements-file.d.ts +9 -0
- package/dist/generators/requirements-file.d.ts.map +1 -0
- package/dist/generators/requirements-file.js +53 -0
- package/dist/generators/requirements-file.js.map +1 -0
- package/dist/generators/requirements-markdown.d.ts +10 -0
- package/dist/generators/requirements-markdown.d.ts.map +1 -0
- package/dist/generators/requirements-markdown.js +71 -0
- package/dist/generators/requirements-markdown.js.map +1 -0
- package/dist/generators/requirements-toon.d.ts +3 -0
- package/dist/generators/requirements-toon.d.ts.map +1 -0
- package/dist/generators/requirements-toon.js +47 -0
- package/dist/generators/requirements-toon.js.map +1 -0
- package/dist/generators/requirements-view.d.ts +32 -0
- package/dist/generators/requirements-view.d.ts.map +1 -0
- package/dist/generators/requirements-view.js +64 -0
- package/dist/generators/requirements-view.js.map +1 -0
- package/dist/generators/trace-helper-file.d.ts.map +1 -1
- package/dist/generators/trace-helper-file.js +19 -11
- package/dist/generators/trace-helper-file.js.map +1 -1
- package/dist/index.d.ts +13 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -1
- package/dist/metaobjects-config.d.ts +12 -20
- package/dist/metaobjects-config.d.ts.map +1 -1
- package/dist/metaobjects-config.js +5 -1
- package/dist/metaobjects-config.js.map +1 -1
- package/dist/orphan-sweep.d.ts +38 -0
- package/dist/orphan-sweep.d.ts.map +1 -0
- package/dist/orphan-sweep.js +129 -0
- package/dist/orphan-sweep.js.map +1 -0
- package/dist/overwrite-policy.d.ts +97 -3
- package/dist/overwrite-policy.d.ts.map +1 -1
- package/dist/overwrite-policy.js +293 -81
- package/dist/overwrite-policy.js.map +1 -1
- package/dist/projection/build-projection-views.d.ts +8 -0
- package/dist/projection/build-projection-views.d.ts.map +1 -1
- package/dist/projection/build-projection-views.js +2 -0
- package/dist/projection/build-projection-views.js.map +1 -1
- package/dist/reconcile-orphans.d.ts +80 -0
- package/dist/reconcile-orphans.d.ts.map +1 -0
- package/dist/reconcile-orphans.js +61 -0
- package/dist/reconcile-orphans.js.map +1 -0
- package/dist/render-engine/embedded-templates.generated.js +1 -1
- package/dist/render-engine/embedded-templates.generated.js.map +1 -1
- package/dist/requirement-walk.d.ts +57 -0
- package/dist/requirement-walk.d.ts.map +1 -0
- package/dist/requirement-walk.js +94 -0
- package/dist/requirement-walk.js.map +1 -0
- package/dist/runner.d.ts +35 -0
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +217 -21
- package/dist/runner.js.map +1 -1
- package/dist/templates/extractor.d.ts +4 -4
- package/dist/templates/extractor.d.ts.map +1 -1
- package/dist/templates/extractor.js +18 -22
- package/dist/templates/extractor.js.map +1 -1
- package/dist/templates/find-inbound.d.ts +44 -0
- package/dist/templates/find-inbound.d.ts.map +1 -0
- package/dist/templates/find-inbound.js +69 -0
- package/dist/templates/find-inbound.js.map +1 -0
- package/dist/templates/output-format-spec-emitter.d.ts.map +1 -1
- package/dist/templates/output-format-spec-emitter.js +7 -4
- package/dist/templates/output-format-spec-emitter.js.map +1 -1
- package/dist/templates/output-parser.d.ts +8 -3
- package/dist/templates/output-parser.d.ts.map +1 -1
- package/dist/templates/output-parser.js +71 -31
- package/dist/templates/output-parser.js.map +1 -1
- package/dist/templates/output-prompt.d.ts +6 -5
- package/dist/templates/output-prompt.d.ts.map +1 -1
- package/dist/templates/output-prompt.js +26 -37
- package/dist/templates/output-prompt.js.map +1 -1
- package/dist/templates/queries.js +1 -1
- package/dist/templates/queries.js.map +1 -1
- package/dist/templates/requirement-test.d.ts +12 -0
- package/dist/templates/requirement-test.d.ts.map +1 -0
- package/dist/templates/requirement-test.js +120 -0
- package/dist/templates/requirement-test.js.map +1 -0
- package/dist/templates/zod-validators.d.ts.map +1 -1
- package/dist/templates/zod-validators.js +32 -15
- package/dist/templates/zod-validators.js.map +1 -1
- package/package.json +7 -6
- package/src/generator.ts +9 -0
- package/src/generators/api-field-shape.ts +1 -1
- package/src/generators/api-model.ts +69 -44
- package/src/generators/docs-data-builder.ts +37 -0
- package/src/generators/docs-data.ts +15 -0
- package/src/generators/docs-file.ts +13 -4
- package/src/generators/extractor-file.ts +7 -11
- package/src/generators/index.ts +11 -0
- package/src/generators/output-parser-file.ts +12 -7
- package/src/generators/output-prompt-file.ts +14 -27
- package/src/generators/requirement-tests.ts +203 -0
- package/src/generators/requirements-file.ts +71 -0
- package/src/generators/requirements-markdown.ts +72 -0
- package/src/generators/requirements-toon.ts +64 -0
- package/src/generators/requirements-view.ts +93 -0
- package/src/generators/trace-helper-file.ts +20 -10
- package/src/index.ts +47 -1
- package/src/metaobjects-config.ts +17 -22
- package/src/orphan-sweep.ts +178 -0
- package/src/overwrite-policy.ts +362 -89
- package/src/projection/build-projection-views.ts +10 -0
- package/src/reconcile-orphans.ts +136 -0
- package/src/reference/barrel.ts +4 -0
- package/src/reference/entity.ts +4 -0
- package/src/reference/queries.ts +4 -0
- package/src/reference/routes.ts +4 -0
- package/src/render-engine/embedded-templates.generated.ts +1 -1
- package/src/requirement-walk.ts +124 -0
- package/src/runner.ts +266 -27
- package/src/templates/extractor.ts +19 -24
- package/src/templates/find-inbound.ts +96 -0
- package/src/templates/output-format-spec-emitter.ts +7 -4
- package/src/templates/output-parser.ts +76 -34
- package/src/templates/output-prompt.ts +29 -42
- package/src/templates/queries.ts +1 -1
- package/src/templates/requirement-test.ts +140 -0
- package/src/templates/zod-validators.ts +32 -15
- package/templates/docs/entity-page.md.mustache +8 -0
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
// byte-identity — the codegen output must match the hand-coded rc.11
|
|
18
18
|
// byte-for-byte. If you're hacking on this and the conformance test
|
|
19
19
|
// breaks, the refactor is the bug, not the fixture.
|
|
20
|
-
import { TYPE_TEMPLATE
|
|
20
|
+
import { TYPE_TEMPLATE } from "@metaobjectsdev/metadata";
|
|
21
21
|
import { render } from "@metaobjectsdev/render";
|
|
22
22
|
import { docPageOutputPath, docPageHref, docPageNode, apiSurfaceHref, assertNoDuplicateDocPaths, } from "../docs-paths.js";
|
|
23
23
|
import { projectProvider } from "../render-engine/framework-provider.js";
|
|
@@ -101,12 +101,21 @@ export const docsFile = function docsFile(opts) {
|
|
|
101
101
|
});
|
|
102
102
|
return { path, content: renderDocPage(TEMPLATE_REF, payload, provider, path) };
|
|
103
103
|
});
|
|
104
|
-
// ALSO emit one NEUTRAL render-contract page per `template
|
|
105
|
-
// a sibling artifact, distinct from the entity page. Raw node name → file
|
|
104
|
+
// ALSO emit one NEUTRAL render-contract page per top-level `template.*` node
|
|
105
|
+
// — a sibling artifact, distinct from the entity page. Raw node name → file
|
|
106
106
|
// (`<name>.md`), agreeing with the entity Used-by back-link target.
|
|
107
|
+
//
|
|
108
|
+
// EVERY template subtype, not just `template.output`: the api-docs surface
|
|
109
|
+
// has always emitted `api/<lang>/<pkg>/<Prompt>.md` for a top-level
|
|
110
|
+
// `template.prompt` (it documents the prompt-render handle), and that page
|
|
111
|
+
// carries a "Model / metadata" back-link to `<pkg>/<Prompt>.md`. While this
|
|
112
|
+
// loop filtered to outputs, that link pointed at a page nothing wrote — a
|
|
113
|
+
// broken link in every shipped doc tree containing a prompt. ADR-0052 makes
|
|
114
|
+
// it worse rather than better: a responding prompt now carries the whole
|
|
115
|
+
// inbound tier, so it is the LAST node a doc tree should omit.
|
|
107
116
|
// ADR-0039: resolving — root has no super (children()==ownChildren()).
|
|
108
117
|
for (const child of ctx.loadedRoot.children()) {
|
|
109
|
-
if (child.type !== TYPE_TEMPLATE
|
|
118
|
+
if (child.type !== TYPE_TEMPLATE)
|
|
110
119
|
continue;
|
|
111
120
|
const node = docPageNode(child);
|
|
112
121
|
templateNodes.push(node);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"docs-file.js","sourceRoot":"","sources":["../../src/generators/docs-file.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,EAAE;AACF,0DAA0D;AAC1D,+DAA+D;AAC/D,0EAA0E;AAC1E,uEAAuE;AACvE,yEAAyE;AACzE,EAAE;AACF,4DAA4D;AAC5D,sEAAsE;AACtE,wEAAwE;AACxE,0EAA0E;AAC1E,8DAA8D;AAC9D,kCAAkC;AAClC,EAAE;AACF,yEAAyE;AACzE,qEAAqE;AACrE,oEAAoE;AACpE,oDAAoD;AAGpD,OAAO,EAAE,aAAa,EAAE,
|
|
1
|
+
{"version":3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AG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACb,KAAK,MAAM,GAAG,IAAI,YAAY,EAAE,CAAC;YAC/B,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,KAAK,KAAK,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC;QAC5C,CAAC;QACD,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACf,CAAC;IAED,4DAA4D;IAC5D,OAAO,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AAC9C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extractor-file.d.ts","sourceRoot":"","sources":["../../src/generators/extractor-file.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"extractor-file.d.ts","sourceRoot":"","sources":["../../src/generators/extractor-file.ts"],"names":[],"mappings":"AAgBA,OAAO,EAGL,KAAK,gBAAgB,EAEtB,MAAM,iBAAiB,CAAC;AAIzB,MAAM,WAAW,aAAa;IAC5B,mFAAmF;IACnF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,0EAA0E;IAC1E,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,SAAS,EA4BjB,gBAAgB,CAAC,aAAa,CAAC,CAAC"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// node whose @format is json/xml. Wraps renderExtractor() from templates/extractor.ts.
|
|
5
5
|
//
|
|
6
6
|
// The emitted extractor sits over the output-parser's nested-capable extract and turns dirty LLM
|
|
7
|
-
// text into the strict typed payload graph. It imports from the sibling <Name>.
|
|
7
|
+
// text into the strict typed payload graph. It imports from the sibling <Name>.response.ts (the
|
|
8
8
|
// output-parser) and from each payload value-object's own entity module (<VO>.ts, emitted by
|
|
9
9
|
// entityFile), so run it alongside outputParser() + entityFile().
|
|
10
10
|
//
|
|
@@ -13,24 +13,20 @@
|
|
|
13
13
|
//
|
|
14
14
|
// Custom output directory:
|
|
15
15
|
// generators: [..., extractor({ outDir: "src/generated/outputs" })]
|
|
16
|
-
import { TYPE_TEMPLATE, TEMPLATE_SUBTYPE_OUTPUT, TEMPLATE_ATTR_FORMAT } from "@metaobjectsdev/metadata";
|
|
17
16
|
import { oncePerRun, } from "../generator.js";
|
|
17
|
+
import { inboundTemplates, responseShape } from "../templates/find-inbound.js";
|
|
18
18
|
import { renderExtractor } from "../templates/extractor.js";
|
|
19
19
|
export const extractor = function extractor(opts) {
|
|
20
20
|
const dirPrefix = opts?.outDir ? `${opts.outDir.replace(/\/$/, "")}/` : "";
|
|
21
21
|
const generator = {
|
|
22
22
|
name: "extractor",
|
|
23
23
|
generate: oncePerRun((_entities, ctx) => {
|
|
24
|
-
// ADR-0039: resolving — root has no super (children()==ownChildren()).
|
|
25
|
-
const outputs = ctx.loadedRoot
|
|
26
|
-
.children()
|
|
27
|
-
.filter((c) => c.type === TYPE_TEMPLATE && c.subType === TEMPLATE_SUBTYPE_OUTPUT);
|
|
28
24
|
const files = [];
|
|
29
|
-
for (const t of
|
|
30
|
-
// The extract tier
|
|
31
|
-
//
|
|
32
|
-
|
|
33
|
-
if (
|
|
25
|
+
for (const t of inboundTemplates(ctx.loadedRoot)) {
|
|
26
|
+
// The extract tier sits over the parser's extract API. Since ADR-0052 every
|
|
27
|
+
// responding prompt emits one (@responseFormat is a closed json|xml set), so
|
|
28
|
+
// the only remaining skip is an unresolvable @responseRef.
|
|
29
|
+
if (!responseShape(ctx.loadedRoot, t))
|
|
34
30
|
continue;
|
|
35
31
|
files.push({
|
|
36
32
|
path: `${dirPrefix}${t.name}.extractor.ts`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extractor-file.js","sourceRoot":"","sources":["../../src/generators/extractor-file.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,EAAE;AACF,+FAA+F;AAC/F,uFAAuF;AACvF,EAAE;AACF,iGAAiG;AACjG,
|
|
1
|
+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AAe,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC,IAAI,EAAE,GAAG,CAAC,aAAa,CAAC;iBACpE,CAAC,CAAC;YACL,CAAC;YACD,OAAO,KAAK,CAAC;QACf,CAAC,CAAC;KACH,CAAC;IACF,IAAI,IAAI,EAAE,MAAM,EAAE,CAAC;QACjB,SAAS,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IACjC,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAoC,CAAC"}
|
|
@@ -25,4 +25,8 @@ export type { EntityDocData, StorageFieldDoc, IdentityDoc, RelationshipDoc, Used
|
|
|
25
25
|
export { buildEntityDocData } from "./docs-data-builder.js";
|
|
26
26
|
export type { TemplateDocData, TemplateOutputPart } from "./template-doc-data.js";
|
|
27
27
|
export { buildTemplateDocData } from "./template-doc-builder.js";
|
|
28
|
+
export { requirementTests } from "./requirement-tests.js";
|
|
29
|
+
export { requirementsFile } from "./requirements-file.js";
|
|
30
|
+
export type { RequirementRow } from "./requirements-view.js";
|
|
31
|
+
export type { RequirementTestsOpts, RequirementTestRenderer, } from "./requirement-tests.js";
|
|
28
32
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/generators/index.ts"],"names":[],"mappings":"AAOA,yIAAyI;AACzI,OAAO,EAAE,UAAU,EAAE,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACnE,2IAA2I;AAC3I,OAAO,EAAE,WAAW,EAAE,KAAK,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,KAAK,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACzE,yIAAyI;AACzI,OAAO,EAAE,UAAU,EAAE,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,KAAK,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAChF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K,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC/E,YAAY,EACV,aAAa,EACb,eAAe,EACf,WAAW,EACX,eAAe,EACf,SAAS,EACT,aAAa,GACd,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,YAAY,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAClF,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAKjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,YAAY,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,YAAY,EACV,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,wBAAwB,CAAC"}
|
package/dist/generators/index.js
CHANGED
|
@@ -29,4 +29,9 @@ export { templateGenerator, } from "./template-generator.js";
|
|
|
29
29
|
export { traceHelperFile } from "./trace-helper-file.js";
|
|
30
30
|
export { buildEntityDocData } from "./docs-data-builder.js";
|
|
31
31
|
export { buildTemplateDocData } from "./template-doc-builder.js";
|
|
32
|
+
// FR-038 — requirement-derived test stubs. The factory is a convenience; the
|
|
33
|
+
// primitives beside it are the real escape hatch, so an app needing different
|
|
34
|
+
// behaviour composes its own generator instead of filing an issue here.
|
|
35
|
+
export { requirementTests } from "./requirement-tests.js";
|
|
36
|
+
export { requirementsFile } from "./requirements-file.js";
|
|
32
37
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/generators/index.ts"],"names":[],"mappings":"AAAA,qFAAqF;AACrF,sFAAsF;AACtF,sFAAsF;AACtF,iFAAiF;AACjF,mFAAmF;AACnF,sFAAsF;AAEtF,yIAAyI;AACzI,OAAO,EAAE,UAAU,EAAuB,MAAM,kBAAkB,CAAC;AACnE,2IAA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
+
{"version":3,"file":"output-parser-file.d.ts","sourceRoot":"","sources":["../../src/generators/output-parser-file.ts"],"names":[],"mappings":"AAkBA,OAAO,EAGL,KAAK,gBAAgB,EAEtB,MAAM,iBAAiB,CAAC;AAGzB,MAAM,WAAW,gBAAgB;IAC/B,mFAAmF;IACnF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,0EAA0E;IAC1E,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,YAAY,EAyBpB,gBAAgB,CAAC,gBAAgB,CAAC,CAAC"}
|
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
// server/typescript/packages/codegen-ts/src/generators/output-parser-file.ts
|
|
2
2
|
//
|
|
3
|
-
// Stock generator that emits one <
|
|
4
|
-
// template.
|
|
3
|
+
// Stock generator that emits one <PromptName>.response.ts file per declared
|
|
4
|
+
// `template.prompt` carrying `@responseRef`. Wraps renderOutputParser() from
|
|
5
|
+
// templates/output-parser.ts.
|
|
6
|
+
//
|
|
7
|
+
// ADR-0052: this tier is INBOUND — it reads a model's reply. It used to key on
|
|
8
|
+
// `template.output` with no `@kind` filter at all, so an email template generated
|
|
9
|
+
// a parser for text the system had just rendered. `template.output` is outbound
|
|
10
|
+
// only and emits nothing here.
|
|
5
11
|
//
|
|
6
12
|
// Consumer wiring (metaobjects.config.ts):
|
|
7
13
|
// generators: [..., promptRender(), outputParser()]
|
|
8
14
|
//
|
|
9
15
|
// Custom output directory:
|
|
10
16
|
// generators: [..., outputParser({ outDir: "src/generated/outputs" })]
|
|
11
|
-
import {
|
|
12
|
-
import { findTemplates } from "../templates/find-templates.js";
|
|
17
|
+
import { inboundTemplates } from "../templates/find-inbound.js";
|
|
13
18
|
import { oncePerRun, } from "../generator.js";
|
|
14
19
|
import { renderOutputParser } from "../templates/output-parser.js";
|
|
15
20
|
export const outputParser = function outputParser(opts) {
|
|
@@ -17,11 +22,11 @@ export const outputParser = function outputParser(opts) {
|
|
|
17
22
|
const generator = {
|
|
18
23
|
name: "output-parser",
|
|
19
24
|
generate: oncePerRun((_entities, ctx) => {
|
|
20
|
-
const
|
|
25
|
+
const responders = inboundTemplates(ctx.loadedRoot);
|
|
21
26
|
const files = [];
|
|
22
|
-
for (const t of
|
|
27
|
+
for (const t of responders) {
|
|
23
28
|
files.push({
|
|
24
|
-
path: `${dirPrefix}${t.name}.
|
|
29
|
+
path: `${dirPrefix}${t.name}.response.ts`,
|
|
25
30
|
// ADR-0044/#228: thread ctx.renderContext (when present — runGen always supplies it;
|
|
26
31
|
// a hand-rolled GenContext in a unit test may omit it, falling back to bare naming) so
|
|
27
32
|
// a payload/nested value-object whose bare name collides across packages emits the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output-parser-file.js","sourceRoot":"","sources":["../../src/generators/output-parser-file.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,EAAE;AACF,4EAA4E;AAC5E,
|
|
1
|
+
{"version":3,"file":"output-parser-file.js","sourceRoot":"","sources":["../../src/generators/output-parser-file.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,EAAE;AACF,4EAA4E;AAC5E,6EAA6E;AAC7E,8BAA8B;AAC9B,EAAE;AACF,+EAA+E;AAC/E,kFAAkF;AAClF,gFAAgF;AAChF,+BAA+B;AAC/B,EAAE;AACF,2CAA2C;AAC3C,sDAAsD;AACtD,EAAE;AACF,2BAA2B;AAC3B,yEAAyE;AAEzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAIL,UAAU,GACX,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AASnE,MAAM,CAAC,MAAM,YAAY,GAAG,SAAS,YAAY,CAAC,IAAuB;IACvE,MAAM,SAAS,GAAG,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IAC3E,MAAM,SAAS,GAAc;QAC3B,IAAI,EAAE,eAAe;QACrB,QAAQ,EAAE,UAAU,CAAC,CAAC,SAAS,EAAE,GAAG,EAAE,EAAE;YACtC,MAAM,UAAU,GAAG,gBAAgB,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;YACpD,MAAM,KAAK,GAAkB,EAAE,CAAC;YAChC,KAAK,MAAM,CAAC,IAAI,UAAU,EAAE,CAAC;gBAC3B,KAAK,CAAC,IAAI,CAAC;oBACT,IAAI,EAAE,GAAG,SAAS,GAAG,CAAC,CAAC,IAAI,cAAc;oBACzC,qFAAqF;oBACrF,uFAAuF;oBACvF,mFAAmF;oBACnF,iFAAiF;oBACjF,yCAAyC;oBACzC,OAAO,EAAE,kBAAkB,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC,IAAI,EAAE,GAAG,CAAC,aAAa,CAAC;iBACvE,CAAC,CAAC;YACL,CAAC;YACD,OAAO,KAAK,CAAC;QACf,CAAC,CAAC;KACH,CAAC;IACF,IAAI,IAAI,EAAE,MAAM,EAAE,CAAC;QACjB,SAAS,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IACjC,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAuC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output-prompt-file.d.ts","sourceRoot":"","sources":["../../src/generators/output-prompt-file.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"output-prompt-file.d.ts","sourceRoot":"","sources":["../../src/generators/output-prompt-file.ts"],"names":[],"mappings":"AAiBA,OAAO,EAGL,KAAK,gBAAgB,EAEtB,MAAM,iBAAiB,CAAC;AAIzB,MAAM,WAAW,gBAAgB;IAC/B,mFAAmF;IACnF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,0EAA0E;IAC1E,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,YAAY,EAsBpB,gBAAgB,CAAC,gBAAgB,CAAC,CAAC"}
|
|
@@ -1,45 +1,35 @@
|
|
|
1
1
|
// server/typescript/packages/codegen-ts/src/generators/output-prompt-file.ts
|
|
2
2
|
//
|
|
3
|
-
// FR-010 stock generator that emits one <
|
|
4
|
-
// template.
|
|
5
|
-
// like this"). Wraps renderOutputPrompt() from templates/output-prompt.ts.
|
|
6
|
-
//
|
|
7
|
-
//
|
|
3
|
+
// FR-010 stock generator that emits one <PromptName>.responseFormat.ts file per
|
|
4
|
+
// responding `template.prompt` — the response-format fragment ("produce your answer
|
|
5
|
+
// like this"). Wraps renderOutputPrompt() from templates/output-prompt.ts.
|
|
6
|
+
//
|
|
7
|
+
// ADR-0052: gated on `@responseRef` presence, like every other inbound generator.
|
|
8
|
+
// It previously keyed on `template.output` + a json/xml `@format` gate, which is
|
|
9
|
+
// how a fragment that instructs an LLM came to be emitted from the subtype defined
|
|
10
|
+
// as "every rendered artifact other than an LLM prompt".
|
|
8
11
|
//
|
|
9
12
|
// Consumer wiring (metaobjects.config.ts):
|
|
10
13
|
// generators: [..., promptRender(), outputParser(), outputPrompt()]
|
|
11
14
|
//
|
|
12
15
|
// Custom output directory:
|
|
13
16
|
// generators: [..., outputPrompt({ outDir: "src/generated/outputs" })]
|
|
14
|
-
import { TYPE_TEMPLATE, TEMPLATE_SUBTYPE_OUTPUT, TEMPLATE_ATTR_PAYLOAD_REF, resolveObjectRef, } from "@metaobjectsdev/metadata";
|
|
15
17
|
import { oncePerRun, } from "../generator.js";
|
|
16
|
-
import {
|
|
18
|
+
import { inboundTemplates, responseShape } from "../templates/find-inbound.js";
|
|
19
|
+
import { renderOutputPrompt } from "../templates/output-prompt.js";
|
|
17
20
|
export const outputPrompt = function outputPrompt(opts) {
|
|
18
21
|
const dirPrefix = opts?.outDir ? `${opts.outDir.replace(/\/$/, "")}/` : "";
|
|
19
22
|
const generator = {
|
|
20
23
|
name: "output-prompt",
|
|
21
24
|
generate: oncePerRun((_entities, ctx) => {
|
|
22
25
|
const root = ctx.loadedRoot;
|
|
23
|
-
// ADR-0039: resolving — root has no super (children()==ownChildren()).
|
|
24
|
-
const outputs = root
|
|
25
|
-
.children()
|
|
26
|
-
.filter((c) => c.type === TYPE_TEMPLATE && c.subType === TEMPLATE_SUBTYPE_OUTPUT);
|
|
27
26
|
const files = [];
|
|
28
|
-
for (const t of
|
|
29
|
-
//
|
|
30
|
-
if (!
|
|
31
|
-
continue;
|
|
32
|
-
// @payloadRef must resolve to a value-object (same contract as the parser).
|
|
33
|
-
// ADR-0039: resolving — a template may inherit its @* refs/format/kind via extends.
|
|
34
|
-
const payloadRef = t.attr(TEMPLATE_ATTR_PAYLOAD_REF);
|
|
35
|
-
if (typeof payloadRef !== "string")
|
|
36
|
-
continue;
|
|
37
|
-
// ADR-0042: a bare @payloadRef resolves in the template's package.
|
|
38
|
-
const vo = resolveObjectRef(root, payloadRef, t.package ?? t.fileDefaultPackage ?? "").node;
|
|
39
|
-
if (!vo)
|
|
27
|
+
for (const t of inboundTemplates(root)) {
|
|
28
|
+
// @responseRef must resolve to a value-object (same contract as the parser).
|
|
29
|
+
if (!responseShape(root, t))
|
|
40
30
|
continue;
|
|
41
31
|
files.push({
|
|
42
|
-
path: `${dirPrefix}${t.name}.
|
|
32
|
+
path: `${dirPrefix}${t.name}.responseFormat.ts`,
|
|
43
33
|
content: renderOutputPrompt(root, t.name),
|
|
44
34
|
});
|
|
45
35
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output-prompt-file.js","sourceRoot":"","sources":["../../src/generators/output-prompt-file.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,EAAE;AACF,
|
|
1
|
+
{"version":3,"file":"output-prompt-file.js","sourceRoot":"","sources":["../../src/generators/output-prompt-file.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,EAAE;AACF,gFAAgF;AAChF,oFAAoF;AACpF,2EAA2E;AAC3E,EAAE;AACF,kFAAkF;AAClF,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AO,SAAS,CAAC;AACnB,CAAuC,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { Generator } from "../generator.js";
|
|
2
|
+
import { type RequirementView } from "../requirement-walk.js";
|
|
3
|
+
import { type RequirementTestArgs } from "../templates/requirement-test.js";
|
|
4
|
+
export type RequirementTestRenderer = (a: RequirementTestArgs) => string;
|
|
5
|
+
export interface RequirementTestsOpts {
|
|
6
|
+
/** Generator name — surfaces in diagnostics and drift logs. */
|
|
7
|
+
name?: string;
|
|
8
|
+
/** WHICH requirements get stubs. This is the app's policy declaration. */
|
|
9
|
+
filter?: (r: RequirementView) => boolean;
|
|
10
|
+
/** Renderer per concern key: exact `type.subType`, `type.*`, or `*`. */
|
|
11
|
+
renderers?: Record<string, RequirementTestRenderer>;
|
|
12
|
+
/** Full control over renderer selection — beats `renderers` when it returns one. */
|
|
13
|
+
resolveRenderer?: (concern: string) => RequirementTestRenderer | undefined;
|
|
14
|
+
/** Where each stub lands. */
|
|
15
|
+
path?: (view: RequirementView, concern: string) => string;
|
|
16
|
+
/** Named output target (registry key). */
|
|
17
|
+
target?: string;
|
|
18
|
+
/** Name requirements no filter covered. Default true; never fails the build. */
|
|
19
|
+
warnUncovered?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* FR-038 §8 — which emitted paths this generator is the sole producer of, so
|
|
22
|
+
* the runner may remove a stub whose requirement was deleted. Given a path
|
|
23
|
+
* relative to this generator's output directory, `/`-separated.
|
|
24
|
+
*
|
|
25
|
+
* Defaults to the namespace `defaultPath` writes into. Supply this whenever you
|
|
26
|
+
* supply `path`: the two describe the same namespace from opposite directions
|
|
27
|
+
* and only you can keep them in agreement.
|
|
28
|
+
*/
|
|
29
|
+
owns?: (relPathInTarget: string) => boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Delete a hand-edited orphan rather than refusing it. Default false.
|
|
32
|
+
*
|
|
33
|
+
* A refusal already names the file and tells you the two ways out; this makes
|
|
34
|
+
* the destructive one automatic. It exists so the decision is yours, not
|
|
35
|
+
* because it is a good default.
|
|
36
|
+
*/
|
|
37
|
+
forceOrphanDelete?: boolean;
|
|
38
|
+
/** Turn orphan reconciliation off entirely. Default true — a stub whose
|
|
39
|
+
* requirement is gone is drift, and leaving it is how a deleted claim keeps a
|
|
40
|
+
* green test. */
|
|
41
|
+
reconcileOrphans?: boolean;
|
|
42
|
+
}
|
|
43
|
+
export declare function requirementTests(opts?: RequirementTestsOpts): Generator;
|
|
44
|
+
//# sourceMappingURL=requirement-tests.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requirement-tests.d.ts","sourceRoot":"","sources":["../../src/generators/requirement-tests.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,SAAS,EAA2B,MAAM,iBAAiB,CAAC;AAC1E,OAAO,EAIL,KAAK,eAAe,EACrB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAEL,KAAK,mBAAmB,EACzB,MAAM,kCAAkC,CAAC;AAE1C,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,EAAE,mBAAmB,KAAK,MAAM,CAAC;AAEzE,MAAM,WAAW,oBAAoB;IACnC,+DAA+D;IAC/D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,0EAA0E;IAC1E,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,eAAe,KAAK,OAAO,CAAC;IACzC,wEAAwE;IACxE,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,uBAAuB,CAAC,CAAC;IACpD,oFAAoF;IACpF,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,uBAAuB,GAAG,SAAS,CAAC;IAC3E,6BAA6B;IAC7B,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,KAAK,MAAM,CAAC;IAC1D,0CAA0C;IAC1C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gFAAgF;IAChF,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;;;;;;OAQG;IACH,IAAI,CAAC,EAAE,CAAC,eAAe,EAAE,MAAM,KAAK,OAAO,CAAC;IAC5C;;;;;;OAMG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;sBAEkB;IAClB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AA4CD,wBAAgB,gBAAgB,CAAC,IAAI,GAAE,oBAAyB,GAAG,SAAS,CAoF3E"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
// FR-038 §5/§6 — generate test stubs from `requirement.*` nodes.
|
|
2
|
+
//
|
|
3
|
+
// THE DIVISION OF LABOUR: this package owns the MECHANISM; the application owns
|
|
4
|
+
// the POLICY. Which requirements get tests, at which levels, in what style, or
|
|
5
|
+
// none at all, is the app's decision — the library ships defaults and
|
|
6
|
+
// recommendations, never rules.
|
|
7
|
+
//
|
|
8
|
+
// The filter IS the policy declaration, which is why there is no opt-out
|
|
9
|
+
// vocabulary: a requirement matched by no generator expects no stub by
|
|
10
|
+
// construction, so `verify --codegen` has nothing to drift against. An `@noTest`
|
|
11
|
+
// attribute would have to clear ADR-0023's can't-be-computed bar, and it cannot —
|
|
12
|
+
// the generator config already says it.
|
|
13
|
+
//
|
|
14
|
+
// Every default below has an override seam. The rule: if an application can hit a
|
|
15
|
+
// decision and cannot change it, that decision becomes a bug report against this
|
|
16
|
+
// package.
|
|
17
|
+
import { REQUIREMENT_SUBTYPE_FUNCTIONAL, REQUIREMENT_LINK_FLOOR_LEVEL, REQUIREMENT_ATTR_STATEMENT, REQUIREMENT_ATTR_COUNTEREXAMPLE, } from "@metaobjectsdev/metadata";
|
|
18
|
+
import { walkRequirements, groupByConcern, NO_CONCERN, } from "../requirement-walk.js";
|
|
19
|
+
import { renderRequirementTest, } from "../templates/requirement-test.js";
|
|
20
|
+
/** How many uncovered requirements to name before "…and N more". Mirrors the
|
|
21
|
+
* runner's MAX_NAMED — the same cutoff, so every wall-avoiding message in the
|
|
22
|
+
* feature reads the same shape. */
|
|
23
|
+
const MAX_NAMED_UNCOVERED = 5;
|
|
24
|
+
/** The directory `defaultPath` writes into — and therefore the namespace the
|
|
25
|
+
* default policy claims. Kept beside it so the pair cannot drift. */
|
|
26
|
+
const DEFAULT_STUB_DIR = "requirements/";
|
|
27
|
+
/**
|
|
28
|
+
* RECOMMENDATION, not a rule: functional requirements at or below the link floor.
|
|
29
|
+
*
|
|
30
|
+
* Architectural requirements are excluded by default because `verify`'s
|
|
31
|
+
* universality check already proves them structurally, so a test there is usually
|
|
32
|
+
* redundant — usually, not never, which is exactly why this is overridable.
|
|
33
|
+
*/
|
|
34
|
+
const defaultFilter = (r) => r.subType === REQUIREMENT_SUBTYPE_FUNCTIONAL &&
|
|
35
|
+
(r.level ?? 0) >= REQUIREMENT_LINK_FLOOR_LEVEL;
|
|
36
|
+
const defaultPath = (view, concern) => concern === NO_CONCERN
|
|
37
|
+
? `${DEFAULT_STUB_DIR}${view.path}.test.ts`
|
|
38
|
+
: `${DEFAULT_STUB_DIR}${view.path}.${concern}.test.ts`;
|
|
39
|
+
/** Exact concern → `type.*` → `*` → the built-in renderer. */
|
|
40
|
+
function pickRenderer(concern, opts) {
|
|
41
|
+
const viaFn = opts.resolveRenderer?.(concern);
|
|
42
|
+
if (viaFn !== undefined)
|
|
43
|
+
return viaFn;
|
|
44
|
+
const map = opts.renderers ?? {};
|
|
45
|
+
const typeOnly = `${concern.split(".")[0] ?? ""}.*`;
|
|
46
|
+
return map[concern] ?? map[typeOnly] ?? map[NO_CONCERN] ?? renderRequirementTest;
|
|
47
|
+
}
|
|
48
|
+
function attrString(node, name) {
|
|
49
|
+
const v = node.attr(name);
|
|
50
|
+
return typeof v === "string" ? v : "";
|
|
51
|
+
}
|
|
52
|
+
export function requirementTests(opts = {}) {
|
|
53
|
+
const filter = opts.filter ?? defaultFilter;
|
|
54
|
+
const toPath = opts.path ?? defaultPath;
|
|
55
|
+
// A custom `path` with no custom `owns` leaves the default namespace pointing
|
|
56
|
+
// somewhere the generator no longer writes, so reconciliation matches nothing.
|
|
57
|
+
// That degrades safely — it can only ever delete less — but silently, and a
|
|
58
|
+
// policy nobody can tell isn't running is the failure mode §5 is about.
|
|
59
|
+
const namespaceUnknown = opts.path !== undefined && opts.owns === undefined;
|
|
60
|
+
const generator = {
|
|
61
|
+
name: opts.name ?? "requirement-tests",
|
|
62
|
+
generate: (ctx) => {
|
|
63
|
+
const files = [];
|
|
64
|
+
const uncovered = [];
|
|
65
|
+
if (namespaceUnknown && opts.reconcileOrphans !== false) {
|
|
66
|
+
ctx.warn(`a custom 'path' was supplied without a matching 'owns', so a stub left ` +
|
|
67
|
+
`behind by a deleted requirement will NOT be cleaned up. Supply 'owns' ` +
|
|
68
|
+
`to describe where 'path' writes, or set reconcileOrphans: false.`);
|
|
69
|
+
}
|
|
70
|
+
for (const walked of walkRequirements(ctx.loadedRoot)) {
|
|
71
|
+
if (!filter(walked.view)) {
|
|
72
|
+
uncovered.push(walked.view.path);
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
for (const [concern, targets] of groupByConcern(walked)) {
|
|
76
|
+
const args = {
|
|
77
|
+
view: walked.view,
|
|
78
|
+
concern,
|
|
79
|
+
targets,
|
|
80
|
+
statement: attrString(walked.node, REQUIREMENT_ATTR_STATEMENT),
|
|
81
|
+
counterexample: attrString(walked.node, REQUIREMENT_ATTR_COUNTEREXAMPLE),
|
|
82
|
+
disposition: walked.node.disposition(),
|
|
83
|
+
trackedBy: walked.node.trackedBy(),
|
|
84
|
+
};
|
|
85
|
+
files.push({
|
|
86
|
+
path: toPath(walked.view, concern),
|
|
87
|
+
content: pickRenderer(concern, opts)(args),
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
// Policy living only in config means an uncovered requirement is
|
|
92
|
+
// indistinguishable from a deliberate exclusion. One warning, never failing,
|
|
93
|
+
// so "no tests here" is a visible choice rather than silence.
|
|
94
|
+
if ((opts.warnUncovered ?? true) && uncovered.length > 0) {
|
|
95
|
+
// CAPPED, matching the runner's refusal message. The default filter excludes
|
|
96
|
+
// every architectural node and every L1-L3 functional one, so on the ledger
|
|
97
|
+
// shapes this repo's own docs describe — dozens to hundreds of entries — an
|
|
98
|
+
// uncapped list is a wall of dotted paths with the one actionable sentence
|
|
99
|
+
// buried at the end of it. This is a generator meant to be the feature's first
|
|
100
|
+
// contact; burying the opt-out is how it gets switched off wholesale.
|
|
101
|
+
const shown = uncovered.slice(0, MAX_NAMED_UNCOVERED).join(", ");
|
|
102
|
+
const more = uncovered.length > MAX_NAMED_UNCOVERED
|
|
103
|
+
? `, and ${uncovered.length - MAX_NAMED_UNCOVERED} more`
|
|
104
|
+
: "";
|
|
105
|
+
ctx.warn(`${uncovered.length} requirement(s) matched no filter and get no stub. ` +
|
|
106
|
+
`If that is deliberate, set warnUncovered: false to silence this. ` +
|
|
107
|
+
`Uncovered: ${shown}${more}.`);
|
|
108
|
+
}
|
|
109
|
+
return files;
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
if (opts.target !== undefined)
|
|
113
|
+
generator.target = opts.target;
|
|
114
|
+
if (opts.reconcileOrphans !== false) {
|
|
115
|
+
generator.orphanPolicy = {
|
|
116
|
+
// With a custom `path` and no `owns`, claim NOTHING rather than guess: the
|
|
117
|
+
// default namespace would be a claim over a directory this generator does
|
|
118
|
+
// not write to, and a wrong claim deletes another generator's files.
|
|
119
|
+
owns: opts.owns ?? (namespaceUnknown
|
|
120
|
+
? () => false
|
|
121
|
+
: (relPath) => relPath.startsWith(DEFAULT_STUB_DIR)),
|
|
122
|
+
...(opts.forceOrphanDelete === true && { force: true }),
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
return generator;
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=requirement-tests.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requirement-tests.js","sourceRoot":"","sources":["../../src/generators/requirement-tests.ts"],"names":[],"mappings":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AS,CAAC,MAAM,GAAG,mBAAmB,OAAO;oBACxD,CAAC,CAAC,EAAE,CAAC;gBACT,GAAG,CAAC,IAAI,CACN,GAAG,SAAS,CAAC,MAAM,qDAAqD;oBACtE,mEAAmE;oBACnE,cAAc,KAAK,GAAG,IAAI,GAAG,CAChC,CAAC;YACJ,CAAC;YAED,OAAO,KAAK,CAAC;QACf,CAAC;KACF,CAAC;IAEF,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS;QAAE,SAAS,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IAC9D,IAAI,IAAI,CAAC,gBAAgB,KAAK,KAAK,EAAE,CAAC;QACpC,SAAS,CAAC,YAAY,GAAG;YACvB,2EAA2E;YAC3E,0EAA0E;YAC1E,qEAAqE;YACrE,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,CAAC,gBAAgB;gBAClC,CAAC,CAAC,GAAG,EAAE,CAAC,KAAK;gBACb,CAAC,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC;YACtD,GAAG,CAAC,IAAI,CAAC,iBAAiB,KAAK,IAAI,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;SACxD,CAAC;IACJ,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type GeneratorFactory } from "../generator.js";
|
|
2
|
+
export interface RequirementsFileOpts {
|
|
3
|
+
/** Output directory prefix relative to the target's outDir. Default: "" (root). */
|
|
4
|
+
outDir?: string;
|
|
5
|
+
/** Optional named output target (registry key). Defaults to "default". */
|
|
6
|
+
target?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const requirementsFile: GeneratorFactory<RequirementsFileOpts>;
|
|
9
|
+
//# sourceMappingURL=requirements-file.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requirements-file.d.ts","sourceRoot":"","sources":["../../src/generators/requirements-file.ts"],"names":[],"mappings":"AAsBA,OAAO,EAGL,KAAK,gBAAgB,EAEtB,MAAM,iBAAiB,CAAC;AAUzB,MAAM,WAAW,oBAAoB;IACnC,mFAAmF;IACnF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,0EAA0E;IAC1E,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,gBAAgB,EA0BxB,gBAAgB,CAAC,oBAAoB,CAAC,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// server/typescript/packages/codegen-ts/src/generators/requirements-file.ts
|
|
2
|
+
//
|
|
3
|
+
// The `requirements` docs surface generator — emits the ledger as documentation.
|
|
4
|
+
//
|
|
5
|
+
// Design: docs/superpowers/specs/2026-08-21-requirements-doc-surface-design.md
|
|
6
|
+
//
|
|
7
|
+
// METADATA ALONE. `meta docs` guarantees output "from metadata ALONE — no gen config, no
|
|
8
|
+
// codegen pipeline" (cli/src/commands/docs.ts). This generator reads `ctx.loadedRoot` and
|
|
9
|
+
// NOTHING else — no filesystem walk, no config read, no test-source scan. That sentence
|
|
10
|
+
// is what rules out reviving the retired `@verifiedBy` scan here, and it only keeps being
|
|
11
|
+
// true if nobody adds a second input.
|
|
12
|
+
//
|
|
13
|
+
// AN EMPTY LEDGER EMITS ZERO FILES, not an empty page. That is a contract with the
|
|
14
|
+
// surface wiring, not a cosmetic choice: `requirements` defaults to ON, and this is the
|
|
15
|
+
// only reason that is a no-op for every project without a ledger.
|
|
16
|
+
//
|
|
17
|
+
// BOTH FILES, UNCONDITIONALLY — deliberately not behind a `--format` flag. `meta docs`
|
|
18
|
+
// writes FILES, while `--format` on gen/migrate selects a STDOUT encoding; reusing the
|
|
19
|
+
// name would make it mean something materially different on this command. A drift gate
|
|
20
|
+
// also wants the machine-readable artifact committed regardless of who ran it or from
|
|
21
|
+
// what kind of terminal.
|
|
22
|
+
import { oncePerRun, } from "../generator.js";
|
|
23
|
+
import { renderRequirementsMarkdown } from "./requirements-markdown.js";
|
|
24
|
+
import { renderRequirementsToon } from "./requirements-toon.js";
|
|
25
|
+
import { requirementRows } from "./requirements-view.js";
|
|
26
|
+
/** The human-facing index. */
|
|
27
|
+
const MARKDOWN_FILENAME = "requirements.md";
|
|
28
|
+
/** The machine-facing artifact — see requirements-toon.ts for why TOON. */
|
|
29
|
+
const TOON_FILENAME = "requirements.toon";
|
|
30
|
+
export const requirementsFile = function requirementsFile(opts) {
|
|
31
|
+
const dirPrefix = opts?.outDir ? `${opts.outDir.replace(/\/$/, "")}/` : "";
|
|
32
|
+
const generator = {
|
|
33
|
+
name: "requirements-file",
|
|
34
|
+
generate: oncePerRun((_entities, ctx) => {
|
|
35
|
+
const rows = requirementRows(ctx.loadedRoot);
|
|
36
|
+
// The one early return that matters. Both renderers also return "" for an empty
|
|
37
|
+
// ledger, so this is belt-and-braces — but the guarantee callers depend on is
|
|
38
|
+
// "zero FILES", which only this line can provide.
|
|
39
|
+
if (rows.length === 0)
|
|
40
|
+
return [];
|
|
41
|
+
const files = [
|
|
42
|
+
{ path: `${dirPrefix}${MARKDOWN_FILENAME}`, content: renderRequirementsMarkdown(rows) },
|
|
43
|
+
{ path: `${dirPrefix}${TOON_FILENAME}`, content: renderRequirementsToon(rows) },
|
|
44
|
+
];
|
|
45
|
+
return files;
|
|
46
|
+
}),
|
|
47
|
+
};
|
|
48
|
+
if (opts?.target) {
|
|
49
|
+
generator.target = opts.target;
|
|
50
|
+
}
|
|
51
|
+
return generator;
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=requirements-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requirements-file.js","sourceRoot":"","sources":["../../src/generators/requirements-file.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,EAAE;AACF,iFAAiF;AACjF,EAAE;AACF,+EAA+E;AAC/E,EAAE;AACF,yFAAyF;AACzF,0FAA0F;AAC1F,wFAAwF;AACxF,0FAA0F;AAC1F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,EAAE;aAChF,CAAC;YACF,OAAO,KAAK,CAAC;QACf,CAAC,CAAC;KACH,CAAC;IAEF,IAAI,IAAI,EAAE,MAAM,EAAE,CAAC;QACjB,SAAS,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IACjC,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAA2C,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { RequirementRow } from "./requirements-view.js";
|
|
2
|
+
/**
|
|
3
|
+
* Render the ledger as one markdown index.
|
|
4
|
+
*
|
|
5
|
+
* Returns the EMPTY STRING for an empty ledger rather than a headed-but-empty page.
|
|
6
|
+
* The generator keys on that to emit no file at all, which is in turn what lets the
|
|
7
|
+
* surface default to on without changing output for any project lacking a ledger.
|
|
8
|
+
*/
|
|
9
|
+
export declare function renderRequirementsMarkdown(rows: readonly RequirementRow[]): string;
|
|
10
|
+
//# sourceMappingURL=requirements-markdown.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requirements-markdown.d.ts","sourceRoot":"","sources":["../../src/generators/requirements-markdown.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAmC7D;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,SAAS,cAAc,EAAE,GAAG,MAAM,CAUlF"}
|