@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
@@ -4,10 +4,10 @@
4
4
  //
5
5
  // resolveExtensions(repoRoot) → { entries: Map<name, ResolvedEntry>, biasByBundle }
6
6
  //
7
- // `human` is the default active bundle (everyday-world vocabulary); `seon`/`conceptnet`
8
- // (code/tech-domain) and four tier-2 bundles ship inactive, activated via `tmct init
9
- // --with-persona`/`--corpus <id>` or a `[extensions.<name>] active = true` override.
10
- // `human-medium`/`human-large` are additive SIZE TIERS of `human`, not separate personas.
7
+ // `human` is the default active bundle (everyday-world vocabulary); every other
8
+ // bundle ships inactive, activated via `tmct init --with-persona`/`--corpus <id>`
9
+ // or a `[extensions.<name>] active = true` override. `human-medium`/`human-large`
10
+ // are additive SIZE TIERS of `human`, not separate personas.
11
11
  //
12
12
  // A `tmct.toml` `[extensions]` table-of-tables may override a recognized builtin, or
13
13
  // declare a new host entry with its own `kind` (corpus | lexicon | templates | pack |
@@ -20,7 +20,7 @@
20
20
  import { isAbsolute, join, resolve, dirname } from "node:path";
21
21
  import { readFile } from "node:fs/promises";
22
22
  import { fileURLToPath } from "node:url";
23
- import { CODE_VOCAB_DATA, EMPTY_VOCAB_DATA as TIER2_EMPTY_VOCAB_DATA } from "./lane-vocab-data.mjs";
23
+ import { CODE_VOCAB_DATA } from "./lane-vocab-data.mjs";
24
24
  import { loadTomlConfig } from "../adapters/toml-config.mjs";
