Skip to content

refactor: extract shared validation utilities and expand agent frontmatter support#40

Merged
marcusrbrown merged 1 commit into
mainfrom
black-tragic-catfish
Feb 1, 2026
Merged

refactor: extract shared validation utilities and expand agent frontmatter support#40
marcusrbrown merged 1 commit into
mainfrom
black-tragic-catfish

Conversation

@marcusrbrown
Copy link
Copy Markdown
Owner

  • 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).

…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).
@marcusrbrown marcusrbrown enabled auto-merge (squash) February 1, 2026 04:09
@marcusrbrown marcusrbrown self-assigned this Feb 1, 2026
@marcusrbrown marcusrbrown merged commit 0c9147d into main Feb 1, 2026
8 checks passed
@marcusrbrown marcusrbrown deleted the black-tragic-catfish branch February 1, 2026 04:10
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.

1 participant