human-to-code 0.1.22 → 0.1.23

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 (38) hide show
  1. package/Readme.md +28 -6
  2. package/SECURITY.md +14 -3
  3. package/dist/agents/direct/generation-client.d.ts +11 -0
  4. package/dist/agents/direct/generation-client.d.ts.map +1 -1
  5. package/dist/agents/direct/generation-client.js +7 -0
  6. package/dist/agents/direct/generation-client.js.map +1 -1
  7. package/dist/agents/direct/index.d.ts +1 -0
  8. package/dist/agents/direct/index.d.ts.map +1 -1
  9. package/dist/agents/direct/index.js +1 -0
  10. package/dist/agents/direct/index.js.map +1 -1
  11. package/dist/agents/direct/integration-validation.d.ts +47 -0
  12. package/dist/agents/direct/integration-validation.d.ts.map +1 -0
  13. package/dist/agents/direct/integration-validation.js +284 -0
  14. package/dist/agents/direct/integration-validation.js.map +1 -0
  15. package/dist/agents/direct/presentation.d.ts +9 -1
  16. package/dist/agents/direct/presentation.d.ts.map +1 -1
  17. package/dist/agents/direct/presentation.js +25 -2
  18. package/dist/agents/direct/presentation.js.map +1 -1
  19. package/dist/cli.d.ts.map +1 -1
  20. package/dist/cli.js +76 -4
  21. package/dist/cli.js.map +1 -1
  22. package/dist/config/config.d.ts +5 -0
  23. package/dist/config/config.d.ts.map +1 -1
  24. package/dist/config/config.js +21 -0
  25. package/dist/config/config.js.map +1 -1
  26. package/dist/prompts/direct-integration.d.ts +23 -0
  27. package/dist/prompts/direct-integration.d.ts.map +1 -0
  28. package/dist/prompts/direct-integration.js +45 -0
  29. package/dist/prompts/direct-integration.js.map +1 -0
  30. package/dist/prompts/index.d.ts +1 -0
  31. package/dist/prompts/index.d.ts.map +1 -1
  32. package/dist/prompts/index.js +1 -0
  33. package/dist/prompts/index.js.map +1 -1
  34. package/docs/ARCHITECTURE.md +2 -2
  35. package/docs/MODULES.md +5 -2
  36. package/docs/SCALABILITY.md +7 -0
  37. package/docs/roadmap/html-css.md +6 -1
  38. package/package.json +1 -1
package/Readme.md CHANGED
@@ -57,10 +57,11 @@ By default this runs the **direct converter**, not an instruction to rewrite the
57
57
  2. Reports marker-shaped requests in unsupported file types and refuses a `.human` request whose sibling output already exists. Intentionally ignored directories and symlinks remain outside discovery.
58
58
  3. Prints a receipt (the output languages actually selected for this worklist, provider, model, and exact source-to-output paths) and asks for confirmation. Nothing is written until you confirm — or pass `-y`/`--yes`. If no request is found it returns `NEEDS_INPUT`.
59
59
  4. On confirmation, converts each item with one model completion per unit, extracts one unambiguous code block, and validates the complete candidate before writing. JavaScript and TypeScript use the TypeScript parser; supported programming languages receive a deterministic structural syntax check. HTML and CSS receive the non-empty and code-fence gates because generic delimiter balancing misreads valid markup and stylesheet text. Inline validation compares the candidate with the original file and rejects only syntax errors introduced by that replacement, without blaming it for unchanged baseline errors.
60
- 5. For JavaScript/TypeScript output, additionally stages every accepted unit into an in-memory candidate overlay and type-checks the combined candidate project with the TypeScript Compiler API — imports/exports, methods and properties, argument counts, literal unions, object shapes, readonly rules, and call compatibility across the generated files together. Diagnostics are compared against the unchanged baseline, so pre-existing project errors are never blamed on generated units. A dependency-connected group that introduces new cross-file errors receives at most one bounded repair request per whole-file unit (same provider and model); if it still fails, every generated unit in that group is rejected before application while units proven independent may still apply. Other direct languages keep their per-file validation level.
61
- 6. Applies each accepted item defensively: new sibling files use exclusive creation, inline markers must still match the bytes found during discovery, and multi-line replacements inherit the marker's indentation. A failing or stale item is skipped with a reason rather than aborting the rest.
60
+ 5. When `direct.reconcileIntegrations` is explicitly enabled, checks generated whole-file HTML against conventional generated CSS/browser-JavaScript companions in the same directory. An already-linked group adds no request. A missing exact reference permits one disclosed, bounded HTML reconciliation request; if the relationship remains broken, the connected opt-in group is rejected before application. This phase is off by default, so it adds no requests or rejection behavior to an ordinary upgrade.
61
+ 6. For JavaScript/TypeScript output, additionally stages every accepted unit into an in-memory candidate overlay and type-checks the combined candidate project with the TypeScript Compiler API — imports/exports, methods and properties, argument counts, literal unions, object shapes, readonly rules, and call compatibility across the generated files together. Diagnostics are compared against the unchanged baseline, so pre-existing project errors are never blamed on generated units. A dependency-connected group that introduces new cross-file errors receives at most one bounded repair request per whole-file unit (same provider and model); if it still fails, every generated unit in that group is rejected before application while units proven independent may still apply. Other direct languages keep their per-file validation level.
62
+ 7. Applies each accepted item defensively: new sibling files use exclusive creation, inline markers must still match the bytes found during discovery, and multi-line replacements inherit the marker's indentation. A failing or stale item is skipped with a reason rather than aborting the rest.
62
63
 
