Skip to content

Commit f868d2d

Browse files
committed
Add two-pass pipeline: Pass 1 (correctness) + Pass 2 (quality refactoring)
Pass 1 generates schema-correct Pydantic models (may have mechanical names). Pass 2 aggressively refactors for production quality: TS-derived class names, error deduplication, cleanup of alphabetic suffixes and deep path names. New CLI flags: --pass1-only Stop after Pass 1 --pass1-dir Skip Pass 1, refactor existing output --pass2-max-attempts Separate retry budget for Pass 2 Both passes use the same verifier to ensure correctness is preserved.
1 parent 0b689d2 commit f868d2d

File tree

4 files changed

+571
-78
lines changed

4 files changed

+571
-78
lines changed

codegen-llm/src/cli.ts

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,12 @@ program
2121
program
2222
.command("generate")
2323
.description(
24-
"Generate a Python Pydantic client from a TypeScript River server",
24+
"Generate a Python Pydantic client from a TypeScript River server.\n\n" +
25+
"Runs a two-pass pipeline:\n" +
26+
" Pass 1: Generate schema-correct models (names may be mechanical)\n" +
27+
" Pass 2: Aggressively refactor for quality (TS-derived names, dedup)\n\n" +
28+
"Use --pass1-only to stop after Pass 1, or --pass1-dir to skip Pass 1\n" +
29+
"and refactor an existing output.",
2530
)
2631
.requiredOption(
2732
"--server-src <path>",
@@ -56,9 +61,22 @@ program
5661
)
5762
.option(
5863
"--max-attempts <n>",
59-
"Maximum generation + verification attempts",
64+
"Maximum generation + verification attempts (Pass 1)",
6065
"3",
6166
)
67+
.option(
68+
"--pass2-max-attempts <n>",
69+
"Maximum verification attempts for Pass 2 (defaults to --max-attempts)",
70+
)
71+
.option(
72+
"--pass1-dir <path>",
73+
"Skip Pass 1 — use this directory as pre-generated Pass 1 output",
74+
)
75+
.option(
76+
"--pass1-only",
77+
"Only run Pass 1 (correctness), skip Pass 2 (quality refactoring)",
78+
false,
79+
)
6280
.option(
6381
"--api-key <key>",
6482
"OpenAI API key (or set OPENAI_API_KEY / CODEX_API_KEY env var)",
@@ -76,6 +94,13 @@ program
7694
model: rawOpts.model,
7795
effort: rawOpts.effort,
7896
maxAttempts: parseInt(rawOpts.maxAttempts, 10),
97+
pass2MaxAttempts: rawOpts.pass2MaxAttempts
98+
? parseInt(rawOpts.pass2MaxAttempts, 10)
99+
: undefined,
100+
pass1Dir: rawOpts.pass1Dir
101+
? path.resolve(rawOpts.pass1Dir)
102+
: undefined,
103+
pass1Only: rawOpts.pass1Only,
79104
apiKey:
80105
rawOpts.apiKey ||
81106
process.env.OPENAI_API_KEY ||

0 commit comments

Comments
 (0)