@polycode-projects/the-mechanical-code-talker 4.1.0 → 4.1.2

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 (60) hide show
  1. package/README.md +31 -18
  2. package/bin/tmct.mjs +3 -0
  3. package/data/templates/responses.jsonl +3 -0
  4. package/package.json +2 -1
  5. package/src/adapters/memory/core.mjs +1358 -196
  6. package/src/adapters/memory/inspect.mjs +11 -0
  7. package/src/adapters/memory/shacl.mjs +38 -0
  8. package/src/adapters/p2p/webrtc-transport.mjs +28 -5
  9. package/src/domain/ask-vocab.mjs +39 -0
  10. package/src/domain/ask.mjs +183 -34
  11. package/src/domain/grammar/assert.mjs +8 -2
  12. package/src/domain/hanoi-board.mjs +232 -0
  13. package/src/domain/ingest-facts.mjs +120 -0
  14. package/src/domain/interpret/normalize.mjs +49 -0
  15. package/src/domain/memory/compaction.mjs +284 -0
  16. package/src/domain/memory/resolution.mjs +171 -0
  17. package/src/domain/memory/trust.mjs +175 -5
  18. package/src/domain/memory-facts.mjs +139 -0
  19. package/src/domain/p2p/facts.mjs +21 -0
  20. package/src/domain/p2p/peer-id.mjs +15 -0
  21. package/src/domain/p2p/provenance-relabel.mjs +13 -2
  22. package/src/domain/p2p/sync-filter.mjs +5 -1
  23. package/src/domain/p2p/wire.mjs +7 -4
  24. package/src/domain/scene-compose.mjs +2 -2
  25. package/src/domain/sprite-facts.mjs +0 -0
  26. package/src/domain/sprite-request.mjs +1 -1
  27. package/src/services/adventure-viz.mjs +43 -39
  28. package/src/services/adventure.mjs +70 -44
  29. package/src/services/chat-page-viz.mjs +403 -332
  30. package/src/services/chat.mjs +274 -156
  31. package/src/services/code-explorer-viz.mjs +142 -55
  32. package/src/services/index.mjs +1 -1
  33. package/src/services/ingest-viz.mjs +153 -28
  34. package/src/services/ledger-viz.mjs +47 -47
  35. package/src/services/memory-panel-viz.mjs +8 -3
  36. package/src/services/mud-turn.mjs +11 -8
  37. package/src/services/mud-viz.mjs +474 -234
  38. package/src/services/p2p-room.mjs +110 -23
  39. package/src/services/plan-viz.mjs +72 -13
  40. package/src/services/research-viz.mjs +35 -24
  41. package/src/services/share-overlay-viz.mjs +623 -0
  42. package/src/services/spider-fly-viz.mjs +24 -24
  43. package/src/services/sprite-catalog-viz.mjs +307 -82
  44. package/src/surfaces/web/adventure-browser-entry.mjs +46 -25
  45. package/src/surfaces/web/chat-browser-entry.mjs +55 -9
  46. package/src/surfaces/web/code-explorer-browser-entry.mjs +30 -16
  47. package/src/surfaces/web/engine-surface.mjs +82 -0
  48. package/src/surfaces/web/ingest-browser-entry.mjs +81 -11
  49. package/src/surfaces/web/ledger-browser-entry.mjs +47 -14
  50. package/src/surfaces/web/memory-ask-browser-entry.mjs +55 -13
  51. package/src/surfaces/web/memory-ask-browser.bundle.js +149 -116
  52. package/src/surfaces/web/mud-browser-entry.mjs +77 -25
  53. package/src/surfaces/web/p2p-browser-entry.mjs +1 -1
  54. package/src/surfaces/web/plan-browser-entry.mjs +49 -11
  55. package/src/surfaces/web/research-browser-entry.mjs +33 -24
  56. package/src/surfaces/web/spider-fly-browser-entry.mjs +32 -13
  57. package/src/surfaces/web/sprites-browser-entry.mjs +51 -11
  58. package/src/surfaces/web/tmct-surface.mjs +159 -0
  59. package/src/surfaces/web/turn-session.mjs +16 -5
  60. package/src/tools/server.mjs +13 -6
@@ -1,20 +1,62 @@
1
1
  // memory-ask-browser-entry.mjs — the esbuild entry for the ledger page's
2
2
  // chat dock (`tmct viz`, src/services/ledger-viz.mjs).
3
3
  //
