@inerrata-corporation/errata 2.0.2-dev.866 → 2.0.2-dev.873

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 +55 -37
  2. package/package.json +1 -1
package/errata.mjs CHANGED
@@ -15485,9 +15485,17 @@ function substituteSymbolSummaries(text, summaryByToken) {
15485
15485
  let out2 = text;
15486
15486
  let substituted = 0;
15487
15487
  for (const key of present) {
15488
- const re = new RegExp(`(?<![A-Za-z0-9_$.])${escapeRe2(key)}(?![A-Za-z0-9_$])`, "g");
15488
+ const phrase = summaryByToken.get(key);
15489
+ const leadsWithArticle = RE_LEADING_ARTICLE.test(phrase);
15490
+ const re = new RegExp(
15491
+ `(?<![A-Za-z0-9_$.])${leadsWithArticle ? String.raw`(?:(An|an|A|a|The|the)\s+)?` : ""}${escapeRe2(key)}(?![A-Za-z0-9_$])`,
15492
+ "g"
15493
+ );
15489
15494
  const before = out2;
15490
- out2 = out2.replace(re, summaryByToken.get(key));
15495
+ out2 = leadsWithArticle ? out2.replace(
15496
+ re,
15497
+ (_m, article) => article !== void 0 && /^[A-Z]/.test(article) ? phrase.charAt(0).toUpperCase() + phrase.slice(1) : phrase
15498
+ ) : out2.replace(re, phrase);
15491
15499
  if (out2 !== before) substituted++;
15492
15500
  }
15493
15501
  return { text: out2, substituted, offered: summaryByToken.size };
@@ -15504,7 +15512,7 @@ function vetSidecarSummaries(sidecar) {
15504
15512
  }
15505
15513
  return clean.size > 0 ? clean : null;
15506
15514
  }
