diff --git a/AGENTS.md b/AGENTS.md index ea3a6322..23ed281b 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -4,7 +4,7 @@ 本仓库专注AI编程与能力研究工作台。其他项目不纳入本项目计划或代码。用户确定的研究对象为Codex、Claude Code、Cursor、DeepSeek Harness、WorkBuddy及DSH-purge;目标是将有证据的机制独立开发成自有Harness内置能力。 -1.0.0是已保存的基础里程碑;1.1.0已交付M1可靠内核,1.2.0增加当前Task的本地Git交付及证据报告。后续实现与真实工程验收见docs/PRODUCT-PLAN.md、docs/CAPABILITIES.md和docs/RESEARCH-ROADMAP.md。计划中的能力不能写成已经实现。 +1.0.0是已保存的基础里程碑;1.1.0已交付M1可靠内核,1.2.0增加当前Task的本地Git交付及证据报告,1.3.0增加有界工程索引与精确补丁。后续实现与真实工程验收见docs/PRODUCT-PLAN.md、docs/CAPABILITIES.md和docs/RESEARCH-ROADMAP.md。计划中的能力不能写成已经实现。 ## 研究与来源 diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d16a6a9..f4241b8c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Agent Workbench 更新记录 +## 1.3.0 · 2026-10-29 + +- 增加当前项目的工程索引:JS/TS/React静态声明与导入、Python声明候选、逐文件SHA256增量复用及覆盖范围;新增index_project/query_code模型工具和Task所属索引工件。 +- 右侧「索引」查询符号、导入与文件,结果定位实际文件行;项目切换忽略旧响应,文件变化后提示刷新并核对新位置,桌面与390px可用。 +- 新增propose_patch:按原文件SHA256、唯一锚点和不重叠范围产生审核提案,保留BOM、统一LF/CRLF与未选择原字节,拒绝旧基线、模糊锚点和无效Unicode。 +- 长文件差异定位首处实际改动,审查页展示精确替换数与格式;标签保持单行,索引失败有明确项目归属和重试入口。 +- 工程只读Git检查先禁用配置的clean/process过滤脚本并跳过子模块工作区;依赖、常见凭据与链接沿统一清单规则排除。 +- 完整112项行为/API/实际退出恢复检查通过。新索引界面8组流程通过;发行、真实模型与全部界面的最终证据汇总到[验收记录](docs/VALIDATION.md)。 + ## 1.2.0 · 2026-10-29 - 任务记录增加本地Git提交预览、实际文件diff、署名和说明;确认只提交当前Task已应用且检查有效的文件,保留其他暂存与工作区改动。 diff --git a/DESIGN.md b/DESIGN.md index 5fc0edb0..b016a6d6 100644 --- a/DESIGN.md +++ b/DESIGN.md @@ -11,3 +11,5 @@ 桌面三栏,较窄屏幕收起右侧检视区;移动宽度改为对话、项目和检视标签切换。按钮、错误与空状态使用用户能操作的动作名称。减少动态效果,尊重 reduced-motion。 模型未连接时明确显示离线演示;演示使用固定脚本和真实本地工具流程,不能表现为真实模型推理。 + +1.3.0索引与文件/差异/轨迹/任务共用右侧五标签。结果按实际声明、路径、行和文件指纹组织,候选和部分范围直接标明;数字来自当前索引,输入保持单一焦点。文件和差异仅滚动各自容器,长文件审查直接定位首处改动;390px保持标签单行与指纹换行。 diff --git a/README.md b/README.md index 167dd7ce..0933e1a5 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # 本地 Agent 工作台 -Agent Workbench 1.2.0 将 Claude Code 与 Cursor 的机制研究整合为独立的本地 AI 编程工作台。任务与运行记录、实际工程检查、文件审查、本地Git提交及交付报告现在可以在同一个Task中完成。 +Agent Workbench 1.3.0 将 Claude Code 与 Cursor 的机制研究整合为独立的本地 AI 编程工作台。工程索引、代码定位、精确补丁、实际检查、文件审查、本地Git提交及交付报告可以在同一个Task中完成。 -每次运行保留模型与预算、已完成工具和日志工件。检查通过需要实际退出码、测试数量和对应源码快照;应用改动后可点击「继续检查与交付」,沿用原目标进行测试与修复。提交前查看实际文件、diff、署名和检查结果,确认后生成本地提交及可下载的JSON/Markdown报告。版本改动见 [CHANGELOG](CHANGELOG.md),本轮验收范围见 [QA-1.2](docs/QA-1.2.md)。 +每次运行保留模型与预算、已完成工具和日志工件。索引结果可打开实际文件行,精确补丁按文件SHA256和唯一锚点保留未修改内容与格式。检查通过需要实际退出码、测试数量和对应源码快照;应用改动后可点击「继续检查与交付」,沿用原目标进行测试与修复。提交前查看实际文件、diff、署名和检查结果,确认后生成本地提交及可下载的JSON/Markdown报告。版本改动见 [CHANGELOG](CHANGELOG.md),能力范围见[索引与补丁契约](docs/CODE-INDEX-AND-PATCHES.md)。 ## 后续产品与能力建设 @@ -13,7 +13,7 @@ Agent Workbench 1.2.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`;后续按独立小步检查并及时提交。 -1.2.0实现有界工程识别、Node/npm检查job、当前Task已审核文件的Git交付及证据报告。增量工程索引、任务依赖图、patch/ChangeSet、隔离worktree、多worker、外部引擎、REA执行和桌面/手机配对按后续阶段建设。 +1.3.0实现有界JS/TS/React静态索引、Python声明候选和精确补丁,沿用Node/npm检查job、当前Task已审核文件的Git交付及证据报告。任务依赖图、语义引用、ChangeSet、隔离worktree、多类工程检查器、外部引擎、REA执行和桌面/手机配对继续按后续阶段建设。 ## 直接运行 @@ -29,6 +29,7 @@ Windows x64 便携包自带 Node.js 24.22.1和npm。解压后双击 `Start-Workb 6. 遇到请求失败,点击错误卡片的「查看运行诊断」。可在同一会话提问,助手通过本地 `inspect_session` 核对错误来源、近期工具和文件实际状态。 7. 点击「查看任务记录」查看目标、各轮运行、累计用量与工件。准备工程检查后,核对npm脚本再执行;查看实际测试数量与日志。应用全部提案后,用「继续检查与交付」继续同一目标。 8. 检查通过后,在任务记录中「预览Git提交」,核对已审核路径、差异、署名和说明,再「确认创建本地提交」。工作台保留其他暂存与工作区改动,结果未知时提供「核对提交结果」;报告可直接查看和下载。Git需要本机安装,具体范围见[Git交付契约](docs/GIT-DELIVERY.md)。 +9. 右侧「索引」按函数、类、路径或导入查找代码,结果可定位原文件行。文件在索引后变化时打开当前内容并提示刷新;Python声明候选与局部模块文件候选显示各自范围。长文件差异可直接「定位首处改动」。 ## 模型连接 diff --git a/docs/CAPABILITIES.md b/docs/CAPABILITIES.md index 7a325a16..d2f975c6 100644 --- a/docs/CAPABILITIES.md +++ b/docs/CAPABILITIES.md @@ -1,6 +1,6 @@ # Agent Workbench 能力目标与验收矩阵 -日期:2026-10-29。1.0.0为基础里程碑,1.1.0实现M1,1.2.0实现首个内置Git交付切片。下表保留1.0.0缺口与完整产品目标;每项完成范围以实际验证记录为准。 +日期:2026-10-29。1.0.0为基础里程碑,1.1.0实现M1,1.2.0实现首个内置Git交付切片,1.3.0增加工程索引和精确补丁。下表保留1.0.0缺口与完整产品目标;每项完成范围以实际验证记录为准。 总体方案见 [PRODUCT-PLAN.md](PRODUCT-PLAN.md),研究问题与来源见 [RESEARCH-ROADMAP.md](RESEARCH-ROADMAP.md)。 @@ -28,6 +28,13 @@ - C11/C24:源码与Git基线分别验证,检查日志完整性和测试数量仍须满足;92项完整行为检查、9组桌面/390px交付界面通过。 - C08、多类工程与完整M2/M6成功率仍待后续实施。范围见[QA-1.2](QA-1.2.md)与[Git交付契约](GIT-DELIVERY.md)。 +### 1.3.0 M2工程定位与精确补丁切片 + +- C03/C04:JS/TS/React静态AST声明与导入、Python声明候选、逐文件SHA256增量复用、依赖候选重算与当前项目绑定;工具工件有Task/Run归属。暂不提供编译器级引用、路径别名或动态模块解析。 +- C08:唯一锚点/原SHA256的局部补丁、BOM和LF/CRLF保留、旧基线与重叠/重复锚点拒绝;继续由逐文件审查/备份流程应用,完整多文件ChangeSet仍待实现。 +- C07/C23:只读Git检查禁用配置过滤脚本,统一清单排除依赖/凭据/链接;索引范围、格式、Unicode、项目切换、原文件行定位、工件恢复和API契约有实际检查。 +- 完整112项行为/API/实际退出检查通过,新索引UI8组通过;源码/发行与真实模型工程验收以[验收记录](VALIDATION.md)为准。详见[索引与补丁契约](CODE-INDEX-AND-PATCHES.md)。React/Python真实工程交付、worktree和完整M2/M6仍继续实施。 + | ID / 能力 | 当前1.0.0基础与缺口 | 后续产品目标 | 参考问题 / 模块 / 阶段 | 必须看到的验收证据 | | --- | --- | --- | --- | --- | | C01 需求与任务规划 | 有对话和有限步数工具循环,没有任务依赖图 | 固定目标、约束和完成标准;拆任务、判断依赖、接收追加要求与重规划 | CX-1、WB-1 / tasks / M1–M2 | 追加要求后仍保留原目标;任务完成由验收条件决定 | diff --git a/docs/CODE-INDEX-AND-PATCHES.md b/docs/CODE-INDEX-AND-PATCHES.md new file mode 100644 index 00000000..2b80054d --- /dev/null +++ b/docs/CODE-INDEX-AND-PATCHES.md @@ -0,0 +1,36 @@ +# 工程索引与精确补丁契约 · 1.3.0 + +本切片将工程声明定位与局部编辑接入工作台已有的任务、审核、实际检查和Git交付。来源机制映射到C03/C04/C08;自有实现、契约检查与真实模型结果分别保存。 + +## 索引范围与依据 + +`ProjectIndex`为当前项目重新核对有界文件快照,并按每个文件SHA256复用或更新分析结果。导入目标候选每次重算,新增/删除文件也会改变结果。缓存最多8个项目,项目ID和真实根目录共同隔离;目前每次仍核对文件内容,没有后台文件监听或语义向量检索。 + +JS/TS/JSX/TSX/MTS/CTS采用MIT许可的`@babel/parser 7.29.11`,登记函数、类、方法、顶层变量、TS类型/接口/枚举与静态导出;导入、重导出、字面动态导入、字面require调用和TS import-equals来自语法节点。相对路径只比较当前范围的文件候选,包含JS→TS和MJS/CJS→MTS/CTS;有实际文件时优先该文件。候选附目标SHA256和`runtimeResolution: not_verified`,路径别名、调用绑定和动态参数仍需进一步分析。 + +Python采用移除注释/字符串体并识别缩进及声明的有界候选定位。结果明确显示`python-declaration-candidate`,保留行、名称、文件SHA256,使用前读取实际源码。没有执行Python代码,也没有进行Python编译器、完整引用或类型分析。 + +快照最多1000个候选文件/16MB;常规读取单文件最多1MB,声明分析最多256000字节,每文件300个符号/80000个AST节点,结果最多6000个符号与6000个导入。损坏文本、解析错误、读取/分析超限、无法确定静态目标的导入和不完整快照都显示范围。无匹配只表示当前查询范围;Go/Rust/Vue等暂保留文件指纹。 + +Git工程遵循ignore,常见依赖/生成目录、常见凭据、链接和子模块工作区排除。Git status可能运行配置的clean/process脚本,因此先只读取配置键名并在本次状态查询禁用这些脚本;未能确认配置时不声称基线完整。运行命令仍走原有独立确认流程。 + +## 使用与工件 + +- `index_project`:摘要、覆盖范围、增量计数和有限示例;完整索引成为当前Task/Run的SHA256工件。 +- `query_code`:按名称/路径查找all/symbols/imports/files,查询最多200字,结果1–60条,附实际文件、行、SHA256和依据。 +- 项目只读API:`GET /api/projects/:id/code-index`、`GET /api/projects/:id/code-query`。单独浏览索引无需创建Task;模型执行保存任务工件。 +- 右侧「索引」可查找并打开原文件行。打开时重新读取文件;SHA256已变化时显示当前内容和刷新提示,清除旧行高亮。滚动限于代码容器,切换项目忽略旧请求返回。 + +## 精确编辑 + +`propose_patch`及`POST /api/sessions/:id/patch-proposals`要求现有文件路径、读取时64位SHA256、说明和1–32个`old_text`/`new_text`替换。非空锚点须在同一原文中恰好出现一次,全部范围不得重叠;输入顺序不会改变匹配基线。重叠、重复、未找到、过期SHA256、NUL和无效Unicode拒绝,空改动不产生提案。 + +统一LF/CRLF按原文件格式匹配与生成替换;混合换行按原文严格匹配。UTF-8 BOM单独保留。提案记录基线和结果SHA256、格式、替换数、原行范围及锚点/替换SHA256,保留未选中内容。新文件继续使用完整文本提案。 + +提案只保存到工作台,不写入工程;用户查看差异后应用。应用前再次核对实际文件基线,备份原字节并写入建议内容,冲突保留外部修改。精确补丁沿用逐文件状态,不提供多文件原子应用、改名/删除或worktree合并。长文件差异可定位首处实际改动,应用后的检查/提交仍由已有Task契约负责。 + +## 验证与剩余工作 + +源码检查覆盖实际AST行与导出、Python候选/多行签名、项目隔离、增量更新/删除与目标重算、MTS/CTS候选、过滤脚本不执行、损坏/大文件范围、BOM/CRLF/混合格式、唯一/重叠锚点、Unicode、冲突、Task工件/API与恢复。完整112项通过,见[m2-index-tests-validation.json](m2-index-tests-validation.json)。 + +界面验收包含独立浏览、长文件行定位、旧SHA、延迟项目请求、Python/导入依据、实际审查应用、390px及失败重试。真实模型使用四模块封存验收,源码增加420行受保护说明,其中两个模块有BOM/CRLF,要求仅定位正文并提交精确补丁;结果随[VALIDATION](VALIDATION.md)保存。完整多类工程、ChangeSet/worktree、引擎适配、桌面端/手机配对继续按产品计划开发。 diff --git a/docs/PRODUCT-PLAN.md b/docs/PRODUCT-PLAN.md index f2d447fc..3fc95d69 100644 --- a/docs/PRODUCT-PLAN.md +++ b/docs/PRODUCT-PLAN.md @@ -144,8 +144,8 @@ Purge的包声明Apache-2.0,另有商业许可联系说明;Harness声明MIT ## 9. 下一轮最先执行的三个开发切片 -1. 定义Task/Run/Step/Event/Tool/Artifact契约,将现有模型循环的状态从UI会话表述中拆出;先保留兼容层。 -2. 抽象Storage,给JSON→SQLite迁移和崩溃/重放边界建立可验证样本;同时生成首批真实工程任务基准。 -3. 实现工程识别、TestRunner检查计划/planId/jobId/结果及Git基线,完成一个“跨文件修改→实际测试→修复→diff→提交”的最小工程交付。 +1. 1.1.0的Task/Run/工件/SQLite及1.2.0的检查/Git/report切片已交付;1.3.0继续完成工程索引和精确补丁,按独立包与长文件真实模型验收发布。 +2. 下一批实现多文件ChangeSet与可恢复应用、任务工作区/worktree隔离,再完成React/TypeScript及Python专用检查与封存任务;当前单Node样本不计为三类工程完成。 +3. 在写入/取消/事件归属边界稳定后按M3接入REA及Codex/DeepSeek EngineAdapter的契约探针,分别固定Harness/Purge/profile版本,再比较真实同题工程收益。桌面Electron与手机配对网关复用同一执行宿主,按M5推进。 这些切片优先复用已验证的文件范围、基线备份、UTF-8、取消与诊断能力。研究结论每次至少绑定一个实现模块、一个契约检查和一个用户场景,按实际失败分类持续调整顺序。 diff --git a/docs/QA-1.3.md b/docs/QA-1.3.md new file mode 100644 index 00000000..0e3c049d --- /dev/null +++ b/docs/QA-1.3.md @@ -0,0 +1,19 @@ +# 1.3.0工程索引与精确补丁验收 + +本轮交付当前项目的JS/TS/React静态声明与导入索引、Python声明候选、原SHA256与唯一锚点的精确补丁,接入实际工程检查、审核、Git和报告。完整多文件ChangeSet、React/Python专用检查器、隔离worktree与引擎/桌面/手机配对继续按产品计划实施。 + +| 用户可见行为 | 实际检查 | 已验证结果 | +| --- | --- | --- | +| 工程声明与导入能定位真实源码 | AST行/导出、Python候选、MTS/CTS、动态目标范围 | 112项完整行为/API/进程恢复全部通过 | +| 索引增量更新且项目隔离 | 原SHA256复用、增加/删除目标重算、缓存隔离 | 文件变化返回新符号与目标,不污染旧证据 | +| 只读工程检查保持只读范围 | Git过滤脚本探针、ignore/依赖/凭据/链接 | 未执行配置的clean脚本,Git索引字节保留 | +| 精确补丁先审核再写入 | BOM/LF/CRLF/混合格式、Unicode、唯一/重叠锚点 | 提案不写入;冲突保留owner字节,应用备份原字节 | +| 结果打开实际文件行 | 181→184行、旧SHA不高亮、容器内滚动 | 输入和顶部保持可见 | +| 切换项目及失败处理 | 延迟旧响应、部分覆盖、失败重试 | 旧响应忽略,旧结果禁用并可恢复 | +| 长文件审查与手机宽度 | 首处实际修改、五标签、指纹换行、390px | 新索引8组及原有35组界面通过 | + +基础10/诊断9/任务7/Git交付9/索引8共43组界面全部通过,页面/请求异常为零。结构化结果分别为[m2-index-tests-validation.json](m2-index-tests-validation.json)、[基础](m2-index-basic-ui-validation.json)、[诊断](m2-index-diagnostics-ui-validation.json)、[任务](m2-index-execution-ui-validation.json)、[Git交付](m2-index-delivery-ui-validation.json)和[索引](m2-index-index-ui-validation.json)。 + +桌面及390px的索引、文件行与精确差异截图已目视核对,见[screenshots](screenshots/1.3-index-desktop.png)。初始两项Windows Node HTTP连接重置已独立复验并采用有限QA请求独立连接,完整112项最终回归全部通过;没有自动重试副作用请求。 + +便携包、独立源码安装/构建、原进程升级与真实模型长文件精确交付的最终结果汇总到[VALIDATION](VALIDATION.md)。真实模型样本增加420行受保护说明及两种BOM/换行格式,要求用索引定位正文、仅读取必要源码并提出精确补丁,沿原Task完成14项测试、Git和报告;不由单个样本推断完整M2/M6成功率。 diff --git a/docs/m2-index-basic-ui-validation.json b/docs/m2-index-basic-ui-validation.json new file mode 100644 index 00000000..2a3d3c37 --- /dev/null +++ b/docs/m2-index-basic-ui-validation.json @@ -0,0 +1,28 @@ +{ + "success": true, + "url": "http://127.0.0.1:52944", + "browser": "Microsoft Edge 156.0.4314.42", + "date": "2026-10-29T09:53:02.565Z", + "projectRoot": "D:\\Ai-project\\REA逆向\\Agent-Workbench\\.qa\\ui-79c795e4-ec52-40a9-aebf-aee109426e81\\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", + "version": "1.3.0" +} diff --git a/docs/m2-index-delivery-ui-validation.json b/docs/m2-index-delivery-ui-validation.json new file mode 100644 index 00000000..631db9b4 --- /dev/null +++ b/docs/m2-index-delivery-ui-validation.json @@ -0,0 +1,31 @@ +{ + "success": true, + "version": "1.3.0", + "testedAt": "2026-10-29T09:54:11.002Z", + "browser": "156.0.4314.42", + "passed": [ + "actual failing tests and four source proposals retain the original project and task", + "reviewed changes continue the same Task through 14 real tests and model-prepared Git review", + "review shows actual paths, diffs, tests, author and policy; cancelling leaves Git unchanged", + "an index change after confirmation preview refuses the stale job and preserves both staged owners", + "390px confirmation keeps file hashes, diffs and actions inside the modal", + "double confirmation creates one four-file commit, retains owner bytes and publishes report with completion", + "report viewing and Markdown/JSON downloads preserve verified artifact bytes and truthful acceptance limits", + "mobile report preview closes cleanly and keeps the task input fixed", + "unknown Git results block new submission and the explicit reconcile action restores the existing commit" + ], + "pageErrors": [], + "requestFailures": [], + "projectRoot": "D:\\Ai-project\\REA逆向\\Agent-Workbench\\.qa\\delivery-ui-5786ccd4-434a-41d2-939f-ce6269a39070\\四模块交付工程", + "projectId": "dd123252-c383-4f92-a26d-4c2a599cc0e8", + "sessionId": "a64178fc-1939-4a40-ab52-a76492deff11", + "taskId": "9c146230-85e9-47e9-a496-bb9d184db3a6", + "commit": "ad61b9ee20b163c8ed706d9b6dc7b86b7b45500f", + "recoveryCommit": "ab1afdcb8f17774d1a20246e24a48ea1fbba054d", + "testCounts": { + "baselineFailed": 13, + "passed": 14 + }, + "model": "controlled local HTTP fixture", + "confirmations": 2 +} diff --git a/docs/m2-index-diagnostics-ui-validation.json b/docs/m2-index-diagnostics-ui-validation.json new file mode 100644 index 00000000..b35967f7 --- /dev/null +++ b/docs/m2-index-diagnostics-ui-validation.json @@ -0,0 +1,20 @@ +{ + "success": true, + "version": "1.3.0", + "url": "http://127.0.0.1:52944", + "date": "2026-10-29T09:53:18.523Z", + "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" +} diff --git a/docs/m2-index-execution-ui-validation.json b/docs/m2-index-execution-ui-validation.json new file mode 100644 index 00000000..7dc418ff --- /dev/null +++ b/docs/m2-index-execution-ui-validation.json @@ -0,0 +1,19 @@ +{ + "success": true, + "version": "1.3.0", + "testedAt": "2026-10-29T09:53:39.177Z", + "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-f35e1e33-7a89-4726-8752-7c490d6f50d8\\project", + "model": "controlled local HTTP fixture" +} diff --git a/docs/m2-index-index-ui-validation.json b/docs/m2-index-index-ui-validation.json new file mode 100644 index 00000000..66412259 --- /dev/null +++ b/docs/m2-index-index-ui-validation.json @@ -0,0 +1,19 @@ +{ + "checkedAt": "2026-10-29T09:54:16.255Z", + "version": "1.3.0", + "passed": [ + "工程索引可独立于任务使用,实际覆盖范围与损坏文件显示明确", + "真实AST查询打开原文件第181行并仅滚动代码容器,输入区和顶部保持可见", + "查询词保留;过期SHA不高亮旧位置,增量刷新后正确定位第184行", + "切换项目时延迟返回的旧索引不覆盖新项目结果", + "Python候选、字符串误报排除和局部导入文件候选保留真实证据标签", + "两处唯一锚点成为待审核提案,真实界面应用后BOM/CRLF和未选择原字节保留", + "390px索引查询、范围和完整指纹可读且无横向溢出,实际文件行定位通过", + "索引刷新失败保留归属和解释,旧结果禁用并可重试恢复" + ], + "pageErrors": [], + "requestFailures": [], + "root": "D:\\Ai-project\\REA逆向\\Agent-Workbench\\.qa\\index-ui-8c1879b7-0cae-4317-abf3-0d8a08053ab4", + "primaryProjectId": "aac0e660-995b-45b8-80f9-9d4600016791", + "otherProjectId": "02811d53-9145-446d-bf0e-057b4bca3af9" +} diff --git a/docs/m2-index-tests-validation.json b/docs/m2-index-tests-validation.json new file mode 100644 index 00000000..711d5785 --- /dev/null +++ b/docs/m2-index-tests-validation.json @@ -0,0 +1,21 @@ +{ + "version": "1.3.0", + "testedAt": "2026-10-29T09:52:45.109Z", + "platform": "win32", + "node": "v24.22.1", + "command": "npm test", + "tests": 112, + "passed": 112, + "failed": 0, + "skipped": 0, + "cancelled": 0, + "durationMs": 147134.9173, + "logSha256": "382482cce71e278acda6d64d40793164840ec076ba80db9db26a1a2b090e5622", + "initialRun": { + "tests": 110, + "passed": 108, + "failed": 2, + "reason": "Windows Node HTTP ECONNRESET in restart/event fixtures; isolated repro passed 2/2, finite QA requests use independent connections and record response phase, without replay." + }, + "scope": "Behavior, API, index/patch contracts, real process recovery and consecutive in-place upgrade; no M2/M6 completion-rate claim." +} diff --git a/docs/screenshots/1.3-index-desktop-line.png b/docs/screenshots/1.3-index-desktop-line.png new file mode 100644 index 00000000..891303c5 Binary files /dev/null and b/docs/screenshots/1.3-index-desktop-line.png differ diff --git a/docs/screenshots/1.3-index-desktop.png b/docs/screenshots/1.3-index-desktop.png new file mode 100644 index 00000000..8636feef Binary files /dev/null and b/docs/screenshots/1.3-index-desktop.png differ diff --git a/docs/screenshots/1.3-index-mobile-line.png b/docs/screenshots/1.3-index-mobile-line.png new file mode 100644 index 00000000..c036b750 Binary files /dev/null and b/docs/screenshots/1.3-index-mobile-line.png differ diff --git a/docs/screenshots/1.3-index-mobile.png b/docs/screenshots/1.3-index-mobile.png new file mode 100644 index 00000000..f92d7f98 Binary files /dev/null and b/docs/screenshots/1.3-index-mobile.png differ diff --git a/docs/screenshots/1.3-index-patch-desktop.png b/docs/screenshots/1.3-index-patch-desktop.png new file mode 100644 index 00000000..a68d2e06 Binary files /dev/null and b/docs/screenshots/1.3-index-patch-desktop.png differ diff --git a/findings.md b/findings.md index 228174d9..c1a94f6b 100644 --- a/findings.md +++ b/findings.md @@ -139,3 +139,9 @@ Claude Code 报告已验证工具输入校验、权限决定、队列并发屏 - 修复后15项恢复/升级专项和92项完整回归全部通过;基础10/诊断9/任务7/交付9组界面均通过且0页面/请求异常。新QA宿主4321/PID38288独立于4318原进程。 - Git与报告完成状态必须同次保存;实际模型验收从旧的验收器自行提交改为确认工作台的持久Git job,并校验报告SHA256、commit和原owner索引。源码包验收脚本采用独立解压、离线npm安装和构建逐字节比较。 - 便携验收不能使用固定4320端口:残留1.1.0QA会被启动器视为可复用。验收器改用随机空闲端口,并在操作/停止之前证明自己拥有该data/PID/发行路径;失败记录保留。 + +## 1.3.0工程索引与精确补丁 + +- 首轮14项专项10通过/4失败,实际暴露默认箭头导出/TS声明函数遗漏、Python候选跨字符串及旧作用域误报、Git文件清单中的依赖目录未排除和Unicode半字符可被补丁选择。已分别补齐AST导出、跨行词法状态、统一清单排除与有效Unicode约束;待复验。 +- 精确补丁BOM/CRLF、LF与混合换行、32个编辑上限、同一原文的唯一锚点和重叠/过期冲突已通过首轮检查;未应用前不写入,实际应用备份原字节。 +- 合成Git工程证实普通status及当前inspectProject会运行配置的clean过滤器。已先只读取得过滤器键名,在本次status禁用clean/process/required,并跳过子模块工作区;无法确认配置时保持未完成基线,避免以只读索引隐式执行项目代码。专项同时核对Git索引原字节,待复验。 diff --git a/package-lock.json b/package-lock.json index a05f45b7..64e4950e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,13 +1,14 @@ { "name": "local-agent-workbench", - "version": "1.2.0", + "version": "1.3.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "local-agent-workbench", - "version": "1.2.0", + "version": "1.3.0", "dependencies": { + "@babel/parser": "7.29.11", "diff": "^8.0.2", "lucide-react": "^0.548.0", "react": "^19.2.0", @@ -170,7 +171,6 @@ "version": "7.29.11", "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.29.11.tgz", "integrity": "sha512-snZbO7MEDOof+hvNa97EjEY7qD7h2kwvQr5AJC3ZhQudKW5dnej6k3kP9NQV88hJwaS8vDqRLFo9rivLEhle2g==", - "dev": true, "license": "MIT", "engines": { "node": ">=6.9.0" @@ -180,7 +180,6 @@ "version": "7.29.7", "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.29.7.tgz", "integrity": "sha512-qehxGkRj55h/ff8EMaJ+cYhyaKlHIxqYDn682wQD7RNp9UujOQsHog2uS0r2vzr4pW+sXf90NeeayjcNaX3fFg==", - "dev": true, "license": "MIT", "engines": { "node": ">=6.9.0" @@ -214,7 +213,6 @@ "version": "7.29.11", "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.11.tgz", "integrity": "sha512-OZ6+oaK7GMyg3IfCpj8JOmn8n+w2rJbDT0LLfVDTLb1ZFeKDh3AiNELgCMUw175IJHSkLl74hG0M0VLsvx+gag==", - "dev": true, "license": "MIT", "dependencies": { "@babel/types": "^7.29.11" @@ -296,7 +294,6 @@ "version": "7.29.11", "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.29.11.tgz", "integrity": "sha512-WCsemW40Cpc6gouC1SrY6PBaZ+oLRlEVY9XBvZBI7il/HyUrb2nJ505wE1MHEFyDZNnrWDEuy4jL50WVHfTTSQ==", - "dev": true, "license": "MIT", "dependencies": { "@babel/helper-string-parser": "^7.29.11", diff --git a/package.json b/package.json index 19e67cd5..ba1f267a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "local-agent-workbench", - "version": "1.2.0", + "version": "1.3.0", "private": true, "type": "module", "description": "A local coding workbench with explicit tool execution, reviewable changes and recoverable sessions.", @@ -14,6 +14,7 @@ "package": "node scripts/package.mjs" }, "dependencies": { + "@babel/parser": "7.29.11", "diff": "^8.0.2", "lucide-react": "^0.548.0", "react": "^19.2.0", diff --git a/progress.md b/progress.md index efdce119..6713f6d9 100644 --- a/progress.md +++ b/progress.md @@ -110,3 +110,18 @@ - 后续继续1.3.0工程符号索引与带SHA256的精确补丁,按实际定位、格式保留、冲突和项目归属验证推进。 - 最终1.2.0包使用独立带时间戳目录,原已验证发行不覆盖。最终2116份便携/254份源码清单及ZIP CRC/SHA通过;54份核心/测试/声明与独立源码验收逐字节一致,6份构建文件一致。原PID23080已切换最终1.2.0实现,连接与全部当时会话保持。 - 1.3.0索引实现将复用已安装@babel/parser 7.29.11(MIT),提升为明确运行依赖;JS/TS/React静态AST证据与Python声明定位分开标明,动态绑定不假定已经解析。 + +## 2026-10-29 1.3.0继续全量开发 + +- 接续5ec85b0之后的索引/精确补丁未提交实现,读取AGENTS和既有计划。正式4318保持1.2.0/PID23080,源码1.3.0尚未通过功能验收或部署。 +- 本轮先核对AST导出/定位、Python候选范围、增量依赖变化与项目隔离;补丁核对BOM/换行/唯一锚点/重叠/冲突,再接入第五个索引检视页与真实文件行定位。 +- 新读取时PowerShell不展开rg的src/client/*.css路径参数,改为rg -g '*.css' src/client;输出过长采用文件段落与独立预算,不把截断内容当完整核对。 +- 14项首轮专项10通过/4失败,修正AST默认导出、Python候选词法/作用域、依赖清单与Unicode补丁边界后14/14通过;另补真实Git clean执行探针,修正只读检查后1/1通过。 +- 第五个索引检视页、结果类型/范围/增量统计、原文件SHA256核对及容器内行定位已接入;精确补丁在审查页展示替换数与格式。1.3.0源码完整构建通过,随后做API/Runtime与实际桌面/390px流程。 +- 索引/补丁/API/模型工具与工件恢复18/18专项通过;Python与随附Python均缺Playwright模块,继续使用仓库已安装并经过验收的Node Playwright测试,未为此安装或替换环境。webapp-testing的with_server --help已核对。 +- 首轮索引UI8/8通过,零页面/请求异常。桌面与390px截图显示实际文件/行/候选依据;目视发现带待审查数量时标签会折行、长文件差异初始只见说明行,正在改善标签和首处实际改动定位。 +- 首轮完整110项108通过/2失败,最终错误是Windows Node HTTP连接ECONNRESET,并非已确认的任务等待超时;两项实际重启/SSE专项独立复跑2/2通过。沿用既有升级验收的独立连接策略,将QA有限API请求设为Connection:close并记录请求阶段,不重试副作用请求;随后完整复验。 +- 标签保持单行和长差异首处改动定位已完成,索引UI再次8/8通过。目视发现sticky差异标题需背景以免文字穿透,已修正;补充Python多行签名及TS import-equals/MTS/CTS和动态导入范围专项。 +- 新增两项声明/候选专项2/2通过,重建后完整112/112通过,零失败/跳过/取消。验收记录已保存;本轮QA有限请求不自动重试任何副作用。 +- 已关闭本轮旧QA11548并以新编译源码/独立数据启动38436,原4318/PID23080保持。接续全部基础/诊断/任务/Git/索引UI,之后保存实现本地提交并验证发行与真实模型精确补丁样本。 +- 新源码独立QA完整基础10/诊断9/任务7/Git9/索引8共43组全部通过,零页面/请求异常。索引/行定位/首处差异及390px截图已核对,证据复制到docs;开始保存实现本地Git提交并生成独立1.3.0包。 diff --git a/scripts/upgrade-running.mjs b/scripts/upgrade-running.mjs index 23111f87..a1f45a2d 100644 --- a/scripts/upgrade-running.mjs +++ b/scripts/upgrade-running.mjs @@ -64,7 +64,7 @@ export async function upgradeRunning({ url, pid, currentRoot, newRoot, handlerRo 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 readUpgradeJson(origin + '/api/bootstrap', 5000, 'Read original Workbench'); - if (!before.token || !['0.1.0', '1.0.0', '1.1.0', '1.2.0'].includes(before.version)) throw new Error('This migration accepts a supported existing Workbench.'); + if (!before.token || !['0.1.0', '1.0.0', '1.1.0', '1.2.0', '1.3.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 = []; diff --git a/scripts/verify-index-ui.mjs b/scripts/verify-index-ui.mjs new file mode 100644 index 00000000..e7f358ae --- /dev/null +++ b/scripts/verify-index-ui.mjs @@ -0,0 +1,143 @@ +import assert from 'node:assert/strict'; +import fs from 'node:fs'; +import path from 'node:path'; +import { randomUUID } from 'node:crypto'; +import { chromium, expect } from 'playwright/test'; + +const url = process.env.AGENT_WORKBENCH_URL; +if (!url || !/^http:\/\/127\.0\.0\.1:(?!4318(?:\/|$))\d+\/?$/.test(url)) throw new Error('Set AGENT_WORKBENCH_URL to an independent local QA service.'); +const root = path.resolve('.qa', 'index-ui-' + randomUUID()), primaryRoot = path.join(root, 'index-ui-project'), otherRoot = path.join(root, 'index-ui-other'); +fs.mkdirSync(path.join(primaryRoot, 'src'), { recursive: true }); fs.mkdirSync(otherRoot, { recursive: true }); fs.mkdirSync('.qa/screenshots', { recursive: true }); +const sourcePath = path.join(primaryRoot, 'src', 'invoice.ts'); +const banner = Array.from({ length: 180 }, (_, line) => '// 保留的项目说明 ' + (line + 1) + ' · 原文🙂').join('\r\n') + '\r\n'; +const original = '\uFEFF' + banner + 'export function total(amount: number, discount: number) { return amount - discount; }\r\nexport const currency = "CNY";\r\n'; +fs.writeFileSync(sourcePath, original); +fs.writeFileSync(path.join(primaryRoot, 'src', 'Card.tsx'), 'import { total } from "./invoice.js";\nexport const Card = () =>
{total(10, 2)}
;\n'); +fs.writeFileSync(path.join(primaryRoot, 'legacy.py'), '# def FakeComment():\n"""def FakeString():"""\ndef repair():\n pass\n'); +fs.writeFileSync(path.join(primaryRoot, 'broken.js'), 'export function unfinished('); +fs.writeFileSync(path.join(primaryRoot, 'package.json'), JSON.stringify({ name: 'index-ui-project', type: 'module' })); +fs.writeFileSync(path.join(otherRoot, 'other.ts'), 'export function otherOnly() { return true; }\n'); +const bootstrap = await (await fetch(url + '/api/bootstrap')).json(); +assert.equal(bootstrap.version, '1.3.0'); assert.equal(bootstrap.config.mode, 'demo'); assert.equal(bootstrap.config.hasKey, false); +const api = async (route, input) => { + const response = await fetch(url + '/api' + route, { method: input === undefined ? 'GET' : 'POST', + headers: { 'Content-Type': 'application/json', 'X-Workbench-Token': bootstrap.token }, ...(input === undefined ? {} : { body: JSON.stringify(input) }) }); + const value = await response.json(); assert.ok(response.ok, value.error); return value; +}; +const primary = await api('/projects', { root: primaryRoot }), other = await api('/projects', { root: otherRoot }); +const browser = await chromium.launch({ channel: 'msedge', headless: true }); +const context = await browser.newContext({ viewport: { width: 1440, height: 1000 } }), page = await context.newPage(); +const passed = [], pageErrors = [], requestFailures = []; let heldRelease; +page.on('pageerror', cause => pageErrors.push(cause.message)); +page.on('requestfailed', request => { if (request.resourceType() !== 'eventsource') requestFailures.push(request.url() + ': ' + request.failure()?.errorText); }); +const panel = () => page.getByLabel('工程索引', { exact: true }); +const indexTab = () => page.locator('.inspector-tabs').getByRole('button', { name: '索引', exact: true }); +const screenshot = name => page.screenshot({ path: '.qa/screenshots/' + name + '.png', scale: 'css' }); +async function find(query, kind = 'symbols') { + await panel().getByLabel('索引查询').fill(query); + if (await panel().getByLabel('索引结果类型').inputValue() !== kind) await panel().getByLabel('索引结果类型').selectOption(kind); + else await panel().getByRole('button', { name: '查找', exact: true }).click(); + await expect(panel().getByRole('button', { name: '查找', exact: true })).toBeEnabled(); + await expect(panel().getByRole('status')).toContainText('“' + query + '”'); +} +async function checkPosition(line) { + await expect(page.locator('.code-line-target')).toHaveAttribute('data-line', String(line)); + await expect.poll(() => page.evaluate(() => { + const line = document.querySelector('.code-line-target').getBoundingClientRect(), area = document.querySelector('.code-view').getBoundingClientRect(); + return line.top >= area.top && line.bottom <= area.bottom; + })).toBe(true); + const layout = await page.evaluate(() => ({ scrollY, header: document.querySelector('.work-header').getBoundingClientRect().top, + composerBottom: document.querySelector('.composer-wrap').getBoundingClientRect().bottom, height: innerHeight })); + assert.equal(layout.scrollY, 0); assert.ok(layout.header >= 0); assert.ok(layout.composerBottom <= layout.height + 1); +} +try { + await page.goto(url); await page.waitForLoadState('networkidle'); + await page.getByLabel('当前项目', { exact: true }).selectOption(primary.id); + fs.writeFileSync(path.join(root, 'initial-dom.html'), await page.content()); + assert.ok((await page.locator('.inspector-tabs button').allTextContents()).some(value => value === '索引')); + await indexTab().click(); await expect(panel()).toBeVisible(); + await expect(panel().getByRole('button', { name: '查找', exact: true })).toBeEnabled(); + await expect(panel()).toContainText('当前项目 · index-ui-project'); await expect(panel()).toContainText('部分结果'); + assert.equal((await api('/sessions')).filter(value => value.projectId === primary.id).length, 0); + passed.push('工程索引可独立于任务使用,实际覆盖范围与损坏文件显示明确'); + + await find('total'); await expect(panel().locator('.index-result-location')).toContainText(':181'); + await screenshot('m2-index-desktop'); + await panel().getByRole('button', { name: '打开 src/invoice.ts 第 181 行 total', exact: true }).click(); + await checkPosition(181); await screenshot('m2-index-desktop-line'); + passed.push('真实AST查询打开原文件第181行并仅滚动代码容器,输入区和顶部保持可见'); + + await indexTab().click(); await expect(panel().getByLabel('索引查询')).toHaveValue('total'); + fs.writeFileSync(sourcePath, '\uFEFF// 新说明1\r\n// 新说明2\r\n// 新说明3\r\n' + original.slice(1)); + await panel().getByRole('button', { name: '打开 src/invoice.ts 第 181 行 total', exact: true }).click(); + await expect(page.getByText('文件在索引后已变化,已打开当前内容。请回到索引刷新后重新定位。', { exact: true })).toBeVisible(); + await expect(page.locator('.code-line-target')).toHaveCount(0); await expect(page.locator('.code-view')).toContainText('新说明3'); + await indexTab().click(); await panel().getByRole('button', { name: '刷新工程索引' }).click(); + await expect(panel().getByRole('button', { name: '查找', exact: true })).toBeEnabled(); + await panel().getByRole('button', { name: '打开 src/invoice.ts 第 184 行 total', exact: true }).click(); await checkPosition(184); + passed.push('查询词保留;过期SHA不高亮旧位置,增量刷新后正确定位第184行'); + + await indexTab().click(); let held = false; + const gate = new Promise(resolve => { heldRelease = resolve; }); + const routePattern = new RegExp('/api/projects/' + primary.id + '/code-query\\?'); + await page.route(routePattern, async route => { const response = await route.fetch(); held = true; await gate; await route.fulfill({ response }); }); + await panel().getByRole('button', { name: '刷新工程索引' }).click(); await expect.poll(() => held).toBe(true); + await page.getByLabel('当前项目', { exact: true }).selectOption(other.id); + await expect(panel()).toContainText('当前项目 · index-ui-other'); await expect(panel()).toContainText('otherOnly'); + heldRelease(); await page.waitForTimeout(300); await page.unroute(routePattern); + await expect(panel()).not.toContainText('src/invoice.ts'); await expect(panel()).toContainText('otherOnly'); + passed.push('切换项目时延迟返回的旧索引不覆盖新项目结果'); + + await page.getByLabel('当前项目', { exact: true }).selectOption(primary.id); + await expect(panel().getByRole('button', { name: '查找', exact: true })).toBeEnabled(); await find('repair'); + await expect(panel()).toContainText('Python 候选 · 需读源码核对'); await expect(panel().locator('.index-result-location')).toContainText('legacy.py'); + await find('FakeString'); await expect(panel().getByText('当前范围没有匹配', { exact: true })).toBeVisible(); + await find('invoice.js', 'imports'); await expect(panel()).toContainText('文件候选 → src/invoice.ts'); + await panel().getByText('查看索引范围与依据', { exact: true }).click(); await expect(panel()).toContainText('不证明实际运行时模块解析'); + passed.push('Python候选、字符串误报排除和局部导入文件候选保留真实证据标签'); + + const current = await api('/projects/' + primary.id + '/file?path=src%2Finvoice.ts'), before = fs.readFileSync(sourcePath); + const session = await api('/sessions', { projectId: primary.id }); + const proposed = await api('/sessions/' + session.id + '/patch-proposals', { path: 'src/invoice.ts', base_sha256: current.sha256, reason: '精确调整金额与币种', edits: [ + { old_text: 'return amount - discount;', new_text: 'return Math.max(0, amount - discount);' }, { old_text: 'currency = "CNY"', new_text: 'currency = "USD"' }] }); + assert.deepEqual(fs.readFileSync(sourcePath), before); + await page.evaluate(id => localStorage.setItem('awb-session', id), session.id); await page.reload(); await page.waitForLoadState('networkidle'); + await page.locator('.inspector-tabs').getByRole('button', { name: /^改动/ }).click(); + await expect(page.locator('.patch-detail')).toHaveText('精确补丁 · 2 处替换 · 保留 CRLF 换行 · 保留 BOM'); + await expect.poll(() => page.evaluate(() => { + const row = document.querySelector('.diff-removed').getBoundingClientRect(), area = document.querySelector('.diff-view').getBoundingClientRect(); + return row.top > area.top && row.bottom <= area.bottom; + })).toBe(true); + await page.evaluate(() => { document.querySelector('.diff-view').scrollTop = 0; }); + await page.getByRole('button', { name: '定位首处改动', exact: true }).click(); + await expect.poll(() => page.evaluate(() => document.querySelector('.diff-view').scrollTop > 0)).toBe(true); + await screenshot('m2-index-patch-desktop'); await page.getByRole('button', { name: '应用这项改动', exact: true }).click(); + await expect(page.getByText('这项改动已写入项目。', { exact: true })).toBeVisible(); + const expected = before.toString('utf8').replace('return amount - discount;', 'return Math.max(0, amount - discount);').replace('currency = "CNY"', 'currency = "USD"'); + assert.deepEqual(fs.readFileSync(sourcePath), Buffer.from(expected)); assert.equal((await api('/sessions/' + proposed.id)).changes[0].status, 'applied'); + passed.push('两处唯一锚点成为待审核提案,真实界面应用后BOM/CRLF和未选择原字节保留'); + + await page.setViewportSize({ width: 390, height: 844 }); await expect(page.getByRole('button', { name: '查看文件', exact: true })).toBeVisible(); + await page.getByRole('button', { name: '查看文件', exact: true }).click(); await indexTab().click(); + await panel().getByRole('button', { name: '刷新工程索引' }).click(); await expect(panel().getByRole('button', { name: '查找', exact: true })).toBeEnabled(); + await find('total'); await panel().getByText('查看索引范围与依据', { exact: true }).click(); + const bounds = await page.evaluate(() => ({ page: document.documentElement.scrollWidth <= innerWidth, + panel: document.querySelector('.code-index-panel').scrollWidth <= document.querySelector('.code-index-panel').clientWidth + 1, + tabs: document.querySelector('.inspector-tabs').scrollWidth <= document.querySelector('.inspector-tabs').clientWidth + 1 })); + assert.deepEqual(bounds, { page: true, panel: true, tabs: true }); await screenshot('m2-index-mobile'); + await panel().getByRole('button', { name: '打开 src/invoice.ts 第 184 行 total', exact: true }).click(); await checkPosition(184); await screenshot('m2-index-mobile-line'); + passed.push('390px索引查询、范围和完整指纹可读且无横向溢出,实际文件行定位通过'); + + await indexTab().click(); const errorPattern = new RegExp('/api/projects/' + primary.id + '/code-query\\?'); let failNext = true; + await page.route(errorPattern, route => { if (failNext) { failNext = false; return route.fulfill({ status: 409, contentType: 'application/json', body: JSON.stringify({ error: '建立索引期间文件已变化,请刷新工程索引。' }) }); } return route.continue(); }); + await panel().getByRole('button', { name: '刷新工程索引' }).click(); await expect(panel().getByRole('alert')).toContainText('索引未刷新'); + await expect(panel().locator('.index-result').first()).toBeDisabled(); await panel().getByRole('button', { name: '重试索引' }).click(); + await expect(panel().getByRole('alert')).toHaveCount(0); await expect(panel().locator('.index-result').first()).toBeEnabled(); await page.unroute(errorPattern); + passed.push('索引刷新失败保留归属和解释,旧结果禁用并可重试恢复'); + assert.deepEqual(pageErrors, []); assert.deepEqual(requestFailures, []); + const result = { checkedAt: new Date().toISOString(), version: bootstrap.version, passed, pageErrors, requestFailures, root, primaryProjectId: primary.id, otherProjectId: other.id }; + fs.writeFileSync('.qa/index-ui-result.json', JSON.stringify(result, null, 2) + '\n'); console.log(JSON.stringify(result, null, 2)); +} catch (cause) { + fs.writeFileSync('.qa/index-ui-failure.json', JSON.stringify({ passed, pageErrors, requestFailures, message: cause.message, root }, null, 2)); + await screenshot('m2-index-failure').catch(() => {}); throw cause; +} finally { heldRelease?.(); await browser.close(); } diff --git a/scripts/verify-live-delivery.mjs b/scripts/verify-live-delivery.mjs index be076ab1..885a04d6 100644 --- a/scripts/verify-live-delivery.mjs +++ b/scripts/verify-live-delivery.mjs @@ -8,32 +8,43 @@ import { APP_VERSION } from '../src/server/diagnostics.mjs'; // 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 precision = process.argv.includes('--precision'); +const bannerLines = 420; 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(); +const bootstrap = await (await fetch(origin.origin + '/api/bootstrap', { headers: { Connection: 'close' } })).json(); assert.equal(bootstrap.version, APP_VERSION); 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 }, + headers: { 'Content-Type': 'application/json', 'X-Workbench-Token': bootstrap.token, Connection: 'close' }, ...(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 caseRoot = path.resolve('.qa', (precision ? 'live-precision-' : 'live-delivery-') + randomUUID()); +const projectRoot = path.join(caseRoot, precision ? '精确补丁交付工程' : '交付报告工程'); 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 }); +const sourcePrefixes = {}, sourceFormats = {}; +if (precision) for (const file of allowed) { + const target = path.join(projectRoot, file), body = fs.readFileSync(target, 'utf8').replaceAll('\r\n', '\n'); + const bom = ['src/normalize.mjs', 'src/cli.mjs'].includes(file), ending = bom ? '\r\n' : '\n'; + const banner = Array.from({ length: bannerLines }, (_, line) => '// 保留工程说明 ' + (line + 1) + ' · ' + file + ' · 原文🙂').join(ending) + ending; + const prefix = (bom ? '\uFEFF' : '') + banner; + sourcePrefixes[file] = Buffer.from(prefix); sourceFormats[file] = { bom, lineEnding: bom ? 'crlf' : 'lf', firstSourceLine: bannerLines + 1 }; + fs.writeFileSync(target, prefix + body.replaceAll('\n', ending)); +} fs.writeFileSync(path.join(projectRoot, '.gitignore'), 'dist/\n'); fs.writeFileSync(path.join(projectRoot, 'OWNER-NOTES.md'), '# Owner notes\nBaseline owner content.\n'); fs.writeFileSync(path.join(projectRoot, 'OWNER-STAGED.txt'), 'Baseline staged 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']); +git(['init', '--initial-branch=main']); git(['config', 'core.autocrlf', 'false']); 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'); @@ -49,6 +60,12 @@ 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.'); assert.equal(git(['diff', '--cached', '--', 'OWNER-STAGED.txt']), ownerStagedDiff, 'Existing owner stage changed.'); + if (precision) for (const file of allowed) { + const bytes = fs.readFileSync(path.join(projectRoot, file)); assert.deepEqual(bytes.subarray(0, sourcePrefixes[file].length), sourcePrefixes[file], 'Protected source banner changed: ' + file); + const text = bytes.toString('utf8'); + if (sourceFormats[file].lineEnding === 'crlf') assert.ok(!/(^|[^\r])\n/.test(text), 'CRLF changed: ' + file); + else assert.ok(!text.includes('\r'), 'LF changed: ' + file); + } }; const project = await api('/projects', { root: projectRoot }); const session = await api('/sessions', { projectId: project.id }); @@ -56,14 +73,17 @@ 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)); + fs.writeFileSync(path.join(workspace, precision ? '.qa/live-precision-validation.json' : '.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;' + + '依据实际失败读取有关文件,使用 read_artifact 进一步核对失败日志。' + (precision + ? '先用 index_project 建立工程索引,再用 query_code 的 symbols/imports 结果定位源码,特别是CLI入口的实际导入行。每个源码模块前420行都是须原字节保留的说明;用 read_file 指定start_line至少421的必要行范围,取得最新SHA256。已有源码只能用 propose_patch 及该SHA256、唯一old_text锚点精确修改;保留BOM及原LF/CRLF,不使用 propose_file,不读整个说明块。' + : '只能用 propose_file 修改 src/normalize.mjs、src/summary.mjs、src/render.mjs、src/cli.mjs;') + + '允许修改的源码仅为 src/normalize.mjs、src/summary.mjs、src/render.mjs、src/cli.mjs。' + '测试、fixtures、构建脚本、package.json、README 和 OWNER 文件必须保留。四模块都需修复,不能修改验收来通过。' + '本工程没有第三方依赖,不用安装。不要使用 run_command、不要自己提交Git;本轮终端仅通过已识别的npm检查计划运行。' + '提案等待审查应用,随后继续同一目标并实际重新运行 test/build,依据日志修复直至通过。检查通过后用 plan_delivery 准备本Task的四文件本地Git预览,等待用户独立确认;最后用中文报告实际测试数量、构建结果和改动。' }); @@ -80,6 +100,12 @@ try { 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); + if (precision) { + assert.ok(!state.events.some(event => event.tool === 'propose_file'), 'Precision sample must use exact patch proposals only.'); + for (const event of state.events.filter(event => event.tool === 'read_file' && allowed.includes(event.input?.path))) { + assert.ok(event.input.start_line >= bannerLines + 1, 'Source reads must target indexed implementation lines: ' + event.input.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 @@ -103,9 +129,15 @@ try { for (const proposal of pending) { assert.equal(sha(proposal.path), proposal.baseSha256, 'Proposal baseline changed.'); assert.notEqual(proposal.content.trim(), '', 'Empty source proposal.'); + if (precision) { + assert.equal(proposal.editKind, 'exact-patch'); assert.ok(proposal.patch.edits > 0); + assert.ok(proposal.patch.ranges.every(range => range.startLine >= bannerLines + 1), 'Patch must not select the preserved banner.'); + assert.deepEqual(Buffer.from(proposal.content).subarray(0, sourcePrefixes[proposal.path].length), sourcePrefixes[proposal.path]); + assert.equal(proposal.patch.preservedBom, sourceFormats[proposal.path].bom); assert.equal(proposal.patch.lineEnding, sourceFormats[proposal.path].lineEnding); + } 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 }); + applied.push({ id: proposal.id, path: proposal.path, sha256: proposal.sha256, taskId: originalTaskId, ...(precision ? { editKind: proposal.editKind, patch: proposal.patch } : {}) }); assert.ok(beforeApply.session ?? beforeApply, 'No apply response.'); assertProtected(); } await api('/sessions/' + session.id + '/continue-reviewed', {}); continue; @@ -120,6 +152,16 @@ try { 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(); + let precisionEvidence = null; + if (precision) { + const indexed = state.events.filter(event => event.tool === 'index_project' && event.phase === 'completed'), queries = state.events.filter(event => event.tool === 'query_code' && event.phase === 'completed'); + assert.ok(indexed.length > 0 && queries.length > 0, 'The model must use project index and symbol/import queries.'); + const sourceReads = state.events.filter(event => event.tool === 'read_file' && event.phase === 'completed' && allowed.includes(event.input?.path)); + for (const file of allowed) assert.ok(sourceReads.some(event => event.input.path === file), 'Each patched source must be read by its actual lines: ' + file); + precisionEvidence = { bannerLines, formats: sourceFormats, preservedPrefixes: Object.fromEntries(allowed.map(file => [file, { bytes: sourcePrefixes[file].length, sha256: createHash('sha256').update(sourcePrefixes[file]).digest('hex') }])), + indexCalls: indexed.length, queryCalls: queries.length, sourceReads: sourceReads.map(event => ({ path: event.input.path, startLine: event.input.start_line, endLine: event.input.end_line ?? null, runId: event.runId })), + exactPatchesOnly: true, sourcePrefixesPreserved: true, formatPreserved: true }; + } 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 }); @@ -165,14 +207,14 @@ try { 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, + const result = { success: true, version: bootstrap.version, mode: precision ? 'indexed-exact-patch' : 'whole-file', testedAt: new Date().toISOString(), model: bootstrap.config.model, projectRoot, projectId: project.id, sessionId: session.id, taskId: originalTaskId, baselineCommit, deliveredCommit, deliveryPlan, deliveryJob, elapsedSeconds: Math.round((Date.now() - started) / 1000), runs: state.execution.runs.length, reviewRounds: reviewedRounds, applied, - protectedHashes, ownerEditsPreserved: true, ownerStagePreserved: true, reportStatus: report.status, reportPath: path.join(caseRoot, 'delivery-report.md'), buildOutput: JSON.parse(built.stdout), usage: state.execution.task.usage, + protectedHashes, ownerEditsPreserved: true, ownerStagePreserved: true, precisionEvidence, reportStatus: report.status, reportPath: path.join(caseRoot, 'delivery-report.md'), 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, reviewed and applied four source proposals, and confirmed an owned Git preview through the Workbench API. Implementation came from the configured model; the Workbench generated and verified the commit and evidence reports.', - scope: 'One synthetic Node engineering sample; does not establish M2 or M6 delivery success rates.' }; + scope: 'One synthetic Node engineering sample; does not establish all M2 engineering classes, ChangeSet/worktree 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) { diff --git a/scripts/verify-live-session.mjs b/scripts/verify-live-session.mjs index 173c11b4..41bfb9bc 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.ok(['1.0.0', '1.1.0', '1.2.0'].includes(bootstrap.version)); +assert.ok(['1.0.0', '1.1.0', '1.2.0', '1.3.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 376ce387..35643b45 100644 --- a/src/client/App.tsx +++ b/src/client/App.tsx @@ -5,13 +5,14 @@ import { api, downloadBlob, exportSession, setToken } from './api'; import { DiffView, EmptyInspector, IconButton, Modal, ResearchContent, Status, ToolRow, FailureCard } from './components'; import { DiagnosticsPanel } from './DiagnosticsPanel'; import { TaskPanel } from './TaskPanel'; +import { CodeIndexPanel } from './CodeIndexPanel'; const activeStates = ['running', 'awaiting_approval', 'stopping']; const defaultConfig: Config = { mode: 'demo', baseUrl: 'http://127.0.0.1:11434/v1', model: '', contextLimit: 16000, maxSteps: 12, maxOutputTokens: 2048, hasKey: false, maxRunDurationMs: 600000, maxRunTokens: 200000, maxTaskTokens: 1000000 }; export default function App() { const [token, setAccess] = useState(''); - const [version, setVersion] = useState('1.2.0'); + const [version, setVersion] = useState('1.3.0'); const [diagnosticsOpen, setDiagnosticsOpen] = useState(false); const [diagnostics, setDiagnostics] = useState