[PR #6738] fix(config): allow extra fields in Command schema for SpecKit compatibility #12078

Closed
opened 2026-02-16 18:17:00 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/6738

State: closed
Merged: No


Summary

Adds .passthrough() to the Command Zod schema to allow external tools like SpecKit to include additional frontmatter fields without causing validation errors.

Problem

When using SpecKit with OpenCode (specify init --ai opencode), commands fail to load because SpecKit templates include additional frontmatter fields that OpenCode's schema rejects:

  • handoffs - SpecKit's workflow transition feature
  • scripts - Shell script definitions
  • agent_scripts - Agent-specific scripts

Solution

Add .passthrough() to the Command schema (line 422-428 in config/config.ts), which allows unknown fields to pass through validation without stripping them.

Before

export const Command = z.object({
  template: z.string(),
  description: z.string().optional(),
  agent: z.string().optional(),
  model: z.string().optional(),
  subtask: z.boolean().optional(),
})

After

export const Command = z
  .object({
    template: z.string(),
    description: z.string().optional(),
    agent: z.string().optional(),
    model: z.string().optional(),
    subtask: z.boolean().optional(),
  })
  .passthrough()

Benefits

  • Future-proof: New fields from SpecKit or other tools won't break OpenCode
  • Minimal change: No breaking changes to existing functionality
  • Extensibility: Enables third-party tool integration

Related

  • Stacked on top of #6724 (session directory filtering)
  • Fixes SpecKit/OpenCode compatibility issue

Testing

  1. Run specify init test-project --ai opencode
  2. Navigate to test-project/.opencode/command/
  3. Run opencode in the project
  4. SpecKit commands should load without errors
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/6738 **State:** closed **Merged:** No --- ## Summary Adds `.passthrough()` to the `Command` Zod schema to allow external tools like SpecKit to include additional frontmatter fields without causing validation errors. ## Problem When using [SpecKit](https://github.com/speckit/speckit) with OpenCode (`specify init --ai opencode`), commands fail to load because SpecKit templates include additional frontmatter fields that OpenCode's schema rejects: - `handoffs` - SpecKit's workflow transition feature - `scripts` - Shell script definitions - `agent_scripts` - Agent-specific scripts ## Solution Add `.passthrough()` to the `Command` schema (line 422-428 in `config/config.ts`), which allows unknown fields to pass through validation without stripping them. ### Before ```typescript export const Command = z.object({ template: z.string(), description: z.string().optional(), agent: z.string().optional(), model: z.string().optional(), subtask: z.boolean().optional(), }) ``` ### After ```typescript export const Command = z .object({ template: z.string(), description: z.string().optional(), agent: z.string().optional(), model: z.string().optional(), subtask: z.boolean().optional(), }) .passthrough() ``` ## Benefits - **Future-proof**: New fields from SpecKit or other tools won't break OpenCode - **Minimal change**: No breaking changes to existing functionality - **Extensibility**: Enables third-party tool integration ## Related - Stacked on top of #6724 (session directory filtering) - Fixes SpecKit/OpenCode compatibility issue ## Testing 1. Run `specify init test-project --ai opencode` 2. Navigate to `test-project/.opencode/command/` 3. Run `opencode` in the project 4. SpecKit commands should load without errors
yindo added the pull-request label 2026-02-16 18:17:00 -05:00
yindo closed this issue 2026-02-16 18:17:00 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#12078