human-to-code 0.1.12 → 0.1.14
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 +33 -45
- package/assets/banner.svg +9 -14
- package/assets/brand/social-card.svg +6 -6
- package/dist/agents/direct/application.d.ts +7 -0
- package/dist/agents/direct/application.d.ts.map +1 -0
- package/dist/agents/direct/application.js +30 -0
- package/dist/agents/direct/application.js.map +1 -0
- package/dist/agents/direct/discovery.d.ts +4 -0
- package/dist/agents/direct/discovery.d.ts.map +1 -0
- package/dist/agents/direct/discovery.js +101 -0
- package/dist/agents/direct/discovery.js.map +1 -0
- package/dist/agents/direct/file-memory.d.ts +20 -0
- package/dist/agents/direct/file-memory.d.ts.map +1 -0
- package/dist/agents/direct/file-memory.js +174 -0
- package/dist/agents/direct/file-memory.js.map +1 -0
- package/dist/agents/direct/generation-client.d.ts +4 -0
- package/dist/agents/direct/generation-client.d.ts.map +1 -0
- package/dist/agents/direct/generation-client.js +56 -0
- package/dist/agents/direct/generation-client.js.map +1 -0
- package/dist/agents/direct/index.d.ts +10 -0
- package/dist/agents/direct/index.d.ts.map +1 -0
- package/dist/agents/direct/index.js +10 -0
- package/dist/agents/direct/index.js.map +1 -0
- package/dist/agents/direct/languages.d.ts +5 -0
- package/dist/agents/direct/languages.d.ts.map +1 -0
- package/dist/agents/direct/languages.js +17 -0
- package/dist/agents/direct/languages.js.map +1 -0
- package/dist/agents/direct/marker-parser.d.ts +8 -0
- package/dist/agents/direct/marker-parser.d.ts.map +1 -0
- package/dist/agents/direct/marker-parser.js +68 -0
- package/dist/agents/direct/marker-parser.js.map +1 -0
- package/dist/agents/direct/presentation.d.ts +4 -0
- package/dist/agents/direct/presentation.d.ts.map +1 -0
- package/dist/agents/direct/presentation.js +28 -0
- package/dist/agents/direct/presentation.js.map +1 -0
- package/dist/agents/direct/types.d.ts +74 -0
- package/dist/agents/direct/types.d.ts.map +1 -0
- package/dist/agents/direct/types.js +2 -0
- package/dist/agents/direct/types.js.map +1 -0
- package/dist/agents/guided/api-grounding.d.ts +6 -0
- package/dist/agents/guided/api-grounding.d.ts.map +1 -0
- package/dist/agents/guided/api-grounding.js +158 -0
- package/dist/agents/guided/api-grounding.js.map +1 -0
- package/dist/agents/guided/index.d.ts +7 -0
- package/dist/agents/guided/index.d.ts.map +1 -0
- package/dist/agents/guided/index.js +7 -0
- package/dist/agents/guided/index.js.map +1 -0
- package/dist/agents/guided/patch-diff.d.ts +4 -0
- package/dist/agents/guided/patch-diff.d.ts.map +1 -0
- package/dist/agents/guided/patch-diff.js +31 -0
- package/dist/agents/guided/patch-diff.js.map +1 -0
- package/dist/agents/guided/types.d.ts +55 -0
- package/dist/agents/guided/types.d.ts.map +1 -0
- package/dist/agents/guided/types.js +2 -0
- package/dist/agents/guided/types.js.map +1 -0
- package/dist/agents/guided/workflow.d.ts +17 -0
- package/dist/agents/guided/workflow.d.ts.map +1 -0
- package/dist/agents/guided/workflow.js +1360 -0
- package/dist/agents/guided/workflow.js.map +1 -0
- package/dist/agents/guided/workspace-policy.d.ts +9 -0
- package/dist/agents/guided/workspace-policy.d.ts.map +1 -0
- package/dist/agents/guided/workspace-policy.js +83 -0
- package/dist/agents/guided/workspace-policy.js.map +1 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +7 -107
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/pipeline/simple.d.ts +3 -160
- package/dist/pipeline/simple.d.ts.map +1 -1
- package/dist/pipeline/simple.js +3 -502
- package/dist/pipeline/simple.js.map +1 -1
- package/dist/pipeline/workflow.d.ts +5 -66
- package/dist/pipeline/workflow.d.ts.map +1 -1
- package/dist/pipeline/workflow.js +5 -1642
- package/dist/pipeline/workflow.js.map +1 -1
- package/dist/prompts/direct-conversion.d.ts +13 -0
- package/dist/prompts/direct-conversion.d.ts.map +1 -0
- package/dist/prompts/direct-conversion.js +35 -0
- package/dist/prompts/direct-conversion.js.map +1 -0
- package/dist/prompts/guided-patch.d.ts +14 -0
- package/dist/prompts/guided-patch.d.ts.map +1 -0
- package/dist/prompts/guided-patch.js +41 -0
- package/dist/prompts/guided-patch.js.map +1 -0
- package/dist/prompts/guided-repair.d.ts +12 -0
- package/dist/prompts/guided-repair.d.ts.map +1 -0
- package/dist/prompts/guided-repair.js +30 -0
- package/dist/prompts/guided-repair.js.map +1 -0
- package/dist/prompts/index.d.ts +6 -0
- package/dist/prompts/index.d.ts.map +1 -0
- package/dist/prompts/index.js +6 -0
- package/dist/prompts/index.js.map +1 -0
- package/dist/prompts/provider-output.d.ts +4 -0
- package/dist/prompts/provider-output.d.ts.map +1 -0
- package/dist/prompts/provider-output.js +12 -0
- package/dist/prompts/provider-output.js.map +1 -0
- package/dist/providers/providers.d.ts.map +1 -1
- package/dist/providers/providers.js +2 -10
- package/dist/providers/providers.js.map +1 -1
- package/docs/ARCHITECTURE.md +30 -28
- package/docs/MODULES.md +46 -8
- package/docs/SCALABILITY.md +10 -8
- package/docs/roadmap/README.md +1 -1
- package/docs/roadmap/ruby.md +1 -1
- package/package.json +1 -8
- package/dist/pipeline/deep-agent.d.ts +0 -242
- package/dist/pipeline/deep-agent.d.ts.map +0 -1
- package/dist/pipeline/deep-agent.js +0 -265
- package/dist/pipeline/deep-agent.js.map +0 -1
package/Readme.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<img src="assets/banner.svg" alt="human-to-code —
|
|
2
|
+
<img src="assets/banner.svg" alt="human-to-code — write intent in plain language, compile it to real code" width="100%">
|
|
3
3
|
</p>
|
|
4
4
|
|
|
5
5
|
<p align="center">
|
|
@@ -9,7 +9,12 @@
|
|
|
9
9
|
<a href="CONTRIBUTING.md"><img alt="contributions welcome" src="https://img.shields.io/badge/contributions-welcome-brightgreen"></a>
|
|
10
10
|
</p>
|
|
11
11
|
|
|
12
|
-
`human-to-code`
|
|
12
|
+
`human-to-code` turns natural-language change requests — whole `.human` files or inline `@human` markers — into code. It has two entry points:
|
|
13
|
+
|
|
14
|
+
- **Direct converter** (the default `npx human-to-code .`): discovers each request and turns it straight into code, with a receipt and confirmation. Fast, works with small local models, and writes to the working tree **without** a change contract or sandbox validation.
|
|
15
|
+
- **Guided pipeline** (`human-to-code guided`): the security-constrained, production-architecture path. It statically analyzes the host project, binds the request to a versioned JSON change contract, limits what an LLM can see and request, validates the candidate in an isolated snapshot, and keeps application as a separate explicit action.
|
|
16
|
+
|
|
17
|
+
The guided pipeline is shown below:
|
|
13
18
|
|
|
14
19
|
```text
|
|
15
20
|
static project analysis
|
|
@@ -25,12 +30,12 @@ unchanged baseline vs candidate in a strong sandbox
|
|
|
25
30
|
reviewed diff ── explicit apply only after VERIFIED ── exact rollback artifact
|
|
26
31
|
```
|
|
27
32
|
|
|
28
|
-
This is not a universal deterministic source-to-source compiler. The LLM writes framework-specific patch operations, but it does not choose its own scope, validation commands, credentials, documentation sources, or acceptance criteria.
|
|
33
|
+
This is not a universal deterministic source-to-source compiler. The LLM writes framework-specific patch operations, but it does not choose its own scope, validation commands, credentials, documentation sources, or acceptance criteria. The `.strict.human.json` change contract, `VERIFIED` status, and `apply`/`rollback` machinery all belong to the guided pipeline — the default direct converter does not use them.
|
|
29
34
|
|
|
30
35
|
## Release status
|
|
31
36
|
|
|
32
37
|
> [!WARNING]
|
|
33
|
-
>
|
|
38
|
+
> This `0.1.x` release is a production-architecture **preview**, not a certified production release.
|
|
34
39
|
|
|
35
40
|
The shipped React, NestJS, FastAPI, and Rust profiles are currently `preview` (CRA is `legacy`), and no provider/model certification benchmark entry is enabled by the CLI. Therefore generated runs in this release cannot honestly become `VERIFIED`; even a clean strong-sandbox validation remains `INCONCLUSIVE`, and `apply` (therefore `rollback`) stays unreachable through a normal preview CLI run. This fail-closed behavior is intentional.
|
|
36
41
|
|
|
@@ -46,26 +51,32 @@ The published-package entry point is:
|
|
|
46
51
|
npx human-to-code .
|
|
47
52
|
```
|
|
48
53
|
|
|
49
|
-
|
|
54
|
+
By default this runs the **direct converter**, not an instruction to rewrite the whole directory. It:
|
|
55
|
+
|
|
56
|
+
1. Loads config and scans the project for `.human` files and inline `@human` markers, without importing application modules or executing project configuration.
|
|
57
|
+
2. Prints a receipt (language, provider, model, and the exact worklist) and asks for confirmation. Nothing is written until you confirm — or pass `-y`/`--yes`. If no request is found it returns `NEEDS_INPUT`.
|
|
58
|
+
3. On confirmation, converts each item with one model completion per unit and writes the result: a whole `.human` file becomes a sibling source file; an inline `@human` marker is replaced in place. Each item is independent — a failing one is skipped with a reason rather than aborting the rest.
|
|
50
59
|
|
|
51
|
-
|
|
52
|
-
2. It finds one `.human` change request. If none or several are found, it returns `NEEDS_INPUT`.
|
|
53
|
-
3. On the first run, it writes a review draft named `foo.strict.human.json` next to `foo.human` and exits with code `3`.
|
|
54
|
-
4. You review the target workspaces and symbols, allowed paths and operations, acceptance criteria, risks, and unresolved questions. A material unresolved question blocks generation.
|
|
55
|
-
5. Before any provider request, it scans first-party repository files—including ignored/untracked fixtures and logs—for credential-like content. A finding returns `SECURITY_BLOCKED`; an incomplete scan fails closed.
|
|
56
|
-
6. On the next run, it builds an outbound context manifest, requests a structured patch from the selected provider, and validates an isolated baseline and candidate.
|
|
57
|
-
7. It prints a diff and report. It never applies the patch as part of the guided command.
|
|
60
|
+
The direct converter writes code straight to the working tree. It does **not** create a `.strict.human.json` change contract, run sandbox validation, 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).
|
|
58
61
|
|
|
59
|
-
No configured provider is needed
|
|
62
|
+
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):
|
|
60
63
|
|
|
61
64
|
```bash
|
|
62
65
|
npx human-to-code --init .
|
|
63
66
|
# Edit human-to-code.config.json: select OpenAI, local Ollama, or Ollama Cloud.
|
|
64
67
|
```
|
|
65
68
|
|
|
66
|
-
|
|
69
|
+
Remote OpenAI/Ollama Cloud generation needs a config because `privacy.remoteProviderConsent` defaults to `false` and has no consent-enabling CLI flag.
|
|
67
70
|
|
|
68
|
-
|
|
71
|
+
Direct-converter example (inline marker converted in place):
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
printf '// @human add a function named health that returns { status: 200 }\n' > health.ts
|
|
75
|
+
npx human-to-code . --yes --model qwen2.5-coder:7b
|
|
76
|
+
# health.ts now contains the generated function in place of the marker.
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Guided-pipeline example (reviewed contract, no code written until VERIFIED):
|
|
69
80
|
|
|
70
81
|
```bash
|
|
71
82
|
cat > add-health-route.human <<'EOF'
|
|
@@ -73,9 +84,8 @@ Add a health endpoint using the existing routing, response, authentication,
|
|
|
73
84
|
logging, and test conventions. It must not expose secrets or tenant data.
|
|
74
85
|
EOF
|
|
75
86
|
|
|
76
|
-
npx human-to-code . --provider ollama --model qwen2.5-coder:14b
|
|
77
|
-
# Review add-health-route.strict.human.json, resolve REVIEW-1, then rerun
|
|
78
|
-
npx human-to-code . --file add-health-route.human --provider ollama --model qwen2.5-coder:14b
|
|
87
|
+
npx human-to-code guided . --provider ollama --model qwen2.5-coder:14b
|
|
88
|
+
# Review add-health-route.strict.human.json, resolve REVIEW-1, then rerun the same command.
|
|
79
89
|
```
|
|
80
90
|
|
|
81
91
|
From a source checkout:
|
|
@@ -89,13 +99,13 @@ node dist/cli.js .
|
|
|
89
99
|
|
|
90
100
|
Node.js 24 or newer is required.
|
|
91
101
|
|
|
92
|
-
## Generation
|
|
102
|
+
## Generation engine
|
|
93
103
|
|
|
94
104
|
The direct `npx human-to-code .` flow discovers work (whole `.human` files and
|
|
95
105
|
inline `@human` markers), prints a receipt, and — after you confirm — converts
|
|
96
|
-
|
|
106
|
+
them with the deterministic direct engine.
|
|
97
107
|
|
|
98
|
-
###
|
|
108
|
+
### Fast deterministic engine
|
|
99
109
|
|
|
100
110
|
The host does the orchestration; the model only writes code. For each unit the
|
|
101
111
|
host issues **one plain model completion** (no tool calls) and applies the
|
|
@@ -117,30 +127,9 @@ tool-calling, models that can only do plain text generation work fine.
|
|
|
117
127
|
This engine cannot produce `VERIFIED` runs; for the reviewed, sandbox-validated
|
|
118
128
|
pipeline use `human-to-code guided`.
|
|
119
129
|
|
|
120
|
-
### `--agent`: LangGraph deep agent
|
|
121
|
-
|
|
122
|
-
`--agent` runs the [`deepagents`](https://docs.langchain.com/oss/javascript/deepagents/overview)
|
|
123
|
-
harness with the four deep-agent pillars — **Planning** (`write_todos`),
|
|
124
|
-
**File System** (a project-rooted `FilesystemBackend`, with writes denied on
|
|
125
|
-
VCS/dependency/config/secret paths), **Sub Agents** (`planner`/`implementer`/
|
|
126
|
-
`reviewer` via the `task` tool), and **Prompts** (per-role system prompts). The
|
|
127
|
-
model drives scope, file edits, and delegation; live progress streams to the
|
|
128
|
-
terminal.
|
|
129
|
-
|
|
130
|
-
This engine needs a **tool-calling-capable model** (~7B+). It is reached through
|
|
131
|
-
the OpenAI-compatible chat client (Ollama via its `/v1` endpoint, since the deep
|
|
132
|
-
agent's structured tool messages are not supported by the native `/api/chat`
|
|
133
|
-
surface). Small models that cannot emit valid tool calls fail with a
|
|
134
|
-
tool-call/XML parse error; the CLI detects this and suggests a larger model or
|
|
135
|
-
the default engine. It also pulls the runtime dependencies `deepagents`,
|
|
136
|
-
`langchain`, `@langchain/core`, `@langchain/openai`, and `@langchain/ollama`.
|
|
137
|
-
|
|
138
130
|
```bash
|
|
139
|
-
#
|
|
131
|
+
# Deterministic engine — works with small models:
|
|
140
132
|
npx human-to-code . --yes --model qwen2.5-coder:1.5b
|
|
141
|
-
|
|
142
|
-
# LangGraph deep agent — needs a tool-calling model:
|
|
143
|
-
npx human-to-code . --yes --agent --model qwen2.5-coder:7b
|
|
144
133
|
```
|
|
145
134
|
|
|
146
135
|
## The reviewed change contract
|
|
@@ -162,7 +151,6 @@ The draft is deliberately conservative. Do not remove its review question until
|
|
|
162
151
|
| Command | Behavior |
|
|
163
152
|
| --- | --- |
|
|
164
153
|
| `human-to-code [root]` | Default direct flow: discover `.human` files and `@human` markers, show a receipt, and on confirmation convert them with the **fast deterministic engine** (one plain model completion per marker; see below). `npx human-to-code .` is the normal entry point. |
|
|
165
|
-
| `human-to-code [root] --agent` | Same direct flow using the **LangGraph deep agent** (planning/filesystem/subagents). Needs a tool-calling-capable model (~7B+). |
|
|
166
154
|
| `human-to-code guided [root]` | Reviewed contract → grounding → sandbox-validation lifecycle. The only path that can reach `VERIFIED`. |
|
|
167
155
|
| `human-to-code analyze [root] [--json]` | Produce a deterministic multi-workspace project profile and diagnostics. `SUPPORTED` means statically recognized, not certified. |
|
|
168
156
|
| `human-to-code plan <file.human> [--root <root>]` | Write a review-blocked `ChangeContractV1` draft. |
|
|
@@ -420,7 +408,7 @@ Captured stdout and stderr are scanned before report persistence. If either cont
|
|
|
420
408
|
|
|
421
409
|
No strong sandbox means no project command runs and the result is `INCONCLUSIVE`. Baseline failures, fail-then-pass flakiness, pending manual checks, unavailable toolchains/services, or mixed ecosystems without an explicit multi-toolchain image also prevent verification.
|
|
422
410
|
|
|
423
|
-
The
|
|
411
|
+
The `human-to-code guided` flow may ask the same provider/model for at most two diagnostic repairs, further limited by `budgets.maxRepairs`. Repairs run only for deterministic candidate regressions after a healthy baseline in the strong sandbox. They cannot run for security findings, infrastructure/toolchain failures, timeouts, flaky/truncated output, or unavailable services, and they cannot change paths/operation kinds, provenance, requirement coverage, dependencies, lockfiles, test operations, validation configuration, or remove existing proposed test obligations. Every accepted repair is safety-checked and validated from fresh baseline/candidate copies.
|
|
424
412
|
|
|
425
413
|
Repair checkpoints preserve cumulative request/token/cost/repair usage, provider identity, request IDs, immutable input hashes, attempt patches/diffs, and reports. A crash cannot reset the allowance. The standalone `validate <run-id>` command deliberately has no provider credentials and therefore only revalidates the stored patch; an embedding caller can continue any remaining repair allowance only by supplying the exact original provider and persisted configuration.
|
|
426
414
|
|
package/assets/banner.svg
CHANGED
|
@@ -16,23 +16,18 @@
|
|
|
16
16
|
<text x="640" y="118" text-anchor="middle" class="mono" font-size="62" font-weight="700" fill="#f8fafc">human-to-code</text>
|
|
17
17
|
<text x="640" y="158" text-anchor="middle" class="sans" font-size="21" fill="#94a3b8">Write intent in plain language. Compile it to real code.</text>
|
|
18
18
|
|
|
19
|
-
<!-- pipeline: human ->
|
|
19
|
+
<!-- pipeline: human -> code (the guided reviewed/validated path is optional) -->
|
|
20
20
|
<g>
|
|
21
|
-
<rect x="
|
|
22
|
-
<text x="
|
|
21
|
+
<rect x="445" y="212" width="170" height="62" rx="14" fill="#f59e0b"/>
|
|
22
|
+
<text x="530" y="251" text-anchor="middle" class="mono" font-size="24" font-weight="700" fill="#1c1206">human</text>
|
|
23
23
|
|
|
24
|
-
<text x="
|
|
24
|
+
<text x="640" y="252" text-anchor="middle" class="sans" font-size="30" fill="#64748b">→</text>
|
|
25
25
|
|
|
26
|
-
<rect x="
|
|
27
|
-
<text x="
|
|
28
|
-
|
|
29
|
-
<text x="785" y="252" text-anchor="middle" class="sans" font-size="30" fill="#64748b">→</text>
|
|
30
|
-
|
|
31
|
-
<rect x="810" y="212" width="170" height="62" rx="14" fill="#34d399"/>
|
|
32
|
-
<text x="895" y="251" text-anchor="middle" class="mono" font-size="24" font-weight="700" fill="#062018">code</text>
|
|
26
|
+
<rect x="665" y="212" width="170" height="62" rx="14" fill="#34d399"/>
|
|
27
|
+
<text x="750" y="251" text-anchor="middle" class="mono" font-size="24" font-weight="700" fill="#062018">code</text>
|
|
33
28
|
</g>
|
|
34
29
|
|
|
35
|
-
<text x="
|
|
36
|
-
<text x="
|
|
37
|
-
<text x="
|
|
30
|
+
<text x="530" y="304" text-anchor="middle" class="sans" font-size="15" fill="#64748b">natural language</text>
|
|
31
|
+
<text x="750" y="304" text-anchor="middle" class="sans" font-size="15" fill="#64748b">TS · JS · Python</text>
|
|
32
|
+
<text x="640" y="336" text-anchor="middle" class="sans" font-size="14" fill="#475569">optional guided pipeline → reviewed contract → sandbox-validated patch</text>
|
|
38
33
|
</svg>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1280 640" width="1280" height="640" role="img" aria-labelledby="title desc">
|
|
2
|
-
<title id="title">human-to-code —
|
|
2
|
+
<title id="title">human-to-code — plain language to real code</title>
|
|
3
3
|
<desc id="desc">Social sharing card for human-to-code.</desc>
|
|
4
4
|
<defs>
|
|
5
5
|
<linearGradient id="bg" x1="80" y1="40" x2="1200" y2="620" gradientUnits="userSpaceOnUse">
|
|
@@ -24,19 +24,19 @@
|
|
|
24
24
|
<rect x="58" y="45" width="12" height="38" rx="6" fill="#ff5f3c"/>
|
|
25
25
|
</g>
|
|
26
26
|
<text x="258" y="177" fill="#f7f4ef" font-family="Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, sans-serif" font-size="64" font-weight="850" letter-spacing="-3">human-to-code</text>
|
|
27
|
-
<text x="91" y="315" fill="#f7f4ef" font-family="Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, sans-serif" font-size="50" font-weight="760" letter-spacing="-1.6">
|
|
28
|
-
<text x="91" y="376" fill="#ff8a5c" font-family="Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, sans-serif" font-size="50" font-weight="760" letter-spacing="-1.6">
|
|
29
|
-
<text x="91" y="432" fill="#aaa6b0" font-family="Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, sans-serif" font-size="23">
|
|
27
|
+
<text x="91" y="315" fill="#f7f4ef" font-family="Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, sans-serif" font-size="50" font-weight="760" letter-spacing="-1.6">Plain language.</text>
|
|
28
|
+
<text x="91" y="376" fill="#ff8a5c" font-family="Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, sans-serif" font-size="50" font-weight="760" letter-spacing="-1.6">Real code.</text>
|
|
29
|
+
<text x="91" y="432" fill="#aaa6b0" font-family="Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, sans-serif" font-size="23">Turns .human files and @human markers straight into real code.</text>
|
|
30
30
|
<g transform="translate(91 500)" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" font-size="18" font-weight="700">
|
|
31
31
|
<rect width="142" height="48" rx="24" fill="#f7f4ef" fill-opacity=".08" stroke="#fff" stroke-opacity=".12"/>
|
|
32
32
|
<text x="71" y="31" text-anchor="middle" fill="#f7f4ef">.human</text>
|
|
33
33
|
<path d="M155 24h42" stroke="#ff5f3c" stroke-width="3" stroke-linecap="round"/>
|
|
34
34
|
<path d="m190 17 8 7-8 7" fill="none" stroke="#ff5f3c" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/>
|
|
35
35
|
<rect x="211" width="168" height="48" rx="24" fill="#f7f4ef" fill-opacity=".08" stroke="#fff" stroke-opacity=".12"/>
|
|
36
|
-
<text x="295" y="31" text-anchor="middle" fill="#f7f4ef">
|
|
36
|
+
<text x="295" y="31" text-anchor="middle" fill="#f7f4ef">generate</text>
|
|
37
37
|
<path d="M392 24h42" stroke="#ff5f3c" stroke-width="3" stroke-linecap="round"/>
|
|
38
38
|
<path d="m427 17 8 7-8 7" fill="none" stroke="#ff5f3c" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/>
|
|
39
39
|
<rect x="448" width="182" height="48" rx="24" fill="#ff5f3c"/>
|
|
40
|
-
<text x="539" y="31" text-anchor="middle" fill="#13090b">
|
|
40
|
+
<text x="539" y="31" text-anchor="middle" fill="#13090b">code</text>
|
|
41
41
|
</g>
|
|
42
42
|
</svg>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { dirname } from "node:path";
|
|
2
|
+
import type { ConversionUnit } from "./types.ts";
|
|
3
|
+
/** Apply one already-generated unit and return the project-relative path changed. */
|
|
4
|
+
export declare function applyUnit(root: string, unit: ConversionUnit, code: string): Promise<string>;
|
|
5
|
+
export declare function pathExists(target: string): Promise<boolean>;
|
|
6
|
+
export { dirname };
|
|
7
|
+
//# sourceMappingURL=application.d.ts.map
|
|
@@ -0,0 +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;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,qFAAqF;AACrF,wBAAsB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAgBjG;AAED,wBAAsB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAOjE;AAED,OAAO,EAAE,OAAO,EAAE,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { readFile, stat, writeFile } from "node:fs/promises";
|
|
2
|
+
import { dirname, resolve, sep } from "node:path";
|
|
3
|
+
/** Apply one already-generated unit and return the project-relative path changed. */
|
|
4
|
+
export async function applyUnit(root, unit, code) {
|
|
5
|
+
const absoluteRoot = resolve(root);
|
|
6
|
+
if (unit.kind === "file") {
|
|
7
|
+
const target = resolve(absoluteRoot, unit.outputPath);
|
|
8
|
+
if (!target.startsWith(absoluteRoot + sep)) {
|
|
9
|
+
throw new Error(`Refusing to write outside the project root: ${unit.outputPath}`);
|
|
10
|
+
}
|
|
11
|
+
await writeFile(target, code.endsWith("\n") ? code : `${code}\n`);
|
|
12
|
+
return unit.outputPath;
|
|
13
|
+
}
|
|
14
|
+
const original = await readFile(unit.absoluteSource, "utf8");
|
|
15
|
+
const { start, end } = unit.range;
|
|
16
|
+
const replaced = `${original.slice(0, start)}${code.trim()}${original.slice(end)}`;
|
|
17
|
+
await writeFile(unit.absoluteSource, replaced);
|
|
18
|
+
return unit.sourcePath;
|
|
19
|
+
}
|
|
20
|
+
export async function pathExists(target) {
|
|
21
|
+
try {
|
|
22
|
+
await stat(target);
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export { dirname };
|
|
30
|
+
//# sourceMappingURL=application.js.map
|
|
@@ -0,0 +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;AAC7D,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAGlD,qFAAqF;AACrF,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,IAAY,EAAE,IAAoB,EAAE,IAAY;IAC9E,MAAM,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnC,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;QACzB,MAAM,MAAM,GAAG,OAAO,CAAC,YAAY,EAAE,IAAI,CAAC,UAAW,CAAC,CAAC;QACvD,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,YAAY,GAAG,GAAG,CAAC,EAAE,CAAC;YAC3C,MAAM,IAAI,KAAK,CAAC,+CAA+C,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;QACpF,CAAC;QACD,MAAM,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,CAAC,CAAC;QAClE,OAAO,IAAI,CAAC,UAAW,CAAC;IAC1B,CAAC;IAED,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;IAC7D,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,KAAM,CAAC;IACnC,MAAM,QAAQ,GAAG,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,GAAG,IAAI,CAAC,IAAI,EAAE,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;IACnF,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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../../../src/agents/direct/discovery.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAmCjD,8DAA8D;AAC9D,wBAAsB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAqD7F"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { readdir, readFile } from "node:fs/promises";
|
|
2
|
+
import { basename, extname, join, relative, resolve, sep } from "node:path";
|
|
3
|
+
import { languageProfile } from "./languages.js";
|
|
4
|
+
import { extractInlineMarkers } from "./marker-parser.js";
|
|
5
|
+
const SCANNED_EXTENSIONS = new Set([
|
|
6
|
+
".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs",
|
|
7
|
+
".py", ".rs", ".go", ".java", ".rb", ".cs", ".cpp", ".cc", ".c", ".h", ".hpp",
|
|
8
|
+
]);
|
|
9
|
+
const DEFAULT_IGNORES = new Set([
|
|
10
|
+
"node_modules", ".git", "dist", "build", ".next", "target", ".venv", "venv",
|
|
11
|
+
"coverage", ".human-to-code",
|
|
12
|
+
]);
|
|
13
|
+
async function walk(root, ignores) {
|
|
14
|
+
const results = [];
|
|
15
|
+
const visit = async (dir, depth) => {
|
|
16
|
+
if (depth > 40)
|
|
17
|
+
return;
|
|
18
|
+
let entries;
|
|
19
|
+
try {
|
|
20
|
+
entries = await readdir(dir, { withFileTypes: true });
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
for (const entry of entries) {
|
|
26
|
+
if (entry.name.startsWith(".") && entry.name !== ".human-to-code" && entry.isDirectory())
|
|
27
|
+
continue;
|
|
28
|
+
if (ignores.has(entry.name))
|
|
29
|
+
continue;
|
|
30
|
+
const full = join(dir, entry.name);
|
|
31
|
+
if (entry.isSymbolicLink())
|
|
32
|
+
continue;
|
|
33
|
+
if (entry.isDirectory())
|
|
34
|
+
await visit(full, depth + 1);
|
|
35
|
+
else if (entry.isFile())
|
|
36
|
+
results.push(full);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
await visit(root, 0);
|
|
40
|
+
return results.sort();
|
|
41
|
+
}
|
|
42
|
+
/** Discover whole-file and inline direct-conversion units. */
|
|
43
|
+
export async function discoverUnits(root, language) {
|
|
44
|
+
const absoluteRoot = resolve(root);
|
|
45
|
+
const profile = languageProfile(language);
|
|
46
|
+
const files = await walk(absoluteRoot, DEFAULT_IGNORES);
|
|
47
|
+
const units = [];
|
|
48
|
+
for (const absolute of files) {
|
|
49
|
+
const rel = relative(absoluteRoot, absolute).split(sep).join("/");
|
|
50
|
+
const name = basename(absolute);
|
|
51
|
+
if (name.endsWith(".strict.human"))
|
|
52
|
+
continue;
|
|
53
|
+
if (name.endsWith(".human")) {
|
|
54
|
+
let content;
|
|
55
|
+
try {
|
|
56
|
+
content = await readFile(absolute, "utf8");
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
const prompt = content.trim();
|
|
62
|
+
if (prompt.length === 0)
|
|
63
|
+
continue;
|
|
64
|
+
const outputPath = `${rel.slice(0, -".human".length)}.${profile.ext}`;
|
|
65
|
+
units.push({
|
|
66
|
+
kind: "file",
|
|
67
|
+
sourcePath: rel,
|
|
68
|
+
absoluteSource: absolute,
|
|
69
|
+
prompt,
|
|
70
|
+
outputPath,
|
|
71
|
+
describe: `${rel} -> ${outputPath}`,
|
|
72
|
+
});
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
if (!SCANNED_EXTENSIONS.has(extname(absolute).toLowerCase()))
|
|
76
|
+
continue;
|
|
77
|
+
let content;
|
|
78
|
+
try {
|
|
79
|
+
content = await readFile(absolute, "utf8");
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
if (!content.includes("@human"))
|
|
85
|
+
continue;
|
|
86
|
+
for (const marker of extractInlineMarkers(content)) {
|
|
87
|
+
const line = content.slice(0, marker.start).split("\n").length;
|
|
88
|
+
units.push({
|
|
89
|
+
kind: "inline",
|
|
90
|
+
sourcePath: rel,
|
|
91
|
+
absoluteSource: absolute,
|
|
92
|
+
prompt: marker.prompt,
|
|
93
|
+
range: { start: marker.start, end: marker.end },
|
|
94
|
+
line,
|
|
95
|
+
describe: `${rel} (inline @human, line ${line}) -> ${rel}`,
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return units;
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=discovery.js.map
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AM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC;YAC/D,KAAK,CAAC,IAAI,CAAC;gBACT,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE,GAAG;gBACf,cAAc,EAAE,QAAQ;gBACxB,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE;gBAC/C,IAAI;gBACJ,QAAQ,EAAE,GAAG,GAAG,0BAA0B,IAAI,UAAU,GAAG,EAAE;aAC9D,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ConversionUnit, FileMemoryEntry, GeneratedConversionUnit, GenerateUnitsOptions, UnitGenerationContext } from "./types.ts";
|
|
2
|
+
export declare class FileMemoryConflictError extends Error {
|
|
3
|
+
constructor(message: string);
|
|
4
|
+
}
|
|
5
|
+
/** Ephemeral declaration memory shared by markers in one source file. */
|
|
6
|
+
export declare class FileMemory {
|
|
7
|
+
#private;
|
|
8
|
+
readonly sourcePath: string;
|
|
9
|
+
constructor(sourcePath: string, sourceText: string);
|
|
10
|
+
get entries(): readonly FileMemoryEntry[];
|
|
11
|
+
rememberReplacement(range: {
|
|
12
|
+
start: number;
|
|
13
|
+
end: number;
|
|
14
|
+
}, code: string): void;
|
|
15
|
+
render(): string;
|
|
16
|
+
normalizeReplacement(code: string): string;
|
|
17
|
+
}
|
|
18
|
+
/** Generate each unit without mutating source files. */
|
|
19
|
+
export declare function generateConversionUnits(units: readonly ConversionUnit[], generator: (unit: ConversionUnit, context: UnitGenerationContext) => Promise<string>, options?: GenerateUnitsOptions): Promise<GeneratedConversionUnit[]>;
|
|
20
|
+
//# sourceMappingURL=file-memory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-memory.d.ts","sourceRoot":"","sources":["../../../src/agents/direct/file-memory.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,cAAc,EACd,eAAe,EACf,uBAAuB,EACvB,oBAAoB,EACpB,qBAAqB,EACtB,MAAM,YAAY,CAAC;AAEpB,qBAAa,uBAAwB,SAAQ,KAAK;gBACpC,OAAO,EAAE,MAAM;CAI5B;AAuBD,yEAAyE;AACzE,qBAAa,UAAU;;IACrB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;gBAMhB,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;IAMlD,IAAI,OAAO,IAAI,SAAS,eAAe,EAAE,CAWxC;IAED,mBAAmB,CAAC,KAAK,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;IAoB9E,MAAM,IAAI,MAAM;IAchB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;CAkC3C;AAED,wDAAwD;AACxD,wBAAsB,uBAAuB,CAC3C,KAAK,EAAE,SAAS,cAAc,EAAE,EAChC,SAAS,EAAE,CAAC,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,qBAAqB,KAAK,OAAO,CAAC,MAAM,CAAC,EACpF,OAAO,GAAE,oBAAyB,GACjC,OAAO,CAAC,uBAAuB,EAAE,CAAC,CAoDpC"}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { ContextSecurityError, scanSecrets } from "../../context/context.js";
|
|
3
|
+
import { extractStaticFileMemory } from "../../pipeline/file-memory.js";
|
|
4
|
+
export class FileMemoryConflictError extends Error {
|
|
5
|
+
constructor(message) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = "FileMemoryConflictError";
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
function declaredIdentifiers(code) {
|
|
11
|
+
const identifiers = new Set();
|
|
12
|
+
const declaration = /^[ \t]*(?:(?:export|default|declare|public|private|protected|async|pub)\s+)*(?:const|let|var|function|class|interface|enum|struct|trait|fn|def|static|type)\s+([A-Za-z_$][A-Za-z0-9_$]*)/gmu;
|
|
13
|
+
let match;
|
|
14
|
+
while ((match = declaration.exec(code)) !== null)
|
|
15
|
+
identifiers.add(match[1]);
|
|
16
|
+
return identifiers;
|
|
17
|
+
}
|
|
18
|
+
function stripMemorySeparator(value) {
|
|
19
|
+
let offset = 0;
|
|
20
|
+
for (;;) {
|
|
21
|
+
if (value.startsWith("\r\n", offset))
|
|
22
|
+
offset += 2;
|
|
23
|
+
else if (value.startsWith("\n", offset))
|
|
24
|
+
offset += 1;
|
|
25
|
+
else if (value.startsWith("\\r\\n", offset))
|
|
26
|
+
offset += 4;
|
|
27
|
+
else if (value.startsWith("\\n", offset))
|
|
28
|
+
offset += 2;
|
|
29
|
+
else if (value[offset] === " " || value[offset] === "\t")
|
|
30
|
+
offset += 1;
|
|
31
|
+
else
|
|
32
|
+
break;
|
|
33
|
+
}
|
|
34
|
+
return offset > 0 ? value.slice(offset) : undefined;
|
|
35
|
+
}
|
|
36
|
+
/** Ephemeral declaration memory shared by markers in one source file. */
|
|
37
|
+
export class FileMemory {
|
|
38
|
+
sourcePath;
|
|
39
|
+
#generatedEntries = [];
|
|
40
|
+
#staticEntries;
|
|
41
|
+
#virtualText;
|
|
42
|
+
#characterDelta = 0;
|
|
43
|
+
constructor(sourcePath, sourceText) {
|
|
44
|
+
this.sourcePath = sourcePath;
|
|
45
|
+
this.#virtualText = sourceText;
|
|
46
|
+
this.#staticEntries = extractStaticFileMemory(sourcePath, sourceText);
|
|
47
|
+
}
|
|
48
|
+
get entries() {
|
|
49
|
+
const unique = new Map();
|
|
50
|
+
const staticEntries = this.#staticEntries.filter((entry) => !this.#generatedEntries.some((generated) => entry.startLine >= generated.startLine && entry.endLine <= generated.endLine));
|
|
51
|
+
for (const entry of [...staticEntries, ...this.#generatedEntries]) {
|
|
52
|
+
unique.set(`${entry.startLine}:${entry.endLine}:${entry.code}`, entry);
|
|
53
|
+
}
|
|
54
|
+
return [...unique.values()]
|
|
55
|
+
.sort((left, right) => left.startLine - right.startLine || left.endLine - right.endLine || left.code.localeCompare(right.code))
|
|
56
|
+
.map((entry) => ({ ...entry }));
|
|
57
|
+
}
|
|
58
|
+
rememberReplacement(range, code) {
|
|
59
|
+
const replacement = code.trim();
|
|
60
|
+
if (replacement.length === 0)
|
|
61
|
+
return;
|
|
62
|
+
const start = range.start + this.#characterDelta;
|
|
63
|
+
const end = range.end + this.#characterDelta;
|
|
64
|
+
if (start < 0 || end < start || end > this.#virtualText.length) {
|
|
65
|
+
throw new Error(`Cannot update FileMemory for ${this.sourcePath}: marker range is stale.`);
|
|
66
|
+
}
|
|
67
|
+
const marker = this.#virtualText.slice(start, end);
|
|
68
|
+
if (!marker.includes("@human")) {
|
|
69
|
+
throw new Error(`Cannot update FileMemory for ${this.sourcePath}: expected an @human marker.`);
|
|
70
|
+
}
|
|
71
|
+
const startLine = 1 + (this.#virtualText.slice(0, start).match(/\n/g)?.length ?? 0);
|
|
72
|
+
const endLine = startLine + (replacement.match(/\n/g)?.length ?? 0);
|
|
73
|
+
this.#virtualText = `${this.#virtualText.slice(0, start)}${replacement}${this.#virtualText.slice(end)}`;
|
|
74
|
+
this.#characterDelta += replacement.length - (range.end - range.start);
|
|
75
|
+
this.#generatedEntries.push({ startLine, endLine, code: replacement, fragment: false });
|
|
76
|
+
this.#staticEntries = extractStaticFileMemory(this.sourcePath, this.#virtualText);
|
|
77
|
+
}
|
|
78
|
+
render() {
|
|
79
|
+
const rendered = this.entries
|
|
80
|
+
.map((entry) => `line ${entry.startLine} to line ${entry.endLine}:\n${entry.code}`)
|
|
81
|
+
.join("\n\n");
|
|
82
|
+
if (scanSecrets(rendered).length > 0) {
|
|
83
|
+
throw new ContextSecurityError("SECRET_DETECTED", `FileMemory for ${this.sourcePath} contains credential-like declaration content.`, this.sourcePath);
|
|
84
|
+
}
|
|
85
|
+
return rendered;
|
|
86
|
+
}
|
|
87
|
+
normalizeReplacement(code) {
|
|
88
|
+
const original = code.trim();
|
|
89
|
+
let normalized = original;
|
|
90
|
+
let removedPrefix = false;
|
|
91
|
+
const entries = [...this.entries].sort((left, right) => right.code.length - left.code.length);
|
|
92
|
+
for (;;) {
|
|
93
|
+
const repeated = entries.find((entry) => !entry.fragment && normalized.startsWith(entry.code));
|
|
94
|
+
if (!repeated)
|
|
95
|
+
break;
|
|
96
|
+
const remainder = normalized.slice(repeated.code.length);
|
|
97
|
+
if (remainder.length === 0) {
|
|
98
|
+
normalized = "";
|
|
99
|
+
removedPrefix = true;
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
const withoutSeparator = stripMemorySeparator(remainder);
|
|
103
|
+
if (withoutSeparator === undefined)
|
|
104
|
+
break;
|
|
105
|
+
normalized = withoutSeparator.trimStart();
|
|
106
|
+
removedPrefix = true;
|
|
107
|
+
}
|
|
108
|
+
if (removedPrefix && normalized.length === 0) {
|
|
109
|
+
throw new FileMemoryConflictError(`The provider only repeated existing FileMemory for ${this.sourcePath}; the current marker was not implemented.`);
|
|
110
|
+
}
|
|
111
|
+
const remembered = new Set(this.#generatedEntries.flatMap((entry) => [...declaredIdentifiers(entry.code)]));
|
|
112
|
+
const conflicts = [...declaredIdentifiers(normalized)].filter((identifier) => remembered.has(identifier));
|
|
113
|
+
if (conflicts.length > 0) {
|
|
114
|
+
throw new FileMemoryConflictError(`The provider redeclared FileMemory identifier${conflicts.length === 1 ? "" : "s"} ${conflicts.join(", ")} in ${this.sourcePath}.`);
|
|
115
|
+
}
|
|
116
|
+
return normalized;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
/** Generate each unit without mutating source files. */
|
|
120
|
+
export async function generateConversionUnits(units, generator, options = {}) {
|
|
121
|
+
const ordered = [...units].sort((left, right) => {
|
|
122
|
+
if (left.kind !== right.kind)
|
|
123
|
+
return left.kind === "file" ? -1 : 1;
|
|
124
|
+
const byPath = left.sourcePath.localeCompare(right.sourcePath);
|
|
125
|
+
if (byPath !== 0)
|
|
126
|
+
return byPath;
|
|
127
|
+
return (left.range?.start ?? 0) - (right.range?.start ?? 0);
|
|
128
|
+
});
|
|
129
|
+
const memories = new Map();
|
|
130
|
+
const generated = [];
|
|
131
|
+
const maxAttempts = 1 + Math.max(0, options.retries ?? 1);
|
|
132
|
+
for (const unit of ordered) {
|
|
133
|
+
let memory;
|
|
134
|
+
if (unit.kind === "inline") {
|
|
135
|
+
memory = memories.get(unit.absoluteSource);
|
|
136
|
+
if (!memory) {
|
|
137
|
+
memory = new FileMemory(unit.sourcePath, await readFile(unit.absoluteSource, "utf8"));
|
|
138
|
+
memories.set(unit.absoluteSource, memory);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
let code;
|
|
142
|
+
let failure;
|
|
143
|
+
for (let attempt = 1; attempt <= maxAttempts; attempt += 1) {
|
|
144
|
+
options.onProgress?.({ kind: "start", unit, attempt });
|
|
145
|
+
try {
|
|
146
|
+
const renderedMemory = memory?.render();
|
|
147
|
+
const rawCode = await generator(unit, {
|
|
148
|
+
inline: unit.kind === "inline",
|
|
149
|
+
...(renderedMemory ? { fileMemory: renderedMemory } : {}),
|
|
150
|
+
});
|
|
151
|
+
code = memory && renderedMemory ? memory.normalizeReplacement(rawCode) : rawCode;
|
|
152
|
+
failure = undefined;
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
catch (error) {
|
|
156
|
+
if (error instanceof ContextSecurityError)
|
|
157
|
+
throw error;
|
|
158
|
+
failure = error instanceof Error ? error.message : String(error);
|
|
159
|
+
code = undefined;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
if (failure !== undefined || code === undefined) {
|
|
163
|
+
generated.push({ unit, code: "", error: failure ?? "generation produced no code" });
|
|
164
|
+
options.onProgress?.({ kind: "skip", unit, reason: failure ?? "generation produced no code" });
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
generated.push({ unit, code });
|
|
168
|
+
if (memory && code.trim().length > 0)
|
|
169
|
+
memory.rememberReplacement(unit.range, code);
|
|
170
|
+
options.onProgress?.({ kind: "done", unit });
|
|
171
|
+
}
|
|
172
|
+
return generated;
|
|
173
|
+
}
|
|
174
|
+
//# sourceMappingURL=file-memory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-memory.js","sourceRoot":"","sources":["../../../src/agents/direct/file-memory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC7E,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AASxE,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IAChD,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;IACxC,CAAC;CACF;AAED,SAAS,mBAAmB,CAAC,IAAY;IACvC,MAAM,WAAW,GAAG,IAAI,GAAG,EAAU,CAAC;IACtC,MAAM,WAAW,GAAG,6LAA6L,CAAC;IAClN,IAAI,KAA6B,CAAC;IAClC,OAAO,CAAC,KAAK,GAAG,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,IAAI;QAAE,WAAW,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAE,CAAC,CAAC;IAC7E,OAAO,WAAW,CAAC;AACrB,CAAC;AAED,SAAS,oBAAoB,CAAC,KAAa;IACzC,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,SAAS,CAAC;QACR,IAAI,KAAK,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC;YAAE,MAAM,IAAI,CAAC,CAAC;aAC7C,IAAI,KAAK,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC;YAAE,MAAM,IAAI,C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,CAAC,CAAC;IAC/C,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { GenerateOptions } from "./types.ts";
|
|
2
|
+
/** Send one direct-conversion request to OpenAI-compatible chat or Ollama. */
|
|
3
|
+
export declare function generateCode(instruction: string, options: GenerateOptions): Promise<string>;
|
|
4
|
+
//# sourceMappingURL=generation-client.d.ts.map
|