feat(ui): review original-text drafts and explicit task scope
This commit is contained in:
@@ -11,3 +11,13 @@
|
||||
首相关21项20通过/1失败:新HTTP用例在宿主尚未重建时返回旧“接口不存在”;原日志`.qa/task-agreement/backend-first.tap`保留。重建宿主后原测试/断言不变,21/21通过,含HTTP实际重启复用、跨Task、全来源变化、原工件篡改、截断、范围分类和旧证据保持。复验日志`backend-recheck.tap`,无真实模型请求。
|
||||
|
||||
阶段回顾:草案是用户审阅的起点,不是语义提取准确率或自主交付证明。禁止事项的文字记录不代表已经验证遵守,既有文件/检查/Git和审批硬门保持。下一完成实际审阅界面、诊断与报告,独立发行/安装/正式保持与最终证据另验。
|
||||
|
||||
## 阶段二:原文审阅界面
|
||||
|
||||
现有任务要求面板增加“从原文整理草案”。用户逐项选择业务要求、参考、禁止或待澄清,明确证据/体验/no-test方式并审阅保存;参考文件不自动填入输出路径。手动编辑与草案共用范围字段;切换用途时清除不适用的旧证据范围。未知继续阻止完成,用户确认与工程复核分别记录。并发保存拒绝旧修订且保留输入,迟到响应不打开其它Task的草案。
|
||||
|
||||
完整构建通过(`build-ui-recheck.log`),旧要求网页7组通过(`legacy-ui-first.log`);新网页6组与实际沙箱Electron6组通过,结果分别在`.qa/task-agreement/web-4d96bd78-7b95-4f8e-b015-3015365c28d6`及`electron-798aa49a-4438-4693-a65e-7abcbd8cca61`。实际1440/390px截图检查了原文、分类说明、可滚动审阅、保存后分类和并发冲突。页面没有意外横向溢出;390px只是桌面布局适配,不增加手机写权限。所有夹具hasKey=false、独立端口/数据,模型请求0,正式未触碰。
|
||||
|
||||
首网页末项因验收器先解除route再释放请求而失败;先等待原拦截处理结束再解除,保留原断言,复验6/6。实际Electron首轮隐藏窗口截图超时,改用既有showInactive后第二轮通过前4组,但验收器宿主适配未把写入传为POST而409;补齐适配后原6组全部通过。首日志`ui-first.log`、`ui-electron-first.log`、`ui-electron-recheck.log`与相应目录保留;没有重写失败、降低断言或修改正式配置。
|
||||
|
||||
阶段回顾:真实操作已证明本地草案可取消、审阅、保存、刷新、澄清及隔离迟到响应;不证明自动理解准确率、真实模型自主交付或禁止事项已经履行。下一补诊断原失败绑定和统一当前缺口/下一步,再独立发行及保留状态升级。
|
||||
|
||||
@@ -1212,3 +1212,5 @@ Q验收复核:测试必须等待新修订的结果,不能只等待“通过
|
||||
Q发行复核:源码ZIP独立560输入/22编译完全一致,555跟踪输入之外5份原示例dist经ZIP自身脚本独立重建逐SHA匹配;三载荷新界面各9组、三归档/便携、12实际安装和16+9文件操作通过。正式原生入口首launch窗口未及时返回,随后只读清单发现实际1.24.6,未重复启动。回看后全部原状态再次一致。677755ms操作历史明确出现重复full-manifest与directory-inventory,应单列优化,不移除核验。438份/89228582字节原材料离线通过。
|
||||
|
||||
V调用前检查:新增11文件SHA断言首语法检查发现多一个右括号,已修正;此时尚无网络诊断/模型调用。保留首错误,语法检查通过后才冻结契约。
|
||||
|
||||
草案阶段:Electron截图需先showInactive;HostController.api使用{method,input},与launchWorkbench的简化api不同。两处验收器错误在新结果修正,原失败保留。参考/边界只记录,unknown仍阻止复核;UI分类变化应清除残留paths等旧字段。恢复时两次已知文件路径不存在,已按实际清单定位,未将其记作验证通过。
|
||||
|
||||
@@ -1765,3 +1765,5 @@ M最终发行与预检收尾:d62d03f9/20261103112054864的源码ZIP549输入
|
||||
M最终Git索引核对:证据及manifest共746份/55074620字节,实际暂存blob逐项长度与SHA256全部一致。首cached diff发现原CRLF收据和供应商HTML尾空格,保留全部捕获字节,只补本轮证据属性;不把原字节格式当产品错误,也不改已安装包。
|
||||
|
||||
V调用前检查:新增11文件SHA断言首语法检查发现多一个右括号,已修正;此时尚无网络诊断/模型调用。保留首错误,语法检查通过后才冻结契约。
|
||||
|
||||
1.25草案界面阶段:完整构建、旧网页7组、新网页6组及实际Electron6组通过。首route释放次序/隐藏窗口截图/POST适配失败原日志与目录保留;实际1440/390px截图回看、保存刷新、并发拒绝/输入保留与迟到Task隔离完成。真实模型0,正式1.24.9/原PID36552/Provider保持。下一诊断与报告闭环。
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import net from 'node:net';
|
||||
import assert from 'node:assert/strict';
|
||||
import { randomUUID } from 'node:crypto';
|
||||
import { chromium, _electron } from 'playwright';
|
||||
import { fixture, launchWorkbench, until } from '../tests/helpers.mjs';
|
||||
import { beginPlanTask, completeRead } from '../tests/fixtures/task-plan-fixture.mjs';
|
||||
import { HostController } from '../src/core/desktop/host-controller.mjs';
|
||||
import { desktopExecutableIdentity } from '../src/core/desktop/app-installation.mjs';
|
||||
import { projectEnvironment } from '../src/core/process-environment.mjs';
|
||||
|
||||
const desktop = process.argv.includes('--desktop'), appRoot = path.resolve(process.env.AGENT_WORKBENCH_QA_APP_ROOT || '.');
|
||||
const directory = path.resolve('.qa/task-agreement', (desktop ? 'electron-' : 'web-') + randomUUID()); fs.mkdirSync(directory, { recursive: true });
|
||||
const disposers = [], t = { after: fn => disposers.push(fn) }, f = fixture(t);
|
||||
beginPlanTask(f, '说明当前工程;参考 README.md;禁止修改原说明;后续范围待确认。无需测试。');
|
||||
const read = completeRead(f); f.session.title = '草案与范围审阅'; f.store.save(f.session);
|
||||
const other = f.store.createSession(f.project.id), original = f.session; f.session = other; beginPlanTask(f, '另一独立目标'); other.title = '草案隔离的另一任务'; f.store.save(other); f.session = original;
|
||||
const originalMessages = structuredClone(f.session.providerMessages); f.store.close();
|
||||
const passed = [], screenshots = [], errors = []; let browser, application, controller, host, page, window, result;
|
||||
const mark = name => { passed.push(name); console.log('PASS ' + name); };
|
||||
const panel = () => page.getByLabel('要求与证据', { exact: true });
|
||||
const editor = () => page.getByRole('dialog', { name: '审阅原文草案', exact: true });
|
||||
async function select(session) {
|
||||
if (!await page.getByLabel('当前项目').isVisible()) await page.getByRole('button', { name: '展开项目栏', exact: true }).click();
|
||||
await page.getByLabel('当前项目').selectOption(f.project.id); await page.locator('.session-list button').filter({ hasText: session.title }).click();
|
||||
if (!await panel().isVisible()) await page.getByRole('button', { name: '查看任务记录', exact: true }).click();
|
||||
await until(() => panel().getByRole('button', { name: '从原文整理草案', exact: true }).isEnabled());
|
||||
}
|
||||
async function resize(width, height) {
|
||||
if (window) { await window.evaluate((win, size) => win.setContentSize(size.width, size.height), { width, height }); await until(() => page.evaluate(w => innerWidth === w, width)); }
|
||||
else await page.setViewportSize({ width, height });
|
||||
}
|
||||
async function shot(name) {
|
||||
const file = path.join(directory, name + '.png'); await page.screenshot({ path: file, scale: 'css' }); screenshots.push(file);
|
||||
fs.writeFileSync(path.join(directory, name + '.txt'), await page.locator('body').innerText());
|
||||
}
|
||||
try {
|
||||
if (desktop) {
|
||||
const socket = net.createServer(); await new Promise(resolve => socket.listen(0, '127.0.0.1', resolve)); const port = socket.address().port; await new Promise(resolve => socket.close(resolve));
|
||||
assert.notEqual(port, 4318); controller = new HostController({ appRoot, dataRoot: f.data, port, nodePath: process.execPath, timeoutMs: 60000 }); await controller.start();
|
||||
host = { api: (route, input) => controller.api(route, input ? { method: 'POST', input } : {}), bootstrap: await controller.api('/bootstrap') };
|
||||
const executable = desktopExecutableIdentity(appRoot).path;
|
||||
application = await _electron.launch({ executablePath: executable, args: [...(executable.toLowerCase().endsWith('agentworkbench.exe') ? [] : [path.join(appRoot, 'dist-desktop/main.cjs')]),
|
||||
'--app-root', appRoot, '--data-root', f.data, '--node', process.execPath, '--port', String(port), '--hidden-window'], cwd: appRoot, env: projectEnvironment(), timeout: 60000 });
|
||||
page = await application.firstWindow(); window = await application.browserWindow(page); await window.evaluate(win => win.showInactive()); await resize(1440, 1080);
|
||||
} else { host = await launchWorkbench(t, f.data, {}, { appRoot }); assert.notEqual(new URL(host.url).port, '4318'); browser = await chromium.launch({ channel: 'msedge', headless: true }); page = await browser.newPage({ viewport: { width: 1440, height: 1080 } }); await page.goto(host.url); }
|
||||
page.on('pageerror', error => errors.push(error.message)); assert.equal(host.bootstrap.config.hasKey, false);
|
||||
await page.locator('.connection.connected').waitFor(); await select(f.session);
|
||||
await panel().getByRole('button', { name: '从原文整理草案', exact: true }).click(); await editor().waitFor();
|
||||
assert.equal(await editor().getByLabel('草案1 内容用途', { exact: true }).inputValue(), 'unknown');
|
||||
assert.equal(await editor().getByRole('button', { name: '审阅并保存', exact: true }).isEnabled(), false);
|
||||
await editor().getByRole('button', { name: '取消', exact: true }).click();
|
||||
assert.equal((await host.api('/sessions/' + f.session.id + '/requirements?taskId=' + f.session.taskId)).configured, false);
|
||||
mark('generated and cancelled draft stays unconfigured, unresolved and independent of model history');
|
||||
await panel().getByRole('button', { name: '从原文整理草案', exact: true }).click(); await editor().waitFor();
|
||||
const roles = ['requirement', 'reference', 'prohibition', 'unknown', 'requirement'];
|
||||
for (const [i, role] of roles.entries()) await editor().getByLabel(`草案${i + 1} 内容用途`, { exact: true }).selectOption(role);
|
||||
await editor().getByLabel('草案1 要求证据类别', { exact: true }).selectOption('results');
|
||||
assert.equal(await editor().getByLabel('草案1 要求文件范围', { exact: true }).inputValue(), '');
|
||||
await editor().getByLabel('草案1 要求证据类别', { exact: true }).selectOption('analysis');
|
||||
await editor().getByLabel('草案5 要求复核方式', { exact: true }).selectOption('not_requested');
|
||||
await shot('desktop-draft'); await resize(390, 844);
|
||||
await editor().getByLabel('草案2 内容用途', { exact: true }).scrollIntoViewIfNeeded();
|
||||
assert.equal(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth + 1), true); await shot('narrow-draft');
|
||||
await editor().getByRole('checkbox').check(); await editor().getByRole('button', { name: '审阅并保存', exact: true }).click(); await editor().waitFor({ state: 'hidden' });
|
||||
await until(async () => await panel().locator('.requirement-list > li').count() === 5);
|
||||
assert.deepEqual(await panel().locator('.requirement-state').allTextContents(), ['待复核', '参考已记录', '边界已记录', '范围待澄清', '按约定未执行']);
|
||||
mark('reviewed classification preserves reference, boundary, unknown and no-test semantics without inferring file paths');
|
||||
await resize(1440, 1080); await page.reload(); await page.locator('.connection.connected').waitFor(); await select(f.session);
|
||||
const rows = panel().locator('.requirement-list > li'); await rows.nth(0).getByRole('combobox').selectOption(read.id);
|
||||
await rows.nth(0).getByRole('button', { name: '复核所选证据', exact: true }).click(); await until(async () => (await rows.nth(0).locator('.requirement-state').textContent()) === '所选证据已核对');
|
||||
assert.equal((await host.api('/sessions/' + f.session.id + '/requirements?taskId=' + f.session.taskId)).all_resolved, false);
|
||||
mark('refresh restores saved scope, original read is separately verified and unknown still blocks resolution');
|
||||
await rows.nth(3).getByRole('button', { name: '修订此要求', exact: true }).click();
|
||||
const manual = page.getByRole('dialog', { name: '记录用户要求', exact: true });
|
||||
await manual.getByLabel('内容用途', { exact: true }).selectOption('requirement');
|
||||
await manual.getByLabel('要求复核方式', { exact: true }).selectOption('user');
|
||||
await manual.getByLabel('要求验收条件', { exact: true }).fill('用户实际体验后确认说明范围');
|
||||
await manual.getByRole('button', { name: '保存要求', exact: true }).click(); await manual.waitFor({ state: 'hidden' });
|
||||
await rows.nth(3).getByRole('textbox').fill('实际阅读了当前说明,确认范围符合本次原目标。');
|
||||
await rows.nth(3).getByRole('button', { name: '记录用户确认', exact: true }).click();
|
||||
await until(async () => (await rows.nth(3).locator('.requirement-state').textContent()) === '用户已确认');
|
||||
assert.equal((await host.api('/sessions/' + f.session.id + '/requirements?taskId=' + f.session.taskId)).all_resolved, true);
|
||||
await panel().scrollIntoViewIfNeeded(); await shot('desktop-reviewed');
|
||||
mark('explicit clarification and actual user confirmation resolve only the selected revision');
|
||||
await panel().getByRole('button', { name: '从原文整理草案', exact: true }).click(); await editor().waitFor();
|
||||
const externalView = await host.api('/sessions/' + f.session.id + '/requirements?taskId=' + f.session.taskId);
|
||||
const clean = row => ({ key: row.key, role: row.role, title: row.title, criterion: row.criterion, method: row.method, kind: row.kind,
|
||||
source: { kind: row.source.kind, id: row.source.id, start: row.source.start, end: row.source.end },
|
||||
...(row.method === 'scope' ? {} : row.kind === 'analysis' ? { tools: row.tools } : { checks: row.checks }) });
|
||||
const externalRows = externalView.items.map(clean); externalRows[0].criterion += '(另一窗口追加)';
|
||||
await host.api('/sessions/' + f.session.id + '/requirements', { taskId: f.session.taskId, runId: f.session.runId, expected_revision: externalView.revision, requirements: externalRows });
|
||||
await editor().getByRole('checkbox').check(); await editor().getByRole('button', { name: '审阅并保存', exact: true }).click();
|
||||
await until(async () => /修订|旧来源/.test(await page.locator('body').innerText()));
|
||||
assert.equal(await editor().isVisible(), true); await shot('desktop-stale-draft'); await editor().getByRole('button', { name: '取消', exact: true }).click();
|
||||
mark('concurrent revision rejects stale draft while preserving its review fields and original ledger');
|
||||
let release, finished, held = false; const handled = new Promise(resolve => { finished = resolve; });
|
||||
await page.route('**/requirement-drafts', async route => {
|
||||
held = true; await new Promise(resolve => { release = resolve; });
|
||||
try { await route.continue(); } catch (error) { errors.push(error.message); } finally { finished(); }
|
||||
});
|
||||
await panel().getByRole('button', { name: '从原文整理草案', exact: true }).click(); await until(() => held); await select(other); release(); await handled; await page.unroute('**/requirement-drafts');
|
||||
await until(async () => /尚未逐项记录/.test(await panel().textContent())); assert.equal(await editor().count(), 0);
|
||||
mark('late draft response does not open a modal or overwrite another selected Task');
|
||||
assert.deepEqual(errors, []);
|
||||
const exported = await host.api('/sessions/' + f.session.id + '/export'); assert.deepEqual(exported.session.providerMessages, originalMessages);
|
||||
fs.writeFileSync(path.join(directory, 'session.json'), JSON.stringify(exported, null, 2));
|
||||
result = { success: true, version: host.bootstrap.version, appRoot, actualElectron: desktop, passed, screenshots, errors, realModelRequests: 0, officialServiceTouched: false };
|
||||
} catch (error) {
|
||||
if (page) { await page.screenshot({ path: path.join(directory, 'failure.png') }).catch(() => {}); fs.writeFileSync(path.join(directory, 'failure.txt'), await page.locator('body').innerText().catch(() => 'Unavailable')); }
|
||||
result = { success: false, passed, screenshots, errors, error: error.stack, realModelRequests: 0 };
|
||||
} finally {
|
||||
if (application) await application.close(); if (browser) await browser.close(); if (controller && await controller.health()) await controller.stop();
|
||||
for (const dispose of disposers.reverse()) await dispose(); fs.writeFileSync(path.join(directory, 'result.json'), JSON.stringify(result, null, 2));
|
||||
}
|
||||
console.log(JSON.stringify({ directory, ...result })); if (!result.success) process.exitCode = 1;
|
||||
@@ -0,0 +1,69 @@
|
||||
import { useState } from 'react';
|
||||
import { Modal } from './components';
|
||||
import type { RequirementDraft, RequirementItem, RequirementView, TaskPlanStep } from './types';
|
||||
|
||||
export const requirementRoles = { requirement: '业务要求', reference: '参考资料', prohibition: '禁止事项', unknown: '待澄清' };
|
||||
const kinds: Record<TaskPlanStep['kind'], string> = { analysis: '研究与读取', changes: '已应用改动', results: '当前文件', checks: '工程检查', browser: '页面断言' };
|
||||
export const requirementInput = (row: RequirementItem) => ({ key: row.key, title: row.title, criterion: row.criterion,
|
||||
...(row.role ? { role: row.role } : {}), kind: row.kind, method: row.method,
|
||||
source: { kind: row.source.kind, id: row.source.id, start: row.source.start, end: row.source.end },
|
||||
...(row.method === 'scope' ? {} : row.kind === 'analysis' ? { tools: row.tools } : ['changes', 'results'].includes(row.kind) ? { paths: row.paths }
|
||||
: row.kind === 'checks' ? { checks: row.checks } : { viewport_width: row.viewport_width, actions: row.actions }) });
|
||||
const evidenceScope = (kind: TaskPlanStep['kind']) => kind === 'analysis' ? { tools: ['read_file'] } : ['changes', 'results'].includes(kind)
|
||||
? { paths: [] } : kind === 'checks' ? { checks: ['test', 'build'] } : { viewport_width: 1280, actions: ['assert_visible'] };
|
||||
export function changeRequirementRole(row: RequirementItem, role: NonNullable<RequirementItem['role']>): RequirementItem {
|
||||
const { tools, paths, checks, actions, viewport_width, ...base } = row;
|
||||
return role === 'requirement' ? { ...base, role, method: 'evidence', kind: 'analysis', tools: ['read_file'] }
|
||||
: { ...base, role, kind: 'analysis', method: 'scope' };
|
||||
}
|
||||
export function RequirementScopeFields({ row, change, prefix = '' }: { row: RequirementItem; change: (row: RequirementItem) => void; prefix?: string }) {
|
||||
const updateKind = (kind: TaskPlanStep['kind']) => {
|
||||
const { tools, paths, checks, actions, viewport_width, ...base } = row;
|
||||
change({ ...base, kind, ...evidenceScope(kind) });
|
||||
};
|
||||
return <>
|
||||
<label>内容用途<select aria-label={prefix + '内容用途'} value={row.role ?? 'requirement'} onChange={event => change(changeRequirementRole(row, event.target.value as NonNullable<RequirementItem['role']>))}>
|
||||
{Object.entries(requirementRoles).map(([key, value]) => <option key={key} value={key}>{value}</option>)}</select></label>
|
||||
{row.method === 'scope' ? <p className="record-footnote">{row.role === 'unknown' ? '尚未确定用途,保存后仍阻止要求复核完成。' : row.role === 'reference' ? '只记录参考用途,不要求修改此文件,也不计为交付成果。' : '保留用户边界供执行和复核使用;记录边界不等于已证明遵守。既有操作审批仍保留。'}</p> : <>
|
||||
<label>复核方式<select aria-label={prefix + '要求复核方式'} value={row.method} onChange={event => {
|
||||
const method = event.target.value as RequirementItem['method'];
|
||||
const { tools, paths, checks, actions, viewport_width, ...base } = row;
|
||||
change(method === 'not_requested' ? { ...base, method, kind: 'checks', checks: ['test', 'build'] }
|
||||
: method === 'user' ? { ...base, method, kind: 'analysis', tools: ['read_file'] } : { ...row, method });
|
||||
}}><option value="evidence">核对实际证据</option><option value="user">用户体验确认</option><option value="not_requested">按用户约定不执行检查</option></select></label>
|
||||
{row.method === 'evidence' && <><label>证据类别<select aria-label={prefix + '要求证据类别'} value={row.kind} onChange={event => updateKind(event.target.value as TaskPlanStep['kind'])}>{Object.entries(kinds).map(([key, value]) => <option key={key} value={key}>{value}</option>)}</select></label>
|
||||
{['results', 'changes'].includes(row.kind) && <label>文件范围(每行一项)<textarea aria-label={prefix + '要求文件范围'} required value={row.paths?.join('\n') ?? ''} onChange={event => change({ ...row, paths: event.target.value.split('\n').filter(Boolean) })} /></label>}
|
||||
{row.kind === 'analysis' && <label>读取工具(逗号分隔)<input aria-label={prefix + '要求读取工具'} required value={row.tools?.join(',') ?? ''} onChange={event => change({ ...row, tools: event.target.value.split(',').map(value => value.trim()) })} /></label>}
|
||||
{row.kind === 'checks' && <label>检查名称(逗号分隔)<input aria-label={prefix + '要求检查名称'} required value={row.checks?.join(',') ?? ''} onChange={event => change({ ...row, checks: event.target.value.split(',').map(value => value.trim()) })} /></label>}
|
||||
{row.kind === 'browser' && <label>验收视口<select aria-label={prefix + '要求验收视口'} value={row.viewport_width} onChange={event => change({ ...row, viewport_width: Number(event.target.value) })}><option value={1280}>桌面 · 1280px</option><option value={390}>手机 · 390px</option></select></label>}</>}
|
||||
</>}
|
||||
</>;
|
||||
}
|
||||
|
||||
export function RequirementDraftEditor({ value, view, saving, submit, close }: { value: RequirementDraft; view: RequirementView; saving: boolean;
|
||||
submit: (input: object) => void; close: () => void }) {
|
||||
const [rows, setRows] = useState<RequirementItem[]>(value.proposal.items.map(row => ({ ...row, role: 'unknown', kind: 'analysis', method: 'scope', depends_on: [] })));
|
||||
const [reviewed, setReviewed] = useState(false);
|
||||
const count = view.items.length + rows.filter(row => !view.items.some(old => old.key === row.key)).length;
|
||||
return <Modal title="审阅原文草案" description="草案只整理原文。逐项确定用途、验收方式和范围后保存;待澄清内容继续保留。" wide onClose={() => { if (!saving) close(); }}>
|
||||
<form className="plan-editor requirement-editor requirement-draft-editor" onSubmit={event => {
|
||||
event.preventDefault(); const keys = new Set(rows.map(row => row.key));
|
||||
submit({ draft_id: value.id, source_set_sha256: value.sourceSetSha256,
|
||||
reviewed_source_ids: [...new Set([...view.sources.filter(row => !view.unreviewed_sources?.includes(row.id)).map(row => row.id), ...value.proposal.covered_source_ids])],
|
||||
requirements: [...view.items.filter(row => !keys.has(row.key)).map(requirementInput), ...rows.map(requirementInput)] });
|
||||
}}>
|
||||
<p className="record-footnote">{value.proposal.note}</p>
|
||||
{value.proposal.truncated && <p role="alert" className="plan-problem">草案达到保留上限,部分原文未收录。未完整收录的来源仍保持未审阅,请分小任务或手动核对。</p>}
|
||||
{count > 24 && <p role="alert" className="plan-problem">合计 {count} 项,超过24项上限。请取消并逐项手动审阅,原草案与旧要求均保留。</p>}
|
||||
<fieldset disabled={saving} className="requirement-draft-items">{rows.map((row, i) => <section className="plan-editor-step" key={row.key} aria-label={`草案条目 ${i + 1}`}>
|
||||
<p className="requirement-draft-origin">{row.source.kind === 'goal' ? '原目标' : '追加要求'} · [{row.source.start}, {row.source.end})</p>
|
||||
<blockquote className="requirement-quote">{row.source.quote}</blockquote>
|
||||
<label>名称<input aria-label={`草案名称 ${i + 1}`} required maxLength={100} value={row.title} onChange={event => setRows(values => values.map((item, index) => index === i ? { ...item, title: event.target.value } : item))} /></label>
|
||||
<label>验收条件或范围说明<textarea aria-label={`草案条件 ${i + 1}`} required maxLength={300} rows={2} value={row.criterion} onChange={event => setRows(values => values.map((item, index) => index === i ? { ...item, criterion: event.target.value } : item))} /></label>
|
||||
<RequirementScopeFields row={row} prefix={`草案${i + 1} `} change={next => setRows(values => values.map((item, index) => index === i ? next : item))} />
|
||||
</section>)}</fieldset>
|
||||
<label className="requirement-review-check"><input type="checkbox" required checked={reviewed} disabled={saving} onChange={event => setReviewed(event.target.checked)} />已核对所收录的原文和分类;未确定内容保留为待澄清。</label>
|
||||
<div className="modal-actions"><button type="button" className="button secondary" disabled={saving} onClick={close}>取消</button><button className="button primary" disabled={saving || !reviewed || count > 24}>审阅并保存</button></div>
|
||||
</form>
|
||||
</Modal>;
|
||||
}
|
||||
@@ -2,6 +2,13 @@
|
||||
.requirement-list > li { padding: 14px 0; border-top: 1px solid #dce7e2; font-size: 12px; line-height: 1.65; overflow-wrap: anywhere; }
|
||||
.requirement-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
|
||||
.requirement-heading strong { font-size: 13px; }
|
||||
.requirement-role, .requirement-draft-origin { color: #526a70; font-size: 11px; margin: 4px 0; }
|
||||
.requirement-draft-items { border: 0; margin: 0; padding: 0; min-width: 0; }
|
||||
.requirement-draft-editor .plan-editor-step { border-top: 1px solid #dce7e2; padding-top: 14px; margin-top: 14px; }
|
||||
.requirement-review-check { display: flex !important; align-items: flex-start; gap: 9px; font-size: 12px; padding: 12px 0; line-height: 1.7; }
|
||||
.requirement-review-check input { width: auto !important; margin-top: 4px; flex-shrink: 0; }
|
||||
.requirement-reference_recorded, .requirement-boundary_recorded { color: #526a70; background: #eef1f4; }
|
||||
.requirement-panel .plan-toolbar { flex-wrap: wrap; }
|
||||
.requirement-state { color: #674917; background: #fbf2df; padding: 2px 6px; border-radius: 3px; flex-shrink: 0; font-size: 11px; }
|
||||
.requirement-evidence_verified, .requirement-user_confirmed { color: #154b4a; background: #edf3f1; }
|
||||
.requirement-list summary, .requirement-history summary { cursor: pointer; color: #526a70; }
|
||||
@@ -16,4 +23,4 @@
|
||||
.requirement-offsets { display: flex; gap: 12px; margin: 12px 0; }
|
||||
.requirement-offsets label { min-width: 0; font-size: 12px; }
|
||||
.requirement-panel button:focus-visible, .requirement-panel textarea:focus-visible, .requirement-editor :is(input, select, textarea):focus-visible { outline: 2px solid #4664d9; outline-offset: 2px; }
|
||||
@media (max-width: 600px) { .requirement-heading { flex-direction: column; gap: 4px; } .requirement-panel .button { min-height: 36px; } }
|
||||
@media (max-width: 600px) { .requirement-heading { flex-direction: column; gap: 4px; } .requirement-panel .button, .requirement-editor button, .requirement-editor select { min-height: 44px; } }
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
import { Check, FileText, Plus, RefreshCw } from 'lucide-react';
|
||||
import { Check, FileText, Plus, RefreshCw, ListChecks } from 'lucide-react';
|
||||
import { api } from './api';
|
||||
import { Modal } from './components';
|
||||
import type { RequirementItem, RequirementView, Session, TaskPlanStep } from './types';
|
||||
import type { RequirementDraft, RequirementItem, RequirementView, Session, TaskPlanStep } from './types';
|
||||
import { RequirementDraftEditor, RequirementScopeFields, requirementInput as clean, requirementRoles } from './RequirementDraftEditor';
|
||||
import './RequirementPanel.css';
|
||||
|
||||
const states: Record<string, string> = { pending: '待复核', failed: '复核未通过', stale: '依据已失效', unverified: '原记录待核对',
|
||||
evidence_verified: '所选证据已核对', user_confirmed: '用户已确认', not_requested: '按约定未执行' };
|
||||
evidence_verified: '所选证据已核对', user_confirmed: '用户已确认', not_requested: '按约定未执行',
|
||||
scope_unknown: '范围待澄清', reference_recorded: '参考已记录', boundary_recorded: '边界已记录' };
|
||||
const kinds: Record<TaskPlanStep['kind'], string> = { analysis: '研究与读取', changes: '已应用改动', results: '当前文件', checks: '工程检查', browser: '页面断言' };
|
||||
const clean = (row: RequirementItem) => ({ key: row.key, title: row.title, criterion: row.criterion, kind: row.kind, method: row.method,
|
||||
source: { kind: row.source.kind, id: row.source.id, start: row.source.start, end: row.source.end },
|
||||
...(row.kind === 'analysis' ? { tools: row.tools } : ['changes', 'results'].includes(row.kind) ? { paths: row.paths }
|
||||
: row.kind === 'checks' ? { checks: row.checks } : { viewport_width: row.viewport_width, actions: row.actions }) });
|
||||
const scope = (kind: TaskPlanStep['kind']) => kind === 'analysis' ? { tools: ['read_file'] } : ['changes', 'results'].includes(kind)
|
||||
? { paths: [] } : kind === 'checks' ? { checks: ['test', 'build'] } : { viewport_width: 1280, actions: ['assert_visible'] };
|
||||
|
||||
@@ -24,9 +22,10 @@ export function RequirementPanel({ session, busy, onSession, onError, openArtifa
|
||||
const generation = useRef(0), mutation = useRef(false);
|
||||
const [view, setView] = useState<RequirementView | null>(null), [loading, setLoading] = useState(false), [saving, setSaving] = useState(false);
|
||||
const [draft, setDraft] = useState<RequirementItem | null>(null), [picked, setPicked] = useState<Record<string, string>>({}), [notes, setNotes] = useState<Record<string, string>>({});
|
||||
const [proposal, setProposal] = useState<RequirementDraft | null>(null);
|
||||
const [notice, setNotice] = useState('');
|
||||
const disabled = busy || saving || ['running', 'awaiting_approval', 'stopping'].includes(session.status);
|
||||
useEffect(() => { generation.current++; setView(null); setDraft(null); setPicked({}); setNotes({}); setNotice(''); setSaving(false); mutation.current = false;
|
||||
useEffect(() => { generation.current++; setView(null); setDraft(null); setProposal(null); setPicked({}); setNotes({}); setNotice(''); setSaving(false); mutation.current = false;
|
||||
return () => { generation.current++; }; }, [identity]);
|
||||
useEffect(() => { const timer = setTimeout(() => { void load(); }, 120); return () => clearTimeout(timer); }, [identity, session.revision, session.status]);
|
||||
async function load() {
|
||||
@@ -41,12 +40,13 @@ export function RequirementPanel({ session, busy, onSession, onError, openArtifa
|
||||
if (!task || !run || !view || mutation.current) return;
|
||||
mutation.current = true; generation.current++; setSaving(true); setNotice(''); const scopeId = identity;
|
||||
try {
|
||||
const reply = await api<{ session: Session; requirements: RequirementView; verification?: { status: string; message?: string } }>(`/sessions/${session.id}/${action}`,
|
||||
const reply = await api<{ session: Session; requirements: RequirementView; draft?: RequirementDraft; verification?: { status: string; message?: string } }>(`/sessions/${session.id}/${action}`,
|
||||
{ taskId: task.id, runId: run.id, expected_revision: view.revision, ...input });
|
||||
if (selected.current !== scopeId) return;
|
||||
setView(reply.requirements); onSession(reply.session);
|
||||
setNotice(reply.verification?.status === 'error' ? reply.verification.message ?? '复核未通过,原失败已保留。' : action === 'requirements' ? '要求与原文来源已保存。' : '本次复核已记录。');
|
||||
if (action === 'requirements') setDraft(null);
|
||||
setNotice(reply.verification?.status === 'error' ? reply.verification.message ?? '复核未通过,原失败已保留。' : action === 'requirements' ? '要求与原文来源已保存。' : action === 'requirement-drafts' ? '草案已整理,尚未成为要求或完成依据。' : '本次复核已记录。');
|
||||
if (reply.draft) setProposal(reply.draft);
|
||||
if (action === 'requirements') { setDraft(null); setProposal(null); }
|
||||
} catch (error) { if (selected.current === scopeId) onError(error); }
|
||||
finally { if (selected.current === scopeId) { mutation.current = false; setSaving(false); setLoading(false); } }
|
||||
}
|
||||
@@ -60,6 +60,7 @@ export function RequirementPanel({ session, busy, onSession, onError, openArtifa
|
||||
<div className="record-heading"><h3>要求与证据</h3><span>{view?.items.length ?? 0} 项</span></div>
|
||||
<p className="record-footnote">逐项保留用户原文与实际依据,工程证据和用户体验分别记录。</p>
|
||||
<div className="plan-toolbar"><button className="text-button" disabled={loading || disabled} onClick={() => void load()}><RefreshCw size={13} />刷新复核</button>
|
||||
<button className="button secondary" disabled={disabled || !view || view.status === 'unverified'} onClick={() => void mutate('requirement-drafts', { source_set_sha256: view!.source_set_sha256 })}><ListChecks size={13} />从原文整理草案</button>
|
||||
<button className="button secondary" disabled={disabled || !view || view.status === 'unverified' || (view.items.length >= 24)} onClick={() => edit()}><Plus size={13} />记录要求</button></div>
|
||||
{notice && <p className="plan-notice" role="status">{notice}</p>}
|
||||
{view?.error && <p className="plan-problem" role="alert">{view.error}</p>}
|
||||
@@ -67,6 +68,7 @@ export function RequirementPanel({ session, busy, onSession, onError, openArtifa
|
||||
{view && !view.items.length && <p className="record-empty">尚未逐项记录要求。模型的完成答复保留在原会话中。</p>}
|
||||
<ol className="requirement-list">{view?.items.map(row => <li key={row.key}>
|
||||
<div className="requirement-heading"><strong>{row.title}</strong><span className={'requirement-state requirement-' + row.status}>{states[row.status ?? 'pending'] ?? row.status}</span></div>
|
||||
<p className="requirement-role">{requirementRoles[row.role ?? 'requirement']}{row.method !== 'scope' ? ' · ' + kinds[row.kind] + (row.paths?.length ? ' · ' + row.paths.join('、') : '') : ''}</p>
|
||||
<p>{row.criterion}</p>
|
||||
<details><summary>用户原文 · {row.source.kind === 'goal' ? '原目标' : '追加要求'} · 要求修订 {row.revision}</summary>
|
||||
<blockquote>{row.source.quote}</blockquote><code>{row.source.id} [{row.source.start}, {row.source.end})</code></details>
|
||||
@@ -80,23 +82,21 @@ export function RequirementPanel({ session, busy, onSession, onError, openArtifa
|
||||
{row.method === 'user' && <div className="requirement-confirm"><label>实际体验与结论<textarea aria-label={`用户确认 ${row.title}`} rows={2} maxLength={1000} disabled={disabled} value={notes[row.key] ?? ''} onChange={event => setNotes(values => ({ ...values, [row.key]: event.target.value }))} /></label>
|
||||
<button className="button secondary" disabled={disabled || !notes[row.key]?.trim()} onClick={() => void mutate('requirement-proofs', { key: row.key, note: notes[row.key] })}>记录用户确认</button></div>}
|
||||
{row.method === 'not_requested' && <p className="record-footnote">检查未执行,不计为测试通过。</p>}
|
||||
{row.method === 'scope' && <p className="record-footnote">{row.role === 'unknown' ? '请先澄清原文的用途或验收范围。' : row.role === 'reference' ? '参考资料不计为需要修改或交付的文件。' : '仅记录禁止事项;是否遵守仍需实际证据,不代表验收通过。'}</p>}
|
||||
</li>)}</ol>
|
||||
{!!view?.history?.length && <details className="requirement-history"><summary>原复核历史 · {view.history.length} 条</summary>{view.history.map(row => <p key={row.id}><button className="text-button" onClick={() => openArtifact(row.artifact_id)}>{row.key} · 修订 {row.revision} · {row.status === 'rejected' ? '未通过' : '已记录'}</button>{row.error && <span>{row.error}</span>}</p>)}</details>}
|
||||
{draft && view && <Modal title="记录用户要求" description="选定用户原文、验收范围和复核方式;修订保留旧要求与原失败。" wide onClose={() => { if (!saving) setDraft(null); }}>
|
||||
<form className="plan-editor requirement-editor" onSubmit={event => { event.preventDefault(); const rows = view.items.some(row => row.key === draft.key) ? view.items.map(row => row.key === draft.key ? clean(draft) : clean(row)) : [...view.items.map(clean), clean(draft)]; void mutate('requirements', { requirements: rows }); }}>
|
||||
<form className="plan-editor requirement-editor" onSubmit={event => { event.preventDefault(); const rows = view.items.some(row => row.key === draft.key) ? view.items.map(row => row.key === draft.key ? clean(draft) : clean(row)) : [...view.items.map(clean), clean(draft)]; void mutate('requirements', { requirements: rows, source_set_sha256: view.source_set_sha256,
|
||||
reviewed_source_ids: [...new Set([...view.sources.filter(row => !view.unreviewed_sources?.includes(row.id)).map(row => row.id), ...(source && draft.source.start === 0 && draft.source.end === source.text.length ? [source.id] : [])])] }); }}>
|
||||
<fieldset disabled={saving} className="plan-editor-step">
|
||||
<label>要求名称<input aria-label="要求名称" maxLength={100} required value={draft.title} onChange={event => setDraft({ ...draft, title: event.target.value })} /></label>
|
||||
<label>验收条件<textarea aria-label="要求验收条件" rows={2} required maxLength={300} value={draft.criterion} onChange={event => setDraft({ ...draft, criterion: event.target.value })} /></label>
|
||||
<label>用户原文来源<select aria-label="要求原文来源" value={draft.source.id} onChange={event => { const row = view.sources.find(value => value.id === event.target.value)!; setDraft({ ...draft, source: { kind: row.kind, id: row.id, start: 0, end: row.text.length } }); }}>{view.sources.map((row, i) => <option key={row.id} value={row.id}>{row.kind === 'goal' ? '原目标' : `追加要求 ${i}`} · {row.text.slice(0, 65)}</option>)}</select></label>
|
||||
<blockquote className="requirement-quote">{source?.text.slice(draft.source.start, draft.source.end)}</blockquote>
|
||||
<div className="requirement-offsets"><label>原文起点<input aria-label="原文起点" type="number" min={0} max={Math.max(0, (source?.text.length ?? 1) - 1)} value={draft.source.start} onChange={event => setDraft({ ...draft, source: { ...draft.source, start: Number(event.target.value) } })} /></label><label>原文终点<input aria-label="原文终点" type="number" min={draft.source.start + 1} max={source?.text.length} value={draft.source.end} onChange={event => setDraft({ ...draft, source: { ...draft.source, end: Number(event.target.value) } })} /></label></div>
|
||||
<label>复核方式<select aria-label="要求复核方式" value={draft.method} onChange={event => setDraft({ ...draft, method: event.target.value as RequirementItem['method'], ...(event.target.value === 'not_requested' ? { kind: 'checks', checks: ['test', 'build'] } : {}) })}><option value="evidence">核对实际证据</option><option value="user">用户体验确认</option><option value="not_requested">按用户约定不执行检查</option></select></label>
|
||||
{draft.method === 'evidence' && <><label>证据类别<select aria-label="要求证据类别" value={draft.kind} onChange={event => { const kind = event.target.value as TaskPlanStep['kind']; setDraft({ ...draft, kind, ...scope(kind) }); }}>{Object.entries(kinds).map(([key, label]) => <option key={key} value={key}>{label}</option>)}</select></label>
|
||||
{['results', 'changes'].includes(draft.kind) && <label>文件范围(每行一项)<textarea aria-label="要求文件范围" required value={draft.paths?.join('\n') ?? ''} onChange={event => setDraft({ ...draft, paths: event.target.value.split('\n').filter(Boolean) })} /></label>}
|
||||
{draft.kind === 'analysis' && <label>读取工具(逗号分隔)<input aria-label="要求读取工具" required value={draft.tools?.join(',') ?? ''} onChange={event => setDraft({ ...draft, tools: event.target.value.split(',').map(value => value.trim()) })} /></label>}
|
||||
{draft.kind === 'checks' && <label>检查名称(逗号分隔)<input aria-label="要求检查名称" required value={draft.checks?.join(',') ?? ''} onChange={event => setDraft({ ...draft, checks: event.target.value.split(',').map(value => value.trim()) })} /></label>}
|
||||
{draft.kind === 'browser' && <label>验收视口<select aria-label="要求验收视口" value={draft.viewport_width} onChange={event => setDraft({ ...draft, viewport_width: Number(event.target.value) })}><option value={1280}>桌面 · 1280px</option><option value={390}>手机 · 390px</option></select></label>}</>}
|
||||
<RequirementScopeFields row={draft} change={setDraft} />
|
||||
</fieldset><div className="modal-actions"><button type="button" className="button secondary" disabled={saving} onClick={() => setDraft(null)}>取消</button><button className="button primary" disabled={saving}>保存要求</button></div>
|
||||
</form></Modal>}
|
||||
{proposal && view && <RequirementDraftEditor value={proposal} view={view} saving={saving} close={() => setProposal(null)} submit={input => void mutate('requirements', input)} />}
|
||||
</section>;
|
||||
}
|
||||
|
||||
+7
-2
@@ -236,15 +236,20 @@ export interface TaskPlanView {
|
||||
export interface TaskPlanReply { session: Session; plan: TaskPlanView; verification?: { status: string; reused?: boolean; proof_id: string; message?: string } }
|
||||
export interface RequirementSource { kind: 'goal' | 'instruction'; id: string; text: string; sha256: string; at: string | null }
|
||||
export interface RequirementItem extends TaskPlanStep {
|
||||
method: 'evidence' | 'user' | 'not_requested'; source: { kind: string; id: string; start: number; end: number; quote?: string; sourceSha256?: string; at?: string | null };
|
||||
role?: 'requirement' | 'reference' | 'prohibition' | 'unknown';
|
||||
method: 'evidence' | 'user' | 'not_requested' | 'scope'; source: { kind: string; id: string; start: number; end: number; quote?: string; sourceSha256?: string; at?: string | null };
|
||||
revision?: number; status?: string; error?: string | null; proof_id?: string | null; proof_artifact_id?: string | null; user_note?: string | null;
|
||||
evidence?: TaskPlanStepView['evidence']; candidates?: TaskPlanStepView['candidates']; last_rejection?: { message: string } | null;
|
||||
}
|
||||
export interface RequirementView {
|
||||
configured: boolean; task_id: string; revision: number; status: string; items: RequirementItem[]; sources: RequirementSource[];
|
||||
configured: boolean; task_id: string; revision: number; status: string; items: RequirementItem[]; sources: RequirementSource[]; source_set_sha256: string;
|
||||
all_resolved: boolean; unreviewed_sources?: string[]; error?: string; note: string; contract_artifact_id?: string;
|
||||
history?: { id: string; key: string; revision: number; status: string; error: string | null; at: string; artifact_id: string }[];
|
||||
}
|
||||
export interface RequirementDraft {
|
||||
id: string; taskId: string; runId: string; expectedRevision: number; sourceSetSha256: string; contractArtifactId: string;
|
||||
proposal: { items: (Pick<RequirementItem, 'key' | 'title' | 'criterion' | 'source' | 'role'>)[]; covered_source_ids: string[]; truncated: boolean; note: string };
|
||||
}
|
||||
export interface ExecutionSnapshot { schemaVersion: number; task: Task | null; run: Run | null; runs: RunBrief[]; progress: { totalTools: number; completedTools: number; requiresVerification: { id: string; tool: string; state: string; callId: string }[] }; artifacts: Artifact[]; checks: CheckJob[]; mcpJobs?: McpJob[]; plans?: CheckPlan[]; deliveries?: DeliveryJob[]; deliveryPlans?: DeliveryPlan[]; changeSets?: ChangeSet[]; contextPlans?: ContextPlan[]; workspaces?: WorkspaceRecord[]; researchTargets?: ResearchTarget[]; researchJobs?: ResearchJob[]; engineJobs?: EngineJob[]; engineRuns?: EngineRunView[]; browserPlans?: BrowserPlan[]; browserJobs?: BrowserJob[]; taskPlans?: TaskPlanRecord[]; taskProofs?: { id: string; planId: string; stepKey: string; status: string }[]; collaborations?: CollaborationGroup[]; workers?: WorkerRecord[]; workspaceIdentity?: WorkspaceIdentity; accountedTaskTokens: number }
|
||||
export interface WorkerBudget { maxTokens: number; maxSteps: number; maxToolCalls: number }
|
||||
export interface WorkerDefinition { id: string; label: string; goal: string; paths: string[]; budget: WorkerBudget; workspaceId: string; projectId: string; sessionId: string; taskId: string; engine?: ControlledEngineAvailability }
|
||||
|
||||
+2
-2
@@ -6,8 +6,8 @@
|
||||
|
||||
1. [complete] 核对现有要求/Task约定/诊断与真实入口,范围及验收案例已记docs/TASK-AGREEMENT-C.md;草案只保留原文待审阅,参考文件不变成输出。
|
||||
2. [complete] 本地有界草案/来源修订/跨Task/篡改/HTTP重启及显式范围接到原账本,首21项20通过1失败(旧编译宿主)保留,重建后原21/21通过,阶段回顾后本地提交。
|
||||
3. [in_progress] 现有任务面板完成草案审阅、范围编辑/保存/刷新/迟到响应保护及桌面/390px和实际Electron验收,异常恢复与基础文件路径回归后回顾提交。
|
||||
4. [pending] 诊断绑定原失败/Task/Run,报告与任务显示同一当前缺口/下一步;不重放命令、不丢原目标或把诊断算交付,相关验证与回顾提交。
|
||||
3. [complete] 草案审阅/范围保存刷新/澄清/旧修订拒绝/迟到响应隔离,网页6组与实际Electron6组、1440/390px和构建通过;旧要求网页7组通过。三份验收器首失败保留,回顾见TASK-AGREEMENT-C,阶段提交。
|
||||
4. [in_progress] 诊断绑定原失败/Task/Run,报告与任务显示同一当前缺口/下一步;不重放命令、不丢原目标或把诊断算交付,相关验证与回顾提交。
|
||||
5. [pending] 完整构建、冻结来源/独立发行/安装/保留状态正式升级、原证据封存/离线/索引复核、最终回顾与本地提交;按实际完成报告,不把localhost夹具当真实自主交付。
|
||||
|
||||
恢复首次宽读发生截断,随后限定已知文件短段;一次PowerShell rg目录通配失败改-g过滤。只读失败和截断不作验证通过。session-catchup无待同步输出,工作区干净。
|
||||
|
||||
Reference in New Issue
Block a user