Skip to content

feat: add Trae command adapter#1090

Open
jjxyxsjr wants to merge 2 commits into
Fission-AI:mainfrom
jjxyxsjr:add-trae-command-adapter
Open

feat: add Trae command adapter#1090
jjxyxsjr wants to merge 2 commits into
Fission-AI:mainfrom
jjxyxsjr:add-trae-command-adapter

Conversation

@jjxyxsjr
Copy link
Copy Markdown

@jjxyxsjr jjxyxsjr commented May 14, 2026

Summary

  • Adds a Trae command adapter that generates .trae/commands/opsx-<id>.md files
  • Updates documentation to reflect Trae command support
  • Adds unit tests (9 test cases) and integration tests for Trae command generation
  • Fixes YAML escaping for carriage returns (\r)

Context

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

  1. src/core/command-generation/adapters/trae.ts - New Trae command adapter
  2. src/core/command-generation/registry.ts - Register adapter in registry
  3. test/core/command-generation/adapters.test.ts - Unit tests
  4. test/core/init.test.ts - Integration tests
  5. docs/supported-tools.md - Documentation update
  6. .gitignore - Add .trae/ entry
  7. .changeset/add-trae-command-adapter.md - Changeset

Testing

  • pnpm exec tsc --noEmit - TypeScript check passes
  • pnpm run lint - Lint passes
  • pnpm run build - Build succeeds
  • ZSH="" pnpm test - All tests pass (1496/1496)
  • openspec init --tools trae - Generates commands correctly

Related

Summary by CodeRabbit

  • New Features

    • Added TRAE IDE command adapter to generate TRAE command files for custom slash commands.
  • Documentation

    • Updated supported-tools docs to reflect TRAE command adapter capabilities.
  • Tests

    • Added tests covering TRAE adapter formatting, path handling, and init behavior (creates both skill and command files when enabled).
  • Chores

    • Updated ignore rules to exclude generated TRAE files.

Review Change Stack

@jjxyxsjr jjxyxsjr requested a review from TabishB as a code owner May 14, 2026 02:50
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 14, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: aae2f3b7-5bd2-488b-9b26-2bf8f4efdc77

📥 Commits

Reviewing files that changed from the base of the PR and between 94fc05c and 1af91e1.

📒 Files selected for processing (7)
  • .changeset/add-trae-command-adapter.md
  • .gitignore
  • docs/supported-tools.md
  • src/core/command-generation/adapters/trae.ts
  • src/core/command-generation/registry.ts
  • test/core/command-generation/adapters.test.ts
  • test/core/init.test.ts
✅ Files skipped from review due to trivial changes (3)
  • .gitignore
  • .changeset/add-trae-command-adapter.md
  • docs/supported-tools.md
🚧 Files skipped from review as they are similar to previous changes (4)
  • src/core/command-generation/registry.ts
  • test/core/command-generation/adapters.test.ts
  • test/core/init.test.ts
  • src/core/command-generation/adapters/trae.ts

📝 Walkthrough

Walkthrough

Adds a TRAE tool command adapter that generates .trae/commands/opsx-<id>.md files with YAML frontmatter, registers it in the adapter registry, adds unit and integration tests, and updates docs and .gitignore for the generated Trae files.

Changes

TRAE Command Adapter Feature

Layer / File(s) Summary
TRAE Adapter Core Implementation
src/core/command-generation/adapters/trae.ts
Introduces traeAdapter and escapeYamlValue to generate .trae/commands/opsx-<id>.md paths and render markdown with YAML frontmatter (name, description) followed by the command body.
Registry Integration
src/core/command-generation/registry.ts
Imports and registers traeAdapter in CommandAdapterRegistry's static initializer to make it available as a built-in adapter.
Adapter Testing
test/core/command-generation/adapters.test.ts
Unit tests validate adapter toolId, file path generation for multiple command IDs, YAML frontmatter formatting and escaping (special chars, newlines, CRs, empty descriptions), and include traeAdapter in cross-platform path tests.
Integration Testing
test/core/init.test.ts
Integration test verifies InitCommand with delivery: 'both' and tools: 'trae' creates .trae/skills/openspec-explore/SKILL.md and .trae/commands/opsx-explore.md including YAML frontmatter markers/fields.
Documentation and Configuration
.changeset/add-trae-command-adapter.md, .gitignore, docs/supported-tools.md
Changeset documents the new TRAE command adapter; .gitignore adds .trae/; docs/supported-tools.md updates Trae entry to show generated command path pattern .trae/commands/opsx-<id>.md.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • TabishB

Poem

🐰 I hopped in with a YAML sigh,
Quoted names so values won't cry,
opsx files sprout where Trae can find,
Frontmatter neat, body aligned,
Hooray — commands saved, tidy and spry!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: add Trae command adapter' directly and accurately summarizes the main change in the pull request, which adds a new Trae command adapter.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 053d8a5 and b2dfeb0.

📒 Files selected for processing (7)
  • .changeset/add-trae-command-adapter.md
  • .gitignore
  • docs/supported-tools.md
  • src/core/command-generation/adapters/trae.ts
  • src/core/command-generation/registry.ts
  • test/core/command-generation/adapters.test.ts
  • test/core/init.test.ts

Comment thread src/core/command-generation/adapters/trae.ts
jjxyxsjr and others added 2 commits May 18, 2026 08:55
- 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>
@jjxyxsjr jjxyxsjr force-pushed the add-trae-command-adapter branch from abc328d to 1af91e1 Compare May 18, 2026 00:56
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