Skip to content

feat(targets): pluggable codegen target API#134

Merged
ssilvius merged 13 commits intomainfrom
feat/target-api
Mar 20, 2026
Merged

feat(targets): pluggable codegen target API#134
ssilvius merged 13 commits intomainfrom
feat/target-api

Conversation

@ssilvius
Copy link
Copy Markdown
Contributor

Summary

  • Introduces CodegenTarget interface so kelex can target any framework/format
  • Pipeline becomes: Introspect (universal) -> Target (owns mapping + output)
  • Ships two built-in targets: react-tanstack (default, wraps existing templates) and composite (FormDescriptor -> JSON)
  • CLI gains --target flag and kelex targets subcommand
  • Generator preserves backwards-compatible code/primitives fields on GenerateResult

Test plan

  • All 379 existing tests pass unchanged (zero behavioral regression)
  • 26 new tests for target types, registry, react-tanstack target, and composite target
  • pnpm typecheck clean
  • pnpm lint clean (only pre-existing a11y issues in test fixtures)
  • Manual: kelex generate schema.ts --target react-tanstack same output as before
  • Manual: kelex generate schema.ts --target composite produces valid JSON
  • Manual: kelex targets lists available targets

🤖 Generated with Claude Code

ssilvius and others added 13 commits March 1, 2026 14:02
Defines data-driven assertion tables for all 11 stress schemas to verify
pipeline fidelity (introspection types, component mapping, constraints) and
generated JSX correctness (nested paths, imports, structural patterns).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Detailed task-by-task plan for expanding stress.spec.ts with assertion
tables for all 11 schemas, covering introspection fidelity, component
mapping, and generated JSX structure.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Pipeline becomes Introspect (universal) -> Target (owns mapping + output).
CodegenTarget interface lets kelex target any framework/format. Ships with
react-tanstack (default, wraps existing templates) and composite (JSON).

CLI gains --target flag and `kelex targets` subcommand. Generator accepts
target + targetOptions while preserving backwards-compatible code/primitives
fields on GenerateResult.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
registerTarget() now throws if target name already exists unless
{ force: true } is passed. Added unregisterTarget() for cleanup.
Registry tests use afterEach to remove custom targets.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Remove intermediate variables and restating comments. Use satisfies
for type-safe inline option construction. Move interface declaration
before first usage in CLI.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
CLI now validates that target-produced filenames resolve within the
output directory. unregisterTarget() throws when called on built-in
targets (react-tanstack, composite). Renamed internal map from
builtinTargets to targets for clarity.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Remove index signature from TargetOptions (enables excess property
  checking on all option subtypes)
- Non-empty tuple for TargetResult.files (compile-time guarantee)
- Template literal for defaultExtension (catches missing dot)
- Per-file write error context in CLI
- Fix stale JSDoc on deriveOutputPath, code, and primitives fields
- Add tests for targetOptions passthrough and backwards-compat shims

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace single-assertion module check with per-module export
verification covering codegen, introspection, mapping, schema-writer,
and target functions/built-in targets.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Expand index.test.ts to verify every public function and built-in
target is exported. Add biome override to skip a11y rules and
formatting on test fixtures (generated code, not hand-authored).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Primary output file uses the user-specified -o path; auxiliary files
(primitives) use target-generated names in the same directory. Add CLI
spec tests for `kelex targets` listing and --target unknown error.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace button+role="checkbox" with native <input type="checkbox">.
Replace button+role="radio" with native <input type="radio">. Use
<span> for Field label (form lib handles association). Add aria-hidden
to decorative SVGs. Revert biome override -- fix the code, not the
rules.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Migrate from @ezmode-games/kelex to @rafters-studio/kelex. Update
package name, repository URL, homepage, README references, and
changeset.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
# Conflicts:
#	.changeset/initial-release.md
#	package.json
@ssilvius ssilvius merged commit 603f9df into main Mar 20, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant