AtomCode 工具定义与数据模型完整分析
基于二进制字符串提取、datalog 分析和源代码路径推断 2026-06-22
1. 完整工具清单(25 个工具)
通过二进制中 Rust 源码路径提取:
| 源码路径 | 工具名 | 功能 |
|---|---|---|
src/tool/bash.rs | bash | 执行 shell 命令 |
src/tool/read.rs | read_file | 读取文件内容 |
src/tool/write.rs | write_file | 创建/覆写文件 |
src/tool/edit.rs | edit_file | 编辑文件(行替换) |
src/tool/search_replace.rs | search_replace | 搜索替换文本 |
src/tool/glob.rs | glob | 通配符文件搜索 |
src/tool/grep.rs | grep | 文本内容搜索 |
src/tool/list_dir.rs | list_directory | 列出目录 |
src/tool/open_file.rs | open_file | 在编辑器中打开文件(IDE集成) |
src/tool/parallel_edit.rs | parallel_edit | 并行编辑多个文件(上限12) |
src/tool/file_deps.rs | file_deps | 文件依赖分析 |
src/tool/file_history.rs | file_history | 文件修改历史 |
src/tool/auto_fix.rs | auto_fix | 自动修复(lint/编译) |
src/tool/blast_radius.rs | blast_radius | 变更影响范围分析 |
src/tool/diagnostics.rs | diagnostics | 诊断分析 |
src/tool/todo.rs | todo | TODO 管理 |
src/tool/trace_callees.rs | trace_callees | 函数调用者追踪 |
src/tool/trace_callers.rs | trace_callers | 函数被调用追踪 |
src/tool/trace_chain.rs | trace_chain | 调用链追踪 |
src/tool/cd.rs | cd | 切换工作目录 |
src/tool/use_skill.rs | use_skill | 调用内置技能 |
src/tool/web_search.rs | web_search | 网络搜索 |
src/tool/web_fetch.rs | web_fetch | 网页抓取 |
src/tool/mod.rs | — | 工具模块注册 |
2. 工具参数结构体
Bash (BashArgs, 3 个字段)
struct BashArgs with 3 elementsReadFile (ReadFileArgs, 3 个字段)
struct ReadFileArgs with 3 elementsWriteFile (WriteFileArgs, 2 个字段)
struct WriteFileArgs with 2 elementsEditFile (EditFileArgs, 8 个字段)
struct EditFileArgs with 8 elementsSearchReplace (SearchReplaceArgs, 5 个字段)
struct SearchReplaceArgs with 5 elementsGlob (GlobArgs, 2 个字段)
struct GlobArgs with 2 elementsGrep (GrepArgs, 4 个字段)
struct GrepArgs with 4 elementsListDir (ListDirArgs, 2 个字段)
struct ListDirArgs with 2 elementsParallelEdit (ParallelEditArgs, 2 个字段 + ParallelEditFile, 2 个字段)
struct ParallelEditArgs with 2 elements
struct ParallelEditFile with 2 elementsWebFetch (WebFetchArgs, 3 个字段)
struct WebFetchArgs with 3 elementsWebSearch (WebSearchArgs, 2 个字段)
struct WebSearchArgs with 2 elementsTraceCallees (TraceCalleesArgs, 2 个字段)
struct TraceCalleesArgs with 2 elementsTraceCallers (TraceCallersArgs, 2 个字段)
struct TraceCallersArgs with 2 elementsTraceChain (TraceChainArgs, 2 个字段)
struct TraceChainArgs with 2 elementsTodo (TodoArgs, 4 个字段)
struct TodoArgs with 4 elementsUseSkill (UseSkillArgs, 2 个字段)
struct UseSkillArgs with 2 elementsOpenFile (OpenFileArgs, 1 个字段)
struct OpenFileArgs with 1 elementsFileDeps (FileDepsArgs, 1 个字段)
struct FileDepsArgs with 1 elements3. 核心数据模型(完整结构体定义)
Chat 相关
struct ChatRequest with 5 elements
→ message, stream, provider, system, session_id
struct ChatChunk with 2 elements
→ type, content (SSE event)
struct ChunkChoice with 2 elements
struct ChunkDelta with 3 elements
struct ChunkUsage with 5 elements
struct DeltaToolCall with 3 elements
struct DeltaFunction with 2 elements
struct ChatCompletionResponse with 2 elements
struct ResponseChoice with 2 elements
struct ResponseMessage with 2 elements
struct ToolCall with 3 elements
struct ToolResult with 3 elements
struct ToolResultRef with 5 elements消息内容模型
enum MessageContent:
- Text(String)
- AssistantWithToolCalls { text, tool_calls, reasoning_content, thinking_blocks }
- MultiPart { parts: Vec<ContentBlock> }
- ToolResult(Vec<ToolResultRef>)
- ToolCall(Vec<ToolCall>)
struct ContentBlock with 3 elements:
- Text { text: String }
- Image { media_type, data: Base64 }
- Resource { uri, resource }
struct ThinkingBlock with 2 elements
struct ThinkingBlock with 2 elements认证模型
struct AuthInfo with 6 elements
→ access_token, token_type, expires_in, created_at, has_refresh_token, refresh_token
struct UserInfo with 5 elements
→ id, username, name, email, avatar_url
struct StoredAuth with 4 elements
→ access_token, refresh_token, token_type, expires_in (auth.toml 磁盘格式)
struct PlatformTokenResponse with 5 elements
struct PlatformUserInfo with 5 elements
struct PlatformLoginResponse with 2 elements
struct PlatformCheckResponse with 1 element
struct RefreshedAuth with 5 elements
struct RefreshedUser with 5 elementsCodingPlan 模型
struct ClaimResponse with 3 elements
→ success, duplicate, message
struct PlanInfo (无 struct 标签,但字段已知):
→ plan_name, plan_type, status, claimed_at, expires_at, remaining_days, total_days
→ window_token_limit, window_tokens_used, usage_percent, is_infinity
→ is_atomcode_exclusive, display_model_name
struct RateLimitWindow:
→ window_size_seconds, window_hours, call_limit, calls_used
→ usage_percent, quota_exhausted, reset_at, seconds_until_resetProvider 模型
struct ProviderConfig with 15 elements
→ name, type, model, base_url, api_key, context_window, max_tokens
→ is_default, thinking_enabled, thinking_budget, thinking_type, thinking_keep
→ reasoning_history, reasoning_effort, skip_tls_verify
struct CreateProviderRequest with 16 elements
→ 15 个 ProviderConfig 字段 + ephemeral
struct PatchProviderRequest with 19 elements
struct PatchThinkingRequest with 6 elements会话模型
struct Session with 8 elements
→ id, name, working_dir, created_at, updated_at, messages, turn_stats, cold_summaries
struct Message with 3 elements
→ role (User/Assistant/Tool), content
struct TurnStat with 6 elements
→ turn_count, tool_call_count, total_tokens, errored, ...
struct StopChatRequest with 1 element配置模型
struct Config with 14 elements
→ default_provider, providers, ui, plugin, datalog, hooks, lsp
→ notifications, subagent, auto_update, auto_commit, ...
struct SetupState with 5 elements
struct ScriptHookConfig with 7 elements
struct CCHookSpec with 3 elements
→ event, command, timeout_ms
struct CCHookGroup with 2 elementsMCP 模型
struct McpToolDefinition with 3 elements
→ name, description, input_schema
struct McpOAuthToken with 11 elements
→ access_token, refresh_token, token_type, expires_in, scopes, ...
struct AuthorizationServerMetadata with 5 elements
→ authorization_endpoint, token_endpoint, ...
struct ClientRegistrationResponse with 2 elements
struct ToolResultRef with 5 elements
struct ListToolsResult with 1 element插件模型
struct PluginEntry with 3 elements
struct PluginManifest (无 struct 标签)
struct InstalledPluginEntry with 5 elements
struct InstalledPluginsFile with 2 elements
struct MarketplaceEntry with 4 elements
struct MarketplaceManifest with 2 elements
struct MarketplacesFile with 2 elements4. 对话流数据类型
SSE 事件中的 tool_calls 字段:
- tool_calls: [{ tool_call_id, image_uri }]
助手回复消息体 (AssistantWithToolCalls):
- text: String
- tool_calls: Vec<ToolCall>
- reasoning_content: Option<String>
- thinking_blocks: Option<Vec<ThinkingBlock>>
工具调用格式 (OpenAI function calling):
- tool_call_id
- name
- arguments (JSON string)
工具执行结果:
- id, name, output, success, duration_ms5. 模型等级与套餐限制
二进制中找到字符串 % (requires Pro plan or higher),存在于提示消息中。
| 套餐 | 模型访问 | 状态 |
|---|---|---|
| Lite | deepseek-v4-flash, Qwen3-VL-8B-Instruct | ✅ 当前可用 |
| Pro | 高级模型(含 GLM-5.1 等) | ❌ Pro 套餐尚未开放,敬请期待 |
| Basic/Premium/Plus/Enterprise/Team | 不存在 | ❌ 参数错误 |
6. MCP 集成
MCP 工具定义:
struct McpToolDefinition with 3 elements
- name: String
- description: String
- input_schema: JSON Schema Object
MCP 服务器类型:
- stdio (本地进程)
- HTTP (远程服务器)
- OAuth (GitHub MCP)6. 语言支持
二进制中提取的语言代码:
| 代码 | 语言 |
|---|---|
en | 英语 |
zh-cn, zh_cn, chinese | 简体中文 |
zh-tw, zh_hk | 繁体中文 |
config.toml 中 theme = "auto",语言默认自动检测。
7. CodingPlan Crypto 层线索
二进制中引用的源码路径:
crates/atomcode-codingplan-crypto/src/versions/v1.rs加密相关的结构体名称包含 sign、token、hash 等。没有发现具体算法名称(AES/RSA/SHA 等)被硬编码在字符串中,说明加密逻辑在 Rust 编译时已经被优化掉了。
相关结构体:
struct TokenResponse with 5 elements
struct RefreshedAuth with 5 elements8. 所有已知结构体索引(按元素数排序)
| 结构体 | 元素数 |
|---|---|
| OpenFileArgs | 1 |
| FileDepsArgs | 1 |
| FsMkdirRequest | 1 |
| UseSkillArgs | 2 |
| WebSearchArgs | 2 |
| WebFetchArgs | 3 |
| GlobArgs | 2 |
| ListDirArgs | 2 |
| RenameRequest | 1 |
| WriteFileArgs | 2 |
| BashArgs | 3 |
| ReadFileArgs | 3 |
| ToolCall | 3 |
| ToolResult | 3 |
| GrepArgs | 4 |
| TodoArgs | 4 |
| EditFileArgs | 8 |
| ChatRequest | 5 |
| ChatChunk | 2 |
| Session | 8 |
| AuthInfo | 6 |
| UserInfo | 5 |
| ProviderConfig | 15 |
| Config | 14 |
| McpOAuthToken | 11 |
逆向命令索引
bash
# 提取所有工具参数结构体
strings atomcode.bin.bak | grep -oP 'struct \w+Args with \d+ element' | sort -u
# 输出: 22 个结构体 (ReadFileArgs, WriteFileArgs, BashArgs, EditFileArgs 等)
# 提取工具源文件
strings atomcode.bin.bak | grep "^crates/atomcode-core/src/tool/" | sort -u | wc -l
# 输出: 26
# 禁用工具机制
strings atomcode.bin.bak | grep -E "disable.*tools|DISABLE_TOOLS" | sort -u