mpt-workflow 0.0.0-stage → 0.5.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 +144 -0
- package/LICENSE +21 -0
- package/README.md +323 -2
- package/README.zh-CN.md +272 -0
- package/dist/cli.js +479 -0
- package/dist/cli.js.map +1 -0
- package/dist/core/acl.js +120 -0
- package/dist/core/acl.js.map +1 -0
- package/dist/core/config.js +100 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/demo.js +50 -0
- package/dist/core/demo.js.map +1 -0
- package/dist/core/docs.js +291 -0
- package/dist/core/docs.js.map +1 -0
- package/dist/core/fsutil.js +89 -0
- package/dist/core/fsutil.js.map +1 -0
- package/dist/core/git.js +126 -0
- package/dist/core/git.js.map +1 -0
- package/dist/core/glob.js +36 -0
- package/dist/core/glob.js.map +1 -0
- package/dist/core/hooks.js +277 -0
- package/dist/core/hooks.js.map +1 -0
- package/dist/core/init.js +382 -0
- package/dist/core/init.js.map +1 -0
- package/dist/core/markdown.js +109 -0
- package/dist/core/markdown.js.map +1 -0
- package/dist/core/messages.js +365 -0
- package/dist/core/messages.js.map +1 -0
- package/dist/core/questions.js +240 -0
- package/dist/core/questions.js.map +1 -0
- package/dist/core/state.js +139 -0
- package/dist/core/state.js.map +1 -0
- package/dist/core/types.js +8 -0
- package/dist/core/types.js.map +1 -0
- package/dist/core/workflow.js +1050 -0
- package/dist/core/workflow.js.map +1 -0
- package/dist/mcp/server.js +852 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/version.js +2 -0
- package/dist/version.js.map +1 -0
- package/dist/web/public/index.html +1094 -0
- package/dist/web/server.js +249 -0
- package/dist/web/server.js.map +1 -0
- package/package.json +63 -4
|
@@ -0,0 +1,1094 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="zh-CN" data-theme="">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
|
+
<title>mpt-workflow · 开发看板</title>
|
|
7
|
+
<style>
|
|
8
|
+
/* Palette: dataviz reference. State colours are paired with a symbol AND a text
|
|
9
|
+
label everywhere, so colour never carries meaning alone. */
|
|
10
|
+
:root {
|
|
11
|
+
color-scheme: light;
|
|
12
|
+
--surface-1: #fcfcfb;
|
|
13
|
+
--page: #f9f9f7;
|
|
14
|
+
--card: #ffffff;
|
|
15
|
+
--ink: #0b0b0b;
|
|
16
|
+
--ink-2: #52514e;
|
|
17
|
+
--muted: #898781;
|
|
18
|
+
--grid: #e1e0d9;
|
|
19
|
+
--line: #c3c2b7;
|
|
20
|
+
--ring: rgba(11,11,11,0.10);
|
|
21
|
+
--blue: #2a78d6;
|
|
22
|
+
--yellow: #eda100;
|
|
23
|
+
--violet: #6250d6;
|
|
24
|
+
--good: #0ca30c;
|
|
25
|
+
--critical: #d03b3b;
|
|
26
|
+
--serious: #ec835a;
|
|
27
|
+
--warning: #fab219;
|
|
28
|
+
--good-text: #006300;
|
|
29
|
+
--track: #f0efec;
|
|
30
|
+
}
|
|
31
|
+
@media (prefers-color-scheme: dark) {
|
|
32
|
+
:root:where(:not([data-theme="light"])) {
|
|
33
|
+
color-scheme: dark;
|
|
34
|
+
--surface-1: #1a1a19;
|
|
35
|
+
--page: #0d0d0d;
|
|
36
|
+
--card: #1a1a19;
|
|
37
|
+
--ink: #f0efec;
|
|
38
|
+
--ink-2: #c3c2b7;
|
|
39
|
+
--muted: #898781;
|
|
40
|
+
--grid: #2c2c2a;
|
|
41
|
+
--line: #383835;
|
|
42
|
+
--ring: rgba(255,255,255,0.10);
|
|
43
|
+
--blue: #3987e5;
|
|
44
|
+
--yellow: #c98500;
|
|
45
|
+
--violet: #9085e9;
|
|
46
|
+
--good: #0ca30c;
|
|
47
|
+
--critical: #e66767;
|
|
48
|
+
--serious: #ec835a;
|
|
49
|
+
--warning: #fab219;
|
|
50
|
+
--good-text: #0ca30c;
|
|
51
|
+
--track: #262624;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
:root[data-theme="dark"] {
|
|
55
|
+
color-scheme: dark;
|
|
56
|
+
--surface-1: #1a1a19;
|
|
57
|
+
--page: #0d0d0d;
|
|
58
|
+
--card: #1a1a19;
|
|
59
|
+
--ink: #f0efec;
|
|
60
|
+
--ink-2: #c3c2b7;
|
|
61
|
+
--muted: #898781;
|
|
62
|
+
--grid: #2c2c2a;
|
|
63
|
+
--line: #383835;
|
|
64
|
+
--ring: rgba(255,255,255,0.10);
|
|
65
|
+
--blue: #3987e5;
|
|
66
|
+
--yellow: #c98500;
|
|
67
|
+
--violet: #9085e9;
|
|
68
|
+
--good: #0ca30c;
|
|
69
|
+
--critical: #e66767;
|
|
70
|
+
--serious: #ec835a;
|
|
71
|
+
--warning: #fab219;
|
|
72
|
+
--good-text: #0ca30c;
|
|
73
|
+
--track: #262624;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
* { box-sizing: border-box; }
|
|
77
|
+
html, body { margin: 0; }
|
|
78
|
+
body {
|
|
79
|
+
background: var(--page);
|
|
80
|
+
color: var(--ink);
|
|
81
|
+
font: 14px/1.55 system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
|
|
82
|
+
-webkit-font-smoothing: antialiased;
|
|
83
|
+
}
|
|
84
|
+
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
|
|
85
|
+
a { color: var(--blue); text-decoration: none; }
|
|
86
|
+
a:hover { text-decoration: underline; }
|
|
87
|
+
button { font: inherit; }
|
|
88
|
+
|
|
89
|
+
.wrap { max-width: 1440px; margin: 0 auto; padding: 0 24px 64px; }
|
|
90
|
+
|
|
91
|
+
/* header */
|
|
92
|
+
header.top {
|
|
93
|
+
display: flex; align-items: center; gap: 20px;
|
|
94
|
+
padding: 20px 0 16px; border-bottom: 1px solid var(--grid); margin-bottom: 20px;
|
|
95
|
+
flex-wrap: wrap;
|
|
96
|
+
}
|
|
97
|
+
.brand { display: flex; align-items: center; gap: 10px; min-width: 220px; }
|
|
98
|
+
.brand .mark {
|
|
99
|
+
width: 26px; height: 26px; border-radius: 7px;
|
|
100
|
+
background: var(--blue); display: grid; place-items: center;
|
|
101
|
+
color: #fff; font-weight: 700; font-size: 13px;
|
|
102
|
+
}
|
|
103
|
+
.brand h1 { font-size: 15px; margin: 0; font-weight: 650; letter-spacing: .2px; }
|
|
104
|
+
.brand .sub { color: var(--muted); font-size: 12px; }
|
|
105
|
+
.hero { display: flex; align-items: baseline; gap: 10px; margin-left: 8px; }
|
|
106
|
+
.hero .num { font-size: 48px; line-height: 1; font-weight: 650; letter-spacing: -1.5px; }
|
|
107
|
+
.hero .of { font-size: 18px; color: var(--muted); }
|
|
108
|
+
.hero .lbl { color: var(--ink-2); font-size: 12px; margin-left: 4px; }
|
|
109
|
+
.top-tools { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
|
|
110
|
+
|
|
111
|
+
.pill {
|
|
112
|
+
display: inline-flex; align-items: center; gap: 6px;
|
|
113
|
+
border: 1px solid var(--ring); border-radius: 999px;
|
|
114
|
+
padding: 3px 10px; font-size: 12px; color: var(--ink-2); background: var(--card);
|
|
115
|
+
}
|
|
116
|
+
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
|
|
117
|
+
.pill[hidden] { display: none; }
|
|
118
|
+
.pill.active .dot { background: var(--good); }
|
|
119
|
+
.btn {
|
|
120
|
+
border: 1px solid var(--ring); background: var(--card); color: var(--ink);
|
|
121
|
+
border-radius: 8px; padding: 6px 12px; cursor: pointer; font-size: 13px;
|
|
122
|
+
}
|
|
123
|
+
.btn:hover { border-color: var(--line); }
|
|
124
|
+
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
|
|
125
|
+
.btn.primary:hover { filter: brightness(1.06); }
|
|
126
|
+
.btn.ghost { background: transparent; }
|
|
127
|
+
.btn:disabled { opacity: .45; cursor: not-allowed; }
|
|
128
|
+
|
|
129
|
+
/* tiles */
|
|
130
|
+
.tiles { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 20px; }
|
|
131
|
+
.tile {
|
|
132
|
+
background: var(--card); border: 1px solid var(--ring); border-radius: 12px; padding: 14px 16px;
|
|
133
|
+
min-height: 92px; display: flex; flex-direction: column; justify-content: space-between;
|
|
134
|
+
}
|
|
135
|
+
.tile .label { color: var(--ink-2); font-size: 12px; display: flex; align-items: center; gap: 7px; }
|
|
136
|
+
.tile .value { font-size: 28px; font-weight: 640; letter-spacing: -.5px; }
|
|
137
|
+
.tile .hint { color: var(--muted); font-size: 11px; }
|
|
138
|
+
.tile .sym { width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; color: #fff; font-weight: 700; }
|
|
139
|
+
.sym.good { background: var(--good); }
|
|
140
|
+
.sym.warn { background: var(--warning); color: #0b0b0b; }
|
|
141
|
+
.sym.crit { background: var(--critical); }
|
|
142
|
+
.sym.info { background: var(--blue); }
|
|
143
|
+
|
|
144
|
+
/* layout */
|
|
145
|
+
.grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(320px, 1fr); gap: 20px; align-items: start; }
|
|
146
|
+
.col { display: flex; flex-direction: column; gap: 20px; }
|
|
147
|
+
section.card {
|
|
148
|
+
background: var(--card); border: 1px solid var(--ring); border-radius: 12px; overflow: hidden;
|
|
149
|
+
}
|
|
150
|
+
.card-head {
|
|
151
|
+
display: flex; align-items: center; gap: 10px;
|
|
152
|
+
padding: 13px 16px; border-bottom: 1px solid var(--grid);
|
|
153
|
+
}
|
|
154
|
+
.card-head h2 { font-size: 13px; margin: 0; font-weight: 650; letter-spacing: .2px; }
|
|
155
|
+
.card-head .count { color: var(--muted); font-size: 12px; }
|
|
156
|
+
.card-body { padding: 14px 16px; }
|
|
157
|
+
.card-body.flush { padding: 0; }
|
|
158
|
+
|
|
159
|
+
/* repo */
|
|
160
|
+
.repo + .repo { border-top: 1px solid var(--grid); }
|
|
161
|
+
.repo { padding: 15px 16px; }
|
|
162
|
+
.repo-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
|
|
163
|
+
.repo-head h3 { font-size: 14px; margin: 0; font-weight: 650; }
|
|
164
|
+
.repo-meta { color: var(--muted); font-size: 12px; }
|
|
165
|
+
.repo-meta .dirty { color: var(--serious); }
|
|
166
|
+
.meter { height: 4px; background: var(--track); border-radius: 999px; margin: 10px 0 12px; overflow: hidden; }
|
|
167
|
+
.meter > i { display: block; height: 100%; background: var(--blue); border-radius: 999px; }
|
|
168
|
+
|
|
169
|
+
.track { display: flex; gap: 6px; flex-wrap: wrap; }
|
|
170
|
+
.ms {
|
|
171
|
+
display: inline-flex; align-items: center; gap: 6px;
|
|
172
|
+
border: 1px solid var(--ring); background: var(--surface-1);
|
|
173
|
+
border-radius: 8px; padding: 5px 9px; font-size: 12px; color: var(--ink-2);
|
|
174
|
+
cursor: pointer; text-align: left; white-space: nowrap;
|
|
175
|
+
}
|
|
176
|
+
.ms:hover { border-color: var(--line); }
|
|
177
|
+
.ms .id { font-weight: 650; color: var(--ink); }
|
|
178
|
+
.ms .sy { width: 14px; text-align: center; font-size: 11px; }
|
|
179
|
+
.ms.accepted { border-color: color-mix(in srgb, var(--good) 45%, transparent); }
|
|
180
|
+
.ms.accepted .sy { color: var(--good-text); }
|
|
181
|
+
.ms.review { border-color: color-mix(in srgb, var(--violet) 45%, transparent); }
|
|
182
|
+
.ms.review .sy { color: var(--violet); }
|
|
183
|
+
.ms.implementing { border-color: color-mix(in srgb, var(--yellow) 50%, transparent); }
|
|
184
|
+
.ms.implementing .sy { color: var(--yellow); }
|
|
185
|
+
.ms.rejected { border-color: color-mix(in srgb, var(--critical) 50%, transparent); }
|
|
186
|
+
.ms.rejected .sy { color: var(--critical); }
|
|
187
|
+
.ms.todo_ready .sy { color: var(--blue); }
|
|
188
|
+
.ms.planned { opacity: .72; }
|
|
189
|
+
|
|
190
|
+
.legend { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: 11px; padding: 0 16px 12px; }
|
|
191
|
+
.legend span { display: inline-flex; align-items: center; gap: 5px; }
|
|
192
|
+
.legend i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
|
|
193
|
+
|
|
194
|
+
details.ms-detail { margin-top: 10px; }
|
|
195
|
+
details.ms-detail summary {
|
|
196
|
+
cursor: pointer; color: var(--ink-2); font-size: 12px; list-style: none;
|
|
197
|
+
display: inline-flex; align-items: center; gap: 6px;
|
|
198
|
+
}
|
|
199
|
+
details.ms-detail summary::-webkit-details-marker { display: none; }
|
|
200
|
+
details.ms-detail summary::before { content: "▸"; color: var(--muted); }
|
|
201
|
+
details.ms-detail[open] summary::before { content: "▾"; }
|
|
202
|
+
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 10px; }
|
|
203
|
+
.detail-box { background: var(--surface-1); border: 1px solid var(--ring); border-radius: 8px; padding: 10px 12px; }
|
|
204
|
+
.detail-box h4 { margin: 0 0 6px; font-size: 11px; text-transform: none; color: var(--muted); font-weight: 600; }
|
|
205
|
+
.detail-box ul { margin: 0; padding-left: 16px; }
|
|
206
|
+
.detail-box li { font-size: 12px; color: var(--ink-2); margin: 2px 0; }
|
|
207
|
+
.ev { border-top: 1px solid var(--grid); padding: 8px 0; }
|
|
208
|
+
.ev:first-child { border-top: 0; }
|
|
209
|
+
.ev .cmd { font-family: ui-monospace, monospace; font-size: 11.5px; color: var(--ink); word-break: break-all; }
|
|
210
|
+
.ev .meta { color: var(--muted); font-size: 11px; }
|
|
211
|
+
.tag { display: inline-block; border-radius: 5px; padding: 0 6px; font-size: 11px; border: 1px solid var(--ring); color: var(--ink-2); }
|
|
212
|
+
.tag.ok { color: var(--good-text); border-color: color-mix(in srgb, var(--good) 45%, transparent); }
|
|
213
|
+
.tag.bad { color: var(--critical); border-color: color-mix(in srgb, var(--critical) 45%, transparent); }
|
|
214
|
+
|
|
215
|
+
/* questions */
|
|
216
|
+
.q { padding: 14px 16px; border-top: 1px solid var(--grid); }
|
|
217
|
+
.q:first-child { border-top: 0; }
|
|
218
|
+
.q-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
|
|
219
|
+
.q-id { font-family: ui-monospace, monospace; font-weight: 650; font-size: 12px; }
|
|
220
|
+
.q-flow { color: var(--muted); font-size: 12px; }
|
|
221
|
+
.q-context { white-space: pre-wrap; color: var(--ink-2); font-size: 13px; margin: 6px 0; }
|
|
222
|
+
.q-context.clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
|
|
223
|
+
.q-opts { display: flex; flex-direction: column; gap: 3px; margin: 8px 0; }
|
|
224
|
+
.q-opt { display: flex; gap: 8px; font-size: 12.5px; color: var(--ink-2); }
|
|
225
|
+
.q-opt b { color: var(--ink); font-weight: 650; min-width: 14px; }
|
|
226
|
+
.q-rec { font-size: 12.5px; color: var(--ink-2); margin: 6px 0; padding-left: 10px; border-left: 2px solid var(--violet); }
|
|
227
|
+
.q-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
|
|
228
|
+
.q-form { display: none; margin-top: 10px; }
|
|
229
|
+
.q-form.open { display: block; }
|
|
230
|
+
.q-form textarea, .q-form input {
|
|
231
|
+
width: 100%; background: var(--surface-1); color: var(--ink);
|
|
232
|
+
border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font: inherit; font-size: 13px;
|
|
233
|
+
}
|
|
234
|
+
.q-form textarea { min-height: 76px; resize: vertical; }
|
|
235
|
+
.q-form .row { display: flex; gap: 8px; margin-top: 8px; align-items: center; }
|
|
236
|
+
|
|
237
|
+
.status {
|
|
238
|
+
display: inline-flex; align-items: center; gap: 5px; font-size: 11px;
|
|
239
|
+
padding: 1px 7px; border-radius: 999px; border: 1px solid var(--ring); color: var(--ink-2);
|
|
240
|
+
}
|
|
241
|
+
.status .d { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); }
|
|
242
|
+
.status.open .d { background: var(--critical); }
|
|
243
|
+
.status.answered .d { background: var(--blue); }
|
|
244
|
+
.status.applied .d { background: var(--good); }
|
|
245
|
+
.status.closed { opacity: .6; }
|
|
246
|
+
|
|
247
|
+
/* side lists */
|
|
248
|
+
.list { display: flex; flex-direction: column; }
|
|
249
|
+
.row-item { padding: 11px 16px; border-top: 1px solid var(--grid); display: flex; gap: 10px; }
|
|
250
|
+
.row-item:first-child { border-top: 0; }
|
|
251
|
+
.row-item .k { color: var(--muted); font-size: 11px; min-width: 64px; }
|
|
252
|
+
.row-item .v { font-size: 12.5px; color: var(--ink-2); }
|
|
253
|
+
.next-actor {
|
|
254
|
+
font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px; font-weight: 650;
|
|
255
|
+
color: var(--ink-2); background: var(--track); border-radius: 4px; padding: 1px 6px; height: fit-content;
|
|
256
|
+
}
|
|
257
|
+
.timeline { max-height: 320px; overflow: auto; }
|
|
258
|
+
.ev-row { display: grid; grid-template-columns: 66px 1fr; gap: 10px; padding: 7px 16px; border-top: 1px solid var(--grid); font-size: 12px; }
|
|
259
|
+
.ev-row:first-child { border-top: 0; }
|
|
260
|
+
.ev-row .t { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 11px; }
|
|
261
|
+
.ev-row .what { color: var(--ink-2); }
|
|
262
|
+
.ev-row .what b { color: var(--ink); font-weight: 600; }
|
|
263
|
+
.doctor-row { display: flex; gap: 9px; padding: 9px 16px; border-top: 1px solid var(--grid); font-size: 12.5px; }
|
|
264
|
+
.doctor-row:first-child { border-top: 0; }
|
|
265
|
+
.doctor-row .lv { font-weight: 700; font-size: 10.5px; padding: 1px 6px; border-radius: 4px; height: fit-content; }
|
|
266
|
+
.lv.FAIL { background: color-mix(in srgb, var(--critical) 16%, transparent); color: var(--critical); }
|
|
267
|
+
.lv.WARN { background: color-mix(in srgb, var(--warning) 22%, transparent); color: var(--ink); }
|
|
268
|
+
.lv.OK { background: color-mix(in srgb, var(--good) 14%, transparent); color: var(--good-text); }
|
|
269
|
+
.empty { padding: 16px; color: var(--muted); font-size: 12.5px; }
|
|
270
|
+
.empty b { color: var(--ink); }
|
|
271
|
+
.empty pre {
|
|
272
|
+
background: var(--surface-1); border: 1px solid var(--ring); border-radius: 6px;
|
|
273
|
+
padding: 7px 9px; margin: 6px 0; overflow: auto; font-size: 11.5px; color: var(--ink);
|
|
274
|
+
}
|
|
275
|
+
.footer { color: var(--muted); font-size: 11.5px; margin-top: 24px; display: flex; gap: 14px; flex-wrap: wrap; }
|
|
276
|
+
|
|
277
|
+
/* feedback and controls */
|
|
278
|
+
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
|
|
279
|
+
.banner {
|
|
280
|
+
display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
|
|
281
|
+
background: color-mix(in srgb, var(--critical) 9%, var(--card));
|
|
282
|
+
border: 1px solid color-mix(in srgb, var(--critical) 35%, transparent);
|
|
283
|
+
color: var(--ink); border-radius: 10px; padding: 10px 14px; margin-bottom: 16px;
|
|
284
|
+
}
|
|
285
|
+
.banner[hidden] { display: none; }
|
|
286
|
+
.banner .grow { flex: 1; min-width: 200px; }
|
|
287
|
+
.pill input[type="checkbox"] { margin: 0; }
|
|
288
|
+
.msg-filters { display: flex; gap: 6px; padding: 9px 16px; border-bottom: 1px solid var(--grid); flex-wrap: wrap; }
|
|
289
|
+
.msg-help {
|
|
290
|
+
padding: 9px 16px; border-bottom: 1px solid var(--grid);
|
|
291
|
+
color: var(--muted); font-size: 11.5px; line-height: 1.55;
|
|
292
|
+
}
|
|
293
|
+
.msg-help b { color: var(--ink-2); }
|
|
294
|
+
.chip {
|
|
295
|
+
border: 1px solid var(--ring); background: var(--card); color: var(--ink-2);
|
|
296
|
+
border-radius: 999px; padding: 3px 10px; font-size: 11.5px; cursor: pointer;
|
|
297
|
+
}
|
|
298
|
+
.chip:hover { border-color: var(--line); }
|
|
299
|
+
.chip.active { background: var(--track); color: var(--ink); border-color: var(--line); font-weight: 600; }
|
|
300
|
+
|
|
301
|
+
/* diff modal */
|
|
302
|
+
.modal {
|
|
303
|
+
position: fixed; inset: 0; z-index: 50; padding: 20px;
|
|
304
|
+
background: rgba(0, 0, 0, .45); display: grid; place-items: center;
|
|
305
|
+
}
|
|
306
|
+
.modal[hidden] { display: none; }
|
|
307
|
+
.modal-card {
|
|
308
|
+
background: var(--card); color: var(--ink); border: 1px solid var(--ring);
|
|
309
|
+
border-radius: 12px; width: min(1040px, 100%); max-height: 88vh;
|
|
310
|
+
display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 18px 60px rgba(0,0,0,.25);
|
|
311
|
+
}
|
|
312
|
+
.modal-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--grid); }
|
|
313
|
+
.modal-head h2 { font-size: 14px; margin: 0; }
|
|
314
|
+
.modal-head .btn { margin-left: auto; }
|
|
315
|
+
.modal-body { padding: 14px 16px; overflow: auto; }
|
|
316
|
+
.diff {
|
|
317
|
+
background: var(--surface-1); border: 1px solid var(--ring); border-radius: 8px;
|
|
318
|
+
padding: 10px; overflow: auto; max-height: 52vh; margin: 0;
|
|
319
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; line-height: 1.55;
|
|
320
|
+
}
|
|
321
|
+
.diff .dline { display: block; white-space: pre; }
|
|
322
|
+
.dline.add { color: var(--good-text); background: color-mix(in srgb, var(--good) 9%, transparent); }
|
|
323
|
+
.dline.rem { color: var(--critical); background: color-mix(in srgb, var(--critical) 9%, transparent); }
|
|
324
|
+
.dline.hunk { color: var(--blue); }
|
|
325
|
+
.modal-actions { display: flex; gap: 8px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
|
|
326
|
+
|
|
327
|
+
@media (max-width: 1000px) {
|
|
328
|
+
.grid { grid-template-columns: 1fr; }
|
|
329
|
+
.tiles { grid-template-columns: repeat(2, 1fr); }
|
|
330
|
+
.hero .num { font-size: 38px; }
|
|
331
|
+
}
|
|
332
|
+
@media (max-width: 620px) {
|
|
333
|
+
.wrap { padding: 0 14px 48px; }
|
|
334
|
+
.tiles { grid-template-columns: 1fr; }
|
|
335
|
+
.detail-grid { grid-template-columns: 1fr; }
|
|
336
|
+
}
|
|
337
|
+
</style>
|
|
338
|
+
</head>
|
|
339
|
+
<body>
|
|
340
|
+
<div class="wrap">
|
|
341
|
+
<header class="top">
|
|
342
|
+
<div class="brand">
|
|
343
|
+
<div class="mark">mpt</div>
|
|
344
|
+
<div>
|
|
345
|
+
<h1 id="program-name">mpt-workflow</h1>
|
|
346
|
+
<div class="sub" id="root-path">正在加载…</div>
|
|
347
|
+
</div>
|
|
348
|
+
</div>
|
|
349
|
+
<div class="hero">
|
|
350
|
+
<span class="num" id="hero-num">–</span>
|
|
351
|
+
<span class="of" id="hero-of">/ –</span>
|
|
352
|
+
<span class="lbl">个里程碑已验收</span>
|
|
353
|
+
</div>
|
|
354
|
+
<div class="top-tools">
|
|
355
|
+
<span class="pill" id="version" hidden></span>
|
|
356
|
+
<span class="pill" id="active-repo"><span class="dot"></span><span>无 active repo</span></span>
|
|
357
|
+
<label class="pill" title="自动刷新不会在你输入或查看详情时打断">
|
|
358
|
+
<input type="checkbox" id="autorefresh" checked /> 自动刷新
|
|
359
|
+
</label>
|
|
360
|
+
<button class="btn ghost" id="refresh">刷新</button>
|
|
361
|
+
<button class="btn ghost" id="theme">切换主题</button>
|
|
362
|
+
</div>
|
|
363
|
+
</header>
|
|
364
|
+
|
|
365
|
+
<div id="error" class="banner" role="alert" hidden>
|
|
366
|
+
<span class="grow" id="error-msg"></span>
|
|
367
|
+
<button class="btn" id="retry">重试</button>
|
|
368
|
+
</div>
|
|
369
|
+
|
|
370
|
+
<div class="tiles" id="tiles"></div>
|
|
371
|
+
|
|
372
|
+
<div class="grid">
|
|
373
|
+
<div class="col">
|
|
374
|
+
<section class="card">
|
|
375
|
+
<div class="card-head"><h2>仓库与里程碑</h2><span class="count" id="repo-count"></span></div>
|
|
376
|
+
<div class="card-body flush" id="repos"></div>
|
|
377
|
+
<div class="legend" id="legend">
|
|
378
|
+
<span><i style="background:var(--muted)"></i>草稿/无 TODO</span>
|
|
379
|
+
<span><i style="background:var(--blue)"></i>待实现</span>
|
|
380
|
+
<span><i style="background:var(--yellow)"></i>实现中</span>
|
|
381
|
+
<span><i style="background:var(--violet)"></i>待验收</span>
|
|
382
|
+
<span><i style="background:var(--good)"></i>已验收</span>
|
|
383
|
+
<span><i style="background:var(--critical)"></i>已打回</span>
|
|
384
|
+
</div>
|
|
385
|
+
</section>
|
|
386
|
+
|
|
387
|
+
<section class="card">
|
|
388
|
+
<div class="card-head"><h2>问题收件箱</h2><span class="count" id="question-count"></span>
|
|
389
|
+
<label class="pill" style="margin-left:auto;cursor:pointer">
|
|
390
|
+
<input type="checkbox" id="show-closed" style="margin:0" /> 显示已关闭
|
|
391
|
+
</label>
|
|
392
|
+
</div>
|
|
393
|
+
<div class="card-body flush" id="questions"></div>
|
|
394
|
+
</section>
|
|
395
|
+
</div>
|
|
396
|
+
|
|
397
|
+
<aside class="col">
|
|
398
|
+
<section class="card">
|
|
399
|
+
<div class="card-head"><h2>消息 · 发给 user</h2><span class="count" id="message-count"></span></div>
|
|
400
|
+
<div class="msg-filters" id="message-filters"></div>
|
|
401
|
+
<div class="msg-help">
|
|
402
|
+
发给 <b>user</b> 的消息是给你看的。<b>仅标记已读</b> 只改变未读状态;
|
|
403
|
+
<b>确认已处理</b>(ack)才会解除 blocking。审批请求的详情和操作在右侧
|
|
404
|
+
「待批准提交」,批准后会自动 ack 这条通知。
|
|
405
|
+
</div>
|
|
406
|
+
<div class="list" id="messages"></div>
|
|
407
|
+
</section>
|
|
408
|
+
|
|
409
|
+
<section class="card">
|
|
410
|
+
<div class="card-head"><h2>下一步</h2><span class="count" id="next-count"></span></div>
|
|
411
|
+
<div class="list" id="next"></div>
|
|
412
|
+
</section>
|
|
413
|
+
|
|
414
|
+
<section class="card">
|
|
415
|
+
<div class="card-head"><h2>待批准提交</h2></div>
|
|
416
|
+
<div class="list" id="approvals"></div>
|
|
417
|
+
</section>
|
|
418
|
+
|
|
419
|
+
<section class="card">
|
|
420
|
+
<div class="card-head"><h2>环境体检</h2></div>
|
|
421
|
+
<div class="list" id="doctor"></div>
|
|
422
|
+
</section>
|
|
423
|
+
|
|
424
|
+
<section class="card">
|
|
425
|
+
<div class="card-head"><h2>时间线</h2><span class="count">最近 60 条</span></div>
|
|
426
|
+
<div class="timeline" id="timeline"></div>
|
|
427
|
+
</section>
|
|
428
|
+
</aside>
|
|
429
|
+
</div>
|
|
430
|
+
|
|
431
|
+
<div class="footer">
|
|
432
|
+
<span>本地看板(仅 127.0.0.1)· 写操作:回答/关闭问题、批准提交、ack 消息、切换 active repo</span>
|
|
433
|
+
<span>数据源:Markdown + .workflow/runtime</span>
|
|
434
|
+
<span id="auto-state" aria-live="polite"></span>
|
|
435
|
+
<span id="generated" aria-live="polite"></span>
|
|
436
|
+
</div>
|
|
437
|
+
</div>
|
|
438
|
+
|
|
439
|
+
<div id="modal" class="modal" hidden>
|
|
440
|
+
<div class="modal-card" role="dialog" aria-modal="true" aria-labelledby="modal-title">
|
|
441
|
+
<div class="modal-head">
|
|
442
|
+
<h2 id="modal-title">提交详情</h2>
|
|
443
|
+
<button class="btn ghost" id="modal-close">关闭</button>
|
|
444
|
+
</div>
|
|
445
|
+
<div class="modal-body" id="modal-body"></div>
|
|
446
|
+
</div>
|
|
447
|
+
</div>
|
|
448
|
+
|
|
449
|
+
<script>
|
|
450
|
+
const $ = (s, el = document) => el.querySelector(s);
|
|
451
|
+
const el = (tag, cls, html) => { const n = document.createElement(tag); if (cls) n.className = cls; if (html != null) n.innerHTML = html; return n; };
|
|
452
|
+
const esc = (s) => String(s ?? '').replace(/[&<>"']/g, c => ({ '&':'&','<':'<','>':'>','"':'"',"'":''' }[c]));
|
|
453
|
+
|
|
454
|
+
const STATE = {
|
|
455
|
+
planned: { label: '草稿', sym: '○' },
|
|
456
|
+
todo_ready: { label: '待实现', sym: '●' },
|
|
457
|
+
implementing: { label: '实现中', sym: '◐' },
|
|
458
|
+
review: { label: '待验收', sym: '◆' },
|
|
459
|
+
accepted: { label: '已验收', sym: '✓' },
|
|
460
|
+
committed: { label: '已提交', sym: '✓' },
|
|
461
|
+
rejected: { label: '已打回', sym: '✕' },
|
|
462
|
+
};
|
|
463
|
+
const QSTATUS = { open: '待回答', answered: '已回答', applied: '已应用', closed: '已关闭', canceled: '已取消' };
|
|
464
|
+
|
|
465
|
+
let data = null;
|
|
466
|
+
let showClosed = false;
|
|
467
|
+
let messagesData = { unread: 0, blocking: [], messages: [] };
|
|
468
|
+
let messageFilter = 'unread';
|
|
469
|
+
let autoRefresh = localStorage.getItem('wf-auto') !== 'off';
|
|
470
|
+
let openDetail = null;
|
|
471
|
+
let modalOpen = false;
|
|
472
|
+
let lastFocus = null;
|
|
473
|
+
let loading = false;
|
|
474
|
+
const drafts = new Map();
|
|
475
|
+
const openForms = new Set();
|
|
476
|
+
|
|
477
|
+
async function get(path) {
|
|
478
|
+
const r = await fetch(path);
|
|
479
|
+
if (!r.ok) throw new Error(await r.text());
|
|
480
|
+
return r.json();
|
|
481
|
+
}
|
|
482
|
+
async function post(path, body) {
|
|
483
|
+
const r = await fetch(path, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(body) });
|
|
484
|
+
if (!r.ok) throw new Error(await r.text());
|
|
485
|
+
return r.json();
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
function ago(ts) {
|
|
489
|
+
if (!ts) return '';
|
|
490
|
+
const d = new Date(ts);
|
|
491
|
+
if (isNaN(d)) return ts;
|
|
492
|
+
const s = Math.floor((Date.now() - d.getTime()) / 1000);
|
|
493
|
+
if (s < 60) return s + 's';
|
|
494
|
+
if (s < 3600) return Math.floor(s / 60) + 'm';
|
|
495
|
+
if (s < 86400) return Math.floor(s / 3600) + 'h';
|
|
496
|
+
return Math.floor(s / 86400) + 'd';
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
function isEditing() {
|
|
500
|
+
const a = document.activeElement;
|
|
501
|
+
if (a && /^(INPUT|TEXTAREA|SELECT)$/.test(a.tagName)) return true;
|
|
502
|
+
return !!document.querySelector('.q-form.open');
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
function updateAutoState() {
|
|
506
|
+
const box = $('#auto-state');
|
|
507
|
+
if (!box) return;
|
|
508
|
+
if (!autoRefresh) box.textContent = '自动刷新已关闭';
|
|
509
|
+
else if (document.visibilityState === 'hidden') box.textContent = '自动刷新暂停(页面隐藏)';
|
|
510
|
+
else if (isEditing()) box.textContent = '自动刷新暂停(正在编辑)';
|
|
511
|
+
else box.textContent = '自动刷新 15s';
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
function showError(msg) {
|
|
515
|
+
$('#error-msg').textContent = msg;
|
|
516
|
+
$('#error').hidden = false;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
function hideError() {
|
|
520
|
+
$('#error').hidden = true;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
async function copyText(text, btn) {
|
|
524
|
+
const old = btn ? btn.textContent : '';
|
|
525
|
+
try {
|
|
526
|
+
await navigator.clipboard.writeText(text);
|
|
527
|
+
if (btn) btn.textContent = '已复制';
|
|
528
|
+
} catch {
|
|
529
|
+
window.prompt('复制以下内容', text);
|
|
530
|
+
}
|
|
531
|
+
if (btn) setTimeout(() => { btn.textContent = old; }, 1500);
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
function openModal(title, html) {
|
|
535
|
+
lastFocus = document.activeElement;
|
|
536
|
+
$('#modal-title').textContent = title;
|
|
537
|
+
$('#modal-body').innerHTML = html;
|
|
538
|
+
$('#modal').hidden = false;
|
|
539
|
+
modalOpen = true;
|
|
540
|
+
$('#modal-close').focus();
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
function closeModal() {
|
|
544
|
+
if (!modalOpen) return;
|
|
545
|
+
modalOpen = false;
|
|
546
|
+
$('#modal').hidden = true;
|
|
547
|
+
if (lastFocus && lastFocus.focus) lastFocus.focus();
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
function renderTiles(st) {
|
|
551
|
+
const milestones = st.repos.flatMap(r => r.milestones);
|
|
552
|
+
const accepted = milestones.filter(m => m.status === 'accepted' || m.status === 'committed').length;
|
|
553
|
+
$('#hero-num').textContent = accepted;
|
|
554
|
+
$('#hero-of').textContent = '/ ' + milestones.length;
|
|
555
|
+
$('#program-name').textContent = st.program;
|
|
556
|
+
$('#root-path').textContent = st.root;
|
|
557
|
+
const ver = $('#version');
|
|
558
|
+
if (st.version) { ver.hidden = false; ver.textContent = 'v' + st.version; }
|
|
559
|
+
else ver.hidden = true;
|
|
560
|
+
|
|
561
|
+
const active = $('#active-repo');
|
|
562
|
+
active.classList.toggle('active', !!st.activeRepo);
|
|
563
|
+
active.innerHTML = `<span class="dot"></span><span>${st.activeRepo ? 'active: ' + esc(st.activeRepo) : '无 active repo'}</span>`;
|
|
564
|
+
|
|
565
|
+
const blocking = st.blockingQuestions.length;
|
|
566
|
+
const inProgress = milestones.filter(m => ['implementing', 'review'].includes(m.status)).length;
|
|
567
|
+
const dirty = st.repos.filter(r => r.git.dirty).length;
|
|
568
|
+
|
|
569
|
+
const tiles = [
|
|
570
|
+
{ label: '阻塞问题', value: blocking, hint: blocking ? '实现必须先停下回答' : '没有阻塞', sym: blocking ? 'crit' : 'good', ch: blocking ? '!' : '✓' },
|
|
571
|
+
{ label: '未读消息', value: messagesData.unread, hint: messagesData.blocking.length ? `${messagesData.blocking.length} 条 blocking` : 'inbox 里没有新消息', sym: messagesData.blocking.length ? 'crit' : messagesData.unread ? 'info' : 'good', ch: messagesData.blocking.length ? '!' : '●' },
|
|
572
|
+
{ label: '进行中的 M', value: inProgress, hint: '实现中 + 待验收', sym: 'info', ch: '◐' },
|
|
573
|
+
{ label: '待批准提交', value: (window.__approvals || []).filter(a => !a.used_at).length, hint: '需要用户 review diff', sym: 'warn', ch: '!' },
|
|
574
|
+
{ label: '工作区有改动', value: dirty + ' / ' + st.repos.length, hint: '仓库未提交状态', sym: dirty ? 'warn' : 'good', ch: dirty ? '●' : '✓' },
|
|
575
|
+
];
|
|
576
|
+
const box = $('#tiles');
|
|
577
|
+
box.innerHTML = '';
|
|
578
|
+
for (const t of tiles) {
|
|
579
|
+
const n = el('div', 'tile');
|
|
580
|
+
n.innerHTML = `
|
|
581
|
+
<div class="label"><span class="sym ${t.sym}">${t.ch}</span>${esc(t.label)}</div>
|
|
582
|
+
<div class="value">${esc(t.value)}</div>
|
|
583
|
+
<div class="hint">${esc(t.hint)}</div>`;
|
|
584
|
+
box.appendChild(n);
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
function renderRepos(st) {
|
|
589
|
+
const box = $('#repos');
|
|
590
|
+
box.innerHTML = '';
|
|
591
|
+
$('#repo-count').textContent = st.repos.length + ' 个仓库';
|
|
592
|
+
if (!st.repos.length) {
|
|
593
|
+
box.innerHTML = `<div class="empty onboarding">
|
|
594
|
+
<b>还没有仓库</b>
|
|
595
|
+
<p>在工作区根目录运行:</p>
|
|
596
|
+
<pre>mpt-workflow init --root "${esc(st.root)}" --adopt</pre>
|
|
597
|
+
<pre>mpt-workflow init --root "${esc(st.root)}" --install-hooks</pre>
|
|
598
|
+
<p>然后用角色启动 agent:<code>WF_ROLE=plan WF_REPO=<repo> claude</code></p>
|
|
599
|
+
</div>`;
|
|
600
|
+
return;
|
|
601
|
+
}
|
|
602
|
+
for (const r of st.repos) {
|
|
603
|
+
const total = r.milestones.length;
|
|
604
|
+
const done = r.milestones.filter(m => ['accepted', 'committed'].includes(m.status)).length;
|
|
605
|
+
const pct = total ? Math.round(done / total * 100) : 0;
|
|
606
|
+
const wrap = el('div', 'repo');
|
|
607
|
+
const cur = r.currentMilestone;
|
|
608
|
+
const head = el('div', 'repo-head');
|
|
609
|
+
head.innerHTML = `
|
|
610
|
+
<h3>${esc(r.id)}</h3>
|
|
611
|
+
${st.activeRepo === r.id ? '<span class="pill active"><span class="dot"></span>active</span>' : ''}
|
|
612
|
+
<span class="repo-meta">${esc(r.git.branch || '?')}@${esc(r.git.shortHead || '?')}
|
|
613
|
+
${r.git.dirty ? '<span class="dirty"> · dirty ' + (r.git.changed.length + r.git.untracked.length) + '</span>' : ''}
|
|
614
|
+
</span>
|
|
615
|
+
<span class="repo-meta" style="margin-left:auto">${done}/${total} M</span>`;
|
|
616
|
+
wrap.appendChild(head);
|
|
617
|
+
|
|
618
|
+
const meter = el('div', 'meter');
|
|
619
|
+
meter.innerHTML = `<i style="width:${pct}%"></i>`;
|
|
620
|
+
wrap.appendChild(meter);
|
|
621
|
+
|
|
622
|
+
const track = el('div', 'track');
|
|
623
|
+
for (const m of r.milestones) {
|
|
624
|
+
const s = STATE[m.status] || STATE.planned;
|
|
625
|
+
const b = el('button', 'ms ' + m.status);
|
|
626
|
+
b.innerHTML = `<span class="sy">${s.sym}</span><span class="id">${esc(m.id)}</span><span>${s.label}</span>`;
|
|
627
|
+
b.title = m.title + (m.sha ? ' · ' + m.sha : '');
|
|
628
|
+
b.setAttribute('aria-label', `${m.id} ${m.title} · ${s.label}`);
|
|
629
|
+
b.onclick = () => toggleDetail(wrap, r, m, b);
|
|
630
|
+
track.appendChild(b);
|
|
631
|
+
}
|
|
632
|
+
wrap.appendChild(track);
|
|
633
|
+
|
|
634
|
+
const sum = el('div', 'repo-meta');
|
|
635
|
+
sum.style.marginTop = '9px';
|
|
636
|
+
sum.textContent = cur
|
|
637
|
+
? `当前 ${cur.id}「${cur.title}」 · ${(STATE[cur.status] || {}).label || cur.status}` + (cur.evidence.length ? ` · ${cur.evidence.length} 条证据` : '')
|
|
638
|
+
: (total === 0 ? '无 M(缺 PLAN)' : '全部里程碑已验收') + (r.problems.length ? ' · ' + r.problems.join(';') : '');
|
|
639
|
+
wrap.appendChild(sum);
|
|
640
|
+
if (r.problems.length && cur) {
|
|
641
|
+
const p = el('div', 'repo-meta');
|
|
642
|
+
p.style.marginTop = '4px';
|
|
643
|
+
p.innerHTML = r.problems.map(x => '<span style="color:var(--serious)">! ' + esc(x) + '</span>').join(' · ');
|
|
644
|
+
wrap.appendChild(p);
|
|
645
|
+
}
|
|
646
|
+
if (total === 0) {
|
|
647
|
+
const hint = el('div', 'repo-meta');
|
|
648
|
+
hint.style.marginTop = '6px';
|
|
649
|
+
hint.innerHTML = '先写 PLAN.md 的里程碑表或 TODO-M1.md,然后点刷新。';
|
|
650
|
+
wrap.appendChild(hint);
|
|
651
|
+
}
|
|
652
|
+
if (openDetail && openDetail.repo === r.id) {
|
|
653
|
+
const m = r.milestones.find(x => x.id === openDetail.ms);
|
|
654
|
+
if (m) appendDetail(wrap, r, m);
|
|
655
|
+
}
|
|
656
|
+
box.appendChild(wrap);
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
function appendDetail(wrap, repo, m) {
|
|
661
|
+
const d = el('details', 'ms-detail');
|
|
662
|
+
d.dataset.ms = m.id;
|
|
663
|
+
d.open = true;
|
|
664
|
+
const evs = (m.evidence || []).map(e => `
|
|
665
|
+
<div class="ev">
|
|
666
|
+
<div class="cmd">${esc(e.command || '(未记录命令)')} <span class="tag ${e.exitCode === 0 ? 'ok' : 'bad'}">exit ${e.exitCode}</span></div>
|
|
667
|
+
<div class="meta">${esc(e.id)} · ${esc(e.at)} · head ${esc(e.head || '?')}${e.dirty ? ' (dirty)' : ''}</div>
|
|
668
|
+
</div>`).join('') || '<div class="meta" style="color:var(--muted)">还没有证据</div>';
|
|
669
|
+
const acc = (m.acceptance || []).map(a => `<li>${esc(a)}</li>`).join('') || '<li style="color:var(--muted)">未声明</li>';
|
|
670
|
+
d.innerHTML = `
|
|
671
|
+
<summary>${esc(m.id)}「${esc(m.title)}」详情</summary>
|
|
672
|
+
<div class="detail-grid">
|
|
673
|
+
<div class="detail-box"><h4>验收标准</h4><ul>${acc}</ul></div>
|
|
674
|
+
<div class="detail-box"><h4>状态</h4>
|
|
675
|
+
<div style="font-size:12px;color:var(--ink-2)">
|
|
676
|
+
${esc((STATE[m.status] || {}).label || m.status)}
|
|
677
|
+
${m.sha ? '<br>受验 SHA: <code>' + esc(m.sha) + '</code>' : ''}
|
|
678
|
+
${m.todoFile ? '<br>TODO: <code>' + esc(m.todoFile) + '</code>' : ''}
|
|
679
|
+
</div>
|
|
680
|
+
</div>
|
|
681
|
+
<div class="detail-box" style="grid-column:1 / -1"><h4>证据(${(m.evidence || []).length})</h4>${evs}</div>
|
|
682
|
+
</div>`;
|
|
683
|
+
wrap.appendChild(d);
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
function toggleDetail(wrap, repo, m) {
|
|
687
|
+
const existing = wrap.querySelector('details.ms-detail');
|
|
688
|
+
const same = existing && existing.dataset.ms === m.id;
|
|
689
|
+
if (existing) existing.remove();
|
|
690
|
+
if (same) {
|
|
691
|
+
openDetail = null;
|
|
692
|
+
return;
|
|
693
|
+
}
|
|
694
|
+
openDetail = { repo: repo.id, ms: m.id };
|
|
695
|
+
appendDetail(wrap, repo, m);
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
function renderQuestions(st) {
|
|
699
|
+
const box = $('#questions');
|
|
700
|
+
// Preserve half-written answers across refreshes.
|
|
701
|
+
box.querySelectorAll('.q').forEach(qn => {
|
|
702
|
+
const id = qn.dataset.qid;
|
|
703
|
+
if (!id) return;
|
|
704
|
+
const ta = qn.querySelector('textarea');
|
|
705
|
+
const input = qn.querySelector('input');
|
|
706
|
+
if (ta) drafts.set(id, { answer: ta.value, resolution: input ? input.value : '' });
|
|
707
|
+
});
|
|
708
|
+
box.innerHTML = '';
|
|
709
|
+
const all = st.questions;
|
|
710
|
+
const list = all
|
|
711
|
+
.filter(q => showClosed ? true : (q.status !== 'closed' && q.status !== 'canceled'))
|
|
712
|
+
.sort((a, b) => {
|
|
713
|
+
const rank = q => (q.blocking && q.status === 'open' ? 0 : q.status === 'open' ? 1 : q.status === 'answered' ? 2 : 3);
|
|
714
|
+
return rank(a) - rank(b);
|
|
715
|
+
});
|
|
716
|
+
$('#question-count').textContent = `${list.length} 条 · ${all.filter(q => q.blocking && q.status === 'open').length} 阻塞`;
|
|
717
|
+
if (!list.length) {
|
|
718
|
+
box.appendChild(el('div', 'empty', '没有需要处理的问题。agent 调用 <code>ask</code> 后会出现在这里。'));
|
|
719
|
+
return;
|
|
720
|
+
}
|
|
721
|
+
for (const q of list) {
|
|
722
|
+
if (q.status === 'closed' || q.status === 'canceled') {
|
|
723
|
+
openForms.delete(q.id);
|
|
724
|
+
drafts.delete(q.id);
|
|
725
|
+
}
|
|
726
|
+
const n = el('div', 'q');
|
|
727
|
+
n.dataset.qid = q.id;
|
|
728
|
+
const opts = q.options.map(o => `<div class="q-opt"><b>${esc(o.id)}</b><span>${esc(o.text)}</span></div>`).join('');
|
|
729
|
+
const draft = drafts.get(q.id) || { answer: '', resolution: '' };
|
|
730
|
+
n.innerHTML = `
|
|
731
|
+
<div class="q-head">
|
|
732
|
+
<span class="q-id">${esc(q.id)}</span>
|
|
733
|
+
<span class="status ${q.status}"><span class="d"></span>${esc(QSTATUS[q.status] || q.status)}</span>
|
|
734
|
+
${q.blocking ? '<span class="tag bad">blocking</span>' : ''}
|
|
735
|
+
<span class="q-flow">${esc(q.from)} → ${esc(q.to)} · ${esc(q.repo || 'root')}</span>
|
|
736
|
+
</div>
|
|
737
|
+
<div class="q-context clamp" data-context>${esc(q.context)}</div>
|
|
738
|
+
${opts ? '<div class="q-opts">' + opts + '</div>' : ''}
|
|
739
|
+
${q.recommendation ? '<div class="q-rec">建议:' + esc(q.recommendation) + '</div>' : ''}
|
|
740
|
+
${q.answer ? '<div class="q-rec" style="border-color:var(--good)">回答:' + esc(q.answer) + '</div>' : ''}
|
|
741
|
+
<div class="q-actions">
|
|
742
|
+
${q.status !== 'closed' ? '<button class="btn primary" data-act="answer">回答</button>' : ''}
|
|
743
|
+
${q.recommendation && q.status !== 'closed' ? '<button class="btn" data-act="rec">采纳建议</button>' : ''}
|
|
744
|
+
${q.status !== 'closed' ? '<button class="btn" data-act="close">关闭</button>' : ''}
|
|
745
|
+
<button class="btn ghost" data-act="expand">展开/收起</button>
|
|
746
|
+
<button class="btn ghost" data-act="relay">复制转发文本</button>
|
|
747
|
+
</div>
|
|
748
|
+
<div class="q-form${openForms.has(q.id) ? ' open' : ''}">
|
|
749
|
+
<textarea placeholder="写下决定(会写入 docs/agent-questions.md 的 answer 字段)">${esc(draft.answer)}</textarea>
|
|
750
|
+
<input placeholder="resolution(回写 PLAN/TODO/decisions 的位置,可选)" value="${esc(draft.resolution)}" />
|
|
751
|
+
<div class="row"><button class="btn primary" data-act="submit">提交回答</button><span class="repo-meta" data-msg></span></div>
|
|
752
|
+
</div>`;
|
|
753
|
+
const form = n.querySelector('.q-form');
|
|
754
|
+
const msg = n.querySelector('[data-msg]');
|
|
755
|
+
const ta = form.querySelector('textarea');
|
|
756
|
+
const input = form.querySelector('input');
|
|
757
|
+
const sync = () => drafts.set(q.id, { answer: ta.value, resolution: input.value });
|
|
758
|
+
ta.addEventListener('input', sync);
|
|
759
|
+
input.addEventListener('input', sync);
|
|
760
|
+
n.querySelectorAll('[data-act]').forEach(b => {
|
|
761
|
+
b.onclick = async () => {
|
|
762
|
+
const act = b.dataset.act;
|
|
763
|
+
if (act === 'expand') {
|
|
764
|
+
n.querySelector('[data-context]').classList.toggle('clamp');
|
|
765
|
+
return;
|
|
766
|
+
}
|
|
767
|
+
if (act === 'relay') {
|
|
768
|
+
await copyText(relayText(q), b);
|
|
769
|
+
return;
|
|
770
|
+
}
|
|
771
|
+
if (act === 'answer') {
|
|
772
|
+
const opening = !form.classList.contains('open');
|
|
773
|
+
form.classList.toggle('open', opening);
|
|
774
|
+
if (opening) { openForms.add(q.id); ta.focus(); }
|
|
775
|
+
else openForms.delete(q.id);
|
|
776
|
+
return;
|
|
777
|
+
}
|
|
778
|
+
if (act === 'rec') {
|
|
779
|
+
openForms.add(q.id);
|
|
780
|
+
form.classList.add('open');
|
|
781
|
+
ta.value = q.recommendation || '';
|
|
782
|
+
sync();
|
|
783
|
+
ta.focus();
|
|
784
|
+
return;
|
|
785
|
+
}
|
|
786
|
+
try {
|
|
787
|
+
if (act === 'close') {
|
|
788
|
+
await post(`/api/question/${encodeURIComponent(q.id)}/close`, {});
|
|
789
|
+
} else {
|
|
790
|
+
const answer = ta.value.trim();
|
|
791
|
+
const resolution = input.value.trim();
|
|
792
|
+
if (!answer) { msg.textContent = '先写回答'; ta.focus(); return; }
|
|
793
|
+
await post(`/api/question/${encodeURIComponent(q.id)}/answer`, { answer, resolution });
|
|
794
|
+
}
|
|
795
|
+
drafts.delete(q.id);
|
|
796
|
+
openForms.delete(q.id);
|
|
797
|
+
await load();
|
|
798
|
+
} catch (e) { msg.textContent = '失败:' + e.message; }
|
|
799
|
+
};
|
|
800
|
+
});
|
|
801
|
+
box.appendChild(n);
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
function relayText(q) {
|
|
806
|
+
const lines = [
|
|
807
|
+
`【${q.id}】${q.from} → ${q.to}(${q.blocking ? 'blocking' : '非阻塞'})`,
|
|
808
|
+
'',
|
|
809
|
+
q.context,
|
|
810
|
+
];
|
|
811
|
+
if (q.options.length) { lines.push('', '选项:', ...q.options.map(o => `${o.id}) ${o.text}`)); }
|
|
812
|
+
if (q.recommendation) lines.push('', '建议:' + q.recommendation);
|
|
813
|
+
if (q.answer) lines.push('', '回答:' + q.answer);
|
|
814
|
+
if (q.resolution) lines.push('', 'resolution:' + q.resolution);
|
|
815
|
+
return lines.join('\n');
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
function renderMessageFilters() {
|
|
819
|
+
const box = $('#message-filters');
|
|
820
|
+
const defs = [['unread', '未读'], ['blocking', 'blocking'], ['all', '全部']];
|
|
821
|
+
box.innerHTML = defs
|
|
822
|
+
.map(([k, label]) => `<button class="chip${messageFilter === k ? ' active' : ''}" data-filter="${k}">${label}</button>`)
|
|
823
|
+
.join('');
|
|
824
|
+
box.querySelectorAll('[data-filter]').forEach(b => {
|
|
825
|
+
b.onclick = () => { messageFilter = b.dataset.filter; renderMessages(); };
|
|
826
|
+
});
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
function renderMessages() {
|
|
830
|
+
renderMessageFilters();
|
|
831
|
+
const box = $('#messages');
|
|
832
|
+
box.innerHTML = '';
|
|
833
|
+
const all = messagesData.messages || [];
|
|
834
|
+
const list = all.filter(m => {
|
|
835
|
+
if (messageFilter === 'all') return true;
|
|
836
|
+
if (messageFilter === 'blocking') return m.blocking && !['acked', 'expired'].includes(m.status);
|
|
837
|
+
return m.status === 'queued' || m.status === 'unread';
|
|
838
|
+
});
|
|
839
|
+
$('#message-count').textContent = `${messagesData.unread} 未读` +
|
|
840
|
+
(messagesData.blocking.length ? ` · ${messagesData.blocking.length} blocking` : '') +
|
|
841
|
+
` · 显示 ${list.length}`;
|
|
842
|
+
if (!list.length) {
|
|
843
|
+
const empty = messageFilter === 'all' ? '还没有消息。' : messageFilter === 'blocking' ? '没有 blocking 消息。' : '没有未读消息。';
|
|
844
|
+
box.appendChild(el('div', 'empty', empty));
|
|
845
|
+
return;
|
|
846
|
+
}
|
|
847
|
+
for (const m of list) {
|
|
848
|
+
const r = el('div', 'row-item');
|
|
849
|
+
const isApproval = m.kind === 'approval_request';
|
|
850
|
+
const refs = Object.entries(m.refs || {})
|
|
851
|
+
.filter(([k, v]) => (!isApproval || k === 'repo' || k === 'approval_id') && v && (!Array.isArray(v) || v.length));
|
|
852
|
+
const approvalId = String((m.refs && m.refs.approval_id) || '');
|
|
853
|
+
const done = m.status === 'acked';
|
|
854
|
+
r.innerHTML = `
|
|
855
|
+
<div class="v" style="flex:1">
|
|
856
|
+
<div>
|
|
857
|
+
${m.blocking ? '<span class="tag bad">blocking</span> ' : ''}
|
|
858
|
+
<span class="tag">${esc(m.status)}</span>
|
|
859
|
+
<b>${esc(m.subject)}</b>
|
|
860
|
+
</div>
|
|
861
|
+
<div class="repo-meta">${esc(m.kind)} · ${esc(m.from.role)}${m.from.repo ? '@' + esc(m.from.repo) : ''} → ${esc(m.to.role)}${m.to.repo ? '@' + esc(m.to.repo) : ''} · ${esc(ago(m.created_at))}</div>
|
|
862
|
+
${!isApproval && m.body ? '<div class="q-context clamp" style="margin:5px 0;font-size:12.5px">' + esc(m.body) + '</div>' : ''}
|
|
863
|
+
${isApproval ? '<div class="repo-meta" style="margin:5px 0">审批详情和操作在右侧「待批准提交」;批准后会自动 ack 这条通知。</div>' : ''}
|
|
864
|
+
${refs.length ? '<div class="repo-meta">' + refs.map(([k, v]) => esc(k) + '=' + esc(Array.isArray(v) ? v.join(',') : v)).join(' · ') + '</div>' : ''}
|
|
865
|
+
<div style="margin-top:6px;display:flex;gap:8px;flex-wrap:wrap;align-items:center">
|
|
866
|
+
${approvalId ? `<button class="btn" data-approval="${esc(approvalId)}">查看待批准提交</button>` : ''}
|
|
867
|
+
${done ? '<span class="tag ok">已处理</span>' : (!isApproval ? `<button class="btn" data-ack="${esc(m.id)}" title="ack 后才会解除 blocking,并记录处理时间">确认已处理</button>` : '')}
|
|
868
|
+
${m.status === 'unread' || m.status === 'queued' ? `<button class="btn ghost" data-read="${esc(m.id)}" title="只改变未读状态;不会解除 blocking,也不会批准提交">仅标记已读</button>` : ''}
|
|
869
|
+
</div>
|
|
870
|
+
</div>`;
|
|
871
|
+
const ap = r.querySelector('[data-approval]');
|
|
872
|
+
if (ap) ap.onclick = () => {
|
|
873
|
+
const a = (window.__approvals || []).find(x => x.id === ap.dataset.approval);
|
|
874
|
+
if (a) openDiff(a);
|
|
875
|
+
else showError(`审批 ${ap.dataset.approval} 不存在或已使用`);
|
|
876
|
+
};
|
|
877
|
+
const ack = r.querySelector('[data-ack]');
|
|
878
|
+
if (ack) ack.onclick = async () => {
|
|
879
|
+
ack.disabled = true;
|
|
880
|
+
try { await post(`/api/message/${encodeURIComponent(m.id)}/ack`, {}); await load(); }
|
|
881
|
+
catch (e) { showError(e.message); ack.disabled = false; }
|
|
882
|
+
};
|
|
883
|
+
const rd = r.querySelector('[data-read]');
|
|
884
|
+
if (rd) rd.onclick = async () => {
|
|
885
|
+
try { await post(`/api/message/${encodeURIComponent(m.id)}/read`, {}); await load(); }
|
|
886
|
+
catch (e) { showError(e.message); }
|
|
887
|
+
};
|
|
888
|
+
box.appendChild(r);
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
function renderNext(st) {
|
|
893
|
+
const box = $('#next');
|
|
894
|
+
box.innerHTML = '';
|
|
895
|
+
$('#next-count').textContent = st.next.length ? st.next.length + ' 项' : '';
|
|
896
|
+
if (!st.next.length) {
|
|
897
|
+
box.appendChild(el('div', 'empty', '没有识别到待办。运行 <code>mpt-workflow doctor</code> 检查配置。'));
|
|
898
|
+
return;
|
|
899
|
+
}
|
|
900
|
+
for (const n of st.next) {
|
|
901
|
+
const cmd = n.actor === 'user'
|
|
902
|
+
? `mpt-workflow web --root ${JSON.stringify(st.root)}`
|
|
903
|
+
: `WF_ROLE=${n.actor}${n.repo ? ` WF_REPO=${n.repo}` : ''} claude`;
|
|
904
|
+
const r = el('div', 'row-item');
|
|
905
|
+
r.innerHTML = `
|
|
906
|
+
<span class="next-actor">${esc(n.actor)}</span>
|
|
907
|
+
<div class="v" style="flex:1">
|
|
908
|
+
<div style="color:var(--ink);font-weight:600">${esc(n.action)}${n.repo ? ' <span class="repo-meta">' + esc(n.repo) + (n.milestone ? '/' + esc(n.milestone) : '') + '</span>' : ''}</div>
|
|
909
|
+
<div>${esc(n.detail)}</div>
|
|
910
|
+
<div class="repo-meta" style="margin-top:5px;display:flex;gap:6px;align-items:center;flex-wrap:wrap">
|
|
911
|
+
<code>${esc(cmd)}</code>
|
|
912
|
+
<button class="btn ghost" data-copy="${esc(cmd)}">复制</button>
|
|
913
|
+
</div>
|
|
914
|
+
</div>`;
|
|
915
|
+
r.querySelector('[data-copy]').onclick = (e) => copyText(e.currentTarget.dataset.copy, e.currentTarget);
|
|
916
|
+
box.appendChild(r);
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
function diffLines(diff) {
|
|
921
|
+
if (!diff) return '<span class="dline">(no diff)</span>';
|
|
922
|
+
return diff.slice(0, 200000).split('\n').map(line => {
|
|
923
|
+
let cls = '';
|
|
924
|
+
if (line.startsWith('@@')) cls = 'hunk';
|
|
925
|
+
else if (line.startsWith('+') && !line.startsWith('+++')) cls = 'add';
|
|
926
|
+
else if (line.startsWith('-') && !line.startsWith('---')) cls = 'rem';
|
|
927
|
+
return `<span class="dline ${cls}">${esc(line) || ' '}</span>`;
|
|
928
|
+
}).join('');
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
async function openDiff(a) {
|
|
932
|
+
openModal(`提交 ${a.id}`, '<div class="empty">正在加载 diff…</div>');
|
|
933
|
+
try {
|
|
934
|
+
const d = await get(`/api/diff?repo=${encodeURIComponent(a.repo)}`);
|
|
935
|
+
const files = (a.files || []).map(f => `<li><code>${esc(f)}</code></li>`).join('');
|
|
936
|
+
const log = (d.log || []).map(x => `<div class="repo-meta">${esc(x)}</div>`).join('');
|
|
937
|
+
$('#modal-body').innerHTML = `
|
|
938
|
+
<div class="repo-meta">${esc(a.repo)} · ${esc(a.message)}</div>
|
|
939
|
+
<div class="repo-meta">tree <code>${esc(a.tree_hash)}</code> · ${(a.files || []).length} 个文件</div>
|
|
940
|
+
<div class="modal-actions">
|
|
941
|
+
${a.approved_at ? '<span class="tag ok">已批准</span>' : '<button class="btn primary" id="modal-approve">批准这个提交</button>'}
|
|
942
|
+
<span class="repo-meta">批准绑定当前工作区 hash;批准后 agent 才能 commit。</span>
|
|
943
|
+
</div>
|
|
944
|
+
<h3 style="font-size:12px;margin:14px 0 6px">改动文件</h3>
|
|
945
|
+
<ul style="margin:0;padding-left:18px;font-size:12px">${files}</ul>
|
|
946
|
+
<h3 style="font-size:12px;margin:14px 0 6px">diff 摘要</h3>
|
|
947
|
+
<pre class="diff">${esc(d.stat || '(no stat)')}</pre>
|
|
948
|
+
<h3 style="font-size:12px;margin:14px 0 6px">diff</h3>
|
|
949
|
+
<pre class="diff">${diffLines(d.diff || '')}</pre>
|
|
950
|
+
${log ? '<h3 style="font-size:12px;margin:14px 0 6px">最近提交</h3>' + log : ''}`;
|
|
951
|
+
const btn = $('#modal-approve');
|
|
952
|
+
if (btn) btn.onclick = async () => {
|
|
953
|
+
btn.disabled = true;
|
|
954
|
+
btn.textContent = '批准中…';
|
|
955
|
+
try { await post('/api/approve', { id: a.id }); closeModal(); await load(); }
|
|
956
|
+
catch (e) { btn.disabled = false; btn.textContent = '批准提交'; showError(e.message); }
|
|
957
|
+
};
|
|
958
|
+
} catch (e) {
|
|
959
|
+
$('#modal-body').innerHTML = '<div class="empty">加载 diff 失败:' + esc(e.message) + '</div>';
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
function renderApprovals() {
|
|
964
|
+
const box = $('#approvals');
|
|
965
|
+
const list = (window.__approvals || []).filter(a => !a.used_at);
|
|
966
|
+
box.innerHTML = '';
|
|
967
|
+
if (!list.length) { box.appendChild(el('div', 'empty', '没有待批准的提交。')); return; }
|
|
968
|
+
for (const a of list) {
|
|
969
|
+
const files = (a.files || []).map(f => `<li><code>${esc(f)}</code></li>`).join('');
|
|
970
|
+
const r = el('div', 'row-item');
|
|
971
|
+
r.innerHTML = `
|
|
972
|
+
<div class="v" style="flex:1">
|
|
973
|
+
<div><code>${esc(a.id)}</code> · ${esc(a.repo)} ${a.approved_at ? '<span class="tag ok">已批准</span>' : '<span class="tag">待批准</span>'}</div>
|
|
974
|
+
<div style="color:var(--ink-2)">${esc(a.message)}</div>
|
|
975
|
+
<div class="repo-meta">${(a.files || []).length} 个文件 · tree ${esc(a.tree_hash)}</div>
|
|
976
|
+
<details class="repo-meta" style="margin-top:4px">
|
|
977
|
+
<summary>查看文件列表</summary>
|
|
978
|
+
<ul style="margin:4px 0 0;padding-left:18px">${files}</ul>
|
|
979
|
+
</details>
|
|
980
|
+
<div style="margin-top:6px;display:flex;gap:8px;flex-wrap:wrap">
|
|
981
|
+
<button class="btn" data-diff="${esc(a.id)}">查看 diff</button>
|
|
982
|
+
${a.approved_at ? '' : `<button class="btn primary" data-approve="${esc(a.id)}">批准提交</button>`}
|
|
983
|
+
</div>
|
|
984
|
+
</div>`;
|
|
985
|
+
const diffBtn = r.querySelector('[data-diff]');
|
|
986
|
+
if (diffBtn) diffBtn.onclick = () => openDiff(a);
|
|
987
|
+
const b = r.querySelector('[data-approve]');
|
|
988
|
+
if (b) b.onclick = async () => {
|
|
989
|
+
b.disabled = true;
|
|
990
|
+
b.textContent = '批准中…';
|
|
991
|
+
try { await post('/api/approve', { id: a.id }); await load(); }
|
|
992
|
+
catch (e) { showError(e.message); b.disabled = false; b.textContent = '批准提交'; }
|
|
993
|
+
};
|
|
994
|
+
box.appendChild(r);
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
function renderDoctor(rows) {
|
|
999
|
+
const box = $('#doctor');
|
|
1000
|
+
box.innerHTML = '';
|
|
1001
|
+
const order = { FAIL: 0, WARN: 1, OK: 2 };
|
|
1002
|
+
rows.sort((a, b) => order[a.level] - order[b.level]);
|
|
1003
|
+
for (const f of rows.slice(0, 12)) {
|
|
1004
|
+
const r = el('div', 'doctor-row');
|
|
1005
|
+
r.innerHTML = `<span class="lv ${f.level}">${f.level}</span>
|
|
1006
|
+
<div><div>${esc(f.message)}${f.repo ? ' <span class="repo-meta">[' + esc(f.repo) + ']</span>' : ''}</div>
|
|
1007
|
+
${f.hint ? '<div class="repo-meta">' + esc(f.hint) + '</div>' : ''}</div>`;
|
|
1008
|
+
box.appendChild(r);
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
function renderTimeline(events) {
|
|
1013
|
+
const box = $('#timeline');
|
|
1014
|
+
box.innerHTML = '';
|
|
1015
|
+
if (!events.length) { box.appendChild(el('div', 'empty', '暂无事件。')); return; }
|
|
1016
|
+
for (const e of events.slice(0, 60)) {
|
|
1017
|
+
const r = el('div', 'ev-row');
|
|
1018
|
+
const where = [e.repo, e.milestone, e.question].filter(Boolean).join('/');
|
|
1019
|
+
r.innerHTML = `<span class="t">${esc(ago(e.ts))}</span>
|
|
1020
|
+
<span class="what"><b>${esc(e.role)}</b> ${esc(e.tool)}${where ? ' · ' + esc(where) : ''}
|
|
1021
|
+
${e.ok === false ? '<span class="tag bad">失败</span>' : ''}</span>`;
|
|
1022
|
+
box.appendChild(r);
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
|
|
1026
|
+
async function load(opts = {}) {
|
|
1027
|
+
if (loading) return;
|
|
1028
|
+
loading = true;
|
|
1029
|
+
const y = window.scrollY;
|
|
1030
|
+
try {
|
|
1031
|
+
const [st, approvals, events, doctor, messages] = await Promise.all([
|
|
1032
|
+
get('/api/status'), get('/api/approvals'), get('/api/events?limit=120'), get('/api/doctor'),
|
|
1033
|
+
get('/api/messages?role=user&all=1&limit=100'),
|
|
1034
|
+
]);
|
|
1035
|
+
data = st;
|
|
1036
|
+
window.__approvals = approvals;
|
|
1037
|
+
messagesData = messages;
|
|
1038
|
+
renderTiles(st);
|
|
1039
|
+
renderRepos(st);
|
|
1040
|
+
renderQuestions(st);
|
|
1041
|
+
renderMessages();
|
|
1042
|
+
renderNext(st);
|
|
1043
|
+
renderApprovals();
|
|
1044
|
+
renderDoctor(doctor);
|
|
1045
|
+
renderTimeline(events);
|
|
1046
|
+
hideError();
|
|
1047
|
+
$('#generated').textContent = '更新于 ' + new Date(st.generatedAt).toLocaleTimeString();
|
|
1048
|
+
if (!opts.silent && y > 0) { try { window.scrollTo(0, y); } catch { /* jsdom/no-op */ } }
|
|
1049
|
+
} catch (e) {
|
|
1050
|
+
showError('加载失败:' + e.message);
|
|
1051
|
+
} finally {
|
|
1052
|
+
loading = false;
|
|
1053
|
+
updateAutoState();
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
const autoBox = $('#autorefresh');
|
|
1058
|
+
autoBox.checked = autoRefresh;
|
|
1059
|
+
autoBox.onchange = () => {
|
|
1060
|
+
autoRefresh = autoBox.checked;
|
|
1061
|
+
localStorage.setItem('wf-auto', autoRefresh ? 'on' : 'off');
|
|
1062
|
+
updateAutoState();
|
|
1063
|
+
};
|
|
1064
|
+
|
|
1065
|
+
$('#refresh').onclick = () => load();
|
|
1066
|
+
$('#retry').onclick = () => load();
|
|
1067
|
+
$('#show-closed').onchange = (e) => { showClosed = e.target.checked; if (data) renderQuestions(data); };
|
|
1068
|
+
$('#theme').onclick = () => {
|
|
1069
|
+
const cur = document.documentElement.getAttribute('data-theme');
|
|
1070
|
+
const next = cur === 'dark' ? 'light' : cur === 'light' ? 'dark' : (matchMedia('(prefers-color-scheme: dark)').matches ? 'light' : 'dark');
|
|
1071
|
+
document.documentElement.setAttribute('data-theme', next);
|
|
1072
|
+
localStorage.setItem('wf-theme', next);
|
|
1073
|
+
};
|
|
1074
|
+
$('#modal-close').onclick = closeModal;
|
|
1075
|
+
$('#modal').addEventListener('click', (e) => { if (e.target === $('#modal')) closeModal(); });
|
|
1076
|
+
document.addEventListener('keydown', (e) => { if (e.key === 'Escape') closeModal(); });
|
|
1077
|
+
document.addEventListener('visibilitychange', () => {
|
|
1078
|
+
updateAutoState();
|
|
1079
|
+
if (document.visibilityState === 'visible' && autoRefresh && !isEditing() && !modalOpen) load({ silent: true });
|
|
1080
|
+
});
|
|
1081
|
+
const saved = localStorage.getItem('wf-theme');
|
|
1082
|
+
if (saved) document.documentElement.setAttribute('data-theme', saved);
|
|
1083
|
+
|
|
1084
|
+
load();
|
|
1085
|
+
setInterval(() => {
|
|
1086
|
+
if (!autoRefresh || document.visibilityState === 'hidden' || isEditing() || modalOpen) {
|
|
1087
|
+
updateAutoState();
|
|
1088
|
+
return;
|
|
1089
|
+
}
|
|
1090
|
+
load({ silent: true });
|
|
1091
|
+
}, 15000);
|
|
1092
|
+
</script>
|
|
1093
|
+
</body>
|
|
1094
|
+
</html>
|