@polycode-projects/the-mechanical-code-talker 4.1.1 → 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 (55) 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/services/adventure-viz.mjs +5 -1
  27. package/src/services/adventure.mjs +70 -44
  28. package/src/services/chat-page-viz.mjs +381 -310
  29. package/src/services/chat.mjs +273 -155
  30. package/src/services/code-explorer-viz.mjs +141 -54
  31. package/src/services/index.mjs +1 -1
  32. package/src/services/ingest-viz.mjs +134 -9
  33. package/src/services/ledger-viz.mjs +7 -4
  34. package/src/services/memory-panel-viz.mjs +8 -3
  35. package/src/services/mud-turn.mjs +11 -8
  36. package/src/services/mud-viz.mjs +441 -206
  37. package/src/services/p2p-room.mjs +110 -23
  38. package/src/services/plan-viz.mjs +63 -4
  39. package/src/services/research-viz.mjs +18 -7
  40. package/src/services/share-overlay-viz.mjs +623 -0
  41. package/src/services/spider-fly-viz.mjs +2 -2
  42. package/src/services/sprite-catalog-viz.mjs +303 -78
  43. package/src/surfaces/web/adventure-browser-entry.mjs +27 -5
  44. package/src/surfaces/web/chat-browser-entry.mjs +37 -10
  45. package/src/surfaces/web/code-explorer-browser-entry.mjs +4 -3
  46. package/src/surfaces/web/ingest-browser-entry.mjs +73 -12
  47. package/src/surfaces/web/ledger-browser-entry.mjs +32 -7
  48. package/src/surfaces/web/memory-ask-browser.bundle.js +149 -116
  49. package/src/surfaces/web/mud-browser-entry.mjs +38 -7
  50. package/src/surfaces/web/p2p-browser-entry.mjs +1 -1
  51. package/src/surfaces/web/plan-browser-entry.mjs +33 -2
  52. package/src/surfaces/web/research-browser-entry.mjs +11 -19
  53. package/src/surfaces/web/sprites-browser-entry.mjs +39 -8
  54. package/src/surfaces/web/tmct-surface.mjs +12 -0
  55. package/src/surfaces/web/turn-session.mjs +10 -3
package/README.md CHANGED
@@ -152,7 +152,7 @@ are two of them exactly as they sit in the graph — `dog capableOf bark` and
152
152
 
