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/index.js CHANGED
@@ -233,7 +233,7 @@ function initialSpec(title, raw, sources) {
233
233
  "",
234
234
  "## 测试约束",
235
235
  "",
236
- "## 非阻塞 Open Questions",
236
+ "## 待补充资料",
237
237
  ""
238
238
  ].join("\n");
239
239
  }
@@ -1031,24 +1031,31 @@ function readiness(markdown, record) {
1031
1031
  }
1032
1032
  function readyMarkdown(view) {
1033
1033
  const open = view.reviewItems.filter((item) => item.status === "non-blocking-verify");
1034
+ const sourceStatus = {
1035
+ available: "可查阅",
1036
+ unverified: "待核对",
1037
+ missing: "待补充"
1038
+ };
1034
1039
  return [
1035
- `# Ready Spec:${view.title}`,
1040
+ `# 就绪需求:${view.title}`,
1041
+ "",
1042
+ "## 版本信息",
1036
1043
  "",
1037
- `- 需求 ID:${view.id}`,
1038
- `- Commit:${view.currentCommit}`,
1044
+ `- 需求编号:${view.id}`,
1045
+ `- 文档版本:${view.currentCommit}`,
1039
1046
  `- 产品确认:${view.confirmations.filter((item) => item.role === "product" && item.status === "active").map((item) => item.participant.nickname).join("、")}`,
1040
1047
  `- 研发确认:${view.confirmations.filter((item) => item.role === "engineering" && item.status === "active").map((item) => item.participant.nickname).join("、")}`,
1041
1048
  "",
1042
1049
  view.version.markdown,
1043
1050
  "",
1044
- "## Decisions",
1045
- ...view.decisions.filter((item) => item.status === "active").map((item) => `- ${item.question}:${item.decision}(${item.rationale})`),
1051
+ "## 已确认决策",
1052
+ ...view.decisions.filter((item) => item.status === "active").map((item) => `- ${item.question}:${item.decision}(原因:${item.rationale})`),
1046
1053
  "",
1047
- "## 证据来源与版本",
1048
- ...view.sources.map((source) => `- [${source.accessStatus}] ${source.label}${source.stableId ? ` — ${source.stableId}` : ""}${source.version ? ` @ ${source.version}` : ""}`),
1054
+ "## 参考资料",
1055
+ ...view.sources.map((source) => `- [${sourceStatus[source.accessStatus]}] ${source.label}${source.stableId ? `:${source.stableId}` : ""}${source.version ? `(版本:${source.version})` : ""}`),
1049
1056
  "",
1050
- "## 非阻塞 Open Questions",
1051
- ...open.map((item) => `- ${item.question};负责人:${item.ownerParticipantId ?? item.ownerRole};影响:${item.impact}`),
1057
+ "## 待确认问题",
1058
+ ...open.map((item) => `- ${item.question};负责人:${item.ownerParticipantId ?? (item.ownerRole === "product" ? "产品" : "研发")};影响:${item.impact}`),
1052
1059
  ""
1053
1060
  ].join("\n");
1054
1061
  }
@@ -1245,7 +1252,15 @@ function common(requirement, context) {
1245
1252
  "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.",
1246
1253
  "A FACT must cite an accessible, version-pinned source. If evidence is unavailable, use TO_VERIFY; never invent historical or implementation conflicts.",
1247
1254
  "Use spec_read to retrieve the exact current data. Do not modify files directly.",
1248
- "每个 Review Item 必须给出至少三个具体、互斥或有明确取舍差异的 recommendedOptions,供用户快速选择;不得只重复“接受、拒绝、待验证”这类通用状态。"
1255
+ "每个 Review Item 默认给出三个 recommendedOptions。每个选项只表达一个决定,使用“选择 + 直接结果”的短句,建议不超过 45 个汉字;三个选项必须有真实差异,不得只是“接受、拒绝、待验证”的同义改写。确有四种独立方案时才允许第四项。",
1256
+ "Review Item 的 question 只问一个可以直接回答的问题,建议不超过 40 个汉字。背景放在 statement,后果放在 impact,不要把背景、问题和多个子问题挤进 question 或选项。",
1257
+ "审核记录与正式文档必须分层:FACT / INFERENCE / ASSUMPTION / TO_VERIFY、commit SHA、run ID 等只用于结构化审核记录,不得堆入候选 Spec 正文。",
1258
+ "候选 Spec 必须使用产品和研发都能直接理解的自然中文。避免行业黑话、审计腔和无必要的英文;英文缩写首次出现时必须同时写出中文含义,例如“行动按钮(CTA)”,后续优先使用中文。无法准确解释的缩写不要使用。",
1259
+ "优先使用这些通俗说法:操作按钮(不用 CTA)、统一风格标识(不用 canonical key)、点赞(不用 like)、提示词(不用 prompt)、测试数据(不用 fixture)、最终判断依据(不用事实源)、完成状态(不用终态)、重复操作结果一致(不用幂等)。Upgrade、Download、Lite、Plus 等确为界面文案或套餐名时可保留,但首次出现要说明中文含义。",
1260
+ "正文不要写“当前唯一可访问来源”“固定于某 commit”“统一记为 TO_VERIFY”这类过程说明。资料不足时,只在“待补充资料”章节按“资料名称:需要补充的内容;负责人(如已知)”列出,不重复背景、不写内部状态枚举。",
1261
+ "每段只表达一个结论,优先使用短句和具体业务语言。删除不影响需求理解、研发实现或验收判断的元信息。",
1262
+ "候选 patch 直接从文档标题开始,不写“本文为候选 patch”“不代表已确认决策”等免责声明。保留清晰的 Markdown 章节;身份与权限差异优先用表格,验收标准使用“前提 / 操作 / 预期结果”,不要使用 Given / When / Then。",
1263
+ "合并重复内容:目标讲用户结果,范围只列做与不做,业务规则只定义规则,验收标准只写可验证场景。同一句规则不要再分别复制到目标、范围、术语、验收和风险章节。"
1249
1264
  ].join("\n");
