ata-coder 2.4.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. ata_coder/__init__.py +1 -0
  2. ata_coder/agent.py +874 -0
  3. ata_coder/agent_compact.py +190 -0
  4. ata_coder/agent_controller.py +218 -0
  5. ata_coder/agent_extension.py +69 -0
  6. ata_coder/agent_routing.py +105 -0
  7. ata_coder/agent_subsystems.py +72 -0
  8. ata_coder/agent_tools.py +318 -0
  9. ata_coder/agent_undo.py +63 -0
  10. ata_coder/anthropic_client.py +465 -0
  11. ata_coder/change_tracker.py +368 -0
  12. ata_coder/clawd_integration.py +574 -0
  13. ata_coder/commands/__init__.py +128 -0
  14. ata_coder/commands/_core.py +184 -0
  15. ata_coder/commands/_safety.py +95 -0
  16. ata_coder/commands/_settings.py +241 -0
  17. ata_coder/commands/_workflow.py +451 -0
  18. ata_coder/commands.py +974 -0
  19. ata_coder/config.py +257 -0
  20. ata_coder/core/__init__.py +35 -0
  21. ata_coder/core/events.py +73 -0
  22. ata_coder/core/queue.py +85 -0
  23. ata_coder/core/state.py +17 -0
  24. ata_coder/event_queue.py +5 -0
  25. ata_coder/extension.py +654 -0
  26. ata_coder/extensions/__init__.py +1 -0
  27. ata_coder/extensions/hello_skill.py +47 -0
  28. ata_coder/fool_proof.py +295 -0
  29. ata_coder/git_workflow.py +371 -0
  30. ata_coder/gui.py +511 -0
  31. ata_coder/llm_client.py +543 -0
  32. ata_coder/main.py +814 -0
  33. ata_coder/mcp_client.py +1095 -0
  34. ata_coder/memory.py +539 -0
  35. ata_coder/model_registry.py +134 -0
  36. ata_coder/model_router.py +105 -0
  37. ata_coder/permissions.py +274 -0
  38. ata_coder/privilege.py +464 -0
  39. ata_coder/project.py +273 -0
  40. ata_coder/prompt_template.py +423 -0
  41. ata_coder/prompts/auto-mode.md +7 -0
  42. ata_coder/prompts/coding-rules.md +40 -0
  43. ata_coder/prompts/execution-guardrails.md +14 -0
  44. ata_coder/prompts/memory-system.md +24 -0
  45. ata_coder/prompts/output-style.md +23 -0
  46. ata_coder/prompts/safety.md +17 -0
  47. ata_coder/prompts/slash-commands.md +24 -0
  48. ata_coder/prompts/sub-agents.md +38 -0
  49. ata_coder/prompts/system-reminders.md +17 -0
  50. ata_coder/prompts/system.md +105 -0
  51. ata_coder/prompts/tool-policy.md +46 -0
  52. ata_coder/repl_theme.py +99 -0
  53. ata_coder/repl_tracker.py +89 -0
  54. ata_coder/repl_ui.py +1214 -0
  55. ata_coder/safety_guard.py +434 -0
  56. ata_coder/self_correct.py +346 -0
  57. ata_coder/server.py +882 -0
  58. ata_coder/server_session.py +159 -0
  59. ata_coder/server_shell.py +129 -0
  60. ata_coder/session.py +431 -0
  61. ata_coder/settings.py +439 -0
  62. ata_coder/setup_wizard.py +136 -0
  63. ata_coder/skill_extension.py +92 -0
  64. ata_coder/skills/architect/SKILL.md +42 -0
  65. ata_coder/skills/code-reviewer/SKILL.md +37 -0
  66. ata_coder/skills/codecraft/SKILL.md +452 -0
  67. ata_coder/skills/debugger/SKILL.md +45 -0
  68. ata_coder/skills/doc-writer/SKILL.md +36 -0
  69. ata_coder/skills/general-coder/SKILL.md +76 -0
  70. ata_coder/skills/math-calculator/README.md +40 -0
  71. ata_coder/skills/math-calculator/SKILL.md +59 -0
  72. ata_coder/skills/math-calculator/handler.py +103 -0
  73. ata_coder/skills/math-calculator/prompts/system.md +8 -0
  74. ata_coder/skills/math-calculator/requirements.txt +2 -0
  75. ata_coder/skills/math-calculator/resources/constants.json +8 -0
  76. ata_coder/skills/math-calculator/tests/test_handler.py +53 -0
  77. ata_coder/skills/security-auditor/SKILL.md +40 -0
  78. ata_coder/skills/test-writer/SKILL.md +36 -0
  79. ata_coder/skills/weather-skill/README.md +45 -0
  80. ata_coder/skills/weather-skill/handler.py +76 -0
  81. ata_coder/skills/weather-skill/manifest.json +48 -0
  82. ata_coder/skills/weather-skill/prompts/system_prompt.txt +9 -0
  83. ata_coder/skills/weather-skill/prompts/user_prompt_template.txt +3 -0
  84. ata_coder/skills/weather-skill/requirements.txt +1 -0
  85. ata_coder/skills/weather-skill/resources/city_list.json +17 -0
  86. ata_coder/skills/weather-skill/resources/error_messages.json +7 -0
  87. ata_coder/skills/weather-skill/tests/test_handler.py +28 -0
  88. ata_coder/skills/weather-skill/weather_utils.py +50 -0
  89. ata_coder/skills.py +1014 -0
  90. ata_coder/sub_agent.py +273 -0
  91. ata_coder/sub_agent_manager.py +203 -0
  92. ata_coder/system_prompt_builder.py +146 -0
  93. ata_coder/task_planner.py +391 -0
  94. ata_coder/terminal.py +318 -0
  95. ata_coder/test_runner.py +219 -0
  96. ata_coder/thread_supervisor.py +195 -0
  97. ata_coder/tool_defs.py +335 -0
  98. ata_coder/tools/__init__.py +11 -0
  99. ata_coder/tools/definitions.py +335 -0
  100. ata_coder/tools/executor.py +1036 -0
  101. ata_coder/tools/result.py +26 -0
  102. ata_coder/tools/subagent.py +332 -0
  103. ata_coder/tools/web.py +361 -0
  104. ata_coder/tools.py +1576 -0
  105. ata_coder/types.py +92 -0
  106. ata_coder/utils.py +113 -0
  107. ata_coder/web/css/style.css +180 -0
  108. ata_coder/web/index.html +84 -0
  109. ata_coder/web/js/app.js +489 -0
  110. ata_coder/web/package-lock.json +25 -0
  111. ata_coder/web/package.json +10 -0
  112. ata_coder/web/tsconfig.json +13 -0
  113. ata_coder-2.4.2.dist-info/METADATA +799 -0
  114. ata_coder-2.4.2.dist-info/RECORD +118 -0
  115. ata_coder-2.4.2.dist-info/WHEEL +5 -0
  116. ata_coder-2.4.2.dist-info/entry_points.txt +2 -0
  117. ata_coder-2.4.2.dist-info/licenses/LICENSE +21 -0
  118. ata_coder-2.4.2.dist-info/top_level.txt +1 -0
