@polycode-projects/the-mechanical-code-talker 6.0.21 → 7.0.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 (36) hide show
  1. package/README.md +5 -15
  2. package/bin/tmct.mjs +8 -3
  3. package/package.json +1 -5
  4. package/src/adapters/memory/core.mjs +108 -96
  5. package/src/domain/agent-traits.mjs +1 -1
  6. package/src/domain/answer-variants.json +1 -1
  7. package/src/domain/cli-verbs.mjs +1 -0
  8. package/src/domain/memory/causal-stability.mjs +22 -5
  9. package/src/domain/memory/fact-order.mjs +3 -3
  10. package/src/domain/memory/provenance-time.mjs +35 -0
  11. package/src/domain/memory/retraction.mjs +3 -5
  12. package/src/domain/memory/trust.mjs +11 -11
  13. package/src/domain/news-feed.mjs +1 -1
  14. package/src/domain/seeded-random.mjs +6 -6
  15. package/src/services/adventure.mjs +10 -41
  16. package/src/services/chat-page-viz.mjs +12 -1111
  17. package/src/services/chat-session.mjs +20 -6
  18. package/src/services/chat.mjs +269 -197
  19. package/src/services/extract-facts.mjs +1 -1
  20. package/src/services/import-file.mjs +1 -1
  21. package/src/services/mud-viz.mjs +21 -1082
  22. package/src/services/mudiii-viz.mjs +0 -4
  23. package/src/services/pill-complete.mjs +5 -8
  24. package/src/services/predator-prey.mjs +3 -5
  25. package/src/surfaces/web/memory-ask-browser.bundle.js +107 -107
  26. package/src/surfaces/web/mud-browser-entry.mjs +8 -48
  27. package/test-benchmarks/agentbench/README.md +7 -10
  28. package/src/adapters/p2p/webrtc-transport.mjs +0 -169
  29. package/src/domain/p2p/facts.mjs +0 -102
  30. package/src/domain/p2p/peer-id.mjs +0 -47
  31. package/src/domain/p2p/provenance-relabel.mjs +0 -37
  32. package/src/domain/p2p/sync-filter.mjs +0 -43
  33. package/src/domain/p2p/wire.mjs +0 -126
  34. package/src/services/p2p-room.mjs +0 -848
  35. package/src/services/share-overlay-viz.mjs +0 -623
  36. package/src/surfaces/web/p2p-browser-entry.mjs +0 -39