1250
1265
  }
1251
1266
  function reviewPrompt(requirement, run, context) {
@@ -1256,8 +1271,8 @@ function reviewPrompt(requirement, run, context) {
1256
1271
  `AI session ID: {{SESSION_ID}}`,
1257
1272
  "",
1258
1273
  {
1259
- "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.",
1260
- "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.",
1274
+ "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.",
1275
+ "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.",
1261
1276
  "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.",
1262
1277
  "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."
1263
1278
  }[run.kind]
@@ -1756,13 +1771,14 @@ function specSubmitReviewTool(engine) {
1756
1771
  },
1757
1772
  question: {
1758
1773
  type: "string",
1759
- required: true
1774
+ required: true,
1775
+ description: "只问一个可直接回答的问题,使用简洁中文。"
1760
1776
  },
1761
1777
  recommendedOptions: {
1762
1778
  type: "array",
1763
1779
  required: true,
1764
1780
  items: { type: "string" },
1765
- description: "至少三个可直接供用户选择的具体中文建议,不得只是同义改写。"
1781
+ description: "默认三个、最多四个互有取舍的中文选项;每项只表达一个决定,建议不超过 45 个汉字。"
1766
1782
  },
1767
1783
  affectedSections: {
1768
1784
  type: "array",
@@ -1820,6 +1836,9 @@ function specSubmitReviewTool(engine) {
1820
1836
  for (const item of args.items) {
1821
1837
  const options = item.recommendedOptions.map((option) => option.trim()).filter(Boolean);
1822
1838
  if (options.length < 3 || new Set(options).size < 3) throw new Error("each review item requires at least three distinct recommended options");
1839
+ if (options.length > 4) throw new Error("each review item allows at most four recommended options");
1840
+ if (options.some((option) => [...option].length > 60)) throw new Error("recommended options must be concise (60 characters maximum)");
1841
+ if ([...item.question.trim()].length > 80) throw new Error("review questions must be concise (80 characters maximum)");
1823
1842
  if (item.epistemicStatus === "FACT" && !item.evidence.some((evidence) => evidence.accessible && typeof evidence.version === "string" && evidence.version !== "")) throw new Error("FACT requires accessible versioned evidence");
1824
1843
  }
1825
1844
  engine.submitReview({
@@ -1850,7 +1869,7 @@ function specSubmitReviewTool(engine) {
1850
1869
  function specProposePatchTool(engine) {
1851
1870
  return defineTool({
1852
1871
  name: "spec_propose_patch",
1853
- description: "Propose a complete revised Markdown Spec against an exact base commit. This creates a reviewable candidate only; it never writes Git.",
1872
+ 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.",
1854
1873
  parameters: {
1855
1874
  requirementId: {
1856
1875
  type: "string",
@@ -1909,6 +1928,9 @@ function specProposePatchTool(engine) {
1909
1928
  },
1910
1929
  output: contentOutput("Patch proposal result."),
1911
1930
  async execute(args) {
1931
+ if (/\b(?:FACT|INFERENCE|ASSUMPTION|TO_VERIFY)\b/.test(args.proposedMarkdown)) throw new Error("candidate Spec must not contain internal evidence status enums");
1932
+ 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");
1933
+ if (/\b(?:Given|When|Then)\b/.test(args.proposedMarkdown)) throw new Error("candidate Spec acceptance criteria must use 前提 / 操作 / 预期结果");
1912
1934
  engine.submitPatch({
1913
1935
  requirementId: args.requirementId,
1914
1936
  baseCommit: args.baseCommit,
@@ -1 +1 @@
1
- {"version":3,"file":"SpecWorkbench.d.ts","sourceRoot":"","sources":["../../../src/client/SpecWorkbench.tsx"],"names":[],"mappings":"AAGA,OAAO,kCAAkC,CAAA;AAGzC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAiCvC,wBAAgB,aAAa,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE;IAAE,GAAG,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,IAAI,CAAA;CAAE,+BA0IpF"}
1
+ {"version":3,"file":"SpecWorkbench.d.ts","sourceRoot":"","sources":["../../../src/client/SpecWorkbench.tsx"],"names":[],"mappings":"AAGA,OAAO,kCAAkC,CAAA;AAGzC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAiCvC,wBAAgB,aAAa,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE;IAAE,GAAG,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,IAAI,CAAA;CAAE,+BAoKpF"}
@@ -0,0 +1,32 @@
1
+ import type { ParticipantRole, RequirementView, ReviewKind } from '../protocol.ts';
2
+ export type TaskView = 'review' | 'patches' | 'ready';
3
+ export type WorkflowCommand = {
4
+ kind: 'open';
5
+ view: TaskView;
6
+ } | {
7
+ kind: 'bind-workspace';
8
+ } | {
9
+ kind: 'request-review';
10
+ reviewKind: ReviewKind;
11
+ } | {
12
+ kind: 'advance';
13
+ } | {
14
+ kind: 'confirm';
15
+ role: ParticipantRole;
16
+ } | {
17
+ kind: 'generate-ready';
18
+ } | {
19
+ kind: 'none';
20
+ };
21
+ export interface WorkflowState {
22
+ eyebrow: string;
23
+ title: string;
24
+ detail: string;
25
+ actionLabel: string;
26
+ command: WorkflowCommand;
27
+ disabled?: boolean;
28
+ disabledReason?: string;
29
+ }
30
+ export declare function workflowState(requirement: RequirementView, participantRole: ParticipantRole): WorkflowState;
31
+ export declare function friendlyActionError(error: string): string;
32
+ //# sourceMappingURL=workflow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow.d.ts","sourceRoot":"","sources":["../../../src/client/workflow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAElF,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,OAAO,CAAA;AACrD,MAAM,MAAM,eAAe,GACvB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,QAAQ,CAAA;CAAE,GAChC;IAAE,IAAI,EAAE,gBAAgB,CAAA;CAAE,GAC1B;IAAE,IAAI,EAAE,gBAAgB,CAAC;IAAC,UAAU,EAAE,UAAU,CAAA;CAAE,GAClD;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,GACnB;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,eAAe,CAAA;CAAE,GAC1C;IAAE,IAAI,EAAE,gBAAgB,CAAA;CAAE,GAC1B;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAA;AAEpB,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,MAAM,CAAA;IACnB,OAAO,EAAE,eAAe,CAAA;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB;AAID,wBAAgB,aAAa,CAAC,WAAW,EAAE,eAAe,EAAE,eAAe,EAAE,eAAe,GAAG,aAAa,CAmG3G;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAYzD"}
@@ -1 +1 @@
1
- {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/tools.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAOjD,wBAAgB,YAAY,CAAC,MAAM,EAAE,mBAAmB,mDAMvD;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,mBAAmB,mDAmBvD;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,mBAAmB,mDAOxD;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,mBAAmB,mDAqB/D;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,mBAAmB,mDAO/D;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,mBAAmB,qDAA4I"}
1
+ {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/tools.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAOjD,wBAAgB,YAAY,CAAC,MAAM,EAAE,mBAAmB,mDAMvD;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,mBAAmB,mDAmBvD;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,mBAAmB,mDAOxD;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,mBAAmB,mDAwB/D;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,mBAAmB,mDAO/D;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,mBAAmB,qDAA4I"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-spec-collab",
3
- "version": "0.1.5",
3
+ "version": "0.2.0",
4
4
  "description": "AI-assisted requirement clarification and Git-backed Spec co-creation for DeepSeek Harness, ending at a human-confirmed Ready Spec.",
5
5
  "keywords": [
6
6
  "deepseek-harness",