4
- // Re-exports `factAnswer` (src/services/chat.mjs) and `createInMemoryStore`
5
- // (src/adapters/memory/core.mjs), which lets the dock hand `factAnswer` the page's
6
- // already-embedded payload with zero fs I/O. Called with `envelope: null,
7
- // miss: true` to arm factAnswer's bare-question regex fallbacks directly,
8
- // bypassing the structural-graph parse pipeline this dock has no use for.
4
+ // The one COMMITTED browser bundle: `tmct viz` is a real CLI command run
5
+ // against a user's own local .tmct store, so this ships with the package. It
6
+ // deliberately carries the question lanes only (factAnswer/factReadBack) and
7
+ // not the full turn engine — see ledger-browser-entry.mjs's header for the
8
+ // contrast with the demo site's own 1.5MB dock.
9
+ //
10
+ // It publishes the SAME `globalThis.tmct` every other page does, through
11
+ // tmct-surface.mjs, which imports nothing — so this bundle gets the shared
12
+ // contract without the tool layer or the capability router coming with it.
13
+ // `tmct.turn` and `tmct.plan` are unwired here and say so: this dock asks
14
+ // questions, it does not hold a conversation or plan anything.
9
15
  import { factAnswer, factReadBack } from "../../services/chat.mjs";
10
16
  import { createInMemoryStore, normFactTerm } from "../../adapters/memory/core.mjs";
11
17
  import { digestTermFromPayloadBrowser } from "./digest-client.mjs";
18
+ import { publishTmctSurface } from "./tmct-surface.mjs";
19
+
20
+ /** A question-only session over a payload the page already embeds — no fs I/O,
21
+ * no turn engine. Returns `{ memoryDir }`. */
22
+ export function createMemoryAskSession({ payload = null } = {}) {
23
+ const memoryDir = createInMemoryStore();
24
+ if (payload) memoryDir.payload = payload;
25
+ return { memoryDir };
26
+ }
27
+
28
+ /**
29
+ * One question, answered from the page's own embedded store. Runs the same
30
+ * cascade `runAsk` runs — factAnswer first, then factReadBack, which is where
31
+ * the taught-relation chases live ("who is the grandfather of ishmael") that
32
+ * factAnswer's own lanes don't reach.
33
+ *
34
+ * Both are called with `envelope: null, miss: true`, which arms factAnswer's
35
+ * bare-question fallbacks directly and skips the structural-graph parse
36
+ * pipeline this dock has no use for.
37
+ *
38
+ * Returns `{ answer, data, miss }`. `data` is the reader's own result, so a
39
+ * caller still sees the inferred `goal` line it computed on the way.
40
+ */
41
+ export async function askMemory(request, options, session) {
42
+ let fact = null;
43
+ try { fact = await factAnswer(session.memoryDir, request, null, true, {}); } catch { fact = null; }
44
+ if (!(fact && fact.text)) {
45
+ try { fact = await factReadBack(session.memoryDir, request, null, true, null); } catch { fact = null; }
46
+ }
47
+ if (!(fact && fact.text)) return { answer: null, data: null, miss: true };
48
+ return { answer: fact.text, data: fact, miss: false };
49
+ }
12
50
 
13
- // normFactTerm is re-exported too, for the page's client-side term normalization.
14
- // factReadBack carries the taught-relation chases (grandfather-style questions)
15
- // that factAnswer's own lanes don't reach.
16
- // digestTermFromPayloadBrowser lets the CLI `tmct viz` page read a refocused
17
- // term back as a digest client-side, from the structure table the page embeds
18
- // the same narrative the demo ledger's live bundle produces, over the same
19
- // static store this page already carries.
20
- globalThis.tmctMemoryAsk = { factAnswer, factReadBack, createInMemoryStore, normFactTerm, digestTermFromPayloadBrowser };
51
+ // `tmct.page` keeps the term normalizer the dock refocuses the ledger with,
52
+ // and the client-side digest reader — the narrative the demo ledger's live
53
+ // bundle produces, over the static structure table this page embeds.
54
+ // `fallback`, because the demo ledger page carries this bundle AND the full
55
+ // turn engine at once: this one answers where it is alone, and steps aside
56
+ // wherever the live dock is loaded, whichever order the two arrive in.
57
+ publishTmctSurface({
58
+ open: createMemoryAskSession,
59
+ ask: askMemory,
60
+ page: { normFactTerm, digestTermFromPayloadBrowser },
61
+ fallback: true,
62
+ });