@inerrata-corporation/errata 2.0.2-dev.302 → 2.0.2-dev.305

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 -7
  2. package/package.json +1 -1
package/errata.mjs CHANGED
@@ -28148,6 +28148,19 @@ function summariesByBodyHash(cache) {
28148
28148
  }
28149
28149
  return m;
28150
28150
  }
28151
+ function buildDocIndex(store) {
28152
+ const byName = /* @__PURE__ */ new Map();
28153
+ for (const c of store.findNodesByLabel("Comment")) {
28154
+ const name2 = c.attrs["attachedTo"];
28155
+ const kind = c.attrs["kind"];
28156
+ if (typeof name2 !== "string" || !name2) continue;
28157
+ if (typeof kind !== "string" || !DOC_COMMENT_KINDS.has(kind)) continue;
28158
+ const text = typeof c.attrs["text"] === "string" ? c.attrs["text"] : c.description;
28159
+ if (!text?.trim()) continue;
28160
+ if (!byName.has(name2)) byName.set(name2, text.trim().slice(0, MAX_DOC_CHARS));
28161
+ }
28162
+ return byName;
28163
+ }
28151
28164
  function parseSummaryJson(text, expected) {
28152
28165
  const start2 = text.indexOf("[");
28153
28166
  const end = text.lastIndexOf("]");
@@ -28173,7 +28186,8 @@ function haikuIntentSummarizer(apiKey) {
28173
28186
  const listing = symbols.map(
28174
28187
  (s, i2) => `### ${i2 + 1}. kind: ${s.kind}
28175
28188
  name: ${s.name}
28176
- ${s.snippet ? `\`\`\`
28189
+ ` + (s.doc ? `doc: ${s.doc}
28190
+ ` : "") + `${s.snippet ? `\`\`\`
28177
28191
  ${s.snippet}
28178
28192
  \`\`\`` : "(no source available \u2014 describe from the name)"}`
28179
28193
  ).join("\n\n");
@@ -28193,10 +28207,20 @@ SYMBOLS:
28193
28207
  ${listing}` }]
28194
28208
  })
28195
28209
  });
28196
- if (!resp.ok) return symbols.map(() => null);
28210
+ if (!resp.ok) {
28211
+ const detail = await resp.text().catch(() => "");
28212
+ console.warn(
28213
+ `[errata] symbol summaries: API ${resp.status} \u2014 sweep produced nothing this round. ${detail.slice(0, 200)}`
28214
+ );
28215
+ return symbols.map(() => null);
28216
+ }
28197
28217
  const json2 = await resp.json();
28198
28218
  return parseSummaryJson(json2.content?.find((c) => c.type === "text")?.text ?? "", symbols.length);
28199
- } catch {
28219
+ } catch (err2) {
28220
+ console.warn(
28221
+ "[errata] symbol summaries: transport failed \u2014 sweep produced nothing this round:",
28222
+ err2 instanceof Error ? err2.message : err2
28223
+ );
28200
28224
  return symbols.map(() => null);
28201
28225
  }
28202
28226
  };
