@oathe/oathe 0.2.2 → 0.3.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/NOTICE +3 -4
- package/README.md +14 -45
- package/assets/oathe-hero.svg +92 -0
- package/bin/oathe.mjs +397 -59
- package/docs/PRIVACY.md +13 -5
- package/notch/Oathe Notch.app/Contents/Info.plist +13 -0
- package/notch/Oathe Notch.app/Contents/MacOS/OatheNotch +0 -0
- package/notch/Oathe Notch.app/Contents/_CodeSignature/CodeResources +115 -0
- package/notch/README.md +88 -0
- package/package.json +13 -4
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/.cursor-plugin/plugin.json +36 -0
- package/plugin/.mcp.json +1 -4
- package/plugin/commands/verify.md +18 -0
- package/plugin/hooks/frame-note.mjs +5 -3
- package/plugin/hooks/heartbeat.mjs +21 -25
- package/plugin/hooks/lib.mjs +96 -33
- package/plugin/hooks/render-board.mjs +47 -7
- package/src/activation.mjs +126 -0
- package/src/atif.mjs +4 -13
- package/src/blocks.mjs +113 -8
- package/src/board-render.mjs +55 -29
- package/src/config.mjs +100 -15
- package/src/context.mjs +4 -8
- package/src/doctor.mjs +96 -15
- package/src/fence.mjs +85 -0
- package/src/fslock.mjs +51 -0
- package/src/harnesses/catalog.mjs +180 -0
- package/src/harnesses/claude.mjs +196 -0
- package/src/harnesses/codex.mjs +188 -0
- package/src/harnesses/cursor.mjs +234 -0
- package/src/harnesses/dialects.mjs +52 -0
- package/src/harnesses/harness.mjs +203 -0
- package/src/harnesses/surfaces.mjs +71 -0
- package/src/home.mjs +107 -0
- package/src/init.mjs +101 -21
- package/src/launch-env.mjs +1 -51
- package/src/launch.mjs +37 -106
- package/src/manifest.mjs +7 -3
- package/src/mcp/connection.mjs +218 -0
- package/src/mcp/oathe-tools.mjs +380 -140
- package/src/notch.mjs +154 -0
- package/src/pager.mjs +178 -0
- package/src/paths.mjs +13 -1
- package/src/plans.mjs +10 -2
- package/src/registry.mjs +110 -0
- package/src/runtime/discharge.mjs +1 -1
- package/src/runtime/provider.mjs +10 -6
- package/src/runtime/simple-cage.mjs +32 -12
- package/src/runtime/sql-acceptance-lane.mjs +1 -1
- package/src/session-host.mjs +8 -6
- package/src/sessions.mjs +168 -0
- package/src/setup.mjs +494 -0
- package/src/speaker.mjs +65 -0
- package/src/statements.mjs +113 -0
- package/src/substrate.mjs +44 -0
- package/src/successor.mjs +3 -2
- package/src/traces.mjs +8 -8
- package/src/uninstall.mjs +10 -2
- package/src/verifier.mjs +135 -47
- package/src/verify-dispatch.mjs +169 -0
- package/src/welcome.mjs +32 -0
- package/src/wire.mjs +64 -0
- package/src/workspace-resolver.mjs +178 -0
- package/src/workspace.mjs +16 -5
- package/vendor/ddl/001_core.sql +1 -1
- package/vendor/ddl/004_delegation.sql +1 -1
- package/vendor/ddl/006_dependency.sql +1 -1
- package/vendor/ddl/008_effect_receipt.sql +1 -1
- package/vendor/ddl/009_verified_edge.sql +1 -1
- package/vendor/ddl/011_confirm.sql +2 -2
- package/vendor/ddl/manifest.json +8 -8
- package/assets/claude-splash.png +0 -0
- package/assets/resume-splash.png +0 -0
- package/src/harness.mjs +0 -271
|
@@ -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
|
|
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
|
-
|
|
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 (
|
|
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
|
|
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
|
-
|
|
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
|
|
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
|
+
}
|
package/src/board-render.mjs
CHANGED
|
@@ -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
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
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
|
|
16
|
-
*
|
|
17
|
-
*
|
|
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
|
|
21
|
-
const
|
|
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
|
-
|
|
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(
|
|
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
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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(
|
|
64
|
-
if (
|
|
65
|
-
if (
|
|
66
|
-
message =
|
|
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
|
|
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
|
}
|
package/src/config.mjs
CHANGED
|
@@ -7,6 +7,8 @@ import fs from 'node:fs';
|
|
|
7
7
|
import os from 'node:os';
|
|
8
8
|
import path from 'node:path';
|
|
9
9
|
|
|
10
|
+
import { launchable, verifierCapable } from './harnesses/catalog.mjs';
|
|
11
|
+
|
|
10
12
|
export class ConfigError extends Error {
|
|
11
13
|
constructor(code, message, details = {}) {
|
|
12
14
|
super(message);
|
|
@@ -16,7 +18,7 @@ export class ConfigError extends Error {
|
|
|
16
18
|
}
|
|
17
19
|
}
|
|
18
20
|
|
|
19
|
-
const ENGINES =
|
|
21
|
+
const ENGINES = verifierCapable();
|
|
20
22
|
|
|
21
23
|
/** Every key: default, env var, validator. Adding a tunable means adding a row HERE. */
|
|
22
24
|
const KEYS = Object.freeze({
|
|
@@ -35,13 +37,31 @@ const KEYS = Object.freeze({
|
|
|
35
37
|
pgPort: { default: 5432, env: 'OATHE_PG_PORT', check: positiveInt },
|
|
36
38
|
leaseHours: { default: 4, env: 'OATHE_LEASE_HOURS', check: positiveInt },
|
|
37
39
|
verifyByHours: { default: 24, env: 'OATHE_VERIFY_BY_HOURS', check: positiveInt },
|
|
38
|
-
verifier: { default:
|
|
40
|
+
verifier: { default: ENGINES[0], env: 'OATHE_VERIFIER', check: oneOf(ENGINES) },
|
|
41
|
+
// Who picks your work back up (the notch's continue, resumption spawning): chosen at
|
|
42
|
+
// onboarding — the init question ABOVE the verifier question (founder ruling 2026-08-30).
|
|
43
|
+
defaultAgent: { default: null, env: 'OATHE_DEFAULT_AGENT', check: nullOrOneOf(launchable()) },
|
|
39
44
|
verifierPrincipal: { default: 'oathe-verifier', env: 'OATHE_VERIFIER_PRINCIPAL', check: nonEmptyString },
|
|
40
45
|
verifierEvidenceBudget: { default: 24000, env: 'OATHE_VERIFIER_EVIDENCE_BUDGET', check: positiveInt },
|
|
41
46
|
runtimeProvider: { default: 'auto', env: 'OATHE_RUNTIME_PROVIDER', check: oneOf(['auto', 'oathe', 'standalone']) },
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
},
|
|
47
|
+
// Activation (registry row + context-file fences) on first use in a workspace: the off
|
|
48
|
+
// switch for machines that want register-only sessions.
|
|
49
|
+
autoActivate: { default: true, env: 'OATHE_AUTO_ACTIVATE', check: boolean },
|
|
50
|
+
// How long the MCP server waits on a client's roots/list answer before falling down the
|
|
51
|
+
// resolution ladder.
|
|
52
|
+
rootsTimeoutMs: { default: 2000, env: 'OATHE_ROOTS_TIMEOUT_MS', check: positiveInt },
|
|
53
|
+
// R-PAGER: an active claim with no non-trace progress statement inside this many hours is
|
|
54
|
+
// a breached promise (paged at session start). Lifecycle facts like a lapsed lease are not.
|
|
55
|
+
pagerQuietHours: { default: 24, env: 'OATHE_PAGER_QUIET_HOURS', check: positiveInt },
|
|
56
|
+
// The notch app: the machine opts in by naming its binary — init then owns the
|
|
57
|
+
// LaunchAgent (src/notch.mjs). D1 packaging will default this to a bundled binary.
|
|
58
|
+
notchApp: { default: null, env: 'OATHE_NOTCH_APP', check: nullOrString },
|
|
59
|
+
// What "in motion" means on the glass: a claim whose last word (statement, or the claim
|
|
60
|
+
// itself) is younger than this earns a row; idle-held work stays in `oathe ls`.
|
|
61
|
+
notchMotionMinutes: { default: 60, env: 'OATHE_NOTCH_MOTION_MINUTES', check: positiveInt },
|
|
62
|
+
// The notch feed's drift guard: `oathe notch --serve` recomputes a frame this often even
|
|
63
|
+
// when no wire event arrives (the push path is pg_notify; this is the belt to its braces).
|
|
64
|
+
notchHeartbeatSeconds: { default: 300, env: 'OATHE_NOTCH_HEARTBEAT_SECONDS', check: positiveInt },
|
|
45
65
|
});
|
|
46
66
|
|
|
47
67
|
function nonEmptyString(v) {
|
|
@@ -53,15 +73,31 @@ function nullOrString(v) {
|
|
|
53
73
|
function positiveInt(v) {
|
|
54
74
|
return Number.isInteger(v) && v > 0;
|
|
55
75
|
}
|
|
76
|
+
function boolean(v) {
|
|
77
|
+
return v === true || v === false;
|
|
78
|
+
}
|
|
79
|
+
boolean.expected = 'true|false';
|
|
80
|
+
|
|
81
|
+
/** Env strings for boolean keys: 'true'/'1' and 'false'/'0'; anything else stays a string and refuses. */
|
|
82
|
+
function coerceEnv(spec, raw) {
|
|
83
|
+
if (typeof spec.default === 'number') return Number(raw);
|
|
84
|
+
if (typeof spec.default === 'boolean') {
|
|
85
|
+
if (raw === 'true' || raw === '1') return true;
|
|
86
|
+
if (raw === 'false' || raw === '0') return false;
|
|
87
|
+
return raw;
|
|
88
|
+
}
|
|
89
|
+
return raw;
|
|
90
|
+
}
|
|
56
91
|
function oneOf(allowed) {
|
|
57
92
|
const check = (v) => allowed.includes(v);
|
|
58
93
|
check.expected = allowed.join('|');
|
|
59
94
|
return check;
|
|
60
95
|
}
|
|
61
|
-
function
|
|
62
|
-
|
|
96
|
+
function nullOrOneOf(allowed) {
|
|
97
|
+
const check = (v) => v === null || allowed.includes(v);
|
|
98
|
+
check.expected = `null|${allowed.join('|')}`;
|
|
99
|
+
return check;
|
|
63
100
|
}
|
|
64
|
-
|
|
65
101
|
/** Walk up from `dir` to the workspace root (the dir holding .git), else `dir` itself. */
|
|
66
102
|
function workspaceRoot(dir) {
|
|
67
103
|
let current = dir;
|
|
@@ -74,25 +110,32 @@ function workspaceRoot(dir) {
|
|
|
74
110
|
}
|
|
75
111
|
|
|
76
112
|
export const CONFIG_KEYS = Object.freeze(Object.keys(KEYS));
|
|
77
|
-
export const VERIFIER_ENGINES = Object.freeze([...ENGINES]);
|
|
78
113
|
|
|
79
114
|
export class OatheConfig {
|
|
80
|
-
/** @param {{env?: NodeJS.ProcessEnv, cwd?: string}} o */
|
|
115
|
+
/** @param {{env?: NodeJS.ProcessEnv, cwd?: string|null}} o cwd:null = global-only (no workspace layer) */
|
|
81
116
|
constructor({ env = process.env, cwd = process.cwd() } = {}) {
|
|
117
|
+
// A cwd that does not exist would walk to / and pick a silently-wrong config root — the
|
|
118
|
+
// exact shape of an unexpanded ${...} template reaching us. Refuse at construction.
|
|
119
|
+
if (cwd !== null && !fs.existsSync(cwd)) {
|
|
120
|
+
throw new ConfigError('OATHE_CONFIG_CWD_INVALID',
|
|
121
|
+
`config cwd '${cwd}' is not an existing directory — refusing to guess a workspace root`, { cwd });
|
|
122
|
+
}
|
|
82
123
|
this.env = env;
|
|
83
|
-
|
|
84
|
-
this.
|
|
124
|
+
const files = OatheConfig.filesFor({ env, cwd });
|
|
125
|
+
this.globalPath = files[0];
|
|
126
|
+
this.workspacePath = files[1] ?? null;
|
|
85
127
|
this.values = { ...Object.fromEntries(Object.entries(KEYS).map(([k, spec]) => [k, spec.default])) };
|
|
86
128
|
this.sources = Object.fromEntries(Object.keys(KEYS).map((k) => [k, 'default']));
|
|
87
|
-
|
|
129
|
+
const layers = [[this.globalPath, 'global']];
|
|
130
|
+
if (this.workspacePath !== null) layers.push([this.workspacePath, 'workspace']);
|
|
131
|
+
for (const [file, layer] of layers) {
|
|
88
132
|
const loaded = this.#loadFile(file);
|
|
89
133
|
Object.assign(this.values, loaded);
|
|
90
134
|
for (const key of Object.keys(loaded)) this.sources[key] = layer;
|
|
91
135
|
}
|
|
92
136
|
for (const [key, spec] of Object.entries(KEYS)) {
|
|
93
137
|
if (spec.env && env[spec.env] !== undefined) {
|
|
94
|
-
const
|
|
95
|
-
const value = typeof spec.default === 'number' ? Number(raw) : raw;
|
|
138
|
+
const value = coerceEnv(spec, env[spec.env]);
|
|
96
139
|
this.#checkValue(key, value, `env ${spec.env}`);
|
|
97
140
|
this.values[key] = value;
|
|
98
141
|
this.sources[key] = 'env';
|
|
@@ -100,6 +143,44 @@ export class OatheConfig {
|
|
|
100
143
|
}
|
|
101
144
|
}
|
|
102
145
|
|
|
146
|
+
/** Defaults → global file → env, with NO workspace layer — the pre-resolution bootstrap. */
|
|
147
|
+
static global({ env = process.env } = {}) {
|
|
148
|
+
return new OatheConfig({ env, cwd: null });
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Coerce a CLI word into `key`'s own value shape — booleans take true/false, numbers
|
|
153
|
+
* take digits, nullable keys take the word null. The one coercion (shared with the env
|
|
154
|
+
* layer's rules); set() still validates, so a wrong word stays a typed refusal. The
|
|
155
|
+
* digits-only rule this replaces made the documented `oathe config autoActivate false`
|
|
156
|
+
* refuse — a config surface that cannot speak its own keys' types.
|
|
157
|
+
*/
|
|
158
|
+
static coerce(key, raw) {
|
|
159
|
+
const spec = KEYS[key];
|
|
160
|
+
if (!spec) {
|
|
161
|
+
throw new ConfigError('OATHE_CONFIG_KEY_UNKNOWN',
|
|
162
|
+
`unknown config key '${key}' — known keys: ${CONFIG_KEYS.join(', ')}`, { key });
|
|
163
|
+
}
|
|
164
|
+
if (raw === 'null' && spec.check(null)) return null;
|
|
165
|
+
if (typeof spec.default === 'boolean' || spec.check === boolean) {
|
|
166
|
+
if (raw === 'true' || raw === '1') return true;
|
|
167
|
+
if (raw === 'false' || raw === '0') return false;
|
|
168
|
+
return raw;
|
|
169
|
+
}
|
|
170
|
+
return /^\d+$/.test(raw) ? Number(raw) : raw;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* The config LAYER FILES for an (env, cwd) — the one path logic, shared by the
|
|
175
|
+
* constructor and by staleness watchers (the MCP connection stamps these files' clocks
|
|
176
|
+
* so a long-lived server follows `oathe config`, never its startup snapshot).
|
|
177
|
+
* @returns {string[]} [globalPath] or [globalPath, workspacePath]
|
|
178
|
+
*/
|
|
179
|
+
static filesFor({ env = process.env, cwd = null } = {}) {
|
|
180
|
+
const globalPath = path.join(env.OATHE_HOME || path.join(env.HOME || os.homedir(), '.oathe'), 'config.json');
|
|
181
|
+
return cwd === null ? [globalPath] : [globalPath, path.join(workspaceRoot(cwd), '.oathe.json')];
|
|
182
|
+
}
|
|
183
|
+
|
|
103
184
|
/** Where a key's value came from: 'default' | 'global' | 'workspace' | 'env'. */
|
|
104
185
|
source(key) {
|
|
105
186
|
if (!(key in KEYS)) {
|
|
@@ -158,6 +239,10 @@ export class OatheConfig {
|
|
|
158
239
|
throw new ConfigError('OATHE_CONFIG_SCOPE_UNKNOWN',
|
|
159
240
|
`unknown scope '${scope}' — use 'global' or 'workspace'`, { scope });
|
|
160
241
|
})();
|
|
242
|
+
if (file === null) {
|
|
243
|
+
throw new ConfigError('OATHE_CONFIG_SCOPE_UNKNOWN',
|
|
244
|
+
'this config was built global-only (no workspace) — workspace scope has no file here', { scope });
|
|
245
|
+
}
|
|
161
246
|
const doc = this.#loadFile(file);
|
|
162
247
|
doc[key] = value;
|
|
163
248
|
fs.mkdirSync(path.dirname(file), { recursive: true });
|