@@ -0,0 +1,799 @@
1
+ Metadata-Version: 2.4
2
+ Name: ata-coder
3
+ Version: 2.4.2
4
+ Summary: ATA Coder — AI-powered coding assistant
5
+ Author: ATA Coder Team
6
+ License-Expression: MIT
7
+ Requires-Python: >=3.10
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Requires-Dist: click>=8.0
11
+ Requires-Dist: httpx>=0.27.0
12
+ Requires-Dist: colorama>=0.4.6
13
+ Requires-Dist: python-dotenv>=1.0.0
14
+ Requires-Dist: rich>=13.0.0
15
+ Requires-Dist: pyyaml>=6.0
16
+ Requires-Dist: prompt-toolkit>=3.0
17
+ Provides-Extra: dev
18
+ Requires-Dist: pytest>=8.0; extra == "dev"
19
+ Requires-Dist: pytest-asyncio>=0.21; extra == "dev"
20
+ Requires-Dist: pytest-timeout>=2.0; extra == "dev"
21
+ Requires-Dist: tiktoken>=0.5.0; extra == "dev"
22
+ Dynamic: license-file
23
+
24
+ # ATA Coder v2.4.2
25
+
26
+ **AI-powered coding assistant — async, AST-aware, single config file.**
27
+
28
+ [English](#english) | [中文](#中文)
29
+
30
+ > **v2.4.2** — 🐾 **Clawd working state + Window tokens**: Clawd shows 'working' immediately. Status line shows window tokens (~120k) not cumulative (7.8M). Surrogate-safe session saves.
31
+ >
32
+ > > **v2.4.1** — 🗂️ **3-Part Session IDs + /resume**: Session ID: `xxxxxxxx-xxxxxxxx-xxxxxxxx` (workspace·timestamp·task). `/resume` lists sessions for current project folder. Resume by any 8-char hash.
33
+ >
34
+ > > **v2.4.0** — 💾 **Auto-Save Sessions**: Every conversation auto-saved to `~/.ata_coder/sessions/`. Hash-based session IDs. Resume by hash: `ata --resume xxxxxxxx`. Round 9 self-repair.
35
+ >
36
+ > > **v2.3.11** — ⚡ **Self-Bootstrapped Streaming + Crash Fixes**: 15 bugs found and fixed by **ATA Coder auditing its own source code** — round 7.5. Real-time shell/web output, full command display, subprocess hang fixes, surrogate crash fix.
37
+ >
38
+ > > **v2.3.10** — 🐛 **Self-Bootstrapped Bug Hunt**: 25 bugs found, 18 fixed by ATA Coder scanning its own source code. Semaphore leak, command injection, missing import, memory leak — round 7 of closed-loop self-repair.
39
+
40
+ > **v2.3.6** — 🧹 Code Quality Audit: version sync, CI/CD, ruff/mypy config.
41
+ > **v2.3.5** — 🤖 Security Audit v2: 23 findings, 20 fixed. Auth, shell/RCE, CORS.
42
+ > **v2.3.4** — 🤖 First self-bootstrapped audit.
43
+
44
+ ---
45
+
46
+ ## English
47
+
48
+ ### Overview
49
+
50
+ ATA Coder is a CLI AI coding assistant compatible with OpenAI and Anthropic APIs. It runs on a **single-threaded asyncio event loop** — no threads, no race conditions, low memory. Features deterministic AST-based code editing, sub-agent pool, MCP support, and a built-in HTTP API server.
51
+
52
+ ### Architecture (v2.3.3)
53
+
54
+ ```
55
+ asyncio Event Loop (single-threaded)
56
+ ├── REPL (prompt_toolkit + Rich)
57
+ │ await controller.submit(task)
58
+ │ await event_queue.drain() → ui.on_event()
59
+
60
+ ├── AgentController (asyncio.Task)
61
+ │ CoderAgent.run() → async LLM loop → await tool calls
62
+ │ BaseLLMClient (ABC) — unified OpenAI/Anthropic async interface
63
+ │ ExtensionManager → skill prompt aggregation
64
+ │ Keyword-based task classification (zero extra API calls)
65
+
66
+ ├── Sub-Agent Tasks (asyncio.TaskGroup)
67
+ │ SubAgent 1..N: independent LLM, tools, context
68
+ │ asyncio.Semaphore → concurrency limit
69
+
70
+ └── MCP Clients (asyncio subprocess)
71
+ StdioConnection → create_subprocess_exec + async read loop
72
+ HTTPConnection → httpx.AsyncClient
73
+ ```
74
+
75
+ ### Key Features
76
+
77
+ | Feature | Description |
78
+ |---------|-------------|
79
+ | **Async Event Loop** | Single-threaded asyncio — zero race conditions, no thread overhead |
80
+ | **AST Code Editing** | libcst-based deterministic edits for Python, preserves all formatting |
81
+ | **Safe Rename** | `rename_symbol` tool — renames definitions + references, skips strings/comments |
82
+ | **Sub-Agent Pool** | Parallel sub-agents with isolated context, asyncio.Semaphore bounded |
83
+ | **Skill System** | Keyword-based auto-detection, single-skill activation for clean prompts |
84
+ | **MCP Support** | Model Context Protocol — cross-tool interoperability via stdio/HTTP |
85
+ | **Multimodal Vision** | `analyze_image` tool — vision model auto-falls back to main API config |
86
+ | **Diff Preview** | Colorized unified diff before file edits — green/red lines in terminal |
87
+ | **Session Persistence** | Save / resume / export conversation history by workspace |
88
+ | **Safety Pipeline** | Fool-proof validation → permissions → privilege → self-correction |
89
+ | **HTTP API Server** | SSE streaming, shell sessions, multi-session management |
90
+ | **One Dark Pro Theme** | Rich syntax highlighting for code blocks |
91
+ | **Web GUI** | SPA with SSE streaming, markdown, sidebar, command popup |
92
+
93
+ ### Quick Start
94
+
95
+ ```bash
96
+ pip install -e .
97
+ ata # Interactive REPL
98
+ ata run "Add type hints" # Single task
99
+ ata server --port 8080 # HTTP API server
100
+ ata --skill debugger # With specific skill
101
+ ata --resume <session-id> # Resume saved session
102
+ ```
103
+
104
+ ### Project Structure
105
+
106
+ ```
107
+ ata_coder/
108
+ ├── main.py # CLI entry point (click) + asyncio.run()
109
+ ├── agent.py # Core agent: async run loop + tool execution
110
+ ├── agent_controller.py # asyncio.Task-based orchestrator
111
+ ├── agent_subsystems.py # Subsystem container dataclass
112
+ ├── core/ # Extracted from agent.py
113
+ │ ├── events.py # AgentEvent dataclasses
114
+ │ └── state.py # AgentState dataclass
115
+ ├── tools.py # 15 built-in tools (incl. rename_symbol, analyze_image)
116
+ ├── llm_client.py # OpenAI-compatible async client (httpx.AsyncClient)
117
+ ├── anthropic_client.py # Anthropic Messages API async client
118
+ ├── skills.py # Folder-based skill manager
119
+ ├── skill_extension.py # Skill → Extension adapter
120
+ ├── extension.py # Plugin/extension system
121
+ ├── sub_agent.py # asyncio.Task-based sub-agent
122
+ ├── sub_agent_manager.py # asyncio.Semaphore-bounded pool
123
+ ├── event_queue.py # asyncio.Queue-based event bus
124
+ ├── mcp_client.py # Async MCP (stdio + HTTP/SSE)
125
+ ├── memory.py # Persistent file-based memory
126
+ ├── session.py # Session save/load/search
127
+ ├── change_tracker.py # File change undo/redo
128
+ ├── safety_guard.py # Pattern-based risk analysis
129
+ ├── fool_proof.py # Unified pre-execution safety check
130
+ ├── permissions.py # Interactive allow/deny rules
131
+ ├── privilege.py # OS-aware privilege elevation
132
+ ├── config.py # Runtime config (reads settings.json only)
133
+ ├── settings.py # ~/.ata_coder/settings.json persistence
134
+ ├── self_correct.py # Error diagnosis + auto-fix (8 patterns)
135
+ ├── system_prompt_builder.py
136
+ ├── model_registry.py # Model metadata + pricing
137
+ ├── model_router.py # Keyword-based complexity classification
138
+ ├── commands.py # Slash command registry (~40 commands)
139
+ ├── repl_ui.py # Rich/prompt-toolkit REPL + diff preview
140
+ ├── server.py # HTTP API server + SSE streaming
141
+ ├── utils.py # Shared utilities + API error helper
142
+ ├── prompt_template.py # {% if %} templating
143
+ ├── task_planner.py # Task decomposition
144
+ ├── git_workflow.py # Git integration
145
+ ├── project.py # Project auto-detection
146
+ ├── skills/ # Built-in skill folders
147
+ ├── extensions/ # Plugin directory
148
+ ├── examples/ # Usage examples
149
+ ├── tests/ # pytest suite
150
+ └── README.md
151
+ ```
152
+
153
+ ### Configuration
154
+
155
+ **settings.json is the single source of truth.** All config lives in `~/.ata_coder/settings.json`:
156
+
157
+ ```json
158
+ {
159
+ "env": {
160
+ "ATA_CODER_BASE_URL": "https://api.deepseek.com",
161
+ "ATA_CODER_API_KEY": "sk-...",
162
+ "ATA_CODER_DEFAULT_MODEL": "deepseek-v4-pro",
163
+ "ATA_CODER_DEFAULT_OPUS_MODEL": "deepseek-v4-pro",
164
+ "ATA_CODER_DEFAULT_SONNET_MODEL": "deepseek-v4-pro",
165
+ "ATA_CODER_DEFAULT_HAIKU_MODEL": "deepseek-v4-flash",
166
+ "ATA_CODER_SUBAGENT_MODEL": "deepseek-v4-flash",
167
+ "ATA_CODER_MAX_OUTPUT_TOKENS": "131072",
168
+ "ATA_CODER_EFFORT_LEVEL": "max",
169
+ "ATA_CODER_VISION_MODEL": "",
170
+ "ATA_CODER_VISION_API_BASE": "",
171
+ "ATA_CODER_VISION_API_KEY": ""
172
+ },
173
+ "complexity": {
174
+ "auto_detect": true,
175
+ "simple_max_chars": 60,
176
+ "complex_min_chars": 500
177
+ },
178
+ "paths": {
179
+ "data": "~/.ata_coder",
180
+ "skills": "~/.ata_coder/skills",
181
+ "sessions": "~/.ata_coder/sessions",
182
+ "memory": "~/.ata_coder/memory",
183
+ "changes": "~/.ata_coder/changes"
184
+ },
185
+ "permissions": {
186
+ "allow": [
187
+ "Bash(git:*)",
188
+ "Bash(python:*)",
189
+ "Bash(pip:*)",
190
+ "Read(./**)",
191
+ "Edit(./**/*.{py,pyi})",
192
+ "Edit(./**/*.{json,md,txt,yml,yaml})"
193
+ ],
194
+ "deny": [
195
+ "Bash(rm -rf:*)",
196
+ "Bash(sudo:*)",
197
+ "Bash(curl:*)",
198
+ "Bash(wget:*)",
199
+ "Read(./.env)",
200
+ "Read(./**/*.key)"
201
+ ]
202
+ }
203
+ }
204
+ ```
205
+
206
+ - Vision model empty = auto-uses main model. No separate API config needed.
207
+ - Model names auto-strip `[1m]` suffix — write `deepseek-v4-pro`, not `deepseek-v4-pro[1m]`.
208
+ - API errors get friendly troubleshooting suggestions inline.
209
+
210
+ ### Skills
211
+
212
+ Skills live in `skills/<name>/` folders with `SKILL.md` manifest (YAML frontmatter + markdown body). Single-skill activation via keyword matching — no extra LLM calls.
213
+
214
+ ```
215
+ skills/weather-skill/
216
+ ├── SKILL.md # name, version, triggers, tools, I/O spec
217
+ ├── handler.py # Python entry point
218
+ ├── utils.py # Helpers
219
+ ├── prompts/ # LLM prompt templates
220
+ ├── resources/ # Static data
221
+ └── tests/ # pytest tests
222
+ ```
223
+
224
+ ### Commands
225
+
226
+ | Command | Description |
227
+ |---------|-------------|
228
+ | `/help` | Show help |
229
+ | `/skills` | List available skills |
230
+ | `/skill <name>` | Switch skill |
231
+ | `/review` | AI code review of git diff |
232
+ | `/fix [severity]` | Auto-fix review issues |
233
+ | `/undo [n]` | Undo file changes |
234
+ | `/changes` | List tracked changes |
235
+ | `/dry-run` | Toggle dry-run mode |
236
+ | `/save` | Save current session |
237
+ | `/resume <id>` | Resume saved session |
238
+ | `/sessions` | List/search session history |
239
+ | `/compact` | Compact conversation context |
240
+ | `/context` | Show token usage + cost |
241
+ | `/model <name>` | Change model at runtime |
242
+ | `/config` | Show current configuration |
243
+ | `/vision <img> [prompt]` | Analyze image |
244
+ | `/think` | Toggle thinking mode |
245
+ | `/extensions` | List loaded extensions |
246
+ | `/sub-agents` | List sub-agents |
247
+ | `/mcp search <q>` | Search MCP tools |
248
+ | `/permissions` | Show permission rules |
249
+ | `/git <sub>` | Git operations |
250
+ | `/plan <task>` | Task planning |
251
+ | `/remember` / `/recall` | Memory management |
252
+
253
+ ### API Server
254
+
255
+ ```bash
256
+ ata server --port 8080
257
+ ```
258
+
259
+ | Endpoint | Description |
260
+ |----------|-------------|
261
+ | `POST /chat` | Non-streaming chat |
262
+ | `POST /chat/stream` | SSE streaming chat |
263
+ | `GET /health` | Health check |
264
+ | `GET /tools` | List tools |
265
+ | `GET /skills` | List skills |
266
+ | `GET /models` | List available models |
267
+ | `GET /sessions` | List sessions |
268
+ | `DELETE /sessions/<id>` | Delete session |
269
+ | `POST /api/shell` | Interactive shell |
270
+
271
+ ```bash
272
+ # Streaming chat
273
+ curl -N -X POST http://localhost:8080/chat/stream \
274
+ -H "Content-Type: application/json" \
275
+ -d '{"message": "Explain async/await"}'
276
+
277
+ # Non-streaming
278
+ curl -X POST http://localhost:8080/chat \
279
+ -H "Content-Type: application/json" \
280
+ -d '{"message": "Write hello world", "skill": "general-coder"}'
281
+ ```
282
+
283
+ ### Design Patterns
284
+
285
+ | Pattern | Implementation |
286
+ |---------|---------------|
287
+ | **Async LLM** | `BaseLLMClient` ABC — `LLMClient` and `AnthropicClient` use `httpx.AsyncClient` |
288
+ | **Tool Pipeline** | SafetyCheck → PermissionCheck → PrivilegeCheck → Execute → SelfCorrect |
289
+ | **AST Editing** | libcst `CSTTransformer` — parse, match, replace, preserve formatting |
290
+ | **Cancellation** | `asyncio.Task.cancel()` + `asyncio.CancelledError` — no threading events |
291
+ | **Concurrency** | `asyncio.Semaphore` for sub-agent limits, `asyncio.gather()` for parallel tools |
292
+ | **Event Bus** | `asyncio.Queue` — agent task produces, UI task consumes |
293
+ | **Retry Jitter** | Exponential backoff + random jitter in LLM clients |
294
+ | **Circuit Breaker** | Consecutive-tool-failure counter (5 all-fail batches → break) |
295
+ | **Token Budget** | Auto-compact at 200k effective tokens, force-truncate at 95% of 1M max |
296
+ | **Diff Preview** | `difflib.unified_diff` + Rich colored output before file writes |
297
+
298
+ ### 🐾 v2.4.2 Clawd + Window Tokens Fix
299
+
300
+ | # | Fix | Detail |
301
+ |---|-----|--------|
302
+ | 1 | 🐾 Clawd | Shows 'working' immediately on task submit (was stuck thinking) |
303
+ | 2 | 📊 Status | Line shows window tokens (~120k) not cumulative (7.8M) |
304
+ | 3 | 🛡️ Sessions | Belt-and-suspenders surrogate stripping on all writes |
305
+ | 4 | 🔧 Cleanup | Reverted unintended skill file changes |
306
+
307
+ ### 🗂️ v2.4.1 3-Part Session IDs + /resume
308
+
309
+ Session IDs now encode workspace, timestamp, and task in three 8-char hashes.
310
+
311
+ | # | Feature | Detail |
312
+ |---|---------|--------|
313
+ | 1 | 🗂️ **3-Part ID** | `xxxxxxxx-xxxxxxxx-xxxxxxxx` — workspace hash, time hash, task hash |
314
+ | 2 | 🔍 **//resume** | Lists all sessions in the current project folder |
315
+ | 3 | 🎯 **Any hash** | Resume with any of the three hashes: `ata --resume 12345678` |
316
+ | 4 | 📂 **Workspace scoped** | First hash = SHA256(workspace path)[:8] — groups sessions by project |
317
+
318
+ ### 💾 v2.4.0 Auto-Save Sessions
319
+
320
+ Conversations are now automatically saved after every task — never lose your context again.
321
+
322
+ | # | Feature | Detail |
323
+ |---|---------|--------|
324
+ | 1 | 💾 **Auto-save** | Every conversation auto-saved to `~/.ata_coder/sessions/` on task completion |
325
+ | 2 | 🆔 **Hash-based IDs** | Session IDs use 8-char SHA256 hash: `add-type-hints-a3f8b91c` |
326
+ | 3 | 🔍 **Resume by hash** | `ata --resume a3f8b91c` — type just the 8-char hash suffix |
327
+ | 4 | 📁 **JSONL format** | Files named `{slug}-{hash}.jsonl`, each line = one message or tool call |
328
+ | 5 | 🔄 **Reuse on resume** | `--resume` reuses the existing session ID — no duplicate saves |
329
+
330
+ ### 🛠️ v2.3.12 Self-Bootstrapped Quality Fixes
331
+
332
+ All 10 bugs found and fixed by **ATA Coder auditing its own source code** — round 8 of the closed-loop self-repair cycle.
333
+
334
+ | # | Severity | Fix |
335
+ |---|----------|-----|
336
+ | 1 | 🔴 Crash | `ToolStreamEvent` import added to `agent_tools.py` — was NameError on streaming tools |
337
+ | 2 | 🔴 Crash | `zip(tool_calls, results, strict=True)` — prevents silent data misalignment |
338
+ | 3 | 🟠 Fix | `raise ... from e` exception chaining in `anthropic_client.py` (3 sites) |
339
+ | 4 | 🟡 Fix | Threshold consistency: `<=` / `>=` across `ModelRouter` and `_ai_classify` |
340
+ | 5 | 🟢 Cleanup | Module-level logger in `config.py` (removed redundant per-call `getLogger`) |
341
+ | 6 | 🟢 Cleanup | E701 multi-statement splits in `change_tracker.py`, `anthropic_client.py`, `_workflow.py` |
342
+
343
+ ### ⚡ v2.3.11 Self-Bootstrapped Streaming + Crash Fixes
344
+
345
+ All 15 fixes discovered by **ATA Coder auditing its own source code** — round 7.5 of the closed-loop self-repair cycle.
346
+
347
+ | # | Category | Fix |
348
+ |---|----------|-----|
349
+ | 1 | ⚡ Streaming | Shell output streams in real-time via `ToolStreamEvent` — no more frozen terminal |
350
+ | 2 | ⚡ Streaming | Web search shows backend progress: `🔍 Searching Bing...` → `✓ 5 results` |
351
+ | 3 | ⚡ Streaming | Web fetch shows download/extract progress in real-time |
352
+ | 4 | 👁️ Display | Shell commands displayed in full (was truncated to 70 chars) |
353
+ | 5 | 👁️ Display | SSE frontend receives full `args` object (was truncated `brief_args`) |
354
+ | 6 | 🔴 Crash | `_read_old_content` 2-tuple → 3-tuple cache unpack (regression from LRU timestamp) |
355
+ | 7 | 🔴 Crash | `_save_index` missing `sanitize_surrogates` → UTF-8 encode crash |
356
+ | 8 | 🔴 Crash | `BaseSubprocessTransport.__del__` closed pipe — explicit pipe cleanup in `finally` |
357
+ | 9 | 🔴 Crash | `import asyncio` in `__del__` fails during interpreter shutdown — cached reference |
358
+ | 10 | 🔴 Hang | `stdin=asyncio.subprocess.DEVNULL` prevents subprocess stdin-inherit freeze |
359
+ | 11 | 🟠 Fix | `--anthropic` CLI flag now sets `config.llm.use_anthropic` (was ignored) |
360
+ | 12 | 🟠 Fix | `chat_stream` error body now enriched with `enhance_api_error` (was lost) |
361
+ | 13 | 🟡 Test | Server tests skipped on Windows (`handle_request` blocks indefinitely) |
362
+ | 14 | 🟡 Test | Sub-agent tests fixed: `async def` + `@pytest.mark.asyncio` (4 tests) |
363
+ | 15 | 🟡 Test | Privilege test method names restored (7 missing underscores) |
364
+
365
+ ### 🐛 v2.3.10 Self-Bootstrapped Bug Hunt
366
+
367
+ All 25 bugs in this release were found and 18 fixed by **ATA Coder scanning its own source code** — round 7 of the closed-loop "AI-driven self-repair" cycle. 7 findings confirmed as false positives (existing protections already in place).
368
+
369
+ | # | Severity | Finding | Fix |
370
+ |---|----------|---------|-----|
371
+ | 1 | 🔴 Critical | Semaphore leak in `spawn()` on exception | `try/finally` release |
372
+ | 2 | 🔴 Critical | `clear_finished()` doesn't release semaphore | Release per removed agent |
373
+ | 3 | 🔴 Critical | `agent_compact.py` missing `import json` | Added at module top |
374
+ | 4 | 🔴 Critical | PowerShell command injection in `wrap_privileged_command()` | `shlex.quote()` inner command |
375
+ | 5 | 🔴 Critical | Unparseable session timestamps never expire | `t=0` on failure (evict) |
376
+ | 6 | 🔴 High | Duplicate `_http` class attribute | Removed duplicate |
377
+ | 7 | 🔴 High | Dead CRITICAL check in `fool_proof.py` | Removed unreachable block |
378
+ | 8 | 🔴 High | Division by zero if `max_tokens=0` | `max(max_tokens, 1)` guard |
379
+ | 9 | 🔴 High | `except ImportError` never triggers | `if _yaml_mod is not None` |
380
+ | 10 | 🟡 Medium | Hardcoded complexity thresholds in `_ai_classify` | Read from `get_settings()` |
381
+ | 11 | 🟡 Medium | `Path.replace()` fails on Windows | `os.replace()` atomic |
382
+ | 12 | 🟡 Medium | `getattr(self, f"_fn_{key}")` arbitrary access | `_ALLOWED_BUILTINS` whitelist |
383
+ | 13 | 🟡 Medium | `rm -r -f /` not caught by safety regex | Broadened pattern |
384
+ | 14 | 🟡 Medium | Session file can exhaust memory | 100 MB size limit |
385
+ | 15 | 🟡 Medium | Inconsistent `errors="replace"` encoding | Unified across all writes |
386
+ | 16 | 🟡 Medium | `_deep_merge` list semantics unclear | Documented replace behavior |
387
+ | 17 | 🔵 Low | Path traversal in `_serve_static()` | ✅ Already protected (false positive) |
388
+ | 18 | 🔵 Low | `TextDeltaEvent` unused import | ✅ Used in `_streaming_chat()` (false positive) |
389
+
390
+ ### 🧹 v2.3.9 Self-Bootstrapped Housekeeping & Hardening
391
+
392
+ All 10 bugs in this release were found and fixed by **ATA Coder scanning its own source code** — round 5 of the closed-loop "AI-driven self-repair" cycle. Plus 2 critical runtime fixes (`stream` parameter, `HAS_COLORAMA` import).
393
+
394
+ | # | Severity | Finding | Fix |
395
+ |---|----------|---------|-----|
396
+ | 1 | 🔴 Critical | `_run_loop()` lost `stream` closure variable (a192787) | Pass `stream` parameter explicitly |
397
+ | 2 | 🔴 Critical | `repl_theme.py` missing `HAS_COLORAMA` import | Restore `try: from colorama ...` guard |
398
+ | 3 | 🔴 Critical | `get_config()` threading.Lock adds complexity without benefit | Remove lock, document single-threaded design |
399
+ | 4 | 🟠 High | Event queue silently drops events when full | Log WARNING on `QueueFull` |
400
+ | 5 | 🟠 High | Vision provider hardcoded in tool description | Generic description referencing `VISION_*` env vars |
401
+ | 6 | 🟠 High | `SYSTEM_PROMPT` evaluated at import time | Convert to `__getattr__` lazy accessor |
402
+ | 7 | 🟡 Medium | File cache has no TTL | Add 30s TTL — re-read stale entries |
403
+ | 8 | 🟡 Medium | `SKIP_DIRS` missing common cache dirs | Add `.mypy_cache`, `.ruff_cache`, `.idea`, `.vs`, `.terraform` etc. |
404
+ | 9 | 🟡 Medium | No structured logging | `_SessionLogger` adapter injects `[session_id]` prefix |
405
+ | 10 | 🟡 Medium | `commands.py` 974 lines monolithic | Split to `commands/` package (4 sub-modules) |
406
+
407
+ **Package health**: `agent.py` 1199→829 lines (-31%), `server.py` 1067→823 (-23%), `main.py` 866→738 (-15%), `commands.py` → `commands/` package.
408
+
409
+ ### 🔧 v2.3.8 Self-Bootstrapped Technical Debt Audit
410
+
411
+ Bug fixes from the project health scan — async test compat, agent/server refactoring, deprecated API cleanup.
412
+
413
+ | # | Severity | Finding | Fix |
414
+ |---|----------|---------|-----|
415
+ | 1 | 🔴 Critical | `test_chat_stream_yields_*` fails on Python 3.14 | `async def` + `async for` (5 tests) |
416
+ | 2 | 🔴 Critical | `skills.deactivate()` not called on exception | `finally` block in `run()` |
417
+ | 3 | 🟠 High | `_build_handlers()` may register mixin attrs | `callable()` guard |
418
+ | 4 | 🟠 High | `agent.py` 1199 lines | Extract 3 mixins: tools, routing, extension |
419
+ | 5 | 🟠 High | `server.py` 1067 lines | Extract `server_session.py`, `server_shell.py` |
420
+ | 6 | 🟡 Medium | `time.mktime` deprecated in Python 3.14 | `datetime.fromisoformat()` |
421
+ | 7 | 🟡 Medium | `_consecutive_failures` parameter confusion | Move constants into `_run_loop()` |
422
+ | 8 | 🟡 Medium | `_file_cache` LRU not implemented | Move-to-end on cache hit |
423
+ | 9 | 🟡 Medium | `AgentAPIHandler` class attr shared state | `__init__` copies to instance attrs |
424
+ | 10 | 🔵 Low | Version mismatch CLAUDE.md vs README | Sync to v2.3.8 |
425
+
426
+ ### 🧹 v2.3.6 Self-Bootstrapped Code Quality Audit
427
+
428
+ All 24 findings in this release were audited by **ATA Coder scanning its own source code** — round 2 of the v2.3.5 closed-loop verification cycle, addressing code quality, testing, and DevOps.
429
+
430
+ | # | Severity | Finding | Fix |
431
+ |---|----------|---------|-----|
432
+ | 1 | 🔴 Critical | `main.py:__version__ = "2.3.4"` stale while `pyproject.toml` = `2.3.5` | Synced all three locations to `2.3.6` |
433
+ | 2 | 🔴 Critical | 4 config tests FAILED — env var overrides ignored by settings.json system | Updated to `get_settings()` mock pattern |
434
+ | 3 | 🔴 Critical | No CI/CD — tests never run on push | `.github/workflows/ci.yml` — matrix py3.10-3.13 + lint |
435
+ | 4 | 🟠 High | `sub_agent.py` LLMConfig missing `thinking_strength` | Passes `thinking_strength=config.llm.thinking_strength` |
436
+ | 5 | 🟠 High | `anthropic_client.py` inline `import os as _os` in `__init__` | Moved to module top-level |
437
+ | 6 | 🟠 High | `safety_guard.py` IEX regex: `IEX?\s*\(` matches `IE(` | Tightened to `\bIEX\s*\([^)]*\)` |
438
+ | 7 | 🟡 Medium | `memory.py` + `skills.py` duplicate yaml import pattern | Extracted `try_import_yaml()` to `utils.py` |
439
+ | 8 | 🟡 Medium | `ATA_CODER_ALLOW_ALL` silently allows all — no audit trail | `logger.warning()` on activation |
440
+ | 9 | 🟡 Medium | `out.txt`, `web/node_modules/` exposed in working tree | Added to `.gitignore` |
441
+ | 10 | 🟡 Medium | No ruff/mypy/pytest config in `pyproject.toml` | Added `[tool.ruff]`, `[tool.mypy]`, `[tool.pytest.ini_options]` |
442
+
443
+ ---
444
+
445
+ ### 🤖 v2.3.5 Self-Bootstrapped Security Audit
446
+
447
+ All 23 findings in this release were audited by **ATA Coder scanning its own source code** — the second closed-loop "AI-driven self-repair" verification. 20 fixed, 2 pre-existing mitigations confirmed, 1 deferred.
448
+
449
+ | # | Severity | Finding | Fix |
450
+ |---|----------|---------|-----|
451
+ | 1 | 🔴 Critical | `/api/shell` no auth — remote arbitrary command execution | Added `_require_auth` + `SafetyGuard.check_shell()` |
452
+ | 2 | 🔴 Critical | Auth logic backwards — denied all when no token set | `_check_auth()` returns `True` when no token configured |
453
+ | 3 | 🔴 Critical | Default `0.0.0.0` bind + wide CORS + no-auth endpoints | Default `127.0.0.1`; CORS reflects localhost only; `0.0.0.0` warns without token |
454
+ | 4 | 🟠 High | `/chat` and `/chat/stream` endpoints no authentication | Added `_require_auth()` to both |
455
+ | 5 | 🟠 High | Protected paths missing `.env`, cloud creds, Windows paths | Expanded to 30 entries; added suffix matching for dotfiles |
456
+ | 6 | 🟠 High | SSE logs leak LLM output (potential API keys, tokens) | `_sanitize_log()` redacts keys; downgraded to DEBUG |
457
+ | 7 | 🟠 High | Error responses leak internal paths (`str(e)` → client) | Generic "Internal server error" in chat handler |
458
+ | 8 | 🟠 High | PowerShell RCE vectors undetected (IEX, Invoke-*) | Added 5 new destructive patterns |
459
+ | 9 | 🟡 Medium | File read cache unbounded (memory leak on large projects) | LRU eviction at 50 entries |
460
+ | 10 | 🟡 Medium | Session store no TTL (agent instances never freed) | 30-minute `_evict_expired()` auto-cleanup |
461
+ | 11 | 🟡 Medium | `print()` instead of `logger` for runtime events | Replaced 3 `print()` calls with `logger.info()` |
462
+ | 12 | 🟡 Medium | Duplicate `@property` decorator on `vision_model` | Removed |
463
+ | 13 | 🟡 Medium | `shlex.split` called twice in `check_shell` | Reused cached `cmd_tokens` |
464
+ | 14 | 🟡 Medium | Sync `httpx.Client` blocks async event loop | `_tool_web_search`/`_tool_web_fetch` via `run_in_executor` |
465
+ | 15 | 🟡 Medium | Sync `os.walk` blocks event loop in `_tool_grep` | Filesystem traversal runs in thread pool |
466
+ | 16 | 🟡 Medium | `requirements.txt` missing `click>=8.0` | Synced with `pyproject.toml` |
467
+ | 17 | 🟡 Medium | PowerShell hardcoded (crashes on Linux/macOS) | Platform detection: PS on Windows, bash elsewhere |
468
+ | 18 | 🔵 Low | API keys in plaintext `settings.json` | Already mitigated — `chmod 0600` since v2.3.4 |
469
+ | 19 | 🔵 Low | XSS via `innerHTML` in Web UI | Already mitigated — `escapeHtml()` on all paths |
470
+ | 20 | 🔵 Low | Sub-agent concurrency unlimited | Pre-existing: `asyncio.Semaphore(max_sub_agents)` |
471
+ | 21 | 🔵 Low | Config field naming (`thinking_strength` vs `effort_level`) | Documented — backward compatibility constraint |
472
+ | 22 | 🔵 Low | CSRF protection (no token on state-changing endpoints) | Noted for future cookie-auth scenario |
473
+ | 23 | 🔵 Low | Hardcoded default API endpoint | Documented — intentional project default |
474
+
475
+ ---
476
+
477
+ ### 🤖 v2.3.4 Self-Bootstrapped Security Audit
478
+
479
+ All 6 findings in this release were discovered by **ATA Coder scanning its own source code** — the first closed-loop "AI-driven self-repair" verification for this project.
480
+
481
+ | # | Severity | Finding | Fix |
482
+ |---|----------|---------|-----|
483
+ | 1 | 🔴 High | Server auth allowed all when no token set | Default deny + CORS restricted to localhost:3000 |
484
+ | 2 | 🔴 Medium | HTML parser boolean flag leaked content on nested tags | `_skip_count` counter replaces `_skip` bool |
485
+ | 3 | 🔴 Medium | API keys stored plaintext without file permission lock | `chmod 0600` after every `settings.json` write |
486
+ | 4 | 🔴 Medium | Shell command guard bypassable (case, encoding, find -delete) | Added `find -delete`, `shred`, `dd of=`, cmd-sub patterns |
487
+ | 5 | 🟡 Low | Model registry substring-match caused false pricing hits | Removed substring fallback entirely |
488
+ | 6 | 🟡 Medium | CST renamers had ~60 lines of duplicated `leave_Name`/`leave_Call` | Extracted `_SymbolRenamer` base class |
489
+
490
+ **Bugs fixed in v2.3.3 (hotfixes):**
491
+ - CST import guard crash when libcst not installed
492
+ - `_summarise_messages` missing `async def` → SyntaxError
493
+ - Stale `TaskPlanner` instantiation → NameError at startup
494
+ - Nested `asyncio.run()` crash (prompt_toolkit + asyncio)
495
+ - Clawd shutdown not awaited on `/quit` exit path
496
+ - Welcome screen model labels (opus/sonnet/haiku)
497
+
498
+ ---
499
+
500
+ ## 中文
501
+
502
+ ### 概述
503
+
504
+ ATA Coder 是一个命令行 AI 编码助手,兼容 OpenAI / Anthropic API。基于 **单线程 asyncio 事件循环** — 无线程、无竞态、低内存。配备确定性 AST 代码编辑、子 Agent 池、MCP 支持和内置 HTTP API 服务。
505
+
506
+ ### 架构 (v2.3.3)
507
+
508
+ ```
509
+ asyncio 事件循环(单线程)
510
+ ├── REPL (prompt_toolkit + Rich)
511
+ │ await controller.submit(task)
512
+ │ await event_queue.drain() → ui.on_event()
513
+
514
+ ├── AgentController (asyncio.Task)
515
+ │ CoderAgent.run() → 异步 LLM 循环 → await 工具调用
516
+ │ BaseLLMClient (ABC) — 统一 OpenAI/Anthropic 异步接口
517
+ │ ExtensionManager → Skill 提示聚合
518
+ │ 关键词任务分类(零额外 API 调用)
519
+
520
+ ├── 子 Agent (asyncio.TaskGroup)
521
+ │ SubAgent 1..N: 独立 LLM、工具、上下文
522
+ │ asyncio.Semaphore → 并发限制
523
+
524
+ └── MCP 客户端 (asyncio subprocess)
525
+ StdioConnection → create_subprocess_exec + 异步读取
526
+ ```
527
+
528
+ ### 核心特性
529
+
530
+ | 特性 | 说明 |
531
+ |------|------|
532
+ | **异步事件循环** | 单线程 asyncio — 零竞态、无线程开销 |
533
+ | **AST 代码编辑** | libcst 确定性 Python 编辑,完美保留格式 |
534
+ | **安全重命名** | `rename_symbol` 工具 — 改名不碰字符串和注释 |
535
+ | **子 Agent 池** | 独立上下文并行执行,信号量限制并发 |
536
+ | **Skill 系统** | 关键词自动检测,单 Skill 激活防提示稀释 |
537
+ | **MCP 支持** | Model Context Protocol — 跨工具互操作 |
538
+ | **多模态视觉** | `analyze_image` — 视觉模型未设置自动用主模型 |
539
+ | **Diff 预览** | 编辑前彩色 unified diff,终端红绿高亮 |
540
+ | **会话持久化** | 按工作区保存/恢复/导出对话历史 |
541
+ | **API 服务** | SSE 流式、Shell 会话、多会话管理 |
542
+ | **安全管线** | 防呆 → 权限 → 特权 → 自校正 |
543
+
544
+ ### 快速开始
545
+
546
+ ```bash
547
+ pip install -e .
548
+ ata # 交互模式
549
+ ata run "添加类型注解" # 单任务
550
+ ata server --port 8080 # API 服务
551
+ ```
552
+
553
+ ### 配置
554
+
555
+ **settings.json 是唯一配置源。** 所有配置在 `~/.ata_coder/settings.json`:
556
+
557
+ ```json
558
+ {
559
+ "env": {
560
+ "ATA_CODER_BASE_URL": "https://api.deepseek.com",
561
+ "ATA_CODER_API_KEY": "sk-...",
562
+ "ATA_CODER_DEFAULT_MODEL": "deepseek-v4-pro",
563
+ "ATA_CODER_VISION_MODEL": "",
564
+ "ATA_CODER_VISION_API_BASE": "",
565
+ "ATA_CODER_VISION_API_KEY": ""
566
+ }
567
+ }
568
+ ```
569
+
570
+ - 视觉模型留空 = 自动用主模型,无需单独配置
571
+ - 模型名自动剥离 `[1m]` 后缀
572
+ - API 错误自动附带友好修复建议
573
+
574
+ ### 常用命令
575
+
576
+ | 命令 | 说明 |
577
+ |------|------|
578
+ | `/help` | 帮助 |
579
+ | `/skills` | 列出 Skill |
580
+ | `/review` | AI 审查代码 |
581
+ | `/undo [n]` | 撤销变更 |
582
+ | `/save` | 保存会话 |
583
+ | `/resume <id>` | 恢复会话 |
584
+ | `/compact` | 压缩上下文 |
585
+ | `/context` | Token 用量 |
586
+ | `/model <name>` | 切换模型 |
587
+ | `/vision <图片>` | 视觉分析 |
588
+ | `/config` | 查看配置 |
589
+
590
+ ### API 服务
591
+
592
+ ```bash
593
+ ata server --port 8080
594
+ ```
595
+
596
+ ```bash
597
+ # SSE 流式
598
+ curl -N -X POST http://localhost:8080/chat/stream \
599
+ -H "Content-Type: application/json" \
600
+ -d '{"message": "解释 async/await"}'
601
+ ```
602
+
603
+ ### 🐾 v2.4.2 Clawd + 窗口 Token 修复
604
+
605
+ | # | 修复 | 说明 |
606
+ |---|------|------|
607
+ | 1 | 🐾 Clawd | 提交任务立刻显示工作中(之前卡在思考) |
608
+ | 2 | 📊 状态栏 | 显示窗口 token (~120k) 而非累计 (7.8M) |
609
+ | 3 | 🛡️ 会话 | 双重 surrogate 过滤保护所有写入 |
610
+ | 4 | 🔧 清理 | 回滚意外提交的 skill 文件改动 |
611
+
612
+ ### 🗂️ v2.4.1 三段哈希会话 ID + /resume
613
+
614
+ 三段哈希编码工作区、时间戳和任务。
615
+
616
+ | # | 特性 | 说明 |
617
+ |---|------|------|
618
+ | 1 | 🗂️ **三段 ID** | `xxxxxxxx-xxxxxxxx-xxxxxxxx` — 工作区哈希·时间哈希·任务哈希 |
619
+ | 2 | 🔍 **//resume** | 列出当前项目文件夹所有会话 |
620
+ | 3 | 🎯 **任意哈希** | 用三段中任意一个哈希恢复:`ata --resume 12345678` |
621
+ | 4 | 📂 **工作区隔离** | 第一段 = SHA256(工作区路径)[:8] — 按项目分组 |
622
+
623
+ ### 💾 v2.4.0 会话自动保存
624
+
625
+ 每轮对话自动保存 —— 再也不丢上下文。
626
+
627
+ | # | 特性 | 说明 |
628
+ |---|------|------|
629
+ | 1 | 💾 **自动保存** | 任务完成后自动存入 `~/.ata_coder/sessions/` |
630
+ | 2 | 🆔 **哈希 ID** | 8 位 SHA256 哈希:`add-type-hints-a3f8b91c` |
631
+ | 3 | 🔍 **哈希恢复** | `ata --resume a3f8b91c` — 只输 8 位哈希即可 |
632
+ | 4 | 📁 **JSONL 格式** | 文件名 `{摘要}-{哈希}.jsonl`,每行一条消息或工具调用 |
633
+ | 5 | 🔄 **恢复复用** | `--resume` 复用原有 session ID 避免重复存储 |
634
+
635
+ ### 🛠️ v2.3.12 自举质量修复
636
+
637
+ 全部 10 个 bug 由 **ATA Coder 审计自身源码** 发现并修复——第八轮闭环自修复。
638
+
639
+ | # | 严重度 | 修复 |
640
+ |---|--------|------|
641
+ | 1 | 🔴 崩溃 | `ToolStreamEvent` 导入添加到 `agent_tools.py` — 流式工具 NameError |
642
+ | 2 | 🔴 崩溃 | `zip(tool_calls, results, strict=True)` — 防止数据静默错位 |
643
+ | 3 | 🟠 修复 | `raise ... from e` 异常链在 `anthropic_client.py`(3 处) |
644
+ | 4 | 🟡 修复 | 阈值一致性:`ModelRouter` 和 `_ai_classify` 统一 `<=` / `>=` |
645
+ | 5 | 🟢 清理 | `config.py` 模块级 logger(移除冗余的每次调用 getLogger) |
646
+ | 6 | 🟢 清理 | E701 多语句拆分:`change_tracker.py`、`anthropic_client.py`、`_workflow.py` |
647
+
648
+ ### ⚡ v2.3.11 自举流式输出 + 崩溃修复
649
+
650
+ 全部 15 项修复由 **ATA Coder 审计自身源码** 发现——第七轮半闭环自修复。
651
+
652
+ | # | 类别 | 修复 |
653
+ |---|------|------|
654
+ | 1 | ⚡ 流式 | Shell 输出实时流式传输 — 不再死盯黑屏等待 |
655
+ | 2 | ⚡ 流式 | Web 搜索显示后端进度:`🔍 正在搜索 Bing...` → `✓ 5 条结果` |
656
+ | 3 | ⚡ 流式 | Web 抓取实时显示下载/提取进度 |
657
+ | 4 | 👁️ 显示 | Shell 命令完整展示(之前截断到 70 字符) |
658
+ | 5 | 👁️ 显示 | SSE 前端接收完整 `args` 对象(之前是截断的 `brief_args`) |
659
+ | 6 | 🔴 崩溃 | `_read_old_content` 2 元组 → 3 元组缓存解包(LRU 引入的回归) |
660
+ | 7 | 🔴 崩溃 | `_save_index` 缺少 `sanitize_surrogates` → UTF-8 编码崩溃 |
661
+ | 8 | 🔴 崩溃 | `BaseSubprocessTransport.__del__` 管道已关闭 — finally 中显式关闭 |
662
+ | 9 | 🔴 崩溃 | `__del__` 中 `import asyncio` 解释器关闭时失败 — 缓存引用 |
663
+ | 10 | 🔴 卡死 | `stdin=asyncio.subprocess.DEVNULL` 防止子进程继承 stdin 卡死 |
664
+ | 11 | 🟠 修复 | `--anthropic` CLI 标志写入 `config.llm.use_anthropic`(之前被忽略) |
665
+ | 12 | 🟠 修复 | `chat_stream` 错误体用 `enhance_api_error` 丰富(之前丢失) |
666
+ | 13 | 🟡 测试 | Windows 跳过服务端测试(`handle_request` 永久阻塞) |
667
+ | 14 | 🟡 测试 | 子 Agent 测试修复:`async def` + `@pytest.mark.asyncio`(4 个) |
668
+ | 15 | 🟡 测试 | 权限测试方法名恢复(7 个缺失下划线) |
669
+
670
+ ### 🐛 v2.3.10 自举 Bug 狩猎
671
+
672
+ 本版本全部 25 个 bug 由 **ATA Coder 扫描自身源码** 发现,18 个已修复——第七轮闭环验证。7 项确认为误报(已有防护)。
673
+
674
+ | # | 严重度 | 发现 | 修复 |
675
+ |---|--------|------|------|
676
+ | 1 | 🔴 严重 | `spawn()` 异常时信号量泄漏 | `try/finally` 释放 |
677
+ | 2 | 🔴 严重 | `clear_finished()` 不释放信号量 | 每个 agent 释放一个槽位 |
678
+ | 3 | 🔴 严重 | `agent_compact.py` 缺少 `import json` | 模块顶部添加 |
679
+ | 4 | 🔴 严重 | PowerShell 命令注入 | `shlex.quote()` 包装 |
680
+ | 5 | 🔴 严重 | 时间戳解析失败 → 永不过期 | 失败时 `t=0`(逐出) |
681
+ | 6 | 🔴 高 | 重复 `_http` 类属性 | 删除重复 |
682
+ | 7 | 🔴 高 | `fool_proof.py` 死代码 CRITICAL 检查 | 删除不可达代码块 |
683
+ | 8 | 🔴 高 | `max_tokens=0` 除零错误 | `max(max_tokens, 1)` |
684
+ | 9 | 🔴 高 | `except ImportError` 永远不触发 | `if _yaml_mod is not None` |
685
+ | 10 | 🟡 中 | `_ai_classify` 硬编码阈值 | 从 `get_settings()` 读取 |
686
+ | 11 | 🟡 中 | `Path.replace()` Windows 不兼容 | `os.replace()` |
687
+ | 12 | 🟡 中 | 模板 `getattr` 任意访问 | `_ALLOWED_BUILTINS` 白名单 |
688
+ | 13 | 🟡 中 | `rm -r -f /` 未被检测 | 拓宽正则模式 |
689
+ | 14 | 🟡 中 | 会话文件可能导致内存耗尽 | 100 MB 大小限制 |
690
+ | 15 | 🟡 中 | 编码错误处理不一致 | 统一使用 `errors="replace"` |
691
+ | 16 | 🟡 中 | `_deep_merge` 列表语义不清 | 文档化替换行为 |
692
+ | 17 | 🔵 低 | `_serve_static()` 路径遍历 | ✅ 已有防护(误报) |
693
+ | 18 | 🔵 低 | `TextDeltaEvent` 未使用 | ✅ 在 `_streaming_chat()` 使用(误报) |
694
+
695
+ ### 🧹 v2.3.9 自举修缮与加固
696
+
697
+ 本版本全部 10 个 bug 由 **ATA Coder 扫描自身源码** 发现并修复——第五轮闭环验证。另修复 2 个关键运行时 bug(`stream` 参数丢失、`HAS_COLORAMA` 导入缺失)。
698
+
699
+ | # | 严重度 | 发现 | 修复 |
700
+ |---|--------|------|------|
701
+ | 1 | 🔴 严重 | `_run_loop()` 丢失 `stream` 闭包变量 | 显式传递 `stream` 参数 |
702
+ | 2 | 🔴 严重 | `repl_theme.py` 缺少 `HAS_COLORAMA` 导入 | 恢复 `try: from colorama ...` |
703
+ | 3 | 🔴 严重 | `get_config()` 不必要的线程锁 | 移除锁,文档化单线程设计 |
704
+ | 4 | 🟠 高 | 事件队列满时静默丢弃 | `QueueFull` 时记录 WARNING |
705
+ | 5 | 🟠 高 | 视觉模型描述硬编码提供商 | 通用描述,引用 `VISION_*` 环境变量 |
706
+ | 6 | 🟠 高 | `SYSTEM_PROMPT` 导入时求值 | 改为 `__getattr__` 懒加载 |
707
+ | 7 | 🟡 中 | 文件缓存无 TTL | 添加 30s TTL |
708
+ | 8 | 🟡 中 | `SKIP_DIRS` 遗漏常见缓存目录 | 新增 `.mypy_cache`、`.idea`、`.terraform` 等 |
709
+ | 9 | 🟡 中 | 无结构化日志 | `_SessionLogger` 适配器注入 `[session_id]` |
710
+ | 10 | 🟡 中 | `commands.py` 974 行单体文件 | 拆分为 `commands/` 包(4 个子模块) |
711
+
712
+ ### 🔧 v2.3.8 自举技术债审计
713
+
714
+ | # | 严重度 | 发现 | 修复 |
715
+ |---|--------|------|------|
716
+ | 1 | 🔴 严重 | Python 3.14 测试不兼容 | `async def` + `async for` |
717
+ | 2 | 🔴 严重 | 异常路径未清理技能状态 | `finally` 块调用 `deactivate()` |
718
+ | 3 | 🟠 高 | `agent.py` 1199 行 | 提取 3 个 Mixin |
719
+ | 4 | 🟠 高 | `server.py` 1067 行 | 提取 session/shell 模块 |
720
+ | 5 | 🟡 中 | `time.mktime` 已弃用 | `datetime.fromisoformat()` |
721
+ | 6 | 🟡 中 | LRU 缓存驱逐未实现 | 命中时 move-to-end |
722
+
723
+ ### 🧹 v2.3.6 自举代码质量审计
724
+
725
+ 本次版本全部 24 个质量问题均由 **ATA Coder 扫描自身源码审计** — v2.3.5 闭环验证的第二轮,针对代码质量、测试和 DevOps。
726
+
727
+ | # | 严重度 | 发现 | 修复 |
728
+ |---|--------|------|------|
729
+ | 1 | 🔴 严重 | `main.py:__version__ = "2.3.4"` 过期,与 `pyproject.toml` 不一致 | 三处同步至 `2.3.6` |
730
+ | 2 | 🔴 严重 | 4 个配置测试 FAILED — 环境变量被 settings.json 系统忽略 | 改用 `get_settings()` mock 模式 |
731
+ | 3 | 🔴 严重 | 无 CI/CD — push 时从不运行测试 | `.github/workflows/ci.yml` — 矩阵 py3.10-3.13 + lint |
732
+ | 4 | 🟠 高危 | `sub_agent.py` LLMConfig 遗漏 `thinking_strength` | 传递 `thinking_strength=config.llm.thinking_strength` |
733
+ | 5 | 🟠 高危 | `anthropic_client.py` 构造函数内 `import os as _os` | 移至模块顶层 |
734
+ | 6 | 🟠 高危 | `safety_guard.py` IEX 正则 `IEX?\s*\(` 可匹配 `IE(` | 收紧为 `\bIEX\s*\([^)]*\)` |
735
+ | 7 | 🟡 中危 | `memory.py` + `skills.py` 重复 yaml 导入模式 | 提取 `try_import_yaml()` 至 `utils.py` |
736
+ | 8 | 🟡 中危 | `ATA_CODER_ALLOW_ALL` 静默放行 — 无审计记录 | 激活时 `logger.warning()` |
737
+ | 9 | 🟡 中危 | `out.txt`、`web/node_modules/` 暴露在工作区 | 加入 `.gitignore` |
738
+ | 10 | 🟡 中危 | `pyproject.toml` 缺少 ruff/mypy/pytest 配置 | 添加 `[tool.ruff]`、`[tool.mypy]`、`[tool.pytest.ini_options]` |
739
+
740
+ ---
741
+
742
+ ### 🤖 v2.3.5 自举安全审计
743
+
744
+ 本次版本全部 23 个安全漏洞均由 **ATA Coder 扫描自身源码审计** — 项目第二次"AI 驱动自我修复"闭环验证。修复 20 项,确认 2 项已有缓解措施,1 项延后。
745
+
746
+ | # | 严重度 | 发现 | 修复 |
747
+ |---|--------|------|------|
748
+ | 1 | 🔴 严重 | `/api/shell` 无认证 — 远程任意命令执行 | 添加 `_require_auth` + `SafetyGuard.check_shell()` |
749
+ | 2 | 🔴 严重 | 认证逻辑颠倒 — 未设 token 时拒绝所有请求 | 无 token 时返回 `True`(放行),有 token 时正确校验 |
750
+ | 3 | 🔴 严重 | 默认 `0.0.0.0` 绑定 + 宽 CORS + 无认证端点 | 默认 `127.0.0.1`;CORS 仅回显 localhost;`0.0.0.0` 无 token 时警告 |
751
+ | 4 | 🟠 高危 | `/chat` 和 `/chat/stream` 端点无认证 | 两个端点均添加 `_require_auth()` |
752
+ | 5 | 🟠 高危 | 受保护路径缺少 `.env`、云凭据、Windows 路径 | 扩展至 30 项;添加 dotfile 后缀匹配 |
753
+ | 6 | 🟠 高危 | SSE 日志泄露 LLM 输出(可能含 API 密钥) | `_sanitize_log()` 脱敏;降级为 DEBUG |
754
+ | 7 | 🟠 高危 | 错误响应泄露内部路径(`str(e)` → 客户端) | Chat 处理器返回通用 "Internal server error" |
755
+ | 8 | 🟠 高危 | PowerShell RCE 向量未检测(IEX, Invoke-*) | 新增 5 个攻击模式 |
756
+ | 9 | 🟡 中危 | 文件读取缓存无上限(大项目内存泄漏) | 50 条目 LRU 淘汰 |
757
+ | 10 | 🟡 中危 | 会话存储无过期(Agent 实例永不释放) | 30 分钟 `_evict_expired()` 自动清理 |
758
+ | 11 | 🟡 中危 | `print()` 替代 logger 记录运行时事件 | 3 处替换为 `logger.info()` |
759
+ | 12 | 🟡 中危 | `vision_model` 重复 `@property` 装饰器 | 已移除 |
760
+ | 13 | 🟡 中危 | `check_shell` 中 `shlex.split` 重复调用 | 复用缓存的 `cmd_tokens` |
761
+ | 14 | 🟡 中危 | 同步 `httpx.Client` 阻塞异步事件循环 | `_tool_web_search`/`_tool_web_fetch` 通过 `run_in_executor` 运行 |
762
+ | 15 | 🟡 中危 | 同步 `os.walk` 阻塞事件循环 | 文件系统遍历在线程池中运行 |
763
+ | 16 | 🟡 中危 | `requirements.txt` 缺少 `click>=8.0` | 与 `pyproject.toml` 同步 |
764
+ | 17 | 🟡 中危 | PowerShell 硬编码(Linux/macOS 崩溃) | 平台检测:Windows 用 PS,其他用 bash |
765
+ | 18 | 🔵 低危 | API 密钥明文存储在 `settings.json` | 自 v2.3.4 已有 `chmod 0600` |
766
+ | 19 | 🔵 低危 | Web UI `innerHTML` XSS 风险 | 已有 `escapeHtml()` 覆盖所有路径 |
767
+ | 20 | 🔵 低危 | 子 Agent 并发无限制 | 已有 `asyncio.Semaphore(max_sub_agents)` |
768
+ | 21 | 🔵 低危 | 配置字段命名不一致(`thinking_strength` vs `effort_level`) | 记录 — 向后兼容约束 |
769
+ | 22 | 🔵 低危 | CSRF 保护(状态变更端点无 token) | 留待未来 cookie 认证场景 |
770
+ | 23 | 🔵 低危 | 硬编码默认 API 端点 | 记录 — 项目有意为之的默认值 |
771
+
772
+ ---
773
+
774
+ ### 🤖 v2.3.4 自举安全审计
775
+
776
+ 本次版本全部 6 个安全漏洞均由 **ATA Coder 扫描自身源码发现并建议修复** — 项目首次实现"AI 驱动自我修复"的闭环验证。
777
+
778
+ | # | 严重度 | 发现 | 修复 |
779
+ |---|--------|------|------|
780
+ | 1 | 🔴 高 | Server 无 token 时允许所有连接 | 默认拒绝 + CORS 限制为 localhost:3000 |
781
+ | 2 | 🔴 中 | HTML 解析器布尔标志导致嵌套标签内容泄露 | `_skip_count` 计数器替代 `_skip` 布尔值 |
782
+ | 3 | 🔴 中 | API 密钥明文存储无文件权限保护 | 每次写入 `settings.json` 后 `chmod 0600` |
783
+ | 4 | 🔴 中 | Shell 命令拦截可被绕过(大小写、编码、find -delete) | 新增 `find -delete`、`shred`、`dd of=`、命令替换模式 |
784
+ | 5 | 🟡 低 | 模型注册表子串匹配导致错误定价 | 彻底移除子串回退 |
785
+ | 6 | 🟡 中 | CST 重命名器约 60 行重复代码 | 提取 `_SymbolRenamer` 基类 |
786
+
787
+ **v2.3.3 紧急修复的 Bug:**
788
+ - libcst 未安装时 CST 类 import 崩溃
789
+ - `_summarise_messages` 遗漏 `async def` → SyntaxError
790
+ - 残留 `TaskPlanner` 实例化 → 启动 NameError
791
+ - `prompt_async` vs `asyncio.run()` 嵌套崩溃
792
+ - `/quit` 退出路径未 await Clawd shutdown
793
+ - 欢迎屏模型标签 (opus/sonnet/haiku)
794
+
795
+ ---
796
+
797
+ ## License
798
+
799
+ MIT — see [LICENSE](LICENSE)