63
- The direct converter writes code straight to the working tree. Its combined static compiler validation for JS/TS is stronger than syntax parsing, but it is still static analysis: it does **not** execute or import project code, run project builds or tests, prove runtime behavior or external-API grounding, execute code in a sandbox, create a `.strict.human.json` change contract, produce a `VERIFIED` run, or perform the guided pipeline's repository-wide secret scan only the indexed declarations it attaches to an inline prompt as context are secret-scanned (a finding is `SECURITY_BLOCKED`). For the reviewed contract → grounding → sandbox-validation lifecycle — where the `.strict.human.json` contract and the `VERIFIED`/`apply`/`rollback` machinery live — use `human-to-code guided` (see [The reviewed change contract](#the-reviewed-change-contract) and the [CLI](#cli) table).
64
+ The direct converter writes code straight to the working tree. Its combined static compiler validation for JS/TS is stronger than syntax parsing, but it is still static analysis: it does **not** execute or import project code, run project builds or tests, prove runtime behavior or external-API grounding, execute code in a sandbox, create a `.strict.human.json` change contract, produce a `VERIFIED` run, or perform the guided pipeline's repository-wide secret scan. Direct outbound FileMemory and optional integration-reconciliation candidate bundles are credential-scanned, while ProjectMemory omits credential-bearing contracts; these narrower gates are not a repository-wide proof. For the reviewed contract → grounding → sandbox-validation lifecycle — where the `.strict.human.json` contract and the `VERIFIED`/`apply`/`rollback` machinery live — use `human-to-code guided` (see [The reviewed change contract](#the-reviewed-change-contract) and the [CLI](#cli) table).
64
65
 
65
66
  No configured provider is needed to scan and preview. A default run selects loopback-local Ollama with `qwen2.5-coder:7b`, so a fresh `npx human-to-code .` never transmits code remotely by default. The model must already be installed; the tool never pulls it implicitly. To use another local model, OpenAI, or Ollama Cloud, create and edit a config (the command never overwrites one):
66
67
 
@@ -165,6 +166,12 @@ text generation work fine.
165
166
  bounded repair attempt per whole-file unit); independent units still apply.
166
167
  Pre-existing baseline errors are never attributed to generated code. This is
167
168
  static compilation, not sandbox execution, runtime testing, or API grounding.
169
+ - **Optional generated-link reconciliation** —
170
+ `direct.reconcileIntegrations` defaults to `false`. When enabled, generated
171
+ whole-file HTML is checked against conventional same-directory generated CSS
172
+ and browser scripts. Correct links add no request; a missing link permits one
173
+ disclosed bounded correction request and otherwise rejects that connected
174
+ opt-in group.
168
175
  - **Clear, stable output** — a single truncated status line per marker
169
176
  (`✓ app.ts (inline @human, line 12)` / `⊘ skipped … : <reason>`), plus an
170
177
  in-place elapsed spinner while a completion is in flight.
@@ -181,9 +188,12 @@ such as `../styles.css`; it does not assume every file lives at the root.
181
188
 
182
189
  ProjectMemory is evidence for generation, not proof of correctness. Its prompt
183
190
  contract tells the model to connect genuine companions without importing every
184
- file it sees. JS/TS relationships still receive combined compiler validation;
185
- HTML/CSS relationships are not runtime-tested by the direct engine, so use the
186
- guided path when integration must be sandbox-verified.
191
+ file it sees. JS/TS relationships still receive combined compiler validation.
192
+ HTML/CSS relationships are not runtime-tested by the direct engine. The
193
+ optional `direct.reconcileIntegrations` pass can statically enforce generated
194
+ HTML references to same-directory generated stylesheets/browser scripts, but it
195
+ is deliberately off by default and is not a runtime or sandbox verification.
196
+ Use the guided path when integration must be sandbox-verified.
187
197
 
188
198
  ```bash
189
199
  # Deterministic engine — works with small models:
@@ -288,6 +298,9 @@ This complete local-Ollama example shows the policy fields:
288
298
  "maxRequests": 12,
289
299
  "maxRepairs": 2,
290
300
  "timeoutMs": 900000
301
+ },
302
+ "direct": {
303
+ "reconcileIntegrations": false
291
304
  }
292
305
  }
293
306
  ```
@@ -296,6 +309,15 @@ This complete local-Ollama example shows the policy fields:
296
309
 
297
310
  `humanFileExtensions` provides the strongest routing signal. Each entry binds one exact, portable project-relative `.human` path to an output extension; a leading dot is optional, and the extension's language must appear in `languages`. This prevents prompt vocabulary from changing the output: the example always routes `script.human` to `script.js`, even if its instruction repeatedly mentions stylesheets, CSS classes, colors, or themes. Recognized inner extensions are replaced when an explicit mapping is present, so mapping `page.html.human` to `js` produces `page.js`.
