Repository navigation
Add CodeBuddy as a built-in coding agent - #23740
Conversation
|
There was a problem hiding this comment.
Important
Two things to address before merge: the new CodeBuddy resume is gated on the generic host-authority probe instead of its own capability, so a remote CodeBuddy resume dies under version skew instead of degrading to a legacy launch; and the mobile bundled-icon ratchet fails for the new favicon-path agent.
Reviewed changes
- Agent registration —
codebuddy/cbcadded acrossTuiAgent,agent-kind, telemetryAGENT_KIND_VALUES, display names, desktop/mobile catalog, process recognition, skills CLI keys, permissions, rest signal, auto-pick order, and AI Vault resume/deletion lists. - Managed hooks — new
src/main/codebuddy/hook-service.tsreusesClaudeHookServicewith.codebuddy/settings.jsonandcodebuddy-hookscripts (PowerShell on Windows), wired into the local/remote install, refresh, remove and status registries plus the/hook/codebuddyrelay route. - Status projection — the Qoder normalizer is extracted into a shared
normalizeCompatibleLifecycleEvent, preserving Qoder behavior and adding CodeBuddy handling (ignore a lateSessionStart, forcePreToolUseto working, and map theAskUserQuestionpermission notification to a waiting question). - AI Vault history — a new CodeBuddy JSONL parser (top-level roles,
input_text/output_textblocks,summary/ai-titlerecords) with local/WSL/SSH sources, resume command and deletion, plus a captured-event fixture and focused tests.
ℹ️ Nitpicks
- The
expectedProcess: 'opencode2'removal is a no-op (TUI_AGENT_CONFIG_SOURCEdefaults it todetectCmd) and thegetCatalogPlatformextraction intoagent-catalog-platform.tsis unrelated to CodeBuddy. Both are fine to keep, but they widen an otherwise focused diff.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 📝 WalkthroughWalkthroughThis change adds CodeBuddy CLI support across agent configuration, command and session handling, hook lifecycle processing, managed hook installation, and AI Vault discovery. It adds CodeBuddy catalogs, localized labels, mobile icon mappings, and documentation. AI Vault scans and parses local and remote CodeBuddy JSONL transcripts. CodeBuddy session resume uses its session ID. The shared lifecycle normalizer also handles Qoder events, replacing its previous provider-specific normalization. Priority: ➖ Normal Merge Risk: 🔵 Low · up to A CodeBuddy clear or resume event may leave stale session status. This is a bounded risk to address or explicitly accept before merging; the mobile icon is bundled. Security Architecture ReviewSecurity architecture risk: 🟡 Moderate · up to Saved conversations and persistent integrations now cover another coding agent on local and remote hosts. A crafted conversation file may be attributed to the wrong project, although deletion still requires a local file and user action. Behavior across the supported environments has not been fully verified. Retained concerns
Security review detailsSecurity Blast Radius
Security Findings and Attack Paths
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 3 | ❌ 1 | ❓ 1❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
Full details: Out of Scope Changes checkExplanation Most changes support CodeBuddy and are within issue Full details: Docstring CoverageExplanation Docstring coverage is 25.81% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 31 functions across 50 files. (22 skipped: 12 unsupported, 10 over the file limit.)
✨ Finishing Touches 💡 2📝 Generate docstrings 💡
🛠️ Fix failing CI checks 💡
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.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 55d228f0-dc34-4f10-8773-9f48253d3fa4
⛔ Files ignored due to path filters (1)
src/shared/agent-icons/codebuddy.pngis excluded by!**/*.png
📒 Files selected for processing (72)
README.mdconfig/tsconfig.cli.jsondocs/reference/codebuddy-harness.mddocs/site/content/docs/agents/supported.mdxmobile/src/components/mobile-agent-icon-assets.tsmobile/src/tasks/mobile-tui-agents.tssrc/main/agent-hooks/managed-agent-hook-registry.tssrc/main/agent-hooks/managed-hook-command-contract.test.tssrc/main/agent-hooks/remote-hook-service-registry-coverage.test.tssrc/main/agent-hooks/remote-managed-hook-installers.tssrc/main/agent-hooks/server-retired-pane-new-turn.test.tssrc/main/ai-vault/remote-session-scanner-sources.tssrc/main/ai-vault/session-cwd-bucket-layouts.test.tssrc/main/ai-vault/session-cwd-bucket-layouts.tssrc/main/ai-vault/session-scanner-agent-parser.tssrc/main/ai-vault/session-scanner-agent-sources.tssrc/main/ai-vault/session-scanner-codebuddy-parser.tssrc/main/ai-vault/session-scanner-codebuddy-scope.test.tssrc/main/ai-vault/session-scanner-codebuddy-source.test.tssrc/main/ai-vault/session-scanner-log-agent-fixtures.tssrc/main/ai-vault/session-scanner-parse-cache.tssrc/main/ai-vault/session-scanner-scope-discovery.tssrc/main/ai-vault/session-scanner-test-fixtures.tssrc/main/ai-vault/session-scanner-types.tssrc/main/ai-vault/session-scanner.tssrc/main/claude/hook-settings.tssrc/main/codebuddy/hook-service.test.tssrc/main/codebuddy/hook-service.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/fr.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/zh.jsonsrc/renderer/src/lib/agent-catalog-platform.tssrc/renderer/src/lib/agent-catalog.tsxsrc/renderer/src/lib/agent-status.tssrc/renderer/src/runtime/agent-resume-host-authority-capability.test.tssrc/renderer/src/runtime/agent-resume-host-authority-capability.tssrc/renderer/src/runtime/remote-agent-session-launch.test.tssrc/shared/__fixtures__/codebuddy-question-hooks.jsonlsrc/shared/__fixtures__/codebuddy-question-hooks.meta.jsonsrc/shared/agent-headless-command.tssrc/shared/agent-hook-listener/provider-dispatch.tssrc/shared/agent-hook-listener/provider-event-routing.tssrc/shared/agent-hook-listener/providers/compatible-lifecycle-events.tssrc/shared/agent-hook-listener/providers/qoder-events.tssrc/shared/agent-hook-listener/source-routing.tssrc/shared/agent-hook-relay.tssrc/shared/agent-hook-types.tssrc/shared/agent-kind.tssrc/shared/agent-node-package-entrypoints.tssrc/shared/agent-session-option-catalog-codebuddy.tssrc/shared/agent-session-option-catalog.tssrc/shared/agent-session-resume.test.tssrc/shared/agent-session-resume.tssrc/shared/agent-type-label.tssrc/shared/ai-vault-resume-command.test.tssrc/shared/ai-vault-resume-command.tssrc/shared/ai-vault-session-deletion.tssrc/shared/ai-vault-types.tssrc/shared/codebuddy-agent.test.tssrc/shared/codebuddy-headless-command.tssrc/shared/protocol-version.tssrc/shared/skills-cli-agent-keys.tssrc/shared/telemetry-property-schemas.tssrc/shared/tui-agent-config.tssrc/shared/tui-agent-display-names.tssrc/shared/tui-agent-permissions.tssrc/shared/tui-agent-rest-signal.test.tssrc/shared/tui-agent-selection.tssrc/shared/tui-agent.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.
| if (source === 'codebuddy' && eventName === 'SessionStart') { | ||
| return null | ||
| } | ||
| const stateName = | ||
| source === 'codebuddy' && eventName === 'PreToolUse' | ||
| ? 'working' | ||
| : readCompatibleState(eventName, hookPayload) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
rg -n -C3 'SessionStart' docs/reference/codebuddy-harness.md src/shared/__fixtures__/codebuddy-question-hooks*Repository: stablyai/orca
Length of output: 3445
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- changed implementation ---'
cat -n src/shared/agent-hook-listener/providers/compatible-lifecycle-events.ts
printf '%s\n' '--- direct callers and state handling ---'
rg -n -C4 'normalizeCompatibleLifecycleEvent|ParsedAgentStatusPayload|session-boundary|SessionStart|source.*(clear|resume)|\"clear\"|\"resume\"' src/shared/agent-hook-listener docs/reference src/shared/__fixtures__ -g '*.ts' -g '*.md' -g '*.json' -g '*.jsonl' | head -n 400
printf '%s\n' '--- harness documentation ---'
cat -n docs/reference/codebuddy-harness.md
printf '%s\n' '--- relevant diff ---'
git diff --unified=30 4b622e1b1354a83b9b4cf963fdcc96b3266ff0eb c33c81d12b86d143356f546721f86f7388b2d0f6 -- src/shared/agent-hook-listener/providers/compatible-lifecycle-events.ts src/shared/agent-hook-listenerRepository: stablyai/orca
Length of output: 42129
🏁 Script executed:
#!/bin/bash
set -e
cat -n src/shared/agent-hook-listener/providers/compatible-lifecycle-events.ts
printf '%s\n' '--- callers ---'
rg -n -C5 'normalizeCompatibleLifecycleEvent' src
printf '%s\n' '--- CodeBuddy source values ---'
rg -n -C3 'SessionStart|source.*(startup|clear|resume)|source.*clear|source.*resume' docs src -g '*.ts' -g '*.md' -g '*.json' -g '*.jsonl'Repository: stablyai/orca
Length of output: 12852
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- CodeBuddy harness lines 1-60 ---'
sed -n '1,60p' docs/reference/codebuddy-harness.md
printf '%s\n' '--- session boundary consumers ---'
rg -n -C6 'sessionBoundary|resetOnNewTurn|function resolveToolState|export function resolveToolState' src/shared src -g '*.ts' | head -n 300
printf '%s\n' '--- CodeBuddy resume/clear references ---'
rg -n -i -C4 'codebuddy|sessionstart|session start|source.*(resume|clear)|resum(e|ed)|/clear' docs/reference src/shared/__fixtures__ src/shared/agent-hook-listener -g '*.md' -g '*.ts' -g '*.json' -g '*.jsonl' | head -n 400Repository: stablyai/orca
Length of output: 41575
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- prompt state helpers ---'
rg -n 'resolveToolState|resetOnNewTurn|clearPaneTurnCacheState' src/shared/agent-hook-listener -g '*.ts'
printf '%s\n' '--- helper implementation ---'
sed -n '1,260p' src/shared/agent-hook-listener/prompt-fields.ts
printf '%s\n' '--- status publication handling ---'
rg -n -C8 'sessionBoundary|payload\.sessionBoundary|clear.*cache|reset.*cache' src/shared/agent-hook-listener src/shared -g '*.ts' | head -n 400Repository: stablyai/orca
Length of output: 42529
Handle non-startup CodeBuddy SessionStart events as session boundaries.
The CodeBuddy branch drops every SessionStart before boundary handling. If CodeBuddy sends source: "clear" or source: "resume", the previous prompt and tool caches remain because CodeBuddy currently treats only UserPromptSubmit as a new-turn reset. Keep suppressing source: "startup", but allow non-startup session events to reset cached state and emit the existing boundary row.
Suggested fix
--- a/src/shared/agent-hook-listener/providers/compatible-lifecycle-events.ts
+++ b/src/shared/agent-hook-listener/providers/compatible-lifecycle-events.ts
@@ -59,7 +59,11 @@ export function normalizeCompatibleLifecycleEvent(
return null
}
// CodeBuddy emits SessionStart after UserPromptSubmit, so it cannot settle a turn.
- if (source === 'codebuddy' && eventName === 'SessionStart') {
+ if (
+ source === 'codebuddy' &&
+ eventName === 'SessionStart' &&
+ hookPayload.source === 'startup'
+ ) {
return null
}--- a/src/shared/agent-hook-listener/provider-event-routing.ts
+++ b/src/shared/agent-hook-listener/provider-event-routing.ts
@@ -30,7 +30,9 @@ export function isNewTurnEvent(source: AgentHookSource, eventName: unknown): boolean {
return eventName === 'SessionStart' || eventName === 'UserPromptSubmit'
case 'codebuddy':
+ return eventName === 'SessionStart' || eventName === 'UserPromptSubmit'
case 'kimi':
- // Why: Kimi Code emits Claude-compatible hook events, so UserPromptSubmit is its new-turn boundary too.
+ // Why: Kimi Code emits Claude-compatible hook events, so UserPromptSubmit is its new-turn boundary too.
return eventName === 'UserPromptSubmit'📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if (source === 'codebuddy' && eventName === 'SessionStart') { | |
| return null | |
| } | |
| const stateName = | |
| source === 'codebuddy' && eventName === 'PreToolUse' | |
| ? 'working' | |
| : readCompatibleState(eventName, hookPayload) | |
| if ( | |
| source === 'codebuddy' && | |
| eventName === 'SessionStart' && | |
| hookPayload.source === 'startup' | |
| ) { | |
| return null | |
| } | |
| const stateName = | |
| source === 'codebuddy' && eventName === 'PreToolUse' | |
| ? 'working' | |
| : readCompatibleState(eventName, hookPayload) |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
This incremental review covers c33c81d, which retires both prior findings and adds scoped CodeBuddy history backfill.
- CodeBuddy resume capability —
codebuddynow maps to a dedicatedagent-session.codebuddy-resume.v1capability advertised inRUNTIME_CAPABILITIES, so resuming against an older remote host degrades to the legacy launch instead of dying oninvalid_argument. The capability gate pin and the fallback/host-authority test matrices now includecodebuddy. - Bundled mobile icon —
src/shared/agent-icons/codebuddy.pngships and is wired intoMOBILE_AGENT_ICON_ASSETS, satisfying the #8451 no-network ratchet. - Scoped CodeBuddy history — a new
CODEBUDDY_CWD_BUCKET_LAYOUTencodes scope paths to bucket prefixes, and scope discovery now passesscopePathsto every non-Claude bucket layout so each CodeBuddy transcript's owncwddecides membership. New encoding and end-to-end scope tests cover the recency-cap bypass, sibling-prefix exclusion, and lossy-collision cases.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

ELI5
CodeBuddy can now be selected and launched like Orca's other terminal agents. Orca shows when it is working, waiting for an answer or permission, and finished, and its saved conversations appear in AI Vault.
What Changed
cbcalias across desktop/mobile agent selection, process recognition, settings, telemetry and skill CLI mapping. Add model/effort launch preferences without changing existing automatic agent priorities.SessionStartcan arrive after work starts, and its question wait is announced beforePreToolUse.Why
Previously CodeBuddy was an unrecognized terminal command. Reusing Orca's launch, hook transport and history infrastructure gives it the same integration surfaces without a separate status cache or terminal-text polling. The live event trace is committed as a regression fixture.
The launch/history starting point was the community patch linked from the issue; this adds lifecycle status and adapts the integration to current Orca.
Linked Issue
Fixes #9354
Visual Proof
Actual authenticated CodeBuddy 2.159.0 running in this branch's hidden Electron renderer, captured with CDP. These show the new running, question and completed states; the previous version had no built-in CodeBuddy integration.
Working:
Waiting for a real question:
Completed after answering:
Testing
Live macOS: launched from the agent menu, switched models, submitted a question task, answered it, observed waiting → working → done, ran a Bash task, discovered the resulting AI Vault sessions, and resumed a session that correctly recalled the earlier answer.
251 tests passed across 18 focused suites, including captured-event replay, installer preservation, local/remote registration, command generation for macOS/Linux/Windows, history, resume, selection and neighboring agent regressions.
pnpm tc, changed-code quality andgit diff --checkpass.Review follow-up: 42 tests passed for scoped history, path encodings, older/newer remote hosts, and mobile icon assets. Typecheck and changed-code quality pass.
The desktop/CLI/relay/renderer build stages passed. The initial full build stopped at absent mobile dependencies; after installing the existing mobile lockfile, mobile web build and verification passed. The native build passed as well.
Review
The hook source remains provider-specific; readers use the existing execution-host status store. User hook configuration is preserved, and noninteractive CodeBuddy processes are excluded from terminal-agent recognition.
Agent skill upstream boundary
Notes
Live validation is macOS only. Linux, Windows, WSL and SSH execution are not claimed as live-tested. No new RPC method or stream opcode is introduced. See
docs/reference/codebuddy-harness.mdfor the observed lifecycle and validation scope.Checklist
CI exception: the unchanged RPC recording corpus pins
03995ae29d28dd39bd2546423831987db68985de, which is not an ancestor of current main (bd5dca4406ff). This PR changes neither the pin nor the goldens. Full mobile tests pass locally (9,819 tests). Final follow-up changes only the stale CLI test expectation to include CodeBuddy; production code is unchanged from the CI-tested commitc33c81d12b86.