Skip to content

feat: add g0 config validate command#98

Open
kai-agent-free wants to merge 1 commit into
guard0-ai:mainfrom
kai-agent-free:feat/config-validate
Open

feat: add g0 config validate command#98
kai-agent-free wants to merge 1 commit into
guard0-ai:mainfrom
kai-agent-free:feat/config-validate

Conversation

@kai-agent-free
Copy link
Copy Markdown

Summary

Adds g0 config validate [path] command that checks .g0.yaml for errors before running a scan.

Features

  • Validates all known config keys: preset, min_score, min_grade, fail_on, exclude_rules, exclude_paths, rules_dir, severity_overrides, thresholds, analyzers, domain_weights, risk_accepted
  • Reports unknown keys with "did you mean?" suggestions (e.g. stricktstrict)
  • Type validation for all fields (numbers, strings, booleans, arrays, mappings)
  • Warns on out-of-range values (e.g. min_score > 100)
  • Validates risk_accepted entries for required rule/reason fields
  • Exits 0 on valid config, 1 on errors
  • Accepts optional path argument (file or directory)

Files

  • src/cli/commands/config.ts — new config command with validate subcommand
  • src/cli/index.ts — register config command
  • tests/unit/config-validate.test.ts — 18 unit tests

Verification

  • tsc --noEmit passes ✅
  • All 18 tests pass ✅

Closes #85

- Add src/cli/commands/config.ts with validate subcommand
- Validates .g0.yaml against expected schema
- Reports unknown keys with 'did you mean?' suggestions
- Validates presets, severities, grades, analyzers, thresholds
- Checks risk_accepted entries for required fields
- Exit 0 on valid, exit 1 on errors
- Register config command in CLI index
- Add 18 unit tests

Closes guard0-ai#85
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.

Add g0 config validate command

1 participant