298
311
 
312
+ `direct.reconcileIntegrations` is an opt-in post-generation safety net. The
313
+ default `false` keeps the established ProjectMemory first pass unchanged and
314
+ adds no provider calls, checks, group coupling, or receipt fields. With `true`,
315
+ the receipt/JSON plan discloses the maximum conditional requests; a request is
316
+ actually made only when generated HTML is missing an exact reference to a
317
+ conventional generated CSS/browser-JavaScript companion in the same directory.
318
+ One failed bounded reconciliation rejects that connected group instead of
319
+ writing a known-disconnected partial result.
320
+
299
321
  The direct engine uses `privacy.maxContextTokens` as the combined upper bound
300
322
  for FileMemory and ProjectMemory. ProjectMemory additionally caps each rendered
301
323
  block at 24,000 characters, reads at most 240 high-priority files for compact
package/SECURITY.md CHANGED
@@ -62,15 +62,26 @@ no `context --explain` preview. Remote direct conversion therefore remains
62
62
  blocked until explicit project-level remote-provider consent; use local Ollama
63
63
  or the guided flow when this compact context is not appropriate to transmit.
64
64
 
65
+ Post-generation HTML integration reconciliation is a separate explicit opt-in
66
+ (`direct.reconcileIntegrations`, default `false`). When disabled, it performs
67
+ no audit and sends no additional request. When enabled, the host checks exact
68
+ local stylesheet/script references after all relevant first-pass candidates
69
+ exist. Only a detected missing relationship may trigger one bounded whole-file
70
+ HTML request. That request contains the current HTML, bounded generated
71
+ companion content, and bounded ProjectMemory; the outbound bundle is
72
+ credential-scanned, all evidence is prompt-isolated as untrusted data, and an
73
+ unresolved relationship rejects the connected opt-in group before writing.
74
+ This is static link consistency, not runtime or sandbox verification.
75
+
65
76
  These controls prevent the specific malformed-output, overwrite, stale-range,
66
77
  indentation, and cross-file-contract failures they check. Static compilation
67
78
  is stronger than syntax parsing, but it does not prove runtime behavior,
68
79
  external-API grounding, project-wide security properties, or test success,
69
80
  and it never executes the candidate in a sandbox or claims `VERIFIED`. Other
70
81
  direct programming languages keep their per-file structural validation level;
71
- HTML and CSS use only the non-empty and code-fence gates. Use the
72
- guided contract and validation path when those stronger boundaries are
73
- required.
82
+ HTML and CSS normally use only the non-empty and code-fence gates; the optional
83
+ reconciliation adds only the narrow generated-link check described above. Use
84
+ the guided contract and validation path when stronger boundaries are required.
74
85
 
75
86
  ### The reviewed contract owns authority
76
87
 
@@ -1,7 +1,18 @@
1
+ import { type DirectIntegrationIssue, type DirectIntegrationRelatedFile } from "../../prompts/direct-integration.ts";
1
2
  import { type DirectRepairDiagnostic, type DirectRepairRelatedFile } from "../../prompts/direct-repair.ts";
2
3
  import type { GenerateOptions } from "./types.ts";
3
4
  /** Send one direct-conversion request to OpenAI-compatible chat or Ollama. */
4
5
  export declare function generateCode(instruction: string, options: GenerateOptions): Promise<string>;
6
+ export interface IntegrationGenerationRequest {
7
+ targetPath: string;
8
+ instruction: string;
9
+ currentCode: string;
10
+ issues: readonly DirectIntegrationIssue[];
11
+ relatedFiles: readonly DirectIntegrationRelatedFile[];
12
+ projectMemory?: string;
13
+ }
14
+ /** Send one opt-in bounded integration request with the configured provider/model. */
15
+ export declare function generateIntegrationCode(request: IntegrationGenerationRequest, options: GenerateOptions): Promise<string>;
5
16
  export interface RepairGenerationRequest {
6
17
  targetPath: string;
7
18
  inline: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"generation-client.d.ts","sourceRoot":"","sources":["../../../src/agents/direct/generation-client.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC7B,MAAM,gCAAgC,CAAC;AAGxC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AA+ClD,8EAA8E;AAC9E,wBAAsB,YAAY,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CAWjG;AAED,MAAM,WAAW,uBAAuB;IACtC,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,OAAO,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,SAAS,sBAAsB,EAAE,CAAC;IAC/C,YAAY,EAAE,SAAS,uBAAuB,EAAE,CAAC;IACjD,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,mFAAmF;AACnF,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,uBAAuB,EAChC,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,MAAM,CAAC,CAIjB"}
1
+ {"version":3,"file":"generation-client.d.ts","sourceRoot":"","sources":["../../../src/agents/direct/generation-client.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,sBAAsB,EAC3B,KAAK,4BAA4B,EAClC,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAEL,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC7B,MAAM,gCAAgC,CAAC;AAGxC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AA+ClD,8EAA8E;AAC9E,wBAAsB,YAAY,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CAWjG;AAED,MAAM,WAAW,4BAA4B;IAC3C,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,SAAS,sBAAsB,EAAE,CAAC;IAC1C,YAAY,EAAE,SAAS,4BAA4B,EAAE,CAAC;IACtD,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,sFAAsF;AACtF,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,4BAA4B,EACrC,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,MAAM,CAAC,CAIjB;AAED,MAAM,WAAW,uBAAuB;IACtC,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,OAAO,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,SAAS,sBAAsB,EAAE,CAAC;IAC/C,YAAY,EAAE,SAAS,uBAAuB,EAAE,CAAC;IACjD,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,mFAAmF;AACnF,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,uBAAuB,EAChC,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,MAAM,CAAC,CAIjB"}
@@ -1,4 +1,5 @@
1
1
  import { buildDirectConversionPrompt } from "../../prompts/direct-conversion.js";
2
+ import { buildDirectIntegrationPrompt, } from "../../prompts/direct-integration.js";
2
3
  import { buildDirectRepairPrompt, } from "../../prompts/direct-repair.js";
3
4
  import { languageProfile } from "./languages.js";
4
5
  import { stripCodeFence } from "./presentation.js";
@@ -60,6 +61,12 @@ export async function generateCode(instruction, options) {
60
61
  });
61
62
  return requestChatCompletion(prompt, options);
62
63
  }
64
+ /** Send one opt-in bounded integration request with the configured provider/model. */
65
+ export async function generateIntegrationCode(request, options) {
66
+ const profile = languageProfile(options.language);
67
+ const prompt = buildDirectIntegrationPrompt({ languageLabel: profile.label, ...request });
68
+ return requestChatCompletion(prompt, options);
69
+ }
63
70
  /** Send one bounded cross-file repair request with the same provider and model. */
64
71
  export async function generateRepairCode(request, options) {
65
72
  const profile = languageProfile(options.language);
@@ -1 +1 @@
1
- {"version":3,"file":"generation-client.js","sourceRoot":"","sources":["../../../src/agents/direct/generation-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAuB,MAAM,oCAAoC,CAAC;AACtG,OAAO,EACL,uBAAuB,GAGxB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGnD,0EAA0E;AAC1E,KAAK,UAAU,qBAAqB,CAAC,MAAsB,EAAE,OAAwB;IAC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AE,aAAa,EAAE,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC3E,CAAC,CAAC;IACH,OAAO,qBAAqB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAChD,CAAC;AAWD,sFAAsF;AACtF,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,OAAqC,EACrC,OAAwB;IAExB,MAAM,OAAO,GAAG,eAAe,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAClD,MAAM,MAAM,GAAG,4BAA4B,CAAC,EAAE,aAAa,EAAE,OAAO,CAAC,KAAK,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAC1F,OAAO,qBAAqB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAChD,CAAC;AAYD,mFAAmF;AACnF,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,OAAgC,EAChC,OAAwB;IAExB,MAAM,OAAO,GAAG,eAAe,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAClD,MAAM,MAAM,GAAG,uBAAuB,CAAC,EAAE,aAAa,EAAE,OAAO,CAAC,KAAK,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACrF,OAAO,qBAAqB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAChD,CAAC"}
@@ -15,5 +15,6 @@ export * from "./candidate-validation.ts";
15
15
  export * from "./candidate-overlay.ts";
16
16
  export * from "./program-diagnostics.ts";
17
17
  export * from "./dependency-graph.ts";
18
+ export * from "./integration-validation.ts";
18
19
  export * from "./staged-validation.ts";
19
20
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agents/direct/index.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agents/direct/index.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC"}
@@ -15,5 +15,6 @@ export * from "./candidate-validation.js";
15
15
  export * from "./candidate-overlay.js";
16
16
  export * from "./program-diagnostics.js";
17
17
  export * from "./dependency-graph.js";
18
+ export * from "./integration-validation.js";
18
19
  export * from "./staged-validation.js";
19
20
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/agents/direct/index.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/agents/direct/index.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC"}
@@ -0,0 +1,47 @@
1
+ import type { DirectIntegrationIssue } from "../../prompts/direct-integration.ts";
2
+ import type { ConversionUnit, GeneratedConversionUnit, ProjectMemoryProvider } from "./types.ts";
3
+ export interface IntegrationRequest {
4
+ unit: ConversionUnit;
5
+ targetPath: string;
6
+ instruction: string;
7
+ currentCode: string;
8
+ issues: DirectIntegrationIssue[];
9
+ relatedFiles: Array<{
10
+ path: string;
11
+ content: string;
12
+ }>;
13
+ projectMemory?: string;
14
+ }
15
+ export type IntegrationProgress = {
16
+ kind: "integration-check";
17
+ unit: ConversionUnit;
18
+ issues: number;
19
+ } | {
20
+ kind: "integrate";
21
+ unit: ConversionUnit;
22
+ attempt: number;
23
+ issues: number;
24
+ } | {
25
+ kind: "reject";
26
+ unit: ConversionUnit;
27
+ reason: string;
28
+ };
29
+ export interface IntegrationValidationOptions {
30
+ integrate?: (request: IntegrationRequest) => Promise<string>;
31
+ maxIntegrationAttemptsPerUnit?: number;
32
+ contextCharBudget?: number;
33
+ projectMemory?: ProjectMemoryProvider;
34
+ onProgress?: (event: IntegrationProgress) => void;
35
+ }
36
+ export interface IntegrationValidationOutcome {
37
+ results: GeneratedConversionUnit[];
38
+ integrationRequests: number;
39
+ checkedTargets: number;
40
+ }
41
+ /** Maximum integration requests disclosed before an opt-in run. */
42
+ export declare function potentialIntegrationRequests(units: readonly ConversionUnit[]): number;
43
+ /** Check one complete HTML candidate against its known generated companions. */
44
+ export declare function findHtmlIntegrationIssues(htmlPath: string, html: string, relatedUnits: readonly ConversionUnit[]): DirectIntegrationIssue[];
45
+ /** Run opt-in integration checks and bounded repair over generated candidates. */
46
+ export declare function reconcileGeneratedIntegrations(generated: readonly GeneratedConversionUnit[], options?: IntegrationValidationOptions): Promise<IntegrationValidationOutcome>;
47
+ //# sourceMappingURL=integration-validation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"integration-validation.d.ts","sourceRoot":"","sources":["../../../src/agents/direct/integration-validation.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAElF,OAAO,KAAK,EAAE,cAAc,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEjG,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,cAAc,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,C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,EAAE,SAAS,cAAc,EAAE,GACtC,sBAAsB,EAAE,CAuB1B;AAqCD,kFAAkF;AAClF,wBAAsB,8BAA8B,CAClD,SAAS,EAAE,SAAS,uBAAuB,EAAE,EAC7C,OAAO,GAAE,4BAAiC,GACzC,OAAO,CAAC,4BAA4B,CAAC,CAkEvC"}
@@ -0,0 +1,284 @@
1
+ /**
2
+ * Opt-in post-generation checks for relationships that a compiler cannot
3
+ * validate. The first contract covers static-web entry documents: generated
4
+ * HTML must reference conventional generated CSS/browser-JavaScript companions
5
+ * in the same directory. Consistent groups issue no request; a detected gap
6
+ * permits one bounded whole-file reconciliation and otherwise fails closed.
7
+ */
8
+ import { posix } from "node:path";
9
+ import { ContextSecurityError, scanSecrets } from "../../context/context.js";
10
+ import { validateGeneratedUnit } from "./candidate-validation.js";
11
+ const DEFAULT_CONTEXT_CHAR_BUDGET = 48_000;
12
+ const HTML_EXTENSIONS = new Set([".html", ".htm"]);
13
+ const BROWSER_SCRIPT_EXTENSIONS = new Set([".js", ".mjs"]);
14
+ const RAW_OR_INERT_HTML_ELEMENTS = new Set([
15
+ "iframe", "noembed", "noframes", "script", "style", "template", "textarea", "title", "xmp",
16
+ ]);
17
+ const CONVENTIONAL_BROWSER_SCRIPT = /^(?:app|client|frontend|index|main|page|script|ui)(?:[.-].*)?\.(?:js|mjs)$/iu;
18
+ const BROWSER_PURPOSE = /\b(?:browser|button|calculator|click|document|dom|event|form|html|page|screen|ui|window)\b/iu;
19
+ function targetPath(unit) {
20
+ return unit.kind === "file" ? unit.outputPath : unit.sourcePath;
21
+ }
22
+ function extension(path) {
23
+ return posix.extname(path).toLowerCase();
24
+ }
25
+ function isWholeHtml(unit) {
26
+ return unit.kind === "file" && HTML_EXTENSIONS.has(extension(targetPath(unit)));
27
+ }
28
+ function isStylesheetCompanion(unit) {
29
+ if (unit.kind !== "file" || extension(targetPath(unit)) !== ".css")
30
+ return false;
31
+ return !/(?:^|[.-])(?:module|spec|test)(?:[.-]|\.css$)/iu.test(posix.basename(targetPath(unit)));
32
+ }
33
+ function isBrowserScriptCompanion(unit) {
34
+ if (unit.kind !== "file" || !BROWSER_SCRIPT_EXTENSIONS.has(extension(targetPath(unit))))
35
+ return false;
36
+ const name = posix.basename(targetPath(unit));
37
+ if (/(?:^|[.-])(?:config|server|spec|test)(?:[.-]|\.(?:js|mjs)$)/iu.test(name))
38
+ return false;
39
+ return CONVENTIONAL_BROWSER_SCRIPT.test(name) || BROWSER_PURPOSE.test(unit.prompt);
40
+ }
41
+ function webIntegrationGroups(units) {
42
+ const files = units.filter((unit) => unit.kind === "file");
43
+ return files.filter(isWholeHtml).flatMap((html) => {
44
+ const directory = posix.dirname(targetPath(html));
45
+ const related = files.filter((unit) => unit !== html
46
+ && posix.dirname(targetPath(unit)) === directory
47
+ && (isStylesheetCompanion(unit) || isBrowserScriptCompanion(unit)));
48
+ return related.length > 0 ? [{ html, related }] : [];
49
+ });
50
+ }
51
+ /** Maximum integration requests disclosed before an opt-in run. */
52
+ export function potentialIntegrationRequests(units) {
53
+ return webIntegrationGroups(units).length;
54
+ }
55
+ function requiredReference(from, to) {
56
+ return posix.relative(posix.dirname(from), to) || posix.basename(to);
57
+ }
58
+ function attribute(tag, name) {
59
+ const pattern = new RegExp(`(?:^|\\s)${name}\\s*=\\s*(?:"([^"]*)"|'([^']*)'|([^\\s"'=<>\u0060]+))`, "iu");
60
+ const match = pattern.exec(tag);
61
+ return match?.[1] ?? match?.[2] ?? match?.[3];
62
+ }
63
+ function resolveLocalReference(from, reference) {
64
+ const trimmed = reference.trim();
65
+ if (trimmed.length === 0 || trimmed.startsWith("#") || trimmed.startsWith("//"))
66
+ return undefined;
67
+ if (/^[a-z][a-z0-9+.-]*:/iu.test(trimmed))
68
+ return undefined;
69
+ const withoutSuffix = trimmed.split(/[?#]/u, 1)[0] ?? "";
70
+ let decoded;
71
+ try {
72
+ decoded = decodeURIComponent(withoutSuffix);
73
+ }
74
+ catch {
75
+ decoded = withoutSuffix;
76
+ }
77
+ const resolved = decoded.startsWith("/")
78
+ ? posix.normalize(decoded.slice(1))
79
+ : posix.normalize(posix.join(posix.dirname(from), decoded));
80
+ if (resolved === ".." || resolved.startsWith("../"))
81
+ return undefined;
82
+ return resolved.replace(/^\.\//u, "");
83
+ }
84
+ function tagEnd(html, start) {
85
+ let quote;
86
+ for (let index = start + 1; index < html.length; index += 1) {
87
+ const char = html[index];
88
+ if (quote !== undefined) {
89
+ if (char === quote)
90
+ quote = undefined;
91
+ }
92
+ else if (char === "\"" || char === "'") {
93
+ quote = char;
94
+ }
95
+ else if (char === ">") {
96
+ return index;
97
+ }
98
+ }
99
+ return html.length - 1;
100
+ }
101
+ /**
102
+ * Extract active start tags without accepting examples inside HTML comments,
103
+ * template contents, or JavaScript/CSS raw-text bodies as real references.
104
+ */
105
+ function htmlStartTags(html) {
106
+ const tags = [];
107
+ let offset = 0;
108
+ while (offset < html.length) {
109
+ const start = html.indexOf("<", offset);
110
+ if (start === -1)
111
+ break;
112
+ if (html.startsWith("<!--", start)) {
113
+ const end = html.indexOf("-->", start + 4);
114
+ offset = end === -1 ? html.length : end + 3;
115
+ continue;
116
+ }
117
+ const end = tagEnd(html, start);
118
+ const source = html.slice(start, end + 1);
119
+ const match = /^<\s*([a-z][a-z0-9:-]*)\b/iu.exec(source);
120
+ if (!match) {
121
+ offset = end + 1;
122
+ continue;
123
+ }
124
+ const name = match[1].toLowerCase();
125
+ tags.push({ name, source });
126
+ if (RAW_OR_INERT_HTML_ELEMENTS.has(name) && !/\/\s*>$/u.test(source)) {
127
+ const closing = new RegExp(`<\\/\\s*${name}\\s*>`, "giu");
128
+ closing.lastIndex = end + 1;
129
+ const close = closing.exec(html);
130
+ offset = close === null ? html.length : close.index + close[0].length;
131
+ }
132
+ else {
133
+ offset = end + 1;
134
+ }
135
+ }
136
+ return tags;
137
+ }
138
+ function hasStylesheetReference(htmlPath, tags, stylesheetPath) {
139
+ for (const tag of tags) {
140
+ if (tag.name !== "link")
141
+ continue;
142
+ const rel = attribute(tag.source, "rel")?.toLowerCase().split(/\s+/u) ?? [];
143
+ const href = attribute(tag.source, "href");
144
+ if (rel.includes("stylesheet") && href !== undefined && resolveLocalReference(htmlPath, href) === stylesheetPath)
145
+ return true;
146
+ }
147
+ return false;
148
+ }
149
+ function hasScriptReference(htmlPath, tags, scriptPath) {
150
+ for (const tag of tags) {
151
+ if (tag.name !== "script")
152
+ continue;
153
+ const source = attribute(tag.source, "src");
154
+ if (source !== undefined && resolveLocalReference(htmlPath, source) === scriptPath)
155
+ return true;
156
+ }
157
+ return false;
158
+ }
159
+ /** Check one complete HTML candidate against its known generated companions. */
160
+ export function findHtmlIntegrationIssues(htmlPath, html, relatedUnits) {
161
+ const issues = [];
162
+ const tags = htmlStartTags(html);
163
+ for (const unit of relatedUnits) {
164
+ const relatedPath = targetPath(unit);
165
+ const reference = requiredReference(htmlPath, relatedPath);
166
+ if (isStylesheetCompanion(unit) && !hasStylesheetReference(htmlPath, tags, relatedPath)) {
167
+ issues.push({
168
+ code: "MISSING_STYLESHEET_REFERENCE",
169
+ message: `${htmlPath} does not load its generated stylesheet companion ${relatedPath}.`,
170
+ relatedPath,
171
+ requiredReference: reference,
172
+ });
173
+ }
174
+ else if (isBrowserScriptCompanion(unit) && !hasScriptReference(htmlPath, tags, relatedPath)) {
175
+ issues.push({
176
+ code: "MISSING_BROWSER_SCRIPT_REFERENCE",
177
+ message: `${htmlPath} does not load its generated browser-script companion ${relatedPath}.`,
178
+ relatedPath,
179
+ requiredReference: reference,
180
+ });
181
+ }
182
+ }
183
+ return issues;
184
+ }
185
+ function describeIssues(issues) {
186
+ return issues.map((issue) => `${issue.code} (${issue.requiredReference})`).join(", ");
187
+ }
188
+ function buildIntegrationRequest(group, currentCode, issues, byUnit, contextCharBudget, projectMemory) {
189
+ const issueChars = issues.reduce((total, issue) => total + issue.message.length + issue.relatedPath.length + issue.requiredReference.length + 48, 0);
190
+ let budget = contextCharBudget - currentCode.length - issueChars;
191
+ if (budget < 0)
192
+ return undefined;
193
+ const renderedProjectMemory = projectMemory?.renderFor(group.html, Math.floor(budget / 2));
194
+ budget -= renderedProjectMemory?.length ?? 0;
195
+ const relatedFiles = [];
196
+ for (const unit of group.related) {
197
+ const item = byUnit.get(unit);
198
+ if (!item || item.error !== undefined || item.code.length > budget)
199
+ continue;
200
+ relatedFiles.push({ path: targetPath(unit), content: item.code });
201
+ budget -= item.code.length;
202
+ }
203
+ return {
204
+ unit: group.html,
205
+ targetPath: targetPath(group.html),
206
+ instruction: group.html.prompt,
207
+ currentCode,
208
+ issues,
209
+ relatedFiles,
210
+ ...(renderedProjectMemory ? { projectMemory: renderedProjectMemory } : {}),
211
+ };
212
+ }
213
+ /** Run opt-in integration checks and bounded repair over generated candidates. */
214
+ export async function reconcileGeneratedIntegrations(generated, options = {}) {
215
+ const results = generated.map((item) => ({ ...item }));
216
+ const byUnit = new Map(results.map((item) => [item.unit, item]));
217
+ const groups = webIntegrationGroups(results.map((item) => item.unit));
218
+ const maxAttempts = Math.max(0, options.maxIntegrationAttemptsPerUnit ?? 1);
219
+ const contextCharBudget = Math.max(0, options.contextCharBudget ?? DEFAULT_CONTEXT_CHAR_BUDGET);
220
+ let integrationRequests = 0;
221
+ const rejectGroup = (group, reason) => {
222
+ for (const unit of [group.html, ...group.related]) {
223
+ const item = byUnit.get(unit);
224
+ if (!item || item.error !== undefined)
225
+ continue;
226
+ item.error = reason;
227
+ item.code = "";
228
+ options.onProgress?.({ kind: "reject", unit, reason });
229
+ }
230
+ };
231
+ for (const group of groups) {
232
+ const groupItems = [group.html, ...group.related].map((unit) => byUnit.get(unit));
233
+ const unavailable = groupItems.filter((item) => item.error !== undefined || item.code.trim().length === 0);
234
+ if (unavailable.length > 0) {
235
+ rejectGroup(group, `cross-file integration group is incomplete because ${unavailable.map((item) => item.unit.sourcePath).join(", ")} did not produce an applicable candidate`);
236
+ continue;
237
+ }
238
+ const htmlItem = byUnit.get(group.html);
239
+ let issues = findHtmlIntegrationIssues(targetPath(group.html), htmlItem.code, group.related);
240
+ options.onProgress?.({ kind: "integration-check", unit: group.html, issues: issues.length });
241
+ if (issues.length === 0)
242
+ continue;
243
+ if (!options.integrate || maxAttempts === 0) {
244
+ rejectGroup(group, `cross-file integration validation failed: ${describeIssues(issues)}`);
245
+ continue;
246
+ }
247
+ let reconciled = false;
248
+ for (let attempt = 1; attempt <= maxAttempts; attempt += 1) {
249
+ const request = buildIntegrationRequest(group, htmlItem.code, issues, byUnit, contextCharBudget, options.projectMemory);
250
+ if (!request)
251
+ break;
252
+ const outbound = [request.currentCode, request.projectMemory ?? "", ...request.relatedFiles.map((file) => file.content)].join("\n");
253
+ if (scanSecrets(outbound).length > 0)
254
+ break;
255
+ options.onProgress?.({ kind: "integrate", unit: group.html, attempt, issues: issues.length });
256
+ integrationRequests += 1;
257
+ try {
258
+ const integratedCode = await options.integrate(request);
259
+ if (integratedCode.trim().length === 0 || integratedCode === htmlItem.code)
260
+ continue;
261
+ await validateGeneratedUnit(group.html, integratedCode);
262
+ const remaining = findHtmlIntegrationIssues(targetPath(group.html), integratedCode, group.related);
263
+ if (remaining.length > 0) {
264
+ issues = remaining;
265
+ continue;
266
+ }
267
+ htmlItem.code = integratedCode;
268
+ options.projectMemory?.remember(group.html, integratedCode);
269
+ reconciled = true;
270
+ break;
271
+ }
272
+ catch (error) {
273
+ if (error instanceof ContextSecurityError)
274
+ throw error;
275
+ // The request budget is consumed. A known-broken connected group is
276
+ // rejected below instead of being written partially.
277
+ }
278
+ }
279
+ if (!reconciled)
280
+ rejectGroup(group, `cross-file integration validation failed after bounded reconciliation: ${describeIssues(issues)}`);
281
+ }
282
+ return { results, integrationRequests, checkedTargets: groups.length };
283
+ }
284
+ //# sourceMappingURL=integration-validation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"integration-validation.js","sourceRoot":"","sources":["../../../src/agents/direct/integration-validation.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,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C;gBACH,MAAM,cAAc,GAAG,MAAM,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;gBACxD,IAAI,cAAc,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,IAAI,cAAc,KAAK,QAAQ,CAAC,IAAI;oBAAE,SAAS;gBACrF,MAAM,qBAAqB,CAAC,KAAK,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;gBACxD,MAAM,SAAS,GAAG,yBAAyB,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,cAAc,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;gBACnG,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBACzB,MAAM,GAAG,SAAS,CAAC;oBACnB,SAAS;gBACX,CAAC;gBACD,QAAQ,CAAC,IAAI,GAAG,cAAc,CAAC;gBAC/B,OAAO,CAAC,aAAa,EAAE,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;gBAC5D,UAAU,GAAG,IAAI,CAAC;gBAClB,MAAM;YACR,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,IAAI,KAAK,YAAY,oBAAoB;oBAAE,MAAM,KAAK,CAAC;gBACvD,oEAAoE;gBACpE,qDAAqD;YACvD,CAAC;QACH,CAAC;QACD,IAAI,CAAC,UAAU;YAAE,WAAW,CAAC,KAAK,EAAE,0EAA0E,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAC1I,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC;AACzE,CAAC"}
@@ -2,6 +2,14 @@ import type { ConversionUnit } from "./types.ts";
2
2
  export declare class ModelOutputError extends Error {
3
3
  constructor(message: string);
4
4
  }
5
- export declare function renderReceipt(units: readonly ConversionUnit[], provider: string, model: string, configuredLanguages: string | readonly string[]): string;
5
+ export interface ConditionalRequestAllowance {
6
+ integrationUpTo: number;
7
+ compilerRepairUpTo: number;
8
+ }
9
+ /** Conservative opt-in request ceilings for pre-generation disclosure. */
10
+ export declare function conditionalRequestAllowance(units: readonly ConversionUnit[], configuredLanguages: string | readonly string[]): ConditionalRequestAllowance;
11
+ export declare function renderReceipt(units: readonly ConversionUnit[], provider: string, model: string, configuredLanguages: string | readonly string[], options?: {
12
+ reconcileIntegrations?: boolean;
13
+ }): string;
6
14
  export declare function stripCodeFence(output: string): string;
7
15
  //# sourceMappingURL=presentation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"presentation.d.ts","sourceRoot":"","sources":["../../../src/agents/direct/presentation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,qBAAa,gBAAiB,SAAQ,KAAK;gBAC7B,OAAO,EAAE,MAAM;CAI5B;AAED,wBAAgB,aAAa,CAC3B,KAAK,EAAE,SAAS,cAAc,EAAE,EAChC,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,EACb,mBAAmB,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,GAC9C,MAAM,CAyCR;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAWrD"}
1
+ {"version":3,"file":"presentation.d.ts","sourceRoot":"","sources":["../../../src/agents/direct/presentation.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,qBAAa,gBAAiB,SAAQ,KAAK;gBAC7B,OAAO,EAAE,MAAM;CAI5B;AAED,MAAM,WAAW,2BAA2B;IAC1C,eAAe,EAAE,MAAM,CAAC;IACxB,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAED,0EAA0E;AAC1E,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,SAAS,cAAc,EAAE,EAChC,mBAAmB,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,GAC9C,2BAA2B,CAU7B;AAED,wBAAgB,aAAa,CAC3B,KAAK,EAAE,SAAS,cAAc,EAAE,EAChC,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,EACb,mBAAmB,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,EAC/C,OAAO,GAAE;IAAE,qBAAqB,CAAC,EAAE,OAAO,CAAA;CAAO,GAChD,MAAM,CAmDR;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAWrD"}