@polycode-projects/the-mechanical-code-talker 5.0.15 → 5.0.17
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 +12 -3
- package/bin/tmct.mjs +52 -3
- 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 +19 -1
- package/src/adapters/corpus/conceptnet.mjs +7 -3
- package/src/adapters/corpus/courtesy.mjs +129 -0
- package/src/adapters/corpus/research-source.mjs +137 -0
- package/src/adapters/corpus/wikidata-live.mjs +262 -0
- package/src/adapters/corpus/wikipedia-live.mjs +83 -116
- package/src/domain/cli-verbs.mjs +2 -0
- 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-page-viz.mjs +9 -6
- package/src/services/chat-session.mjs +65 -9
- package/src/services/chat.mjs +395 -121
- package/src/services/extensions.mjs +203 -3
- package/src/services/init.mjs +27 -6
- package/src/services/lane-vocab-data.mjs +56 -0
- package/src/services/research.mjs +36 -14
- 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
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
// planner-instances.mjs — the three taught puzzles claim-planner.mjs measures,
|
|
2
|
+
// and the one per-instance solve function every caller (that rig, and
|
|
3
|
+
// claims-browser-entry.mjs's own "run it on this device" button) drives
|
|
4
|
+
// through. Lives under surfaces/web because solvePlannerInstance itself
|
|
5
|
+
// drives createTurnSession (turn-session.mjs, this same directory) — the
|
|
6
|
+
// src/ layer boundary only lets a module reach a peer or a lower layer, and
|
|
7
|
+
// turn-session.mjs is surfaces-layer, so this module has to sit here too
|
|
8
|
+
// rather than under domain/ or services/. scripts/claims/planner-domains.mjs
|
|
9
|
+
// re-exports everything below so the rig's own import path, and
|
|
10
|
+
// test/adapters/planner-domains.test.mjs's, both keep working unchanged.
|
|
11
|
+
//
|
|
12
|
+
// blocksworld and gripper are authored the same way src/domain/hanoi-lesson.mjs
|
|
13
|
+
// generalizes data/games/hanoi-3.txt: a fixed small rule set teaches the
|
|
14
|
+
// domain's types and action family, and a size parameter scales the puzzle
|
|
15
|
+
// instance stacked on top of it. Both reuse the exact closed teach frames
|
|
16
|
+
// data/games/hanoi-3.txt and data/games/river.txt already exercise (the
|
|
17
|
+
// action-signature, clearing-precondition, and action-effect sentences), so
|
|
18
|
+
// nothing here is a new grammar shape — only new vocabulary and a new
|
|
19
|
+
// instance shape.
|
|
20
|
+
//
|
|
21
|
+
// blocksworld drops hanoi's "smaller than" comparative precondition: real
|
|
22
|
+
// Blocksworld blocks are uniform, so any clear block may stack on any other
|
|
23
|
+
// clear block or spot. gripper drops the clearing precondition entirely: a
|
|
24
|
+
// room holds any number of balls, so carrying one is unconditional. Removing
|
|
25
|
+
// constraints only ever ADDS legal moves at each search step, which is why
|
|
26
|
+
// both grow harder than hanoi at the same instance size — the search radius
|
|
27
|
+
// shrinks. claim-planner.mjs measures how much.
|
|
28
|
+
|
|
29
|
+
import { hanoiLessonSentences } from "../../domain/hanoi-lesson.mjs";
|
|
30
|
+
import { createInMemoryStore } from "../../adapters/memory/core.mjs";
|
|
31
|
+
import { parseEntities } from "../../domain/codegraph.mjs";
|
|
32
|
+
import { loadLexicon } from "../../domain/grammar/lexicon.mjs";
|
|
33
|
+
import { createTurnSession } from "./turn-session.mjs";
|
|
34
|
+
|
|
35
|
+
/** The block-stacking domain's rule scaffolding alone (types, individuals,
|
|
36
|
+
* the "stack onto" action family, render hints) — no starting stack, no
|
|
37
|
+
* goal, no solve. This is the half of the taught content that belongs in
|
|
38
|
+
* the committed rule file, matching how data/games/hanoi-3.txt carries only
|
|
39
|
+
* hanoi's rules and leaves the instance to be typed interactively. */
|
|
40
|
+
export function blocksworldRuleSentences(blockCount = 3) {
|
|
41
|
+
const n = Math.max(1, Math.floor(Number(blockCount) || 1));
|
|
42
|
+
const blocks = Array.from({ length: n }, (_, i) => `block-${i + 1}`);
|
|
43
|
+
const spots = ["spot-a", "spot-b", "spot-c"];
|
|
44
|
+
const sentences = [];
|
|
45
|
+
sentences.push("a block is a kind of game piece.");
|
|
46
|
+
sentences.push("a spot is a kind of place.");
|
|
47
|
+
for (const b of blocks) sentences.push(`${b} is a block.`);
|
|
48
|
+
for (const p of spots) sentences.push(`${p} is a spot.`);
|
|
49
|
+
sentences.push("you can stack a block onto a spot.");
|
|
50
|
+
sentences.push("you can stack a block onto a block.");
|
|
51
|
+
sentences.push("to stack a block onto a target, nothing may rest on the block.");
|
|
52
|
+
sentences.push("to stack a block onto a target, nothing may rest on the target.");
|
|
53
|
+
sentences.push("stacking a block onto a target makes the block rest on the target.");
|
|
54
|
+
sentences.push("a block renders as a cube.");
|
|
55
|
+
sentences.push("a spot renders as a mat.");
|
|
56
|
+
return sentences;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** blocksworldRuleSentences(blockCount) plus one solvable instance: every
|
|
60
|
+
* block starts in a single stack on spot-a (block-1 on top), and the goal
|
|
61
|
+
* gathers them all onto spot-c — the same shape hanoiLessonSentences uses
|
|
62
|
+
* for its own starting stack, minus the size ordering. */
|
|
63
|
+
export function blocksworldInstanceSentences(blockCount = 3) {
|
|
64
|
+
const n = Math.max(1, Math.floor(Number(blockCount) || 1));
|
|
65
|
+
const blocks = Array.from({ length: n }, (_, i) => `block-${i + 1}`);
|
|
66
|
+
const sentences = blocksworldRuleSentences(n);
|
|
67
|
+
for (let i = 0; i < n - 1; i += 1) sentences.push(`${blocks[i]} rests on ${blocks[i + 1]}.`);
|
|
68
|
+
sentences.push(`${blocks[n - 1]} rests on spot-a.`);
|
|
69
|
+
sentences.push("the goal is that every block rests on spot-c.");
|
|
70
|
+
sentences.push("solve it.");
|
|
71
|
+
return sentences;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** The ball-transport domain's rule scaffolding alone. Rooms hold any number
|
|
75
|
+
* of balls, so the family carries no clearing precondition at all — the
|
|
76
|
+
* cleanest possible action family the taught grammar supports (a signature
|
|
77
|
+
* and an effect, nothing else). */
|
|
78
|
+
export function gripperRuleSentences(ballCount = 3) {
|
|
79
|
+
const n = Math.max(1, Math.floor(Number(ballCount) || 1));
|
|
80
|
+
const balls = Array.from({ length: n }, (_, i) => `ball-${i + 1}`);
|
|
81
|
+
const rooms = ["room-a", "room-b", "room-c"];
|
|
82
|
+
const sentences = [];
|
|
83
|
+
sentences.push("a ball is a kind of game piece.");
|
|
84
|
+
sentences.push("a room is a kind of place.");
|
|
85
|
+
for (const b of balls) sentences.push(`${b} is a ball.`);
|
|
86
|
+
for (const r of rooms) sentences.push(`${r} is a room.`);
|
|
87
|
+
sentences.push("you can carry a ball inside a room.");
|
|
88
|
+
sentences.push("carrying a ball inside a room makes the ball rest inside the target.");
|
|
89
|
+
sentences.push("a ball renders as a sphere.");
|
|
90
|
+
sentences.push("a room renders as a chamber.");
|
|
91
|
+
return sentences;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** gripperRuleSentences(ballCount) plus one solvable instance: every ball
|
|
95
|
+
* starts in room-a, and the goal gathers them all in room-c. */
|
|
96
|
+
export function gripperInstanceSentences(ballCount = 3) {
|
|
97
|
+
const n = Math.max(1, Math.floor(Number(ballCount) || 1));
|
|
98
|
+
const balls = Array.from({ length: n }, (_, i) => `ball-${i + 1}`);
|
|
99
|
+
const sentences = gripperRuleSentences(n);
|
|
100
|
+
for (const b of balls) sentences.push(`${b} rests inside room-a.`);
|
|
101
|
+
sentences.push("the goal is that every ball rests inside room-c.");
|
|
102
|
+
sentences.push("solve it.");
|
|
103
|
+
return sentences;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** The three envelope columns claim-planner.mjs measures, and the
|
|
107
|
+
* benchmark-this-device button offers a visitor. `unit` names what `size`
|
|
108
|
+
* counts; `instanceSentences(size)` is the full taught sequence a fresh
|
|
109
|
+
* session runs to solve one instance. */
|
|
110
|
+
export const PLANNER_DOMAINS = {
|
|
111
|
+
hanoi: { unit: "disks", instanceSentences: hanoiLessonSentences },
|
|
112
|
+
blocksworld: { unit: "blocks", instanceSentences: blocksworldInstanceSentences },
|
|
113
|
+
gripper: { unit: "balls", instanceSentences: gripperInstanceSentences },
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
/** Teach one fresh in-memory session domain's instance at `size` and solve
|
|
117
|
+
* it, over the real chat turn entry point (`createTurnSession` — the same
|
|
118
|
+
* wrapper claims-browser-entry.mjs's own live session opens through).
|
|
119
|
+
* Returns `{ ms, size, solved, moves, declined }`: `moves` is the shortest
|
|
120
|
+
* plan's length or null on an honest miss (no plan within the search
|
|
121
|
+
* bound); `declined` is null when every teach sentence was accepted, or the
|
|
122
|
+
* first sentence that was not (`{ sentence, via, answer }`) — a rig that
|
|
123
|
+
* finds one mid-sweep should stop and report it rather than keep timing a
|
|
124
|
+
* half-taught domain. This is the one per-instance solve entry point every
|
|
125
|
+
* caller (this rig, the browser button) drives through, so a visitor's
|
|
126
|
+
* timing and this claim's timing can never silently diverge. */
|
|
127
|
+
export async function solvePlannerInstance(domainName, size) {
|
|
128
|
+
const domain = PLANNER_DOMAINS[domainName];
|
|
129
|
+
if (!domain) throw new Error(`solvePlannerInstance: unknown domain "${domainName}"`);
|
|
130
|
+
|
|
131
|
+
const memoryDir = createInMemoryStore();
|
|
132
|
+
const graph = parseEntities({ individuals: [], objectProperties: [] });
|
|
133
|
+
const lexicon = loadLexicon();
|
|
134
|
+
const sessionId = globalThis.crypto?.randomUUID?.() ?? String(Math.random());
|
|
135
|
+
const session = createTurnSession({ memoryDir, graph, lexicon, sessionId, vocabHint: "" });
|
|
136
|
+
|
|
137
|
+
let plan = null;
|
|
138
|
+
let declined = null;
|
|
139
|
+
const sentences = domain.instanceSentences(size);
|
|
140
|
+
const start = performance.now();
|
|
141
|
+
for (const sentence of sentences) {
|
|
142
|
+
const r = await session.turn(sentence);
|
|
143
|
+
if (r.plan) plan = r.plan;
|
|
144
|
+
const via = r.record?.via;
|
|
145
|
+
if (!declined && via && via !== "assert" && via !== "plan") {
|
|
146
|
+
declined = { sentence, via, answer: r.answer };
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
const ms = performance.now() - start;
|
|
150
|
+
|
|
151
|
+
return { ms, size, solved: Boolean(plan), moves: plan?.actions?.length ?? null, declined };
|
|
152
|
+
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
import { renderUntested } from "../../domain/codegraph.mjs";
|
|
4
4
|
|
|
5
|
-
export function tmct_untested(_args, { graph }) {
|
|
6
|
-
return renderUntested(graph);
|
|
5
|
+
export function tmct_untested(_args, { graph, codeDomainActive = null }) {
|
|
6
|
+
return renderUntested(graph, { codeDomainActive });
|
|
7
7
|
}
|
package/src/tools/server.mjs
CHANGED
|
@@ -51,7 +51,7 @@ export const TOOLS = HOT_TOOLS.map(({ name, agentDescription, inputSchema }) =>
|
|
|
51
51
|
inputSchema,
|
|
52
52
|
}));
|
|
53
53
|
|
|
54
|
-
async function runHandler(name, args, { config, source = defaultSource, tel = null, ingest = null, memoryBackend = null, factLookup = null, graph: suppliedGraph = null } = {}) {
|
|
54
|
+
async function runHandler(name, args, { config, source = defaultSource, tel = null, ingest = null, memoryBackend = null, factLookup = null, graph: suppliedGraph = null, codeDomainActive = null } = {}) {
|
|
55
55
|
// Reject an unknown tool BEFORE touching the graph — an unknown name never
|
|
56
56
|
// triggers a load. hasOwn, so an inherited name ("constructor", "toString")
|
|
57
57
|
// is unknown rather than a callable found on the prototype chain.
|
|
@@ -64,8 +64,13 @@ async function runHandler(name, args, { config, source = defaultSource, tel = nu
|
|
|
64
64
|
// handle (e.g. a session's own `memoryDir`) — a handler that reads the
|
|
65
65
|
// conversational memory store (tmct_export) prefers it over re-deriving a
|
|
66
66
|
// backend from config when one is supplied; every other caller leaves it null
|
|
67
|
-
// and gets today's re-derive-from-config behaviour unchanged.
|
|
68
|
-
|
|
67
|
+
// and gets today's re-derive-from-config behaviour unchanged. `codeDomainActive`
|
|
68
|
+
// is the same kind of seam again — the service layer's own session-level
|
|
69
|
+
// predicate, threaded down only so a handler whose empty-graph wording is
|
|
70
|
+
// code-domain-flavored (tmct_untested) can decline that wording on a bare
|
|
71
|
+
// install; a caller that omits it (a cold `cli <tool>` invocation, most
|
|
72
|
+
// dispatchTool tests) gets the handler's own graph-derived fallback.
|
|
73
|
+
if (handle.ownsGraphLoad) return handle(args, { config, source, tel, ingest, memoryBackend, graph: suppliedGraph, codeDomainActive });
|
|
69
74
|
// `graph` is the third seam of the same kind: a caller that ALREADY holds a
|
|
70
75
|
// parsed graph hands it over instead of making the tool layer load one. A
|
|
71
76
|
// browser session is the case that needs it — its graph is built in memory
|
|
@@ -79,7 +84,7 @@ async function runHandler(name, args, { config, source = defaultSource, tel = nu
|
|
|
79
84
|
// isn't there.
|
|
80
85
|
const repoRoot = config?.graphFile ? dirname(dirname(config.graphFile)) : null;
|
|
81
86
|
const svc = createGraphService(graph, { sourceAccess: Boolean(repoRoot), repoRoot, readFile, tel, ask });
|
|
82
|
-
const out = handle(args, { graph, svc, config, repoRoot, memoryBackend });
|
|
87
|
+
const out = handle(args, { graph, svc, config, repoRoot, memoryBackend, codeDomainActive });
|
|
83
88
|
return name === "tmct_ask" ? askWithMemoryFallback(out, args, factLookup) : out;
|
|
84
89
|
}
|
|
85
90
|
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
LICENSE NOTICE — corpus/seon/
|
|
2
|
-
=============================
|
|
3
|
-
|
|
4
|
-
The files in this directory (concepts.jsonl, definitions.jsonl, README.md) are
|
|
5
|
-
ORIGINAL WORK authored by hand for the-mechanical-code-talker (tmct), and are
|
|
6
|
-
licensed under this repository's license, the Mozilla Public License Version 2.0
|
|
7
|
-
(MPL-2.0) — the same terms as the rest of the repository.
|
|
8
|
-
|
|
9
|
-
https://www.mozilla.org/MPL/2.0/
|
|
10
|
-
|
|
11
|
-
They are NOT derived from ConceptNet and are NOT under CC-BY-SA. Do not confuse
|
|
12
|
-
this directory with corpus/conceptnet/, whose slice.jsonl is a CC-BY-SA 4.0
|
|
13
|
-
excerpt of ConceptNet 5 (see corpus/conceptnet/LICENSE-NOTICE).
|
|
14
|
-
|
|
15
|
-
What this is
|
|
16
|
-
------------
|
|
17
|
-
|
|
18
|
-
corpus/seon is tmct's curated tier-1 software-engineering ontology: a hand-
|
|
19
|
-
authored, language-neutral set of concept definitions and relation facts covering
|
|
20
|
-
the vocabulary declared in src/grammar/lexicon-core.json. Every line was written
|
|
21
|
-
and checked by the project, not compiled from an external dataset.
|
|
22
|
-
|
|
23
|
-
On the name "seon"
|
|
24
|
-
------------------
|
|
25
|
-
|
|
26
|
-
The directory is named for SEON (the Software Evolution ONtologies, se-on.org),
|
|
27
|
-
the FAMIX-derived reference vocabulary tmct's code-graph prop tokens borrow term
|
|
28
|
-
IDEAS from (see ontology/tmct-core.ttl). This directory does NOT redistribute
|
|
29
|
-
SEON's published ontology files; it is tmct's own curated ontology, named in
|
|
30
|
-
homage to that reference vocabulary. No SEON content is copied here.
|
|
31
|
-
|
|
32
|
-
Reuse
|
|
33
|
-
-----
|
|
34
|
-
|
|
35
|
-
As MPL-2.0 material, these files may be used, modified, and redistributed under
|
|
36
|
-
the MPL-2.0 terms. Attribution to the-mechanical-code-talker / Polycode is
|
|
37
|
-
appreciated but governed by the license, not by CC-BY-SA share-alike.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|