Skip to content

feat: add CodeBuddy agent support#378

Closed
studyzy wants to merge 4 commits into
UfoMiao:mainfrom
studyzy:main
Closed

feat: add CodeBuddy agent support#378
studyzy wants to merge 4 commits into
UfoMiao:mainfrom
studyzy:main

Conversation

@studyzy

@studyzy studyzy commented Jun 30, 2026

Copy link
Copy Markdown

Description

Add CodeBuddy AI agent support to zcf CLI, adapting the same pattern as the existing ClaudeCode support.

Closes #331

Motivation

CodeBuddy is a popular AI coding agent that users want to configure and use with zcf. This PR adds full CodeBuddy adapter support including config management, MCP registration, and CLI commands.

Changes

  • Added CodeBuddy agent adapter and provider
  • Registered CodeBuddy in agent registry
  • Added CodeBuddy MCP registrar
  • Added CLI subcommands for CodeBuddy
  • Updated README and docs compatibility matrix
  • Added unit tests for CodeBuddy adapter

Testing

  • pnpm typecheck passes
  • pnpm lint passes
  • pnpm test:run passes
  • New tests pass locally

Checklist

  • Code follows project style guidelines
  • Self-reviewed the code
  • Added tests for new functionality
  • Updated documentation
  • CI checks pass locally

- Add codebuddy code-type with cb abbreviation
- Create codebuddy-config.ts for MCP/settings file I/O to ~/.codebuddy/
- Create codebuddy-config-manager.ts for API profile management
- Create codebuddy.ts entry aggregating full init/update/uninstall/configure
- Wire codebuddy into init/update/uninstall/check-updates/config-switch/menu
- Add CodeBuddy path constants (CODEBUDDY_DIR, MCP, settings, agents)
- Update i18n with codebuddy menu entries (en/zh-CN)
- Update README and package.json keywords
- Add unit tests for codebuddy config and config manager

Closes UfoMiao#331
@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Jun 30, 2026

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Action required

1. plan.md contains Chinese text ✓ Resolved 📘 Rule violation ⚙ Maintainability
Description
A new Markdown documentation file (plan.md) introduces substantial non-English content outside of
README_zh-CN, violating the English-only documentation requirement. This can reduce
maintainability and accessibility for contributors who rely on English docs.
Code

plan.md[R7-17]

+zcf 当前 `code-type` 只支持 `claude-code` 和 `codex`. 需新增 `codebuddy` 支持.
+
+**关键发现 (探索阶段):**
+- zcf 对 Claude Code 和 Codex 都是**纯文件 I/O**, 不用任何 agent SDK (node_modules 无 `@anthropic-ai/claude-code`, 无 `@tencent-ai/agent-sdk`). 因此 CodeBuddy 适配也采用纯文件 I/O, 与现有模式一致, 不引入 SDK 依赖.
+- CodeBuddy 配置路径 (官方文档确认):
+  - 全局 settings: `~/.codebuddy/settings.json`
+  - 全局 MCP: `~/.codebuddy/.mcp.json` (推荐; legacy fallback `~/.codebuddy/mcp.json`, `~/.codebuddy.json`)
+  - 全局 agents: `~/.codebuddy/agents/*.md`
+  - 入口指令: `CODEBUDDY.md`
+  - settings.json schema 与 Claude Code 高度相似 (`permissions.allow/ask/deny`, `env`, `hooks`, `statusLine`, `model`, `agent`)
+- Claude Code 适配套件分散在 `src/utils/` 根 (多个 `claude-*.ts`); Codex 套件在 `src/utils/code-tools/` 子目录. CodeBuddy 套件放在 `src/utils/code-tools/` 子目录 (与 Codex 组织一致, 因为是新加的独立 tool).
Evidence
The checklist requires Markdown documentation to be written in English except for README_zh-CN.
The newly added plan.md includes Chinese text describing the implementation plan and decisions.

