@polycode-projects/the-mechanical-code-talker 3.0.5 → 3.0.6

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 (53) hide show
  1. package/README.md +6 -6
  2. package/corpus/child/README.md +2 -2
  3. package/corpus/child/index.json.gz +0 -0
  4. package/corpus/child/manifest.json +74 -74
  5. package/corpus/child/shards/child-00.jsonl.gz +0 -0
  6. package/corpus/child/shards/child-01.jsonl.gz +0 -0
  7. package/corpus/child/shards/child-02.jsonl.gz +0 -0
  8. package/corpus/child/shards/child-03.jsonl.gz +0 -0
  9. package/corpus/child/shards/child-04.jsonl.gz +0 -0
  10. package/corpus/child/shards/child-05.jsonl.gz +0 -0
  11. package/corpus/child/shards/child-06.jsonl.gz +0 -0
  12. package/corpus/child/shards/child-07.jsonl.gz +0 -0
  13. package/corpus/child/shards/child-08.jsonl.gz +0 -0
  14. package/corpus/child/shards/child-09.jsonl.gz +0 -0
  15. package/corpus/child/shards/child-0a.jsonl.gz +0 -0
  16. package/corpus/child/shards/child-0b.jsonl.gz +0 -0
  17. package/corpus/child/shards/child-0c.jsonl.gz +0 -0
  18. package/corpus/child/shards/child-0d.jsonl.gz +0 -0
  19. package/corpus/child/shards/child-0e.jsonl.gz +0 -0
  20. package/corpus/child/shards/child-0f.jsonl.gz +0 -0
  21. package/corpus/child/shards/child-10.jsonl.gz +0 -0
  22. package/corpus/child/shards/child-11.jsonl.gz +0 -0
  23. package/corpus/child/shards/child-12.jsonl.gz +0 -0
  24. package/corpus/child/shards/child-13.jsonl.gz +0 -0
  25. package/corpus/child/shards/child-14.jsonl.gz +0 -0
  26. package/corpus/child/shards/child-15.jsonl.gz +0 -0
  27. package/corpus/child/shards/child-16.jsonl.gz +0 -0
  28. package/corpus/child/shards/child-17.jsonl.gz +0 -0
  29. package/corpus/child/shards/child-18.jsonl.gz +0 -0
  30. package/corpus/child/shards/child-19.jsonl.gz +0 -0
  31. package/corpus/child/shards/child-1a.jsonl.gz +0 -0
  32. package/corpus/child/shards/child-1b.jsonl.gz +0 -0
  33. package/corpus/child/shards/child-1c.jsonl.gz +0 -0
  34. package/corpus/child/shards/child-1d.jsonl.gz +0 -0
  35. package/corpus/child/shards/child-1e.jsonl.gz +0 -0
  36. package/corpus/child/shards/child-1f.jsonl.gz +0 -0
  37. package/corpus/conceptnet/quality-filter.mjs +28 -4
  38. package/corpus/tier2/generate.mjs +4 -8
  39. package/corpus/tier2/human-large.jsonl +0 -2
  40. package/corpus/tier2/human-medium.jsonl +0 -2
  41. package/corpus/tier2/manifest.json +6 -6
  42. package/data/templates/constructions/digest-sentence-structures.toml +146 -1
  43. package/package.json +1 -1
  44. package/src/adapters/corpus/digest-bank.mjs +15 -3
  45. package/src/domain/digest/compose.mjs +142 -10
  46. package/src/domain/digest/config.json +5 -0
  47. package/src/domain/digest/structures.mjs +39 -14
  48. package/src/services/chat-page-viz.mjs +15 -4
  49. package/src/services/chat.mjs +118 -49
  50. package/src/services/extract-facts.mjs +46 -4
  51. package/src/services/research.mjs +80 -3
  52. package/src/surfaces/web/chat-browser-entry.mjs +23 -3
  53. package/src/surfaces/web/memory-ask-browser.bundle.js +108 -108