25
25
  import {
26
26
  SEON_CONCEPTS_FILE,
@@ -36,17 +36,15 @@ import {
36
36
  // corpus/namenet/generate.mjs's output — a single small top-up bundle.
37
37
  const NAMENET_DIR = join(dirname(fileURLToPath(import.meta.url)), "..", "..", "corpus", "namenet");
38
38
 
39
+ // The CHILD triples pack: gzipped shards plus a term index, not a slice file,
40
+ // so its entry declares shard_pack_path and seeds through child-seed.mjs.
41
+ const CHILD_PACK_DIR = join(dirname(fileURLToPath(import.meta.url)), "..", "..", "corpus", "child");
42
+
39
43
  // The code domain pack's lane vocabulary — count nouns/class labels, help rows
40
44
  // and the miss-recovery pointer today's code-graph surfaces render, moved out
41
45
  // of chat.mjs so a bare install carries none of it (see mergedLaneVocab).
42
46
  const CODE_VOCAB_FILE = join(dirname(fileURLToPath(import.meta.url)), "..", "..", "corpus", "domains", "code", "vocab.json");
43
47
 
44
- // Empty vocabulary file for tier2 packs: they are authored corpora with no
45
- // extraction adapter, so they need no lane-specific vocabulary, help rows, or
46
- // miss-recovery pointers. A pack entry can have an empty vocab (counts as having
47
- // one declared, but contributes nothing to the merged lane vocabulary).
48
- const TIER2_EMPTY_VOCAB_FILE = join(dirname(fileURLToPath(import.meta.url)), "..", "..", "corpus", "tier2", "vocab-empty.json");
49
-
50
48
  export const EXTENSION_KINDS = Object.freeze(["corpus", "lexicon", "templates", "pack", "ontology"]);
51
49
 
52
50
  // The definitional-band-first predicate order for the ConceptNet seed (re-declared,
@@ -119,38 +117,6 @@ function builtinExtensions() {
119
117
  corpusPath: join(TIER2_DIR, "human-large.jsonl"),
120
118
  provenancePrefix: "corpus:human-large",
121
119
  },
122
- // Tier2 packs: authored language-domain bundles (AWS, Python, Java) without
123
- // extraction adapters (no tmct index for these domains yet). Each bundles
124
- // its corpus unchanged and an empty lane vocabulary, so a bare install stays
125
- // domain-neutral (no AWS/Python/Java vocabulary reaches banners or help text
126
- // without explicit activation).
127
- "tier2-aws": {
128
- kind: "pack",
129
- active: false,
130
- corpusPath: join(TIER2_DIR, "aws.jsonl"),
131
- provenancePrefix: "corpus:tier2-aws",
132
- vocabPath: TIER2_EMPTY_VOCAB_FILE,
133
- vocabData: TIER2_EMPTY_VOCAB_DATA,
134
- groundingKind: "taught-only",
135
- },
136
- "tier2-python": {
137
- kind: "pack",
138
- active: false,
139
- corpusPath: join(TIER2_DIR, "python.jsonl"),
140
- provenancePrefix: "corpus:tier2-python",
141
- vocabPath: TIER2_EMPTY_VOCAB_FILE,
142
- vocabData: TIER2_EMPTY_VOCAB_DATA,
143
- groundingKind: "taught-only",
144
- },
145
- "tier2-java": {
146
- kind: "pack",
147
- active: false,
148
- corpusPath: join(TIER2_DIR, "java.jsonl"),
149
- provenancePrefix: "corpus:tier2-java",
150
- vocabPath: TIER2_EMPTY_VOCAB_FILE,
151
- vocabData: TIER2_EMPTY_VOCAB_DATA,
152
- groundingKind: "taught-only",
153
- },
154
120
  "tier2-general": {
155
121
  kind: "corpus",
156
122
  active: false,
@@ -179,6 +145,16 @@ function builtinExtensions() {
179
145
  corpusPath: join(NAMENET_DIR, "namenet.jsonl"),
180
146
  provenancePrefix: "corpus:namenet",
181
147
  },
148
+ // scripts/fetch-child-corpus.mjs's output: the ConceptNet edges around the
149
+ // vocabulary a child has by about age eight. The clean-miss cascade already
150
+ // reads it one term at a time; activating it here seeds the whole pack, so
151
+ // the reasoning layers see the edges instead of only a miss lookup.
152
+ child: {
153
+ kind: "corpus",
154
+ active: false,
155
+ shardPackPath: CHILD_PACK_DIR,
156
+ provenancePrefix: "corpus:child",
157
+ },
182
158
  };
183
159
  }
184
160
 
@@ -196,8 +172,8 @@ export function validateExtensionEntry(name, entry) {
196
172
  if (entry.active !== undefined && typeof entry.active !== "boolean") {
197
173
  throw new Error(`extension "${name}": "active" must be a boolean`);
198
174
  }
199
- if (entry.kind === "corpus" && !entry.corpusPath) {
200
- throw new Error(`extension "${name}": a "corpus" entry needs corpus_path`);
175
+ if (entry.kind === "corpus" && !entry.corpusPath && !entry.shardPackPath) {
176
+ throw new Error(`extension "${name}": a "corpus" entry needs corpus_path or shard_pack_path`);
201
177
  }
202
178
  if (entry.kind === "ontology" && !entry.corpusPath) {
203
179
  throw new Error(`extension "${name}": an "ontology" entry needs ontology_path`);
@@ -208,8 +184,8 @@ export function validateExtensionEntry(name, entry) {
208
184
  if (entry.kind === "templates" && !entry.templatesPath) {
209
185
  throw new Error(`extension "${name}": a "templates" entry needs templates_path`);
210
186
  }
211
- if (entry.kind === "pack" && !entry.corpusPath && !entry.lexiconPath && !entry.templatesPath && !entry.phrasebookPath) {
212
- throw new Error(`extension "${name}": a "pack" entry needs at least one of corpus_path/lexicon_path/templates_path/phrasebook_path`);
187
+ if (entry.kind === "pack" && !entry.corpusPath && !entry.shardPackPath && !entry.lexiconPath && !entry.templatesPath && !entry.phrasebookPath) {
188
+ throw new Error(`extension "${name}": a "pack" entry needs at least one of corpus_path/shard_pack_path/lexicon_path/templates_path/phrasebook_path`);
213
189
  }
214
190
  if (entry.limit !== undefined && !Number.isFinite(entry.limit)) {
215
191
  throw new Error(`extension "${name}": "limit" must be a finite number`);
@@ -239,6 +215,7 @@ function mergeExtensionEntry(name, builtin, override, repoRoot) {
239
215
  const paths = [
240
216
  ["corpus_path", "corpusPath"],
241
217
  ["ontology_path", "corpusPath"], // alias: an "ontology" entry's own path key, same internal field as "corpus"
218
+ ["shard_pack_path", "shardPackPath"],
242
219
  ["lexicon_path", "lexiconPath"],
243
220
  ["templates_path", "templatesPath"],
244
221
  ["phrasebook_path", "phrasebookPath"],
@@ -307,6 +284,16 @@ export async function resolveExtensions(repoRoot, { configFile } = {}) {
307
284
 
308
285
  // ---- Part 2: the unified corpus loader loop ---------------------------------
309
286
 
287
+ /** Whether this entry has corpus facts to write: a `corpus`/`ontology` entry, or
288
+ * a `pack` entry that declares a corpus file. The one rule both the seeding
289
+ * loop and `tmct init`/`tmct import`'s status line read, so a bundle can never
290
+ * seed under one and read as "nothing to seed" under the other. */
291
+ export function isSeedableEntry(entry) {
292
+ if (!entry) return false;
293
+ if (entry.kind === "corpus" || entry.kind === "ontology") return true;
294
+ return entry.kind === "pack" && Boolean(entry.corpusPath || entry.shardPackPath);
295
+ }
296
+
310
297
  /** Seed every ACTIVE `corpus`/`ontology`-kind entry, plus any ACTIVE `pack`-kind entry
311
298
  * that declares a `corpusPath`, into `repo`'s memory, one seedMemory() call per bundle.
312
299
  * Shared by chat.mjs's first-run bootstrap, `tmct init`'s seed step, and
@@ -328,18 +315,24 @@ export async function seedActiveCorpusEntries(repo, entries, opts = {}) {
328
315
  let total = 0;
329
316
  for (const [name, entry] of entries instanceof Map ? entries : new Map()) {
330
317
  if (!entry.active) continue;
331
- const seedable = entry.kind === "corpus" || entry.kind === "ontology" || (entry.kind === "pack" && entry.corpusPath);
332
- if (!seedable) continue;
318
+ if (!isSeedableEntry(entry)) continue;
333
319
  try {
334
- const res = await seedMemory(repo, {
335
- slicePath: entry.corpusPath,
336
- mapPath: entry.mapPath,
337
- provenancePrefix: entry.provenancePrefix,
338
- limit: entry.limit,
339
- prefer: entry.prefer,
340
- captureUnknownContext,
341
- unknownContextLimit,
342
- });
320
+ const res = entry.shardPackPath
321
+ ? await (await import("../adapters/corpus/child-seed.mjs")).seedChildPack(repo, {
322
+ packDir: entry.shardPackPath,
323
+ provenancePrefix: entry.provenancePrefix,
324
+ limit: entry.limit,
325
+ prefer: entry.prefer,
326
+ })
327
+ : await seedMemory(repo, {
328
+ slicePath: entry.corpusPath,
329
+ mapPath: entry.mapPath,
330
+ provenancePrefix: entry.provenancePrefix,
331
+ limit: entry.limit,
332
+ prefer: entry.prefer,
333
+ captureUnknownContext,
334
+ unknownContextLimit,
335
+ });
343
336
  perBundle[name] = { appended: res.appended, skipped: res.skipped, total: res.total };
344
337
  appended += res.appended;
345
338
  skipped += res.skipped;