Skip to content

Commit 4c56ffc

Browse files
committed
feat: Add JSON Schema validation support and enhance configuration management in documentation
1 parent 3184484 commit 4c56ffc

File tree

3 files changed

+101
-17
lines changed

3 files changed

+101
-17
lines changed

.codebase-validation.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/codebase-interface/cli/refs/heads/main/cmd/schema/codebase-validation.schema.json
12
# Go Project Configuration
23
# Comprehensive configuration for Go projects with modern development practices
34
# Includes Go-specific validation rules and strict quality standards
@@ -63,7 +64,7 @@ validation:
6364
- "build"
6465

6566
output:
66-
format: "table"
67+
format: "table"
6768
verbose: true
6869

6970
scoring:

.vscode/settings.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"yaml.schemas": {
3+
"https://raw.githubusercontent.com/codebase-interface/cli/refs/heads/main/cmd/schema/codebase-validation.schema.json": [
4+
".codebase-validation.yml",
5+
"**/codebase-validation.yml",
6+
"**/.codebase-validation.yml"
7+
]
8+
},
9+
"yaml.validate": true,
10+
"yaml.completion": true,
11+
"yaml.hover": true,
12+
"yaml.format.enable": true
13+
}

AGENTS.md

Lines changed: 86 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,25 @@ This document defines the validation agents for the codebase interface CLI. Thes
99
- **Language:** Go (latest stable version)
1010
- **CLI Framework:** [Cobra](https://github.com/spf13/cobra) - Standard Go CLI framework with command structure and flags
1111
- **TUI Framework:** [Bubble Tea](https://github.com/charmbracelet/bubbletea) - Modern terminal UI for interactive validation reports
12+
- **Schema Validation:** [JSON Schema](https://json-schema.org/draft/2020-12/schema) with [gojsonschema](https://github.com/xeipuuv/gojsonschema) - Comprehensive configuration validation
1213
- **Task Runner:** [Taskfile](https://taskfile.dev/) - Task runner for development workflows
1314
- **Testing:** Test-driven development (TDD) approach with Go's built-in testing framework
1415

1516
### Development Principles
1617

1718
- **Test-Driven Development (TDD)** - All features must be developed with tests first
1819
- **Go Best Practices** - Follow Go idioms, effective Go guidelines, and community standards
19-
- **Documentation-Driven** - Maintain comprehensive README.md, CONTRIBUTING.md, and detailed docs/ directory
20+
- **Documentation-Driven** - Maintain comprehensive README.md, CONTRIBUTING.md, AGENTS.md and detailed docs/ directory
2021
- **Task Automation** - Use Taskfile for all development interactions (build, test, lint, release)
2122
- **Conventional Commits** - Follow [Conventional Commits](https://www.conventionalcommits.org/) specification for commit messages
2223

2324
### Architecture Requirements
2425

2526
- Modular agent system for extensibility
2627
- Clean separation between validation logic and UI presentation
27-
- Configuration-driven validation rules
28+
- Configuration-driven validation rules with JSON Schema validation
29+
- Embedded schema system for offline validation and editor integration
30+
- Configuration presets and templates for quick setup
2831
- Structured JSON output for programmatic use
2932
- Interactive TUI for human-friendly reports
3033

@@ -114,25 +117,35 @@ The minimal requirements for any codebase to be considered properly structured.
114117
### Project Structure
115118

116119
```text
117-
codebase-cli/
120+
codebase-interface-cli/
118121
├── cmd/ # Cobra CLI commands
119-
│ ├── root.go # Root command
122+
│ ├── codebase-interface/ # Main CLI entry point
123+
│ ├── root.go # Root command with alias support
120124
│ ├── validate.go # Validation command
125+
│ ├── validate-config.go # Configuration validation command
126+
│ ├── init-config.go # Configuration preset generator
127+
│ ├── schema.go # Schema export command
128+
│ ├── schema/ # Embedded JSON schema
129+
│ │ └── codebase-validation.schema.json
121130
│ └── version.go # Version command
122131
├── internal/ # Internal packages
123132
│ ├── agents/ # Validation agents
124-
│ ├── config/ # Configuration handling
133+
│ ├── config/ # Configuration handling with schema validation
125134
│ ├── output/ # Output formatters
126135
│ └── ui/ # Bubble Tea TUI components
127136
├── pkg/ # Public API packages
128137
├── test/ # Test files and fixtures
129-
├── docs/ # Documentation directory
138+
├── docs/ # Documentation directory (MkDocs)
130139
│ ├── README.md # Documentation overview
131140
│ ├── usage.md # Detailed CLI usage instructions
132-
│ ├── configuration.md # Configuration reference
141+
│ ├── configuration.md # Configuration reference with schema docs
133142
│ ├── agents.md # Agent documentation
134143
│ └── examples/ # Example configurations and use cases
135-
├── Taskfile.yml # Development tasks
144+
├── .vscode/ # VS Code workspace settings
145+
│ └── settings.json # YAML schema integration
146+
├── bin/ # Compiled binaries (git-ignored)
147+
├── Taskfile.yml # Development tasks with MkDocs integration
148+
├── mkdocs.yml # Documentation site configuration
136149
├── README.md # Project documentation
137150
├── CONTRIBUTING.md # Development guidelines
138151
└── go.mod # Go module definition
@@ -145,7 +158,7 @@ tasks:
145158
build:
146159
desc: Build the CLI binary
147160
cmds:
148-
- go build -o bin/codebase-cli ./cmd/codebase-cli
161+
- go build -o bin/codebase-interface ./cmd/codebase-interface
149162

150163
test:
151164
desc: Run all tests
@@ -162,6 +175,22 @@ tasks:
162175
cmds:
163176
- golangci-lint run
164177

178+
validate-schema:
179+
desc: Validate JSON schema and test configuration validation
180+
cmds:
181+
- ./bin/codebase-interface validate-config
182+
- ./bin/codebase-interface schema --output /tmp/schema-test.json
183+
184+
docs:serve:
185+
desc: Serve documentation locally
186+
cmds:
187+
- mkdocs serve
188+
189+
docs:build:
190+
desc: Build documentation site
191+
cmds:
192+
- mkdocs build
193+
165194
tidy:
166195
desc: Tidy Go modules
167196
cmds:
@@ -170,7 +199,7 @@ tasks:
170199
install:
171200
desc: Install CLI locally
172201
cmds:
173-
- go install ./cmd/codebase-cli
202+
- go install ./cmd/codebase-interface
174203
```
175204
176205
### Test-Driven Development Requirements
@@ -198,16 +227,26 @@ tasks:
198227
199228
```bash
200229
# Validate all essential files
201-
codebase-cli validate
230+
codebase-interface validate
202231

203232
# Validate specific agent
204-
codebase-cli validate --agent essential-files
205-
codebase-cli validate --agent git-configuration
206-
codebase-cli validate --agent development-standards
233+
codebase-interface validate --agent essential-files
234+
codebase-interface validate --agent git-configuration
235+
codebase-interface validate --agent development-standards
207236

208237
# Output formats
209-
codebase-cli validate --output json
210-
codebase-cli validate --output table
238+
codebase-interface validate --output json
239+
codebase-interface validate --output table
240+
241+
# Configuration management
242+
codebase-interface init-config basic # Create configuration from preset
243+
codebase-interface validate-config # Validate configuration against schema
244+
codebase-interface schema --output schema.json # Export schema for editor integration
245+
246+
# Short alias available for all commands
247+
cbi validate
248+
cbi init-config go-project
249+
cbi validate-config
211250
```
212251

213252
### Exit Codes
@@ -225,6 +264,37 @@ codebase-cli validate --output table
225264

226265
## Configuration
227266

267+
### Configuration Validation & Management
268+
269+
The CLI provides comprehensive configuration management with JSON Schema validation:
270+
271+
#### Schema Validation Features
272+
273+
- **Type Safety:** Validates data types (boolean, string, number, array)
274+
- **Range Validation:** Ensures numeric values are within valid ranges (0.0-1.0)
275+
- **Enum Validation:** Checks string values against allowed options
276+
- **Property Validation:** Detects typos and unknown configuration keys
277+
- **Required Field Validation:** Ensures all mandatory fields are present
278+
- **Editor Integration:** Provides autocomplete and real-time validation in IDEs
279+
280+
#### Configuration Presets
281+
282+
```bash
283+
# Available preset configurations
284+
cbi init-config basic # Simple validation rules
285+
cbi init-config strict # Comprehensive validation for production
286+
cbi init-config beginner # Gentle validation for learning projects
287+
cbi init-config open-source # Optimized for public repositories
288+
cbi init-config go-project # Go-specific validation rules
289+
```
290+
291+
#### Schema Integration
292+
293+
```yaml
294+
# Enable editor autocomplete and validation
295+
# yaml-language-server: $schema=https://raw.githubusercontent.com/codebase-interface/cli/refs/heads/main/cmd/schema/codebase-validation.schema.json
296+
```
297+
228298
### Default Configuration File: `.codebase-validation.yml`
229299

230300
```yaml

0 commit comments

Comments
 (0)