Skip to content

Commit a177a1a

Browse files
huangguang1999rootrootCopilotCopilot
authored
feat: add Trae IDE support as a new agent (#1817)
* feat: add Trae IDE support as a new agent Add Trae (https://www.trae.ai/) as a supported AI agent in spec-kit. Trae is an IDE-based agent that uses .trae/rules/ directory for project-level rules in Markdown format. Changes across 9 files: - src/specify_cli/__init__.py: Add trae to AGENT_CONFIG (IDE-based, .trae/ folder, rules subdir, no CLI required) - src/specify_cli/extensions.py: Add trae to CommandRegistrar.AGENT_CONFIGS (.trae/rules, markdown format, .md extension) - README.md: Add Trae to supported agents table, CLI examples, and --ai option description - .github/workflows/scripts/create-release-packages.sh: Add trae to ALL_AGENTS array and build case statement - .github/workflows/scripts/create-release-packages.ps1: Add trae to AllAgents array and switch statement - .github/workflows/scripts/create-github-release.sh: Add trae template zip files to release assets - scripts/bash/update-agent-context.sh: Add TRAE_FILE, trae case in update function, and auto-detect block - scripts/powershell/update-agent-context.ps1: Add TRAE_FILE, ValidateSet entry, switch case, and auto-detect block - tests/test_agent_config_consistency.py: Add 8 consistency tests for trae following established kimi/tabnine patterns * fix: correct Generate-Commands parameter names for trae in PowerShell release script Fix incorrect parameter names in the trae case of Build-Variant: - -Format -> -Extension - -ArgsToken -> -ArgFormat - -OutDir -> -OutputDir These now match the Generate-Commands function signature and all other agent entries in the script. Co-authored-by: Copilot <copilot@github.com> * Update release packaging scripts and agent docs * Update Agent.md * Restore format * Adjust order * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Unused * fix: add TRAE_FILE to update_all_existing_agents() for auto-detect support Add missing update_if_new call for TRAE_FILE in the bash update-agent-context.sh script's update_all_existing_agents() function, matching the PowerShell implementation. This ensures running the script without arguments will correctly auto-detect and update existing Trae agent files. * Add configuration for 'trae' in agents.py * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Refactor trae configuration test for clarity * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Update update-agent-context.sh * Fix formatting in update-agent-context.sh --------- Co-authored-by: root <root@g340-cd52-700-60f9-5561-211-6c32.byted.org> Co-authored-by: root <root@g340-cd52-700-c3d1-c735-796-4b9e.byted.org> Co-authored-by: Copilot <copilot@github.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent c12b8c1 commit a177a1a

File tree

10 files changed

+119
-10
lines changed

10 files changed

+119
-10
lines changed

.github/workflows/scripts/create-github-release.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ gh release create "$VERSION" \
5858
.genreleases/spec-kit-template-vibe-ps-"$VERSION".zip \
5959
.genreleases/spec-kit-template-kimi-sh-"$VERSION".zip \
6060
.genreleases/spec-kit-template-kimi-ps-"$VERSION".zip \
61+
.genreleases/spec-kit-template-trae-sh-"$VERSION".zip \
62+
.genreleases/spec-kit-template-trae-ps-"$VERSION".zip \
6163
.genreleases/spec-kit-template-generic-sh-"$VERSION".zip \
6264
.genreleases/spec-kit-template-generic-ps-"$VERSION".zip \
6365
--title "Spec Kit Templates - $VERSION_NO_V" \

.github/workflows/scripts/create-release-packages.ps1

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
1515
.PARAMETER Agents
1616
Comma or space separated subset of agents to build (default: all)
17-
Valid agents: claude, gemini, copilot, cursor-agent, qwen, opencode, windsurf, codex, kilocode, auggie, roo, codebuddy, amp, kiro-cli, bob, qodercli, shai, tabnine, agy, vibe, kimi, generic
17+
Valid agents: claude, gemini, copilot, cursor-agent, qwen, opencode, windsurf, codex, kilocode, auggie, roo, codebuddy, amp, kiro-cli, bob, qodercli, shai, tabnine, agy, vibe, kimi, trae, generic
1818
1919
.PARAMETER Scripts
2020
Comma or space separated subset of script types to build (default: both)
@@ -454,6 +454,11 @@ function Build-Variant {
454454
New-Item -ItemType Directory -Force -Path $skillsDir | Out-Null
455455
New-KimiSkills -SkillsDir $skillsDir -ScriptVariant $Script
456456
}
457+
'trae' {
458+
$rulesDir = Join-Path $baseDir ".trae/rules"
459+
New-Item -ItemType Directory -Force -Path $rulesDir | Out-Null
460+
Generate-Commands -Agent 'trae' -Extension 'md' -ArgFormat '$ARGUMENTS' -OutputDir $rulesDir -ScriptVariant $Script
461+
}
457462
'generic' {
458463
$cmdDir = Join-Path $baseDir ".speckit/commands"
459464
Generate-Commands -Agent 'generic' -Extension 'md' -ArgFormat '$ARGUMENTS' -OutputDir $cmdDir -ScriptVariant $Script
@@ -470,7 +475,7 @@ function Build-Variant {
470475
}
471476

472477
# Define all agents and scripts
473-
$AllAgents = @('claude', 'gemini', 'copilot', 'cursor-agent', 'qwen', 'opencode', 'windsurf', 'codex', 'kilocode', 'auggie', 'roo', 'codebuddy', 'amp', 'kiro-cli', 'bob', 'qodercli', 'shai', 'tabnine', 'agy', 'vibe', 'kimi', 'generic')
478+
$AllAgents = @('claude', 'gemini', 'copilot', 'cursor-agent', 'qwen', 'opencode', 'windsurf', 'codex', 'kilocode', 'auggie', 'roo', 'codebuddy', 'amp', 'kiro-cli', 'bob', 'qodercli', 'shai', 'tabnine', 'agy', 'vibe', 'kimi', 'trae', 'generic')
474479
$AllScripts = @('sh', 'ps')
475480

476481
function Normalize-List {

.github/workflows/scripts/create-release-packages.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ set -euo pipefail
66
# Usage: .github/workflows/scripts/create-release-packages.sh <version>
77
# Version argument should include leading 'v'.
88
# Optionally set AGENTS and/or SCRIPTS env vars to limit what gets built.
9-
# AGENTS : space or comma separated subset of: claude gemini copilot cursor-agent qwen opencode windsurf codex kilocode auggie roo codebuddy amp shai tabnine kiro-cli agy bob vibe qodercli kimi generic (default: all)
9+
# AGENTS : space or comma separated subset of: claude gemini copilot cursor-agent qwen opencode windsurf codex kilocode auggie roo codebuddy amp shai tabnine kiro-cli agy bob vibe qodercli kimi trae generic (default: all)
1010
# SCRIPTS : space or comma separated subset of: sh ps (default: both)
1111
# Examples:
1212
# AGENTS=claude SCRIPTS=sh $0 v0.2.0
@@ -291,6 +291,9 @@ build_variant() {
291291
kimi)
292292
mkdir -p "$base_dir/.kimi/skills"
293293
create_kimi_skills "$base_dir/.kimi/skills" "$script" ;;
294+
trae)
295+
mkdir -p "$base_dir/.trae/rules"
296+
generate_commands trae md "\$ARGUMENTS" "$base_dir/.trae/rules" "$script" ;;
294297
generic)
295298
mkdir -p "$base_dir/.speckit/commands"
296299
generate_commands generic md "\$ARGUMENTS" "$base_dir/.speckit/commands" "$script" ;;
@@ -300,7 +303,7 @@ build_variant() {
300303
}
301304

302305
# Determine agent list
303-
ALL_AGENTS=(claude gemini copilot cursor-agent qwen opencode windsurf codex kilocode auggie roo codebuddy amp shai tabnine kiro-cli agy bob vibe qodercli kimi generic)
306+
ALL_AGENTS=(claude gemini copilot cursor-agent qwen opencode windsurf codex kilocode auggie roo codebuddy amp shai tabnine kiro-cli agy bob vibe qodercli kimi trae generic)
304307
ALL_SCRIPTS=(sh ps)
305308

306309
norm_list() {

AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ Specify supports multiple AI agents by generating agent-specific command files a
4646
| **Tabnine CLI** | `.tabnine/agent/commands/` | TOML | `tabnine` | Tabnine CLI |
4747
| **Kimi Code** | `.kimi/skills/` | Markdown | `kimi` | Kimi Code CLI (Moonshot AI) |
4848
| **IBM Bob** | `.bob/commands/` | Markdown | N/A (IDE-based) | IBM Bob IDE |
49+
| **Trae** | `.trae/rules/` | Markdown | N/A (IDE-based) | Trae IDE |
4950
| **Generic** | User-specified via `--ai-commands-dir` | Markdown | N/A | Bring your own agent |
5051

5152
### Step-by-Step Integration Guide

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ See Spec-Driven Development in action across different scenarios with these comm
186186
| [Kimi Code](https://code.kimi.com/) || |
187187
| [Windsurf](https://windsurf.com/) || |
188188
| [Antigravity (agy)](https://antigravity.google/) || Requires `--ai-skills` |
189+
| [Trae](https://www.trae.ai/) || |
189190
| Generic || Bring your own agent — use `--ai generic --ai-commands-dir <path>` for unsupported agents |
190191

191192
## 🔧 Specify CLI Reference

scripts/bash/update-agent-context.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
# - Creates default Claude file if no agent files exist
3636
#
3737
# Usage: ./update-agent-context.sh [agent_type]
38-
# Agent types: claude|gemini|copilot|cursor-agent|qwen|opencode|codex|windsurf|kilocode|auggie|roo|codebuddy|amp|shai|tabnine|kiro-cli|agy|bob|vibe|qodercli|kimi|generic
38+
# Agent types: claude|gemini|copilot|cursor-agent|qwen|opencode|codex|windsurf|kilocode|auggie|roo|codebuddy|amp|shai|tabnine|kiro-cli|agy|bob|vibe|qodercli|kimi|trae|generic
3939
# Leave empty to update all existing agent files
4040

4141
set -e
@@ -83,6 +83,7 @@ AGY_FILE="$REPO_ROOT/.agent/rules/specify-rules.md"
8383
BOB_FILE="$AGENTS_FILE"
8484
VIBE_FILE="$REPO_ROOT/.vibe/agents/specify-agents.md"
8585
KIMI_FILE="$REPO_ROOT/KIMI.md"
86+
TRAE_FILE="$REPO_ROOT/.trae/rules/AGENTS.md"
8687

8788
# Template file
8889
TEMPLATE_FILE="$REPO_ROOT/.specify/templates/agent-file-template.md"
@@ -675,12 +676,15 @@ update_specific_agent() {
675676
kimi)
676677
update_agent_file "$KIMI_FILE" "Kimi Code" || return 1
677678
;;
679+
trae)
680+
update_agent_file "$TRAE_FILE" "Trae" || return 1
681+
;;
678682
generic)
679683
log_info "Generic agent: no predefined context file. Use the agent-specific update script for your agent."
680684
;;
681685
*)
682686
log_error "Unknown agent type '$agent_type'"
683-
log_error "Expected: claude|gemini|copilot|cursor-agent|qwen|opencode|codex|windsurf|kilocode|auggie|roo|codebuddy|amp|shai|tabnine|kiro-cli|agy|bob|vibe|qodercli|kimi|generic"
687+
log_error "Expected: claude|gemini|copilot|cursor-agent|qwen|opencode|codex|windsurf|kilocode|auggie|roo|codebuddy|amp|shai|tabnine|kiro-cli|agy|bob|vibe|qodercli|kimi|trae|generic"
684688
exit 1
685689
;;
686690
esac
@@ -739,6 +743,7 @@ update_all_existing_agents() {
739743
_update_if_new "$AGY_FILE" "Antigravity" || _all_ok=false
740744
_update_if_new "$VIBE_FILE" "Mistral Vibe" || _all_ok=false
741745
_update_if_new "$KIMI_FILE" "Kimi Code" || _all_ok=false
746+
_update_if_new "$TRAE_FILE" "Trae" || _all_ok=false
742747

743748
# If no agent files exist, create a default Claude file
744749
if [[ "$_found_agent" == false ]]; then
@@ -765,7 +770,7 @@ print_summary() {
765770
fi
766771

767772
echo
768-
log_info "Usage: $0 [claude|gemini|copilot|cursor-agent|qwen|opencode|codex|windsurf|kilocode|auggie|roo|codebuddy|amp|shai|tabnine|kiro-cli|agy|bob|vibe|qodercli|kimi|generic]"
773+
log_info "Usage: $0 [claude|gemini|copilot|cursor-agent|qwen|opencode|codex|windsurf|kilocode|auggie|roo|codebuddy|amp|shai|tabnine|kiro-cli|agy|bob|vibe|qodercli|kimi|trae|generic]"
769774
}
770775

771776
#==============================================================================

scripts/powershell/update-agent-context.ps1

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Mirrors the behavior of scripts/bash/update-agent-context.sh:
99
2. Plan Data Extraction
1010
3. Agent File Management (create from template or update existing)
1111
4. Content Generation (technology stack, recent changes, timestamp)
12-
5. Multi-Agent Support (claude, gemini, copilot, cursor-agent, qwen, opencode, codex, windsurf, kilocode, auggie, roo, codebuddy, amp, shai, tabnine, kiro-cli, agy, bob, vibe, qodercli, kimi, generic)
12+
5. Multi-Agent Support (claude, gemini, copilot, cursor-agent, qwen, opencode, codex, windsurf, kilocode, auggie, roo, codebuddy, amp, shai, tabnine, kiro-cli, agy, bob, vibe, qodercli, kimi, trae, generic)
1313
1414
.PARAMETER AgentType
1515
Optional agent key to update a single agent. If omitted, updates all existing agent files (creating a default Claude file if none exist).
@@ -25,7 +25,7 @@ Relies on common helper functions in common.ps1
2525
#>
2626
param(
2727
[Parameter(Position=0)]
28-
[ValidateSet('claude','gemini','copilot','cursor-agent','qwen','opencode','codex','windsurf','kilocode','auggie','roo','codebuddy','amp','shai','tabnine','kiro-cli','agy','bob','qodercli','vibe','kimi','generic')]
28+
[ValidateSet('claude','gemini','copilot','cursor-agent','qwen','opencode','codex','windsurf','kilocode','auggie','roo','codebuddy','amp','shai','tabnine','kiro-cli','agy','bob','qodercli','vibe','kimi','trae','generic')]
2929
[string]$AgentType
3030
)
3131

@@ -64,6 +64,7 @@ $AGY_FILE = Join-Path $REPO_ROOT '.agent/rules/specify-rules.md'
6464
$BOB_FILE = Join-Path $REPO_ROOT 'AGENTS.md'
6565
$VIBE_FILE = Join-Path $REPO_ROOT '.vibe/agents/specify-agents.md'
6666
$KIMI_FILE = Join-Path $REPO_ROOT 'KIMI.md'
67+
$TRAE_FILE = Join-Path $REPO_ROOT '.trae/rules/AGENTS.md'
6768

6869
$TEMPLATE_FILE = Join-Path $REPO_ROOT '.specify/templates/agent-file-template.md'
6970

@@ -408,8 +409,9 @@ function Update-SpecificAgent {
408409
'bob' { Update-AgentFile -TargetFile $BOB_FILE -AgentName 'IBM Bob' }
409410
'vibe' { Update-AgentFile -TargetFile $VIBE_FILE -AgentName 'Mistral Vibe' }
410411
'kimi' { Update-AgentFile -TargetFile $KIMI_FILE -AgentName 'Kimi Code' }
412+
'trae' { Update-AgentFile -TargetFile $TRAE_FILE -AgentName 'Trae' }
411413
'generic' { Write-Info 'Generic agent: no predefined context file. Use the agent-specific update script for your agent.' }
412-
default { Write-Err "Unknown agent type '$Type'"; Write-Err 'Expected: claude|gemini|copilot|cursor-agent|qwen|opencode|codex|windsurf|kilocode|auggie|roo|codebuddy|amp|shai|tabnine|kiro-cli|agy|bob|vibe|qodercli|kimi|generic'; return $false }
414+
default { Write-Err "Unknown agent type '$Type'"; Write-Err 'Expected: claude|gemini|copilot|cursor-agent|qwen|opencode|codex|windsurf|kilocode|auggie|roo|codebuddy|amp|shai|tabnine|kiro-cli|agy|bob|vibe|qodercli|kimi|trae|generic'; return $false }
413415
}
414416
}
415417

@@ -435,6 +437,7 @@ function Update-AllExistingAgents {
435437
if (Test-Path $BOB_FILE) { if (-not (Update-AgentFile -TargetFile $BOB_FILE -AgentName 'IBM Bob')) { $ok = $false }; $found = $true }
436438
if (Test-Path $VIBE_FILE) { if (-not (Update-AgentFile -TargetFile $VIBE_FILE -AgentName 'Mistral Vibe')) { $ok = $false }; $found = $true }
437439
if (Test-Path $KIMI_FILE) { if (-not (Update-AgentFile -TargetFile $KIMI_FILE -AgentName 'Kimi Code')) { $ok = $false }; $found = $true }
440+
if (Test-Path $TRAE_FILE) { if (-not (Update-AgentFile -TargetFile $TRAE_FILE -AgentName 'Trae')) { $ok = $false }; $found = $true }
438441
if (-not $found) {
439442
Write-Info 'No existing agent files found, creating default Claude file...'
440443
if (-not (Update-AgentFile -TargetFile $CLAUDE_FILE -AgentName 'Claude Code')) { $ok = $false }

src/specify_cli/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,13 @@ def _format_rate_limit_error(status_code: int, headers: httpx.Headers, url: str)
275275
"install_url": "https://code.kimi.com/",
276276
"requires_cli": True,
277277
},
278+
"trae": {
279+
"name": "Trae",
280+
"folder": ".trae/",
281+
"commands_subdir": "rules", # Trae uses .trae/rules/ for project rules
282+
"install_url": None, # IDE-based
283+
"requires_cli": False,
284+
},
278285
"generic": {
279286
"name": "Generic (bring your own agent)",
280287
"folder": None, # Set dynamically via --ai-commands-dir

src/specify_cli/agents.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,12 @@ class CommandRegistrar:
135135
"format": "markdown",
136136
"args": "$ARGUMENTS",
137137
"extension": "/SKILL.md"
138+
},
139+
"trae": {
140+
"dir": ".trae/rules",
141+
"format": "markdown",
142+
"args": "$ARGUMENTS",
143+
"extension": ".md"
138144
}
139145
}
140146

tests/test_agent_config_consistency.py

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,3 +233,79 @@ def test_kimi_in_github_release_output(self):
233233
def test_ai_help_includes_kimi(self):
234234
"""CLI help text for --ai should include kimi."""
235235
assert "kimi" in AI_ASSISTANT_HELP
236+
237+
# --- Trae IDE consistency checks ---
238+
239+
def test_trae_in_agent_config(self):
240+
"""AGENT_CONFIG should include trae with correct folder and commands_subdir."""
241+
assert "trae" in AGENT_CONFIG
242+
assert AGENT_CONFIG["trae"]["folder"] == ".trae/"
243+
assert AGENT_CONFIG["trae"]["commands_subdir"] == "rules"
244+
assert AGENT_CONFIG["trae"]["requires_cli"] is False
245+
assert AGENT_CONFIG["trae"]["install_url"] is None
246+
247+
def test_trae_in_extension_registrar(self):
248+
"""Extension command registrar should include trae using .trae/rules and markdown, if present."""
249+
cfg = CommandRegistrar.AGENT_CONFIGS
250+
251+
assert "trae" in cfg
252+
trae_cfg = cfg["trae"]
253+
assert trae_cfg["format"] == "markdown"
254+
assert trae_cfg["args"] == "$ARGUMENTS"
255+
assert trae_cfg["extension"] == ".md"
256+
257+
def test_trae_in_release_agent_lists(self):
258+
"""Bash and PowerShell release scripts should include trae in agent lists."""
259+
sh_text = (REPO_ROOT / ".github" / "workflows" / "scripts" / "create-release-packages.sh").read_text(encoding="utf-8")
260+
ps_text = (REPO_ROOT / ".github" / "workflows" / "scripts" / "create-release-packages.ps1").read_text(encoding="utf-8")
261+
262+
sh_match = re.search(r"ALL_AGENTS=\(([^)]*)\)", sh_text)
263+
assert sh_match is not None
264+
sh_agents = sh_match.group(1).split()
265+
266+
ps_match = re.search(r"\$AllAgents = @\(([^)]*)\)", ps_text)
267+
assert ps_match is not None
268+
ps_agents = re.findall(r"'([^']+)'", ps_match.group(1))
269+
270+
assert "trae" in sh_agents
271+
assert "trae" in ps_agents
272+
273+
def test_trae_in_release_scripts_generate_commands(self):
274+
"""Release scripts should generate markdown commands for trae in .trae/rules."""
275+
sh_text = (REPO_ROOT / ".github" / "workflows" / "scripts" / "create-release-packages.sh").read_text(encoding="utf-8")
276+
ps_text = (REPO_ROOT / ".github" / "workflows" / "scripts" / "create-release-packages.ps1").read_text(encoding="utf-8")
277+
278+
assert ".trae/rules" in sh_text
279+
assert ".trae/rules" in ps_text
280+
assert re.search(r"'trae'\s*\{.*?\.trae/rules", ps_text, re.S) is not None
281+
282+
def test_trae_in_github_release_output(self):
283+
"""GitHub release script should include trae template packages."""
284+
gh_release_text = (REPO_ROOT / ".github" / "workflows" / "scripts" / "create-github-release.sh").read_text(encoding="utf-8")
285+
286+
assert "spec-kit-template-trae-sh-" in gh_release_text
287+
assert "spec-kit-template-trae-ps-" in gh_release_text
288+
289+
def test_trae_in_agent_context_scripts(self):
290+
"""Agent context scripts should support trae agent type."""
291+
bash_text = (REPO_ROOT / "scripts" / "bash" / "update-agent-context.sh").read_text(encoding="utf-8")
292+
pwsh_text = (REPO_ROOT / "scripts" / "powershell" / "update-agent-context.ps1").read_text(encoding="utf-8")
293+
294+
assert "trae" in bash_text
295+
assert "TRAE_FILE" in bash_text
296+
assert "trae" in pwsh_text
297+
assert "TRAE_FILE" in pwsh_text
298+
299+
def test_trae_in_powershell_validate_set(self):
300+
"""PowerShell update-agent-context script should include 'trae' in ValidateSet."""
301+
ps_text = (REPO_ROOT / "scripts" / "powershell" / "update-agent-context.ps1").read_text(encoding="utf-8")
302+
303+
validate_set_match = re.search(r"\[ValidateSet\(([^)]*)\)\]", ps_text)
304+
assert validate_set_match is not None
305+
validate_set_values = re.findall(r"'([^']+)'", validate_set_match.group(1))
306+
307+
assert "trae" in validate_set_values
308+
309+
def test_ai_help_includes_trae(self):
310+
"""CLI help text for --ai should include trae."""
311+
assert "trae" in AI_ASSISTANT_HELP

0 commit comments

Comments
 (0)