@yiyi_zhang/laoshi 0.2.0-beta.3 → 0.3.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.
Files changed (139) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/README.md +3 -2
  3. package/adapters/dsh/adapter.ts +22 -1
  4. package/adapters/dsh/dsh-runtime.ts +14 -3
  5. package/adapters/dsh/install.mjs +16 -4
  6. package/adapters/dsh/plugin/index.mjs +197 -18
  7. package/adapters/dsh/plugin/package.json +1 -1
  8. package/adapters/mogao/adapter.ts +10 -1
  9. package/adapters/mogao/mogao-runtime.ts +58 -23
  10. package/adapters/mogao/skill/setup.md +6 -0
  11. package/adapters/paseo/install.mjs +13 -4
  12. package/adapters/paseo/plugin/client/data.ts +13 -2
  13. package/adapters/paseo/plugin/client/detail.tsx +244 -4
  14. package/adapters/paseo/plugin/client/format.ts +25 -117
  15. package/adapters/paseo/plugin/client/overview.tsx +3 -3
  16. package/adapters/paseo/plugin/index.server.ts +2 -1
  17. package/adapters/paseo/plugin/package.json +1 -1
  18. package/adapters/paseo/plugin/paseo-plugin.json +1 -1
  19. package/adapters/paseo/plugin/server/handlers.ts +22 -4
  20. package/adapters/paseo/plugin/server/req.ts +17 -4
  21. package/adapters/paseo/plugin/shared/contracts.ts +28 -2
  22. package/adapters/paseo/plugin/shared/view-model.ts +425 -0
  23. package/bin/ensure-version.mjs +60 -0
  24. package/bin/req-doctor.mjs +5 -0
  25. package/bin/req.mjs +18 -0
  26. package/bin/start-pipeline.mjs +5 -0
  27. package/contracts/cli-json.md +3 -1
  28. package/docs/design/builtin-capabilities.md +2 -2
  29. package/docs/design/cli-adapter.md +1 -1
  30. package/docs/design/dsh-adapter.md +11 -11
  31. package/docs/design/shared-ui.md +43 -0
  32. package/docs/guide//345/234/250/346/221/270/351/253/230/344/270/212/344/275/277/347/224/250.md +2 -1
  33. package/docs/guide//345/256/211/350/243/205/344/270/216/345/215/207/347/272/247.md +13 -8
  34. package/docs/guide//347/234/237/345/256/236/347/216/257/345/242/203/350/265/260/346/237/245.md +78 -0
  35. package/docs/guide//347/273/264/346/212/244/350/200/205/346/214/207/345/215/227.md +36 -6
  36. package/engine/prompts/00-shared-context.md +7 -0
  37. package/engine/prompts/03-design.md +2 -0
  38. package/engine/prompts/04-design-review.md +5 -1
  39. package/engine/skill-fragments/defaults.md +5 -0
  40. package/engine/src/api.ts +11 -2
  41. package/engine/src/board.ts +435 -0
  42. package/engine/src/config.ts +23 -0
  43. package/engine/src/diagnose.ts +238 -0
  44. package/engine/src/doctor.ts +25 -0
  45. package/engine/src/estimate.ts +11 -0
  46. package/engine/src/extensions.ts +271 -0
  47. package/engine/src/handover-cmd.ts +47 -0
  48. package/engine/src/handover.ts +89 -0
  49. package/engine/src/history.ts +102 -0
  50. package/engine/src/joint.ts +49 -4
  51. package/engine/src/launch.ts +20 -5
  52. package/engine/src/main.ts +1 -1
  53. package/engine/src/messages.ts +58 -0
  54. package/engine/src/pipeline.ts +121 -5
  55. package/engine/src/platform.ts +6 -0
  56. package/engine/src/reply.ts +27 -6
  57. package/engine/src/semver.ts +21 -0
  58. package/engine/src/skills-render.ts +10 -1
  59. package/package.json +5 -2
  60. package/site-dist/404.html +2 -2
  61. package/site-dist/assets/{app.CXydUhZx.js → app.DZpVs0VH.js} +1 -1
  62. package/site-dist/assets/changelog.md.CdUYbro4.js +1 -0
  63. package/site-dist/assets/{changelog.md.BU-CvyJ1.lean.js → changelog.md.CdUYbro4.lean.js} +1 -1
  64. package/site-dist/assets/chunks/@localSearchIndexroot.CHr-ITwS.js +1 -0
  65. package/site-dist/assets/chunks/{VPLocalSearchBox.CIjDV0ax.js → VPLocalSearchBox.BHkmziy1.js} +1 -1
  66. package/site-dist/assets/chunks/{theme.CWtC1Kby.js → theme.BsPChbDE.js} +2 -2
  67. package/site-dist/assets/guide_dsh.md.D0XhcUHz.js +7 -0
  68. package/site-dist/assets/guide_dsh.md.D0XhcUHz.lean.js +7 -0
  69. package/site-dist/assets/{guide_getting-started.md.BxOxfic_.js → guide_getting-started.md.BDd3nU5n.js} +1 -1
  70. package/site-dist/assets/{guide_install.md.By4WxsJG.js → guide_install.md.SsIHMfUu.js} +7 -5
  71. package/site-dist/assets/{guide_install.md.By4WxsJG.lean.js → guide_install.md.SsIHMfUu.lean.js} +7 -5
  72. package/site-dist/assets/guide_maintainer.md.CvqvRle1.js +1 -0
  73. package/site-dist/assets/guide_maintainer.md.CvqvRle1.lean.js +1 -0
  74. package/site-dist/assets/{guide_mogao.md.S0eln1Pr.js → guide_mogao.md.TCu3lgE9.js} +2 -2
  75. package/site-dist/assets/{guide_mogao.md.S0eln1Pr.lean.js → guide_mogao.md.TCu3lgE9.lean.js} +2 -2
  76. package/site-dist/assets/guide_walkthrough.md.nj_PWP9Y.js +5 -0
  77. package/site-dist/assets/guide_walkthrough.md.nj_PWP9Y.lean.js +5 -0
  78. package/site-dist/assets/reference_contracts_cli-json.md.3iU9h4rw.js +1 -0
  79. package/site-dist/assets/reference_contracts_cli-json.md.3iU9h4rw.lean.js +1 -0
  80. package/site-dist/assets/{reference_design_builtin-capabilities.md.CZYtjo_v.js → reference_design_builtin-capabilities.md.k5NXkESv.js} +2 -2
  81. package/site-dist/assets/{reference_design_builtin-capabilities.md.CZYtjo_v.lean.js → reference_design_builtin-capabilities.md.k5NXkESv.lean.js} +2 -2
  82. package/site-dist/assets/{reference_design_cli-adapter.md.pJy3x6Un.js → reference_design_cli-adapter.md.C1lcDATP.js} +1 -1
  83. package/site-dist/assets/{reference_design_cli-adapter.md.pJy3x6Un.lean.js → reference_design_cli-adapter.md.C1lcDATP.lean.js} +1 -1
  84. package/site-dist/changelog.html +5 -5
  85. package/site-dist/guide/cli.html +4 -4
  86. package/site-dist/guide/dsh.html +8 -6
  87. package/site-dist/guide/getting-started.html +5 -5
  88. package/site-dist/guide/how-it-works.html +4 -4
  89. package/site-dist/guide/index.html +4 -4
  90. package/site-dist/guide/install.html +11 -9
  91. package/site-dist/guide/intranet.html +4 -4
  92. package/site-dist/guide/maintainer.html +5 -5
  93. package/site-dist/guide/mogao.html +7 -7
  94. package/site-dist/guide/phases.html +4 -4
  95. package/site-dist/guide/project.html +4 -4
  96. package/site-dist/guide/user.html +4 -4
  97. package/site-dist/guide/walkthrough.html +34 -0
  98. package/site-dist/hashmap.json +1 -1
  99. package/site-dist/index.html +4 -4
  100. package/site-dist/reference/adr/0001-new-repo-core-and-adapters.html +4 -4
  101. package/site-dist/reference/adr/0002-two-orchestration-modes.html +4 -4
  102. package/site-dist/reference/adr/0003-generate-once-then-lock.html +4 -4
  103. package/site-dist/reference/adr/0004-external-contracts-stay-stable.html +4 -4
  104. package/site-dist/reference/adr/0005-skill-names.html +4 -4
  105. package/site-dist/reference/adr/0006-deterministic-engine-platform-capabilities.html +4 -4
  106. package/site-dist/reference/adr/0007-one-install-many-repos.html +4 -4
  107. package/site-dist/reference/adr/0008-capability-sources-and-platform-plugin.html +4 -4
  108. package/site-dist/reference/adr/index.html +4 -4
  109. package/site-dist/reference/commands.html +4 -4
  110. package/site-dist/reference/config.html +4 -4
  111. package/site-dist/reference/contracts/agent-runtime.html +4 -4
  112. package/site-dist/reference/contracts/cli-json.html +5 -5
  113. package/site-dist/reference/contracts/feature-files.html +4 -4
  114. package/site-dist/reference/contracts/index.html +4 -4
  115. package/site-dist/reference/contracts/notifier-event.html +4 -4
  116. package/site-dist/reference/contracts/result-file.html +4 -4
  117. package/site-dist/reference/contracts/spec.html +4 -4
  118. package/site-dist/reference/contracts/state.html +4 -4
  119. package/site-dist/reference/contracts/usage-record.html +4 -4
  120. package/site-dist/reference/contracts/verify.html +4 -4
  121. package/site-dist/reference/design/adapter-guide.html +4 -4
  122. package/site-dist/reference/design/architecture.html +4 -4
  123. package/site-dist/reference/design/builtin-capabilities.html +6 -6
  124. package/site-dist/reference/design/cli-adapter.html +5 -5
  125. package/site-dist/reference/design/platform-vocabulary.html +4 -4
  126. package/site-dist/reference/scope.html +4 -4
  127. package/skills/laoshi/SKILL.md +1 -3
  128. package/skills/laoshi-setup/SKILL.md +1 -1
  129. package/ui/shared/view-model.ts +424 -0
  130. package/ui/web/board.ts +1126 -0
  131. package/site-dist/assets/changelog.md.BU-CvyJ1.js +0 -1
  132. package/site-dist/assets/chunks/@localSearchIndexroot.CfgJeQRO.js +0 -1
  133. package/site-dist/assets/guide_dsh.md.0X-eYB87.js +0 -5
  134. package/site-dist/assets/guide_dsh.md.0X-eYB87.lean.js +0 -5
  135. package/site-dist/assets/guide_maintainer.md.Da1ffqxm.js +0 -1
  136. package/site-dist/assets/guide_maintainer.md.Da1ffqxm.lean.js +0 -1
  137. package/site-dist/assets/reference_contracts_cli-json.md.D6vfWOD9.js +0 -1
  138. package/site-dist/assets/reference_contracts_cli-json.md.D6vfWOD9.lean.js +0 -1
  139. /package/site-dist/assets/{guide_getting-started.md.BxOxfic_.lean.js → guide_getting-started.md.BDd3nU5n.lean.js} +0 -0
