Skip to content

feat: make --config a command-local flag - #241

Merged
ZergsLaw merged 1 commit into
mainfrom
feat/command-local-config
Oct 14, 2026
Merged

ZergsLaw merged 1 commit into
mainfrom
feat/command-local-config

Conversation

@ZergsLaw

Copy link
Copy Markdown
Contributor

Summary

The global --cfg/--config flag was read by only lint, breaking, and validate-config, which declared it again locally anyway. generate, mod, get, ls-files, init, and migrate accepted it and ignored it without any message. For example, easyp --cfg x generate succeeded and did nothing with x. A global EASYP_CFG also leaked into every command that reads it.

This PR replaces the global flag with a single command-local --config:

Command --config selects Without it
lint, breaking a policy file nearest easyp.yaml (unchanged)
generate a generation file; replaces --gen-config; still exclusive with --project/--all nearest easyp.gen.yaml (unchanged)
validate-config a file or directory scans cwd (unchanged)
mod, get, ls-files, init, migrate — (directory-based discovery as before) —
  • EASYP_CFG is removed.
  • --frozen, --debug, and --format stay global.

File kinds by name

New v1.KindOf / v1.RequireKind in internal/config/v1/files.go recognize these names:

Name Kind
easyp.yaml, *.easyp.yaml policy
easyp.gen.yaml, *.easyp.gen.yaml generation
protobuf.mod module manifest
protobuf.lock module lock

How the kind is used:

  • Wrong kind: a command rejects a recognized file of another kind, e.g. lint --config easyp.gen.yaml fails with easyp.gen.yaml is a generation config; this command expects a policy config. Before, such a file failed with a confusing YAML decode error.
  • Other names: read as the format the command expects. Arbitrary names such as strict.yaml still work.
  • validate-config: this fixes a bug. Before, validate-config --config private.easyp.gen.yaml validated the file as a policy and reported additional property "plugins" is not allowed. Directory scans skipped named profiles entirely. Now they are found and validated with the right schema. The policy extends check also skips generation profiles.

Breaking for nightly users

Before After
easyp --cfg strict.yaml lint easyp lint --config strict.yaml
easyp generate --gen-config private.easyp.gen.yaml easyp generate --config private.easyp.gen.yaml
EASYP_CFG=… removed

The old forms now fail with flag provided but not defined. --gen-config shipped only in v1.0.0-nightly.20261009.1.

Follow-ups (not in this PR)

  • easyp-tech/actions: lint and breaking pass the config input as a global --cfg=… before mod download and the command. With a v1 image that includes this change, setting config breaks the action. The action has to place --config after lint/breaking when the image is v1. The vendored skill already tells users to leave config unset with v1 images until then.
  • feat: EasyP v1 support and v0 → v1 migration procedure protobuf-expert-skill#2: upstream needs the same skill edits as .agents/skills/protobuf-expert-skill here.

Docs

  • Updated .spec/CLI.md, README.md, and V1_RELEASE_NOTES.md (new "Command-local configuration selection" section).
  • Updated .agents/skills/{epctl-commands,go-testing,protobuf-expert-skill}.

Test plan

  • go test -race -count=1 ./... passes, except internal/adapters/gitmodules TestGitTimeoutStopsModuleCandidateSearch. That test fails identically on pristine main (987036e) on this machine. It depends on GIT_SSH_COMMAND being honoured, and this machine's git config intercepts it. It is unrelated to this change.
  • New tests:
    • v1.KindOf/RequireKind tables;
    • validate-config named-profile discovery and explicit selection;
    • CLI rejection of empty or wrong-kind --config for lint/breaking/generate/validate;
    • cmd/easyp: --config is not global, is registered exactly on lint/breaking/generate/validate-config, and the global --cfg is rejected.
  • Existing --gen-config tests moved to --config, with precise error assertions.
  • golangci-lint v2.14.0 (repo pin) on the changed packages: 0 issues; gofmt clean.
  • Manual smoke test with the built binary:
    • --cfg is rejected;
    • lint --config private.easyp.gen.yaml and generate --config easyp.yaml are rejected with kind errors;
    • lint --config strict.easyp.yaml lints;
    • validate-config passes on a directory with named profiles.

🤖 Generated with Claude Code

Remove the global --cfg/--config flag and EASYP_CFG. lint and breaking
select a policy file, generate selects a generation file (replacing
--gen-config), and validate-config selects a file or directory, each
through its own --config flag.

File kinds come from names: easyp.yaml and *.easyp.yaml are policies,
easyp.gen.yaml and *.easyp.gen.yaml are generation configs. Commands
reject a recognized file of another kind, and validate-config now
validates named profiles with the right schema and discovers them when
scanning a directory.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ZergsLaw

Copy link
Copy Markdown
Contributor Author

The GitHub Actions follow-up is in easyp-tech/actions#1: the actions now detect whether the image takes <command> --config and fall back to the global --cfg for v0 and older nightlies.

@ZergsLaw
ZergsLaw merged commit 793353c into main Oct 14, 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.

2 participants