Skip to content

feat(targets): add codebuddy as alias of claude#1334

Open
xuedizi wants to merge 1 commit into
microsoft:mainfrom
xuedizi:add-codebuddy-target
Open

feat(targets): add codebuddy as alias of claude#1334
xuedizi wants to merge 1 commit into
microsoft:mainfrom
xuedizi:add-codebuddy-target

Conversation

@xuedizi
Copy link
Copy Markdown

@xuedizi xuedizi commented May 15, 2026

Summary

Registers Tencent CodeBuddy IDE as a first-class target with its own deploy directory .codebuddy/. CodeBuddy is a Claude-Code-compatible AI coding assistant — it reads CLAUDE.md from the project root and uses .claude/-style settings.json for hook configuration. Reuses the existing claude_* primitive formatters but deploys to .codebuddy/ so projects using both Claude Code and CodeBuddy can co-exist without directory collision.

CodeBuddy CLI: https://copilot.tencent.com/codebuddy

Patch surface (4 files, +37 net)

  • src/apm_cli/integration/targets.py — new KNOWN_TARGETS["codebuddy"] TargetProfile (root_dir=".codebuddy", compile_family="claude", primitives reuse claude_rules / claude_agent / claude_command / skill_standard / claude_hooks, hooks_config_display=".codebuddy/settings.json")
  • src/apm_cli/core/target_detection.pyTargetType / UserTargetType Literals + ALL_CANONICAL_TARGETS + CANONICAL_TARGETS_ORDERED + CANONICAL_DEPLOY_DIRS + CANONICAL_SIGNAL + SIGNAL_WHITELIST all add codebuddy; detect_target() --target / apm.yml elif chains return "codebuddy"; should_compile_claude_md() accepts codebuddy (so root CLAUDE.md is still generated); get_target_description() describes codebuddy output
  • src/apm_cli/core/apm_yml.pyCANONICAL_TARGETS frozenset gains "codebuddy"
  • src/apm_cli/compilation/agents_compiler.py_KNOWN_TARGETS tuple gains "codebuddy" so the compiler's local validation accepts config.target == "codebuddy"

Verified locally against upstream/main (219af91)

$ apm targets
  TARGET       STATUS     SOURCE                         DEPLOY DIR
  claude       inactive   needs CLAUDE.md                .claude/
  codebuddy    inactive   needs .codebuddy/              .codebuddy/
  ...

$ apm install --target codebuddy
Installed 17 APM dependencies in 15.2s

$ apm compile -t codebuddy
[+] Compilation completed successfully!
[i] Targets: codebuddy  (source: --target flag)
[i] Compiling for CLAUDE.md + .codebuddy/commands/ + .codebuddy/agents/ + .codebuddy/skills/ (Claude-compatible)

End-to-end on a real project — fresh git repo + apm install --target codebuddy:

  • .codebuddy/agents/ populated with agent files
  • .codebuddy/commands/ populated with command files
  • .codebuddy/skills/ populated with skills
  • .codebuddy/settings.json written (hook config)
  • Root CLAUDE.md generated by apm compile -t codebuddy

Multi-IDE (.claude/ + .codebuddy/ in the same project) deploys primitives to both directories in parallel with no overlap.

Design choices

  • compile_family="claude" so root CLAUDE.md is still generated. CodeBuddy reads Claude Code's format verbatim — adding a new compile_family="codebuddy" would have required a new template and output writer with no functional benefit. Happy to revisit if maintainers prefer a dedicated CODEBUDDY.md marker.
  • Reuse claude_* primitive formatters. Same justification — CodeBuddy's parser is Claude-Code compatible.
  • Add _KNOWN_TARGETS entry in agents_compiler.py. Because detect_target() now returns "codebuddy" (not "claude"), the compiler's config.target is "codebuddy" when codebuddy is the active target; the existing _KNOWN_TARGETS validation rejects it unless we register it explicitly.
  • Add SIGNAL_WHITELIST entry for .codebuddy/ so apm install without --target auto-detects codebuddy alongside other harnesses.

Why this changed shape vs the earlier revision

An earlier version of this PR (47 lines) registered codebuddy as a pure alias of claude in TARGET_ALIASES. That's the smallest possible patch and makes apm compile -t codebuddy work without errors — but the deploy lands in .claude/, so codebuddy-only projects end up with a .claude/ directory and no .codebuddy/ content beyond what the caller manually places. The first-class registration here is what we ship downstream (Tinnove TAC bundles a patched wheel for our internal users) and produces a coherent .codebuddy/ deploy parallel to other native targets.

Tests

