@polycode-projects/the-mechanical-code-talker 6.0.19 → 6.0.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/README.md +20 -23
  2. package/bin/tmct.mjs +16 -33
  3. package/corpus/LICENSES.json +0 -21
  4. package/corpus/README.md +10 -13
  5. package/corpus/reference/manifest.json +19 -19
  6. package/corpus/reference/shards/ref-01.jsonl.gz +0 -0
  7. package/corpus/reference/shards/ref-04.jsonl.gz +0 -0
  8. package/corpus/reference/shards/ref-08.jsonl.gz +0 -0
  9. package/corpus/reference/shards/ref-10.jsonl.gz +0 -0
  10. package/corpus/reference/shards/ref-11.jsonl.gz +0 -0
  11. package/corpus/reference/shards/ref-17.jsonl.gz +0 -0
  12. package/corpus/reference/shards/ref-20.jsonl.gz +0 -0
  13. package/corpus/reference/shards/ref-25.jsonl.gz +0 -0
  14. package/corpus/reference/shards/ref-2c.jsonl.gz +0 -0
  15. package/corpus/tier2/generate.mjs +6 -142
  16. package/corpus/tier2/manifest.json +0 -42
  17. package/package.json +4 -4
  18. package/src/adapters/corpus/child-seed.mjs +74 -0
  19. package/src/adapters/corpus/conceptnet.mjs +45 -26
  20. package/src/adapters/memory/blocks.mjs +7 -1
  21. package/src/adapters/memory/core.mjs +453 -103
  22. package/src/adapters/memory/corpus-bands.mjs +33 -10
  23. package/src/adapters/memory/inspect.mjs +24 -5
  24. package/src/adapters/memory/rows.mjs +106 -9
  25. package/src/adapters/memory/shacl.mjs +10 -3
  26. package/src/domain/ask.mjs +27 -10
  27. package/src/domain/cli-verbs.mjs +3 -4
  28. package/src/domain/completions/group.mjs +8 -3
  29. package/src/domain/completions/infer.mjs +7 -2
  30. package/src/domain/completions/prune.mjs +5 -1
  31. package/src/domain/completions/rank.mjs +7 -2
  32. package/src/domain/digest/compose.mjs +5 -1
  33. package/src/domain/digest/select.mjs +12 -6
  34. package/src/domain/domain.mjs +15 -8
  35. package/src/domain/el-classify.mjs +11 -2
  36. package/src/domain/fact-phrase.mjs +86 -4
  37. package/src/domain/hash.mjs +9 -0
  38. package/src/domain/memory/bias.mjs +8 -4
  39. package/src/domain/memory/capability.mjs +12 -6
  40. package/src/domain/memory/fact-order.mjs +29 -0
  41. package/src/domain/memory/resolution.mjs +3 -0
  42. package/src/domain/news-feed.mjs +422 -56
  43. package/src/domain/reference-pack.mjs +5 -0
  44. package/src/domain/sense-scope.mjs +116 -0
  45. package/src/domain/sense-split.mjs +1 -1
  46. package/src/domain/syllogise.mjs +21 -13
  47. package/src/domain/tableau.mjs +23 -14
  48. package/src/domain/worlds-pack.mjs +5 -1
  49. package/src/services/adventure-autoplay.mjs +6 -1
  50. package/src/services/adventure-editor.mjs +43 -21
  51. package/src/services/adventure-viz.mjs +26 -9
  52. package/src/services/adventure.mjs +40 -10
  53. package/src/services/chat.mjs +253 -113
  54. package/src/services/extensions.mjs +51 -58
  55. package/src/services/extract-facts.mjs +670 -95
  56. package/src/services/init.mjs +4 -4
  57. package/src/services/ledger-viz.mjs +9 -4
  58. package/src/services/memory-panel-viz.mjs +4 -5
  59. package/src/services/mud-editor.mjs +40 -16
  60. package/src/services/mud-viz.mjs +8 -2
  61. package/src/services/mudiii-turn.mjs +5 -3
  62. package/src/services/mudiii-viz.mjs +8 -2
  63. package/src/services/news.mjs +277 -11
  64. package/src/services/research-viz.mjs +1 -1
  65. package/src/services/sprite-catalog-viz.mjs +10 -5
  66. package/src/surfaces/web/adventure-browser-entry.mjs +6 -12
  67. package/src/surfaces/web/memory-ask-browser.bundle.js +152 -151
  68. package/src/surfaces/web/mud-browser-entry.mjs +7 -11
  69. package/src/surfaces/web/research-browser-entry.mjs +5 -2
  70. package/corpus/tier2/aws.jsonl +0 -39
  71. package/corpus/tier2/java.jsonl +0 -31
  72. package/corpus/tier2/python.jsonl +0 -30
@@ -761,18 +761,26 @@ function rulingTestimonyClaim(provenance, knower, currentEpoch = 0) {
761
761
  }
762
762
 
