diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d96c6cf..4e75ad73 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # Agent Workbench 更新记录 +## 1.1.0 · 2026-10-29 + +- 任务与每轮运行分别保存,原目标、追加要求、模型配置、累计用量和预算可在任务面板核对。 +- SQLite事务保存状态、工具实际结果与事件游标;旧JSON带原字节备份迁移,重启不重放已完成工具。 +- 工程识别保存语言、npm脚本、项目规则和只读Git基线;检查计划绑定源码快照,确认后产生实际job、退出码、测试数量和日志。 +- 零测试、跳过、未知日志、取消或源码变化都不能显示为验证通过;模型可通过read_artifact读取保存的失败日志进行修复。 +- 应用全部待审查改动后可「继续检查与交付」,保留原Task进入新Run;重复请求只接受一轮,无效模型配置不追加任务指令。 +- 增加Task/Run/工件/预算界面、断线补发和390px日志弹窗;便携宿主随附npm,支持旧Node原进程使用新发行目录的检查器。 +- 新增封存四模块工程和真实模型交付验收器,记录测试/构建、保护输入、既有改动、审查次数和源文件独立Git提交。 + +验收结果以[实际验证记录](docs/VALIDATION.md)为准。任务依赖图、增量索引、ChangeSet、外部引擎及桌面/手机配对继续按M2–M6实施。 + ## 1.0.0 · 2026-10-29 - 助手解释工作台报错时读取本机会话诊断,使用错误来源、工具结果和文件的当前审核状态。 diff --git a/README.md b/README.md index e5e89a53..09492510 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # 本地 Agent 工作台 -Agent Workbench 1.0.0 将 Claude Code 与 Cursor 的机制研究整合为一个独立的本地 AI 编程工作台。一个页面内完成项目选择、任务对话、文件读取/搜索、工具轨迹、差异审查、命令确认、运行诊断与会话恢复。这是已验证的基础里程碑,持续完成真实工程任务的能力按后续方案逐步建设。 +Agent Workbench 1.1.0 将 Claude Code 与 Cursor 的机制研究整合为独立的本地 AI 编程工作台。在项目对话、文件工具、审核和诊断的基础上,增加可靠Task/Run记录、SQLite保存、实际工程检查与审核后继续原任务的流程。 -本次正式版补充工作台自身的错误诊断与当前执行状态,使助手可以区分模型连接失败、终端失败和文件审核状态。版本改动见 [CHANGELOG](CHANGELOG.md)。 +每次运行保留模型与预算、已完成工具和日志工件。检查通过需要实际退出码、测试数量和对应源码快照;应用改动后可点击「继续检查与交付」,沿用原目标进行测试与修复。版本改动见 [CHANGELOG](CHANGELOG.md),本轮验收范围见 [QA-1.1](docs/QA-1.1.md)。 ## 后续产品与能力建设 @@ -13,11 +13,11 @@ Agent Workbench 1.0.0 将 Claude Code 与 Cursor 的机制研究整合为一个 - [研究路线](docs/RESEARCH-ROADMAP.md)与[目标来源登记](research/targets.json):版本、来源、SDK限制及未解决问题。 - [本地Git流程](docs/GIT-WORKFLOW.md)与[项目执行规范](AGENTS.md):源码仓库已建立,main基线`bac87da`、标签`v1.0.0-baseline`;后续按独立小步检查并及时提交。 -高级任务图、工程索引、patch/ChangeSet、用户工程Git/worktree、结构化测试修复、多worker、外部引擎、REA执行和桌面/手机配对仍在规划中。下一轮先建设可靠任务状态与真实工程交付切片。 +1.1.0实现有界工程识别、只读Git基线和Node/npm检查job。增量工程索引、任务依赖图、patch/ChangeSet、用户工程Git/worktree自动交付、多worker、外部引擎、REA执行和桌面/手机配对按后续阶段建设。 ## 直接运行 -Windows x64 便携包自带 Node.js 24.22.1。解压后双击 `Start-Workbench.cmd`,浏览器打开 `http://127.0.0.1:4318`。双击 `Stop-Workbench.cmd` 可停止服务及它正在运行的任务。 +Windows x64 便携包自带 Node.js 24.22.1和npm。解压后双击 `Start-Workbench.cmd`,浏览器打开 `http://127.0.0.1:4318`。双击 `Stop-Workbench.cmd` 可停止服务及它正在运行的任务。 启动不需要安装 npm 依赖或管理员权限。窗口关闭后本地服务仍运行,任务与会话继续保存。再次打开相同地址即可查看记录。 @@ -27,6 +27,7 @@ Windows x64 便携包自带 Node.js 24.22.1。解压后双击 `Start-Workbench.c 4. 文件建议先成为提案;查看右侧差异,点击「应用这项改动」才写入项目。 5. 点击「模型连接」,选择兼容模型服务,填写接口根地址、模型和按需填写的 Key;可先「验证模型响应」,再保存连接。 6. 遇到请求失败,点击错误卡片的「查看运行诊断」。可在同一会话提问,助手通过本地 `inspect_session` 核对错误来源、近期工具和文件实际状态。 +7. 点击「查看任务记录」查看目标、各轮运行、累计用量与工件。准备工程检查后,核对npm脚本再执行;查看实际测试数量与日志。应用全部提案后,用「继续检查与交付」继续同一目标。 ## 模型连接 @@ -44,7 +45,9 @@ API Key 只在当前服务内存中使用,不写入配置、会话或导出。 终端命令逐次确认,最长 60 秒,有输出上限,确认后以当前系统用户权限执行。项目工作目录不是操作系统沙箱。停止任务会中止工作台启动的进程树。 -数据默认保存在 `%LOCALAPPDATA%\AgentWorkbench`。会话 JSON 原子替换并保留 `.bak`;服务意外退出后保留待审查提案,将未完成调用标为中断,不自动重放命令。暂停后可「继续任务」,沿用已保存的模型消息;待审查状态显示「审核 N 项」,已完成状态可以发送新的任务内容。 +数据默认保存在 `%LOCALAPPDATA%\AgentWorkbench`。1.1.0将任务、运行、工具、检查与事件保存到`workbench.sqlite`;旧JSON在有备份的事务迁移后保留。大型结果和检查日志另存为SHA256校验工件。服务意外退出后保留提案和完成结果;结果未知的副作用需要核对,不自动重放。暂停后可「继续任务」;已应用的审核任务可「继续检查与交付」。 + +工程检查当前支持已识别的npm test/typecheck/check/lint/build脚本,计划绑定源码与Git快照。执行前展示脚本与npm生命周期钩子,实际job保留退出码、测试统计及日志。零测试、跳过、未识别日志、取消或源码过期均不记为任务验证通过。 Windows 终端使用 PowerShell 5.1,通过 UTF-8 stdin 传入经确认的完整脚本,同时设置输入、输出和 `$OutputEncoding`。多条命令用换行组织,不能使用 `&&` 或 `||`;原生命令的 `$LASTEXITCODE` 会成为执行结果。 @@ -54,8 +57,8 @@ Windows 终端使用 PowerShell 5.1,通过 UTF-8 stdin 传入经确认的完 - [统一机制报告](docs/RESEARCH.md):原版静态证据与本产品实现逐项对照。 - [详细报告与证据索引](docs/research):Claude Code 工具循环、上下文/恢复,以及 Cursor 工具执行/编辑。 -- [验收记录](docs/VALIDATION.md):34 项行为测试、10 组基础界面与9组异常专项流程、便携包测试与截图。 -- [正式版验收清单](docs/QA-1.0.md)与[保留连接的升级说明](docs/UPGRADE.md)。 +- [验收记录](docs/VALIDATION.md):保留1.0.0基线与本轮1.1.0的实际验证结果。 +- [本轮验收清单](docs/QA-1.1.md)、[封存四模块工程基准](benchmarks/node-delivery-v1/README.md)与[保留连接的升级说明](docs/UPGRADE.md)。 - [独立架构](docs/ARCHITECTURE.md)与[界面设计](DESIGN.md)。 原版研究没有执行 Claude Code/Cursor,报告不表示恢复了全部源码或验证了远端服务。完整分析工件保留在原研究工作区;本产品包不包含第三方客户端原二进制、完整提取源码或大体积代码切片。 @@ -72,7 +75,7 @@ npm.cmd test 启动构建结果可运行 `npm.cmd start` 或双击启动脚本。前端开发使用 `npm.cmd run dev`,另开终端运行构建后的本地服务。 -UI 验收先启动独立测试服务(指定不同数据目录),然后依次运行 `npm.cmd run verify:ui` 和 `npm.cmd run verify:diagnostics`。脚本默认检查 `http://127.0.0.1:4319`,使用本机 Edge;可用 `AGENT_WORKBENCH_URL` 指定其他独立测试地址。验证器要求测试服务为离线演示且未配置 Key,防止覆盖用户连接。它会创建工作区内的 `.qa` 测试项目。 +UI 验收先启动独立测试服务(指定不同数据目录),然后依次运行 `npm.cmd run verify:ui`、`npm.cmd run verify:diagnostics`和`node scripts/verify-execution-ui.mjs`。脚本默认检查 `http://127.0.0.1:4319`,使用本机 Edge;可用 `AGENT_WORKBENCH_URL` 指定其他独立测试地址。验证器要求测试服务为离线演示且未配置 Key,防止覆盖用户连接。它会创建工作区内的 `.qa` 测试项目。 ```powershell $env:AGENT_WORKBENCH_DATA_DIR = Join-Path (Get-Location) '.qa\browser-data' diff --git a/benchmarks/node-delivery-v1/README.md b/benchmarks/node-delivery-v1/README.md new file mode 100644 index 00000000..c09d17c1 --- /dev/null +++ b/benchmarks/node-delivery-v1/README.md @@ -0,0 +1,15 @@ +# 四模块工程交付基准 + +[baseline/README.md](baseline/README.md)和14项测试固定初始缺失功能。`baseline`保持封存;验证器复制到独立`.qa`工程,在本地Git固定基线并增加需保留的原有工作区改动。 + +在已升级到1.1.0、已配置模型的工作台上,从本仓库运行: + +```powershell +node scripts/verify-live-delivery.mjs +``` + +验证器使用工作台现有内存连接,允许模型读取当前合成工程、提出四个`src`模块改动,以及经核对的npm test/build计划。它核对提案范围、基线、保护文件hash后应用,随后调用“继续检查与交付”保留原Task。其他终端请求拒绝。 + +完成要求:实际失败记录、全部四文件修复、14项测试及构建通过、构建入口结果正确、保护输入与已有工作区改动保留、四源文件独立Git提交。日志、diff、会话及结果保存在`.qa/live-delivery-*/`,摘要索引为`.qa/live-delivery-validation.json`。 + +这是M1进入真实工程的单个受控样本。记录审核次数、模型用量与耗时,不将一次通过称为完整M2/M6能力;验收器的脚本确认、提案审查和Git提交属于已记录的人工介入替代操作。 diff --git a/benchmarks/node-delivery-v1/baseline/.gitignore b/benchmarks/node-delivery-v1/baseline/.gitignore new file mode 100644 index 00000000..ad8757c6 --- /dev/null +++ b/benchmarks/node-delivery-v1/baseline/.gitignore @@ -0,0 +1,3 @@ +/dist/ +.awb-* +node_modules/ diff --git a/benchmarks/node-delivery-v1/baseline/README.md b/benchmarks/node-delivery-v1/baseline/README.md new file mode 100644 index 00000000..6a71d45d --- /dev/null +++ b/benchmarks/node-delivery-v1/baseline/README.md @@ -0,0 +1,15 @@ +# Delivery Report 工程验收样本 + +这是有意保留缺失功能的Node工程,用于验证“失败→跨文件修复→实际测试→审查→Git交付”。本目录是封存输入,不是已完成产品。 + +仅修改 `src/normalize.mjs`、`src/summary.mjs`、`src/render.mjs`、`src/cli.mjs`。测试、fixtures、构建脚本、package.json与本文保持原字节。没有第三方依赖。 + +1. normalizeTasks接受最多10000项的数组;每项必须是对象,id/title为非空字符串且trim,trim后的id唯一。 +2. status严格限定todo/doing/done/blocked;minutes必须是0到1000000之间的安全整数,拒绝文本、NaN、负数或越界;返回独立的四字段记录,不改变输入对象。 +3. summarize返回total、counts(四种状态都出现)、completedPercent(done/total四舍五入到整数,空数组为0)、remainingMinutes(所有非done记录分钟数之和)。空数组计数全部为0。 +4. renderText精确输出三行:`交付进度:D/T(P%)`、`待办 A · 进行中 B · 已完成 D · 阻塞 C`、`剩余预计:M 分钟`,保持中文可读。 +5. CLI用法 `node src/cli.mjs [--json]`。默认输出上述三行加尾换行,--json输出同一个summary的可解析JSON加换行。 +6. 参数缺失、未知选项、无效JSON、无效数据或文件读取失败均以退出码2和stderr中文前缀“输入错误:”报告;stdout为空。成功退出0。 +7. build核对四模块语法并复制到dist。`node dist/cli.mjs fixtures/tasks.json --json`与源码入口结果一致。 + +先运行npm test保存真实失败,再修改四个模块;应用提案后重跑npm test与npm run build。验收器另核对保护文件hash、源文件diff和构建入口,不把修改测试或只输出“成功”当交付。 diff --git a/benchmarks/node-delivery-v1/baseline/fixtures/invalid.json b/benchmarks/node-delivery-v1/baseline/fixtures/invalid.json new file mode 100644 index 00000000..b0911c49 --- /dev/null +++ b/benchmarks/node-delivery-v1/baseline/fixtures/invalid.json @@ -0,0 +1 @@ +{ "unfinished": diff --git a/benchmarks/node-delivery-v1/baseline/fixtures/tasks.json b/benchmarks/node-delivery-v1/baseline/fixtures/tasks.json new file mode 100644 index 00000000..735200c6 --- /dev/null +++ b/benchmarks/node-delivery-v1/baseline/fixtures/tasks.json @@ -0,0 +1,6 @@ +[ + { "id": " docs ", "title": " 编写交付文档 ", "status": "done", "minutes": 30 }, + { "id": "api", "title": "接口回归", "status": "doing", "minutes": 40 }, + { "id": "release", "title": "准备发行包", "status": "blocked", "minutes": 10 }, + { "id": "review", "title": "代码审查", "status": "done", "minutes": 20 } +] diff --git a/benchmarks/node-delivery-v1/baseline/package.json b/benchmarks/node-delivery-v1/baseline/package.json new file mode 100644 index 00000000..3d971166 --- /dev/null +++ b/benchmarks/node-delivery-v1/baseline/package.json @@ -0,0 +1,7 @@ +{ + "name": "delivery-report-lab", + "version": "0.1.0", + "private": true, + "type": "module", + "scripts": { "test": "node --test test/*.test.mjs", "build": "node scripts/build.mjs" } +} diff --git a/benchmarks/node-delivery-v1/baseline/scripts/build.mjs b/benchmarks/node-delivery-v1/baseline/scripts/build.mjs new file mode 100644 index 00000000..679a831d --- /dev/null +++ b/benchmarks/node-delivery-v1/baseline/scripts/build.mjs @@ -0,0 +1,11 @@ +import fs from 'node:fs'; +import { spawnSync } from 'node:child_process'; +const modules = ['normalize.mjs', 'summary.mjs', 'render.mjs', 'cli.mjs']; +for (const name of modules) { + const check = spawnSync(process.execPath, ['--check', 'src/' + name], { encoding: 'utf8', windowsHide: true }); + if (check.status !== 0) { process.stderr.write(check.stderr); process.exit(1); } +} +fs.mkdirSync('dist', { recursive: true }); +for (const name of modules) fs.copyFileSync('src/' + name, 'dist/' + name); +fs.writeFileSync('dist/package.json', '{"type":"module"}\n'); +console.log('四个模块语法检查及可运行构建完成。'); diff --git a/benchmarks/node-delivery-v1/baseline/src/cli.mjs b/benchmarks/node-delivery-v1/baseline/src/cli.mjs new file mode 100644 index 00000000..090ad4d1 --- /dev/null +++ b/benchmarks/node-delivery-v1/baseline/src/cli.mjs @@ -0,0 +1,8 @@ +import fs from 'node:fs'; +import { normalizeTasks } from './normalize.mjs'; +import { summarize } from './summary.mjs'; +import { renderText } from './render.mjs'; +try { + const tasks = normalizeTasks(JSON.parse(fs.readFileSync(process.argv[2], 'utf8'))); + console.log(renderText(summarize(tasks))); +} catch (error) { console.error(error.message); } diff --git a/benchmarks/node-delivery-v1/baseline/src/normalize.mjs b/benchmarks/node-delivery-v1/baseline/src/normalize.mjs new file mode 100644 index 00000000..70d376df --- /dev/null +++ b/benchmarks/node-delivery-v1/baseline/src/normalize.mjs @@ -0,0 +1,4 @@ +export function normalizeTasks(input) { + if (!Array.isArray(input)) throw new TypeError('tasks must be an array'); + return input; +} diff --git a/benchmarks/node-delivery-v1/baseline/src/render.mjs b/benchmarks/node-delivery-v1/baseline/src/render.mjs new file mode 100644 index 00000000..f8ab62fa --- /dev/null +++ b/benchmarks/node-delivery-v1/baseline/src/render.mjs @@ -0,0 +1,3 @@ +export function renderText(summary) { + return `Done: ${summary.counts.done}/${summary.total}`; +} diff --git a/benchmarks/node-delivery-v1/baseline/src/summary.mjs b/benchmarks/node-delivery-v1/baseline/src/summary.mjs new file mode 100644 index 00000000..2d615a3a --- /dev/null +++ b/benchmarks/node-delivery-v1/baseline/src/summary.mjs @@ -0,0 +1,5 @@ +export function summarize(tasks) { + const done = tasks.filter(task => task.status === 'done').length; + return { total: tasks.length, counts: { done }, completedPercent: tasks.length ? 100 : 0, + remainingMinutes: tasks.reduce((sum, task) => sum + task.minutes, 0) }; +} diff --git a/benchmarks/node-delivery-v1/baseline/test/delivery.test.mjs b/benchmarks/node-delivery-v1/baseline/test/delivery.test.mjs new file mode 100644 index 00000000..438c3e7e --- /dev/null +++ b/benchmarks/node-delivery-v1/baseline/test/delivery.test.mjs @@ -0,0 +1,26 @@ +import test from 'node:test'; +import assert from 'node:assert/strict'; +import fs from 'node:fs'; +import { spawnSync } from 'node:child_process'; +import { normalizeTasks } from '../src/normalize.mjs'; +import { summarize } from '../src/summary.mjs'; +import { renderText } from '../src/render.mjs'; +const input = () => JSON.parse(fs.readFileSync('fixtures/tasks.json', 'utf8')); +const record = overrides => ({ id: 'one', title: '任务', status: 'todo', minutes: 5, ...overrides }); +const expected = { total: 4, counts: { todo: 0, doing: 1, done: 2, blocked: 1 }, completedPercent: 50, remainingMinutes: 50 }; +const invoke = (...args) => spawnSync(process.execPath, ['src/cli.mjs', ...args], { encoding: 'utf8', windowsHide: true }); + +test('normalize trims identifiers and titles into independent records', () => { const original = input(), before = structuredClone(original), result = normalizeTasks(original); assert.equal(result[0].id, 'docs'); assert.equal(result[0].title, '编写交付文档'); assert.notEqual(result, original); assert.notEqual(result[1], original[1]); assert.deepEqual(original, before); }); +test('normalize rejects blank and duplicate normalized identifiers', () => { assert.throws(() => normalizeTasks([record({ id: ' ' })])); assert.throws(() => normalizeTasks([record({ title: ' ' })])); assert.throws(() => normalizeTasks([record(), record({ id: ' one ' })])); }); +test('normalize validates record shape and bounded collection size', () => { assert.throws(() => normalizeTasks({})); assert.throws(() => normalizeTasks([null])); assert.throws(() => normalizeTasks(Array.from({ length: 10001 }, (_, i) => record({ id: String(i) })))); }); +test('normalize supports all four states and rejects unknown states', () => { for (const status of ['todo', 'doing', 'done', 'blocked']) assert.equal(normalizeTasks([record({ status })])[0].status, status); assert.throws(() => normalizeTasks([record({ status: 'completed' })])); }); +test('normalize rejects noninteger and out-of-range estimates', () => { for (const minutes of ['5', null, -1, 0.5, NaN, Infinity, 1000001]) assert.throws(() => normalizeTasks([record({ minutes })])); assert.equal(normalizeTasks([record({ minutes: 0 })])[0].minutes, 0); assert.equal(normalizeTasks([record({ minutes: 1000000 })])[0].minutes, 1000000); }); +test('normalize emits only the declared four-field contract', () => assert.deepEqual(normalizeTasks([record({ unrelated: true })])[0], record())); +test('summary reports complete state counts and excludes completed work from remaining time', () => assert.deepEqual(summarize(normalizeTasks(input())), expected)); +test('summary rounds progress instead of truncating percentages', () => assert.equal(summarize([record({ status: 'done' }), record({ id: 'two', status: 'done' }), record({ id: 'three' })]).completedPercent, 67)); +test('summary handles an empty plan with every state present', () => assert.deepEqual(summarize([]), { total: 0, counts: { todo: 0, doing: 0, done: 0, blocked: 0 }, completedPercent: 0, remainingMinutes: 0 })); +test('text rendering keeps the required three readable Chinese lines', () => assert.equal(renderText(expected), '交付进度:2/4(50%)\n待办 0 · 进行中 1 · 已完成 2 · 阻塞 1\n剩余预计:50 分钟')); +test('CLI JSON output matches the summary contract and has a trailing newline', () => { const result = invoke('fixtures/tasks.json', '--json'); assert.equal(result.status, 0); assert.equal(result.stderr, ''); assert.deepEqual(JSON.parse(result.stdout), expected); assert.ok(result.stdout.endsWith('\n')); }); +test('CLI text output is readable and matches the shared rendering', () => { const result = invoke('fixtures/tasks.json'); assert.equal(result.status, 0); assert.equal(result.stdout, renderText(expected) + '\n'); assert.equal(result.stderr, ''); }); +test('CLI missing arguments and unknown options return exit 2 without output', () => { for (const args of [[], ['fixtures/tasks.json', '--unknown'], ['fixtures/tasks.json', '--json', '--json']]) { const result = invoke(...args); assert.equal(result.status, 2); assert.equal(result.stdout, ''); assert.match(result.stderr, /^输入错误:/); } }); +test('CLI invalid JSON and missing files preserve the failure exit code', () => { for (const file of ['fixtures/invalid.json', 'fixtures/not-found.json']) { const result = invoke(file); assert.equal(result.status, 2); assert.equal(result.stdout, ''); assert.match(result.stderr, /^输入错误:/); } }); diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index 8ab844bd..c18059e2 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -11,7 +11,15 @@ 终端命令每次确认后以当前 Windows 用户权限执行;工作目录为所选项目,但这不是操作系统沙箱。界面显示完整命令。停止任务会中止工作台启动的进程树。 ## 持久化与恢复 -状态与工具事件保存在独立应用数据目录。状态使用临时文件原子替换,并保留备份。服务重启后把仍在运行或等待确认的任务标为暂停;未完成 tool_call 按 ID 写入中断结果以保持消息契约。已开始命令的实际结果未知时明确标记,不自动重放终端或应用文件改动。 +1.1.0使用SQLite同步事务保存Task/Run/Step/Tool/Check/Event/Artifact记录,状态、追加事件与outbox一同提交,成功提交后再发布会话更新。旧JSON迁移保留原字节备份,旧Store接口通过兼容层保存新契约。大型工具结果与检查日志保存在独立SHA256工件中,读取和恢复均核对归属与字节。 + +服务重启后把仍在运行或等待确认的任务标为暂停;未完成tool_call按ID写入中断或实际保存的结果以保持消息配对。已开始命令的结果未知时保留需核对状态。执行宿主使用持久owner限制同一数据目录并发写入,停止时释放owner。SSE按持久seq补发,客户端不会因重连重放工具。 + +## 工程检查与审核后继续 + +ProjectInspector识别有界工程文件、语言、规则、npm脚本及当前工程自身的Git基线。CheckRunner将脚本和源码指纹固定为plan;执行前再次核对,在用户确认后创建独立job,保留真实退出码、统计与日志工件。模型通过read_artifact读取已有失败信息。没有实际测试、日志不能识别或源码已变化时,verification不记通过。 + +应用提案使原Run保留needs_review历史,当前会话的文件状态更新。continue-reviewed仅在当前Task已有应用且无剩余提案/冲突时接受,先校验模型配置,再将review-action追加要求与新Run一同提交;保留原始目标、累计用量和resumeOf。普通completed的resume不会重新调用模型。 ## 上下文 完整会话仍保留在磁盘。模型请求使用有预算的投影:以完整 user/assistant/tool 组为单位保留近期内容,较早内容形成有长度限制的本地提要。计数为估算,服务返回的 usage 另外记录。该机制是本产品的独立提取式实现,不声称与 Claude Code 的模型摘要等价。 diff --git a/docs/CAPABILITIES.md b/docs/CAPABILITIES.md index 1ea334dc..c0079f3f 100644 --- a/docs/CAPABILITIES.md +++ b/docs/CAPABILITIES.md @@ -1,6 +1,6 @@ # Agent Workbench 能力目标与验收矩阵 -日期:2026-10-29。当前产品:1.0.0基础里程碑。下表的目标、模块和阶段均是后续开发计划,不能作为已经交付的功能宣传。 +日期:2026-10-29。1.0.0为已保存的基础里程碑,1.1.0为本轮M1实现。下表保留1.0.0缺口与完整产品目标;每项完成范围以实际验证记录为准。 总体方案见 [PRODUCT-PLAN.md](PRODUCT-PLAN.md),研究问题与来源见 [RESEARCH-ROADMAP.md](RESEARCH-ROADMAP.md)。 @@ -12,6 +12,13 @@ ## 2. 能力矩阵 +### 1.1.0 M1已实现切片 + +- C01/C02/C04/C14/C15/C23:原Task目标、追加要求、Run模型/预算与累计usage,SQLite事务、稳定工具身份、SHA256工件与断线事件补发。 +- C03/C09/C11:有界工程识别、只读Git基线、npm检查计划/job、真实测试统计与日志、源码变化后失效。当前支持Node/npm,尚无三类工程专用执行器或用户工程自动提交。 +- C08/C12/C13/C24:应用全部提案后继续原任务、读取保存的失败日志进行修复,封存四模块样本与独立验收器;多文件ChangeSet、依赖计划和长期恢复仍待M2/M4。 +- 完整M2/M6成功率验收、外部引擎、REA运行和Electron/PWA配对不计入上述实现。对应检查见[QA-1.1](QA-1.1.md),封存样本见[四模块工程基准](../benchmarks/node-delivery-v1/README.md)。 + 模块路径指 [建议架构](PRODUCT-PLAN.md#4-建议架构一套执行核心多种入口),不是当前目录结构。研究编号对应研究路线中的问题组。 | ID / 能力 | 当前1.0.0基础与缺口 | 后续产品目标 | 参考问题 / 模块 / 阶段 | 必须看到的验收证据 | diff --git a/docs/QA-1.1.md b/docs/QA-1.1.md new file mode 100644 index 00000000..d90abec6 --- /dev/null +++ b/docs/QA-1.1.md @@ -0,0 +1,18 @@ +# 1.1.0 M1 验收清单 + +本轮验证范围:可靠任务内核、工程检查、审核应用后继续原任务、执行日志读取和真实模型四模块工程交付。桌面客户端安装包、手机远程配对、任务依赖图及外部引擎适配仍在后续计划。 + +| 用户可见行为 | 功能检查 | 界面和证据状态 | +| --- | --- | --- | +| 原Task目标、每轮Run模型/预算/工具/工件可追溯 | SQLite/API/退出恢复测试 | 任务记录面板,桌面与390px | +| 应用全部提案后继续检查与交付 | 同Task、新Run、真实check job | 待审查→应用→继续→确认执行→检查结果 | +| 读取失败日志后修复 | read_artifact归属/hash/分页,禁止自动重跑 | 日志弹窗标题/全文/hash/关闭与分页 | +| 工程检查有真实退出码和测试数量 | 失败、零测试、跳过、未知、源码过期均不判通过 | 检查计划、确认按钮、实际结果和失败原因 | +| 断线后补发,预算与停止可恢复 | 持久event cursor与不重放 | 断流恢复、暂停和再次运行记录 | +| 真实模型完成四模块修复 | 先失败、四文件提案、应用、14项测试与构建 | 保存模型会话、工具结果、保护文件hash、Git diff | +| 便携执行宿主不依赖系统npm | 随附Node/npm执行检查,启动/复用/停止 | 可运行1.1.0包清单与hash | +| 原实例升级保留连接和历史 | 旧版→SQLite→再升级测试,正式PID/模型身份核对 | 4318页面版本、任务记录与实际模型调用 | + +额外异常场景:未应用或有冲突时继续必须拒绝;双击继续只能建立一轮Run;模型配置无效时拒绝继续且不追加重复任务指令;检查期间修改源码后结果必须标过期;读取其他会话或损坏工件不能显示为成功。 + +视觉验收:固定工作台的页头、任务输入、主操作和弹窗必须在初始视口内可用;分别核对1440px桌面与390px手机尺寸。功能通过后另行目视检查文字可读性、遮挡和横向溢出,并记录短时探索结果。 diff --git a/docs/UPGRADE.md b/docs/UPGRADE.md index 95249256..bb98c02f 100644 --- a/docs/UPGRADE.md +++ b/docs/UPGRADE.md @@ -1,25 +1,28 @@ -# 从 0.1.0 升级到 1.0.0 +# 升级到 1.1.0并保留原连接 升级脚本在原Node进程中替换工作台实现,保留现有内存连接对象、项目和会话。它不会读取、打印、导出或复制API Key。普通停止后重启会丢失仅在内存中的Key,需要重新填写。 ## 升级条件 -使用已完成构建的1.0.0便携包,保留原0.1.0发行目录。工作台中的任务和命令审批均已结束,当前本地9229端口可用。脚本只接受127.0.0.1上的0.1.0工作台,先核对进程PID和原发行路径,再迁移对象。升级后校验配置、项目、会话和PID,并关闭本次开启的调试端口。 +使用已完成构建的1.1.0便携包,保留原启动发行目录及当前实现目录。工作台中的任务、工程检查和命令审批均已结束,当前本地9229端口可用。脚本接受127.0.0.1上的0.1.0、1.0.0或1.1.0工作台,先核对进程PID和原发行路径,再迁移对象。升级后校验配置、项目、会话和PID,并关闭本次开启的调试端口。控制请求使用独立HTTP连接,避免调试暂停后复用超时连接。 + +首次进入1.1.0时,旧JSON数据在保留原字节备份的事务中迁移到SQLite。任务、运行、事件和工件使用新契约,旧历史以legacy-import标明来源。随附npm位于新发行runtime,原进程保留原Node可执行路径并使用新npm检查器。 ## 执行 -在解压后的1.0.0便携目录打开PowerShell。下面的旧发行路径替换为本机真实路径,数据目录沿用当前启动配置。 +在解压后的1.1.0便携目录打开PowerShell。使用service-info保存的原启动目录,数据目录沿用当前启动配置;此前已经热升级的实例另传当前handler目录。 ```powershell -$awOldRoot = 'D:\Ai-project\REA逆向\Agent-Workbench\releases\Agent-Workbench-0.1.0-win-x64' $awNewRoot = (Get-Location).Path $awServiceInfo = Get-Content -LiteralPath (Join-Path $env:LOCALAPPDATA 'AgentWorkbench\service-info.json') -Encoding UTF8 -Raw | ConvertFrom-Json -& (Join-Path $awNewRoot 'runtime\node.exe') (Join-Path $awNewRoot 'scripts\upgrade-running.mjs') --url http://127.0.0.1:4318 --pid $awServiceInfo.pid --current-root $awOldRoot --new-root $awNewRoot +$awUpgradeArguments = @((Join-Path $awNewRoot 'scripts\upgrade-running.mjs'), '--url', 'http://127.0.0.1:4318', '--pid', $awServiceInfo.pid, '--current-root', $awServiceInfo.appRoot, '--new-root', $awNewRoot) +if ($awServiceInfo.runtimeRoot) { $awUpgradeArguments += @('--handler-root', $awServiceInfo.runtimeRoot) } +& (Join-Path $awNewRoot 'runtime\node.exe') @awUpgradeArguments ``` -成功后访问 `http://127.0.0.1:4318/?release=1.0.0`,界面显示v1.0.0。运行诊断可核对模型名称、凭据是否已配置和文件审核状态。已有项目路径继续指向原项目,不移动用户文件。 +成功后访问 `http://127.0.0.1:4318/?release=1.1.0`,界面显示v1.1.0。任务记录和运行诊断可核对模型、预算、工具、工件与文件审核状态。已有项目路径继续指向原项目,不移动用户文件。 -`service-info.json`保留原启动目录,并增加当前实现目录`runtimeRoot`与版本。再次运行启动器会复用当前本地服务;以后需要重启时,从1.0.0目录启动。 +`service-info.json`保留原启动目录,并更新当前实现目录`runtimeRoot`与版本。再次运行启动器会复用当前本地服务;以后需要重启时,从1.1.0目录启动。 ## 验证范围 diff --git a/docs/VALIDATION.md b/docs/VALIDATION.md index d93834e9..3ffbd24c 100644 --- a/docs/VALIDATION.md +++ b/docs/VALIDATION.md @@ -1,4 +1,25 @@ -# Agent Workbench 1.0.0 验收记录 +# Agent Workbench 验收记录 + +## 1.1.0 · M1可靠内核与工程切片 + +2026-10-29,Windows x64,Node24.22.1,Edge156.0.4314.42。TypeScript/Vite/esbuild构建通过。完整68项行为/API/进程退出恢复检查通过,0失败/跳过/取消;新增Task/Run、SQLite事务、工件损坏、预算、工程检查与审核后继续的覆盖。 + +| 验证 | 结果 | 结构化证据 | +| --- | --- | --- | +| 完整行为/API/实际退出与升级 | 68/68通过 | [m1-tests-validation.json](m1-tests-validation.json) | +| 基础界面 | 10/10通过 | [m1-ui-validation.json](m1-ui-validation.json) | +| 模型错误与诊断界面 | 9/9通过 | [m1-diagnostics-ui-validation.json](m1-diagnostics-ui-validation.json) | +| 任务、工件、断流、预算和审核后继续 | 7/7通过 | [m1-execution-ui-validation.json](m1-execution-ui-validation.json) | +| 1.1.0便携宿主与随附npm | 待发行验证 | 后续记录 | +| 正式原进程升级与真实模型四模块交付 | 待实际验证 | 后续记录 | + +26组界面流程的页面异常/请求失败均为0,覆盖桌面和390px。已目视核对任务、差异和手机日志弹窗:标题、hash、正文、关闭/分页及固定任务输入区均可用,无遮挡或横向溢出。新增继续按钮使用明确的可访问名称。 + +首次完整回归曾出现Windows进程fixture的ECONNRESET,旧版升级控制请求改用独立HTTP连接并记录失败阶段后,完整68项复验通过。专项第一次收尾因按钮名称包含说明文字而定位超时,补齐aria-label并完成7组任务UI复验。失败记录保留在findings.md,未重放迁移或命令来掩盖问题。 + +1.1.0实现Node/npm工程切片;三类工程完整M2验收、任务依赖图、外部引擎、REA执行和桌面/手机配对仍在后续阶段。真实模型样本的审查次数与用量单独报告。 + +以下保留1.0.0基线验收。 验收日期:2026-10-29(Asia/Shanghai)。环境:Windows x64,Node.js 24.22.1,npm 11.19.1,Microsoft Edge 156.0.4314.42。自动化验证使用独立项目和数据目录,正式用户会话验证单独记录。 diff --git a/docs/m1-diagnostics-ui-validation.json b/docs/m1-diagnostics-ui-validation.json new file mode 100644 index 00000000..22a6dd2f --- /dev/null +++ b/docs/m1-diagnostics-ui-validation.json @@ -0,0 +1,20 @@ +{ + "success": true, + "version": "1.1.0", + "url": "http://127.0.0.1:4319", + "date": "2026-10-29T06:36:49.517Z", + "passed": [ + "model response validation checks the tentative connection before saving", + "a model failure after successful tools shows source, attempts and local runtime diagnosis", + "explicit retry preserves the completed tool result without replaying the task", + "an error question receives the actual session diagnosis and formatted answer", + "review state exposes the review action and prevents application during a running request", + "approved Unicode commands execute in the declared shell and retain Chinese output", + "authentication errors do not retry and error/diagnostic controls fit a 390 px viewport", + "stop cancels pending retry and clears running model state", + "a transient service failure recovers within the bounded retry policy" + ], + "pageErrors": [], + "requestFailures": [], + "modelValidation": "controlled local HTTP fixture; actual configured model is verified separately" +} \ No newline at end of file diff --git a/docs/m1-execution-ui-validation.json b/docs/m1-execution-ui-validation.json new file mode 100644 index 00000000..bf8c8785 --- /dev/null +++ b/docs/m1-execution-ui-validation.json @@ -0,0 +1,19 @@ +{ + "success": true, + "version": "1.1.0", + "testedAt": "2026-10-29T06:41:24.891Z", + "browser": "156.0.4314.42", + "passed": [ + "model-selected checks wait for approval and display actual counted results", + "verified artifact preview shows the real check log and hash", + "changed source invalidates old checks and manual confirmation runs the new plan", + "390px task drawer, log preview, close controls and fixed composer remain operable", + "reconnection synchronizes missed session changes in other projects", + "budget controls pause before tools and preserve the goal across recorded runs", + "applied proposals continue the original task into actual engineering verification" + ], + "pageErrors": [], + "requestFailures": [], + "projectRoot": "D:\\Ai-project\\REA逆向\\Agent-Workbench\\.qa\\execution-ui-cf140b8d-6210-49cd-bbdf-18dae4cb7de1\\project", + "model": "controlled local HTTP fixture" +} \ No newline at end of file diff --git a/docs/m1-tests-validation.json b/docs/m1-tests-validation.json new file mode 100644 index 00000000..64640e8f --- /dev/null +++ b/docs/m1-tests-validation.json @@ -0,0 +1,14 @@ +{ + "success": true, + "version": "1.1.0", + "testedAt": "2026-10-29T06:39:22.343Z", + "command": "npm test", + "tests": 68, + "passed": 68, + "failed": 0, + "skipped": 0, + "cancelled": 0, + "durationMs": 62325.4018, + "priorFailures": "Two complete runs recorded ECONNRESET in Windows process fixtures; after independent control HTTP connections the full suite passed.", + "realModel": false +} \ No newline at end of file diff --git a/docs/m1-ui-validation.json b/docs/m1-ui-validation.json new file mode 100644 index 00000000..1b92eada --- /dev/null +++ b/docs/m1-ui-validation.json @@ -0,0 +1,27 @@ +{ + "success": true, + "url": "http://127.0.0.1:4319", + "browser": "Microsoft Edge 156.0.4314.42", + "date": "2026-10-29T06:25:49.209Z", + "projectRoot": "D:\\Ai-project\\REA逆向\\Agent-Workbench\\.qa\\ui-d29db581-673d-48a9-a777-954d6b96fb11\\ui-project", + "viewports": [ + 1440, + 780, + 390 + ], + "passed": [ + "project selection and real file preview", + "real command consent, execution and stale snapshot rejection", + "diff review and verified file application", + "manual editor creates a reviewable proposal", + "file responses stay with the current selection", + "denial, session selection, reload, stale response rejection and export", + "project inventory responses cannot replace another project", + "780 and 390 px: project drawer, file, diff and trace controls, no page overflow", + "unified and detailed research reports render", + "model list, ephemeral key, compatible fixture tool loop and return to offline mode" + ], + "pageErrors": [], + "requestFailures": [], + "modelValidation": "controlled local HTTP fixture; no real model" +} \ No newline at end of file diff --git a/findings.md b/findings.md index 5c8b2849..90250bda 100644 --- a/findings.md +++ b/findings.md @@ -99,3 +99,15 @@ Claude Code 报告已验证工具输入校验、权限决定、队列并发屏 - 完整15项检查专项通过;串行热升级发现第二个handler闭包缺少原server绑定。新handler显式持有服务器身份,兼容旧handler时仅按已核对PID/端口取回当前本地Server对象;新增server close监听释放SQLite owner,继续验证二次升级。 - 串行升级和SQLite停止owner释放已通过。任务UI首4组通过;目视发现390px日志弹窗被检视区滚动/长hash影响而横向偏移,改为body Portal并允许hash换行。Playwright setOffline未切断已有SSE,改用只连接独立QA服务的代理真实断流测试补发。 - 当前65/65完整测试、6/6任务UI通过。手机日志Portal后的标题、hash、全文与关闭/分页入口在视口,已目视确认;任务目标、实际模型、预算和工程检查层次清楚。 +- 核心/检查提交2ea3485已保存。追加“继续检查与交付”显式操作,审核应用后保留原Task目标进入新Run;普通completed的resume仍拒绝。检查结果加入真实日志摘录及read_artifact工具,模型可读已保存日志而不重跑。 +- 1.1.0便携增加随附npm;原进程执行路径仍是旧Node,热升级后的检查器优先使用新发行runtime中的npm CLI,保留原Node/模型对象。升级专项加入无npm的旧Node副本→新随附npm真实检查。 +- 跨四模块Delivery Report基线/14项验收已封存到benchmarks/node-delivery-v1/baseline;模型仅允许修改四个src模块,验收文件/构建脚本与package保持hash,等待真实运行。 + +- 本轮修正继续操作的写入顺序:先校验模型配置,再在run.started事务内追加review-action指令;无效请求不新增Run或指令,双请求只接受一轮。界面按当前Task筛选已应用改动。 +- 专项19项中18通过;新增API并发/重启行为已通过,收尾断言误读export的顶层providerMessages,实际格式为session.providerMessages。已修正测试读取位置,产品不需要改变导出格式。 +- 首次完整68项回归66通过,两个Windows进程重启/升级fixture请求出现ECONNRESET;没有业务断言失败。单独复核这两个实际进程场景均通过,旧Node副本调用新随附npm与停止owner释放正常。准备在不并发浏览器工作负载下重跑完整回归,保留首次失败记录,不添加会重放POST的盲目重试。 +- 基础UI10/10通过,页面异常与请求失败为零,覆盖1440/780/390px和模型配置恢复。真实四模块验收器已写入,只操作独立合成工程并核对封存脚本/保护hash/原Task与Git提交范围。 +- 第二次完整回归67/68通过,旧版串行升级fixture在并发进程负载下再次ECONNRESET。升级控制请求改用Connection:close,避免调试暂停超过keep-alive时复用旧连接;增加具体请求阶段和底层code。没有重试迁移/写入,后续完整回归用于验证这项修改。 +- README首个更新补丁因把完整长行截成前半句而未匹配,未写文件;改为完整行后应用成功。 +- 新任务UI前6组通过,最后一组定位“继续检查与交付”超时。真实DOM与Task/Run核对确认按钮已显示,accessible name包含辅助说明,导致精确名称不匹配。为操作补充明确aria-label后重新构建并复验,保留界面截图与失败记录。 +- 最终68/68行为与10/9/7组界面全部通过,证据已复制到docs/m1-*.json。持续浏览器补充观察的组合cell超时并重置kernel,功能验收仍以已完成的独立脚本和截图为准;后续浏览器操作拆成短cell。 diff --git a/package-lock.json b/package-lock.json index 606e8214..88de51a3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "local-agent-workbench", - "version": "1.0.0", + "version": "1.1.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "local-agent-workbench", - "version": "1.0.0", + "version": "1.1.0", "dependencies": { "diff": "^8.0.2", "lucide-react": "^0.548.0", diff --git a/package.json b/package.json index f46e0a2e..4fdf2b2f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "local-agent-workbench", - "version": "1.0.0", + "version": "1.1.0", "private": true, "type": "module", "description": "A local coding workbench with explicit tool execution, reviewable changes and recoverable sessions.", diff --git a/progress.md b/progress.md index f0f3b360..f0547fe1 100644 --- a/progress.md +++ b/progress.md @@ -78,3 +78,12 @@ - 任务/运行/预算/工件界面、断线补发、工程识别/检查计划/实际npm job、错误与过期状态完成;空文件/零测试/未知统计均不判通过。 - 当前完整65项测试通过,0失败/跳过;新增6组任务UI通过,0页面/请求异常。390px工件弹窗已修正并目视核对;旧1.0热handler→SQLite→第二次升级、真实内存合成连接及停止owner释放通过。 - 开始保存本地工程检查实现提交,随后做跨文件真实工程样本、基础/诊断UI、1.1.0便携包与实际4318升级。 + +## 2026-10-29 持续开发接续 + +- 用户要求继续开发不要停。核对2ea3485及20份已有续作,当前服务仍是4318/PID23080,独立QA服务为4319/PID44240。 +- 沿用planning-with-files与webapp-testing,继续审核后同Task新Run、真实失败日志读取及四模块工程交付;先完善对应契约,再验证发行与原进程升级。 +- 审核后继续、无效配置与重复请求、重启目标保存通过。Windows串行升级在完整并发回归出现两次ECONNRESET,控制请求改用独立连接并保存请求阶段;完整68/68回归随后通过。 +- 基础UI10/10、诊断UI9/9通过,页面异常/请求失败为零。任务UI正在完成新增继续交付场景;便携验证器增加无系统Node/npm下的真实4项示例检查和日志校验。 +- 任务UI最终7/7通过,含应用→继续原Task→实际检查。首轮定位因辅助说明进入accessible name而超时,新增明确aria-label后通过;手机日志和桌面差异/输入区域已目视核对。 +- 持久Node REPL的Edge自动发现路径不存在,已使用实测Program Files (x86)路径恢复浏览器;未安装或替换系统浏览器。 diff --git a/scripts/upgrade-running.mjs b/scripts/upgrade-running.mjs index 3895d074..231522a4 100644 --- a/scripts/upgrade-running.mjs +++ b/scripts/upgrade-running.mjs @@ -15,6 +15,18 @@ async function within(promise, milliseconds, label) { finally { clearTimeout(timer); } } +async function readUpgradeJson(address, milliseconds, stage) { + try { + // Inspector pauses can outlast a server's keep-alive timeout. Use a fresh + // connection for each control request rather than reuse a stale pooled one. + const response = await fetch(address, { headers: { Connection: 'close' }, signal: AbortSignal.timeout(milliseconds) }); + if (!response.ok) throw new Error('HTTP ' + response.status); + return await response.json(); + } catch (error) { + throw new Error(stage + ': ' + error.message + (error.cause?.code ? ' (' + error.cause.code + ')' : ''), { cause: error }); + } +} + class Protocol { constructor(socket) { this.socket = socket; this.nextId = 1; this.pending = new Map(); this.listeners = new Map(); @@ -51,20 +63,20 @@ export async function upgradeRunning({ url, pid, currentRoot, newRoot, handlerRo const upgradeScript = path.join(next, 'dist-server', 'hot-upgrade.mjs'); if (!fs.existsSync(originalScript) || !fs.existsSync(upgradeScript) || !fs.existsSync(path.join(next, 'dist-client', 'index.html'))) throw new Error('Upgrade bundles are incomplete.'); if (!Number.isInteger(pid) || pid < 1 || pid === process.pid) throw new Error('Invalid target process.'); - const before = await (await fetch(origin + '/api/bootstrap', { signal: AbortSignal.timeout(5000) })).json(); + const before = await readUpgradeJson(origin + '/api/bootstrap', 5000, 'Read original Workbench'); if (!before.token || !['0.1.0', '1.0.0', '1.1.0'].includes(before.version)) throw new Error('This migration accepts a supported existing Workbench.'); if (before.sessions.some(session => ['running', 'awaiting_approval', 'stopping'].includes(session.status))) throw new Error('Wait for existing tasks and approvals before upgrading.'); let protocol, socket, enabledHere = false, paused = false; const breakpoints = []; try { let targets; - try { targets = await (await fetch('http://127.0.0.1:9229/json/list', { signal: AbortSignal.timeout(500) })).json(); } catch {} + try { targets = await readUpgradeJson('http://127.0.0.1:9229/json/list', 500, 'Discover inspector'); } catch {} if (targets && !targets.some(target => sameTarget(target, originalScript))) throw new Error('The local inspector port belongs to another process.'); if (!targets) { process._debugProcess(pid); enabledHere = true; for (let attempt = 0; attempt < 40 && !targets; attempt++) { await delay(100); - try { targets = await (await fetch('http://127.0.0.1:9229/json/list', { signal: AbortSignal.timeout(500) })).json(); } catch {} + try { targets = await readUpgradeJson('http://127.0.0.1:9229/json/list', 500, 'Discover opened inspector'); } catch {} } } const target = targets?.find(item => sameTarget(item, originalScript)); @@ -91,11 +103,11 @@ export async function upgradeRunning({ url, pid, currentRoot, newRoot, handlerRo if (locations.length !== 1) throw new Error('The existing request handler could not be identified uniquely.'); breakpoints.push((await protocol.send('Debugger.setBreakpoint', { location: { scriptId: script.scriptId, lineNumber: locations[0] } })).breakpointId); } - const probe = fetch(origin + '/api/health', { signal: AbortSignal.timeout(15000) }); + const probe = readUpgradeJson(origin + '/api/health', 15000, 'Observe owned request handler'); probe.catch(() => {}); const event = await within(pausedEvent, 10000, 'Workbench request observation'); const captured = await protocol.send('Debugger.evaluateOnCallFrame', { callFrameId: event.callFrames[0].callFrameId, - expression: "(() => { const retainedServer = typeof server !== 'undefined' ? server : process._getActiveHandles().find(handle => handle?.listening && handle.address?.()?.port === " + new URL(origin).port + "); if (!retainedServer) throw new Error('Owned local server not found'); globalThis.__awUpgradeContext = { server: retainedServer, store, provider, runtime, token, clients, started, exampleProject, shutdown }; return 'context-ready'; })()", returnByValue: true }); + expression: "(() => { const servers = typeof server !== 'undefined' ? [server] : process._getActiveHandles().filter(handle => handle?.listening && handle.address?.()?.address === '127.0.0.1' && handle.address?.()?.port === " + new URL(origin).port + "); if (servers.length !== 1) throw new Error('Owned local server not found uniquely'); globalThis.__awUpgradeContext = { server: servers[0], store, provider, runtime, token, clients, started, exampleProject, shutdown }; return 'context-ready'; })()", returnByValue: true }); if (captured.exceptionDetails || captured.result.value !== 'context-ready') throw new Error('Could not retain the existing runtime objects.'); for (const breakpointId of breakpoints.splice(0)) await protocol.send('Debugger.removeBreakpoint', { breakpointId }); await protocol.send('Debugger.resume'); paused = false; await probe; @@ -103,8 +115,8 @@ export async function upgradeRunning({ url, pid, currentRoot, newRoot, handlerRo const upgraded = await protocol.send('Runtime.evaluate', { expression, awaitPromise: true, returnByValue: true }); if (upgraded.exceptionDetails) throw new Error('Runtime upgrade failed: ' + (upgraded.exceptionDetails.exception?.description ?? upgraded.exceptionDetails.text)); const result = upgraded.result.value; - const after = await (await fetch(origin + '/api/bootstrap', { signal: AbortSignal.timeout(5000) })).json(); - const health = await (await fetch(origin + '/api/health', { signal: AbortSignal.timeout(5000) })).json(); + const after = await readUpgradeJson(origin + '/api/bootstrap', 5000, 'Read upgraded Workbench'); + const health = await readUpgradeJson(origin + '/api/health', 5000, 'Verify upgraded PID'); if (health.pid !== pid || result.pid !== pid || after.version !== result.version || after.config.hasKey !== before.config.hasKey || after.config.model !== before.config.model || after.config.baseUrl !== before.config.baseUrl || JSON.stringify(after.projects) !== JSON.stringify(before.projects) diff --git a/scripts/verify-diagnostics-ui.mjs b/scripts/verify-diagnostics-ui.mjs index 6757608d..31b98978 100644 --- a/scripts/verify-diagnostics-ui.mjs +++ b/scripts/verify-diagnostics-ui.mjs @@ -158,7 +158,7 @@ try { mode = 'transient'; requestCount = 0; await task('验证自动恢复'); await waitState('completed'); assert.equal(requestCount, 2); await screenshot('formal-desktop'); mark('a transient service failure recovers within the bounded retry policy'); assert.deepEqual(pageErrors, []); assert.deepEqual(networkErrors, []); - const result = { success: true, version: '1.0.0', url, date: new Date().toISOString(), passed, pageErrors, requestFailures: networkErrors, modelValidation: 'controlled local HTTP fixture; actual configured model is verified separately' }; + const result = { success: true, version: bootstrap.version, url, date: new Date().toISOString(), passed, pageErrors, requestFailures: networkErrors, modelValidation: 'controlled local HTTP fixture; actual configured model is verified separately' }; fs.writeFileSync('.qa/diagnostics-ui-validation.json', JSON.stringify(result, null, 2)); console.log(JSON.stringify(result, null, 2)); } catch (error) { if (page) await page.screenshot({ path: '.qa/screenshots/formal-ui-failure.png', scale: 'css' }).catch(() => {}); diff --git a/scripts/verify-execution-ui.mjs b/scripts/verify-execution-ui.mjs index 9ec018d2..726273af 100644 --- a/scripts/verify-execution-ui.mjs +++ b/scripts/verify-execution-ui.mjs @@ -46,6 +46,7 @@ const model = http.createServer(async (request, response) => { let call; if (mode === 'checks') call = !results.length ? ['inspect_project', {}] : results.length === 1 ? ['plan_checks', {}] : results.length === 2 ? ['run_checks', { plan_id: plan.id }] : null; if (mode === 'budget') call = ['list_files', { path: '' }]; + if (mode === 'proposal') call = !results.length ? ['propose_file', { path: 'src.mjs', content: 'export const add = (a, b) => a + b + 0;\n', reason: 'Verify reviewed task continuation' }] : null; response.writeHead(200, { 'Content-Type': 'application/json' }); response.end(JSON.stringify({ choices: [{ message: { role: 'assistant', content: call ? '' : mode === 'answer' ? '依据已保存记录完成本次回应。' : '已记录实际工程检查和日志。', ...(call ? { tool_calls: [{ id: randomUUID(), type: 'function', function: { name: call[0], arguments: JSON.stringify(call[1]) } }] } : {}) }, finish_reason: call ? 'tool_calls' : 'stop' }], usage: mode === 'budget' ? { prompt_tokens: 1000, completion_tokens: 100 } : { prompt_tokens: 40, completion_tokens: 20 } })); } catch (error) { response.writeHead(500, { 'Content-Type': 'application/json' }); response.end(JSON.stringify({ error: { message: error.message } })); } @@ -118,6 +119,13 @@ try { await expect(taskPanel()).toContainText('到达本次 token 预算'); await expect(taskPanel()).toContainText('1,000 tokens'); await screenshot('execution-budget-history'); mark('budget controls pause before tools and preserve the goal across recorded runs'); + mode = 'proposal'; await newTask('应用后继续同一个工程任务'); await waitState('needs_review'); const reviewed = await state(); + await page.locator('.inspector-tabs').getByRole('button', { name: /改动/ }).click(); await page.getByRole('button', { name: '应用这项改动', exact: true }).click(); + await waitState('completed'); mode = 'checks'; await page.getByRole('button', { name: '继续检查与交付', exact: true }).click(); await waitState('awaiting_approval'); + await page.getByRole('button', { name: '确认执行', exact: true }).click(); await waitState('completed'); + const delivered = await state(); assert.equal(delivered.execution.task.id, reviewed.execution.task.id); assert.equal(delivered.execution.task.goal, '应用后继续同一个工程任务'); assert.equal(delivered.execution.checks.at(-1).status, 'passed'); + mark('applied proposals continue the original task into actual engineering verification'); + assert.deepEqual(errors, []); assert.deepEqual(requestFailures, []); const result = { success: true, version: bootstrap.version, testedAt: new Date().toISOString(), browser: browser.version(), passed, pageErrors: errors, requestFailures, projectRoot, model: 'controlled local HTTP fixture' }; fs.writeFileSync('.qa/execution-ui-validation.json', JSON.stringify(result, null, 2)); console.log(JSON.stringify(result, null, 2)); diff --git a/scripts/verify-live-delivery.mjs b/scripts/verify-live-delivery.mjs new file mode 100644 index 00000000..ab47a891 --- /dev/null +++ b/scripts/verify-live-delivery.mjs @@ -0,0 +1,149 @@ +import fs from 'node:fs'; +import path from 'node:path'; +import assert from 'node:assert/strict'; +import { createHash, randomUUID } from 'node:crypto'; +import { execFileSync, spawnSync } from 'node:child_process'; + +// Operates only on a fresh synthetic project. The configured model remains in +// the running host; bootstrap contains an API session token, never its model key. +const workspace = process.cwd(); +const url = process.env.AGENT_WORKBENCH_URL || 'http://127.0.0.1:4318'; +const origin = new URL(url); +assert.equal(origin.hostname, '127.0.0.1'); assert.equal(origin.protocol, 'http:'); +const bootstrap = await (await fetch(origin.origin + '/api/bootstrap')).json(); +assert.equal(bootstrap.version, '1.1.0'); assert.equal(bootstrap.config.mode, 'compatible'); +assert.ok(bootstrap.config.model, 'Configure a model on the running Workbench first.'); +const api = async (route, input) => { + const response = await fetch(origin.origin + '/api' + route, { method: input === undefined ? 'GET' : 'POST', + headers: { 'Content-Type': 'application/json', 'X-Workbench-Token': bootstrap.token }, + ...(input === undefined ? {} : { body: JSON.stringify(input) }), signal: AbortSignal.timeout(15000) }); + const result = await response.json(); + if (!response.ok) throw Object.assign(new Error(result.error ?? 'Workbench HTTP ' + response.status), { status: response.status }); + return result; +}; + +const caseRoot = path.resolve('.qa', 'live-delivery-' + randomUUID()); +const projectRoot = path.join(caseRoot, '交付报告工程'); +const allowed = ['src/normalize.mjs', 'src/summary.mjs', 'src/render.mjs', 'src/cli.mjs']; +const scripts = { test: 'node --test test/*.test.mjs', build: 'node scripts/build.mjs' }; +fs.mkdirSync(caseRoot, { recursive: true }); +fs.cpSync(path.join(workspace, 'benchmarks/node-delivery-v1/baseline'), projectRoot, { recursive: true }); +fs.writeFileSync(path.join(projectRoot, '.gitignore'), 'dist/\n'); +fs.writeFileSync(path.join(projectRoot, 'OWNER-NOTES.md'), '# Owner notes\nBaseline owner content.\n'); +const git = args => execFileSync('git', ['-c', 'core.autocrlf=false', '-c', 'user.name=Agent Workbench QA', '-c', 'user.email=qa@workbench.local', '-C', projectRoot, ...args], { encoding: 'utf8', windowsHide: true }); +git(['init', '--initial-branch=main']); git(['add', '.']); git(['commit', '-m', 'test: seal delivery-report acceptance baseline']); +const baselineCommit = git(['rev-parse', 'HEAD']).trim(); +fs.appendFileSync(path.join(projectRoot, 'OWNER-NOTES.md'), 'Existing owner edit: ' + randomUUID() + '\n'); +fs.writeFileSync(path.join(projectRoot, 'UNTRACKED-OWNER.txt'), 'Existing untracked owner file: ' + randomUUID() + '\n'); +const sha = file => createHash('sha256').update(fs.readFileSync(path.join(projectRoot, file))).digest('hex'); +const protectedPaths = ['README.md', 'package.json', 'test/delivery.test.mjs', 'scripts/build.mjs', 'fixtures/tasks.json', 'fixtures/invalid.json', '.gitignore', 'OWNER-NOTES.md', 'UNTRACKED-OWNER.txt']; +const protectedHashes = Object.fromEntries(protectedPaths.map(file => [file, sha(file)])); +const beforeSources = Object.fromEntries(allowed.map(file => [file, sha(file)])); +const ownerDiff = git(['diff', '--', 'OWNER-NOTES.md']); +const assertProtected = () => { + for (const [file, hash] of Object.entries(protectedHashes)) assert.equal(sha(file), hash, 'Protected input changed: ' + file); + assert.equal(git(['diff', '--', 'OWNER-NOTES.md']), ownerDiff, 'Existing owner edits changed.'); +}; +const project = await api('/projects', { root: projectRoot }); +const session = await api('/sessions', { projectId: project.id }); +const started = Date.now(), applied = [], decisions = [], reviewLimit = 4; +let reviewedRounds = 0, state, succeeded = false, lastProgress = '', originalTaskId; +const saveEvidence = result => { + fs.writeFileSync(path.join(caseRoot, 'result.json'), JSON.stringify(result, null, 2)); + fs.writeFileSync(path.join(workspace, '.qa/live-delivery-validation.json'), JSON.stringify(result, null, 2)); +}; + +try { + await api('/sessions/' + session.id + '/messages', { content: + '完成当前 Delivery Report 工程,严格实现 README.md 的七项要求。先用 inspect_project 识别工程,' + + '再用 plan_checks 选择 test/build,并用 run_checks 实际运行封存输入,取得失败的测试和日志。' + + '依据实际失败读取有关文件,使用 read_artifact 进一步核对失败日志。只能用 propose_file 修改 src/normalize.mjs、src/summary.mjs、src/render.mjs、src/cli.mjs;' + + '测试、fixtures、构建脚本、package.json、README 和 OWNER 文件必须保留。四模块都需修复,不能修改验收来通过。' + + '本工程没有第三方依赖,不用安装。不要使用 run_command、不要自己提交Git;本轮终端仅通过已识别的npm检查计划运行。' + + '提案等待审查应用,随后继续同一目标并实际重新运行 test/build,依据日志修复直至通过;最后用中文报告实际测试数量、构建结果和改动。' }); + while (Date.now() - started < 720000) { + state = await api('/sessions/' + session.id); originalTaskId ??= state.execution.task.id; + assert.equal(state.execution.task.id, originalTaskId, 'Engineering delivery must retain the original Task.'); + assertProtected(); + const progress = state.status + '|' + state.events.length + '|' + state.execution.checks.map(job => job.status).join(','); + if (progress !== lastProgress) { + console.log(JSON.stringify({ status: state.status, elapsedSeconds: Math.round((Date.now() - started) / 1000), + tools: state.events.filter(event => event.kind === 'tool').slice(-5).map(event => ({ tool: event.tool, phase: event.phase })), + checks: state.execution.checks.map(job => ({ status: job.status, results: job.results.map(result => ({ name: result.name, status: result.status, tests: result.tests })) })), + appliedFiles: applied.map(item => item.path) })); + lastProgress = progress; + } + for (const proposal of state.changes.filter(change => ['pending', 'conflict'].includes(change.status))) assert.ok(allowed.includes(proposal.path), 'Out-of-scope proposal: ' + proposal.path); + for (const approval of state.approvals.filter(item => item.status === 'pending')) { + const plan = state.execution.plans?.find(item => item.id === approval.checkPlanId); + const allow = !!plan && plan.taskId === originalTaskId && plan.checks.length > 0 && plan.checks.length <= 2 + && plan.checks.every(check => scripts[check.name] === check.script && check.command === 'npm run ' + check.name && check.lifecycle.length === 0) + && approval.command === plan.checks.map(check => check.command).join('\n'); + decisions.push({ approvalId: approval.id, planId: plan?.id ?? null, command: approval.command, allow }); + await api('/sessions/' + session.id + '/approvals/' + approval.id, { allow }); + assert.ok(allow, 'Model requested a command outside the sealed test/build contract.'); + } + if (['running', 'awaiting_approval', 'stopping'].includes(state.status)) { await new Promise(resolve => setTimeout(resolve, 1000)); continue; } + if (state.status === 'failed') throw new Error(state.failure?.message ?? 'The real model task failed.'); + if (state.status === 'paused') { + assert.equal(state.execution.run.stopReason, 'step_limit', 'Budget/cancellation must be inspected before continuing.'); + assert.ok(state.execution.runs.length < 5, 'Bounded continuation count exceeded.'); + await api('/sessions/' + session.id + '/resume', {}); continue; + } + const pending = state.changes.filter(change => change.status === 'pending'); + if (pending.length) { + assert.ok(state.execution.checks.some(job => job.status === 'failed' && job.results.some(result => result.tests?.failed > 0)), 'Capture a real baseline test failure before applying repairs.'); + assert.ok(++reviewedRounds <= reviewLimit, 'Too many repair/review rounds.'); + for (const proposal of pending) { + assert.equal(sha(proposal.path), proposal.baseSha256, 'Proposal baseline changed.'); + assert.notEqual(proposal.content.trim(), '', 'Empty source proposal.'); + const beforeApply = await api('/sessions/' + session.id + '/changes/' + proposal.id + '/apply', {}); + assert.equal(sha(proposal.path), proposal.sha256, 'Applied bytes do not match the reviewed proposal.'); + applied.push({ id: proposal.id, path: proposal.path, sha256: proposal.sha256, taskId: originalTaskId }); + assert.ok(beforeApply.session ?? beforeApply, 'No apply response.'); assertProtected(); + } + await api('/sessions/' + session.id + '/continue-reviewed', {}); continue; + } + assert.equal(state.status, 'completed'); break; + } + assert.equal(state?.status, 'completed', 'Engineering delivery timed out.'); + assert.equal(state.execution.task.verification.status, 'passed', 'No authoritative passing engineering check.'); + const passedJob = state.execution.checks.filter(job => job.status === 'passed').at(-1); + assert.ok(passedJob); assert.ok(passedJob.results.some(result => result.name === 'test' && result.exitCode === 0 && result.tests?.total === 14 && result.tests.passed === 14)); + assert.ok(passedJob.results.some(result => result.name === 'build' && result.exitCode === 0 && result.status === 'passed')); + assert.deepEqual([...new Set(applied.map(item => item.path))].sort(), [...allowed].sort()); + for (const file of allowed) assert.notEqual(sha(file), beforeSources[file], 'Module was not repaired: ' + file); + assertProtected(); + const built = spawnSync(process.execPath, [path.join(projectRoot, 'dist/cli.mjs'), path.join(projectRoot, 'fixtures/tasks.json'), '--json'], { cwd: projectRoot, encoding: 'utf8', windowsHide: true }); + assert.equal(built.status, 0); assert.equal(built.stderr, ''); + assert.deepEqual(JSON.parse(built.stdout), { total: 4, counts: { todo: 0, doing: 1, done: 2, blocked: 1 }, completedPercent: 50, remainingMinutes: 50 }); + const diff = git(['diff', '--', ...allowed]); assert.ok(diff.length > 0); fs.writeFileSync(path.join(caseRoot, 'reviewed-changes.diff'), diff); + git(['add', '--', ...allowed]); git(['commit', '--only', '-m', 'feat: repair delivery report with 14 verified acceptance cases', '--', ...allowed]); + const deliveredCommit = git(['rev-parse', 'HEAD']).trim(); assert.notEqual(deliveredCommit, baselineCommit); assertProtected(); + assert.deepEqual(git(['diff-tree', '--no-commit-id', '--name-only', '-r', 'HEAD']).trim().split(/\r?\n/).sort(), [...allowed].sort()); + const exported = await api('/sessions/' + session.id + '/export'); + fs.writeFileSync(path.join(caseRoot, 'session.json'), JSON.stringify(exported, null, 2)); + for (const job of state.execution.checks) for (const result of job.results) { + if (!result.logArtifactId) continue; + let offset = 0, text = '', log; + do { log = await api('/artifacts/' + result.logArtifactId + '?session=' + session.id + '&offset=' + offset + '&limit=16000'); text += log.content; offset += log.content.length; } while (log.truncated && log.content.length); + fs.writeFileSync(path.join(caseRoot, job.id + '-' + result.name + '.log'), text); + } + const result = { success: true, version: bootstrap.version, testedAt: new Date().toISOString(), model: bootstrap.config.model, + projectRoot, projectId: project.id, sessionId: session.id, taskId: originalTaskId, baselineCommit, deliveredCommit, + elapsedSeconds: Math.round((Date.now() - started) / 1000), runs: state.execution.runs.length, reviewRounds: reviewedRounds, applied, + protectedHashes, ownerEditsPreserved: true, buildOutput: JSON.parse(built.stdout), usage: state.execution.task.usage, + checks: state.execution.checks, decisions, diffPath: path.join(caseRoot, 'reviewed-changes.diff'), sessionPath: path.join(caseRoot, 'session.json'), + credentialsHandling: 'Calls use the running host model configuration; no model key was read, copied or saved.', + intervention: 'Verifier approved only sealed npm scripts, checked four source proposals and applied them; implementation came from the configured model. The verifier saved a source-only local Git commit.', + scope: 'One synthetic Node engineering sample; does not establish M2 or M6 delivery success rates.' }; + saveEvidence(result); succeeded = true; + console.log(JSON.stringify({ success: true, model: result.model, testsPassed: 14, buildPassed: true, deliveredCommit, elapsedSeconds: result.elapsedSeconds, reviewRounds: reviewedRounds, projectRoot, sessionId: session.id }, null, 2)); +} catch (error) { + saveEvidence({ success: false, version: bootstrap.version, testedAt: new Date().toISOString(), model: bootstrap.config.model, projectRoot, + projectId: project.id, sessionId: session.id, taskId: originalTaskId, error: error.message, elapsedSeconds: Math.round((Date.now() - started) / 1000), applied, decisions, + checks: state?.execution?.checks ?? [] }); + throw error; +} finally { + if (!succeeded) await api('/sessions/' + session.id + '/stop', {}).catch(() => {}); +} diff --git a/scripts/verify-live-session.mjs b/scripts/verify-live-session.mjs index 319d8294..de8e903b 100644 --- a/scripts/verify-live-session.mjs +++ b/scripts/verify-live-session.mjs @@ -6,7 +6,7 @@ import { createHash } from 'node:crypto'; const url = process.env.AGENT_WORKBENCH_URL || 'http://127.0.0.1:4318'; const sessionId = process.env.AGENT_WORKBENCH_SESSION || '569c9457-d399-46e6-b53e-4b1fdbb02109'; const bootstrap = await (await fetch(url + '/api/bootstrap')).json(); -assert.equal(bootstrap.version, '1.0.0'); +assert.ok(['1.0.0', '1.1.0'].includes(bootstrap.version)); assert.equal(bootstrap.config.mode, 'compatible'); assert.ok(bootstrap.config.hasKey, 'The existing in-memory connection must be present.'); const api = async (route, input) => { diff --git a/src/client/App.tsx b/src/client/App.tsx index 3ea9ad0a..57847973 100644 --- a/src/client/App.tsx +++ b/src/client/App.tsx @@ -11,7 +11,7 @@ const defaultConfig: Config = { mode: 'demo', baseUrl: 'http://127.0.0.1:11434/v export default function App() { const [token, setAccess] = useState(''); - const [version, setVersion] = useState('1.0.0'); + const [version, setVersion] = useState('1.1.0'); const [diagnosticsOpen, setDiagnosticsOpen] = useState(false); const [diagnostics, setDiagnostics] = useState(null); const [diagnosticsBusy, setDiagnosticsBusy] = useState(false); @@ -256,6 +256,11 @@ export default function App() { try { acceptSession(await api('/sessions/' + session.id + '/resume', {})); } catch (error) { failure(error); } finally { setResuming(false); } } + async function continueReviewed() { + if (!session || resuming || isRunning) return; setResuming(true); + try { acceptSession(await api('/sessions/' + session.id + '/continue-reviewed', {})); } + catch (error) { failure(error); } finally { setResuming(false); } + } async function testModel() { setSettingsBusy(true); setModelCheck(null); try { @@ -419,6 +424,7 @@ export default function App() { } {approval &&
确认这次终端执行

{approval.reason}

{approval.command}
{approval.cwd}

{approval.shell || '项目终端'} · UTF-8

确认后以你的系统权限执行。

} {pending.length > 0 && !isRunning && } + {pending.length === 0 && !isRunning && session?.execution?.run?.status === 'needs_review' && session.changes.some(change => change.status === 'applied' && (!change.taskId || change.taskId === session.execution?.task?.id)) && }