@polycode-projects/the-mechanical-code-talker 2.6.1 → 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 (56) 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/package.json +4 -1
  46. package/src/adapters/corpus/child-pack.mjs +115 -0
  47. package/src/adapters/corpus/conceptnet-map.toml +7 -0
  48. package/src/adapters/corpus/worlds-pack.mjs +122 -0
  49. package/src/domain/child-pack.mjs +79 -0
  50. package/src/domain/grammar/ace.mjs +77 -0
  51. package/src/domain/grammar/lexicon-core.json +6 -0
  52. package/src/domain/memory/trust.mjs +8 -0
  53. package/src/domain/worlds-pack.mjs +71 -0
  54. package/src/services/adventure.mjs +669 -0
  55. package/src/services/chat.mjs +26 -0
  56. package/src/surfaces/web/memory-ask-browser.bundle.js +521 -39
@@ -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();
@@ -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;
@@ -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 };
@@ -6341,8 +6342,8 @@ ${branches.map((b, i) => `${i + 1}) ${b.candidate.label}: ${b.rendered.content}`
6341
6342
  byModule.get(mod).push(symbolLabelOf(m));
6342
6343
  }
6343
6344
  const clauses = [...byModule.entries()].map(([mod, syms], i) => {
6344
- const list = listJoin(syms);
6345
- 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}`;
6346
6347
  });
6347
6348
  const extra = result.matches.length > OVERFLOW_CAP ? ` \u2026and ${result.matches.length - OVERFLOW_CAP} more` : "";
6348
6349
  return { content: clauses.join(" and ") + extra + ".", miss: false, ambiguous: false, matches: result.matches };
@@ -9624,8 +9625,8 @@ ${bodyText}` : graphText, tier });
9624
9625
  const statedGroup = (payload.objectProperties || []).find((g) => g?.prop === STATED_BY_PROP);
9625
9626
  for (const e of statedGroup?.examples || []) {
9626
9627
  if (!e?.subject) continue;
9627
- const list = statedByBySubject.get(e.subject);
9628
- if (list) list.push(e.object);
9628
+ const list2 = statedByBySubject.get(e.subject);
9629
+ if (list2) list2.push(e.object);
9629
9630
  else statedByBySubject.set(e.subject, [e.object]);
9630
9631
  }
9631
9632
  payload[MEMORY_INDEX] = { individualsById, sourcesById, statedByBySubject };
@@ -9837,9 +9838,9 @@ ${bodyText}` : graphText, tier });
9837
9838
  group.examples.push({ ...edge, createdAt });
9838
9839
  group.count = group.examples.length;
9839
9840
  if (idx) {
9840
- const list = idx.statedByBySubject.get(edge.subject) || [];
9841
- if (!list.includes(edge.object)) list.push(edge.object);
9842
- 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);
9843
9844
  }
9844
9845
  }
9845
9846
  function recountClasses(payload) {
@@ -11796,6 +11797,9 @@ ${codeblock}`, options);
11796
11797
  judge: {},
11797
11798
  priest: {},
11798
11799
  servant: {},
11800
+ butler: {},
11801
+ housekeeper: {},
11802
+ gardener: {},
11799
11803
  employee: {},
11800
11804
  boss: {},
11801
11805
  husband: {},
@@ -11850,6 +11854,9 @@ ${codeblock}`, options);
11850
11854
  dress: {},
11851
11855
  clothing: {},
11852
11856
  chair: {},
11857
+ desk: {},
11858
+ lamp: {},
11859
+ portrait: {},
11853
11860
  bed: {},
11854
11861
  door: {},
11855
11862
  window: {},
@@ -21595,6 +21602,361 @@ ${codeblock}`, options);
21595
21602
  }
21596
21603
  });
21597
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
+
21598
21960
  // src/adapters/toml-config.mjs
