dsh-spec-collab 0.1.5 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/client.js +845 -461
- package/lib/index.js +38 -16
- package/lib/types/client/SpecWorkbench.d.ts.map +1 -1
- package/lib/types/client/workflow.d.ts +32 -0
- package/lib/types/client/workflow.d.ts.map +1 -0
- package/lib/types/tools.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/client/SpecWorkbench.tsx +119 -61
- package/src/client/workbench.module.css +256 -190
- package/src/client/workflow.ts +138 -0
- package/src/engine.ts +1 -1
- package/src/git-store.ts +1 -1
- package/src/review-runtime.ts +11 -3
- package/src/tools.ts +6 -3
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import type { ParticipantRole, RequirementView, ReviewKind } from '../protocol.ts'
|
|
2
|
+
|
|
3
|
+
export type TaskView = 'review' | 'patches' | 'ready'
|
|
4
|
+
export type WorkflowCommand =
|
|
5
|
+
| { kind: 'open'; view: TaskView }
|
|
6
|
+
| { kind: 'bind-workspace' }
|
|
7
|
+
| { kind: 'request-review'; reviewKind: ReviewKind }
|
|
8
|
+
| { kind: 'advance' }
|
|
9
|
+
| { kind: 'confirm'; role: ParticipantRole }
|
|
10
|
+
| { kind: 'generate-ready' }
|
|
11
|
+
| { kind: 'none' }
|
|
12
|
+
|
|
13
|
+
export interface WorkflowState {
|
|
14
|
+
eyebrow: string
|
|
15
|
+
title: string
|
|
16
|
+
detail: string
|
|
17
|
+
actionLabel: string
|
|
18
|
+
command: WorkflowCommand
|
|
19
|
+
disabled?: boolean
|
|
20
|
+
disabledReason?: string
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const reviewIsOpen = (status: RequirementView['reviewItems'][number]['status']): boolean => !['resolved', 'invalidated', 'non-blocking-verify'].includes(status)
|
|
24
|
+
|
|
25
|
+
export function workflowState(requirement: RequirementView, participantRole: ParticipantRole): WorkflowState {
|
|
26
|
+
const currentReviews = requirement.reviewItems.filter(item => item.commit === requirement.currentCommit)
|
|
27
|
+
const blockers = currentReviews.filter(item => item.severity === 'blocking' && reviewIsOpen(item.status))
|
|
28
|
+
const productBlockers = blockers.filter(item => item.status !== 'joint-review')
|
|
29
|
+
const unanswered = blockers.filter(item => item.status === 'open')
|
|
30
|
+
const currentPatches = requirement.patches.filter(item => item.baseCommit === requirement.currentCommit && item.status === 'pending')
|
|
31
|
+
const currentRuns = requirement.aiRuns.filter(run => run.commit === requirement.currentCommit)
|
|
32
|
+
const activeRun = currentRuns.slice().reverse().find(run => ['queued', 'running'].includes(run.status))
|
|
33
|
+
const completed = (kind: ReviewKind): boolean => currentRuns.some(run => run.kind === kind && run.status === 'completed')
|
|
34
|
+
const productConfirmed = requirement.confirmations.some(item => item.commit === requirement.currentCommit && item.role === 'product' && item.scope === 'version' && item.status === 'active')
|
|
35
|
+
const engineeringConfirmed = requirement.confirmations.some(item => item.commit === requirement.currentCommit && item.role === 'engineering' && item.scope === 'version' && item.status === 'active')
|
|
36
|
+
const failedChecks = requirement.readiness.filter(check => !check.passed)
|
|
37
|
+
|
|
38
|
+
if (!requirement.workspaceId) return {
|
|
39
|
+
eyebrow: '开始前', title: '关联需求所在的项目', detail: 'AI 会从这个项目读取代码、规范和团队知识,关联后不能中途切换。',
|
|
40
|
+
actionLabel: '选择项目', command: { kind: 'bind-workspace' },
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (activeRun) return {
|
|
44
|
+
eyebrow: 'AI 正在工作', title: activeRun.kind === 'engineering-precheck' ? '正在从研发视角检查需求' : '正在整理需求中的问题',
|
|
45
|
+
detail: '结果会自动出现在这里,可以先继续编辑正文。', actionLabel: '分析中', command: { kind: 'none' }, disabled: true,
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (requirement.stage === 'product-review') {
|
|
49
|
+
if (!completed('product-first')) return {
|
|
50
|
+
eyebrow: '需求澄清', title: '先让 AI 找出需求缺口', detail: 'AI 会检查目标、范围、验收标准、证据和潜在风险。',
|
|
51
|
+
actionLabel: '开始需求检查', command: { kind: 'request-review', reviewKind: 'product-first' },
|
|
52
|
+
}
|
|
53
|
+
if (unanswered.length > 0) return {
|
|
54
|
+
eyebrow: '需要你的判断', title: `回答 ${unanswered.length} 个关键问题`, detail: '先处理会影响范围、规则或验收结果的问题,其余内容可以稍后核对。',
|
|
55
|
+
actionLabel: '继续回答', command: { kind: 'open', view: 'review' },
|
|
56
|
+
}
|
|
57
|
+
if (currentPatches.length > 0) return {
|
|
58
|
+
eyebrow: 'AI 已整理改动', title: `审核 ${currentPatches.length} 份正文修改`, detail: '确认改动符合你的判断后,再写入正式需求版本。',
|
|
59
|
+
actionLabel: '查看改动', command: { kind: 'open', view: 'patches' },
|
|
60
|
+
}
|
|
61
|
+
if (productBlockers.length > 0 || !completed('product-second')) return {
|
|
62
|
+
eyebrow: '答案已收集', title: '让 AI 把结论整理进正文', detail: 'AI 会复核你的回答,并生成可逐项审核的正文修改。',
|
|
63
|
+
actionLabel: '整理正文改动', command: { kind: 'request-review', reviewKind: 'product-second' },
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
eyebrow: '产品澄清完成', title: '进入产品确认', detail: '当前版本没有产品侧阻塞问题,下一步由产品负责人确认内容。',
|
|
67
|
+
actionLabel: '进入产品确认', command: { kind: 'advance' },
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (requirement.stage === 'product-confirmation') {
|
|
72
|
+
if (!productConfirmed) return {
|
|
73
|
+
eyebrow: '产品确认', title: '确认当前需求版本', detail: participantRole === 'product' ? '确认目标、范围、业务规则和验收标准准确反映了产品决策。' : '需要一位产品角色确认当前版本后才能继续。',
|
|
74
|
+
actionLabel: participantRole === 'product' ? '确认当前版本' : '等待产品确认', command: participantRole === 'product' ? { kind: 'confirm', role: 'product' } : { kind: 'none' },
|
|
75
|
+
...(participantRole === 'product' ? {} : { disabled: true, disabledReason: '当前身份是研发,需由产品角色完成确认。' }),
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
eyebrow: '产品已确认', title: '邀请研发共同检查', detail: '产品结论已经锁定到当前版本,可以进入研发可行性和测试约束检查。',
|
|
79
|
+
actionLabel: '进入产研共审', command: { kind: 'advance' },
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (requirement.stage === 'joint-review') {
|
|
84
|
+
if (!completed('engineering-precheck')) return {
|
|
85
|
+
eyebrow: '产研共审', title: '从研发视角检查可实施性', detail: '重点检查现有实现、影响范围、兼容性和测试落点。',
|
|
86
|
+
actionLabel: '开始研发检查', command: { kind: 'request-review', reviewKind: 'engineering-precheck' },
|
|
87
|
+
}
|
|
88
|
+
if (unanswered.length > 0) return {
|
|
89
|
+
eyebrow: '研发发现待确认项', title: `处理 ${unanswered.length} 个阻塞问题`, detail: '这些问题会影响实现或验收,需要在交付研发前明确。',
|
|
90
|
+
actionLabel: '继续处理', command: { kind: 'open', view: 'review' },
|
|
91
|
+
}
|
|
92
|
+
if (currentPatches.length > 0) return {
|
|
93
|
+
eyebrow: '研发建议了改动', title: `审核 ${currentPatches.length} 份正文修改`, detail: '确认实现约束和测试条件已准确写回需求。',
|
|
94
|
+
actionLabel: '查看改动', command: { kind: 'open', view: 'patches' },
|
|
95
|
+
}
|
|
96
|
+
if (blockers.length > 0) return {
|
|
97
|
+
eyebrow: '仍有待收敛内容', title: '复核已回复的问题', detail: '已有回复尚未消除阻塞,请重新检查或让 AI 根据结论更新正文。',
|
|
98
|
+
actionLabel: '查看问题', command: { kind: 'open', view: 'review' },
|
|
99
|
+
}
|
|
100
|
+
if (failedChecks.length > 0) return {
|
|
101
|
+
eyebrow: '交付条件未齐', title: `补齐 ${failedChecks.length} 项需求内容`, detail: '完成条件会指出正文缺少的目标、范围、验收标准或测试约束。',
|
|
102
|
+
actionLabel: '查看缺少内容', command: { kind: 'open', view: 'ready' },
|
|
103
|
+
}
|
|
104
|
+
if (!productConfirmed) return {
|
|
105
|
+
eyebrow: '等待角色确认', title: '请产品确认当前版本', detail: participantRole === 'product' ? '正文已通过检查,确认它准确反映最终产品结论。' : '需要产品角色确认同一个当前版本。',
|
|
106
|
+
actionLabel: participantRole === 'product' ? '以产品身份确认' : '等待产品确认', command: participantRole === 'product' ? { kind: 'confirm', role: 'product' } : { kind: 'none' },
|
|
107
|
+
...(participantRole === 'product' ? {} : { disabled: true, disabledReason: '当前身份是研发,需由产品角色完成确认。' }),
|
|
108
|
+
}
|
|
109
|
+
if (!engineeringConfirmed) return {
|
|
110
|
+
eyebrow: '最后一步确认', title: '请研发确认当前版本', detail: participantRole === 'engineering' ? '确认实现边界、风险和测试约束已经足够明确。' : '需要研发角色确认同一个当前版本。',
|
|
111
|
+
actionLabel: participantRole === 'engineering' ? '以研发身份确认' : '等待研发确认', command: participantRole === 'engineering' ? { kind: 'confirm', role: 'engineering' } : { kind: 'none' },
|
|
112
|
+
...(participantRole === 'engineering' ? {} : { disabled: true, disabledReason: '当前身份是产品,需由研发角色完成确认。' }),
|
|
113
|
+
}
|
|
114
|
+
return {
|
|
115
|
+
eyebrow: '可以交付研发', title: '生成就绪需求', detail: '产品和研发已确认同一个版本,所有完成条件均已通过。',
|
|
116
|
+
actionLabel: '生成就绪需求', command: { kind: 'generate-ready' },
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return {
|
|
121
|
+
eyebrow: '需求已就绪', title: '这份需求可以进入研发', detail: '正文、确认人、关键决策和待验证项已固定在同一个版本中。',
|
|
122
|
+
actionLabel: '查看交付内容', command: { kind: 'open', view: 'ready' },
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export function friendlyActionError(error: string): string {
|
|
127
|
+
const messages: Array<[string, string]> = [
|
|
128
|
+
['product blocking review items remain', '还有阻塞问题未处理,请先完成待澄清事项。'],
|
|
129
|
+
['product second review is required', '需要先让 AI 根据回复整理并复核正文。'],
|
|
130
|
+
['product must confirm the current version', '需要产品角色确认当前版本后才能进入产研共审。'],
|
|
131
|
+
['readiness gate is not satisfied', '需求内容还没有满足全部交付条件,请查看缺少内容。'],
|
|
132
|
+
['current version needs product and engineering confirmation', '产品和研发需要分别确认同一个当前版本。'],
|
|
133
|
+
['review workspace is required', '请选择需求所在的项目。'],
|
|
134
|
+
['human participant is required', '这项操作需要由真实参与者完成。'],
|
|
135
|
+
['role is required', '当前身份角色不能执行这项确认。'],
|
|
136
|
+
]
|
|
137
|
+
return messages.find(([source]) => error.includes(source))?.[1] ?? error
|
|
138
|
+
}
|
package/src/engine.ts
CHANGED
|
@@ -355,4 +355,4 @@ export function readiness(markdown: string, record: RequirementRecord): Readines
|
|
|
355
355
|
{ key: 'test-constraints', passed: meaningful('测试约束'), reasons: meaningful('测试约束') ? [] : ['测试环境、账号、权限或 fixture 约束不完整'] },
|
|
356
356
|
]
|
|
357
357
|
}
|
|
358
|
-
function readyMarkdown(view: RequirementView): string { const open = view.reviewItems.filter(item => item.status === 'non-blocking-verify'); return [`#
|
|
358
|
+
function readyMarkdown(view: RequirementView): string { const open = view.reviewItems.filter(item => item.status === 'non-blocking-verify'); const sourceStatus = { available: '可查阅', unverified: '待核对', missing: '待补充' } as const; return [`# 就绪需求:${view.title}`, '', '## 版本信息', '', `- 需求编号:${view.id}`, `- 文档版本:${view.currentCommit}`, `- 产品确认:${view.confirmations.filter(item => item.role === 'product' && item.status === 'active').map(item => item.participant.nickname).join('、')}`, `- 研发确认:${view.confirmations.filter(item => item.role === 'engineering' && item.status === 'active').map(item => item.participant.nickname).join('、')}`, '', view.version.markdown, '', '## 已确认决策', ...view.decisions.filter(item => item.status === 'active').map(item => `- ${item.question}:${item.decision}(原因:${item.rationale})`), '', '## 参考资料', ...view.sources.map(source => `- [${sourceStatus[source.accessStatus]}] ${source.label}${source.stableId ? `:${source.stableId}` : ''}${source.version ? `(版本:${source.version})` : ''}`), '', '## 待确认问题', ...open.map(item => `- ${item.question};负责人:${item.ownerParticipantId ?? (item.ownerRole === 'product' ? '产品' : '研发')};影响:${item.impact}`), ''].join('\n') }
|
package/src/git-store.ts
CHANGED
|
@@ -129,5 +129,5 @@ function slug(title: string): string {
|
|
|
129
129
|
function assertRequirementId(value: string): void { if (!/^[a-z0-9\u4e00-\u9fff][a-z0-9\u4e00-\u9fff-]{1,80}$/.test(value)) throw new Error('invalid requirement id') }
|
|
130
130
|
function initialSpec(title: string, raw: string, sources: SourceReference[]): string {
|
|
131
131
|
const sourceLines = sources.length === 0 ? ['- 原始需求:当前文档(创建版本)'] : sources.map(item => `- [${item.accessStatus}] ${item.label}${item.stableId ? ` — ${item.stableId}` : ''}`)
|
|
132
|
-
return [`# ${title}`, '', '## 原始需求与来源', '', raw.trim(), '', ...sourceLines, '', '## 目标与用户结果', '', '<!-- AI 初审后补充 -->', '', '## 范围与非范围', '', '### 范围', '', '### 非范围', '', '## 业务术语与规则', '', '## 需求与验收标准', '', '- **AC-1**:待澄清', '', '## 异常、权限与兼容', '', '## 测试约束', '', '##
|
|
132
|
+
return [`# ${title}`, '', '## 原始需求与来源', '', raw.trim(), '', ...sourceLines, '', '## 目标与用户结果', '', '<!-- AI 初审后补充 -->', '', '## 范围与非范围', '', '### 范围', '', '### 非范围', '', '## 业务术语与规则', '', '## 需求与验收标准', '', '- **AC-1**:待澄清', '', '## 异常、权限与兼容', '', '## 测试约束', '', '## 待补充资料', ''].join('\n')
|
|
133
133
|
}
|
package/src/review-runtime.ts
CHANGED
|
@@ -89,13 +89,21 @@ function common(requirement: RequirementView, context: ReturnType<ReviewContextC
|
|
|
89
89
|
'You are a review worker for a requirements clarification product. You must not implement code, generate downstream test delivery, create worktrees, deploy, or mark the requirement Ready. AI output is proposal data only and requires human confirmation.',
|
|
90
90
|
'A FACT must cite an accessible, version-pinned source. If evidence is unavailable, use TO_VERIFY; never invent historical or implementation conflicts.',
|
|
91
91
|
'Use spec_read to retrieve the exact current data. Do not modify files directly.',
|
|
92
|
-
'每个 Review Item
|
|
92
|
+
'每个 Review Item 默认给出三个 recommendedOptions。每个选项只表达一个决定,使用“选择 + 直接结果”的短句,建议不超过 45 个汉字;三个选项必须有真实差异,不得只是“接受、拒绝、待验证”的同义改写。确有四种独立方案时才允许第四项。',
|
|
93
|
+
'Review Item 的 question 只问一个可以直接回答的问题,建议不超过 40 个汉字。背景放在 statement,后果放在 impact,不要把背景、问题和多个子问题挤进 question 或选项。',
|
|
94
|
+
'审核记录与正式文档必须分层:FACT / INFERENCE / ASSUMPTION / TO_VERIFY、commit SHA、run ID 等只用于结构化审核记录,不得堆入候选 Spec 正文。',
|
|
95
|
+
'候选 Spec 必须使用产品和研发都能直接理解的自然中文。避免行业黑话、审计腔和无必要的英文;英文缩写首次出现时必须同时写出中文含义,例如“行动按钮(CTA)”,后续优先使用中文。无法准确解释的缩写不要使用。',
|
|
96
|
+
'优先使用这些通俗说法:操作按钮(不用 CTA)、统一风格标识(不用 canonical key)、点赞(不用 like)、提示词(不用 prompt)、测试数据(不用 fixture)、最终判断依据(不用事实源)、完成状态(不用终态)、重复操作结果一致(不用幂等)。Upgrade、Download、Lite、Plus 等确为界面文案或套餐名时可保留,但首次出现要说明中文含义。',
|
|
97
|
+
'正文不要写“当前唯一可访问来源”“固定于某 commit”“统一记为 TO_VERIFY”这类过程说明。资料不足时,只在“待补充资料”章节按“资料名称:需要补充的内容;负责人(如已知)”列出,不重复背景、不写内部状态枚举。',
|
|
98
|
+
'每段只表达一个结论,优先使用短句和具体业务语言。删除不影响需求理解、研发实现或验收判断的元信息。',
|
|
99
|
+
'候选 patch 直接从文档标题开始,不写“本文为候选 patch”“不代表已确认决策”等免责声明。保留清晰的 Markdown 章节;身份与权限差异优先用表格,验收标准使用“前提 / 操作 / 预期结果”,不要使用 Given / When / Then。',
|
|
100
|
+
'合并重复内容:目标讲用户结果,范围只列做与不做,业务规则只定义规则,验收标准只写可验证场景。同一句规则不要再分别复制到目标、范围、术语、验收和风险章节。',
|
|
93
101
|
].join('\n')
|
|
94
102
|
}
|
|
95
103
|
function reviewPrompt(requirement: RequirementView, run: AiReviewRun, context: ReturnType<ReviewContextCatalog['resolve']>): string {
|
|
96
104
|
const tasks: Record<AiReviewRun['kind'], string> = {
|
|
97
|
-
'product-first': 'Perform the initial product review across goal, evidence, history-conflict, current-implementation, scope, semantics, completeness, acceptance, and risk. Submit structured findings with spec_submit_review. If the draft needs changes, also submit a candidate patch with spec_propose_patch.',
|
|
98
|
-
'product-second': 'Review product responses against their original Review Items. Do not close vague answers. Submit remaining/new findings with spec_submit_review and a reviewable candidate patch with spec_propose_patch.',
|
|
105
|
+
'product-first': 'Perform the initial product review across goal, evidence, history-conflict, current-implementation, scope, semantics, completeness, acceptance, and risk. Submit structured findings with spec_submit_review. If the draft needs changes, also submit a candidate patch with spec_propose_patch. The candidate document must follow the plain-language and audit-metadata separation rules above.',
|
|
106
|
+
'product-second': 'Review product responses against their original Review Items. Do not close vague answers. Submit remaining/new findings with spec_submit_review and a reviewable candidate patch with spec_propose_patch. Rewrite awkward inherited wording instead of copying internal review terminology into the document.',
|
|
99
107
|
'engineering-precheck': 'Read the product-confirmed Spec and inspect relevant current code/history available in the workspace. Find implementation fact conflicts, affected entries/roles/states, technical ambiguity, compatibility/permission/data boundaries, and unverifiable acceptance criteria. Submit with spec_submit_review and propose a patch only when needed.',
|
|
100
108
|
'change-review': 'Review only the latest saved commit against its parent. Identify materiality, affected sections/ACs, confirmations or decisions that need reconfirmation, and new conflicts. Submit with spec_submit_review; propose a patch only when needed.',
|
|
101
109
|
}
|
package/src/tools.ts
CHANGED
|
@@ -52,7 +52,7 @@ export function specSubmitReviewTool(engine: CollaborationEngine) {
|
|
|
52
52
|
requirementId: { type: 'string', required: true }, commit: { type: 'string', required: true }, runId: { type: 'string', required: true }, reviewKind: { type: 'string', required: true, enum: ['product-first', 'product-second', 'engineering-precheck', 'change-review'] },
|
|
53
53
|
nickname: { type: 'string', required: true }, role: { type: 'string', required: true, enum: ['product', 'engineering'] }, sessionId: { type: 'string', required: true }, maturitySummary: { type: 'string', required: true },
|
|
54
54
|
items: { type: 'array', required: true, items: { type: 'object', additionalProperties: false, properties: {
|
|
55
|
-
type: { type: 'string', required: true, enum: ['goal', 'evidence', 'history-conflict', 'current-implementation', 'scope', 'semantics', 'completeness', 'acceptance', 'risk'] }, severity: { type: 'string', required: true, enum: ['blocking', 'major', 'minor'] }, statement: { type: 'string', required: true }, epistemicStatus: { type: 'string', required: true, enum: ['FACT', 'INFERENCE', 'ASSUMPTION', 'TO_VERIFY'] }, impact: { type: 'string', required: true }, question: { type: 'string', required: true }, recommendedOptions: { type: 'array', required: true, items: { type: 'string' }, description: '
|
|
55
|
+
type: { type: 'string', required: true, enum: ['goal', 'evidence', 'history-conflict', 'current-implementation', 'scope', 'semantics', 'completeness', 'acceptance', 'risk'] }, severity: { type: 'string', required: true, enum: ['blocking', 'major', 'minor'] }, statement: { type: 'string', required: true }, epistemicStatus: { type: 'string', required: true, enum: ['FACT', 'INFERENCE', 'ASSUMPTION', 'TO_VERIFY'] }, impact: { type: 'string', required: true }, question: { type: 'string', required: true, description: '只问一个可直接回答的问题,使用简洁中文。' }, recommendedOptions: { type: 'array', required: true, items: { type: 'string' }, description: '默认三个、最多四个互有取舍的中文选项;每项只表达一个决定,建议不超过 45 个汉字。' }, affectedSections: { type: 'array', required: true, items: { type: 'string' } }, affectedAcceptanceIds: { type: 'array', required: true, items: { type: 'string' } }, ownerRole: { type: 'string', required: true, enum: ['product', 'engineering'] }, status: { type: 'string', required: true, enum: ['open', 'joint-review', 'non-blocking-verify'] }, evidence: { type: 'array', required: true, items: { type: 'object', additionalProperties: false, properties: { statement: { type: 'string', required: true }, source: { type: 'string', required: true }, version: { type: 'string' }, accessible: { type: 'boolean', required: true } } } },
|
|
56
56
|
} } },
|
|
57
57
|
},
|
|
58
58
|
output: contentOutput('Review submission result.'),
|
|
@@ -60,6 +60,9 @@ export function specSubmitReviewTool(engine: CollaborationEngine) {
|
|
|
60
60
|
for (const item of args.items) {
|
|
61
61
|
const options = item.recommendedOptions.map(option => option.trim()).filter(Boolean)
|
|
62
62
|
if (options.length < 3 || new Set(options).size < 3) throw new Error('each review item requires at least three distinct recommended options')
|
|
63
|
+
if (options.length > 4) throw new Error('each review item allows at most four recommended options')
|
|
64
|
+
if (options.some(option => [...option].length > 60)) throw new Error('recommended options must be concise (60 characters maximum)')
|
|
65
|
+
if ([...item.question.trim()].length > 80) throw new Error('review questions must be concise (80 characters maximum)')
|
|
63
66
|
if (item.epistemicStatus === 'FACT' && !item.evidence.some(evidence => evidence.accessible && typeof evidence.version === 'string' && evidence.version !== '')) throw new Error('FACT requires accessible versioned evidence')
|
|
64
67
|
}
|
|
65
68
|
engine.submitReview({ requirementId: args.requirementId, commit: args.commit, runId: args.runId, ai: ai(args.nickname, args.role as ParticipantRole, args.sessionId), maturitySummary: args.maturitySummary, items: args.items.map(item => ({ type: item.type as ReviewItemType, severity: item.severity as Severity, statement: item.statement, evidence: item.evidence, epistemicStatus: item.epistemicStatus as EpistemicStatus, impact: item.impact, question: item.question, recommendedOptions: item.recommendedOptions, affectedSections: item.affectedSections, affectedAcceptanceIds: item.affectedAcceptanceIds, ownerRole: item.ownerRole as ParticipantRole, status: item.status as ReviewItemStatus })) })
|
|
@@ -70,10 +73,10 @@ export function specSubmitReviewTool(engine: CollaborationEngine) {
|
|
|
70
73
|
|
|
71
74
|
export function specProposePatchTool(engine: CollaborationEngine) {
|
|
72
75
|
return defineTool({
|
|
73
|
-
name: 'spec_propose_patch', description: 'Propose a complete
|
|
76
|
+
name: 'spec_propose_patch', description: 'Propose a complete, plain-language Chinese Markdown Spec. Keep audit metadata in review records, not in the document. This creates a reviewable candidate only; it never writes Git.',
|
|
74
77
|
parameters: { requirementId: { type: 'string', required: true }, baseCommit: { type: 'string', required: true }, reviewKind: { type: 'string', required: true, enum: ['product-first', 'product-second', 'engineering-precheck', 'change-review'] }, proposedMarkdown: { type: 'string', required: true }, summary: { type: 'string', required: true }, affectedReviewItemIds: { type: 'array', required: true, items: { type: 'string' } }, affectedSections: { type: 'array', required: true, items: { type: 'string' } }, affectedAcceptanceIds: { type: 'array', required: true, items: { type: 'string' } }, nickname: { type: 'string', required: true }, role: { type: 'string', required: true, enum: ['product', 'engineering'] }, sessionId: { type: 'string', required: true } },
|
|
75
78
|
output: contentOutput('Patch proposal result.'),
|
|
76
|
-
async execute(args) { engine.submitPatch({ requirementId: args.requirementId, baseCommit: args.baseCommit, reviewKind: args.reviewKind as ReviewKind, ai: ai(args.nickname, args.role as ParticipantRole, args.sessionId), proposedMarkdown: args.proposedMarkdown, summary: args.summary, affectedReviewItemIds: args.affectedReviewItemIds, affectedSections: args.affectedSections, affectedAcceptanceIds: args.affectedAcceptanceIds }); return { content: `candidate patch proposed for ${args.baseCommit}` } },
|
|
79
|
+
async execute(args) { if (/\b(?:FACT|INFERENCE|ASSUMPTION|TO_VERIFY)\b/.test(args.proposedMarkdown)) throw new Error('candidate Spec must not contain internal evidence status enums'); if (/^\s*本文为.{0,30}候选\s*patch/i.test(args.proposedMarkdown)) throw new Error('candidate Spec must start with its document title, not a candidate disclaimer'); if (/\b(?:Given|When|Then)\b/.test(args.proposedMarkdown)) throw new Error('candidate Spec acceptance criteria must use 前提 / 操作 / 预期结果'); engine.submitPatch({ requirementId: args.requirementId, baseCommit: args.baseCommit, reviewKind: args.reviewKind as ReviewKind, ai: ai(args.nickname, args.role as ParticipantRole, args.sessionId), proposedMarkdown: args.proposedMarkdown, summary: args.summary, affectedReviewItemIds: args.affectedReviewItemIds, affectedSections: args.affectedSections, affectedAcceptanceIds: args.affectedAcceptanceIds }); return { content: `candidate patch proposed for ${args.baseCommit}` } },
|
|
77
80
|
})
|
|
78
81
|
}
|
|
79
82
|
|