the 2026-11-16 rounds, the whole day in one commit: model discovery (the two-step op act -- discover scrapes the provider metadata, refine runs the deterministic battery over every id and hands the adjudicated results to the best passing model for the curated registry; state/models.json is the truth of selectable models and gates all model use, a fresh deployment has none; the five named sampling knobs ride run.json params over server.json params, sent only when set; the curator call retries once on the host's network hiccups, its output strictly validated with the machine-list fallback, and the do-not-deliberate line keeps its thinking tokens down); the pick rule reworked on the GM's rulings -- the dv endpoint's 5.2/5.3-max flip was an alias (one model behind both ids), the rank keys on the reasoning bucket not the raw token count (within-bucket differences are sampling noise, the thresholds sit in the endpoint's observed gaps) and full ties settle sort-lex-pick-bottom, with the mock registry carrying a canned tie pair (mock/mock-tie) and the smoke asserting the lex-bottom pick; the play-protocol batch (OOC GM turns carry no cache blocks, memory.json is authored draft applied by the start gate's reapply over a fresh db, /story filters OOC whole, the per-turn raw control on the table); the tunables UX round (web/knobs.mjs: the definitions table with the GM's hint texts and the probed this-endpoint bounds, the per-knob explicit override toggle replacing implicit empty-means-unset diffing, the shared focus-driven hint bar; the run detail and /model responses carry paramDefaults, the deployment layer -- the only default anyone can honestly name); request recording (every provider call lands its resolved model + effective params on the msg event as via, a failed call lands a req event with the failure, both surface on the raw tab and the per-turn raw control on no model-facing surface, a req riding the slidwin tail passes the start lint as conversation machinery; the housekeeping pass log names its model via the clerk's --model flag); the mind verb (<mind> JSON in a player turn sets its sampling for its next turn -- one-shot, max_tokens excluded, a budget not a mind; bounds enforced in KNOB_BOUNDS with the range named in the conflict and the heal restatement the statement that counts; derive() makes a statement live until a player reply consumes it, honest across restarts, session boundaries and forks -- an unconsumed mind rides on); the full-block protocol (the GM rewrote system/invariants/reminder to eliminate the diff verbs: she emits whole <status>/<agenda> at her turn tail, a present block is a whole-list set, absent means unchanged never blank, over-cap agendas evict from the bottom silently -- ruled a feature, silent to her, the note shows the GM; renderView strips every copy and stamps the newest of each kind at the tail of her most recent prose turn, her own emission, so the context reads as the same sequence of events the game had; GM prose goes pure, old logs' composited rides strip, they were never GM words; <mind> is write-only, its tags strip from the view; every turn of hers carries its <model> block -- the params it rode, bare JSON from the via record, the current call included, suppressed when nothing is set, emitting one refused with a pointer at <mind>; the clerk's status-apply/agenda-apply delta verbs RETIRED with their dispatch and collectors, status-set/agenda-set are the player path now; the story strips her blocks, the table chips them; the smoke imports renderView and asserts the view policy directly -- the pattern for testing view-only policy no API exposes); and the opening event RETIRED (the start gate seeds the clerk from her last authored turn's blocks -- the GM moved la-caramba's initial status into her opening turn; old carryovers keep their events as inert history; the event's pre-existing double-landing in every started log, pre-bundle and in-carry, died with the branch); smoke ALL PASS + restart + reminder + repo checks green, browser passes over the knob UX and the new chips and notes with zero console errors, typecheck green on both programs; README and DICTIONARY carry the durable design, HANDOFF trimmed to the map