@@ -0,0 +1,425 @@
1
+ // Generated from ui/shared/view-model.ts by scripts/sync-ui-shared.mjs — do not edit directly.
2
+ // Platform-agnostic UI view-model shared by Paseo (React Native), dsh (Web plugin),
3
+ // and local web views. Zero DOM, zero React Native, zero Node imports.
4
+
5
+ export type Attention = "approval" | "business" | "permission" | "interrupted" | "not_completed" | "not_started" | null;
6
+
7
+ export type Group = "attention" | "running" | "verify" | "done" | "other";
8
+
9
+ export type ActionKind = "approve" | "stop" | "resume" | "verify" | "sync" | "start" | "reply";
10
+
11
+ export type Tone = "needs" | "running" | "success" | "warning" | "danger" | "muted";
12
+
13
+ export type Urgency = "normal" | "elevated" | "urgent";
14
+
15
+ export interface RequirementWaiting {
16
+ since: string;
17
+ reason?: string | null;
18
+ questions: string[];
19
+ canReply?: boolean;
20
+ card?: { system: string; id: string; requester?: string | null } | null;
21
+ }
22
+
23
+ export interface RequirementView {
24
+ key: string;
25
+ repo: string;
26
+ sourceRepo?: string | null;
27
+ project: string;
28
+ featureDir: string;
29
+ title: string;
30
+ branch?: string | null;
31
+ type: string | null;
32
+ profile: string | null;
33
+ stage: string;
34
+ status: string | null;
35
+ attention: Attention;
36
+ running: boolean;
37
+ updatedAt: string;
38
+ startedBy?: string | null;
39
+ owner?: string | null;
40
+ hasPrototype?: boolean;
41
+ current: Array<{ key: string; title?: string }>;
42
+ waiting?: RequirementWaiting | null;
43
+ external?: Array<{ pending: number; id: string | null }>;
44
+ jointCount?: number;
45
+ }
46
+
47
+ export const ATTENTION_LABELS: Record<Exclude<Attention, null>, string> = {
48
+ approval: "等待确认方案",
49
+ business: "等待需求方决定",
50
+ permission: "等待批准权限",
51
+ interrupted: "已中断,可以继续",
52
+ not_completed: "结束但未完成",
53
+ not_started: "已确认,未开始开发",
54
+ };
55
+
56
+ export const TYPE_LABELS: Record<string, string> = {
57
+ defect: "缺陷",
58
+ refactor: "重构",
59
+ assessment: "评估",
60
+ };
61
+
62
+ export const PROFILE_LABELS: Record<string, string> = {
63
+ quick: "快速档",
64
+ standard: "标准档",
65
+ };
66
+
67
+ export const GROUP_ORDER: Group[] = ["attention", "running", "verify", "done", "other"];
68
+
69
+ export const GROUP_LABELS: Record<Group, string> = {
70
+ attention: "需要你处理",
71
+ running: "进行中",
72
+ verify: "研发完成,待测试验证",
73
+ done: "最近完成",
74
+ other: "其他",
75
+ };
76
+
77
+ export const GROUP_EYEBROWS: Record<Group, string> = {
78
+ attention: "需要你处理",
79
+ running: "进行中",
80
+ verify: "待测试验证",
81
+ done: "最近完成",
82
+ other: "其他",
83
+ };
84
+
85
+ export const ACTION_TEXT: Record<ActionKind, { label: string; confirm: string }> = {
86
+ approve: { label: "确认方案", confirm: "确认 preview.md 中的方案,开始写代码?请先看过确认预览和原型。" },
87
+ stop: { label: "停止", confirm: "停止这个需求的流水线?正在运行的步骤会被中断,之后可以继续。" },
88
+ start: { label: "开始开发", confirm: "按已确认的需求说明开始开发?在项目主目录中的需求会新建自己的工作区。" },
89
+ resume: { label: "继续", confirm: "从中断处继续?需求说明改过的话,只处理变化的部分。" },
90
+ verify: { label: "开始测试验证", confirm: "开始测试验证?选择在哪里验证。" },
91
+ sync: { label: "同步到外部系统", confirm: "把这个需求同步到对接的外部系统:补发没有成功的调用、补建卡片、更新状态。" },
92
+ reply: { label: "发送回复", confirm: "把回复转给这个需求的对话,由它更新需求说明并继续开发。" },
93
+ };
94
+
95
+ const RECENT_MS = 14 * 24 * 3600_000;
96
+ const ELEVATED_WAIT_MS = 4 * 3600_000;
97
+ const URGENT_WAIT_MS = 24 * 3600_000;
98
+
99
+ export function groupOf(r: Pick<RequirementView, "attention" | "running" | "status" | "updatedAt">, now = Date.now()): Group {
100
+ if (r.attention) return "attention";
101
+ if (r.running) return "running";
102
+ if (r.status === "phase_done") return "verify";
103
+ if (r.status === "completed" && now - Date.parse(r.updatedAt) < RECENT_MS) return "done";
104
+ return "other";
105
+ }
106
+
107
+ export function minutes(m: number): string {
108
+ if (m < 1) return "不到 1 分钟";
109
+ if (m < 60) return `${Math.round(m)} 分钟`;
110
+ const h = Math.floor(m / 60);
111
+ const rest = Math.round(m % 60);
112
+ return rest === 0 ? `${h} 小时` : `${h} 小时 ${rest} 分`;
113
+ }
114
+
115
+ export function ago(iso: string, now = Date.now()): string {
116
+ const m = (now - Date.parse(iso)) / 60_000;
117
+ if (!Number.isFinite(m)) return "";
118
+ if (m < 1) return "刚刚";
119
+ if (m < 60) return `${Math.round(m)} 分钟前`;
120
+ if (m < 24 * 60) return `${Math.round(m / 60)} 小时前`;
121
+ return `${Math.round(m / 60 / 24)} 天前`;
122
+ }
123
+
124
+ export function waited(since: string, now = Date.now()): string {
125
+ const m = (now - Date.parse(since)) / 60_000;
126
+ if (!Number.isFinite(m) || m < 1) return "刚刚";
127
+ if (m < 60) return `等了 ${Math.round(m)} 分钟`;
128
+ if (m < 48 * 60) return `等了 ${Math.round(m / 60)} 小时`;
129
+ return `等了 ${Math.round(m / 60 / 24)} 天`;
130
+ }
131
+
132
+ export function urgencyOf(since: string, now = Date.now()): Urgency {
133
+ const ms = now - Date.parse(since);
134
+ if (!Number.isFinite(ms) || ms < ELEVATED_WAIT_MS) return "normal";
135
+ if (ms >= URGENT_WAIT_MS) return "urgent";
136
+ return "elevated";
137
+ }
138
+
139
+ export function tokens(n: number | null): string {
140
+ if (n === null) return "未报告";
141
+ return n >= 10_000 ? `${Math.round(n / 1_000) / 10} 万` : String(n);
142
+ }
143
+
144
+ export function facts(r: Pick<RequirementView, "project" | "type" | "profile" | "jointCount">): string {
145
+ return [
146
+ r.project,
147
+ r.type ? (TYPE_LABELS[r.type] ?? r.type) : null,
148
+ r.profile ? (PROFILE_LABELS[r.profile] ?? r.profile) : null,
149
+ r.jointCount && r.jointCount > 0 ? `多仓 +${r.jointCount}` : null,
150
+ ]
151
+ .filter(Boolean)
152
+ .join(" · ");
153
+ }
154
+
155
+ export function actionsFor(
156
+ r: Pick<RequirementView, "attention" | "running" | "status" | "external">,
157
+ ): Array<Exclude<ActionKind, "reply">> {
158
+ const base: Array<Exclude<ActionKind, "reply">> = r.running
159
+ ? ["stop"]
160
+ : r.attention === "approval"
161
+ ? ["approve"]
162
+ : r.attention === "interrupted" || r.attention === "business"
163
+ ? ["resume"]
164
+ : r.attention === "not_started"
165
+ ? ["start"]
166
+ : r.status === "phase_done"
167
+ ? ["verify"]
168
+ : [];
169
+ if (!r.running && r.status && (r.external ?? []).some((e) => e.pending > 0 || !e.id)) base.push("sync");
170
+ return base;
171
+ }
172
+
173
+ export const TRACK = [
174
+ { label: "对齐", who: "你" },
175
+ { label: "方案", who: "AI · 你确认" },
176
+ { label: "实现", who: "AI" },
177
+ { label: "评审", who: "AI · 开发同事" },
178
+ { label: "验证", who: "AI" },
179
+ { label: "验收", who: "需求方" },
180
+ ] as const;
181
+
182
+ const STEP_STOP: Array<[RegExp, number]> = [
183
+ [/^(design|design_review|design_revise|design_proposal|assessment|diagnosis|reproduce)/, 1],
184
+ [/^(implement|acceptance_tests)/, 2],
185
+ [/^(code_review|review_fix)/, 3],
186
+ [/^(verify|defect_fix|reverify|service|handoff|report)/, 4],
187
+ ];
188
+
189
+ export interface TrackStop {
190
+ label: string;
191
+ who: string;
192
+ state: "done" | "now" | "needs" | "todo";
193
+ }
194
+
195
+ export function trackOf(
196
+ r: Pick<RequirementView, "stage" | "status" | "attention" | "running" | "current">,
197
+ humanReview?: { status: string; stale: boolean } | null,
198
+ ): TrackStop[] {
199
+ let at = 0;
200
+ let needs = false;
201
+ const running = r.current[0]?.key;
202
+ if (r.stage.startsWith("对齐")) at = 0;
203
+ else if (r.attention === "approval" || r.attention === "business" || r.attention === "not_started") [at, needs] = [1, true];
204
+ else if (running) at = STEP_STOP.find(([re]) => re.test(running))?.[1] ?? 2;
205
+ else if (r.status === "phase_done") [at, needs] = [4, true];
206
+ else if (r.status === "completed" || /待验收|已验收|验收/.test(r.stage)) {
207
+ const reviewed = humanReview && humanReview.status === "approved" && !humanReview.stale;
208
+ if (/已验收|验收通过/.test(r.stage)) at = TRACK.length;
209
+ else if (humanReview !== undefined && !reviewed) [at, needs] = [3, true];
210
+ else [at, needs] = [5, true];
211
+ } else if (r.status) at = 2;
212
+ return TRACK.map((t, i) => ({ ...t, state: i < at ? "done" : i === at ? (needs ? "needs" : "now") : "todo" }));
213
+ }
214
+
215
+ export function iconOf(r: Pick<RequirementView, "attention" | "running" | "status" | "stage">): { name: string; tone: Tone } {
216
+ if (r.attention === "interrupted") return { name: "OctagonAlert", tone: "danger" };
217
+ if (r.attention === "permission") return { name: "ShieldCheck", tone: "needs" };
218
+ if (r.attention === "approval") return { name: "PenTool", tone: "needs" };
219
+ if (r.attention === "business") return { name: "MessagesSquare", tone: "needs" };
220
+ if (r.attention === "not_started") return { name: "Play", tone: "needs" };
221
+ if (r.attention === "not_completed") return { name: "CircleDashed", tone: "warning" };
222
+ if (r.running) return { name: "LoaderCircle", tone: "running" };
223
+ if (r.stage.startsWith("对齐")) return { name: "MessagesSquare", tone: "muted" };
224
+ if (r.status === "phase_done" || /待验收/.test(r.stage)) return { name: "ClipboardCheck", tone: "warning" };
225
+ if (r.status === "completed") return { name: "CircleCheck", tone: "success" };
226
+ return { name: "Circle", tone: "muted" };
227
+ }
228
+
229
+ export const INBOX_KIND: Record<
230
+ Exclude<Attention, null>,
231
+ { label: string; tone: "needs" | "danger" | "muted"; icon: string; todo: string; impact: string }
232
+ > = {
233
+ approval: {
234
+ icon: "PenTool",
235
+ label: "确认方案",
236
+ tone: "needs",
237
+ todo: "方案已通过审核。看一下“做完后会看到什么”,没问题就确认开始写代码;要改就写下来。",
238
+ impact: "确认前不会开始写代码,此时调整成本最低。",
239
+ },
240
+ business: {
241
+ icon: "MessagesSquare",
242
+ label: "回答问题",
243
+ tone: "needs",
244
+ todo: "方案审核有业务问题需要你拍板,回答后开发会接着进行。",
245
+ impact: "流水线暂停在方案阶段,回答前不会继续。",
246
+ },
247
+ permission: {
248
+ icon: "ShieldCheck",
249
+ label: "批准权限",
250
+ tone: "needs",
251
+ todo: "当前步骤在等你允许它执行一项操作,批准或拒绝后会立即继续。",
252
+ impact: "批准前步骤会一直停留在这里。",
253
+ },
254
+ interrupted: {
255
+ icon: "OctagonAlert",
256
+ label: "已中断",
257
+ tone: "danger",
258
+ todo: "开发中断了,自动处理没能解决。查看原因后可直接继续,已完成步骤不会重做。",
259
+ impact: "流水线已停止,需要人工确认后恢复。",
260
+ },
261
+ not_completed: {
262
+ icon: "CircleDashed",
263
+ label: "没有完成",
264
+ tone: "muted",
265
+ todo: "流水线已结束但存在未完成项,完成报告里记录了原因和建议。",
266
+ impact: "请查看完成报告决定补充开发或收尾。",
267
+ },
268
+ not_started: {
269
+ icon: "Play",
270
+ label: "还没开始开发",
271
+ tone: "needs",
272
+ todo: "需求说明已经确认,但开发尚未启动。确认无误即可点“开始开发”。",
273
+ impact: "尚未进入方案与编码阶段。",
274
+ },
275
+ };
276
+
277
+ export interface InboxCardModel {
278
+ item: RequirementView;
279
+ kind: (typeof INBOX_KIND)[Exclude<Attention, null>];
280
+ since: string;
281
+ waitedText: string;
282
+ urgency: Urgency;
283
+ primaryAction: Exclude<ActionKind, "reply"> | null;
284
+ }
285
+
286
+ /** Longest-waiting decisions first, enriched with urgency level and clear impact/CTA metadata. */
287
+ export function buildInboxCards(items: RequirementView[], now = Date.now()): InboxCardModel[] {
288
+ return items
289
+ .filter((r) => r.attention !== null)
290
+ .sort((a, b) => (a.waiting?.since ?? a.updatedAt).localeCompare(b.waiting?.since ?? b.updatedAt))
291
+ .map((item) => {
292
+ const since = item.waiting?.since ?? item.updatedAt;
293
+ const actions = actionsFor(item);
294
+ return {
295
+ item,
296
+ kind: INBOX_KIND[item.attention!],
297
+ since,
298
+ waitedText: waited(since, now),
299
+ urgency: urgencyOf(since, now),
300
+ primaryAction: actions[0] ?? null,
301
+ };
302
+ });
303
+ }
304
+
305
+ export interface BoardFilter {
306
+ project?: string | null;
307
+ group?: Group | "all";
308
+ query?: string;
309
+ }
310
+
311
+ export function filterRequirements(items: RequirementView[], filter: BoardFilter, now = Date.now()): RequirementView[] {
312
+ const q = filter.query?.trim().toLowerCase() ?? "";
313
+ return items.filter((item) => {
314
+ if (filter.project && item.project !== filter.project) return false;
315
+ if (filter.group && filter.group !== "all" && groupOf(item, now) !== filter.group) return false;
316
+ if (!q) return true;
317
+ const haystack = [
318
+ item.title,
319
+ item.project,
320
+ item.featureDir,
321
+ item.branch ?? "",
322
+ item.stage,
323
+ item.startedBy ?? "",
324
+ item.owner ?? "",
325
+ item.waiting?.card?.id ?? "",
326
+ ]
327
+ .join(" ")
328
+ .toLowerCase();
329
+ return haystack.includes(q);
330
+ });
331
+ }
332
+
333
+ export interface BoardSummary {
334
+ total: number;
335
+ attention: number;
336
+ running: number;
337
+ verify: number;
338
+ done: number;
339
+ urgentCount: number;
340
+ longestWaitText: string | null;
341
+ }
342
+
343
+ /** Top-bar KPI summary across requirements (Linear / Vercel Dashboard style). */
344
+ export function summarizeBoard(items: RequirementView[], now = Date.now()): BoardSummary {
345
+ let attention = 0;
346
+ let running = 0;
347
+ let verify = 0;
348
+ let done = 0;
349
+ let urgentCount = 0;
350
+ let oldestWaitSince: string | null = null;
351
+
352
+ for (const item of items) {
353
+ const g = groupOf(item, now);
354
+ if (g === "attention") {
355
+ attention++;
356
+ const since = item.waiting?.since ?? item.updatedAt;
357
+ if (!oldestWaitSince || since < oldestWaitSince) oldestWaitSince = since;
358
+ if (urgencyOf(since, now) === "urgent") urgentCount++;
359
+ } else if (g === "running") running++;
360
+ else if (g === "verify") verify++;
361
+ else if (g === "done") done++;
362
+ }
363
+
364
+ return {
365
+ total: items.length,
366
+ attention,
367
+ running,
368
+ verify,
369
+ done,
370
+ urgentCount,
371
+ longestWaitText: oldestWaitSince ? waited(oldestWaitSince, now) : null,
372
+ };
373
+ }
374
+
375
+ export interface ChecklistItemView {
376
+ id: string;
377
+ kind: "criterion" | "decision";
378
+ title: string;
379
+ required: boolean;
380
+ pipeline: "pass" | "fail" | "unverified" | "unknown";
381
+ evidence: string | null;
382
+ }
383
+
384
+ export interface ChecklistSummary {
385
+ total: number;
386
+ requiredTotal: number;
387
+ pipelinePass: number;
388
+ pipelineNeedsEyes: number;
389
+ checkedPass: number;
390
+ checkedFail: number;
391
+ remainingRequired: number;
392
+ }
393
+
394
+ /** Summarizes pipeline verification progress and human acceptance ticks for the workbench. */
395
+ export function summarizeChecklist(
396
+ items: ChecklistItemView[],
397
+ marks: Record<string, "pass" | "fail" | "skip"> = {},
398
+ ): ChecklistSummary {
399
+ let requiredTotal = 0;
400
+ let pipelinePass = 0;
401
+ let pipelineNeedsEyes = 0;
402
+ let checkedPass = 0;
403
+ let checkedFail = 0;
404
+ let remainingRequired = 0;
405
+
406
+ for (const item of items) {
407
+ if (item.required) requiredTotal++;
408
+ if (item.pipeline === "pass") pipelinePass++;
409
+ else pipelineNeedsEyes++;
410
+ const m = marks[item.id];
411
+ if (m === "pass") checkedPass++;
412
+ else if (m === "fail") checkedFail++;
413
+ else if (item.required) remainingRequired++;
414
+ }
415
+
416
+ return {
417
+ total: items.length,
418
+ requiredTotal,
419
+ pipelinePass,
420
+ pipelineNeedsEyes,
421
+ checkedPass,
422
+ checkedFail,
423
+ remainingRequired,
424
+ };
425
+ }
@@ -0,0 +1,60 @@
1
+ // A command that must run a given laoshi version (LAOSHI_WANT_VERSION, which platforms such as 摸高
2
+ // put in front of every command in the skills they render) installs that version first when the
3
+ // installed one is different, then runs again with it. Only for laoshi installed in an install
4
+ // root's npm directory (<root>/npm/…/node_modules), as the 摸高 expert installs it: elsewhere upgrades
5
+ // go through `laoshi upgrade`.
6
+ //
7
+ // Without this, the version the expert asks for was only checked by one line the chat agent is told
8
+ // to run first; skipping it (or editing an expert by hand and missing a place) kept the old version.
9
+ import { spawnSync } from "node:child_process";
10
+ import fs from "node:fs";
11
+ import path from "node:path";
12
+
13
+ /**
14
+ * Makes sure the running laoshi is the wanted version; returns only when it is (or nothing is
15
+ * wanted, or it cannot change it), otherwise runs the command again with the new version and exits.
16
+ */
17
+ export function ensureVersion({ kitRoot, version, packageName, script, argv, env = process.env }) {
18
+ const want = env.LAOSHI_WANT_VERSION?.trim();
19
+ if (!want || want === version || env.LAOSHI_WANT_VERSION_DONE) return;
20
+ const m = /^(.*)[\\/]npm[\\/](?:lib[\\/])?node_modules[\\/]/.exec(kitRoot);
21
+ if (!m) return;
22
+ const root = m[1];
23
+ console.error(`laoshi ${version} 不是要求的 ${want}:从 npm 安装 ${want}(约一分钟)…`);
24
+ const fake = env.LAOSHI_NPM?.trim();
25
+ const npmArgs = ["install", "--prefix", path.join(root, "npm"), "--no-audit", "--no-fund", `${packageName}@${want}`];
26
+ const npm = fake
27
+ ? spawnSync(process.execPath, [fake, ...npmArgs], { stdio: ["ignore", "inherit", "inherit"], env })
28
+ : spawnSync(process.platform === "win32" ? "npm.cmd" : "npm", npmArgs, { stdio: ["ignore", "inherit", "inherit"], env, shell: process.platform === "win32" });
29
+ const installed = (() => {
30
+ try {
31
+ return JSON.parse(fs.readFileSync(path.join(kitRoot, "package.json"), "utf8")).version;
32
+ } catch {
33
+ return null;
34
+ }
35
+ })();
36
+ if (npm.status !== 0 || installed !== want) {
37
+ console.error(`没能安装 ${want}(${installed ?? "读不到版本"}),这次仍用 ${version}。请检查 npm 镜像能否取到这个版本。`);
38
+ // Prevent child scripts spawned by this command (e.g. req.mjs -> start-pipeline.mjs) from retrying npm install.
39
+ env.LAOSHI_WANT_VERSION_DONE = "1";
40
+ return;
41
+ }
42
+ // The new version's own setup (skills, platform settings) for the install root.
43
+ const config = path.join(root, "config.json");
44
+ let platform = null;
45
+ try {
46
+ platform = JSON.parse(fs.readFileSync(config, "utf8")).platform?.adapter ?? null;
47
+ } catch {
48
+ // No install-level config: `laoshi install` writes one.
49
+ }
50
+ const installer = path.join(kitRoot, "bin", "install.mjs");
51
+ if (platform && fs.existsSync(installer)) {
52
+ const setup = spawnSync(process.execPath, [installer, "--platform", platform, "--home", root], { stdio: ["ignore", "ignore", "inherit"], env });
53
+ if (setup.status !== 0) {
54
+ console.error(`警告:更新 ${want} 的平台设置失败(退出码 ${setup.status ?? "未知"}),将继续执行命令。`);
55
+ }
56
+ }
57
+ console.error(`已换成 ${want}。`);
58
+ const again = spawnSync(process.execPath, [script, ...argv], { stdio: "inherit", env: { ...env, LAOSHI_WANT_VERSION_DONE: "1" }, windowsHide: true });
59
+ process.exit(again.status ?? 1);
60
+ }
@@ -5,9 +5,14 @@ import { spawnSync } from "node:child_process";
5
5
  import fs from "node:fs";