@@ -131,6 +131,14 @@ export async function createSession({
131
131
  ephemeral = false,
132
132
  narrate = false,
133
133
  liveReference = false,
134
+ // Whether this session reads its lines as questions about a code graph.
135
+ // The switch a host sets when it supplies its own code graph (seonix does),
136
+ // so it never has to type a slash command. Session-scoped and mutable —
137
+ // `/code-graph on|off` flips it turn-to-turn, exactly like narrate. Default
138
+ // OFF, and nothing derives it from what happens to be loaded: a session
139
+ // answers code questions because its caller said so, never because a graph
140
+ // turned up.
141
+ codeGraphMode = false,
134
142
  // Which research source "research <topic>" fetches from: this session's
135
143
  // starting value. Precedence — /wikipedia|/wikidata in chat (mutable,
136
144
  // applied to session state by `turn()` below) > this param (`tmct chat
@@ -215,6 +223,9 @@ export async function createSession({
215
223
  // and mutable — `/wiki on|off` flips it turn-to-turn, exactly like narrate.
216
224
  // Default OFF; the toml tier is folded in below, once toml has resolved.
217
225
  let liveReferenceOn = liveReference || /^(1|true|yes)$/i.test(String(env.TMCT_LIVE_WIKIPEDIA || ""));
226
+ // CODE-GRAPH mode (the `codeGraphMode` option, or TMCT_CODE_GRAPH=1): see the
227
+ // option's own doc comment above. Session-scoped and mutable.
228
+ let codeGraphModeOn = codeGraphMode || /^(1|true|yes)$/i.test(String(env.TMCT_CODE_GRAPH || ""));
218
229
  // Graph resolution order (delegates to src/services/cli-args.mjs's
219
230
  // resolveRuntimeConfig): explicit --graph path(s) win outright; then --repo
220
231
  // (never silently redirected by env); then TMCT_GRAPH_FILE env; then
@@ -554,6 +565,7 @@ export async function createSession({
554
565
  get turns() { return turns; },
555
566
  get narrate() { return narrateOn; },
556
567
  get liveReference() { return liveReferenceOn; },
568
+ get codeGraphMode() { return codeGraphModeOn; },
557
569
  get researchSource() { return researchSourceOn; },
558
570
  promptFor: () => promptFor(focus),
559
571
 
@@ -567,7 +579,7 @@ export async function createSession({
567
579
  async turn(line, { retrieval: turnRetrieval = null } = {}) {
568
580
  let result;
569
581
  try {
570
- result = await runTurn(line, { config, source, graph, focus, last, memoryDir, sessionId, env, lexicon, narrate: narrateOn, liveReference: liveReferenceOn, researchSource: researchSourceOn, vocabHint, tel, biasByBundle, planState, gameConfig, recognitionConfig, researchState, researchConfig, newsState, newsConfig, newsProviders, discourse: discourseRecord, actingSubject, codeDomainActive: domainActive, laneVocab, domainPacks, retrieval: turnRetrieval ?? retrieval });
582
+ result = await runTurn(line, { config, source, graph, focus, last, memoryDir, sessionId, env, lexicon, narrate: narrateOn, liveReference: liveReferenceOn, codeGraphMode: codeGraphModeOn, researchSource: researchSourceOn, vocabHint, tel, biasByBundle, planState, gameConfig, recognitionConfig, researchState, researchConfig, newsState, newsConfig, newsProviders, discourse: discourseRecord, actingSubject, codeDomainActive: domainActive, laneVocab, domainPacks, retrieval: turnRetrieval ?? retrieval });
571
583
  } catch (e) {
572
584
  const ts = new Date().toISOString();
573
585
  const message = e instanceof Error ? e.message : String(e);
@@ -578,7 +590,7 @@ export async function createSession({
578
590
  turns += 1;
579
591
  return { answer: `Something went wrong answering that (${message}). Try rephrasing, or /help.`, end: false, prompt: promptFor(focus) };
580
592
  }
581
- const { record, focus: nextFocus, last: nextLast, end, narrate: nextNarrate, liveReference: nextLiveReference, researchSource: nextResearchSource } = result;
593
+ const { record, focus: nextFocus, last: nextLast, end, narrate: nextNarrate, liveReference: nextLiveReference, codeGraphMode: nextCodeGraphMode, researchSource: nextResearchSource } = result;
582
594
  // "noted — remembered" reports a durable write. In a session that keeps
583
595
  // nothing it is the last word on a fact that dies with the process, so
584
596
  // say where the fact actually went.
@@ -591,10 +603,11 @@ export async function createSession({
591
603
  if ("researchState" in result) researchState = result.researchState;
592
604
  if ("newsState" in result) newsState = result.newsState;
593
605
  if ("discourse" in result) discourseRecord = result.discourse;
594
- // /narrate on|off and /wiki on|off (runCommand) ride the turn RESULT the
595
- // same way a focus update does — apply them to this handle's
596
- // session-scoped state.
606
+ // /narrate on|off, /wiki on|off and /code-graph on|off (runCommand) ride
607
+ // the turn RESULT the same way a focus update does — apply them to this
608
+ // handle's session-scoped state.
597
609
  if (typeof nextNarrate === "boolean") narrateOn = nextNarrate;
610
+ if (typeof nextCodeGraphMode === "boolean") codeGraphModeOn = nextCodeGraphMode;
598
611
  // four-state: false (off), true (rescue on a miss), "supplement" (also
599
612
  // append a cited read-out under every grounded vocabulary answer), or
600
613
  // "always" (widen that to every grounded answer).
@@ -655,6 +668,7 @@ export async function runChat({
655
668
  ephemeral = false,
656
669
  narrate = false,
657
670
  liveReference = false,
671
+ codeGraphMode = false,
658
672
  researchSource = null,
659
673
  memoryBackend = null,
660
674
  toolNamePrefix,
@@ -663,7 +677,7 @@ export async function runChat({
663
677
  // createSession's first-run seed (~2-3s) produces ZERO output until it fully
664
678
  // resolves, which otherwise reads as `npm run chat` hanging with total silence.
665
679
  output.write("tmct — starting…\n");
666
- const session = await createSession({ repoPath, graphPaths, configPath, source, env, cwd, gitRoot, ephemeral, narrate, liveReference, researchSource, memoryBackend, toolNamePrefix, actingSubject });
680
+ const session = await createSession({ repoPath, graphPaths, configPath, source, env, cwd, gitRoot, ephemeral, narrate, liveReference, codeGraphMode, researchSource, memoryBackend, toolNamePrefix, actingSubject });
667
681
 
668
682
  const dim = (s) => (env.NO_COLOR || !output.isTTY ? s : `\x1b[2m${s}\x1b[0m`);
669
683
  for (const line of session.bannerLines) output.write(dim(line) + "\n");