This commit is contained in:
2026-11-16 21:32:02 +00:00
parent 193dc336be
commit 894737fcf3
30 changed files with 2193 additions and 518 deletions
+135 -185
View File
@@ -14,10 +14,10 @@
// included), give it an anonymous id and
// the pc's name (distinct per package),
// build dormant session one (bundle, db,
// carryover; memory.json applies through
// the standard apply path). From then on
// the run dir is the only truth; the
// package is never read again.
// carryover; memory.json stays authored
// material -- the start gate applies it).
// From then on the run dir is the only
// truth; the package is never read again.
// save-package "display name" save a DRAFT's craft as a new user
// package (state/packages/, published to
// all; pc never rides; --owner stamps)
@@ -25,6 +25,10 @@
// (the low-level primitive under create)
// render write canon/ring-a.md, ring-b.md, status.md
// apply <manifest.json> apply a housekeeper manifest (validated, transactional)
// reapply session-0's housekeeping: rebuild session
// one's rings from its memory.json over a
// fresh db (the start gate runs it; a
// played session one refuses)
// insert <ring> <type> "Label" "detail" GM-authoritative insert
// delete <id> "reason" GM-authoritative removal to cold storage
// revive <id> [a|b] GM pulls an entry back from cold storage
@@ -36,18 +40,13 @@
// search <terms...> query the records (max 10; a miss is a miss)
// unarchive <rid> [a|b] GM pulls a record back into the rings
// status her status, as JSON (the status tier)
// status-apply "<turn text>" apply <lost>/<gained> deltas from a player
// turn; exact match, non-blocking; JSON result
// (lost / gained / conflicts / status)
// status-set "descr" ... GM override: replace the whole status
// status-set "descr" ... whole-status replace -- the GM override
// and the player's <status> block alike
// (no descrs = clear it)
// agenda the agenda, as JSON (the intentions tier)
// agenda-apply "<turn text>" apply <add>/<drop> deltas from a player
// turn; drops are 0-based indexes against
// the agenda as last rendered; JSON result
// (added / dropped / evicted / conflicts /
// agenda)
// agenda-set "item" ... GM override: replace the whole agenda
// agenda-set "item" ... whole-queue replace -- the GM override
// and the player's <agenda> block alike;
// over-cap evicts the bottom, silently
// (no items = clear it)
// pick "a" "b" "c" ... dice for prose -- uniform random choice
// dump canonical dump to dumps/memory.sql
@@ -65,6 +64,7 @@
/** @typedef {import('../server/shapes.mjs').InsertOp} InsertOp */
/** @typedef {import('../server/shapes.mjs').RefOp} RefOp */
/** @typedef {import('../server/shapes.mjs').RewordOp} RewordOp */
/** @typedef {import('../server/shapes.mjs').RecordOp} RecordOp */
/** @typedef {import('../server/shapes.mjs').RunMeta} RunMeta */
/** @typedef {import('../server/shapes.mjs').RunSettings} RunSettings */
@@ -121,7 +121,8 @@ const fail = (msg) => { console.error(`error: ${msg}`); process.exit(1); };
/** @param {string} p @returns {string} */
const rel = (p) => path.relative(ROOT, p).replaceAll('\\', '/');
// flags: --run <name> beats everything; --gm attributes the op to the GM
// flags: --run <name> beats everything; --gm attributes the op to the GM;
// --model <id> names the pass's model in the apply log
const argv = process.argv.slice(2);
const runIdx = argv.indexOf('--run');
/** @type {?string} */
@@ -155,6 +156,15 @@ if (ownerIdx !== -1) {
ownerOverride = argv[ownerIdx + 1] ?? null;
argv.splice(ownerIdx, 2);
}
// the pass's model, named in the apply log (the server's housekeeping
// passes it; a hand apply or the start gate has none)
const modelIdx = argv.indexOf('--model');
/** @type {?string} */
let passModel = null;
if (modelIdx !== -1) {
passModel = argv[modelIdx + 1] ?? null;
argv.splice(modelIdx, 2);
}
const [cmd, ...args] = argv;
// a run is an instance under runs/, created from a package by `create`;
@@ -241,9 +251,8 @@ if (RUN != null && cmd !== 'init') setSessionRoot(resolveSession(sessionOverride
/** @type {Record<string, string[]>} */
const PHASE_RULES = {
insert: ['dormant'], delete: ['dormant'], revive: ['dormant'], unarchive: ['dormant'],
apply: ['dormant'],
apply: ['dormant'], reapply: ['dormant'],
'status-set': ['dormant', 'live'], 'agenda-set': ['dormant', 'live'],
'status-apply': ['live'], 'agenda-apply': ['live'],
file: ['dormant', 'live'], amend: ['dormant', 'live'], discard: ['dormant', 'live'],
};
/** @param {string} verb */
@@ -533,9 +542,11 @@ function makeValidator(db) {
// --- apply ------------------------------------------------------------------
/** @param {Manifest} mf @param {AppliedLog} applied @param {OverflowItem[]} overflow @returns {string} */
function renderLog(mf, applied, overflow) {
const L = [`# ${mf.session}`, '', mf.summary, ''];
/** @param {Manifest} mf @param {AppliedLog} applied @param {OverflowItem[]} overflow @param {?string} [model] @returns {string} */
function renderLog(mf, applied, overflow, model = null) {
const L = [`# ${mf.session}`, ''];
if (model) L.push(`housekeeper: ${model}`, '');
L.push(mf.summary, '');
/** @template T @param {string} title @param {T[]} rows @param {(r: T) => string} fmt */
const section = (title, rows, fmt) => {
if (!rows.length) return;
@@ -557,25 +568,23 @@ function renderLog(mf, applied, overflow) {
return L.join('\n');
}
/** @param {string} manifestPath */
function cmdApply(manifestPath) {
const db = openDb();
/** @type {Manifest} */ let mf;
try {
mf = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
} catch (e) {
fail(`cannot read manifest ${manifestPath}: ${e.message}`);
}
// the manifest checks, shared by apply and the start-gate reapply's
// scratch pass. freshLog skips the log-collision check -- the reapply
// wipes the old logs before anything lands.
/** @param {DatabaseSync} db @param {Manifest} mf @param {{ freshLog?: boolean }} [opts]
* @returns {{ errors: string[], ins: InsertOp[], touch: RefOp[], promote: RefOp[], demote: RefOp[], reword: RewordOp[], del: RefOp[], rec: RecordOp[], arch: RefOp[], inventions: string[], questions: string[] }} */
function validateManifest(db, mf, opts = {}) {
const { errors, need, asArray, ref } = makeValidator(db);
need(mf.session, 'session');
need(mf.summary, 'summary');
if (typeof mf.session === 'string' && !/^[a-z0-9-]+$/i.test(mf.session)) {
errors.push('session must be a short slug (letters, digits, dashes)');
}
const logFile = mf.session ? path.join(LOG_DIR, `${mf.session}.md`) : null;
if (logFile && fs.existsSync(logFile)) {
errors.push(`${rel(logFile)} already exists -- delete it first if this is a re-run`);
if (!opts.freshLog) {
const logFile = mf.session ? path.join(LOG_DIR, `${mf.session}.md`) : null;
if (logFile && fs.existsSync(logFile)) {
errors.push(`${rel(logFile)} already exists -- delete it first if this is a re-run`);
}
}
const ins = asArray(mf.insert, 'insert');
@@ -615,14 +624,26 @@ function cmdApply(manifestPath) {
for (const [name, arr] of /** @type {[string, string[]][]} */ ([['inventions', inventions], ['open_questions', questions]])) {
arr.forEach((s, i) => { if (typeof s !== 'string' || !s.trim()) errors.push(`${name}[${i}] must be a non-empty string`); });
}
return { errors, ins, touch, promote, demote, reword, del, rec, arch, inventions, questions };
}
/** @param {string} manifestPath */
function cmdApply(manifestPath) {
const db = openDb();
/** @type {Manifest} */ let mf;
try {
mf = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
} catch (e) {
fail(`cannot read manifest ${manifestPath}: ${e.message}`);
}
const { errors, ins, touch, promote, demote, reword, del, arch } = validateManifest(db, mf);
if (errors.length) {
console.error('manifest rejected -- nothing was applied:');
for (const e of errors) console.error(` - ${e}`);
process.exit(1);
}
// validation demands a session slug, so a null logFile is unreachable
if (!logFile) fail('unreachable: manifest without a session');
const logFile = path.join(LOG_DIR, `${mf.session}.md`);
/** @type {AppliedLog} */ const applied = { insert: [], touch: [], promote: [], demote: [], reword: [], delete: [], archive: [] };
/** @type {OverflowItem[]} */ const overflow = [];
@@ -703,7 +724,7 @@ function cmdApply(manifestPath) {
}
fs.mkdirSync(LOG_DIR, { recursive: true });
fs.writeFileSync(logFile, renderLog(mf, applied, overflow));
fs.writeFileSync(logFile, renderLog(mf, applied, overflow, passModel));
const dumpFile = dumpDb(db);
// per-pass snapshot: the committed-truth successor now that runs are
// gitignored -- diffing consecutive snapshots reconstructs the session's
@@ -729,6 +750,53 @@ function cmdApply(manifestPath) {
}
}
// session-0's housekeeping, run at the start gate: rebuild session
// one's rings from its memory.json over a fresh db. Her starting
// memories are authored material through the draft window -- the file
// is the one truth of a draft, so the rebuild discards any hand state
// in the db, and a package saved from the draft carries the same
// file. The manifest is checked against a scratch db first (create's
// empty-rings vantage: a fresh manifest cannot cite entries), so a
// refusal touches nothing.
function cmdReapply() {
enforcePhase('reapply');
if (SESS !== 1) fail('reapply rebuilds session one\'s starting memories -- address session 1');
const dir = path.join(RUN_ROOT, 'sessions', '1');
if (fs.existsSync(path.join(dir, 'log.jsonl'))) {
fail('session one has a log -- it has played; its rings are frozen (a half-stopped run is fixed by hand)');
}
const mem = path.join(dir, 'memory.json');
/** @type {?Manifest} */ let mf = null;
if (fs.existsSync(mem)) {
try {
mf = JSON.parse(fs.readFileSync(mem, 'utf8'));
} catch (e) {
fail(`cannot read ${rel(mem)}: ${e.message}`);
}
}
if (mf) {
const scratch = new DatabaseSync(':memory:');
scratch.exec(fs.readFileSync(SCHEMA_PATH, 'utf8'));
const { errors } = validateManifest(scratch, mf, { freshLog: true });
if (errors.length) {
fail(`memory.json was rejected -- nothing was applied: ${errors.join('; ')}`);
}
}
for (const d of ['db', 'dumps', 'log', 'canon']) {
fs.rmSync(path.join(dir, d), { recursive: true, force: true });
}
fs.mkdirSync(path.join(dir, 'db'), { recursive: true });
const db = new DatabaseSync(DB_PATH);
db.exec(fs.readFileSync(SCHEMA_PATH, 'utf8'));
if (mf) {
cmdApply(mem); // validates again over the real db (deterministic pass), logs, renders, dumps
} else {
renderAll(db);
dumpDb(db);
if (!QUIET) console.log('rebuilt session one: memory.json absent -- empty rings, honestly listed');
}
}
// --- simple commands ---------------------------------------------------------
function cmdInit() {
@@ -930,21 +998,17 @@ function cmdCreate(pkgName, pc, displayName, model) {
setRunRoot(runDir); // views and dumps land inside the new run
buildSession1(runDir);
setSessionRoot(1);
// session-0's housekeeping: memory.json is a manifest -- the mock
// output of the session that never existed -- applied through the
// same path a real pass takes. An absent file is empty rings,
// listed honestly.
// her starting memories stay authored material through the draft
// window: memory.json is editable in setup, and the start gate
// applies it (reapply -- the session-0 housekeeping). The db is an
// empty shell until then; an absent file is empty rings.
const mem = path.join(s1, 'memory.json');
if (fs.existsSync(mem)) {
cmdApply(mem);
} else {
const db = openDb();
renderAll(db);
dumpDb(db);
}
const db = openDb();
renderAll(db);
dumpDb(db);
if (AS_JSON) { console.log(JSON.stringify({ id: runId, package: pkgName, name: settings.name, pc })); return; }
console.log(`created run '${runId}' -- ${runDisplay(pkgName, settings)}: ${rel(runDir)}`);
console.log(` session one is dormant \u00b7 memory ${fs.existsSync(mem) ? 'applied' : 'absent'} \u00b7 start it from setup`);
console.log(` session one is dormant \u00b7 memory ${fs.existsSync(mem) ? 'lands at start' : 'absent'} \u00b7 start it from setup`);
}
function cmdRuns() {
@@ -1176,60 +1240,12 @@ function cmdDiscard(ridStr, reason) {
/** @param {DatabaseSync} db @returns {string[]} */
const statusList = (db) => /** @type {{ descr: string }[]} */ (db.prepare('SELECT descr FROM status ORDER BY id').all()).map((r) => r.descr);
// split a list of descriptions, tolerating newlines and list bullets --
// covers the delta tags and a <status> block body alike
/** @param {unknown} s @returns {string[]} */
const splitDescrs = (s) =>
String(s ?? '').split('\n').flatMap((line) =>
line.replace(/^\s*[-*]\s+/, '').split(',')).map((x) => x.trim()).filter(Boolean);
function cmdStatus() {
console.log(JSON.stringify(statusList(openDb())));
}
/** @param {string} text */
function cmdStatusApply(text) {
const db = openDb();
const lost = [];
const gained = [];
for (const m of String(text ?? '').matchAll(/<lost>([\s\S]*?)<\/lost>/g)) lost.push(...splitDescrs(m[1]));
for (const m of String(text ?? '').matchAll(/<gained>([\s\S]*?)<\/gained>/g)) gained.push(...splitDescrs(m[1]));
/** @type {{ lost: string[], gained: string[], conflicts: string[] }} */ const applied = { lost: [], gained: [], conflicts: [] };
if (!lost.length && !gained.length) {
console.log(JSON.stringify({ ...applied, status: statusList(db) }));
return;
}
const win = AS_GM ? 'gm' : 'pc';
db.exec('BEGIN');
try {
for (const item of lost) {
const row = /** @type {?StatusRow} */ (db.prepare('SELECT * FROM status WHERE descr = ?').get(item));
if (row) {
db.prepare('DELETE FROM status WHERE id = ?').run(row.id);
journal(db, win, 'status-drop', `p${row.id}`, 'delta', row.descr);
applied.lost.push(item);
} else {
applied.conflicts.push(`not in her status: ${item}`);
}
}
for (const item of gained) {
// already listed is a no-op, not a conflict
if (db.prepare('SELECT 1 FROM status WHERE descr = ?').get(item)) continue;
const res = db.prepare('INSERT INTO status (descr, added) VALUES (?, ?)').run(item, today());
journal(db, win, 'status-add', `p${Number(res.lastInsertRowid)}`, 'delta');
applied.gained.push(item);
}
db.exec('COMMIT');
} catch (e) {
db.exec('ROLLBACK');
fail(`status-apply failed, rolled back: ${e.message}`);
}
console.log(JSON.stringify({ ...applied, status: statusList(db) }));
renderAll(db);
dumpDb(db);
}
// whole-status replace (GM override); the journal keeps
// whole-status replace (GM override and the player's <status> block --
// the full-block protocol); the journal keeps
// the full prior status so turn surgery can compensate mechanically
/** @param {DatabaseSync} db @param {string[]} items @param {string} reason @param {string} win @returns {string[]} */
function setStatus(db, items, reason, win) {
@@ -1263,11 +1279,11 @@ function cmdStatusSet(items) {
//
// The hot queue of what drives her: goals she is working towards right
// now -- intentions, never states (those are the status's). Fixed cap
// (a dial); id order IS queue order -- adds land at the top in written
// order, overflow evicts the bottom, a recency ring buffer for free.
// The player mutates via <add>/<drop> in its own turns: drops are
// 0-based indexes against the agenda as last rendered, adds are
// comma-separated. The GM overrides whole-list with agenda-set.
// (a dial); id order IS queue order -- the first item is the top, a
// whole-list set lands in written order, over-cap evicts the bottom,
// a recency ring buffer for free. The player mutates by restating the
// whole <agenda> block in its own turns (the full-block protocol,
// 2026-11-16); the GM overrides whole-list with agenda-set.
/** @param {DatabaseSync} db @returns {string[]} */
const agendaList = (db) => /** @type {{ descr: string }[]} */ (db.prepare('SELECT descr FROM agenda ORDER BY id DESC').all()).map((r) => r.descr);
@@ -1276,87 +1292,22 @@ function cmdAgenda() {
console.log(JSON.stringify(agendaList(openDb())));
}
/** @param {string} text */
function cmdAgendaApply(text) {
const db = openDb();
/** @type {string[]} */ const added = [];
/** @type {string[]} */ const dropped = [];
/** @type {string[]} */ const evicted = [];
/** @type {string[]} */ const conflicts = [];
/** @type {string[]} */ const adds = [];
for (const m of String(text ?? '').matchAll(/<add>([\s\S]*?)<\/add>/g)) adds.push(...splitDescrs(m[1]));
/** @type {string[]} */ const drops = [];
for (const m of String(text ?? '').matchAll(/<drop>([\s\S]*?)<\/drop>/g)) {
drops.push(...String(m[1]).split(/[\n,]/).map((x) => x.trim()).filter(Boolean));
}
if (!adds.length && !drops.length) {
console.log(JSON.stringify({ added, dropped, evicted, conflicts, agenda: agendaList(db) }));
return;
}
const win = AS_GM ? 'gm' : 'pc';
db.exec('BEGIN');
try {
// order of execution (invariants.md): received block -> drop -> add
// -> next block. Indexes resolve against the same snapshot, so a
// multi-drop never shifts under itself.
const snapshot = agendaList(db);
/** @type {number[]} */ const kill = [];
for (const d of drops) {
if (!/^\d+$/.test(d)) { conflicts.push(`not an agenda index: ${JSON.stringify(d)}`); continue; }
const i = Number(d);
if (i >= snapshot.length) {
conflicts.push(`agenda has no item at index ${i}${snapshot.length ? '' : ' -- it is empty'}`);
continue;
}
kill.push(i);
}
for (const i of [...new Set(kill)].sort((a, b) => b - a)) {
const descr = snapshot[i];
const row = /** @type {{ id: number }} */ (db.prepare('SELECT id FROM agenda WHERE descr = ?').get(descr));
db.prepare('DELETE FROM agenda WHERE id = ?').run(row.id);
journal(db, win, 'agenda-drop', `a${row.id}`, 'delta', descr);
dropped.push(descr);
}
// adds land at the top in written order (first item = the top slot):
// insert in reverse, id order does the rest. Already queued is a
// no-op, not a conflict -- reorder is drop-then-add, by design.
// The report keeps written order (the reverse loop is storage mechanics).
const fresh = [];
for (const item of [...new Set(adds)].reverse()) {
if (db.prepare('SELECT 1 FROM agenda WHERE descr = ?').get(item)) continue;
const res = db.prepare('INSERT INTO agenda (descr, added) VALUES (?, ?)').run(item, today());
journal(db, win, 'agenda-add', `a${Number(res.lastInsertRowid)}`, 'delta');
fresh.push(item);
}
added.push(...fresh.reverse());
// overflow: the bottom sinks off the list -- by design, not an error
const over = agendaList(db);
for (let i = over.length - 1; i >= AGENDA_CAP; i--) {
const row = /** @type {{ id: number }} */ (db.prepare('SELECT id FROM agenda WHERE descr = ?').get(over[i]));
db.prepare('DELETE FROM agenda WHERE id = ?').run(row.id);
journal(db, win, 'agenda-evict', `a${row.id}`, 'agenda overflow (auto)');
evicted.push(over[i]);
}
db.exec('COMMIT');
} catch (e) {
db.exec('ROLLBACK');
fail(`agenda-apply failed, rolled back: ${e.message}`);
}
console.log(JSON.stringify({ added, dropped, evicted, conflicts, agenda: agendaList(db) }));
renderAll(db);
dumpDb(db);
}
// whole-list replace (GM override); the journal keeps the prior queue
// so turn surgery can compensate mechanically (the saga rule)
/** @param {DatabaseSync} db @param {string[]} items @param {string} reason @param {string} win @returns {string[]} */
// whole-list replace (GM override and the player's <agenda> block --
// the full-block protocol); the journal keeps the prior queue so turn
// surgery can compensate mechanically (the saga rule). Over-cap lists
// evict from the bottom silently -- ruled a feature (GM, 2026-11-16):
// immersive, human-like, fun chaos. Silent to her; the caller surfaces
// the evicted to the GM.
/** @param {DatabaseSync} db @param {string[]} items @param {string} reason @param {string} win @returns {{ set: string[], evicted: string[] }} */
function setAgenda(db, items, reason, win) {
const clean = [...new Set(items.map((s) => String(s ?? '').trim()))].filter(Boolean);
const set = clean.slice(0, AGENDA_CAP);
const evicted = clean.slice(AGENDA_CAP);
const prior = agendaList(db);
db.exec('BEGIN');
try {
db.prepare('DELETE FROM agenda').run();
for (const d of [...clean].reverse()) { // first item = the top of the queue
for (const d of [...set].reverse()) { // first item = the top of the queue
db.prepare('INSERT INTO agenda (descr, added) VALUES (?, ?)').run(d, today());
}
journal(db, win, 'agenda-set', 'agenda', reason, JSON.stringify(prior));
@@ -1365,14 +1316,14 @@ function setAgenda(db, items, reason, win) {
db.exec('ROLLBACK');
fail(`agenda-set failed, rolled back: ${e.message}`);
}
return clean;
return { set, evicted };
}
/** @param {string[]} items */
function cmdAgendaSet(items) {
const db = openDb();
const clean = setAgenda(db, items, AS_GM ? 'GM override' : 'agenda set', AS_GM ? 'gm' : 'pc');
console.log(JSON.stringify(clean));
const r = setAgenda(db, items, AS_GM ? 'GM override' : 'agenda set', AS_GM ? 'gm' : 'pc');
console.log(JSON.stringify(r));
renderAll(db);
dumpDb(db);
}
@@ -1474,6 +1425,7 @@ switch (cmd) {
case 'init': cmdInit(); break;
case 'render': renderAll(openDb()); break;
case 'apply': args[0] ? cmdApply(args[0]) : fail('usage: apply <manifest.json>'); break;
case 'reapply': cmdReapply(); break;
case 'insert': (args.length >= 3) ? gmOp(args[0], args[1], args[2], args[3] ?? '') : fail('usage: insert <a|b> <type> "Label" "detail"'); break;
case 'delete': (args.length >= 1) ? cmdDelete(args[0], args[1]) : fail('usage: delete <id> "reason"'); break;
case 'revive': (args.length >= 1) ? cmdRevive(args[0], args[1]) : fail('usage: revive <id> [a|b]'); break;
@@ -1481,10 +1433,8 @@ switch (cmd) {
case 'amend': (args.length >= 2) ? cmdAmend(args[0], args[1]) : fail('usage: amend <rid> "new detail"'); break;
case 'discard': (args.length >= 1) ? cmdDiscard(args[0], args[1]) : fail('usage: discard <rid> "reason"'); break;
case 'status': cmdStatus(); break;
case 'status-apply': (args.length >= 1) ? cmdStatusApply(args.join(' ')) : fail('usage: status-apply "<turn text>"'); break;
case 'status-set': cmdStatusSet(args); break; // no args = clear the status (a legitimate GM override)
case 'status-set': cmdStatusSet(args); break; // no args = clear the status (a deliberate clear -- the player's empty block or a GM override)
case 'agenda': cmdAgenda(); break;
case 'agenda-apply': (args.length >= 1) ? cmdAgendaApply(args.join(' ')) : fail('usage: agenda-apply "<turn text>"'); break;
case 'agenda-set': cmdAgendaSet(args); break; // no args = clear the agenda
case 'pick': cmdPick(args); break;
case 'search': cmdSearch(args); break;
@@ -1493,6 +1443,6 @@ switch (cmd) {
case 'dump': cmdDump(); break;
case 'restore': cmdRestore(FORCE); break;
default:
console.error('usage: node tool/memory.mjs <packages|runs|create|save-package|init|render|apply|insert|delete|revive|file|amend|discard|search|unarchive|status|status-apply|status-set|agenda|agenda-apply|agenda-set|pick|dump|restore|report>');
console.error('usage: node tool/memory.mjs <packages|runs|create|save-package|init|render|apply|reapply|insert|delete|revive|file|amend|discard|search|unarchive|status|status-set|agenda|agenda-set|pick|dump|restore|report>');
process.exit(1);
}