CLAUDE.md: Repository Documentation and Code Comments Must Be Written in English (Except README_zh-CN): CLAUDE.md: Repository Documentation and Code Comments Must Be Written in English (Except README_zh-CN): CLAUDE.md: Repository Documentation and Code Comments Must Be Written in English (Except README_zh-CN): CLAUDE.md: Repository Documentation and Code Comments Must Be Written in English (Except README_zh-CN)
plan.md[7-17]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`plan.md` introduces/contains non-English (Chinese) documentation text, which violates the project requirement that Markdown docs be written in English (except `README_zh-CN`).
## Issue Context
This PR adds a new planning/implementation document `plan.md`. The current content includes Chinese sentences and headings.
## Fix Focus Areas
- plan.md[7-17]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. codebuddy.ts prints hardcoded logs ✓ Resolved 📘 Rule violation ⚙ Maintainability
Description
New CodeBuddy workflow changes introduce multiple hardcoded user-facing strings (including
console/file creation notices, a CLI --code-type help description, and an error message) that
bypass i18next translation keys. This violates the i18n requirement for translated user-facing
output and risks locale drift and loss of zh-CN/en parity.
Code

src/utils/code-tools/codebuddy.ts[R281-292]

+  if (!exists(CODEBUDDY_MD_FILE)) {
+    const langDirective = aiOutputLang
+      ? (aiOutputLang === 'zh-CN' ? 'Always respond in Chinese-simplified' : 'Always respond in English')
+      : ''
+
+    const content = langDirective
+      ? `**Most Important: ${langDirective}**\n`
+      : '# CodeBuddy Instructions\n'
+
+    writeFile(CODEBUDDY_MD_FILE, content)
+    console.log(ansis.green(`Created CODEBUDDY.md at ${CODEBUDDY_MD_FILE}`))
+  }
Evidence
The compliance checklist requires all user-facing prompts/logs/errors (including CLI help text) to
go through i18next via i18n.t(...) with maintained en and zh-CN parity. The cited CodeBuddy
changes include direct hardcoded English output to the console for workflow status (e.g., file
creation messaging), a plain-text --code-type option description rather than an i18n key, and a
hardcoded stderr error message ("Failed to add onboarding flag"), demonstrating that these
user-facing strings are not translated as required.

CLAUDE.md: All User-Facing Strings Must Use i18next Translations (zh-CN and en Parity): CLAUDE.md: All User-Facing Strings Must Use i18next Translations (zh-CN and en Parity): CLAUDE.md: All User-Facing Strings Must Use i18next Translations (zh-CN and en Parity): CLAUDE.md: All User-Facing Strings Must Use i18next Translations (zh-CN and en Parity)
src/utils/code-tools/codebuddy.ts[281-292]
src/cli-setup.ts[232-232]
src/utils/code-tools/codebuddy-config.ts[96-113]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
User-facing console output, CLI help text, and error logging introduced/updated in the CodeBuddy workflow are currently hardcoded English strings instead of being routed through i18next translation keys.
## Issue Context
Compliance requires that all user-facing strings—prompts, logs, errors, and CLI option descriptions—use `i18n.t()` and maintain translation parity across `en` and `zh-CN` locale files. The CodeBuddy implementation currently prints user-facing messages directly (including file creation notices), the `--code-type` option description remains plain text, and a new hardcoded error message in the MCP config module is written to stderr (e.g., "Failed to add onboarding flag").
## Fix Focus Areas
- src/utils/code-tools/codebuddy.ts[281-292]
- src/cli-setup.ts[232-232]
- src/utils/code-tools/codebuddy-config.ts[96-113]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. Localized READMEs not updated ✓ Resolved 📘 Rule violation ⚙ Maintainability
Description
This PR updates documentation to include CodeBuddy support in README.md, but does not update the
localized READMEs to match. This causes documentation drift after i18n/documentation changes.
Code

README.md[21]

+> Zero-config, one-click setup for Claude Code, Codex & CodeBuddy with bilingual support, intelligent agent system and personalized AI assistant
Evidence
The compliance checklist requires parallel documentation and localized READMEs to be updated when
i18n/templates are modified to prevent instruction drift. The English README was updated to include
CodeBuddy, but the Chinese and Japanese READMEs still describe only Claude Code & Codex.

