Skip to content

feat: add CodeBuddy CLI harness adapter - #110

Open
aleexjiang wants to merge 2 commits into
BytePioneer-AI:mainfrom
aleexjiang:feat/codebuddy-harness-adapter
Open

feat: add CodeBuddy CLI harness adapter#110
aleexjiang wants to merge 2 commits into
BytePioneer-AI:mainfrom
aleexjiang:feat/codebuddy-harness-adapter

Conversation

@aleexjiang

Copy link
Copy Markdown

Summary

Integrates the Tencent CodeBuddy CLI as a new external Harness, so its Agent runs as a native Thread inside Codex Desktop — alongside Pi, Claude Code, DeepSeek Harness, OpenCode, Grok, and OMP.

The adapter follows the repos native-interface integration approach (see .agents/skills/codexhost-add-harness): it drives the CodeBuddy CLI over its **bidirectional stream-json print transport** (-p --output-format stream-json --input-format stream-json --include-partial-messages`) and keeps one CLI process alive across Turns, projecting frames into the standard HarnessAdapter contract.

What is supported

  • Sessions: create / resume via --resume <sessionId> (fork and rollback are reported as unsupported)
  • Streaming: text and reasoning deltas projected from stream_event frames, with an assistant-text fallback for CLI builds that skip deltas
  • Tools: tool_use / tool_result projected into commandExecution / toolExecution items (Bash/PowerShell mapped to command execution)
  • Permission modes: selected at Session creation via --permission-mode; unattended-full-access delegation maps to bypassPermissions
  • Model Catalog: parsed from codebuddy --help, filtered to transport-safe Model Ref IDs, with a static fallback catalog
  • Usage: token counters, context window / context-used, and total cost from the terminal result frame
  • History: transcript snapshots parsed from ~/.codebuddy/projects/<slug>/<sessionId>.jsonl (with project-slug scan fallback); Native Turn Refs keyed by persisted user-message ids
  • Cancellation: kills the CLI process; the next Turn re-spawns with --resume

Explicitly not supported (reported, never silently degraded)

  • Interactive approvals / questions (the print transport has no approval channel)
  • Mid-session model / thinking / permission-mode switching (CLI fixes configuration at process start)
  • Fork and rollback

Wiring

  • packages/adapters/codebuddy — new adapter package (transport, accumulator, usage, history, discovery, model catalog, session/adapter)
  • protocol-corecodebuddy added to EXTERNAL_HARNESS_IDS, transport Model codec (codexhost/codebuddy-native, encodes model + permission mode)
  • host-runtime — adapter registration, CODEXHOST_CODEBUDDY_COMMAND override, approval-server naming, package metadata
  • renderer-extension — agent selection state, binding probe, transport model codec, icon/labels, picker, sidebar, connections page
  • Root tsconfig references, host-runtime dependencies, package-lock
  • README (zh/en/ko): badge, intro, and feature-status matrix

Testing

  • npx tsc -b — clean (also tsc -p tests/tsconfig.json --noEmit)
  • vitest run — 185 files / 1595 tests passing, including 40 new tests covering frame parsing, turn projection, usage mapping, transcript history, and the full create → turn → stream → complete / cancel / crash lifecycle against a fake child process
  • eslint / prettier --check — clean for all touched files

Note: two pre-existing eslint errors exist in packages/adapters/opencode/src/opencode-adapter.ts (non-null assertions at lines 1726/1736) on the untouched main code; left as-is to keep this PR focused.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@aleexjiang
aleexjiang force-pushed the feat/codebuddy-harness-adapter branch from 4cac20b to 7e87b00 Compare September 1, 2026 13:08
Integrate the Tencent CodeBuddy CLI as a new external Harness so its
Agent can run as a native Thread inside Codex Desktop, alongside Pi,
Claude Code, DeepSeek Harness, OpenCode, Grok, and OMP.

The adapter drives the CodeBuddy CLI over its bidirectional
stream-json print transport (`-p --output-format stream-json
--input-format stream-json --include-partial-messages`) and reuses the
same process across Turns:

- create / resume Sessions (fork and rollback reported as unsupported)
- streaming text and reasoning deltas via stream_event projections
- tool call / result projection into commandExecution and
  toolExecution items
- Permission Mode selection at Session creation; unattended
  full-access delegation maps to bypassPermissions
- Model Catalog parsed from `codebuddy --help` with a static fallback
- Usage (tokens, context window, total cost) from the terminal result
  frame, plus transcript-based history snapshots under
  ~/.codebuddy/projects

Registration wiring covers model routing, adapter composition,
host-runtime metadata, root tsconfig references, and the full renderer
surface (agent selection state, binding probe, transport model
codec, icons, picker, sidebar, connections page).

Interactive approvals/questions, mid-session model switching,
thinking options, fork, and rollback are explicitly not supported in
this first iteration and are reported as such instead of being
silently degraded.
@aleexjiang
aleexjiang force-pushed the feat/codebuddy-harness-adapter branch from 7e87b00 to 9291f0f Compare September 1, 2026 13:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant