@polycode-projects/the-mechanical-code-talker 2.6.0 → 2.7.0

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 (63) hide show
  1. package/corpus/LICENSES.json +14 -0
  2. package/corpus/child/LICENSE-NOTICE +43 -0
  3. package/corpus/child/README.md +79 -0
  4. package/corpus/child/index.json.gz +0 -0
  5. package/corpus/child/manifest.json +313 -0
  6. package/corpus/child/shards/child-00.jsonl.gz +0 -0
  7. package/corpus/child/shards/child-01.jsonl.gz +0 -0
  8. package/corpus/child/shards/child-02.jsonl.gz +0 -0
  9. package/corpus/child/shards/child-03.jsonl.gz +0 -0
  10. package/corpus/child/shards/child-04.jsonl.gz +0 -0
  11. package/corpus/child/shards/child-05.jsonl.gz +0 -0
  12. package/corpus/child/shards/child-06.jsonl.gz +0 -0
  13. package/corpus/child/shards/child-07.jsonl.gz +0 -0
  14. package/corpus/child/shards/child-08.jsonl.gz +0 -0
  15. package/corpus/child/shards/child-09.jsonl.gz +0 -0
  16. package/corpus/child/shards/child-0a.jsonl.gz +0 -0
  17. package/corpus/child/shards/child-0b.jsonl.gz +0 -0
  18. package/corpus/child/shards/child-0c.jsonl.gz +0 -0
  19. package/corpus/child/shards/child-0d.jsonl.gz +0 -0
  20. package/corpus/child/shards/child-0e.jsonl.gz +0 -0
  21. package/corpus/child/shards/child-0f.jsonl.gz +0 -0
  22. package/corpus/child/shards/child-10.jsonl.gz +0 -0
  23. package/corpus/child/shards/child-11.jsonl.gz +0 -0
  24. package/corpus/child/shards/child-12.jsonl.gz +0 -0
  25. package/corpus/child/shards/child-13.jsonl.gz +0 -0
  26. package/corpus/child/shards/child-14.jsonl.gz +0 -0
  27. package/corpus/child/shards/child-15.jsonl.gz +0 -0
  28. package/corpus/child/shards/child-16.jsonl.gz +0 -0
  29. package/corpus/child/shards/child-17.jsonl.gz +0 -0
  30. package/corpus/child/shards/child-18.jsonl.gz +0 -0
  31. package/corpus/child/shards/child-19.jsonl.gz +0 -0
  32. package/corpus/child/shards/child-1a.jsonl.gz +0 -0
  33. package/corpus/child/shards/child-1b.jsonl.gz +0 -0
  34. package/corpus/child/shards/child-1c.jsonl.gz +0 -0
  35. package/corpus/child/shards/child-1d.jsonl.gz +0 -0
  36. package/corpus/child/shards/child-1e.jsonl.gz +0 -0
  37. package/corpus/child/shards/child-1f.jsonl.gz +0 -0
  38. package/corpus/conceptnet/child-seed.mjs +169 -0
  39. package/corpus/conceptnet/filter-dump.mjs +69 -48
  40. package/corpus/worlds/README.md +26 -0
  41. package/corpus/worlds/index.json.gz +0 -0
  42. package/corpus/worlds/manifest.json +33 -0
  43. package/corpus/worlds/shards/ashcombe-hall.jsonl.gz +0 -0
  44. package/corpus/worlds/src/ashcombe-hall.jsonl +64 -0
  45. package/data/templates/responses.jsonl +1 -1
  46. package/package.json +4 -1
  47. package/src/adapters/corpus/child-pack.mjs +115 -0
  48. package/src/adapters/corpus/conceptnet-map.toml +7 -0
  49. package/src/adapters/corpus/worlds-pack.mjs +122 -0
  50. package/src/domain/ask.mjs +66 -10
  51. package/src/domain/child-pack.mjs +79 -0
  52. package/src/domain/codegraph.mjs +1 -1
  53. package/src/domain/grammar/ace.mjs +77 -0
  54. package/src/domain/grammar/lexicon-core.json +6 -0
  55. package/src/domain/interpret/normalize.mjs +1 -1
  56. package/src/domain/memory/trust.mjs +8 -0
  57. package/src/domain/router/registry.mjs +17 -4
  58. package/src/domain/router/resolver.mjs +4 -2
  59. package/src/domain/worlds-pack.mjs +71 -0
  60. package/src/services/adventure.mjs +669 -0
  61. package/src/services/chat.mjs +652 -43
  62. package/src/services/sessions.mjs +10 -2
  63. package/src/surfaces/web/memory-ask-browser.bundle.js +607 -57
@@ -945,9 +945,9 @@
945
945
  const layer = layers[name];
946
946
  if (!layer || typeof layer !== "object") continue;
947
947
  const posting = layer[t];
948
- const list = Array.isArray(posting) ? posting : Array.isArray(posting?.ids) ? posting.ids : null;
949
- if (!list?.length) continue;
950
- for (const id of list) ids.add(id);
948
+ const list2 = Array.isArray(posting) ? posting : Array.isArray(posting?.ids) ? posting.ids : null;
949
+ if (!list2?.length) continue;
950
+ for (const id of list2) ids.add(id);
951
951
  via.add(name);
952
952
  }
953
953
  return ids.size ? { ids: [...ids].sort(), via: [...via].sort().join("+") } : empty;
@@ -984,6 +984,7 @@
984
984
  const head = t.split(/\s+/)[0];
985
985
  if (head.startsWith("corpus-weak:")) return { kind: "corpusWeak", name: head.slice("corpus-weak:".length) || "unknown" };
986
986
  if (head.startsWith("corpus:")) return { kind: "corpus", name: head.slice("corpus:".length) || "unknown" };
987
+ if (head.startsWith("child:")) return { kind: "corpus", name: head.slice("child:".length).split(":")[0] || "unknown" };
987
988
  if (head.startsWith("ace:")) return { kind: "operator", ...parseChatTagRest(head.slice("ace:".length)) };
988
989
  if (head.startsWith("teach:")) {
989
990
  return { kind: "teach", ...parseChatTagRest(head.slice("teach:".length)) };
@@ -1331,8 +1332,8 @@
1331
1332
  return lines.join("\n");
1332
1333
  }
1333
1334
  function truncationNote(graph) {
1334
- const list = graph.truncated.map((t) => `${t.predicate} (${t.shown}/${t.count})`).join(", ");
1335
- return `note: partial edge lists for: ${list}. Counts are complete; the lists are not.`;
1335
+ const list2 = graph.truncated.map((t) => `${t.predicate} (${t.shown}/${t.count})`).join(", ");
1336
+ return `note: partial edge lists for: ${list2}. Counts are complete; the lists are not.`;
1336
1337
  }
1337
1338
  function impactClosure(graph, ind, { maxDepth = 8 } = {}) {
1338
1339
  const dependents = /* @__PURE__ */ new Map();
@@ -1399,7 +1400,7 @@
1399
1400
  });
1400
1401
  if (truncatedStructural.length) {
1401
1402
  lines.push(
1402
- "warning: partial edge lists (" + truncatedStructural.map((t) => `${t.predicate}: ${t.shown}/${t.count}`).join(", ") + ") \u2014 this closure may be missing edges. Cross-check critical results with tmct_search."
1403
+ "warning: partial edge lists (" + truncatedStructural.map((t) => `${t.predicate}: ${t.shown}/${t.count}`).join(", ") + ") \u2014 this closure may be missing edges. Cross-check critical results with a lexical search (/find <term>)."
1403
1404
  );
1404
1405
  }
1405
1406
  return lines.join("\n");
@@ -2532,9 +2533,9 @@ ${shown.join("\n")}${tail}`;
2532
2533
  const modLabel = graph.byId.get(modId)?.label || modId;
2533
2534
  const hits = cochangeNeighbours(graph, modId);
2534
2535
  if (!hits.length) return `${modLabel}: no change-coupling recorded (rarely co-committed, or outside the git-log window).`;
2535
- const list = hits.slice(0, COCHANGE_CAP).map((h) => `${h.label} (\xD7${h.weight})`);
2536
+ const list2 = hits.slice(0, COCHANGE_CAP).map((h) => `${h.label} (\xD7${h.weight})`);
2536
2537
  return `${modLabel} \u2014 usually changes together with ${hits.length} module(s) (edit these too):
2537
- ${list.join("\n ")}` + (hits.length > COCHANGE_CAP ? `
2538
+ ${list2.join("\n ")}` + (hits.length > COCHANGE_CAP ? `
2538
2539
  \u2026+${hits.length - COCHANGE_CAP} more` : "");
2539
2540
  }
2540
2541
  function renderExports(graph, ind) {
@@ -2543,14 +2544,14 @@ ${shown.join("\n")}${tail}`;
2543
2544
  const modLabel = graph.byId.get(modId)?.label || modId;
2544
2545
  const edges = edgesOfKind(graph, "reexports").filter((e) => e.subject === modId);
2545
2546
  if (!edges.length) return `${modLabel}: no public exports recorded (no export list / __all__ found, or none resolved).`;
2546
- const list = edges.slice(0, EXPORTS_CAP).map((e) => {
2547
+ const list2 = edges.slice(0, EXPORTS_CAP).map((e) => {
2547
2548
  const origin = graph.byId.get(e.object);
2548
2549
  const where = origin ? siteOf(origin) : null;
2549
2550
  const from = where ? ` \u2190 ${where.path}` : "";
2550
2551
  return `${e.objectLabel || e.object}${from}`;
2551
2552
  });
2552
2553
  return `${modLabel} \u2014 public API (${edges.length} export(s)):
2553
- ${list.join("\n ")}` + (edges.length > EXPORTS_CAP ? `
2554
+ ${list2.join("\n ")}` + (edges.length > EXPORTS_CAP ? `
2554
2555
  \u2026+${edges.length - EXPORTS_CAP} more` : "");
2555
2556
  }
2556
2557
  var PROP_KIND, isProvRef, DESCRIBE_EDGE_CAP, PROV_CAP, IMPACT_DEPTHS_LISTED, IMPACT_PER_DEPTH, IMPACT_TESTS_PER_DEP, SEARCH_LIMIT, SEARCH_SYMBOLS_SHOWN, PATH_W, SYM_W, EXACT_W, SYM_MATCH_CAP, PROX_FRAC, PROX_CAP_FRAC, NONPROD_DEMOTE, isNonProdLabel, CALL_PROX_FRAC, CALL_PROX_CAP_FRAC, IMPL_PROX_FRAC, IMPL_PROX_CAP_FRAC, isCsModuleLabel, looksLikeCsInterface, PROSE_PROX_FRAC, PROSE_PROX_CAP_FRAC, PROSE_LOOKUP_LIMIT, PROSE_LAYER_FRAC, PROSE_LAYER_CAP_FRAC, PROSE_LAYER_DISCOUNT, LIT_W, LIT_MIN_COMPONENTS, LIT_COMP_CAP, LIT_FRAC, LIT_CAP_FRAC, BEAM_MARGIN_FRAC, BEAM_PROX_FRAC, BEAM_PROX_CAP_FRAC, BEAM_OVERFLOW_CAP, BEAM_PLIES, BEAM_EDGE_GROUPS, SPIRAL_DEPTH_DEFAULT, SPIRAL_NODE_LIMIT_DEFAULT, SPIRAL_Q_DEFAULT, SPIRAL_EXPAND_KINDS, SPIRAL_EMIT_FRAC, SPIRAL_HOP_DECAY, SPIRAL_PROX_FRAC, SPIRAL_PROX_CAP_FRAC, NAME_PATTERN_MAX_LENGTH, NAME_PATTERN_MAX_QUANTIFIERS, NAME_MATCH_MAX_LABEL, NAME_MATCH_BUDGET_MS, NameFilterBudgetExceeded, edgesOfKindCache, MEMBERS_CAP, SUBCLASS_CAP, CALL_CAP, attrVal, ARCH_PKG_CAP, ARCH_HUB_CAP, COVERAGE_CAP, TESTS_GRAIN_NOTE, HISTORY_CAP, CALL_SYMBOL_CLASSES, CALL_HINT_CAP, SYMBOL_CLASSES, CONTEXT_SIBLING_CAP, CLASS_MEMBER_CAP, COCHANGE_MID_CAP, CONTEXT_TESTS_CAP, TINY_MAX_LOC, TINY_MAX_ARITY, LARGE_CLASS_MEMBERS, INLINE_CALLEE_CAP, splitDecs, tokenize, countParams, modeOf, COCHANGE_CAP, EXPORTS_CAP;
@@ -2877,7 +2878,7 @@ ${shown.join("\n")}${tail}`;
2877
2878
  GREETING_PREAMBLE_RE = /^(?:hi|hiya|hello|hey|yo|howdy|g'?day|yeah\s+nah|good\s+(?:morning|afternoon|evening|day)|greetings|salutations)(?:\s+(?:there|pardner|folks|friend|mate))?\s*[,.—–-]\s*(?:(?:just\s+a\s+)?quick\s+question\s*[,:—–-]?\s*)?(.+)$/i;
2878
2879
  THANKS_PREAMBLE_RE = /^(?:thanks|thank\s+you|many\s+thanks|thx|ty|cheers)(?:\s+(?:so\s+much|a\s+lot|very\s+much|a\s+bunch))?\s*[,—–-]\s*(?:(?:just\s+a\s+)?quick\s+question\s*[,:—–-]?\s*)?(.+)$/i;
2879
2880
  ACK_PREAMBLE_RE = /^(?:(?:ok(?:ay)?|aight|cool|alright|sure|right|fine|great|nice|got it|gotcha|sounds good|no worries|no problem)[\s,]+)+(.+)$/i;
2880
- BROWSING_PREAMBLE_RE = /^(?:just\s+(?:poking\s+around|looking\s+around|browsing|exploring|checking\s+(?:this|it)\s+out)|first\s+time\s+(?:trying\s+this\s+out|using\s+this|here))\s*[,.—–-]\s*(.+)$/i;
2881
+ BROWSING_PREAMBLE_RE = /^(?:just\s+(?:poking\s+around|looking\s+around|browsing|exploring|checking\s+(?:this|it)\s+out)|first\s+time\s+(?:trying\s+this\s+out|using\s+this|here)|i'?m\s+new\s+(?:here|around\s+here|to\s+(?:this|all\s+this)(?:\s+(?:repo|codebase|project|app|tool|thing))?))\s*[,.—–-]\s*(.+)$/i;
2881
2882
  HEDGE_ADVERB_PREAMBLE_RE = /^(?:(?:maybe|possibly|perhaps)\s+)+(.+)$/i;
2882
2883
  TROUBLE_ASIDE_RE = /,?\s*if\s+(?:it'?s|it\s+is|that'?s|that\s+is)\s+not\s+too\s+much\s+(?:trouble|bother|hassle)\s*,?\s*/i;
2883
2884
  MODAL_WRAPPER_RE = /^(?:can|could|would|will)\s+you\s+(?:please\s+)?(.+?)(?:[,\s]+please)?\??$/i;
@@ -3783,7 +3784,7 @@ ${shown.join("\n")}${tail}`;
3783
3784
  function parseComposite(text, nlp) {
3784
3785
  const w = splitWords(text);
3785
3786
  const lc = w.map((x) => x.toLowerCase());
3786
- return parseExistence(w, lc) || parseQualifierCheck(w, lc) || parseUniversal(w, lc, nlp) || parseNegation(text, nlp, 0) || parseNegatedAsk(w, lc) || parseForwardNegation(w, lc, nlp) || parseTemporal(w, lc, nlp, 0) || parseCommitFilter(w, lc) || parseAnaphora(w, lc, nlp) || parseAggregate(w, lc, nlp) || parseSuperlative(w, lc, nlp) || parseFind(w, lc, nlp, 0) || parseList(w, lc, nlp, 0) || parseNested(w, lc, nlp, 0) || parsePluralAnaphoraObject(w, lc, nlp) || parseRelationalOrQualified(w, lc, nlp, 0);
3787
+ return parseExistence(w, lc) || parseQualifierCheck(w, lc) || parseUniversal(w, lc, nlp) || parseNegation(text, nlp, 0) || parseNegatedAsk(w, lc, nlp) || parseForwardNegation(w, lc, nlp) || parseTemporal(w, lc, nlp, 0) || parseCommitFilter(w, lc) || parseAnaphora(w, lc, nlp) || parseAggregate(w, lc, nlp) || parseSuperlative(w, lc, nlp) || parseFind(w, lc, nlp, 0) || parseList(w, lc, nlp, 0) || parseNested(w, lc, nlp, 0) || parsePluralAnaphoraObject(w, lc, nlp) || parseRelationalOrQualified(w, lc, nlp, 0);
3787
3788
  }
3788
3789
  function complementAst(entityType, diffAtom) {
3789
3790
  return {
@@ -4110,11 +4111,11 @@ ${shown.join("\n")}${tail}`;
4110
4111
  if (!term) return { node: "miss", reason: `"is/are <qualifier>" needs a named thing to check first` };
4111
4112
  return { node: "qualCheck", term, qualifier: lc[qualIdx], negated, scope: tail?.scope || null };
4112
4113
  }
4113
- function parseNegatedAsk(w, lc) {
4114
- if (lc[0] !== "do" && lc[0] !== "does" && lc[0] !== "did") return null;
4114
+ function parseNegatedAsk(w, lc, nlp) {
4115
+ if (!["do", "does", "did", "is", "are", "was", "were"].includes(lc[0])) return null;
4115
4116
  const notIdx = lc.indexOf("not", 1);
4116
4117
  if (notIdx < 0) return null;
4117
- const positive = parseAnchored(w.filter((_, i) => i !== notIdx).join(" "));
4118
+ const positive = parseSimpleClause(w.filter((_, i) => i !== notIdx).join(" "), nlp);
4118
4119
  if (!positive || positive.shape !== "ask") return null;
4119
4120
  return { ...positive, negated: true };
4120
4121
  }
@@ -4855,7 +4856,7 @@ ${shown.join("\n")}${tail}`;
4855
4856
  items = items.filter((ind) => ok.has(ind.id));
4856
4857
  }
4857
4858
  }
4858
- const sameClass = (list) => list.length && list.every((x) => x.class === list[0].class) ? list[0].class : null;
4859
+ const sameClass = (list2) => list2.length && list2.every((x) => x.class === list2[0].class) ? list2[0].class : null;
4859
4860
  const common = items.length ? sameClass(items) : sameClass(baseItems);
4860
4861
  if (ast.mode === "count") return { compositeKind: "count", count: items.length, entityType: common, matches: [] };
4861
4862
  return { compositeKind: "set", matches: items, entityType: common };
@@ -4917,7 +4918,11 @@ ${shown.join("\n")}${tail}`;
4917
4918
  return { compositeKind: "temporal", matches: commits, entityType: ast.entityType, innerCount: inner.length };
4918
4919
  }
4919
4920
  function evalSuperlative(graph, ast) {
4920
- const pool = graph.individuals.filter((i) => i.class === ast.entityType);
4921
+ let pool = graph.individuals.filter((i) => i.class === ast.entityType);
4922
+ if (ast.metric?.kind === "tests" && ast.entityType === "Module") {
4923
+ const testSubjects = new Set(edgesOfKind2(graph, "tests").map((e) => e.subject));
4924
+ pool = pool.filter((i) => !testSubjects.has(i.id) && !isTestPath(String(i.label).toLowerCase()));
4925
+ }
4921
4926
  const scored = pool.map((ind) => ({ ind, score: degreeMetric(graph, ind, ast.metric) })).sort((a, z) => ast.extreme === "most" ? z.score - a.score : a.score - z.score);
4922
4927
  if (!scored.length) return { compositeKind: "superlative", entityType: ast.entityType, matches: [] };
4923
4928
  const best = scored[0].score;
@@ -5498,7 +5503,7 @@ ${shown.join("\n")}${tail}`;
5498
5503
  }
5499
5504
  return declineOnUnplacedWords(resolveObjectCore(graph, term, opts), term);
5500
5505
  }
