@adhdev/daemon-core 0.9.82-rc.202 → 0.9.82-rc.204

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/dist/index.mjs CHANGED
@@ -26366,7 +26366,8 @@ function extractModal(state, sections, fullScreen, title, trace) {
26366
26366
  }
26367
26367
  function evaluate(spec, screenText, cursor) {
26368
26368
  const trace = [];
26369
- const lines = screenText.split("\n");
26369
+ const lines = screenText.split("\n").map((l) => l.endsWith("\r") ? l.slice(0, -1) : l);
26370
+ const cleanScreen = lines.join("\n");
26370
26371
  const sections = resolveSections(spec, lines);
26371
26372
  for (const s of sections) {
26372
26373
  trace.push({ kind: "section", text: `section[${s.id}] lines [${s.fromLine}, ${s.toLine}) (${s.toLine - s.fromLine} lines)` });
@@ -26377,9 +26378,9 @@ function evaluate(spec, screenText, cursor) {
26377
26378
  let activeState = null;
26378
26379
  let modal = null;
26379
26380
  for (const st of spec.states) {
26380
- const { matched, title } = matchState(st, sections, screenText, trace, cursor);
26381
+ const { matched, title } = matchState(st, sections, cleanScreen, trace, cursor);
26381
26382
  if (!matched) continue;
26382
- const extractedModal = extractModal(st, sections, screenText, title, trace);
26383
+ const extractedModal = extractModal(st, sections, cleanScreen, title, trace);
26383
26384
  if (st.modal_buttons && !extractedModal) {
26384
26385
  trace.push({ kind: "state_skip", text: `state[${st.id}] matched but modal_buttons extraction failed \u2014 not promoting` });
26385
26386
  continue;
@@ -28549,21 +28550,11 @@ var SpecCliAdapter = class {
28549
28550
  let sections;
28550
28551
  try {
28551
28552
  screen = this.driver.snapshot();
28552
- const lines = screen.split("\n");
28553
- sections = {};
28554
- for (const sec of this.spec.layout?.sections ?? []) {
28555
- const from = sec.from_top;
28556
- const fromBottom = sec.from_bottom;
28557
- let start = 0;
28558
- let end = lines.length;
28559
- if (typeof from === "number") start = Math.max(0, from);
28560
- else if (typeof fromBottom === "number") start = Math.max(0, lines.length - fromBottom);
28561
- const until = sec.until;
28562
- if (until && typeof until === "object" && typeof until.section === "string") {
28563
- const ref = (this.spec.layout?.sections ?? []).find((s) => s.id === until.section);
28564
- if (ref && typeof ref.from_bottom === "number") end = Math.max(start, lines.length - ref.from_bottom);
28565
- }
28566
- sections[sec.id] = lines.slice(start, end).join("\n");
28553
+ const driverSections = this.driver.getSections?.();
28554
+ if (driverSections) {
28555
+ sections = Object.fromEntries(driverSections.map((s) => [s.id, s.text]));
28556
+ } else {
28557
+ sections = this.readCurrentScreenSections(screen);
28567
28558
  }
28568
28559
  } catch {
28569
28560
  }