新增: 批次工作落地(推进链/评估闭环/事件总线/并发/加固) + 技术债清理 + 文档整理

后端:
- 工作流推进链(D-03):advance_task/状态机/闸门走 df-nodes Node trait,conditions 条件引擎扩展
- 想法评估闭环:启发式评分+对抗评估,df-ideas/scoring + df-storage/idea_eval_repo + idea 前端打通
- 全局事件数据总线:df-ai/context+context_helpers+augmentation 跨模块解耦
- AI planner/plan_hint/intent:aichat B 路线并行多轮基础
- patch_file 加固(TD-03/04):读改写整体锁防 lost update,expected_hash 合约闭环
- 压缩超时兜底(F-15 卡死根治)
- F-09 多会话并发:LlmConcurrency per-conv + streamingGuard 前端守护 + verify 脚本
- 知识注入 DRY/skills/audit 扩展

清理:
- aichat 技术债(误报 allow/死导入/过时注释 30 项)
- URGENT.md 删除(11 项加急全解决/迁 todo)
- 文档整理(todo/待决策/待审查/ARCHITECTURE/INDEX + 总线/技术债审查新文档)
This commit is contained in:
2026-06-21 20:51:26 +08:00
parent 330bb7f505
commit bd6a41fe6e
111 changed files with 11932 additions and 1034 deletions

View File

@@ -2,15 +2,18 @@
import { invoke } from '@tauri-apps/api/core'
import { listen, type UnlistenFn } from '@tauri-apps/api/event'
import type { AiChatEvent, AiConversationDetail, AiConversationSummary, AiProviderConfig, ContentPart, ModelConfig, SkillInfo } from './types'
import type { AiChatEvent, AiConversationDetail, AiConversationSummary, AiProviderConfig, ContentPart, MentionSpan, ModelConfig, SkillInfo } from './types'
export const aiApi = {
/**
* 发送消息(非阻塞,通过 ai-chat-event 流式返回skill 传技能名则注入其 SKILL.md。
* F-260614-05 Phase 2c: parts 透传给后端 ai_chat_send → user_parts → provider vision 端点。
* parts 为空/undefined → 后端走 user() 纯文本(向后兼容)。
* Input Augmentation: mentionSpans 透传给后端 ai_chat_send 的 mention_spans 参数
* (后端 resolve_and_inject 按 kind 投影成 Augmentation 注入 system prompt)。
* undefined/空数组 → 不传(后端 None 走无 mention 路径,向后兼容)。
*/
sendMessage(message: string, language?: string, skill?: string, modelOverride?: string | null, parts?: ContentPart[], conversationId?: string | null): Promise<string> {
sendMessage(message: string, language?: string, skill?: string, modelOverride?: string | null, parts?: ContentPart[], conversationId?: string | null, mentionSpans?: MentionSpan[]): Promise<string> {
return invoke('ai_chat_send', {
message,
language: language || 'zh-CN',
@@ -19,11 +22,13 @@ export const aiApi = {
parts: parts && parts.length > 0 ? parts : null,
// F-260616-09 B 批4(决策 e):传 conv_id,操作指定 conv 的 per_conv(不依赖 active 单值)。
conversationId: conversationId || null,
// Input Augmentation: 非空数组才传(undefined/空让 payload 不含该键,后端默认 None)。
mentionSpans: mentionSpans && mentionSpans.length > 0 ? mentionSpans : null,
})
},
/** 强制发送B-260616-02: 复位 generating 残留后走 send 同款流程parts 透传同 sendMessage。 */
forceSend(message: string, language?: string, skill?: string, modelOverride?: string | null, parts?: ContentPart[], conversationId?: string | null): Promise<string> {
/** 强制发送B-260616-02: 复位 generating 残留后走 send 同款流程parts/mentionSpans 透传同 sendMessage。 */
forceSend(message: string, language?: string, skill?: string, modelOverride?: string | null, parts?: ContentPart[], conversationId?: string | null, mentionSpans?: MentionSpan[]): Promise<string> {
return invoke('ai_chat_force_send', {
message,
language: language || 'zh-CN',
@@ -32,6 +37,8 @@ export const aiApi = {
parts: parts && parts.length > 0 ? parts : null,
// F-260616-09 B 批4(决策 e):传 conv_id,强制复位+发送仅作用于目标 conv。
conversationId: conversationId || null,
// Input Augmentation: 同 sendMessage,非空数组才传(后端 mention_spans 参数)。
mentionSpans: mentionSpans && mentionSpans.length > 0 ? mentionSpans : null,
})
},
@@ -94,8 +101,9 @@ export const aiApi = {
return invoke('ai_stop_loop', { conversationId })
},
/** 查询某对话积压的待审批工具(重启后恢复 toolCard pending_approval 态用) */
pendingToolCalls(convId: string): Promise<{ tool_call_id: string; conversation_id: string | null }[]> {
/** 查询某对话积压的待审批工具(重启后恢复 toolCard pending_approval 态用)
* 阶段4:返 kind 字段(risk/path),前端按 kind 渲染不同决策按钮。 */
pendingToolCalls(convId: string): Promise<{ tool_call_id: string; conversation_id: string | null; kind: 'risk' | 'path' }[]> {
return invoke('ai_pending_tool_calls', { convId })
},
@@ -224,6 +232,17 @@ export const aiApi = {
return invoke('ai_list_skills')
},
/**
* Input Augmentation:进程内重载 skills 缓存(OnceLock → RwLock 后支持热重载)。
*
* 用户增删/修改 SKILL.md 后无需重启即可让后续 `/技能` 注入读到最新内容。
* 后端 ai_reload_skills 复用 scan_skills 走剥 frontmatter 的读取 + invalidate 缓存,
* 返回重载后的全量 skills 列表(供前端同步刷新 skills state)。
*/
reloadSkills(): Promise<SkillInfo[]> {
return invoke('ai_reload_skills')
},
/** F-260619-03 Phase A: 获取 AI 工具文件访问授权目录列表(含 workspace_root) */
getAllowedDirs(): Promise<string[]> {
return invoke<string[]>('ai_get_allowed_dirs')