refactor: extract shared validation utilities and expand agent frontmatter support#40
Merged
Merged
Conversation
…atter support
- Create validation.ts module with shared type guards and utilities
- Add PermissionConfig interface and related type guards (isRecord, isPermissionSetting, isToolsMap, isAgentMode)
- Extract normalizePermission with helper functions to reduce complexity
- Support AgentMode type ('subagent' | 'primary' | 'all')
- Expand AgentFrontmatter interface with 10+ optional fields
- Add model, temperature, top_p, tools, disable, mode, color, maxSteps, permission
- Implement extraction with type-safe helper functions (extractString, extractNumber, extractBoolean)
- Add early return for parse errors
- Update agent conversion logic
- Add addOptionalFields helper to reduce complexity
- Support preserving explicit frontmatter mode over CLI options
- Extract all optional fields to OpenCode config in config-handler
- Replace stripFrontmatter with parseFrontmatter().body.trim()
- Update bootstrap.ts, config-handler.ts, skill-loader.ts
- Add JSDoc to stripFrontmatter clarifying it's a convenience wrapper
- Refactor CLI to import AgentMode from validation.ts
- Add comprehensive test coverage
- 24 tests for agent frontmatter extraction (agents.test.ts)
- 6 new tests for config handler field extraction
- 10 new tests for converter frontmatter transformation
- Tests for edge cases: mode: all, invalid values, empty permissions
All 151 tests passing. Complexity reduced below Biome limit (15).
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.
Create validation.ts module with shared type guards and utilities
Expand AgentFrontmatter interface with 10+ optional fields
Update agent conversion logic
Replace stripFrontmatter with parseFrontmatter().body.trim()
Refactor CLI to import AgentMode from validation.ts
Add comprehensive test coverage
All 151 tests passing. Complexity reduced below Biome limit (15).