Commit Graph

4 Commits

Author SHA1 Message Date
wangjia 9b17d3e24f feat: 任务附件上传(图片/文件随任务提交)
B-① 附件上传(⑧ ★ POST /api/tasks/:id/attachments):

后端:
- 加 @fastify/multipart;schema/db.ts tasks.attachments 列(幂等迁移)
- types.Attachment{name,type,path} + Task.attachments;mappers 映射
- store.addAttachments(追加元数据 + 广播 task.updated)
- POST /api/tasks/:id/attachments:multipart files[](单文件≤25MB/单次≤10),
  落盘 <data>/tasks/<id>/attachments/,文件名消毒,返回全部附件

前端:
- api.uploadAttachments(FormData multipart)
- 新建任务表单加文件选择 + 已选列表;创建任务后自动上传附件

验证:typecheck 干净;206 测试通过;前端 build 通过。
(端到端需重启 daemon 加载新端点——与后续 SSE/takeover 一并重启。)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-24 16:58:14 +08:00
wangjia 6c9b05e575 feat: 项目级成本预算系统(按模型×token 精确计费 + 超额自动暂停)
精确到项目级的成本/预算护栏,成本按「模型 × token 用量」折算(⑧ ★ 新特性)。

定价(单源):
- src/model/pricing.ts:MODEL_PRICES(opus/sonnet/haiku,USD/1M token,分
  input/output/cacheRead/cacheWrite)+ computeCost/addUsage,前缀容错、未知模型记 0

token 捕获链(worker → daemon):
- cc.ts:从 SDK result 消息抓 usage,跨 resume/回退累计;CCResult.usage
- runner/reviewer:结果对象带 usage + modelUsed
- protocol.ts:新增 'usage' outbox 记录;pipeline 每次 CC(executor/复审/planner/
  conflict)后 emit usage(worker 侧写文件,不碰 DB)
- ingest.ts:'usage' → store.setRunUsage(累加、按模型折算)→ enforceBudget

存储 + 护栏:
- schema/db.ts:runs.usage/cost_usd、projects.budget_usd/budget_period(幂等迁移)
- store.ts:setRunUsage(累加)、projectSpend、costSummary(按项目/模型/总计)、
  enforceBudget(超额 → 置 paused + 广播 budget.exceeded)
- 编排器天然停领:orchestrator 既有「跳过 paused 项目」即生效,无需改

API:
- GET /api/usage:并入成本明细 {session,weekly,cost:{period,total,byProject,byModel}},?period/?project
- GET /api/health:{ok,db,inflight,at}
- PATCH /api/projects:支持 budgetUsd/budgetPeriod

前端:
- adapt.js:agentSummary 用真实成本/token;adaptProject 透传预算字段
- app.jsx:budget.exceeded → 告警 toast
- ConfigPanel:预算 $ + 周期(day|month)受控输入

验证:typecheck 干净;206 测试通过(含新增 budget.test.ts 4 例:定价折算/累加/
costSummary/enforceBudget);前端 build + 截图确认预算输入渲染、0 错误。
注:生效需合并后重启 daemon(迁移幂等加列、向后兼容旧库)。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-24 15:29:44 +08:00
wangjia 0a1f500c12 feat(app+ds): 阶段2 接前端写操作——任务创建/配置保存/新建项目
让原型里的视觉 mock 表单变为真正可写(附加式、向后兼容原型 index.html):

design/ui_kits/console(surface 功能化,DS 组件本就支持 onChange):
- NewTaskPanel:表单受控(title/complexity/priority/parentId),onCreate 出参;
  父任务下拉扁平化含子任务
- TaskSection:暴露 onCreate prop(无则回退原 toast)
- ConfigPanel:受控(concurrency/autonomy/logo/verifyCmd/model),onSave 出参

app/:
- api.js:加 createProject
- app.jsx:createTask→POST /tasks、saveConfig→PATCH /projects、createProject→
  POST /projects;新增 NewProjectModal(design 无现成 surface,用 DS 组件就地拼装,
  zh/en 标签自含);接 Sidebar 新建项目入口

验证:dev + 生产构建双通过;Playwright 实测新建项目模态打开、受控输入捕获值
(["demo-app",".../demo-app","main"])、0 console 错误。写端点契约逐字段比对
server.ts(PATCH camelCase / POST tasks {title,complexity(auto),priority,parentId,deps})。
活写测试从略:maestro 为 auto-approved,建真实任务会触发 agent。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-24 14:44:46 +08:00
wangjia 5a1e185b1a docs(design): 解压 Maestro Design System 到 design/(重构参照材料)
phosphor console v1.1 设计系统(从现网 web/style.css 演化):tokens(colors/effects/
typography/fonts) + components(core/forms/surfaces .jsx) + ui_kits(console + console_mobile)
+ assets/icons(15 双色 SVG) + guidelines + CLAUDE/SKILL/readme。供 B1–B6 重构任务对照实现。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-13 14:29:07 +08:00