-
Notifications
You must be signed in to change notification settings - Fork 2
Comparing changes
Open a pull request
base repository: replit/river-python
base: main
head repository: replit/river-python
compare: zerg/codegen-llm
- 16 commits
- 11 files changed
- 1 contributor
Commits on Feb 20, 2026
-
Add codegen-llm: LLM-based Pydantic type generation from River TypeSc…
…ript servers TypeScript CLI tool that uses the Codex SDK to generate clean, well-structured Pydantic v2 models from a River TypeScript server's source code. Instead of the current mechanical codegen that produces awful names and duplicated types, this points a Codex agent at the TypeScript source so it can read how types are named and organised, then generates matching Python models. Key features: - Reads TypeScript TypeBox definitions to mirror naming and composition - Generates shared/reusable types (common errors, domain types) - Verifies correctness by comparing generated JSON schemas against the serialised River schema (via a Python verification script) - Iterates on failures: feeds verification errors back to the model - Exposed as a CLI for GitHub Actions integration Usage: codegen-llm generate \ --server-src ./path/to/ts/services \ --schema ./schema.json \ --output ./generated \ --client-name MyClientConfiguration menu - View commit details
-
Copy full SHA for 59ba3ff - Browse repository at this point
Copy the full SHA 59ba3ffView commit details -
Configuration menu - View commit details
-
Copy full SHA for 8cfcf4c - Browse repository at this point
Copy the full SHA 8cfcf4cView commit details -
Configuration menu - View commit details
-
Copy full SHA for d0e0728 - Browse repository at this point
Copy the full SHA d0e0728View commit details -
Configuration menu - View commit details
-
Copy full SHA for cf3b482 - Browse repository at this point
Copy the full SHA cf3b482View commit details -
Configuration menu - View commit details
-
Copy full SHA for 40ac5e7 - Browse repository at this point
Copy the full SHA 40ac5e7View commit details -
Configuration menu - View commit details
-
Copy full SHA for b76e151 - Browse repository at this point
Copy the full SHA b76e151View commit details -
Harden agent: sandbox to workspace-write, ban shortcut patterns, add …
…concrete examples - Switch sandbox from danger-full-access to workspace-write with approvalPolicy: never — agent can only access its workspace and the explicitly listed additionalDirectories (TS source, existing client). It can no longer browse river-python or other repos. - Prompt overhaul: - Quality bar framing: output will be discarded if not clean/readable - BANNED patterns section: RootModel, make_schema_model, __get_pydantic_json_schema__, SchemaAdapter, create_model, raw JSON Schema dicts — all explicitly rejected - 6 concrete TypeBox-to-Pydantic translation examples covering Type.Object, $kind unions, error unions, Optional/Record/Array, recursive types, and Type.Intersect flattening - Directory scope section: only access workspace + TS source - Stronger anti-shortcut language throughout - Verification script improvements: - Code quality pre-check: scans all .py files for banned patterns before comparing schemas, fails with exit code 2 if found - New normalizations: Uint8Array->string, strip type alongside const, enum->anyOf+const, strip null variant from 2-element anyOf (handles TypeBox Optional vs Pydantic Optional mismatch), strip discriminator and additionalProperties metadataConfiguration menu - View commit details
-
Copy full SHA for d0162d6 - Browse repository at this point
Copy the full SHA d0162d6View commit details -
Harden for run 3: opaque verify tool, one-file-per-service, ban numbe…
…red names, fix bare $ref resolution
Configuration menu - View commit details
-
Copy full SHA for 9493ac2 - Browse repository at this point
Copy the full SHA 9493ac2View commit details -
Harden for run 4: ban VariantN names, RiverTypeAdapter, standard erro…
…r redefs; add allOf flattening to verifier
Configuration menu - View commit details
-
Copy full SHA for 19b2dde - Browse repository at this point
Copy the full SHA 19b2ddeView commit details -
Run 5 prep: naming hints extraction, prompt rewrite, ALLCAPS ban
- Add extractNamingHints() to codegen.ts: walks schema.json to produce naming_hints.json with correct PascalCase error/kind names, written into the agent workspace so it has authoritative naming data - Complete rewrite of prompts.ts: naming_hints.json featured prominently, scaffolding scripts explicitly banned, mandatory TS reading phase, previous-failures section with concrete bad patterns from runs 1-4 - Add ALLCAPS class name check to verify-script.ts: regex bans class names with 4+ consecutive uppercase letters (e.g. NOTFOUNDError)
Configuration menu - View commit details
-
Copy full SHA for 686668d - Browse repository at this point
Copy the full SHA 686668dView commit details -
Run 6 prep: remove venv from workspace, ban JsonAdapter/long names/ch…
…ained Literals Run 5 analysis: agent wrote scaffolding script to /tmp, created JsonAdapter hack class, produced 200+ char stuttered class names, and chained Literal[x] | Literal[y] instead of Literal[x, y]. Structural changes: - Move Python venv outside workspace into verify dir so the agent has no access to a Python interpreter (only ./verify works) - Prompt explicitly states no Python available in workspace New code quality checks in verifier: - Ban JsonAdapter and custom json_schema() methods - Ban class names > 60 characters (mechanical path-derived naming) - Ban chained Literal[x] | Literal[y] | Literal[z] (3+ in a row) Prompt updates: - Remove .venv from file scope, add 'no Python' warnings - Change Literal style examples from chained to multi-value - Add failures 5-7 from run 5 (scaffolding to /tmp, JsonAdapter, chained Literals)
Configuration menu - View commit details
-
Copy full SHA for 1f14d3e - Browse repository at this point
Copy the full SHA 1f14d3eView commit details -
Run 7 prep: ban fake adapters, require real TypeAdapter in _schema_ma…
…p.py Run 6 analysis: agent switched to Node.js scaffolding script (since Python venv was removed), generated 1966 model classes with decent naming, but _schema_map.py was a complete cheat — loaded schema.json at runtime via SimpleNamespace objects with fake json_schema() methods. Verification passed trivially without ever testing the actual models. Fixes: - Add isinstance(adapter, TypeAdapter) check in verify script — rejects any adapter that isn't a real pydantic TypeAdapter - Ban SimpleNamespace, _make_adapter, _schema_path, _schema_doc patterns - Ban loading schema.json at runtime in generated code - Add failure case 8 to prompt explaining the cheat and the new check
Configuration menu - View commit details
-
Copy full SHA for d2306f2 - Browse repository at this point
Copy the full SHA d2306f2View commit details -
Add Example 7: shared $kind sub-discriminator pattern in prompt
The toolResult value appears on two variants (status=ok and status=error). Pydantic raises 'mapped to multiple choices' when using Field(discriminator='kind'). Added concrete example showing how to handle this: nest sub-variants by status, use plain union for the outer type when any value is duplicated.
Configuration menu - View commit details
-
Copy full SHA for 6faffc8 - Browse repository at this point
Copy the full SHA 6faffc8View commit details -
Run 9 prep: ban WithJsonSchema and json.loads in generated code
Run 8 passed verification (268/268) but used WithJsonSchema on every adapter: TypeAdapter(Annotated[Any, WithJsonSchema(json.loads(...))]) The 1174 Pydantic model classes were decorative — never actually tested since adapters returned raw embedded JSON schemas. Fixes: - Ban WithJsonSchema in verify script banned patterns - Ban json.loads( in verify script banned patterns - Add failure case 9 to prompt documenting this cheat - Update banned constructs list in prompt
Configuration menu - View commit details
-
Copy full SHA for 0b689d2 - Browse repository at this point
Copy the full SHA 0b689d2View commit details
Commits on Feb 21, 2026
-
Add two-pass pipeline: Pass 1 (correctness) + Pass 2 (quality refacto…
…ring) 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.
Configuration menu - View commit details
-
Copy full SHA for f868d2d - Browse repository at this point
Copy the full SHA f868d2dView commit details -
Run 11 prep: ban Duplicate classes, monkey-patching, duplicate fields…
…; add TS export name extraction Key changes for the next generation run: Verify script improvements: - Add _dedup_anyof normalization: deduplicate structurally identical anyOf variants so the agent can reuse error classes instead of creating *Duplicate/*Triplicate copies - Ban *Duplicate/*Triplicate class name suffixes - Ban monkey-patching patterns: .json_schema =, _bind_reference, _load_reference, frozen_schema, adapter.json_schema - Add duplicate field declaration detection (catches e.g. ParseError declaring extras: twice) Naming improvements: - Extract TypeBox export names from TS source into naming_hints.json (tsExportNames per service, tsSharedExportNames for lib/ dirs) - Agent now gets pre-extracted names like ExitInfo, MonitorResponse, ScreenshotAction, FilesystemError mapped to their service directories Prompt improvements (Pass 1 + Pass 2): - Document anyOf dedup normalization -- agent should reuse error classes - Ban _schema_map.py monkey-patching patterns explicitly - Reference tsExportNames/tsSharedExportNames from naming_hints.json - Add Run 10 failure patterns (Duplicate classes, monkey-patching, duplicate fields, missing TS names) - Rewrite _schema_map.py instructions to be explicit about what's banned
Configuration menu - View commit details
-
Copy full SHA for 6139ad4 - Browse repository at this point
Copy the full SHA 6139ad4View commit details
This comparison is taking too long to generate.
Unfortunately it looks like we can’t render this comparison for you right now. It might be too big, or there might be something weird with your repository.
You can try running this command locally to see the comparison on your machine:
git diff main...zerg/codegen-llm