新增: 初始化 DevFlow 项目仓库

Tauri 2 + Vue 3 + Vite 6 桌面应用,Rust workspace 含 13 个 crate
(df-ai / df-storage / df-workflow / df-core / df-execute 等)。
核心能力:AI 聊天 agentic 循环(工具调用+人工审批)、工作流引擎、
任务/想法/项目/阶段管理、可追溯性,及配套前端组件。
This commit is contained in:
2026-06-12 01:31:05 +08:00
commit 98393b4908
178 changed files with 27859 additions and 0 deletions

204
src/api/types.ts Normal file
View File

@@ -0,0 +1,204 @@
//! TypeScript 类型定义 — 与 Rust Record 结构体严格对齐
// ============================================================
// 想法
// ============================================================
export interface IdeaRecord {
id: string
title: string
description: string
status: string // draft | pending_review | approved | promoted | rejected
priority: number
score: number | null
tags: string | null // JSON 数组字符串
source: string | null
promoted_to: string | null
ai_analysis: string | null
scores: string | null
created_at: string
updated_at: string
}
export interface CreateIdeaInput {
title: string
description?: string
priority?: number
tags?: string
source?: string
}
// ============================================================
// 项目
// ============================================================
export interface ProjectRecord {
id: string
name: string
description: string
status: string // planning | in_progress | paused | completed | cancelled
idea_id: string | null
created_at: string
updated_at: string
}
export interface CreateProjectInput {
name: string
description?: string
idea_id?: string
}
// ============================================================
// 任务
// ============================================================
export interface TaskRecord {
id: string
project_id: string
title: string
description: string
status: string // todo | in_progress | review_ready | merged | abandoned
priority: number // 0=critical, 1=high, 2=medium, 3=low
branch_name: string | null
assignee: string | null
workflow_def_id: string | null
base_branch: string | null
created_at: string
updated_at: string
}
export interface CreateTaskInput {
project_id: string
title: string
description?: string
priority?: number
branch_name?: string
assignee?: string
}
// ============================================================
// 工作流
// ============================================================
export interface WorkflowRecord {
id: string
name: string
dag_json: string
status: string // running | completed | failed | cancelled
triggered_by: string | null
project_id: string | null
task_id: string | null
created_at: string
completed_at: string | null
}
/** 工作流事件载荷(后端 emit 的结构) */
export interface WorkflowEventPayload {
execution_id: string
event: {
type: string
[key: string]: unknown
}
}
// ============================================================
// 通用
// ============================================================
export type UpdateField = {
id: string
field: string
value: string
}
// ============================================================
// AI 聊天
// ============================================================
export interface AiProviderConfig {
id: string
name: string
provider_type: string
api_key: string
base_url: string
default_model: string
models: string | null
is_default: boolean
config: string | null
created_at: string
updated_at: string
}
/** AI 聊天事件(后端 emit 的结构conversation_id 用于多对话流式路由) */
export type AiChatEvent = ({
type: 'AiTextDelta'; delta: string
} | {
type: 'AiToolCallStarted'; id: string; name: string; args: unknown
} | {
type: 'AiToolCallCompleted'; id: string; result: unknown
} | {
type: 'AiApprovalRequired'; id: string; name: string; args: unknown; reason: string
} | {
type: 'AiApprovalResult'; id: string; approved: boolean
} | {
type: 'AiCompleted'; total_tokens: number
} | {
type: 'AiError'; error: string
} | {
type: 'AiAgentRound'; round: number
}) & {
conversation_id?: string
}
/** AI 消息前端渲染用isError 标记错误消息用于差异化样式) */
export interface AiMessage {
id: string
role: 'user' | 'assistant' | 'tool'
content: string
isError?: boolean
toolCalls?: AiToolCallInfo[]
timestamp: number
}
/** 工具调用信息 */
export interface AiToolCallInfo {
id: string
name: string
args: unknown
status: 'running' | 'pending_approval' | 'completed' | 'rejected'
result?: unknown
}
/** 对话列表摘要 */
export interface AiConversationSummary {
id: string
title: string | null
provider_id: string | null
model: string | null
created_at: string
updated_at: string
}
/** 人工审批请求 */
export interface HumanApprovalRequest {
execution_id: string
node_id: string
title: string
description: string
options: string[]
}
/** 人工审批响应 */
export interface HumanApprovalResponse {
execution_id: string
node_id: string
decision: string
comment?: string
}
/** 切换对话返回(含 messages JSON */
export interface AiConversationDetail {
id: string
title: string | null
messages: string // JSON string of ChatMessage[]
}