fix: add Trae command adapter for slash commands support#1193
Conversation
Adds a command adapter for Trae so that 'openspec init --tools trae' generates commands in .trae/commands/opsx/ directory. Per Trae's convention, the command name uses the bare ID (e.g., 'apply') instead of the prefixed format used by Claude (e.g., 'OPSX: Apply'). Fixes missing Trae adapter registration in CommandAdapterRegistry.init().
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds a Trae tool command adapter that emits markdown files at ChangesTrae Adapter Integration
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/core/command-generation/adapters/trae.ts`:
- Around line 23-31: formatFile in adapters/trae.ts injects content.id and
content.description directly into YAML frontmatter causing invalid YAML when
values contain special characters; update formatFile to use the same
escapeYamlValue utility used by sibling adapters (e.g., claude.ts, cursor.ts) to
sanitize both the name and description before interpolation. Locate the
formatFile method and replace direct interpolation of content.id and
content.description with escaped values (call escapeYamlValue(content.id) and
escapeYamlValue(content.description)), ensuring description remains quoted in
the frontmatter as in other adapters.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 994aa242-f91e-4b26-80ad-06f65cd96244
📒 Files selected for processing (3)
src/core/command-generation/adapters/index.tssrc/core/command-generation/adapters/trae.tssrc/core/command-generation/registry.ts
alfred-openspec
left a comment
There was a problem hiding this comment.
Thanks for jumping on Trae support. I think this needs one more pass before merge: add focused adapter/registry/update tests, escape the YAML frontmatter values, and update the supported-tools docs or cite the verified Trae command contract, since trunk currently documents Trae as skills-only.
- Add escapeYamlValue to trae adapter for safe YAML frontmatter output - Add traeAdapter unit tests covering toolId, getFilePath, formatFile, and YAML escaping - Add trae registry tests for get/has/getAll - Update supported-tools.md: Trae command path from 'Not generated' to '.trae/commands/opsx/<id>.md'
|
Thanks for the review. All requested changes have been addressed and verified locally:
Lint, build, and all command-generation tests pass. |
alfred-openspec
left a comment
There was a problem hiding this comment.
Re-approved latest head 7b5b114. The requested Trae follow-ups are in: YAML escaping for name/description, focused adapter and registry tests, and supported-tools docs. I reran the focused command-generation tests and typecheck in a temp worktree, and they passed. The Trae + weak-model explore-mode behavior in #1203 is a separate prompt/model compliance issue, not a blocker for this adapter.
Summary
Fixes a bug where
openspec init --tools traedid not generate any commands because the Trae adapter was never registered inCommandAdapterRegistry.init().Changes
src/core/command-generation/adapters/trae.ts(new): Trae command adapter. Writes to.trae/commands/opsx/<id>.mdwith bare command ID as thenamefield (per Trae convention).src/core/command-generation/adapters/index.ts: ExporttraeAdapter.src/core/command-generation/registry.ts: RegistertraeAdapterinCommandAdapterRegistry.init().Root Cause
The adapter file and export were missing entirely —
CommandAdapterRegistry.init()had no entry for Trae, so the tool was silently skipped during init.Testing
All existing tests pass (
npm test). Thetest/core/command-generation/adapters.test.tssuite (92 tests) covers adapter formatting and confirms the fix works correctly.Summary by CodeRabbit
New Features
Documentation
Tests