5501
- return resolveObjectCore(graph, term, opts);
5506
+ return declineOnUnplacedWords(resolveObjectCore(graph, term, opts), term);
5502
5507
  }
5503
5508
  function resolveTermOrContext(graph, term, contextId) {
5504
5509
  if (CONTEXT_PRONOUNS.includes(String(term || "").trim().toLowerCase())) {
@@ -5771,7 +5776,7 @@ ${shown.join("\n")}${tail}`;
5771
5776
  if (entityType && entityType !== "Change") {
5772
5777
  const wantClasses = classesForKinds(graph, fwdKinds);
5773
5778
  const siblingClass = FINE_CLASS_SIBLING[entityType];
5774
- if (!wantClasses.has(entityType) && !(siblingClass && wantClasses.has(siblingClass))) {
5779
+ if (wantClasses.size && !wantClasses.has(entityType) && !(siblingClass && wantClasses.has(siblingClass))) {
5775
5780
  return {
5776
5781
  matches: [],
5777
5782
  objMatch,
@@ -6144,13 +6149,44 @@ ${options2}
6144
6149
  };
6145
6150
  }
6146
6151
  if (result.ambiguous) {
6147
- const pool = [result.objMatch, ...result.candidates || []].filter(Boolean);
6152
+ let pool = [result.objMatch, ...result.candidates || []].filter(Boolean);
6153
+ let branches = result.branches;
6154
+ if (parsed.kind && parsed.kind !== "touches" && !pool.every((i) => i.class === "Commit")) {
6155
+ const grainOk = (i) => !["Commit", "Session", "Source", "Utterance"].includes(i?.class);
6156
+ const kept = pool.filter(grainOk);
6157
+ if (kept.length) {
6158
+ pool = kept;
6159
+ if (branches?.length) branches = branches.filter((b) => grainOk(b.candidate));
6160
+ }
6161
+ }
6162
+ if (graph && !/[/.]/.test(String(parsed.object || ""))) {
6163
+ const tLc = String(parsed.object || "").toLowerCase();
6164
+ const termWords = new Set(splitIdentifierWords(String(parsed.object || "")).filter((w) => w.length >= 3));
6165
+ const already = new Set(pool.map((i) => i.id));
6166
+ let nearest = null;
6167
+ let bestShared = 0;
6168
+ let bestD = Infinity;
6169
+ if (termWords.size) {
6170
+ for (const i of graph.individuals) {
6171
+ if (!["Function", "Method", "Class", "GlobalVariable", "Attribute"].includes(i.class) || already.has(i.id)) continue;
6172
+ const shared = splitIdentifierWords(String(i.label)).filter((w) => termWords.has(w)).length;
6173
+ if (!shared || shared < bestShared) continue;
6174
+ const d = editDistance(String(i.label).toLowerCase(), tLc, 8);
6175
+ if (shared > bestShared || d < bestD) {
6176
+ nearest = i;
6177
+ bestShared = shared;
6178
+ bestD = d;
6179
+ }
6180
+ }
6181
+ }
6182
+ if (nearest) pool = [...pool, nearest];
6183
+ }
6148
6184
  const noun = pool.length && pool.every((i) => i.class === "Commit") ? "commit" : "module";
6149
6185
  const shown = pool.slice(0, OVERFLOW_CAP).map((i) => i.label);
6150
6186
  const extra2 = pool.length > OVERFLOW_CAP ? `, \u2026and ${pool.length - OVERFLOW_CAP} more` : "";
6151
6187
  const lead = `"${parsed.object}" matches more than one ${noun} ambiguously \u2014 did you mean ${listJoin(shown)}${extra2}? Try one of those. If you're not sure, narrow it to one name.`;
6152
- const content = result.branches && result.branches.length ? `${lead}
6153
- ${result.branches.map((b, i) => `${i + 1}) ${b.candidate.label}: ${b.rendered.content}`).join("\n")}` : lead;
6188
+ const content = branches && branches.length ? `${lead}
6189
+ ${branches.map((b, i) => `${i + 1}) ${b.candidate.label}: ${b.rendered.content}`).join("\n")}` : lead;
6154
6190
  return {
6155
6191
  content,
6156
6192
  miss: false,
@@ -6306,8 +6342,8 @@ ${result.branches.map((b, i) => `${i + 1}) ${b.candidate.label}: ${b.rendered.co
6306
6342
  byModule.get(mod).push(symbolLabelOf(m));
6307
6343
  }
6308
6344
  const clauses = [...byModule.entries()].map(([mod, syms], i) => {
6309
- const list = listJoin(syms);
6310
- return i === 0 ? `in ${mod} there is ${list}` : `there is ${list} in ${mod}`;
6345
+ const list2 = listJoin(syms);
6346
+ return i === 0 ? `in ${mod} there is ${list2}` : `there is ${list2} in ${mod}`;
6311
6347
  });
6312
6348
  const extra = result.matches.length > OVERFLOW_CAP ? ` \u2026and ${result.matches.length - OVERFLOW_CAP} more` : "";
6313
6349
  return { content: clauses.join(" and ") + extra + ".", miss: false, ambiguous: false, matches: result.matches };
@@ -9589,8 +9625,8 @@ ${bodyText}` : graphText, tier });
9589
9625
  const statedGroup = (payload.objectProperties || []).find((g) => g?.prop === STATED_BY_PROP);
9590
9626
  for (const e of statedGroup?.examples || []) {
9591
9627
  if (!e?.subject) continue;
9592
- const list = statedByBySubject.get(e.subject);
9593
- if (list) list.push(e.object);
9628
+ const list2 = statedByBySubject.get(e.subject);
9629
+ if (list2) list2.push(e.object);
9594
9630
  else statedByBySubject.set(e.subject, [e.object]);
9595
9631
  }
9596
9632
  payload[MEMORY_INDEX] = { individualsById, sourcesById, statedByBySubject };
@@ -9802,9 +9838,9 @@ ${bodyText}` : graphText, tier });
9802
9838
  group.examples.push({ ...edge, createdAt });
9803
9839
  group.count = group.examples.length;
9804
9840
  if (idx) {
9805
- const list = idx.statedByBySubject.get(edge.subject) || [];
9806
- if (!list.includes(edge.object)) list.push(edge.object);
9807
- idx.statedByBySubject.set(edge.subject, list);
9841
+ const list2 = idx.statedByBySubject.get(edge.subject) || [];
9842
+ if (!list2.includes(edge.object)) list2.push(edge.object);
9843
+ idx.statedByBySubject.set(edge.subject, list2);
9808
9844
  }
9809
9845
  }
9810
9846
  function recountClasses(payload) {
@@ -11761,6 +11797,9 @@ ${codeblock}`, options);
11761
11797
  judge: {},
