@richjava/req0 0.1.0 → 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/cockpit/app.js +466 -70
- package/cockpit/index.html +50 -8
- package/cockpit/styles.css +106 -5
- package/dist/agent-questions.d.ts +48 -0
- package/dist/agent-questions.js +278 -0
- package/dist/cli.js +6 -2
- package/dist/fix-from-proof.js +2 -0
- package/dist/implement-brief.js +2 -1
- package/dist/implement.d.ts +6 -0
- package/dist/implement.js +71 -20
- package/dist/improve.js +4 -3
- package/dist/pack.d.ts +20 -2
- package/dist/pack.js +128 -13
- package/dist/ready.js +7 -0
- package/dist/server.d.ts +2 -1
- package/dist/server.js +146 -20
- package/dist/types.d.ts +5 -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"),
|
|
@@ -39,6 +45,8 @@ const els = {
|
|
|
39
45
|
createNew: document.getElementById("create-new"),
|
|
40
46
|
createError: document.getElementById("create-error"),
|
|
41
47
|
homeBtn: document.getElementById("home-btn"),
|
|
48
|
+
projectName: document.getElementById("project-name"),
|
|
49
|
+
subbar: document.getElementById("subbar"),
|
|
42
50
|
allRequirements: document.getElementById("all-requirements"),
|
|
43
51
|
packHome: document.getElementById("pack-home"),
|
|
44
52
|
packWorkspace: document.getElementById("pack-workspace"),
|
|
@@ -69,6 +77,18 @@ const els = {
|
|
|
69
77
|
reviewDiff: document.getElementById("review-diff"),
|
|
70
78
|
reviewAccept: document.getElementById("review-accept"),
|
|
71
79
|
reviewReject: document.getElementById("review-reject"),
|
|
80
|
+
questionActions: document.getElementById("question-actions"),
|
|
81
|
+
questionContinue: document.getElementById("question-continue"),
|
|
82
|
+
questionStop: document.getElementById("question-stop"),
|
|
83
|
+
defineQuestions: document.getElementById("define-questions"),
|
|
84
|
+
implementTabs: document.getElementById("implement-tabs"),
|
|
85
|
+
implementTabQuestions: document.getElementById("implement-tab-questions"),
|
|
86
|
+
implementTabActivity: document.getElementById("implement-tab-activity"),
|
|
87
|
+
implementActivityLabel: document.getElementById("implement-activity-label"),
|
|
88
|
+
implementQuestions: document.getElementById("implement-questions"),
|
|
89
|
+
discardDialog: document.getElementById("discard-questions-dialog"),
|
|
90
|
+
discardCancel: document.getElementById("discard-questions-cancel"),
|
|
91
|
+
discardConfirm: document.getElementById("discard-questions-confirm"),
|
|
72
92
|
};
|
|
73
93
|
|
|
74
94
|
let state = null;
|
|
@@ -92,17 +112,35 @@ let focusedSection = "Business Rules";
|
|
|
92
112
|
let actionNotice = "";
|
|
93
113
|
let actionBusy = false;
|
|
94
114
|
let headerBusyLabel = "";
|
|
95
|
-
let
|
|
96
|
-
let
|
|
115
|
+
let implementLines = [];
|
|
116
|
+
let proveLines = [];
|
|
117
|
+
let lastImplementKey = "";
|
|
118
|
+
let lastProveKey = "";
|
|
119
|
+
let qaTab = "activity";
|
|
120
|
+
let implementTab = "questions";
|
|
121
|
+
let questionDrafts = {};
|
|
122
|
+
let questionDraftKey = "";
|
|
123
|
+
let lastQuestionsKey = "";
|
|
97
124
|
let loadInFlight = false;
|
|
98
125
|
let loadAgain = false;
|
|
99
126
|
let loadTimer;
|
|
100
127
|
let stateEpoch = 0;
|
|
101
128
|
|
|
129
|
+
function applyActivities(payload) {
|
|
130
|
+
if (!payload) return;
|
|
131
|
+
if (Array.isArray(payload.implementActivity)) implementLines = payload.implementActivity;
|
|
132
|
+
if (Array.isArray(payload.proveActivity)) proveLines = payload.proveActivity;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function lastBusyMessage(kind) {
|
|
136
|
+
const lines = kind === "prove" ? proveLines : implementLines;
|
|
137
|
+
return lines[lines.length - 1]?.message ?? "";
|
|
138
|
+
}
|
|
139
|
+
|
|
102
140
|
function takeState(next) {
|
|
103
141
|
stateEpoch += 1;
|
|
104
142
|
state = next;
|
|
105
|
-
|
|
143
|
+
applyActivities(state);
|
|
106
144
|
}
|
|
107
145
|
|
|
108
146
|
async function load() {
|
|
@@ -117,7 +155,7 @@ async function load() {
|
|
|
117
155
|
const body = await res.json();
|
|
118
156
|
if (epoch !== stateEpoch) return;
|
|
119
157
|
state = body;
|
|
120
|
-
|
|
158
|
+
applyActivities(state);
|
|
121
159
|
render();
|
|
122
160
|
} catch (err) {
|
|
123
161
|
if (els.going) {
|
|
@@ -186,11 +224,18 @@ function renderSetupGate(snapshot) {
|
|
|
186
224
|
}
|
|
187
225
|
}
|
|
188
226
|
|
|
227
|
+
function directoryName(cwd) {
|
|
228
|
+
if (typeof cwd !== "string") return "";
|
|
229
|
+
const parts = cwd.split(/[/\\]/).filter(Boolean);
|
|
230
|
+
return parts.at(-1) ?? "";
|
|
231
|
+
}
|
|
232
|
+
|
|
189
233
|
function render() {
|
|
190
234
|
const health = state.health;
|
|
191
235
|
const packId = state.packId;
|
|
192
236
|
const onHome = !packId;
|
|
193
237
|
const packList = Array.isArray(state.packList) ? state.packList : [];
|
|
238
|
+
if (els.projectName) els.projectName.textContent = directoryName(state.cwd);
|
|
194
239
|
els.title.textContent = packId ? `Requirement: ${packId.replaceAll("-", " ")}` : "Requirements";
|
|
195
240
|
els.going.textContent = packId
|
|
196
241
|
? (health?.howThisIsGoing ?? "")
|
|
@@ -201,17 +246,24 @@ function render() {
|
|
|
201
246
|
|
|
202
247
|
const action = health?.nextAction;
|
|
203
248
|
const review = state.improveReview;
|
|
204
|
-
|
|
249
|
+
const questions = openQuestions();
|
|
250
|
+
syncQuestionDrafts(questions);
|
|
251
|
+
maybeOpenQuestions(questions);
|
|
252
|
+
if (review?.files?.length || questions) actionNotice = "";
|
|
205
253
|
const canStop = action?.id === "stop-implement";
|
|
206
|
-
const
|
|
254
|
+
const continueReady = action?.id !== "answer-questions" || questionsContinueEnabled(questions);
|
|
255
|
+
const nextEnabled =
|
|
256
|
+
Boolean(action?.enabled) &&
|
|
257
|
+
continueReady &&
|
|
258
|
+
!(actionBusy && !canStop && !review?.files?.length && !questions);
|
|
207
259
|
const nextLabel =
|
|
208
|
-
actionBusy && headerBusyLabel && !canStop && !review?.files?.length
|
|
260
|
+
actionBusy && headerBusyLabel && !canStop && !review?.files?.length && !questions
|
|
209
261
|
? headerBusyLabel
|
|
210
262
|
: action?.label ?? "Create a requirement";
|
|
211
263
|
paintActionButton(els.next, {
|
|
212
264
|
id: action?.id ?? "create",
|
|
213
265
|
label: nextLabel,
|
|
214
|
-
hint: review ? action?.hint || "" : actionNotice || action?.hint || "",
|
|
266
|
+
hint: questions || review ? action?.hint || "" : actionNotice || action?.hint || "",
|
|
215
267
|
enabled: nextEnabled,
|
|
216
268
|
primary: true,
|
|
217
269
|
hidden: false,
|
|
@@ -224,6 +276,7 @@ function render() {
|
|
|
224
276
|
els.next.hidden = gated || onHome;
|
|
225
277
|
els.packHome?.classList.toggle("hidden", !onHome);
|
|
226
278
|
els.packWorkspace?.classList.toggle("hidden", onHome);
|
|
279
|
+
els.subbar?.classList.toggle("hidden", onHome);
|
|
227
280
|
els.allRequirements?.classList.toggle("hidden", onHome);
|
|
228
281
|
els.createBar?.classList.toggle("hidden", !onHome);
|
|
229
282
|
if (!onHome) hidePackMenu();
|
|
@@ -237,10 +290,10 @@ function render() {
|
|
|
237
290
|
|
|
238
291
|
if (onHome) return;
|
|
239
292
|
|
|
240
|
-
if (review && currentView !== "define") currentView = "define";
|
|
293
|
+
if (review && !questions && currentView !== "define") currentView = "define";
|
|
241
294
|
if (currentView === "implement" && health?.build?.owned === false) currentView = "define";
|
|
242
295
|
|
|
243
|
-
if (!applying && !state.improveReview) {
|
|
296
|
+
if (!applying && !state.improveReview && questions?.channel !== "improve") {
|
|
244
297
|
applying = true;
|
|
245
298
|
markdownEditor.setValue(state.markdown ?? "");
|
|
246
299
|
applying = false;
|
|
@@ -250,10 +303,13 @@ function render() {
|
|
|
250
303
|
renderStageNav();
|
|
251
304
|
showView(currentView);
|
|
252
305
|
renderReview();
|
|
306
|
+
renderQuestions();
|
|
307
|
+
renderImplementLayout();
|
|
253
308
|
renderSpecPane();
|
|
254
309
|
renderJudgmentPane();
|
|
255
310
|
renderRunStatus();
|
|
256
311
|
renderProofReport();
|
|
312
|
+
renderQaLayout();
|
|
257
313
|
renderActivity();
|
|
258
314
|
}
|
|
259
315
|
|
|
@@ -382,6 +438,9 @@ async function selectPack(id) {
|
|
|
382
438
|
}
|
|
383
439
|
takeState(body);
|
|
384
440
|
currentView = "define";
|
|
441
|
+
qaTab = "activity";
|
|
442
|
+
implementTab = "questions";
|
|
443
|
+
lastQuestionsKey = "";
|
|
385
444
|
actionNotice = "";
|
|
386
445
|
render();
|
|
387
446
|
}
|
|
@@ -396,22 +455,235 @@ async function goHome() {
|
|
|
396
455
|
}
|
|
397
456
|
takeState(body);
|
|
398
457
|
currentView = "define";
|
|
458
|
+
qaTab = "activity";
|
|
459
|
+
implementTab = "questions";
|
|
460
|
+
lastQuestionsKey = "";
|
|
399
461
|
actionNotice = "";
|
|
400
462
|
render();
|
|
401
463
|
}
|
|
402
464
|
|
|
465
|
+
function openQuestions() {
|
|
466
|
+
const round = state?.agentQuestions;
|
|
467
|
+
if (!round || round.status !== "open" || !Array.isArray(round.questions) || !round.questions.length) {
|
|
468
|
+
return null;
|
|
469
|
+
}
|
|
470
|
+
return round;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
function questionsContinueEnabled(round = openQuestions()) {
|
|
474
|
+
if (!round) return false;
|
|
475
|
+
return round.questions.every(
|
|
476
|
+
(question) => !question.required || String(questionDrafts[question.id] ?? "").trim(),
|
|
477
|
+
);
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
function syncQuestionDrafts(round) {
|
|
481
|
+
const key = round
|
|
482
|
+
? `${round.channel}|${round.at}|${round.questions.map((question) => question.id).join(",")}`
|
|
483
|
+
: "";
|
|
484
|
+
if (key === questionDraftKey) return;
|
|
485
|
+
questionDraftKey = key;
|
|
486
|
+
questionDrafts = {};
|
|
487
|
+
if (!round) return;
|
|
488
|
+
for (const question of round.questions) {
|
|
489
|
+
questionDrafts[question.id] = question.answer?.optionId || question.answer?.text || "";
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
function maybeOpenQuestions(round) {
|
|
494
|
+
const key = round ? `${round.channel}|${round.at}` : "";
|
|
495
|
+
if (key && key !== lastQuestionsKey) {
|
|
496
|
+
currentView = round.channel === "improve" ? "define" : "implement";
|
|
497
|
+
implementTab = "questions";
|
|
498
|
+
}
|
|
499
|
+
lastQuestionsKey = key;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
function collectedAnswers(round = openQuestions()) {
|
|
503
|
+
const answers = {};
|
|
504
|
+
if (!round) return answers;
|
|
505
|
+
for (const question of round.questions) {
|
|
506
|
+
answers[question.id] = String(questionDrafts[question.id] ?? "");
|
|
507
|
+
}
|
|
508
|
+
return answers;
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
function paintQuestionContinue() {
|
|
512
|
+
const round = openQuestions();
|
|
513
|
+
const askingDefine = round?.channel === "improve";
|
|
514
|
+
const ready = questionsContinueEnabled(round);
|
|
515
|
+
paintActionButton(els.questionContinue, {
|
|
516
|
+
id: "answer-questions",
|
|
517
|
+
label: "Continue",
|
|
518
|
+
hint: "Answer each required question, then Continue.",
|
|
519
|
+
enabled: Boolean(askingDefine && ready && !actionBusy),
|
|
520
|
+
primary: true,
|
|
521
|
+
hidden: !askingDefine,
|
|
522
|
+
});
|
|
523
|
+
const action = state?.health?.nextAction;
|
|
524
|
+
if (action?.id === "answer-questions") {
|
|
525
|
+
paintActionButton(els.next, {
|
|
526
|
+
id: action.id,
|
|
527
|
+
label: action.label,
|
|
528
|
+
hint: action.hint || "",
|
|
529
|
+
enabled: Boolean(action.enabled && ready && !actionBusy),
|
|
530
|
+
primary: true,
|
|
531
|
+
hidden: false,
|
|
532
|
+
});
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
function fillQuestionPanel(panel, round) {
|
|
537
|
+
const key = `${round.channel}|${round.at}|${round.questions.map((question) => question.id).join(",")}`;
|
|
538
|
+
if (panel.dataset.sig === key) {
|
|
539
|
+
syncQuestionCardSelection(panel);
|
|
540
|
+
return;
|
|
541
|
+
}
|
|
542
|
+
panel.dataset.sig = key;
|
|
543
|
+
panel.innerHTML = "";
|
|
544
|
+
for (const question of round.questions) {
|
|
545
|
+
panel.append(renderQuestionCard(question));
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
function syncQuestionCardSelection(panel) {
|
|
550
|
+
for (const card of panel.querySelectorAll(".question-card")) {
|
|
551
|
+
const id = card.dataset.questionId;
|
|
552
|
+
const value = questionDrafts[id] ?? "";
|
|
553
|
+
for (const btn of card.querySelectorAll(".stack-choice")) {
|
|
554
|
+
btn.classList.toggle("is-selected", btn.dataset.optionId === value);
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
function renderQuestionCard(question) {
|
|
560
|
+
const article = document.createElement("article");
|
|
561
|
+
article.className = "question-card";
|
|
562
|
+
article.dataset.questionId = question.id;
|
|
563
|
+
const prompt = document.createElement("p");
|
|
564
|
+
prompt.className = "question-card-prompt";
|
|
565
|
+
prompt.textContent = question.prompt;
|
|
566
|
+
article.append(prompt);
|
|
567
|
+
if (question.kind === "choice") {
|
|
568
|
+
const choices = document.createElement("div");
|
|
569
|
+
choices.className = "question-choices";
|
|
570
|
+
for (const option of question.options ?? []) {
|
|
571
|
+
const btn = document.createElement("button");
|
|
572
|
+
btn.type = "button";
|
|
573
|
+
btn.className = "stack-choice";
|
|
574
|
+
btn.dataset.optionId = option.id;
|
|
575
|
+
btn.classList.toggle("is-selected", questionDrafts[question.id] === option.id);
|
|
576
|
+
const label = document.createElement("strong");
|
|
577
|
+
label.textContent = option.label;
|
|
578
|
+
btn.append(label);
|
|
579
|
+
btn.addEventListener("click", () => {
|
|
580
|
+
questionDrafts[question.id] = option.id;
|
|
581
|
+
render();
|
|
582
|
+
});
|
|
583
|
+
choices.append(btn);
|
|
584
|
+
}
|
|
585
|
+
article.append(choices);
|
|
586
|
+
} else {
|
|
587
|
+
const input = document.createElement("input");
|
|
588
|
+
input.className = "input";
|
|
589
|
+
input.type = "text";
|
|
590
|
+
input.value = questionDrafts[question.id] ?? "";
|
|
591
|
+
input.placeholder = question.required ? "Required" : "Optional";
|
|
592
|
+
input.addEventListener("input", () => {
|
|
593
|
+
questionDrafts[question.id] = input.value;
|
|
594
|
+
paintQuestionContinue();
|
|
595
|
+
});
|
|
596
|
+
article.append(input);
|
|
597
|
+
}
|
|
598
|
+
if (question.required) {
|
|
599
|
+
const meta = document.createElement("p");
|
|
600
|
+
meta.className = "question-card-meta";
|
|
601
|
+
meta.textContent = "Required";
|
|
602
|
+
article.append(meta);
|
|
603
|
+
}
|
|
604
|
+
return article;
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
function renderQuestions() {
|
|
608
|
+
const round = openQuestions();
|
|
609
|
+
const askingDefine = round?.channel === "improve";
|
|
610
|
+
if (els.questionActions) els.questionActions.classList.toggle("hidden", !askingDefine);
|
|
611
|
+
if (els.defineQuestions) {
|
|
612
|
+
els.defineQuestions.classList.toggle("hidden", !askingDefine);
|
|
613
|
+
els.defineQuestions.hidden = !askingDefine;
|
|
614
|
+
if (askingDefine) fillQuestionPanel(els.defineQuestions, round);
|
|
615
|
+
else {
|
|
616
|
+
els.defineQuestions.innerHTML = "";
|
|
617
|
+
delete els.defineQuestions.dataset.sig;
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
if (askingDefine) {
|
|
621
|
+
els.workspace?.classList.add("is-review");
|
|
622
|
+
markdownEditor.setHidden(true);
|
|
623
|
+
if (els.save) els.save.classList.add("hidden");
|
|
624
|
+
if (els.workspaceLabel) els.workspaceLabel.textContent = "Agent questions";
|
|
625
|
+
}
|
|
626
|
+
paintActionButton(els.questionContinue, {
|
|
627
|
+
id: "answer-questions",
|
|
628
|
+
label: "Continue",
|
|
629
|
+
hint: "Answer each required question, then Continue.",
|
|
630
|
+
enabled: Boolean(askingDefine && questionsContinueEnabled(round) && !actionBusy),
|
|
631
|
+
primary: true,
|
|
632
|
+
hidden: !askingDefine,
|
|
633
|
+
});
|
|
634
|
+
paintActionButton(els.questionStop, {
|
|
635
|
+
id: "discard-questions",
|
|
636
|
+
label: "Stop",
|
|
637
|
+
hint: "Discard unanswered questions.",
|
|
638
|
+
enabled: Boolean(askingDefine && !actionBusy),
|
|
639
|
+
primary: false,
|
|
640
|
+
hidden: !askingDefine,
|
|
641
|
+
});
|
|
642
|
+
if (els.implementQuestions) {
|
|
643
|
+
if (round?.channel === "implement") fillQuestionPanel(els.implementQuestions, round);
|
|
644
|
+
else {
|
|
645
|
+
els.implementQuestions.innerHTML = "";
|
|
646
|
+
delete els.implementQuestions.dataset.sig;
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
function renderImplementLayout() {
|
|
652
|
+
const asking = openQuestions()?.channel === "implement";
|
|
653
|
+
const hasActivity = implementLines.length > 0;
|
|
654
|
+
const showTabs = Boolean(asking && hasActivity);
|
|
655
|
+
if (!asking) implementTab = "questions";
|
|
656
|
+
else if (!hasActivity) implementTab = "questions";
|
|
657
|
+
els.implementTabs?.classList.toggle("hidden", !showTabs);
|
|
658
|
+
if (els.implementTabs) els.implementTabs.hidden = !showTabs;
|
|
659
|
+
const showQuestions = Boolean(asking && (!showTabs || implementTab === "questions"));
|
|
660
|
+
const showActivity = !asking || (showTabs && implementTab === "activity");
|
|
661
|
+
els.implementActivityLabel?.classList.toggle("hidden", Boolean(asking));
|
|
662
|
+
els.implementQuestions?.classList.toggle("hidden", !showQuestions);
|
|
663
|
+
if (els.implementQuestions) els.implementQuestions.hidden = !showQuestions;
|
|
664
|
+
els.implementActivity?.classList.toggle("hidden", !showActivity);
|
|
665
|
+
if (els.implementActivity) els.implementActivity.hidden = !showActivity;
|
|
666
|
+
els.implementTabQuestions?.classList.toggle("is-active", implementTab !== "activity");
|
|
667
|
+
els.implementTabActivity?.classList.toggle("is-active", implementTab === "activity");
|
|
668
|
+
els.implementTabQuestions?.setAttribute("aria-selected", implementTab !== "activity" ? "true" : "false");
|
|
669
|
+
els.implementTabActivity?.setAttribute("aria-selected", implementTab === "activity" ? "true" : "false");
|
|
670
|
+
}
|
|
671
|
+
|
|
403
672
|
function renderReview() {
|
|
404
|
-
const
|
|
673
|
+
const askingDefine = openQuestions()?.channel === "improve";
|
|
674
|
+
const review = askingDefine ? null : state.improveReview;
|
|
405
675
|
const reviewing = Boolean(review);
|
|
406
676
|
const hasDiff = Boolean(review?.files?.length);
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
677
|
+
if (!askingDefine) {
|
|
678
|
+
els.workspace?.classList.toggle("is-review", reviewing);
|
|
679
|
+
markdownEditor.setHidden(reviewing);
|
|
680
|
+
if (els.save) els.save.classList.toggle("hidden", reviewing);
|
|
681
|
+
}
|
|
410
682
|
if (!els.reviewActions || !els.reviewDiff) return;
|
|
411
683
|
els.reviewActions.classList.toggle("hidden", !reviewing);
|
|
412
684
|
els.reviewDiff.classList.toggle("hidden", !reviewing);
|
|
413
685
|
els.reviewDiff.hidden = !reviewing;
|
|
414
|
-
if (els.workspaceLabel) {
|
|
686
|
+
if (els.workspaceLabel && !askingDefine) {
|
|
415
687
|
els.workspaceLabel.textContent = hasDiff ? "Improve patch" : reviewing ? "Waiting for the patch" : "requirement.md";
|
|
416
688
|
}
|
|
417
689
|
const lintOk = review?.lint?.ok !== false;
|
|
@@ -508,13 +780,13 @@ function actionGlyph(id, label = "") {
|
|
|
508
780
|
`<path d="M8 2.6 9 6l3.4 1L9 8l-1 3.4L7 8 3.6 7 7 6zM12.4 10.2l.5 1.6 1.6.5-1.6.5-.5 1.6-.5-1.6-1.6-.5 1.6-.5z" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linejoin="round"/>`,
|
|
509
781
|
);
|
|
510
782
|
}
|
|
511
|
-
if (id === "review-improve") {
|
|
783
|
+
if (id === "review-improve" || id === "answer-questions") {
|
|
512
784
|
return iconSvg(
|
|
513
785
|
`<path d="M2.8 8.2 6.1 11.4 13.2 4.4" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"/>`,
|
|
514
786
|
);
|
|
515
787
|
}
|
|
516
|
-
if (id === "reject-improve" || id === "stop-implement") {
|
|
517
|
-
return id === "stop-implement"
|
|
788
|
+
if (id === "reject-improve" || id === "stop-implement" || id === "discard-questions") {
|
|
789
|
+
return id === "stop-implement" || id === "discard-questions"
|
|
518
790
|
? iconSvg(`<rect x="4.2" y="4.2" width="7.6" height="7.6" rx="1.2" fill="currentColor"/>`)
|
|
519
791
|
: iconSvg(
|
|
520
792
|
`<path d="M4 4l8 8M12 4l-8 8" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/>`,
|
|
@@ -1074,14 +1346,30 @@ function renderProofReport() {
|
|
|
1074
1346
|
if (!els.proofReport) return;
|
|
1075
1347
|
const report = state?.proofReport?.trim();
|
|
1076
1348
|
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>`;
|
|
1349
|
+
els.proofReport.innerHTML = "";
|
|
1079
1350
|
return;
|
|
1080
1351
|
}
|
|
1081
1352
|
els.proofReport.className = "proof-report md-preview";
|
|
1082
1353
|
els.proofReport.innerHTML = renderProofMarkdown(report);
|
|
1083
1354
|
}
|
|
1084
1355
|
|
|
1356
|
+
function renderQaLayout() {
|
|
1357
|
+
const hasReport = Boolean(state?.proofReport?.trim());
|
|
1358
|
+
if (!hasReport) qaTab = "activity";
|
|
1359
|
+
els.qaTabs?.classList.toggle("hidden", !hasReport);
|
|
1360
|
+
if (els.qaTabs) els.qaTabs.hidden = !hasReport;
|
|
1361
|
+
els.qaActivityLabel?.classList.toggle("hidden", hasReport);
|
|
1362
|
+
const showReport = hasReport && qaTab === "report";
|
|
1363
|
+
els.qaActivityPanel?.classList.toggle("hidden", showReport);
|
|
1364
|
+
if (els.qaActivityPanel) els.qaActivityPanel.hidden = showReport;
|
|
1365
|
+
els.qaReportPanel?.classList.toggle("hidden", !showReport);
|
|
1366
|
+
if (els.qaReportPanel) els.qaReportPanel.hidden = !showReport;
|
|
1367
|
+
els.qaTabActivity?.classList.toggle("is-active", qaTab !== "report");
|
|
1368
|
+
els.qaTabReport?.classList.toggle("is-active", qaTab === "report");
|
|
1369
|
+
els.qaTabActivity?.setAttribute("aria-selected", qaTab !== "report" ? "true" : "false");
|
|
1370
|
+
els.qaTabReport?.setAttribute("aria-selected", qaTab === "report" ? "true" : "false");
|
|
1371
|
+
}
|
|
1372
|
+
|
|
1085
1373
|
function renderProofMarkdown(source) {
|
|
1086
1374
|
const blocks = [];
|
|
1087
1375
|
let list = [];
|
|
@@ -1146,32 +1434,40 @@ function jumpToSpecId(id) {
|
|
|
1146
1434
|
return false;
|
|
1147
1435
|
}
|
|
1148
1436
|
|
|
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;
|
|
1437
|
+
function fillActivityLog(log, lines, emptyMessage, which) {
|
|
1438
|
+
if (!log) return;
|
|
1439
|
+
const rows = lines.length ? lines : [{ level: "info", message: emptyMessage }];
|
|
1440
|
+
const key = rows.map((line) => `${line.level}\0${line.message}`).join("\n");
|
|
1441
|
+
const previous = which === "prove" ? lastProveKey : lastImplementKey;
|
|
1442
|
+
if (key === previous && log.childElementCount === rows.length) return;
|
|
1443
|
+
if (which === "prove") lastProveKey = key;
|
|
1444
|
+
else lastImplementKey = key;
|
|
1445
|
+
const pinned = log.scrollHeight - log.scrollTop - log.clientHeight < 16;
|
|
1446
|
+
const savedTop = log.scrollTop;
|
|
1447
|
+
log.innerHTML = "";
|
|
1448
|
+
for (const line of rows) {
|
|
1449
|
+
const li = document.createElement("li");
|
|
1450
|
+
const kind = line.level === "error" ? "bad" : line.level === "ok" ? "ok" : "idle";
|
|
1451
|
+
li.className = `list-row list-row-${kind}`;
|
|
1452
|
+
li.textContent = line.message;
|
|
1453
|
+
log.append(li);
|
|
1170
1454
|
}
|
|
1455
|
+
log.scrollTop = pinned ? log.scrollHeight : savedTop;
|
|
1456
|
+
}
|
|
1457
|
+
|
|
1458
|
+
function renderActivity() {
|
|
1459
|
+
fillActivityLog(
|
|
1460
|
+
els.implementActivity,
|
|
1461
|
+
implementLines,
|
|
1462
|
+
"No activity yet. Implement writes progress here.",
|
|
1463
|
+
"implement",
|
|
1464
|
+
);
|
|
1465
|
+
fillActivityLog(els.qaActivity, proveLines, "No activity yet. Prove writes progress here.", "prove");
|
|
1171
1466
|
}
|
|
1172
1467
|
|
|
1173
|
-
function appendActivity(line) {
|
|
1174
|
-
|
|
1468
|
+
function appendActivity(line, channel) {
|
|
1469
|
+
if (channel === "prove") proveLines = [...proveLines, line].slice(-80);
|
|
1470
|
+
else implementLines = [...implementLines, line].slice(-80);
|
|
1175
1471
|
if (line.message) {
|
|
1176
1472
|
actionNotice = line.message;
|
|
1177
1473
|
setActionHint(line.message);
|
|
@@ -1227,6 +1523,12 @@ onEnabledClick(els.reviewAccept, () => {
|
|
|
1227
1523
|
onEnabledClick(els.reviewReject, () => {
|
|
1228
1524
|
void runNextAction("Rejecting…", "/api/improve/reject");
|
|
1229
1525
|
});
|
|
1526
|
+
onEnabledClick(els.questionContinue, () => {
|
|
1527
|
+
void runStageAction("answer-questions");
|
|
1528
|
+
});
|
|
1529
|
+
onEnabledClick(els.questionStop, () => {
|
|
1530
|
+
void runStageAction("discard-questions");
|
|
1531
|
+
});
|
|
1230
1532
|
onEnabledClick(els.next, () => {
|
|
1231
1533
|
void runStageAction(state.health?.nextAction?.id);
|
|
1232
1534
|
});
|
|
@@ -1263,9 +1565,55 @@ function askIgnoreBuild() {
|
|
|
1263
1565
|
});
|
|
1264
1566
|
}
|
|
1265
1567
|
|
|
1568
|
+
let discardDialogResolve = null;
|
|
1569
|
+
|
|
1570
|
+
function closeDiscardDialog(value) {
|
|
1571
|
+
if (els.discardDialog?.open) els.discardDialog.close(value);
|
|
1572
|
+
}
|
|
1573
|
+
|
|
1574
|
+
function askDiscardQuestions() {
|
|
1575
|
+
if (!els.discardDialog) return Promise.resolve(false);
|
|
1576
|
+
return new Promise((resolve) => {
|
|
1577
|
+
discardDialogResolve = resolve;
|
|
1578
|
+
const onClose = () => {
|
|
1579
|
+
els.discardDialog.removeEventListener("close", onClose);
|
|
1580
|
+
const answer = els.discardDialog.returnValue;
|
|
1581
|
+
const done = discardDialogResolve;
|
|
1582
|
+
discardDialogResolve = null;
|
|
1583
|
+
done?.(answer === "confirm");
|
|
1584
|
+
};
|
|
1585
|
+
els.discardDialog.addEventListener("close", onClose);
|
|
1586
|
+
els.discardDialog.returnValue = "";
|
|
1587
|
+
els.discardDialog.showModal();
|
|
1588
|
+
});
|
|
1589
|
+
}
|
|
1590
|
+
|
|
1591
|
+
async function discardOpenQuestions() {
|
|
1592
|
+
actionNotice = "Discarding questions…";
|
|
1593
|
+
setActionHint(actionNotice);
|
|
1594
|
+
try {
|
|
1595
|
+
const res = await fetch("/api/agent-questions/discard", {
|
|
1596
|
+
method: "POST",
|
|
1597
|
+
headers: { "Content-Type": "application/json" },
|
|
1598
|
+
body: "{}",
|
|
1599
|
+
});
|
|
1600
|
+
const payload = await res.json();
|
|
1601
|
+
if (payload.health || payload.packId) state = { ...state, ...payload };
|
|
1602
|
+
applyActivities(payload);
|
|
1603
|
+
actionNotice = payload.error ?? payload.message ?? "Discarded the agent's questions.";
|
|
1604
|
+
} catch (err) {
|
|
1605
|
+
actionNotice = err instanceof Error ? err.message : "Could not discard questions.";
|
|
1606
|
+
}
|
|
1607
|
+
setActionHint(actionNotice);
|
|
1608
|
+
render();
|
|
1609
|
+
}
|
|
1610
|
+
|
|
1266
1611
|
function viewForAction(id) {
|
|
1267
1612
|
if (id === "check-jev") return "judgment";
|
|
1268
1613
|
if (id === "improve" || id === "review-improve" || id === "fix-spec" || id === "create") return "define";
|
|
1614
|
+
if (id === "answer-questions" || id === "discard-questions") {
|
|
1615
|
+
return openQuestions()?.channel === "implement" ? "implement" : "define";
|
|
1616
|
+
}
|
|
1269
1617
|
if (id === "implement" || id === "stop-implement" || id === "ignore-build" || id === "fix-from-proof") {
|
|
1270
1618
|
return state?.health?.build?.owned === false ? null : "implement";
|
|
1271
1619
|
}
|
|
@@ -1296,7 +1644,7 @@ async function runStageAction(id) {
|
|
|
1296
1644
|
return;
|
|
1297
1645
|
}
|
|
1298
1646
|
if (id === "improve") {
|
|
1299
|
-
|
|
1647
|
+
implementLines = [{ level: "info", message: "Improve started." }];
|
|
1300
1648
|
actionNotice = "Writing the improve brief…";
|
|
1301
1649
|
setActionHint(actionNotice);
|
|
1302
1650
|
renderActivity();
|
|
@@ -1307,11 +1655,35 @@ async function runStageAction(id) {
|
|
|
1307
1655
|
await runNextAction("Accepting…", "/api/improve/accept");
|
|
1308
1656
|
return;
|
|
1309
1657
|
}
|
|
1658
|
+
if (id === "answer-questions") {
|
|
1659
|
+
const round = openQuestions();
|
|
1660
|
+
if (!round || !questionsContinueEnabled(round)) return;
|
|
1661
|
+
const kind = round.channel === "improve" ? "improve" : "implement";
|
|
1662
|
+
actionNotice = "Continuing with owner answers…";
|
|
1663
|
+
setActionHint(actionNotice);
|
|
1664
|
+
await runBackgroundAction(
|
|
1665
|
+
"Continuing…",
|
|
1666
|
+
"/api/agent-answers",
|
|
1667
|
+
{ answers: collectedAnswers(round), adapter: recordedAdapter() },
|
|
1668
|
+
kind,
|
|
1669
|
+
);
|
|
1670
|
+
return;
|
|
1671
|
+
}
|
|
1672
|
+
if (id === "discard-questions") {
|
|
1673
|
+
const confirmed = await askDiscardQuestions();
|
|
1674
|
+
if (!confirmed) return;
|
|
1675
|
+
await discardOpenQuestions();
|
|
1676
|
+
return;
|
|
1677
|
+
}
|
|
1310
1678
|
if (id === "check-jev") {
|
|
1311
1679
|
await runNextAction("Checking…", "/api/check-jev");
|
|
1312
1680
|
return;
|
|
1313
1681
|
}
|
|
1314
1682
|
if (id === "stop-implement") {
|
|
1683
|
+
if (openQuestions()?.channel === "implement") {
|
|
1684
|
+
const confirmed = await askDiscardQuestions();
|
|
1685
|
+
if (!confirmed) return;
|
|
1686
|
+
}
|
|
1315
1687
|
actionNotice = "Stopping…";
|
|
1316
1688
|
setActionHint(actionNotice);
|
|
1317
1689
|
try {
|
|
@@ -1322,7 +1694,7 @@ async function runStageAction(id) {
|
|
|
1322
1694
|
});
|
|
1323
1695
|
const payload = await res.json();
|
|
1324
1696
|
if (payload.health || payload.packId) state = { ...state, ...payload };
|
|
1325
|
-
|
|
1697
|
+
applyActivities(payload);
|
|
1326
1698
|
actionNotice = payload.error ?? payload.message ?? "Owner stopped Implement.";
|
|
1327
1699
|
} catch (err) {
|
|
1328
1700
|
actionNotice = err instanceof Error ? err.message : "Stop failed.";
|
|
@@ -1332,7 +1704,7 @@ async function runStageAction(id) {
|
|
|
1332
1704
|
return;
|
|
1333
1705
|
}
|
|
1334
1706
|
if (id === "implement") {
|
|
1335
|
-
|
|
1707
|
+
implementLines = [{ level: "info", message: "Implement started." }];
|
|
1336
1708
|
actionNotice = "Implement started.";
|
|
1337
1709
|
setMeter("build", "running");
|
|
1338
1710
|
renderActivity();
|
|
@@ -1351,7 +1723,7 @@ async function runStageAction(id) {
|
|
|
1351
1723
|
return;
|
|
1352
1724
|
}
|
|
1353
1725
|
if (id === "fix-from-proof") {
|
|
1354
|
-
|
|
1726
|
+
implementLines = [{ level: "info", message: "Fix from proof started." }];
|
|
1355
1727
|
actionNotice = "Fix from proof started.";
|
|
1356
1728
|
setMeter("build", "running");
|
|
1357
1729
|
renderActivity();
|
|
@@ -1365,7 +1737,8 @@ async function runStageAction(id) {
|
|
|
1365
1737
|
return;
|
|
1366
1738
|
}
|
|
1367
1739
|
if (id === "prove") {
|
|
1368
|
-
|
|
1740
|
+
proveLines = [{ level: "info", message: "Prove started." }];
|
|
1741
|
+
qaTab = "activity";
|
|
1369
1742
|
actionNotice = "Prove started.";
|
|
1370
1743
|
setMeter("proof", "running");
|
|
1371
1744
|
renderActivity();
|
|
@@ -1375,6 +1748,8 @@ async function runStageAction(id) {
|
|
|
1375
1748
|
}
|
|
1376
1749
|
|
|
1377
1750
|
async function runProveAction() {
|
|
1751
|
+
openView("qa");
|
|
1752
|
+
qaTab = "activity";
|
|
1378
1753
|
actionBusy = true;
|
|
1379
1754
|
headerBusyLabel = "Proving…";
|
|
1380
1755
|
paintActionButton(els.next, {
|
|
@@ -1394,8 +1769,8 @@ async function runProveAction() {
|
|
|
1394
1769
|
body: "{}",
|
|
1395
1770
|
});
|
|
1396
1771
|
const payload = await res.json();
|
|
1397
|
-
|
|
1398
|
-
|
|
1772
|
+
applyActivities(payload);
|
|
1773
|
+
if (Array.isArray(payload.proveActivity) && payload.proveActivity.length) {
|
|
1399
1774
|
renderActivity();
|
|
1400
1775
|
}
|
|
1401
1776
|
if (!res.ok && !payload.started) {
|
|
@@ -1424,17 +1799,16 @@ async function waitWhileBusy(kind) {
|
|
|
1424
1799
|
try {
|
|
1425
1800
|
const res = await fetch("/api/state");
|
|
1426
1801
|
const data = await res.json();
|
|
1427
|
-
if (data.health || data.packId || data.improveReview) state = { ...state, ...data };
|
|
1428
|
-
|
|
1429
|
-
if (data.improveReview?.files?.length) {
|
|
1802
|
+
if (data.health || data.packId || data.improveReview || data.agentQuestions) state = { ...state, ...data };
|
|
1803
|
+
applyActivities(data);
|
|
1804
|
+
if (data.improveReview?.files?.length || data.agentQuestions?.status === "open") {
|
|
1430
1805
|
actionNotice = "";
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
setActionHint(last.message);
|
|
1806
|
+
} else {
|
|
1807
|
+
const last = lastBusyMessage(kind === "prove" ? "prove" : "implement");
|
|
1808
|
+
if (last && !data.improveReview) {
|
|
1809
|
+
actionNotice = last;
|
|
1810
|
+
setActionHint(last);
|
|
1811
|
+
}
|
|
1438
1812
|
}
|
|
1439
1813
|
render();
|
|
1440
1814
|
if (data.busy !== kind) return;
|
|
@@ -1449,14 +1823,14 @@ async function refreshActivity() {
|
|
|
1449
1823
|
try {
|
|
1450
1824
|
const res = await fetch("/api/state");
|
|
1451
1825
|
const data = await res.json();
|
|
1452
|
-
if (data.health || data.packId || data.improveReview) state = { ...state, ...data };
|
|
1453
|
-
|
|
1454
|
-
if (data.improveReview?.files?.length) actionNotice = "";
|
|
1826
|
+
if (data.health || data.packId || data.improveReview || data.agentQuestions) state = { ...state, ...data };
|
|
1827
|
+
applyActivities(data);
|
|
1828
|
+
if (data.improveReview?.files?.length || data.agentQuestions?.status === "open") actionNotice = "";
|
|
1455
1829
|
else {
|
|
1456
|
-
const last =
|
|
1457
|
-
if (last
|
|
1458
|
-
actionNotice = last
|
|
1459
|
-
setActionHint(last
|
|
1830
|
+
const last = lastBusyMessage(data.busy === "prove" ? "prove" : "implement");
|
|
1831
|
+
if (last) {
|
|
1832
|
+
actionNotice = last;
|
|
1833
|
+
setActionHint(last);
|
|
1460
1834
|
}
|
|
1461
1835
|
}
|
|
1462
1836
|
render();
|
|
@@ -1487,8 +1861,11 @@ async function runBackgroundAction(busyLabel, url, body, kind) {
|
|
|
1487
1861
|
});
|
|
1488
1862
|
const payload = await res.json();
|
|
1489
1863
|
if (payload.health || payload.packId) state = { ...state, ...payload };
|
|
1490
|
-
|
|
1491
|
-
|
|
1864
|
+
applyActivities(payload);
|
|
1865
|
+
if (
|
|
1866
|
+
(Array.isArray(payload.implementActivity) && payload.implementActivity.length) ||
|
|
1867
|
+
(Array.isArray(payload.proveActivity) && payload.proveActivity.length)
|
|
1868
|
+
) {
|
|
1492
1869
|
renderActivity();
|
|
1493
1870
|
}
|
|
1494
1871
|
if (!res.ok && !payload.started) {
|
|
@@ -1536,7 +1913,7 @@ async function runNextAction(busyLabel, url, body) {
|
|
|
1536
1913
|
});
|
|
1537
1914
|
const payload = await res.json();
|
|
1538
1915
|
if (payload.health || payload.packId) state = { ...state, ...payload };
|
|
1539
|
-
|
|
1916
|
+
applyActivities(payload);
|
|
1540
1917
|
if (!res.ok || payload.error) {
|
|
1541
1918
|
actionNotice = payload.error ?? "Request failed.";
|
|
1542
1919
|
actionBusy = false;
|
|
@@ -1630,6 +2007,25 @@ els.stackNextjs?.addEventListener("click", () => void recordStack("nextjs-defaul
|
|
|
1630
2007
|
els.stackAmplify?.addEventListener("click", () => void recordStack("amplify-gen2"));
|
|
1631
2008
|
|
|
1632
2009
|
els.homeBtn?.addEventListener("click", () => void goHome());
|
|
2010
|
+
els.qaTabActivity?.addEventListener("click", () => {
|
|
2011
|
+
qaTab = "activity";
|
|
2012
|
+
renderQaLayout();
|
|
2013
|
+
});
|
|
2014
|
+
els.qaTabReport?.addEventListener("click", () => {
|
|
2015
|
+
qaTab = "report";
|
|
2016
|
+
renderQaLayout();
|
|
2017
|
+
});
|
|
2018
|
+
els.implementTabQuestions?.addEventListener("click", () => {
|
|
2019
|
+
implementTab = "questions";
|
|
2020
|
+
renderImplementLayout();
|
|
2021
|
+
});
|
|
2022
|
+
els.implementTabActivity?.addEventListener("click", () => {
|
|
2023
|
+
implementTab = "activity";
|
|
2024
|
+
renderImplementLayout();
|
|
2025
|
+
});
|
|
2026
|
+
els.discardCancel?.addEventListener("click", () => closeDiscardDialog("cancel"));
|
|
2027
|
+
els.discardConfirm?.addEventListener("click", () => closeDiscardDialog("confirm"));
|
|
2028
|
+
els.discardDialog?.addEventListener("cancel", () => closeDiscardDialog("cancel"));
|
|
1633
2029
|
els.allRequirements?.addEventListener("click", () => void goHome());
|
|
1634
2030
|
els.packMenu?.addEventListener("contextmenu", (event) => event.preventDefault());
|
|
1635
2031
|
els.packMenuDelete?.addEventListener("click", () => openDeleteDialog());
|