@metaobjectsdev/render 0.7.0-rc.9 → 0.8.0-rc.1

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 (72) hide show
  1. package/dist/index.d.ts +8 -0
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +8 -0
  4. package/dist/index.js.map +1 -1
  5. package/dist/prompt/output-format-renderer.d.ts +8 -0
  6. package/dist/prompt/output-format-renderer.d.ts.map +1 -0
  7. package/dist/prompt/output-format-renderer.js +164 -0
  8. package/dist/prompt/output-format-renderer.js.map +1 -0
  9. package/dist/prompt/output-format-spec.d.ts +18 -0
  10. package/dist/prompt/output-format-spec.d.ts.map +1 -0
  11. package/dist/prompt/output-format-spec.js +3 -0
  12. package/dist/prompt/output-format-spec.js.map +1 -0
  13. package/dist/prompt/prompt-field.d.ts +22 -0
  14. package/dist/prompt/prompt-field.d.ts.map +1 -0
  15. package/dist/prompt/prompt-field.js +3 -0
  16. package/dist/prompt/prompt-field.js.map +1 -0
  17. package/dist/prompt/prompt-overrides.d.ts +16 -0
  18. package/dist/prompt/prompt-overrides.d.ts.map +1 -0
  19. package/dist/prompt/prompt-overrides.js +13 -0
  20. package/dist/prompt/prompt-overrides.js.map +1 -0
  21. package/dist/prompt/prompt-style.d.ts +17 -0
  22. package/dist/prompt/prompt-style.d.ts.map +1 -0
  23. package/dist/prompt/prompt-style.js +34 -0
  24. package/dist/prompt/prompt-style.js.map +1 -0
  25. package/dist/recover/coerce.d.ts +5 -0
  26. package/dist/recover/coerce.d.ts.map +1 -0
  27. package/dist/recover/coerce.js +124 -0
  28. package/dist/recover/coerce.js.map +1 -0
  29. package/dist/recover/json-forgiving-reader.d.ts +5 -0
  30. package/dist/recover/json-forgiving-reader.d.ts.map +1 -0
  31. package/dist/recover/json-forgiving-reader.js +178 -0
  32. package/dist/recover/json-forgiving-reader.js.map +1 -0
  33. package/dist/recover/locate.d.ts +5 -0
  34. package/dist/recover/locate.d.ts.map +1 -0
  35. package/dist/recover/locate.js +75 -0
  36. package/dist/recover/locate.js.map +1 -0
  37. package/dist/recover/recover-map.d.ts +7 -0
  38. package/dist/recover/recover-map.d.ts.map +1 -0
  39. package/dist/recover/recover-map.js +36 -0
  40. package/dist/recover/recover-map.js.map +1 -0
  41. package/dist/recover/recover.d.ts +4 -0
  42. package/dist/recover/recover.d.ts.map +1 -0
  43. package/dist/recover/recover.js +115 -0
  44. package/dist/recover/recover.js.map +1 -0
  45. package/dist/recover/strip.d.ts +2 -0
  46. package/dist/recover/strip.d.ts.map +1 -0
  47. package/dist/recover/strip.js +17 -0
  48. package/dist/recover/strip.js.map +1 -0
  49. package/dist/recover/types.d.ts +117 -0
  50. package/dist/recover/types.d.ts.map +1 -0
  51. package/dist/recover/types.js +124 -0
  52. package/dist/recover/types.js.map +1 -0
  53. package/dist/recover/xml-forgiving-reader.d.ts +2 -0
  54. package/dist/recover/xml-forgiving-reader.d.ts.map +1 -0
  55. package/dist/recover/xml-forgiving-reader.js +79 -0
  56. package/dist/recover/xml-forgiving-reader.js.map +1 -0
  57. package/package.json +1 -1
  58. package/src/index.ts +42 -0
  59. package/src/prompt/output-format-renderer.ts +179 -0
  60. package/src/prompt/output-format-spec.ts +20 -0
  61. package/src/prompt/prompt-field.ts +24 -0
  62. package/src/prompt/prompt-overrides.ts +27 -0
  63. package/src/prompt/prompt-style.ts +36 -0
  64. package/src/recover/KNOWN_GAPS.md +35 -0
  65. package/src/recover/coerce.ts +141 -0
  66. package/src/recover/json-forgiving-reader.ts +167 -0
  67. package/src/recover/locate.ts +72 -0
  68. package/src/recover/recover-map.ts +39 -0
  69. package/src/recover/recover.ts +146 -0
  70. package/src/recover/strip.ts +17 -0
  71. package/src/recover/types.ts +217 -0
  72. package/src/recover/xml-forgiving-reader.ts +82 -0
package/dist/index.d.ts CHANGED
@@ -2,4 +2,12 @@ export { render, type RenderOptions } from "./render.js";
2
2
  export { type Provider, InMemoryProvider } from "./provider.js";
3
3
  export { ESCAPERS, type RenderFormat } from "./escapers.js";