21599
21961
  var init_toml_config = __esm({
21600
21962
  "src/adapters/toml-config.mjs"() {
@@ -21651,7 +22013,7 @@ ${codeblock}`, options);
21651
22013
  });
21652
22014
 
21653
22015
  // src/adapters/corpus/conceptnet.mjs
21654
- 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;
21655
22017
  var init_conceptnet = __esm({
21656
22018
  "src/adapters/corpus/conceptnet.mjs"() {
21657
22019
  init_node_fs();
@@ -21661,15 +22023,15 @@ ${codeblock}`, options);
21661
22023
  init_node_path();
21662
22024
  init_dist();
21663
22025
  init_core();
21664
- import_meta5 = {};
21665
- PKG_ROOT3 = join(dirname(fileURLToPath2(import_meta5.url)), "..", "..", "..");
21666
- SLICE_FILE = join(PKG_ROOT3, "corpus", "conceptnet", "slice.jsonl");
21667
- MAP_FILE = join(PKG_ROOT3, "src", "adapters", "corpus", "conceptnet-map.toml");
21668
- SEON_CONCEPTS_FILE = join(PKG_ROOT3, "corpus", "seon", "concepts.jsonl");
21669
- SEON_DEFINITIONS_FILE = join(PKG_ROOT3, "corpus", "seon", "definitions.jsonl");
21670
- 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");
21671
22033
  TIER2_MANIFEST_FILE = join(TIER2_DIR, "manifest.json");
21672
- WORDNET_DIR = join(PKG_ROOT3, "corpus", "wordnet");
22034
+ WORDNET_DIR = join(PKG_ROOT4, "corpus", "wordnet");
21673
22035
  WORDNET_MANIFEST_FILE = join(WORDNET_DIR, "manifest.json");
21674
22036
  }
21675
22037
  });
@@ -21763,7 +22125,7 @@ ${codeblock}`, options);
21763
22125
  }
21764
22126
  };
21765
22127
  }
21766
- var import_meta6, NAMENET_DIR, EXTENSION_KINDS, CONCEPTNET_PREFER, BUILTIN_EXTENSIONS;
22128
+ var import_meta7, NAMENET_DIR, EXTENSION_KINDS, CONCEPTNET_PREFER, BUILTIN_EXTENSIONS;
21767
22129
  var init_extensions = __esm({
21768
22130
  "src/services/extensions.mjs"() {
21769
22131
  init_node_path();
@@ -21771,8 +22133,8 @@ ${codeblock}`, options);
21771
22133
  init_node_url();
21772
22134
  init_toml_config();
21773
22135
  init_conceptnet();
21774
- import_meta6 = {};
21775
- NAMENET_DIR = join(dirname(fileURLToPath2(import_meta6.url)), "..", "..", "corpus", "namenet");
22136
+ import_meta7 = {};
22137
+ NAMENET_DIR = join(dirname(fileURLToPath2(import_meta7.url)), "..", "..", "corpus", "namenet");
21776
22138
  EXTENSION_KINDS = Object.freeze(["corpus", "lexicon", "templates", "pack", "ontology"]);
21777
22139
  CONCEPTNET_PREFER = ["rdfs:subClassOf", "rdf:type", "mgx:usedFor", "mgx:partOf", "mgx:capableOf"];
21778
22140
  BUILTIN_EXTENSIONS = Object.freeze(builtinExtensions());
@@ -22110,12 +22472,12 @@ ${codeblock}`, options);
22110
22472
  return s;
22111
22473
  }
22112
22474
  function mergeEntityPayloads(entries) {
22113
- const list = (Array.isArray(entries) ? entries : []).map((e, i) => ({
22475
+ const list2 = (Array.isArray(entries) ? entries : []).map((e, i) => ({
22114
22476
  file: e?.file,
22115
22477
  payload: e?.payload || {},
22116
22478
  name: e?.name != null && String(e.name).length ? String(e.name) : String(i)
22117
22479
  }));
22118
- const idSets = list.map(({ payload }) => idsOf(payload));
22480
+ const idSets = list2.map(({ payload }) => idsOf(payload));
22119
22481
  const seenInCount = /* @__PURE__ */ new Map();
22120
22482
  for (const s of idSets) for (const id of s) seenInCount.set(id, (seenInCount.get(id) || 0) + 1);
22121
22483
  const colliding = new Set([...seenInCount.entries()].filter(([, n]) => n > 1).map(([id]) => id));
@@ -22128,8 +22490,8 @@ ${codeblock}`, options);
22128
22490
  proseIndex: {}
22129
22491
  };
22130
22492
  let latestGeneratedAt = "";
