Feature Request: Add CodeBuddy CN preset and extensible adapter architecture for emerging AI coding tools
#1,035 opened on Apr 9, 2026
Repository metrics
- Stars
- (2,272 stars)
- PR merge metrics
- (PR metrics pending)
Description
Summary
git-ai checkpoint currently supports 12 presets (claude, codex, continue-cli, cursor, gemini, github-copilot, amp, windsurf, opencode, ai_tab, firebender, mock_ai), but does not support CodeBuddy CN (Tencent's AI coding assistant, a Claude Code-compatible IDE plugin with ~large user base in China). Additionally, the rapid growth of AI coding assistants (Kiro, Trae, Amazon Q, etc.) suggests we need a more extensible approach to adding new agent support.
Problem
Users of CodeBuddy CN (and similar Claude Code-compatible tools) cannot use git-ai for authorship tracking because:
1. No matching preset
There is no codebuddy or codebuddy-cn preset. The claude preset fails to parse CodeBuddy CN's transcript format.
2. Transcript format is different
| Claude Code | CodeBuddy CN | |
|---|---|---|
| Format | Single JSONL file with inline content | index.json (message index) + messages/ subdirectory (individual JSON files per message) |
| Content location | Inline in transcript | Each message stored as messages/{id}.json |
| User prompt field | content[0].text |
message (JSON-encoded string) → parsed → content[0].text |
Claude Code transcript example:
{"type":"user","message":{"role":"user","content":[{"type":"text","text":"Write a function..."}]}}
{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":"I'll help..."}]}}
CodeBuddy CN transcript structure:
{session_id}/
├── index.json # {"messages": [{"id":"...","role":"user","type":"text",...}], "requests": [...]}
└── messages/
├── {id}.json # {"role":"user","message":"<JSON-encoded string>","id":"...","references":[...],"extra":"<JSON>"}
└── ...
The actual user prompt is nested inside: messages/{id}.json → message field (JSON string) → parse → content[0].text.
3. Hook data field cwd is incorrect
CodeBuddy CN sends "cwd": "/" instead of the actual project directory, causing git-ai to fail with:
Failed to find repository: workspace root is not a git repository and no edited files provided
Workaround: extract project root from tool_input.filePath via a wrapper script.
4. Client identification
CodeBuddy CN sends "client": "CodeBuddyIDE" and "model": "glm-5.0-turbo" in hook data, which could be used for agent identification.
Environment Details
git-ai version: 1.2.7
OS: macOS 15.5 (arm64)
CodeBuddy CN version: 4.7.0
Model: glm-5.0-turbo (GLM-5.0-Turbo)
Hook data sample (from CodeBuddy CN)
PreToolUse:
{
"session_id": "929375d78608481096a2e1fb77eb7987",
"transcript_path": "/Users/{user}/Library/Application Support/CodeBuddyExtension/Data/{uuid}/CodeBuddyIDE/{uuid}/history/{uuid}/{session_id}/index.json",
"cwd": "/",
"hook_event_name": "PreToolUse",
"tool_name": "Edit",
"tool_input": {"filePath": "/private/tmp/git-ai-demo/app.py", "new_str": "..."},
"generation_id": "a7eac231ef13499b8e001f0b59295451",
"model": "glm-5.0-turbo",
"client": "CodeBuddyIDE",
"version": "4.7.0"
}
PostToolUse:
{
"session_id": "...",
"transcript_path": "...",
"cwd": "/",
"hook_event_name": "PostToolUse",
"tool_name": "Edit",
"tool_input": {"filePath": "...", "new_str": "..."},
"tool_response": {"type": "replace_in_file_result", "path": "...", "addLineCount": 3, ...},
"generation_id": "...",
"model": "glm-5.0-turbo",
"client": "CodeBuddyIDE",
"version": "4.7.0"
}
Transcript message file (messages/{id}.json):
{
"role": "user",
"message": "{\"role\":\"user\",\"content\":[{\"type\":\"text\",\"text\":\"编写一些3个测试功能,分别完成设计测试提交\"}]}",
"id": "1ce29baa2875490984b9573bfd00b1ae",
"references": [...],
"extra": "{\"requestId\":\"...\",\"modelId\":\"glm-5.0-turbo\",\"sourceContentBlocks\":[{\"type\":\"text\",\"text\":\"编写一些3个测试功能...\"}],\"traceId\":\"...\"}"
}
Proposed Solution
Option A: Add codebuddy preset (minimal)
Add a dedicated preset that:
- Parses CodeBuddy CN's
index.json+messages/directory structure - Extracts prompts from the double-encoded
messagefield - Uses
tool_input.filePathto resolve project root whencwdis/ - Records
client: "CodeBuddyIDE"and model info in commit notes
Option B: Extensible adapter architecture (recommended)
Many Claude Code-compatible tools are emerging (Trae, Kiro, Amazon Q, etc.). Rather than adding presets one-by-one, consider:
- Auto-detection: Use the
clientfield from hook data to auto-select or fallback to the closest adapter - Pluggable transcript parsers: Allow transcript parsing strategies to be configured or extended
- Configurable field mappings: Let users map tool_name / tool_input fields between different agent formats via config
- Fallback chain: e.g., if
codebuddypreset is missing, tryclaudewith a transcript adapter that handles the directory-based format
Other tools that may benefit
These tools are gaining traction and may have similar Claude Code-compatible hook formats:
| Tool | Vendor | Notes |
|---|---|---|
| Trae | ByteDance | Claude Code-compatible, VS Code fork |
| Kiro | AWS | Spec-oriented AI IDE |
| Amazon Q Developer | AWS | VS Code / JetBrains extension |
| VOID | Alibaba | Chinese market AI coding assistant |
| Windsurf (Codeium) | Codeium | Already has preset, but may need updates |
Temporary Workaround
Until this is supported, CodeBuddy CN users can use a wrapper script that:
- Reads hook stdin from CodeBuddy CN
- Fixes the
cwdfield (extracts project root fromtool_input.filePath) - Converts transcript path to a format git-ai can parse
- Pipes to
git-ai checkpoint claude --hook-input stdin
#!/bin/bash
# /Users/{user}/.git-ai/bin/git-ai-checkpoint-wrapper.sh
INPUT=$(cat)
FIXED=$(echo "$INPUT" | python3 -c "
import json, sys, os, subprocess
data = json.loads(sys.stdin.read())
# Fix cwd
project_dir = os.environ.get('CODEBUDDY_PROJECT_DIR', '')
if not project_dir:
tool_input = data.get('tool_input', {})
file_path = tool_input.get('filePath', '')
if file_path:
d = os.path.dirname(file_path)
while d and d != '/':
if os.path.isdir(os.path.join(d, '.git')):
project_dir = d
break
d = os.path.dirname(d)
data['cwd'] = project_dir or os.getcwd()
print(json.dumps(data))
")
echo "$FIXED" | /path/to/git-ai checkpoint claude --hook-input stdin
References
- CodeBuddy CN: https://www.codebuddy.cn/
- CodeBuddy CN Hooks Docs: https://www.codebuddy.cn/docs/ide/Features/Hooks
- Related Claude Code compatibility issues: CodeBuddy CN docs claim full Claude Code hook compatibility, but
matcher: "*"doesn't work (requires".*") and transcript format differs