@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.
- package/NOTICE +3 -4
- package/README.md +15 -45
- package/assets/oathe-hero.svg +92 -0
- package/bin/oathe.mjs +401 -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 +36 -105
- package/src/manifest.mjs +7 -3
- package/src/mcp/connection.mjs +218 -0
- package/src/mcp/oathe-tools.mjs +380 -141
- package/src/notch.mjs +160 -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 -7
- package/src/runtime/simple-cage.mjs +18 -9
- 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 +1 -1
- 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/handoff-splash.png +0 -0
- package/src/harness.mjs +0 -271
package/bin/oathe.mjs
CHANGED
|
@@ -1,27 +1,32 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// oathe — the subcommand router. Deliberate divergence from the monorepo's env-only bins:
|
|
3
|
-
// oathe is a USER tool, so it speaks argv (node:util parseArgs); it keeps the
|
|
3
|
+
// oathe is a USER tool, so it speaks argv (node:util parseArgs); it keeps the runtime's
|
|
4
4
|
// machine-parseable summary line (`oathe: <verb> <status>`) as the last line of every run.
|
|
5
5
|
|
|
6
6
|
import { parseArgs } from 'node:util';
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
import { isTraceSubjectSql } from '../src/statements.mjs';
|
|
9
|
+
import { byName, launchable, projectorFor, verifierCapable } from '../src/harnesses/catalog.mjs';
|
|
10
|
+
|
|
11
|
+
const VERBS = ['init', ...launchable(), 'claim', 'ls', 'note', 'amend', 'done', 'verify', 'trace', 'notch', 'yield', 'config', 'doctor', 'uninstall', 'status', 'version', 'hook', 'mcp'];
|
|
9
12
|
|
|
10
13
|
const USAGE = `usage: oathe <verb> [args]
|
|
11
14
|
|
|
12
15
|
verbs:
|
|
13
|
-
init
|
|
14
|
-
|
|
15
|
-
codex [--hermetic] [args…] launch interactive Codex inside the cage, board attached
|
|
16
|
+
init [--harness a,b] [--yes] bring up the local cell substrate + wire the harnesses you pick
|
|
17
|
+
${launchable().map((name) => ` ${name.padEnd(6)} [--hermetic] [args…] launch interactive ${byName(name).displayName} inside the cage, board attached`).join('\n')}
|
|
16
18
|
claim <task-id> [objective] claim a task (minting it when new — objective required then)
|
|
17
19
|
ls [--all] this workspace's board (--all: every workspace)
|
|
18
20
|
note <task-id> <text> [ref] record a progress statement against your active claim
|
|
21
|
+
amend <task> "<objective>" "<why>" change what done means, on the record (active claim only)
|
|
19
22
|
done <task-id> <what> [ref] assert completion (a completion statement + the substrate's terminal)
|
|
20
|
-
verify [task] [--all] [--engine
|
|
23
|
+
verify [task] [--all] [--engine ${verifierCapable().join('|')}] run the verification lane (non-author seat settles)
|
|
21
24
|
trace <task-id> [--out dir] export the claim's linked session traces as ATIF trajectories
|
|
25
|
+
notch [--welcome] the whole machine's board + breach digest, pure JSON (only shows); --welcome replays the one-time welcome on the glass
|
|
22
26
|
yield <task-id> <note> yield: the task goes back on the board, unowned
|
|
23
|
-
doctor
|
|
27
|
+
doctor [--surface] verify every managed surface (--surface: the resolution report only)
|
|
24
28
|
status the substrate half of doctor
|
|
29
|
+
version the package version (upgrade: npm i -g @oathe/oathe@latest && oathe init)
|
|
25
30
|
config <key> [value] [--global] read or write a config key (workspace scope by default)
|
|
26
31
|
uninstall [--purge-db] remove exactly what init recorded (the database stays put)
|
|
27
32
|
hook <name> · mcp internal: the plugin's hook/server entry points (bin-addressed)
|
|
@@ -38,60 +43,102 @@ function fail(verb, e) {
|
|
|
38
43
|
process.exit(1);
|
|
39
44
|
}
|
|
40
45
|
|
|
46
|
+
// An unknown flag refuses loudly with the verb's usable flags, derived from the same options
|
|
47
|
+
// the verb parses with — never a raw parse error (fresh-user-trial ruling, 2026-08-29).
|
|
48
|
+
function parseFlags(verb, spec) {
|
|
49
|
+
try {
|
|
50
|
+
return parseArgs(spec);
|
|
51
|
+
} catch (e) {
|
|
52
|
+
if (e?.code !== 'ERR_PARSE_ARGS_UNKNOWN_OPTION') throw e;
|
|
53
|
+
const flags = Object.entries(spec.options ?? {})
|
|
54
|
+
.map(([name, opt]) => `--${name}${opt.type === 'string' ? ' <value>' : ''}`).join(', ');
|
|
55
|
+
const flag = /'(--?[^']*)'/.exec(e.message)?.[1] ?? 'flag';
|
|
56
|
+
const err = new Error(`unknown option '${flag}' refused — ${verb} takes: ${flags || 'no flags'}`);
|
|
57
|
+
err.code = 'OATHE_UNKNOWN_FLAG';
|
|
58
|
+
throw err;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
41
62
|
async function toolsForCwd(env = process.env) {
|
|
42
|
-
const [{ buildContext }, { createOatheTools }, {
|
|
43
|
-
import('../src/context.mjs'), import('../src/mcp/oathe-tools.mjs'), import('../src/workspace.mjs'),
|
|
63
|
+
const [{ buildContext }, { createOatheTools }, { WorkspaceResolver }, { WorkspaceRegistry }, { ActivationSeam }, { homeOf }, { resolveSpeaker }, { verifierSeam }] = await Promise.all([
|
|
64
|
+
import('../src/context.mjs'), import('../src/mcp/oathe-tools.mjs'), import('../src/workspace-resolver.mjs'),
|
|
65
|
+
import('../src/registry.mjs'), import('../src/activation.mjs'), import('../src/paths.mjs'),
|
|
66
|
+
import('../src/speaker.mjs'), import('../src/verify-dispatch.mjs'),
|
|
44
67
|
]);
|
|
45
68
|
const ctx = buildContext({ env });
|
|
69
|
+
// The terminal IS the workspace: its facts (ref, synthetic) come from the one describer, and
|
|
70
|
+
// every verb registers it centrally through the one seam — claim activates (fences included).
|
|
71
|
+
const cwd = process.cwd();
|
|
72
|
+
const place = WorkspaceResolver.describe({ dir: cwd, home: homeOf(env) });
|
|
46
73
|
return {
|
|
47
74
|
ctx,
|
|
48
75
|
tools: createOatheTools({
|
|
49
76
|
client: ctx.substrate,
|
|
50
77
|
identity: ctx.identity,
|
|
51
78
|
config: ctx.config,
|
|
52
|
-
workspace:
|
|
79
|
+
workspace: place.ref,
|
|
80
|
+
synthetic: place.synthetic,
|
|
81
|
+
// A CLI verb run from inside a harness session's shell speaks FOR that session — the
|
|
82
|
+
// ancestry reaches the registered harness pid; a bare terminal resolves to nulls.
|
|
83
|
+
speaker: resolveSpeaker({ sessionsPath: ctx.paths.sessionsPath }),
|
|
84
|
+
// ONE verifier seam, every surface: done's auto-dispatch works from the CLI too.
|
|
85
|
+
verifier: verifierSeam({
|
|
86
|
+
orgId: ctx.identity.orgId,
|
|
87
|
+
query: (sql, params) => ctx.substrate.query(sql, params),
|
|
88
|
+
paths: ctx.paths,
|
|
89
|
+
cwd,
|
|
90
|
+
}),
|
|
91
|
+
activation: new ActivationSeam({
|
|
92
|
+
cwd,
|
|
93
|
+
env,
|
|
94
|
+
registry: new WorkspaceRegistry({ registryPath: ctx.paths.registryPath }),
|
|
95
|
+
manifest: ctx.manifest,
|
|
96
|
+
config: ctx.config,
|
|
97
|
+
version: ctx.version,
|
|
98
|
+
synthetic: place.synthetic,
|
|
99
|
+
sourceFor: (tool) => `cli:${tool.replace(/^oathe_/, '')}`,
|
|
100
|
+
}),
|
|
53
101
|
}),
|
|
54
102
|
};
|
|
55
103
|
}
|
|
56
104
|
|
|
57
105
|
const handlers = {
|
|
58
|
-
async init() {
|
|
106
|
+
async init(argv) {
|
|
107
|
+
const { values } = parseFlags('init', {
|
|
108
|
+
args: argv,
|
|
109
|
+
options: { harness: { type: 'string' }, yes: { type: 'boolean', default: false } },
|
|
110
|
+
allowPositionals: false,
|
|
111
|
+
});
|
|
59
112
|
const { runInit } = await import('../src/init.mjs');
|
|
60
|
-
const result = await runInit({
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
lines.push(` ${B}! yield cause MISSING${R} — run \`oathe doctor\` before claiming work`);
|
|
113
|
+
const result = await runInit({
|
|
114
|
+
harnessFilter: values.harness ? values.harness.split(',').map((s) => s.trim()).filter(Boolean) : null,
|
|
115
|
+
assumeYes: values.yes === true,
|
|
116
|
+
});
|
|
117
|
+
process.stdout.write('oathe init — done\n');
|
|
118
|
+
for (const step of result.steps) {
|
|
119
|
+
// Paths were disclosed on the screen before Enter; `oathe doctor` is the audit (ruling 2026-08-29).
|
|
120
|
+
const detail = step.outcome === 'wired' ? 'wired'
|
|
121
|
+
: step.outcome === 'unwired' ? 'unwired'
|
|
122
|
+
: `skipped — ${step.reason}`;
|
|
123
|
+
process.stdout.write(` ${step.displayName.padEnd(13)} ${detail}\n`);
|
|
72
124
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
125
|
+
process.stdout.write(` verifier ${result.verifier_engine.chosen}\n`);
|
|
126
|
+
const s = result.substrate;
|
|
127
|
+
process.stdout.write(` substrate: db up, ddl ${s.ddl_applied}/${s.ddl_expected} applied `
|
|
128
|
+
+ `(source: ${s.ddl_source}), yield cause ${s.yield_cause_registered ? 'registered' : 'MISSING'}\n`);
|
|
129
|
+
process.stdout.write(` principal: ${result.principal.principal_id} (${result.principal.role})\n`);
|
|
130
|
+
// The surface note lives here, once: the screen showed only the row.
|
|
131
|
+
for (const surface of result.surfaces.filter((x) => x.detected)) {
|
|
132
|
+
process.stdout.write(`\n${surface.displayName} — detected; nothing to wire:\n${surface.steps.split('\n').map((l) => ` ${l}`).join('\n')}\n`);
|
|
78
133
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
process.stdout.write(`${lines.join('\n')}\n`);
|
|
134
|
+
// The moment after init (live polish #7): what to do next, coloured only on a TTY.
|
|
135
|
+
const tty = process.stdout.isTTY === true;
|
|
136
|
+
const [B, D, R] = tty ? ['\x1b[1m', '\x1b[2m', '\x1b[0m'] : ['', '', ''];
|
|
137
|
+
const [first, ...rest] = launchable();
|
|
138
|
+
process.stdout.write(`\n Next: ${B}oathe ${first}${R} ${D}(or ${rest.join(', ')})${R} in any project — the board rides every session.\n`);
|
|
85
139
|
summary('init', 'ok');
|
|
86
140
|
},
|
|
87
141
|
|
|
88
|
-
async claude(argv) {
|
|
89
|
-
return launchHarness('claude', argv);
|
|
90
|
-
},
|
|
91
|
-
|
|
92
|
-
async codex(argv) {
|
|
93
|
-
return launchHarness('codex', argv);
|
|
94
|
-
},
|
|
95
142
|
|
|
96
143
|
async hook(argv) {
|
|
97
144
|
const scripts = {
|
|
@@ -123,7 +170,7 @@ const handlers = {
|
|
|
123
170
|
},
|
|
124
171
|
|
|
125
172
|
async ls(argv) {
|
|
126
|
-
const { values } =
|
|
173
|
+
const { values } = parseFlags('ls', {
|
|
127
174
|
args: argv, options: { all: { type: 'boolean', default: false } }, allowPositionals: true,
|
|
128
175
|
});
|
|
129
176
|
const { ctx, tools } = await toolsForCwd();
|
|
@@ -142,6 +189,19 @@ const handlers = {
|
|
|
142
189
|
}
|
|
143
190
|
},
|
|
144
191
|
|
|
192
|
+
async amend(argv) {
|
|
193
|
+
const [taskId, objective, why] = argv;
|
|
194
|
+
if (!taskId || !objective || !why) throw new Error('usage: oathe amend <task-id> "<new objective>" "<why>"');
|
|
195
|
+
const { ctx, tools } = await toolsForCwd();
|
|
196
|
+
try {
|
|
197
|
+
const out = await tools.oathe_amend({ task_id: taskId, objective, why });
|
|
198
|
+
process.stdout.write(`amended to v${out.version} — ${out.note}\n`);
|
|
199
|
+
summary('amend', 'ok');
|
|
200
|
+
} finally {
|
|
201
|
+
await ctx.substrate.close();
|
|
202
|
+
}
|
|
203
|
+
},
|
|
204
|
+
|
|
145
205
|
async note(argv) {
|
|
146
206
|
const [taskId, proposition, evidenceRef] = argv;
|
|
147
207
|
if (!taskId || !proposition) throw new Error('usage: oathe note <task-id> <text> [evidence-ref]');
|
|
@@ -162,22 +222,48 @@ const handlers = {
|
|
|
162
222
|
try {
|
|
163
223
|
const out = await tools.oathe_done({ task_id: taskId, proposition, evidence_ref: evidenceRef });
|
|
164
224
|
process.stdout.write(`done: ${out.task_id} — ${out.note}\n`);
|
|
165
|
-
|
|
225
|
+
// The blocked verdict, for the human (ruling 2026-08-31: locally, done owes its answer).
|
|
226
|
+
const v = out.verification;
|
|
227
|
+
if (v?.verdict) {
|
|
228
|
+
process.stdout.write(`verdict: ${v.verdict} — ${v.reason}\n`);
|
|
229
|
+
if (v.your_options) process.stdout.write(`next: ${v.your_options}\n`);
|
|
230
|
+
} else if (v?.failed) {
|
|
231
|
+
process.stdout.write(`verification failed: ${v.reason}\n`);
|
|
232
|
+
}
|
|
233
|
+
summary('done', v?.verdict === 'rejected' || v?.failed ? 'attention' : 'ok');
|
|
166
234
|
} finally {
|
|
167
235
|
await ctx.substrate.close();
|
|
168
236
|
}
|
|
169
237
|
},
|
|
170
238
|
|
|
171
239
|
async verify(argv) {
|
|
172
|
-
const { values, positionals } =
|
|
240
|
+
const { values, positionals } = parseFlags('verify', {
|
|
173
241
|
args: argv,
|
|
174
|
-
options: { all: { type: 'boolean', default: false }, engine: { type: 'string' } },
|
|
242
|
+
options: { all: { type: 'boolean', default: false }, engine: { type: 'string' }, detach: { type: 'boolean', default: false } },
|
|
175
243
|
allowPositionals: true,
|
|
176
244
|
});
|
|
177
245
|
const [{ buildContext }, { Verifier }, { workspaceRef }] = await Promise.all([
|
|
178
246
|
import('../src/context.mjs'), import('../src/verifier.mjs'), import('../src/workspace.mjs'),
|
|
179
247
|
]);
|
|
180
248
|
const ctx = buildContext({});
|
|
249
|
+
// --detach: the judgment survives its terminal — one dispatcher, same as MCP and the
|
|
250
|
+
// glass; closing the window can never orphan a verify claim again.
|
|
251
|
+
if (values.detach === true) {
|
|
252
|
+
if (!positionals[0]) throw new Error('usage: oathe verify --detach <task-id>');
|
|
253
|
+
const { dispatchVerification } = await import('../src/verify-dispatch.mjs');
|
|
254
|
+
try {
|
|
255
|
+
const out = await dispatchVerification({
|
|
256
|
+
taskId: positionals[0], engine: values.engine ?? null, orgId: ctx.identity.orgId,
|
|
257
|
+
query: (sql, params) => ctx.substrate.query(sql, params),
|
|
258
|
+
paths: ctx.paths, cwd: process.cwd(), env: process.env,
|
|
259
|
+
});
|
|
260
|
+
process.stdout.write(`dispatched — the verdict lands on the glass. Log: ${out.log}\n`);
|
|
261
|
+
summary('verify', 'ok');
|
|
262
|
+
} finally {
|
|
263
|
+
await ctx.substrate.close();
|
|
264
|
+
}
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
181
267
|
const verifier = new Verifier({
|
|
182
268
|
substrate: ctx.substrate, paths: ctx.paths, config: ctx.config,
|
|
183
269
|
workspace: workspaceRef(process.cwd()),
|
|
@@ -201,13 +287,13 @@ const handlers = {
|
|
|
201
287
|
},
|
|
202
288
|
|
|
203
289
|
async trace(argv) {
|
|
204
|
-
const { values, positionals } =
|
|
290
|
+
const { values, positionals } = parseFlags('trace', {
|
|
205
291
|
args: argv, options: { out: { type: 'string' } }, allowPositionals: true,
|
|
206
292
|
});
|
|
207
293
|
const [taskId] = positionals;
|
|
208
294
|
if (!taskId) throw new Error('usage: oathe trace <task-id> [--out <dir>]');
|
|
209
|
-
const [{ buildContext }, {
|
|
210
|
-
import('../src/context.mjs'), import('../src/
|
|
295
|
+
const [{ buildContext }, { workspaceRef }, fs, path] = await Promise.all([
|
|
296
|
+
import('../src/context.mjs'), import('../src/workspace.mjs'),
|
|
211
297
|
import('node:fs'), import('node:path'),
|
|
212
298
|
]);
|
|
213
299
|
const ctx = buildContext({});
|
|
@@ -220,7 +306,7 @@ const handlers = {
|
|
|
220
306
|
const claim = claims[0];
|
|
221
307
|
const { rows: traceRows } = await ctx.substrate.query(
|
|
222
308
|
`SELECT evidence_refs FROM cell.agent_statement
|
|
223
|
-
WHERE org_id = $1 AND work_claim_id = $2 AND subject_ref
|
|
309
|
+
WHERE org_id = $1 AND work_claim_id = $2 AND ${isTraceSubjectSql('subject_ref')}`,
|
|
224
310
|
[ctx.identity.orgId, claim.work_claim_id]);
|
|
225
311
|
const { rows: verdicts } = await ctx.substrate.query(
|
|
226
312
|
`SELECT result, verifier_principal, verification_id FROM cell.verification
|
|
@@ -228,8 +314,9 @@ const handlers = {
|
|
|
228
314
|
[ctx.identity.orgId, taskId]);
|
|
229
315
|
const files = traceRows.flatMap((r) => r.evidence_refs);
|
|
230
316
|
if (files.length === 0) throw new Error(`'${taskId}' has no linked traces — nothing to export`);
|
|
231
|
-
const trajectories =
|
|
232
|
-
|
|
317
|
+
const trajectories = [];
|
|
318
|
+
for (const file of files) {
|
|
319
|
+
const trajectory = (await projectorFor(file)).project(file);
|
|
233
320
|
Object.assign(trajectory.extra.oathe, {
|
|
234
321
|
org_id: ctx.identity.orgId,
|
|
235
322
|
task_id: taskId,
|
|
@@ -238,8 +325,8 @@ const handlers = {
|
|
|
238
325
|
workspace: workspaceRef(process.cwd()),
|
|
239
326
|
...(verdicts[0] ? { verdict: verdicts[0] } : {}),
|
|
240
327
|
});
|
|
241
|
-
|
|
242
|
-
}
|
|
328
|
+
trajectories.push(trajectory);
|
|
329
|
+
}
|
|
243
330
|
if (values.out) {
|
|
244
331
|
fs.mkdirSync(values.out, { recursive: true });
|
|
245
332
|
for (const [at, trajectory] of trajectories.entries()) {
|
|
@@ -257,6 +344,225 @@ const handlers = {
|
|
|
257
344
|
}
|
|
258
345
|
},
|
|
259
346
|
|
|
347
|
+
// The notch feed: machine board + breach digest, pure JSON on stdout (trailer on stderr,
|
|
348
|
+
// the trace precedent). Workspace-less by construction — buildContext({cwd: null}) is the
|
|
349
|
+
// global bootstrap — and seamless: no activation, no registry write; it only SHOWS
|
|
350
|
+
// (R-PAGER kinship: resurfacing is fact-paged; this verb is the facts, not a dashboard).
|
|
351
|
+
// One flag: --serve LISTENs on the wire and streams one ndjson frame per speech act
|
|
352
|
+
// (receipts ride the frame that caused them), plus a heartbeat frame as drift guard;
|
|
353
|
+
// it exits when the supervisor (the notch app) closes stdin.
|
|
354
|
+
async notch(argv) {
|
|
355
|
+
const { values } = parseFlags('notch', {
|
|
356
|
+
args: argv, options: { serve: { type: 'boolean', default: false }, welcome: { type: 'boolean', default: false } }, allowPositionals: false,
|
|
357
|
+
});
|
|
358
|
+
if (values.welcome && values.serve) {
|
|
359
|
+
const err = new Error('--welcome with --serve refused — the feed consumes the welcome; the flag plants it for a live feed to play');
|
|
360
|
+
err.code = 'OATHE_NOTCH_WELCOME_SERVE';
|
|
361
|
+
throw err;
|
|
362
|
+
}
|
|
363
|
+
const [{ buildContext }, { renderBoard }, { Pager }, { WorkspaceRegistry }, { WIRE_CHANNEL, noticeFor, emit }, { plantWelcome, consumeWelcome }] = await Promise.all([
|
|
364
|
+
import('../src/context.mjs'), import('../src/board-render.mjs'),
|
|
365
|
+
import('../src/pager.mjs'), import('../src/registry.mjs'), import('../src/wire.mjs'),
|
|
366
|
+
import('../src/welcome.mjs'),
|
|
367
|
+
]);
|
|
368
|
+
const ctx = buildContext({ cwd: null });
|
|
369
|
+
if (values.welcome) {
|
|
370
|
+
// The demo/replay lever: plant the one-shot marker, nudge the wire. Same path as the
|
|
371
|
+
// real first run — a live feed consumes it on its very next frame; with no feed up,
|
|
372
|
+
// the marker waits for the next serve start. emit is fail-soft by the wire's ruling.
|
|
373
|
+
plantWelcome({ paths: ctx.paths, by: 'cli' });
|
|
374
|
+
try {
|
|
375
|
+
await emit(ctx.substrate, { kind: 'welcome' });
|
|
376
|
+
} finally {
|
|
377
|
+
await ctx.substrate.close().catch(() => {});
|
|
378
|
+
}
|
|
379
|
+
process.stdout.write('welcome queued — a live glass plays it now; otherwise on its next start\n');
|
|
380
|
+
process.stderr.write('oathe: notch ok\n');
|
|
381
|
+
return;
|
|
382
|
+
}
|
|
383
|
+
const registry = new WorkspaceRegistry({ registryPath: ctx.paths.registryPath });
|
|
384
|
+
// MOTION (founder ruling, 2026-08-30): a row on the glass means a LIVE session — a claim
|
|
385
|
+
// whose last word is younger than notchMotionMinutes, or one the wire just heard (serve
|
|
386
|
+
// mode overlays `heard`, ephemeral by design). Idle-held work is `oathe ls`'s business.
|
|
387
|
+
const { ownerOfTracePath, surfaceForSession, launchable: launchableNames } = await import('../src/harnesses/catalog.mjs');
|
|
388
|
+
const { SessionRegistry, pidAlive } = await import('../src/sessions.mjs');
|
|
389
|
+
const sessionsReg = new SessionRegistry({ sessionsPath: ctx.paths.sessionsPath });
|
|
390
|
+
// A broken sessions file costs the frame its session refs, never the frame.
|
|
391
|
+
const loadSessions = () => {
|
|
392
|
+
try { return sessionsReg.load().sessions; } catch (e) {
|
|
393
|
+
process.stderr.write(`oathe notch: sessions ${String(e?.message || e).slice(0, 120)}\n`);
|
|
394
|
+
return {};
|
|
395
|
+
}
|
|
396
|
+
};
|
|
397
|
+
const launchables = launchableNames();
|
|
398
|
+
const defaultAgent = ctx.config.get('defaultAgent');
|
|
399
|
+
const TERMINAL_FALLBACK = '/System/Applications/Utilities/Terminal.app'; // the system terminal — an OS fact
|
|
400
|
+
const shellQuote = (s) => `'${String(s).replaceAll("'", "'\\''")}'`;
|
|
401
|
+
const heard = new Map(); // task → {at, via}: what the wire heard, ephemeral by design
|
|
402
|
+
const motionWindowMs = ctx.config.get('notchMotionMinutes') * 60_000;
|
|
403
|
+
const moving = (r) => (heard.get(r.task_id)?.at ?? 0) > Date.now() - motionWindowMs
|
|
404
|
+
|| (r.last_word_at && Date.parse(r.last_word_at) > Date.now() - motionWindowMs);
|
|
405
|
+
// Continue is a RESUMPTION, never a shrug (founder ruling 2026-08-30): activate the
|
|
406
|
+
// living app; else spawn the agent at the task's home in a terminal; else open the
|
|
407
|
+
// desktop app; else the clipboard is the act. The package decides — the glass executes.
|
|
408
|
+
const resumeFor = (base, ref) => {
|
|
409
|
+
if (ref?.alive && ref.app_pid !== null && ref.app_pid !== undefined) {
|
|
410
|
+
// The bundle rides along: macOS may deny a background app's activate (cooperative
|
|
411
|
+
// activation) — opening the bundle is the permission-free fallback that still switches.
|
|
412
|
+
return { kind: 'activate', app_pid: ref.app_pid, bundle: ref.bundle ?? null };
|
|
413
|
+
}
|
|
414
|
+
const surface = ref?.surface ?? base.surface;
|
|
415
|
+
const agent = launchables.includes(surface) ? surface
|
|
416
|
+
: (launchables.includes(defaultAgent) ? defaultAgent : null);
|
|
417
|
+
if (agent && typeof base.home_path === 'string' && base.home_path.startsWith('/')) {
|
|
418
|
+
return {
|
|
419
|
+
kind: 'spawn-terminal',
|
|
420
|
+
command: `oathe ${agent} ${shellQuote(`continue ${base.task_id}`)}`,
|
|
421
|
+
cwd: base.home_path,
|
|
422
|
+
terminal_bundle: ref?.bundle ?? TERMINAL_FALLBACK,
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
if (ref?.bundle) return { kind: 'open-app', bundle: ref.bundle };
|
|
426
|
+
return { kind: 'copy-only' };
|
|
427
|
+
};
|
|
428
|
+
const glassRow = (r, sess) => {
|
|
429
|
+
const row = (r.trace_session_id && sess[r.trace_session_id]) || null;
|
|
430
|
+
const h = heard.get(r.task_id);
|
|
431
|
+
// The durable registry row outranks the wire's ephemeral word; either way the ref
|
|
432
|
+
// carries surface + the focusable app, so a HOMELESS task heard from a living app
|
|
433
|
+
// (ChatGPT's embedded codex — no hooks, no registry row) still resolves to a switch.
|
|
434
|
+
const ref = row !== null ? {
|
|
435
|
+
surface: surfaceForSession({ ancestry: row.ancestry, app: row.app, transcriptPath: row.transcript_path }),
|
|
436
|
+
app_pid: row.app?.pid ?? null,
|
|
437
|
+
bundle: row.app?.bundle ?? null,
|
|
438
|
+
alive: pidAlive(row.pid),
|
|
439
|
+
} : (h?.app ? {
|
|
440
|
+
surface: h.via ?? null,
|
|
441
|
+
app_pid: h.app.pid ?? null,
|
|
442
|
+
bundle: h.app.bundle ?? null,
|
|
443
|
+
alive: h.app.pid !== null && h.app.pid !== undefined && pidAlive(h.app.pid),
|
|
444
|
+
} : null);
|
|
445
|
+
const base = {
|
|
446
|
+
task_id: r.task_id, holder: r.principal_id, state: r.state,
|
|
447
|
+
last_word_at: r.last_word_at, last_progress: r.last_progress,
|
|
448
|
+
home_path: registry.rootOf(r.home) ?? r.home ?? 'homeless',
|
|
449
|
+
// The surface speaking on the claim: the wire's live word wins; the durable fallback
|
|
450
|
+
// is the latest trace-link statement's transcript, mapped by its owning store.
|
|
451
|
+
surface: heard.get(r.task_id)?.via ?? (r.trace_path ? ownerOfTracePath(r.trace_path) : null),
|
|
452
|
+
};
|
|
453
|
+
return { ...base, session: ref, resume: resumeFor(base, ref) };
|
|
454
|
+
};
|
|
455
|
+
// A breach row carries the ONE act that can change its truth (ruling 2026-08-31):
|
|
456
|
+
// never-judged (overdue) → dispatch the judgment, DETACHED (closing the window can't
|
|
457
|
+
// orphan it); engine-failed (stalled) → retry, same dispatcher; judged-rejected
|
|
458
|
+
// (reopened) and gone-quiet → CONTINUE into the work (the reclaim bundle carries the
|
|
459
|
+
// verdict — re-judging a judged assertion is the one act that can never help).
|
|
460
|
+
// Home is the ONE resolver's answer; a homeless judgment runs from the operator's home.
|
|
461
|
+
const { homeOf } = await import('../src/paths.mjs');
|
|
462
|
+
const glassBreach = (b) => {
|
|
463
|
+
const home = typeof b.home === 'string' && b.home.startsWith('/') ? b.home : null;
|
|
464
|
+
let act = { kind: 'copy-only' };
|
|
465
|
+
if (b.kind === 'overdue' || b.kind === 'stalled') {
|
|
466
|
+
act = { kind: 'spawn-terminal', command: `oathe verify --detach ${shellQuote(b.task_id)}`, cwd: home ?? homeOf(), terminal_bundle: TERMINAL_FALLBACK };
|
|
467
|
+
} else if (home !== null && launchables.includes(defaultAgent)) {
|
|
468
|
+
act = { kind: 'spawn-terminal', command: `oathe ${defaultAgent} ${shellQuote(`continue ${b.task_id}`)}`, cwd: home, terminal_bundle: TERMINAL_FALLBACK };
|
|
469
|
+
}
|
|
470
|
+
return { ...b, act };
|
|
471
|
+
};
|
|
472
|
+
const frame = async () => {
|
|
473
|
+
const breaches = (await new Pager({ client: ctx.substrate, identity: ctx.identity, config: ctx.config, registry }).breaches())
|
|
474
|
+
.map(glassBreach);
|
|
475
|
+
const { message, sections } = await renderBoard({
|
|
476
|
+
client: ctx.substrate, identity: ctx.identity, workspace: null, config: ctx.config, all: true, breaches,
|
|
477
|
+
});
|
|
478
|
+
const sess = loadSessions();
|
|
479
|
+
return {
|
|
480
|
+
push: message,
|
|
481
|
+
breaches,
|
|
482
|
+
// motion = anyone's active claim with a recent word (or heard live on the wire);
|
|
483
|
+
// idle = YOUR held claims gone quiet — the sheet shows them after motion, aged.
|
|
484
|
+
motion: [...sections.mine, ...sections.held].filter(moving).map((r) => glassRow(r, sess)),
|
|
485
|
+
idle: sections.mine.filter((r) => !moving(r)).map((r) => glassRow(r, sess)),
|
|
486
|
+
sections,
|
|
487
|
+
workspace: null,
|
|
488
|
+
// The machine's chosen agent rides every frame — the glass reads no config (the
|
|
489
|
+
// welcome ruling generalized: Node owns the words and the facts; the glass plays
|
|
490
|
+
// them). null when onboarding never chose one; the empty-board invite goes generic.
|
|
491
|
+
default_agent: launchables.includes(defaultAgent) ? defaultAgent : null,
|
|
492
|
+
};
|
|
493
|
+
};
|
|
494
|
+
if (!values.serve) {
|
|
495
|
+
try {
|
|
496
|
+
process.stdout.write(`${JSON.stringify(await frame())}\n`);
|
|
497
|
+
process.stderr.write('oathe: notch ok\n');
|
|
498
|
+
} finally {
|
|
499
|
+
await ctx.substrate.close();
|
|
500
|
+
}
|
|
501
|
+
return;
|
|
502
|
+
}
|
|
503
|
+
const { default: pg } = await import('pg');
|
|
504
|
+
const write = (f) => process.stdout.write(`${JSON.stringify(f)}\n`);
|
|
505
|
+
// The one-shot welcome rides the next frame after a SUCCESSFUL build — consume-on-emit,
|
|
506
|
+
// never on failure, so a broken frame cannot eat the shot (and a KeepAlive restart
|
|
507
|
+
// cannot replay it: the marker is gone the moment it is spoken).
|
|
508
|
+
const serveFrame = async () => {
|
|
509
|
+
const f = await frame();
|
|
510
|
+
const welcome = consumeWelcome({ paths: ctx.paths });
|
|
511
|
+
if (welcome) f.welcome = welcome;
|
|
512
|
+
return f;
|
|
513
|
+
};
|
|
514
|
+
const listener = new pg.Client(ctx.substrate.connectionConfig());
|
|
515
|
+
await listener.connect();
|
|
516
|
+
await listener.query(`LISTEN ${WIRE_CHANNEL}`);
|
|
517
|
+
let beat = null;
|
|
518
|
+
let closing = false;
|
|
519
|
+
// The trailer tells the truth (fail loud): only a clean stdin-close is ok; a lost
|
|
520
|
+
// wire or dead substrate exits nonzero so the supervisor's restart means something.
|
|
521
|
+
const shutdown = async (status = 'ok', code = 0) => {
|
|
522
|
+
if (closing) return;
|
|
523
|
+
closing = true;
|
|
524
|
+
if (beat) clearInterval(beat);
|
|
525
|
+
await listener.end().catch(() => {});
|
|
526
|
+
await ctx.substrate.close().catch(() => {});
|
|
527
|
+
process.stderr.write(`oathe: notch ${status}\n`);
|
|
528
|
+
process.exit(code);
|
|
529
|
+
};
|
|
530
|
+
// A TRANSIENT substrate failure (a Postgres restart, a locked table) must never kill
|
|
531
|
+
// the feed — the error is a typed stderr note and the next event/heartbeat retries.
|
|
532
|
+
// A DEAD CONNECTION is fatal-but-clean: exit nonzero; the app's backoff restart is
|
|
533
|
+
// the recovery. (An unguarded rejection here used to kill the process with no
|
|
534
|
+
// trailer at all — the review's SERVE-CRASH finding.)
|
|
535
|
+
const guarded = (label, fn) => async (...args) => {
|
|
536
|
+
try {
|
|
537
|
+
await fn(...args);
|
|
538
|
+
} catch (e) {
|
|
539
|
+
process.stderr.write(`oathe notch: ${label} failed (${String(e?.message || e).slice(0, 160)}) — serving continues\n`);
|
|
540
|
+
}
|
|
541
|
+
};
|
|
542
|
+
listener.on('notification', guarded('wire frame', async (msg) => {
|
|
543
|
+
let ev = null;
|
|
544
|
+
try { ev = JSON.parse(msg.payload); } catch { /* a foreign payload nudges, it does not speak */ }
|
|
545
|
+
if (ev?.task_id) heard.set(ev.task_id, { at: Date.now(), via: ev.via ?? null, app: ev.app ?? null }); // the wire IS liveness
|
|
546
|
+
const f = await serveFrame();
|
|
547
|
+
// The event's own notice rides the frame it caused — the glass PULSES its tone and
|
|
548
|
+
// keeps the words for the sheet (never expanding the bar; founder ruling 2026-08-31).
|
|
549
|
+
const notice = ev?.task_id ? noticeFor(ev.kind, ev.task_id, ev.via) : null;
|
|
550
|
+
if (notice) f.notice = notice;
|
|
551
|
+
write(f);
|
|
552
|
+
}));
|
|
553
|
+
listener.on('error', (e) => {
|
|
554
|
+
process.stderr.write(`oathe notch: wire lost (${String(e?.message || e).slice(0, 120)})\n`);
|
|
555
|
+
shutdown('error', 1);
|
|
556
|
+
});
|
|
557
|
+
beat = setInterval(guarded('heartbeat frame', async () => write(await serveFrame())), ctx.config.get('notchHeartbeatSeconds') * 1000);
|
|
558
|
+
write(await serveFrame());
|
|
559
|
+
process.stdin.resume();
|
|
560
|
+
process.stdin.on('end', shutdown);
|
|
561
|
+
process.stdin.on('close', shutdown);
|
|
562
|
+
process.on('SIGTERM', shutdown);
|
|
563
|
+
process.on('SIGINT', shutdown);
|
|
564
|
+
},
|
|
565
|
+
|
|
260
566
|
async yield(argv) {
|
|
261
567
|
const [taskId, note] = argv;
|
|
262
568
|
if (!taskId || !note) throw new Error('usage: oathe yield <task-id> <note>');
|
|
@@ -271,26 +577,60 @@ const handlers = {
|
|
|
271
577
|
},
|
|
272
578
|
|
|
273
579
|
async config(argv) {
|
|
274
|
-
const { values, positionals } =
|
|
580
|
+
const { values, positionals } = parseFlags('config', {
|
|
275
581
|
args: argv, options: { global: { type: 'boolean', default: false } }, allowPositionals: true,
|
|
276
582
|
});
|
|
277
583
|
const [key, raw] = positionals;
|
|
278
584
|
if (!key) throw new Error('usage: oathe config <key> [value] [--global]');
|
|
279
|
-
const { OatheConfig
|
|
585
|
+
const { OatheConfig } = await import('../src/config.mjs');
|
|
280
586
|
const cfg = new OatheConfig({});
|
|
281
587
|
if (raw === undefined) {
|
|
282
588
|
process.stdout.write(`${key} = ${JSON.stringify(cfg.get(key)).replaceAll('"', '')}\n`);
|
|
283
589
|
} else {
|
|
284
|
-
|
|
590
|
+
// Each key's OWN coercion (booleans, numbers, null) — set() still validates typed.
|
|
591
|
+
const value = OatheConfig.coerce(key, raw);
|
|
285
592
|
const out = cfg.set(key, value, { scope: values.global ? 'global' : 'workspace' });
|
|
286
593
|
process.stdout.write(`${key} = ${raw} (${out.file})\n`);
|
|
287
594
|
}
|
|
288
595
|
summary('config', 'ok');
|
|
289
596
|
},
|
|
290
597
|
|
|
291
|
-
async
|
|
598
|
+
async version() {
|
|
599
|
+
const [{ buildPaths }, { packageVersion }] = await Promise.all([import('../src/paths.mjs'), import('../src/context.mjs')]);
|
|
600
|
+
process.stdout.write(`${packageVersion(buildPaths(process.env))}\n`);
|
|
601
|
+
summary('version', 'ok');
|
|
602
|
+
},
|
|
603
|
+
|
|
604
|
+
async doctor(argv) {
|
|
605
|
+
const { values } = parseFlags('doctor', {
|
|
606
|
+
args: argv, options: { surface: { type: 'boolean', default: false } }, allowPositionals: false,
|
|
607
|
+
});
|
|
608
|
+
if (values.surface) {
|
|
609
|
+
// The per-surface resolution report: no substrate contact — this must answer on ANY
|
|
610
|
+
// machine, from ANY harness's spawn environment, exactly as the MCP server would see it.
|
|
611
|
+
const { runSurfaceReport } = await import('../src/doctor.mjs');
|
|
612
|
+
const report = await runSurfaceReport({});
|
|
613
|
+
for (const [name, value] of Object.entries(report.env_slice)) {
|
|
614
|
+
process.stdout.write(` env ${name.padEnd(22)} ${value === null ? '(unset)' : value}\n`);
|
|
615
|
+
}
|
|
616
|
+
process.stdout.write(` cwd ${process.cwd()}\n`);
|
|
617
|
+
if (report.resolved) {
|
|
618
|
+
const r = report.resolution;
|
|
619
|
+
process.stdout.write(`workspace: ${r.ref} via ${r.source}\n dir ${r.dir}\n root ${r.root}\n`);
|
|
620
|
+
for (const d of r.diagnostics) process.stdout.write(` note ${d}\n`);
|
|
621
|
+
process.stdout.write(`registry: ${report.registered === null ? 'unreadable'
|
|
622
|
+
: report.registered ? 'registered' : 'not yet registered (first use registers it)'}\n`);
|
|
623
|
+
} else {
|
|
624
|
+
process.stdout.write(`workspace: UNRESOLVED\n${report.refusal}\n`);
|
|
625
|
+
}
|
|
626
|
+
summary('doctor', report.resolved ? 'ok' : 'attention');
|
|
627
|
+
if (!report.resolved) process.exit(1);
|
|
628
|
+
return;
|
|
629
|
+
}
|
|
292
630
|
const { runDoctor } = await import('../src/doctor.mjs');
|
|
293
631
|
const result = await runDoctor({});
|
|
632
|
+
const caches = Object.entries(result.version.plugin).map(([name, v]) => `${name} ${v ?? 'none'}`).join('; ');
|
|
633
|
+
process.stdout.write(`version: ${result.version.package} (plugin cache: ${caches})\n`);
|
|
294
634
|
const s = result.substrate;
|
|
295
635
|
process.stdout.write(`substrate: ${s.reachable ? 'reachable' : 'UNREACHABLE'}, `
|
|
296
636
|
+ `db ${s.database_exists ? 'present' : 'ABSENT'}, ddl ${s.ddl_applied}/${s.ddl_expected}, `
|
|
@@ -336,7 +676,7 @@ const handlers = {
|
|
|
336
676
|
},
|
|
337
677
|
|
|
338
678
|
async uninstall(argv) {
|
|
339
|
-
const { values } =
|
|
679
|
+
const { values } = parseFlags('uninstall', {
|
|
340
680
|
args: argv, options: { 'purge-db': { type: 'boolean', default: false } }, allowPositionals: true,
|
|
341
681
|
});
|
|
342
682
|
const { runUninstall } = await import('../src/uninstall.mjs');
|
|
@@ -383,7 +723,9 @@ if (!verb || !VERBS.includes(verb)) {
|
|
|
383
723
|
process.exit(2);
|
|
384
724
|
}
|
|
385
725
|
try {
|
|
386
|
-
|
|
726
|
+
// Launch verbs come from the catalog (every adapter with a `launch` capability), not a handler each.
|
|
727
|
+
const handler = launchable().includes(verb) ? (argv) => launchHarness(verb, argv) : handlers[verb];
|
|
728
|
+
await handler(rest);
|
|
387
729
|
} catch (e) {
|
|
388
730
|
fail(verb, e);
|
|
389
731
|
}
|
package/docs/PRIVACY.md
CHANGED
|
@@ -12,13 +12,21 @@ Oathe does not crawl arbitrary files. It reads exactly these declared surfaces:
|
|
|
12
12
|
(`plugin/hooks/heartbeat.mjs`), and `oathe verify` / `oathe trace` read the transcript
|
|
13
13
|
files linked to a claim. Codex thread indexes are read through `node:sqlite` where the
|
|
14
14
|
Node version provides it.
|
|
15
|
-
- **Harness configuration it manages**: `~/.claude/settings.json` (two owned keys)
|
|
16
|
-
`~/.codex/config.toml` (via the codex CLI),
|
|
17
|
-
fenced sections.
|
|
18
|
-
- **Its own state**: the install manifest, backups,
|
|
19
|
-
|
|
15
|
+
- **Harness configuration it manages**: `~/.claude/settings.json` (two owned keys),
|
|
16
|
+
`~/.codex/config.toml` (via the codex CLI), and `~/.cursor/mcp.json` + `~/.cursor/hooks.json`
|
|
17
|
+
(owned entries), plus the project's `CLAUDE.md`/`AGENTS.md` fenced sections.
|
|
18
|
+
- **Its own state**: the install manifest, backups, artifact store, and the workspace
|
|
19
|
+
registry (`workspaces.json` — folder path, git identity, when each harness last opened it)
|
|
20
|
+
under `~/.oathe/`, and the workspace config (`.oathe.json`).
|
|
20
21
|
- **Git metadata** of the working directory (root, origin) to derive the workspace identity.
|
|
21
22
|
|
|
23
|
+
One write behavior to know about: **opening a session in a folder activates it** — the
|
|
24
|
+
SessionStart hook (or your first `oathe_claim` there) records the folder in the local
|
|
25
|
+
registry and pins the board's fenced section into that folder's `CLAUDE.md`/`AGENTS.md`,
|
|
26
|
+
disclosing the write in the session banner. `oathe config autoActivate false --global`
|
|
27
|
+
turns the file writes off (registration stays); `oathe uninstall` removes every recorded
|
|
28
|
+
write. Everything stays on your machine.
|
|
29
|
+
|
|
22
30
|
## Stores (locally, in YOUR Postgres)
|
|
23
31
|
|
|
24
32
|
Task ids, objectives, claims, statements, verdicts, and transcript file **paths**.
|