Skip to content

AtomCode 工具定义与数据模型完整分析

基于二进制字符串提取、datalog 分析和源代码路径推断 2026-06-22


1. 完整工具清单(25 个工具)

通过二进制中 Rust 源码路径提取:

源码路径工具名功能
src/tool/bash.rsbash执行 shell 命令
src/tool/read.rsread_file读取文件内容
src/tool/write.rswrite_file创建/覆写文件
src/tool/edit.rsedit_file编辑文件(行替换)
src/tool/search_replace.rssearch_replace搜索替换文本
src/tool/glob.rsglob通配符文件搜索
src/tool/grep.rsgrep文本内容搜索
src/tool/list_dir.rslist_directory列出目录
src/tool/open_file.rsopen_file在编辑器中打开文件(IDE集成)
src/tool/parallel_edit.rsparallel_edit并行编辑多个文件(上限12)
src/tool/file_deps.rsfile_deps文件依赖分析
src/tool/file_history.rsfile_history文件修改历史
src/tool/auto_fix.rsauto_fix自动修复(lint/编译)
src/tool/blast_radius.rsblast_radius变更影响范围分析
src/tool/diagnostics.rsdiagnostics诊断分析
src/tool/todo.rstodoTODO 管理
src/tool/trace_callees.rstrace_callees函数调用者追踪
src/tool/trace_callers.rstrace_callers函数被调用追踪
src/tool/trace_chain.rstrace_chain调用链追踪
src/tool/cd.rscd切换工作目录
src/tool/use_skill.rsuse_skill调用内置技能
src/tool/web_search.rsweb_search网络搜索
src/tool/web_fetch.rsweb_fetch网页抓取
src/tool/mod.rs工具模块注册

2. 工具参数结构体

Bash (BashArgs, 3 个字段)

struct BashArgs with 3 elements

ReadFile (ReadFileArgs, 3 个字段)

struct ReadFileArgs with 3 elements

WriteFile (WriteFileArgs, 2 个字段)

struct WriteFileArgs with 2 elements

EditFile (EditFileArgs, 8 个字段)

struct EditFileArgs with 8 elements

SearchReplace (SearchReplaceArgs, 5 个字段)

struct SearchReplaceArgs with 5 elements

Glob (GlobArgs, 2 个字段)

struct GlobArgs with 2 elements

Grep (GrepArgs, 4 个字段)

struct GrepArgs with 4 elements

ListDir (ListDirArgs, 2 个字段)

struct ListDirArgs with 2 elements

ParallelEdit (ParallelEditArgs, 2 个字段 + ParallelEditFile, 2 个字段)

struct ParallelEditArgs with 2 elements
struct ParallelEditFile with 2 elements

WebFetch (WebFetchArgs, 3 个字段)

struct WebFetchArgs with 3 elements

WebSearch (WebSearchArgs, 2 个字段)

struct WebSearchArgs with 2 elements

TraceCallees (TraceCalleesArgs, 2 个字段)

struct TraceCalleesArgs with 2 elements

TraceCallers (TraceCallersArgs, 2 个字段)

struct TraceCallersArgs with 2 elements

TraceChain (TraceChainArgs, 2 个字段)

struct TraceChainArgs with 2 elements

Todo (TodoArgs, 4 个字段)

struct TodoArgs with 4 elements

UseSkill (UseSkillArgs, 2 个字段)

struct UseSkillArgs with 2 elements

OpenFile (OpenFileArgs, 1 个字段)

struct OpenFileArgs with 1 elements

FileDeps (FileDepsArgs, 1 个字段)

struct FileDepsArgs with 1 elements

3. 核心数据模型(完整结构体定义)

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 elements

CodingPlan 模型

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_reset

Provider 模型

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 elements

MCP 模型

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 elements

4. 对话流数据类型

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_ms

5. 模型等级与套餐限制

二进制中找到字符串 % (requires Pro plan or higher),存在于提示消息中。

套餐模型访问状态
Litedeepseek-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.tomltheme = "auto",语言默认自动检测。


7. CodingPlan Crypto 层线索

二进制中引用的源码路径:

crates/atomcode-codingplan-crypto/src/versions/v1.rs

加密相关的结构体名称包含 signtokenhash 等。没有发现具体算法名称(AES/RSA/SHA 等)被硬编码在字符串中,说明加密逻辑在 Rust 编译时已经被优化掉了。

相关结构体:

struct TokenResponse with 5 elements
struct RefreshedAuth with 5 elements

8. 所有已知结构体索引(按元素数排序)

结构体元素数
OpenFileArgs1
FileDepsArgs1
FsMkdirRequest1
UseSkillArgs2
WebSearchArgs2
WebFetchArgs3
GlobArgs2
ListDirArgs2
RenameRequest1
WriteFileArgs2
BashArgs3
ReadFileArgs3
ToolCall3
ToolResult3
GrepArgs4
TodoArgs4
EditFileArgs8
ChatRequest5
ChatChunk2
Session8
AuthInfo6
UserInfo5
ProviderConfig15
Config14
McpOAuthToken11

逆向命令索引

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

基于 VitePress 构建 · AtomCode v4.25.3 逆向工程分析文档