feat: add complypack init command and JSON Schema validation layer#142
Draft
trevor-vaughan wants to merge 1 commit into
Draft
feat: add complypack init command and JSON Schema validation layer#142trevor-vaughan wants to merge 1 commit into
complypack init command and JSON Schema validation layer#142trevor-vaughan wants to merge 1 commit into
Conversation
- Introduce `complypack init` with interactive (charmbracelet/huh) and
flag-driven modes for generating complypack.yaml configs
- Add Draft 2020-12 JSON Schema at schemas/jsonschema/ with embedded
go:embed, enforcing reverse-domain IDs, semver, and evaluator-id format
- Wire schema validation into LoadConfig, pack, and mcp serve entry points
- Add unknown-key detection with Levenshtein did-you-mean suggestions
- Restructure Taskfile into root + .taskfiles/{deps,dev}.yml includes
- Pin Ginkgo as Go 1.24+ tool dependency; CI uses `go tool ginkgo`
- Add ADR-018 documenting schema file layout and symlink rationale
- Expose module version via internal/version for --version flag and
generated config headers
Details:
Init command (cmd/complypack/cli/init.go):
- Interactive mode: huh forms with inline validators derived from schema
regex patterns (single source of truth for ID, version, evaluator-id)
- Non-interactive mode: --schema, --source, --evaluator-id, --id, --version
- O_EXCL prevents accidental overwrites; --force switches to O_TRUNC
- Credential detection on source URIs with --allow-credentials escape hatch
- --strict promotes unknown-key warnings to errors
Schema validation (schemas/jsonschema/):
- complypack.schema.json embedded via go:embed; symlinked at
schemas/json-schema/ for editor discoverability
- validate.go: scope-aware validators (ValidateConfig, ValidateForPack,
ValidateForMCP, ValidateForInit) with human-readable error mapping
- unknown.go: walks deserialized maps against known-field registry;
Levenshtein-based did-you-mean on unrecognized keys
Config layer (internal/config/complypack.go):
- LoadConfig gains strict parameter; pack always validates strictly,
mcp serve uses lenient mode (warnings on stderr, no startup failure)
- BuildConfig, MarshalConfigYAML, WriteConfigFile, CheckCredentialURIs
extracted as shared helpers
- omitempty on optional struct tags for clean partial configs
Build and docs:
- Taskfile split: root aliases delegate to .taskfiles/{deps,dev}.yml
- README updated with init usage, shell completion, and --strict docs
- Windows symlink caveat documented in README and ADR-018
Closes: #80
Assisted-by: Claude (Anthropic, Claude Opus 4.6)
Signed-off-by: Trevor Vaughan <tvaughan@redhat.com>
b488b6b to
3d3bab9
Compare
✅ CRAP Load Analysis: PASS (no baseline)No baseline file found at How to Enable Regression DetectionGenerate and commit a baseline file to track CRAP score changes over time: # 1. Install gaze
go install github.com/unbound-force/gaze/cmd/gaze@latest
# 2. Run tests and generate baseline
go test -coverprofile=coverage.out ./...
mkdir -p .gaze
gaze crap --format=json --coverprofile=coverage.out ./... > .gaze/baseline.json
# 3. Commit the baseline
git add .gaze/baseline.json
git commit -m "chore: add CRAP baseline for regression detection"For more information: Summary
|
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.
complypack initwith interactive (charmbracelet/huh) andflag-driven modes for generating complypack.yaml configs
go:embed, enforcing reverse-domain IDs, semver, and evaluator-id format
go tool ginkgogenerated config headers
Details:
Init command (cmd/complypack/cli/init.go):
regex patterns (single source of truth for ID, version, evaluator-id)
Schema validation (schemas/jsonschema/):
schemas/json-schema/ for editor discoverability
ValidateForMCP, ValidateForInit) with human-readable error mapping
Levenshtein-based did-you-mean on unrecognized keys
Config layer (internal/config/complypack.go):
mcp serve uses lenient mode (warnings on stderr, no startup failure)
extracted as shared helpers
Build and docs:
Closes: #80
Assisted-by: Claude (Anthropic, Claude Opus 4.6)
Signed-off-by: Trevor Vaughan tvaughan@redhat.com