@@ -10,12 +10,21 @@
10
10
  // built seed payload (scripts/build-chat-seed.mjs), so teach turns, recall,
11
11
  // proof chains and the honest miss all run client-side with zero I/O.
12
12
  //
13
- // Two browser traps this file owns so no caller can fall into them:
13
+ // Three browser traps this file owns so no caller can fall into them:
14
14
  // - runTurn defaults `env` to process.env, and a browser has no `process`
15
15
  // global — every turn here passes `env: {}` explicitly;
16
16
  // - the uuid adapter needs node:crypto — the session id comes from the
17
17
  // Web Crypto API instead, with a Date.now fallback for contexts
18
- // without it.
18
+ // without it;
19
+ // - setDigestStructures is imported from adapters/corpus/digest-bank.mjs.
20
+ // Under the bundle build, scripts/build-chat-bundle.mjs swaps that import
21
+ // for a live in-memory twin, and this call actually feeds it the page's
22
+ // embedded structure rows; this file is ALSO imported directly by plain
23
+ // Node (e2e/web-chat-memory.test.mjs, exercising the same engine contract
24
+ // without a browser), where the import resolves to the real fs+TOML
25
+ // adapter — its own setDigestStructures is a documented no-op there
26
+ // (see that module's header), so the call is harmless either way, never
27
+ // a load error and never a behavior change on the Node side.
19
28
  import { runTurn, vocabExampleHint } from "../../services/chat.mjs";
20
29
  import { createInMemoryStore, normFactTerm, loadMemory, readFactRows } from "../../adapters/memory/core.mjs";
21
30
  import { serializeFactsJsonl } from "../../adapters/memory/export-jsonl.mjs";
@@ -24,6 +33,7 @@ import { provenanceTagToSource } from "../../domain/memory/trust.mjs";
24
33
  import { parseEntities } from "../../domain/codegraph.mjs";
25
34
  import { loadLexicon } from "../../domain/grammar/lexicon.mjs";
26
35
  import { registerWinkModel } from "../../adapters/wink-model.mjs";
36
+ import { setDigestStructures } from "../../adapters/corpus/digest-bank.mjs";
27
37
  // The reference-pack provider seam: the page registers a fetch-backed
28
38
  // provider over public/reference-pack/ so the engine's pack lookups work
29
39
  // where the gzipped fs layout cannot (the module's own fs loader degrades to
@@ -50,11 +60,21 @@ import { openPersistedStore } from "./idb-persist.mjs";
50
60
  * payload carries the starter vocabulary, so an unseeded session offers the
51
61
  * teach pointer instead of an example it cannot answer.
52
62
  *
63
+ * `digestStructures` (optional) is the page's build-time-embedded
64
+ * [[structure]] rows from the digest sentence-structure bank (chat-page-viz.mjs's
65
+ * DIGEST_STRUCTURES) — fed once to the bundle's live digest-bank twin so a
66
+ * long "what is X" answer leads with a composed digest instead of always
67
+ * falling back to the flat fact list (the bundle's stub used to return null
68
+ * unconditionally). Harmless to call more than once per page load: the table
69
+ * is module-scope, last write wins, and every session created after this one
70
+ * shares it.
71
+ *
53
72
  * Returns { memoryDir, sessionId, turn }. `turn(line)` resolves to
54
73
  * { answer, end, record, plan } and threads focus/last/planState between
55
74
  * calls exactly as the CLI session does.
56
75
  */
57
- export function createChatSession({ seedPayload = null, vocabSeeded = false, liveReference = false, onLiveLookup = null, synthesisBudget = 12 } = {}) {
76
+ export function createChatSession({ seedPayload = null, vocabSeeded = false, liveReference = false, onLiveLookup = null, synthesisBudget = 12, digestStructures = null } = {}) {
77
+ setDigestStructures(digestStructures || []);
58
78
  const memoryDir = createInMemoryStore();
59
79
  // Spread onto the store's own empty payload so a partial seed (individuals
60
80
  // and objectProperties only) still carries the classes/prefixes scaffolding