4
4
  export { verify, ERR_VAR_NOT_ON_PAYLOAD, ERR_PARTIAL_UNRESOLVED, ERR_REQUIRED_SLOT_UNUSED, ERR_OUTPUT_TAG_MISSING, type PayloadField, type VerifyError, type VerifyOptions, } from "./verify.js";
5
+ export { recover } from "./recover/recover.js";
6
+ export { Format, FieldKind, FieldRecovery, Tolerance, RecoveryReport, scalar, enumField, range, object, recoverSchema, defaults, type FieldSpec, type RecoverSchema, type RecoverOptions, type RecoverOutcome, type RecoveryResult, type Coercion, type OnField, } from "./recover/types.js";
7
+ export { asString, asInt, asLong, asDouble, asBool, asStringList, } from "./recover/recover-map.js";
8
+ export { renderOutputFormat } from "./prompt/output-format-renderer.js";
9
+ export { PromptStyle, promptStyleFrom } from "./prompt/prompt-style.js";
10
+ export { PROMPT_OVERRIDES_NONE, noOverrides, type PromptOverrides, } from "./prompt/prompt-overrides.js";
11
+ export type { OutputFormatSpec } from "./prompt/output-format-spec.js";
12
+ export type { PromptField } from "./prompt/prompt-field.js";
5
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,KAAK,QAAQ,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EACL,MAAM,EACN,sBAAsB,EACtB,sBAAsB,EACtB,wBAAwB,EACxB,sBAAsB,EACtB,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,aAAa,GACnB,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,KAAK,QAAQ,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EACL,MAAM,EACN,sBAAsB,EACtB,sBAAsB,EACtB,wBAAwB,EACxB,sBAAsB,EACtB,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,aAAa,GACnB,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EACL,MAAM,EACN,SAAS,EACT,aAAa,EACb,SAAS,EACT,cAAc,EACd,MAAM,EACN,SAAS,EACT,KAAK,EACL,MAAM,EACN,aAAa,EACb,QAAQ,EACR,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,QAAQ,EACb,KAAK,OAAO,GACb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,QAAQ,EACR,KAAK,EACL,MAAM,EACN,QAAQ,EACR,MAAM,EACN,YAAY,GACb,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AACxE,OAAO,EACL,qBAAqB,EACrB,WAAW,EACX,KAAK,eAAe,GACrB,MAAM,8BAA8B,CAAC;AACtC,YAAY,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AACvE,YAAY,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC"}
package/dist/index.js CHANGED
@@ -2,4 +2,12 @@ export { render } from "./render.js";
2
2
  export { InMemoryProvider } from "./provider.js";
3
3
  export { ESCAPERS } from "./escapers.js";
4
4
  export { verify, ERR_VAR_NOT_ON_PAYLOAD, ERR_PARTIAL_UNRESOLVED, ERR_REQUIRED_SLOT_UNUSED, ERR_OUTPUT_TAG_MISSING, } from "./verify.js";
