-
Notifications
You must be signed in to change notification settings - Fork 608
feat(commands): add handoffs support for speckit compatibility #410
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Upgrade frontmatter parser to use js-yaml for complex YAML support - Add HandoffDefinition interface for speckit-style workflow transitions - Update CommandFrontmatter and CommandDefinition to include handoffs - Add comprehensive tests for backward compatibility and complex YAML - Fix type parameters in auto-slash-command and slashcommand tools Closes #407
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No issues found across 7 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Greptile SummaryReplaces manual line-by-line frontmatter parser with Key Changes:
Critical Issue:
Confidence Score: 3/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant CommandLoader as Command Loader
participant Frontmatter as parseFrontmatter()
participant YAML as js-yaml
participant Command as CommandDefinition
User->>CommandLoader: Load command from .md file
CommandLoader->>Frontmatter: Parse file content
Frontmatter->>YAML: yaml.load(yamlContent)
YAML-->>Frontmatter: Parsed object with handoffs[]
Frontmatter-->>CommandLoader: {data: CommandFrontmatter, body}
CommandLoader->>CommandLoader: Extract handoffs from data
CommandLoader->>Command: Create CommandDefinition with handoffs
Command-->>User: Command ready with handoff workflows
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
7 files reviewed, 2 comments
src/shared/frontmatter.ts
Outdated
| const parsed = yaml.load(yamlContent) | ||
| const data = (parsed ?? {}) as T | ||
| return { data, body } | ||
| } catch { | ||
| return { data: {} as T, body } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: yaml.load() can execute arbitrary JavaScript code when parsing YAML with !!js/function tags by default
add { schema: yaml.SAFE_SCHEMA } option to prevent code execution:
| const parsed = yaml.load(yamlContent) | |
| const data = (parsed ?? {}) as T | |
| return { data, body } | |
| } catch { | |
| return { data: {} as T, body } | |
| const parsed = yaml.load(yamlContent, { schema: yaml.SAFE_SCHEMA }) | |
| const data = (parsed ?? {}) as T | |
| return { data, body } | |
| } catch { | |
| return { data: {} as T, body } |
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/shared/frontmatter.ts
Line: 22:26
Comment:
**logic:** `yaml.load()` can execute arbitrary JavaScript code when parsing YAML with `!!js/function` tags by default
add `{ schema: yaml.SAFE_SCHEMA }` option to prevent code execution:
```suggestion
const parsed = yaml.load(yamlContent, { schema: yaml.SAFE_SCHEMA })
const data = (parsed ?? {}) as T
return { data, body }
} catch {
return { data: {} as T, body }
```
How can I resolve this? If you propose a fix, please make it concise.| content: string | ||
| ): FrontmatterResult<T> { | ||
| const frontmatterRegex = /^---\r?\n([\s\S]*?)\r?\n---\r?\n([\s\S]*)$/ | ||
| const frontmatterRegex = /^---\r?\n([\s\S]*?)\r?\n?---\r?\n([\s\S]*)$/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: regex now allows optional newline before closing ---, which relaxes the frontmatter format validation
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/shared/frontmatter.ts
Line: 11:11
Comment:
**style:** regex now allows optional newline before closing `---`, which relaxes the frontmatter format validation
<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>
How can I resolve this? If you propose a fix, please make it concise.
|
…olerance tests - Use JSON_SCHEMA in yaml.load() to prevent code execution via YAML tags - Add tests to verify extra fields in frontmatter don't cause failures - Address Greptile security review comment
Review Feedback AddressedI've addressed the review feedback: 1. Security Fix (Greptile Review)
2. Extra Fields Tolerance (User Request)Yes, the current implementation correctly handles extra fields without failing. Added tests to confirm and document this behavior:
The implementation casts the parsed YAML to the generic type
Changes
All 430 tests pass. Build successful. |
Summary
js-yamlfor complex YAML support (speckit compatibility)HandoffDefinitioninterface for speckit-style workflow transitionsCommandFrontmatterandCommandDefinitionto include handoffsChanges
Core Changes
src/shared/frontmatter.ts: Replace manual line-by-line parsing withjs-yamlfor full YAML spec supportsrc/features/claude-code-command-loader/types.ts: AddHandoffDefinitioninterface and update command typessrc/features/claude-code-command-loader/loader.ts: Pass handoffs through to command definitionsSupporting Changes
src/hooks/auto-slash-command/executor.ts: Add explicit type parameter for frontmatter parsingsrc/tools/slashcommand/tools.ts: Add explicit type parameter for frontmatter parsingsrc/features/opencode-skill-loader/loader.test.ts: Update test for new YAML parsing behaviorTests
src/shared/frontmatter.test.ts: New comprehensive test suite covering:Handoff Format (speckit)
Commands can now use complex handoffs in frontmatter:
Closes #407
Summary by cubic
Adds speckit-style handoffs to commands by switching frontmatter parsing to full YAML with js-yaml and extending command types. Enables complex workflow definitions in command frontmatter while preserving backward compatibility, and closes #407.
Written for commit fb7230f. Summary will update on new commits.