@inerrata-corporation/errata 2.0.2-dev.476 → 2.0.2-dev.479

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/errata.mjs CHANGED
@@ -19409,6 +19409,7 @@ function isLegacyAnchor(attrs) {
19409
19409
  function repairLegacyAnchorsFromStatement(store, ts) {
19410
19410
  const report = {
19411
19411
  repaired: [],
19412
+ retiredGuesses: 0,
19412
19413
  noPathNamed: 0,
19413
19414
  pathUnknown: 0,
19414
19415
  alreadyCorrect: 0
@@ -19431,7 +19432,22 @@ function repairLegacyAnchorsFromStatement(store, ts) {
19431
19432
  const anchors = store.outEdges(p.id, ["ANCHORED_AT"]);
19432
19433
  const legacy = anchors.filter((e) => e.attrs?.["anchorProvenance"] === "legacy");
19433
19434
  if (legacy.length === 0) continue;
19434
- if (anchors.some((e) => e.attrs?.["anchorProvenance"] === "restated")) continue;
19435
+ const better = anchors.filter((e) => {
19436
+ const prov = e.attrs?.["anchorProvenance"];
19437
+ return prov === "restated" || prov === "witnessed" || prov === "edited";
19438
+ });
19439
+ if (better.length > 0) {
19440
+ const betterTargets = new Set(better.map((e) => e.to));
19441
+ let retired = 0;
19442
+ for (const e of legacy) {
19443
+ if (!betterTargets.has(e.to)) {
19444
+ store.closeEdge(e.id, ts);
19445
+ retired++;
19446
+ }
19447
+ }
19448
+ report.retiredGuesses += retired;
19449
+ continue;
19450
+ }
19435
19451
  const named = [...String(p.description ?? "").matchAll(STATEMENT_PATH_RE)].map((m) => m[0]);
19436
19452
  if (named.length === 0) {
19437
19453
  report.noPathNamed++;
@@ -19469,6 +19485,10 @@ function repairLegacyAnchorsFromStatement(store, ts) {
19469
19485
  restatedAt: ts
19470
19486
  }
19471
19487
  });
19488
+ for (const e of legacy) {
19489
+ if (e.to !== target.id) store.closeEdge(e.id, ts);
19490
+ }
19491
+ report.retiredGuesses += legacy.filter((e) => e.to !== target.id).length;
19472
19492
  report.repaired.push({
19473
19493
  problemId: p.id,
19474
19494
  problem: p.description,
@@ -22094,7 +22114,24 @@ function renderSnapshot(s) {
22094
22114
  }
22095
22115
  lines.push("");
22096
22116
  }
22097
- if (s.workingFile) {
22117
+ if (s.statedIntent) {
22118
+ const si = s.statedIntent;
22119
+ lines.push(`### \u{1F3AF} You said you're working on this`);
22120
+ lines.push(`> ${si.text}`);
22121
+ if (si.hits.length === 0) {
22122
+ lines.push("");
22123
+ lines.push(
22124
+ "_Nothing recorded here matches that yet \u2014 you're first. What you hit and how you resolve it is what a later agent will be shown._"
22125
+ );
22126
+ } else {
22127
+ lines.push("");
22128
+ lines.push("_Priors that speak to it \u2014 cite one with its `[handle]` if you lean on it:_");
22129
+ for (const h of si.hits) {
22130
+ lines.push(`- **${h.description}** \u2014 \`${h.id}\``);
22131
+ }
22132
+ }
22133
+ lines.push("");
22134
+ } else if (s.workingFile) {
22098
22135
  const w = s.workingFile;
22099
22136
  lines.push(`### Working file: \`${w.relPath}\``);
22100
22137
  if (w.symbols.length) {
@@ -22207,6 +22244,7 @@ function dropLowestUnit(s) {
22207
22244
  if (s.motifs.length) return s.motifs.pop(), true;
22208
22245
  break;
22209
22246
  case "workingFile":
22247
+ if (s.statedIntent) return delete s.statedIntent, true;
22210
22248
  if (s.workingFile) return delete s.workingFile, true;
22211
22249
  break;
22212
22250
  case "remoteOverFloor":
@@ -22255,6 +22293,7 @@ function assembleAgentContext(opts) {
22255
22293
  if (opts.edgeElicitation) snapshot.edgeElicitation = opts.edgeElicitation;
22256
22294
  if (opts.pendingUpdate) snapshot.pendingUpdate = opts.pendingUpdate;
22257
22295
  if (opts.reviewItems?.length) snapshot.reviewItems = [...opts.reviewItems];
22296
+ if (opts.statedIntent) snapshot.statedIntent = opts.statedIntent;
22258
22297
  if (opts.remote && opts.remote.length > 0) {
22259
22298
  const seen = /* @__PURE__ */ new Set();
22260
22299
  const remote = opts.remote.filter((n) => {
@@ -22295,6 +22334,7 @@ function snapshotImpressions(s) {
22295
22334
  (s.reviewItems ?? []).map((r) => r.kind === "abstraction" ? r.candidate : r.route)
22296
22335
  );
22297
22336
  push("workingFile", s.workingFile?.priors?.openProblems.map((p) => p.id) ?? []);
22337
+ push("statedIntent", (s.statedIntent?.hits ?? []).map((h) => h.id));
22298
22338
  return out2;
22299
22339
  }
22300
22340
  function diffRenderLedger(before, after) {
@@ -53094,6 +53134,38 @@ ${GITIGNORE_LINES.join("\n")}
53094
53134
  }
53095
53135
  }
53096
53136
 
53137
+ // src/intent-state.ts
53138
+ var INTENT_TTL_MS = 15 * 60 * 1e3;
53139
+ function createIntentState(ttlMs = INTENT_TTL_MS) {
53140
+ const bySession = /* @__PURE__ */ new Map();
53141
+ let recent = null;
53142
+ const live = (s, nowMs) => s !== void 0 && nowMs - s.atMs < ttlMs;
53143
+ return {
53144
+ set(sessionId, text, nowMs) {
53145
+ const trimmed = text.trim();
53146
+ if (!trimmed) return false;
53147
+ const prev = bySession.get(sessionId);
53148
+ bySession.set(sessionId, { text: trimmed, atMs: nowMs });
53149
+ const changed = !(recent && recent.text === trimmed);
53150
+ recent = { sessionId, text: trimmed, atMs: nowMs };
53151
+ if (!changed && prev && prev.text === trimmed) return false;
53152
+ return changed;
53153
+ },
53154
+ get(sessionId, nowMs) {
53155
+ const s = bySession.get(sessionId);
53156
+ return live(s, nowMs) ? s.text : void 0;
53157
+ },
53158
+ mostRecent(nowMs) {
53159
+ if (!recent) return void 0;
53160
+ return nowMs - recent.atMs < ttlMs ? recent.text : void 0;
53161
+ },
53162
+ clear(sessionId) {
53163
+ bySession.delete(sessionId);
53164
+ if (recent?.sessionId === sessionId) recent = null;
53165
+ }
53166
+ };
53167
+ }
53168
+
53097
53169
  // src/working-file-state.ts
53098
53170
  function createWorkingFileState() {
53099
53171
  const bySession = /* @__PURE__ */ new Map();
@@ -53611,7 +53683,7 @@ function startLoopLagMonitor(thresholdMs = 1e3) {
53611
53683
  }
53612
53684
 
53613
53685
  // src/engine.ts
53614
- var DAEMON_VERSION = true ? "2.0.2-dev.476" : "2.0.0-alpha.0";
53686
+ var DAEMON_VERSION = true ? "2.0.2-dev.479" : "2.0.0-alpha.0";
53615
53687
  var IGNORED_PATH = /[\\/](?:\.git|node_modules|\.errata|\.claude|\.codex|\.cursor|\.turbo|\.next|dist|coverage|test-results|playwright-report|__pycache__)(?:[\\/]|$)/;
53616
53688
  var IGNORED_NOISE = /castalia\.db|eventlog\.sqlite|turn-cursors/;
53617
53689
  var GIT_OP_MUTE_MS = 4e3;
@@ -53915,6 +53987,7 @@ function createWorkspaceEngine(opts) {
53915
53987
  });
53916
53988
  }
53917
53989
  const workingFiles = createWorkingFileState();
53990
+ const intents = createIntentState();
53918
53991
  const toolRuns = createToolRunState();
53919
53992
  let ctxRefreshTimer = null;
53920
53993
  let contextDirty = false;
@@ -53982,6 +54055,13 @@ function createWorkspaceEngine(opts) {
53982
54055
  const doneRender = prebuilt ? null : markPass(`context-render-inline:${profile.name}`);
53983
54056
  const pendingUpdate = opts.pendingUpdate?.() ?? null;
53984
54057
  const reviewItems = pickReviewItems();
54058
+ const liveIntent = intents.mostRecent(Date.now());
54059
+ const intentHits = liveIntent ? searchByIntent(store, liveIntent, { limit: 4 }).map((h) => ({
54060
+ id: h.node.id,
54061
+ label: h.node.label,
54062
+ description: h.node.description,
54063
+ coverage: h.coverage
54064
+ })) : [];
53985
54065
  const { body: body2, snapshot, ledger } = assembleAgentContext({
53986
54066
  store,
53987
54067
  ...snapOpts,
@@ -53989,7 +54069,8 @@ function createWorkspaceEngine(opts) {
53989
54069
  ...elicit ? { edgeElicitation: { instruction: PRIOR_TAG_INSTRUCTION } } : {},
53990
54070
  ...prebuilt ? { snapshot: prebuilt } : {},
53991
54071
  ...pendingUpdate ? { pendingUpdate } : {},
53992
- ...reviewItems.length ? { reviewItems } : {}
54072
+ ...reviewItems.length ? { reviewItems } : {},
54073
+ ...liveIntent ? { statedIntent: { text: liveIntent, hits: intentHits } } : {}
53993
54074
  });
53994
54075
  doneRender?.();
53995
54076
  try {
@@ -54351,6 +54432,9 @@ function createWorkspaceEngine(opts) {
54351
54432
  const touchedFileId = turnFile ? resolveFileId(turnFile) : void 0;
54352
54433
  const touched = new Set(toolRuns.get(sessionId));
54353
54434
  if (touchedFileId) touched.add(touchedFileId);
54435
+ for (const fence of parseIntentFences(turn.text)) {
54436
+ if (intents.set(sessionId, fence.intent, t)) refreshContextNow();
54437
+ }
54354
54438
  const plan = harvestInlineTags(store, turn.text, {
54355
54439
  sourceId: sessionLastProblem.get(sessionId),
54356
54440
  handleMap,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inerrata-corporation/errata",
3
- "version": "2.0.2-dev.476",
3
+ "version": "2.0.2-dev.479",
4
4
  "description": "errata - local-first observation engine for AI coding agents",
5
5
  "type": "module",
6
6
  "bin": {
package/pass-worker.mjs CHANGED
@@ -25571,6 +25571,7 @@ var STATEMENT_PATH_RE = new RegExp(
25571
25571
  function repairLegacyAnchorsFromStatement(store2, ts) {
25572
25572
  const report = {
25573
25573
  repaired: [],
25574
+ retiredGuesses: 0,
25574
25575
  noPathNamed: 0,
25575
25576
  pathUnknown: 0,
25576
25577
  alreadyCorrect: 0
@@ -25593,7 +25594,22 @@ function repairLegacyAnchorsFromStatement(store2, ts) {
25593
25594
  const anchors = store2.outEdges(p.id, ["ANCHORED_AT"]);
25594
25595
  const legacy = anchors.filter((e) => e.attrs?.["anchorProvenance"] === "legacy");
25595
25596
  if (legacy.length === 0) continue;
25596
- if (anchors.some((e) => e.attrs?.["anchorProvenance"] === "restated")) continue;
25597
+ const better = anchors.filter((e) => {
25598
+ const prov = e.attrs?.["anchorProvenance"];
25599
+ return prov === "restated" || prov === "witnessed" || prov === "edited";
25600
+ });
25601
+ if (better.length > 0) {
25602
+ const betterTargets = new Set(better.map((e) => e.to));
25603
+ let retired = 0;
25604
+ for (const e of legacy) {
25605
+ if (!betterTargets.has(e.to)) {
25606
+ store2.closeEdge(e.id, ts);
25607
+ retired++;
25608
+ }
25609
+ }
25610
+ report.retiredGuesses += retired;
25611
+ continue;
25612
+ }
25597
25613
  const named = [...String(p.description ?? "").matchAll(STATEMENT_PATH_RE)].map((m) => m[0]);
25598
25614
  if (named.length === 0) {
25599
25615
  report.noPathNamed++;
@@ -25631,6 +25647,10 @@ function repairLegacyAnchorsFromStatement(store2, ts) {
25631
25647
  restatedAt: ts
25632
25648
  }
25633
25649
  });
25650
+ for (const e of legacy) {
25651
+ if (e.to !== target.id) store2.closeEdge(e.id, ts);
25652
+ }
25653
+ report.retiredGuesses += legacy.filter((e) => e.to !== target.id).length;
25634
25654
  report.repaired.push({
25635
25655
  problemId: p.id,
25636
25656
  problem: p.description,