@richjava/req0 0.3.0 → 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/README.md +6 -5
- package/cockpit/app.js +299 -29
- package/cockpit/index.html +18 -1
- package/cockpit/styles.css +37 -0
- package/dist/agent-questions.d.ts +15 -4
- package/dist/agent-questions.js +75 -26
- package/dist/author.d.ts +103 -0
- package/dist/author.js +435 -0
- package/dist/pack.d.ts +45 -2
- package/dist/pack.js +203 -1
- package/dist/server.d.ts +3 -1
- package/dist/server.js +173 -9
- package/dist/types.d.ts +3 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
|
|
7
7
|
# Req0
|
|
8
8
|
|
|
9
|
-
Req0
|
|
9
|
+
Req0 allows you to keep structured requirement packs in your product git repo. The same pack drives definition, implementation, and proof — not a ticket, a chat, or a separate test script.
|
|
10
10
|
|
|
11
|
-
A local **cockpit**
|
|
11
|
+
A local **cockpit** runs that loop: a coding agent (Cursor or Copilot) interviews you, drafts frozen-grammar `requirement.md`, and later implements — only after you answer, a compiler checks the grammar, and **Jev** (TypeSafe System One) judges Ready. The browser then proves the app against the spec. If proof fails, **Fix from proof** sends that report back so the same agent can repair the implementation — not the spec.
|
|
12
12
|
|
|
13
|
-
Req0 is a CLI plus a thin HTML cockpit. It is not a hosted SaaS.
|
|
13
|
+
Req0 is a CLI plus a thin HTML cockpit, free and open source. It is not a hosted SaaS.
|
|
14
14
|
|
|
15
15
|
## Install
|
|
16
16
|
|
|
@@ -37,9 +37,9 @@ cd /path/to/your-product
|
|
|
37
37
|
req0 start
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
-
The cockpit opens at `http://127.0.0.1:4370` (or the next free port). From the requirement list, create a pack with a kebab-case id such as `001`. That writes `docs/requirements/<id
|
|
40
|
+
The cockpit opens at `http://127.0.0.1:4370` (or the next free port). From the requirement list, create a pack with a kebab-case id such as `001`. That writes `docs/requirements/<id>/`. On **Define**, describe the requirement and **Start** — the recorded coding agent interviews you (you can skip questions) and drafts frozen-grammar `requirement.md`. Optional PNG/JPG/WebP go in that pack’s `context/` folder. `req0 create` on the CLI still writes the starter template only.
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
You can also edit `requirement.md` yourself. Save compiles. Spec Valid means the [grammar](https://github.com/richjava/req0/blob/main/docs/grammar.md) parsed — it does not mean the spec is ready to implement. With a TypeSafe key, authoring keeps going until Ready is Clear; without one, it stops at Spec Valid.
|
|
43
43
|
|
|
44
44
|
## Commands
|
|
45
45
|
|
|
@@ -65,6 +65,7 @@ docs/requirements/invoice-approval/
|
|
|
65
65
|
requirement.md
|
|
66
66
|
fixtures/personas.yaml # test users, never production credentials
|
|
67
67
|
fixtures/runtime.yaml # app URL and login selectors for Prove
|
|
68
|
+
context/ # optional screenshots the authoring agent can Read
|
|
68
69
|
derived/ # generated; do not hand-edit
|
|
69
70
|
```
|
|
70
71
|
|
package/cockpit/app.js
CHANGED
|
@@ -80,7 +80,15 @@ const els = {
|
|
|
80
80
|
questionActions: document.getElementById("question-actions"),
|
|
81
81
|
questionContinue: document.getElementById("question-continue"),
|
|
82
82
|
questionStop: document.getElementById("question-stop"),
|
|
83
|
+
questionSkipAll: document.getElementById("question-skip-all"),
|
|
83
84
|
defineQuestions: document.getElementById("define-questions"),
|
|
85
|
+
defineTabs: document.getElementById("define-tabs"),
|
|
86
|
+
defineTabQuestions: document.getElementById("define-tab-questions"),
|
|
87
|
+
defineTabActivity: document.getElementById("define-tab-activity"),
|
|
88
|
+
defineActivity: document.getElementById("define-activity"),
|
|
89
|
+
authorDescribe: document.getElementById("author-describe"),
|
|
90
|
+
authorDescription: document.getElementById("author-description"),
|
|
91
|
+
authorStart: document.getElementById("author-start"),
|
|
84
92
|
implementTabs: document.getElementById("implement-tabs"),
|
|
85
93
|
implementTabQuestions: document.getElementById("implement-tab-questions"),
|
|
86
94
|
implementTabActivity: document.getElementById("implement-tab-activity"),
|
|
@@ -118,6 +126,10 @@ let lastImplementKey = "";
|
|
|
118
126
|
let lastProveKey = "";
|
|
119
127
|
let qaTab = "activity";
|
|
120
128
|
let implementTab = "questions";
|
|
129
|
+
let defineTab = "questions";
|
|
130
|
+
let authorLines = [];
|
|
131
|
+
let lastAuthorKey = "";
|
|
132
|
+
const SKIP_ANSWER = "__skip__";
|
|
121
133
|
let questionDrafts = {};
|
|
122
134
|
let questionDraftKey = "";
|
|
123
135
|
let lastQuestionsKey = "";
|
|
@@ -130,10 +142,11 @@ function applyActivities(payload) {
|
|
|
130
142
|
if (!payload) return;
|
|
131
143
|
if (Array.isArray(payload.implementActivity)) implementLines = payload.implementActivity;
|
|
132
144
|
if (Array.isArray(payload.proveActivity)) proveLines = payload.proveActivity;
|
|
145
|
+
if (Array.isArray(payload.authorActivity)) authorLines = payload.authorActivity;
|
|
133
146
|
}
|
|
134
147
|
|
|
135
148
|
function lastBusyMessage(kind) {
|
|
136
|
-
const lines = kind === "prove" ? proveLines : implementLines;
|
|
149
|
+
const lines = kind === "prove" ? proveLines : kind === "author" ? authorLines : implementLines;
|
|
137
150
|
return lines[lines.length - 1]?.message ?? "";
|
|
138
151
|
}
|
|
139
152
|
|
|
@@ -250,11 +263,13 @@ function render() {
|
|
|
250
263
|
syncQuestionDrafts(questions);
|
|
251
264
|
maybeOpenQuestions(questions);
|
|
252
265
|
if (review?.files?.length || questions) actionNotice = "";
|
|
253
|
-
const canStop = action?.id === "stop-implement";
|
|
266
|
+
const canStop = action?.id === "stop-implement" || action?.id === "stop-author";
|
|
254
267
|
const continueReady = action?.id !== "answer-questions" || questionsContinueEnabled(questions);
|
|
268
|
+
const describeReady = action?.id !== "author-start" || Boolean(String(els.authorDescription?.value ?? "").trim());
|
|
255
269
|
const nextEnabled =
|
|
256
270
|
Boolean(action?.enabled) &&
|
|
257
271
|
continueReady &&
|
|
272
|
+
describeReady &&
|
|
258
273
|
!(actionBusy && !canStop && !review?.files?.length && !questions);
|
|
259
274
|
const nextLabel =
|
|
260
275
|
actionBusy && headerBusyLabel && !canStop && !review?.files?.length && !questions
|
|
@@ -293,7 +308,7 @@ function render() {
|
|
|
293
308
|
if (review && !questions && currentView !== "define") currentView = "define";
|
|
294
309
|
if (currentView === "implement" && health?.build?.owned === false) currentView = "define";
|
|
295
310
|
|
|
296
|
-
if (!applying && !state.improveReview && questions?.channel !== "improve") {
|
|
311
|
+
if (!applying && !state.improveReview && questions?.channel !== "improve" && questions?.channel !== "author") {
|
|
297
312
|
applying = true;
|
|
298
313
|
markdownEditor.setValue(state.markdown ?? "");
|
|
299
314
|
applying = false;
|
|
@@ -302,8 +317,10 @@ function render() {
|
|
|
302
317
|
renderPipeline();
|
|
303
318
|
renderStageNav();
|
|
304
319
|
showView(currentView);
|
|
320
|
+
renderAuthorDescribe();
|
|
305
321
|
renderReview();
|
|
306
322
|
renderQuestions();
|
|
323
|
+
renderDefineLayout();
|
|
307
324
|
renderImplementLayout();
|
|
308
325
|
renderSpecPane();
|
|
309
326
|
renderJudgmentPane();
|
|
@@ -440,7 +457,10 @@ async function selectPack(id) {
|
|
|
440
457
|
currentView = "define";
|
|
441
458
|
qaTab = "activity";
|
|
442
459
|
implementTab = "questions";
|
|
460
|
+
defineTab = "questions";
|
|
443
461
|
lastQuestionsKey = "";
|
|
462
|
+
authorLines = [];
|
|
463
|
+
if (els.authorDescription) els.authorDescription.value = "";
|
|
444
464
|
actionNotice = "";
|
|
445
465
|
render();
|
|
446
466
|
}
|
|
@@ -457,7 +477,9 @@ async function goHome() {
|
|
|
457
477
|
currentView = "define";
|
|
458
478
|
qaTab = "activity";
|
|
459
479
|
implementTab = "questions";
|
|
480
|
+
defineTab = "questions";
|
|
460
481
|
lastQuestionsKey = "";
|
|
482
|
+
authorLines = [];
|
|
461
483
|
actionNotice = "";
|
|
462
484
|
render();
|
|
463
485
|
}
|
|
@@ -472,9 +494,10 @@ function openQuestions() {
|
|
|
472
494
|
|
|
473
495
|
function questionsContinueEnabled(round = openQuestions()) {
|
|
474
496
|
if (!round) return false;
|
|
475
|
-
return round.questions.every(
|
|
476
|
-
(
|
|
477
|
-
|
|
497
|
+
return round.questions.every((question) => {
|
|
498
|
+
if (!question.required) return true;
|
|
499
|
+
return Boolean(String(questionDrafts[question.id] ?? "").trim());
|
|
500
|
+
});
|
|
478
501
|
}
|
|
479
502
|
|
|
480
503
|
function syncQuestionDrafts(round) {
|
|
@@ -486,15 +509,18 @@ function syncQuestionDrafts(round) {
|
|
|
486
509
|
questionDrafts = {};
|
|
487
510
|
if (!round) return;
|
|
488
511
|
for (const question of round.questions) {
|
|
489
|
-
questionDrafts[question.id] = question.answer?.
|
|
512
|
+
questionDrafts[question.id] = question.answer?.skipped
|
|
513
|
+
? SKIP_ANSWER
|
|
514
|
+
: question.answer?.optionId || question.answer?.text || question.answer?.artifact || "";
|
|
490
515
|
}
|
|
491
516
|
}
|
|
492
517
|
|
|
493
518
|
function maybeOpenQuestions(round) {
|
|
494
519
|
const key = round ? `${round.channel}|${round.at}` : "";
|
|
495
520
|
if (key && key !== lastQuestionsKey) {
|
|
496
|
-
currentView = round.channel === "
|
|
497
|
-
implementTab = "questions";
|
|
521
|
+
currentView = round.channel === "implement" ? "implement" : "define";
|
|
522
|
+
if (round.channel === "implement") implementTab = "questions";
|
|
523
|
+
else defineTab = "questions";
|
|
498
524
|
}
|
|
499
525
|
lastQuestionsKey = key;
|
|
500
526
|
}
|
|
@@ -508,18 +534,70 @@ function collectedAnswers(round = openQuestions()) {
|
|
|
508
534
|
return answers;
|
|
509
535
|
}
|
|
510
536
|
|
|
537
|
+
async function uploadAuthorArtifact(questionId, file, status) {
|
|
538
|
+
status.textContent = "Uploading…";
|
|
539
|
+
try {
|
|
540
|
+
const data = await fileToBase64(file);
|
|
541
|
+
const res = await fetch("/api/author/artifact", {
|
|
542
|
+
method: "POST",
|
|
543
|
+
headers: { "Content-Type": "application/json" },
|
|
544
|
+
body: JSON.stringify({ filename: file.name, mime: file.type || mimeFromName(file.name), data }),
|
|
545
|
+
});
|
|
546
|
+
const body = await res.json();
|
|
547
|
+
if (!res.ok) {
|
|
548
|
+
status.textContent = body.error ?? "Could not save the upload.";
|
|
549
|
+
return;
|
|
550
|
+
}
|
|
551
|
+
questionDrafts[questionId] = body.filename ?? file.name;
|
|
552
|
+
status.textContent = `Saved context/${questionDrafts[questionId]}`;
|
|
553
|
+
if (body.health || body.packId) state = { ...state, ...body };
|
|
554
|
+
applyActivities(body);
|
|
555
|
+
paintQuestionContinue();
|
|
556
|
+
} catch (err) {
|
|
557
|
+
status.textContent = err instanceof Error ? err.message : "Could not save the upload.";
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
function mimeFromName(name) {
|
|
562
|
+
if (/\.png$/i.test(name)) return "image/png";
|
|
563
|
+
if (/\.jpe?g$/i.test(name)) return "image/jpeg";
|
|
564
|
+
if (/\.webp$/i.test(name)) return "image/webp";
|
|
565
|
+
return "";
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
function fileToBase64(file) {
|
|
569
|
+
return new Promise((resolve, reject) => {
|
|
570
|
+
const reader = new FileReader();
|
|
571
|
+
reader.onload = () => {
|
|
572
|
+
const result = String(reader.result ?? "");
|
|
573
|
+
const comma = result.indexOf(",");
|
|
574
|
+
resolve(comma >= 0 ? result.slice(comma + 1) : result);
|
|
575
|
+
};
|
|
576
|
+
reader.onerror = () => reject(new Error("Could not read the file."));
|
|
577
|
+
reader.readAsDataURL(file);
|
|
578
|
+
});
|
|
579
|
+
}
|
|
580
|
+
|
|
511
581
|
function paintQuestionContinue() {
|
|
512
582
|
const round = openQuestions();
|
|
513
|
-
const askingDefine = round?.channel === "improve";
|
|
583
|
+
const askingDefine = round?.channel === "improve" || round?.channel === "author";
|
|
514
584
|
const ready = questionsContinueEnabled(round);
|
|
515
585
|
paintActionButton(els.questionContinue, {
|
|
516
586
|
id: "answer-questions",
|
|
517
587
|
label: "Continue",
|
|
518
|
-
hint: "Answer each required question, then Continue.",
|
|
588
|
+
hint: "Answer each required question, then Continue. You may skip a question or all of them.",
|
|
519
589
|
enabled: Boolean(askingDefine && ready && !actionBusy),
|
|
520
590
|
primary: true,
|
|
521
591
|
hidden: !askingDefine,
|
|
522
592
|
});
|
|
593
|
+
paintActionButton(els.questionSkipAll, {
|
|
594
|
+
id: "skip-all-questions",
|
|
595
|
+
label: "Skip all",
|
|
596
|
+
hint: "Skip this round. The agent will not assume answers.",
|
|
597
|
+
enabled: Boolean(askingDefine && !actionBusy),
|
|
598
|
+
primary: false,
|
|
599
|
+
hidden: !askingDefine,
|
|
600
|
+
});
|
|
523
601
|
const action = state?.health?.nextAction;
|
|
524
602
|
if (action?.id === "answer-questions") {
|
|
525
603
|
paintActionButton(els.next, {
|
|
@@ -531,6 +609,16 @@ function paintQuestionContinue() {
|
|
|
531
609
|
hidden: false,
|
|
532
610
|
});
|
|
533
611
|
}
|
|
612
|
+
if (action?.id === "author-start") {
|
|
613
|
+
paintActionButton(els.next, {
|
|
614
|
+
id: action.id,
|
|
615
|
+
label: action.label,
|
|
616
|
+
hint: action.hint || "",
|
|
617
|
+
enabled: Boolean(action.enabled && String(els.authorDescription?.value ?? "").trim() && !actionBusy),
|
|
618
|
+
primary: true,
|
|
619
|
+
hidden: false,
|
|
620
|
+
});
|
|
621
|
+
}
|
|
534
622
|
}
|
|
535
623
|
|
|
536
624
|
function fillQuestionPanel(panel, round) {
|
|
@@ -560,14 +648,26 @@ function renderQuestionCard(question) {
|
|
|
560
648
|
const article = document.createElement("article");
|
|
561
649
|
article.className = "question-card";
|
|
562
650
|
article.dataset.questionId = question.id;
|
|
651
|
+
const heading = document.createElement("div");
|
|
652
|
+
heading.className = "question-card-row";
|
|
563
653
|
const prompt = document.createElement("p");
|
|
564
654
|
prompt.className = "question-card-prompt";
|
|
565
655
|
prompt.textContent = question.prompt;
|
|
566
|
-
|
|
656
|
+
heading.append(prompt);
|
|
657
|
+
const skip = document.createElement("button");
|
|
658
|
+
skip.type = "button";
|
|
659
|
+
skip.className = "btn-secondary";
|
|
660
|
+
skip.textContent = questionDrafts[question.id] === SKIP_ANSWER ? "Skipped" : "Skip";
|
|
661
|
+
skip.addEventListener("click", () => {
|
|
662
|
+
questionDrafts[question.id] = questionDrafts[question.id] === SKIP_ANSWER ? "" : SKIP_ANSWER;
|
|
663
|
+
render();
|
|
664
|
+
});
|
|
665
|
+
heading.append(skip);
|
|
666
|
+
article.append(heading);
|
|
567
667
|
if (question.kind === "choice") {
|
|
568
668
|
const choices = document.createElement("div");
|
|
569
669
|
choices.className = "question-choices";
|
|
570
|
-
|
|
670
|
+
(question.options ?? []).forEach((option, index) => {
|
|
571
671
|
const btn = document.createElement("button");
|
|
572
672
|
btn.type = "button";
|
|
573
673
|
btn.className = "stack-choice";
|
|
@@ -576,18 +676,54 @@ function renderQuestionCard(question) {
|
|
|
576
676
|
const label = document.createElement("strong");
|
|
577
677
|
label.textContent = option.label;
|
|
578
678
|
btn.append(label);
|
|
679
|
+
if (index === 0) {
|
|
680
|
+
const suggested = document.createElement("span");
|
|
681
|
+
suggested.className = "question-suggested";
|
|
682
|
+
suggested.textContent = "Suggested";
|
|
683
|
+
btn.append(suggested);
|
|
684
|
+
}
|
|
579
685
|
btn.addEventListener("click", () => {
|
|
580
686
|
questionDrafts[question.id] = option.id;
|
|
581
687
|
render();
|
|
582
688
|
});
|
|
583
689
|
choices.append(btn);
|
|
584
|
-
}
|
|
690
|
+
});
|
|
585
691
|
article.append(choices);
|
|
692
|
+
if (question.allowCustom) {
|
|
693
|
+
const input = document.createElement("input");
|
|
694
|
+
input.className = "input";
|
|
695
|
+
input.type = "text";
|
|
696
|
+
const current = questionDrafts[question.id] ?? "";
|
|
697
|
+
const optionIds = new Set((question.options ?? []).map((option) => option.id));
|
|
698
|
+
input.value = optionIds.has(current) || current === SKIP_ANSWER ? "" : current;
|
|
699
|
+
input.placeholder = "Something else";
|
|
700
|
+
input.addEventListener("input", () => {
|
|
701
|
+
questionDrafts[question.id] = input.value;
|
|
702
|
+
paintQuestionContinue();
|
|
703
|
+
});
|
|
704
|
+
article.append(input);
|
|
705
|
+
}
|
|
706
|
+
} else if (question.kind === "artifact") {
|
|
707
|
+
const file = document.createElement("input");
|
|
708
|
+
file.className = "input";
|
|
709
|
+
file.type = "file";
|
|
710
|
+
file.accept = (question.accept ?? ["image/png", "image/jpeg", "image/webp"]).join(",");
|
|
711
|
+
const status = document.createElement("p");
|
|
712
|
+
status.className = "question-card-meta";
|
|
713
|
+
const current = questionDrafts[question.id] ?? "";
|
|
714
|
+
status.textContent =
|
|
715
|
+
current && current !== SKIP_ANSWER ? `Saved context/${current}` : "Optional. PNG, JPG, or WebP.";
|
|
716
|
+
file.addEventListener("change", () => {
|
|
717
|
+
const picked = file.files?.[0];
|
|
718
|
+
if (!picked) return;
|
|
719
|
+
void uploadAuthorArtifact(question.id, picked, status);
|
|
720
|
+
});
|
|
721
|
+
article.append(file, status);
|
|
586
722
|
} else {
|
|
587
723
|
const input = document.createElement("input");
|
|
588
724
|
input.className = "input";
|
|
589
725
|
input.type = "text";
|
|
590
|
-
input.value = questionDrafts[question.id] ?? "";
|
|
726
|
+
input.value = questionDrafts[question.id] === SKIP_ANSWER ? "" : (questionDrafts[question.id] ?? "");
|
|
591
727
|
input.placeholder = question.required ? "Required" : "Optional";
|
|
592
728
|
input.addEventListener("input", () => {
|
|
593
729
|
questionDrafts[question.id] = input.value;
|
|
@@ -606,7 +742,7 @@ function renderQuestionCard(question) {
|
|
|
606
742
|
|
|
607
743
|
function renderQuestions() {
|
|
608
744
|
const round = openQuestions();
|
|
609
|
-
const askingDefine = round?.channel === "improve";
|
|
745
|
+
const askingDefine = round?.channel === "improve" || round?.channel === "author";
|
|
610
746
|
if (els.questionActions) els.questionActions.classList.toggle("hidden", !askingDefine);
|
|
611
747
|
if (els.defineQuestions) {
|
|
612
748
|
els.defineQuestions.classList.toggle("hidden", !askingDefine);
|
|
@@ -617,7 +753,7 @@ function renderQuestions() {
|
|
|
617
753
|
delete els.defineQuestions.dataset.sig;
|
|
618
754
|
}
|
|
619
755
|
}
|
|
620
|
-
if (askingDefine) {
|
|
756
|
+
if (askingDefine && round?.channel === "improve") {
|
|
621
757
|
els.workspace?.classList.add("is-review");
|
|
622
758
|
markdownEditor.setHidden(true);
|
|
623
759
|
if (els.save) els.save.classList.add("hidden");
|
|
@@ -626,15 +762,23 @@ function renderQuestions() {
|
|
|
626
762
|
paintActionButton(els.questionContinue, {
|
|
627
763
|
id: "answer-questions",
|
|
628
764
|
label: "Continue",
|
|
629
|
-
hint: "Answer each required question, then Continue.",
|
|
765
|
+
hint: "Answer each required question, then Continue. You may skip a question or all of them.",
|
|
630
766
|
enabled: Boolean(askingDefine && questionsContinueEnabled(round) && !actionBusy),
|
|
631
767
|
primary: true,
|
|
632
768
|
hidden: !askingDefine,
|
|
633
769
|
});
|
|
770
|
+
paintActionButton(els.questionSkipAll, {
|
|
771
|
+
id: "skip-all-questions",
|
|
772
|
+
label: "Skip all",
|
|
773
|
+
hint: "Skip this round. The agent will not assume answers.",
|
|
774
|
+
enabled: Boolean(askingDefine && !actionBusy),
|
|
775
|
+
primary: false,
|
|
776
|
+
hidden: !askingDefine,
|
|
777
|
+
});
|
|
634
778
|
paintActionButton(els.questionStop, {
|
|
635
779
|
id: "discard-questions",
|
|
636
780
|
label: "Stop",
|
|
637
|
-
hint: "
|
|
781
|
+
hint: "Stop and discard unanswered questions.",
|
|
638
782
|
enabled: Boolean(askingDefine && !actionBusy),
|
|
639
783
|
primary: false,
|
|
640
784
|
hidden: !askingDefine,
|
|
@@ -648,6 +792,56 @@ function renderQuestions() {
|
|
|
648
792
|
}
|
|
649
793
|
}
|
|
650
794
|
|
|
795
|
+
function offeringAuthor() {
|
|
796
|
+
return state?.health?.nextAction?.id === "author-start";
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
function authoringActive() {
|
|
800
|
+
const status = state?.authorRun?.status;
|
|
801
|
+
return status === "running" || status === "waiting_questions" || state?.busy === "author";
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
function renderAuthorDescribe() {
|
|
805
|
+
const offer = offeringAuthor();
|
|
806
|
+
if (els.authorDescribe) {
|
|
807
|
+
els.authorDescribe.classList.toggle("hidden", !offer);
|
|
808
|
+
els.authorDescribe.hidden = !offer;
|
|
809
|
+
}
|
|
810
|
+
if (els.authorStart) {
|
|
811
|
+
paintActionButton(els.authorStart, {
|
|
812
|
+
id: "author-start",
|
|
813
|
+
label: "Start",
|
|
814
|
+
hint: "The agent will draft the requirement from this description.",
|
|
815
|
+
enabled: Boolean(offer && String(els.authorDescription?.value ?? "").trim() && !actionBusy),
|
|
816
|
+
primary: true,
|
|
817
|
+
hidden: !offer,
|
|
818
|
+
});
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
function renderDefineLayout() {
|
|
823
|
+
const askingAuthor = openQuestions()?.channel === "author";
|
|
824
|
+
const hasActivity = authorLines.length > 0;
|
|
825
|
+
const showTabs = Boolean(askingAuthor && hasActivity);
|
|
826
|
+
if (!askingAuthor) defineTab = "questions";
|
|
827
|
+
else if (!hasActivity) defineTab = "questions";
|
|
828
|
+
els.defineTabs?.classList.toggle("hidden", !showTabs);
|
|
829
|
+
if (els.defineTabs) els.defineTabs.hidden = !showTabs;
|
|
830
|
+
if (askingAuthor && els.defineQuestions) {
|
|
831
|
+
const showQuestions = !showTabs || defineTab === "questions";
|
|
832
|
+
els.defineQuestions.classList.toggle("hidden", !showQuestions);
|
|
833
|
+
els.defineQuestions.hidden = !showQuestions;
|
|
834
|
+
}
|
|
835
|
+
const activityVisible = Boolean(authoringActive() && (!askingAuthor || (showTabs && defineTab === "activity")));
|
|
836
|
+
els.defineActivity?.classList.toggle("hidden", !activityVisible);
|
|
837
|
+
if (els.defineActivity) els.defineActivity.hidden = !activityVisible;
|
|
838
|
+
els.defineTabQuestions?.classList.toggle("is-active", defineTab !== "activity");
|
|
839
|
+
els.defineTabActivity?.classList.toggle("is-active", defineTab === "activity");
|
|
840
|
+
els.defineTabQuestions?.setAttribute("aria-selected", defineTab !== "activity" ? "true" : "false");
|
|
841
|
+
els.defineTabActivity?.setAttribute("aria-selected", defineTab === "activity" ? "true" : "false");
|
|
842
|
+
if (askingAuthor && els.workspaceLabel) els.workspaceLabel.textContent = "Agent questions";
|
|
843
|
+
}
|
|
844
|
+
|
|
651
845
|
function renderImplementLayout() {
|
|
652
846
|
const asking = openQuestions()?.channel === "implement";
|
|
653
847
|
const hasActivity = implementLines.length > 0;
|
|
@@ -1438,9 +1632,11 @@ function fillActivityLog(log, lines, emptyMessage, which) {
|
|
|
1438
1632
|
if (!log) return;
|
|
1439
1633
|
const rows = lines.length ? lines : [{ level: "info", message: emptyMessage }];
|
|
1440
1634
|
const key = rows.map((line) => `${line.level}\0${line.message}`).join("\n");
|
|
1441
|
-
const previous =
|
|
1635
|
+
const previous =
|
|
1636
|
+
which === "prove" ? lastProveKey : which === "author" ? lastAuthorKey : lastImplementKey;
|
|
1442
1637
|
if (key === previous && log.childElementCount === rows.length) return;
|
|
1443
1638
|
if (which === "prove") lastProveKey = key;
|
|
1639
|
+
else if (which === "author") lastAuthorKey = key;
|
|
1444
1640
|
else lastImplementKey = key;
|
|
1445
1641
|
const pinned = log.scrollHeight - log.scrollTop - log.clientHeight < 16;
|
|
1446
1642
|
const savedTop = log.scrollTop;
|
|
@@ -1463,10 +1659,12 @@ function renderActivity() {
|
|
|
1463
1659
|
"implement",
|
|
1464
1660
|
);
|
|
1465
1661
|
fillActivityLog(els.qaActivity, proveLines, "No activity yet. Prove writes progress here.", "prove");
|
|
1662
|
+
fillActivityLog(els.defineActivity, authorLines, "No activity yet. Authoring writes progress here.", "author");
|
|
1466
1663
|
}
|
|
1467
1664
|
|
|
1468
1665
|
function appendActivity(line, channel) {
|
|
1469
1666
|
if (channel === "prove") proveLines = [...proveLines, line].slice(-80);
|
|
1667
|
+
else if (channel === "author") authorLines = [...authorLines, line].slice(-80);
|
|
1470
1668
|
else implementLines = [...implementLines, line].slice(-80);
|
|
1471
1669
|
if (line.message) {
|
|
1472
1670
|
actionNotice = line.message;
|
|
@@ -1529,6 +1727,12 @@ onEnabledClick(els.questionContinue, () => {
|
|
|
1529
1727
|
onEnabledClick(els.questionStop, () => {
|
|
1530
1728
|
void runStageAction("discard-questions");
|
|
1531
1729
|
});
|
|
1730
|
+
onEnabledClick(els.questionSkipAll, () => {
|
|
1731
|
+
void runStageAction("skip-all-questions");
|
|
1732
|
+
});
|
|
1733
|
+
onEnabledClick(els.authorStart, () => {
|
|
1734
|
+
void runStageAction("author-start");
|
|
1735
|
+
});
|
|
1532
1736
|
onEnabledClick(els.next, () => {
|
|
1533
1737
|
void runStageAction(state.health?.nextAction?.id);
|
|
1534
1738
|
});
|
|
@@ -1610,8 +1814,10 @@ async function discardOpenQuestions() {
|
|
|
1610
1814
|
|
|
1611
1815
|
function viewForAction(id) {
|
|
1612
1816
|
if (id === "check-jev") return "judgment";
|
|
1613
|
-
if (id === "improve" || id === "review-improve" || id === "fix-spec" || id === "create"
|
|
1614
|
-
|
|
1817
|
+
if (id === "improve" || id === "review-improve" || id === "fix-spec" || id === "create" || id === "author-start" || id === "stop-author") {
|
|
1818
|
+
return "define";
|
|
1819
|
+
}
|
|
1820
|
+
if (id === "answer-questions" || id === "discard-questions" || id === "skip-all-questions") {
|
|
1615
1821
|
return openQuestions()?.channel === "implement" ? "implement" : "define";
|
|
1616
1822
|
}
|
|
1617
1823
|
if (id === "implement" || id === "stop-implement" || id === "ignore-build" || id === "fix-from-proof") {
|
|
@@ -1633,9 +1839,61 @@ async function runStageAction(id) {
|
|
|
1633
1839
|
}
|
|
1634
1840
|
const res = await fetch("/api/create-in-place", { method: "POST" });
|
|
1635
1841
|
takeState(await res.json());
|
|
1636
|
-
|
|
1842
|
+
currentView = "define";
|
|
1843
|
+
render();
|
|
1844
|
+
return;
|
|
1845
|
+
}
|
|
1846
|
+
if (id === "author-start") {
|
|
1847
|
+
const description = String(els.authorDescription?.value ?? "").trim();
|
|
1848
|
+
if (!description) return;
|
|
1849
|
+
authorLines = [{ level: "info", message: "Authoring started." }];
|
|
1850
|
+
actionNotice = "Authoring started.";
|
|
1851
|
+
setActionHint(actionNotice);
|
|
1852
|
+
renderActivity();
|
|
1853
|
+
await runBackgroundAction(
|
|
1854
|
+
"Authoring…",
|
|
1855
|
+
"/api/author/start",
|
|
1856
|
+
{ description, adapter: recordedAdapter() },
|
|
1857
|
+
"author",
|
|
1858
|
+
);
|
|
1859
|
+
return;
|
|
1860
|
+
}
|
|
1861
|
+
if (id === "stop-author") {
|
|
1862
|
+
if (openQuestions()?.channel === "author") {
|
|
1863
|
+
const confirmed = await askDiscardQuestions();
|
|
1864
|
+
if (!confirmed) return;
|
|
1865
|
+
}
|
|
1866
|
+
actionNotice = "Stopping…";
|
|
1867
|
+
setActionHint(actionNotice);
|
|
1868
|
+
try {
|
|
1869
|
+
const res = await fetch("/api/author/stop", {
|
|
1870
|
+
method: "POST",
|
|
1871
|
+
headers: { "Content-Type": "application/json" },
|
|
1872
|
+
body: "{}",
|
|
1873
|
+
});
|
|
1874
|
+
const payload = await res.json();
|
|
1875
|
+
if (payload.health || payload.packId) state = { ...state, ...payload };
|
|
1876
|
+
applyActivities(payload);
|
|
1877
|
+
actionNotice = payload.error ?? payload.message ?? "Owner stopped authoring.";
|
|
1878
|
+
} catch (err) {
|
|
1879
|
+
actionNotice = err instanceof Error ? err.message : "Stop failed.";
|
|
1880
|
+
}
|
|
1881
|
+
setActionHint(actionNotice);
|
|
1637
1882
|
render();
|
|
1638
|
-
|
|
1883
|
+
return;
|
|
1884
|
+
}
|
|
1885
|
+
if (id === "skip-all-questions") {
|
|
1886
|
+
const round = openQuestions();
|
|
1887
|
+
if (!round) return;
|
|
1888
|
+
const kind = round.channel === "author" ? "author" : round.channel === "improve" ? "improve" : "implement";
|
|
1889
|
+
actionNotice = "Skipping this round…";
|
|
1890
|
+
setActionHint(actionNotice);
|
|
1891
|
+
await runBackgroundAction(
|
|
1892
|
+
"Continuing…",
|
|
1893
|
+
"/api/agent-answers",
|
|
1894
|
+
{ answers: collectedAnswers(round), skipAll: true, adapter: recordedAdapter() },
|
|
1895
|
+
kind,
|
|
1896
|
+
);
|
|
1639
1897
|
return;
|
|
1640
1898
|
}
|
|
1641
1899
|
if (id === "fix-spec") {
|
|
@@ -1658,7 +1916,7 @@ async function runStageAction(id) {
|
|
|
1658
1916
|
if (id === "answer-questions") {
|
|
1659
1917
|
const round = openQuestions();
|
|
1660
1918
|
if (!round || !questionsContinueEnabled(round)) return;
|
|
1661
|
-
const kind = round.channel === "improve" ? "improve" : "implement";
|
|
1919
|
+
const kind = round.channel === "author" ? "author" : round.channel === "improve" ? "improve" : "implement";
|
|
1662
1920
|
actionNotice = "Continuing with owner answers…";
|
|
1663
1921
|
setActionHint(actionNotice);
|
|
1664
1922
|
await runBackgroundAction(
|
|
@@ -1804,7 +2062,7 @@ async function waitWhileBusy(kind) {
|
|
|
1804
2062
|
if (data.improveReview?.files?.length || data.agentQuestions?.status === "open") {
|
|
1805
2063
|
actionNotice = "";
|
|
1806
2064
|
} else {
|
|
1807
|
-
const last = lastBusyMessage(kind
|
|
2065
|
+
const last = lastBusyMessage(kind);
|
|
1808
2066
|
if (last && !data.improveReview) {
|
|
1809
2067
|
actionNotice = last;
|
|
1810
2068
|
setActionHint(last);
|
|
@@ -1827,7 +2085,7 @@ async function refreshActivity() {
|
|
|
1827
2085
|
applyActivities(data);
|
|
1828
2086
|
if (data.improveReview?.files?.length || data.agentQuestions?.status === "open") actionNotice = "";
|
|
1829
2087
|
else {
|
|
1830
|
-
const last = lastBusyMessage(data.busy === "prove" ? "prove" : "implement");
|
|
2088
|
+
const last = lastBusyMessage(data.busy === "prove" ? "prove" : data.busy === "author" ? "author" : "implement");
|
|
1831
2089
|
if (last) {
|
|
1832
2090
|
actionNotice = last;
|
|
1833
2091
|
setActionHint(last);
|
|
@@ -1864,7 +2122,8 @@ async function runBackgroundAction(busyLabel, url, body, kind) {
|
|
|
1864
2122
|
applyActivities(payload);
|
|
1865
2123
|
if (
|
|
1866
2124
|
(Array.isArray(payload.implementActivity) && payload.implementActivity.length) ||
|
|
1867
|
-
(Array.isArray(payload.proveActivity) && payload.proveActivity.length)
|
|
2125
|
+
(Array.isArray(payload.proveActivity) && payload.proveActivity.length) ||
|
|
2126
|
+
(Array.isArray(payload.authorActivity) && payload.authorActivity.length)
|
|
1868
2127
|
) {
|
|
1869
2128
|
renderActivity();
|
|
1870
2129
|
}
|
|
@@ -2023,6 +2282,17 @@ els.implementTabActivity?.addEventListener("click", () => {
|
|
|
2023
2282
|
implementTab = "activity";
|
|
2024
2283
|
renderImplementLayout();
|
|
2025
2284
|
});
|
|
2285
|
+
els.defineTabQuestions?.addEventListener("click", () => {
|
|
2286
|
+
defineTab = "questions";
|
|
2287
|
+
renderDefineLayout();
|
|
2288
|
+
});
|
|
2289
|
+
els.defineTabActivity?.addEventListener("click", () => {
|
|
2290
|
+
defineTab = "activity";
|
|
2291
|
+
renderDefineLayout();
|
|
2292
|
+
});
|
|
2293
|
+
els.authorDescription?.addEventListener("input", () => {
|
|
2294
|
+
paintQuestionContinue();
|
|
2295
|
+
});
|
|
2026
2296
|
els.discardCancel?.addEventListener("click", () => closeDiscardDialog("cancel"));
|
|
2027
2297
|
els.discardConfirm?.addEventListener("click", () => closeDiscardDialog("confirm"));
|
|
2028
2298
|
els.discardDialog?.addEventListener("cancel", () => closeDiscardDialog("cancel"));
|
|
@@ -2064,8 +2334,8 @@ els.createNew.addEventListener("click", async () => {
|
|
|
2064
2334
|
currentView = "define";
|
|
2065
2335
|
actionNotice = "";
|
|
2066
2336
|
if (els.newId) els.newId.value = "";
|
|
2337
|
+
if (els.authorDescription) els.authorDescription.value = "";
|
|
2067
2338
|
render();
|
|
2068
|
-
jumpToSection("Business Rules");
|
|
2069
2339
|
});
|
|
2070
2340
|
|
|
2071
2341
|
let pollTimer = null;
|
package/cockpit/index.html
CHANGED
|
@@ -112,13 +112,30 @@
|
|
|
112
112
|
<button type="button" class="btn-primary cta" id="review-accept" disabled>Accept</button>
|
|
113
113
|
</div>
|
|
114
114
|
<div class="review-actions hidden" id="question-actions">
|
|
115
|
+
<button type="button" class="btn-secondary cta" id="question-skip-all">Skip all</button>
|
|
115
116
|
<button type="button" class="btn-secondary cta" id="question-stop">Stop</button>
|
|
116
117
|
<button type="button" class="btn-primary cta" id="question-continue" disabled>Continue</button>
|
|
117
118
|
</div>
|
|
118
119
|
</div>
|
|
120
|
+
<div class="author-describe hidden" id="author-describe" hidden>
|
|
121
|
+
<label class="field">
|
|
122
|
+
What should this requirement cover?
|
|
123
|
+
<textarea class="input" id="author-description" rows="5" placeholder="A short description is enough. The agent will ask questions to fill the rest."></textarea>
|
|
124
|
+
</label>
|
|
125
|
+
<button type="button" class="btn-primary cta" id="author-start">Start</button>
|
|
126
|
+
</div>
|
|
127
|
+
<div class="qa-tab-bar hidden" id="define-tabs" role="tablist" hidden>
|
|
128
|
+
<button type="button" class="qa-tab is-active" role="tab" id="define-tab-questions" aria-selected="true" aria-controls="define-questions">
|
|
129
|
+
Questions
|
|
130
|
+
</button>
|
|
131
|
+
<button type="button" class="qa-tab" role="tab" id="define-tab-activity" aria-selected="false" aria-controls="define-activity">
|
|
132
|
+
Activity
|
|
133
|
+
</button>
|
|
134
|
+
</div>
|
|
135
|
+
<div class="question-panel hidden" id="define-questions" hidden></div>
|
|
136
|
+
<ul class="activity-log list-rows hidden" id="define-activity" hidden></ul>
|
|
119
137
|
<div id="editor" class="markdown-editor" aria-label="requirement.md"></div>
|
|
120
138
|
<div class="review-diff hidden" id="review-diff" hidden></div>
|
|
121
|
-
<div class="question-panel hidden" id="define-questions" hidden></div>
|
|
122
139
|
<p class="save-state" id="save-state"></p>
|
|
123
140
|
</section>
|
|
124
141
|
|