Local smoke (Python REPL against the patched checkout): TARGET_ALIASES does not contain codebuddy (intentional — first-class now, not an alias); CANONICAL_TARGETS / ALL_CANONICAL_TARGETS / CANONICAL_DEPLOY_DIRS / CANONICAL_SIGNAL / SIGNAL_WHITELIST / CANONICAL_TARGETS_ORDERED all contain codebuddy; KNOWN_TARGETS["codebuddy"].root_dir == ".codebuddy" and .compile_family == "claude"; detect_target(explicit_target="codebuddy") returns ("codebuddy", "explicit --target flag"). Two unrelated tests/unit/marketplace/test_schema_conformance.py / tests/unit/test_plugin_exporter_schema.py collection errors from missing optional jsonschema dep on my machine; not affected by this patch.

Happy to add a dedicated tests/test_codebuddy_target.py if maintainers want unit coverage parallel to the existing target tests.

Copilot AI review requested due to automatic review settings May 15, 2026 02:02
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds Tencent CodeBuddy as a claude-compatible target alias so apm compile -t codebuddy can reuse the existing Claude output format without introducing a new compilation target.

Changes:

  • Accept codebuddy in detect_target() for both --target and apm.yml-provided target values, mapping it to the internal claude target.
  • Register codebuddy -> claude in TARGET_ALIASES so the shared target validator accepts it.
  • Add codebuddy to apm.yml schema validation targets to prevent early rejection before aliasing.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/apm_cli/core/target_detection.py Adds codebuddy handling in detection and the alias registry.
src/apm_cli/core/apm_yml.py Extends the YAML target allowlist to accept codebuddy.
Comments suppressed due to low confidence (3)

src/apm_cli/core/target_detection.py:341

  • TARGET_ALIASES now includes codebuddy, which makes it a globally accepted --target/apm.yml value, but the v2 resolver (resolve_targets()) currently returns the raw tokens without alias normalization for single-token inputs. That allows codebuddy to propagate into later phases that expect canonical TargetProfile names (e.g., KNOWN_TARGETS keys). Consider normalizing aliases during resolution (e.g., map tokens via TARGET_ALIASES before returning ResolvedTargets) so aliases never leak past the boundary that promises canonical target names.
#: Alias mapping: user-facing name -> canonical internal name.
TARGET_ALIASES: dict[str, str] = {
    "copilot": "vscode",
    "agents": "vscode",
    "vscode": "vscode",
    # TNV downstream: Tencent CodeBuddy is Claude-Code-compatible (reads
    # root CLAUDE.md, uses .claude/-style hook settings). Register as an
    # alias of claude so `apm compile -t codebuddy` resolves to the same
    # output. Required by TAC's stepApm which passes each --ide value
    # straight to `apm compile -t`.
    "codebuddy": "claude",
}

src/apm_cli/core/target_detection.py:340

  • This PR introduces a new user-facing --target/apm.yml value (codebuddy), but the docs and generated APM guide content still list the older target enums (e.g. docs/src/content/docs/reference/cli/{compile,install,deps,init}.md and packages/apm-guide/.apm/skills/apm-usage/{commands.md,package-authoring.md}), so users will not discover/understand the alias. Please update the relevant docs/resources to include codebuddy (as an alias of claude) to keep documentation in sync with the CLI contract.
    # TNV downstream: Tencent CodeBuddy is Claude-Code-compatible (reads
    # root CLAUDE.md, uses .claude/-style hook settings). Register as an
    # alias of claude so `apm compile -t codebuddy` resolves to the same
    # output. Required by TAC's stepApm which passes each --ide value
    # straight to `apm compile -t`.
    "codebuddy": "claude",

src/apm_cli/core/target_detection.py:129

  • New alias behavior (explicit_target='codebuddy' and config_target='codebuddy' mapping to claude) is not covered by the existing tests/unit/core/test_target_detection.py suite, which already has per-target assertions for the other explicit/config cases. Please add unit tests for codebuddy (and ideally an install-resolution test to ensure --target codebuddy results in the same TargetProfile set as --target claude) to prevent regressions.
    if explicit_target:
        if explicit_target in ("copilot", "vscode", "agents"):
            return "vscode", "explicit --target flag"
        elif explicit_target in ("claude", "codebuddy"):  # TNV downstream: codebuddy -> claude
            return "claude", "explicit --target flag"
        elif explicit_target == "cursor":