5
+ // FR-010 tolerant recover engine (Tier-2 forgiving parser).
6
+ export { recover } from "./recover/recover.js";
7
+ export { Format, FieldKind, FieldRecovery, Tolerance, RecoveryReport, scalar, enumField, range, object, recoverSchema, defaults, } from "./recover/types.js";
8
+ export { asString, asInt, asLong, asDouble, asBool, asStringList, } from "./recover/recover-map.js";
9
+ // FR-010 artifact 1 — output-format prompt renderer ("produce your answer like this").
10
+ export { renderOutputFormat } from "./prompt/output-format-renderer.js";
11
+ export { PromptStyle, promptStyleFrom } from "./prompt/prompt-style.js";
12
+ export { PROMPT_OVERRIDES_NONE, noOverrides, } from "./prompt/prompt-overrides.js";
5
13
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAsB,MAAM,aAAa,CAAC;AACzD,OAAO,EAAiB,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAqB,MAAM,eAAe,CAAC;AAC5D,OAAO,EACL,MAAM,EACN,sBAAsB,EACtB,sBAAsB,EACtB,wBAAwB,EACxB,sBAAsB,GAIvB,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAsB,MAAM,aAAa,CAAC;AACzD,OAAO,EAAiB,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAqB,MAAM,eAAe,CAAC;AAC5D,OAAO,EACL,MAAM,EACN,sBAAsB,EACtB,sBAAsB,EACtB,wBAAwB,EACxB,sBAAsB,GAIvB,MAAM,aAAa,CAAC;AAErB,4DAA4D;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EACL,MAAM,EACN,SAAS,EACT,aAAa,EACb,SAAS,EACT,cAAc,EACd,MAAM,EACN,SAAS,EACT,KAAK,EACL,MAAM,EACN,aAAa,EACb,QAAQ,GAQT,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,QAAQ,EACR,KAAK,EACL,MAAM,EACN,QAAQ,EACR,MAAM,EACN,YAAY,GACb,MAAM,0BAA0B,CAAC;AAElC,uFAAuF;AACvF,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AACxE,OAAO,EACL,qBAAqB,EACrB,WAAW,GAEZ,MAAM,8BAA8B,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { OutputFormatSpec } from "./output-format-spec.js";
2
+ import type { PromptOverrides } from "./prompt-overrides.js";
3
+ /**
4
+ * Render an {@link OutputFormatSpec} into an output-format prompt fragment. The
5
+ * effective style is the override's style if present, otherwise the spec's.
6
+ */
7
+ export declare function renderOutputFormat(spec: OutputFormatSpec, overrides: PromptOverrides): string;
8
+ //# sourceMappingURL=output-format-renderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output-format-renderer.d.ts","sourceRoot":"","sources":["../../src/prompt/output-format-renderer.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAe7D;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,gBAAgB,EAAE,SAAS,EAAE,eAAe,GAAG,MAAM,CAU7F"}
@@ -0,0 +1,164 @@
1
+ // FR-010 artifact 1 — output-format prompt renderer ("produce your answer like this").
2
+ //
3
+ // Renders an OutputFormatSpec into a prompt fragment that teaches an LLM how to
4
+ // shape its answer. Three comment-free styles (guide / inline / exampleOnly) ×
5
+ // two formats (json / xml). Guidance is carried in prose / inline placeholders /
6
+ // a filled skeleton — NEVER in comments (models ignore them).
7
+ //
8
+ // Cross-port INVARIANT: the rendered text is byte-identical to the Java/C#/Kotlin
9
+ // reference (com.metaobjects.render.prompt.OutputFormatRenderer). Do not change
10
+ // the verbatim prose, skeleton shapes, or numeric-vs-quoted decision.
11
+ import { ESCAPERS } from "../escapers.js";
12
+ import { FieldKind, Format } from "../recover/types.js";
13
+ import { PromptStyle } from "./prompt-style.js";
14
+ const NUMERIC_KINDS = new Set([
15
+ FieldKind.INT,
16
+ FieldKind.LONG,
17
+ FieldKind.DOUBLE,
18
+ FieldKind.BOOLEAN,
19
+ ]);
20
+ // The render engine OWNS format-keyed escaping; Format ("JSON"/"XML") maps to the
21
+ // lowercase ESCAPERS keys.
22
+ const escapeXml = (s) => ESCAPERS.xml(s);
23
+ const escapeJson = (s) => ESCAPERS.json(s);
24
+ /**
25
+ * Render an {@link OutputFormatSpec} into an output-format prompt fragment. The
26
+ * effective style is the override's style if present, otherwise the spec's.
27
+ */
28
+ export function renderOutputFormat(spec, overrides) {
29
+ const effectiveStyle = overrides.style ?? spec.style;
30
+ switch (effectiveStyle) {
31
+ case PromptStyle.EXAMPLE_ONLY:
32
+ return renderExampleOnly(spec, overrides);
33
+ case PromptStyle.INLINE:
34
+ return renderInline(spec, overrides);
35
+ default:
36
+ return renderGuide(spec, overrides);
37
+ }
38
+ }
39
+ // ---- INLINE ----------------------------------------------------------------
40
+ function renderInline(spec, overrides) {
41
+ return spec.format === Format.XML
42
+ ? renderXmlInline(spec, overrides)
43
+ : renderJsonInline(spec, overrides);
44
+ }
45
+ function renderXmlInline(spec, overrides) {
46
+ const lines = spec.fields.map((field) => {
47
+ const escaped = escapeXml(inlineContent(field, overrides));
48
+ return ` <${field.name}>${escaped}</${field.name}>\n`;
49
+ });
50
+ return `<${spec.rootName}>\n${lines.join("")}</${spec.rootName}>`;
51
+ }
52
+ function renderJsonInline(spec, overrides) {
53
+ const lines = spec.fields.map((field) => ` "${field.name}": "${escapeJson(inlineContent(field, overrides))}"`);
54
+ // Empty object is `{\n}` (Java/C# parity), not `{\n\n}` from join("") on no lines.
55
+ return spec.fields.length === 0 ? "{\n}" : `{\n${lines.join(",\n")}\n}`;
56
+ }
57
+ function inlineContent(field, overrides) {
58
+ if (field.kind === FieldKind.ENUM && field.enumValues != null && field.enumValues.length > 0) {
59
+ return field.enumValues.join(" | ");
60
+ }
61
+ if (field.kind === FieldKind.BOOLEAN) {
62
+ return "true | false";
63
+ }
64
+ const instruction = resolveInstruction(field, overrides);
65
+ return instruction != null ? `{${instruction}}` : `{${field.name}}`;
66
+ }
67
+ /** Effective instruction: override first, then the field default, else null. */
68
+ function resolveInstruction(field, overrides) {
69
+ const ov = overrides.instructions?.[field.name];
70
+ if (ov != null)
71
+ return ov;
72
+ return field.instruction;
73
+ }
74
+ // ---- GUIDE -----------------------------------------------------------------
75
+ function renderGuide(spec, overrides) {
76
+ let sb = "Fill in each field as described below:\n";
77
+ for (const field of spec.fields) {
78
+ const req = field.required ? "required" : "optional";
79
+ sb += `- ${field.name} (${req})`;
80
+ const instruction = resolveInstruction(field, overrides);
81
+ if (instruction != null) {
82
+ sb += `: ${instruction}`;
83
+ }
84
+ sb += "\n";
85
+ if (field.kind === FieldKind.ENUM && field.enumValues != null && field.enumValues.length > 0) {
86
+ sb += ` one of ${field.enumValues.join(", ")}\n`;
87
+ const enumDoc = field.enumDoc;
88
+ if (enumDoc != null) {
89
+ for (const val of field.enumValues) {
90
+ const doc = enumDoc[val];
91
+ if (doc != null) {
92
+ sb += ` ${val} = ${doc}\n`;
93
+ }
94
+ }
95
+ }
96
+ }
97
+ const eg = exampleValueIfDeclared(field, overrides);
98
+ if (eg != null) {
99
+ sb += ` e.g. ${eg}\n`;
100
+ }
101
+ }
102
+ sb += "\nRespond exactly like this:\n";
103
+ sb += renderExampleOnly(spec, overrides);
104
+ return sb;
105
+ }
106
+ // ---- EXAMPLE-ONLY (also the skeleton appended by GUIDE) ---------------------
107
+ function renderExampleOnly(spec, overrides) {
108
+ return spec.format === Format.XML
109
+ ? renderXmlSkeleton(spec, overrides)
110
+ : renderJsonSkeleton(spec, overrides);
111
+ }
112
+ function renderXmlSkeleton(spec, overrides) {
113
+ const lines = spec.fields.map((field) => {
114
+ const escaped = escapeXml(exampleValue(field, overrides));
115
+ return ` <${field.name}>${escaped}</${field.name}>\n`;
116
+ });
117
+ return `<${spec.rootName}>\n${lines.join("")}</${spec.rootName}>`;
118
+ }
119
+ function renderJsonSkeleton(spec, overrides) {
120
+ // NOTE: FieldKind.OBJECT / nested fields are not expanded here — they render as
121
+ // a "{fieldName}" placeholder. Nested-object expansion is a bounded deferral
122
+ // (mirrors Java/C#).
123
+ const lines = spec.fields.map((field) => {
124
+ const value = exampleValue(field, overrides);
125
+ const rendered = isNumericOrBoolean(field.kind, value) ? value : `"${escapeJson(value)}"`;
126
+ return ` "${field.name}": ${rendered}`;
127
+ });
128
+ // Empty object is `{\n}` (Java/C# parity), not `{\n\n}` from join("") on no lines.
129
+ return spec.fields.length === 0 ? "{\n}" : `{\n${lines.join(",\n")}\n}`;
130
+ }
131
+ function exampleValueIfDeclared(field, overrides) {
132
+ const ov = overrides.examples?.[field.name];
133
+ if (ov != null)
134
+ return ov;
135
+ if (field.example != null)
136
+ return field.example;
137
+ return null;
138
+ }
139
+ function exampleValue(field, overrides) {
140
+ const ov = overrides.examples?.[field.name];
141
+ if (ov != null)
142
+ return ov;
143
+ if (field.example != null)
144
+ return field.example;
145
+ if (field.kind === FieldKind.ENUM && field.enumValues != null && field.enumValues.length > 0) {
146
+ return field.enumValues[0];
147
+ }
148
+ return `{${field.name}}`;
149
+ }
150
+ function isNumericOrBoolean(kind, value) {
151
+ if (!NUMERIC_KINDS.has(kind))
152
+ return false;
153
+ if (value === "true" || value === "false")
154
+ return true;
155
+ // Finite-only: NaN/Infinity fall through to a quoted string so the emitted JSON
156
+ // stays valid. Number("") is 0, so guard the empty/blank case explicitly. Reject
157
+ // JS-only radix literals (0x../0b../0o..) that Number() accepts but Java/C# don't —
158
+ // same guard as the recover engine's parseFiniteNumber (keeps the JSON valid + parity).
159
+ const t = value.trim();
160
+ if (t === "" || /^[+-]?0[xXbBoO]/.test(t))
161
+ return false;
162
+ return Number.isFinite(Number(t));
163
+ }
164
+ //# sourceMappingURL=output-format-renderer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output-format-renderer.js","sourceRoot":"","sources":["../../src/prompt/output-format-renderer.ts"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,EAAE;AACF,gFAAgF;AAChF,+EAA+E;AAC/E,iFAAiF;AACjF,8DAA8D;AAC9D,EAAE;AACF,kFAAkF;AAClF,gFAAgF;AAChF,sEAAsE;AAEtE,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAIxD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,aAAa,GAA2B,IAAI,GAAG,CAAY;IAC/D,SAAS,CAAC,GAAG;IACb,SAAS,CAAC,IAAI;IACd,SAAS,CAAC,MAAM;IAChB,SAAS,CAAC,OAAO;CAClB,CAAC,CAAC;AAEH,kFAAkF;AAClF,2BAA2B;AAC3B,MAAM,SAAS,GAAG,CAAC,CAAS,EAAU,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACzD,MAAM,UAAU,GAAG,CAAC,CAAS,EAAU,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAE3D;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAAsB,EAAE,SAA0B;IACnF,MAAM,cAAc,GAAG,SAAS,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC;IACrD,QAAQ,cAAc,EAAE,CAAC;QACvB,KAAK,WAAW,CAAC,YAAY;YAC3B,OAAO,iBAAiB,CAAC,IA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C;IACxD,OAAO,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AACpC,CAAC"}
@@ -0,0 +1,18 @@
1
+ import type { Format } from "../recover/types.js";
2
+ import type { PromptField } from "./prompt-field.js";
3
+ import type { PromptStyle } from "./prompt-style.js";
4
+ /**
5
+ * A complete output-format descriptor: the format, the root element/object name,
6
+ * the default presentation style, and the ordered fields. Drives
7
+ * {@link renderOutputFormat}.
8
+ *
9
+ * Precondition: `rootName` must be identifier-safe (valid XML element name / JSON
10
+ * key). The renderer does not escape it.
11
+ */
12
+ export interface OutputFormatSpec {
13
+ readonly format: Format;
14
+ readonly rootName: string;
15
+ readonly style: PromptStyle;
16
+ readonly fields: readonly PromptField[];
17
+ }
18
+ //# sourceMappingURL=output-format-spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output-format-spec.d.ts","sourceRoot":"","sources":["../../src/prompt/output-format-spec.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD;;;;;;;GAOG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,SAAS,WAAW,EAAE,CAAC;CACzC"}
@@ -0,0 +1,3 @@
1
+ // FR-010 artifact 1 — a complete output-format descriptor.
2
+ export {};
3
+ //# sourceMappingURL=output-format-spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output-format-spec.js","sourceRoot":"","sources":["../../src/prompt/output-format-spec.ts"],"names":[],"mappings":"AAAA,2DAA2D"}
@@ -0,0 +1,22 @@
1
+ import type { FieldKind } from "../recover/types.js";
2
+ import type { OutputFormatSpec } from "./output-format-spec.js";
3
+ /**
4
+ * One field of an output-format fragment. `enumValues`/`enumDoc` are non-null
5
+ * only for ENUM; `nested` non-null only for OBJECT; `example`/`instruction` are
6
+ * nullable.
7
+ *
8
+ * Precondition: `name` must be identifier-safe (valid XML element name / JSON
9
+ * key). The renderer does not escape field names.
10
+ */
11
+ export interface PromptField {
12
+ readonly name: string;
13
+ readonly kind: FieldKind;
14
+ readonly required: boolean;
15
+ readonly array: boolean;
16
+ readonly enumValues: readonly string[] | null;
17
+ readonly enumDoc: Readonly<Record<string, string>> | null;
18
+ readonly example: string | null;
19
+ readonly instruction: string | null;
20
+ readonly nested: OutputFormatSpec | null;
21
+ }
22
+ //# sourceMappingURL=prompt-field.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt-field.d.ts","sourceRoot":"","sources":["../../src/prompt/prompt-field.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE;;;;;;;GAOG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAAC;IAC9C,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,IAAI,CAAC;IAC1D,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,QAAQ,CAAC,MAAM,EAAE,gBAAgB,GAAG,IAAI,CAAC;CAC1C"}
@@ -0,0 +1,3 @@
1
+ // FR-010 artifact 1 — one field of an output-format fragment.
2
+ export {};
3
+ //# sourceMappingURL=prompt-field.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt-field.js","sourceRoot":"","sources":["../../src/prompt/prompt-field.ts"],"names":[],"mappings":"AAAA,8DAA8D"}
@@ -0,0 +1,16 @@
1
+ import type { PromptStyle } from "./prompt-style.js";
2
+ /**
3
+ * Render-time overrides of the metadata defaults. `style` undefined keeps the
4
+ * spec's style; the maps override `PromptField.example`/`PromptField.instruction`
5
+ * per field name.
6
+ */
7
+ export interface PromptOverrides {
8
+ readonly style?: PromptStyle;
9
+ readonly examples?: Readonly<Record<string, string>>;
10
+ readonly instructions?: Readonly<Record<string, string>>;
11
+ }
12
+ /** No overrides — keep every metadata default. Mirrors Java `PromptOverrides.none()`. */
13
+ export declare const PROMPT_OVERRIDES_NONE: PromptOverrides;
14
+ /** No overrides — keep every metadata default. */
15
+ export declare function noOverrides(): PromptOverrides;
16
+ //# sourceMappingURL=prompt-overrides.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt-overrides.d.ts","sourceRoot":"","sources":["../../src/prompt/prompt-overrides.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,KAAK,CAAC,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACrD,QAAQ,CAAC,YAAY,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CAC1D;AAED,yFAAyF;AACzF,eAAO,MAAM,qBAAqB,EAAE,eAKlC,CAAC;AAEH,kDAAkD;AAClD,wBAAgB,WAAW,IAAI,eAAe,CAE7C"}
@@ -0,0 +1,13 @@
1
+ // FR-010 artifact 1 — render-time overrides of the metadata defaults.
2
+ /** No overrides — keep every metadata default. Mirrors Java `PromptOverrides.none()`. */
3
+ export const PROMPT_OVERRIDES_NONE = Object.freeze({
4
+ // `style` omitted (not `undefined`) under exactOptionalPropertyTypes: an absent
5
+ // style keeps the spec's own style, matching Java `PromptOverrides.none()`.
6
+ examples: {},
7
+ instructions: {},
8
+ });
9
+ /** No overrides — keep every metadata default. */
10
+ export function noOverrides() {
11
+ return PROMPT_OVERRIDES_NONE;
12
+ }
13
+ //# sourceMappingURL=prompt-overrides.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt-overrides.js","sourceRoot":"","sources":["../../src/prompt/prompt-overrides.ts"],"names":[],"mappings":"AAAA,sEAAsE;AAetE,yFAAyF;AACzF,MAAM,CAAC,MAAM,qBAAqB,GAAoB,MAAM,CAAC,MAAM,CAAC;IAClE,gFAAgF;IAChF,4EAA4E;IAC5E,QAAQ,EAAE,EAAE;IACZ,YAAY,EAAE,EAAE;CACjB,CAAC,CAAC;AAEH,kDAAkD;AAClD,MAAM,UAAU,WAAW;IACzB,OAAO,qBAAqB,CAAC;AAC/B,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * - `"guide"`: prose field list ("Fill in each field…") followed by an example skeleton.
3
+ * - `"inline"`: a single skeleton whose field values are inline placeholders / enum choices.
4
+ * - `"exampleOnly"`: just a filled example skeleton, nothing else.
5
+ */
6
+ export declare const PromptStyle: {
7
+ readonly GUIDE: "guide";
8
+ readonly INLINE: "inline";
9
+ readonly EXAMPLE_ONLY: "exampleOnly";
10
+ };
11
+ export type PromptStyle = (typeof PromptStyle)[keyof typeof PromptStyle];
12
+ /**
13
+ * Maps the `@promptStyle` attribute string to a {@link PromptStyle}. Null or any
14
+ * unrecognized value falls back to `"guide"` (matches Java `PromptStyle.from`).
15
+ */
16
+ export declare function promptStyleFrom(s?: string | null): PromptStyle;
17
+ //# sourceMappingURL=prompt-style.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt-style.d.ts","sourceRoot":"","sources":["../../src/prompt/prompt-style.ts"],"names":[],"mappings":"AAUA;;;;GAIG;AACH,eAAO,MAAM,WAAW;;;;CAId,CAAC;AACX,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,OAAO,WAAW,CAAC,CAAC;AAEzE;;;GAGG;AACH,wBAAgB,eAAe,CAAC,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,WAAW,CAS9D"}
@@ -0,0 +1,34 @@
1
+ // FR-010 artifact 1 — output-format prompt renderer.
2
+ //
3
+ // How the output-format fragment teaches the model. Guidance is NEVER carried in
4
+ // comments (models ignore them) — it lives in prose / inline placeholders / a
5
+ // filled skeleton. Default is "guide".
6
+ //
7
+ // Tier-2 idiomatic TS: the Java SCREAMING_SNAKE enum (GUIDE/INLINE/EXAMPLE_ONLY)
8
+ // becomes a string-union whose members ARE the wire `@promptStyle` values
9
+ // ("guide" | "inline" | "exampleOnly") — no name<->wire mapping table needed.
10
+ /**
11
+ * - `"guide"`: prose field list ("Fill in each field…") followed by an example skeleton.
12
+ * - `"inline"`: a single skeleton whose field values are inline placeholders / enum choices.
13
+ * - `"exampleOnly"`: just a filled example skeleton, nothing else.
14
+ */
15
+ export const PromptStyle = {
16
+ GUIDE: "guide",
17
+ INLINE: "inline",
18
+ EXAMPLE_ONLY: "exampleOnly",
19
+ };
20
+ /**
21
+ * Maps the `@promptStyle` attribute string to a {@link PromptStyle}. Null or any
22
+ * unrecognized value falls back to `"guide"` (matches Java `PromptStyle.from`).
23
+ */
24
+ export function promptStyleFrom(s) {
25
+ switch (s) {
26
+ case PromptStyle.INLINE:
27
+ return PromptStyle.INLINE;
28
+ case PromptStyle.EXAMPLE_ONLY:
29
+ return PromptStyle.EXAMPLE_ONLY;
30
+ default:
31
+ return PromptStyle.GUIDE;
32
+ }
33
+ }
34
+ //# sourceMappingURL=prompt-style.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt-style.js","sourceRoot":"","sources":["../../src/prompt/prompt-style.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,EAAE;AACF,iFAAiF;AACjF,8EAA8E;AAC9E,uCAAuC;AACvC,EAAE;AACF,iFAAiF;AACjF,0EAA0E;AAC1E,8EAA8E;AAE9E;;;;GAIG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,KAAK,EAAE,OAAO;IACd,MAAM,EAAE,QAAQ;IAChB,YAAY,EAAE,aAAa;CACnB,CAAC;AAGX;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,CAAiB;IAC/C,QAAQ,CAAC,EAAE,CAAC;QACV,KAAK,WAAW,CAAC,MAAM;YACrB,OAAO,WAAW,CAAC,MAAM,CAAC;QAC5B,KAAK,WAAW,CAAC,YAAY;YAC3B,OAAO,WAAW,CAAC,YAAY,CAAC;QAClC;YACE,OAAO,WAAW,CAAC,KAAK,CAAC;IAC7B,CAAC;AACH,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { FieldSpec, RecoverOptions, RecoveryReport } from "./types.js";
2
+ /** Sentinel: the value was present but could not be coerced to the declared kind/vocabulary. */
3
+ export declare const MALFORMED: unique symbol;
4
+ export declare function coerceValue(raw: string | null, spec: FieldSpec, opts: RecoverOptions, fieldPath: string, report: RecoveryReport): unknown | typeof MALFORMED;
5
+ //# sourceMappingURL=coerce.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coerce.d.ts","sourceRoot":"","sources":["../../src/recover/coerce.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5E,gGAAgG;AAChG,eAAO,MAAM,SAAS,EAAE,OAAO,MAA2C,CAAC;AAE3E,wBAAgB,WAAW,CACzB,GAAG,EAAE,MAAM,GAAG,IAAI,EAClB,IAAI,EAAE,SAAS,EACf,IAAI,EAAE,cAAc,EACpB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,cAAc,GACrB,OAAO,GAAG,OAAO,SAAS,CAmC5B"}
@@ -0,0 +1,124 @@
1
+ // Stage 7: canonicalize a raw scalar string per its FieldSpec. Returns the MALFORMED
2
+ // sentinel when present-but-uncoercible. Mirrors Java Coerce.
3
+ //
4
+ // Tier-2 divergence (documented, parity with the C# port's KNOWN_GAPS): JS has one
5
+ // number type. INT/LONG both truncate toward zero via Math.trunc and return `number`.
6
+ // Coercion uses Number(...) + Number.isFinite, NOT Java's Double.parseDouble — so JS
7
+ // does NOT accept Java's numeric suffixes ("42d"/"42f") or hex-float literals. The
8
+ // load-bearing contract (finite-only acceptance; NaN/±Infinity → MALFORMED; numeric
9
+ // classification) is identical across ports.
10
+ import { FieldKind, Tolerance } from "./types.js";
11
+ /** Sentinel: the value was present but could not be coerced to the declared kind/vocabulary. */
12
+ export const MALFORMED = Symbol("recover.coerce.MALFORMED");
13
+ export function coerceValue(raw, spec, opts, fieldPath, report) {
14
+ if (raw == null)
15
+ return MALFORMED;
16
+ if (opts.onField != null) {
17
+ const hooked = opts.onField(fieldPath, raw, spec);
18
+ if (hooked != null) {
19
+ report.addCoercion({ fieldPath, from: raw, to: stringify(hooked), kind: "onField" });
20
+ return hooked;
21
+ }
22
+ }
23
+ // Per-field runtime normalizer (bounded 20% surface). Keyed by field path, then simple name.
24
+ const norm = opts.normalizers[fieldPath] ?? opts.normalizers[spec.name];
25
+ if (norm != null) {
26
+ const normalized = norm(raw);
27
+ if (normalized != null) {
28
+ report.addCoercion({ fieldPath, from: raw, to: stringify(normalized), kind: "normalizer" });
29
+ return normalized;
30
+ }
31
+ }
32
+ const ci = opts.tolerance !== Tolerance.STRICT;
33
+ switch (spec.kind) {
34
+ case FieldKind.ENUM:
35
+ return coerceEnum(raw, spec, opts, fieldPath, report, ci);
36
+ case FieldKind.INT:
37
+ case FieldKind.LONG:
38
+ return coerceInt(raw, spec, fieldPath, report);
39
+ case FieldKind.DOUBLE:
40
+ return coerceDouble(raw, spec, fieldPath, report);
41
+ case FieldKind.BOOLEAN:
42
+ return coerceBool(raw, ci);
43
+ default:
44
+ return raw;
45
+ }
46
+ }
47
+ function coerceEnum(raw, spec, opts, path, report, ci) {
48
+ if (spec.enumValues != null) {
49
+ for (const v of spec.enumValues) {
50
+ if (v === raw)
51
+ return v;
52
+ if (ci && v.toLowerCase() === raw.toLowerCase()) {
53
+ report.addCoercion({ fieldPath: path, from: raw, to: v, kind: "case" });
54
+ return v;
55
+ }
56
+ }
57
+ }
58
+ const schemaTarget = spec.enumAlias == null ? undefined : spec.enumAlias[raw];
59
+ const runtimeTarget = opts.aliases[raw];
60
+ if (runtimeTarget != null) {
61
+ const kind = schemaTarget != null && schemaTarget !== runtimeTarget ? "runtime-alias-override" : "alias";
62
+ report.addCoercion({ fieldPath: path, from: raw, to: runtimeTarget, kind });
63
+ return runtimeTarget;
64
+ }
65
+ if (schemaTarget != null) {
66
+ report.addCoercion({ fieldPath: path, from: raw, to: schemaTarget, kind: "alias" });
67
+ return schemaTarget;
68
+ }
69
+ return MALFORMED;
70
+ }
71
+ function coerceInt(raw, spec, path, report) {
72
+ const n = parseFiniteNumber(raw);
73
+ if (n === null)
74
+ return MALFORMED;
75
+ return clamp(Math.trunc(n), spec, path, report);
76
+ }
77
+ function coerceDouble(raw, spec, path, report) {
78
+ const n = parseFiniteNumber(raw);
79
+ if (n === null)
80
+ return MALFORMED;
81
+ return clamp(n, spec, path, report);
82
+ }
83
+ /** Parse a trimmed numeric string; null if empty, non-numeric, or non-finite (NaN/±Infinity). */
84
+ function parseFiniteNumber(raw) {
85
+ const t = raw.trim();
86
+ if (t.length === 0)
87
+ return null;
88
+ // Reject JS-only radix-prefixed literals (0x.., 0b.., 0o..) that Number() would
89
+ // accept but Java/C# numeric parsing rejects → MALFORMED. Keeps cross-port parity.
90
+ if (/^[+-]?0[xXbBoO]/.test(t))
91
+ return null;
92
+ const n = Number(t); // Number("") === 0, hence the empty guard above
93
+ return Number.isFinite(n) ? n : null;
94
+ }
95
+ function clamp(n, spec, path, report) {
96
+ let c = n;
97
+ if (spec.min != null && c < spec.min)
98
+ c = spec.min;
99
+ if (spec.max != null && c > spec.max)
100
+ c = spec.max;
101
+ if (c !== n)
102
+ report.addCoercion({ fieldPath: path, from: stringify(n), to: stringify(c), kind: "clamp" });
103
+ return c;
104
+ }
105
+ function coerceBool(raw, ci) {
106
+ const t = ci ? raw.trim().toLowerCase() : raw.trim();
107
+ switch (t) {
108
+ case "true":
109
+ case "yes":
110
+ case "1":
111
+ return true;
112
+ case "false":
113
+ case "no":
114
+ case "0":
115
+ return false;
116
+ default:
117
+ return MALFORMED;
118
+ }
119
+ }
120
+ /** Canonical string form (locale-independent), mirroring Java String.valueOf for the corpus. */
121
+ function stringify(v) {
122
+ return String(v);
123
+ }
124
+ //# sourceMappingURL=coerce.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coerce.js","sourceRoot":"","sources":["../../src/recover/coerce.ts"],"names":[],"mappings":"AAAA,qFAAqF;AACrF,8DAA8D;AAC9D,EAAE;AACF,mFAAmF;AACnF,sFAAsF;AACtF,qFAAqF;AACrF,mFAAmF;AACnF,oFAAoF;AACpF,6CAA6C;AAE7C,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAGlD,gGAAgG;AAChG,MAAM,CAAC,MAAM,SAAS,GAAkB,MAAM,CAAC,0BAA0B,CAAC,CAAC;AAE3E,MAAM,UAAU,WAAW,CACzB,GAAkB,EAClB,IAAe,EACf,IAAoB,EACpB,SAAiB,EACjB,MAAsB;IAEtB,IAAI,GAAG,IAAI,IAAI;QAAE,OAAO,SAAS,CAAC;IAElC,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,EAAE,CAAC;QACzB,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,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empty/cut-off (present-but-garbled). */
2
+ export declare const TRUNCATED: unique symbol;
3
+ /** Parse a tolerant JSON object span into a forgiving record. Never throws. */
4
+ export declare function readJson(span: string | null | undefined): Record<string, unknown>;
5
+ //# sourceMappingURL=json-forgiving-reader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json-forgiving-reader.d.ts","sourceRoot":"","sources":["../../src/recover/json-forgiving-reader.ts"],"names":[],"mappings":"AAGA,kGAAkG;AAClG,eAAO,MAAM,SAAS,EAAE,OAAO,MAAyC,CAAC;AA+JzE,+EAA+E;AAC/E,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEjF"}