@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.
- package/CHANGELOG.md +39 -0
- package/README.md +3 -2
- package/adapters/dsh/adapter.ts +22 -1
- package/adapters/dsh/dsh-runtime.ts +14 -3
- package/adapters/dsh/install.mjs +16 -4
- package/adapters/dsh/plugin/index.mjs +197 -18
- package/adapters/dsh/plugin/package.json +1 -1
- package/adapters/mogao/adapter.ts +10 -1
- package/adapters/mogao/mogao-runtime.ts +58 -23
- package/adapters/mogao/skill/setup.md +6 -0
- package/adapters/paseo/install.mjs +13 -4
- package/adapters/paseo/plugin/client/data.ts +13 -2
- package/adapters/paseo/plugin/client/detail.tsx +244 -4
- package/adapters/paseo/plugin/client/format.ts +25 -117
- package/adapters/paseo/plugin/client/overview.tsx +3 -3
- package/adapters/paseo/plugin/index.server.ts +2 -1
- package/adapters/paseo/plugin/package.json +1 -1
- package/adapters/paseo/plugin/paseo-plugin.json +1 -1
- package/adapters/paseo/plugin/server/handlers.ts +22 -4
- package/adapters/paseo/plugin/server/req.ts +17 -4
- package/adapters/paseo/plugin/shared/contracts.ts +28 -2
- package/adapters/paseo/plugin/shared/view-model.ts +425 -0
- package/bin/ensure-version.mjs +60 -0
- package/bin/req-doctor.mjs +5 -0
- package/bin/req.mjs +18 -0
- package/bin/start-pipeline.mjs +5 -0
- package/contracts/cli-json.md +3 -1
- package/docs/design/builtin-capabilities.md +2 -2
- package/docs/design/cli-adapter.md +1 -1
- package/docs/design/dsh-adapter.md +11 -11
- package/docs/design/shared-ui.md +43 -0
- package/docs/guide//345/234/250/346/221/270/351/253/230/344/270/212/344/275/277/347/224/250.md +2 -1
- package/docs/guide//345/256/211/350/243/205/344/270/216/345/215/207/347/272/247.md +13 -8
- package/docs/guide//347/234/237/345/256/236/347/216/257/345/242/203/350/265/260/346/237/245.md +78 -0
- package/docs/guide//347/273/264/346/212/244/350/200/205/346/214/207/345/215/227.md +36 -6
- package/engine/prompts/00-shared-context.md +7 -0
- package/engine/prompts/03-design.md +2 -0
- package/engine/prompts/04-design-review.md +5 -1
- package/engine/skill-fragments/defaults.md +5 -0
- package/engine/src/api.ts +11 -2
- package/engine/src/board.ts +435 -0
- package/engine/src/config.ts +23 -0
- package/engine/src/diagnose.ts +238 -0
- package/engine/src/doctor.ts +25 -0
- package/engine/src/estimate.ts +11 -0
- package/engine/src/extensions.ts +271 -0
- package/engine/src/handover-cmd.ts +47 -0
- package/engine/src/handover.ts +89 -0
- package/engine/src/history.ts +102 -0
- package/engine/src/joint.ts +49 -4
- package/engine/src/launch.ts +20 -5
- package/engine/src/main.ts +1 -1
- package/engine/src/messages.ts +58 -0
- package/engine/src/pipeline.ts +121 -5
- package/engine/src/platform.ts +6 -0
- package/engine/src/reply.ts +27 -6
- package/engine/src/semver.ts +21 -0
- package/engine/src/skills-render.ts +10 -1
- package/package.json +5 -2
- package/site-dist/404.html +2 -2
- package/site-dist/assets/{app.CXydUhZx.js → app.DZpVs0VH.js} +1 -1
- package/site-dist/assets/changelog.md.CdUYbro4.js +1 -0
- package/site-dist/assets/{changelog.md.BU-CvyJ1.lean.js → changelog.md.CdUYbro4.lean.js} +1 -1
- package/site-dist/assets/chunks/@localSearchIndexroot.CHr-ITwS.js +1 -0
- package/site-dist/assets/chunks/{VPLocalSearchBox.CIjDV0ax.js → VPLocalSearchBox.BHkmziy1.js} +1 -1
- package/site-dist/assets/chunks/{theme.CWtC1Kby.js → theme.BsPChbDE.js} +2 -2
- package/site-dist/assets/guide_dsh.md.D0XhcUHz.js +7 -0
- package/site-dist/assets/guide_dsh.md.D0XhcUHz.lean.js +7 -0
- package/site-dist/assets/{guide_getting-started.md.BxOxfic_.js → guide_getting-started.md.BDd3nU5n.js} +1 -1
- package/site-dist/assets/{guide_install.md.By4WxsJG.js → guide_install.md.SsIHMfUu.js} +7 -5
- package/site-dist/assets/{guide_install.md.By4WxsJG.lean.js → guide_install.md.SsIHMfUu.lean.js} +7 -5
- package/site-dist/assets/guide_maintainer.md.CvqvRle1.js +1 -0
- package/site-dist/assets/guide_maintainer.md.CvqvRle1.lean.js +1 -0
- package/site-dist/assets/{guide_mogao.md.S0eln1Pr.js → guide_mogao.md.TCu3lgE9.js} +2 -2
- package/site-dist/assets/{guide_mogao.md.S0eln1Pr.lean.js → guide_mogao.md.TCu3lgE9.lean.js} +2 -2
- package/site-dist/assets/guide_walkthrough.md.nj_PWP9Y.js +5 -0
- package/site-dist/assets/guide_walkthrough.md.nj_PWP9Y.lean.js +5 -0
- package/site-dist/assets/reference_contracts_cli-json.md.3iU9h4rw.js +1 -0
- package/site-dist/assets/reference_contracts_cli-json.md.3iU9h4rw.lean.js +1 -0
- package/site-dist/assets/{reference_design_builtin-capabilities.md.CZYtjo_v.js → reference_design_builtin-capabilities.md.k5NXkESv.js} +2 -2
- package/site-dist/assets/{reference_design_builtin-capabilities.md.CZYtjo_v.lean.js → reference_design_builtin-capabilities.md.k5NXkESv.lean.js} +2 -2
- package/site-dist/assets/{reference_design_cli-adapter.md.pJy3x6Un.js → reference_design_cli-adapter.md.C1lcDATP.js} +1 -1
- package/site-dist/assets/{reference_design_cli-adapter.md.pJy3x6Un.lean.js → reference_design_cli-adapter.md.C1lcDATP.lean.js} +1 -1
- package/site-dist/changelog.html +5 -5
- package/site-dist/guide/cli.html +4 -4
- package/site-dist/guide/dsh.html +8 -6
- package/site-dist/guide/getting-started.html +5 -5
- package/site-dist/guide/how-it-works.html +4 -4
- package/site-dist/guide/index.html +4 -4
- package/site-dist/guide/install.html +11 -9
- package/site-dist/guide/intranet.html +4 -4
- package/site-dist/guide/maintainer.html +5 -5
- package/site-dist/guide/mogao.html +7 -7
- package/site-dist/guide/phases.html +4 -4
- package/site-dist/guide/project.html +4 -4
- package/site-dist/guide/user.html +4 -4
- package/site-dist/guide/walkthrough.html +34 -0
- package/site-dist/hashmap.json +1 -1
- package/site-dist/index.html +4 -4
- package/site-dist/reference/adr/0001-new-repo-core-and-adapters.html +4 -4
- package/site-dist/reference/adr/0002-two-orchestration-modes.html +4 -4
- package/site-dist/reference/adr/0003-generate-once-then-lock.html +4 -4
- package/site-dist/reference/adr/0004-external-contracts-stay-stable.html +4 -4
- package/site-dist/reference/adr/0005-skill-names.html +4 -4
- package/site-dist/reference/adr/0006-deterministic-engine-platform-capabilities.html +4 -4
- package/site-dist/reference/adr/0007-one-install-many-repos.html +4 -4
- package/site-dist/reference/adr/0008-capability-sources-and-platform-plugin.html +4 -4
- package/site-dist/reference/adr/index.html +4 -4
- package/site-dist/reference/commands.html +4 -4
- package/site-dist/reference/config.html +4 -4
- package/site-dist/reference/contracts/agent-runtime.html +4 -4
- package/site-dist/reference/contracts/cli-json.html +5 -5
- package/site-dist/reference/contracts/feature-files.html +4 -4
- package/site-dist/reference/contracts/index.html +4 -4
- package/site-dist/reference/contracts/notifier-event.html +4 -4
- package/site-dist/reference/contracts/result-file.html +4 -4
- package/site-dist/reference/contracts/spec.html +4 -4
- package/site-dist/reference/contracts/state.html +4 -4
- package/site-dist/reference/contracts/usage-record.html +4 -4
- package/site-dist/reference/contracts/verify.html +4 -4
- package/site-dist/reference/design/adapter-guide.html +4 -4
- package/site-dist/reference/design/architecture.html +4 -4
- package/site-dist/reference/design/builtin-capabilities.html +6 -6
- package/site-dist/reference/design/cli-adapter.html +5 -5
- package/site-dist/reference/design/platform-vocabulary.html +4 -4
- package/site-dist/reference/scope.html +4 -4
- package/skills/laoshi/SKILL.md +1 -3
- package/skills/laoshi-setup/SKILL.md +1 -1
- package/ui/shared/view-model.ts +424 -0
- package/ui/web/board.ts +1126 -0
- package/site-dist/assets/changelog.md.BU-CvyJ1.js +0 -1
- package/site-dist/assets/chunks/@localSearchIndexroot.CfgJeQRO.js +0 -1
- package/site-dist/assets/guide_dsh.md.0X-eYB87.js +0 -5
- package/site-dist/assets/guide_dsh.md.0X-eYB87.lean.js +0 -5
- package/site-dist/assets/guide_maintainer.md.Da1ffqxm.js +0 -1
- package/site-dist/assets/guide_maintainer.md.Da1ffqxm.lean.js +0 -1
- package/site-dist/assets/reference_contracts_cli-json.md.D6vfWOD9.js +0 -1
- package/site-dist/assets/reference_contracts_cli-json.md.D6vfWOD9.lean.js +0 -1
- /package/site-dist/assets/{guide_getting-started.md.BxOxfic_.lean.js → guide_getting-started.md.BDd3nU5n.lean.js} +0 -0
|
@@ -0,0 +1,424 @@
|
|
|
1
|
+
// Platform-agnostic UI view-model shared by Paseo (React Native), dsh (Web plugin),
|
|
2
|
+
// and local web views. Zero DOM, zero React Native, zero Node imports.
|
|
3
|
+
|
|
4
|
+
export type Attention = "approval" | "business" | "permission" | "interrupted" | "not_completed" | "not_started" | null;
|
|
5
|
+
|
|
6
|
+
export type Group = "attention" | "running" | "verify" | "done" | "other";
|
|
7
|
+
|
|
8
|
+
export type ActionKind = "approve" | "stop" | "resume" | "verify" | "sync" | "start" | "reply";
|
|
9
|
+
|
|
10
|
+
export type Tone = "needs" | "running" | "success" | "warning" | "danger" | "muted";
|
|
11
|
+
|
|
12
|
+
export type Urgency = "normal" | "elevated" | "urgent";
|
|
13
|
+
|
|
14
|
+
export interface RequirementWaiting {
|
|
15
|
+
since: string;
|
|
16
|
+
reason?: string | null;
|
|
17
|
+
questions: string[];
|
|
18
|
+
canReply?: boolean;
|
|
19
|
+
card?: { system: string; id: string; requester?: string | null } | null;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface RequirementView {
|
|
23
|
+
key: string;
|
|
24
|
+
repo: string;
|
|
25
|
+
sourceRepo?: string | null;
|
|
26
|
+
project: string;
|
|
27
|
+
featureDir: string;
|
|
28
|
+
title: string;
|
|
29
|
+
branch?: string | null;
|
|
30
|
+
type: string | null;
|
|
31
|
+
profile: string | null;
|
|
32
|
+
stage: string;
|
|
33
|
+
status: string | null;
|
|
34
|
+
attention: Attention;
|
|
35
|
+
running: boolean;
|
|
36
|
+
updatedAt: string;
|
|
37
|
+
startedBy?: string | null;
|
|
38
|
+
owner?: string | null;
|
|
39
|
+
hasPrototype?: boolean;
|
|
40
|
+
current: Array<{ key: string; title?: string }>;
|
|
41
|
+
waiting?: RequirementWaiting | null;
|
|
42
|
+
external?: Array<{ pending: number; id: string | null }>;
|
|
43
|
+
jointCount?: number;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export const ATTENTION_LABELS: Record<Exclude<Attention, null>, string> = {
|
|
47
|
+
approval: "等待确认方案",
|
|
48
|
+
business: "等待需求方决定",
|
|
49
|
+
permission: "等待批准权限",
|
|
50
|
+
interrupted: "已中断,可以继续",
|
|
51
|
+
not_completed: "结束但未完成",
|
|
52
|
+
not_started: "已确认,未开始开发",
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export const TYPE_LABELS: Record<string, string> = {
|
|
56
|
+
defect: "缺陷",
|
|
57
|
+
refactor: "重构",
|
|
58
|
+
assessment: "评估",
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export const PROFILE_LABELS: Record<string, string> = {
|
|
62
|
+
quick: "快速档",
|
|
63
|
+
standard: "标准档",
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export const GROUP_ORDER: Group[] = ["attention", "running", "verify", "done", "other"];
|
|
67
|
+
|
|
68
|
+
export const GROUP_LABELS: Record<Group, string> = {
|
|
69
|
+
attention: "需要你处理",
|
|
70
|
+
running: "进行中",
|
|
71
|
+
verify: "研发完成,待测试验证",
|
|
72
|
+
done: "最近完成",
|
|
73
|
+
other: "其他",
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export const GROUP_EYEBROWS: Record<Group, string> = {
|
|
77
|
+
attention: "需要你处理",
|
|
78
|
+
running: "进行中",
|
|
79
|
+
verify: "待测试验证",
|
|
80
|
+
done: "最近完成",
|
|
81
|
+
other: "其他",
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export const ACTION_TEXT: Record<ActionKind, { label: string; confirm: string }> = {
|
|
85
|
+
approve: { label: "确认方案", confirm: "确认 preview.md 中的方案,开始写代码?请先看过确认预览和原型。" },
|
|
86
|
+
stop: { label: "停止", confirm: "停止这个需求的流水线?正在运行的步骤会被中断,之后可以继续。" },
|
|
87
|
+
start: { label: "开始开发", confirm: "按已确认的需求说明开始开发?在项目主目录中的需求会新建自己的工作区。" },
|
|
88
|
+
resume: { label: "继续", confirm: "从中断处继续?需求说明改过的话,只处理变化的部分。" },
|
|
89
|
+
verify: { label: "开始测试验证", confirm: "开始测试验证?选择在哪里验证。" },
|
|
90
|
+
sync: { label: "同步到外部系统", confirm: "把这个需求同步到对接的外部系统:补发没有成功的调用、补建卡片、更新状态。" },
|
|
91
|
+
reply: { label: "发送回复", confirm: "把回复转给这个需求的对话,由它更新需求说明并继续开发。" },
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const RECENT_MS = 14 * 24 * 3600_000;
|
|
95
|
+
const ELEVATED_WAIT_MS = 4 * 3600_000;
|
|
96
|
+
const URGENT_WAIT_MS = 24 * 3600_000;
|
|
97
|
+
|
|
98
|
+
export function groupOf(r: Pick<RequirementView, "attention" | "running" | "status" | "updatedAt">, now = Date.now()): Group {
|
|
99
|
+
if (r.attention) return "attention";
|
|
100
|
+
if (r.running) return "running";
|
|
101
|
+
if (r.status === "phase_done") return "verify";
|
|
102
|
+
if (r.status === "completed" && now - Date.parse(r.updatedAt) < RECENT_MS) return "done";
|
|
103
|
+
return "other";
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export function minutes(m: number): string {
|
|
107
|
+
if (m < 1) return "不到 1 分钟";
|
|
108
|
+
if (m < 60) return `${Math.round(m)} 分钟`;
|
|
109
|
+
const h = Math.floor(m / 60);
|
|
110
|
+
const rest = Math.round(m % 60);
|
|
111
|
+
return rest === 0 ? `${h} 小时` : `${h} 小时 ${rest} 分`;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export function ago(iso: string, now = Date.now()): string {
|
|
115
|
+
const m = (now - Date.parse(iso)) / 60_000;
|
|
116
|
+
if (!Number.isFinite(m)) return "";
|
|
117
|
+
if (m < 1) return "刚刚";
|
|
118
|
+
if (m < 60) return `${Math.round(m)} 分钟前`;
|
|
119
|
+
if (m < 24 * 60) return `${Math.round(m / 60)} 小时前`;
|
|
120
|
+
return `${Math.round(m / 60 / 24)} 天前`;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export function waited(since: string, now = Date.now()): string {
|
|
124
|
+
const m = (now - Date.parse(since)) / 60_000;
|
|
125
|
+
if (!Number.isFinite(m) || m < 1) return "刚刚";
|
|
126
|
+
if (m < 60) return `等了 ${Math.round(m)} 分钟`;
|
|
127
|
+
if (m < 48 * 60) return `等了 ${Math.round(m / 60)} 小时`;
|
|
128
|
+
return `等了 ${Math.round(m / 60 / 24)} 天`;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export function urgencyOf(since: string, now = Date.now()): Urgency {
|
|
132
|
+
const ms = now - Date.parse(since);
|
|
133
|
+
if (!Number.isFinite(ms) || ms < ELEVATED_WAIT_MS) return "normal";
|
|
134
|
+
if (ms >= URGENT_WAIT_MS) return "urgent";
|
|
135
|
+
return "elevated";
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export function tokens(n: number | null): string {
|
|
139
|
+
if (n === null) return "未报告";
|
|
140
|
+
return n >= 10_000 ? `${Math.round(n / 1_000) / 10} 万` : String(n);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export function facts(r: Pick<RequirementView, "project" | "type" | "profile" | "jointCount">): string {
|
|
144
|
+
return [
|
|
145
|
+
r.project,
|
|
146
|
+
r.type ? (TYPE_LABELS[r.type] ?? r.type) : null,
|
|
147
|
+
r.profile ? (PROFILE_LABELS[r.profile] ?? r.profile) : null,
|
|
148
|
+
r.jointCount && r.jointCount > 0 ? `多仓 +${r.jointCount}` : null,
|
|
149
|
+
]
|
|
150
|
+
.filter(Boolean)
|
|
151
|
+
.join(" · ");
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export function actionsFor(
|
|
155
|
+
r: Pick<RequirementView, "attention" | "running" | "status" | "external">,
|
|
156
|
+
): Array<Exclude<ActionKind, "reply">> {
|
|
157
|
+
const base: Array<Exclude<ActionKind, "reply">> = r.running
|
|
158
|
+
? ["stop"]
|
|
159
|
+
: r.attention === "approval"
|
|
160
|
+
? ["approve"]
|
|
161
|
+
: r.attention === "interrupted" || r.attention === "business"
|
|
162
|
+
? ["resume"]
|
|
163
|
+
: r.attention === "not_started"
|
|
164
|
+
? ["start"]
|
|
165
|
+
: r.status === "phase_done"
|
|
166
|
+
? ["verify"]
|
|
167
|
+
: [];
|
|
168
|
+
if (!r.running && r.status && (r.external ?? []).some((e) => e.pending > 0 || !e.id)) base.push("sync");
|
|
169
|
+
return base;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export const TRACK = [
|
|
173
|
+
{ label: "对齐", who: "你" },
|
|
174
|
+
{ label: "方案", who: "AI · 你确认" },
|
|
175
|
+
{ label: "实现", who: "AI" },
|
|
176
|
+
{ label: "评审", who: "AI · 开发同事" },
|
|
177
|
+
{ label: "验证", who: "AI" },
|
|
178
|
+
{ label: "验收", who: "需求方" },
|
|
179
|
+
] as const;
|
|
180
|
+
|
|
181
|
+
const STEP_STOP: Array<[RegExp, number]> = [
|
|
182
|
+
[/^(design|design_review|design_revise|design_proposal|assessment|diagnosis|reproduce)/, 1],
|
|
183
|
+
[/^(implement|acceptance_tests)/, 2],
|
|
184
|
+
[/^(code_review|review_fix)/, 3],
|
|
185
|
+
[/^(verify|defect_fix|reverify|service|handoff|report)/, 4],
|
|
186
|
+
];
|
|
187
|
+
|
|
188
|
+
export interface TrackStop {
|
|
189
|
+
label: string;
|
|
190
|
+
who: string;
|
|
191
|
+
state: "done" | "now" | "needs" | "todo";
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export function trackOf(
|
|
195
|
+
r: Pick<RequirementView, "stage" | "status" | "attention" | "running" | "current">,
|
|
196
|
+
humanReview?: { status: string; stale: boolean } | null,
|
|
197
|
+
): TrackStop[] {
|
|
198
|
+
let at = 0;
|
|
199
|
+
let needs = false;
|
|
200
|
+
const running = r.current[0]?.key;
|
|
201
|
+
if (r.stage.startsWith("对齐")) at = 0;
|
|
202
|
+
else if (r.attention === "approval" || r.attention === "business" || r.attention === "not_started") [at, needs] = [1, true];
|
|
203
|
+
else if (running) at = STEP_STOP.find(([re]) => re.test(running))?.[1] ?? 2;
|
|
204
|
+
else if (r.status === "phase_done") [at, needs] = [4, true];
|
|
205
|
+
else if (r.status === "completed" || /待验收|已验收|验收/.test(r.stage)) {
|
|
206
|
+
const reviewed = humanReview && humanReview.status === "approved" && !humanReview.stale;
|
|
207
|
+
if (/已验收|验收通过/.test(r.stage)) at = TRACK.length;
|
|
208
|
+
else if (humanReview !== undefined && !reviewed) [at, needs] = [3, true];
|
|
209
|
+
else [at, needs] = [5, true];
|
|
210
|
+
} else if (r.status) at = 2;
|
|
211
|
+
return TRACK.map((t, i) => ({ ...t, state: i < at ? "done" : i === at ? (needs ? "needs" : "now") : "todo" }));
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export function iconOf(r: Pick<RequirementView, "attention" | "running" | "status" | "stage">): { name: string; tone: Tone } {
|
|
215
|
+
if (r.attention === "interrupted") return { name: "OctagonAlert", tone: "danger" };
|
|
216
|
+
if (r.attention === "permission") return { name: "ShieldCheck", tone: "needs" };
|
|
217
|
+
if (r.attention === "approval") return { name: "PenTool", tone: "needs" };
|
|
218
|
+
if (r.attention === "business") return { name: "MessagesSquare", tone: "needs" };
|
|
219
|
+
if (r.attention === "not_started") return { name: "Play", tone: "needs" };
|
|
220
|
+
if (r.attention === "not_completed") return { name: "CircleDashed", tone: "warning" };
|
|
221
|
+
if (r.running) return { name: "LoaderCircle", tone: "running" };
|
|
222
|
+
if (r.stage.startsWith("对齐")) return { name: "MessagesSquare", tone: "muted" };
|
|
223
|
+
if (r.status === "phase_done" || /待验收/.test(r.stage)) return { name: "ClipboardCheck", tone: "warning" };
|
|
224
|
+
if (r.status === "completed") return { name: "CircleCheck", tone: "success" };
|
|
225
|
+
return { name: "Circle", tone: "muted" };
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
export const INBOX_KIND: Record<
|
|
229
|
+
Exclude<Attention, null>,
|
|
230
|
+
{ label: string; tone: "needs" | "danger" | "muted"; icon: string; todo: string; impact: string }
|
|
231
|
+
> = {
|
|
232
|
+
approval: {
|
|
233
|
+
icon: "PenTool",
|
|
234
|
+
label: "确认方案",
|
|
235
|
+
tone: "needs",
|
|
236
|
+
todo: "方案已通过审核。看一下“做完后会看到什么”,没问题就确认开始写代码;要改就写下来。",
|
|
237
|
+
impact: "确认前不会开始写代码,此时调整成本最低。",
|
|
238
|
+
},
|
|
239
|
+
business: {
|
|
240
|
+
icon: "MessagesSquare",
|
|
241
|
+
label: "回答问题",
|
|
242
|
+
tone: "needs",
|
|
243
|
+
todo: "方案审核有业务问题需要你拍板,回答后开发会接着进行。",
|
|
244
|
+
impact: "流水线暂停在方案阶段,回答前不会继续。",
|
|
245
|
+
},
|
|
246
|
+
permission: {
|
|
247
|
+
icon: "ShieldCheck",
|
|
248
|
+
label: "批准权限",
|
|
249
|
+
tone: "needs",
|
|
250
|
+
todo: "当前步骤在等你允许它执行一项操作,批准或拒绝后会立即继续。",
|
|
251
|
+
impact: "批准前步骤会一直停留在这里。",
|
|
252
|
+
},
|
|
253
|
+
interrupted: {
|
|
254
|
+
icon: "OctagonAlert",
|
|
255
|
+
label: "已中断",
|
|
256
|
+
tone: "danger",
|
|
257
|
+
todo: "开发中断了,自动处理没能解决。查看原因后可直接继续,已完成步骤不会重做。",
|
|
258
|
+
impact: "流水线已停止,需要人工确认后恢复。",
|
|
259
|
+
},
|
|
260
|
+
not_completed: {
|
|
261
|
+
icon: "CircleDashed",
|
|
262
|
+
label: "没有完成",
|
|
263
|
+
tone: "muted",
|
|
264
|
+
todo: "流水线已结束但存在未完成项,完成报告里记录了原因和建议。",
|
|
265
|
+
impact: "请查看完成报告决定补充开发或收尾。",
|
|
266
|
+
},
|
|
267
|
+
not_started: {
|
|
268
|
+
icon: "Play",
|
|
269
|
+
label: "还没开始开发",
|
|
270
|
+
tone: "needs",
|
|
271
|
+
todo: "需求说明已经确认,但开发尚未启动。确认无误即可点“开始开发”。",
|
|
272
|
+
impact: "尚未进入方案与编码阶段。",
|
|
273
|
+
},
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
export interface InboxCardModel {
|
|
277
|
+
item: RequirementView;
|
|
278
|
+
kind: (typeof INBOX_KIND)[Exclude<Attention, null>];
|
|
279
|
+
since: string;
|
|
280
|
+
waitedText: string;
|
|
281
|
+
urgency: Urgency;
|
|
282
|
+
primaryAction: Exclude<ActionKind, "reply"> | null;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/** Longest-waiting decisions first, enriched with urgency level and clear impact/CTA metadata. */
|
|
286
|
+
export function buildInboxCards(items: RequirementView[], now = Date.now()): InboxCardModel[] {
|
|
287
|
+
return items
|
|
288
|
+
.filter((r) => r.attention !== null)
|
|
289
|
+
.sort((a, b) => (a.waiting?.since ?? a.updatedAt).localeCompare(b.waiting?.since ?? b.updatedAt))
|
|
290
|
+
.map((item) => {
|
|
291
|
+
const since = item.waiting?.since ?? item.updatedAt;
|
|
292
|
+
const actions = actionsFor(item);
|
|
293
|
+
return {
|
|
294
|
+
item,
|
|
295
|
+
kind: INBOX_KIND[item.attention!],
|
|
296
|
+
since,
|
|
297
|
+
waitedText: waited(since, now),
|
|
298
|
+
urgency: urgencyOf(since, now),
|
|
299
|
+
primaryAction: actions[0] ?? null,
|
|
300
|
+
};
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
export interface BoardFilter {
|
|
305
|
+
project?: string | null;
|
|
306
|
+
group?: Group | "all";
|
|
307
|
+
query?: string;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
export function filterRequirements(items: RequirementView[], filter: BoardFilter, now = Date.now()): RequirementView[] {
|
|
311
|
+
const q = filter.query?.trim().toLowerCase() ?? "";
|
|
312
|
+
return items.filter((item) => {
|
|
313
|
+
if (filter.project && item.project !== filter.project) return false;
|
|
314
|
+
if (filter.group && filter.group !== "all" && groupOf(item, now) !== filter.group) return false;
|
|
315
|
+
if (!q) return true;
|
|
316
|
+
const haystack = [
|
|
317
|
+
item.title,
|
|
318
|
+
item.project,
|
|
319
|
+
item.featureDir,
|
|
320
|
+
item.branch ?? "",
|
|
321
|
+
item.stage,
|
|
322
|
+
item.startedBy ?? "",
|
|
323
|
+
item.owner ?? "",
|
|
324
|
+
item.waiting?.card?.id ?? "",
|
|
325
|
+
]
|
|
326
|
+
.join(" ")
|
|
327
|
+
.toLowerCase();
|
|
328
|
+
return haystack.includes(q);
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
export interface BoardSummary {
|
|
333
|
+
total: number;
|
|
334
|
+
attention: number;
|
|
335
|
+
running: number;
|
|
336
|
+
verify: number;
|
|
337
|
+
done: number;
|
|
338
|
+
urgentCount: number;
|
|
339
|
+
longestWaitText: string | null;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/** Top-bar KPI summary across requirements (Linear / Vercel Dashboard style). */
|
|
343
|
+
export function summarizeBoard(items: RequirementView[], now = Date.now()): BoardSummary {
|
|
344
|
+
let attention = 0;
|
|
345
|
+
let running = 0;
|
|
346
|
+
let verify = 0;
|
|
347
|
+
let done = 0;
|
|
348
|
+
let urgentCount = 0;
|
|
349
|
+
let oldestWaitSince: string | null = null;
|
|
350
|
+
|
|
351
|
+
for (const item of items) {
|
|
352
|
+
const g = groupOf(item, now);
|
|
353
|
+
if (g === "attention") {
|
|
354
|
+
attention++;
|
|
355
|
+
const since = item.waiting?.since ?? item.updatedAt;
|
|
356
|
+
if (!oldestWaitSince || since < oldestWaitSince) oldestWaitSince = since;
|
|
357
|
+
if (urgencyOf(since, now) === "urgent") urgentCount++;
|
|
358
|
+
} else if (g === "running") running++;
|
|
359
|
+
else if (g === "verify") verify++;
|
|
360
|
+
else if (g === "done") done++;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
return {
|
|
364
|
+
total: items.length,
|
|
365
|
+
attention,
|
|
366
|
+
running,
|
|
367
|
+
verify,
|
|
368
|
+
done,
|
|
369
|
+
urgentCount,
|
|
370
|
+
longestWaitText: oldestWaitSince ? waited(oldestWaitSince, now) : null,
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
export interface ChecklistItemView {
|
|
375
|
+
id: string;
|
|
376
|
+
kind: "criterion" | "decision";
|
|
377
|
+
title: string;
|
|
378
|
+
required: boolean;
|
|
379
|
+
pipeline: "pass" | "fail" | "unverified" | "unknown";
|
|
380
|
+
evidence: string | null;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
export interface ChecklistSummary {
|
|
384
|
+
total: number;
|
|
385
|
+
requiredTotal: number;
|
|
386
|
+
pipelinePass: number;
|
|
387
|
+
pipelineNeedsEyes: number;
|
|
388
|
+
checkedPass: number;
|
|
389
|
+
checkedFail: number;
|
|
390
|
+
remainingRequired: number;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
/** Summarizes pipeline verification progress and human acceptance ticks for the workbench. */
|
|
394
|
+
export function summarizeChecklist(
|
|
395
|
+
items: ChecklistItemView[],
|
|
396
|
+
marks: Record<string, "pass" | "fail" | "skip"> = {},
|
|
397
|
+
): ChecklistSummary {
|
|
398
|
+
let requiredTotal = 0;
|
|
399
|
+
let pipelinePass = 0;
|
|
400
|
+
let pipelineNeedsEyes = 0;
|
|
401
|
+
let checkedPass = 0;
|
|
402
|
+
let checkedFail = 0;
|
|
403
|
+
let remainingRequired = 0;
|
|
404
|
+
|
|
405
|
+
for (const item of items) {
|
|
406
|
+
if (item.required) requiredTotal++;
|
|
407
|
+
if (item.pipeline === "pass") pipelinePass++;
|
|
408
|
+
else pipelineNeedsEyes++;
|
|
409
|
+
const m = marks[item.id];
|
|
410
|
+
if (m === "pass") checkedPass++;
|
|
411
|
+
else if (m === "fail") checkedFail++;
|
|
412
|
+
else if (item.required) remainingRequired++;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
return {
|
|
416
|
+
total: items.length,
|
|
417
|
+
requiredTotal,
|
|
418
|
+
pipelinePass,
|
|
419
|
+
pipelineNeedsEyes,
|
|
420
|
+
checkedPass,
|
|
421
|
+
checkedFail,
|
|
422
|
+
remainingRequired,
|
|
423
|
+
};
|
|
424
|
+
}
|