human-to-code 0.1.13 → 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 +4 -39
- 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 +4 -55
- 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 -29
- package/docs/MODULES.md +46 -10
- package/docs/SCALABILITY.md +10 -9
- package/docs/roadmap/README.md +1 -1
- package/docs/roadmap/ruby.md +1 -1
- package/package.json +1 -6
- package/dist/pipeline/agent-tools.d.ts +0 -348
- package/dist/pipeline/agent-tools.d.ts.map +0 -1
- package/dist/pipeline/agent-tools.js +0 -542
- package/dist/pipeline/agent-tools.js.map +0 -1
- package/dist/pipeline/agent-tui.d.ts +0 -15
- package/dist/pipeline/agent-tui.d.ts.map +0 -1
- package/dist/pipeline/agent-tui.js +0 -133
- package/dist/pipeline/agent-tui.js.map +0 -1
- package/dist/pipeline/deep-agent.d.ts +0 -61
- package/dist/pipeline/deep-agent.d.ts.map +0 -1
- package/dist/pipeline/deep-agent.js +0 -395
- package/dist/pipeline/deep-agent.js.map +0 -1
package/Readme.md
CHANGED
|
@@ -99,13 +99,13 @@ node dist/cli.js .
|
|
|
99
99
|
|
|
100
100
|
Node.js 24 or newer is required.
|
|
101
101
|
|
|
102
|
-
## Generation
|
|
102
|
+
## Generation engine
|
|
103
103
|
|
|
104
104
|
The direct `npx human-to-code .` flow discovers work (whole `.human` files and
|
|
105
105
|
inline `@human` markers), prints a receipt, and — after you confirm — converts
|
|
106
|
-
|
|
106
|
+
them with the deterministic direct engine.
|
|
107
107
|
|
|
108
|
-
###
|
|
108
|
+
### Fast deterministic engine
|
|
109
109
|
|
|
110
110
|
The host does the orchestration; the model only writes code. For each unit the
|
|
111
111
|
host issues **one plain model completion** (no tool calls) and applies the
|
|
@@ -127,43 +127,9 @@ tool-calling, models that can only do plain text generation work fine.
|
|
|
127
127
|
This engine cannot produce `VERIFIED` runs; for the reviewed, sandbox-validated
|
|
128
128
|
pipeline use `human-to-code guided`.
|
|
129
129
|
|
|
130
|
-
### `--agent`: LangGraph deep agent
|
|
131
|
-
|
|
132
|
-
`--agent` runs a LangChain/LangGraph agent with an explicit coding-tool surface:
|
|
133
|
-
`Task`, `Bash`, `Glob`, `Grep`,
|
|
134
|
-
`LS`, `ExitPlanMode`, `Read`, `Edit`, `MultiEdit`, `Write`, `NotebookEdit`,
|
|
135
|
-
`WebFetch`, `TodoWrite`, `WebSearch`, `BashOutput`, and `KillBash`. File tools
|
|
136
|
-
are project-confined, reads are required before edits, protected paths are
|
|
137
|
-
denied, multi-edits are atomic, shell output is bounded, and secret-bearing
|
|
138
|
-
environment variables are removed from commands.
|
|
139
|
-
|
|
140
|
-
In an interactive terminal, agent mode uses a two-column dashboard: the current
|
|
141
|
-
todo list stays on the left while tool calls, command output, and git-style
|
|
142
|
-
green `+` / red `-` file changes stream on the right. Non-TTY and `--json`
|
|
143
|
-
usage remains line-oriented and machine-readable.
|
|
144
|
-
|
|
145
|
-
The agent prompt includes concrete JSON tool-call examples intended to help
|
|
146
|
-
very small models, including 0.8B-class models. Model size is not treated as a
|
|
147
|
-
capability guarantee: the model must reliably support structured tool calling.
|
|
148
|
-
If a model repeats the same call four times, claims completion without changing
|
|
149
|
-
every worklist item, or reaches the bounded graph step limit, the run stops with
|
|
150
|
-
a concise incomplete result instead of continuing to the framework recursion
|
|
151
|
-
error. When the host observes that every discovered item is implemented, it
|
|
152
|
-
stops the graph even if the model forgets to provide a final response.
|
|
153
|
-
|
|
154
|
-
The engine is reached through the OpenAI-compatible chat client (Ollama via its
|
|
155
|
-
`/v1` endpoint). Its `Bash` tool executes development commands on the host from
|
|
156
|
-
the project root; it is bounded and guarded but is not a strong sandbox. Use
|
|
157
|
-
the guided pipeline when hash-bound patches and container validation are
|
|
158
|
-
required. Agent mode pulls the runtime dependencies `langchain`,
|
|
159
|
-
`@langchain/core`, and `@langchain/openai`.
|
|
160
|
-
|
|
161
130
|
```bash
|
|
162
|
-
#
|
|
131
|
+
# Deterministic engine — works with small models:
|
|
163
132
|
npx human-to-code . --yes --model qwen2.5-coder:1.5b
|
|
164
|
-
|
|
165
|
-
# Agent dashboard — needs reliable JSON tool calling:
|
|
166
|
-
npx human-to-code . --yes --agent --model qwen2.5-coder:7b
|
|
167
133
|
```
|
|
168
134
|
|
|
169
135
|
## The reviewed change contract
|
|
@@ -185,7 +151,6 @@ The draft is deliberately conservative. Do not remove its review question until
|
|
|
185
151
|
| Command | Behavior |
|
|
186
152
|
| --- | --- |
|
|
187
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. |
|
|
188
|
-
| `human-to-code [root] --agent` | Same direct flow using the tool-rich **LangGraph agent dashboard** (todos, filesystem, shell, diffs, and subagents). Needs reliable structured tool calling; model size alone is not a capability guarantee. |
|
|
189
154
|
| `human-to-code guided [root]` | Reviewed contract → grounding → sandbox-validation lifecycle. The only path that can reach `VERIFIED`. |
|
|
190
155
|
| `human-to-code analyze [root] [--json]` | Produce a deterministic multi-workspace project profile and diagnostics. `SUPPORTED` means statically recognized, not certified. |
|
|
191
156
|
| `human-to-code plan <file.human> [--root <root>]` | Write a review-blocked `ChangeContractV1` draft. |
|
|
@@ -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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discovery.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AAC,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,CAAC,CAAC;aAChD,IAAI,KAAK,CAAC,UAAU,CAAC,QAAQ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B,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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generation-client.d.ts","sourceRoot":"","sources":["../../../src/agents/direct/generation-client.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,8EAA8E;AAC9E,wBAAsB,YAAY,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CAkDjG"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { buildDirectConversionPrompt } from "../../prompts/direct-conversion.js";
|
|
2
|
+
import { languageProfile } from "./languages.js";
|
|
3
|
+
import { stripCodeFence } from "./presentation.js";
|
|
4
|
+
/** Send one direct-conversion request to OpenAI-compatible chat or Ollama. */
|
|
5
|
+
export async function generateCode(instruction, options) {
|
|
6
|
+
const profile = languageProfile(options.language);
|
|
7
|
+
const prompt = buildDirectConversionPrompt({
|
|
8
|
+
languageLabel: profile.label,
|
|
9
|
+
instruction,
|
|
10
|
+
inline: options.inline ?? false,
|
|
11
|
+
...(options.fileMemory ? { fileMemory: options.fileMemory } : {}),
|
|
12
|
+
});
|
|
13
|
+
if (options.provider === "openai") {
|
|
14
|
+
const base = options.baseUrl ?? "https://api.openai.com/v1";
|
|
15
|
+
const response = await fetch(`${base}/chat/completions`, {
|
|
16
|
+
method: "POST",
|
|
17
|
+
headers: {
|
|
18
|
+
"content-type": "application/json",
|
|
19
|
+
...(options.apiKey ? { authorization: `Bearer ${options.apiKey}` } : {}),
|
|
20
|
+
},
|
|
21
|
+
body: JSON.stringify({
|
|
22
|
+
model: options.model,
|
|
23
|
+
messages: [
|
|
24
|
+
{ role: "system", content: prompt.system },
|
|
25
|
+
{ role: "user", content: prompt.user },
|
|
26
|
+
],
|
|
27
|
+
temperature: 0,
|
|
28
|
+
}),
|
|
29
|
+
signal: options.signal,
|
|
30
|
+
});
|
|
31
|
+
if (!response.ok)
|
|
32
|
+
throw new Error(`OpenAI request failed: ${response.status} ${await response.text()}`);
|
|
33
|
+
const data = (await response.json());
|
|
34
|
+
return stripCodeFence(data.choices?.[0]?.message?.content ?? "");
|
|
35
|
+
}
|
|
36
|
+
const base = options.baseUrl ?? "http://localhost:11434";
|
|
37
|
+
const response = await fetch(`${base.replace(/\/api\/?$/u, "")}/api/chat`, {
|
|
38
|
+
method: "POST",
|
|
39
|
+
headers: { "content-type": "application/json" },
|
|
40
|
+
body: JSON.stringify({
|
|
41
|
+
model: options.model,
|
|
42
|
+
stream: false,
|
|
43
|
+
options: { temperature: 0 },
|
|
44
|
+
messages: [
|
|
45
|
+
{ role: "system", content: prompt.system },
|
|
46
|
+
{ role: "user", content: prompt.user },
|
|
47
|
+
],
|
|
48
|
+
}),
|
|
49
|
+
signal: options.signal,
|
|
50
|
+
});
|
|
51
|
+
if (!response.ok)
|
|
52
|
+
throw new Error(`Ollama request failed: ${response.status} ${await response.text()}`);
|
|
53
|
+
const data = (await response.json());
|
|
54
|
+
return stripCodeFence(data.message?.content ?? "");
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=generation-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generation-client.js","sourceRoot":"","sources":["../../../src/agents/direct/generation-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,oCAAoC,CAAC;AACjF,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGnD,8EAA8E;AAC9E,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,WAAmB,E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ct conversion agent. */
|
|
2
|
+
export * from "./types.ts";
|
|
3
|
+
export * from "./languages.ts";
|
|
4
|
+
export * from "./marker-parser.ts";
|
|
5
|
+
export * from "./file-memory.ts";
|
|
6
|
+
export * from "./discovery.ts";
|
|
7
|
+
export * from "./presentation.ts";
|
|
8
|
+
export * from "./generation-client.ts";
|
|
9
|
+
export * from "./application.ts";
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +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,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Public surface of the small-model-friendly direct conversion agent. */
|
|
2
|
+
export * from "./types.js";
|
|
3
|
+
export * from "./languages.js";
|
|
4
|
+
export * from "./marker-parser.js";
|
|
5
|
+
export * from "./file-memory.js";
|
|
6
|
+
export * from "./discovery.js";
|
|
7
|
+
export * from "./presentation.js";
|
|
8
|
+
export * from "./generation-client.js";
|
|
9
|
+
export * from "./application.js";
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +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,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { LanguageProfile } from "./types.ts";
|
|
2
|
+
/** Operator-declared config language -> output extension and prompt label. */
|
|
3
|
+
export declare const LANGUAGE_PROFILES: Record<string, LanguageProfile>;
|
|
4
|
+
export declare function languageProfile(language: string): LanguageProfile;
|
|
5
|
+
//# sourceMappingURL=languages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"languages.d.ts","sourceRoot":"","sources":["../../../src/agents/direct/languages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,8EAA8E;AAC9E,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAW7D,CAAC;AAEF,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,eAAe,CAEjE"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Operator-declared config language -> output extension and prompt label. */
|
|
2
|
+
export const LANGUAGE_PROFILES = {
|
|
3
|
+
typescript: { ext: "ts", label: "TypeScript" },
|
|
4
|
+
javascript: { ext: "js", label: "JavaScript" },
|
|
5
|
+
python: { ext: "py", label: "Python" },
|
|
6
|
+
rust: { ext: "rs", label: "Rust" },
|
|
7
|
+
go: { ext: "go", label: "Go" },
|
|
8
|
+
java: { ext: "java", label: "Java" },
|
|
9
|
+
ruby: { ext: "rb", label: "Ruby" },
|
|
10
|
+
csharp: { ext: "cs", label: "C#" },
|
|
11
|
+
cpp: { ext: "cpp", label: "C++" },
|
|
12
|
+
c: { ext: "c", label: "C" },
|
|
13
|
+
};
|
|
14
|
+
export function languageProfile(language) {
|
|
15
|
+
return LANGUAGE_PROFILES[language.trim().toLowerCase()] ?? { ext: "txt", label: language };
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=languages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"languages.js","sourceRoot":"","sources":["../../../src/agents/direct/languages.ts"],"names":[],"mappings":"AAEA,8EAA8E;AAC9E,MAAM,CAAC,MAAM,iBAAiB,GAAoC;IAChE,UAAU,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,YAAY,EAAE;IAC9C,UAAU,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,YAAY,EAAE;IAC9C,MAAM,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE;IACtC,IAAI,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE;IAClC,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE;IAC9B,IAAI,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE;IACpC,IAAI,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE;IAClC,MAAM,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE;IAClC,GAAG,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE;IACjC,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE;CAC5B,CAAC;AAEF,MAAM,UAAU,eAAe,CAAC,QAAgB;IAC9C,OAAO,iBAAiB,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;AAC7F,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface InlineMarker {
|
|
2
|
+
prompt: string;
|
|
3
|
+
start: number;
|
|
4
|
+
end: number;
|
|
5
|
+
}
|
|
6
|
+
/** Find every lexical `@human` comment marker with its exact character range. */
|
|
7
|
+
export declare function extractInlineMarkers(text: string): InlineMarker[];
|
|
8
|
+
//# sourceMappingURL=marker-parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"marker-parser.d.ts","sourceRoot":"","sources":["../../../src/agents/direct/marker-parser.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACb;AA0BD,iFAAiF;AACjF,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,EAAE,CA8CjE"}
|