11762
11798
  priest: {},
11763
11799
  servant: {},
11800
+ butler: {},
11801
+ housekeeper: {},
11802
+ gardener: {},
11764
11803
  employee: {},
11765
11804
  boss: {},
11766
11805
  husband: {},
@@ -11815,6 +11854,9 @@ ${codeblock}`, options);
11815
11854
  dress: {},
11816
11855
  clothing: {},
11817
11856
  chair: {},
11857
+ desk: {},
11858
+ lamp: {},
11859
+ portrait: {},
11818
11860
  bed: {},
11819
11861
  door: {},
11820
11862
  window: {},
@@ -21560,6 +21602,361 @@ ${codeblock}`, options);
21560
21602
  }
21561
21603
  });
21562
21604
 
21605
+ // src/domain/grammar/ace.mjs
21606
+ var PATTERN_SUB_CLASS_OF, PATTERN_TYPE_ASSERTION, PATTERN_RELATION, PATTERN_SOME_VALUES_FROM, PATTERN_CARDINALITY, PATTERN_DISJOINT_WITH, PATTERN_POSSESSIVE, PATTERN_ADJECTIVE, PATTERN_CAPABILITY, PATTERNS;
21607
+ var init_ace2 = __esm({
21608
+ "src/domain/grammar/ace.mjs"() {
21609
+ init_lexicon();
21610
+ PATTERN_SUB_CLASS_OF = "subClassOf";
21611
+ PATTERN_TYPE_ASSERTION = "typeAssertion";
21612
+ PATTERN_RELATION = "relation";
21613
+ PATTERN_SOME_VALUES_FROM = "someValuesFrom";
21614
+ PATTERN_CARDINALITY = "cardinality";
21615
+ PATTERN_DISJOINT_WITH = "disjointWith";
21616
+ PATTERN_POSSESSIVE = "possessive";
21617
+ PATTERN_ADJECTIVE = "adjective";
21618
+ PATTERN_CAPABILITY = "capability";
21619
+ PATTERNS = Object.freeze([
21620
+ PATTERN_SUB_CLASS_OF,
21621
+ PATTERN_TYPE_ASSERTION,
21622
+ PATTERN_RELATION,
21623
+ PATTERN_SOME_VALUES_FROM,
21624
+ PATTERN_CARDINALITY,
21625
+ PATTERN_DISJOINT_WITH,
21626
+ PATTERN_POSSESSIVE,
21627
+ PATTERN_ADJECTIVE,
21628
+ PATTERN_CAPABILITY
21629
+ ]);
21630
+ }
21631
+ });
21632
+
21633
+ // src/domain/completions/injected.mjs
21634
+ var init_injected = __esm({
21635
+ "src/domain/completions/injected.mjs"() {
21636
+ }
21637
+ });
21638
+
21639
+ // src/domain/completions/graph-adapter.mjs
21640
+ var init_graph_adapter = __esm({
21641
+ "src/domain/completions/graph-adapter.mjs"() {
21642
+ init_codegraph();
21643
+ init_ask();
21644
+ init_injected();
21645
+ }
21646
+ });
21647
+
21648
+ // src/domain/router/registry.mjs
21649
+ function capability({ name, label, question, params = [], preconditions = [], add = [], del = [] }) {
21650
+ return Object.freeze({
21651
+ type: VOCAB.Capability,
21652
+ name,
21653
+ // the dispatchTool tool name — directly callable
21654
+ label,
21655
+ // human label (the slash-command verb)
21656
+ question,
21657
+ // one-line "what question does this answer"
21658
+ readOnly: true,
21659
+ // dispatching this capability performs no writes
21660
+ parameters: Object.freeze(params),
21661
+ preconditions: Object.freeze(preconditions),
21662
+ effects: Object.freeze({ add: Object.freeze(add), del: Object.freeze(del) })
21663
+ });
21664
+ }
21665
+ var PREFIXES, VOCAB, KINDS, PRECOND, param, graphLoaded, resolves, anyPresent, memoryFacts, knows, CAPABILITIES, buildIndex, list, byName, EXCLUDED_FROM_REGISTRY, REGISTRY;
21666
+ var init_registry = __esm({
21667
+ "src/domain/router/registry.mjs"() {
21668
+ PREFIXES = Object.freeze({
21669
+ cap: "urn:tmct:cap#",
21670
+ // the capability/operator vocabulary (this module)
21671
+ taught: "urn:tmct:taught#",
21672
+ // taught-action operators + their world-state predicates (taught.mjs)
21673
+ mgx: "urn:tmct:mgx#",
21674
+ // tmct's code-graph predicates (imports/calls/tests/…)
21675
+ seon: "http://se-on.org/ontologies/seon.owl#"
21676
+ // software-evolution ontology classes
21677
+ });
21678
+ VOCAB = Object.freeze({
21679
+ Capability: "cap:Capability",
21680
+ // rdf:type of a declared tool/operator
21681
+ Parameter: "cap:Parameter",
21682
+ Precondition: "cap:Precondition",
21683
+ Effect: "cap:Effect"
21684
+ });
21685
+ KINDS = Object.freeze({
21686
+ Symbol: "seon:CodeEntity",
21687
+ // any code symbol: function/method/class/module/attribute
21688
+ Module: "mgx:Module",
21689
+ // SEON has no JS-module class (its nearest are Namespace/main:File); owned
21690
+ Class: "seon:ClassType",
21691
+ // SEON's real class for a class definition
21692
+ Query: "cap:FreeText",
21693
+ // lexical search string — no resolution precondition
21694
+ Kind: "cap:KindFilter",
21695
+ // enum: function|class|method|… (search filter)
21696
+ Package: "cap:PackageName"
21697
+ // optional architecture-scope filter
21698
+ });
21699
+ PRECOND = Object.freeze({
21700
+ graphLoaded: "cap:graph-loaded",
21701
+ // a graph artifact is present + parseable
21702
+ resolves: "cap:resolves",
21703
+ // { param, as } — the slot binds to an entity of kind `as`
21704
+ anyPresent: "cap:any-present",
21705
+ // { params } — at least one of these slots is provided
21706
+ memoryFacts: "cap:memory-facts"
21707
+ // the conversational-memory store holds relation facts for the term
21708
+ });
21709
+ param = (name, kind, { arg = name, required = true, note = "" } = {}) => Object.freeze({ type: VOCAB.Parameter, name, kind, arg, required, note });
21710
+ graphLoaded = () => Object.freeze({ type: VOCAB.Precondition, pred: PRECOND.graphLoaded });
21711
+ resolves = (paramName, as) => Object.freeze({ type: VOCAB.Precondition, pred: PRECOND.resolves, param: paramName, as });
21712
+ anyPresent = (params) => Object.freeze({ type: VOCAB.Precondition, pred: PRECOND.anyPresent, params: Object.freeze([...params]) });
21713
+ memoryFacts = () => Object.freeze({ type: VOCAB.Precondition, pred: PRECOND.memoryFacts });
21714
+ knows = (topic, ofParam = null) => Object.freeze({ type: VOCAB.Effect, pred: "cap:knows", topic, of: ofParam ? `?${ofParam}` : null });
21715
+ CAPABILITIES = Object.freeze([
21716
+ capability({
21717
+ name: "tmct_search",
21718
+ label: "search",
21719
+ question: "lexical search across the graph",
21720
+ params: [
21721
+ param("query", KINDS.Query, { required: false, note: "required unless a kind filter is given" }),
21722
+ param("kind", KINDS.Kind, { required: false }),
21723
+ param("name", KINDS.Query, { required: false }),
21724
+ param("decorator", KINDS.Query, { required: false })
21725
+ ],
21726
+ preconditions: [graphLoaded(), anyPresent(["query", "kind"])],
21727
+ add: [knows("matches", "query")]
21728
+ }),
21729
+ capability({
21730
+ name: "tmct_describe",
21731
+ label: "describe",
21732
+ question: "a symbol's definition, kind and relations",
21733
+ params: [param("symbol", KINDS.Symbol)],
21734
+ preconditions: [graphLoaded(), resolves("symbol", KINDS.Symbol)],
21735
+ add: [knows("description", "symbol")]
21736
+ }),
21737
+ capability({
21738
+ name: "tmct_signature",
21739
+ label: "signature",
21740
+ question: "a symbol's signature only",
21741
+ params: [param("symbol", KINDS.Symbol)],
21742
+ preconditions: [graphLoaded(), resolves("symbol", KINDS.Symbol)],
21743
+ add: [knows("signature", "symbol")]
21744
+ }),
21745
+ capability({
21746
+ name: "tmct_impact",
21747
+ label: "impact",
21748
+ question: "what a change to this module or symbol reaches (impact closure)",
21749
+ params: [param("module", KINDS.Symbol, { note: "a Module, or any sited symbol \u2014 a fine-grained seed walks callsSymbol dependents and coarsens them to module grain" })],
21750
+ preconditions: [graphLoaded(), resolves("module", KINDS.Symbol)],
21751
+ add: [knows("impact", "module")]
21752
+ }),
21753
+ capability({
21754
+ name: "tmct_members",
21755
+ label: "members",
21756
+ question: "the methods/attributes of a class",
21757
+ params: [param("class", KINDS.Class, { arg: "class" })],
21758
+ preconditions: [graphLoaded(), resolves("class", KINDS.Class)],
21759
+ add: [knows("members", "class")]
21760
+ }),
21761
+ capability({
21762
+ name: "tmct_subclasses",
21763
+ label: "subclasses",
21764
+ question: "the subclasses of a class",
21765
+ params: [param("class", KINDS.Class, { arg: "class" })],
21766
+ preconditions: [graphLoaded(), resolves("class", KINDS.Class)],
21767
+ add: [knows("subclasses", "class")]
21768
+ }),
21769
+ capability({
21770
+ name: "tmct_exports",
21771
+ label: "exports",
21772
+ question: "a module's public exports",
21773
+ params: [param("module", KINDS.Module)],
21774
+ preconditions: [graphLoaded(), resolves("module", KINDS.Module)],
21775
+ add: [knows("exports", "module")]
21776
+ }),
21777
+ capability({
21778
+ name: "tmct_callers",
21779
+ label: "callers",
21780
+ question: "functions that call this symbol",
21781
+ params: [param("symbol", KINDS.Symbol)],
21782
+ preconditions: [graphLoaded(), resolves("symbol", KINDS.Symbol)],
21783
+ add: [knows("callers", "symbol")]
21784
+ }),
21785
+ capability({
21786
+ name: "tmct_callees",
21787
+ label: "callees",
21788
+ question: "functions this symbol calls",
21789
+ params: [param("symbol", KINDS.Symbol)],
21790
+ preconditions: [graphLoaded(), resolves("symbol", KINDS.Symbol)],
21791
+ add: [knows("callees", "symbol")]
21792
+ }),
21793
+ capability({
21794
+ name: "tmct_calls",
21795
+ label: "calls",
21796
+ question: "the call edges out of this symbol/module",
21797
+ params: [param("symbol", KINDS.Symbol)],
21798
+ preconditions: [graphLoaded(), resolves("symbol", KINDS.Symbol)],
21799
+ add: [knows("calls", "symbol")]
21800
+ }),
21801
+ capability({
21802
+ name: "tmct_tests_for",
21803
+ label: "tests",
21804
+ question: "the tests covering this symbol",
21805
+ params: [param("symbol", KINDS.Symbol)],
21806
+ preconditions: [graphLoaded(), resolves("symbol", KINDS.Symbol)],
21807
+ add: [knows("tests", "symbol")]
21808
+ }),
21809
+ capability({
21810
+ name: "tmct_untested",
21811
+ label: "untested",
21812
+ question: "symbols with no covering test",
21813
+ params: [],
21814
+ preconditions: [graphLoaded()],
21815
+ add: [knows("untested", null)]
21816
+ }),
21817
+ capability({
21818
+ name: "tmct_history",
21819
+ label: "history",
21820
+ question: "the commit history of this symbol",
21821
+ params: [param("symbol", KINDS.Symbol)],
21822
+ preconditions: [graphLoaded(), resolves("symbol", KINDS.Symbol)],
21823
+ add: [knows("history", "symbol")]
21824
+ }),
21825
+ capability({
21826
+ name: "tmct_cochanges",
21827
+ label: "cochanges",
21828
+ question: "symbols that change together with this one",
21829
+ params: [param("symbol", KINDS.Symbol)],
21830
+ preconditions: [graphLoaded(), resolves("symbol", KINDS.Symbol)],
21831
+ add: [knows("cochanges", "symbol")]
21832
+ }),
21833
+ capability({
21834
+ name: "tmct_architecture",
21835
+ label: "arch",
21836
+ question: "the architecture overview (optional package filter)",
21837
+ params: [param("package", KINDS.Package, { required: false })],
21838
+ preconditions: [graphLoaded()],
21839
+ add: [knows("architecture", "package")]
21840
+ }),
21841
+ capability({
21842
+ name: "tmct_related",
21843
+ label: "related",
21844
+ question: "a term's synonyms and related concepts (the SKOS view over the conversational-memory graph)",
21845
+ params: [param("term", KINDS.Query, { note: "a concept term, matched against memory relation facts rather than resolved in the code graph" })],
21846
+ preconditions: [memoryFacts()],
21847
+ add: [knows("related", "term")]
21848
+ })
21849
+ ]);
21850
+ buildIndex = (caps) => Object.freeze(
21851
+ caps.reduce((m, c) => {
21852
+ m[c.name] = c;
21853
+ return m;
21854
+ }, /* @__PURE__ */ Object.create(null))
21855
+ );
21856
+ list = CAPABILITIES;
21857
+ byName = buildIndex(list);
21858
+ EXCLUDED_FROM_REGISTRY = Object.freeze({
21859
+ tmct_context: "unbounded edit-context bundle (multi-file); needs a size/budget precondition",
21860
+ tmct_context_more: "unbounded context continuation; same as tmct_context",
21861
+ tmct_snippet: "raw source-file read (reads the filesystem); needs a file-read + span precondition"
21862
+ });
21863
+ REGISTRY = Object.freeze({
21864
+ prefixes: PREFIXES,
21865
+ vocab: VOCAB,
21866
+ kinds: KINDS,
21867
+ precond: PRECOND,
21868
+ get capabilities() {
21869
+ return list;
21870
+ }
21871
+ });
21872
+ }
21873
+ });
21874
+
21875
+ // src/domain/router/taught.mjs
21876
+ var init_taught = __esm({
21877
+ "src/domain/router/taught.mjs"() {
21878
+ init_registry();
21879
+ }
21880
+ });
21881
+
21882
+ // src/adapters/memory/blocks.mjs
21883
+ var BLOCKS_DIR_REL;
21884
+ var init_blocks = __esm({
21885
+ "src/adapters/memory/blocks.mjs"() {
21886
+ init_promises();
21887
+ init_node_path();
21888
+ init_prose();
21889
+ init_text_stats();
21890
+ init_trust();
21891
+ BLOCKS_DIR_REL = join(".tmct", "memory", "blocks");
21892
+ }
21893
+ });
21894
+
21895
+ // src/domain/completions/search.mjs
21896
+ var init_search = __esm({
21897
+ "src/domain/completions/search.mjs"() {
21898
+ init_injected();
21899
+ }
21900
+ });
21901
+
21902
+ // src/domain/completions/group.mjs
21903
+ var init_group = __esm({
21904
+ "src/domain/completions/group.mjs"() {
21905
+ init_prose();
21906
+ init_text_stats();
21907
+ init_injected();
21908
+ }
21909
+ });
21910
+
21911
+ // src/domain/completions/rank.mjs
21912
+ var init_rank = __esm({
21913
+ "src/domain/completions/rank.mjs"() {
21914
+ init_prose();
21915
+ init_text_stats();
21916
+ init_injected();
21917
+ }
21918
+ });
21919
+
21920
+ // src/domain/completions/infer.mjs
21921
+ var init_infer = __esm({
21922
+ "src/domain/completions/infer.mjs"() {
21923
+ init_rank();
21924
+ init_prose();
21925
+ init_planning();
21926
+ init_injected();
21927
+ }
21928
+ });
21929
+
21930
+ // src/domain/completions/prune.mjs
21931
+ var init_prune = __esm({
21932
+ "src/domain/completions/prune.mjs"() {
21933
+ }
21934
+ });
21935
+
21936
+ // src/domain/completions/complete.mjs
21937
+ var init_complete = __esm({
21938
+ "src/domain/completions/complete.mjs"() {
21939
+ init_search();
21940
+ init_group();
21941
+ init_rank();
21942
+ init_infer();
21943
+ init_prune();
21944
+ init_injected();
21945
+ }
21946
+ });
21947
+
21948
+ // src/services/completions.mjs
21949
+ var init_completions = __esm({
21950
+ "src/services/completions.mjs"() {
21951
+ init_blocks();
21952
+ init_core();
21953
+ init_graph_service();
21954
+ init_finish();
21955
+ init_complete();
21956
+ init_graph_adapter();
21957
+ }
21958
+ });
21959
+
21563
21960
  // src/adapters/toml-config.mjs
