@richjava/req0 0.2.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 +360 -25
- package/cockpit/index.html +34 -3
- package/cockpit/styles.css +72 -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.js +121 -6
- package/dist/types.d.ts +4 -0
- package/package.json +1 -1
package/cockpit/app.js
CHANGED
|
@@ -45,6 +45,8 @@ const els = {
|
|
|
45
45
|
createNew: document.getElementById("create-new"),
|
|
46
46
|
createError: document.getElementById("create-error"),
|
|
47
47
|
homeBtn: document.getElementById("home-btn"),
|
|
48
|
+
projectName: document.getElementById("project-name"),
|
|
49
|
+
subbar: document.getElementById("subbar"),
|
|
48
50
|
allRequirements: document.getElementById("all-requirements"),
|
|
49
51
|
packHome: document.getElementById("pack-home"),
|
|
50
52
|
packWorkspace: document.getElementById("pack-workspace"),
|
|
@@ -75,6 +77,18 @@ const els = {
|
|
|
75
77
|
reviewDiff: document.getElementById("review-diff"),
|
|
76
78
|
reviewAccept: document.getElementById("review-accept"),
|
|
77
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"),
|
|
78
92
|
};
|
|
79
93
|
|
|
80
94
|
let state = null;
|
|
@@ -103,6 +117,10 @@ let proveLines = [];
|
|
|
103
117
|
let lastImplementKey = "";
|
|
104
118
|
let lastProveKey = "";
|
|
105
119
|
let qaTab = "activity";
|
|
120
|
+
let implementTab = "questions";
|
|
121
|
+
let questionDrafts = {};
|
|
122
|
+
let questionDraftKey = "";
|
|
123
|
+
let lastQuestionsKey = "";
|
|
106
124
|
let loadInFlight = false;
|
|
107
125
|
let loadAgain = false;
|
|
108
126
|
let loadTimer;
|
|
@@ -206,11 +224,18 @@ function renderSetupGate(snapshot) {
|
|
|
206
224
|
}
|
|
207
225
|
}
|
|
208
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
|
+
|
|
209
233
|
function render() {
|
|
210
234
|
const health = state.health;
|
|
211
235
|
const packId = state.packId;
|
|
212
236
|
const onHome = !packId;
|
|
213
237
|
const packList = Array.isArray(state.packList) ? state.packList : [];
|
|
238
|
+
if (els.projectName) els.projectName.textContent = directoryName(state.cwd);
|
|
214
239
|
els.title.textContent = packId ? `Requirement: ${packId.replaceAll("-", " ")}` : "Requirements";
|
|
215
240
|
els.going.textContent = packId
|
|
216
241
|
? (health?.howThisIsGoing ?? "")
|
|
@@ -221,17 +246,24 @@ function render() {
|
|
|
221
246
|
|
|
222
247
|
const action = health?.nextAction;
|
|
223
248
|
const review = state.improveReview;
|
|
224
|
-
|
|
249
|
+
const questions = openQuestions();
|
|
250
|
+
syncQuestionDrafts(questions);
|
|
251
|
+
maybeOpenQuestions(questions);
|
|
252
|
+
if (review?.files?.length || questions) actionNotice = "";
|
|
225
253
|
const canStop = action?.id === "stop-implement";
|
|
226
|
-
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);
|
|
227
259
|
const nextLabel =
|
|
228
|
-
actionBusy && headerBusyLabel && !canStop && !review?.files?.length
|
|
260
|
+
actionBusy && headerBusyLabel && !canStop && !review?.files?.length && !questions
|
|
229
261
|
? headerBusyLabel
|
|
230
262
|
: action?.label ?? "Create a requirement";
|
|
231
263
|
paintActionButton(els.next, {
|
|
232
264
|
id: action?.id ?? "create",
|
|
233
265
|
label: nextLabel,
|
|
234
|
-
hint: review ? action?.hint || "" : actionNotice || action?.hint || "",
|
|
266
|
+
hint: questions || review ? action?.hint || "" : actionNotice || action?.hint || "",
|
|
235
267
|
enabled: nextEnabled,
|
|
236
268
|
primary: true,
|
|
237
269
|
hidden: false,
|
|
@@ -244,6 +276,7 @@ function render() {
|
|
|
244
276
|
els.next.hidden = gated || onHome;
|
|
245
277
|
els.packHome?.classList.toggle("hidden", !onHome);
|
|
246
278
|
els.packWorkspace?.classList.toggle("hidden", onHome);
|
|
279
|
+
els.subbar?.classList.toggle("hidden", onHome);
|
|
247
280
|
els.allRequirements?.classList.toggle("hidden", onHome);
|
|
248
281
|
els.createBar?.classList.toggle("hidden", !onHome);
|
|
249
282
|
if (!onHome) hidePackMenu();
|
|
@@ -257,10 +290,10 @@ function render() {
|
|
|
257
290
|
|
|
258
291
|
if (onHome) return;
|
|
259
292
|
|
|
260
|
-
if (review && currentView !== "define") currentView = "define";
|
|
293
|
+
if (review && !questions && currentView !== "define") currentView = "define";
|
|
261
294
|
if (currentView === "implement" && health?.build?.owned === false) currentView = "define";
|
|
262
295
|
|
|
263
|
-
if (!applying && !state.improveReview) {
|
|
296
|
+
if (!applying && !state.improveReview && questions?.channel !== "improve") {
|
|
264
297
|
applying = true;
|
|
265
298
|
markdownEditor.setValue(state.markdown ?? "");
|
|
266
299
|
applying = false;
|
|
@@ -270,6 +303,8 @@ function render() {
|
|
|
270
303
|
renderStageNav();
|
|
271
304
|
showView(currentView);
|
|
272
305
|
renderReview();
|
|
306
|
+
renderQuestions();
|
|
307
|
+
renderImplementLayout();
|
|
273
308
|
renderSpecPane();
|
|
274
309
|
renderJudgmentPane();
|
|
275
310
|
renderRunStatus();
|
|
@@ -404,6 +439,8 @@ async function selectPack(id) {
|
|
|
404
439
|
takeState(body);
|
|
405
440
|
currentView = "define";
|
|
406
441
|
qaTab = "activity";
|
|
442
|
+
implementTab = "questions";
|
|
443
|
+
lastQuestionsKey = "";
|
|
407
444
|
actionNotice = "";
|
|
408
445
|
render();
|
|
409
446
|
}
|
|
@@ -419,22 +456,234 @@ async function goHome() {
|
|
|
419
456
|
takeState(body);
|
|
420
457
|
currentView = "define";
|
|
421
458
|
qaTab = "activity";
|
|
459
|
+
implementTab = "questions";
|
|
460
|
+
lastQuestionsKey = "";
|
|
422
461
|
actionNotice = "";
|
|
423
462
|
render();
|
|
424
463
|
}
|
|
425
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
|
+
|
|
426
672
|
function renderReview() {
|
|
427
|
-
const
|
|
673
|
+
const askingDefine = openQuestions()?.channel === "improve";
|
|
674
|
+
const review = askingDefine ? null : state.improveReview;
|
|
428
675
|
const reviewing = Boolean(review);
|
|
429
676
|
const hasDiff = Boolean(review?.files?.length);
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
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
|
+
}
|
|
433
682
|
if (!els.reviewActions || !els.reviewDiff) return;
|
|
434
683
|
els.reviewActions.classList.toggle("hidden", !reviewing);
|
|
435
684
|
els.reviewDiff.classList.toggle("hidden", !reviewing);
|
|
436
685
|
els.reviewDiff.hidden = !reviewing;
|
|
437
|
-
if (els.workspaceLabel) {
|
|
686
|
+
if (els.workspaceLabel && !askingDefine) {
|
|
438
687
|
els.workspaceLabel.textContent = hasDiff ? "Improve patch" : reviewing ? "Waiting for the patch" : "requirement.md";
|
|
439
688
|
}
|
|
440
689
|
const lintOk = review?.lint?.ok !== false;
|
|
@@ -531,13 +780,13 @@ function actionGlyph(id, label = "") {
|
|
|
531
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"/>`,
|
|
532
781
|
);
|
|
533
782
|
}
|
|
534
|
-
if (id === "review-improve") {
|
|
783
|
+
if (id === "review-improve" || id === "answer-questions") {
|
|
535
784
|
return iconSvg(
|
|
536
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"/>`,
|
|
537
786
|
);
|
|
538
787
|
}
|
|
539
|
-
if (id === "reject-improve" || id === "stop-implement") {
|
|
540
|
-
return id === "stop-implement"
|
|
788
|
+
if (id === "reject-improve" || id === "stop-implement" || id === "discard-questions") {
|
|
789
|
+
return id === "stop-implement" || id === "discard-questions"
|
|
541
790
|
? iconSvg(`<rect x="4.2" y="4.2" width="7.6" height="7.6" rx="1.2" fill="currentColor"/>`)
|
|
542
791
|
: iconSvg(
|
|
543
792
|
`<path d="M4 4l8 8M12 4l-8 8" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/>`,
|
|
@@ -1274,6 +1523,12 @@ onEnabledClick(els.reviewAccept, () => {
|
|
|
1274
1523
|
onEnabledClick(els.reviewReject, () => {
|
|
1275
1524
|
void runNextAction("Rejecting…", "/api/improve/reject");
|
|
1276
1525
|
});
|
|
1526
|
+
onEnabledClick(els.questionContinue, () => {
|
|
1527
|
+
void runStageAction("answer-questions");
|
|
1528
|
+
});
|
|
1529
|
+
onEnabledClick(els.questionStop, () => {
|
|
1530
|
+
void runStageAction("discard-questions");
|
|
1531
|
+
});
|
|
1277
1532
|
onEnabledClick(els.next, () => {
|
|
1278
1533
|
void runStageAction(state.health?.nextAction?.id);
|
|
1279
1534
|
});
|
|
@@ -1310,9 +1565,55 @@ function askIgnoreBuild() {
|
|
|
1310
1565
|
});
|
|
1311
1566
|
}
|
|
1312
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
|
+
|
|
1313
1611
|
function viewForAction(id) {
|
|
1314
1612
|
if (id === "check-jev") return "judgment";
|
|
1315
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
|
+
}
|
|
1316
1617
|
if (id === "implement" || id === "stop-implement" || id === "ignore-build" || id === "fix-from-proof") {
|
|
1317
1618
|
return state?.health?.build?.owned === false ? null : "implement";
|
|
1318
1619
|
}
|
|
@@ -1354,11 +1655,35 @@ async function runStageAction(id) {
|
|
|
1354
1655
|
await runNextAction("Accepting…", "/api/improve/accept");
|
|
1355
1656
|
return;
|
|
1356
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
|
+
}
|
|
1357
1678
|
if (id === "check-jev") {
|
|
1358
1679
|
await runNextAction("Checking…", "/api/check-jev");
|
|
1359
1680
|
return;
|
|
1360
1681
|
}
|
|
1361
1682
|
if (id === "stop-implement") {
|
|
1683
|
+
if (openQuestions()?.channel === "implement") {
|
|
1684
|
+
const confirmed = await askDiscardQuestions();
|
|
1685
|
+
if (!confirmed) return;
|
|
1686
|
+
}
|
|
1362
1687
|
actionNotice = "Stopping…";
|
|
1363
1688
|
setActionHint(actionNotice);
|
|
1364
1689
|
try {
|
|
@@ -1474,17 +1799,16 @@ async function waitWhileBusy(kind) {
|
|
|
1474
1799
|
try {
|
|
1475
1800
|
const res = await fetch("/api/state");
|
|
1476
1801
|
const data = await res.json();
|
|
1477
|
-
if (data.health || data.packId || data.improveReview) state = { ...state, ...data };
|
|
1802
|
+
if (data.health || data.packId || data.improveReview || data.agentQuestions) state = { ...state, ...data };
|
|
1478
1803
|
applyActivities(data);
|
|
1479
|
-
if (data.improveReview?.files?.length) {
|
|
1804
|
+
if (data.improveReview?.files?.length || data.agentQuestions?.status === "open") {
|
|
1480
1805
|
actionNotice = "";
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
setActionHint(last);
|
|
1806
|
+
} else {
|
|
1807
|
+
const last = lastBusyMessage(kind === "prove" ? "prove" : "implement");
|
|
1808
|
+
if (last && !data.improveReview) {
|
|
1809
|
+
actionNotice = last;
|
|
1810
|
+
setActionHint(last);
|
|
1811
|
+
}
|
|
1488
1812
|
}
|
|
1489
1813
|
render();
|
|
1490
1814
|
if (data.busy !== kind) return;
|
|
@@ -1499,9 +1823,9 @@ async function refreshActivity() {
|
|
|
1499
1823
|
try {
|
|
1500
1824
|
const res = await fetch("/api/state");
|
|
1501
1825
|
const data = await res.json();
|
|
1502
|
-
if (data.health || data.packId || data.improveReview) state = { ...state, ...data };
|
|
1826
|
+
if (data.health || data.packId || data.improveReview || data.agentQuestions) state = { ...state, ...data };
|
|
1503
1827
|
applyActivities(data);
|
|
1504
|
-
if (data.improveReview?.files?.length) actionNotice = "";
|
|
1828
|
+
if (data.improveReview?.files?.length || data.agentQuestions?.status === "open") actionNotice = "";
|
|
1505
1829
|
else {
|
|
1506
1830
|
const last = lastBusyMessage(data.busy === "prove" ? "prove" : "implement");
|
|
1507
1831
|
if (last) {
|
|
@@ -1691,6 +2015,17 @@ els.qaTabReport?.addEventListener("click", () => {
|
|
|
1691
2015
|
qaTab = "report";
|
|
1692
2016
|
renderQaLayout();
|
|
1693
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"));
|
|
1694
2029
|
els.allRequirements?.addEventListener("click", () => void goHome());
|
|
1695
2030
|
els.packMenu?.addEventListener("contextmenu", (event) => event.preventDefault());
|
|
1696
2031
|
els.packMenuDelete?.addEventListener("click", () => openDeleteDialog());
|
package/cockpit/index.html
CHANGED
|
@@ -16,11 +16,21 @@
|
|
|
16
16
|
<body>
|
|
17
17
|
<div class="app-shell app-shell-pipeline">
|
|
18
18
|
<header class="topbar">
|
|
19
|
-
<div class="topbar-
|
|
19
|
+
<div class="topbar-brand">
|
|
20
20
|
<button type="button" class="home-btn" id="home-btn" aria-label="All requirements">
|
|
21
21
|
<img class="logo-horiz" src="/req0-logo-horiz.png" alt="Req0" width="148" height="36" />
|
|
22
22
|
</button>
|
|
23
|
-
<
|
|
23
|
+
<p class="project-name" id="project-name"></p>
|
|
24
|
+
</div>
|
|
25
|
+
</header>
|
|
26
|
+
<header class="subbar" id="subbar">
|
|
27
|
+
<div class="topbar-start">
|
|
28
|
+
<button type="button" class="btn-secondary hidden" id="all-requirements">
|
|
29
|
+
<svg viewBox="0 0 16 16" aria-hidden="true">
|
|
30
|
+
<path d="M13 8H3.5M6.2 4.8 3 8l3.2 3.2" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/>
|
|
31
|
+
</svg>
|
|
32
|
+
All requirements
|
|
33
|
+
</button>
|
|
24
34
|
<div class="topbar-copy">
|
|
25
35
|
<p class="sidebar-pack" id="pack-title">Loading…</p>
|
|
26
36
|
<p class="going" id="how-going">Loading…</p>
|
|
@@ -101,9 +111,14 @@
|
|
|
101
111
|
<button type="button" class="btn-secondary cta" id="review-reject">Reject</button>
|
|
102
112
|
<button type="button" class="btn-primary cta" id="review-accept" disabled>Accept</button>
|
|
103
113
|
</div>
|
|
114
|
+
<div class="review-actions hidden" id="question-actions">
|
|
115
|
+
<button type="button" class="btn-secondary cta" id="question-stop">Stop</button>
|
|
116
|
+
<button type="button" class="btn-primary cta" id="question-continue" disabled>Continue</button>
|
|
117
|
+
</div>
|
|
104
118
|
</div>
|
|
105
119
|
<div id="editor" class="markdown-editor" aria-label="requirement.md"></div>
|
|
106
120
|
<div class="review-diff hidden" id="review-diff" hidden></div>
|
|
121
|
+
<div class="question-panel hidden" id="define-questions" hidden></div>
|
|
107
122
|
<p class="save-state" id="save-state"></p>
|
|
108
123
|
</section>
|
|
109
124
|
|
|
@@ -133,7 +148,16 @@
|
|
|
133
148
|
<button type="button" class="pill-btn cta" id="action-build-stop" hidden disabled></button>
|
|
134
149
|
</div>
|
|
135
150
|
</div>
|
|
136
|
-
<
|
|
151
|
+
<div class="qa-tab-bar hidden" id="implement-tabs" role="tablist" hidden>
|
|
152
|
+
<button type="button" class="qa-tab is-active" role="tab" id="implement-tab-questions" aria-selected="true" aria-controls="implement-questions">
|
|
153
|
+
Questions
|
|
154
|
+
</button>
|
|
155
|
+
<button type="button" class="qa-tab" role="tab" id="implement-tab-activity" aria-selected="false" aria-controls="implement-activity">
|
|
156
|
+
Activity
|
|
157
|
+
</button>
|
|
158
|
+
</div>
|
|
159
|
+
<p class="nav-label" id="implement-activity-label">Activity</p>
|
|
160
|
+
<div class="question-panel hidden" id="implement-questions" hidden></div>
|
|
137
161
|
<ol id="implement-activity" class="list-rows activity-log activity-log-main"></ol>
|
|
138
162
|
</section>
|
|
139
163
|
|
|
@@ -166,6 +190,13 @@
|
|
|
166
190
|
</div>
|
|
167
191
|
</div>
|
|
168
192
|
</div>
|
|
193
|
+
<dialog id="discard-questions-dialog" class="confirm-dialog">
|
|
194
|
+
<p>Stop and discard unanswered questions?</p>
|
|
195
|
+
<div class="dialog-actions">
|
|
196
|
+
<button type="button" class="btn-secondary" id="discard-questions-cancel">Cancel</button>
|
|
197
|
+
<button type="button" class="btn-primary cta-danger" id="discard-questions-confirm">Stop</button>
|
|
198
|
+
</div>
|
|
199
|
+
</dialog>
|
|
169
200
|
<dialog id="ignore-build-dialog" class="confirm-dialog">
|
|
170
201
|
<p>Was implementation successful?</p>
|
|
171
202
|
<div class="dialog-actions">
|