@oathe/oathe 0.2.3 → 0.3.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.
Files changed (74) hide show
  1. package/NOTICE +3 -4
  2. package/README.md +15 -45
  3. package/assets/oathe-hero.svg +92 -0
  4. package/bin/oathe.mjs +401 -59
  5. package/docs/PRIVACY.md +13 -5
  6. package/notch/Oathe Notch.app/Contents/Info.plist +13 -0
  7. package/notch/Oathe Notch.app/Contents/MacOS/OatheNotch +0 -0
  8. package/notch/Oathe Notch.app/Contents/_CodeSignature/CodeResources +115 -0
  9. package/notch/README.md +88 -0
  10. package/package.json +13 -4
  11. package/plugin/.claude-plugin/plugin.json +1 -1
  12. package/plugin/.cursor-plugin/plugin.json +36 -0
  13. package/plugin/.mcp.json +1 -4
  14. package/plugin/commands/verify.md +18 -0
  15. package/plugin/hooks/frame-note.mjs +5 -3
  16. package/plugin/hooks/heartbeat.mjs +21 -25
  17. package/plugin/hooks/lib.mjs +96 -33
  18. package/plugin/hooks/render-board.mjs +47 -7
  19. package/src/activation.mjs +126 -0
  20. package/src/atif.mjs +4 -13
  21. package/src/blocks.mjs +113 -8
  22. package/src/board-render.mjs +55 -29
  23. package/src/config.mjs +100 -15
  24. package/src/context.mjs +4 -8
  25. package/src/doctor.mjs +96 -15
  26. package/src/fence.mjs +85 -0
  27. package/src/fslock.mjs +51 -0
  28. package/src/harnesses/catalog.mjs +180 -0
  29. package/src/harnesses/claude.mjs +196 -0
  30. package/src/harnesses/codex.mjs +188 -0
  31. package/src/harnesses/cursor.mjs +234 -0
  32. package/src/harnesses/dialects.mjs +52 -0
  33. package/src/harnesses/harness.mjs +203 -0
  34. package/src/harnesses/surfaces.mjs +71 -0
  35. package/src/home.mjs +107 -0
  36. package/src/init.mjs +101 -21
  37. package/src/launch-env.mjs +1 -51
  38. package/src/launch.mjs +36 -105
  39. package/src/manifest.mjs +7 -3
  40. package/src/mcp/connection.mjs +218 -0
  41. package/src/mcp/oathe-tools.mjs +380 -141
  42. package/src/notch.mjs +160 -0
  43. package/src/pager.mjs +178 -0
  44. package/src/paths.mjs +13 -1
  45. package/src/plans.mjs +10 -2
  46. package/src/registry.mjs +110 -0
  47. package/src/runtime/discharge.mjs +1 -1
  48. package/src/runtime/provider.mjs +10 -7
  49. package/src/runtime/simple-cage.mjs +18 -9
  50. package/src/runtime/sql-acceptance-lane.mjs +1 -1
  51. package/src/session-host.mjs +8 -6
  52. package/src/sessions.mjs +168 -0
  53. package/src/setup.mjs +494 -0
  54. package/src/speaker.mjs +65 -0
  55. package/src/statements.mjs +113 -0
  56. package/src/substrate.mjs +44 -0
  57. package/src/successor.mjs +1 -1
  58. package/src/traces.mjs +8 -8
  59. package/src/uninstall.mjs +10 -2
  60. package/src/verifier.mjs +135 -47
  61. package/src/verify-dispatch.mjs +169 -0
  62. package/src/welcome.mjs +32 -0
  63. package/src/wire.mjs +64 -0
  64. package/src/workspace-resolver.mjs +178 -0
  65. package/src/workspace.mjs +16 -5
  66. package/vendor/ddl/001_core.sql +1 -1
  67. package/vendor/ddl/004_delegation.sql +1 -1
  68. package/vendor/ddl/006_dependency.sql +1 -1
  69. package/vendor/ddl/008_effect_receipt.sql +1 -1
  70. package/vendor/ddl/009_verified_edge.sql +1 -1
  71. package/vendor/ddl/011_confirm.sql +2 -2
  72. package/vendor/ddl/manifest.json +8 -8
  73. package/assets/handoff-splash.png +0 -0
  74. package/src/harness.mjs +0 -271
