feat: add Trae command adapter#1090
Conversation
|
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 (7)
✅ Files skipped from review due to trivial changes (3)
🚧 Files skipped from review as they are similar to previous changes (4)
📝 WalkthroughWalkthroughAdds a TRAE tool command adapter that generates ChangesTRAE Command Adapter Feature
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 14-27: escapeYamlValue currently returns an unquoted empty scalar
for empty strings which YAML parses as null; add an explicit check at the start
of escapeYamlValue (the function named escapeYamlValue) to return a quoted empty
string literal (e.g. "\"\"") when value === '' before running the needsQuoting
regex/escape logic so empty-string metadata is preserved as a string in YAML
frontmatter.
🪄 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: 29f17e78-a3af-4ebd-9bad-402ab2170ede
📒 Files selected for processing (7)
.changeset/add-trae-command-adapter.md.gitignoredocs/supported-tools.mdsrc/core/command-generation/adapters/trae.tssrc/core/command-generation/registry.tstest/core/command-generation/adapters.test.tstest/core/init.test.ts
- Added Trae command adapter for generating `.trae/commands/opsx-<id>.md` files - Complete unit tests (9 test cases) and integration tests - Updated documentation and .gitignore - Fixed YAML escaping for carriage returns (\r) Co-Authored-By: Claude Code <noreply@anthropic.com>
- Add explicit check for empty string in escapeYamlValue - Return quoted empty string '""' instead of unquoted empty scalar - Update test to verify empty string is properly quoted Co-Authored-By: Claude Code <noreply@anthropic.com>
abc328d to
1af91e1
Compare
alfred-openspec
left a comment
There was a problem hiding this comment.
Thanks for the cleanup here. I checked this against the current adapter pattern plus the older Trae PRs (#677/#776), and this looks like the right PR to supersede those stale/conflicting branches once the small consistency gaps below are fixed.
I ran:
pnpm vitest run test/core/command-generation/adapters.test.ts test/core/init.test.ts
pnpm exec tsc --noEmitBoth passed on the PR branch.
Two requested fixes before merge:
docs/commands.mdstill says Trae uses skill-based invocations and has no generatedopsx-*command files. Since this PR changes the actual command surface, that command-reference row should be updated too, otherwise the docs will contradictdocs/supported-tools.md.- Please export
traeAdapterfromsrc/core/command-generation/adapters/index.ts. The file is explicitly the all-adapters re-export surface, and both older Trae PRs included the export. The runtime registry works without it, but leaving Trae out makes the adapter surface inconsistent for tests/importers.
The adapter implementation itself looks narrow and sound, including the empty-string and CR escaping coverage.
Summary
.trae/commands/opsx-<id>.mdfilesContext
Trae IDE now supports custom slash commands via
.trae/commands/directory. This PR adds a command adapter to align Trae with other tools (Claude, Cursor, Windsurf) that use command adapters for the opsx workflow.The adapter generates Markdown files with YAML frontmatter (name, description) following Trae's command specification.
Changes
src/core/command-generation/adapters/trae.ts- New Trae command adaptersrc/core/command-generation/registry.ts- Register adapter in registrytest/core/command-generation/adapters.test.ts- Unit teststest/core/init.test.ts- Integration testsdocs/supported-tools.md- Documentation update.gitignore- Add .trae/ entry.changeset/add-trae-command-adapter.md- ChangesetTesting
pnpm exec tsc --noEmit- TypeScript check passespnpm run lint- Lint passespnpm run build- Build succeedsZSH="" pnpm test- All tests pass (1496/1496)openspec init --tools trae- Generates commands correctlyRelated
Summary by CodeRabbit
New Features
Documentation
Tests
Chores