AtomCode Reverse Engineering — Analysis Report
1. Binary Overview
| Property | Value |
|---|---|
| File | atomcode-v4.25.0-linux-x64 |
| Size | 26 MB |
| Type | ELF 64-bit LSB shared object, x86-64, dynamically linked, stripped |
| Language | Rust (with embedded web frontend: Preact/JS) |
| Source repos | atomgit.com/atomgit_atomcode/atomcode |
2. Architecture
┌─────────────────────────────────────────────────────────────┐
│ AtomCode Daemon (localhost:13456) │
│ ┌──────────────────────────────────────────────────────┐ │
│ │ Web UI (embedded JS) ←→ REST API │ │
│ │ CLI (TUI) ←→ WebSocket (SSE stream) │ │
│ └──────────────────────────────────────────────────────┘ │
│ ↕ │
│ ┌──────────────────────────────────────────────────────┐ │
│ │ Auth Layer (AtomGit OAuth) │ │
│ │ Provider Layer (OpenAI/Claude/Ollama/DeepSeek) │ │
│ │ CodingPlan (Quota/Auth management) │ │
│ └──────────────────────────────────────────────────────┘ │
└──────────────┬──────────────────────────────────────────────┘
│
┌──────────┴──────────┐
▼ ▼
llm-api.atomgit.com acs.atomgit.com
(LLM API) (Telemetry)3. API Endpoints
LLM API (AI 能力)
| Endpoint | Purpose |
|---|---|
https://llm-api.atomgit.com/v1 | Main LLM API (OpenAI-compatible) |
https://pre-llm-api-cce.atomgit.com/v1 | Staging/pre-release LLM API |
Auth (本地 daemon 的 REST API)
| Endpoint | Method | Purpose |
|---|---|---|
/auth/status | GET | Check login status |
/auth/login/start | POST | Start OAuth login, returns {url, login_id} |
/auth/login/:login_id/poll | POST | Poll for login completion |
/auth/login/:login_id | DELETE | Cancel login session |
/auth/logout | POST | Logout |
Chat (本地 daemon WebSocket/SSE)
| Endpoint | Method | Purpose |
|---|---|---|
/chat | POST | Send chat message (streaming via SSE) |
/chat/stop | POST | Stop generation |
/chat/active | GET | Active chat status |
Provider Management
| Endpoint | Method | Purpose |
|---|---|---|
/models | GET | List available models |
/providers | GET | List configured providers |
/providers/:name/default | PATCH | Set default provider |
/providers/:name/thinking | PATCH | Configure thinking mode |
/config/reload | POST | Reload config |
CodingPlan
| Endpoint | Method | Purpose |
|---|---|---|
/codingplan/setup | POST | Setup CodingPlan |
https://api.gitcode.com/api/v5/models-v2?plan_type= | GET | Fetch available models for plan |
/coding-plan/claim-v2 | ? | Claim CodingPlan tokens |
Sessions
| Endpoint | Method | Purpose |
|---|---|---|
/projects/:hash/sessions | GET | List sessions |
/projects/:hash/sessions | POST | Create session |
/projects/:hash/sessions/:id | GET | Get session detail |
/projects/:hash/sessions/:id/rename | PATCH | Rename session |
/health | GET | Health check |
/shutdown | POST | Shutdown daemon |
4. Authentication Flow
AtomGit OAuth Flow
- User runs
/loginor clicks "Sign in" - Daemon calls
POST /auth/login/start→ returns{url, login_id, expires_in_seconds} - Browser opens
url(AtomGit OAuth page) - User authorizes → AtomGit redirects with
?token=xxx - Web UI polls
POST /auth/login/:login_id/pollevery 2 seconds - On success, daemon stores the token
- Token is sent as
Authorization: Bearer <token>header
Token Usage
javascript
var Ji = new URLSearchParams(location.search).get('token') ?? '';
function Yi() { return Ji ? { Authorization: 'Bearer ' + Ji } : {}; }Key Data Structures
struct AuthInfo:
- access_token: string
- token_type: string (Bearer)
- expires_in: number
- has_refresh_token: boolean
struct UserInfo:
- name: string
- username: string
- avatar_url: string5. CodingPlan (AI 额度系统)
CodingPlan is the free AI usage quota system. It provides tokens to free users.
- Base URL:
https://api.gitcode.com/api/v5(AtomGit API) - Endpoint:
/models-v2?plan_type=X— fetches models available for the plan - CodingPlan credentials are managed via
ATOMCODE_CODINGPLAN_LLM_BASE_URL - Crypto implementation in:
crates/atomcode-codingplan-crypto/src/versions/v1.rs - Daemon API:
crates/atomcode-daemon/src/api_codingplan.rs
Data structures:
struct PlanInfo:
- plan_name: string
- claimed_at: timestamp
- expires_at: timestamp
- remaining_days: number
- total_days: number
- window_token_limit: number
- window_tokens_used: number
- usage_percent: number
- is_infinity: boolean
- is_atomcode_exclusive: boolean
- display_model_name: string
struct RateLimitWindow:
- window_size_seconds: number
- call_limit: number
- calls_used: number
- quota_exhausted: boolean6. Provider System
The app supports multiple LLM providers:
| Provider | Base URL |
|---|---|
| DeepSeek | https://api.deepseek.com/v1 |
| OpenAI | https://api.openai.com/v1 |
| Claude/Anthropic | https://api.anthropic.com |
| Ollama | (local) |
ProviderConfig (15 fields):
- name, model, base_url, api_key, provider_type (openai/claude/ollama)
- max_tokens, thinking_budget, thinking_type, thinking_keep
- reasoning_history, user_agent, is_default
- skip_tls_verify, clear_api_key, clear_base_url
ChatRequest (5 fields):
- messages, model, stream, max_tokens, ...
Streaming Chunk Types (SSE):
- text, reasoning, tool_start, tool_output, tool_result, tokens, error, done, stopped
7. Embedded Web UI
The binary embeds a full web UI built with a React-like library (Preact):
- Chat interface with streaming
- Sidebar for session management
- Model/provider selector
- Login/logout UI
- Settings (theme, language)
- File attachment support
- Image upload
8. Key Observations for Reverse Proxy
- LLM API is OpenAI-compatible:
llm-api.atomgit.com/v1uses OpenAI API format - Auth tokens come from AtomGit OAuth: After login, a Bearer token is acquired
- CodingPlan provides the actual API access: This is the mechanism that provides AI tokens/credits
- Streaming uses SSE:
text/event-streamwith custom chunk types - Daemon listens on port 13456: Web UI + REST API
9. Files/Paths
| Path | Purpose |
|---|---|
~/.atomcode/ | Home directory |
~/.atomcode/config.toml | Configuration |
~/.atomcode/auth.toml | Auth storage (OAuth tokens) |
~/.atomcode/codingplan_sync.json | CodingPlan sync timestamp |
~/.atomcode/pending_invite | Referral invite |
~/.atomcode/mcp.json | MCP server config |
~/.atomcode/hooks.toml | Hooks config |
~/.atomcode/marketplaces.json | Plugin marketplaces |
~/.atomcode/installed_plugins.json | Installed plugins |
~/.atomcode/telemetry/ | Telemetry data |
~/.atomcode/stderr.log | Daemon stderr log |
~/.atomcode/history | Command history (observed empty) |
~/.atomcode/recent_dirs.txt | Recent working directories |
~/.atomcode/datalog/<project>/llm/<timestamp>.json | Per-LLM-call logs (request+response) |
~/.atomcode/datalog/<project>/llm/calls.log | Aggregated call log |
~/.atomcode/sessions/<project_hash>/<session_id>.json | Per-session full message history |
10. Session Data Model (实测)
Each session file is a complete conversation record:
json
{
"id": "<uuid>",
"name": "<first user message>",
"working_dir": "<cwd when created>",
"created_at": 1781279460,
"updated_at": 1781279467,
"messages": [
{"role": "User", "content": {"Text": "..."}},
{"role": "Assistant", "content": {
"AssistantWithToolCalls": {
"text": "...",
"tool_calls": [],
"reasoning_content": "..."
}
}},
{"role": "Tool", "content": {"ToolResults": [...]}}
]
}11. LLM Call Log Model (实测)
json
{
"context_window": 1000000,
"model": "deepseek-v4-flash",
"session_id": "<uuid>",
"step": 0,
"timestamp": "2026-06-12T15:51:05",
"request": {
"estimated_tokens": 6332,
"message_count": 2,
"messages": [/* full OpenAI-format messages with system prompt injected */],
"tool_count": 0,
"tools": [/* available tool definitions */]
},
"response": {
"duration_ms": 2023,
"reasoning_content": "...",
"text": "...",
"tool_calls": []
}
}The aggregated call log (calls.log) tracks: timestamp model step msgs/Ntok → Nms tools=N [names] text_only
12. Daemon Version & Auto-Update
- Observed versions: v4.25.1 → v4.25.3 (auto-upgraded between sessions)
- Daemon health response includes
binary_hashfor integrity tracking - Config has
auto_update = trueby default - Update mechanism appears to be built into the binary itself
13. Model Detection
The binary contains references to:
deepseek-chat(default model in config template)deepseek-v4-flash(mentioned in user context as CodingPlan)- Claude models via
api.anthropic.com - OpenAI models via
api.openai.com
14. See Also
DEEP_ANALYSIS.md — 补充分析报告,覆盖 daemon 本质、system prompt 注入内容、会话持久化结构、LLM 日志格式、直接调用 llm-api 可行性验证、MCP/插件系统状态、登出行为、未被覆盖的盲区清单等。
逆向命令索引
bash
# 从二进制查看所有覆盖的子系统
strings atomcode.bin.bak | grep "^crates/atomcode" | sort -u
# 统计结构体
strings atomcode.bin.bak | grep -oP 'struct \w+ with \d+ element' | wc -l本报告由持续分析循环生成