Comment on lines 124 to 129
if explicit_target:
if explicit_target in ("copilot", "vscode", "agents"):
return "vscode", "explicit --target flag"
elif explicit_target == "claude":
elif explicit_target in ("claude", "codebuddy"): # TNV downstream: codebuddy -> claude
return "claude", "explicit --target flag"
elif explicit_target == "cursor":
Comment on lines 24 to 36
# Canonical target names accepted by APM.
CANONICAL_TARGETS: frozenset[str] = frozenset(
{
"claude",
"copilot",
"cursor",
"opencode",
"codex",
"gemini",
"windsurf",
"agent-skills",
"codebuddy", # TNV downstream: alias of claude (see target_detection.TARGET_ALIASES)
}
Tencent CodeBuddy IDE is a Claude-Code-compatible AI coding assistant.
It reads CLAUDE.md from the project root and uses .claude/-style
settings.json for hook configuration. This patch registers it as a
first-class target with its own deploy directory (.codebuddy/) so
projects using both Claude Code and CodeBuddy can deploy primitives
to separate directories without collision.

Design:

  * Own deploy dir (root_dir=".codebuddy") so install/compile output
    lands in .codebuddy/agents/, .codebuddy/commands/, .codebuddy/skills/,
    etc. — parallel to .claude/.
  * Reuses claude_* primitive formatters (claude_rules, claude_agent,
    claude_command, skill_standard, claude_hooks) because CodeBuddy
    parses Claude Code's file formats verbatim.
  * compile_family="claude" so root CLAUDE.md is still generated —
    CodeBuddy reads this natively. No new compile family or output
    template needed.

Patch surface (4 files, ~37 net additions):

  src/apm_cli/integration/targets.py
    +22 lines: new KNOWN_TARGETS["codebuddy"] TargetProfile entry

  src/apm_cli/core/target_detection.py
    + TargetType / UserTargetType Literals gain "codebuddy"
    + ALL_CANONICAL_TARGETS frozenset gains "codebuddy"
    + CANONICAL_TARGETS_ORDERED appends "codebuddy" (apm targets row)
    + CANONICAL_DEPLOY_DIRS: "codebuddy": ".codebuddy/"
    + CANONICAL_SIGNAL:      "codebuddy": ".codebuddy/"
    + SIGNAL_WHITELIST: ("codebuddy", "dir", ".codebuddy")
    + detect_target() --target / apm.yml elif chains return "codebuddy"
    + should_compile_claude_md() accepts "codebuddy" (root CLAUDE.md)
    + get_target_description() describes codebuddy output

  src/apm_cli/core/apm_yml.py
    + CANONICAL_TARGETS frozenset gains "codebuddy"

  src/apm_cli/compilation/agents_compiler.py
    + _KNOWN_TARGETS tuple gains "codebuddy" so the compiler's local
      validation accepts config.target == "codebuddy"

Verified locally against upstream main (219af91):

  $ apm targets
    TARGET       STATUS     SOURCE                         DEPLOY DIR
    claude       inactive   needs CLAUDE.md                .claude/
    codebuddy    inactive   needs .codebuddy/              .codebuddy/
    ...

  $ apm install --target codebuddy
    Installed 17 APM dependencies in 15.2s
  $ apm compile -t codebuddy
    [+] Compilation completed successfully!
    [i] Targets: codebuddy  (source: --target flag)
    [i] Compiling for CLAUDE.md + .codebuddy/commands/ +
        .codebuddy/agents/ + .codebuddy/skills/ (Claude-compatible)

End-to-end on a real project: a fresh git repo with `apm install
--target codebuddy` deploys primitives to .codebuddy/agents/,
.codebuddy/commands/, .codebuddy/skills/, .codebuddy/hooks/, and
writes hook config to .codebuddy/settings.json. Root CLAUDE.md is
generated by `apm compile -t codebuddy` exactly like for claude.

Multi-IDE (.claude/ + .codebuddy/ in the same project) deploys
primitives to both directories in parallel with no overlap.

CodeBuddy CLI: https://copilot.tencent.com/codebuddy

Note on prior PR version: an earlier revision of this PR registered
codebuddy as a pure alias of claude (codebuddy → claude in
TARGET_ALIASES). That version was 47 lines. It is functionally
correct for invocation (apm compile -t codebuddy does not error),
but the deploy goes to .claude/ which means codebuddy-only projects
end up with a .claude/ directory and no .codebuddy/ content beyond
what callers manually deploy. The first-class registration here is
the design we use downstream and produces a coherent .codebuddy/
deploy parallel to other native targets.
@xuedizi xuedizi force-pushed the add-codebuddy-target branch from 5b164a3 to 2f62057 Compare May 15, 2026 02:48
@microsoft-github-policy-service
Copy link
Copy Markdown

@xuedizi please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@microsoft-github-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@microsoft-github-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@microsoft-github-policy-service agree company="Microsoft"
Contributor License Agreement

Contribution License Agreement

This Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
and conveys certain license rights to Microsoft Corporation and its affiliates (“Microsoft”) for Your
contributions to Microsoft open source projects. This Agreement is effective as of the latest signature
date below.

  1. Definitions.
    “Code” means the computer software code, whether in human-readable or machine-executable form,
    that is delivered by You to Microsoft under this Agreement.
    “Project” means any of the projects owned or managed by Microsoft and offered under a license
    approved by the Open Source Initiative (www.opensource.org).
    “Submit” is the act of uploading, submitting, transmitting, or distributing code or other content to any
    Project, including but not limited to communication on electronic mailing lists, source code control
    systems, and issue tracking systems that are managed by, or on behalf of, the Project for the purpose of
    discussing and improving that Project, but excluding communication that is conspicuously marked or
    otherwise designated in writing by You as “Not a Submission.”
    “Submission” means the Code and any other copyrightable material Submitted by You, including any
    associated comments and documentation.
  2. Your Submission. You must agree to the terms of this Agreement before making a Submission to any
    Project. This Agreement covers any and all Submissions that You, now or in the future (except as
    described in Section 4 below), Submit to any Project.
  3. Originality of Work. You represent that each of Your Submissions is entirely Your original work.
    Should You wish to Submit materials that are not Your original work, You may Submit them separately
    to the Project if You (a) retain all copyright and license information that was in the materials as You
    received them, (b) in the description accompanying Your Submission, include the phrase “Submission
    containing materials of a third party:” followed by the names of the third party and any licenses or other
    restrictions of which You are aware, and (c) follow any other instructions in the Project’s written
    guidelines concerning Submissions.
  4. Your Employer. References to “employer” in this Agreement include Your employer or anyone else
    for whom You are acting in making Your Submission, e.g. as a contractor, vendor, or agent. If Your
    Submission is made in the course of Your work for an employer or Your employer has intellectual
    property rights in Your Submission by contract or applicable law, You must secure permission from Your
    employer to make the Submission before signing this Agreement. In that case, the term “You” in this
    Agreement will refer to You and the employer collectively. If You change employers in the future and
    desire to Submit additional Submissions for the new employer, then You agree to sign a new Agreement
    and secure permission from the new employer before Submitting those Submissions.
  5. Licenses.
  • Copyright License. You grant Microsoft, and those who receive the Submission directly or
    indirectly from Microsoft, a perpetual, worldwide, non-exclusive, royalty-free, irrevocable license in the
    Submission to reproduce, prepare derivative works of, publicly display, publicly perform, and distribute
    the Submission and such derivative works, and to sublicense any or all of the foregoing rights to third
    parties.
  • Patent License. You grant Microsoft, and those who receive the Submission directly or
    indirectly from Microsoft, a perpetual, worldwide, non-exclusive, royalty-free, irrevocable license under
    Your patent claims that are necessarily infringed by the Submission or the combination of the
    Submission with the Project to which it was Submitted to make, have made, use, offer to sell, sell and
    import or otherwise dispose of the Submission alone or with the Project.
  • Other Rights Reserved. Each party reserves all rights not expressly granted in this Agreement.
    No additional licenses or rights whatsoever (including, without limitation, any implied licenses) are
    granted by implication, exhaustion, estoppel or otherwise.
  1. Representations and Warranties. You represent that You are legally entitled to grant the above
    licenses. You represent that each of Your Submissions is entirely Your original work (except as You may
    have disclosed under Section 3). You represent that You have secured permission from Your employer to
    make the Submission in cases where Your Submission is made in the course of Your work for Your
    employer or Your employer has intellectual property rights in Your Submission by contract or applicable
    law. If You are signing this Agreement on behalf of Your employer, You represent and warrant that You
    have the necessary authority to bind the listed employer to the obligations contained in this Agreement.
    You are not expected to provide support for Your Submission, unless You choose to do so. UNLESS
    REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING, AND EXCEPT FOR THE WARRANTIES
    EXPRESSLY STATED IN SECTIONS 3, 4, AND 6, THE SUBMISSION PROVIDED UNDER THIS AGREEMENT IS
    PROVIDED WITHOUT WARRANTY OF ANY KIND, INCLUDING, BUT NOT LIMITED TO, ANY WARRANTY OF
    NONINFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
  2. Notice to Microsoft. You agree to notify Microsoft in writing of any facts or circumstances of which
    You later become aware that would make Your representations in this Agreement inaccurate in any
    respect.
  3. Information about Submissions. You agree that contributions to Projects and information about
    contributions may be maintained indefinitely and disclosed publicly, including Your name and other
    information that You submit with Your Submission.
  4. Governing Law/Jurisdiction. This Agreement is governed by the laws of the State of Washington, and
    the parties consent to exclusive jurisdiction and venue in the federal courts sitting in King County,
    Washington, unless no federal subject matter jurisdiction exists, in which case the parties consent to
    exclusive jurisdiction and venue in the Superior Court of King County, Washington. The parties waive all
    defenses of lack of personal jurisdiction and forum non-conveniens.
  5. Entire Agreement/Assignment. This Agreement is the entire agreement between the parties, and
    supersedes any and all prior agreements, understandings or communications, written or oral, between
    the parties relating to the subject matter hereof. This Agreement may be assigned by Microsoft.

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.

2 participants