AGENTS.md: When Modifying i18n or Templates, Update Parallel Documentation and Localized READMEs: AGENTS.md: When Modifying i18n or Templates, Update Parallel Documentation and Localized READMEs: AGENTS.md: When Modifying i18n or Templates, Update Parallel Documentation and Localized READMEs: AGENTS.md: When Modifying i18n or Templates, Update Parallel Documentation and Localized READMEs
README.md[21-21]
README_zh-CN.md[19-22]
README_ja-JP.md[19-22]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`README.md` now states CodeBuddy support, but localized READMEs still describe only Claude Code & Codex.
## Issue Context
Compliance requires that when i18n/templates-related changes occur, parallel documentation and localized READMEs be updated to stay aligned.
## Fix Focus Areas
- README.md[21-21]
- README_zh-CN.md[19-22]
- README_ja-JP.md[19-22]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


View more (4)
4. Wrong CodeBuddy menu routing ✓ Resolved 🐞 Bug ≡ Correctness
Description
showMainMenu() only branches for 'codex' and sends all other code tool types (including 'codebuddy')
to showClaudeCodeMenu(), so selecting CodeBuddy displays and executes Claude Code actions. This
makes the CodeBuddy selection effectively incorrect in the interactive menu flow.
Code

src/commands/menu.ts[R31-35]

const CODE_TOOL_LABELS: Record<CodeToolType, string> = {
'claude-code': 'Claude Code',
'codex': 'Codex',
+  'codebuddy': 'CodeBuddy',
}
Evidence
The menu offers 'codebuddy' as a tool label, and showMainMenu() routes all non-codex tools to the
Claude Code menu, so codebuddy will always hit the Claude Code path.

src/commands/menu.ts[31-35]
src/commands/menu.ts[361-389]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
CodeBuddy is selectable via `CODE_TOOL_LABELS`, but `showMainMenu()` only routes `codex` to `showCodexMenu()` and routes everything else to `showClaudeCodeMenu()`. As a result, choosing CodeBuddy shows the Claude Code menu and triggers Claude Code operations.
## Issue Context
The PR adds `codebuddy` as a valid `CodeToolType` and adds it to the menu labels, but does not add a CodeBuddy-specific menu and does not update `showMainMenu()` dispatch logic.
## Fix Focus Areas
- src/commands/menu.ts[361-389]
- src/commands/menu.ts[31-35]
## Suggested fix
- Implement `showCodebuddyMenu()` (mirroring `showCodexMenu()` structure but calling CodeBuddy functions).
- Update `showMainMenu()` dispatch to route `codeTool === 'codebuddy'` to `showCodebuddyMenu()`.
- Ensure CodeBuddy menu options call the CodeBuddy init/update/uninstall/configure functions rather than Claude Code ones.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


5. CodeBuddy multi-config ignored ✓ Resolved 🐞 Bug ≡ Correctness
Description
init() calls handleMultiConfigurations(options, 'codebuddy') when --api-configs/--api-configs-file
is present, but handleMultiConfigurations only handles 'claude-code' and 'codex'. This causes
CodeBuddy multi-config input to be silently dropped while still printing success.
Code

src/commands/init.ts[R500-507]

