新增: Phase2 阶段收尾(Sprint 1-20)

重构:删 5 零引用 crate(df-evolve/plugin/stages/task/traceability)+ 清死模块、ai.rs 拆 11 子 module、ai.ts 拆 6 composable、i18n 拆目录
功能:知识库全栈(df-project/scan + CRUD + 时间线 + 前端)、Settings 拆分、appSettings KV 迁移、模型池、LLM 并发 Semaphore
修复:审批持久化根治、ConditionEngine 默认拒绝、NodeRegistry unimplemented 清除、promote 补偿删除、工具结果截断 50KB、路径校验防 symlink 逃逸
文档:B-03 人工审批设计、决策记录三分档、规格契约自检、经验记录、todo 看板、PROGRESS 更新

详见 PROGRESS.md。src-tauri/儿童每日打卡应用/ 与本项目无关,已排除。
This commit is contained in:
2026-06-14 14:08:20 +08:00
parent 98393b4908
commit cf017f81e2
167 changed files with 19549 additions and 6886 deletions

View File

@@ -38,6 +38,10 @@ export interface ProjectRecord {
description: string
status: string // planning | in_progress | paused | completed | cancelled
idea_id: string | null
/** 绑定的本地代码目录绝对路径(null=未绑定) */
path: string | null
/** 技术栈 JSON 数组字符串(如 ["rust","vue"],null=未探测) */
stack: string | null
created_at: string
updated_at: string
}
@@ -46,6 +50,30 @@ export interface CreateProjectInput {
name: string
description?: string
idea_id?: string
/** 绑定的本地代码目录(可选) */
path?: string
/** 技术栈 JSON 数组字符串(可选,空则后端自动探测) */
stack?: string
}
/** AI 扫描项目结果(预览用,用户确认后填入) */
export interface AiScanResult {
/** 项目摘要(空=LLM 未得出,需手填) */
description: string
/** 技术栈(规则 LLM,去重小写) */
stack: string[]
/** 项目类型(web/api/cli/library/desktop/mobile/monorepo/other) */
project_type: string | null
/** LLM 原始返回(降级时含错误信息) */
raw: string | null
}
/** 想法晋升结果(后端 promote_idea 返回) */
export interface PromotionResult {
idea_id: string
project_id: string
promoted: boolean
reason: string
}
// ============================================================
@@ -141,7 +169,7 @@ export type AiChatEvent = ({
} | {
type: 'AiApprovalResult'; id: string; approved: boolean
} | {
type: 'AiCompleted'; total_tokens: number
type: 'AiCompleted'; total_tokens: number; prompt_tokens: number; completion_tokens: number
} | {
type: 'AiError'; error: string
} | {
@@ -157,6 +185,8 @@ export interface AiMessage {
content: string
isError?: boolean
toolCalls?: AiToolCallInfo[]
/** 生成该消息的 model(仅 assistant 消息,历史消息从 DB 读) */
model?: string
timestamp: number
}
@@ -167,6 +197,8 @@ export interface AiToolCallInfo {
args: unknown
status: 'running' | 'pending_approval' | 'completed' | 'rejected'
result?: unknown
/** 审批风险说明AiApprovalRequired 时填充) */
reason?: string
}
/** 对话列表摘要 */
@@ -175,6 +207,10 @@ export interface AiConversationSummary {
title: string | null
provider_id: string | null
model: string | null
models?: string[] | null
archived: boolean
prompt_tokens?: number | null
completion_tokens?: number | null
created_at: string
updated_at: string
}
@@ -202,3 +238,97 @@ export interface AiConversationDetail {
title: string | null
messages: string // JSON string of ChatMessage[]
}
/** 技能信息(本机 Claude skill供 `/` 联想 + 注入) */
export interface SkillInfo {
name: string
description: string
argument_hint?: string
/** skill | command | plugin */
source: string
/** SKILL.md 绝对路径(后端注入时读全文) */
path: string
}
// ============================================================
// 知识库
// ============================================================
/** 知识条目(与 Rust KnowledgeRecord 严格对齐) */
export interface KnowledgeRecord {
id: string
kind: string // review_rule | prompt_template | pitfall | architecture_pattern | diagnosis | deployment_note | workflow_optimization
title: string
content: string
tags: string | null // JSON 数组字符串
status: string // candidate | pending_review | published | archived
confidence: string | null // high | medium | low
reuse_count: number
verified: boolean
source_project: string | null
source_ref: string | null
/** AI 提炼判断依据("为何值得沉淀"),手动录入为 null */
reasoning: string | null
created_at: string
updated_at: string
}
/** 创建知识入参 */
export interface CreateKnowledgeInput {
kind: string
title: string
content: string
tags?: string
source_project?: string
source_ref?: string
confidence?: string
}
/** 检索知识入参 */
export interface KnowledgeSearchInput {
query: string
kind?: string
limit?: number
}
/** 知识生命线事件记录(产生/审核/引用/归档审计) */
export interface KnowledgeEventRecord {
id: string
knowledge_id: string
/** created | extracted | status_changed | referenced */
event_type: string
source_ref: string | null
/** JSON 字符串,内容因 event_type 而异(见后端 KnowledgeTimeline) */
context_json: string | null
timestamp: string
}
/** 知识详情聚合负载(基本信息 + 全部生命线事件) */
export interface KnowledgeDetailPayload {
knowledge: KnowledgeRecord
events: KnowledgeEventRecord[]
}
/** 编辑知识入参(部分更新,仅传需改字段) */
export interface UpdateKnowledgeInput {
title?: string
content?: string
tags?: string
confidence?: string
reasoning?: string
}
/** 知识库行为配置(提取 + 注入 + 向量检索) */
export interface KnowledgeConfig {
auto_extract: boolean
trigger_mode: 'on_complete' | 'on_idle' | 'manual_only'
min_messages: number
idle_timeout_ms: number
auto_inject: boolean
/** 语义检索(向量)开关,默认 false——关闭时纯 LIKE 零外部依赖 */
vector_enabled: boolean
/** embedding 用的 provider id(仅 openai_compat 类型) */
embedding_provider_id: string | null
/** embedding 模型名(如 embedding-3) */
embedding_model: string | null
}