21564
21961
  var init_toml_config = __esm({
21565
21962
  "src/adapters/toml-config.mjs"() {
@@ -21616,7 +22013,7 @@ ${codeblock}`, options);
21616
22013
  });
21617
22014
 
21618
22015
  // src/adapters/corpus/conceptnet.mjs
21619
- var import_meta5, PKG_ROOT3, SLICE_FILE, MAP_FILE, SEON_CONCEPTS_FILE, SEON_DEFINITIONS_FILE, TIER2_DIR, TIER2_MANIFEST_FILE, WORDNET_DIR, WORDNET_MANIFEST_FILE;
22016
+ var import_meta6, PKG_ROOT4, SLICE_FILE, MAP_FILE, SEON_CONCEPTS_FILE, SEON_DEFINITIONS_FILE, TIER2_DIR, TIER2_MANIFEST_FILE, WORDNET_DIR, WORDNET_MANIFEST_FILE;
21620
22017
  var init_conceptnet = __esm({
21621
22018
  "src/adapters/corpus/conceptnet.mjs"() {
21622
22019
  init_node_fs();
@@ -21626,15 +22023,15 @@ ${codeblock}`, options);
21626
22023
  init_node_path();
21627
22024
  init_dist();
21628
22025
  init_core();
21629
- import_meta5 = {};
21630
- PKG_ROOT3 = join(dirname(fileURLToPath2(import_meta5.url)), "..", "..", "..");
21631
- SLICE_FILE = join(PKG_ROOT3, "corpus", "conceptnet", "slice.jsonl");
21632
- MAP_FILE = join(PKG_ROOT3, "src", "adapters", "corpus", "conceptnet-map.toml");
21633
- SEON_CONCEPTS_FILE = join(PKG_ROOT3, "corpus", "seon", "concepts.jsonl");
21634
- SEON_DEFINITIONS_FILE = join(PKG_ROOT3, "corpus", "seon", "definitions.jsonl");
21635
- TIER2_DIR = join(PKG_ROOT3, "corpus", "tier2");
22026
+ import_meta6 = {};
22027
+ PKG_ROOT4 = join(dirname(fileURLToPath2(import_meta6.url)), "..", "..", "..");
22028
+ SLICE_FILE = join(PKG_ROOT4, "corpus", "conceptnet", "slice.jsonl");
22029
+ MAP_FILE = join(PKG_ROOT4, "src", "adapters", "corpus", "conceptnet-map.toml");
22030
+ SEON_CONCEPTS_FILE = join(PKG_ROOT4, "corpus", "seon", "concepts.jsonl");
22031
+ SEON_DEFINITIONS_FILE = join(PKG_ROOT4, "corpus", "seon", "definitions.jsonl");
22032
+ TIER2_DIR = join(PKG_ROOT4, "corpus", "tier2");
21636
22033
  TIER2_MANIFEST_FILE = join(TIER2_DIR, "manifest.json");
21637
- WORDNET_DIR = join(PKG_ROOT3, "corpus", "wordnet");
22034
+ WORDNET_DIR = join(PKG_ROOT4, "corpus", "wordnet");
21638
22035
  WORDNET_MANIFEST_FILE = join(WORDNET_DIR, "manifest.json");
21639
22036
  }
21640
22037
  });