@@ -1,11 +1,51 @@
1
- // SessionStart — the board, delivered twice over: the full list as additional context for the
2
- // MODEL, and one visible line for the USER. The rendering itself lives in src/board-render.mjs,
3
- // shared with the launcher (which prints the same board into scrollback before the TUI starts).
1
+ // SessionStart — activation + the board. Opening a session on a folder ACTIVATES its
2
+ // workspace (central registry row + the context-file fences, through the ONE writer in
3
+ // src/activation.mjs, disclosed in the render) and then delivers the board twice over: the
4
+ // full list as additional context for the MODEL, one visible line for the USER — each in the
5
+ // session's own dialect. Activation failing must never cost the session its board: the
6
+ // failure is reported on stderr and the render proceeds (hooks are the sanctioned fail-soft).
4
7
 
5
- import { failSoft, emitSessionStart } from './lib.mjs';
8
+ import { failSoft, emitSessionStart, ensureSessionRegistered } from './lib.mjs';
6
9
  import { renderBoard } from '../../src/board-render.mjs';
10
+ import { WorkspaceRegistry } from '../../src/registry.mjs';
7
11
 
8
- await failSoft(async ({ substrate, workspace, identity, config }) => {
9
- const { context, message } = await renderBoard({ client: substrate, identity, workspace, config });
10
- emitSessionStart({ context, message });
12
+ await failSoft(async ({ substrate, workspace, synthetic, identity, config, cwd, dialect, paths, env, session }) => {
13
+ const registry = new WorkspaceRegistry({ registryPath: paths.registryPath });
14
+ let disclosed = null;
15
+ try {
16
+ const [{ activateWorkspace }, { InstallManifest }, { packageVersion }] = await Promise.all([
17
+ import('../../src/activation.mjs'), import('../../src/manifest.mjs'), import('../../src/context.mjs'),
18
+ ]);
19
+ const manifest = InstallManifest.load({ manifestPath: paths.manifestPath, backupsDir: paths.backupsDir });
20
+ const out = await activateWorkspace({
21
+ cwd, env, manifest, registry, config, version: packageVersion(paths), source: 'hook:session-start',
22
+ });
23
+ // Disclose only when something was actually written — an unchanged fence needs no line,
24
+ // and autoActivate=false registers quietly (the user's own explicit choice).
25
+ disclosed = out.actions.some((a) => a.changed) ? out.disclosed : null;
26
+ } catch (e) {
27
+ process.stderr.write(`oathe hook: activation ${String(e?.message || e)}\n`);
28
+ }
29
+ // Session liveness: the hook's ppid IS the harness process — the shared convergence
30
+ // signal registers its facts so the notch can meet the living process behind a claim.
31
+ await ensureSessionRegistered({ session, paths, workspace });
32
+ // R-PAGER: the breach digest is computed apart from the board, and a failure there is
33
+ // reported on stderr while the board still renders — the digest is a courtesy, the board
34
+ // is the session's contract.
35
+ let breaches = [];
36
+ try {
37
+ const { Pager } = await import('../../src/pager.mjs');
38
+ breaches = await new Pager({ client: substrate, identity, config, registry }).breaches();
39
+ } catch (e) {
40
+ process.stderr.write(`oathe hook: pager ${String(e?.message || e)}\n`);
41
+ }
42
+ const { context, message } = await renderBoard({ client: substrate, identity, workspace, config, synthetic, breaches });
43
+ // R-QUIET: the board message is breaches-or-silence; a real write's disclosure still speaks
44
+ // (a receipt, printed once) even when the board itself has nothing to push.
45
+ const visible = [message, disclosed].filter(Boolean).join('\n') || null;
46
+ emitSessionStart({
47
+ context: disclosed ? `${context}\n\n_${disclosed}_` : context,
48
+ message: visible,
49
+ dialect,
50
+ });
11
51
  }, { quietNote: 'Oathe board unavailable — substrate not initialized; run `oathe init`' });
@@ -0,0 +1,126 @@
1
+ // oathe — workspace activation: THE fence writer. One implementation puts the managed
2
+ // `## Oathe` section into the context files of every harness detected on the machine (each
3
+ // adapter's own declared fact), backed up once and manifest-recorded project-scope, registers
4
+ // the workspace centrally, and DISCLOSES what it wrote. The launcher preflight, the
5
+ // SessionStart hook, and oathe_claim all activate through here — byte-identical output, no
6
+ // drift between paths. `autoActivate` (config) is the off switch: false = register only.
7
+ // A SYNTHETIC workspace (R-BOARD-SCOPE — a harness staging dir, not a project folder) is
8
+ // never activated: no fences, no registry row; the writer defends itself so every caller
9
+ // inherits the rule.
10
+
11
+ import path from 'node:path';
12
+
13
+ import { fenceBody, writeFence } from './fence.mjs';
14
+ import { buildAll, byName, census } from './harnesses/catalog.mjs';
15
+ import { withFileLock } from './fslock.mjs';
16
+ import { homeOf } from './paths.mjs';
17
+ import { WorkspaceResolver } from './workspace-resolver.mjs';
18
+
19
+ export { fenceBody } from './fence.mjs';
20
+
21
+ /** The context files the machine's detected harnesses actually read — each adapter's fact. */
22
+ export function contextFileTargets({ env }) {
23
+ const home = homeOf(env);
24
+ const seen = census(buildAll({ home, envPath: env.PATH ?? '', paths: null }));
25
+ return [...new Set(seen.filter((s) => s.installed).flatMap((s) => byName(s.name).contextFiles))];
26
+ }
27
+
28
+ /**
29
+ * Activate `cwd`'s workspace: register centrally, then (unless autoActivate is off) write the
30
+ * fences + manifest rows. Idempotent; every write is disclosed.
31
+ * @param {{cwd: string, env: NodeJS.ProcessEnv, manifest: object, registry?: object|null,
32
+ * config?: object|null, version: string, source: string, harness?: string|null}} o
33
+ * @returns {Promise<{workspace: string|null, synthetic: boolean, registered: boolean,
34
+ * fences: string[], actions: object[], disclosed: string}>}
35
+ * workspace is null for a synthetic directory — it has no board.
36
+ */
37
+ export async function activateWorkspace({
38
+ cwd, env, manifest, registry = null, config = null, version, source, harness = null,
39
+ }) {
40
+ const { ref: workspace, synthetic } = WorkspaceResolver.describe({ dir: cwd, home: homeOf(env) });
41
+ if (synthetic) {
42
+ return {
43
+ workspace: null,
44
+ synthetic,
45
+ registered: false,
46
+ fences: [],
47
+ actions: [],
48
+ disclosed: 'synthetic workspace (a harness staging directory, not a project folder) — '
49
+ + 'nothing registered, no files written',
50
+ };
51
+ }
52
+ if (registry) await registry.register({ cwd, source, harness });
53
+ const autoOn = config ? config.get('autoActivate') : true;
54
+ if (!autoOn) {
55
+ return {
56
+ workspace,
57
+ synthetic,
58
+ registered: registry !== null,
59
+ fences: [],
60
+ actions: [],
61
+ disclosed: 'activation off (autoActivate=false) — workspace registered only, no files written',
62
+ };
63
+ }
64
+ const targets = contextFileTargets({ env });
65
+ const actions = [];
66
+ const written = [];
67
+ // The lock spans the whole read-modify-write over the shared manifest: concurrent hooks and
68
+ // servers activate at once, and save() alone cannot prevent a lost update.
69
+ await withFileLock(manifest.manifestPath, async () => {
70
+ for (const file of targets) {
71
+ const target = path.join(cwd, file);
72
+ const { changed } = writeFence({ manifest, file: target, version, body: fenceBody(workspace), scope: 'project' });
73
+ actions.push({ action: `${file.toLowerCase().replace('.', '-')}-fence`, file: target, changed });
74
+ written.push(file);
75
+ if (registry) await registry.recordFence(workspace, file, version);
76
+ }
77
+ manifest.save();
78
+ });
79
+ const changedFiles = actions.filter((a) => a.changed).map((a) => path.basename(a.file));
80
+ return {
81
+ workspace,
82
+ synthetic,
83
+ registered: registry !== null,
84
+ fences: written,
85
+ actions,
86
+ disclosed: changedFiles.length > 0
87
+ ? `oathe pinned this folder's board into ${changedFiles.join(' and ')} (managed section; `
88
+ + 'remove with `oathe uninstall`)'
89
+ : `board fences current in ${written.join(' and ')}`,
90
+ };
91
+ }
92
+
93
+ /**
94
+ * The tools' activation seam — ONE implementation for every tool host (the MCP connection,
95
+ * the CLI): every successful speech act registers the workspace centrally; `oathe_claim`
96
+ * activates through the writer above. A synthetic workspace registers nothing (the writer
97
+ * already refuses to activate one). `sourceFor` names the host's registry-source convention.
98
+ */
99
+ export class ActivationSeam {
100
+ /**
101
+ * @param {{cwd: string, env: NodeJS.ProcessEnv, registry: object, manifest: object, config: object,
102
+ * version: string, synthetic: boolean, sourceFor: (tool: string) => string, harness?: string|null}} o
103
+ */
104
+ constructor({ cwd, env, registry, manifest, config, version, synthetic, sourceFor, harness = null }) {
105
+ this.cwd = cwd;
106
+ this.env = env;
107
+ this.registry = registry;
108
+ this.manifest = manifest;
109
+ this.config = config;
110
+ this.version = version;
111
+ this.synthetic = synthetic;
112
+ this.sourceFor = sourceFor;
113
+ this.harness = harness;
114
+ }
115
+
116
+ /** @returns {Promise<object|null>} the registry row, or null for a synthetic workspace */
117
+ register(tool) {
118
+ if (this.synthetic) return Promise.resolve(null);
119
+ return this.registry.register({ cwd: this.cwd, source: this.sourceFor(tool), harness: this.harness });
120
+ }
121
+
122
+ activate(tool) {
123
+ const { cwd, env, manifest, registry, config, version, harness } = this;
124
+ return activateWorkspace({ cwd, env, manifest, registry, config, version, harness, source: this.sourceFor(tool) });
125
+ }
126
+ }
package/src/atif.mjs CHANGED
@@ -5,9 +5,7 @@
5
5
  // trajectory (finalize() validates); anything unmappable is a typed refusal, never a silent
6
6
  // drop. The reference models forbid unknown fields outside `extra` — so does our validator.
7
7
 
8
- import path from 'node:path';
9
-
10
- import { ClaudeTraceStore, CodexTraceStore, TraceContractError, harnessForTracePath } from './traces.mjs';
8
+ import { TraceContractError } from './traces.mjs';
11
9
  import { makeToolDefs } from './mcp/oathe-tools.mjs';
12
10
 
13
11
  export const ATIF_SCHEMA_VERSION = 'ATIF-v1.7';
@@ -64,6 +62,7 @@ export class AtifProjector {
64
62
  constructor({ store }) {
65
63
  if (!store) throw new AtifError('ATIF_STORE_REQUIRED', 'a projector needs its trace store');
66
64
  this.store = store;
65
+ this.harness = store.harness; // the store was named by its adapter; the projector labels ATIF with the same name
67
66
  }
68
67
 
69
68
  /** @returns {object} a VALID ATIF trajectory (validator-asserted) */
@@ -171,8 +170,6 @@ const CLAUDE_NOISE_TYPES = new Set([
171
170
  ]);
172
171
 
173
172
  export class ClaudeAtifProjector extends AtifProjector {
174
- harness = 'claude';
175
-
176
173
  map(rows, file) {
177
174
  let lastMessageId = null;
178
175
  this.turnBroken = false;
@@ -266,8 +263,6 @@ export class ClaudeAtifProjector extends AtifProjector {
266
263
  // --------------------------------------------------------------------------- Codex
267
264
 
268
265
  export class CodexAtifProjector extends AtifProjector {
269
- harness = 'codex';
270
-
271
266
  map(rows, file) {
272
267
  const head = rows[0];
273
268
  if (head?.type !== 'session_meta') {
@@ -377,18 +372,14 @@ export class CodexAtifProjector extends AtifProjector {
377
372
 
378
373
  // --------------------------------------------------------------------------- factory
379
374
 
380
- export function projectorFor(file, { claudeHome, codexHome } = {}) {
381
- return harnessForTracePath(file) === 'codex'
382
- ? new CodexAtifProjector({ store: new CodexTraceStore({ home: codexHome }) })
383
- : new ClaudeAtifProjector({ store: new ClaudeTraceStore({ home: claudeHome }) });
384
- }
375
+ // projectorFor lives in src/harnesses/catalog.mjs — the store that owns a record projects it.
385
376
 
386
377
  // --------------------------------------------------------------------------- claim intervals
387
378
 
388
379
  const FOCUS_CLOSERS = new Set(['oathe_done', 'oathe_yield']);
389
380
 
390
381
  /**
391
- * Claim-focused intervals of a trajectory (correction packet §5.4): a session becomes
382
+ * Claim-focused intervals of a trajectory (ruling R3 §5.4): a session becomes
392
383
  * attributable to a task only from the step where it ACTS on that task through an oathe
393
384
  * speech act (claim, pickup, statement, done, yield — the projector's claim_events), and
394
385
  * stops being attributable when the act names a different task (a switch), when done/yield
package/src/blocks.mjs CHANGED
@@ -3,11 +3,13 @@
3
3
  // not a discipline each call site re-implements.
4
4
  //
5
5
  // Two styles exist because the surfaces do: fenced TEXT for files with comments (CLAUDE.md,
6
- // AGENTS.md, config.toml — the estate's zprofile `>>> <<<` precedent), and owned KEY PATHS for
6
+ // AGENTS.md, config.toml — the long-standing zprofile `>>> <<<` precedent), and owned KEY PATHS for
7
7
  // JSON files, where ownership is recorded in the install manifest rather than as in-file marker
8
8
  // keys (Claude Code validates settings.json and warns on unknown keys, so the file stays clean
9
9
  // and the manifest carries the version + sha).
10
10
 
11
+ import fs from 'node:fs';
12
+
11
13
  const FENCE_NAME = 'oathe';
12
14
 
13
15
  export const FENCE_STYLES = Object.freeze({
@@ -117,18 +119,34 @@ export class FencedBlock {
117
119
  }
118
120
  }
119
121
 
122
+ export class JsonTargetError extends Error {
123
+ constructor(message) {
124
+ super(message);
125
+ this.name = 'JsonTargetError';
126
+ this.code = 'OATHE_JSON_TARGET_INVALID';
127
+ }
128
+ }
129
+
130
+ function parseJsonTarget(text) {
131
+ if (text.trim() === '') return {};
132
+ try {
133
+ return JSON.parse(text);
134
+ } catch (e) {
135
+ throw new JsonTargetError(`the target file is not valid JSON, so oathe refuses to rewrite it: ${e.message}`);
136
+ }
137
+ }
138
+
139
+ function stringifyJsonTarget(doc) {
140
+ return `${JSON.stringify(doc, null, 2)}\n`;
141
+ }
142
+
120
143
  export class JsonEntries {
121
144
  #parse(text) {
122
- if (text.trim() === '') return {};
123
- try {
124
- return JSON.parse(text);
125
- } catch (e) {
126
- throw new Error(`the target file is not valid JSON, so oathe refuses to rewrite it: ${e.message}`);
127
- }
145
+ return parseJsonTarget(text);
128
146
  }
129
147
 
130
148
  #stringify(doc) {
131
- return `${JSON.stringify(doc, null, 2)}\n`;
149
+ return stringifyJsonTarget(doc);
132
150
  }
133
151
 
134
152
  /** @returns {*} the value at `path`, or undefined */
@@ -190,3 +208,90 @@ export class JsonEntries {
190
208
  return { content, changed: content !== text };
191
209
  }
192
210
  }
211
+
212
+ /**
213
+ * Owned ELEMENTS inside JSON arrays (Cursor's hooks.json shape: event name → array of hook
214
+ * definitions the user may also populate). Ownership is a predicate over the element —
215
+ * recorded in the manifest as the matchable detail — so apply never duplicates and remove
216
+ * takes exactly ours, leaving user elements byte-preserved.
217
+ */
218
+ export class JsonArrayEntries {
219
+ /** @param {string} text @param {Array<{path: string[], element: object, owns: (el: any) => boolean}>} entries */
220
+ apply(text, entries) {
221
+ const doc = parseJsonTarget(text);
222
+ for (const { path, element, owns } of entries) {
223
+ let node = doc;
224
+ for (const key of path.slice(0, -1)) {
225
+ if (node[key] === null || typeof node[key] !== 'object') node[key] = {};
226
+ node = node[key];
227
+ }
228
+ const leaf = path.at(-1);
229
+ if (!Array.isArray(node[leaf])) node[leaf] = [];
230
+ if (!node[leaf].some(owns)) node[leaf].push(element);
231
+ }
232
+ const content = stringifyJsonTarget(doc);
233
+ return { content, changed: content !== text };
234
+ }
235
+
236
+ /** Remove OUR elements; an array (or created parent) emptied by that is pruned. */
237
+ remove(text, entries) {
238
+ const doc = parseJsonTarget(text);
239
+ for (const { path, owns } of entries) {
240
+ const parents = [];
241
+ let node = doc;
242
+ let missing = false;
243
+ for (const key of path.slice(0, -1)) {
244
+ if (node === null || typeof node !== 'object' || !(key in node)) { missing = true; break; }
245
+ parents.push({ node, key });
246
+ node = node[key];
247
+ }
248
+ const leaf = path.at(-1);
249
+ if (missing || !Array.isArray(node?.[leaf])) continue;
250
+ node[leaf] = node[leaf].filter((el) => !owns(el));
251
+ if (node[leaf].length === 0) delete node[leaf];
252
+ for (let i = parents.length - 1; i >= 0; i -= 1) {
253
+ const { node: parent, key } = parents[i];
254
+ const child = parent[key];
255
+ if (child !== null && typeof child === 'object' && Object.keys(child).length === 0) {
256
+ delete parent[key];
257
+ } else break;
258
+ }
259
+ }
260
+ const content = stringifyJsonTarget(doc);
261
+ return { content, changed: content !== text };
262
+ }
263
+ }
264
+
265
+ /**
266
+ * Is this the RESIDUE of managed writes — a file with nothing of substance left once oathe's
267
+ * own entries are gone? Whitespace; JSON whose every leaf is an empty container ({} / [] /
268
+ * {"hooks":{}}); TOML/INI text that is only blank lines and comments. Uninstall deletes a file
269
+ * that init created (absent before) when this is true, and never otherwise — the fence rule
270
+ * ("created by us and empty after removal → remove"), applied to every managed-write engine.
271
+ */
272
+ /**
273
+ * Remove the files WE created (absent before our first write) that now hold nothing of
274
+ * substance — the rule uninstall applies machine-wide, and an init unwire applies to one
275
+ * harness's files. One implementation; both callers pass the backups they mean.
276
+ * @returns {Array<{action: string, file: string}>}
277
+ */
278
+ export function sweepCreatedResidue({ backups, fs: fsImpl = fs }) {
279
+ const actions = [];
280
+ for (const b of backups.filter((x) => x.absent_before && fsImpl.existsSync(x.file))) {
281
+ if (!isEmptyResidue(fsImpl.readFileSync(b.file, 'utf8'))) continue;
282
+ fsImpl.rmSync(b.file);
283
+ actions.push({ action: 'created-file-removed', file: b.file });
284
+ }
285
+ return actions;
286
+ }
287
+
288
+ export function isEmptyResidue(text) {
289
+ const trimmed = String(text ?? '').trim();
290
+ if (trimmed === '') return true;
291
+ try {
292
+ const hollow = (v) => (Array.isArray(v) ? v.every(hollow)
293
+ : (v !== null && typeof v === 'object') ? Object.values(v).every(hollow) : false);
294
+ return hollow(JSON.parse(trimmed));
295
+ } catch { /* not JSON */ }
296
+ return trimmed.split('\n').every((line) => /^\s*(#.*)?$/.test(line));
297
+ }
@@ -2,31 +2,45 @@
2
2
  // for the model + the visible line) and the launcher (printed into terminal scrollback before
3
3
  // the harness TUI starts, because TUIs bury hook output in transcript overlays).
4
4
  //
5
- // Three states, three voices: RECOVERY (tasks of yours survived across sessions — the moment
6
- // oathe visibly earned its keep, so the celebration and the star ask ride here, and ONLY
7
- // here); open-but-not-yours (the lock summary); and a clean folder (the beer — silence would
8
- // be indistinguishable from oathe not running).
5
+ // R-QUIET (2026-08-29): the human channel is breaches-or-silence. A line oathe prints must
6
+ // change what the person does next or it gets deleted — so breaches PUSH (a broken promise is
7
+ // this operator's to answer for), status PULLS (`oathe ls`), and the restored-state banner
8
+ // rides the actual pickup (oathe_pickup), never ambient session start. The model's context
9
+ // channel still carries the full board; only the human channel keeps quiet.
9
10
 
10
11
  import { createOatheTools } from './mcp/oathe-tools.mjs';
12
+ import { SPEECH_ACT_RULE } from './fence.mjs';
11
13
 
12
14
 
13
15
 
16
+ /** The board's scope, spoken once: the folder lens, or the whole machine (R-BOARD-SCOPE). */
17
+ export const MACHINE_SCOPE_LABEL = 'all workspaces';
18
+
14
19
  /**
15
- * @param {{client: {query: Function}, identity: object, workspace: string}} o
16
- * @returns {Promise<{context: string, message: string}>} context = the full board (model /
17
- * scrollback); message = the one visible state line
20
+ * @param {{client: {query: Function}, identity: object, workspace: string|null, config?: object,
21
+ * synthetic?: boolean, all?: boolean, breaches?: object[]}} o synthetic — the session
22
+ * sits on a harness staging dir (R-BOARD-SCOPE): the tools serve the full board and the
23
+ * render says so. all — an honest machine lens (the notch feed): the folder filter is
24
+ * dropped without borrowing synthetic's staging-dir semantics. breaches — the Pager's
25
+ * digest (R-PAGER), rendered machine-wide below the board.
26
+ * @returns {Promise<{context: string, message: string|null, sections: object, lens: string|null}>}
27
+ * context = the full board (model / scrollback); message = the one visible push line
28
+ * (breaches only — null is silence); lens = the workspace the board was scoped to,
29
+ * null for the whole machine
18
30
  */
19
- export async function renderBoard({ client, identity, workspace, config }) {
20
- const starUrl = config?.get('starUrl') ?? 'https://github.com/oathe-ai/oathe';
21
- const starAsk = `⭐ Support open-source infra: ${starUrl}`;
22
- const tools = createOatheTools({ client, identity, workspace, config });
23
- const { sections } = await tools.oathe_board({});
31
+ export async function renderBoard({ client, identity, workspace, config, synthetic = false, all = false, breaches = [] }) {
32
+ const tools = createOatheTools({ client, identity, workspace, config, synthetic });
33
+ const { sections, workspace: lens } = await tools.oathe_board({ all });
24
34
  const { mine, open, asserted, held } = sections;
25
35
  const total = mine.length + open.length + asserted.length + held.length;
36
+ const scope = lens ?? MACHINE_SCOPE_LABEL;
37
+ const where = lens ? 'in this folder' : 'anywhere';
26
38
 
27
- const lines = [`## Oathe board (${workspace})`, ''];
39
+ // The rule rides every render: a session with no fence (a staging dir, a folder whose
40
+ // activation is off) still opens knowing how the board is meant to be used.
41
+ const lines = [`## Oathe board (${scope})`, '', `_${SPEECH_ACT_RULE}_`, ''];
28
42
  if (total === 0) {
29
- lines.push('_No open tasks in this workspace. Claim before you build: `oathe_claim`._');
43
+ lines.push(`_No open tasks ${where}._`);
30
44
  }
31
45
  if (mine.length > 0) {
32
46
  lines.push('**Yours (still claimed by you — completion not asserted; say `continue <task>` to pick one up):**');
@@ -53,21 +67,30 @@ export async function renderBoard({ client, identity, workspace, config }) {
53
67
  lines.push('**Held:**');
54
68
  for (const r of held) lines.push(`- [${r.task_id}] ${r.objective} (${r.principal_id})`);
55
69
  }
70
+ if (breaches.length > 0) {
71
+ // R-PAGER: promises breached ANYWHERE on this machine — the one place a folder lens does
72
+ // not apply, because a breach elsewhere is still this operator's to answer for.
73
+ lines.push('', `## Breached promises (${MACHINE_SCOPE_LABEL})`, '');
74
+ for (const b of breaches) lines.push(`- [${b.task_id}] ${b.objective} — ${b.detail} (home: ${b.home})`);
75
+ }
56
76
 
57
- let message;
58
- if (mine.length > 0) {
59
- const n = mine.length === 1 ? '1 task' : `${mine.length} tasks`;
60
- message = `🎉 Oathe just saved your session state — ${n} still yours! ${starAsk}`;
61
- } else if (total > 0) {
77
+ // R-QUIET: breaches-or-silence. Wording is the founder's bar (2026-08-31): PERSON
78
+ // words, not board words — what needs you, in two buckets. "to fix" = a verdict came
79
+ // back or the verifier itself failed (a person acts); "to verify" = asserted and never
80
+ // judged (the system drains these itself; the count is the queue, not a chore). Composed
81
+ // HERE and only here; the hook message and the notch bar render this string verbatim.
82
+ let message = null;
83
+ if (breaches.length > 0) {
84
+ const byKind = {};
85
+ for (const b of breaches) byKind[b.kind] = (byKind[b.kind] ?? 0) + 1;
86
+ const fix = (byKind.reopened ?? 0) + (byKind.stalled ?? 0);
62
87
  const parts = [];
63
- parts.push(open.length === 1 ? '1 open task' : `${open.length} open tasks`);
64
- if (asserted.length > 0) parts.push(`${asserted.length} asserted`);
65
- if (held.length > 0) parts.push(`${held.length} held`);
66
- message = `🔒 Oathe: ${parts.join(' · ')}`;
67
- } else {
68
- message = '🍺 No open tasks in this folder — Oathe is keeping track.';
88
+ if (fix > 0) parts.push(`${fix} to fix`);
89
+ if (byKind.overdue) parts.push(`${byKind.overdue} to verify`);
90
+ if (byKind.quiet) parts.push(`${byKind.quiet} gone quiet`);
91
+ message = parts.join(' · ');
69
92
  }
70
- return { context: lines.join('\n'), message, sections };
93
+ return { context: lines.join('\n'), message, sections, lens };
71
94
  }
72
95
 
73
96
  const BOLD = '\x1b[1m';
@@ -79,10 +102,12 @@ const OBJECTIVE_WIDTH = 48;
79
102
  * The board as an ANSI terminal splash — the launcher's human-facing render. No markdown:
80
103
  * bold ids, aligned columns, dim detail. An empty board is just the state line.
81
104
  */
82
- export function renderSplash({ message, sections, workspace }) {
105
+ export function renderSplash({ message, sections, workspace, breaches = [] }) {
83
106
  const { mine, open, asserted, held } = sections;
84
- const all = [...mine, ...open, ...asserted, ...held];
85
- const out = ['', ` ${message} ${DIM}${workspace}${RESET}`, ''];
107
+ const all = [...mine, ...open, ...asserted, ...held, ...breaches];
108
+ const scope = `${DIM}${workspace ?? MACHINE_SCOPE_LABEL}${RESET}`;
109
+ // R-QUIET: a silent message leaves just the scope line — the board below speaks for itself.
110
+ const out = ['', message ? ` ${message} ${scope}` : ` ${scope}`, ''];
86
111
  if (all.length === 0) return `${out.join('\n')}\n`;
87
112
 
88
113
  const idWidth = Math.max(...all.map((r) => r.task_id.length));
@@ -102,5 +127,6 @@ export function renderSplash({ message, sections, workspace }) {
102
127
  section('OPEN', open, (r) => (r.state === 'reopened' ? 'back — incomplete, actionable' : (r.state ?? 'unclaimed')));
103
128
  section('ASSERTED', asserted, () => 'awaiting verdict');
104
129
  section('HELD', held, (r) => r.principal_id);
130
+ section(`BREACHED PROMISES (${MACHINE_SCOPE_LABEL})`, breaches, (b) => `${b.detail} · ${b.home}`);
105
131
  return `${out.join('\n')}\n`;
106
132
  }