mirror of
https://github.com/stablyai/orca.git
synced 2026-10-21 00:03:46 +00:00
feat: add Trae CLI as a supported TUI agent (#10763)
* feat: [AI-GEN] add Trae CLI as a supported TUI agent Closes #10579. Wire trae-cli into the desktop and mobile agent catalogs following the same integration pattern as other CLI agents (e.g. Ante, Devin): - src/shared/types.ts, tui-agent-config.ts: register 'trae' with detectCmdAliases (traecli/trae-agent) and argv prompt injection, matching trae-cli's `trae-cli [prompt]` contract. The CLI's own third documented alias `ta` is intentionally excluded — too generic a 2-letter name to use as a PATH-existence detection signal without false-positiving on unrelated tools. - src/shared/trae-headless-command.ts: recognize `--print`/`-p` and `--output-format json|stream-json` as one-shot headless invocations (same shape as claude-headless-command.ts) so they aren't mistaken for a live interactive session. - agent-kind.ts, telemetry-events.ts, agent-status-types.ts, agent-type-label.ts, tui-agent-display-names.ts, tui-agent-permissions.ts (YOLO via trae-cli's own --yolo flag), tui-agent-selection.ts: standard per-agent registrations. - agent-catalog.tsx, agent-favicon-assets.ts, mobile/src/tasks/mobile-tui-agents.ts, mobile/src/components/mobile-agent-icon-assets.ts: catalog entries and bundled favicon (fetched from docs.trae.cn, required by mobile's offline-icon invariant test). - i18n: add the "Trae" label to all five locale catalogs (en/es/ja/ko/zh). - Tests: agent-process-recognition, agent-status, tui-agent-startup. Verified with `pnpm typecheck` (desktop + mobile), the relevant vitest suites (869 tests across 12 files, all green), oxlint (clean), and a real end-to-end launch of the actual trae-cli binary through Orca's pty.spawn IPC path (confirmed via the OS process table). * fix: [AI-GEN] point Trae catalog entry at the real CLI quick-start doc docs.trae.cn/cli (what the installed CLI's own --help text prints as its "User manual" link) soft-404s — the docs site restructured and the working page is docs.trae.cn/cli_get-started-with-trae-cli (confirmed by HTTP fetch: real page title "TRAE CLI 快速开始" vs the old path's "404 - 页面不存在"). Addresses CodeRabbit's homepageUrl review comment. * fix: [AI-GEN] detect Trae on traecli, not the ambiguous trae-cli name Per @AmethystLiang's review: the open-source bytedance/trae-agent project (MIT, ~12k stars) registers its own console script as `trae-cli` (pyproject.toml: `trae-cli = "trae_agent.cli:main"`), an entirely unrelated CLI with a different contract (`trae-cli run "task"`, `-p` short for `--provider`). Detecting on bare `trae-cli` would false-positive on that project's installs and break launch for anyone who has it instead of the actual TRAE CN CLI. - tui-agent-config.ts: detectCmd/launchCmd/expectedProcess -> `traecli` (TRAE CN's own installer symlinks this alias too, but the other project does not ship it). Dropped the `trae-agent` alias entirely — it's the colliding project's literal repo name, the highest false-positive string available. - agent-catalog.tsx: cmd -> `traecli` to match; faviconDomain -> `www.trae.cn` (bare `trae.cn` 404s on Google's favicon service; `www.trae.cn` is the product-root domain that actually resolves). - mobile-tui-agents.ts: faviconDomain -> `www.trae.cn` to match. - Tests updated: agent-process-recognition now asserts `trae-cli` and `trae-agent` are NOT recognized as Trae (regression guard against reintroducing the collision); tui-agent-startup updated for the new launch command. promptInjectionMode stays `argv` and the headless-command file stays as-is — both verified against the real TRAE CN CLI's actual --help output (pasted in the PR review thread), not assumptions. * refactor: [AI-GEN] share one print-mode headless matcher across agents trae-headless-command.ts was a rename-only fork of claude-headless-command.ts, and ante-headless-command.ts carried a third copy of optionName. Collapse both print-mode files into print-mode-headless-command.ts, dispatch from a Partial<Record<TuiAgent, ...>> table instead of an if-chain, and compress the Trae comments to the repo's one-line style. * fix: [AI-GEN] terminate Trae flag parsing before the positional prompt `traecli` is a Cobra CLI with subcommands, so an argv prompt starting with `help`, `config`, `-…` was dispatched as a subcommand or flag instead of being run as the task. Add `argvPromptSeparator: '--'` (same reason Grok has it), and stop the shared print-mode headless matcher at `--` so a prompt that reads like `--print` no longer drops the pane out of agent recognition. * docs: [AI-GEN] name both Trae CLIs explicitly in the detect-name comment Co-authored-by: Orca <help@stably.ai> * docs: [AI-GEN] drop the vendor tag from the Trae union comment Co-authored-by: Orca <help@stably.ai> * fix: [AI-GEN] guard the nullable startup plan in the Trae separator test Co-authored-by: Orca <help@stably.ai> --------- Co-authored-by: 陈泽榜 <chenzebang@jianzhikeji.com> Co-authored-by: Jinjing <6427696+AmethystLiang@users.noreply.github.com> Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
co-authored by
Orca
陈泽榜
Jinjing
parent
1bd80931bd
commit
2d23217166
@@ -356,6 +356,7 @@
|
||||
"0708ed89f1": "Claude",
|
||||
"fc80296033": "Devin",
|
||||
"da41abbdd4": "Ante",
|
||||
"060d152fb5": "Trae",
|
||||
"mimo_code_label": "MiMo Code"
|
||||
},
|
||||
"skill": {
|
||||
|
||||
@@ -333,6 +333,7 @@
|
||||
"0708ed89f1": "Claude",
|
||||
"fc80296033": "Devin",
|
||||
"da41abbdd4": "Ante",
|
||||
"060d152fb5": "Trae",
|
||||
"mimo_code_label": "MiMo Code"
|
||||
},
|
||||
"skill": {
|
||||
|
||||
@@ -333,6 +333,7 @@
|
||||
"0708ed89f1": "Claude",
|
||||
"fc80296033": "Devin",
|
||||
"da41abbdd4": "Ante",
|
||||
"060d152fb5": "Trae",
|
||||
"mimo_code_label": "MiMo Code"
|
||||
},
|
||||
"skill": {
|
||||
|
||||
@@ -333,6 +333,7 @@
|
||||
"0708ed89f1": "Claude",
|
||||
"fc80296033": "Devin",
|
||||
"da41abbdd4": "Ante",
|
||||
"060d152fb5": "Trae",
|
||||
"mimo_code_label": "MiMo Code"
|
||||
},
|
||||
"skill": {
|
||||
|
||||
@@ -333,6 +333,7 @@
|
||||
"0708ed89f1": "Claude",
|
||||
"fc80296033": "Devin",
|
||||
"da41abbdd4": "Ante",
|
||||
"060d152fb5": "Trae",
|
||||
"mimo_code_label": "MiMo Code"
|
||||
},
|
||||
"skill": {
|
||||
|
||||
@@ -104,6 +104,15 @@ export const getAgentCatalog = createLocalizedCatalog((): AgentCatalogEntry[] =>
|
||||
faviconDomain: 'antigma.ai',
|
||||
homepageUrl: 'https://github.com/AntigmaLabs/ante-preview'
|
||||
},
|
||||
{
|
||||
id: 'trae',
|
||||
label: translate('auto.lib.agent.catalog.060d152fb5', 'Trae'),
|
||||
// Why: matches TUI_AGENT_CONFIG.trae.detectCmd, not the ambiguous `trae-cli` — see the Why there.
|
||||
cmd: 'traecli',
|
||||
// Why: bare `trae.cn` 404s on Google's favicon service.
|
||||
faviconDomain: 'www.trae.cn',
|
||||
homepageUrl: 'https://docs.trae.cn/cli_get-started-with-trae-cli'
|
||||
},
|
||||
{
|
||||
id: 'pi',
|
||||
label: translate('auto.lib.agent.catalog.302934c5d9', 'Pi'),
|
||||
|
||||
@@ -2,6 +2,7 @@ import type { TuiAgent } from '../../../shared/types'
|
||||
import grokUrl from '../../../shared/agent-icons/grok.png?url'
|
||||
import mimoCodeUrl from '../../../shared/agent-icons/mimo-code.png?url'
|
||||
import anteUrl from '../../../shared/agent-icons/ante.png?url'
|
||||
import traeUrl from '../../../shared/agent-icons/trae.png?url'
|
||||
import geminiUrl from '../../../shared/agent-icons/gemini.png?url'
|
||||
import antigravityUrl from '../../../shared/agent-icons/antigravity.png?url'
|
||||
import gooseUrl from '../../../shared/agent-icons/goose.png?url'
|
||||
@@ -34,6 +35,7 @@ export const AGENT_FAVICON_ASSETS: Partial<Record<TuiAgent, string>> = {
|
||||
grok: grokUrl,
|
||||
'mimo-code': mimoCodeUrl,
|
||||
ante: anteUrl,
|
||||
trae: traeUrl,
|
||||
gemini: geminiUrl,
|
||||
antigravity: antigravityUrl,
|
||||
goose: gooseUrl,
|
||||
|
||||
@@ -860,6 +860,10 @@ describe('formatAgentTypeLabel', () => {
|
||||
expect(formatAgentTypeLabel('ante')).toBe('Ante')
|
||||
})
|
||||
|
||||
it("maps 'trae' to 'Trae'", () => {
|
||||
expect(formatAgentTypeLabel('trae')).toBe('Trae')
|
||||
})
|
||||
|
||||
it('passes through arbitrary custom agent names as-is', () => {
|
||||
expect(formatAgentTypeLabel('weirdo')).toBe('weirdo')
|
||||
})
|
||||
@@ -884,6 +888,7 @@ describe('agentTypeToIconAgent', () => {
|
||||
expect(agentTypeToIconAgent('antigravity')).toBe('antigravity')
|
||||
expect(agentTypeToIconAgent('command-code')).toBe('command-code')
|
||||
expect(agentTypeToIconAgent('ante')).toBe('ante')
|
||||
expect(agentTypeToIconAgent('trae')).toBe('trae')
|
||||
})
|
||||
|
||||
it('returns null for arbitrary non-iconable strings', () => {
|
||||
|
||||
@@ -129,7 +129,8 @@ const ICONABLE_AGENT_TYPES: Record<TuiAgent, true> = {
|
||||
copilot: true,
|
||||
grok: true,
|
||||
devin: true,
|
||||
ante: true
|
||||
ante: true,
|
||||
trae: true
|
||||
}
|
||||
|
||||
// Why: return null (not a 'claude' fallback) for unknown so Codex panes don't flash the Claude icon before the hook fires.
|
||||
|
||||
@@ -115,6 +115,35 @@ describe('buildAgentStartupPlan', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('passes the prompt to Trae as a positional argv behind a `--` separator', () => {
|
||||
expect(
|
||||
buildAgentStartupPlan({
|
||||
agent: 'trae',
|
||||
prompt: 'Summarize the failing tests',
|
||||
cmdOverrides: {},
|
||||
platform: 'linux'
|
||||
})
|
||||
).toEqual({
|
||||
agent: 'trae',
|
||||
launchCommand: "traecli -- 'Summarize the failing tests'",
|
||||
expectedProcess: 'traecli',
|
||||
followupPrompt: null,
|
||||
launchConfig: emptyLaunchConfig('traecli')
|
||||
})
|
||||
})
|
||||
|
||||
// Why: without the separator these dispatch to Trae's `help`/`config` subcommands instead.
|
||||
it('keeps subcommand-shaped Trae prompts as the positional prompt', () => {
|
||||
expect(
|
||||
buildAgentStartupPlan({
|
||||
agent: 'trae',
|
||||
prompt: 'help me name this config',
|
||||
cmdOverrides: {},
|
||||
platform: 'linux'
|
||||
})?.launchCommand
|
||||
).toBe("traecli -- 'help me name this config'")
|
||||
})
|
||||
|
||||
it('uses cursor-agent as the actual launch binary', () => {
|
||||
expect(
|
||||
buildAgentStartupPlan({
|
||||
|
||||
Reference in New Issue
Block a user