22131
- let everyPayloadIsBootstrap = list.length > 0;
22132
- for (const { payload, name } of list) {
22493
+ let everyPayloadIsBootstrap = list2.length > 0;
22494
+ for (const { payload, name } of list2) {
22133
22495
  everyPayloadIsBootstrap = everyPayloadIsBootstrap && Boolean(payload.bootstrap);
22134
22496
  if (typeof payload.generated_at === "string" && payload.generated_at > latestGeneratedAt) {
22135
22497
  latestGeneratedAt = payload.generated_at;
@@ -22832,8 +23194,8 @@ ${JSON.stringify(envelope, null, 2)}`;
22832
23194
  return Math.max(...ids.map((id) => biasForSourceId(id, biasByBundle)));
22833
23195
  }
22834
23196
  function rankByBiasThenTrust(rows, biasByBundle = {}) {
22835
- const list = Array.isArray(rows) ? rows : [];
22836
- 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);
22837
23199
  }
22838
23200
 
22839
23201
  // src/services/chat.mjs
@@ -22859,6 +23221,13 @@ ${JSON.stringify(envelope, null, 2)}`;
22859
23221
 
22860
23222
  // src/adapters/corpus/reference-pack.mjs
22861
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
22862
23231
  init_node_url();
22863
23232
  init_node_path();
22864
23233
  var import_meta4 = {};
@@ -22980,6 +23349,119 @@ ${JSON.stringify(envelope, null, 2)}`;
22980
23349
  "game-inform": "inform"
22981
23350
  });
22982
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
+
22983
23465
  // src/services/chat-session.mjs
22984
23466
  init_node_path();
22985
23467
  init_node_fs();
@@ -23603,7 +24085,7 @@ ${JSON.stringify(envelope, null, 2)}`;
23603
24085
  const last = premises[premises.length - 1];
23604
24086
  return `${premises.map(step).join("; ")}; so ${first.subject} is a ${last.object}`;
23605
24087
  }
23606
- async function memoryFacts(memoryDir) {
24088
+ async function memoryFacts2(memoryDir) {
23607
24089
  try {
23608
24090
  const { loadMemory: loadMemory2 } = await Promise.resolve().then(() => (init_core(), core_exports));
23609
24091
  const m = await loadMemory2(memoryDir);
@@ -24088,7 +24570,7 @@ ${shown.map(renderFactLine).join("\n")}`,
24088
24570
  if (compAsk) {
24089
24571
  const compWord = compAsk[2].toLowerCase().replace(/\s+/g, "-");
24090
24572
  const compPredicate = `mgx:${compWord}-than`;
24091
- const facts = await memoryFacts(memoryDir);
24573
+ const facts = await memoryFacts2(memoryDir);
24092
24574
  const compTerm = (raw) => {
24093
24575
  const t = raw.replace(/^(?:an?|the)\s+/i, "").trim();
24094
24576
  return focusLabel && IS_ADJECTIVE_PRONOUN_RE.test(t) ? focusLabel : t;
@@ -24110,7 +24592,7 @@ ${shown.map(renderFactLine).join("\n")}`,
24110
24592
  for (const { predicate, phrase, re } of FORWARD_YESNO_MARKERS) {
24111
24593
  const m = q.match(re);
24112
24594
  if (!m) continue;
24113
- const facts = await memoryFacts(memoryDir);
24595
+ const facts = await memoryFacts2(memoryDir);
24114
24596
  const subj = factTermVariants(normFactTerm2, m[1]);
24115
24597
  const obj = factTermVariants(normFactTerm2, m[2]);
24116
24598
  const hit2 = facts.find((f) => f.predicate === predicate && subj.has(f.subject) && obj.has(f.object));
@@ -24172,7 +24654,7 @@ ${shown.map(renderFactLine).join("\n")}`,
24172
24654
  const subj = factTermVariants(normFactTerm2, doesHave[1]);
24173
24655
  const obj = factTermVariants(normFactTerm2, doesHave[2]);
24174
24656
  const HAS_PREDICATES = /* @__PURE__ */ new Set(["mgx:hasA", "tmct:has"]);
24175
- const facts = await memoryFacts(memoryDir);
24657
+ const facts = await memoryFacts2(memoryDir);
24176
24658
  const hasHit = (subjectSet) => facts.find(
24177
24659
  (f) => HAS_PREDICATES.has(f.predicate) && subjectSet.has(f.subject) && obj.has(f.object)
24178
24660
  );