@inerrata-corporation/errata 2.0.0-dev.20 → 2.0.0-dev.21

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 (2) hide show
  1. package/errata.mjs +43 -25
  2. package/package.json +1 -1
package/errata.mjs CHANGED
@@ -39472,8 +39472,11 @@ function fixRationaleBefore(sentence, idx) {
39472
39472
  function parseInlineTags(text) {
39473
39473
  const out2 = [];
39474
39474
  const deFenced = text.replace(/```[\s\S]*?```/g, " ");
39475
+ let seqNo = -1;
39475
39476
  for (const raw2 of deFenced.split(/(?<=[.!?])\s+|\n+/)) {
39477
+ seqNo++;
39476
39478
  if (raw2.length > 600) continue;
39479
+ const seqStart = out2.length;
39477
39480
  const sentence = raw2.replace(
39478
39481
  /`[^`]*`/g,
39479
39482
  (m) => /\[[!?]|\((?:fix|cause|constraint):|\(\[/.test(m) ? " " : m
@@ -39559,6 +39562,7 @@ function parseInlineTags(text) {
39559
39562
  out2.push({ kind: "constraint", statement, sentence: sfield });
39560
39563
  }
39561
39564
  }
39565
+ for (let i2 = seqStart; i2 < out2.length; i2++) out2[i2].seq = seqNo;
39562
39566
  }
39563
39567
  return out2;
39564
39568
  }
@@ -39670,7 +39674,18 @@ function harvestInlineTags(store, text, opts) {
39670
39674
  const mintPriors = opts.mintPriors ?? true;
39671
39675
  const touched = opts.sessionTouchedIds ?? /* @__PURE__ */ new Set();
39672
39676
  const plan = { priorEdges: 0, problems: [], fixes: [], triages: [], unresolvedFixes: [] };
39673
- for (const tag of parseInlineTags(text)) {
39677
+ const tags = parseInlineTags(text);
39678
+ const symptomSeqs = tags.filter((t) => (t.kind === "problem" || t.kind === "todo" || t.kind === "constraint") && t.statement).map((t) => ({ seq: t.seq ?? -1, statement: t.statement })).sort((a, b) => a.seq - b.seq);
39679
+ const nearestSymptom = (seq) => {
39680
+ if (seq == null) return void 0;
39681
+ let best;
39682
+ for (const s of symptomSeqs) {
39683
+ if (s.seq <= seq) best = s.statement;
39684
+ else break;
39685
+ }
39686
+ return best;
39687
+ };
39688
+ for (const tag of tags) {
39674
39689
  if (tag.kind === "problem" || tag.kind === "todo") {
39675
39690
  plan.problems.push({
39676
39691
  statement: tag.statement,
@@ -39688,13 +39703,14 @@ function harvestInlineTags(store, text, opts) {
39688
39703
  plan.fixes.push({ inScope: true, fixNote: tag.fixRationale });
39689
39704
  }
39690
39705
  } else if (tag.kind === "triage") {
39706
+ const symptomStatement = nearestSymptom(tag.seq);
39691
39707
  if (tag.handle) {
39692
39708
  const causeId = resolveHandle(store, tag.handle, opts.handleMap);
39693
39709
  const node2 = causeId ? store.getNode(causeId) : null;
39694
- if (node2) plan.triages.push({ causeId: node2.id, causeDescription: node2.description });
39710
+ if (node2) plan.triages.push({ causeId: node2.id, causeDescription: node2.description, ...symptomStatement ? { symptomStatement } : {} });
39695
39711
  } else if (tag.causeText) {
39696
39712
  const causeId = `dcause_${digest({ statement: tag.causeText })}`.slice(0, 56);
39697
- plan.triages.push({ causeId, causeDescription: tag.causeText });
39713
+ plan.triages.push({ causeId, causeDescription: tag.causeText, ...symptomStatement ? { symptomStatement } : {} });
39698
39714
  }
39699
39715
  } else if (mintPriors && source) {
39700
39716
  const targetId = resolveHandle(store, tag.handle, opts.handleMap);
@@ -40951,7 +40967,7 @@ function maybeFlushDigests() {
40951
40967
  }
40952
40968
 
40953
40969
  // src/engine.ts
40954
- var DAEMON_VERSION = true ? "2.0.0-dev.20" : "2.0.0-alpha.0";
40970
+ var DAEMON_VERSION = true ? "2.0.0-dev.21" : "2.0.0-alpha.0";
40955
40971
  var IGNORED_PATH = /[\\/](?:\.git|node_modules|\.errata|\.claude|\.codex|\.cursor|\.turbo|\.next|dist|coverage|test-results|playwright-report|__pycache__)(?:[\\/]|$)/;
40956
40972
  var IGNORED_NOISE = /castalia\.db|eventlog\.sqlite|turn-cursors/;
40957
40973
  var GIT_OP_MUTE_MS = 4e3;
@@ -41542,27 +41558,29 @@ function createWorkspaceEngine(opts) {
41542
41558
  }
41543
41559
  }
41544
41560
  if (opts.sharedStore && plan.triages.length > 0) {
41545
- const symptomId = sessionLastProblem.get(sessionId);
41546
- const symptom = symptomId ? store.getNode(symptomId) : void 0;
41547
- if (symptom) {
41548
- for (const tr of plan.triages) {
41549
- if (tr.causeId === symptomId) continue;
41550
- try {
41551
- recordTriageObservation(
41552
- opts.sharedStore,
41553
- {
41554
- presentingStatement: symptom.description,
41555
- causeId: tr.causeId,
41556
- ...tr.causeDescription ? { causeDescription: tr.causeDescription } : {},
41557
- context: { stack: profile.stack, domain: profile.domains[0] },
41558
- contributor: sessionId
41559
- },
41560
- t
41561
- );
41562
- triaged++;
41563
- } catch (err2) {
41564
- console.warn("[errata] inline triage route failed:", err2);
41565
- }
41561
+ const fallbackId = sessionLastProblem.get(sessionId);
41562
+ const fallbackStatement = fallbackId ? store.getNode(fallbackId)?.description : void 0;
41563
+ for (const tr of plan.triages) {
41564
+ const presentingStatement = tr.symptomStatement ?? fallbackStatement;
41565
+ if (!presentingStatement) continue;
41566
+ const presentingId = designProblemId(presentingStatement);
41567
+ if (tr.causeId === presentingId) continue;
41568
+ try {
41569
+ recordTriageObservation(
41570
+ opts.sharedStore,
41571
+ {
41572
+ presentingStatement,
41573
+ presentingId,
41574
+ causeId: tr.causeId,
41575
+ ...tr.causeDescription ? { causeDescription: tr.causeDescription } : {},
41576
+ context: { stack: profile.stack, domain: profile.domains[0] },
41577
+ contributor: sessionId
41578
+ },
41579
+ t
41580
+ );
41581
+ triaged++;
41582
+ } catch (err2) {
41583
+ console.warn("[errata] inline triage route failed:", err2);
41566
41584
  }
41567
41585
  }
41568
41586
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inerrata-corporation/errata",
3
- "version": "2.0.0-dev.20",
3
+ "version": "2.0.0-dev.21",
4
4
  "description": "errata - local-first observation engine for AI coding agents",
5
5
  "type": "module",
6
6
  "bin": {