@polycode-projects/the-mechanical-code-talker 2.0.1 → 2.0.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.
- package/package.json +1 -1
- package/src/services/plan-viz.mjs +33 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@polycode-projects/the-mechanical-code-talker",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.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; no codebase index of its own.",
|
|
@@ -71,12 +71,31 @@ function rankBySize(sizeOrder, members) {
|
|
|
71
71
|
return { ranks, sized };
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
+
/** Every label the plan itself names — across its states and its actions. The
|
|
75
|
+
* board's undeclared anchors are drawn from this rather than from the whole
|
|
76
|
+
* domain, which is the entire memory. */
|
|
77
|
+
function namesInPlan(plan) {
|
|
78
|
+
const named = new Set();
|
|
79
|
+
for (const rows of plan?.states || []) {
|
|
80
|
+
for (const r of rows || []) {
|
|
81
|
+
if (r?.subject != null) named.add(r.subject);
|
|
82
|
+
if (r?.object != null) named.add(r.object);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
for (const a of plan?.actions || []) {
|
|
86
|
+
if (a?.subject != null) named.add(a.subject);
|
|
87
|
+
if (a?.target != null) named.add(a.target);
|
|
88
|
+
}
|
|
89
|
+
return named;
|
|
90
|
+
}
|
|
91
|
+
|
|
74
92
|
/**
|
|
75
93
|
* Pure geometry for the blocks archetype.
|
|
76
94
|
*
|
|
77
95
|
* plan: { states: [[{subject, predicate, object}], …], domain: { classMembers } }
|
|
78
96
|
* rendersAs: { className: "block" | "slot" } — classes absent from the map
|
|
79
|
-
* fall back to labeled circles
|
|
97
|
+
* fall back to labeled circles, and contribute only the members the
|
|
98
|
+
* plan names (see the loop below: the domain is the whole memory).
|
|
80
99
|
* sizeOrder: [[smallerLabel, largerLabel], …]
|
|
81
100
|
*
|
|
82
101
|
* Returns { board, ranks, anchors, snapshots: [{ items, stacks }] } —
|
|
@@ -85,6 +104,7 @@ function rankBySize(sizeOrder, members) {
|
|
|
85
104
|
export function computeBlocksLayout({ plan, rendersAs = {}, sizeOrder = [] }) {
|
|
86
105
|
const classMembers = plan?.domain?.classMembers || {};
|
|
87
106
|
const classes = Object.keys(classMembers).sort();
|
|
107
|
+
const named = namesInPlan(plan);
|
|
88
108
|
const blockSet = new Set();
|
|
89
109
|
const anchorDefs = [];
|
|
90
110
|
const classHue = {};
|
|
@@ -97,7 +117,18 @@ export function computeBlocksLayout({ plan, rendersAs = {}, sizeOrder = [] }) {
|
|
|
97
117
|
for (const m of members) blockSet.add(m);
|
|
98
118
|
} else {
|
|
99
119
|
const kind = archetype === "slot" ? "slot" : "circle";
|
|
100
|
-
|
|
120
|
+
// A DECLARED class is the board's own furniture: every member is drawn,
|
|
121
|
+
// empty or not (an unused peg is still a peg). An UNDECLARED class only
|
|
122
|
+
// falls back to circles, and the domain it comes from is the whole
|
|
123
|
+
// memory, not just this puzzle — one that has been taught a vocabulary
|
|
124
|
+
// carries hundreds of individuals that have nothing to do with the game.
|
|
125
|
+
// Drawing those puts every noun the memory knows on the board, which
|
|
126
|
+
// squeezes the real anchors into a few pixels at the left edge. So an
|
|
127
|
+
// undeclared class contributes only what the plan actually names.
|
|
128
|
+
for (const m of members) {
|
|
129
|
+
if (!archetype && !named.has(m)) continue;
|
|
130
|
+
anchorDefs.push({ id: m, kind });
|
|
131
|
+
}
|
|
101
132
|
}
|
|
102
133
|
}
|
|
103
134
|
anchorDefs.sort((a, b) => (a.kind === b.kind ? (a.id < b.id ? -1 : 1) : a.kind === "slot" ? -1 : 1));
|