153
153
  ```output cmd="node examples/raw-fact-shape.mjs" cwd=repo
154
154
  {
155
- "id": "fact:d5327019d311a956",
155
+ "id": "fact:d5327019d311a956@src:corpus:human",
156
156
  "label": "dog mgx:capableOf bark",
157
157
  "class": "Fact",
158
158
  "derived_from": [],
@@ -183,6 +183,11 @@ are two of them exactly as they sit in the graph — `dog capableOf bark` and
183
183
  "key": "createdAt",
184
184
  "value": "<timestamp>"
185
185
  },
186
+ {
187
+ "prop": "mgx:sourceId",
188
+ "key": "sourceId",
189
+ "value": "src:corpus:human"
190
+ },
186
191
  {
187
192
  "prop": "mgx:factProvenance",
188
193
  "key": "provenance",
@@ -202,12 +207,9 @@ are two of them exactly as they sit in the graph — `dog capableOf bark` and
202
207
  "prop": "mgx:trustInputs",
203
208
  "key": "trustInputs",
204
209
  "value": {
205
- "sourceTypes": [
206
- "corpus"
207
- ],
208
- "corroboration": 1,
209
- "createdAt": "<timestamp>",
210
- "recency": 1
210
+ "sourceType": "corpus",
211
+ "sourceId": "src:corpus:human",
212
+ "createdAt": "<timestamp>"
211
213
  }
212
214
  },
213
215
  {
@@ -219,7 +221,7 @@ are two of them exactly as they sit in the graph — `dog capableOf bark` and
219
221
  }
220
222
 
221
223
  {
222
- "id": "fact:08d02295fc0fed1c",
224
+ "id": "fact:08d02295fc0fed1c@src:corpus:human",
223
225
  "label": "dog rdfs:subClassOf animal",
224
226
  "class": "Fact",
225
227
  "derived_from": [],
@@ -250,6 +252,11 @@ are two of them exactly as they sit in the graph — `dog capableOf bark` and
250
252
  "key": "createdAt",
251
253
  "value": "<timestamp>"
252
254
  },
255
+ {
256
+ "prop": "mgx:sourceId",
257
+ "key": "sourceId",
258
+ "value": "src:corpus:human"
259
+ },
253
260
  {
254
261
  "prop": "mgx:factProvenance",
255
262
  "key": "provenance",
@@ -269,12 +276,9 @@ are two of them exactly as they sit in the graph — `dog capableOf bark` and
269
276
  "prop": "mgx:trustInputs",
270
277
  "key": "trustInputs",
271
278
  "value": {
272
- "sourceTypes": [
273
- "corpus"
274
- ],
275
- "corroboration": 1,
276
- "createdAt": "<timestamp>",
277
- "recency": 1
279
+ "sourceType": "corpus",
280
+ "sourceId": "src:corpus:human",
281
+ "createdAt": "<timestamp>"
278
282
  }
279
283
  },
280
284
  {
@@ -289,8 +293,17 @@ are two of them exactly as they sit in the graph — `dog capableOf bark` and
289
293
  Every attribute value here is a plain string except `mgx:trustInputs`, which
290
294
  is `JSON.stringify`'d into its `value` field in the actual store (parsed back
291
295
  out above for readability) since the flat attribute list has nowhere else to
292
- put a nested object. `mgx:trustScore` is computed from exactly those inputs —
293
- source type, corroboration count, recency — never guessed.
296
+ put a nested object.
297
+
298
+ The id says who asserted it: `fact:<triple-hash>@<source-id>`. One record is
299
+ one source asserting one triple, so a fact two sources agree on is two
300
+ records sharing the hash. The part before the `@` is the fact id you see in
301
+ citations and premise lists, and it never changes. Each record's own
302
+ `mgx:trustScore` is just that one source's prior, from its type and its own
303
+ track record — never guessed. What the whole fact is worth, corroboration
304
+ across sources and how recently each of them said it, is folded over those
305
+ records when you read them, so it answers for today rather than for the day
306
+ it was written.
294
307
 
295
308
  Point it at a codebase's graph and the same engine answers structural questions.
296
309
  `examples/mini-webapp` ships in this repo, so this runs as written:
@@ -307,8 +320,8 @@ tmct> /exit
307
320
  **[Try it live in your browser →](https://tmct.polycode.co.uk/)**
308
321
  runs the actual query engine client-side. No server, no install. The landing
309
322
  page answers codebase questions live, and eight more pages each ground their
310
- own domain: a full chat seeded with 72,098 facts (the same nine bands as
311
- `npm run init:xl`, uncapped, 4.4 MB on the wire), the
323
+ own domain: a full chat seeded with 63,470 facts (the same nine bands as
324
+ `npm run init:xl`), the
312
325
  **memory ledger** (every fact as a readable sentence; drill by clicking the
313
326
  terms inside), and the **code explorer** (the same ledger UI refocused on a
314
327
  code graph, with a hint rail of suggested next questions). An **ingest
package/bin/tmct.mjs CHANGED
@@ -559,6 +559,7 @@ async function writeStandaloneViewPage(archetype, rest) {
559
559
  const outPath = resolvePath(process.cwd(), strFlag(rest, ["--output", "--out"], `${archetype}.html`));
560
560
  let html;
561
561
  if (archetype === "sprites") {
562
+ const engineBundleJs = await buildEngineBundleJs("build-sprites-bundle.mjs");
562
563
  const { readSpriteTemplateFiles } = await import("../src/adapters/corpus/sprite-template-files.mjs");
563
564
  const { readSpriteLargeTemplateFiles } = await import("../src/adapters/corpus/sprite-large-template-files.mjs");
564
565
  const { loadSpriteOntologyFactRows, renderSpriteCatalogHtml } = await import("../src/services/sprite-catalog-viz.mjs");
@@ -566,6 +567,8 @@ async function writeStandaloneViewPage(archetype, rest) {
566
567
  iconTemplates: readSpriteTemplateFiles(),
567
568
  largeTemplates: readSpriteLargeTemplateFiles(),
568
569
  factRows: await loadSpriteOntologyFactRows(),
570
+ spritesBundleAvailable: true,
571
+ engineBundleJs,
569
572
  });
570
573
  } else if (archetype === "spider-fly") {
571
574
  const engineBundleJs = await buildEngineBundleJs("build-spider-fly-bundle.mjs");
@@ -64,8 +64,11 @@
64
64
  {"id":"orientation-friendly","class":"orientation","register":"friendly","template":"I'm tmct — a deterministic, offline code-graph assistant (no LLM). I answer questions about THIS codebase's structure — imports, calls, definitions,\nhistory and counts. For example:\n which modules import {example1}\n what calls {example2}\n how many classes are there\n/help for commands, /stats for an overview of the graph."}
65
65
  {"id":"miss-no-previous-answer","class":"miss","register":"friendly","template":"No previous answer to expand yet — ask me a question first, then say \"why\" or \"say more\"."}
66
66
  {"id":"conversational-greeting-empty","class":"conversational","register":"friendly","template":"Hi. I'm tmct. {vocabHint} Point me at a repo with `--repo <path>` for code-structure questions too (imports, calls, definitions). /help for commands."}
67
+ {"id":"conversational-greeting-empty-browser","class":"conversational","register":"friendly","template":"Hi. I'm tmct. {vocabHint} /help for commands."}
67
68
  {"id":"orientation-empty","class":"orientation","register":"friendly","template":"I'm tmct — a deterministic, offline chat assistant (no LLM). {vocabHint} /memory for what I remember.\nFor code structure (imports, calls, definitions) point me at a repo: `--repo <path>`, or try the shipped example `npm run example:mini`. tmct reads graphs; it doesn't index code itself.\n/help for commands."}
69
+ {"id":"orientation-empty-browser","class":"orientation","register":"friendly","template":"I'm tmct — a deterministic, offline chat assistant (no LLM). {vocabHint} /memory for what I remember, or ask about what's already loaded.\n/help for commands."}
68
70
  {"id":"identity-self","class":"conversational","register":"friendly","template":"I'm tmct — a deterministic, offline chat assistant. No LLM: wink-nlp parsing over a seeded ontology/lexicon, plus a code graph when you point me at a repo with `--repo <path>`. /help for commands, /stats for an overview."}
71
+ {"id":"identity-self-browser","class":"conversational","register":"friendly","template":"I'm tmct — a deterministic, offline chat assistant. No LLM: wink-nlp parsing over a seeded ontology/lexicon, plus a code graph when one is loaded. {vocabHint} /help for commands, /stats for an overview."}
69
72
  {"id":"identity-not-an-llm","class":"conversational","register":"friendly","template":"No — no LLM involved. tmct is deterministic: wink-nlp parsing over a graph/ontology, not a language model. /help for commands."}
70
73
  {"id":"identity-no-feelings","class":"conversational","register":"friendly","template":"No — I don't have feelings, opinions, or consciousness. tmct is deterministic: wink-nlp parsing over a graph/ontology, not a mind. /help for commands."}
71
74
  {"id":"identity-honest-miss","class":"conversational","register":"friendly","template":"No — I never make up an answer. If a question doesn't ground to a taught fact or a real graph entity, I say so plainly instead of guessing. /help for commands."}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polycode-projects/the-mechanical-code-talker",
3
- "version": "4.1.1",
3
+ "version": "4.1.2",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "The Mechanical Code Talker (tmct) — a tolerant, offline, $0 chat surface that guides you toward precision queries about a software repository. ELIZA/PARRY-style but domain-obsessed with code. No model calls; indexes a repo on request (tmct index) or reads any producer's graph.",
@@ -107,6 +107,7 @@
107
107
  "check:publish": "node scripts/check-publish.mjs",
108
108
  "check:all": "npm run check:links && npm run check:pii && npm run check:licences && npm run check:publint && npm run check:tool-docs && npm run check:budgets",
109
109
  "smoke:deploy": "node scripts/post-deploy-smoke.mjs",
110
+ "wait:site": "node scripts/wait-for-site.mjs",
110
111
  "chat": "node --disable-warning=ExperimentalWarning bin/tmct.mjs",
111
112
  "chat:repo": "node --disable-warning=ExperimentalWarning bin/tmct.mjs chat --repo",
112
113
  "chat:plain": "node --disable-warning=ExperimentalWarning bin/tmct.mjs chat --plain",