1 N 1 N 1 N 1 N 1 N 1 N 1 N 1 N M:N 1 N Workspace id cuid PK name string description? string createdAt datetime updatedAt datetime has: projects[], labels[] Project id cuid PK name, alias?, description? type GIT|NORMAL gitUrl?, localPath? projectType? string workspaceId FK → Workspace has: tasks[], repositories[] Task id cuid PK title, description? status TODO|IN_PROGRESS|IN_REVIEW|DONE|CANCELLED priority LOW|MEDIUM|HIGH|CRITICAL order int, pinned bool baseBranch?, subPath? projectId FK → Project has: executions[], messages[], labels[] TaskExecution id cuid PK taskId FK → Task agent string (def: CLAUDE_CODE) status PENDING|RUNNING|PAUSED|COMPLETED|FAILED sessionId?, worktreePath? summary?, gitLog? startedAt?, endedAt? has: messages[] Label id cuid PK name string color hex (#94a3b8) isBuiltin bool workspaceId? FK TaskLabel taskId FK → Task labelId FK → Label @@id([taskId, labelId]) join table (M:N) TaskMessage id cuid PK taskId FK, executionId? FK role USER|ASSISTANT|SYSTEM content string metadata? JSON Repository id cuid PK name, path string branch (def: main) projectId FK → Project ProjectNote id cuid PK title, content string category? string projectId FK, taskId? FK ProjectAsset id cuid PK filename, mimeType string size int projectId FK, taskId? FK CliProfile id cuid PK command (def: claude) baseArgs JSON string[] envVars JSON object isDefault bool AgentConfig id cuid PK agent, configName string appendPrompt? string settings? JSON isDefault bool @@unique AgentPrompt id cuid PK name, content string workspaceId? FK isDefault bool Legend Primary (Core) Execution Join / Label Content Config 1:N relationship 核心实体 Workspace → Project → Task 层级结构 级联删除:删除父级自动清理子级数据 执行与消息 TaskExecution 记录执行历史与状态 TaskMessage 保存 AI 对话上下文 配置 CliProfile CLI 配置, AgentConfig 代理配置 AgentPrompt 提示模板,支持工作区级别隔离 Tower Data Model · 13 Entities