@@ -21728,7 +22125,7 @@ ${codeblock}`, options);
21728
22125
  }
21729
22126
  };
21730
22127
  }
21731
- var import_meta6, NAMENET_DIR, EXTENSION_KINDS, CONCEPTNET_PREFER, BUILTIN_EXTENSIONS;
22128
+ var import_meta7, NAMENET_DIR, EXTENSION_KINDS, CONCEPTNET_PREFER, BUILTIN_EXTENSIONS;
21732
22129
  var init_extensions = __esm({
21733
22130
  "src/services/extensions.mjs"() {
21734
22131
  init_node_path();
@@ -21736,8 +22133,8 @@ ${codeblock}`, options);
21736
22133
  init_node_url();
21737
22134
  init_toml_config();
21738
22135
  init_conceptnet();
21739
- import_meta6 = {};
21740
- NAMENET_DIR = join(dirname(fileURLToPath2(import_meta6.url)), "..", "..", "corpus", "namenet");
22136
+ import_meta7 = {};
22137
+ NAMENET_DIR = join(dirname(fileURLToPath2(import_meta7.url)), "..", "..", "corpus", "namenet");
21741
22138
  EXTENSION_KINDS = Object.freeze(["corpus", "lexicon", "templates", "pack", "ontology"]);
21742
22139
  CONCEPTNET_PREFER = ["rdfs:subClassOf", "rdf:type", "mgx:usedFor", "mgx:partOf", "mgx:capableOf"];
21743
22140
  BUILTIN_EXTENSIONS = Object.freeze(builtinExtensions());
@@ -22075,12 +22472,12 @@ ${codeblock}`, options);
22075
22472
  return s;
22076
22473
  }
22077
22474
  function mergeEntityPayloads(entries) {
22078
- const list = (Array.isArray(entries) ? entries : []).map((e, i) => ({
22475
+ const list2 = (Array.isArray(entries) ? entries : []).map((e, i) => ({
22079
22476
  file: e?.file,
22080
22477
  payload: e?.payload || {},
22081
22478
  name: e?.name != null && String(e.name).length ? String(e.name) : String(i)
22082
22479
  }));
22083
- const idSets = list.map(({ payload }) => idsOf(payload));
22480
+ const idSets = list2.map(({ payload }) => idsOf(payload));
22084
22481
  const seenInCount = /* @__PURE__ */ new Map();
22085
22482
  for (const s of idSets) for (const id of s) seenInCount.set(id, (seenInCount.get(id) || 0) + 1);
22086
22483
  const colliding = new Set([...seenInCount.entries()].filter(([, n]) => n > 1).map(([id]) => id));
@@ -22093,8 +22490,8 @@ ${codeblock}`, options);
22093
22490
  proseIndex: {}
22094
22491
  };
22095
22492
  let latestGeneratedAt = "";
