@polycode-projects/the-mechanical-code-talker 2.10.5 → 2.11.1
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 +2 -2
- package/corpus/sprites/src/sprite-facts.jsonl +18 -0
- package/corpus/worlds/manifest.json +5 -5
- package/corpus/worlds/shards/ashcombe-hall.jsonl.gz +0 -0
- package/corpus/worlds/src/ashcombe-hall.jsonl +27 -0
- package/data/sprites/book-icon.toml +12 -0
- package/data/sprites/cellar-icon.toml +12 -0
- package/data/sprites/drawing-room-icon.toml +13 -0
- package/data/sprites/garden-icon.toml +12 -0
- package/data/sprites/kitchen-icon.toml +13 -0
- package/data/sprites/library-icon.toml +12 -0
- package/data/sprites/pan-icon.toml +11 -0
- package/data/sprites/study-icon.toml +12 -0
- package/data/templates/responses.jsonl +1 -0
- package/package.json +5 -2
- package/src/adapters/corpus/wikipedia-live.mjs +182 -26
- package/src/adapters/corpus/worlds-pack.mjs +8 -2
- package/src/adapters/toml-config.mjs +6 -0
- package/src/domain/ask-vocab.mjs +17 -0
- package/src/domain/ask.mjs +51 -1
- package/src/domain/grammar/ace.mjs +43 -3
- package/src/domain/interpret/normalize.mjs +6 -2
- package/src/domain/interpret/strategies/grammar.mjs +47 -17
- package/src/domain/interpret/strategies/keywords.mjs +53 -4
- package/src/domain/memory/trust.mjs +11 -0
- package/src/domain/router/registry.mjs +8 -1
- package/src/domain/worlds-pack.mjs +50 -0
- package/src/services/adventure-autoplay.mjs +5 -2
- package/src/services/adventure-viz.mjs +301 -33
- package/src/services/adventure.mjs +162 -14
- package/src/services/chat-page-viz.mjs +265 -189
- package/src/services/chat-session.mjs +15 -5
- package/src/services/chat.mjs +471 -79
- package/src/services/code-explorer-viz.mjs +183 -75
- package/src/services/extract-facts.mjs +118 -28
- package/src/services/ingest-viz.mjs +328 -79
- package/src/services/ledger-viz.mjs +99 -0
- package/src/services/memory-panel-viz.mjs +159 -0
- package/src/services/research.mjs +266 -0
- package/src/services/sentences.mjs +19 -0
- package/src/services/spider-fly-viz.mjs +21 -5
- package/src/surfaces/web/adventure-browser-entry.mjs +9 -5
- package/src/surfaces/web/chat-browser-entry.mjs +28 -11
- package/src/surfaces/web/code-explorer-browser-entry.mjs +27 -11
- package/src/surfaces/web/ingest-browser-entry.mjs +123 -41
- package/src/surfaces/web/ledger-browser-entry.mjs +10 -4
- package/src/surfaces/web/memory-ask-browser.bundle.js +116 -116
- package/src/surfaces/web/memory-stats.mjs +53 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// memory-stats.mjs — the "what does this session's memory hold" reader,
|
|
2
|
+
// shared by chat-browser-entry.mjs and ingest-browser-entry.mjs so both
|
|
3
|
+
// bundles' stats panels read the exact same breakdown for the exact same
|
|
4
|
+
// store shape.
|
|
5
|
+
import { loadMemory, readFactRows } from "../../adapters/memory/core.mjs";
|
|
6
|
+
import { provenanceTagToSource } from "../../domain/memory/trust.mjs";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The memory a running session holds, broken down by where each fact came
|
|
10
|
+
* from: the seed corpus bands it booted with (keyed by the SAME band name
|
|
11
|
+
* build-chat-seed.mjs/extensions.mjs seed under — "human", "seon",
|
|
12
|
+
* "conceptnet" today, whichever bands a future seed adds tomorrow) plus
|
|
13
|
+
* whatever has been taught THIS session. Reuses memory/trust.mjs's own
|
|
14
|
+
* `provenanceTagToSource` against each fact's already-stored provenance
|
|
15
|
+
* tag(s) (readFactRows' `provenance`, the ' | '-joined compat string) rather
|
|
16
|
+
* than inventing a second provenance parse — the same tag chat.mjs's own
|
|
17
|
+
* "(source: ...)" citation already carries, so this panel and a turn's
|
|
18
|
+
* citation always agree on where a fact came from.
|
|
19
|
+
*
|
|
20
|
+
* Returns { total, bandCounts, taught }: `bandCounts` maps a band label to
|
|
21
|
+
* its fact count ("taught this session" for a teach/operator-sourced fact
|
|
22
|
+
* with no corpus band, "other" for anything provenance can't place);
|
|
23
|
+
* `taught` lists every session-taught fact (subject/predicate/object + its
|
|
24
|
+
* own provenance tag), most-recently-taught last — a stats panel's
|
|
25
|
+
* provenance column reads straight off this, no further lookup needed.
|
|
26
|
+
*/
|
|
27
|
+
export async function memoryStats(memoryDir) {
|
|
28
|
+
const memory = await loadMemory(memoryDir);
|
|
29
|
+
const rows = readFactRows(memory);
|
|
30
|
+
const bandCounts = {};
|
|
31
|
+
const taught = [];
|
|
32
|
+
for (const row of rows) {
|
|
33
|
+
const tags = String(row.provenance || "").split(" | ").filter(Boolean);
|
|
34
|
+
let band = null;
|
|
35
|
+
let isTaught = false;
|
|
36
|
+
let taughtTag = "";
|
|
37
|
+
for (const tag of tags) {
|
|
38
|
+
const src = provenanceTagToSource(tag);
|
|
39
|
+
if (!src) continue;
|
|
40
|
+
// corpusWeak (a /r/RelatedTo-strength triple, e.g. ConceptNet's or
|
|
41
|
+
// SEON's own weaker associations) names the SAME band as corpus (a
|
|
42
|
+
// /r/IsA-strength one) — both carry `src.name`, and a band count that
|
|
43
|
+
// dropped the weak tier would undercount a corpus by exactly its
|
|
44
|
+
// weak-relation facts (SEON: 19 of them, all `corpus-weak:seon`).
|
|
45
|
+
if ((src.kind === "corpus" || src.kind === "corpusWeak") && src.name) band = src.name;
|
|
46
|
+
if (src.kind === "teach" || src.kind === "operator") { isTaught = true; taughtTag = tag; }
|
|
47
|
+
}
|
|
48
|
+
const label = band || (isTaught ? "taught this session" : "other");
|
|
49
|
+
bandCounts[label] = (bandCounts[label] || 0) + 1;
|
|
50
|
+
if (isTaught) taught.push({ subject: row.subject, predicate: row.predicate, object: row.object, tag: taughtTag });
|
|
51
|
+
}
|
|
52
|
+
return { total: rows.length, bandCounts, taught };
|
|
53
|
+
}
|