Skip to content

feat: preset abstraction + --preset flag + split: config section (#14)#18

Merged
NickMoignard merged 2 commits into
masterfrom
feat/14-preset-config-cli
Jul 11, 2026
Merged

feat: preset abstraction + --preset flag + split: config section (#14)#18
NickMoignard merged 2 commits into
masterfrom
feat/14-preset-config-cli

Conversation

@NickMoignard

Copy link
Copy Markdown
Owner

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 (supersedes internal/profile): a Preset now bundles split option defaults (MaxLines, MaxDepth) with IDKeys. QuickSight()/Generic()/ByName() carried over; profile package deleted.
  • --preset flag (default quicksight) on split; --profile kept as a hidden deprecated alias so existing scripts keep working.
  • Config split: section (preset, max_lines, max_depth, id_keys) + matching YAMLX_SPLIT_* env vars. Optional fields use nil pointers / empty slices so "unset" lets the preset default stand rather than clobbering it with a zero.
  • Precedence resolved in 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 run all green.
  • New tests: preset defaults; config split: file/env/precedence + invalid-int error; identity.txtar updated to --preset (+ --profile alias + unknown-preset usage error); new preset-config.txtar proving the config block drives the split, a flag overrides it, and it still round-trips.
  • Smoke-tested on a real fixture: --preset quicksight reproduces prior output, --profile alias works and is hidden from help, unknown preset exits 2, YAMLX_SPLIT_MAX_LINES env override applies, verify ok.

Notes

  • --profile is now hidden/deprecated in favor of --preset — flagging in case you'd rather keep --profile visible.
  • config.Config is no longer ==-comparable (nested split: struct); the one test relying on that now uses reflect.DeepEqual.

Closes #14.

🤖 Generated with Claude Code

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>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/preset with Preset (defaults + identity keys) and QuickSight/Generic/ByName helpers; removed internal/profile.
  • Added config support for a split: section (preset, max_lines, max_depth, id_keys) and matching *_SPLIT_* env var overrides.
  • Updated split CLI plumbing to resolve options with precedence flags > 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.

Comment thread internal/cli/commands.go Outdated
- 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>
@NickMoignard NickMoignard merged commit 9975bc6 into master Jul 11, 2026
6 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.

Preset abstraction + --preset flag + split: config section

2 participants