@fractalsynapse/dsh-chapters 0.2.25 → 0.2.27

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/docs/contract.md CHANGED
@@ -902,7 +902,10 @@ Consequences for this plugin, in order of how much they matter:
902
902
  behaviour, and the feature must respect it rather than route around it.
903
903
  3. **Therefore an offer carries an intent, and intent decides whether autorun may act on it.** The suggestion
904
904
  model prefixes its answer: `GOAL:` = this step changes the standing objective → **never auto-run**; the bar
905
- holds it for the human's keystroke and says why. Anything else = a worker step → auto-run is allowed.
905
+ holds it for the human's keystroke, its label slot reading `Goal edit — run it yourself` IN PLACE OF
906
+ `Recommended Next Step` (one message per row — the beside-label badge overflowed it, #300). The prefix is
907
+ legal only while an active goal governs the session: with none, the model must not use it (#300's
908
+ mis-stamp: "…to close out this release cycle" with `goalRevision: null`). Anything else = a worker step → auto-run is allowed.
906
909
  The prefix is stripped before the prompt reaches the composer or the followup, so the worker never sees
907
910
  protocol scaffolding.
908
911
  4. **Exactly one thing may start a turn at a boundary.** The host goal driver queues a round on
package/lib/client.js CHANGED
@@ -176,10 +176,13 @@ window.__ModuleLoader__.load({
176
176
  }
177
177
  return state;
178
178
  }
179
- /** The status label. `failed` keeps the ready label so the error span is the delta, not a mystery row. */
179
+ /** The status label. `failed` keeps the ready label so the error span is the delta, not a mystery row.
180
+ * A goal-edit offer REPLACES the label text (#300): the row is one message tall, and the second-message
181
+ * badge overflowed it and clipped the composer — so the protocol fact earns the slot or goes unsaid. */
180
182
  function barLabel(s) {
181
183
  if (s.running) return "Agent is running — a fresh suggestion lands when the turn ends";
182
184
  if (s.status === "analyzing") return "Analyzing situation…";
185
+ if (s.intent === "goal-edit" && (s.status === "ready" || s.status === "failed")) return "Goal edit — run it yourself";
183
186
  if (s.status === "ready" || s.status === "failed") return "Recommended Next Step";
184
187
  return null;
185
188
  }
@@ -207,16 +210,29 @@ window.__ModuleLoader__.load({
207
210
  function configureQuietHeartbeat(seconds) {
208
211
  QUIET_POLL_MS = typeof seconds === "number" && Number.isFinite(seconds) && seconds > 0 ? Math.trunc(seconds * 1e3) : 0;
209
212
  }
213
+ /**
214
+ * #304: the analyzing belt backs off 10s → 20s → 40s → 60s (cap) while a generation is in
215
+ * flight and nobody is armed. The first wait stays eager (short generations — every rig leg —
216
+ * land in the old 10s rhythm); long and zombie generations stop paying 2 history nodes per
217
+ * poll. The ARMED loop ignores the belt entirely: a stalled round is worse than any cadence.
218
+ * streak counts consecutive analyzing OBSERVATIONS (undefined/0 = eager).
219
+ */
220
+ function analyzingBeltMs(streak) {
221
+ const n = streak === void 0 || streak < 1 ? 0 : Math.min(streak, 3);
222
+ return n === 0 ? ACTIVE_POLL_MS : n === 1 ? 2e4 : n === 2 ? 4e4 : 6e4;
223
+ }
210
224
  function pollSpacingFor(s) {
211
225
  if (s.turnEndPulse === true) return ACTIVE_POLL_MS;
212
226
  if (s.edges) {
213
- if (s.status === "analyzing" || s.autorun === "armed") return ACTIVE_POLL_MS;
227
+ if (s.autorun === "armed") return ACTIVE_POLL_MS;
228
+ if (s.status === "analyzing") return analyzingBeltMs(s.analyzingStreak);
214
229
  return null;
215
230
  }
216
231
  const active = s.status === "analyzing" || s.autorun === "armed";
217
232
  if (!active && s.hidden) return null;
218
233
  if (!active) return QUIET_POLL_MS > 0 ? QUIET_POLL_MS : null;
219
- return ACTIVE_POLL_MS;
234
+ if (s.autorun === "armed") return ACTIVE_POLL_MS;
235
+ return analyzingBeltMs(s.analyzingStreak);
220
236
  }
221
237
  /**
222
238
  * #203: whether a freshly mounted bar pulls, or renders its cache and stays silent. The maintainer's
@@ -478,7 +494,7 @@ window.__ModuleLoader__.load({
478
494
  ".dsh-chapters_promptFull{white-space:pre-wrap;overflow-wrap:break-word;word-break:normal;line-height:20px;font-size:13px;color:var(--dsw-alias-label-primary);display:block;max-height:9rem;overflow-y:auto}",
479
495
  ".dsh-chapters_promptError{color:var(--dsw-alias-state-error-primary);font-size:12px;line-height:20px;flex:none;max-width:34%}",
480
496
  ".dsh-chapters_promptNote{color:var(--dsw-alias-label-secondary);font-size:12px;line-height:20px;min-width:0}",
481
- ".dsh-chapters_promptIntent{color:var(--dsw-alias-label-tertiary);font-size:12px;line-height:20px}",
497
+ ,
482
498
  ".dsh-chapters_promptActions{flex:none;align-items:center;gap:10px;display:flex}",
483
499
  ".dsh-chapters_promptBtn{corner-shape:round;width:28px;height:28px;color:var(--dsw-alias-label-tertiary);cursor:pointer;background:0 0;border:none;border-radius:999px;justify-content:center;align-items:center;padding:0;display:inline-flex;font-size:13px}",
484
500
  ".dsh-chapters_promptBtn:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-secondary)}",
@@ -659,6 +675,7 @@ window.__ModuleLoader__.load({
659
675
  };
660
676
  });
661
677
  const pulling = (0, react.useRef)(false);
678
+ const analyzingStreak = (0, react.useRef)(0);
662
679
  const probed = (0, react.useRef)(false);
663
680
  const pulled = (0, react.useRef)(false);
664
681
  const alive = (0, react.useRef)(true);
@@ -694,7 +711,9 @@ window.__ModuleLoader__.load({
694
711
  const ev = parseBarState(text);
695
712
  if (ev !== null) {
696
713
  answered.current = true;
697
- replyStatus.current = ev.status ?? replyStatus.current;
714
+ const st = ev.status ?? replyStatus.current;
715
+ replyStatus.current = st;
716
+ analyzingStreak.current = st === "analyzing" ? analyzingStreak.current + 1 : 0;
698
717
  dispatch(ev);
699
718
  }
700
719
  const autorun = parseBarAutorun(text);
@@ -749,7 +768,8 @@ window.__ModuleLoader__.load({
749
768
  running: stateRef.current.running,
750
769
  hidden: typeof document !== "undefined" && document.hidden === true,
751
770
  edges: edgesRef.current,
752
- turnEndPulse: pe.pulse
771
+ turnEndPulse: pe.pulse,
772
+ analyzingStreak: analyzingStreak.current
753
773
  });
754
774
  };
755
775
  const duePull = () => {
@@ -911,11 +931,7 @@ window.__ModuleLoader__.load({
911
931
  return (0, react.createElement)("div", {
912
932
  className: "dsh-chapters_promptDock",
913
933
  "data-prompt-bar": "true"
914
- }, (0, react.createElement)("div", { className: `dsh-chapters_promptBar${state.expanded ? " dsh-chapters_promptExpanded" : ""}` }, (0, react.createElement)("span", { className: "dsh-chapters_promptGlyph" }, (0, react.createElement)(Glyph)), (0, react.createElement)("span", { className: "dsh-chapters_promptLabel" }, barLabel(state) ?? ""), ...state.intent === "goal-edit" ? [(0, react.createElement)("span", {
915
- key: "intent",
916
- className: "dsh-chapters_promptIntent",
917
- "aria-label": "This step edits the goal"
918
- }, "edits the goal · run it yourself")] : [], (0, react.createElement)("button", {
934
+ }, (0, react.createElement)("div", { className: `dsh-chapters_promptBar${state.expanded ? " dsh-chapters_promptExpanded" : ""}` }, (0, react.createElement)("span", { className: "dsh-chapters_promptGlyph" }, (0, react.createElement)(Glyph)), (0, react.createElement)("span", { className: "dsh-chapters_promptLabel" }, barLabel(state) ?? ""), (0, react.createElement)("button", {
919
935
  type: "button",
920
936
  className: "dsh-chapters_promptText",
921
937
  "aria-label": state.expanded ? "Click to send this prompt to the chat input for editing" : "Click to expand the full suggested prompt",