|
13 | 13 | // The browser workspace ('just gui') is the primary surface; this CLI is the |
14 | 14 | // offline-first fallback. |
15 | 15 |
|
| 16 | +import { loadCartridges, verdict } from "../src/cartridges.js" |
| 17 | + |
16 | 18 | const KINDS = { |
17 | 19 | "cognate": { glyph: "🤝", pedagogy: "transfer directly" }, |
18 | 20 | "false-friend": { glyph: "🎭", pedagogy: "flag the trap" }, |
@@ -54,42 +56,6 @@ function parseArgs(argv) { |
54 | 56 | return opts |
55 | 57 | } |
56 | 58 |
|
57 | | -async function loadCartridges(dirUrl) { |
58 | | - const out = [] |
59 | | - async function walk(d) { |
60 | | - let entries |
61 | | - try { |
62 | | - entries = Deno.readDir(d) |
63 | | - } catch { |
64 | | - return |
65 | | - } |
66 | | - for await (const e of entries) { |
67 | | - const child = new URL(e.name + (e.isDirectory ? "/" : ""), d) |
68 | | - if (e.isDirectory) { |
69 | | - await walk(child) |
70 | | - continue |
71 | | - } |
72 | | - if (!e.name.endsWith(".cartridge.json")) continue |
73 | | - try { |
74 | | - const c = JSON.parse(await Deno.readTextFile(child)) |
75 | | - out.push({ |
76 | | - cartridge: c.name ?? e.name, |
77 | | - transitions: Array.isArray(c.transitions) ? c.transitions : [], |
78 | | - }) |
79 | | - } catch (err) { |
80 | | - console.error(`skip ${e.name}: ${err.message}`) |
81 | | - } |
82 | | - } |
83 | | - } |
84 | | - await walk(dirUrl) |
85 | | - return out |
86 | | -} |
87 | | - |
88 | | -function verdict(strata, name) { |
89 | | - const v = (strata ?? []).find((s) => s.stratum === name) |
90 | | - return v ? v.holds : null |
91 | | -} |
92 | | - |
93 | 59 | function render(t) { |
94 | 60 | const k = KINDS[t.kind] ?? { glyph: "?", pedagogy: "" } |
95 | 61 | const residue = t.residue?.shape ? ` · residue: ${t.residue.shape}` : "" |
@@ -119,7 +85,7 @@ async function main() { |
119 | 85 |
|
120 | 86 | const cartridges = await loadCartridges(root) |
121 | 87 | let items = cartridges.flatMap((c) => |
122 | | - c.transitions.map((t) => ({ ...t, cartridge: c.cartridge })) |
| 88 | + (c.transitions ?? []).map((t) => ({ ...t, cartridge: c.name })) |
123 | 89 | ) |
124 | 90 |
|
125 | 91 | if (opts.kind) items = items.filter((t) => t.kind === opts.kind) |
|
0 commit comments