6
6
  import path from "node:path";
7
7
  import { fileURLToPath } from "node:url";
8
+ import { ensureVersion } from "./ensure-version.mjs";
8
9
  import { findTsxCli } from "./locate.mjs";
9
10
 
10
11
  const kitRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
12
+ {
13
+ const { name, version } = JSON.parse(fs.readFileSync(path.join(kitRoot, "package.json"), "utf8"));
14
+ ensureVersion({ kitRoot: kitRoot, version, packageName: name, script: fileURLToPath(import.meta.url), argv: process.argv.slice(2) });
15
+ }
11
16
  const tsxCli = findTsxCli(kitRoot) ?? path.join(kitRoot, "node_modules", "tsx", "dist", "cli.mjs");
12
17
  if (!fs.existsSync(tsxCli)) {
13
18
  console.log(`✗ 依赖未安装:找不到 tsx`);
package/bin/req.mjs CHANGED
@@ -5,10 +5,13 @@ import { spawnSync } from "node:child_process";
5
5
  import fs from "node:fs";
6
6
  import path from "node:path";
7
7
  import { fileURLToPath } from "node:url";
8
+ import { ensureVersion } from "./ensure-version.mjs";
8
9
  import { findTsxCli } from "./locate.mjs";
9
10
 
10
11
  const kitRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
11
12
  const { name: packageName, version } = JSON.parse(fs.readFileSync(path.join(kitRoot, "package.json"), "utf8"));
13
+ // The version a platform's skills ask for (LAOSHI_WANT_VERSION): installed first when different.
14
+ ensureVersion({ kitRoot, version, packageName, script: fileURLToPath(import.meta.url), argv: process.argv.slice(2) });
12
15
  const tsxCli = findTsxCli(kitRoot) ?? path.join(kitRoot, "node_modules", "tsx", "dist", "cli.mjs");
13
16
  const launcher = path.join(kitRoot, "bin", "start-pipeline.mjs");
14
17
 
@@ -38,6 +41,8 @@ const HELP = `laoshi ${version}(${kitRoot})
38
41
  laoshi permission <需求> approve|deny [理由]
39
42
  批准或拒绝步骤等待批准的操作,并接着运行(平台在对话里问人时用)
40
43
  laoshi reply <需求> <回复> 把回答或方案意见转给需求的对话(需求插件的"等你处理"用它)
44
+ laoshi handover <需求> <接手人> [--note <说明>]
45
+ 把需求转交给另一位同事负责(记入 .pipeline/owner.json)
41
46
  laoshi integration test [需求] 只显示对接外部系统时会执行的命令,不真正调用
42
47
  laoshi start --from <系统>:<卡号> 从需求管理系统中的一张卡片开始需求(没有人开着对话也可以)
43
48
  laoshi card check [<卡号>|--all] 读取需求方在卡片中的回复,转给需求的会话
@@ -58,6 +63,8 @@ const HELP = `laoshi ${version}(${kitRoot})
58
63
  laoshi index [--rebuild [目录…]] [--prune]
59
64
  本机记录的需求(需求插件据此找到所有需求);索引里缺的需求用 --rebuild 补登
60
65
  laoshi api <命令> … 给程序用的 JSON 输出(见 contracts/cli-json.md)
66
+ laoshi board [--port <端口>] [--repo <目录>] [--read-only] [--no-open]
67
+ 在本机打开需求看板网页(查看所有需求、产物与待处理操作)
61
68
  laoshi plugin install [--yes] | status | remove
62
69
  Paseo 的需求插件(在 Paseo 里看需求、确认方案、停止和继续)
63
70
  laoshi migrate [--apply | --rollback] [--from <目录>] [--to <目录>]
@@ -75,6 +82,8 @@ const HELP = `laoshi ${version}(${kitRoot})
75
82
  laoshi docs [--port <端口>] [--no-open]
76
83
  在本机打开这个版本的文档站点(不需要外网)
77
84
  laoshi doctor [--no-project] 体检:安装、配置、平台、当前项目
85
+ laoshi diagnose <需求> [--out <目录>]
86
+ 导出已脱敏的诊断包(状态、日志、步骤输出与事件),发给维护者排查问题
78
87
  laoshi configure 配置向导:选择 builder 和 reviewer 用的 agent
79
88
  laoshi configure --auto 不提问,按推荐选好 builder、reviewer 和备用模型
80
89
  laoshi notify-test [--type blocked|failed|completed|milestone|permission]
@@ -165,6 +174,9 @@ switch (command) {
165
174
  case "doctor":
166
175
  code = node([path.join(kitRoot, "bin", "req-doctor.mjs"), ...rest]);
167
176
  break;
177
+ case "diagnose":
178
+ code = needTsx() ? node([tsxCli, path.join(kitRoot, "engine", "src", "diagnose.ts"), ...rest]) : 1;
179
+ break;
168
180
  case "configure":
169
181
  case "config":
170
182
  code = needTsx() ? node([tsxCli, path.join(kitRoot, "engine", "src", "configure.ts"), ...rest]) : 1;
@@ -188,9 +200,15 @@ switch (command) {
188
200
  case "api":
189
201
  code = needTsx() ? node([tsxCli, path.join(kitRoot, "engine", "src", "api.ts"), ...rest]) : 1;
190
202
  break;
203
+ case "board":
204
+ code = needTsx() ? node([tsxCli, path.join(kitRoot, "engine", "src", "board.ts"), ...rest]) : 1;
205
+ break;
191
206
  case "reply":
192
207
  code = needTsx() ? node([tsxCli, path.join(kitRoot, "engine", "src", "reply.ts"), ...rest]) : 1;
193
208
  break;
209
+ case "handover":
210
+ code = needTsx() ? node([tsxCli, path.join(kitRoot, "engine", "src", "handover-cmd.ts"), ...rest]) : 1;
211
+ break;
194
212
  case "permission":
195
213
  // Answers a step's pending approval, then continues the run (the step picks up the answer).
196
214
  code = needTsx() ? node([tsxCli, path.join(kitRoot, "engine", "src", "permission-cmd.ts"), ...rest]) : 1;
@@ -7,9 +7,14 @@ import { spawnSync } from "node:child_process";
7
7
  import fs from "node:fs";
8
8
  import path from "node:path";
9
9
  import { fileURLToPath } from "node:url";
10
+ import { ensureVersion } from "./ensure-version.mjs";
10
11
  import { findTsxCli } from "./locate.mjs";
11
12
 
12
13
  const toolDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
14
+ {
15
+ const { name, version } = JSON.parse(fs.readFileSync(path.join(toolDir, "package.json"), "utf8"));
16
+ ensureVersion({ kitRoot: toolDir, version, packageName: name, script: fileURLToPath(import.meta.url), argv: process.argv.slice(2) });
17
+ }
13
18
  const tsxCli = findTsxCli(toolDir) ?? path.join(toolDir, "node_modules", "tsx", "dist", "cli.mjs");
14
19
  if (!fs.existsSync(tsxCli)) {
15
20
  console.error(`未启动:找不到 tsx。请先在 ${toolDir} 中执行 npm install。`);
@@ -24,10 +24,11 @@
24
24
  | `req api list [--repo <目录>]` | 这个仓库所有工作区中的需求,数组,每项见下面的"需求" |
25
25
  | `req api list --all` | 本机记录过的所有需求([需求索引](usage-record.md)),同上;目录已不在的 `present: false`。1.14 起还包括:用 `--track` 登记、还在对齐中的需求(`stage` 为"对齐中",没有 `spec.md` 时 `title` 取自 `alignment.md`),以及索引里出现过的项目中没登记的需求 |
26
26
  | `req api status <需求> [--repo <目录>]` | 一个需求的详情,见下面的"详情" |
27
+ | `req api history <需求> [--repo <目录>]` | 需求的变更历史与负责人:`{ specVersion, changes: [{ title, body }], commits: [{ commit, date, author, subject, diff, truncated }], owner: { owner, history } }` |
27
28
  | `req api file <需求> <文件> [--repo <目录>]` | `{ featureDir, file, size, truncated, content }`;只能读取功能目录中的文档(见下),最多 512 KB |
28
29
  | `req api stats [--since 30d] [--month 2026-10]` | `req stats --json` 的内容,见 [使用记录](usage-record.md) |
29
30
  | `req api index [--rebuild <目录>…] [--prune]` | 不带选项:索引的全部条目;`--rebuild`:`{ scanned, registered, pruned, total }` |
30
- | `req api run <approve\|stop\|resume\|verify\|sync\|reply\|start> <需求> [--repo <目录>] [选项]` | `{ command, featureDir, ok, exitCode, message }`。在 `--repo`(默认当前目录)中执行与 `req <命令> <需求>` 完全相同的操作;`ok` 为 false 时退出码为 1。`start`(1.14):在项目主目录中自动加 `--worktree`(上次已建好工作区的接着用),并把进展发回登记时的对话 |
31
+ | `req api run <approve\|stop\|resume\|verify\|sync\|reply\|start\|try\|handover> <需求> [--repo <目录>] [选项]` | `{ command, featureDir, ok, exitCode, message }`。在 `--repo`(默认当前目录)中执行与 `req <命令> <需求>` 完全相同的操作;`ok` 为 false 时退出码为 1。`start`(1.14):在项目主目录中自动加 `--worktree`(上次已建好工作区的接着用),并把进展发回登记时的对话;`reply --change <需求> <改动内容>`:从看板/插件发起改需求通知对话先停下再对齐变化;`handover <需求> <接手人> [--note <说明>]`:转交负责人到 `.pipeline/owner.json` |
31
32
  | `req api models` | 1.12 起。`{ current, choices, recommended }`:本机配置中现在的 `agents`;daemon 上能无人值守运行的选择(`{ id, label, provider, profile }`,Paseo profile 在前);按推荐的 `agents`。连不上 daemon 时报错 |
32
33
  | `req api config [--repo <目录>] [--machine]` | 1.12 起。`{ sources, ignored, error, repo, groups }`:`sources` 是生效的配置文件(`layer` 为 `machine` / `team` / `project`,按叠加顺序);`groups` 按主题分组,每项 `{ key, label, description, display, value, setBy, scope, changed }`:`display` 是用大白话写的值,`value` 中看起来像密钥的值和个人账号替换为 `••••`,`setBy` 是写了它的文件,`changed` 表示与默认值不同。配置有错误时 `error` 写明原因,值按各文件所写。`--machine` 不看项目配置 |
33
34
  | `req api set-agents --json <设置>` | 1.12 起。`{ ok, message }`。`<设置>` 是 `{ builder, reviewer, fallback }`(`fallback` 可以为 null),检查后写入本机配置的 `agents`,原文件备份 |
@@ -46,6 +47,7 @@
46
47
  | `project` | 项目名:对话所在目录的目录名 |
47
48
  | `codebase` | laoshi M2c 起。需求所属的代码库:`{ root, remote }`,`root` 是主检出目录(需求自己的 worktree 归属它的原仓库),`remote` 是 origin 的地址(去掉凭据),没有时为 null(ADR 0007) |
48
49
  | `startedBy` | laoshi 起。发起人:状态文件的 `startedBy`;还没运行过、或状态文件是更早的版本时为 null |
50
+ | `owner` | 转交接手后的当前负责人(`.pipeline/owner.json` 中的 `owner`);未转交过时为 null |
49
51
  | `repo` | 需求所在的目录(有自己的工作区时是那个工作区) |
50
52
  | `sourceRepo` / `workspaceId` | 有自己的工作区时:对话所在的目录、平台对这个工作区的引用(Paseo 上是工作区 ID);否则 null |
51
53
  | `featureDir` / `name` / `title` | 功能目录、目录名、需求标题 |
@@ -1,6 +1,6 @@
1
1
  # laoshi 内置能力:worktree、服务、本机调度
2
2
 
3
- - 状态:worktree 与服务**已实现**(M2b,`engine/src/builtin/`);本机调度**已设计,未实现**
3
+ - 状态:worktree 与服务**已实现**(M2b,`engine/src/builtin/`);本机调度**不做**(2026-11-21 决定:Paseo 与 dsh 均自带定时任务,命令行适配器已冻结,设计保留供参考)
4
4
  - 依据:[ADR 0008](../adr/0008-capability-sources-and-platform-plugin.md) 决定 3
5
5
  - 相关:[adapter-guide §2](adapter-guide.md)、[dsh-adapter](dsh-adapter.md)
6
6
 
@@ -47,7 +47,7 @@
47
47
  - **停止**:结束运行器的整个进程树(运行器、shell 和服务)。Windows 用 `taskkill /T /F`;其他系统向进程组发送 SIGTERM,5 秒后仍在则发 SIGKILL。运行器以 detached 方式启动,所以它自成一个进程组,服务也在这个组里。
48
48
  - **已知限制**:进程号可能被系统复用,所以停止前不能确认它还是原来的服务进程;绑定 `0.0.0.0` 的服务,空闲端口按 `127.0.0.1` 检查。
49
49
 
50
- ## 4. 本机调度(设计,未实现)
50
+ ## 4. 本机调度(设计归档,不做)
51
51
 
52
52
  **什么时候需要**:平台和插件都没有定时任务时才需要。dsh 的定时消息来自插件,Paseo 有自己的定时任务,所以现在两个适配器都用不上它。第一个用户会是 M3 的无头 CLI 运行时。引擎里用到定时的地方有:预约启动(`launch.ts`)、守护检查(`main.ts`,`cronEvery`)、等待提醒和自动继续(`pipeline.ts`)、需求总览定时发送(`digest.ts`,`scheduleNewAgent`)。
53
53
 
@@ -1,6 +1,6 @@
1
1
  # 命令行 agent 适配器(M3)
2
2
 
3
- - 状态:第一版已实现([adapters/cli](../../adapters/cli/README.md)),用假的命令行测试;真实的 Claude Code、Codex 上的运行待验证。
3
+ - 状态:**已冻结**(2026-11-21 决定,见 [roadmap](../roadmap.md))。第一版已实现([adapters/cli](../../adapters/cli/README.md)),保留现有代码作为一致性测试的参照,不再新增命令行驱动或在真实命令行上维护 evals;需要使用 Claude Code、Codex 时,经由 Paseo 等上层 agent 平台接入。
4
4
  - 目标:不依赖任何 agent 平台,在一台只装了编码 agent 命令行(Claude Code 的 `claude`、OpenAI Codex 的 `codex`)的机器上跑完整的流水线([抽取计划 M3](../extraction/plan.md))。这是第一个"非平台"的适配器,也是 [ADR 0002](../adr/0002-two-orchestration-modes.md) 里模式 A 的最小形态。
5
5
 
6
6
  ## 1. 形态