@@ -195,26 +195,61 @@ This script:
195195
196196**If it fails, read the errors carefully and fix the mismatches. Then re-run.**
197197
198+ ## How to approach this
199+
200+ **Take your time.** There are many services and many procedures. That is
201+ expected — you should work through them methodically, one service at a time.
202+ Do NOT try to be clever by writing a meta-generator or a script that batch-
203+ produces models mechanically. The whole point of using an LLM is that you
204+ read the TypeScript source for each service, understand how the types are
205+ named and structured, and write clean idiomatic Pydantic models that match.
206+
207+ This is a large task and it is fine for it to take a long time. Quality
208+ matters more than speed. Work through every service, every procedure.
209+
198210## Process
199211
200- 1. Start by reading the service registry in the TypeScript source to get the
201- full list of services.
202- 2. Read the TypeScript source for a few representative services to understand
203- patterns (pick ones with varied procedure types: rpc, subscription, stream).
204- 3. Read the serialised schema.json to see the exact JSON Schema structure
205- (use \`head\`, \`jq\`, etc. — the file may be large).
206- 4. Identify shared types that appear across services.
207- 5. Generate \`_errors.py\` and \`_common.py\` first.
208- 6. Generate each service's types, reading the corresponding TypeScript source
209- for naming guidance.
210- 7. Generate \`_schema_map.py\`.
211- 8. Generate the top-level \`__init__.py\` with the \`${ opts . clientName } \` client class.
212+ ### Phase 1: Understand the landscape
213+
214+ 1. Read the service registry in the TypeScript source to get the full list
215+ of services.
216+ 2. Read a few representative services' TypeScript source to understand the
217+ patterns (pick ones with varied procedure types: rpc, subscription,
218+ upload, stream).
219+ 3. Inspect a few services in schema.json via \`jq\` to see the exact JSON
220+ Schema structure the verifier will compare against.
221+
222+ ### Phase 2: Shared types
223+
224+ 4. Identify the shared River error types (\`UNCAUGHT_ERROR\`, etc.) that
225+ appear in every procedure. Write \`_errors.py\`.
226+ 5. Scan the TypeScript source for domain types that are reused across
227+ multiple services. Write \`_common.py\`.
228+
229+ ### Phase 3: Service-by-service generation
230+
231+ 6. For **each** service, one at a time:
232+ a. Read the TypeScript source for that service (the \`index.ts\`,
233+ \`schemas.ts\`, \`scaffold.ts\`, etc. in its directory).
234+ b. Read the corresponding JSON Schema via
235+ \`jq '.services.<serviceName>' schema.json\`.
236+ c. Write the Pydantic models for each procedure in that service,
237+ using names that mirror the TypeScript definitions.
238+ d. Write the service class (\`__init__.py\`) with typed methods.
239+
240+ Do this for every single service. Do not skip any.
241+
242+ ### Phase 4: Assembly and verification
243+
244+ 7. Write \`_schema_map.py\` covering every service and procedure.
245+ 8. Write the top-level \`__init__.py\` with the \`${ opts . clientName } \` client class.
2122469. Run \`.venv/bin/python verify_schema.py schema.json generated\`
213- 10. Fix any errors and re-run until verification passes.
247+ 10. If it fails, read the errors, fix the models, and re-run.
248+ Repeat until verification passes.
214249
215250## Important notes
216251
217- - The JSON schema file may be very large. Don't try to read it all at once.
252+ - The JSON schema file is large. Don't try to read it all at once.
218253 Use \`jq\`, \`head\`, \`grep\`, or read specific services.
219254- Use \`jq '.services | keys' schema.json\` to list all service names.
220255- Use \`jq '.services.<serviceName>' schema.json\` to inspect a specific service.
@@ -226,6 +261,8 @@ This script:
226261- For \`Optional[X]\`, Pydantic produces
227262 \`{"anyOf": [{...X...}, {"type": "null"}]}\` — the verification script
228263 normalises this.
264+ - Do NOT write a Python script or code generator that mechanically produces
265+ models. You are the generator. Read the TypeScript, write the Python.
229266` . trim ( ) ;
230267}
231268
0 commit comments