feat(#14): code Generation Layer module interface specification#77
Conversation
- Remove ParsedTicket alias, use IssueTemplate directly - Extract duplicated readEnv() to shared src/utils/env.ts - Move CONTRIBUTING.md from src/ to designs/ - Move test file to test/layers/code-gen/ matching src/ convention - Merge duplicate imports in test file - Add missing test cases (env var fallback, alias resolution, empty inputs) - Revert unrelated proxyquire change in context-loader.spec.ts - Regenerate clean package-lock.json removing spurious peer additions
Hareet
left a comment
There was a problem hiding this comment.
Interface and registry are clean. Tests are solid on the happy paths.
A few things to address:
1. CodeGenModuleOutput needs a partial failure channel
The output has files and explanation but no way to signal "I generated 3 of 5 files, 2 failed." When a module hits an LLM rate limit or produces invalid output mid-generation, it won't handle partial failures. Suggest adding:
export interface CodeGenModuleOutput {
files: GeneratedFile[];
explanation: string;
tokensUsed?: number;
modelUsed?: string;
warnings?: string[]; // non-fatal issues during generation
}
2.. Silent duplicate registration
Calling registry.register() twice with the same name silently overwrites
And the examples use cht-core's project structure. Maybe in the contributing section, we want to say that will need to be changed to whatever repo you want to code-gen (cht-conf)
Quick changes and everything else looks good, thanks!
…ify repo-specific examples
Hareet
left a comment
There was a problem hiding this comment.
Approving! I've read this in detail and re-ran the review and tests a few times.
It's not blocking, and could be a simple comment or doc fix for future agents to understand:
Revised re-review
Status of feedback items:
- ✅ warnings?: string[] added to CodeGenModuleOutput (interface.ts:29)
- ✅ Duplicate register() throws with helpful message + test (registry.ts:14-18, spec:113)
- ✅ "Note on Examples" section in CONTRIBUTING.md flags repo-specific paths
One question on the unrelated refactor (cd62a6e):
The buildScaffoldFiles rewrite changed the fallback condition. Old code fell back to ticket components when zero files were produced (i.e., even if phase components existed but all yielded null from extractModuleName).
New code falls back only when phaseComponents is empty. Trigger is rare in practice (requires trailing-slash or empty input strings), but the old comment "If no phases produced files, generate one from the first listed
component" signals the original intent was the broader fallback. Was this change intentional? If yes, fine — worth a one-line comment so the next reader understands. If no, swap the order: map+filter first, then check
empty.
Recommendation: Approve. The 3 feedback items are addressed cleanly with tests. The refactor question is worth a comment but not a gate.
Summary
CodeGenModuleplugin interface, registry, and contribution guide for the Code Generation Layerclaude-apimodule as the reference exampleDetails
Interface (
src/layers/code-gen/interface.ts)CodeGenModule: core contract (name,version,generate(),validate?())CodeGenModuleInput/Output: provider-agnostic input/output shapeContextFile,GeneratedFile: supporting typesRegistry (
src/layers/code-gen/registry.ts)CodeGenModuleRegistry: register, get, list, resolve aliases, get active moduleLLM_PROVIDERenv >claude-apidefaultanthropic->claude-api,claude-cli->claude-code-cli)Example module (
src/layers/code-gen/modules/claude-api/)validate()checksANTHROPIC_API_KEYpresenceContribution guide (
designs/code-gen-CONTRIBUTING.md)Review fixes (from PR #69)
ParsedTicketalias, useIssueTemplatedirectlyreadEnv()to sharedsrc/utils/env.tssrc/todesigns/test/layers/code-gen/matchingsrc/conventionTest plan
npm testpasses (150 tests, 20 for code-gen layer)Fixes #14