feat(presets): 10 built-in architecture presets + presets CLI - #2
Merged
Conversation
Adds 'presets: [<name>]' to the config: a partial fragment merged under the user's config (user always wins — override by name, ruleset replaces per layer). Presets (strict, severity error): - clean-architecture, hexagonal, node-service (Clean Arch / Ports & Adapters) - nestjs-clean, nest-js, nextjs, tanstack-starter, adonisjs, elysiajs, encore-ts Opinionated frameworks (Nest/Adonis/Encore) follow their official conventions; unopinionated ones (Elysia/TanStack/Next) get Clean Architecture for the core. Researched against each framework's official docs. Mechanism: applyPresets() resolves + deep-merges fragments before zod; a shared _clean-arch-base builder removes duplication; UnknownPresetError gives a 'did you mean' hint (exit 2). DX: 'arch-contract presets [name]' lists/shows presets; 'init --preset <name>' scaffolds. Engine: implemented namespaceExport/star-export detection (was a silent no-op). Per-preset docs under docs/presets/. 351 tests (merge, per-preset resolution + behavioral compliant/violating, DX); self-dogfooded. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds architecture presets — activate a strict, senior-grade rule bundle by name:
10 built-in presets, researched against each framework's official docs:
clean-architecture,hexagonal,node-servicenestjs-clean,nextjs,tanstack-starter,elysiajsnest-js,adonisjs,encore-tsMechanism
applyPresets()resolvespresets(string | string[]), deep-merges fragments left-to-right, then the user config on top, strips the key — the result flows through the unchanged zod schema + normalize.name;rulesetreplaces per layer (not unioned);paths.includereplace /excludeconcat._clean-arch-basebuilder removes duplication; 3 framework-official presets stand alone.UnknownPresetError→ exit 2 with a Levenshtein "did you mean".DX
arch-contract presets [name]— list all / show one (layers + ruleset + rules).arch-contract init --preset <name>— scaffold a config that uses it.docs/presets/.Engine
Implemented
namespaceExport/ star-export (export *) detection — it was schema-accepted but a silent no-op, so the domain-purity preset rules are now honest.Tests
351 green — merge semantics, per-preset resolution (zero semantic issues), per-preset behavioral (compliant fixture → 0 errors; violating fixture → the targeted rule fires), CLI/DX, and the namespaceExport regression. Self-dogfooded (
arch:check+arch:docs:check).🤖 Generated with Claude Code