human-to-code 0.1.23 → 0.1.26
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/Readme.md +42 -29
- package/SECURITY.md +29 -17
- package/dist/agents/direct/application.d.ts +10 -0
- package/dist/agents/direct/application.d.ts.map +1 -1
- package/dist/agents/direct/application.js +63 -5
- package/dist/agents/direct/application.js.map +1 -1
- package/dist/agents/direct/generation-client.d.ts +16 -5
- package/dist/agents/direct/generation-client.d.ts.map +1 -1
- package/dist/agents/direct/generation-client.js +9 -4
- package/dist/agents/direct/generation-client.js.map +1 -1
- package/dist/agents/direct/index.d.ts +1 -0
- package/dist/agents/direct/index.d.ts.map +1 -1
- package/dist/agents/direct/index.js +1 -0
- package/dist/agents/direct/index.js.map +1 -1
- package/dist/agents/direct/integration-validation.d.ts +38 -15
- package/dist/agents/direct/integration-validation.d.ts.map +1 -1
- package/dist/agents/direct/integration-validation.js +305 -207
- package/dist/agents/direct/integration-validation.js.map +1 -1
- package/dist/agents/direct/language-relationships.d.ts +11 -0
- package/dist/agents/direct/language-relationships.d.ts.map +1 -0
- package/dist/agents/direct/language-relationships.js +55 -0
- package/dist/agents/direct/language-relationships.js.map +1 -0
- package/dist/agents/direct/presentation.d.ts +2 -1
- package/dist/agents/direct/presentation.d.ts.map +1 -1
- package/dist/agents/direct/presentation.js +5 -3
- package/dist/agents/direct/presentation.js.map +1 -1
- package/dist/agents/direct/program-diagnostics.d.ts.map +1 -1
- package/dist/agents/direct/program-diagnostics.js +20 -1
- package/dist/agents/direct/program-diagnostics.js.map +1 -1
- package/dist/agents/direct/project-contracts.d.ts.map +1 -1
- package/dist/agents/direct/project-contracts.js +53 -0
- package/dist/agents/direct/project-contracts.js.map +1 -1
- package/dist/agents/direct/project-memory.d.ts +2 -1
- package/dist/agents/direct/project-memory.d.ts.map +1 -1
- package/dist/agents/direct/project-memory.js +11 -59
- package/dist/agents/direct/project-memory.js.map +1 -1
- package/dist/agents/direct/staged-validation.d.ts +2 -0
- package/dist/agents/direct/staged-validation.d.ts.map +1 -1
- package/dist/agents/direct/staged-validation.js +25 -3
- package/dist/agents/direct/staged-validation.js.map +1 -1
- package/dist/agents/direct/types.d.ts +8 -0
- package/dist/agents/direct/types.d.ts.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +81 -18
- package/dist/cli.js.map +1 -1
- package/dist/prompts/direct-conversion.d.ts.map +1 -1
- package/dist/prompts/direct-conversion.js +4 -3
- package/dist/prompts/direct-conversion.js.map +1 -1
- package/dist/prompts/direct-integration.d.ts +28 -8
- package/dist/prompts/direct-integration.d.ts.map +1 -1
- package/dist/prompts/direct-integration.js +51 -17
- package/dist/prompts/direct-integration.js.map +1 -1
- package/dist/prompts/direct-repair.d.ts +2 -0
- package/dist/prompts/direct-repair.d.ts.map +1 -1
- package/dist/prompts/direct-repair.js +4 -0
- package/dist/prompts/direct-repair.js.map +1 -1
- package/docs/ARCHITECTURE.md +15 -8
- package/docs/MODULES.md +7 -6
- package/docs/SCALABILITY.md +12 -9
- package/docs/roadmap/html-css.md +4 -5
- package/package.json +1 -1
package/Readme.md
CHANGED
|
@@ -57,11 +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. When `direct.reconcileIntegrations` is explicitly enabled,
|
|
61
|
-
6.
|
|
62
|
-
7. Applies
|
|
60
|
+
5. When `direct.reconcileIntegrations` is explicitly enabled, audits ProjectMemory-evidenced groups of generated files across every supported language. A strict-JSON, read-only audit checks concrete imports/includes, modules/packages/namespaces, exports/signatures/calls, schemas/configuration, routes/templates/assets/selectors, and other evidenced contracts. Reported issues receive one target-scoped repair each and one verification audit; an unresolved connected 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. Stages JavaScript/TypeScript output in an in-memory candidate overlay. TypeScript receives combined semantic checking with the TypeScript Compiler API. JavaScript receives the same checking only when the project explicitly enables `checkJs` in `jsconfig.json`/`tsconfig.json` or the file uses `// @ts-check`; ordinary JavaScript is not rejected or rewritten for TypeScript-only inference diagnostics. Diagnostics are compared against the unchanged baseline, and an opted-in dependency group receives at most one bounded repair request per whole-file unit.
|
|
62
|
+
7. Applies output defensively. All successful whole `.human` outputs form one rollback-protected batch: if any whole-file candidate failed generation or validation, none of the batch is written; if exclusive creation fails partway, files created by that batch are removed. Inline markers retain per-marker isolation, exact stale-byte checks, and indentation preservation.
|
|
63
63
|
|
|
64
|
-
The direct converter writes code straight to the working tree. Its
|
|
64
|
+
The direct converter writes code straight to the working tree. Its static compiler validation for TypeScript and explicitly type-checked JavaScript 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).
|
|
65
65
|
|
|
66
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):
|
|
67
67
|
|
|
@@ -130,7 +130,7 @@ indentation.
|
|
|
130
130
|
|
|
131
131
|
The host does the orchestration; the model only writes code. For each unit the
|
|
132
132
|
host issues **one plain model completion** (no tool calls) and applies the
|
|
133
|
-
result by exact marker range; when
|
|
133
|
+
result by exact marker range; when TypeScript or explicitly enabled JavaScript project validation finds a
|
|
134
134
|
repairable cross-file error, a whole-file unit may receive **one additional
|
|
135
135
|
bounded repair completion** with the same provider and model. This is fast and
|
|
136
136
|
works with small models — a 1.5B coder model converts a four-marker file in
|
|
@@ -150,28 +150,34 @@ text generation work fine.
|
|
|
150
150
|
all planned outputs succeed, stores the complete conversion plan and renders
|
|
151
151
|
its target-relevant bounded subset with an explicit omitted count, supplies
|
|
152
152
|
exact relative references to likely companion files, and summarizes relevant
|
|
153
|
-
imports, exports/declarations,
|
|
154
|
-
|
|
155
|
-
|
|
153
|
+
imports/includes, exports/declarations, modules/packages/namespaces,
|
|
154
|
+
language-specific references and manifests, plus markup ids/classes/assets/inline handler calls,
|
|
155
|
+
stylesheet selectors/custom properties, and DOM selectors where relevant.
|
|
156
|
+
Ecosystem rules live in extensible profiles; the ProjectMemory and optional
|
|
157
|
+
reconciliation orchestration do not assume a web application. It is
|
|
156
158
|
rebuilt for each run rather than persisted, so it cannot become a stale cache.
|
|
157
159
|
Accepted candidates update the shared in-memory contracts before later files
|
|
158
160
|
are generated.
|
|
159
161
|
- **Candidate and write guards** — ambiguous fenced responses and malformed
|
|
160
162
|
candidates are retried; existing sibling files, stale inline markers, and
|
|
161
|
-
unsafe indentation changes are refused before mutation.
|
|
163
|
+
unsafe indentation changes are refused before mutation. Whole `.human`
|
|
164
|
+
outputs commit as one rollback-protected batch, so one failed candidate or
|
|
165
|
+
late exclusive-create failure cannot leave a knowingly partial generated
|
|
166
|
+
codebase.
|
|
162
167
|
- **Combined project validation (JS/TS)** — all accepted JavaScript/TypeScript
|
|
163
|
-
units are staged into an in-memory overlay
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
168
|
+
units are staged into an in-memory overlay. TypeScript is type-checked
|
|
169
|
+
together before any write; JavaScript semantic checking runs only when the
|
|
170
|
+
project or file opts into `checkJs`/`@ts-check`. Newly introduced cross-file
|
|
171
|
+
diagnostics reject the dependency-connected group after at most one bounded
|
|
172
|
+
repair attempt per whole-file unit.
|
|
167
173
|
Pre-existing baseline errors are never attributed to generated code. This is
|
|
168
174
|
static compilation, not sandbox execution, runtime testing, or API grounding.
|
|
169
|
-
- **Optional
|
|
170
|
-
`direct.reconcileIntegrations` defaults to `false`. When enabled,
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
+
- **Optional cross-language reconciliation** —
|
|
176
|
+
`direct.reconcileIntegrations` defaults to `false`. When enabled, the host
|
|
177
|
+
forms bounded relationship groups from ProjectMemory, asks for one strict
|
|
178
|
+
read-only audit, repairs only named generated targets, and verifies once.
|
|
179
|
+
Independent files are not coupled merely because they share a run. The
|
|
180
|
+
receipt discloses conservative audit and target-repair ceilings.
|
|
175
181
|
- **Clear, stable output** — a single truncated status line per marker
|
|
176
182
|
(`✓ app.ts (inline @human, line 12)` / `⊘ skipped … : <reason>`), plus an
|
|
177
183
|
in-place elapsed spinner while a completion is in flight.
|
|
@@ -185,15 +191,20 @@ references `styles.css` and `script.js`. After HTML is accepted, the CSS and
|
|
|
185
191
|
JavaScript requests see its generated ids and classes as a compact contract.
|
|
186
192
|
For a nested target, ProjectMemory computes the correct relative reference
|
|
187
193
|
such as `../styles.css`; it does not assume every file lives at the root.
|
|
194
|
+
The same mechanism describes Python modules, Rust crate modules, Go packages,
|
|
195
|
+
Java/C# namespaces and types, C/C++ headers, Ruby loaders, and same-language
|
|
196
|
+
companions. Those conventions are profile data; the grouping, audit, repair,
|
|
197
|
+
and verification control flow is shared.
|
|
188
198
|
|
|
189
199
|
ProjectMemory is evidence for generation, not proof of correctness. Its prompt
|
|
190
200
|
contract tells the model to connect genuine companions without importing every
|
|
191
201
|
file it sees. JS/TS relationships still receive combined compiler validation.
|
|
192
|
-
|
|
193
|
-
optional `direct.reconcileIntegrations` pass
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
Use the guided path when
|
|
202
|
+
Cross-file relationships are not runtime-tested by the direct engine. The
|
|
203
|
+
optional `direct.reconcileIntegrations` pass audits compact contracts across
|
|
204
|
+
supported languages and verifies any target-scoped model repair once, but it is
|
|
205
|
+
deliberately off by default and is not a compiler, runtime, or sandbox proof for
|
|
206
|
+
Python, Rust, web projects, or any other ecosystem. Use the guided path when
|
|
207
|
+
integration must be sandbox-verified.
|
|
197
208
|
|
|
198
209
|
```bash
|
|
199
210
|
# Deterministic engine — works with small models:
|
|
@@ -312,11 +323,13 @@ This complete local-Ollama example shows the policy fields:
|
|
|
312
323
|
`direct.reconcileIntegrations` is an opt-in post-generation safety net. The
|
|
313
324
|
default `false` keeps the established ProjectMemory first pass unchanged and
|
|
314
325
|
adds no provider calls, checks, group coupling, or receipt fields. With `true`,
|
|
315
|
-
the receipt/JSON plan discloses
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
326
|
+
the receipt/JSON plan discloses conservative audit and target-repair ceilings.
|
|
327
|
+
ProjectMemory supplies structured relationships using extensible language
|
|
328
|
+
profiles; the generic orchestrator audits only connected generated groups,
|
|
329
|
+
validates strict JSON against real generated paths, repairs each named target at
|
|
330
|
+
most once, and performs at most one verification audit. A failed bounded cycle
|
|
331
|
+
rejects that evidenced group instead of writing a known-inconsistent partial
|
|
332
|
+
result.
|
|
320
333
|
|
|
321
334
|
The direct engine uses `privacy.maxContextTokens` as the combined upper bound
|
|
322
335
|
for FileMemory and ProjectMemory. ProjectMemory additionally caps each rendered
|
package/SECURITY.md
CHANGED
|
@@ -35,9 +35,11 @@ and preserves marker indentation. Invalid or stale units are retried within the
|
|
|
35
35
|
bounded generation policy and then skipped without mutation.
|
|
36
36
|
|
|
37
37
|
JavaScript/TypeScript units additionally pass staged combined validation: the
|
|
38
|
-
generated files form an in-memory candidate overlay
|
|
39
|
-
unchanged
|
|
40
|
-
|
|
38
|
+
generated files form an in-memory candidate overlay and the working tree stays
|
|
39
|
+
unchanged. The TypeScript Compiler API type-checks TypeScript, while JavaScript
|
|
40
|
+
semantic checking runs only when `checkJs` or `@ts-check` explicitly opts in;
|
|
41
|
+
plain JavaScript is not rewritten to satisfy an unrequested TypeScript policy.
|
|
42
|
+
Newly introduced cross-file
|
|
41
43
|
diagnostics (wrong imports/exports, missing members, argument counts, literal
|
|
42
44
|
unions, object shapes, readonly violations, incompatible calls) reject the
|
|
43
45
|
whole dependency-connected group during validation; if safe isolation cannot
|
|
@@ -49,10 +51,17 @@ data. Generated candidate
|
|
|
49
51
|
content is secret-scanned before it may leave the host. No project code is
|
|
50
52
|
imported or executed and no project scripts run during this validation.
|
|
51
53
|
|
|
54
|
+
Whole-file direct outputs have a final batch barrier. Any failed whole-file
|
|
55
|
+
candidate withholds every whole-file output in that run. Successful candidates
|
|
56
|
+
are then exclusively created as a rollback-protected batch; if a later create
|
|
57
|
+
fails, only files created by that batch are removed. Inline markers retain
|
|
58
|
+
their separate stale-range and per-marker behavior.
|
|
59
|
+
|
|
52
60
|
Direct ProjectMemory is rebuilt from the static discovery inventory for each
|
|
53
61
|
run. It may send project-relative filenames and compact source-derived
|
|
54
|
-
contracts (declarations/imports,
|
|
55
|
-
|
|
62
|
+
contracts (declarations/imports/includes, modules/packages/namespaces,
|
|
63
|
+
language-specific references, markup/style/asset contracts where relevant,
|
|
64
|
+
and limited package metadata) to the selected model. It also
|
|
56
65
|
contains the planned post-conversion output tree and other `.human` purposes so
|
|
57
66
|
the model can coordinate files. Protected paths, configured ignored/excluded
|
|
58
67
|
paths, oversized/unreadable files, and credential-bearing contracts are
|
|
@@ -62,16 +71,18 @@ no `context --explain` preview. Remote direct conversion therefore remains
|
|
|
62
71
|
blocked until explicit project-level remote-provider consent; use local Ollama
|
|
63
72
|
or the guided flow when this compact context is not appropriate to transmit.
|
|
64
73
|
|
|
65
|
-
Post-generation
|
|
74
|
+
Post-generation integration reconciliation is a separate explicit opt-in
|
|
66
75
|
(`direct.reconcileIntegrations`, default `false`). When disabled, it performs
|
|
67
|
-
no audit and sends no additional request. When enabled,
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
credential-scanned
|
|
73
|
-
|
|
74
|
-
|
|
76
|
+
no audit and sends no additional request. When enabled, ProjectMemory supplies
|
|
77
|
+
structured language relationships and the generic orchestrator forms bounded
|
|
78
|
+
generated-file groups. A read-only audit must return strict JSON whose target
|
|
79
|
+
and related paths are members of that exact group. Each reported target may
|
|
80
|
+
receive one bounded repair followed by one verification audit. Audit/repair
|
|
81
|
+
bundles are credential-scanned; file purposes, contracts, diagnostics, and
|
|
82
|
+
source are prompt-isolated as untrusted evidence. Malformed output, invented
|
|
83
|
+
paths, exhausted context, or unresolved issues reject the connected opt-in
|
|
84
|
+
group before writing. This is model-assisted static consistency checking, not
|
|
85
|
+
compiler, runtime, or sandbox verification.
|
|
75
86
|
|
|
76
87
|
These controls prevent the specific malformed-output, overwrite, stale-range,
|
|
77
88
|
indentation, and cross-file-contract failures they check. Static compilation
|
|
@@ -79,9 +90,10 @@ is stronger than syntax parsing, but it does not prove runtime behavior,
|
|
|
79
90
|
external-API grounding, project-wide security properties, or test success,
|
|
80
91
|
and it never executes the candidate in a sandbox or claims `VERIFIED`. Other
|
|
81
92
|
direct programming languages keep their per-file structural validation level;
|
|
82
|
-
|
|
83
|
-
reconciliation adds
|
|
84
|
-
the guided contract and validation path when stronger boundaries
|
|
93
|
+
Non-JS/TS languages normally keep their per-file syntax/structure gates; the
|
|
94
|
+
optional generic reconciliation adds the bounded contract audit described
|
|
95
|
+
above. Use the guided contract and validation path when stronger boundaries
|
|
96
|
+
are required.
|
|
85
97
|
|
|
86
98
|
### The reviewed contract owns authority
|
|
87
99
|
|
|
@@ -3,6 +3,16 @@ import type { ConversionUnit } from "./types.ts";
|
|
|
3
3
|
export declare class DirectApplicationError extends Error {
|
|
4
4
|
constructor(message: string);
|
|
5
5
|
}
|
|
6
|
+
export interface WholeFileApplication {
|
|
7
|
+
unit: ConversionUnit;
|
|
8
|
+
code: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Exclusively create a complete whole-file conversion batch. If any create
|
|
12
|
+
* loses a race or fails, remove only the files created by this call so a
|
|
13
|
+
* multi-file project is never knowingly left half-applied.
|
|
14
|
+
*/
|
|
15
|
+
export declare function applyWholeFileBatch(root: string, applications: readonly WholeFileApplication[]): Promise<string[]>;
|
|
6
16
|
/** Apply one already-generated unit and return the project-relative path changed. */
|
|
7
17
|
export declare function applyUnit(root: string, unit: ConversionUnit, code: string): Promise<string>;
|
|
8
18
|
export declare function pathExists(target: string): Promise<boolean>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"application.d.ts","sourceRoot":"","sources":["../../../src/agents/direct/application.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAgB,MAAM,WAAW,CAAC;AAElD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,qBAAa,sBAAuB,SAAQ,KAAK;gBACnC,OAAO,EAAE,MAAM;CAI5B;AAED,qFAAqF;AACrF,wBAAsB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"application.d.ts","sourceRoot":"","sources":["../../../src/agents/direct/application.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAgB,MAAM,WAAW,CAAC;AAElD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,qBAAa,sBAAuB,SAAQ,KAAK;gBACnC,OAAO,EAAE,MAAM;CAI5B;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,cAAc,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;CACd;AAWD;;;;GAIG;AACH,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,SAAS,oBAAoB,EAAE,GAC5C,OAAO,CAAC,MAAM,EAAE,CAAC,CA4CnB;AAED,qFAAqF;AACrF,wBAAsB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CA2BjG;AAED,wBAAsB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAOjE;AAED,OAAO,EAAE,OAAO,EAAE,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { readFile, stat, writeFile } from "node:fs/promises";
|
|
1
|
+
import { readFile, stat, unlink, writeFile } from "node:fs/promises";
|
|
2
2
|
import { dirname, resolve, sep } from "node:path";
|
|
3
3
|
import { replaceInlineMarker } from "./replacement.js";
|
|
4
4
|
export class DirectApplicationError extends Error {
|
|
@@ -7,14 +7,72 @@ export class DirectApplicationError extends Error {
|
|
|
7
7
|
this.name = "DirectApplicationError";
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
|
+
function wholeFileTarget(absoluteRoot, unit) {
|
|
11
|
+
if (unit.kind !== "file")
|
|
12
|
+
throw new DirectApplicationError("Whole-file batch contains an inline unit.");
|
|
13
|
+
const target = resolve(absoluteRoot, unit.outputPath);
|
|
14
|
+
if (!target.startsWith(absoluteRoot + sep)) {
|
|
15
|
+
throw new DirectApplicationError(`Refusing to write outside the project root: ${unit.outputPath}`);
|
|
16
|
+
}
|
|
17
|
+
return target;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Exclusively create a complete whole-file conversion batch. If any create
|
|
21
|
+
* loses a race or fails, remove only the files created by this call so a
|
|
22
|
+
* multi-file project is never knowingly left half-applied.
|
|
23
|
+
*/
|
|
24
|
+
export async function applyWholeFileBatch(root, applications) {
|
|
25
|
+
if (applications.length === 0)
|
|
26
|
+
return [];
|
|
27
|
+
const absoluteRoot = resolve(root);
|
|
28
|
+
const targets = applications.map(({ unit }) => wholeFileTarget(absoluteRoot, unit));
|
|
29
|
+
if (new Set(targets).size !== targets.length) {
|
|
30
|
+
throw new DirectApplicationError("Whole-file batch contains duplicate output targets.");
|
|
31
|
+
}
|
|
32
|
+
const created = [];
|
|
33
|
+
try {
|
|
34
|
+
for (let index = 0; index < applications.length; index += 1) {
|
|
35
|
+
const application = applications[index];
|
|
36
|
+
const target = targets[index];
|
|
37
|
+
const expected = application.code.endsWith("\n") ? application.code : `${application.code}\n`;
|
|
38
|
+
try {
|
|
39
|
+
await writeFile(target, expected, { flag: "wx" });
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
if (error.code === "EEXIST") {
|
|
43
|
+
throw new DirectApplicationError(`Refusing to overwrite existing generated target: ${application.unit.outputPath}`);
|
|
44
|
+
}
|
|
45
|
+
throw error;
|
|
46
|
+
}
|
|
47
|
+
created.push({ target, expected });
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
const rollbackFailures = [];
|
|
52
|
+
for (const { target, expected } of [...created].reverse()) {
|
|
53
|
+
try {
|
|
54
|
+
if (await readFile(target, "utf8") !== expected) {
|
|
55
|
+
rollbackFailures.push(`${target} changed after creation and was left intact`);
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
await unlink(target);
|
|
59
|
+
}
|
|
60
|
+
catch (rollbackError) {
|
|
61
|
+
rollbackFailures.push(rollbackError instanceof Error ? rollbackError.message : String(rollbackError));
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
65
|
+
throw new DirectApplicationError(rollbackFailures.length === 0
|
|
66
|
+
? `Whole-file batch was not applied: ${reason}`
|
|
67
|
+
: `Whole-file batch failed and rollback was incomplete: ${reason}; ${rollbackFailures.join("; ")}`);
|
|
68
|
+
}
|
|
69
|
+
return applications.map(({ unit }) => unit.outputPath);
|
|
70
|
+
}
|
|
10
71
|
/** Apply one already-generated unit and return the project-relative path changed. */
|
|
11
72
|
export async function applyUnit(root, unit, code) {
|
|
12
73
|
const absoluteRoot = resolve(root);
|
|
13
74
|
if (unit.kind === "file") {
|
|
14
|
-
const target =
|
|
15
|
-
if (!target.startsWith(absoluteRoot + sep)) {
|
|
16
|
-
throw new Error(`Refusing to write outside the project root: ${unit.outputPath}`);
|
|
17
|
-
}
|
|
75
|
+
const target = wholeFileTarget(absoluteRoot, unit);
|
|
18
76
|
try {
|
|
19
77
|
await writeFile(target, code.endsWith("\n") ? code : `${code}\n`, { flag: "wx" });
|
|
20
78
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"application.js","sourceRoot":"","sources":["../../../src/agents/direct/application.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"application.js","sourceRoot":"","sources":["../../../src/agents/direct/application.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAGvD,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IAC/C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;IACvC,CAAC;CACF;AAOD,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,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,KAAM,CAAC;IACnC,IAAI,QAAgB,CAAC;IACrB,IAAI,CAAC;QACH,QAAQ,GAAG,mBAAmB,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC;IACtF,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,sBAAsB,CAC9B,GAAG,IAAI,CAAC,UAAU,KAAK,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAChF,CAAC;IACJ,CAAC;IACD,MAAM,SAAS,CAAC,IAAI,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC;IAC/C,OAAO,IAAI,CAAC,UAAU,CAAC;AACzB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,MAAc;IAC7C,IAAI,CAAC;QACH,MAAM,IAAI,CAAC,MAAM,CAAC,CAAC;QACnB,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,OAAO,EAAE,OAAO,EAAE,CAAC"}
|
|
@@ -1,24 +1,35 @@
|
|
|
1
|
-
import { type DirectIntegrationIssue, type
|
|
1
|
+
import { type DirectIntegrationAuditFile, type DirectIntegrationIssue, type DirectIntegrationRelationship } from "../../prompts/direct-integration.ts";
|
|
2
2
|
import { type DirectRepairDiagnostic, type DirectRepairRelatedFile } from "../../prompts/direct-repair.ts";
|
|
3
3
|
import type { GenerateOptions } from "./types.ts";
|
|
4
4
|
/** Send one direct-conversion request to OpenAI-compatible chat or Ollama. */
|
|
5
5
|
export declare function generateCode(instruction: string, options: GenerateOptions): Promise<string>;
|
|
6
|
-
export interface
|
|
6
|
+
export interface IntegrationAuditGenerationRequest {
|
|
7
|
+
files: readonly DirectIntegrationAuditFile[];
|
|
8
|
+
relationships: readonly DirectIntegrationRelationship[];
|
|
9
|
+
projectMemory?: string;
|
|
10
|
+
}
|
|
11
|
+
/** Send one opt-in, read-only, cross-language integration audit request. */
|
|
12
|
+
export declare function generateIntegrationAudit(request: IntegrationAuditGenerationRequest, options: GenerateOptions): Promise<string>;
|
|
13
|
+
export interface IntegrationRepairGenerationRequest {
|
|
7
14
|
targetPath: string;
|
|
8
15
|
instruction: string;
|
|
9
16
|
currentCode: string;
|
|
10
17
|
issues: readonly DirectIntegrationIssue[];
|
|
11
|
-
relatedFiles:
|
|
18
|
+
relatedFiles: ReadonlyArray<{
|
|
19
|
+
path: string;
|
|
20
|
+
content: string;
|
|
21
|
+
}>;
|
|
12
22
|
projectMemory?: string;
|
|
13
23
|
}
|
|
14
|
-
/** Send one
|
|
15
|
-
export declare function
|
|
24
|
+
/** Send one bounded target repair after a generic integration audit. */
|
|
25
|
+
export declare function generateIntegrationRepairCode(request: IntegrationRepairGenerationRequest, options: GenerateOptions): Promise<string>;
|
|
16
26
|
export interface RepairGenerationRequest {
|
|
17
27
|
targetPath: string;
|
|
18
28
|
inline: boolean;
|
|
19
29
|
instruction: string;
|
|
20
30
|
currentCode: string;
|
|
21
31
|
diagnostics: readonly DirectRepairDiagnostic[];
|
|
32
|
+
hints?: readonly string[];
|
|
22
33
|
relatedFiles: readonly DirectRepairRelatedFile[];
|
|
23
34
|
projectMemory?: string;
|
|
24
35
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generation-client.d.ts","sourceRoot":"","sources":["../../../src/agents/direct/generation-client.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"generation-client.d.ts","sourceRoot":"","sources":["../../../src/agents/direct/generation-client.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,0BAA0B,EAC/B,KAAK,sBAAsB,EAC3B,KAAK,6BAA6B,EACnC,MAAM,qCAAqC,CAAC;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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,5 +1,5 @@
|
|
|
1
1
|
import { buildDirectConversionPrompt } from "../../prompts/direct-conversion.js";
|
|
2
|
-
import {
|
|
2
|
+
import { buildDirectIntegrationAuditPrompt, buildDirectIntegrationRepairPrompt, } from "../../prompts/direct-integration.js";
|
|
3
3
|
import { buildDirectRepairPrompt, } from "../../prompts/direct-repair.js";
|
|
4
4
|
import { languageProfile } from "./languages.js";
|
|
5
5
|
import { stripCodeFence } from "./presentation.js";
|
|
@@ -61,10 +61,15 @@ export async function generateCode(instruction, options) {
|
|
|
61
61
|
});
|
|
62
62
|
return requestChatCompletion(prompt, options);
|
|
63
63
|
}
|
|
64
|
-
/** Send one opt-in
|
|
65
|
-
export async function
|
|
64
|
+
/** Send one opt-in, read-only, cross-language integration audit request. */
|
|
65
|
+
export async function generateIntegrationAudit(request, options) {
|
|
66
|
+
const prompt = buildDirectIntegrationAuditPrompt(request);
|
|
67
|
+
return requestChatCompletion(prompt, options);
|
|
68
|
+
}
|
|
69
|
+
/** Send one bounded target repair after a generic integration audit. */
|
|
70
|
+
export async function generateIntegrationRepairCode(request, options) {
|
|
66
71
|
const profile = languageProfile(options.language);
|
|
67
|
-
const prompt =
|
|
72
|
+
const prompt = buildDirectIntegrationRepairPrompt({ languageLabel: profile.label, ...request });
|
|
68
73
|
return requestChatCompletion(prompt, options);
|
|
69
74
|
}
|
|
70
75
|
/** Send one bounded cross-file repair request with the same provider and model. */
|
|
@@ -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,
|
|
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,iCAAiC,EACjC,kCAAkC,GAInC,MAAM,qCAAqC,CAAC;AAC7C,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;IACnF,IAAI,OAAO,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;QAClC,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,IAAI,2BAA2B,CAAC;QAC5D,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,IAAI,mBAAmB,EAAE;YACvD,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;gBAClC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,UAAU,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aACzE;YACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;gBACnB,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,QAAQ,EAAE;oBACR,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE;oBAC1C,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,IAAI,EAAE;iBACvC;gBACD,WAAW,EAAE,CAAC;aACf,CAAC;YACF,MAAM,EAAE,OAAO,CAAC,MAAM;SACvB,CAAC,CAAC;QACH,IAAI,CAAC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AE,GAAG,OAAO,EAAE,CAAC,CAAC;IAChG,OAAO,qBAAqB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAChD,CAAC;AAaD,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"}
|
|
@@ -5,6 +5,7 @@ export * from "./marker-parser.ts";
|
|
|
5
5
|
export * from "./file-memory.ts";
|
|
6
6
|
export * from "./project-memory.ts";
|
|
7
7
|
export * from "./project-contracts.ts";
|
|
8
|
+
export * from "./language-relationships.ts";
|
|
8
9
|
export * from "./discovery.ts";
|
|
9
10
|
export * from "./presentation.ts";
|
|
10
11
|
export * from "./generation-client.ts";
|
|
@@ -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,6BAA6B,CAAC;AAC5C,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,6BAA6B,CAAC;AAC5C,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"}
|
|
@@ -5,6 +5,7 @@ export * from "./marker-parser.js";
|
|
|
5
5
|
export * from "./file-memory.js";
|
|
6
6
|
export * from "./project-memory.js";
|
|
7
7
|
export * from "./project-contracts.js";
|
|
8
|
+
export * from "./language-relationships.js";
|
|
8
9
|
export * from "./discovery.js";
|
|
9
10
|
export * from "./presentation.js";
|
|
10
11
|
export * from "./generation-client.js";
|
|
@@ -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,6BAA6B,CAAC;AAC5C,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,6BAA6B,CAAC;AAC5C,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"}
|
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
import type { DirectIntegrationIssue } from "../../prompts/direct-integration.ts";
|
|
2
|
-
import type { ConversionUnit, GeneratedConversionUnit, ProjectMemoryProvider } from "./types.ts";
|
|
3
|
-
export interface
|
|
1
|
+
import type { DirectIntegrationAuditFile, DirectIntegrationIssue, DirectIntegrationRelationship } from "../../prompts/direct-integration.ts";
|
|
2
|
+
import type { ConversionUnit, GeneratedConversionUnit, ProjectMemoryProvider, ProjectRelationship } from "./types.ts";
|
|
3
|
+
export interface IntegrationAuditRequest {
|
|
4
|
+
/** Representative unit used for provider defaults and target-specific memory. */
|
|
5
|
+
unit: ConversionUnit;
|
|
6
|
+
units: ConversionUnit[];
|
|
7
|
+
files: DirectIntegrationAuditFile[];
|
|
8
|
+
relationships: DirectIntegrationRelationship[];
|
|
9
|
+
projectMemory?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface IntegrationRepairRequest {
|
|
4
12
|
unit: ConversionUnit;
|
|
5
13
|
targetPath: string;
|
|
6
14
|
instruction: string;
|
|
@@ -12,12 +20,17 @@ export interface IntegrationRequest {
|
|
|
12
20
|
}>;
|
|
13
21
|
projectMemory?: string;
|
|
14
22
|
}
|
|
23
|
+
export interface IntegrationAuditResult {
|
|
24
|
+
status: "consistent" | "issues";
|
|
25
|
+
issues: DirectIntegrationIssue[];
|
|
26
|
+
}
|
|
15
27
|
export type IntegrationProgress = {
|
|
16
|
-
kind: "integration-
|
|
28
|
+
kind: "integration-audit";
|
|
17
29
|
unit: ConversionUnit;
|
|
18
|
-
|
|
30
|
+
pass: number;
|
|
31
|
+
files: number;
|
|
19
32
|
} | {
|
|
20
|
-
kind: "
|
|
33
|
+
kind: "integration-repair";
|
|
21
34
|
unit: ConversionUnit;
|
|
22
35
|
attempt: number;
|
|
23
36
|
issues: number;
|
|
@@ -27,21 +40,31 @@ export type IntegrationProgress = {
|
|
|
27
40
|
reason: string;
|
|
28
41
|
};
|
|
29
42
|
export interface IntegrationValidationOptions {
|
|
30
|
-
|
|
31
|
-
|
|
43
|
+
audit?: (request: IntegrationAuditRequest) => Promise<string>;
|
|
44
|
+
repair?: (request: IntegrationRepairRequest) => Promise<string>;
|
|
45
|
+
/** Initial audit plus one verification audit by default. */
|
|
46
|
+
maxAuditPassesPerGroup?: number;
|
|
47
|
+
/** One target-scoped repair per generated file by default. */
|
|
48
|
+
maxRepairAttemptsPerUnit?: number;
|
|
32
49
|
contextCharBudget?: number;
|
|
33
50
|
projectMemory?: ProjectMemoryProvider;
|
|
34
51
|
onProgress?: (event: IntegrationProgress) => void;
|
|
35
52
|
}
|
|
36
53
|
export interface IntegrationValidationOutcome {
|
|
37
54
|
results: GeneratedConversionUnit[];
|
|
38
|
-
|
|
39
|
-
|
|
55
|
+
auditRequests: number;
|
|
56
|
+
repairRequests: number;
|
|
57
|
+
checkedGroups: number;
|
|
40
58
|
}
|
|
41
|
-
/**
|
|
42
|
-
export declare function
|
|
43
|
-
/**
|
|
44
|
-
export declare function
|
|
45
|
-
|
|
59
|
+
/** Strictly validate the model's audit JSON against the exact generated group. */
|
|
60
|
+
export declare function parseIntegrationAuditOutput(output: string, allowedPaths: ReadonlySet<string>): IntegrationAuditResult;
|
|
61
|
+
/** Conservative pre-run ceiling: two audits and one repair per whole-file unit. */
|
|
62
|
+
export declare function potentialIntegrationRequests(units: readonly ConversionUnit[]): {
|
|
63
|
+
auditUpTo: number;
|
|
64
|
+
repairUpTo: number;
|
|
65
|
+
};
|
|
66
|
+
/** Audit, repair, and verify generated relationship groups without writing. */
|
|
46
67
|
export declare function reconcileGeneratedIntegrations(generated: readonly GeneratedConversionUnit[], options?: IntegrationValidationOptions): Promise<IntegrationValidationOutcome>;
|
|
68
|
+
/** Helper for tests and alternative ProjectMemory implementations. */
|
|
69
|
+
export declare function generatedRelationshipsFor(unit: ConversionUnit, projectMemory: ProjectMemoryProvider): readonly ProjectRelationship[];
|
|
47
70
|
//# sourceMappingURL=integration-validation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integration-validation.d.ts","sourceRoot":"","sources":["../../../src/agents/direct/integration-validation.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"integration-validation.d.ts","sourceRoot":"","sources":["../../../src/agents/direct/integration-validation.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EACV,0BAA0B,EAC1B,sBAAsB,EACtB,6BAA6B,EAC9B,MAAM,qCAAqC,CAAC;AAG7C,OAAO,KAAK,EACV,cAAc,EACd,uBAAuB,EACvB,qBAAqB,EACrB,mBAAmB,EAC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