@polycode-projects/the-mechanical-code-talker 1.10.14 → 1.11.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.
- package/README.md +115 -101
- package/ROADMAP.md +17 -4
- package/bin/tmct.mjs +115 -9
- package/data/games/crates.txt +24 -0
- package/data/games/hanoi-3.txt +30 -0
- package/package.json +1 -1
- package/src/ask-browser.bundle.js +129 -398
- package/src/chat.mjs +564 -12
- package/src/domain.mjs +271 -0
- package/src/import-file.mjs +86 -0
- package/src/init.mjs +46 -1
- package/src/ledger-viz.mjs +613 -0
- package/src/memory/core.mjs +80 -16
- package/src/memory/shacl.mjs +17 -7
- package/src/memory-ask-browser-entry.mjs +4 -2
- package/src/memory-ask-browser.bundle.js +5157 -1165
- package/src/plan-viz.mjs +410 -0
- package/src/router/guardrail.mjs +5 -0
- package/src/router/registry.mjs +55 -11
- package/src/router/taught.mjs +73 -0
- package/src/sentences.mjs +19 -0
- package/src/viz-theme.mjs +50 -0
- package/src/viz.mjs +2 -2
- package/src/wink-model.mjs +12 -6
package/src/viz.mjs
CHANGED
|
@@ -113,14 +113,14 @@ export async function readMemoryAskBundle() {
|
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
/** Escape untrusted text for safe placement inside HTML content/attributes. */
|
|
116
|
-
function escapeHtml(s) {
|
|
116
|
+
export function escapeHtml(s) {
|
|
117
117
|
return String(s ?? "").replace(/[&<>"']/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" }[c]));
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
/** JSON-embed graph data into a `<script>` tag safely — escape `</` so a
|
|
121
121
|
* label/id containing "</script>" can't break out of the tag, and escape
|
|
122
122
|
* U+2028/U+2029 (valid in JSON strings, invalid unescaped in JS source). */
|
|
123
|
-
function embedJson(value) {
|
|
123
|
+
export function embedJson(value) {
|
|
124
124
|
return JSON.stringify(value)
|
|
125
125
|
.replace(/</g, "\\u003c")
|
|
126
126
|
.replace(/\u2028/g, "\\u2028")
|
package/src/wink-model.mjs
CHANGED
|
@@ -21,6 +21,7 @@ let cached; // undefined = not tried yet; null = unavailable (tried once, honest
|
|
|
21
21
|
export function registerWinkModel(factory) {
|
|
22
22
|
injected = factory;
|
|
23
23
|
cached = undefined;
|
|
24
|
+
instance = undefined;
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
/** Load `{ winkNLP, model }` once, or null when wink isn't available. Prefers a
|
|
@@ -46,15 +47,20 @@ function nodeRequireWink() {
|
|
|
46
47
|
};
|
|
47
48
|
}
|
|
48
49
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
let instance; // undefined = not built yet; null = construction failed once
|
|
51
|
+
|
|
52
|
+
/** Convenience: the constructed `nlp` instance (`winkNLP(model)`) or null.
|
|
53
|
+
* Cached: repeated `winkNLP(model)` construction accumulates module-level
|
|
54
|
+
* state inside the model package until V8 throws "Invalid string length",
|
|
55
|
+
* after which every later construction fails for the life of the process. */
|
|
52
56
|
export function winkInstance() {
|
|
57
|
+
if (instance !== undefined) return instance;
|
|
53
58
|
const loaded = loadWinkModel();
|
|
54
|
-
if (!loaded) return null;
|
|
59
|
+
if (!loaded) { instance = null; return null; }
|
|
55
60
|
try {
|
|
56
|
-
|
|
61
|
+
instance = loaded.winkNLP(loaded.model);
|
|
57
62
|
} catch {
|
|
58
|
-
|
|
63
|
+
instance = null;
|
|
59
64
|
}
|
|
65
|
+
return instance;
|
|
60
66
|
}
|