feat(tokenless): add Trae (TraeCode) adapter - #2530
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4fd2c03ae7
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
|
||
| ### Added | ||
|
|
||
| - Trae (TraeCode) adapter: hook groups are merged into the edition's global `hooks.json` (`~/.trae-cn` CN edition, `~/.trae` international edition), with command rewriting on the standardized `RunCommand` tool and response compression delivered via `additionalContext` ([#2525](https://github.com/alibaba/anolisa/issues/2525)). |
There was a problem hiding this comment.
Remove feature changelog from non-release commit
For this feature commit, no version-bearing files are bumped, but this adds an Unreleased changelog entry. The documentation standard mandated by AGENTS says daily feature/fix PRs should update README/user-guide only and reserve CHANGELOG edits for release version bump PRs, so leaving this here will make the next release aggregation duplicate or predate release notes; please remove both EN/ZH changelog entries unless this commit is converted into the release bump.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Accepted. Per specs/documentation-standard.md §5 ("Daily feature/fix PRs update README and user-guide only; CHANGELOG is written exclusively in release version bump PRs") and the matching rule in CONTRIBUTING.md, the premature Unreleased entries were removed from both src/tokenless/CHANGELOG.md and src/tokenless/CHANGELOG_zh.md; the entry will be added by the release version bump PR instead. Following the repo commit discipline (no standalone fix commits for issues introduced within the same PR), the changelog changes were removed from the originating commit via rebase (the follow-up commit that only adjusted those entries was dropped). The README/user-guide documentation introduced by this PR is kept. New branch head: dee2a64.
e4080eb to
dee2a64
Compare
Trae ships a Claude Code-compatible hook system but no plugin marketplace, so the adapter merges tokenless hook groups into the edition's global hooks.json (~/.trae-cn CN edition, ~/.trae international edition): - hooks.json template with RunCommand rewrite matcher, catch-all tool-ready group, and PostToolUse compression group; install.sh stamps the absolute adapter directory because Trae has no plugin-root substitution - idempotent merge preserving user-configured hooks; uninstall.sh removes only tokenless-owned entries (TOKENLESS_AGENT_ID=trae marker) - detect.sh tri-state report, run-hook.sh shared dispatcher symlink - Makefile trae-install/trae-uninstall targets and test wiring - classify Trae's standardized RunCommand tool as layer-2 shell in tool_categories.json and the agentscope policy copy - raw packager materializes the run-hook symlink; RPM packages the adapter - bilingual docs and changelog entries Response compression is delivered via additionalContext because Trae's PostToolUse does not support tool-output replacement.
Every other adapter is documented in README.md / README_zh.md (directory tree, per-adapter strategy section, make target table, project structure table); the Trae adapter added in this branch was missing those entries. Follow-up for the Trae (TraeCode) adapter PR.
dee2a64 to
ffc5935
Compare
Resolve conflict in tokenless_agentscope/middleware.py after main refactored the AgentScope package into _v1/_v2 modules with a shared anolisa_tokenless runtime and left middleware.py as a compat shim. Keep the shim from main and port this branch's one-line change — the Trae standardized "RunCommand" shell tool — into the canonical SHELL_TOOLS frozenset in anolisa_tokenless/tool_response.py, which now backs the 1.x and 2.x integrations and the policy drift test against tool_categories.json.
Resolve additive documentation conflicts after main gained the native DeepSeek Harness (dsh) plugin while this branch adds the Trae adapter: - QUICKSTART (en/zh): keep main's dsh --profile guidance and extend the "not registered with anolisa adapter enable" note to cover both OpenCode and Trae lifecycle scripts - README.md: keep both adapters in the directory tree and keep both the Trae adapter section and the DeepSeek Harness plugin section - README_zh.md: keep both bullets in the integration list and both install sections Co-authored-by: multica-agent <github@multica.ai>
…xonomy Completing the merge with main surfaced two integrations between this branch's Trae taxonomy change (RunCommand classified as layer-2 shell in tool_categories.json) and code main gained afterwards: - dsh/dist/index.js keeps its own publishable copy of the shell-tool set; add RunCommand so tests/test-dsh-adapter.sh's parity check against tool_categories.json passes - tests/test-package-raw.sh fixture now creates the trae hooks dir and run-hook symlink and asserts the materialized hook, matching the packager's trae materialize_hook seam Co-authored-by: multica-agent <github@multica.ai>
The trae materialize_hook seam added with the Trae adapter asserts the staged file after copying, but the require_file preflight list covers the other hook-based adapters (claude-code, qwencode) and not trae. Require trae/hooks/run-hook.sh in the source tree as well so a checkout missing the dispatcher fails early with the same diagnostic as its peers.
Summary
Add a
traeadapter for Trae (ByteDance's AI IDE; TraeCode agent), closing #2525.Trae ships a Claude Code-compatible hook system but has no plugin marketplace, so the adapter merges the tokenless hook groups directly into the edition's global
hooks.json:~/.trae-cn/hooks.json~/.trae/hooks.jsonChanges
adapters/tokenless/trae/hooks/hooks.json— template with@TOKENLESS_ADAPTER_DIR@placeholder: PreToolUseRunCommand→rewrite_hook.py(Trae standardizes the terminal tool name toRunCommand), catch-all PreToolUse group →tool_ready_hook.sh, PostToolUse negative-lookahead group (skipsRead|Glob|LS) →compress_response_hook.pyhooks/run-hook.sh— symlink to the shared dispatcher (same convention as qoder/qwencode)scripts/install.sh— idempotent JSON merge into every detected Trae edition home; stamps the absolute adapter directory into hook commands (Trae has no plugin-root substitution); preserves user-configured hooks; refuses invalid JSON without clobbering; graceful no-op when Trae is absentscripts/uninstall.sh— removes only tokenless-owned entries (TOKENLESS_AGENT_ID=traemarker)scripts/detect.sh— tri-state report aligned with claude-code/qwencode conventionsmanifest.json.in—traetarget (hooks: rewrite / compress-response / compress-toon / tool-ready)trae-install/trae-uninstalltargets wired intoadapter-install/adapter-uninstall, help text, and the new installer test intest-adapterstool_categories.json— classify Trae's standardizedRunCommandas layer-2 shell (64K truncation thresholds like Bash); agentscope middleware policy copy kept in synctrae/hooks/run-hook.shsymlink (ANOLISA ignores archive symlinks)%preuncleanup hookanolisa adapter enableRust driver set is maintained outside this component), QUICKSTART table; changelog entriesResponse compression is delivered via
additionalContext: Trae's PostToolUse contract supportsdecision/reason/additionalContextonly (noupdatedToolOutput), matching the hermes/openclaw treatment. Rewriting usesupdatedInput, which Trae documents as full input replacement.测试情况 (Test report)
Environment: Linux x86_64; GNU bash 4.4.20; system Python 3.8.17 and user-local Python 3.11.14; GNU Make 4.2.1; Node v22.21.1.
Executed:
tests/test-trae-adapter-install.sh(new)tests/test-run-hook-install-scope.shtests/test-tool-ready-readable-fixer.shtests/run-all-tests.shenv-check hard bypassfailures, reproduced identically on the unmodified base treetests/test_compress_response_hook.py(py3.11)tests/test_compress_schema_hook.py(py3.11)tests/test_resolve_agent_id.py(py3.11)tests/test_agentscope_middleware.py(py3.11)tool_categories.jsontests/test-qoder-adapter-install.sh(regression)tests/test-opencode-adapter-install.sh(regression)tests/test-package-raw.shmake stamp-adapter-templates+ manifest inspectiontraetarget present with capabilities/actionsmake -n trae-install/make -n trae-uninstallbash -nsyntax check on all new scriptsPre-existing failures (verified identical on the unmodified base tree, unrelated to this change):
tests/test_rewrite_hook.py— 11 failures: a system-installedrtkinPATHshadows the sandboxed fake rtk the test stages.tests/test_hermes_plugin_import.py— 1 failure: a system-installed adapter tree under/usr/local/share/...shadows the test'sXDG_DATA_HOMEsandbox.test_agentscope_middleware.pycannot import (StrEnumneeds 3.11) and several hook tests skip — same on the base tree.Not run (with reasons):
cargo build/cargo test— no Rust code is touched by this PR.make test-adaptersfull target — itsbuild-openclaw-pluginprerequisite performs an npm dependency build not needed for this change; the individual installer tests above were run directly instead.rpmbuildoftokenless.spec.in— a full RPM build requires the complete native build chain; the spec additions mirror the existing qwencode entries line-for-line.