bareloop 0.55.0 → 0.57.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.
Files changed (92) hide show
  1. package/CHANGELOG.md +82 -0
  2. package/README.md +3 -3
  3. package/bareloop.context.md +69 -209
  4. package/package.json +2 -2
  5. package/src/authorflow.js +164 -340
  6. package/src/authoring.js +7 -127
  7. package/src/authorjob.js +139 -472
  8. package/src/authorreadout.js +24 -368
  9. package/src/authorrun.js +21 -215
  10. package/src/behaviour.js +14 -0
  11. package/src/blockasks.js +43 -0
  12. package/src/bundlerun.js +4 -1
  13. package/src/checkblock.js +798 -0
  14. package/src/checklist.js +128 -0
  15. package/src/checkpick.js +39 -312
  16. package/src/checkwords.js +3 -1
  17. package/src/cli.js +3 -3
  18. package/src/declaredclose.js +38 -108
  19. package/src/destpoint.js +4 -2
  20. package/src/draftspend.js +46 -0
  21. package/src/facts.js +8 -1
  22. package/src/index.js +3 -43
  23. package/src/interviewrun.js +13 -8
  24. package/src/job.js +20 -1
  25. package/src/jobblock.js +11 -46
  26. package/src/judged.js +13 -1229
  27. package/src/kinds.js +5 -347
  28. package/src/noteask.js +124 -0
  29. package/src/pagedry.js +27 -5
  30. package/src/pagemap.js +15 -3
  31. package/src/pagerules.js +18 -3
  32. package/src/panel/authorroutes.js +24 -6
  33. package/src/panel/authorsession.js +222 -177
  34. package/src/panel/importrun.js +0 -1
  35. package/src/panel/index.html +198 -26
  36. package/src/panel/jobplan.js +87 -33
  37. package/src/panel/server.js +74 -68
  38. package/src/panel/status.js +3 -0
  39. package/src/pickrecord.js +34 -55
  40. package/src/placerule.js +355 -0
  41. package/src/planrun.js +2 -48
  42. package/src/promptregisters.js +13 -17
  43. package/src/providerrows.js +0 -36
  44. package/src/providers.js +4 -25
  45. package/src/questionbox.js +104 -0
  46. package/src/rowedit.js +115 -0
  47. package/src/rubricstep.js +234 -127
  48. package/src/run.js +11 -16
  49. package/src/userrun.js +60 -112
  50. package/types/authorflow.d.ts +41 -197
  51. package/types/authoring.d.ts +1 -14
  52. package/types/authorjob.d.ts +35 -59
  53. package/types/authorreadout.d.ts +10 -88
  54. package/types/behaviour.d.ts +12 -0
  55. package/types/blockasks.d.ts +36 -0
  56. package/types/checkblock.d.ts +376 -0
  57. package/types/checklist.d.ts +134 -0
  58. package/types/checkpick.d.ts +8 -140
  59. package/types/cli.d.ts +1 -3
  60. package/types/declaredclose.d.ts +7 -33
  61. package/types/destpoint.d.ts +2 -0
  62. package/types/draftspend.d.ts +21 -0
  63. package/types/index.d.ts +2 -4
  64. package/types/job.d.ts +8 -0
  65. package/types/jobblock.d.ts +8 -38
  66. package/types/judged.d.ts +7 -357
  67. package/types/kinds.d.ts +3 -104
  68. package/types/noteask.d.ts +76 -0
  69. package/types/pagedry.d.ts +13 -0
  70. package/types/pagemap.d.ts +4 -0
  71. package/types/pagerules.d.ts +7 -0
  72. package/types/panel/authorsession.d.ts +47 -5
  73. package/types/panel/jobgrid.d.ts +8 -8
  74. package/types/panel/jobplan.d.ts +48 -10
  75. package/types/panel/server.d.ts +27 -18
  76. package/types/panel/status.d.ts +5 -0
  77. package/types/pickrecord.d.ts +20 -13
  78. package/types/placerule.d.ts +194 -0
  79. package/types/planrun.d.ts +1 -22
  80. package/types/providerrows.d.ts +0 -31
  81. package/types/providers.d.ts +3 -19
  82. package/types/questionbox.d.ts +87 -0
  83. package/types/rowedit.d.ts +32 -0
  84. package/types/rubricstep.d.ts +100 -48
  85. package/types/run.d.ts +9 -19
  86. package/types/userrun.d.ts +0 -1
  87. package/src/calibrate.js +0 -702
  88. package/src/cardauthor.js +0 -502
  89. package/src/fitcheck.js +0 -166
  90. package/types/calibrate.d.ts +0 -201
  91. package/types/cardauthor.d.ts +0 -358
  92. package/types/fitcheck.d.ts +0 -113