@@ -28227,6 +28251,7 @@ async function runSymbolSummarySweep(store, workspaceRoot, configDir, summarizer
28227
28251
  const cache = loadSymbolSummaryCache(configDir);
28228
28252
  const candidates = [];
28229
28253
  const seen = /* @__PURE__ */ new Set();
28254
+ const docs = buildDocIndex(store);
28230
28255
  for (const [label, kind] of SUMMARY_LABELS) {
28231
28256
  for (const n of store.findNodesByLabel(label)) {
28232
28257
  const bodyHash = n.attrs["bodyHash"];
@@ -28236,7 +28261,15 @@ async function runSymbolSummarySweep(store, workspaceRoot, configDir, summarizer
28236
28261
  if (!name2 || !isDistinctiveIdentifier(name2)) continue;
28237
28262
  seen.add(bodyHash);
28238
28263
  const snippet = readSnippet(workspaceRoot, n.attrs);
28239
- candidates.push({ bodyHash, name: name2, kind, ...snippet ? { snippet } : {} });
28264
+ const qname = typeof n.attrs["qname"] === "string" ? n.attrs["qname"] : void 0;
28265
+ const doc = docs.get(name2) ?? (qname ? docs.get(qname) : void 0);
28266
+ candidates.push({
28267
+ bodyHash,
28268
+ name: name2,
28269
+ kind,
28270
+ ...snippet ? { snippet } : {},
28271
+ ...doc ? { doc } : {}
28272
+ });
28240
28273
  }
28241
28274
  }
28242
28275
  const todo = candidates.slice(0, maxSymbols);
@@ -28266,7 +28299,7 @@ async function runSymbolSummarySweep(store, workspaceRoot, configDir, summarizer
28266
28299
  }
28267
28300
  return { generated, rejected, remaining };
28268
28301
  }
28269
- var SUMMARY_LABELS, MAX_SNIPPET_CHARS, DEFAULT_MAX_SYMBOLS_PER_SWEEP, DEFAULT_BATCH_SIZE, SUMMARY_MODEL, SUMMARY_PROMPT;
28302
+ var SUMMARY_LABELS, MAX_SNIPPET_CHARS, DEFAULT_MAX_SYMBOLS_PER_SWEEP, DEFAULT_BATCH_SIZE, DOC_COMMENT_KINDS, MAX_DOC_CHARS, SUMMARY_MODEL, SUMMARY_PROMPT;
28270
28303
  var init_symbol_summaries = __esm({
28271
28304
  "src/symbol-summaries.ts"() {
28272
28305
  "use strict";
@@ -28280,10 +28313,13 @@ var init_symbol_summaries = __esm({
28280
28313
  MAX_SNIPPET_CHARS = 1500;
28281
28314
  DEFAULT_MAX_SYMBOLS_PER_SWEEP = 64;
28282
28315
  DEFAULT_BATCH_SIZE = 16;
28316
+ DOC_COMMENT_KINDS = /* @__PURE__ */ new Set(["docstring", "explanation"]);
28317
+ MAX_DOC_CHARS = 600;
28283
28318
  SUMMARY_MODEL = "claude-haiku-4-5-20251001";
28284
28319
  SUMMARY_PROMPT = `For each code symbol below, write ONE short English phrase stating its intent/role, shaped like "a <kind> that <does what>" (e.g. "a function that binds the server's listen port").
28320
+ Some symbols include a "doc:" line \u2014 the author's own description of what it is for. When present TRUST IT as the primary source of intent and translate it into the required shape; the code is secondary evidence. Carry the SPECIFIC job the symbol does, not the category it belongs to: "a function that releases a pooled connection on every exit path including cancellation" is useful; "a function that handles cleanup" is not.
28285
28321
  HARD RULES \u2014 a violating phrase is discarded:
28286
- - NEVER include any identifier, symbol name, variable, type name, file path, or module name from the code \u2014 describe meaning in plain English words only.
28322
+ - NEVER include any identifier, symbol name, variable, type name, file path, or module name from the code or the doc \u2014 describe meaning in plain English words only.
28287
28323
  - NEVER include quoted strings, literals, numbers copied from the code, or code syntax.
28288
28324
  - One phrase per symbol, under 200 characters, lowercase start, no trailing period.
28289
28325
  Output a JSON array of strings, one per symbol in the SAME ORDER (use null for a symbol you cannot describe). Output JSON only, no prose.`;
@@ -52902,7 +52938,7 @@ function startLoopLagMonitor(thresholdMs = 1e3) {
52902
52938
  }
52903
52939
 
52904
52940
  // src/engine.ts
52905
- var DAEMON_VERSION = true ? "2.0.2-dev.302" : "2.0.0-alpha.0";
52941
+ var DAEMON_VERSION = true ? "2.0.2-dev.305" : "2.0.0-alpha.0";
52906
52942
  var IGNORED_PATH = /[\\/](?:\.git|node_modules|\.errata|\.claude|\.codex|\.cursor|\.turbo|\.next|dist|coverage|test-results|playwright-report|__pycache__)(?:[\\/]|$)/;
52907
52943
  var IGNORED_NOISE = /castalia\.db|eventlog\.sqlite|turn-cursors/;
52908
52944
  var GIT_OP_MUTE_MS = 4e3;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inerrata-corporation/errata",
3
- "version": "2.0.2-dev.302",
3
+ "version": "2.0.2-dev.305",
4
4
  "description": "errata - local-first observation engine for AI coding agents",
5
5
  "type": "module",
6
6
  "bin": {