@richjava/req0 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cockpit/app.js +110 -49
- package/cockpit/index.html +16 -5
- package/cockpit/styles.css +34 -0
- package/dist/server.d.ts +2 -1
- package/dist/server.js +25 -14
- package/dist/types.d.ts +1 -0
- package/package.json +1 -1
package/cockpit/app.js
CHANGED
|
@@ -21,6 +21,12 @@ const els = {
|
|
|
21
21
|
qaStatus: document.getElementById("qa-status"),
|
|
22
22
|
implementActivity: document.getElementById("implement-activity"),
|
|
23
23
|
qaActivity: document.getElementById("qa-activity"),
|
|
24
|
+
qaTabs: document.getElementById("qa-tabs"),
|
|
25
|
+
qaTabActivity: document.getElementById("qa-tab-activity"),
|
|
26
|
+
qaTabReport: document.getElementById("qa-tab-report"),
|
|
27
|
+
qaActivityLabel: document.getElementById("qa-activity-label"),
|
|
28
|
+
qaActivityPanel: document.getElementById("qa-activity-panel"),
|
|
29
|
+
qaReportPanel: document.getElementById("qa-report-panel"),
|
|
24
30
|
proofReport: document.getElementById("proof-report"),
|
|
25
31
|
actionReady: document.getElementById("action-ready"),
|
|
26
32
|
actionBuild: document.getElementById("action-build"),
|
|
@@ -92,17 +98,31 @@ let focusedSection = "Business Rules";
|
|
|
92
98
|
let actionNotice = "";
|
|
93
99
|
let actionBusy = false;
|
|
94
100
|
let headerBusyLabel = "";
|
|
95
|
-
let
|
|
96
|
-
let
|
|
101
|
+
let implementLines = [];
|
|
102
|
+
let proveLines = [];
|
|
103
|
+
let lastImplementKey = "";
|
|
104
|
+
let lastProveKey = "";
|
|
105
|
+
let qaTab = "activity";
|
|
97
106
|
let loadInFlight = false;
|
|
98
107
|
let loadAgain = false;
|
|
99
108
|
let loadTimer;
|
|
100
109
|
let stateEpoch = 0;
|
|
101
110
|
|
|
111
|
+
function applyActivities(payload) {
|
|
112
|
+
if (!payload) return;
|
|
113
|
+
if (Array.isArray(payload.implementActivity)) implementLines = payload.implementActivity;
|
|
114
|
+
if (Array.isArray(payload.proveActivity)) proveLines = payload.proveActivity;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function lastBusyMessage(kind) {
|
|
118
|
+
const lines = kind === "prove" ? proveLines : implementLines;
|
|
119
|
+
return lines[lines.length - 1]?.message ?? "";
|
|
120
|
+
}
|
|
121
|
+
|
|
102
122
|
function takeState(next) {
|
|
103
123
|
stateEpoch += 1;
|
|
104
124
|
state = next;
|
|
105
|
-
|
|
125
|
+
applyActivities(state);
|
|
106
126
|
}
|
|
107
127
|
|
|
108
128
|
async function load() {
|
|
@@ -117,7 +137,7 @@ async function load() {
|
|
|
117
137
|
const body = await res.json();
|
|
118
138
|
if (epoch !== stateEpoch) return;
|
|
119
139
|
state = body;
|
|
120
|
-
|
|
140
|
+
applyActivities(state);
|
|
121
141
|
render();
|
|
122
142
|
} catch (err) {
|
|
123
143
|
if (els.going) {
|
|
@@ -254,6 +274,7 @@ function render() {
|
|
|
254
274
|
renderJudgmentPane();
|
|
255
275
|
renderRunStatus();
|
|
256
276
|
renderProofReport();
|
|
277
|
+
renderQaLayout();
|
|
257
278
|
renderActivity();
|
|
258
279
|
}
|
|
259
280
|
|
|
@@ -382,6 +403,7 @@ async function selectPack(id) {
|
|
|
382
403
|
}
|
|
383
404
|
takeState(body);
|
|
384
405
|
currentView = "define";
|
|
406
|
+
qaTab = "activity";
|
|
385
407
|
actionNotice = "";
|
|
386
408
|
render();
|
|
387
409
|
}
|
|
@@ -396,6 +418,7 @@ async function goHome() {
|
|
|
396
418
|
}
|
|
397
419
|
takeState(body);
|
|
398
420
|
currentView = "define";
|
|
421
|
+
qaTab = "activity";
|
|
399
422
|
actionNotice = "";
|
|
400
423
|
render();
|
|
401
424
|
}
|
|
@@ -1074,14 +1097,30 @@ function renderProofReport() {
|
|
|
1074
1097
|
if (!els.proofReport) return;
|
|
1075
1098
|
const report = state?.proofReport?.trim();
|
|
1076
1099
|
if (!report) {
|
|
1077
|
-
els.proofReport.
|
|
1078
|
-
els.proofReport.innerHTML = `<div class="list-row list-row-idle">No proof report yet. Prove writes derived/proof-report.md here.</div>`;
|
|
1100
|
+
els.proofReport.innerHTML = "";
|
|
1079
1101
|
return;
|
|
1080
1102
|
}
|
|
1081
1103
|
els.proofReport.className = "proof-report md-preview";
|
|
1082
1104
|
els.proofReport.innerHTML = renderProofMarkdown(report);
|
|
1083
1105
|
}
|
|
1084
1106
|
|
|
1107
|
+
function renderQaLayout() {
|
|
1108
|
+
const hasReport = Boolean(state?.proofReport?.trim());
|
|
1109
|
+
if (!hasReport) qaTab = "activity";
|
|
1110
|
+
els.qaTabs?.classList.toggle("hidden", !hasReport);
|
|
1111
|
+
if (els.qaTabs) els.qaTabs.hidden = !hasReport;
|
|
1112
|
+
els.qaActivityLabel?.classList.toggle("hidden", hasReport);
|
|
1113
|
+
const showReport = hasReport && qaTab === "report";
|
|
1114
|
+
els.qaActivityPanel?.classList.toggle("hidden", showReport);
|
|
1115
|
+
if (els.qaActivityPanel) els.qaActivityPanel.hidden = showReport;
|
|
1116
|
+
els.qaReportPanel?.classList.toggle("hidden", !showReport);
|
|
1117
|
+
if (els.qaReportPanel) els.qaReportPanel.hidden = !showReport;
|
|
1118
|
+
els.qaTabActivity?.classList.toggle("is-active", qaTab !== "report");
|
|
1119
|
+
els.qaTabReport?.classList.toggle("is-active", qaTab === "report");
|
|
1120
|
+
els.qaTabActivity?.setAttribute("aria-selected", qaTab !== "report" ? "true" : "false");
|
|
1121
|
+
els.qaTabReport?.setAttribute("aria-selected", qaTab === "report" ? "true" : "false");
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1085
1124
|
function renderProofMarkdown(source) {
|
|
1086
1125
|
const blocks = [];
|
|
1087
1126
|
let list = [];
|
|
@@ -1146,32 +1185,40 @@ function jumpToSpecId(id) {
|
|
|
1146
1185
|
return false;
|
|
1147
1186
|
}
|
|
1148
1187
|
|
|
1149
|
-
function
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
const
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
li.textContent = line.message;
|
|
1167
|
-
log.append(li);
|
|
1168
|
-
}
|
|
1169
|
-
log.scrollTop = pinned ? log.scrollHeight : savedTop;
|
|
1188
|
+
function fillActivityLog(log, lines, emptyMessage, which) {
|
|
1189
|
+
if (!log) return;
|
|
1190
|
+
const rows = lines.length ? lines : [{ level: "info", message: emptyMessage }];
|
|
1191
|
+
const key = rows.map((line) => `${line.level}\0${line.message}`).join("\n");
|
|
1192
|
+
const previous = which === "prove" ? lastProveKey : lastImplementKey;
|
|
1193
|
+
if (key === previous && log.childElementCount === rows.length) return;
|
|
1194
|
+
if (which === "prove") lastProveKey = key;
|
|
1195
|
+
else lastImplementKey = key;
|
|
1196
|
+
const pinned = log.scrollHeight - log.scrollTop - log.clientHeight < 16;
|
|
1197
|
+
const savedTop = log.scrollTop;
|
|
1198
|
+
log.innerHTML = "";
|
|
1199
|
+
for (const line of rows) {
|
|
1200
|
+
const li = document.createElement("li");
|
|
1201
|
+
const kind = line.level === "error" ? "bad" : line.level === "ok" ? "ok" : "idle";
|
|
1202
|
+
li.className = `list-row list-row-${kind}`;
|
|
1203
|
+
li.textContent = line.message;
|
|
1204
|
+
log.append(li);
|
|
1170
1205
|
}
|
|
1206
|
+
log.scrollTop = pinned ? log.scrollHeight : savedTop;
|
|
1171
1207
|
}
|
|
1172
1208
|
|
|
1173
|
-
function
|
|
1174
|
-
|
|
1209
|
+
function renderActivity() {
|
|
1210
|
+
fillActivityLog(
|
|
1211
|
+
els.implementActivity,
|
|
1212
|
+
implementLines,
|
|
1213
|
+
"No activity yet. Implement writes progress here.",
|
|
1214
|
+
"implement",
|
|
1215
|
+
);
|
|
1216
|
+
fillActivityLog(els.qaActivity, proveLines, "No activity yet. Prove writes progress here.", "prove");
|
|
1217
|
+
}
|
|
1218
|
+
|
|
1219
|
+
function appendActivity(line, channel) {
|
|
1220
|
+
if (channel === "prove") proveLines = [...proveLines, line].slice(-80);
|
|
1221
|
+
else implementLines = [...implementLines, line].slice(-80);
|
|
1175
1222
|
if (line.message) {
|
|
1176
1223
|
actionNotice = line.message;
|
|
1177
1224
|
setActionHint(line.message);
|
|
@@ -1296,7 +1343,7 @@ async function runStageAction(id) {
|
|
|
1296
1343
|
return;
|
|
1297
1344
|
}
|
|
1298
1345
|
if (id === "improve") {
|
|
1299
|
-
|
|
1346
|
+
implementLines = [{ level: "info", message: "Improve started." }];
|
|
1300
1347
|
actionNotice = "Writing the improve brief…";
|
|
1301
1348
|
setActionHint(actionNotice);
|
|
1302
1349
|
renderActivity();
|
|
@@ -1322,7 +1369,7 @@ async function runStageAction(id) {
|
|
|
1322
1369
|
});
|
|
1323
1370
|
const payload = await res.json();
|
|
1324
1371
|
if (payload.health || payload.packId) state = { ...state, ...payload };
|
|
1325
|
-
|
|
1372
|
+
applyActivities(payload);
|
|
1326
1373
|
actionNotice = payload.error ?? payload.message ?? "Owner stopped Implement.";
|
|
1327
1374
|
} catch (err) {
|
|
1328
1375
|
actionNotice = err instanceof Error ? err.message : "Stop failed.";
|
|
@@ -1332,7 +1379,7 @@ async function runStageAction(id) {
|
|
|
1332
1379
|
return;
|
|
1333
1380
|
}
|
|
1334
1381
|
if (id === "implement") {
|
|
1335
|
-
|
|
1382
|
+
implementLines = [{ level: "info", message: "Implement started." }];
|
|
1336
1383
|
actionNotice = "Implement started.";
|
|
1337
1384
|
setMeter("build", "running");
|
|
1338
1385
|
renderActivity();
|
|
@@ -1351,7 +1398,7 @@ async function runStageAction(id) {
|
|
|
1351
1398
|
return;
|
|
1352
1399
|
}
|
|
1353
1400
|
if (id === "fix-from-proof") {
|
|
1354
|
-
|
|
1401
|
+
implementLines = [{ level: "info", message: "Fix from proof started." }];
|
|
1355
1402
|
actionNotice = "Fix from proof started.";
|
|
1356
1403
|
setMeter("build", "running");
|
|
1357
1404
|
renderActivity();
|
|
@@ -1365,7 +1412,8 @@ async function runStageAction(id) {
|
|
|
1365
1412
|
return;
|
|
1366
1413
|
}
|
|
1367
1414
|
if (id === "prove") {
|
|
1368
|
-
|
|
1415
|
+
proveLines = [{ level: "info", message: "Prove started." }];
|
|
1416
|
+
qaTab = "activity";
|
|
1369
1417
|
actionNotice = "Prove started.";
|
|
1370
1418
|
setMeter("proof", "running");
|
|
1371
1419
|
renderActivity();
|
|
@@ -1375,6 +1423,8 @@ async function runStageAction(id) {
|
|
|
1375
1423
|
}
|
|
1376
1424
|
|
|
1377
1425
|
async function runProveAction() {
|
|
1426
|
+
openView("qa");
|
|
1427
|
+
qaTab = "activity";
|
|
1378
1428
|
actionBusy = true;
|
|
1379
1429
|
headerBusyLabel = "Proving…";
|
|
1380
1430
|
paintActionButton(els.next, {
|
|
@@ -1394,8 +1444,8 @@ async function runProveAction() {
|
|
|
1394
1444
|
body: "{}",
|
|
1395
1445
|
});
|
|
1396
1446
|
const payload = await res.json();
|
|
1397
|
-
|
|
1398
|
-
|
|
1447
|
+
applyActivities(payload);
|
|
1448
|
+
if (Array.isArray(payload.proveActivity) && payload.proveActivity.length) {
|
|
1399
1449
|
renderActivity();
|
|
1400
1450
|
}
|
|
1401
1451
|
if (!res.ok && !payload.started) {
|
|
@@ -1425,16 +1475,16 @@ async function waitWhileBusy(kind) {
|
|
|
1425
1475
|
const res = await fetch("/api/state");
|
|
1426
1476
|
const data = await res.json();
|
|
1427
1477
|
if (data.health || data.packId || data.improveReview) state = { ...state, ...data };
|
|
1428
|
-
|
|
1478
|
+
applyActivities(data);
|
|
1429
1479
|
if (data.improveReview?.files?.length) {
|
|
1430
1480
|
actionNotice = "";
|
|
1431
1481
|
render();
|
|
1432
1482
|
return;
|
|
1433
1483
|
}
|
|
1434
|
-
const last =
|
|
1435
|
-
if (last
|
|
1436
|
-
actionNotice = last
|
|
1437
|
-
setActionHint(last
|
|
1484
|
+
const last = lastBusyMessage(kind === "prove" ? "prove" : "implement");
|
|
1485
|
+
if (last && !data.improveReview) {
|
|
1486
|
+
actionNotice = last;
|
|
1487
|
+
setActionHint(last);
|
|
1438
1488
|
}
|
|
1439
1489
|
render();
|
|
1440
1490
|
if (data.busy !== kind) return;
|
|
@@ -1450,13 +1500,13 @@ async function refreshActivity() {
|
|
|
1450
1500
|
const res = await fetch("/api/state");
|
|
1451
1501
|
const data = await res.json();
|
|
1452
1502
|
if (data.health || data.packId || data.improveReview) state = { ...state, ...data };
|
|
1453
|
-
|
|
1503
|
+
applyActivities(data);
|
|
1454
1504
|
if (data.improveReview?.files?.length) actionNotice = "";
|
|
1455
1505
|
else {
|
|
1456
|
-
const last =
|
|
1457
|
-
if (last
|
|
1458
|
-
actionNotice = last
|
|
1459
|
-
setActionHint(last
|
|
1506
|
+
const last = lastBusyMessage(data.busy === "prove" ? "prove" : "implement");
|
|
1507
|
+
if (last) {
|
|
1508
|
+
actionNotice = last;
|
|
1509
|
+
setActionHint(last);
|
|
1460
1510
|
}
|
|
1461
1511
|
}
|
|
1462
1512
|
render();
|
|
@@ -1487,8 +1537,11 @@ async function runBackgroundAction(busyLabel, url, body, kind) {
|
|
|
1487
1537
|
});
|
|
1488
1538
|
const payload = await res.json();
|
|
1489
1539
|
if (payload.health || payload.packId) state = { ...state, ...payload };
|
|
1490
|
-
|
|
1491
|
-
|
|
1540
|
+
applyActivities(payload);
|
|
1541
|
+
if (
|
|
1542
|
+
(Array.isArray(payload.implementActivity) && payload.implementActivity.length) ||
|
|
1543
|
+
(Array.isArray(payload.proveActivity) && payload.proveActivity.length)
|
|
1544
|
+
) {
|
|
1492
1545
|
renderActivity();
|
|
1493
1546
|
}
|
|
1494
1547
|
if (!res.ok && !payload.started) {
|
|
@@ -1536,7 +1589,7 @@ async function runNextAction(busyLabel, url, body) {
|
|
|
1536
1589
|
});
|
|
1537
1590
|
const payload = await res.json();
|
|
1538
1591
|
if (payload.health || payload.packId) state = { ...state, ...payload };
|
|
1539
|
-
|
|
1592
|
+
applyActivities(payload);
|
|
1540
1593
|
if (!res.ok || payload.error) {
|
|
1541
1594
|
actionNotice = payload.error ?? "Request failed.";
|
|
1542
1595
|
actionBusy = false;
|
|
@@ -1630,6 +1683,14 @@ els.stackNextjs?.addEventListener("click", () => void recordStack("nextjs-defaul
|
|
|
1630
1683
|
els.stackAmplify?.addEventListener("click", () => void recordStack("amplify-gen2"));
|
|
1631
1684
|
|
|
1632
1685
|
els.homeBtn?.addEventListener("click", () => void goHome());
|
|
1686
|
+
els.qaTabActivity?.addEventListener("click", () => {
|
|
1687
|
+
qaTab = "activity";
|
|
1688
|
+
renderQaLayout();
|
|
1689
|
+
});
|
|
1690
|
+
els.qaTabReport?.addEventListener("click", () => {
|
|
1691
|
+
qaTab = "report";
|
|
1692
|
+
renderQaLayout();
|
|
1693
|
+
});
|
|
1633
1694
|
els.allRequirements?.addEventListener("click", () => void goHome());
|
|
1634
1695
|
els.packMenu?.addEventListener("contextmenu", (event) => event.preventDefault());
|
|
1635
1696
|
els.packMenuDelete?.addEventListener("click", () => openDeleteDialog());
|
package/cockpit/index.html
CHANGED
|
@@ -134,7 +134,7 @@
|
|
|
134
134
|
</div>
|
|
135
135
|
</div>
|
|
136
136
|
<p class="nav-label">Activity</p>
|
|
137
|
-
<ol id="implement-activity" class="list-rows activity-log"></ol>
|
|
137
|
+
<ol id="implement-activity" class="list-rows activity-log activity-log-main"></ol>
|
|
138
138
|
</section>
|
|
139
139
|
|
|
140
140
|
<section class="panel stage-view hidden" id="view-qa" data-view="qa" hidden>
|
|
@@ -145,10 +145,21 @@
|
|
|
145
145
|
<button type="button" class="pill-btn cta" id="action-fix-proof" hidden disabled></button>
|
|
146
146
|
</div>
|
|
147
147
|
</div>
|
|
148
|
-
<
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
148
|
+
<div class="qa-tab-bar hidden" id="qa-tabs" role="tablist" hidden>
|
|
149
|
+
<button type="button" class="qa-tab is-active" role="tab" id="qa-tab-activity" aria-selected="true" aria-controls="qa-activity-panel">
|
|
150
|
+
Activity
|
|
151
|
+
</button>
|
|
152
|
+
<button type="button" class="qa-tab" role="tab" id="qa-tab-report" aria-selected="false" aria-controls="qa-report-panel">
|
|
153
|
+
Report
|
|
154
|
+
</button>
|
|
155
|
+
</div>
|
|
156
|
+
<p class="nav-label" id="qa-activity-label">Activity</p>
|
|
157
|
+
<div id="qa-activity-panel">
|
|
158
|
+
<ol id="qa-activity" class="list-rows activity-log activity-log-main"></ol>
|
|
159
|
+
</div>
|
|
160
|
+
<div id="qa-report-panel" class="hidden" hidden>
|
|
161
|
+
<div id="proof-report" class="proof-report md-preview"></div>
|
|
162
|
+
</div>
|
|
152
163
|
</section>
|
|
153
164
|
</div>
|
|
154
165
|
</div>
|
package/cockpit/styles.css
CHANGED
|
@@ -1165,6 +1165,40 @@ body {
|
|
|
1165
1165
|
list-style: none;
|
|
1166
1166
|
}
|
|
1167
1167
|
|
|
1168
|
+
.activity-log-main {
|
|
1169
|
+
max-height: min(32rem, 60vh);
|
|
1170
|
+
}
|
|
1171
|
+
|
|
1172
|
+
.qa-tab-bar {
|
|
1173
|
+
display: flex;
|
|
1174
|
+
gap: 2px;
|
|
1175
|
+
margin: 0 0 var(--space-3);
|
|
1176
|
+
}
|
|
1177
|
+
|
|
1178
|
+
.qa-tab {
|
|
1179
|
+
appearance: none;
|
|
1180
|
+
border: 0;
|
|
1181
|
+
background: transparent;
|
|
1182
|
+
color: var(--text-secondary);
|
|
1183
|
+
font-family: var(--font-ui);
|
|
1184
|
+
font-size: var(--text-13);
|
|
1185
|
+
font-weight: 700;
|
|
1186
|
+
height: 1.75rem;
|
|
1187
|
+
padding: 0 var(--space-3);
|
|
1188
|
+
border-radius: var(--radius-sm);
|
|
1189
|
+
cursor: pointer;
|
|
1190
|
+
}
|
|
1191
|
+
|
|
1192
|
+
.qa-tab:hover {
|
|
1193
|
+
background: var(--surface-hover);
|
|
1194
|
+
color: var(--text-primary);
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1197
|
+
.qa-tab.is-active {
|
|
1198
|
+
background: var(--surface-selected);
|
|
1199
|
+
color: var(--color-primary);
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1168
1202
|
.activity-log .list-row,
|
|
1169
1203
|
#proof-report.list-rows .list-row {
|
|
1170
1204
|
cursor: default;
|
package/dist/server.d.ts
CHANGED
|
@@ -6,7 +6,8 @@ export type AppState = {
|
|
|
6
6
|
cwd: string;
|
|
7
7
|
pack: PackPaths | null;
|
|
8
8
|
last: CompileResult | null;
|
|
9
|
-
|
|
9
|
+
implementActivity: ActivityLine[];
|
|
10
|
+
proveActivity: ActivityLine[];
|
|
10
11
|
busy: "prove" | "improve" | "implement" | null;
|
|
11
12
|
implementLaunch: LaunchAdapterResult | null;
|
|
12
13
|
};
|
package/dist/server.js
CHANGED
|
@@ -12,7 +12,7 @@ import { adapterDisplayName, parseAdapterId } from "./adapter.js";
|
|
|
12
12
|
import { pipelineView, sectionCatalog } from "./stages.js";
|
|
13
13
|
const cockpitDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../cockpit");
|
|
14
14
|
export function createAppState(cwd, pack) {
|
|
15
|
-
return { cwd, pack, last: null,
|
|
15
|
+
return { cwd, pack, last: null, implementActivity: [], proveActivity: [], busy: null, implementLaunch: null };
|
|
16
16
|
}
|
|
17
17
|
export async function refresh(state) {
|
|
18
18
|
if (!state.pack) {
|
|
@@ -62,7 +62,7 @@ async function handle(state, req, res) {
|
|
|
62
62
|
return;
|
|
63
63
|
}
|
|
64
64
|
state.pack = chosen;
|
|
65
|
-
state
|
|
65
|
+
clearActivity(state);
|
|
66
66
|
await refresh(state);
|
|
67
67
|
await sendJson(res, await snapshot(state));
|
|
68
68
|
return;
|
|
@@ -70,7 +70,7 @@ async function handle(state, req, res) {
|
|
|
70
70
|
if (req.method === "POST" && url.pathname === "/api/home") {
|
|
71
71
|
state.pack = null;
|
|
72
72
|
state.last = null;
|
|
73
|
-
state
|
|
73
|
+
clearActivity(state);
|
|
74
74
|
await sendJson(res, await snapshot(state));
|
|
75
75
|
return;
|
|
76
76
|
}
|
|
@@ -95,7 +95,7 @@ async function handle(state, req, res) {
|
|
|
95
95
|
if (state.pack?.root === chosen.root) {
|
|
96
96
|
state.pack = null;
|
|
97
97
|
state.last = null;
|
|
98
|
-
state
|
|
98
|
+
clearActivity(state);
|
|
99
99
|
}
|
|
100
100
|
await deletePack(chosen);
|
|
101
101
|
await sendJson(res, await snapshot(state));
|
|
@@ -185,7 +185,7 @@ async function handle(state, req, res) {
|
|
|
185
185
|
}
|
|
186
186
|
const pack = state.pack;
|
|
187
187
|
state.busy = "improve";
|
|
188
|
-
state
|
|
188
|
+
clearActivity(state, "implement");
|
|
189
189
|
pushActivity(state, "Wrote derived/improve-brief.md.");
|
|
190
190
|
if (adapter === "manual") {
|
|
191
191
|
pushActivity(state, "Manual adapter: open the brief in any coding agent.", "ok");
|
|
@@ -273,7 +273,7 @@ async function handle(state, req, res) {
|
|
|
273
273
|
const stack = typeof body["stack"] === "string" && body["stack"].trim() ? String(body["stack"]) : undefined;
|
|
274
274
|
const fromProof = body["fromProof"] === true;
|
|
275
275
|
try {
|
|
276
|
-
state
|
|
276
|
+
clearActivity(state, "implement");
|
|
277
277
|
pushActivity(state, fromProof ? "Fix from proof started." : "Implement started.");
|
|
278
278
|
const launched = await implementPack(state.pack, {
|
|
279
279
|
...(stack ? { adapter, stack } : { adapter }),
|
|
@@ -363,8 +363,8 @@ async function handle(state, req, res) {
|
|
|
363
363
|
}
|
|
364
364
|
const pack = state.pack;
|
|
365
365
|
state.busy = "prove";
|
|
366
|
-
state
|
|
367
|
-
pushActivity(state, "Prove started.");
|
|
366
|
+
clearActivity(state, "prove");
|
|
367
|
+
pushActivity(state, "Prove started.", "info", "prove");
|
|
368
368
|
await yieldEventLoop();
|
|
369
369
|
await sendJson(res, { ...(await snapshot(state)), started: true, message: "Prove started." });
|
|
370
370
|
void runProve(state, pack);
|
|
@@ -403,7 +403,7 @@ async function snapshot(state) {
|
|
|
403
403
|
state.last = await compilePack(state.pack);
|
|
404
404
|
}
|
|
405
405
|
const improveReview = state.pack ? await evaluateImproveReview(state.pack) : null;
|
|
406
|
-
if (improveReview?.files.length && !state.
|
|
406
|
+
if (improveReview?.files.length && !state.implementActivity.some((line) => line.message === "Improve patch ready to review.")) {
|
|
407
407
|
pushActivity(state, "Improve patch ready to review.", "ok");
|
|
408
408
|
}
|
|
409
409
|
const health = state.last ? applyImproveReviewGate(state.last.health, improveReview) : null;
|
|
@@ -430,7 +430,8 @@ async function snapshot(state) {
|
|
|
430
430
|
proofReport,
|
|
431
431
|
hasApiKey: hasJevAccess(),
|
|
432
432
|
productRepo: await inspectProductRepo(await inspectFrom(state)),
|
|
433
|
-
|
|
433
|
+
implementActivity: state.implementActivity,
|
|
434
|
+
proveActivity: state.proveActivity,
|
|
434
435
|
busy: state.busy,
|
|
435
436
|
improveReview,
|
|
436
437
|
};
|
|
@@ -498,13 +499,13 @@ async function runImplement(state, pack, launch, adapter) {
|
|
|
498
499
|
async function runProve(state, pack) {
|
|
499
500
|
try {
|
|
500
501
|
const proved = await provePack(pack, {
|
|
501
|
-
onProgress: (message, level) => pushActivity(state, message, level),
|
|
502
|
+
onProgress: (message, level) => pushActivity(state, message, level, "prove"),
|
|
502
503
|
});
|
|
503
504
|
state.last = proved.result;
|
|
504
505
|
}
|
|
505
506
|
catch (err) {
|
|
506
507
|
const message = err instanceof Error ? err.message : "Prove failed.";
|
|
507
|
-
pushActivity(state, message, "error");
|
|
508
|
+
pushActivity(state, message, "error", "prove");
|
|
508
509
|
if (err instanceof JevUnavailableError && state.pack) {
|
|
509
510
|
state.last = await compilePack(state.pack);
|
|
510
511
|
}
|
|
@@ -513,9 +514,19 @@ async function runProve(state, pack) {
|
|
|
513
514
|
state.busy = null;
|
|
514
515
|
}
|
|
515
516
|
}
|
|
516
|
-
function
|
|
517
|
+
function clearActivity(state, channel) {
|
|
518
|
+
if (!channel || channel === "implement")
|
|
519
|
+
state.implementActivity = [];
|
|
520
|
+
if (!channel || channel === "prove")
|
|
521
|
+
state.proveActivity = [];
|
|
522
|
+
}
|
|
523
|
+
function pushActivity(state, message, level = "info", channel = "implement") {
|
|
517
524
|
const line = { at: new Date().toISOString(), level, message };
|
|
518
|
-
|
|
525
|
+
if (channel === "prove") {
|
|
526
|
+
state.proveActivity = [...state.proveActivity, line].slice(-80);
|
|
527
|
+
return;
|
|
528
|
+
}
|
|
529
|
+
state.implementActivity = [...state.implementActivity, line].slice(-80);
|
|
519
530
|
}
|
|
520
531
|
async function yieldEventLoop() {
|
|
521
532
|
await new Promise((resolve) => setImmediate(resolve));
|
package/dist/types.d.ts
CHANGED
package/package.json
CHANGED