@@ -160,7 +160,6 @@ export function bridgeRunDetail(g, facts) {
160
160
  checkTypeTitle: facts.checkTypeTitle,
161
161
  model: facts.model,
162
162
  provider: null,
163
- judgeModel: null,
164
163
  budgetUsd: facts.budgetUsd,
165
164
  glyph: '✓',
166
165
  status: statusFor({ outcome: 'green' }),
@@ -648,6 +648,17 @@
648
648
  .msg.system{color:var(--text-faint);border-left:3px dotted var(--text-faint);font-size:12px;}
649
649
  .msg .who{font-size:11px;color:var(--text-faint);margin-bottom:3px;text-transform:none;font-weight:400;}
650
650
  .chat-input-row{margin-top:10px;border-top:1px dotted var(--border-strong);padding-top:10px;}
651
+ /* hamr 2026-11-12 (as fwdloop M10 am29): a question the drafting raised gets its own box; it takes the chat input's place while it is open */
652
+ .chat-question{border:1px solid var(--border);border-left:3px solid var(--amber);background:var(--panel2);padding:8px 10px;margin-top:10px;max-width:100%;box-sizing:border-box;}
653
+ .chat-question .q-head{font-size:11px;color:var(--text-faint);}
654
+ .chat-question .q-line{font-size:12px;color:var(--text-faint);margin-top:4px;overflow-wrap:anywhere;}
655
+ .chat-question .q-text{font-size:13px;margin-top:4px;overflow-wrap:anywhere;white-space:pre-wrap;}
656
+ .chat-question textarea{display:block;width:100%;max-width:100%;box-sizing:border-box;margin-top:8px;min-height:3.4em;font:inherit;padding:6px 8px;border:1px solid var(--border-strong);border-radius:0;background:var(--bg);color:var(--text);resize:vertical;}
657
+ .chat-question .q-choices{display:flex;flex-wrap:wrap;gap:8px;margin-top:8px;}
658
+ .chat-question .q-choices .btn{flex:1 1 auto;min-width:0;white-space:normal;overflow-wrap:anywhere;height:auto;min-height:44px;}
659
+ .chat-question .q-or{display:block;font-size:12px;color:var(--text-faint);margin-top:8px;text-transform:none;letter-spacing:normal;font-weight:normal;}
660
+ .chat-question .q-or + textarea{margin-top:4px;}
661
+ .chat-question .q-err{color:var(--red);}
651
662
  .chat-input-row input{width:100%;box-sizing:border-box;}
652
663
  /* the ask box wraps long text (textarea, hamr 2026-10-05): grows a few rows (fitBox), then scrolls inside; Enter sends, Shift+Enter is a newline */
653
664
  textarea[data-testid="chat-msg"]{width:100%;box-sizing:border-box;font:inherit;color:var(--text);resize:vertical;overflow-y:auto;max-height:200px;}
@@ -677,9 +688,13 @@
677
688
  .jp .sub{color:var(--text-dim);padding-left:30px;}
678
689
  .jp .fold{padding-left:30px;color:var(--text);}
679
690
  /* who added a check: the drafter's [agent] or the person's own [you picked] (fwdloop's `[added]` marker, in the dim of a ~ row) */
680
- .jp .by,.draft-checks-row .by{color:var(--text-dim);white-space:nowrap;}
691
+ .jp .by,.draft-checks-row .by,.job-card .by{color:var(--text-dim);white-space:nowrap;}
692
+ /* the confirm card's Drop / Add: wraps with its row, a comfortable touch target, no horizontal scroll at phone width */
693
+ .jp .jp-btn{margin:2px 0 2px 8px;padding:4px 12px;min-height:32px;font-size:inherit;}
694
+ .jp .fold{overflow-wrap:anywhere;}
695
+ .jp-sug .lbl{display:block;margin-top:6px;font-weight:700;}
681
696
  .jp details.fold{padding-left:0;margin:6px 0;}
682
- .jp details>summary{cursor:pointer;list-style:none;}
697
+ .jp details>summary{cursor:pointer;list-style:none;font-weight:700;}
683
698
  .jp details>summary::-webkit-details-marker{display:none;}
684
699
  .jp details>summary::before{content:"\203A";color:var(--plan);font-weight:700;margin-right:6px;}
685
700
  .jp details[open]>summary::before{content:"\2304";}
@@ -1027,6 +1042,21 @@
1027
1042
  before a person reads it. -->
1028
1043
  <div class="hint" id="chat-action-error" data-testid="chat-action-error"></div>
1029
1044
 
1045
+ <!-- hamr 2026-11-12 (as fwdloop M10 am29): a question the drafting raised, one at a time. No Skip. Static markup: the poll only rewrites the texts when the question changes, never the typed answer -->
1046
+ <div class="chat-question" id="chat-question" data-testid="chat-question" hidden>
1047
+ <div class="q-head" id="chat-q-head" data-testid="chat-q-head"></div>
1048
+ <div class="q-line" id="chat-q-line" data-testid="chat-q-line"></div>
1049
+ <div class="q-text" id="chat-q-text" data-testid="chat-q-text"></div>
1050
+ <div class="q-choices" id="chat-q-choices" data-testid="chat-q-choices" hidden>
1051
+ <button class="btn small" type="button" id="chat-q-c1" hidden></button>
1052
+ <button class="btn small" type="button" id="chat-q-c2" hidden></button>
1053
+ </div>
1054
+ <label class="q-or" id="chat-q-or" data-testid="chat-q-or" for="chat-q-answer">Type your answer:</label>
1055
+ <textarea id="chat-q-answer" data-testid="chat-q-answer" rows="2" autocomplete="off" spellcheck="false" aria-label="Your answer" placeholder="Your answer, on one line"></textarea>
1056
+ <div class="hint q-err" id="chat-q-error" data-testid="chat-q-error" role="alert"></div>
1057
+ <button class="btn primary wide" type="button" id="chat-q-send" data-testid="chat-q-send">Send</button>
1058
+ </div>
1059
+
1030
1060
  <div class="chat-input-row">
1031
1061
  <label for="chat-msg" style="display:none">Message</label>
1032
1062
  <textarea id="chat-msg" rows="2" placeholder="Answer here when the draft asks you a question…" data-testid="chat-msg"></textarea>
@@ -2994,7 +3024,6 @@
2994
3024
  '<div class="summary-headline"><span class="dot ' + glyphClass(detail.glyph) + '"></span>' + (detail.status && detail.status.word ? '<b class="st-word" data-testid="summary-status">' + escapeXml(detail.status.word) + '</b> &middot; ' : '') + '<b>' + escapeXml(detail.checkType) + '</b> &middot; ' +
2995
3025
  '<span class="num">' + spendText + '</span> &middot; <span class="num">' + wallText + '</span></div>' +
2996
3026
  '<div class="summary-row" data-testid="summary-model"><span class="sum-label">model:</span><span class="sum-val">' + escapeXml(modelLine(detail)) + '</span></div>' +
2997
- (detail.judgeModel ? '<div class="summary-row" data-testid="summary-judge"><span class="sum-label">judge:</span><span class="sum-val">' + escapeXml(detail.judgeModel) + '</span></div>' : '') +
2998
3027
  '<div class="summary-row"><span class="sum-label">steps:</span><span class="sum-val">' + stepsText +
2999
3028
  (detail.replans ? ' &middot; ' + detail.replans + ' replan' + (detail.replans === 1 ? '' : 's') : '') + '</span></div>' +
3000
3029
  '<div class="summary-row"><span class="sum-label">why:</span><span class="sum-val">' + escapeXml(detail.stopReason || (detail.glyph === "✓" ? "run ended clean" : "not recorded")) + '</span></div>' +
@@ -3625,10 +3654,10 @@
3625
3654
  var rows = "";
3626
3655
  // fwd am14 item 6: a revise or a Start over says so, first, in the server's own words (`revise 1`, `revise 2`, `start over`); a first draft has no such row
3627
3656
  if(part.draftLabel) rows += '<tr class="draft-kind-row" data-testid="drafting-kind"><td colspan="5"><b>' + escapeXml(part.draftLabel) + "</b></td></tr>";
3628
- // the checks this draft ended with, each marked who added it: the drafter ([agent]) or the person's pick ([you picked])
3629
- (part.draftChecks || []).forEach(function(c){
3630
- rows += '<tr class="draft-checks-row" data-testid="drafting-check"><td colspan="5" style="overflow-wrap:anywhere">line ' + escapeXml(String(c.line)) + " \u00B7 " + escapeXml(c.text) +
3631
- (c.by === "you" ? ' <span class="by" data-by="you">[you picked]</span>' : c.by === "agent" ? ' <span class="by" data-by="agent">[agent]</span>' : "") + "</td></tr>";
3657
+ // the checks themselves are the Audit's own "Checks" section now (`auditChecks`, one list with each row's result), not a second list here
3658
+ // F-b: a suggested check code could not build is told here in one plain sentence, never on the card
3659
+ (part.draftNotBuilt || []).forEach(function(c){
3660
+ rows += '<tr class="draft-checks-row" data-testid="drafting-notbuilt"><td colspan="5" style="overflow-wrap:anywhere">line ' + escapeXml(String(c.line)) + " \u00B7 " + escapeXml(c.text) + "</td></tr>";
3632
3661
  });
3633
3662
  (part.draftSteps || []).forEach(function(st){
3634
3663
  var wall = st.wallMs === null || st.wallMs === undefined ? "–" : duration(st.wallMs);
@@ -3813,6 +3842,52 @@
3813
3842
  }
3814
3843
  });
3815
3844
  }
3845
+ // one row of the Audit's check list: its words, its tag, its result in the one state sign+word markup (a row with no recorded verdict says so, never "passed")
3846
+ function auditCheckRowHtml(r){
3847
+ var res = r.result === "held" ? ["green", r.word || "held"] : r.result === "record-missing" ? ["grey", r.word || "the gate's record for this run is missing"] : r.result === "passed" ? ["green", "passed"] : r.result === "failed" ? ["red", "failed"] : r.result === "not-checked" ? ["grey", "not checked"] : r.result === "not-reached" ? ["grey", r.word || "not reached"] : ["grey", "no result recorded"];
3848
+ return '<div class="audit-check-row" data-testid="audit-check-row" data-result="' + escapeXml(r.result) + '" style="overflow-wrap:anywhere">' + escapeXml(r.text) + byTagOf(r.by) + " " + stateDotHTML(res[0], res[1], "audit-check-state") + "</div>";
3849
+ }
3850
+ // the Checks fold's one state sign (code-owned, one place): any row failed = [✗]; else any row with no recorded result / no gate record = [·]; else [✓] ("held" is passed, "not checked" rows never move it)
3851
+ function auditChecksSignClass(rows){
3852
+ if(rows.some(function(r){ return r.result === "failed"; })) return glyphClass("\u2717");
3853
+ if(rows.some(function(r){ return r.result === "none" || r.result === "record-missing"; })) return glyphClass("\u00B7");
3854
+ return glyphClass("\u2713");
3855
+ }
3856
+ function auditChecksEl(ac){
3857
+ var wrap = document.createElement("div");
3858
+ wrap.className = "audit-part";
3859
+ wrap.setAttribute("data-testid", "audit-checks-group");
3860
+ var all = (ac.checks || []).concat(ac.always || []);
3861
+ var nPass = all.filter(function(r){ return r.result === "passed" || r.result === "held"; }).length;
3862
+ var nFail = all.filter(function(r){ return r.result === "failed"; }).length;
3863
+ var nUnreached = all.filter(function(r){ return r.result === "not-reached"; }).length;
3864
+ var head = "checks &middot; " + nPass + " passed" + (nFail ? " &middot; " + nFail + " failed" : "") + (nUnreached ? " &middot; " + nUnreached + " not reached" : "") + ((ac.notChecked || []).length ? " &middot; " + ac.notChecked.length + " not checked" : "");
3865
+ var btn = document.createElement("button");
3866
+ btn.type = "button";
3867
+ btn.className = "btn audit-part-toggle";
3868
+ btn.setAttribute("aria-expanded", "false");
3869
+ btn.setAttribute("data-testid", "audit-checks-toggle");
3870
+ var headHtml = function(open){ return auditCaret(open) + stateDotHTML(auditChecksSignClass(all), "", "audit-checks-state") + head; };
3871
+ btn.innerHTML = headHtml(false);
3872
+ var body = document.createElement("div");
3873
+ body.className = "audit-part-body";
3874
+ body.hidden = true;
3875
+ body.setAttribute("data-testid", "audit-checks-body");
3876
+ var sec = function(title, rows, tid){
3877
+ if(!rows || !rows.length) return "";
3878
+ return '<div data-testid="' + tid + '" style="margin:6px 0"><div><b>' + escapeXml(title) + "</b></div>" + rows.map(auditCheckRowHtml).join("") + "</div>";
3879
+ };
3880
+ body.innerHTML = '<div class="jp">' + sec("Checks", ac.checks, "audit-checks-checks") + sec("Not checked", ac.notChecked, "audit-checks-notchecked") + sec("Always checked", ac.always, "audit-checks-always") + "</div>";
3881
+ btn.addEventListener("click", function(){
3882
+ var open = btn.getAttribute("aria-expanded") === "true";
3883
+ btn.setAttribute("aria-expanded", open ? "false" : "true");
3884
+ body.hidden = open;
3885
+ btn.innerHTML = headHtml(!open);
3886
+ });
3887
+ wrap.appendChild(btn);
3888
+ wrap.appendChild(body);
3889
+ return wrap;
3890
+ }
3816
3891
  function renderAuditGroups(detail){
3817
3892
  var container = document.getElementById("audit-groups");
3818
3893
  container.innerHTML = "";
@@ -3871,6 +3946,11 @@
3871
3946
  needsEl.textContent = detail.needsAudit;
3872
3947
  container.appendChild(needsEl);
3873
3948
  }
3949
+ // hamr ruling A (2026-11-13): the card's own sections (Checks, Not checked, Always checked), each row with its tag and, after the run, its recorded result (server: `auditChecks`)
3950
+ var ac = detail.auditChecks;
3951
+ if(ac && ((ac.checks || []).length || (ac.notChecked || []).length || (ac.always || []).length)){
3952
+ container.appendChild(auditChecksEl(ac));
3953
+ }
3874
3954
  // P5-R: a resumed run is ONE run — its legs are told apart by a divider line (code-owned text from the server)
3875
3955
  var dividers = Array.isArray(detail.legDividers) ? detail.legDividers : [];
3876
3956
  boxes.forEach(function(box, idx){
@@ -4072,12 +4152,17 @@
4072
4152
  // ---- the ONE job plan drawing (P7): used by the chat's plan bubble AND the Job tab. `plan` is the server's model
4073
4153
  // (src/panel/jobplan.js): numbered lines with their rule, the checks under the line each serves (folded), the AI's own
4074
4154
  // "Not checked", the always-on guards. Only the marker is blue (--plan). Returns HTML (every text is escaped).
4075
- function renderJobPlan(plan){
4076
- var h = '<div class="jp" data-testid="job-plan">' + (plan.older ? '<div class="older" data-testid="plan-older">older job \u2014 numbered lines were not saved</div>' : "") + '<div class="jp-legend">Done when every <b>\u203A</b> check passes</div>' +
4155
+ // the tag of a row by its kind (F-c, code-owned): `~` rows [you], `!` rows [agent], `$` rows [default]; one spelling for the confirm card, the signed card, the Job tab and the Result tab
4156
+ function byTagOf(by){ return by === "you" ? ' <span class="by" data-testid="plan-by" data-by="you">[you]</span>' : by === "agent" ? ' <span class="by" data-testid="plan-by" data-by="agent">[agent]</span>' : by === "default" ? ' <span class="by" data-testid="plan-by" data-by="default">[default]</span>' : ""; }
4157
+ function renderJobPlan(plan, ctl){
4158
+ // the legend promises \u203A checks, so it shows only when the plan has one to show (the goal-only confirm card has none yet)
4159
+ var hasCheck = (plan.loose || []).length > 0 || (plan.lines || []).some(function(l){ return (l.checks || []).length || (l.picked || []).length || (l.always || []).length; });
4160
+ var h = '<div class="jp" data-testid="job-plan">' + (plan.older ? '<div class="older" data-testid="plan-older">older job \u2014 numbered lines were not saved</div>' : "") + (hasCheck ? '<div class="jp-legend">Done when every <b>\u203A</b> check passes</div>' : "") +
4077
4161
  (plan.goal && !plan.older ? '<div class="jp-sum" data-testid="plan-goal"><span class="lbl">AI\'s summary</span>' + escapeXml(plan.goal) + "</div>" : "");
4078
- var byTag = function(by){ return by === "you" ? ' <span class="by" data-testid="plan-by" data-by="you">[you picked]</span>' : by === "agent" ? ' <span class="by" data-testid="plan-by" data-by="agent">[agent]</span>' : ""; };
4162
+ var byTag = byTagOf;
4163
+ // `ctl` (the confirm card only): draws a Drop button after an [agent] check that has a row key; a [you] or [default] row has none
4079
4164
  var checkLine = function(c){
4080
- return '<div class="fold" data-testid="plan-check"><span class="mk">\u203A</span> check \u00B7 ' + escapeXml(c.name) + (c.cls ? " \u00B7 " + escapeXml(c.cls) : "") + byTag(c.by) + "</div>";
4165
+ return '<div class="fold" data-testid="plan-check"><span class="mk">\u203A</span> check \u00B7 ' + escapeXml(c.name) + (c.cls ? " \u00B7 " + escapeXml(c.cls) : "") + byTag(c.by) + (ctl && c.by === "agent" && c.key ? ctl("drop", c.key) : "") + "</div>";
4081
4166
  };
4082
4167
  (plan.lines || []).forEach(function(l){
4083
4168
  h += '<div class="jl" data-testid="plan-line"><span class="num">' + escapeXml(String(l.n)) + "</span>" + escapeXml(l.text);
@@ -4085,21 +4170,27 @@
4085
4170
  (l.rules && l.rules.length ? l.rules : (l.rule ? [l.rule] : [])).forEach(function(r){ h += '<div class="sub">~ ' + escapeXml(r) + "</div>"; });
4086
4171
  (l.picked || []).forEach(function(p){ h += '<div class="fold" data-testid="plan-picked"><span class="mk">\u203A</span> check \u00B7 ' + escapeXml(p) + byTag("you") + "</div>"; });
4087
4172
  (l.checks || []).forEach(function(c){ h += checkLine(c); });
4088
- (l.always || []).forEach(function(g){ h += '<div class="fold" data-testid="plan-always"><span class="mk">\u203A</span> check \u00B7 always-on: ' + escapeXml(g) + "</div>"; });
4089
- (l.refused || []).forEach(function(r){ h += '<div class="fold" data-testid="plan-refused"><span class="mk">\u203A</span> not checked \u00B7 ' + escapeXml(r) + "</div>"; });
4173
+ (l.always || []).forEach(function(g){ h += '<div class="fold" data-testid="plan-always"><span class="mk">\u203A</span> check \u00B7 always-on: ' + escapeXml(g) + byTag("default") + "</div>"; });
4174
+ (l.refused || []).forEach(function(r){ h += '<div class="fold" data-testid="plan-refused"><span class="mk">\u203A</span> not checked \u00B7 ' + escapeXml(r) + byTag((plan.notCheckedBy || {})[r]) + "</div>"; });
4090
4175
  h += "</div>";
4091
4176
  });
4092
4177
  if((plan.loose || []).length){
4093
4178
  h += '<div class="jl"><span class="num"></span>other checks' + plan.loose.map(checkLine).join("") + "</div>";
4094
4179
  }
4095
- var fold = function(title, items, testid){
4180
+ // N-1: checks the agent suggests that are NOT in the job. Code has already proved each builds; none is checked unless the person adds it
4181
+ if((plan.suggested || []).length){
4182
+ h += '<div class="jl jp-sug" data-testid="plan-suggested"><span class="num"></span><span class="lbl">Suggested \u00B7 not in your job, not checked unless you add it</span>' + plan.suggested.map(function(x){
4183
+ return '<div class="fold" data-testid="plan-suggest-row"><span class="mk">\u203A</span> line ' + escapeXml(String(x.line)) + " \u00B7 " + escapeXml(x.text) + byTag("agent") + (x.dropped ? " (you dropped it)" : "") + (ctl ? ctl("add", x.key) : "") + "</div>";
4184
+ }).join("") + "</div>";
4185
+ }
4186
+ var fold = function(title, items, testid, by){
4096
4187
  if(!items || !items.length) return "";
4097
4188
  return '<details class="fold" data-testid="' + testid + '"><summary>' + escapeXml(title) + " \u00B7 " + items.length + "</summary><ul>" +
4098
- items.map(function(x){ return "<li>" + escapeXml(x) + "</li>"; }).join("") + "</ul></details>";
4189
+ items.map(function(x){ return "<li>" + escapeXml(x) + byTag(by ? by : (plan.notCheckedBy || {})[x]) + "</li>"; }).join("") + "</ul></details>";
4099
4190
  };
4100
- h += fold("Not checked (the AI's own reading)", plan.notChecked, "plan-notchecked");
4191
+ h += fold("Not checked", plan.notChecked, "plan-notchecked");
4101
4192
  h += fold("How the page was read", plan.readNotes, "plan-readnotes");
4102
- h += fold("Always checked", plan.alwaysOn, "plan-alwayson");
4193
+ h += fold("Always checked", plan.alwaysOn, "plan-alwayson", "default");
4103
4194
  if(plan.ticketFilter) h += '<div class="fold" data-testid="plan-ticketfilter"><span class="mk">\u203A</span> ticket filter \u00B7 ' + escapeXml(plan.ticketFilter) + "</div>";
4104
4195
  return h + "</div>";
4105
4196
  }
@@ -4263,10 +4354,10 @@
4263
4354
  return h;
4264
4355
  }
4265
4356
  // a list, one row per item (the Job tab lists the same items one per row)
4266
- function resultNotChecked(label, items, testid){
4357
+ function resultNotChecked(label, items, testid, by){
4267
4358
  if(!items || !items.length) return "";
4268
4359
  return resultField(label, '<div class="ro-value" data-testid="' + testid + '"><ul style="margin:0;padding-left:18px">' +
4269
- items.map(function(t){ return '<li>' + escapeXml(t) + '</li>'; }).join("") + '</ul></div>');
4360
+ items.map(function(t){ return '<li>' + escapeXml(t) + (by && typeof byTagOf === "function" ? byTagOf(by[t]) : "") + '</li>'; }).join("") + '</ul></div>');
4270
4361
  }
4271
4362
  // the web page a result was read from: a link (http/https only, new tab) and the server's words that the page may have moved on
4272
4363
  function resultPageLink(url, note, testid){
@@ -4279,7 +4370,7 @@
4279
4370
  return '<div class="job-card" data-testid="result-line"><h4>Line ' + escapeXml(String(line.n)) + '</h4>' + resultLineBox(line) +
4280
4371
  (own ? resultPageLink(line.page, note, "result-page-line") : "") +
4281
4372
  (line.kind === "facts" ? resultFactsLine(line) : resultTextLine(line)) +
4282
- resultNotChecked("Not checked", line.notChecked, "result-line-notchecked") + '</div>';
4373
+ resultNotChecked("Not checked", line.notChecked, "result-line-notchecked", line.notCheckedBy) + '</div>';
4283
4374
  }
4284
4375
  // ---- the generic Result tab (R7b item 4): every ended non-rubric run. The server sends the facts and the words (`kind: "generic"`); the page only draws.
4285
4376
  // The check words and numbers are the Run/Audit tabs' own owners (stageQuestionText, stageNumberText); the state word is the status table's (the server sends it).
@@ -4322,7 +4413,7 @@
4322
4413
  var rows = k.stages.map(function(s){
4323
4414
  var num = stageNumberText(s);
4324
4415
  return '<div class="rs-check" data-testid="result-check"><span class="rs-q">' + escapeXml(stageQuestionText(s)) + '</span><span class="rs-num hint" data-testid="result-check-num">' +
4325
- (num ? escapeXml(num) : "") + escapeXml(stageTriedText(s)) + '</span><span class="rs-sign">' + stateDotHTML(s.passed ? "green" : "red", s.status.word, "result-check-state") + '</span></div>';
4416
+ (num ? escapeXml(num) : "") + escapeXml(stageTriedText(s)) + '</span><span class="rs-sign">' + stateDotHTML(s.passed ? "green" : s.notReached ? "grey" : "red", s.status.word, "result-check-state") + '</span></div>';
4326
4417
  }).join("");
4327
4418
  var notes = k.notes.length ? '<details data-testid="result-close-notes"><summary>the close\'s own notes</summary><div class="ro-value" style="white-space:pre-wrap">' +
4328
4419
  k.notes.map(function(n){ return escapeXml(n.text); }).join("\n") + '</div></details>' : "";
@@ -4407,7 +4498,7 @@
4407
4498
  if(!k) return "checks: the close did not run any check for this run";
4408
4499
  var bits = k.stages.map(function(s){
4409
4500
  var num = stageNumberText(s);
4410
- return s.passed ? escapeXml(stageQuestionText(s)) : gridGlyph("✗") + " " + escapeXml(stageQuestionText(s)) + (num ? " — " + escapeXml(num) : "") + escapeXml(stageTriedText(s));
4501
+ return s.passed ? escapeXml(stageQuestionText(s)) : s.notReached ? gridGlyph("·") + " " + escapeXml(stageQuestionText(s)) + " — " + escapeXml(s.status.word) : gridGlyph("✗") + " " + escapeXml(stageQuestionText(s)) + (num ? " — " + escapeXml(num) : "") + escapeXml(stageTriedText(s));
4411
4502
  });
4412
4503
  return "checks: " + k.passed + " of " + k.total + " " + (k.allPassed ? gridGlyph("✓") : "") + (bits.length ? " &middot; " : "") + bits.join(" &middot; ");
4413
4504
  }
@@ -4576,7 +4667,7 @@
4576
4667
  h += '<div class="rs-warn" data-testid="result-gap">The check said: ' + escapeXml(data.gap.line) + (data.gap.moreText ? ' ' + escapeXml(data.gap.moreText) : "") + '</div>';
4577
4668
  }
4578
4669
  if((data.notChecked || []).length){
4579
- h += '<div class="job-card"><h4>Not checked</h4>' + resultNotChecked("Not checked (the AI's own reading)", data.notChecked, "result-notchecked") + '</div>';
4670
+ h += '<div class="job-card"><h4>Not checked</h4>' + resultNotChecked("Not checked", data.notChecked, "result-notchecked", data.notCheckedBy) + '</div>';
4580
4671
  }
4581
4672
  if((data.readNotes || []).length){
4582
4673
  h += '<div class="job-card"><h4>How the page was read</h4>' + resultNotChecked("How the page was read \u00b7 " + data.readNotes.length, data.readNotes, "result-readnotes") + '</div>';
@@ -5367,6 +5458,18 @@
5367
5458
  var mainBtn = document.getElementById("chat-main-btn");
5368
5459
  var mainHint = document.getElementById("chat-main-hint");
5369
5460
  var reopenBtn = document.getElementById("chat-reopen-btn");
5461
+ var qBox = document.getElementById("chat-question");
5462
+ var qHead = document.getElementById("chat-q-head");
5463
+ var qLine = document.getElementById("chat-q-line");
5464
+ var qText = document.getElementById("chat-q-text");
5465
+ var qChoices = document.getElementById("chat-q-choices");
5466
+ var qC1 = document.getElementById("chat-q-c1");
5467
+ var qC2 = document.getElementById("chat-q-c2");
5468
+ var qOr = document.getElementById("chat-q-or");
5469
+ var qAnswer = document.getElementById("chat-q-answer");
5470
+ var qError = document.getElementById("chat-q-error");
5471
+ var qSend = document.getElementById("chat-q-send");
5472
+ var qKey = null, qBusy = false, qSendChoice = "rule";
5370
5473
  var revisesLeftEl = document.getElementById("chat-left-count");
5371
5474
  // R10 (fwd am17/am20): the id of the draft the next Start drafting follows; the server hands its check picks on (words-keyed), so a pick already made is not asked again
5372
5475
  var carryFromId = null;
@@ -5649,6 +5752,7 @@
5649
5752
  card.hidden = false;
5650
5753
  originLine.hidden = true;
5651
5754
  exitResumeMode();
5755
+ renderQuestionBox(null);
5652
5756
  thread.innerHTML = ""; lastMsgSig = null;
5653
5757
  errEl.textContent = "";
5654
5758
  actionErrEl.textContent = "";
@@ -5963,11 +6067,16 @@
5963
6067
  }
5964
6068
  // the thread is redrawn only when its messages changed: a 2 s poll tick must not close a fold the person just opened
5965
6069
  var lastMsgSig = null;
6070
+ // the confirm card's Drop / Add button (N-2): a typed row edit, instant and $0; the click is handled once on the thread
6071
+ function planControlHTML(op, key){
6072
+ return ' <button type="button" class="btn jp-btn" data-testid="plan-' + op + '" data-rowop="' + op + '" data-rowkey="' + escapeXml(key) + '">' + (op === "add" ? "Add" : "Drop") + "</button>";
6073
+ }
5966
6074
  function renderMessages(state){
5967
6075
  var sig = JSON.stringify(state.messages);
5968
6076
  if(sig === lastMsgSig) return;
5969
6077
  lastMsgSig = sig;
5970
- thread.innerHTML = state.messages.map(function(m){
6078
+ // a question still open is drawn in its own box, not here
6079
+ thread.innerHTML = state.messages.filter(function(m){ return m.askOpen !== true; }).map(function(m){
5971
6080
  var cls = m.role === "you" ? "you" : (m.role === "system" ? "system" : "bot");
5972
6081
  var who = chatWhoLabel(m.role);
5973
6082
  var whoHtml = who ? ('<div class="who">' + escapeXml(who) + '</div>') : "";
@@ -5976,7 +6085,7 @@
5976
6085
  var qs = (m.plan.questions || []).length
5977
6086
  ? '<div class="jp-qs" data-testid="plan-questions"><span class="lbl">AI\'s open questions</span><ul>' +
5978
6087
  m.plan.questions.map(function(q){ return "<li>" + escapeXml(q) + "</li>"; }).join("") + "</ul><b>Revise if you need to.</b></div>" : "";
5979
- return '<div class="msg ' + cls + '" data-testid="plan-bubble">' + whoHtml + renderJobPlan(m.plan) + qs + '<div class="jp-goal">' + escapeXml(m.text) + "</div></div>";
6088
+ return '<div class="msg ' + cls + '" data-testid="plan-bubble">' + whoHtml + renderJobPlan(m.plan, m.plan.editable === true ? planControlHTML : null) + qs + '<div class="jp-goal">' + escapeXml(m.text) + "</div></div>";
5980
6089
  }
5981
6090
  return '<div class="msg ' + cls + '">' + whoHtml + escapeXml(m.text) + '</div>';
5982
6091
  }).join("");
@@ -6129,7 +6238,7 @@
6129
6238
  // the empty-box examples (grey placeholders that vanish on typing) change with the Check type radio
6130
6239
  var JOB_PLACEHOLDERS = {
6131
6240
  deterministic: "Fix the failing date tests in src/date.js\n~ don't edit any test file\nMake npm test pass",
6132
- rubric: "Write a one-page summary of docs/plan.md\n~ PASS: every number is quoted from the file\n~ FAIL: a number that is not in the file\nKeep it under 300 words",
6241
+ rubric: "Write a one-page summary of docs/plan.md\n~ every number is quoted from the file\nKeep it under 300 words",
6133
6242
  };
6134
6243
  var INPUTS_PLACEHOLDER = "repo: /home/me/myrepo\nspec: docs/spec.md";
6135
6244
  function setJobPlaceholders(v){
@@ -6173,6 +6282,33 @@
6173
6282
  var box = document.getElementById("jf-dest");
6174
6283
  if(box && box.value !== d){ box.value = d; fitCardBoxes(); }
6175
6284
  }
6285
+ // hamr 2026-11-12 (as fwdloop M10 am29): the question box. It shows while the session has a question with a `box` (the server's words, src/questionbox.js) and takes the chat input's
6286
+ // place; the texts are rewritten only when the question changes, so a poll tick never wipes what the person is typing. A state with no box (an ask of another kind) keeps the chat input.
6287
+ function renderQuestionBox(state){
6288
+ var ask = state && state.pendingAsk;
6289
+ var b = ask && ask.box ? ask.box : null;
6290
+ qBox.hidden = b === null;
6291
+ document.querySelector(".chat-input-row").hidden = b !== null;
6292
+ mainBtn.hidden = b !== null; mainHint.hidden = b !== null;
6293
+ if(b === null){ qKey = null; return; }
6294
+ var key = String(sessionId) + ":" + String(ask.index) + ":" + String(ask.source) + ":" + b.text;
6295
+ if(key !== qKey){
6296
+ qKey = key;
6297
+ qSendChoice = b.sendChoice || "rule";
6298
+ qHead.textContent = b.head; qLine.textContent = b.line; qText.textContent = b.text;
6299
+ qHead.hidden = b.head === ""; qLine.hidden = b.line === "";
6300
+ var cs = b.choices || [];
6301
+ [qC1, qC2].forEach(function(btn, i){
6302
+ var c = cs[i];
6303
+ btn.hidden = !c;
6304
+ if(c){ btn.textContent = c.label; btn.setAttribute("data-choice", c.choice); btn.setAttribute("data-testid", "chat-q-" + c.choice); }
6305
+ });
6306
+ qChoices.hidden = cs.length === 0;
6307
+ qOr.hidden = b.orLabel === null; qAnswer.hidden = b.orLabel === null; qSend.hidden = b.orLabel === null;
6308
+ if(b.orLabel !== null) qOr.textContent = b.orLabel;
6309
+ qAnswer.value = ""; qError.textContent = "";
6310
+ }
6311
+ }
6176
6312
  function renderActions(state){
6177
6313
  lastState = state;
6178
6314
  syncDestinationFromSession(state);
@@ -6180,6 +6316,7 @@
6180
6316
  // refused START (its own handler writes it) — echoing state.error here made the same refusal appear twice
6181
6317
  errEl.textContent = "";
6182
6318
  var progressChanged = renderProgress(state);
6319
+ renderQuestionBox(state);
6183
6320
  // build item 4 — re-enable Start only once the session has settled
6184
6321
  // into a terminal phase (a fresh Start becomes possible again).
6185
6322
  sessionLive = CLIENT_TERMINAL_PHASES.indexOf(state.phase) === -1;
@@ -6486,6 +6623,41 @@
6486
6623
  }).catch(function(){ chatActionFailed("network error — could not reach the panel server, nothing was sent"); });
6487
6624
  }
6488
6625
 
6626
+ // the box's own Send and choice buttons: a choice button posts its choice and nothing else; the box's Send posts the box's words (as a new rule where the question has choices)
6627
+ function doQuestion(choice){
6628
+ if(qBusy || !sessionId || !lastState || !lastState.pendingAsk || !lastState.pendingAsk.box) return;
6629
+ qBusy = true; qSend.disabled = true; qC1.disabled = true; qC2.disabled = true; qError.textContent = "";
6630
+ var id = sessionId;
6631
+ // a choice button posts its choice and nothing else; the box's Send posts the box's words with the choice the box carries (a new rule), never read as agree or drop it
6632
+ var body = choice === qSendChoice ? {text: qAnswer.value, choice: choice} : {choice: choice};
6633
+ authorPost("/api/author/" + id + "/send", body).then(function(r){
6634
+ qBusy = false; qSend.disabled = false; qC1.disabled = false; qC2.disabled = false;
6635
+ if(id !== sessionId) return;
6636
+ var o = chatPostOutcome(r);
6637
+ if(!o.ok){ qError.textContent = o.error; return; }
6638
+ qAnswer.value = "";
6639
+ poll();
6640
+ }).catch(function(){ qBusy = false; qSend.disabled = false; qC1.disabled = false; qC2.disabled = false; qError.textContent = "network error \u2014 could not reach the panel server, your answer was NOT sent"; });
6641
+ }
6642
+ qSend.addEventListener("click", function(){ doQuestion(qSendChoice); });
6643
+ qC1.addEventListener("click", function(){ doQuestion(qC1.getAttribute("data-choice")); });
6644
+ qC2.addEventListener("click", function(){ doQuestion(qC2.getAttribute("data-choice")); });
6645
+ qAnswer.addEventListener("keydown", function(e){ if(e.key === "Enter" && !e.shiftKey){ e.preventDefault(); doQuestion(qSendChoice); } });
6646
+
6647
+ // Drop / Add on the confirm card: one delegated click; the server edits the row through the check block (no model call) and the card is drawn again from the rows
6648
+ thread.addEventListener("click", function(ev){
6649
+ var b = ev.target && ev.target.closest ? ev.target.closest("[data-rowop]") : null;
6650
+ if(!b || !sessionId) return;
6651
+ b.disabled = true;
6652
+ var id = sessionId;
6653
+ authorPost("/api/author/" + id + "/row-edit", {op: b.getAttribute("data-rowop"), key: b.getAttribute("data-rowkey")}).then(function(r){
6654
+ if(id !== sessionId) return;
6655
+ var o = chatPostOutcome(r);
6656
+ if(o.ok) chatActionOk(); else { b.disabled = false; chatActionFailed(o.error); }
6657
+ poll();
6658
+ }).catch(function(){ b.disabled = false; chatActionFailed("network error \u2014 could not reach the panel server, nothing was changed"); });
6659
+ });
6660
+
6489
6661
  function doSend(){
6490
6662
  if(!sessionId) return;
6491
6663
  var text = msgInput.value;