@polycode-projects/the-mechanical-code-talker 5.0.15 → 5.0.16
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.
- package/README.md +11 -3
- package/bin/tmct.mjs +16 -0
- package/corpus/LICENSES.json +3 -3
- package/corpus/domains/code/LICENSE-NOTICE +43 -0
- package/corpus/{seon → domains/code}/README.md +22 -24
- package/corpus/domains/code/vocab.json +43 -0
- package/corpus/reference/manifest.json +126 -126
- package/corpus/reference/shards/ref-00.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-01.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-02.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-03.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-04.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-05.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-06.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-07.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-08.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-09.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-0a.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-0b.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-0c.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-0d.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-0e.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-0f.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-10.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-11.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-12.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-13.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-14.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-15.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-16.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-17.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-18.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-19.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-1a.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-1b.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-1c.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-1d.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-1e.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-1f.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-20.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-21.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-22.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-23.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-24.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-25.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-26.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-27.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-28.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-29.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-2a.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-2b.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-2c.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-2d.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-2e.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-2f.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-30.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-31.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-32.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-33.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-34.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-35.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-36.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-37.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-38.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-39.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-3a.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-3b.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-3c.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-3d.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-3e.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-3f.jsonl.gz +0 -0
- package/corpus/tier2/vocab-empty.json +6 -0
- package/data/templates/responses.jsonl +3 -0
- package/package.json +17 -1
- package/src/adapters/corpus/conceptnet.mjs +7 -3
- package/src/adapters/corpus/courtesy.mjs +129 -0
- package/src/adapters/corpus/research-source.mjs +120 -0
- package/src/adapters/corpus/wikidata-live.mjs +262 -0
- package/src/adapters/corpus/wikipedia-live.mjs +52 -108
- package/src/domain/codegraph.mjs +10 -2
- package/src/domain/grammar/lexicon-core.json +1 -0
- package/src/domain/reference-pack.mjs +61 -9
- package/src/services/chat-session.mjs +48 -7
- package/src/services/chat.mjs +359 -115
- package/src/services/extensions.mjs +203 -3
- package/src/services/init.mjs +6 -5
- package/src/services/lane-vocab-data.mjs +56 -0
- package/src/surfaces/web/claims-browser-entry.mjs +26 -0
- package/src/surfaces/web/memory-ask-browser.bundle.js +130 -128
- package/src/surfaces/web/planner-instances.mjs +152 -0
- package/src/tools/handlers/tmct-untested.mjs +2 -2
- package/src/tools/server.mjs +9 -4
- package/corpus/seon/LICENSE-NOTICE +0 -37
- /package/corpus/{seon → domains/code}/concepts.jsonl +0 -0
- /package/corpus/{seon → domains/code}/definitions.jsonl +0 -0
- /package/corpus/{seon → domains/code}/relations.jsonl +0 -0
|
@@ -20,6 +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
24
|
import { loadTomlConfig } from "../adapters/toml-config.mjs";
|
|
24
25
|
import {
|
|
25
26
|
SEON_CONCEPTS_FILE,
|
|
@@ -35,6 +36,17 @@ import {
|
|
|
35
36
|
// corpus/namenet/generate.mjs's output — a single small top-up bundle.
|
|
36
37
|
const NAMENET_DIR = join(dirname(fileURLToPath(import.meta.url)), "..", "..", "corpus", "namenet");
|
|
37
38
|
|
|
39
|
+
// The code domain pack's lane vocabulary — count nouns/class labels, help rows
|
|
40
|
+
// and the miss-recovery pointer today's code-graph surfaces render, moved out
|
|
41
|
+
// of chat.mjs so a bare install carries none of it (see mergedLaneVocab).
|
|
42
|
+
const CODE_VOCAB_FILE = join(dirname(fileURLToPath(import.meta.url)), "..", "..", "corpus", "domains", "code", "vocab.json");
|
|
43
|
+
|
|
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
|
+
|
|
38
50
|
export const EXTENSION_KINDS = Object.freeze(["corpus", "lexicon", "templates", "pack", "ontology"]);
|
|
39
51
|
|
|
40
52
|
// The definitional-band-first predicate order for the ConceptNet seed (re-declared,
|
|
@@ -52,6 +64,23 @@ function builtinExtensions() {
|
|
|
52
64
|
corpusPath: SEON_CONCEPTS_FILE,
|
|
53
65
|
provenancePrefix: "corpus:seon",
|
|
54
66
|
},
|
|
67
|
+
// The code DOMAIN PACK: the seon corpus plus the lane vocabulary (count
|
|
68
|
+
// nouns, help rows, the miss-recovery pointer) a code-graph session needs
|
|
69
|
+
// — see mergedLaneVocab. Keeps seon's own provenance prefix (the curated-
|
|
70
|
+
// definitions gate keys on "corpus:seon" rows regardless of which entry
|
|
71
|
+
// seeded them). Its grounding channel is an extraction adapter: `tmct
|
|
72
|
+
// index` (and the graphPaths provider seam) is the deterministic path
|
|
73
|
+
// from a repo's own source to the facts this pack's vocabulary describes.
|
|
74
|
+
code: {
|
|
75
|
+
kind: "pack",
|
|
76
|
+
active: false,
|
|
77
|
+
corpusPath: SEON_CONCEPTS_FILE,
|
|
78
|
+
provenancePrefix: "corpus:seon",
|
|
79
|
+
vocabPath: CODE_VOCAB_FILE,
|
|
80
|
+
vocabData: CODE_VOCAB_DATA,
|
|
81
|
+
groundingKind: "extraction",
|
|
82
|
+
groundingAdapter: "tmct index (the graphPaths provider seam)",
|
|
83
|
+
},
|
|
55
84
|
// Opt-in too: the committed slice is tech-domain-filtered, equally biased.
|
|
56
85
|
conceptnet: {
|
|
57
86
|
kind: "corpus",
|
|
@@ -83,23 +112,37 @@ function builtinExtensions() {
|
|
|
83
112
|
corpusPath: join(TIER2_DIR, "human-large.jsonl"),
|
|
84
113
|
provenancePrefix: "corpus:human-large",
|
|
85
114
|
},
|
|
115
|
+
// Tier2 packs: authored language-domain bundles (AWS, Python, Java) without
|
|
116
|
+
// extraction adapters (no tmct index for these domains yet). Each bundles
|
|
117
|
+
// its corpus unchanged and an empty lane vocabulary, so a bare install stays
|
|
118
|
+
// domain-neutral (no AWS/Python/Java vocabulary reaches banners or help text
|
|
119
|
+
// without explicit activation).
|
|
86
120
|
"tier2-aws": {
|
|
87
|
-
kind: "
|
|
121
|
+
kind: "pack",
|
|
88
122
|
active: false,
|
|
89
123
|
corpusPath: join(TIER2_DIR, "aws.jsonl"),
|
|
90
124
|
provenancePrefix: "corpus:tier2-aws",
|
|
125
|
+
vocabPath: TIER2_EMPTY_VOCAB_FILE,
|
|
126
|
+
vocabData: TIER2_EMPTY_VOCAB_DATA,
|
|
127
|
+
groundingKind: "taught-only",
|
|
91
128
|
},
|
|
92
129
|
"tier2-python": {
|
|
93
|
-
kind: "
|
|
130
|
+
kind: "pack",
|
|
94
131
|
active: false,
|
|
95
132
|
corpusPath: join(TIER2_DIR, "python.jsonl"),
|
|
96
133
|
provenancePrefix: "corpus:tier2-python",
|
|
134
|
+
vocabPath: TIER2_EMPTY_VOCAB_FILE,
|
|
135
|
+
vocabData: TIER2_EMPTY_VOCAB_DATA,
|
|
136
|
+
groundingKind: "taught-only",
|
|
97
137
|
},
|
|
98
138
|
"tier2-java": {
|
|
99
|
-
kind: "
|
|
139
|
+
kind: "pack",
|
|
100
140
|
active: false,
|
|
101
141
|
corpusPath: join(TIER2_DIR, "java.jsonl"),
|
|
102
142
|
provenancePrefix: "corpus:tier2-java",
|
|
143
|
+
vocabPath: TIER2_EMPTY_VOCAB_FILE,
|
|
144
|
+
vocabData: TIER2_EMPTY_VOCAB_DATA,
|
|
145
|
+
groundingKind: "taught-only",
|
|
103
146
|
},
|
|
104
147
|
"tier2-general": {
|
|
105
148
|
kind: "corpus",
|
|
@@ -193,6 +236,7 @@ function mergeExtensionEntry(name, builtin, override, repoRoot) {
|
|
|
193
236
|
["templates_path", "templatesPath"],
|
|
194
237
|
["phrasebook_path", "phrasebookPath"],
|
|
195
238
|
["map_path", "mapPath"],
|
|
239
|
+
["vocab_path", "vocabPath"],
|
|
196
240
|
];
|
|
197
241
|
for (const [rawKey, key] of paths) {
|
|
198
242
|
if (override[rawKey] !== undefined) entry[key] = resolvePathMaybe(repoRoot, override[rawKey]);
|
|
@@ -205,6 +249,13 @@ function mergeExtensionEntry(name, builtin, override, repoRoot) {
|
|
|
205
249
|
else if (builtin?.limit !== undefined) entry.limit = builtin.limit;
|
|
206
250
|
if (override.prefer !== undefined) entry.prefer = override.prefer;
|
|
207
251
|
else if (builtin?.prefer !== undefined) entry.prefer = builtin.prefer;
|
|
252
|
+
// The grounding-channel declaration (validateExtensionPack requires it on a
|
|
253
|
+
// "pack" candidate): "extraction" names an adapter (grounding_adapter);
|
|
254
|
+
// "taught-only" says the pack's facts grow solely through the teach lane.
|
|
255
|
+
if (override.grounding_kind !== undefined) entry.groundingKind = String(override.grounding_kind);
|
|
256
|
+
else if (builtin?.groundingKind !== undefined) entry.groundingKind = builtin.groundingKind;
|
|
257
|
+
if (override.grounding_adapter !== undefined) entry.groundingAdapter = String(override.grounding_adapter);
|
|
258
|
+
else if (builtin?.groundingAdapter !== undefined) entry.groundingAdapter = builtin.groundingAdapter;
|
|
208
259
|
return entry;
|
|
209
260
|
}
|
|
210
261
|
|
|
@@ -329,6 +380,117 @@ export async function mergedLexiconExtra(entries, biasByBundle = {}) {
|
|
|
329
380
|
return merged;
|
|
330
381
|
}
|
|
331
382
|
|
|
383
|
+
// ---- Part 3b: lane-vocabulary merge (vocab_path) -----------------------------
|
|
384
|
+
|
|
385
|
+
/** Merge every ACTIVE `pack`-kind entry's declared `vocab_path` file into one
|
|
386
|
+
* lane-vocabulary object: `countNouns`/`classLabels` (the count lane's noun
|
|
387
|
+
* table), `helpRows` (the command rows a code-domain pack contributes to
|
|
388
|
+
* `/help`) and `missRecoveryPointer` (the remedy line an empty session's
|
|
389
|
+
* banner offers). Bundles merge in ascending bias order, same rule as
|
|
390
|
+
* mergedLexiconExtra: a higher-bias bundle's same-key entry wins.
|
|
391
|
+
* `helpRows` and `countNouns`/`classLabels` are additive across bundles;
|
|
392
|
+
* `missRecoveryPointer` is single-valued, so the highest-bias bundle to
|
|
393
|
+
* declare one wins outright. No active pack with a vocab_path → every field
|
|
394
|
+
* comes back empty — a bare session carries no code-domain vocabulary. */
|
|
395
|
+
export async function mergedLaneVocab(entries, biasByBundle = {}) {
|
|
396
|
+
const candidates = [];
|
|
397
|
+
for (const [name, entry] of entries instanceof Map ? entries : new Map()) {
|
|
398
|
+
if (!entry.active) continue;
|
|
399
|
+
if (entry.kind !== "pack") continue;
|
|
400
|
+
if (!entry.vocabPath && !entry.vocabData) continue;
|
|
401
|
+
candidates.push({ name, path: entry.vocabPath, data: entry.vocabData, bias: biasByBundle[name] ?? 1 });
|
|
402
|
+
}
|
|
403
|
+
const merged = { countNouns: {}, classLabels: {}, helpRows: [], missRecoveryPointer: "" };
|
|
404
|
+
if (!candidates.length) return merged;
|
|
405
|
+
candidates.sort((a, b) => a.bias - b.bias);
|
|
406
|
+
for (const c of candidates) {
|
|
407
|
+
let raw;
|
|
408
|
+
if (c.data) {
|
|
409
|
+
raw = c.data;
|
|
410
|
+
} else {
|
|
411
|
+
try {
|
|
412
|
+
raw = JSON.parse(await readFile(c.path, "utf8"));
|
|
413
|
+
} catch (e) {
|
|
414
|
+
throw new Error(`extension "${c.name}": vocab file ${c.path} — ${e && e.message ? e.message : e}`);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
Object.assign(merged.countNouns, raw.countNouns || {});
|
|
418
|
+
Object.assign(merged.classLabels, raw.classLabels || {});
|
|
419
|
+
if (Array.isArray(raw.helpRows)) merged.helpRows.push(...raw.helpRows);
|
|
420
|
+
if (raw.missRecoveryPointer) merged.missRecoveryPointer = raw.missRecoveryPointer;
|
|
421
|
+
}
|
|
422
|
+
return merged;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
let cachedDefaultCodeLaneVocab = null;
|
|
426
|
+
/** The shipped code pack's OWN lane vocabulary, loaded unconditionally
|
|
427
|
+
* (memoized — the file never changes mid-process). The safety net a caller
|
|
428
|
+
* holding a real code graph falls back to when the `code` pack itself isn't
|
|
429
|
+
* formally active in tmct.toml — the same "a real graph is enough" rule
|
|
430
|
+
* chat.mjs's own codeDomainActive already applies to the domain-active
|
|
431
|
+
* predicate. Never consulted when the domain is inactive. */
|
|
432
|
+
export function defaultCodeLaneVocab() {
|
|
433
|
+
if (!cachedDefaultCodeLaneVocab) {
|
|
434
|
+
const code = { ...builtinExtensions().code, active: true };
|
|
435
|
+
cachedDefaultCodeLaneVocab = mergedLaneVocab(new Map([["code", code]]), {});
|
|
436
|
+
}
|
|
437
|
+
return cachedDefaultCodeLaneVocab;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
/** Read one pack entry's own declaration into the shape a capability listing
|
|
441
|
+
* renders: the pack's name, the grounding channel it declares
|
|
442
|
+
* (grounding_kind/grounding_adapter) and how much its `vocab_path` file adds
|
|
443
|
+
* to the lane merge. A pack whose vocab file is missing or malformed still
|
|
444
|
+
* names itself and its grounding channel, with nothing counted — the listing
|
|
445
|
+
* reports what the pack declares, and never invents a contribution. */
|
|
446
|
+
async function declaredPackSummary(name, entry) {
|
|
447
|
+
const summary = {
|
|
448
|
+
name,
|
|
449
|
+
groundingKind: entry.groundingKind || "",
|
|
450
|
+
groundingAdapter: entry.groundingAdapter || "",
|
|
451
|
+
commandCount: 0,
|
|
452
|
+
countNounCount: 0,
|
|
453
|
+
};
|
|
454
|
+
if (!entry.vocabPath) return summary;
|
|
455
|
+
try {
|
|
456
|
+
const raw = JSON.parse(await readFile(entry.vocabPath, "utf8"));
|
|
457
|
+
summary.commandCount = Array.isArray(raw.helpRows) ? raw.helpRows.length : 0;
|
|
458
|
+
summary.countNounCount = Object.keys(raw.countNouns || {}).length;
|
|
459
|
+
} catch { /* an unreadable vocab file lists as a pack that adds nothing */ }
|
|
460
|
+
return summary;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
/** Every ACTIVE `pack`-kind entry, summarized from its own declaration, in
|
|
464
|
+
* ascending bias order (name breaks a tie, so the listing is stable). The
|
|
465
|
+
* read-side companion to mergedLaneVocab: that merges what packs contribute,
|
|
466
|
+
* this says which packs contributed it. No active pack → an empty list, and
|
|
467
|
+
* a listing that names no domain at all. */
|
|
468
|
+
export async function activeDomainPacks(entries, biasByBundle = {}) {
|
|
469
|
+
const candidates = [];
|
|
470
|
+
for (const [name, entry] of entries instanceof Map ? entries : new Map()) {
|
|
471
|
+
if (!entry.active) continue;
|
|
472
|
+
if (entry.kind !== "pack") continue;
|
|
473
|
+
candidates.push({ name, entry, bias: biasByBundle[name] ?? 1 });
|
|
474
|
+
}
|
|
475
|
+
candidates.sort((a, b) => a.bias - b.bias || a.name.localeCompare(b.name));
|
|
476
|
+
const summaries = [];
|
|
477
|
+
for (const c of candidates) summaries.push(await declaredPackSummary(c.name, c.entry));
|
|
478
|
+
return summaries;
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
let cachedDefaultCodeDomainPacks = null;
|
|
482
|
+
/** The shipped code pack's OWN declaration as a one-entry listing — the same
|
|
483
|
+
* "a real graph is enough" fallback defaultCodeLaneVocab serves, for the
|
|
484
|
+
* caller that holds a real code graph without the `code` pack formally
|
|
485
|
+
* active in tmct.toml. Never consulted when the domain is inactive. */
|
|
486
|
+
export function defaultCodeDomainPacks() {
|
|
487
|
+
if (!cachedDefaultCodeDomainPacks) {
|
|
488
|
+
const code = { ...builtinExtensions().code, active: true };
|
|
489
|
+
cachedDefaultCodeDomainPacks = activeDomainPacks(new Map([["code", code]]), {});
|
|
490
|
+
}
|
|
491
|
+
return cachedDefaultCodeDomainPacks;
|
|
492
|
+
}
|
|
493
|
+
|
|
332
494
|
// ---- Part 4: `tmct extend --validate <dir>` ---------------------------------
|
|
333
495
|
|
|
334
496
|
/** Validate one CANDIDATE extension pack entry against a directory, reusing the existing
|
|
@@ -381,5 +543,43 @@ export async function validateExtensionPack(dir, candidate) {
|
|
|
381
543
|
}
|
|
382
544
|
}
|
|
383
545
|
|
|
546
|
+
if (candidate.vocabPath) {
|
|
547
|
+
const path = abs(candidate.vocabPath);
|
|
548
|
+
try {
|
|
549
|
+
const raw = JSON.parse(await readFile(path, "utf8"));
|
|
550
|
+
const countNouns = raw.countNouns && typeof raw.countNouns === "object" ? Object.keys(raw.countNouns).length : 0;
|
|
551
|
+
const classLabels = raw.classLabels && typeof raw.classLabels === "object" ? Object.keys(raw.classLabels).length : 0;
|
|
552
|
+
const helpRows = Array.isArray(raw.helpRows) ? raw.helpRows.length : 0;
|
|
553
|
+
results.push({ kind: "vocab", path, ok: true, counts: { countNouns, classLabels, helpRows } });
|
|
554
|
+
} catch (e) {
|
|
555
|
+
results.push({ kind: "vocab", path, ok: false, error: e && e.message ? e.message : String(e) });
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
// The grounding-channel declaration — required on a "pack" candidate only
|
|
560
|
+
// (a plain corpus/lexicon/templates/ontology entry declares no grounding):
|
|
561
|
+
// exactly one of an extraction adapter (named) or explicit taught-only
|
|
562
|
+
// mode. A pack declaring neither is symbols defined in symbols, with no
|
|
563
|
+
// route from a domain's own artifacts back to the facts it describes.
|
|
564
|
+
if (candidate.kind === "pack") {
|
|
565
|
+
const gk = candidate.groundingKind;
|
|
566
|
+
if (gk !== "extraction" && gk !== "taught-only") {
|
|
567
|
+
results.push({
|
|
568
|
+
kind: "grounding", path: "(pack manifest)", ok: false,
|
|
569
|
+
error: `a "pack" entry needs "grounding_kind" of "extraction" or "taught-only" (got ${JSON.stringify(gk ?? null)})`,
|
|
570
|
+
});
|
|
571
|
+
} else if (gk === "extraction" && !candidate.groundingAdapter) {
|
|
572
|
+
results.push({
|
|
573
|
+
kind: "grounding", path: "(pack manifest)", ok: false,
|
|
574
|
+
error: 'grounding_kind "extraction" needs "grounding_adapter" naming the adapter',
|
|
575
|
+
});
|
|
576
|
+
} else {
|
|
577
|
+
results.push({
|
|
578
|
+
kind: "grounding", path: "(pack manifest)", ok: true,
|
|
579
|
+
counts: gk === "extraction" ? { channel: gk, adapter: candidate.groundingAdapter } : { channel: gk },
|
|
580
|
+
});
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
|
|
384
584
|
return { ok: results.length > 0 && results.every((r) => r.ok), results };
|
|
385
585
|
}
|
package/src/services/init.mjs
CHANGED
|
@@ -52,11 +52,12 @@ export function defaultConfig() {
|
|
|
52
52
|
|
|
53
53
|
/** `tmct init --with-persona <name>` presets: a named bundle of `extensions`/`bias`
|
|
54
54
|
* overrides written into tmct.toml. `human` makes the implicit default explicit; `code`
|
|
55
|
-
*
|
|
56
|
-
*
|
|
55
|
+
* activates the `code` domain pack (the seon ontology plus its lane vocabulary — count
|
|
56
|
+
* nouns, help rows, the miss-recovery pointer) alongside `conceptnet`; `empty`
|
|
57
|
+
* deactivates `human`, leaving a repo genuinely empty of corpus facts. */
|
|
57
58
|
export const PERSONA_PRESETS = Object.freeze({
|
|
58
59
|
human: { extensions: {}, bias: { human: 1.0 } },
|
|
59
|
-
code: { extensions: {
|
|
60
|
+
code: { extensions: { code: { active: true }, conceptnet: { active: true } }, bias: { code: 1.0, conceptnet: 1.0 } },
|
|
60
61
|
empty: { extensions: { human: { active: false } }, bias: {} },
|
|
61
62
|
});
|
|
62
63
|
|
|
@@ -151,7 +152,7 @@ backend = ${JSON.stringify(config.memory.backend)}
|
|
|
151
152
|
if (!Object.keys(extras).length) return out;
|
|
152
153
|
return `${out}
|
|
153
154
|
# Extension packs + bias (src/services/extensions.mjs) — written by \`tmct init --with-persona\`
|
|
154
|
-
# or a manual edit. Recognized names (human, seon, conceptnet, tier2-aws,
|
|
155
|
+
# or a manual edit. Recognized names (human, seon, code, conceptnet, tier2-aws,
|
|
155
156
|
# tier2-python, tier2-java, tier2-general) override the shipped defaults; any
|
|
156
157
|
# other name declares a new host-supplied bundle (needs its own "kind").
|
|
157
158
|
# [bias] is a flat bundle-name -> weight table consumed by
|
|
@@ -317,7 +318,7 @@ export async function initRepo(dir, { force = false, seed, env = process.env, pe
|
|
|
317
318
|
if (allFailed) throw new Error(perBundle[bundleNames[0]].error);
|
|
318
319
|
seedResult = {
|
|
319
320
|
appended, skipped, total, perBundle,
|
|
320
|
-
|
|
321
|
+
code: perBundle.code?.appended || 0,
|
|
321
322
|
conceptnet: perBundle.conceptnet?.appended || 0,
|
|
322
323
|
};
|
|
323
324
|
const markerNew = !(await exists(paths.marker));
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// The built-in packs' lane vocabulary, carried as code so it travels inside
|
|
2
|
+
// browser bundles (no filesystem there). Third-party packs still load their
|
|
3
|
+
// vocab_path files through mergedLaneVocab's readFile path, which only runs in
|
|
4
|
+
// Node. Each object must stay deep-equal to its pack's on-disk vocab file —
|
|
5
|
+
// a test pins the sync in both directions.
|
|
6
|
+
|
|
7
|
+
export const CODE_VOCAB_DATA = Object.freeze({
|
|
8
|
+
countNouns: {
|
|
9
|
+
class: "Class", classes: "Class",
|
|
10
|
+
function: "Function", functions: "Function", func: "Function", funcs: "Function",
|
|
11
|
+
module: "Module", modules: "Module", file: "Module", files: "Module",
|
|
12
|
+
package: "Package", packages: "Package",
|
|
13
|
+
method: "Method", methods: "Method",
|
|
14
|
+
attribute: "Attribute", attributes: "Attribute",
|
|
15
|
+
variable: "GlobalVariable", variables: "GlobalVariable", global: "GlobalVariable", globals: "GlobalVariable",
|
|
16
|
+
commit: "Commit", commits: "Commit",
|
|
17
|
+
session: "Session", sessions: "Session",
|
|
18
|
+
},
|
|
19
|
+
classLabels: {
|
|
20
|
+
Class: ["class", "classes"],
|
|
21
|
+
Function: ["function", "functions"],
|
|
22
|
+
Module: ["module", "modules"],
|
|
23
|
+
Package: ["package", "packages"],
|
|
24
|
+
Method: ["method", "methods"],
|
|
25
|
+
Attribute: ["attribute", "attributes"],
|
|
26
|
+
GlobalVariable: ["variable", "variables"],
|
|
27
|
+
Commit: ["commit", "commits"],
|
|
28
|
+
Session: ["session", "sessions"],
|
|
29
|
+
},
|
|
30
|
+
helpRows: [
|
|
31
|
+
["/find <query>", "lexical search across the graph"],
|
|
32
|
+
["/search <query>", "alias of /find"],
|
|
33
|
+
["/context <symbol>", "the sized edit bundle for a symbol (start here to change code)"],
|
|
34
|
+
["/snippet <symbol>", "exact source of one function/class/method"],
|
|
35
|
+
["/describe <symbol>", "a symbol's definition, kind and relations"],
|
|
36
|
+
["/signature <symbol>", "a symbol's signature only"],
|
|
37
|
+
["/members <class>", "the methods/attributes of a class"],
|
|
38
|
+
["/subclasses <class>", "the subclasses of a class"],
|
|
39
|
+
["/impact <module>", "what a change to this module or symbol reaches (impact closure)"],
|
|
40
|
+
["/callers <symbol>", "functions that call this symbol"],
|
|
41
|
+
["/callees <symbol>", "functions this symbol calls"],
|
|
42
|
+
["/tests <symbol>", "the tests covering this symbol"],
|
|
43
|
+
["/untested", "symbols with no covering test"],
|
|
44
|
+
["/history <symbol>", "the commit history of this symbol"],
|
|
45
|
+
["/exports <module>", "a module's public exports"],
|
|
46
|
+
["/arch [package]", "the architecture overview (optional package filter)"],
|
|
47
|
+
],
|
|
48
|
+
missRecoveryPointer: "for code structure, index this repo with `tmct index`, or point me at a .tmct/graph.json with --repo <path> (or try `npm run example:mini`).",
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
export const EMPTY_VOCAB_DATA = Object.freeze({
|
|
52
|
+
countNouns: {},
|
|
53
|
+
classLabels: {},
|
|
54
|
+
helpRows: [],
|
|
55
|
+
missRecoveryPointer: "",
|
|
56
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// claims-browser-entry.mjs — the esbuild entry for the claims page's
|
|
2
|
+
// "run it on this device" button (public/claims-browser.bundle.js, built by
|
|
3
|
+
// scripts/build-claims-bundle.mjs).
|
|
4
|
+
//
|
|
5
|
+
// solvePlannerInstance is planner-instances.mjs's own function (this same
|
|
6
|
+
// directory), the same per-instance solve entry point
|
|
7
|
+
// scripts/claims/claim-planner.mjs drives (via scripts/claims/planner-
|
|
8
|
+
// domains.mjs's re-export) to produce results/claims/planner.json. A
|
|
9
|
+
// visitor's click and the committed number come from the identical code
|
|
10
|
+
// path — teach one domain's rule sentences plus one instance's starting
|
|
11
|
+
// state through the real chat turn engine, then time the solve — so the
|
|
12
|
+
// page never carries a second, lighter "browser demo" implementation that
|
|
13
|
+
// could quietly diverge from what was actually measured.
|
|
14
|
+
//
|
|
15
|
+
// registerWinkModel is re-exported for the same reason plan-browser-entry.mjs
|
|
16
|
+
// re-exports it as tmct.page.registerWinkModel: the hanoi lesson's "moving a
|
|
17
|
+
// disk onto a target makes the disk rest on the target" sentence needs a
|
|
18
|
+
// real lemmatiser to reduce "moving" to "move", and the browser bundle keeps
|
|
19
|
+
// wink-nlp's ~1 MB model out of THIS bundle rather than duplicating it — the
|
|
20
|
+
// page's own script loads the site's one shared ./vendor/wink.js and
|
|
21
|
+
// registers it before the first solve, the identical bounded-race pattern
|
|
22
|
+
// plan-viz.mjs's tryLoadWink already uses.
|
|
23
|
+
import { solvePlannerInstance } from "./planner-instances.mjs";
|
|
24
|
+
import { registerWinkModel } from "../../adapters/wink-model.mjs";
|
|
25
|
+
|
|
26
|
+
globalThis.tmctClaims = { solvePlannerInstance, registerWinkModel };
|