feat: add Trae hook support - #284
Conversation
Reviewer's GuideAdds managed Trae / Trae CN hook support across install, bundle, inspect, and uninstall flows, including Trae-specific hook JSON handling and global vs project config routing, plus version bump to 0.4.0-beta.17. Sequence diagram for Trae hook installation flowsequenceDiagram
actor User
participant CometCLI
participant PlatformInstall as installCometHooksForPlatform
participant Platforms as getPlatformConfigDir
participant TraeInstall as installTraeHooks
participant Settings as readSettingsJsonObject
participant HooksMerge as mergeHookGroups
participant FS as writeFile
User ->> CometCLI: run comet init/update
CometCLI ->> PlatformInstall: installCometHooksForPlatform(baseDir, platform, scope, hooksConfig)
PlatformInstall ->> Platforms: getPlatformConfigDir(platform, scope)
Platforms -->> PlatformInstall: platformBase
alt hookFormat is trae
PlatformInstall ->> TraeInstall: installTraeHooks(baseDir, platformBase, skillsDir, hooksConfig, platform.name, context)
TraeInstall ->> Settings: readSettingsJsonObject(hooksPath, platformName)
Settings -->> TraeInstall: hooksFile
TraeInstall ->> HooksMerge: mergeHookGroups(existingPreToolUse, preToolUseEntries, managedHookScriptPaths(hooksConfig))
HooksMerge -->> TraeInstall: mergedGroups
TraeInstall ->> FS: writeFile(hooksPath, JSON.stringify(hooksFile), utf-8)
FS -->> TraeInstall: ok
TraeInstall -->> PlatformInstall: { status: installed }
else other hookFormat
PlatformInstall ->> PlatformInstall: handle other formats
end
PlatformInstall -->> CometCLI: HookInstallResult
CometCLI -->> User: report hook installation status
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThis change adds Trae and Trae CN Hook Router support. Installation, inspection, distribution, and uninstall manage grouped ChangesTrae Hook Router lifecycle
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Comet
participant TraeConfig
participant HookRouter
Comet->>TraeConfig: Read hooks.json
Comet->>TraeConfig: Merge managed PreToolUse entries
TraeConfig->>HookRouter: Execute verify.mjs command
Comet->>TraeConfig: Remove managed entries during uninstall
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1⚔️ Resolve merge conflicts 💡
🧪 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.
Hey - I've left some high level feedback:
- The new
countTraeHookMatcheslogic is very similar to the existing grouped hook counters; consider reusing or extending the existing helpers (e.g.,countGroupedHookMatches/collectGroupedCommands) to avoid format-specific duplication and keep inspection semantics consistent across platforms. - The
removeTraeHooksimplementation manually walks and filtersPreToolUsegroups instead of using the same grouping/merge utilities asinstallTraeHooks(e.g.,asHookGroup,mergeHookGroups,managedHookScriptPaths), which may make Trae behavior diverge from other formats over time; factoring out a shared helper for grouped hook removal would simplify this and align it with install behavior.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The new `countTraeHookMatches` logic is very similar to the existing grouped hook counters; consider reusing or extending the existing helpers (e.g., `countGroupedHookMatches`/`collectGroupedCommands`) to avoid format-specific duplication and keep inspection semantics consistent across platforms.
- The `removeTraeHooks` implementation manually walks and filters `PreToolUse` groups instead of using the same grouping/merge utilities as `installTraeHooks` (e.g., `asHookGroup`, `mergeHookGroups`, `managedHookScriptPaths`), which may make Trae behavior diverge from other formats over time; factoring out a shared helper for grouped hook removal would simplify this and align it with install behavior.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
b695bbd to
c6f1354
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
|
Some modifications are required for the router hooking mechanism currently used by Comet:
|
c6f1354 to
4694a72
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
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 `@test/domains/skill/skills.test.ts`:
- Around line 1584-1612: Add parallel Trae CN removal coverage alongside the
existing Trae removal tests, using installCometHooksForPlatform with the trae-cn
platform. Verify project uninstallation removes .trae/hooks.json and global
uninstallation removes .trae-cn/hooks.json, while exercising removal through the
packaged router runtime.
🪄 Autofix
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: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: fa666ed3-6635-4157-b4a9-26630b9edcbf
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (21)
CHANGELOG.mdassets/manifest.jsonassets/skills/comet/scripts/comet-hook-router.mjsdomains/bundle/bundle-platform.tsdomains/bundle/types.tsdomains/comet-entry/hook-adapter.tsdomains/skill/platform-inspect.tsdomains/skill/platform-install.tsdomains/skill/uninstall.tspackage.jsonplatform/install/platforms.tstest/app/cli-help.test.tstest/domains/bundle/bundle-distribute.test.tstest/domains/bundle/bundle-platform.test.tstest/domains/comet-entry/hook-adapter.test.tstest/domains/comet-entry/hook-router-runtime.test.tstest/domains/skill/platform-inspect.test.tstest/domains/skill/skills.test.tstest/domains/skill/uninstall.test.tstest/platform/detect.test.tstest/repository/release-metadata.test.ts
🚧 Files skipped from review as they are similar to previous changes (13)
- package.json
- domains/skill/platform-inspect.ts
- domains/bundle/types.ts
- test/repository/release-metadata.test.ts
- assets/manifest.json
- test/domains/bundle/bundle-platform.test.ts
- test/platform/detect.test.ts
- CHANGELOG.md
- domains/bundle/bundle-platform.ts
- test/domains/skill/platform-inspect.test.ts
- platform/install/platforms.ts
- domains/skill/uninstall.ts
- domains/skill/platform-install.ts
4694a72 to
c9a462b
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
test/domains/skill/uninstall.test.ts (1)
57-57: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd equivalent Trae CN uninstall coverage.
All new Trae cases exercise only
trae. The PR also supportstrae-cn. An incorrect Trae CN hook path or removal contract can pass this suite.
test/domains/skill/uninstall.test.ts#L57-L57: add atrae-cnmalformed-JSON case.test/domains/skill/uninstall.test.ts#L76-L76: add atrae-cnarray-shaped JSON case.test/domains/skill/uninstall.test.ts#L141-L145: add atrae-cnunreadable-configuration case.test/domains/skill/uninstall.test.ts#L227-L256: add atrae-cncase that preserves user handlers and metadata.🤖 Prompt for 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. In `@test/domains/skill/uninstall.test.ts` at line 57, Add equivalent Trae CN uninstall coverage in test/domains/skill/uninstall.test.ts: at lines 57-57 add a malformed-JSON case, at 76-76 add an array-shaped JSON case, at 141-145 add an unreadable-configuration case, and at 227-256 add a case verifying user handlers and metadata are preserved; use the existing Trae test structure while targeting the trae-cn configuration and hook path.
🤖 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 `@test/domains/skill/skills.test.ts`:
- Around line 1572-1621: Extend the Trae installation test around
installCometHooksForPlatform to execute
firstInstall.hooks.PreToolUse[1].hooks[0].command with the Native change
configured and Trae skills copied, then assert the command exits successfully.
Keep the existing hooks.json preservation and idempotency assertions unchanged,
and ensure this specifically validates the trae platform path rather than only
trae-cn routing.
---
Nitpick comments:
In `@test/domains/skill/uninstall.test.ts`:
- Line 57: Add equivalent Trae CN uninstall coverage in
test/domains/skill/uninstall.test.ts: at lines 57-57 add a malformed-JSON case,
at 76-76 add an array-shaped JSON case, at 141-145 add an
unreadable-configuration case, and at 227-256 add a case verifying user handlers
and metadata are preserved; use the existing Trae test structure while targeting
the trae-cn configuration and hook path.
🪄 Autofix
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: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 831315e0-983a-4555-8047-48562e54e6d4
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (21)
CHANGELOG.mdassets/manifest.jsonassets/skills/comet/scripts/comet-hook-router.mjsdomains/bundle/bundle-platform.tsdomains/bundle/types.tsdomains/comet-entry/hook-adapter.tsdomains/skill/platform-inspect.tsdomains/skill/platform-install.tsdomains/skill/uninstall.tspackage.jsonplatform/install/platforms.tstest/app/cli-help.test.tstest/domains/bundle/bundle-distribute.test.tstest/domains/bundle/bundle-platform.test.tstest/domains/comet-entry/hook-adapter.test.tstest/domains/comet-entry/hook-router-runtime.test.tstest/domains/skill/platform-inspect.test.tstest/domains/skill/skills.test.tstest/domains/skill/uninstall.test.tstest/platform/detect.test.tstest/repository/release-metadata.test.ts
🚧 Files skipped from review as they are similar to previous changes (16)
- package.json
- test/repository/release-metadata.test.ts
- domains/bundle/bundle-platform.ts
- domains/comet-entry/hook-adapter.ts
- test/platform/detect.test.ts
- test/domains/skill/platform-inspect.test.ts
- CHANGELOG.md
- test/domains/bundle/bundle-platform.test.ts
- domains/skill/platform-inspect.ts
- test/domains/comet-entry/hook-adapter.test.ts
- assets/skills/comet/scripts/comet-hook-router.mjs
- domains/skill/platform-install.ts
- assets/manifest.json
- platform/install/platforms.ts
- domains/bundle/types.ts
- domains/skill/uninstall.ts
c9a462b to
6b557a1
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
6b557a1 to
6439a41
Compare
|
LGTM |
Summary
Test Plan
Notes
Summary by Sourcery
Add managed Trae and Trae CN hook support across install, inspect, uninstall, and bundle workflows.
New Features:
Enhancements:
Documentation:
Tests:
Chores:
Summary by CodeRabbit
New Features
comet init,update,doctor, anduninstallnow manage project and global Trae hook configurations.Documentation
Chores