22096
- let everyPayloadIsBootstrap = list.length > 0;
22097
- for (const { payload, name } of list) {
22493
+ let everyPayloadIsBootstrap = list2.length > 0;
22494
+ for (const { payload, name } of list2) {
22098
22495
  everyPayloadIsBootstrap = everyPayloadIsBootstrap && Boolean(payload.bootstrap);
22099
22496
  if (typeof payload.generated_at === "string" && payload.generated_at > latestGeneratedAt) {
22100
22497
  latestGeneratedAt = payload.generated_at;
@@ -22797,8 +23194,8 @@ ${JSON.stringify(envelope, null, 2)}`;
22797
23194
  return Math.max(...ids.map((id) => biasForSourceId(id, biasByBundle)));
22798
23195
  }
22799
23196
  function rankByBiasThenTrust(rows, biasByBundle = {}) {
22800
- const list = Array.isArray(rows) ? rows : [];
22801
- return list.map((row, index) => ({ row, index, bias: biasForRow(row, biasByBundle) })).sort((a, b) => b.bias - a.bias || (b.row?.trust ?? 0) - (a.row?.trust ?? 0) || a.index - b.index).map((x) => x.row);
23197
+ const list2 = Array.isArray(rows) ? rows : [];
23198
+ return list2.map((row, index) => ({ row, index, bias: biasForRow(row, biasByBundle) })).sort((a, b) => b.bias - a.bias || (b.row?.trust ?? 0) - (a.row?.trust ?? 0) || a.index - b.index).map((x) => x.row);
22802
23199
  }
22803
23200
 
22804
23201
  // src/services/chat.mjs
@@ -22824,6 +23221,13 @@ ${JSON.stringify(envelope, null, 2)}`;
22824
23221
 
22825
23222
  // src/adapters/corpus/reference-pack.mjs
22826
23223
  init_node_fs();
23224
+
23225
+ // node-zlib-stub:node:zlib
23226
+ var gunzipSync = () => {
23227
+ throw new Error("gunzipSync unavailable in a browser bundle");
23228
+ };
23229
+
23230
+ // src/adapters/corpus/reference-pack.mjs
22827
23231
  init_node_url();
22828
23232
  init_node_path();
22829
23233
  var import_meta4 = {};
@@ -22945,6 +23349,119 @@ ${JSON.stringify(envelope, null, 2)}`;
22945
23349
  "game-inform": "inform"
22946
23350
  });
22947
23351
 
23352
+ // src/domain/worlds-pack.mjs
23353
+ var WORLD_NAME_RE = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;
23354
+ var WORLD_RULE_KINDS = Object.freeze([
23355
+ "action-signature",
23356
+ "action-precond",
23357
+ "action-effect",
23358
+ "action-constraint"
23359
+ ]);
23360
+ var RULE_KIND_SET = new Set(WORLD_RULE_KINDS);
23361
+ var isNonEmptyString = (v) => typeof v === "string" && v.trim() !== "";
23362
+ function isWorldName(name) {
23363
+ return typeof name === "string" && WORLD_NAME_RE.test(name);
23364
+ }
23365
+ function isWorldsIndexEntry(e) {
23366
+ return !!e && typeof e === "object" && isNonEmptyString(e.s);
23367
+ }
23368
+ function isWorldFactRow(row) {
23369
+ return !!row && typeof row === "object" && row.kind === "fact" && isWorldName(row.world) && isNonEmptyString(row.subject) && isNonEmptyString(row.predicate) && isNonEmptyString(row.object);
23370
+ }
23371
+ function isWorldRuleRow(row) {
23372
+ if (!row || typeof row !== "object" || row.kind !== "rule") return false;
23373
+ if (!isWorldName(row.world) || !isNonEmptyString(row.name)) return false;
23374
+ if (!RULE_KIND_SET.has(row.ruleKind)) return false;
23375
+ if (!row.slots || typeof row.slots !== "object" || Array.isArray(row.slots)) return false;
23376
+ const values = Object.values(row.slots);
23377
+ return values.length > 0 && values.every(isNonEmptyString);
23378
+ }
23379
+ function isWorldMetaRow(row) {
23380
+ return !!row && typeof row === "object" && row.kind === "meta" && isWorldName(row.world) && isNonEmptyString(row.opening);
23381
+ }
23382
+ function isWorldRow(row) {
23383
+ return isWorldFactRow(row) || isWorldRuleRow(row) || isWorldMetaRow(row);
23384
+ }
23385
+
23386
+ // src/services/adventure.mjs
23387
+ init_ace2();
23388
+ init_graph_adapter();
23389
+ init_taught();
23390
+
23391
+ // src/adapters/corpus/worlds-pack.mjs
23392
+ init_node_fs();
23393
+ init_node_url();
23394
+ init_node_path();
23395
+ var import_meta5 = {};
23396
+ var PKG_ROOT3 = join(dirname(fileURLToPath2(import_meta5.url)), "..", "..", "..");
23397
+ function worldsPackDir(env = process.env) {
23398
+ return env?.TMCT_WORLDS_PACK_DIR || join(PKG_ROOT3, "corpus", "worlds");
23399
+ }
23400
+ var indexCacheByDir = /* @__PURE__ */ new Map();
23401
+ var worldCacheByKey = /* @__PURE__ */ new Map();
23402
+ function readGunzipped(file) {
23403
+ try {
23404
+ return gunzipSync(readFileSync6(file));
23405
+ } catch {
23406
+ return null;
23407
+ }
23408
+ }
23409
+ function loadWorldsIndex(dir) {
23410
+ if (indexCacheByDir.has(dir)) return indexCacheByDir.get(dir);
23411
+ let index = null;
23412
+ const body = readGunzipped(join(dir, "index.json.gz"));
23413
+ if (body) {
23414
+ try {
23415
+ const parsed = JSON.parse(body.toString("utf8"));
23416
+ if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) index = parsed;
23417
+ } catch {
23418
+ }
23419
+ }
23420
+ indexCacheByDir.set(dir, index);
23421
+ return index;
23422
+ }
23423
+ function loadWorld(dir, worldName) {
23424
+ const index = loadWorldsIndex(dir);
23425
+ if (!index) return null;
23426
+ const entry = index[String(worldName ?? "")];
23427
+ if (!isWorldsIndexEntry(entry)) return null;
23428
+ const key = `${dir}\0${worldName}`;
23429
+ if (worldCacheByKey.has(key)) return worldCacheByKey.get(key);
23430
+ let payload = null;
23431
+ const body = readGunzipped(join(dir, "shards", `${entry.s}.jsonl.gz`));
23432
+ if (body) {
23433
+ const facts = [];
23434
+ const rules = [];
23435
+ let meta = null;
23436
+ for (const line of body.toString("utf8").split("\n")) {
23437
+ if (!line.trim()) continue;
23438
+ try {
23439
+ const row = JSON.parse(line);
23440
+ if (!isWorldRow(row) || row.world !== worldName) continue;
23441
+ if (isWorldFactRow(row)) facts.push(row);
23442
+ else if (isWorldRuleRow(row)) rules.push(row);
23443
+ else if (isWorldMetaRow(row) && !meta) meta = row;
23444
+ } catch {
23445
+ }
23446
+ }
23447
+ if (facts.length || rules.length || meta) payload = { name: worldName, facts, rules, meta };
23448
+ }
23449
+ worldCacheByKey.set(key, payload);
23450
+ return payload;
23451
+ }
23452
+ var fsProviderFor = (dirOf) => ({
23453
+ list: async () => {
23454
+ const index = loadWorldsIndex(dirOf());
23455
+ return index ? Object.keys(index).sort() : null;
23456
+ },
23457
+ load: async (worldName) => loadWorld(dirOf(), worldName)
23458
+ });
23459
+ var fsProvider = fsProviderFor(() => worldsPackDir());
23460
+
23461
+ // src/services/adventure.mjs
23462
+ init_core();
23463
+ init_completions();
23464
+
22948
23465
  // src/services/chat-session.mjs
22949
23466
  init_node_path();
22950
23467
  init_node_fs();
@@ -23094,7 +23611,7 @@ ${JSON.stringify(envelope, null, 2)}`;
23094
23611
  signature: { tool: "tmct_signature", arg: "symbol", help: "a symbol's signature only" },
23095
23612
  members: { tool: "tmct_members", arg: "class", help: "the methods/attributes of a class" },
23096
23613
  subclasses: { tool: "tmct_subclasses", arg: "class", help: "the subclasses of a class" },
23097
- impact: { tool: "tmct_impact", arg: "module", help: "what a change to this module reaches (impact closure)" },
23614
+ impact: { tool: "tmct_impact", arg: "module", help: "what a change to this module or symbol reaches (impact closure)" },
23098
23615
  callers: { tool: "tmct_callers", arg: "symbol", help: "functions that call this symbol" },
23099
23616
  callees: { tool: "tmct_callees", arg: "symbol", help: "functions this symbol calls" },
23100
23617
  tests: { tool: "tmct_tests_for", arg: "symbol", help: "the tests covering this symbol" },
@@ -23391,8 +23908,25 @@ ${JSON.stringify(envelope, null, 2)}`;
23391
23908
  }
23392
23909
  return { predicate, object: String(objectRaw || "").trim() };
23393
23910
  }
23394
- var TEACH_PRONOUNS = Object.freeze(["you", "i", "it", "they", "he", "she", "we"]);
23911
+ var TEACH_PRONOUNS = Object.freeze([
23912
+ "you're",
23913
+ "i'm",
23914
+ "it's",
23915
+ "they're",
23916
+ "he's",
23917
+ "she's",
23918
+ "we're",
23919
+ "you",
23920
+ "i",
23921
+ "it",
23922
+ "they",
23923
+ "he",
23924
+ "she",
23925
+ "we"
23926
+ ]);
23395
23927
  var TEACH_PRONOUN_RE = new RegExp(`^(?:every\\s+|each\\s+|all\\s+|some\\s+|a few\\s+|a\\s+|an\\s+)?(${TEACH_PRONOUNS.join("|")})\\s+\\S+`, "i");
23928
+ var BOARD_TEACH_LOCATIVE_RE = new RegExp(`^([\\w-]+)\\s+([a-z]+)s\\s+(${PREP_SRC})\\s+([\\w-]+)$`, "i");
23929
+ var RETRACT_FORGET_LOCATIVE_RE = new RegExp(`^forget\\s+(?:that\\s+)?([\\w-]+)\\s+([a-z]+)s\\s+(${PREP_SRC})\\s+([\\w-]+)$`, "i");
23396
23930
  var TRAILING_ADVERB_RE = "(?:\\s+(?:exactly|really|actually|anyway))?";
23397
23931
  var MODULE_ORIENT_RE = new RegExp(`^what\\s+does\\s+(.+?)\\s+do${TRAILING_ADVERB_RE}\\??$`, "i");
23398
23932
  var MODULE_ORIENT_SVO_RE = new RegExp(`^what\\s+(.+?)\\s+does${TRAILING_ADVERB_RE}\\??$`, "i");
@@ -23520,6 +24054,7 @@ ${JSON.stringify(envelope, null, 2)}`;
23520
24054
  if (f.provenance.includes("ace:chat") || f.provenance.includes("teach:chat")) return `you told me: ${factPhrase(f)}${cite}`;
23521
24055
  if (f.provenance.includes("corpus-weak:")) return `possibly: ${factPhrase(f)}${cite}`;
23522
24056
  if (f.provenance.includes("corpus:")) return `${factPhrase(f)}${cite}`;
24057
+ if (f.provenance.includes("reference:")) return `${factPhrase(f)}${cite}`;
23523
24058
  return `i learned: ${factPhrase(f)}${cite}`;
23524
24059
  }
23525
24060
  function indefiniteArticleFor(term) {
@@ -23550,7 +24085,7 @@ ${JSON.stringify(envelope, null, 2)}`;
23550
24085
  const last = premises[premises.length - 1];
23551
24086
  return `${premises.map(step).join("; ")}; so ${first.subject} is a ${last.object}`;
23552
24087
  }
23553
- async function memoryFacts(memoryDir) {
24088
+ async function memoryFacts2(memoryDir) {
23554
24089
  try {
23555
24090
  const { loadMemory: loadMemory2 } = await Promise.resolve().then(() => (init_core(), core_exports));
23556
24091
  const m = await loadMemory2(memoryDir);
@@ -24035,7 +24570,7 @@ ${shown.map(renderFactLine).join("\n")}`,
24035
24570
  if (compAsk) {
24036
24571
  const compWord = compAsk[2].toLowerCase().replace(/\s+/g, "-");
24037
24572
  const compPredicate = `mgx:${compWord}-than`;
24038
- const facts = await memoryFacts(memoryDir);
24573
+ const facts = await memoryFacts2(memoryDir);
24039
24574
  const compTerm = (raw) => {
24040
24575
  const t = raw.replace(/^(?:an?|the)\s+/i, "").trim();
24041
24576
  return focusLabel && IS_ADJECTIVE_PRONOUN_RE.test(t) ? focusLabel : t;
@@ -24057,7 +24592,7 @@ ${shown.map(renderFactLine).join("\n")}`,
24057
24592
  for (const { predicate, phrase, re } of FORWARD_YESNO_MARKERS) {
24058
24593
  const m = q.match(re);
24059
24594
  if (!m) continue;
24060
- const facts = await memoryFacts(memoryDir);
24595
+ const facts = await memoryFacts2(memoryDir);
24061
24596
  const subj = factTermVariants(normFactTerm2, m[1]);
24062
24597
  const obj = factTermVariants(normFactTerm2, m[2]);
24063
24598
  const hit2 = facts.find((f) => f.predicate === predicate && subj.has(f.subject) && obj.has(f.object));
@@ -24119,18 +24654,25 @@ ${shown.map(renderFactLine).join("\n")}`,
24119
24654
  const subj = factTermVariants(normFactTerm2, doesHave[1]);
24120
24655
  const obj = factTermVariants(normFactTerm2, doesHave[2]);
24121
24656
  const HAS_PREDICATES = /* @__PURE__ */ new Set(["mgx:hasA", "tmct:has"]);
24122
- const facts = await memoryFacts(memoryDir);
24657
+ const facts = await memoryFacts2(memoryDir);
24123
24658
  const hasHit = (subjectSet) => facts.find(
24124
24659
  (f) => HAS_PREDICATES.has(f.predicate) && subjectSet.has(f.subject) && obj.has(f.object)
24125
24660
  );
24126
24661
  const hit2 = hasHit(subj);
24127
24662
  if (hit2) return { text: `yes \u2014 ${renderFactLine(hit2)}`, replace: true };
24128
- const isaStep = facts.find((f) => ISA_PREDICATES2.has(f.predicate) && subj.has(f.subject));
24129
- if (isaStep) {
24130
- const lifted = hasHit(factTermVariants(normFactTerm2, isaStep.object));
24663
+ let liftFrontier = subj;
24664
+ const liftChain = [];
24665
+ const liftSeen = /* @__PURE__ */ new Set();
24666
+ for (let hop = 0; hop < 4; hop += 1) {
24667
+ const step = facts.find((f) => ISA_PREDICATES2.has(f.predicate) && liftFrontier.has(f.subject) && !liftSeen.has(f.object));
24668
+ if (!step) break;
24669
+ liftSeen.add(step.object);
24670
+ liftChain.push(step);
24671
+ const lifted = hasHit(factTermVariants(normFactTerm2, step.object));
24131
24672
  if (lifted) {
24132
- return { text: `yes \u2014 ${renderFactLine(isaStep)}; ${renderFactLine(lifted)}`, replace: true };
24673
+ return { text: `yes \u2014 ${[...liftChain.map(renderFactLine), renderFactLine(lifted)].join("; ")}`, replace: true };
24133
24674
  }
24675
+ liftFrontier = factTermVariants(normFactTerm2, step.object);
24134
24676
  }
24135
24677
  return null;
24136
24678
  }
@@ -24390,6 +24932,14 @@ ${shown.join("\n")}${extra}`, replace: true, ...rest.length ? { pending: { items
24390
24932
  const directObjVariants = factTermVariants(normFactTerm2, stripTrailingDiscourseTag(directIsaAsk[2]));
24391
24933
  const directSup = inheritsChain(graph, ent.id).find((sup) => [...factTermVariants(normFactTerm2, sup.label)].some((v) => directObjVariants.has(v)));
24392
24934
  if (directSup) return { text: `yes \u2014 the code graph says ${ent.label} inherits ${directSup.label}.`, replace: true };
24935
+ const objEnt = await resolveEntity(graph, stripTrailingDiscourseTag(directIsaAsk[2]));
24936
+ if (objEnt && inheritsChain(graph, objEnt.id).some((sup) => sup.id === ent.id)) {
24937
+ return {
24938
+ text: `I can't confirm that \u2014 the code graph's stored direction runs the other way: ${objEnt.label} inherits ${ent.label}. An inheritance doesn't reverse.`,
24939
+ replace: true,
24940
+ miss: true
24941
+ };
24942
+ }
24393
24943
  }
24394
24944
  }
24395
24945
  }