15507
- var SYMBOL_SUMMARY_KINDS, MAX_SYMBOL_SUMMARY_CHARS, MAX_SIDECAR_SYMBOLS, TOKEN_RE2, RE_RESERVED, escapeRe2, PATH_SHAPE_RE, CONTRACTION_RE, QUOTED_LITERAL_RE;
15515
+ var SYMBOL_SUMMARY_KINDS, MAX_SYMBOL_SUMMARY_CHARS, MAX_SIDECAR_SYMBOLS, TOKEN_RE2, RE_RESERVED, escapeRe2, RE_LEADING_ARTICLE, PATH_SHAPE_RE, CONTRACTION_RE, QUOTED_LITERAL_RE;
15508
15516
  var init_symbol_intent = __esm({
15509
15517
  "../../packages/shared/src/symbol-intent.ts"() {
15510
15518
  "use strict";
@@ -15520,6 +15528,7 @@ var init_symbol_intent = __esm({
15520
15528
  TOKEN_RE2 = /[A-Za-z_$][A-Za-z0-9_$]*(?:\.[A-Za-z_$][A-Za-z0-9_$]*)*/g;
15521
15529
  RE_RESERVED = /[.*+?^${}()|[\]\\]/g;
15522
15530
  escapeRe2 = (s) => s.replace(RE_RESERVED, "\\$&");
15531
+ RE_LEADING_ARTICLE = /^(?:an?|the)\s/i;
15523
15532
  PATH_SHAPE_RE = /[\w.~-]+[/\\][\w.$~-]+/;
15524
15533
  CONTRACTION_RE = /([A-Za-z])'([A-Za-z])/g;
15525
15534
  QUOTED_LITERAL_RE = /"[^"]+"|'[^']+'|`[^`]+`/;
@@ -16006,6 +16015,7 @@ __export(src_exports, {
16006
16015
  PROJECT_ONLY_NODE_LABELS: () => PROJECT_ONLY_NODE_LABELS,
16007
16016
  QUARANTINE_EXTRACTION_SOURCE_PREFIX: () => QUARANTINE_EXTRACTION_SOURCE_PREFIX,
16008
16017
  RESOLUTION_EDGES: () => RESOLUTION_EDGES,
16018
+ RE_LEADING_ARTICLE: () => RE_LEADING_ARTICLE,
16009
16019
  RouteContextCountWireSchema: () => RouteContextCountWireSchema,
16010
16020
  SEMANTIC_NODE_LABELS: () => SEMANTIC_NODE_LABELS,
16011
16021
  SOLUTION_STRUCTURE_EDGES: () => SOLUTION_STRUCTURE_EDGES,
@@ -21172,7 +21182,7 @@ function triageOf(l2, q, mathOpts) {
21172
21182
  if (!triage) return { triage: "", presenting: presentingId, routes: [] };
21173
21183
  const seen = triage.attrs["perContextSeen"] ?? {};
21174
21184
  const buckets = q.context ? triageContextBuckets(canonicalizeContext(q.context)) : [];
21175
- const active = new Set(q.activeProblemIds ?? []);
21185
+ const active2 = new Set(q.activeProblemIds ?? []);
21176
21186
  const routes = [];
21177
21187
  for (const e of l2.outEdges(triageId, [...ROUTE_EDGE_TYPES])) {
21178
21188
  const perContext = e.attrs["perContext"] ?? {};
@@ -21193,13 +21203,13 @@ function triageOf(l2, q, mathOpts) {
21193
21203
  }
21194
21204
  const post = triagePosterior(counts, buckets, mathOpts);
21195
21205
  let probability = post.probability;
21196
- if (active.size > 0) {
21206
+ if (active2.size > 0) {
21197
21207
  const neighbors = /* @__PURE__ */ new Set([
21198
21208
  ...l2.outEdges(e.to).map((x) => x.to),
21199
21209
  ...l2.inEdges(e.to).map((x) => x.from)
21200
21210
  ]);
21201
21211
  let hits = 0;
21202
- for (const id of active) if (neighbors.has(id)) hits++;
21212
+ for (const id of active2) if (neighbors.has(id)) hits++;
21203
21213
  if (hits > 0) probability = Math.min(1, probability * (1 + COOCCUR_BONUS * Math.tanh(hits)));
21204
21214
  }
21205
21215
  const cause = l2.getNode(e.to);
@@ -28402,7 +28412,7 @@ function buildSymbolLexicon(store) {
28402
28412
  return lex;
28403
28413
  }
28404
28414
  function replaceWithPhrase(text, before, escapedKey, after, phrase) {
28405
- if (!RE_LEADING_ARTICLE.test(phrase)) {
28415
+ if (!RE_LEADING_ARTICLE2.test(phrase)) {
28406
28416
  return text.replace(new RegExp(`${before}${escapedKey}${after}`, "g"), phrase);
28407
28417
  }
28408
28418
  const re = new RegExp(`${before}${String.raw`(?:(An|an|A|a|The|the)\s+)?`}${escapedKey}${after}`, "g");
@@ -28560,7 +28570,7 @@ function generalizeSymbols(text, lexicon, level = 1, fileLexicon) {
28560
28570
  }
28561
28571
  return generalize(out2, { level }).text;
28562
28572
  }
28563
- var SYMBOL_LABELS2, KIND_PHRASE, BUILTIN_TYPE_NAMES, DOC_COMMENT_KINDS, MAX_DOC_CHARS, RE_RESERVED2, escapeRe4, RE_LEADING_ARTICLE, CONVENTION_FILENAMES, CONVENTION_BASENAME_MIN_FILES, CONVENTION_STEMS, FILE_TOKEN_RE, STEM_TOKEN_RE, SOURCE_EXTENSIONS, TOKEN_RE3;
28573
+ var SYMBOL_LABELS2, KIND_PHRASE, BUILTIN_TYPE_NAMES, DOC_COMMENT_KINDS, MAX_DOC_CHARS, RE_RESERVED2, escapeRe4, RE_LEADING_ARTICLE2, CONVENTION_FILENAMES, CONVENTION_BASENAME_MIN_FILES, CONVENTION_STEMS, FILE_TOKEN_RE, STEM_TOKEN_RE, SOURCE_EXTENSIONS, TOKEN_RE3;
28564
28574
  var init_generalize_graph = __esm({
28565
28575
  "src/generalize-graph.ts"() {
28566
28576
  "use strict";
@@ -28612,7 +28622,7 @@ var init_generalize_graph = __esm({
28612
28622
  MAX_DOC_CHARS = 600;
28613
28623
  RE_RESERVED2 = /[.*+?^${}()|[\]\\]/g;
28614
28624
  escapeRe4 = (s) => s.replace(RE_RESERVED2, "\\$&");
28615
- RE_LEADING_ARTICLE = /^(?:an?|the)\s/i;
28625
+ RE_LEADING_ARTICLE2 = /^(?:an?|the)\s/i;
28616
28626
  CONVENTION_FILENAMES = /* @__PURE__ */ new Set([
28617
28627
  "package.json",
28618
28628
  "package-lock.json",
@@ -56074,30 +56084,34 @@ function createLivenessWatch(deps) {
56074
56084
  // src/loop-lag.ts
56075
56085
  var HEARTBEAT_MS = 500;
56076
56086
  var RECENT_PASS_LIMIT = 12;
56077
- var currentPass = "idle";
56078
- var currentPassStartedAt = null;
56087
+ var active = /* @__PURE__ */ new Map();
56088
+ var nextPassId = 1;
56079
56089
  var started = false;
56080
56090
  var recent = [];
56081
56091
  function markPass(name2) {
56082
- const prev = currentPass;
56083
- const prevStart = currentPassStartedAt;
56092
+ const id = nextPassId++;
56084
56093
  const startedAt = Date.now();
56085
- currentPass = name2;
56086
- currentPassStartedAt = startedAt;
56087
- let restored = false;
56094
+ active.set(id, { name: name2, startedAt });
56095
+ let ended = false;
56088
56096
  return () => {
56089
- if (restored) return;
56090
- restored = true;
56097
+ if (ended) return;
56098
+ ended = true;
56099
+ active.delete(id);
56091
56100
  recent.unshift({ name: name2, ms: Date.now() - startedAt, endedAt: Date.now() });
56092
56101
  if (recent.length > RECENT_PASS_LIMIT) recent.pop();
56093
- currentPass = prev;
56094
- currentPassStartedAt = prevStart;
56095
56102
  };
56096
56103
  }
56104
+ function oldestActive() {
56105
+ for (const p of active.values()) return p;
56106
+ return null;
56107
+ }
56097
56108
  function passState() {
56109
+ const now = Date.now();
56110
+ const oldest = oldestActive();
56098
56111
  return {
56099
- current: currentPass,
56100
- runningMs: currentPassStartedAt === null ? null : Date.now() - currentPassStartedAt,
56112
+ current: oldest?.name ?? "idle",
56113
+ runningMs: oldest === null ? null : now - oldest.startedAt,
56114
+ active: [...active.values()].map((p) => ({ name: p.name, runningMs: now - p.startedAt })),
56101
56115
  recent: [...recent]
56102
56116
  };
56103
56117
  }
@@ -56109,8 +56123,10 @@ function startLoopLagMonitor(thresholdMs = 1e3) {
56109
56123
  const now = Date.now();
56110
56124
  const lag = now - last - HEARTBEAT_MS;
56111
56125
  if (lag > thresholdMs) {
56126
+ const holders = [...active.values()];
56127
+ const who = holders.length === 0 ? "idle" : holders.map((p) => `${p.name} +${((now - p.startedAt) / 1e3).toFixed(1)}s`).join(" | ");
56112
56128
  console.warn(
56113
- `[loop-lag] ${(/* @__PURE__ */ new Date()).toISOString()} event loop held ~${(lag / 1e3).toFixed(1)}s during "${currentPass}"`
56129
+ `[loop-lag] ${(/* @__PURE__ */ new Date()).toISOString()} event loop held ~${(lag / 1e3).toFixed(1)}s during "${who}"`
56114
56130
  );
56115
56131
  }
56116
56132
  last = now;
@@ -56139,7 +56155,7 @@ function watchCensusLine(c = watchCensus()) {
56139
56155
  }
56140
56156
 
56141
56157
  // src/engine.ts
56142
- var DAEMON_VERSION = true ? "2.0.2-dev.866" : "2.0.0-alpha.0";
56158
+ var DAEMON_VERSION = true ? "2.0.2-dev.873" : "2.0.0-alpha.0";
56143
56159
  var IGNORED_PATH = /[\\/](?:\.git|node_modules|\.errata|\.claude|\.codex|\.cursor|\.turbo|\.next|dist|coverage|test-results|playwright-report|__pycache__)(?:[\\/]|$)/;
56144
56160
  var IGNORED_NOISE = /castalia\.db|eventlog\.sqlite|turn-cursors/;
56145
56161
  var GIT_OP_MUTE_MS = 4e3;
@@ -60665,18 +60681,18 @@ async function runUse(action, ctx) {
60665
60681
  }
60666
60682
  }
60667
60683
  function runClear(ctx) {
60668
- const active = ctx.getActiveAgent();
60684
+ const active2 = ctx.getActiveAgent();
60669
60685
  ctx.clearActiveAgent();
60670
- if (active) {
60671
- ctx.log(`no longer acting as ${active.handle} \u2014 the daemon acts as your default identity`);
60686
+ if (active2) {
60687
+ ctx.log(`no longer acting as ${active2.handle} \u2014 the daemon acts as your default identity`);
60672
60688
  } else {
60673
60689
  ctx.log(`already on the default identity \u2014 nothing to clear`);
60674
60690
  }
60675
60691
  return 0;
60676
60692
  }
60677
60693
  async function runShow(ctx) {
60678
- const active = ctx.getActiveAgent();
60679
- ctx.log(active ? `active agent: ${active.handle} (id ${active.id})` : `active agent: (default identity)`);
60694
+ const active2 = ctx.getActiveAgent();
60695
+ ctx.log(active2 ? `active agent: ${active2.handle} (id ${active2.id})` : `active agent: (default identity)`);
60680
60696
  if (!ctx.loggedIn) {
60681
60697
  ctx.log(` log in to list the agents you can act as: errata login`);
60682
60698
  return 0;
@@ -60688,7 +60704,7 @@ async function runShow(ctx) {
60688
60704
  ctx.log(` couldn't list actable agents: ${errText(err2)}`);
60689
60705
  return 1;
60690
60706
  }
60691
- printActable(resp, active, ctx);
60707
+ printActable(resp, active2, ctx);
60692
60708
  return 0;
60693
60709
  }
60694
60710
  async function runSet(handle2, ctx) {
@@ -60717,7 +60733,7 @@ async function runSet(handle2, ctx) {
60717
60733
  ctx.log(`now acting as ${match2.handle} (id ${match2.id}) \u2014 saved; persists across daemon restarts`);
60718
60734
  return 0;
60719
60735
  }
60720
- function printActable(resp, active, ctx) {
60736
+ function printActable(resp, active2, ctx) {
60721
60737
  if (resp.agents.length === 0) {
60722
60738
  ctx.log(` (no agents you can act as)`);
60723
60739
  return;
@@ -60725,7 +60741,7 @@ function printActable(resp, active, ctx) {
60725
60741
  ctx.log(` agents you can act as:`);
60726
60742
  for (const a of resp.agents) {
60727
60743
  const marks = [];
60728
- if (active && a.id === active.id) marks.push("active");
60744
+ if (active2 && a.id === active2.id) marks.push("active");
60729
60745
  if (a.id === resp.defaultAgentId) marks.push("default");
60730
60746
  const suffix = marks.length ? ` (${marks.join(", ")})` : "";
60731
60747
  const scope = a.scope ? ` \xB7 ${a.scope}` : "";
@@ -61866,8 +61882,10 @@ async function cmdStatus() {
61866
61882
  const h = await res.json();
61867
61883
  if (h.pass) {
61868
61884
  const held = h.pass.runningMs !== null && h.pass.current !== "idle" ? ` (${(h.pass.runningMs / 1e3).toFixed(1)}s)` : "";
61885
+ const alsoCount = Math.max(0, (h.pass.active?.length ?? 0) - 1);
61886
+ const also = alsoCount > 0 ? ` +${alsoCount} concurrent` : "";
61869
61887
  const last = (h.pass.recent ?? []).slice(0, 3).map((p) => `${p.name} ${(p.ms / 1e3).toFixed(1)}s`).join(", ");
61870
- console.log(` pass: ${h.pass.current}${held}${last ? ` \xB7 recent: ${last}` : ""}`);
61888
+ console.log(` pass: ${h.pass.current}${held}${also}${last ? ` \xB7 recent: ${last}` : ""}`);
61871
61889
  }
61872
61890
  if (h.watch) {
61873
61891
  const line = watchCensusLine(h.watch);
@@ -61896,9 +61914,9 @@ async function cmdStatus() {
61896
61914
  } else {
61897
61915
  console.log(` logged in: yes (${cfg.email}) \u2014 key capability enforced by Console installation/scopes`);
61898
61916
  }
61899
- const active = getActiveAgent(cfg);
61917
+ const active2 = getActiveAgent(cfg);
61900
61918
  console.log(
61901
- ` active agent: ${active ? `${active.handle} (acting-as; \`errata use --none\` to clear)` : "default identity"}`
61919
+ ` active agent: ${active2 ? `${active2.handle} (acting-as; \`errata use --none\` to clear)` : "default identity"}`
61902
61920
  );
61903
61921
  const inspection = await inspectCloudEndpoint(cfg.cloudUrl);
61904
61922
  const decision = evaluateCloudEndpoint(cfg.cloudUrl, inspection);
@@ -62018,8 +62036,8 @@ async function cmdWhoami(args2) {
62018
62036
  return;
62019
62037
  }
62020
62038
  try {
62021
- const active = getActiveAgent(cfg);
62022
- const response = await resolveWhoami(authedCloudClient(cfg), active?.handle ?? null);
62039
+ const active2 = getActiveAgent(cfg);
62040
+ const response = await resolveWhoami(authedCloudClient(cfg), active2?.handle ?? null);
62023
62041
  if (args2.includes("--json")) {
62024
62042
  console.log(JSON.stringify(response, null, 2));
62025
62043
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inerrata-corporation/errata",
3
- "version": "2.0.2-dev.866",
3
+ "version": "2.0.2-dev.873",
4
4
  "description": "errata - local-first observation engine for AI coding agents",
5
5
  "type": "module",
6
6
  "bin": {