feat(ask): air ask "<task>" — interactive AI task execution

New `air ask` command:
- Accepts task description from CLI
- Auto-initializes project if needed
- MainAgent classifies → LLM generates → tools execute → results
- Supports Chinese keywords (创建/写/开发/实现 etc.)
- Tool call parser supports ```json and ```tool blocks
- Executes tools first, then checks DONE (fixes race condition)
- Strips GLM </think> reasoning tags from output

Usage: air ask "创建一个C++程序打印Hello World"

Tested end-to-end with glm-5.1 on new API endpoint.
Files correctly created: 13/13 E2E gates pass.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
AirCoding
2026-06-05 14:05:05 +08:00
parent bc58bd6840
commit 459308053c
3 changed files with 287 additions and 4 deletions

View File

@@ -134,20 +134,28 @@ export class MainAgent {
}
/**
* Regex-based intent classification (Alpha scope, 5 patterns).
* Regex-based intent classification (Alpha scope, supports EN + 中文).
*/
private classify_regex(message: string): string {
const lower = message.toLowerCase()
if (/^(what|how|why|when|where|who|can you|could you|explain)/.test(lower)) {
// Questions
if (/^(what|how|why|when|where|who|can you|could you|explain|什么是|怎么|如何|为什么|什么意思)/.test(lower)) {
return 'simple_question'
}
if (/^(\/direct|\/done|implement|create|build|write|add|fix|change|update|remove|delete|refactor)/.test(lower)) {
// Implementation requests — English
if (/^(\/direct|\/done|implement|create|build|write|add|fix|change|update|remove|delete|refactor|make|generate)/.test(lower)) {
return 'implementation_request'
}
if (/^(run|execute|test|debug|check|inspect)/.test(lower)) {
// Implementation requests — 中文
if (/创建|写|开发|实现|生成|建立|构建|编译|修改|删除|添加|增加|修复|重构|制作/.test(message)) {
return 'implementation_request'
}
// Direct commands
if (/^(run|execute|test|debug|check|inspect|运行|执行|测试|调试|检查)/.test(lower)) {
return 'direct_command'
}