Task Description
Implement the core bundle validation engine for the oc bundle validate command using TDD (red-to-green approach).
TDD Cycle
RED Phase - Write Failing Tests
Create comprehensive tests in internal/bundle/bundle_test.go for ValidateBundle() function:
TestValidateBundle_ValidBundle - valid bundle passes validation
TestValidateBundle_MissingManifest - missing opencode-bundle.manifest.json returns error
TestValidateBundle_InvalidJSON - malformed JSON in manifest returns error
TestValidateBundle_InvalidManifestVersion - unsupported manifest_version returns error
TestValidateBundle_MissingRequiredFields - missing bundle_name/bundle_version/presets detected
TestValidateBundle_MissingEntrypoint - preset entrypoint file does not exist
TestValidateBundle_InvalidPresetJSON - preset file exists but contains invalid JSON
TestValidateBundle_MissingPromptFile - prompt_files entry references non-existent file
GREEN Phase - Implement to Pass
Add to internal/bundle/bundle.go:
ValidationError struct (Category, Message, File fields)
ValidationResult struct (Errors []ValidationError, Valid bool, Warnings []string)
ValidateBundle(bundleRoot string) (*ValidationResult, error) function
Validation logic per REQ-F-022:
- Check manifest file exists at
opencode-bundle.manifest.json
- Validate manifest is valid JSON
- Validate against JSON schema (embedded
1.0.0.schema.json)
- For each preset: verify
entrypoint path exists
- For each preset: verify all
prompt_files paths exist
- Validate each preset JSON file is valid JSON
Acceptance Criteria
Task Description
Implement the core bundle validation engine for the
oc bundle validatecommand using TDD (red-to-green approach).TDD Cycle
RED Phase - Write Failing Tests
Create comprehensive tests in
internal/bundle/bundle_test.goforValidateBundle()function:TestValidateBundle_ValidBundle- valid bundle passes validationTestValidateBundle_MissingManifest- missingopencode-bundle.manifest.jsonreturns errorTestValidateBundle_InvalidJSON- malformed JSON in manifest returns errorTestValidateBundle_InvalidManifestVersion- unsupportedmanifest_versionreturns errorTestValidateBundle_MissingRequiredFields- missingbundle_name/bundle_version/presetsdetectedTestValidateBundle_MissingEntrypoint- presetentrypointfile does not existTestValidateBundle_InvalidPresetJSON- preset file exists but contains invalid JSONTestValidateBundle_MissingPromptFile-prompt_filesentry references non-existent fileGREEN Phase - Implement to Pass
Add to
internal/bundle/bundle.go:ValidationErrorstruct (Category, Message, File fields)ValidationResultstruct (Errors []ValidationError, Valid bool, Warnings []string)ValidateBundle(bundleRoot string) (*ValidationResult, error)functionValidation logic per REQ-F-022:
opencode-bundle.manifest.json1.0.0.schema.json)entrypointpath existsprompt_filespaths existAcceptance Criteria
internal/bundle/