|
|
@@ -0,0 +1,1452 @@
|
|
|
+# λ-Scientist P0-A 项目工作区与智能体入口 Implementation Plan
|
|
|
+
|
|
|
+> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
|
|
+
|
|
|
+**Goal:** 让 λ-Scientist 以“项目 + 工作文件夹”为工作单位,用户描述目标即可开始,智能体只作为受限的执行资源出现。
|
|
|
+
|
|
|
+**Architecture:** 在 `packages/app/src/pages/paas` 内增加项目状态、智能体画像与路由三个纯逻辑模块,再把它们接入现有会话、侧栏和智能体页。项目元数据先保存在本机 `localStorage`,按平台作用域隔离;工作区路径通过桌面目录选择器绑定,并在调用工作区助手时作为 `context.work_dir` 传给现有平台接口。当前 WIP 的顶栏、文件分组和耗时修复视为前置基线,执行前先提交或保留在独立 commit 中。
|
|
|
+
|
|
|
+**Tech Stack:** SolidJS、TypeScript、Vite、Bun test、Playwright、Electron preload/IPC、现有 AgentPaaS HTTP 接口。
|
|
|
+
|
|
|
+**Spec:** `PAAS_PRODUCT_BRAINSTORM.zh-CN.md`
|
|
|
+
|
|
|
+## Global Constraints
|
|
|
+
|
|
|
+- 只修改 OpenCode 桌面端相关代码;不修改公共 Protocol/Server HttpApi。
|
|
|
+- 项目元数据先本地存储,键名必须带平台 `scope` 和 `windowID`;不得存储 API Key 或凭证。
|
|
|
+- 项目是逻辑单位,工作文件夹是物理绑定;不把绝对路径写进项目名称或智能体分类。
|
|
|
+- 默认入口不展示内部子智能体;内部角色只能通过高级视图或所属流程访问。
|
|
|
+- 智能体分类优先读取平台返回的 `entry_mode / visibility / summary / capabilities / inputs / outputs`;当前平台未返回时使用本计划中的内置画像作为过渡。
|
|
|
+- 不按自然语言模糊猜测智能体类型;只按精确 ID/名称命中和显式规则路由。
|
|
|
+- 没有绑定工作文件夹时,工作区助手不能发起;前端必须先阻止发送并给出绑定入口。
|
|
|
+- 继续遵守“右侧预览只展示 Agent 生成文件”的边界。
|
|
|
+- 所有用户文案使用中文,不使用 emoji。
|
|
|
+- 测试必须从包目录运行,禁止从仓库根目录运行。
|
|
|
+- 类型检查使用 `bun typecheck`,不得直接调用 `tsc`。
|
|
|
+- 每个 Task 独立提交;提交信息使用 conventional commit 格式。
|
|
|
+
|
|
|
+## Scope
|
|
|
+
|
|
|
+本计划只覆盖 P0-A:
|
|
|
+
|
|
|
+- 项目实体、项目切换、项目与工作文件夹绑定。
|
|
|
+- 会话归属项目、按项目过滤历史。
|
|
|
+- 智能体画像、描述覆盖、目录分组。
|
|
|
+- 目标优先路由;内部子智能体从发起入口隐藏。
|
|
|
+- 工作区助手通过项目文件夹获得 `context.work_dir`。
|
|
|
+
|
|
|
+不在本计划内:
|
|
|
+
|
|
|
+- Research Inbox 全局面板。
|
|
|
+- Run Inspector 2.0、计划审阅、证据台账。
|
|
|
+- 成果资产库、跨项目文件检索。
|
|
|
+- 团队共享、评论、权限和云端同步。
|
|
|
+- 平台侧智能体元数据最终迁移。
|
|
|
+
|
|
|
+这些能力在 P0-B/P1 计划中单独实现,避免一个变更同时动项目、任务、运行和资产四个子系统。
|
|
|
+
|
|
|
+## File Structure
|
|
|
+
|
|
|
+### 新建
|
|
|
+
|
|
|
+| 文件 | 职责 |
|
|
|
+| --- | --- |
|
|
|
+| `packages/app/src/pages/paas/projects.ts` | 项目类型、默认项目、本地状态读写、项目增删改纯函数 |
|
|
|
+| `packages/app/src/pages/paas/projects.test.ts` | 项目状态与损坏数据恢复测试 |
|
|
|
+| `packages/app/src/pages/paas/agent-profiles.ts` | 智能体入口层级、用户摘要、能力/输入/产出画像 |
|
|
|
+| `packages/app/src/pages/paas/agent-profiles.test.ts` | 分类、覆盖字段和未知智能体测试 |
|
|
|
+| `packages/app/src/pages/paas/agent-routing.ts` | 目标优先路由:显式指定、文件意图、工作区意图、默认回退 |
|
|
|
+| `packages/app/src/pages/paas/agent-routing.test.ts` | 路由规则与歧义测试 |
|
|
|
+| `packages/app/src/pages/paas/project-switcher.tsx` | 侧栏项目切换、新建项目、绑定/更换工作文件夹 |
|
|
|
+| `packages/app/e2e/paas/project-workflow.spec.ts` | 项目切换、文件夹绑定、历史隔离和自动路由端到端测试 |
|
|
|
+
|
|
|
+### 修改
|
|
|
+
|
|
|
+| 文件 | 改动 |
|
|
|
+| --- | --- |
|
|
|
+| `packages/app/src/pages/paas/chat-state.ts` | `ResearchChat.projectID`、新建会话归属、项目内激活与过滤 |
|
|
|
+| `packages/app/src/pages/paas/chat-cache.ts` | 持久化 `projectID`,旧记录迁移到默认项目 |
|
|
|
+| `packages/app/src/pages/paas/chat.tsx` | 接收项目/工作区,过滤历史与会话,接入路由选择器 |
|
|
|
+| `packages/app/src/pages/paas/index.tsx` | 项目状态、ProjectSwitcher、智能体分组渲染 |
|
|
|
+| `packages/app/src/pages/paas/paas.css` | 项目切换器、智能体分组、路由 chip 样式 |
|
|
|
+| `packages/app/src/pages/paas/studio.css` | 与现有视觉系统保持一致 |
|
|
|
+| `packages/app/src/paas.ts` | execute 请求增加可选 `workDir` |
|
|
|
+| `packages/desktop/src/main/paas.ts` | 将 `workDir` 映射为 `context.work_dir` |
|
|
|
+| `packages/desktop/src/main/paas.test.ts` | 覆盖执行 payload 的 `context.work_dir` |
|
|
|
+| `packages/app/e2e/paas/fixture.tsx` | 目录选择、项目测试数据、workspace agent |
|
|
|
+| `packages/app/src/pages/paas/README.md` | 记录项目模型与智能体入口边界 |
|
|
|
+
|
|
|
+---
|
|
|
+
|
|
|
+### Task 1: 项目状态与本地持久化
|
|
|
+
|
|
|
+**Files:**
|
|
|
+- Create: `packages/app/src/pages/paas/projects.ts`
|
|
|
+- Create: `packages/app/src/pages/paas/projects.test.ts`
|
|
|
+
|
|
|
+**Interfaces:**
|
|
|
+- Consumes: 浏览器 `Storage`
|
|
|
+- Produces:
|
|
|
+ - `type PaasProject = { id: string; name: string; workspace?: string; createdAt: number; updatedAt: number; archivedAt?: number }`
|
|
|
+ - `type PaasProjectState = { version: 1; activeID: string; projects: PaasProject[] }`
|
|
|
+ - `projectStorageKey(scope: string, windowID: string): string`
|
|
|
+ - `readProjectState(storage: Storage, scope: string, windowID: string, now?: number): PaasProjectState`
|
|
|
+ - `writeProjectState(storage: Storage, scope: string, windowID: string, state: PaasProjectState): void`
|
|
|
+ - `newProject(name: string, workspace?: string, now?: number, id?: string): PaasProject`
|
|
|
+ - `renameProject(state, id, name, now?): PaasProjectState`
|
|
|
+ - `bindProjectWorkspace(state, id, workspace, now?): PaasProjectState`
|
|
|
+ - `archiveProject(state, id, now?): PaasProjectState`
|
|
|
+
|
|
|
+- [ ] **Step 1: 写失败测试**
|
|
|
+
|
|
|
+```ts
|
|
|
+import { expect, test } from "bun:test"
|
|
|
+import {
|
|
|
+ archiveProject,
|
|
|
+ bindProjectWorkspace,
|
|
|
+ newProject,
|
|
|
+ projectStorageKey,
|
|
|
+ readProjectState,
|
|
|
+ renameProject,
|
|
|
+ writeProjectState,
|
|
|
+} from "./projects"
|
|
|
+
|
|
|
+class MemoryStorage implements Storage {
|
|
|
+ private data = new Map<string, string>()
|
|
|
+ get length() { return this.data.size }
|
|
|
+ clear() { this.data.clear() }
|
|
|
+ getItem(key: string) { return this.data.get(key) ?? null }
|
|
|
+ key(index: number) { return [...this.data.keys()][index] ?? null }
|
|
|
+ removeItem(key: string) { this.data.delete(key) }
|
|
|
+ setItem(key: string, value: string) { this.data.set(key, value) }
|
|
|
+}
|
|
|
+
|
|
|
+test("empty storage creates one stable default project", () => {
|
|
|
+ const storage = new MemoryStorage()
|
|
|
+ const first = readProjectState(storage, "scope-a", "main", 1000)
|
|
|
+ const second = readProjectState(storage, "scope-a", "main", 2000)
|
|
|
+ expect(first.activeID).toBe(second.activeID)
|
|
|
+ expect(first.projects).toHaveLength(1)
|
|
|
+ expect(first.projects[0].name).toBe("我的研究")
|
|
|
+})
|
|
|
+
|
|
|
+test("projects persist per scope and window", () => {
|
|
|
+ const storage = new MemoryStorage()
|
|
|
+ const state = readProjectState(storage, "scope-a", "main", 1000)
|
|
|
+ writeProjectState(storage, "scope-a", "main", state)
|
|
|
+ expect(storage.getItem(projectStorageKey("scope-a", "main"))).toContain("我的研究")
|
|
|
+ expect(storage.getItem(projectStorageKey("scope-b", "main"))).toBeNull()
|
|
|
+})
|
|
|
+
|
|
|
+test("rename, bind and archive preserve active project invariants", () => {
|
|
|
+ const storage = new MemoryStorage()
|
|
|
+ const state = readProjectState(storage, "scope", "main", 1000)
|
|
|
+ const project = newProject("光学综述", "D:/Research/optics", 1100, "p1")
|
|
|
+ const created = { ...state, projects: [...state.projects, project], activeID: project.id }
|
|
|
+ const renamed = renameProject(created, "p1", "超表面综述", 1200)
|
|
|
+ const bound = bindProjectWorkspace(renamed, "p1", "D:/Research/metasurface", 1300)
|
|
|
+ expect(bound.projects.find((item) => item.id === "p1")).toMatchObject({
|
|
|
+ name: "超表面综述",
|
|
|
+ workspace: "D:/Research/metasurface",
|
|
|
+ updatedAt: 1300,
|
|
|
+ })
|
|
|
+ const archived = archiveProject(bound, "p1", 1400)
|
|
|
+ expect(archived.projects.find((item) => item.id === "p1")?.archivedAt).toBe(1400)
|
|
|
+ expect(archived.activeID).not.toBe("p1")
|
|
|
+})
|
|
|
+
|
|
|
+test("corrupt project data falls back without throwing", () => {
|
|
|
+ const storage = new MemoryStorage()
|
|
|
+ storage.setItem(projectStorageKey("scope", "main"), "{broken")
|
|
|
+ const state = readProjectState(storage, "scope", "main", 1000)
|
|
|
+ expect(state.projects).toHaveLength(1)
|
|
|
+ expect(state.activeID).toBe(state.projects[0].id)
|
|
|
+})
|
|
|
+```
|
|
|
+
|
|
|
+- [ ] **Step 2: 运行测试确认失败**
|
|
|
+
|
|
|
+Run:
|
|
|
+
|
|
|
+```bash
|
|
|
+(cd packages/app && bun test --conditions=solid --preload ./happydom.ts src/pages/paas/projects.test.ts)
|
|
|
+```
|
|
|
+
|
|
|
+Expected: FAIL,提示 `projects.ts` 或导出不存在。
|
|
|
+
|
|
|
+- [ ] **Step 3: 写最小实现**
|
|
|
+
|
|
|
+```ts
|
|
|
+export type PaasProject = {
|
|
|
+ id: string
|
|
|
+ name: string
|
|
|
+ workspace?: string
|
|
|
+ createdAt: number
|
|
|
+ updatedAt: number
|
|
|
+ archivedAt?: number
|
|
|
+}
|
|
|
+
|
|
|
+export type PaasProjectState = {
|
|
|
+ version: 1
|
|
|
+ activeID: string
|
|
|
+ projects: PaasProject[]
|
|
|
+}
|
|
|
+
|
|
|
+const defaultName = "我的研究"
|
|
|
+
|
|
|
+export function projectStorageKey(scope: string, windowID: string) {
|
|
|
+ return `lambda-scientist.projects.v1:${scope}:${windowID}`
|
|
|
+}
|
|
|
+
|
|
|
+export function newProject(name: string, workspace?: string, now = Date.now(), id = crypto.randomUUID()): PaasProject {
|
|
|
+ return { id, name: name.trim() || defaultName, workspace: workspace?.trim() || undefined, createdAt: now, updatedAt: now }
|
|
|
+}
|
|
|
+
|
|
|
+function initial(now = Date.now()): PaasProjectState {
|
|
|
+ const project = newProject(defaultName, undefined, now, "project-default")
|
|
|
+ return { version: 1, activeID: project.id, projects: [project] }
|
|
|
+}
|
|
|
+
|
|
|
+export function readProjectState(storage: Storage, scope: string, windowID: string, now = Date.now()) {
|
|
|
+ const raw = storage.getItem(projectStorageKey(scope, windowID))
|
|
|
+ if (!raw) return initial(now)
|
|
|
+ try {
|
|
|
+ const value = JSON.parse(raw) as Partial<PaasProjectState>
|
|
|
+ const projects = Array.isArray(value.projects)
|
|
|
+ ? value.projects.filter(
|
|
|
+ (item): item is PaasProject =>
|
|
|
+ !!item &&
|
|
|
+ typeof item.id === "string" &&
|
|
|
+ typeof item.name === "string" &&
|
|
|
+ typeof item.createdAt === "number" &&
|
|
|
+ typeof item.updatedAt === "number",
|
|
|
+ )
|
|
|
+ : []
|
|
|
+ if (!projects.length) return initial(now)
|
|
|
+ const activeID = projects.some((item) => item.id === value.activeID && !item.archivedAt)
|
|
|
+ ? String(value.activeID)
|
|
|
+ : projects.find((item) => !item.archivedAt)?.id || projects[0].id
|
|
|
+ return { version: 1, activeID, projects }
|
|
|
+ } catch {
|
|
|
+ return initial(now)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+export function writeProjectState(storage: Storage, scope: string, windowID: string, state: PaasProjectState) {
|
|
|
+ storage.setItem(projectStorageKey(scope, windowID), JSON.stringify(state))
|
|
|
+}
|
|
|
+
|
|
|
+export function renameProject(state: PaasProjectState, id: string, name: string, now = Date.now()): PaasProjectState {
|
|
|
+ return {
|
|
|
+ ...state,
|
|
|
+ projects: state.projects.map((item) => (item.id === id ? { ...item, name: name.trim() || item.name, updatedAt: now } : item)),
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+export function bindProjectWorkspace(
|
|
|
+ state: PaasProjectState,
|
|
|
+ id: string,
|
|
|
+ workspace: string,
|
|
|
+ now = Date.now(),
|
|
|
+): PaasProjectState {
|
|
|
+ return {
|
|
|
+ ...state,
|
|
|
+ projects: state.projects.map((item) => (item.id === id ? { ...item, workspace: workspace.trim() || undefined, updatedAt: now } : item)),
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+export function archiveProject(state: PaasProjectState, id: string, now = Date.now()): PaasProjectState {
|
|
|
+ const projects = state.projects.map((item) => (item.id === id ? { ...item, archivedAt: now, updatedAt: now } : item))
|
|
|
+ const active = projects.find((item) => item.id === state.activeID && !item.archivedAt)
|
|
|
+ return { ...state, projects, activeID: active?.id || projects.find((item) => !item.archivedAt)?.id || state.activeID }
|
|
|
+}
|
|
|
+```
|
|
|
+
|
|
|
+- [ ] **Step 4: 运行测试确认通过**
|
|
|
+
|
|
|
+Run:
|
|
|
+
|
|
|
+```bash
|
|
|
+(cd packages/app && bun test --conditions=solid --preload ./happydom.ts src/pages/paas/projects.test.ts)
|
|
|
+```
|
|
|
+
|
|
|
+Expected: PASS,4 tests。
|
|
|
+
|
|
|
+- [ ] **Step 5: 提交**
|
|
|
+
|
|
|
+```bash
|
|
|
+git add packages/app/src/pages/paas/projects.ts packages/app/src/pages/paas/projects.test.ts
|
|
|
+git commit -m "feat(paas): add local project state model"
|
|
|
+```
|
|
|
+
|
|
|
+---
|
|
|
+
|
|
|
+### Task 2: 会话归属项目并持久化
|
|
|
+
|
|
|
+**Files:**
|
|
|
+- Modify: `packages/app/src/pages/paas/chat-state.ts`
|
|
|
+- Modify: `packages/app/src/pages/paas/chat-cache.ts`
|
|
|
+- Modify: `packages/app/src/pages/paas/chat-cache.test.ts`
|
|
|
+- Modify: `packages/app/src/pages/paas/chat.tsx`
|
|
|
+
|
|
|
+**Interfaces:**
|
|
|
+- Consumes: `PaasProjectState.activeID` 与 `PaasChat.props.projectID`
|
|
|
+- Produces:
|
|
|
+ - `ResearchChat.projectID?: string`
|
|
|
+ - `createResearchChats({ projectID: () => string })`
|
|
|
+ - 新会话自动写入当前 `projectID`
|
|
|
+ - 历史加载时缺失 `projectID` 的旧记录迁移为 `"project-default"`
|
|
|
+
|
|
|
+- [ ] **Step 1: 写失败测试**
|
|
|
+
|
|
|
+在 `chat-cache.test.ts` 增加:
|
|
|
+
|
|
|
+```ts
|
|
|
+test("chat metadata keeps project ownership across reload", () => {
|
|
|
+ const storage = new MemoryStorage()
|
|
|
+ const cache = createChatCache(storage, "scope", "main", () => {})
|
|
|
+ const chat: ResearchChat = {
|
|
|
+ id: "chat-1",
|
|
|
+ projectID: "project-optics",
|
|
|
+ agentID: "research67",
|
|
|
+ name: "科研助手",
|
|
|
+ title: "光学综述",
|
|
|
+ threadID: "",
|
|
|
+ draft: "整理光学综述",
|
|
|
+ files: [],
|
|
|
+ messages: [],
|
|
|
+ }
|
|
|
+ cache.stage(chat)
|
|
|
+ cache.flush()
|
|
|
+ cache.close()
|
|
|
+
|
|
|
+ const next = createChatCache(storage, "scope", "main", () => {})
|
|
|
+ expect(next.load().chats[0]?.projectID).toBe("project-optics")
|
|
|
+})
|
|
|
+```
|
|
|
+
|
|
|
+如果测试文件已有 `MemoryStorage`,复用它;没有则加入与 Task 1 相同的实现。
|
|
|
+
|
|
|
+- [ ] **Step 2: 运行测试确认失败**
|
|
|
+
|
|
|
+```bash
|
|
|
+(cd packages/app && bun test --conditions=solid --preload ./happydom.ts src/pages/paas/chat-cache.test.ts)
|
|
|
+```
|
|
|
+
|
|
|
+Expected: FAIL,`projectID` 未持久化。
|
|
|
+
|
|
|
+- [ ] **Step 3: 修改 chat-state、chat-cache 与 PaasChat 过滤**
|
|
|
+
|
|
|
+在 `chat-state.ts` 的 `ResearchChat` 增加:
|
|
|
+
|
|
|
+```ts
|
|
|
+projectID?: string
|
|
|
+```
|
|
|
+
|
|
|
+`createResearchChats` props 增加访问器:
|
|
|
+
|
|
|
+```ts
|
|
|
+projectID: () => string
|
|
|
+```
|
|
|
+
|
|
|
+`choose()` 新建会话时写入:
|
|
|
+
|
|
|
+```ts
|
|
|
+const chat: ResearchChat = {
|
|
|
+ id: crypto.randomUUID(),
|
|
|
+ projectID: props.projectID(),
|
|
|
+ agentID,
|
|
|
+ name: paasText(agent.name),
|
|
|
+ title: "新会话",
|
|
|
+ threadID: "",
|
|
|
+ draft: "",
|
|
|
+ files: [],
|
|
|
+ messages: [],
|
|
|
+}
|
|
|
+```
|
|
|
+
|
|
|
+历史加载 map 中补迁移:
|
|
|
+
|
|
|
+```ts
|
|
|
+projectID: typeof c.projectID === "string" && c.projectID ? c.projectID : "project-default",
|
|
|
+```
|
|
|
+
|
|
|
+`chat-cache.ts` 的 `Metadata` 和 `metadata()` 增加:
|
|
|
+
|
|
|
+```ts
|
|
|
+projectID: chat.projectID
|
|
|
+```
|
|
|
+
|
|
|
+`chat.tsx` 增加 props:
|
|
|
+
|
|
|
+```ts
|
|
|
+projectID: string
|
|
|
+```
|
|
|
+
|
|
|
+`createResearchChats` 调用增加:
|
|
|
+
|
|
|
+```ts
|
|
|
+get projectID() {
|
|
|
+ return props.projectID
|
|
|
+},
|
|
|
+```
|
|
|
+
|
|
|
+`sessionGroups` 与 `drafts` 的过滤增加:
|
|
|
+
|
|
|
+```ts
|
|
|
+chat.projectID === props.projectID
|
|
|
+```
|
|
|
+
|
|
|
+切换项目时,如果当前会话不属于新项目,激活该项目下最近会话;没有则创建一个使用 `props.agents[0]` 的空白会话:
|
|
|
+
|
|
|
+```ts
|
|
|
+createEffect(
|
|
|
+ on(
|
|
|
+ () => props.projectID,
|
|
|
+ (projectID) => {
|
|
|
+ const chat = current()
|
|
|
+ if (chat?.projectID === projectID) return
|
|
|
+ const next = state.chats.find((item) => item.projectID === projectID && hasConversationHistory(item))
|
|
|
+ if (next) show(next.id)
|
|
|
+ else if (props.agents[0]) model.choose(props.agents[0], true)
|
|
|
+ },
|
|
|
+ ),
|
|
|
+)
|
|
|
+```
|
|
|
+
|
|
|
+- [ ] **Step 4: 运行测试**
|
|
|
+
|
|
|
+```bash
|
|
|
+(cd packages/app && bun test --conditions=solid --preload ./happydom.ts src/pages/paas/chat-cache.test.ts src/pages/paas/projects.test.ts)
|
|
|
+```
|
|
|
+
|
|
|
+Expected: PASS。再运行 `(cd packages/app && bun typecheck)`。
|
|
|
+
|
|
|
+- [ ] **Step 5: 提交**
|
|
|
+
|
|
|
+```bash
|
|
|
+git add packages/app/src/pages/paas/chat-state.ts packages/app/src/pages/paas/chat-cache.ts packages/app/src/pages/paas/chat-cache.test.ts packages/app/src/pages/paas/chat.tsx
|
|
|
+git commit -m "feat(paas): bind research chats to projects"
|
|
|
+```
|
|
|
+
|
|
|
+---
|
|
|
+
|
|
|
+### Task 3: 智能体画像、用户摘要与分组
|
|
|
+
|
|
|
+**Files:**
|
|
|
+- Create: `packages/app/src/pages/paas/agent-profiles.ts`
|
|
|
+- Create: `packages/app/src/pages/paas/agent-profiles.test.ts`
|
|
|
+
|
|
|
+**Interfaces:**
|
|
|
+- Consumes: `Record<string, unknown>` 平台智能体
|
|
|
+- Produces:
|
|
|
+ - `type AgentEntryMode = "default" | "professional" | "workflow" | "internal"`
|
|
|
+ - `type AgentProfile = { entryMode; summary; capabilities; inputs; outputs; example; requiresWorkspace }`
|
|
|
+ - `resolveAgentProfile(agent): AgentProfile`
|
|
|
+ - `groupAgents(agents): { default; professional; workflow; internal }`
|
|
|
+ - `directAgents(agents): Record<string, unknown>[]`
|
|
|
+
|
|
|
+- [ ] **Step 1: 写失败测试**
|
|
|
+
|
|
|
+```ts
|
|
|
+import { expect, test } from "bun:test"
|
|
|
+import { directAgents, groupAgents, resolveAgentProfile } from "./agent-profiles"
|
|
|
+
|
|
|
+const agent = (name: string, id = name) => ({ id, name })
|
|
|
+
|
|
|
+test("built-in internal subagents never appear as direct entries", () => {
|
|
|
+ const agents = [
|
|
|
+ agent("research67"),
|
|
|
+ agent("评审反馈合成器"),
|
|
|
+ agent("本体证据补全员"),
|
|
|
+ agent("data67"),
|
|
|
+ ]
|
|
|
+ expect(directAgents(agents).map((item) => item.name)).toEqual(["research67", "data67"])
|
|
|
+ expect(resolveAgentProfile(agent("本体证据补全员")).entryMode).toBe("internal")
|
|
|
+})
|
|
|
+
|
|
|
+test("agent directory groups all four entry modes", () => {
|
|
|
+ const groups = groupAgents([
|
|
|
+ agent("data67"),
|
|
|
+ agent("工作区助手"),
|
|
|
+ agent("research67"),
|
|
|
+ agent("顶刊审稿助手"),
|
|
|
+ agent("Research67 三阶段研究草稿流水线"),
|
|
|
+ agent("实验执行员"),
|
|
|
+ ])
|
|
|
+ expect(groups.default.map((item) => item.name)).toEqual(["data67", "工作区助手", "research67"])
|
|
|
+ expect(groups.professional.map((item) => item.name)).toEqual(["顶刊审稿助手"])
|
|
|
+ expect(groups.workflow.map((item) => item.name)).toEqual(["Research67 三阶段研究草稿流水线"])
|
|
|
+ expect(groups.internal.map((item) => item.name)).toEqual(["实验执行员"])
|
|
|
+})
|
|
|
+
|
|
|
+test("platform metadata overrides local transitional profile", () => {
|
|
|
+ const profile = resolveAgentProfile({
|
|
|
+ id: "custom",
|
|
|
+ name: "自定义智能体",
|
|
|
+ summary: "整理访谈记录",
|
|
|
+ entry_mode: "default",
|
|
|
+ capabilities: ["访谈分析"],
|
|
|
+ inputs: ["访谈文本"],
|
|
|
+ outputs: ["主题报告"],
|
|
|
+ })
|
|
|
+ expect(profile).toMatchObject({
|
|
|
+ entryMode: "default",
|
|
|
+ summary: "整理访谈记录",
|
|
|
+ capabilities: ["访谈分析"],
|
|
|
+ inputs: ["访谈文本"],
|
|
|
+ outputs: ["主题报告"],
|
|
|
+ })
|
|
|
+})
|
|
|
+
|
|
|
+test("unknown agents remain directly usable", () => {
|
|
|
+ expect(resolveAgentProfile({ id: "custom", name: "新智能体", description: "自定义能力" })).toMatchObject({
|
|
|
+ entryMode: "professional",
|
|
|
+ summary: "自定义能力",
|
|
|
+ })
|
|
|
+})
|
|
|
+```
|
|
|
+
|
|
|
+- [ ] **Step 2: 运行测试确认失败**
|
|
|
+
|
|
|
+```bash
|
|
|
+(cd packages/app && bun test --conditions=solid --preload ./happydom.ts src/pages/paas/agent-profiles.test.ts)
|
|
|
+```
|
|
|
+
|
|
|
+Expected: FAIL,模块不存在。
|
|
|
+
|
|
|
+- [ ] **Step 3: 实现画像**
|
|
|
+
|
|
|
+```ts
|
|
|
+import { paasText } from "@/paas"
|
|
|
+
|
|
|
+export type AgentEntryMode = "default" | "professional" | "workflow" | "internal"
|
|
|
+
|
|
|
+export type AgentProfile = {
|
|
|
+ entryMode: AgentEntryMode
|
|
|
+ summary: string
|
|
|
+ capabilities: string[]
|
|
|
+ inputs: string[]
|
|
|
+ outputs: string[]
|
|
|
+ example: string
|
|
|
+ requiresWorkspace: boolean
|
|
|
+}
|
|
|
+
|
|
|
+const groups: Record<string, AgentEntryMode> = {
|
|
|
+ research67: "default",
|
|
|
+ data67: "default",
|
|
|
+ "工作区助手": "default",
|
|
|
+ "顶刊审稿助手": "professional",
|
|
|
+ "论文评审员": "professional",
|
|
|
+ "数据核验员": "professional",
|
|
|
+ "结果分析师": "professional",
|
|
|
+ "文献检索员": "professional",
|
|
|
+ "创意分析师": "professional",
|
|
|
+ "Research67 三阶段研究草稿流水线": "workflow",
|
|
|
+ "Research67 科研主编排器": "workflow",
|
|
|
+ "评审反馈合成器": "internal",
|
|
|
+ "实验执行员": "internal",
|
|
|
+ "实验规划师": "internal",
|
|
|
+ "论文撰写员": "internal",
|
|
|
+ "本体主张核验员": "internal",
|
|
|
+ "本体实验规划员": "internal",
|
|
|
+ "本体动作推理员": "internal",
|
|
|
+ "本体动作研究计划员": "internal",
|
|
|
+ "可证伪假设构建员": "internal",
|
|
|
+ "本体证据补全员": "internal",
|
|
|
+ "本体完备性审计员": "internal",
|
|
|
+}
|
|
|
+
|
|
|
+const summaries: Record<string, string> = {
|
|
|
+ research67: "从研究问题出发,支持连续追问、证据检索和研究方案起草。",
|
|
|
+ data67: "处理表格、数据清洗、统计分析和图表生成。",
|
|
|
+ "工作区助手": "在绑定的项目文件夹里读写文件、整理材料、修改代码并记录变更。",
|
|
|
+ "顶刊审稿助手": "按顶刊标准评审论文,输出贡献、风险、中稿概率和修改清单。",
|
|
|
+ "论文评审员": "模拟会议审稿流程,输出结构化评审意见。",
|
|
|
+ "数据核验员": "逐项核对论文与数据中的数字、表格和引用是否一致。",
|
|
|
+ "结果分析师": "分析实验结果,生成统计检验、对比表格和图表。",
|
|
|
+ "文献检索员": "围绕研究主题检索并整理有出处的文献综述。",
|
|
|
+ "创意分析师": "评估研究想法的新颖性、可研究性和潜在风险。",
|
|
|
+ "Research67 三阶段研究草稿流水线": "自动完成文献调研、研究方案、论文草稿和评审。",
|
|
|
+ "Research67 科研主编排器": "协调多个研究角色完成从设想到论文的长流程。",
|
|
|
+}
|
|
|
+
|
|
|
+const fallback = (entryMode: AgentEntryMode, name: string): AgentProfile => ({
|
|
|
+ entryMode,
|
|
|
+ summary: entryMode === "internal" ? `${name}由研究流程调用,通常不需要单独发起。` : "暂无用户摘要,请查看智能体详情。",
|
|
|
+ capabilities: [],
|
|
|
+ inputs: [],
|
|
|
+ outputs: [],
|
|
|
+ example: "",
|
|
|
+ requiresWorkspace: false,
|
|
|
+})
|
|
|
+
|
|
|
+export function resolveAgentProfile(agent: Record<string, unknown>): AgentProfile {
|
|
|
+ const id = paasText(agent.id)
|
|
|
+ const name = paasText(agent.name)
|
|
|
+ const local = groups[id] || groups[name] || "professional"
|
|
|
+ const text = (key: string, current: string[]) => {
|
|
|
+ const value = agent[key]
|
|
|
+ return Array.isArray(value) ? value.filter((item): item is string => typeof item === "string") : current
|
|
|
+ }
|
|
|
+ const summary = paasText(agent.summary) || summaries[id] || summaries[name] || paasText(agent.description)
|
|
|
+ const entryMode = ["default", "professional", "workflow", "internal"].includes(paasText(agent.entry_mode))
|
|
|
+ ? (paasText(agent.entry_mode) as AgentEntryMode)
|
|
|
+ : local
|
|
|
+ return {
|
|
|
+ entryMode,
|
|
|
+ summary: summary || fallback(entryMode, name).summary,
|
|
|
+ capabilities: text("capabilities", []),
|
|
|
+ inputs: text("inputs", []),
|
|
|
+ outputs: text("outputs", []),
|
|
|
+ example: paasText(agent.example),
|
|
|
+ requiresWorkspace: agent.requires_workspace === true || name === "工作区助手",
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+export function groupAgents(agents: Record<string, unknown>[]) {
|
|
|
+ const result = { default: [], professional: [], workflow: [], internal: [] } as Record<
|
|
|
+ AgentEntryMode,
|
|
|
+ Record<string, unknown>[]
|
|
|
+ >
|
|
|
+ for (const agent of agents) result[resolveAgentProfile(agent).entryMode].push(agent)
|
|
|
+ return result
|
|
|
+}
|
|
|
+
|
|
|
+export function directAgents(agents: Record<string, unknown>[]) {
|
|
|
+ return agents.filter((agent) => resolveAgentProfile(agent).entryMode !== "internal")
|
|
|
+}
|
|
|
+```
|
|
|
+
|
|
|
+- [ ] **Step 4: 运行测试与类型检查**
|
|
|
+
|
|
|
+```bash
|
|
|
+(cd packages/app && bun test --conditions=solid --preload ./happydom.ts src/pages/paas/agent-profiles.test.ts)
|
|
|
+(cd packages/app && bun typecheck)
|
|
|
+```
|
|
|
+
|
|
|
+Expected: PASS。
|
|
|
+
|
|
|
+- [ ] **Step 5: 提交**
|
|
|
+
|
|
|
+```bash
|
|
|
+git add packages/app/src/pages/paas/agent-profiles.ts packages/app/src/pages/paas/agent-profiles.test.ts
|
|
|
+git commit -m "feat(paas): add agent entry profiles and user summaries"
|
|
|
+```
|
|
|
+
|
|
|
+---
|
|
|
+
|
|
|
+### Task 4: 侧栏项目切换与工作文件夹绑定
|
|
|
+
|
|
|
+**Files:**
|
|
|
+- Create: `packages/app/src/pages/paas/project-switcher.tsx`
|
|
|
+- Modify: `packages/app/src/pages/paas/index.tsx`
|
|
|
+- Modify: `packages/app/src/pages/paas/chat.tsx`
|
|
|
+- Modify: `packages/app/src/pages/paas/paas.css`
|
|
|
+- Modify: `packages/app/src/pages/paas/studio.css`
|
|
|
+- Modify: `packages/app/e2e/paas/fixture.tsx`
|
|
|
+- Create: `packages/app/e2e/paas/project-workflow.spec.ts`
|
|
|
+
|
|
|
+**Interfaces:**
|
|
|
+- Consumes: `PaasProjectState`、`platform.openDirectoryPickerDialog`
|
|
|
+- Produces:
|
|
|
+ - `<ProjectSwitcher projects activeID workspace onCreate onSelect onBind />`
|
|
|
+ - `PaasWorkspace` 持有项目状态并传给 `PaasChat`
|
|
|
+ - 桌面 fixture 的 `openDirectoryPickerDialog()` 返回固定测试目录
|
|
|
+
|
|
|
+- [ ] **Step 1: 写失败 E2E**
|
|
|
+
|
|
|
+```ts
|
|
|
+import { expect, test } from "@playwright/test"
|
|
|
+
|
|
|
+test("projects isolate chat history and keep a bound workspace after reload", async ({ page }) => {
|
|
|
+ await page.goto("/e2e/paas/index.html")
|
|
|
+ await page.getByLabel("API Key", { exact: true }).fill("project-test")
|
|
|
+ await page.getByRole("button", { name: "连接平台", exact: true }).click()
|
|
|
+ await expect(page.getByRole("textbox", { name: "消息", exact: true })).toBeEnabled()
|
|
|
+
|
|
|
+ await page.getByRole("button", { name: "新建项目", exact: true }).click()
|
|
|
+ await page.getByLabel("项目名称", { exact: true }).fill("光学综述")
|
|
|
+ await page.getByRole("button", { name: "创建项目", exact: true }).click()
|
|
|
+ await expect(page.getByLabel("切换项目", { exact: true })).toContainText("光学综述")
|
|
|
+
|
|
|
+ await page.getByRole("button", { name: "绑定工作文件夹", exact: true }).click()
|
|
|
+ await expect(page.getByText("D:/Research/optics", { exact: true })).toBeVisible()
|
|
|
+
|
|
|
+ await page.getByRole("textbox", { name: "消息", exact: true }).fill("光学综述草稿")
|
|
|
+ await page.getByRole("textbox", { name: "消息", exact: true }).press("Enter")
|
|
|
+ await expect(page.getByRole("button", { name: /已有研究/ }).first()).toBeHidden()
|
|
|
+
|
|
|
+ await page.reload()
|
|
|
+ await page.getByLabel("API Key", { exact: true }).fill("project-test")
|
|
|
+ await page.getByRole("button", { name: "连接平台", exact: true }).click()
|
|
|
+ await expect(page.getByLabel("切换项目", { exact: true })).toContainText("光学综述")
|
|
|
+ await expect(page.getByText("D:/Research/optics", { exact: true })).toBeVisible()
|
|
|
+})
|
|
|
+```
|
|
|
+
|
|
|
+- [ ] **Step 2: 运行测试确认失败**
|
|
|
+
|
|
|
+```bash
|
|
|
+(cd packages/app && bun x --no-install playwright test e2e/paas/project-workflow.spec.ts --config e2e/paas/playwright.config.ts)
|
|
|
+```
|
|
|
+
|
|
|
+Expected: FAIL,找不到“新建项目”或“切换项目”。
|
|
|
+
|
|
|
+- [ ] **Step 3: 实现 ProjectSwitcher 与状态接线**
|
|
|
+
|
|
|
+`project-switcher.tsx`:
|
|
|
+
|
|
|
+```tsx
|
|
|
+import { Show, createSignal } from "solid-js"
|
|
|
+import { usePlatform } from "@/context/platform"
|
|
|
+import type { PaasProject } from "./projects"
|
|
|
+
|
|
|
+export function ProjectSwitcher(props: {
|
|
|
+ projects: PaasProject[]
|
|
|
+ activeID: string
|
|
|
+ onSelect: (id: string) => void
|
|
|
+ onCreate: (name: string) => void
|
|
|
+ onBind: (workspace: string) => void
|
|
|
+}) {
|
|
|
+ const platform = usePlatform()
|
|
|
+ const active = () => props.projects.find((item) => item.id === props.activeID)
|
|
|
+ const [creating, setCreating] = createSignal(false)
|
|
|
+ const [name, setName] = createSignal("")
|
|
|
+
|
|
|
+ const bind = async () => {
|
|
|
+ if (platform.platform !== "desktop") return
|
|
|
+ const directory = await platform.openDirectoryPickerDialog({ title: "选择项目工作文件夹" })
|
|
|
+ if (typeof directory === "string" && directory.trim()) props.onBind(directory)
|
|
|
+ }
|
|
|
+
|
|
|
+ return (
|
|
|
+ <section class="paas-project-switcher" aria-label="项目">
|
|
|
+ <div class="paas-project-row">
|
|
|
+ <select
|
|
|
+ aria-label="切换项目"
|
|
|
+ value={props.activeID}
|
|
|
+ onChange={(event) => props.onSelect(event.currentTarget.value)}
|
|
|
+ >
|
|
|
+ {props.projects.filter((item) => !item.archivedAt).map((item) => (
|
|
|
+ <option value={item.id}>{item.name}</option>
|
|
|
+ ))}
|
|
|
+ </select>
|
|
|
+ <button type="button" onClick={() => setCreating(!creating())}>新建项目</button>
|
|
|
+ </div>
|
|
|
+ <Show when={creating()}>
|
|
|
+ <form
|
|
|
+ onSubmit={(event) => {
|
|
|
+ event.preventDefault()
|
|
|
+ if (!name().trim()) return
|
|
|
+ props.onCreate(name().trim())
|
|
|
+ setName("")
|
|
|
+ setCreating(false)
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ <label>
|
|
|
+ 项目名称
|
|
|
+ <input aria-label="项目名称" value={name()} onInput={(event) => setName(event.currentTarget.value)} />
|
|
|
+ </label>
|
|
|
+ <button type="submit">创建项目</button>
|
|
|
+ </form>
|
|
|
+ </Show>
|
|
|
+ <div class="paas-project-workspace">
|
|
|
+ <Show when={active()?.workspace} fallback={<span>尚未绑定工作文件夹</span>}>
|
|
|
+ {(workspace) => <span title={workspace()}>{workspace()}</span>}
|
|
|
+ </Show>
|
|
|
+ <button type="button" onClick={() => void bind()}>
|
|
|
+ {active()?.workspace ? "更换工作文件夹" : "绑定工作文件夹"}
|
|
|
+ </button>
|
|
|
+ </div>
|
|
|
+ </section>
|
|
|
+ )
|
|
|
+}
|
|
|
+```
|
|
|
+
|
|
|
+`index.tsx` 在组件顶部增加导入并使用 `createStore` 保存项目状态:
|
|
|
+
|
|
|
+```ts
|
|
|
+import { createStore, reconcile, unwrap } from "solid-js/store"
|
|
|
+import { bindProjectWorkspace, newProject, readProjectState, writeProjectState } from "./projects"
|
|
|
+
|
|
|
+const [projects, setProjects] = createStore(
|
|
|
+ readProjectState(localStorage, state.scope || "local", platform.windowID || "main"),
|
|
|
+)
|
|
|
+const activeProject = createMemo(() => projects.projects.find((item) => item.id === projects.activeID))
|
|
|
+```
|
|
|
+
|
|
|
+连接作用域变化时重新读取:
|
|
|
+
|
|
|
+```ts
|
|
|
+createEffect(
|
|
|
+ on(
|
|
|
+ () => state.scope,
|
|
|
+ (scope) => {
|
|
|
+ if (!scope) return
|
|
|
+ setProjects(reconcile(readProjectState(localStorage, scope, platform.windowID || "main")))
|
|
|
+ },
|
|
|
+ ),
|
|
|
+)
|
|
|
+```
|
|
|
+
|
|
|
+写回:
|
|
|
+
|
|
|
+```ts
|
|
|
+const saveProjects = () => {
|
|
|
+ if (!state.scope) return
|
|
|
+ writeProjectState(localStorage, state.scope, platform.windowID || "main", unwrap(projects))
|
|
|
+}
|
|
|
+```
|
|
|
+
|
|
|
+侧栏渲染放在“新会话”按钮之前:
|
|
|
+
|
|
|
+```tsx
|
|
|
+<ProjectSwitcher
|
|
|
+ projects={projects.projects}
|
|
|
+ activeID={projects.activeID}
|
|
|
+ onSelect={(activeID) => {
|
|
|
+ setProjects("activeID", activeID)
|
|
|
+ saveProjects()
|
|
|
+ }}
|
|
|
+ onCreate={(name) => {
|
|
|
+ const project = newProject(name)
|
|
|
+ setProjects("projects", (items) => [...items, project])
|
|
|
+ setProjects("activeID", project.id)
|
|
|
+ saveProjects()
|
|
|
+ }}
|
|
|
+ onBind={(workspace) => {
|
|
|
+ setProjects(reconcile(bindProjectWorkspace(unwrap(projects), projects.activeID, workspace)))
|
|
|
+ saveProjects()
|
|
|
+ }}
|
|
|
+/>
|
|
|
+```
|
|
|
+
|
|
|
+`PaasChat` 增加并向下传递:
|
|
|
+
|
|
|
+```ts
|
|
|
+projectID={projects.activeID}
|
|
|
+workspace={activeProject()?.workspace}
|
|
|
+```
|
|
|
+
|
|
|
+测试 fixture 的 `platform` 增加:
|
|
|
+
|
|
|
+```ts
|
|
|
+openDirectoryPickerDialog: async () => "D:/Research/optics",
|
|
|
+```
|
|
|
+
|
|
|
+- [ ] **Step 4: 运行 E2E 与视觉检查**
|
|
|
+
|
|
|
+```bash
|
|
|
+(cd packages/app && bun x --no-install playwright test e2e/paas/project-workflow.spec.ts --config e2e/paas/playwright.config.ts)
|
|
|
+```
|
|
|
+
|
|
|
+Expected: PASS。手动检查 1280 和 600 宽度,项目切换器不挤压导航。
|
|
|
+
|
|
|
+- [ ] **Step 5: 提交**
|
|
|
+
|
|
|
+```bash
|
|
|
+git add packages/app/src/pages/paas/project-switcher.tsx packages/app/src/pages/paas/index.tsx packages/app/src/pages/paas/chat.tsx packages/app/src/pages/paas/paas.css packages/app/src/pages/paas/studio.css packages/app/e2e/paas/fixture.tsx packages/app/e2e/paas/project-workflow.spec.ts
|
|
|
+git commit -m "feat(paas): add project switcher and workspace binding"
|
|
|
+```
|
|
|
+
|
|
|
+---
|
|
|
+
|
|
|
+### Task 5: 工作区助手使用项目文件夹上下文
|
|
|
+
|
|
|
+**Files:**
|
|
|
+- Modify: `packages/app/src/paas.ts`
|
|
|
+- Modify: `packages/app/src/pages/paas/chat-state.ts`
|
|
|
+- Modify: `packages/app/src/pages/paas/chat.tsx`
|
|
|
+- Modify: `packages/desktop/src/main/paas.ts`
|
|
|
+- Modify: `packages/desktop/src/main/paas.test.ts`
|
|
|
+
|
|
|
+**Interfaces:**
|
|
|
+- Consumes: `AgentProfile.requiresWorkspace`、`PaasChat.props.workspace`
|
|
|
+- Produces:
|
|
|
+ - `PaasRequest execute` 可选 `workDir?: string`
|
|
|
+ - `executePayload(input)` 输出 `context: { work_dir }` 或 `{}`
|
|
|
+ - 没有工作区时阻止工作区助手发送
|
|
|
+
|
|
|
+- [ ] **Step 1: 写失败测试**
|
|
|
+
|
|
|
+在 `packages/desktop/src/main/paas.test.ts` 增加:
|
|
|
+
|
|
|
+```ts
|
|
|
+test("workspace execution forwards work_dir in context", () => {
|
|
|
+ expect(
|
|
|
+ executePayload({
|
|
|
+ action: "execute",
|
|
|
+ agentID: "workspace-assistant",
|
|
|
+ input: "整理这个目录",
|
|
|
+ workDir: "D:/Research/optics",
|
|
|
+ }),
|
|
|
+ ).toMatchObject({
|
|
|
+ context: { work_dir: "D:/Research/optics" },
|
|
|
+ mode: "iterate",
|
|
|
+ })
|
|
|
+ expect(
|
|
|
+ executePayload({ action: "execute", agentID: "research67", input: "制定研究计划" }),
|
|
|
+ ).toMatchObject({ context: {} })
|
|
|
+})
|
|
|
+```
|
|
|
+
|
|
|
+- [ ] **Step 2: 运行测试确认失败**
|
|
|
+
|
|
|
+```bash
|
|
|
+(cd packages/desktop && bun test src/main/paas.test.ts)
|
|
|
+```
|
|
|
+
|
|
|
+Expected: FAIL,`executePayload` 不存在。
|
|
|
+
|
|
|
+- [ ] **Step 3: 实现 payload 与发送守卫**
|
|
|
+
|
|
|
+`packages/app/src/paas.ts`:
|
|
|
+
|
|
|
+在 `PaasRequest` 现有的 `action: "execute"` 分支类型中增加:
|
|
|
+
|
|
|
+```ts
|
|
|
+workDir?: string
|
|
|
+```
|
|
|
+
|
|
|
+`packages/desktop/src/main/paas.ts` 增加导出函数并用于请求:
|
|
|
+
|
|
|
+```ts
|
|
|
+type ExecuteInput = Extract<PaasRequest, { action: "execute" }>
|
|
|
+
|
|
|
+export function executePayload(input: ExecuteInput) {
|
|
|
+ return {
|
|
|
+ input: input.input.trim(),
|
|
|
+ input_files: input.files || [],
|
|
|
+ thread_id: input.threadID || "",
|
|
|
+ parameters: {},
|
|
|
+ context: input.workDir ? { work_dir: input.workDir } : {},
|
|
|
+ mode: "iterate",
|
|
|
+ target_subagent: "",
|
|
|
+ effort: input.effort,
|
|
|
+ cancel_on_disconnect: false,
|
|
|
+ }
|
|
|
+}
|
|
|
+```
|
|
|
+
|
|
|
+在 `execute` 分支把原内联对象替换为 `executePayload(input)`。
|
|
|
+
|
|
|
+`chat-state.ts` 的 `send` 改为:
|
|
|
+
|
|
|
+```ts
|
|
|
+async function send(workDir?: string) {
|
|
|
+ // 其余逻辑保持不变
|
|
|
+ await props.api.request({
|
|
|
+ action: "execute",
|
|
|
+ agentID,
|
|
|
+ input,
|
|
|
+ files,
|
|
|
+ threadID: threadID || undefined,
|
|
|
+ executionID,
|
|
|
+ requestID: executionID,
|
|
|
+ effort: chat.effort,
|
|
|
+ workDir,
|
|
|
+ })
|
|
|
+}
|
|
|
+```
|
|
|
+
|
|
|
+`chat.tsx` 的发送守卫:
|
|
|
+
|
|
|
+```ts
|
|
|
+const send = () => {
|
|
|
+ const agent = currentAgent()
|
|
|
+ const profile = agent ? resolveAgentProfile(agent) : undefined
|
|
|
+ if (profile?.requiresWorkspace && !props.workspace) {
|
|
|
+ setState("error", "工作区助手需要先为当前项目绑定工作文件夹。")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (current() && !materials.busy(current()!.id)) {
|
|
|
+ bottom()
|
|
|
+ void model.send(profile?.requiresWorkspace ? props.workspace : undefined)
|
|
|
+ }
|
|
|
+}
|
|
|
+```
|
|
|
+
|
|
|
+- [ ] **Step 4: 运行测试与类型检查**
|
|
|
+
|
|
|
+```bash
|
|
|
+(cd packages/desktop && bun test src/main/paas.test.ts)
|
|
|
+(cd packages/app && bun typecheck)
|
|
|
+(cd packages/desktop && bun typecheck)
|
|
|
+```
|
|
|
+
|
|
|
+Expected: PASS。
|
|
|
+
|
|
|
+- [ ] **Step 5: 提交**
|
|
|
+
|
|
|
+```bash
|
|
|
+git add packages/app/src/paas.ts packages/app/src/pages/paas/chat-state.ts packages/app/src/pages/paas/chat.tsx packages/desktop/src/main/paas.ts packages/desktop/src/main/paas.test.ts
|
|
|
+git commit -m "feat(paas): pass project workspace to workspace assistant"
|
|
|
+```
|
|
|
+
|
|
|
+---
|
|
|
+
|
|
|
+### Task 6: 智能体页按入口层级重组
|
|
|
+
|
|
|
+**Files:**
|
|
|
+- Modify: `packages/app/src/pages/paas/index.tsx`
|
|
|
+- Modify: `packages/app/src/pages/paas/paas.css`
|
|
|
+- Modify: `packages/app/src/pages/paas/studio.css`
|
|
|
+- Modify: `packages/app/e2e/paas/project-workflow.spec.ts`
|
|
|
+- Modify: `packages/app/e2e/paas/fixture.tsx`
|
|
|
+
|
|
|
+**Interfaces:**
|
|
|
+- Consumes: `groupAgents()`、`resolveAgentProfile()`
|
|
|
+- Produces: 智能体页四段式布局;内部角色默认折叠;卡片显示摘要、输入、产出和示例
|
|
|
+
|
|
|
+- [ ] **Step 1: 写失败 E2E**
|
|
|
+
|
|
|
+在 fixture 增加查询参数 `?agent-groups`,返回以下智能体:
|
|
|
+
|
|
|
+```tsx
|
|
|
+const groupedAgents = [
|
|
|
+ agent,
|
|
|
+ { id: "data67", name: "data67", description: "数据分析" },
|
|
|
+ { id: "workspace", name: "工作区助手", description: "文件与命令" },
|
|
|
+ { id: "reviewer", name: "顶刊审稿助手", description: "论文评审" },
|
|
|
+ { id: "pipeline", name: "Research67 三阶段研究草稿流水线", description: "完整研究流程" },
|
|
|
+ { id: "internal-evidence", name: "本体证据补全员", description: "补充证据" },
|
|
|
+]
|
|
|
+```
|
|
|
+
|
|
|
+测试:
|
|
|
+
|
|
|
+```ts
|
|
|
+test("agent directory separates direct roles from internal subagents", async ({ page }) => {
|
|
|
+ await page.goto("/e2e/paas/index.html?agent-groups")
|
|
|
+ await page.getByLabel("API Key", { exact: true }).fill("agent-groups")
|
|
|
+ await page.getByRole("button", { name: "连接平台", exact: true }).click()
|
|
|
+ await page.getByRole("button", { name: "智能体", exact: true }).click()
|
|
|
+
|
|
|
+ await expect(page.getByRole("heading", { name: "默认入口", exact: true })).toBeVisible()
|
|
|
+ await expect(page.getByRole("heading", { name: "专业任务", exact: true })).toBeVisible()
|
|
|
+ await expect(page.getByRole("heading", { name: "研究流水线", exact: true })).toBeVisible()
|
|
|
+ await expect(page.getByText("本体证据补全员", { exact: true })).toBeHidden()
|
|
|
+ await page.getByText("流程内部能力 · 1", { exact: true }).click()
|
|
|
+ await expect(page.getByText("本体证据补全员", { exact: true })).toBeVisible()
|
|
|
+ await expect(page.getByRole("button", { name: "与 本体证据补全员 对话", exact: true })).toHaveCount(0)
|
|
|
+})
|
|
|
+```
|
|
|
+
|
|
|
+- [ ] **Step 2: 运行测试确认失败**
|
|
|
+
|
|
|
+```bash
|
|
|
+(cd packages/app && bun x --no-install playwright test e2e/paas/project-workflow.spec.ts --config e2e/paas/playwright.config.ts -g "agent directory")
|
|
|
+```
|
|
|
+
|
|
|
+Expected: FAIL,没有分组标题。
|
|
|
+
|
|
|
+- [ ] **Step 3: 实现分组视图**
|
|
|
+
|
|
|
+在 `index.tsx` 增加 memo:
|
|
|
+
|
|
|
+```ts
|
|
|
+const agentGroups = createMemo(() => groupAgents(visibleAgents()))
|
|
|
+```
|
|
|
+
|
|
|
+把原有单张卡片渲染提取为局部 `AgentCard` 函数,描述和主操作改为画像驱动:
|
|
|
+
|
|
|
+```tsx
|
|
|
+const profile = () => resolveAgentProfile(agent)
|
|
|
+const summary = () => profile().summary
|
|
|
+const direct = () => profile().entryMode !== "internal"
|
|
|
+
|
|
|
+<Show when={summary()}>
|
|
|
+ <p class="paas-agent-card-description" title={summary()}>{summary()}</p>
|
|
|
+</Show>
|
|
|
+<Show when={profile().capabilities.length}>
|
|
|
+ <div class="paas-agent-tags">
|
|
|
+ {profile().capabilities.map((item) => <span>{item}</span>)}
|
|
|
+ </div>
|
|
|
+</Show>
|
|
|
+<footer>
|
|
|
+ <Show
|
|
|
+ when={direct()}
|
|
|
+ fallback={<span class="paas-muted">由研究流程调用</span>}
|
|
|
+ >
|
|
|
+ <button
|
|
|
+ type="button"
|
|
|
+ class="paas-directory-primary"
|
|
|
+ aria-label={`与 ${name()} 对话`}
|
|
|
+ onClick={() => {
|
|
|
+ setUI("chatAgentID", id())
|
|
|
+ workspace.setState("page", "chat")
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ 在此智能体开始
|
|
|
+ </button>
|
|
|
+ </Show>
|
|
|
+ <button type="button" aria-label={`编辑 ${name()}`} onClick={() => editAgent(id(), "agents")}>
|
|
|
+ 编辑
|
|
|
+ </button>
|
|
|
+</footer>
|
|
|
+```
|
|
|
+
|
|
|
+渲染三段:
|
|
|
+
|
|
|
+```tsx
|
|
|
+<section aria-labelledby="agents-default"><h2 id="agents-default">默认入口</h2><div class="paas-directory-grid">...</div></section>
|
|
|
+<section aria-labelledby="agents-professional"><h2 id="agents-professional">专业任务</h2><div class="paas-directory-grid">...</div></section>
|
|
|
+<section aria-labelledby="agents-workflow"><h2 id="agents-workflow">研究流水线</h2><div class="paas-directory-grid">...</div></section>
|
|
|
+<details class="paas-agent-internal">
|
|
|
+ <summary>流程内部能力 · {agentGroups().internal.length}</summary>
|
|
|
+ <div class="paas-directory-grid">...</div>
|
|
|
+</details>
|
|
|
+```
|
|
|
+
|
|
|
+在 `paas.css` 增加:
|
|
|
+
|
|
|
+```css
|
|
|
+.paas-agent-section { margin-top: 28px; }
|
|
|
+.paas-agent-section > h2 { font-size: var(--paas-type-section); margin: 0 0 12px; }
|
|
|
+.paas-agent-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
|
|
|
+.paas-agent-tags span { padding: 2px 7px; border-radius: 999px; background: var(--background-weak); color: var(--text-weak); font-size: var(--paas-type-meta); }
|
|
|
+.paas-agent-internal { margin-top: 28px; }
|
|
|
+.paas-agent-internal > summary { font-size: var(--paas-type-caption); color: var(--text-weak); }
|
|
|
+```
|
|
|
+
|
|
|
+- [ ] **Step 4: 运行 E2E 和类型检查**
|
|
|
+
|
|
|
+```bash
|
|
|
+(cd packages/app && bun x --no-install playwright test e2e/paas/project-workflow.spec.ts --config e2e/paas/playwright.config.ts -g "agent directory")
|
|
|
+(cd packages/app && bun typecheck)
|
|
|
+```
|
|
|
+
|
|
|
+Expected: PASS。
|
|
|
+
|
|
|
+- [ ] **Step 5: 提交**
|
|
|
+
|
|
|
+```bash
|
|
|
+git add packages/app/src/pages/paas/index.tsx packages/app/src/pages/paas/paas.css packages/app/src/pages/paas/studio.css packages/app/e2e/paas/fixture.tsx packages/app/e2e/paas/project-workflow.spec.ts
|
|
|
+git commit -m "feat(paas): group agent directory by entry role"
|
|
|
+```
|
|
|
+
|
|
|
+---
|
|
|
+
|
|
|
+### Task 7: 目标优先路由与高级智能体选择
|
|
|
+
|
|
|
+**Files:**
|
|
|
+- Create: `packages/app/src/pages/paas/agent-routing.ts`
|
|
|
+- Create: `packages/app/src/pages/paas/agent-routing.test.ts`
|
|
|
+- Modify: `packages/app/src/pages/paas/chat.tsx`
|
|
|
+- Modify: `packages/app/src/pages/paas/chat-state.ts`
|
|
|
+- Modify: `packages/app/src/pages/paas/paas.css`
|
|
|
+- Modify: `packages/app/e2e/paas/project-workflow.spec.ts`
|
|
|
+
|
|
|
+**Interfaces:**
|
|
|
+- Consumes: `directAgents()`、项目工作区、当前输入与文件
|
|
|
+- Produces:
|
|
|
+ - `routeAgent(input): { agentID: string; reason: string; confidence: "high" | "medium" | "low" }`
|
|
|
+ - `ResearchChat.model.route(agentID)` 仅对空白会话切换智能体
|
|
|
+ - 输入区默认显示路由结果;高级选择只列直接智能体
|
|
|
+
|
|
|
+- [ ] **Step 1: 写失败测试**
|
|
|
+
|
|
|
+```ts
|
|
|
+import { expect, test } from "bun:test"
|
|
|
+import { routeAgent } from "./agent-routing"
|
|
|
+
|
|
|
+const agents = [
|
|
|
+ { id: "research67", name: "research67" },
|
|
|
+ { id: "data67", name: "data67" },
|
|
|
+ { id: "workspace", name: "工作区助手" },
|
|
|
+ { id: "reviewer", name: "顶刊审稿助手" },
|
|
|
+ { id: "internal", name: "本体证据补全员" },
|
|
|
+]
|
|
|
+
|
|
|
+test("explicit direct agent wins", () => {
|
|
|
+ expect(routeAgent({ goal: "用顶刊审稿助手评审这篇论文", agents })).toMatchObject({
|
|
|
+ agentID: "reviewer",
|
|
|
+ confidence: "high",
|
|
|
+ })
|
|
|
+})
|
|
|
+
|
|
|
+test("spreadsheets route to data analysis", () => {
|
|
|
+ expect(routeAgent({ goal: "合并并画趋势图", files: [{ name: "sales.csv" }], agents })).toMatchObject({
|
|
|
+ agentID: "data67",
|
|
|
+ })
|
|
|
+ expect(routeAgent({ goal: "合并 CSV 并画趋势图", agents })).toMatchObject({ agentID: "data67" })
|
|
|
+})
|
|
|
+
|
|
|
+test("workspace edits require a bound folder and use workspace assistant", () => {
|
|
|
+ expect(routeAgent({ goal: "整理这个文件夹并改 README", workspace: "D:/Research", agents })).toMatchObject({
|
|
|
+ agentID: "workspace",
|
|
|
+ })
|
|
|
+ expect(routeAgent({ goal: "整理这个文件夹并改 README", agents }).agentID).not.toBe("workspace")
|
|
|
+})
|
|
|
+
|
|
|
+test("default research tasks route to research67", () => {
|
|
|
+ expect(routeAgent({ goal: "从零制定一份研究计划", agents })).toMatchObject({
|
|
|
+ agentID: "research67",
|
|
|
+ confidence: "low",
|
|
|
+ })
|
|
|
+})
|
|
|
+```
|
|
|
+
|
|
|
+- [ ] **Step 2: 运行测试确认失败**
|
|
|
+
|
|
|
+```bash
|
|
|
+(cd packages/app && bun test --conditions=solid --preload ./happydom.ts src/pages/paas/agent-routing.test.ts)
|
|
|
+```
|
|
|
+
|
|
|
+Expected: FAIL,模块不存在。
|
|
|
+
|
|
|
+- [ ] **Step 3: 实现路由与输入区**
|
|
|
+
|
|
|
+`agent-routing.ts`:
|
|
|
+
|
|
|
+```ts
|
|
|
+import { resolveAgentProfile } from "./agent-profiles"
|
|
|
+
|
|
|
+type Agent = Record<string, unknown>
|
|
|
+export type RouteInput = {
|
|
|
+ goal: string
|
|
|
+ files?: { name: string }[]
|
|
|
+ workspace?: string
|
|
|
+ agents: Agent[]
|
|
|
+}
|
|
|
+export type RouteResult = {
|
|
|
+ agentID: string
|
|
|
+ reason: string
|
|
|
+ confidence: "high" | "medium" | "low"
|
|
|
+}
|
|
|
+
|
|
|
+const byID = (agents: Agent[], id: string) => agents.find((agent) => agent.id === id)
|
|
|
+const byName = (agents: Agent[], name: string) => agents.find((agent) => agent.name === name)
|
|
|
+const workspaceAgent = (agents: Agent[]) => agents.find((agent) => resolveAgentProfile(agent).requiresWorkspace)
|
|
|
+const nameHit = (goal: string, agents: Agent[]) =>
|
|
|
+ agents.find((agent) => typeof agent.name === "string" && goal.includes(agent.name))
|
|
|
+
|
|
|
+export function routeAgent(input: RouteInput): RouteResult {
|
|
|
+ const named = nameHit(input.goal, input.agents)
|
|
|
+ if (named) return { agentID: String(named.id), reason: "你明确指定了该智能体", confidence: "high" }
|
|
|
+ const data = byID(input.agents, "data67") || byName(input.agents, "data67")
|
|
|
+ if (
|
|
|
+ (input.files?.some((file) => /\.(csv|tsv|xlsx?)$/i.test(file.name)) ||
|
|
|
+ /(csv|表格|趋势图|统计|数据清洗)/i.test(input.goal)) &&
|
|
|
+ data
|
|
|
+ )
|
|
|
+ return { agentID: String(data.id), reason: "检测到表格文件和数据分析需求", confidence: "high" }
|
|
|
+ const workspace = workspaceAgent(input.agents)
|
|
|
+ if (input.workspace && /文件夹|目录|README|代码|脚本|批量|整理|重命名|修改文件/i.test(input.goal) && workspace)
|
|
|
+ return { agentID: String(workspace.id), reason: "检测到当前项目文件夹中的文件操作", confidence: "high" }
|
|
|
+ const reviewer = byName(input.agents, "顶刊审稿助手")
|
|
|
+ if (/评审|审稿|审阅意见/i.test(input.goal) && reviewer)
|
|
|
+ return { agentID: String(reviewer.id), reason: "检测到论文评审意图", confidence: "medium" }
|
|
|
+ const research = byID(input.agents, "research67") || byName(input.agents, "research67")
|
|
|
+ if (research) return { agentID: String(research.id), reason: "默认交给通用科研助手", confidence: "low" }
|
|
|
+ return { agentID: String(input.agents[0]?.id || ""), reason: "回退到第一个可用智能体", confidence: "low" }
|
|
|
+}
|
|
|
+```
|
|
|
+
|
|
|
+`chat-state.ts` 增加:
|
|
|
+
|
|
|
+```ts
|
|
|
+function route(agentID: string) {
|
|
|
+ const chat = current()
|
|
|
+ const agent = props.agents.find((item) => item.id === agentID)
|
|
|
+ if (!chat || !agent || chat.messages.length || chat.threadID) return false
|
|
|
+ setState("chats", (item) => item.id === chat.id, {
|
|
|
+ agentID,
|
|
|
+ name: paasText(agent.name),
|
|
|
+ })
|
|
|
+ save()
|
|
|
+ return true
|
|
|
+}
|
|
|
+```
|
|
|
+
|
|
|
+返回对象中导出 `route`。
|
|
|
+
|
|
|
+`chat.tsx` 输入区:
|
|
|
+
|
|
|
+```tsx
|
|
|
+const routed = createMemo(() =>
|
|
|
+ routeAgent({
|
|
|
+ goal: current()?.draft || "",
|
|
|
+ files: current()?.files,
|
|
|
+ workspace: props.workspace,
|
|
|
+ agents: directAgents(props.agents),
|
|
|
+ }),
|
|
|
+)
|
|
|
+const routedAgent = createMemo(() => props.agents.find((agent) => paasText(agent.id) === routed().agentID))
|
|
|
+const routeLabel = createMemo(() => paasText(routedAgent()?.name) || "自动选择")
|
|
|
+```
|
|
|
+
|
|
|
+在 composer footer 增加:
|
|
|
+
|
|
|
+```tsx
|
|
|
+<details class="paas-agent-route">
|
|
|
+ <summary>
|
|
|
+ 自动 · {routeLabel()}
|
|
|
+ </summary>
|
|
|
+ <p class="paas-muted">{routed().reason}</p>
|
|
|
+ <select
|
|
|
+ aria-label="选择执行角色"
|
|
|
+ value={current()?.agentID || routed().agentID}
|
|
|
+ onChange={(event) => void model.route(event.currentTarget.value)}
|
|
|
+ >
|
|
|
+ {directAgents(props.agents).map((agent) => (
|
|
|
+ <option value={paasText(agent.id)}>{paasText(agent.name)}</option>
|
|
|
+ ))}
|
|
|
+ </select>
|
|
|
+</details>
|
|
|
+```
|
|
|
+
|
|
|
+发送前按“新会话用路由结果、已有会话用当前角色”处理:
|
|
|
+
|
|
|
+```ts
|
|
|
+const send = () => {
|
|
|
+ const blank = !!current() && !current()!.messages.length && !current()!.threadID
|
|
|
+ const target = blank ? routedAgent() : currentAgent()
|
|
|
+ const profile = resolveAgentProfile(target || {})
|
|
|
+ if (profile.requiresWorkspace && !props.workspace) {
|
|
|
+ setState("error", "工作区助手需要先为当前项目绑定工作文件夹。")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (blank) model.route(routed().agentID)
|
|
|
+ void model.send(profile.requiresWorkspace ? props.workspace : undefined)
|
|
|
+}
|
|
|
+```
|
|
|
+
|
|
|
+在 `project-workflow.spec.ts` 增加自动路由 E2E:
|
|
|
+
|
|
|
+```ts
|
|
|
+test("automatic route selects data analysis and hides internal roles", async ({ page }) => {
|
|
|
+ await page.goto("/e2e/paas/index.html?agent-groups")
|
|
|
+ await page.getByLabel("API Key", { exact: true }).fill("automatic-route")
|
|
|
+ await page.getByRole("button", { name: "连接平台", exact: true }).click()
|
|
|
+ await page.getByRole("textbox", { name: "消息", exact: true }).fill("合并 CSV 并画趋势图")
|
|
|
+ await expect(page.getByText("自动 · data67", { exact: true })).toBeVisible()
|
|
|
+ await page.getByText("自动 · data67", { exact: true }).click()
|
|
|
+ const select = page.getByLabel("选择执行角色", { exact: true })
|
|
|
+ await expect(select.locator("option", { hasText: "data67" })).toHaveCount(1)
|
|
|
+ await expect(select.locator("option", { hasText: "本体证据补全员" })).toHaveCount(0)
|
|
|
+})
|
|
|
+```
|
|
|
+
|
|
|
+- [ ] **Step 4: 运行单元测试、E2E 与类型检查**
|
|
|
+
|
|
|
+```bash
|
|
|
+(cd packages/app && bun test --conditions=solid --preload ./happydom.ts src/pages/paas/agent-routing.test.ts)
|
|
|
+(cd packages/app && bun x --no-install playwright test e2e/paas/project-workflow.spec.ts --config e2e/paas/playwright.config.ts -g "automatic route")
|
|
|
+(cd packages/app && bun typecheck)
|
|
|
+(cd packages/desktop && bun typecheck)
|
|
|
+```
|
|
|
+
|
|
|
+Expected: PASS。
|
|
|
+
|
|
|
+- [ ] **Step 5: 提交**
|
|
|
+
|
|
|
+```bash
|
|
|
+git add packages/app/src/pages/paas/agent-routing.ts packages/app/src/pages/paas/agent-routing.test.ts packages/app/src/pages/paas/chat.tsx packages/app/src/pages/paas/chat-state.ts packages/app/src/pages/paas/paas.css packages/app/e2e/paas/project-workflow.spec.ts
|
|
|
+git commit -m "feat(paas): route new research from user goals"
|
|
|
+```
|
|
|
+
|
|
|
+---
|
|
|
+
|
|
|
+### Task 8: 全链路回归与文档收尾
|
|
|
+
|
|
|
+**Files:**
|
|
|
+- Modify: `packages/app/src/pages/paas/README.md`
|
|
|
+- Modify: `packages/app/e2e/paas/project-workflow.spec.ts`
|
|
|
+- Modify: `PAAS_PRODUCT_BRAINSTORM.zh-CN.md` 仅当实现结果与假设不一致
|
|
|
+
|
|
|
+**Interfaces:**
|
|
|
+- Consumes: Task 1–7 全部能力
|
|
|
+- Produces: 可重复的 P0-A 验收证据和已知限制记录
|
|
|
+
|
|
|
+- [ ] **Step 1: 追加失败/恢复场景**
|
|
|
+
|
|
|
+在 `project-workflow.spec.ts` 增加:
|
|
|
+
|
|
|
+```ts
|
|
|
+test("unbound workspace assistant is blocked before execution", async ({ page }) => {
|
|
|
+ await page.goto("/e2e/paas/index.html?agent-groups")
|
|
|
+ await page.getByLabel("API Key", { exact: true }).fill("workspace-guard")
|
|
|
+ await page.getByRole("button", { name: "连接平台", exact: true }).click()
|
|
|
+ await page.getByRole("button", { name: "智能体", exact: true }).click()
|
|
|
+ await page.getByRole("button", { name: "与 工作区助手 对话", exact: true }).click()
|
|
|
+ await page.getByRole("textbox", { name: "消息", exact: true }).fill("整理这个文件夹")
|
|
|
+ await page.getByRole("textbox", { name: "消息", exact: true }).press("Enter")
|
|
|
+ await expect(page.getByText("工作区助手需要先为当前项目绑定工作文件夹。", { exact: true })).toBeVisible()
|
|
|
+ expect(await page.evaluate(() => window.paasTestCalls.filter((call) => call.action === "execute").length)).toBe(0)
|
|
|
+})
|
|
|
+```
|
|
|
+
|
|
|
+- [ ] **Step 2: 运行完整相关套件**
|
|
|
+
|
|
|
+```bash
|
|
|
+(cd packages/app && bun test --conditions=solid --only-failures --preload ./happydom.ts src/pages/paas)
|
|
|
+(cd packages/app && bun x --no-install playwright test e2e/paas/project-workflow.spec.ts e2e/paas/workbench.spec.ts e2e/paas/fullcheck.spec.ts e2e/paas/panel.spec.ts e2e/paas/preview-check.spec.ts --config e2e/paas/playwright.config.ts)
|
|
|
+```
|
|
|
+
|
|
|
+Expected: 全部 PASS。
|
|
|
+
|
|
|
+- [ ] **Step 3: 类型检查与生产构建**
|
|
|
+
|
|
|
+```bash
|
|
|
+(cd packages/app && bun typecheck)
|
|
|
+(cd packages/desktop && bun typecheck)
|
|
|
+(cd packages/app && bun run build)
|
|
|
+```
|
|
|
+
|
|
|
+Expected: 全部 exit 0。
|
|
|
+
|
|
|
+- [ ] **Step 4: 更新 README 的已实现边界**
|
|
|
+
|
|
|
+在 `packages/app/src/pages/paas/README.md` 增加:
|
|
|
+
|
|
|
+```md
|
|
|
+## P0-A 项目与智能体入口(2026-12)
|
|
|
+
|
|
|
+- 项目元数据保存在本机,按平台作用域和窗口隔离;项目可绑定一个工作文件夹。
|
|
|
+- 会话归属项目,侧栏历史和草稿按当前项目过滤。
|
|
|
+- 新研究默认按目标自动选择执行角色;高级选择只显示可直接发起的智能体。
|
|
|
+- 内部子智能体只出现在“流程内部能力”折叠区,不提供独立对话入口。
|
|
|
+- 工作区助手必须绑定项目文件夹,执行时通过 `context.work_dir` 传递。
|
|
|
+- 平台尚未返回智能体入口元数据时,客户端使用内置画像作为过渡;后续以平台字段为准。
|
|
|
+```
|
|
|
+
|
|
|
+- [ ] **Step 5: 提交**
|
|
|
+
|
|
|
+```bash
|
|
|
+git add packages/app/src/pages/paas/README.md packages/app/e2e/paas/project-workflow.spec.ts
|
|
|
+git commit -m "test(paas): cover project workspace and agent routing"
|
|
|
+```
|
|
|
+
|
|
|
+---
|
|
|
+
|
|
|
+## P0-A 验收清单
|
|
|
+
|
|
|
+- [ ] 首次连接后有一个“我的研究”默认项目,旧会话自动归入该项目。
|
|
|
+- [ ] 新建项目后可绑定工作文件夹,刷新或重启后仍保留。
|
|
|
+- [ ] 切换项目只显示该项目的历史会话和草稿。
|
|
|
+- [ ] 输入目标时默认显示“自动 · 角色”,不要求用户先打开 22 个智能体。
|
|
|
+- [ ] 高级选择不出现内部子智能体。
|
|
|
+- [ ] 内置内部角色在智能体页默认折叠,不能直接发起。
|
|
|
+- [ ] 智能体卡片显示用户摘要、能力、输入和产出,不再只显示技术描述。
|
|
|
+- [ ] 工作区助手在没有绑定文件夹时被前端阻止;绑定后发送 `context.work_dir`。
|
|
|
+- [ ] 1280/600 宽度、亮暗主题无横向溢出;项目切换器不挤压导航。
|
|
|
+- [ ] 单元测试、相关 E2E、App/Desktop 类型检查和生产构建通过。
|
|
|
+
|
|
|
+## 后续独立计划
|
|
|
+
|
|
|
+以下能力不在本计划内,完成 P0-A 后分别开计划:
|
|
|
+
|
|
|
+1. **P0-B Research Inbox**:统一聚合待审批、失败、完成未读、连接异常和预算告警。
|
|
|
+2. **P1 Run Inspector 2.0**:阶段时间线、子智能体参与、证据、成本、恢复点。
|
|
|
+3. **P1 成果资产库**:项目级文件树、来源、版本、比较、打包导出。
|
|
|
+4. **P2 项目上下文与团队能力**:上下文包、记忆、分享、权限、云端同步。
|
|
|
+
|
|
|
+## Self-Review
|
|
|
+
|
|
|
+- **Spec coverage:** 覆盖脑暴稿中的项目/工作文件夹、目标优先路由、智能体分层、智能体页改造、描述规范和 workspace assistant 集成。
|
|
|
+- **Deferred coverage:** Research Inbox、Run Inspector、成果库、团队/云端明确列为后续独立计划。
|
|
|
+- **Placeholder scan:** 无 TBD、TODO、未定义函数或“类似 Task N”的实现步骤。
|
|
|
+- **Type consistency:** `PaasProject`、`AgentProfile`、`RouteResult`、`workDir` 在跨任务接口中保持一致。
|
|
|
+- **Boundary check:** 内部子智能体不可直接发起;工作区助手没有文件夹时不会执行;平台元数据缺失时有明确过渡策略。
|