+    if (codeToolType === 'codebuddy') {
+      const { runCodebuddyFullInit } = await import('../utils/code-tools/codebuddy')
+
+      // Handle multi-config providers before running full init
+      const hasApiConfigs = Boolean(options.apiConfigs || options.apiConfigsFile)
+      if (hasApiConfigs) {
+        await handleMultiConfigurations(options, 'codebuddy')
+      }
Evidence
The CodeBuddy init path explicitly calls multi-config for 'codebuddy', but the multi-config handler
only processes claude-code and codex, meaning the CodeBuddy call does nothing useful.

src/commands/init.ts[500-507]
src/commands/init.ts[1131-1138]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`init()` invokes `handleMultiConfigurations(..., 'codebuddy')`, but `handleMultiConfigurations()` has no `codebuddy` branch, so CodeBuddy API configs are not applied.
## Issue Context
This affects the CLI path using `--api-configs` / `--api-configs-file` during CodeBuddy initialization.
## Fix Focus Areas
- src/commands/init.ts[500-507]
- src/commands/init.ts[1131-1138]
## Suggested fix
- Add an `else if (codeToolType === 'codebuddy')` branch in `handleMultiConfigurations()`.
- Implement a `handleCodebuddyConfigs(configs)` similar to Claude Code’s profile add/switch flow (or reuse Claude profile conversion) and persist the selected/default profile in TOML so subsequent update/switch flows work.
- If CodeBuddy multi-config is not supported, throw an explicit error instead of printing success.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


6. skipPrompt not honored ✓ Resolved 🐞 Bug ☼ Reliability
Description
configureCodebuddyMcp() gates non-interactive behavior on options._skipPrompt, but callers pass
skipPrompt (not _skipPrompt). This can still enter inquirer prompts in non-interactive/CI runs and
hang the process.
Code

src/utils/code-tools/codebuddy.ts[R196-210]

+export async function configureCodebuddyMcp(options: {
+  mcpServices?: string
+  _skipPrompt?: boolean
+} = {}): Promise<void> {
+  ensureI18nInitialized()
+
+  if (options.mcpServices === 'skip') {
+    console.log(ansis.yellow(i18n.t('mcp:mcpSkipped') || 'MCP configuration skipped'))
+    return
+  }
+
+  if (options._skipPrompt) {
+    console.log(ansis.gray(i18n.t('mcp:mcpNonInteractiveSkipped') || 'MCP configuration requires interactive mode, skipped'))
+    return
+  }
Evidence
The init flow forwards options into configureCodebuddyMcp(), and that function only checks
_skipPrompt, so skipPrompt doesn’t prevent prompting.

src/utils/code-tools/codebuddy.ts[42-60]
src/utils/code-tools/codebuddy.ts[196-210]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`configureCodebuddyMcp()` checks `options._skipPrompt`, but the init flow passes `options.skipPrompt` through the shared options object. Because `_skipPrompt` is never set, the function can still prompt.
## Issue Context
`runCodebuddyFullInit()` passes its `options` directly into `configureCodebuddyMcp(options)`.
## Fix Focus Areas
- src/utils/code-tools/codebuddy.ts[55-60]
- src/utils/code-tools/codebuddy.ts[196-210]
## Suggested fix
- Rename `_skipPrompt` to `skipPrompt` in `configureCodebuddyMcp()` options type and logic.
- Or map `skipPrompt` to `_skipPrompt` at the call site (less ideal).
- Ensure non-interactive mode truly never calls `inquirer` (and consider honoring `mcpServices` CLI input for a fully non-interactive path).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


7. Update clears CodeBuddy env ✓ Resolved 🐞 Bug ≡ Correctness
Description
runCodebuddyUpdate() always calls CodeBuddyConfigManager.applyCurrentProfile(); if TOML has no
current profile configured, getCurrentProfile() returns null and applyProfileSettings(null) clears
ANTHROPIC_* env keys in ~/.codebuddy/settings.json. This can wipe a user’s existing CodeBuddy env
configuration just by running an update.
Code

src/utils/code-tools/codebuddy.ts[R89-90]

+  // Apply current profile settings
+  await CodeBuddyConfigManager.applyCurrentProfile()
Evidence
The update path calls applyCurrentProfile(), which can pass null into applyProfileSettings().
applyProfileSettings(null) clears model env vars and writes settings.json, and the default TOML
config sets codebuddy.currentProfile to an empty string, making the null path common.

src/utils/code-tools/codebuddy.ts[82-93]
src/utils/code-tools/codebuddy-config-manager.ts[15-34]
src/utils/code-tools/codebuddy-config-manager.ts[70-81]
src/utils/zcf-config.ts[310-314]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The CodeBuddy update flow unconditionally applies the “current profile”, but when no profile is configured it effectively performs an “official login reset” by clearing ANTHROPIC env keys and writing the file.
## Issue Context
- `runCodebuddyUpdate()` calls `applyCurrentProfile()`.
- `applyCurrentProfile()` calls `getCurrentProfile()` and then calls `applyProfileSettings(profile)` even when `profile` is null.
- `applyProfileSettings(null)` calls `clearModelEnv(settings.env)` and then writes settings.json.
## Fix Focus Areas
- src/utils/code-tools/codebuddy.ts[82-93]
- src/utils/code-tools/codebuddy-config-manager.ts[70-81]
- src/utils/code-tools/codebuddy-config-manager.ts[21-34]
- src/utils/zcf-config.ts[310-314]
## Suggested fix
- Change `applyCurrentProfile()` to be a no-op when `getCurrentProfile()` returns null (do not call `applyProfileSettings(null)` from update).
- Keep `applyProfileSettings(null)` behavior for explicit “switch to official login” only.
- Optionally log a message when no profile is configured so users understand why no env changes occurred.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

8. Uninstall leaves model env vars ✓ Resolved 🐞 Bug ☼ Reliability
Description
uninstallCodebuddy() clears only ANTHROPIC_API_KEY/AUTH_TOKEN/BASE_URL/MODEL but leaves
ANTHROPIC_DEFAULT_* model env keys that CodeBuddyConfigManager can set. This can leave stale model
configuration behind after uninstall.
Code

src/utils/uninstaller.ts[R395-406]

+      // Remove settings.json env section (clear profile)
+      const settingsPath = join(homedir(), '.codebuddy', 'settings.json')
+      if (await pathExists(settingsPath)) {
+        const settings = JSON.parse(readFileSync(settingsPath, 'utf-8'))
+        if (settings.env) {
+          delete settings.env.ANTHROPIC_API_KEY
+          delete settings.env.ANTHROPIC_AUTH_TOKEN
+          delete settings.env.ANTHROPIC_BASE_URL
+          delete settings.env.ANTHROPIC_MODEL
+          writeFileSync(settingsPath, JSON.stringify(settings, null, 2))
+          result.removedConfigs.push('~/.codebuddy/settings.json (API configuration cleared)')
+        }
Evidence
The uninstaller deletes only four env keys, while CodeBuddyConfigManager can set additional model
env keys that are not removed.

src/utils/uninstaller.ts[395-406]
src/utils/code-tools/codebuddy-config-manager.ts[49-60]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The CodeBuddy uninstaller clears only a subset of env keys in `~/.codebuddy/settings.json`, but the CodeBuddy config manager can set additional model keys (default haiku/sonnet/opus). Those keys remain after uninstall.
## Issue Context
This creates surprising leftover configuration even after a user explicitly uninstalls CodeBuddy configuration.
## Fix Focus Areas
- src/utils/uninstaller.ts[395-406]
- src/utils/code-tools/codebuddy-config-manager.ts[49-60]
## Suggested fix
- Also delete:
- `ANTHROPIC_DEFAULT_HAIKU_MODEL`
- `ANTHROPIC_DEFAULT_SONNET_MODEL`
- `ANTHROPIC_DEFAULT_OPUS_MODEL`
- Consider removing the `env` object if it becomes empty to avoid leaving an empty env stanza.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Qodo Logo

Comment thread plan.md Outdated
Comment thread src/utils/code-tools/codebuddy.ts
Comment thread README.md
Comment thread src/commands/menu.ts
Comment thread src/commands/init.ts
Comment thread src/utils/code-tools/codebuddy.ts
Comment thread src/utils/code-tools/codebuddy.ts
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

feat: add CodeBuddy agent support to zcf CLI

✨ Enhancement 🧪 Tests 📝 Documentation 🕐 40+ Minutes

Grey Divider

AI Description

• Adds full CodeBuddy AI agent adapter to zcf CLI, using the existing pure file I/O pattern to
 ~/.codebuddy/
• Registers codebuddy as a new CodeToolType with cb alias and wires it into
 init/update/uninstall/config-switch/menu/update-scheduler flows
• Adds CodeBuddy MCP/settings config utilities, TOML-backed API profile management, i18n strings,
 and unit tests
Diagram

graph TD
    CLI["CLI (cli-setup.ts)"] --> INIT["init.ts"] --> CB["codebuddy.ts"]
    CLI --> UPDATE["update.ts"] --> CB
    CLI --> CFGSW["config-switch.ts"] --> CBMGR["codebuddy-config-manager.ts"]
    CLI --> SCHED["tool-update-scheduler.ts"] --> CB
    CLI --> UNINSTALL["uninstaller.ts"]

    CB --> CBCFG["codebuddy-config.ts"] --> MCP[("~/.codebuddy/.mcp.json")]
    CBCFG --> SETTINGS[("~/.codebuddy/settings.json")]
    CBMGR --> SETTINGS
    CBMGR --> TOML[("~/.ufomiao/zcf/config.toml")]
    UNINSTALL --> MCP --> SETTINGS

    CONST["constants.ts"] --> CB

    subgraph Legend
      direction LR
      _mod["Module"] ~~~ _file[("Config file")]
    end
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Extract shared MCP config utilities (Claude/CodeBuddy)
  • ➕ Removes near-duplicated MCP helper code (merge/build/fixWindows/approval) across agents
  • ➕ Makes future agent adapters cheaper to add and less error-prone
  • ➖ Requires refactoring stable Claude Code path; slightly higher regression risk
  • ➖ Adds abstraction that may reduce local readability for small projects
2. Use json-config helpers in CodeBuddy uninstaller
  • ➕ Consistent error handling and formatting across the codebase
  • ➕ Avoids direct node:fs usage inside the uninstaller module
  • ➖ Small win; not functionally required

Recommendation: The PR’s approach (pure file I/O, mirroring ClaudeCode/Codex patterns) is appropriate and consistent with existing architecture. The main improvement opportunity is reducing duplication by extracting shared MCP config utilities, and aligning uninstall code with existing JSON helpers for consistency.

Files changed (27) +1485 / -16

Enhancement (18) +873 / -8
cli-setup.tsExpand --code-type help text to include codebuddy/cb +4/-4

Expand --code-type help text to include codebuddy/cb

• Updates multiple command option descriptions to include 'codebuddy' and 'cb' as valid --code-type values.

src/cli-setup.ts

config-switch.tsAdd interactive CodeBuddy config switch +46/-0

Add interactive CodeBuddy config switch

• Imports 'CodeBuddyConfigManager' and adds a new interactive switch flow for CodeBuddy (official login vs current profile). Wires it into the dispatcher.

src/commands/config-switch.ts

init.tsAdd CodeBuddy init dispatch path +49/-0

Add CodeBuddy init dispatch path

• Adds a 'codebuddy' branch that resolves template language, optionally handles multi-config providers, runs 'runCodebuddyFullInit', and updates ZCF config.

src/commands/init.ts

menu.tsRegister CodeBuddy in CODE_TOOL_LABELS +1/-0

Register CodeBuddy in CODE_TOOL_LABELS

• Adds 'codebuddy: 'CodeBuddy'' label mapping for menu/banner rendering.

src/commands/menu.ts

update.tsAdd CodeBuddy update dispatch path +21/-0

Add CodeBuddy update dispatch path

• Adds an early-return 'codebuddy' branch that calls 'runCodebuddyUpdate' and persists updated ZCF config metadata.

src/commands/update.ts

constants.tsAdd CodeBuddy paths and type registration +10/-1

Add CodeBuddy paths and type registration

• Defines '~/.codebuddy' path constants, adds 'codebuddy' to supported code tool types, adds banner entry, and registers 'cb' alias.

src/constants.ts

cli.jsonAdd CodeBuddy CLI example description key +1/-0

Add CodeBuddy CLI example description key

• Adds 'help.exampleDescriptions.checkCodebuddy' for English CLI help examples.

src/i18n/locales/en/cli.json

menu.jsonAdd CodeBuddy menu strings (EN) +17/-1

Add CodeBuddy menu strings (EN)

• Adds menu options/descriptions for CodeBuddy operations and updates tool-switch description to include CodeBuddy.

src/i18n/locales/en/menu.json

cli.jsonAdd CodeBuddy CLI example description key (zh-CN) +1/-0

Add CodeBuddy CLI example description key (zh-CN)

• Adds the Simplified Chinese translation for the CodeBuddy CLI help example key.

src/i18n/locales/zh-CN/cli.json

menu.jsonAdd CodeBuddy menu strings (zh-CN) +17/-1

Add CodeBuddy menu strings (zh-CN)

• Adds CodeBuddy menu options/descriptions translations and updates tool-switch description to include CodeBuddy.

src/i18n/locales/zh-CN/menu.json

toml-config.tsAdd CodeBuddyConfig schema to TOML config types +13/-0

Add CodeBuddyConfig schema to TOML config types

• Defines 'CodeBuddyConfig' and adds optional 'codebuddy' section to 'ZcfTomlConfig' / 'PartialZcfTomlConfig' for profile management.

src/types/toml-config.ts

codebuddy-config-manager.tsNew CodeBuddy profile manager (settings env + TOML state) +123/-0

New CodeBuddy profile manager (settings env + TOML state)

• Implements 'CodeBuddyConfigManager' to apply profiles into '~/.codebuddy/settings.json' env vars and store current profile/profiles in TOML.

src/utils/code-tools/codebuddy-config-manager.ts

codebuddy-config.tsNew CodeBuddy config I/O for MCP + settings +196/-0

New CodeBuddy config I/O for MCP + settings

• Adds '~/.codebuddy/.mcp.json' and 'settings.json' helpers, MCP server merging/building, Windows command wrapping, and API key approval helpers.

src/utils/code-tools/codebuddy-config.ts

codebuddy.tsNew CodeBuddy adapter entry (full init/update/uninstall/configure) +293/-0

New CodeBuddy adapter entry (full init/update/uninstall/configure)

• Implements CodeBuddy workflows: ensure 'CODEBUDDY.md', configure API and MCP interactively/non-interactively, update current profile, and uninstall logic hook.

src/utils/code-tools/codebuddy.ts

code-type-resolver.tsSupport codebuddy and cb abbreviation in code type resolution +2/-1

Support codebuddy and cb abbreviation in code type resolution

• Adds 'cb' abbreviation and includes 'codebuddy' in the valid code type set.

src/utils/code-type-resolver.ts

tool-update-scheduler.tsSchedule CodeBuddy tool updates +8/-0

Schedule CodeBuddy tool updates

• Adds a 'codebuddy' switch case that calls 'runCodebuddyUpdate' via a new private helper.

src/utils/tool-update-scheduler.ts

uninstaller.tsAdd CodeBuddy uninstall item and implementation +48/-0

Add CodeBuddy uninstall item and implementation

• Adds 'codebuddy' uninstall item, conflict rule, dispatcher case, and 'uninstallCodebuddy' that trashes MCP config and clears Anthropic env fields from settings.

src/utils/uninstaller.ts

zcf-config.tsPersist CodeBuddy section in TOML config +23/-0

Persist CodeBuddy section in TOML config

• Extends default config creation, JSON migration, TOML update merging, and incremental TOML writes to include 'codebuddy' enabled/currentProfile fields.

src/utils/zcf-config.ts

Tests (5) +305 / -7
menu.test.tsUpdate menu tests for new valid code types +1/-1

Update menu tests for new valid code types

• Updates mocked error message expectation to include 'cb' and 'codebuddy' among valid code type options.

tests/unit/commands/menu.test.ts

codebuddy-config-manager.test.tsAdd unit tests for CodeBuddyConfigManager +141/-0

Add unit tests for CodeBuddyConfigManager

• Covers current profile retrieval, env application for api_key/auth_token, clearing behavior, profile ID generation, and sanitization.

tests/unit/utils/code-tools/codebuddy-config-manager.test.ts

codebuddy-config.test.tsAdd unit tests for codebuddy-config utilities +145/-0

Add unit tests for codebuddy-config utilities

• Tests MCP/settings path helpers, read/write behavior, merge/build helpers, Windows fix no-op on non-Windows, and API key approval behavior.

tests/unit/utils/code-tools/codebuddy-config.test.ts

code-type-resolver.test.tsExpand resolver tests for cb/codebuddy +15/-4

Expand resolver tests for cb/codebuddy

• Adds cb resolution tests and updates invalid-type error message assertions to include CodeBuddy values.

tests/unit/utils/code-type-resolver.test.ts

constants.test.tsUpdate constants tests for added codebuddy type +3/-2

Update constants tests for added codebuddy type

• Updates CODE_TOOL_TYPES assertions/length and adds 'isCodeToolType('codebuddy')' coverage.

tests/unit/utils/constants.test.ts

Documentation (2) +174 / -1
README.mdMention CodeBuddy in project tagline +1/-1

Mention CodeBuddy in project tagline

• Updates the main README tagline to list CodeBuddy alongside Claude Code and Codex.

README.md

plan.mdAdd implementation plan for CodeBuddy support +173/-0

Add implementation plan for CodeBuddy support

• Adds a detailed plan document describing design decisions, file layout, and test/CI steps for CodeBuddy integration.

plan.md

Other (2) +133 / -0
project.ymlAdd Serena project configuration +132/-0

Add Serena project configuration

• Introduces a Serena project config defining language servers, encoding, ignore behavior, and tool settings for the repo.

.serena/project.yml

package.jsonAdd codebuddy keyword +1/-0

Add codebuddy keyword

• Adds 'codebuddy' to npm keywords for discoverability.

package.json

- Delete plan.md (Chinese content, should not be committed)
- Fix showMainMenu routing for codebuddy tool type
- Map skipPrompt to _skipPrompt in runCodebuddyFullInit to prevent
  inquirer prompts in non-interactive mode
- Make applyCurrentProfile a no-op when no profile configured, preventing
  runCodebuddyUpdate from wiping user env settings
- Add codebuddy branch to handleMultiConfigurations with new
  handleCodebuddyConfigs function
@codecov

codecov Bot commented Jul 2, 2026

Copy link
Copy Markdown

WitMiao pushed a commit that referenced this pull request Jul 2, 2026
- Delete plan.md (Chinese content, should not be committed)
- Fix showMainMenu routing for codebuddy tool type
- Map skipPrompt to _skipPrompt in runCodebuddyFullInit to prevent
  inquirer prompts in non-interactive mode
- Make applyCurrentProfile a no-op when no profile configured, preventing
  runCodebuddyUpdate from wiping user env settings
- Add codebuddy branch to handleMultiConfigurations with new
  handleCodebuddyConfigs function
WitMiao added a commit that referenced this pull request Jul 2, 2026
- Add CodeBuddy unit tests and config-switch tests

- Update README, CLAUDE.md and multilingual docs

- Sync i18n strings for installation/updater/uninstall/multi-config

- Clean up dead code and fix menu routing/config writes
@WitMiao

WitMiao commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

@studyzy 感谢佬提 pr 🎉
只是 pr 问题还是挺多的,是不是用 AI 一句话跑的🤪配置完全照抄的 cc 的,和 codebuddy 实际的不符,可以让 AI 读一下官方文档重新修改下;另外单元测试也需要补全

studyzy added 2 commits July 3, 2026 18:49
- Fix env var names: ANTHROPIC_* → CODEBUDDY_* (CODEBUDDY_API_KEY,
  CODEBUDDY_AUTH_TOKEN, CODEBUDDY_BASE_URL, CODEBUDDY_MODEL,
  CODEBUDDY_SMALL_FAST_MODEL, CODEBUDDY_BIG_SLOW_MODEL) per official
  docs (https://www.codebuddy.cn/docs/cli/env-vars)
- Add CodeBuddy-specific clearCodebuddyModelEnv/clearCodebuddyAuthEnv;
  uninstaller no longer imports ClaudeCode's clearModelEnv
- Implement independent showCodebuddyMenu() instead of routing to
  showClaudeCodeMenu(); update showMainMenu() dispatch
- Add codebuddy branch in uninstall.ts calling runCodebuddyUninstall()
- Remove ClaudeCode copy-paste dead code from codebuddy-config.ts:
  addCompletedOnboarding, ensureApiKeyApproved,
  removeApiKeyFromRejected, manageApiKeyApproval (never called)
- Drop unused onboardingFlagFailed i18n key (en/zh-CN)
- Fix hardcoded 'MCP config backed up' string to use i18n.t
- Add --code-type codebuddy to config-switch command and help examples
- Sync README_zh-CN.md and README_ja-JP.md intro with CodeBuddy
- Delete tracked .serena/ config files
@studyzy

studyzy commented Jul 6, 2026

Copy link
Copy Markdown
Author

@studyzy 感谢佬提 pr 🎉 只是 pr 问题还是挺多的,是不是用 AI 一句话跑的🤪配置完全照抄的 cc 的,和 codebuddy 实际的不符,可以让 AI 读一下官方文档重新修改下;另外单元测试也需要补全

@WitMiao 我正在写一款SKILL,比较复杂,测试过程中把没有实测完善的代码PR了,抱歉打搅了;待我把zcf完善了再重新PR。

@studyzy studyzy closed this Jul 6, 2026
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.

feature: 支持 codebuddy code

2 participants