feat: preset abstraction + --preset flag + split: config section (#14)#18
Merged
Conversation
Introduce a `preset` package that supersedes `profile`. A preset now carries split option defaults (max-lines, max-depth) alongside identity keys, so a named document shape can seed the whole split configuration — the seam later slices hang semantic extraction rules on. Wire the split command to resolve options with the precedence flags > env > config file > preset > engine defaults: - add `--preset` (default quicksight); keep `--profile` as a hidden deprecated alias - add a `split:` section to the config file (preset, max_lines, max_depth, id_keys) and matching YAMLX_SPLIT_* env vars, with unset pointers letting the preset default stand - stash the loaded config on the command context so the split command can read it Behavior is unchanged for existing invocations: the quicksight preset keeps the engine's 40-line / depth-3 defaults, and round-trip verify stays green. Closes #14. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR introduces a new preset abstraction (superseding profile) and wires it through the CLI and config system so split defaults can be driven by --preset, config split: settings, and YAMLX_SPLIT_* env vars—while preserving existing behavior via a hidden --profile alias.
Changes:
- Added
internal/presetwithPreset(defaults + identity keys) andQuickSight/Generic/ByNamehelpers; removedinternal/profile. - Added config support for a
split:section (preset,max_lines,max_depth,id_keys) and matching*_SPLIT_*env var overrides. - Updated
splitCLI plumbing to resolve options with precedenceflags > env > config file > preset > engine defaults, plus updated script-based fixtures/tests.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| internal/profile/profile.go | Removed old profile abstraction (identity-key-only). |
| internal/preset/preset.go | Introduces preset abstraction carrying split defaults + ID keys. |
| internal/preset/preset_test.go | Updates tests to preset package and adds default-threshold coverage. |
| internal/config/config.go | Adds SplitConfig and env parsing for SPLIT_* keys. |
| internal/config/config_test.go | Adds tests for split config parsing, env overrides, and invalid ints. |
| internal/cli/testdata/script/preset-config.txtar | New script proving config-driven split behavior + precedence. |
| internal/cli/testdata/script/identity.txtar | Updates scripts to --preset, retains --profile alias coverage. |
| internal/cli/logger.go | Adds a new context key for stashing resolved config. |
| internal/cli/commands.go | Implements resolveSplitOptions, adds --preset + hidden --profile alias. |
| internal/cli/cli.go | Stashes loaded config on command context for split option resolution. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Bind --preset and --profile to separate vars so resolveSplitOptions can prefer --preset when both are set (was: both bound the same var, resolving by cobra arg-order with a comment that falsely claimed separate vars). Add a txtar case proving --preset wins over --profile. - Tighten the precedence comment: env/file are pre-merged by config.Load, so the effective layering the resolver sees is flags > config > preset > defaults. - Update README + config guide: --profile → --preset (kept as a documented deprecated alias), document the split: config block, YAMLX_SPLIT_* env vars, and the full precedence order; fix the stale internal/profile path/type in the contributor section. 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 & why
First slice of preset-based semantic explosion (#14). Establishes the preset abstraction and the config/CLI plumbing that later slices (#15 rule engine, #16 SQL sidecar) hang rules on. No semantic extraction rules yet — this is the additive foundation, and existing behavior is unchanged.
Changes
internal/preset(supersedesinternal/profile): aPresetnow bundles split option defaults (MaxLines,MaxDepth) withIDKeys.QuickSight()/Generic()/ByName()carried over; profile package deleted.--presetflag (defaultquicksight) onsplit;--profilekept as a hidden deprecated alias so existing scripts keep working.split:section (preset,max_lines,max_depth,id_keys) + matchingYAMLX_SPLIT_*env vars. Optional fields use nil pointers / empty slices so "unset" lets the preset default stand rather than clobbering it with a zero.resolveSplitOptions:flags > env > config file > preset > engine defaults. Loaded config is stashed on the command context for the split command to read.Verification
go build ./...,go test ./...,golangci-lint runall green.split:file/env/precedence + invalid-int error;identity.txtarupdated to--preset(+--profilealias + unknown-preset usage error); newpreset-config.txtarproving the config block drives the split, a flag overrides it, and it still round-trips.--preset quicksightreproduces prior output,--profilealias works and is hidden from help, unknown preset exits 2,YAMLX_SPLIT_MAX_LINESenv override applies,verifyok.Notes
--profileis now hidden/deprecated in favor of--preset— flagging in case you'd rather keep--profilevisible.config.Configis no longer==-comparable (nestedsplit:struct); the one test relying on that now usesreflect.DeepEqual.Closes #14.
🤖 Generated with Claude Code