Skip to content

feat: add hive config validate command#7

Merged
hay-kot merged 6 commits into
mainfrom
feat/config-validate
Jan 24, 2026
Merged

feat: add hive config validate command#7
hay-kot merged 6 commits into
mainfrom
feat/config-validate

Conversation

@hay-kot

@hay-kot hay-kot commented Dec 4, 2025

Copy link
Copy Markdown
Collaborator

Summary

  • Add hive config validate command to test configuration files before execution
  • Validates file access, template syntax, regex patterns, and keybindings
  • Supports --format json for tooling integration
  • Exits with code 1 if validation fails

Validation Checks

  1. File Access - Config file readable, git executable found, data directory accessible
  2. Template Syntax - Spawn commands and keybinding shell commands parse correctly
  3. Pattern Syntax - Hook patterns are valid regex (warns if patterns look like globs)
  4. Keybindings - Valid actions, no conflicts between action/sh fields

Example Output

$ hive config validate
✔ File Access: File paths validated
  Config file: ~/.config/hive/config.yaml (found)
  Git path: /opt/homebrew/bin/git (found)
  Data directory: ~/.local/share/hive (exists)
✔ Spawn Commands: 1 command(s) defined
  Command 0: valid template
✔ Recycle Commands: 3 command(s) defined
✔ Hooks: 3 hook(s) defined
✔ Keybindings: 4 keybinding(s) defined

✔ Configuration is valid

Test plan

  • Unit tests for all validation scenarios
  • Manual testing with valid config
  • Manual testing with invalid templates, regex, and keybindings
  • JSON output format verified
  • Exit code 1 on validation failure

Closes #3

Add comprehensive configuration validation that checks:
- File access (config file, git path, data directory)
- Template syntax for spawn commands and keybinding shell commands
- Regex patterns for hooks (with glob pattern detection)
- Keybinding configuration (action/sh exclusivity, valid actions)

Supports text and JSON output formats. Exits with code 1 on errors.

Closes #3
- Use io.Discard instead of custom nopWriter
- Add JSON tags to validation structs for consistent output
- Sort keybinding keys for deterministic validation order
- Remove glob pattern detection (just validate regex)
- Fix comment to reflect regex usage instead of glob
- Replace custom ValidationResult with criterio.FieldErrors
- Add Warnings() method for non-fatal issues
- Improve CLI output with grouped errors/warnings
- Add FatalError support for criterio.FieldErrors in printer
- Add validate:invalid task for testing error output
- ValidateDeep now calls Validate first for basic structural checks
- Add recycle command template validation (was missing)
- Simplify validateKeybindingTemplates to only check templates
- Add RecycleTemplateData type with field documentation
- Add field documentation to SpawnTemplateData and KeybindingTemplateData
- Add nil check for Config in validate command
- Rename context variable to errContext to avoid shadowing
- Add validConfig test helper and recycle template tests
- Merge validateSpawnCommands and validateRecycleCommands into generic validateTemplates helper
- Extract extractFieldErrors helper to unify error extraction in outputJSON and outputText
Add extensible health check system with styled output.
Config validation is now the first check under `hive doctor`.
@hay-kot hay-kot force-pushed the feat/config-validate branch from 4d41b38 to 242be3f Compare January 24, 2026 02:16
@hay-kot hay-kot merged commit 563a1d6 into main Jan 24, 2026
2 checks passed
@hay-kot hay-kot deleted the feat/config-validate branch January 24, 2026 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add hive config validate command

1 participant