763
763
  /** What `person` knows about NOW: the object of every knows-about edge whose
764
- * ruling claim still stands, in the order the edges were first written.
765
- * Nothing is deleted — an edge whose newest claim says the thing is gone just
766
- * stops reading back. `currentEpoch` is the run the reader is on, so a claim a
767
- * recast has left behind cannot decide what a character knows today. */
764
+ * ruling claim still stands, oldest learned first. Nothing is deleted an edge
765
+ * whose newest claim says the thing is gone just stops reading back.
766
+ * `currentEpoch` is the run the reader is on, so a claim a recast has left
767
+ * behind cannot decide what a character knows today.
768
+ *
769
+ * The order comes off each edge's own ruling claim rather than off the row
770
+ * array, so it says what it means: a character lists what it learned in the
771
+ * order it learned it, and two peers holding one fact set read the same list.
772
+ * Two topics learned on one turn fall back to the topic word. */
768
773
  function currentKnowsAboutTopics(rows, person, currentEpoch = 0) {
769
- const topics = [];
774
+ const known = [];
770
775
  for (const row of rows || []) {
771
776
  if (row.subject !== person || row.predicate !== KNOWS_ABOUT_PREDICATE) continue;
772
- if (rulingTestimonyClaim(row.provenance, person, currentEpoch)?.voided) continue;
773
- topics.push(row.object);
777
+ const claim = rulingTestimonyClaim(row.provenance, person, currentEpoch);
778
+ if (claim?.voided) continue;
779
+ known.push({ topic: row.object, epoch: claim?.epoch ?? 0, turn: claim?.turn ?? 0 });
774
780
  }
775
- return topics;
781
+ known.sort((a, b) => a.epoch - b.epoch || a.turn - b.turn
782
+ || (a.topic < b.topic ? -1 : a.topic > b.topic ? 1 : 0));
783
+ return known.map((entry) => entry.topic);
776
784
  }
777
785
 
778
786
  /**
@@ -1223,12 +1231,34 @@ export function freshObjectId(rows, kind, alsoTaken = new Set()) {
1223
1231
  }
1224
1232
 
1225
1233
  /** The kinds a room kind declares for one of the spawn pools, in the order the
1226
- * world wrote them, or `fallback` when it declares none. Pure. */
1234
+ * fold hands them over, or `fallback` when it declares none. A pool is a set of
1235
+ * rows, not a list, so the store keeps no rank between them and the order is
1236
+ * the fold's content order rather than the order the world file lists them in.
1237
+ * A caller that shows the whole pool can read it as it stands; one that takes
1238
+ * only part of it wants preferredDigKinds below. Pure. */
1227
1239
  function declaredKindsOr(rows, roomClass, predicate, fallback) {
1228
1240
  const declared = factObjects(rows, roomClass, predicate);
1229
1241
  return declared.length ? declared : fallback;
1230
1242
  }
1231
1243
 
1244
+ /** A dig pool ranked by what a dig should turn up first: the engine's own
1245
+ * DIG_SPAWN_KINDS order, then content order for a kind it does not name.
1246
+ *
1247
+ * A den shows everything it holds, so its pool needs no rank. A plain dig takes
1248
+ * the first few, so which few it takes is a real choice — and the fact store
1249
+ * holds the pool as a set, with no rank to read. Leaving it to the fold's own
1250
+ * order would decide it alphabetically, which puts a kind the world already
1251
+ * keeps as one hand-named prop ahead of one minted only by digging, and the
1252
+ * point of a minted id is that it names something a hand-authored prop does
1253
+ * not. Pure. */
1254
+ function preferredDigKinds(kinds) {
1255
+ const rank = (kind) => {
1256
+ const at = DIG_SPAWN_KINDS.indexOf(kind);
1257
+ return at < 0 ? DIG_SPAWN_KINDS.length : at;
1258
+ };
1259
+ return kinds.slice().sort((a, b) => rank(a) - rank(b) || (a < b ? -1 : a > b ? 1 : 0));
1260
+ }
1261
+
1232
1262
  /** The mass row a freshly minted instance needs, copied off its own class, or
1233
1263
  * nothing when the class declares no mass. eat reads the instance's mass, so a
1234
1264
  * dug carrot with none would be worth the flat default however the world
@@ -1499,7 +1529,7 @@ async function handleDigVerb(ctx) {
1499
1529
  const spawnCount = DIG_SPAWN_MIN + stableIndex(dug, spawnMax - DIG_SPAWN_MIN + 1);
1500
1530
  const spawnedKinds = isDen
1501
1531
  ? declaredKindsOr(rows, dugKind, DEN_SPAWN_PREDICATE, DIG_SPAWN_KINDS)
1502
- : declaredKindsOr(rows, dugKind, DIG_SPAWN_PREDICATE, DIG_SPAWN_KINDS).slice(0, spawnCount);
1532
+ : preferredDigKinds(declaredKindsOr(rows, dugKind, DIG_SPAWN_PREDICATE, DIG_SPAWN_KINDS)).slice(0, spawnCount);
1503
1533
  const minted = new Set();
1504
1534
  const spawned = spawnedKinds.map((kind) => {
1505
1535
  const id = freshObjectId(rows, kind, minted);