@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/src/init.mjs
CHANGED
|
@@ -1,29 +1,45 @@
|
|
|
1
|
-
// oathe init — census → substrate →
|
|
2
|
-
//
|
|
3
|
-
// is
|
|
1
|
+
// oathe init — census → plan → (substrate reachable?) → ask everything → do everything → summary.
|
|
2
|
+
// The order is the promise: the questions come from the census and each adapter's own
|
|
3
|
+
// description of its writes (src/setup.mjs); nothing is asked of a world whose substrate cannot
|
|
4
|
+
// come up; nothing is written before the last answer; nothing is recorded that was not
|
|
5
|
+
// verified. On a TTY the plan is a conversation; with --yes or off-TTY the plan's defaults are
|
|
6
|
+
// applied and ANNOUNCED — never a silent assumption, never a hang.
|
|
4
7
|
|
|
5
8
|
import { buildContext } from './context.mjs';
|
|
6
|
-
import { census } from './
|
|
9
|
+
import { census, detectOnlySurfaces } from './harnesses/catalog.mjs';
|
|
10
|
+
import { OatheConfig } from './config.mjs';
|
|
7
11
|
import { standardPlan } from './plans.mjs';
|
|
12
|
+
import { OatheInitError, SetupPlan, SetupPrompter } from './setup.mjs';
|
|
8
13
|
|
|
9
|
-
export
|
|
10
|
-
constructor(code, message, details = {}) {
|
|
11
|
-
super(message);
|
|
12
|
-
this.name = 'OatheInitError';
|
|
13
|
-
this.code = code;
|
|
14
|
-
this.details = details;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
14
|
+
export { OatheInitError };
|
|
17
15
|
|
|
18
16
|
/**
|
|
19
|
-
* @returns {Promise<{census: object[],
|
|
17
|
+
* @returns {Promise<{plan: SetupPlan, census: object[], surfaces: object[], substrate: object,
|
|
18
|
+
* principal: object, verifier: object, verifier_engine: object, wired: string[],
|
|
19
|
+
* actions: object[], steps: object[]}>}
|
|
20
20
|
*/
|
|
21
|
-
export async function runInit({
|
|
21
|
+
export async function runInit({
|
|
22
|
+
env = process.env, exec, stdin = process.stdin, out = process.stdout, err = process.stderr,
|
|
23
|
+
harnessFilter = null, assumeYes = false,
|
|
24
|
+
} = {}) {
|
|
22
25
|
const ctx = buildContext({ env, exec });
|
|
23
26
|
const { manifest, harnesses, substrate, identity, version } = ctx;
|
|
24
27
|
try {
|
|
25
|
-
const
|
|
28
|
+
const wired = harnesses.filter((h) => h.constructor.wiring !== null);
|
|
29
|
+
const seen = census(wired); // what an installer can wire
|
|
30
|
+
const surfaces = detectOnlySurfaces({ home: ctx.home });
|
|
31
|
+
// The verifier is a MACHINE-WIDE choice: only the global layer decides whether it was made.
|
|
32
|
+
// A per-folder .oathe.json in the cwd init runs from must not silence the question (it did,
|
|
33
|
+
// 2026-08-29).
|
|
34
|
+
const machine = OatheConfig.global({ env: ctx.config.env });
|
|
35
|
+
// DECLARATIVE: the screen shows the wiring state and Enter makes the machine match it.
|
|
36
|
+
const wiredNow = new Set(manifest.rows.map((r) => r.harness).filter((h) => wired.some((a) => a.name === h)));
|
|
37
|
+
const plan = SetupPlan.from({
|
|
38
|
+
adapters: wired, census: seen, surfaces, machine, home: ctx.home, paths: ctx.paths, fallbackVerifier: ctx.config.get('verifier'), wiredNow,
|
|
39
|
+
});
|
|
40
|
+
if (harnessFilter) plan.narrow(harnessFilter);
|
|
26
41
|
|
|
42
|
+
// The substrate is checked BEFORE any question: nobody answers a setup that cannot come up.
|
|
27
43
|
const detect = await substrate.detect();
|
|
28
44
|
if (!detect.reachable) {
|
|
29
45
|
throw new OatheInitError('OATHE_SUBSTRATE_UNREACHABLE',
|
|
@@ -39,7 +55,27 @@ export async function runInit({ env = process.env, exec } = {}) {
|
|
|
39
55
|
// Same preflight block as detect(): a missing DDL source is caught here too, before any
|
|
40
56
|
// database is created — never a half-onboarded world.
|
|
41
57
|
substrate.assertDdlSource();
|
|
42
|
-
|
|
58
|
+
|
|
59
|
+
// Ask everything…
|
|
60
|
+
if (assumeYes) plan.applyDefaults('assume-yes');
|
|
61
|
+
else if (SetupPrompter.isInteractive({ stdin, out })) await new SetupPrompter({ stdin, out }).ask(plan);
|
|
62
|
+
else plan.applyDefaults('no-tty');
|
|
63
|
+
if (plan.defaultsReason !== null) {
|
|
64
|
+
const label = { 'assume-yes': '--yes', 'no-tty': 'no TTY' }[plan.defaultsReason] ?? plan.defaultsReason;
|
|
65
|
+
const stream = assumeYes ? out : err; // --yes was asked for: stdout; a pipe hears it on stderr
|
|
66
|
+
stream?.write?.(`init: ${label} — applying defaults: ${plan.announceLines().join('; ')}\n`);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// …then do everything.
|
|
70
|
+
const db = await substrate.ensureDatabase();
|
|
71
|
+
// A database made for the FIRST time plants the one-shot welcome — the glass plays it
|
|
72
|
+
// on its next frame. Planted here, not with the actions: a failed later step must not
|
|
73
|
+
// cost the eventual successful init its welcome.
|
|
74
|
+
let welcomePlanted = null;
|
|
75
|
+
if (db.created) {
|
|
76
|
+
const { plantWelcome } = await import('./welcome.mjs');
|
|
77
|
+
welcomePlanted = plantWelcome({ paths: ctx.paths });
|
|
78
|
+
}
|
|
43
79
|
await substrate.applyDdl();
|
|
44
80
|
await substrate.seed({
|
|
45
81
|
orgId: identity.orgId, principalId: identity.principalId, department: identity.department,
|
|
@@ -66,25 +102,69 @@ export async function runInit({ env = process.env, exec } = {}) {
|
|
|
66
102
|
registeredBy: 'oathe-init',
|
|
67
103
|
});
|
|
68
104
|
|
|
105
|
+
const v = plan.verifier;
|
|
106
|
+
// Record when there was no machine-wide choice, or the screen changed it — re-running init IS the switch.
|
|
107
|
+
const record = v.alreadyChosen === null || v.chosen !== v.alreadyChosen.value;
|
|
108
|
+
if (record) ctx.config.set('verifier', v.chosen, { scope: 'global' });
|
|
109
|
+
const a = plan.agent;
|
|
110
|
+
if (a.chosen !== null && (a.alreadyChosen === null || a.chosen !== a.alreadyChosen.value)) {
|
|
111
|
+
ctx.config.set('defaultAgent', a.chosen, { scope: 'global' });
|
|
112
|
+
}
|
|
113
|
+
|
|
69
114
|
const actions = [];
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
115
|
+
if (welcomePlanted) actions.push({ harness: 'notch', action: 'welcome-planted', file: welcomePlanted.file });
|
|
116
|
+
// The screen's unchecks first: unwire exactly those harnesses through their own offboard.
|
|
117
|
+
// (The codex global fence rides uninstall, not a per-harness unwire.)
|
|
118
|
+
for (const name of plan.toUnwire) {
|
|
119
|
+
const harness = wired.find((h) => h.name === name);
|
|
120
|
+
const files = new Set(manifest.rows.filter((r) => r.harness === name).map((r) => r.file));
|
|
121
|
+
for (const action of harness.offboard({ manifest })) actions.push({ harness: name, ...action });
|
|
122
|
+
const { sweepCreatedResidue } = await import('./blocks.mjs');
|
|
123
|
+
for (const action of sweepCreatedResidue({ backups: manifest.backups.filter((b) => files.has(b.file)) })) {
|
|
124
|
+
actions.push({ harness: name, ...action });
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
for (const step of plan.steps) {
|
|
128
|
+
if (!step.installed) {
|
|
129
|
+
actions.push({ harness: step.name, action: 'skipped-not-installed' });
|
|
74
130
|
continue;
|
|
75
131
|
}
|
|
76
|
-
|
|
132
|
+
if (step.selected !== true) {
|
|
133
|
+
actions.push({ harness: step.name, action: plan.toUnwire.includes(step.name) ? 'unwired' : 'skipped-not-selected' });
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
const harness = wired.find((h) => h.name === step.name);
|
|
137
|
+
for (const action of [...harness.onboard({ manifest, version }), ...harness.installGlobalFence({ manifest, version })]) {
|
|
77
138
|
actions.push({ harness: harness.name, ...action });
|
|
78
139
|
}
|
|
79
140
|
}
|
|
141
|
+
// The notch (the quiet glass): shipped with the package for everyone — the packaged
|
|
142
|
+
// app is the default, notchApp the override, a missing build a stated fact.
|
|
143
|
+
const { wireNotch } = await import('./notch.mjs');
|
|
144
|
+
for (const action of wireNotch({ home: ctx.home, manifest, config: ctx.config, version, packageRoot: ctx.paths.packageRoot, ...(exec ? { exec } : {}) })) {
|
|
145
|
+
actions.push({ harness: 'notch', ...action });
|
|
146
|
+
}
|
|
80
147
|
manifest.save();
|
|
81
148
|
|
|
82
149
|
return {
|
|
150
|
+
plan,
|
|
83
151
|
census: seen,
|
|
152
|
+
surfaces,
|
|
84
153
|
substrate: await substrate.status(),
|
|
85
154
|
principal: { org_id: identity.orgId, principal_id: identity.principalId, role: 'ceo' },
|
|
86
155
|
verifier: { principal_id: verifierPrincipal, seats },
|
|
156
|
+
verifier_engine: {
|
|
157
|
+
chosen: v.chosen,
|
|
158
|
+
candidates: v.candidates,
|
|
159
|
+
asked: v.asked,
|
|
160
|
+
recorded: record,
|
|
161
|
+
reason: v.alreadyChosen
|
|
162
|
+
? `already chosen machine-wide (${v.alreadyChosen.file}); switch with \`oathe config verifier <name> --global\``
|
|
163
|
+
: null,
|
|
164
|
+
},
|
|
165
|
+
wired: plan.wired,
|
|
87
166
|
actions,
|
|
167
|
+
steps: plan.outcomes(actions),
|
|
88
168
|
};
|
|
89
169
|
} finally {
|
|
90
170
|
await substrate.close();
|
package/src/launch-env.mjs
CHANGED
|
@@ -4,59 +4,9 @@
|
|
|
4
4
|
// and everything plugin-side asks ONE predicate before touching the substrate. Named once here:
|
|
5
5
|
// the launcher writes the block, the hooks and the server read it.
|
|
6
6
|
|
|
7
|
-
import fs from 'node:fs';
|
|
8
|
-
import path from 'node:path';
|
|
9
|
-
|
|
10
7
|
export const LAUNCHED_HARNESS_ENV = 'OATHE_LAUNCHED_HARNESS';
|
|
11
8
|
|
|
12
|
-
|
|
13
|
-
// children (Claude Code). Codex builds MCP child environments from its own config, so the
|
|
14
|
-
// marker dies at that boundary — the SESSION MARKER FILE is the harness-agnostic transport:
|
|
15
|
-
// the launcher writes <oatheHome>/launched/<workspace>.<pid>.json while it supervises, the
|
|
16
|
-
// gate honors any marker for its workspace whose supervisor is still alive, and teardown
|
|
17
|
-
// (or the supervisor dying) retires it. Stale markers fail the liveness probe and are inert.
|
|
18
|
-
|
|
19
|
-
export function sessionMarkerPath(oatheHome, workspace, pid = process.pid) {
|
|
20
|
-
return path.join(oatheHome, 'launched', `${workspace}.${pid}.json`);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/** @returns {string} the marker file path (hand it to clearSessionMarker at teardown).
|
|
24
|
-
* `wiring` is the launchSessionEnv block: harnesses that strip the environment on the way
|
|
25
|
-
* to their MCP children (Codex) get it back from here, identity included. */
|
|
26
|
-
export function writeSessionMarker({ oatheHome, workspace, harness, cwd, wiring = {}, pid = process.pid }) {
|
|
27
|
-
const file = sessionMarkerPath(oatheHome, workspace, pid);
|
|
28
|
-
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
29
|
-
fs.writeFileSync(file, `${JSON.stringify({
|
|
30
|
-
harness, supervisor_pid: pid, cwd, wiring, started_at: new Date().toISOString(),
|
|
31
|
-
})}\n`);
|
|
32
|
-
return file;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export function clearSessionMarker(file) {
|
|
36
|
-
fs.rmSync(file, { force: true });
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/** The full LIVE launch marker for this workspace ({harness, wiring, …}), or null.
|
|
40
|
-
* Dead and unreadable markers are retired on sight. */
|
|
41
|
-
export function liveSessionMarker({ oatheHome, workspace }) {
|
|
42
|
-
const dir = path.join(oatheHome, 'launched');
|
|
43
|
-
let names;
|
|
44
|
-
try { names = fs.readdirSync(dir); } catch { return null; }
|
|
45
|
-
for (const name of names) {
|
|
46
|
-
if (!name.startsWith(`${workspace}.`) || !name.endsWith('.json')) continue;
|
|
47
|
-
const file = path.join(dir, name);
|
|
48
|
-
try {
|
|
49
|
-
const marker = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
50
|
-
process.kill(marker.supervisor_pid, 0); // throws when the supervisor is gone
|
|
51
|
-
return marker;
|
|
52
|
-
} catch {
|
|
53
|
-
fs.rmSync(file, { force: true }); // stale or unreadable: retire it
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/** The harness ('claude' | 'codex') that launched this session, or null when unlaunched. */
|
|
9
|
+
/** The name of the launch-capable harness (catalog `launchable()`) that launched this session, or null when unlaunched. */
|
|
60
10
|
export function launchedHarness(env = process.env) {
|
|
61
11
|
const value = String(env[LAUNCHED_HARNESS_ENV] ?? '').trim();
|
|
62
12
|
return value === '' ? null : value;
|
package/src/launch.mjs
CHANGED
|
@@ -10,13 +10,9 @@ import fs from 'node:fs';
|
|
|
10
10
|
import path from 'node:path';
|
|
11
11
|
|
|
12
12
|
import { buildContext } from './context.mjs';
|
|
13
|
-
import {
|
|
14
|
-
import { census } from './harness.mjs';
|
|
15
|
-
import { FencedBlock, FENCE_STYLES } from './blocks.mjs';
|
|
16
|
-
import { sha256Hex } from './manifest.mjs';
|
|
17
|
-
import { workspaceRef } from './workspace.mjs';
|
|
13
|
+
import { byName } from './harnesses/catalog.mjs';
|
|
18
14
|
import { SessionHost } from './session-host.mjs';
|
|
19
|
-
import { launchSessionEnv
|
|
15
|
+
import { launchSessionEnv } from './launch-env.mjs';
|
|
20
16
|
|
|
21
17
|
export class LaunchError extends Error {
|
|
22
18
|
constructor(code, message, details = {}) {
|
|
@@ -27,59 +23,27 @@ export class LaunchError extends Error {
|
|
|
27
23
|
}
|
|
28
24
|
}
|
|
29
25
|
|
|
30
|
-
/** The managed section: an H2 inside HTML-comment fences — the estate-convention hybrid. */
|
|
31
|
-
function fenceBody(workspace) {
|
|
32
|
-
return [
|
|
33
|
-
'## Oathe',
|
|
34
|
-
'',
|
|
35
|
-
`This folder has an Oathe board (workspace \`${workspace}\`). Claims are speech acts:`,
|
|
36
|
-
'claim before you build, record progress as statements, yield what you cannot finish —',
|
|
37
|
-
'via the `oathe_*` MCP tools. The board renders at SessionStart; `continue <task>`',
|
|
38
|
-
'picks work back up.',
|
|
39
|
-
].join('\n');
|
|
40
|
-
}
|
|
41
|
-
|
|
42
26
|
/**
|
|
43
|
-
* Ensure the cwd's
|
|
44
|
-
*
|
|
45
|
-
* when absent — recorded as a project-scope manifest row either way.
|
|
27
|
+
* Ensure the cwd's context files carry the managed Oathe section (through the ONE activation
|
|
28
|
+
* writer — src/activation.mjs), and that the global install exists.
|
|
46
29
|
*/
|
|
47
|
-
export async function preflight({ env = process.env, cwd = process.cwd(), exec, harness
|
|
30
|
+
export async function preflight({ env = process.env, cwd = process.cwd(), exec, harness } = {}) {
|
|
31
|
+
byName(harness); // the harness to launch is named by the caller — unknown or missing is the catalog's typed refusal
|
|
48
32
|
const ctx = buildContext({ env, exec });
|
|
49
|
-
const { manifest,
|
|
33
|
+
const { manifest, version, substrate, paths, config } = ctx;
|
|
50
34
|
await substrate.close(); // preflight itself never talks to the database
|
|
51
35
|
if (!manifest.rows.some((r) => r.harness === harness)) {
|
|
52
36
|
throw new LaunchError('OATHE_NOT_INSTALLED',
|
|
53
37
|
`the ${harness} install is missing (no ${harness} rows in the install manifest) — `
|
|
54
38
|
+ 'run `oathe init` with that harness present first');
|
|
55
39
|
}
|
|
56
|
-
const
|
|
57
|
-
const
|
|
58
|
-
const
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
const actions = [];
|
|
64
|
-
for (const target of targets) {
|
|
65
|
-
const file = path.join(cwd, target.file);
|
|
66
|
-
manifest.backupOnce(file);
|
|
67
|
-
const before = fs.existsSync(file) ? fs.readFileSync(file, 'utf8') : '';
|
|
68
|
-
const { content, changed } = block.apply(before, { version, body: fenceBody(workspace) });
|
|
69
|
-
if (changed) fs.writeFileSync(file, content);
|
|
70
|
-
manifest.upsert({
|
|
71
|
-
harness: 'project',
|
|
72
|
-
file,
|
|
73
|
-
kind: 'fence',
|
|
74
|
-
scope: 'project',
|
|
75
|
-
detail: { style: 'html' },
|
|
76
|
-
blockVersion: version,
|
|
77
|
-
sha256: sha256Hex(block.read(content).blockText),
|
|
78
|
-
});
|
|
79
|
-
actions.push({ action: target.action, file, changed });
|
|
80
|
-
}
|
|
81
|
-
manifest.save();
|
|
82
|
-
return { workspace, actions };
|
|
40
|
+
const { activateWorkspace } = await import('./activation.mjs');
|
|
41
|
+
const { WorkspaceRegistry } = await import('./registry.mjs');
|
|
42
|
+
const registry = new WorkspaceRegistry({ registryPath: paths.registryPath });
|
|
43
|
+
const { workspace, synthetic, actions } = await activateWorkspace({
|
|
44
|
+
cwd, env, manifest, registry, config, version, source: 'launcher:preflight', harness,
|
|
45
|
+
});
|
|
46
|
+
return { workspace, synthetic, actions };
|
|
83
47
|
}
|
|
84
48
|
|
|
85
49
|
/** POSIX-name keys only — what the cage can declare; the rest cannot ride an `env -i` word. */
|
|
@@ -118,7 +82,7 @@ function curatedEnv(env, { hermetic, extra }) {
|
|
|
118
82
|
|
|
119
83
|
/**
|
|
120
84
|
* ONE launcher, both harnesses — same cage, same session host, same pre-flight; only the
|
|
121
|
-
* binary differs. (
|
|
85
|
+
* binary differs. (An earlier plan deferred `oathe codex` on the premise that Codex lacked
|
|
122
86
|
* Stop/PreCompact; the docs pass proved both exist, so the premise — and the wait — died.)
|
|
123
87
|
*
|
|
124
88
|
* @param {{harness: 'claude'|'codex', env?: object, cwd?: string, args?: string[],
|
|
@@ -129,22 +93,25 @@ export async function runHarness({
|
|
|
129
93
|
harness, env = process.env, cwd = process.cwd(), args = [], hermetic = false, exec,
|
|
130
94
|
observeIntervalMs = 60_000, out = process.stdout, stdin = process.stdin, pauseMs = 3000,
|
|
131
95
|
} = {}) {
|
|
132
|
-
const { workspace } = await preflight({ env, cwd, exec, harness });
|
|
96
|
+
const { workspace, synthetic } = await preflight({ env, cwd, exec, harness });
|
|
133
97
|
const ctx = buildContext({ env, exec, cwd });
|
|
134
98
|
const { paths, substrate, identity, config } = ctx;
|
|
135
99
|
|
|
136
100
|
// First launch in a folder: the verifier is CHOSEN, on the record, before any claim binds it.
|
|
137
101
|
await ensureVerifierChoice({ config, harness, stdin, out });
|
|
138
102
|
|
|
139
|
-
//
|
|
140
|
-
//
|
|
141
|
-
|
|
142
|
-
if (harness === 'codex') {
|
|
103
|
+
// The splash is the adapter's own quirk (codex buries hook output in its ctrl+T transcript
|
|
104
|
+
// overlay, unrendered; Claude Code shows the systemMessage banner inside its own TUI).
|
|
105
|
+
if (byName(harness).launch?.splash) {
|
|
143
106
|
let openWork = false;
|
|
144
107
|
try {
|
|
145
|
-
const { renderBoard, renderSplash } = await
|
|
146
|
-
|
|
147
|
-
|
|
108
|
+
const [{ renderBoard, renderSplash }, { Pager }, { WorkspaceRegistry }] = await Promise.all([
|
|
109
|
+
import('./board-render.mjs'), import('./pager.mjs'), import('./registry.mjs'),
|
|
110
|
+
]);
|
|
111
|
+
const registry = new WorkspaceRegistry({ registryPath: paths.registryPath });
|
|
112
|
+
const breaches = await new Pager({ client: substrate, identity, config, registry }).breaches();
|
|
113
|
+
const seen = await renderBoard({ client: substrate, identity, workspace, config, synthetic, breaches });
|
|
114
|
+
out.write(renderSplash({ message: seen.message, sections: seen.sections, workspace: seen.lens, breaches }));
|
|
148
115
|
openWork = Object.values(seen.sections).some((rows) => rows.length > 0);
|
|
149
116
|
} catch (e) {
|
|
150
117
|
out.write(`Oathe board unavailable (${String(e?.message || e).slice(0, 120)})\n`);
|
|
@@ -157,14 +124,10 @@ export async function runHarness({
|
|
|
157
124
|
|
|
158
125
|
const unit = `oathe-${Date.now().toString(36)}-${process.pid}`;
|
|
159
126
|
const extra = launchSessionEnv({ config, identity, cwd, harness });
|
|
160
|
-
// The env block above dies at Codex's MCP spawn boundary; the marker file is the
|
|
161
|
-
// harness-agnostic copy of the same wiring, retired in the finally below.
|
|
162
|
-
const marker = writeSessionMarker({
|
|
163
|
-
oatheHome: paths.oatheHome, workspace, harness, cwd, wiring: extra });
|
|
164
127
|
const cage = spawnCaged({
|
|
165
128
|
unit,
|
|
166
129
|
env: curatedEnv(env, { hermetic, extra }),
|
|
167
|
-
cmd: resolveOnPath(env.PATH, harness),
|
|
130
|
+
cmd: resolveOnPath(env.PATH, byName(harness).launch?.bin ?? harness), // the adapter names its own binary
|
|
168
131
|
args,
|
|
169
132
|
cwd,
|
|
170
133
|
stdio: 'inherit', // an interactive daily driver owns the terminal
|
|
@@ -173,7 +136,6 @@ export async function runHarness({
|
|
|
173
136
|
const host = new SessionHost({
|
|
174
137
|
client: substrate,
|
|
175
138
|
identity,
|
|
176
|
-
workspace,
|
|
177
139
|
liveness: () => (cage.alive ? cage.alive() : cage.enumerate().length > 0),
|
|
178
140
|
observeIntervalMs,
|
|
179
141
|
});
|
|
@@ -186,7 +148,6 @@ export async function runHarness({
|
|
|
186
148
|
if (exitCode === 0) await host.stop({ exitCode });
|
|
187
149
|
else await host.stopSilently(); // a non-zero exit was not a clean goodbye — leave the absence
|
|
188
150
|
} finally {
|
|
189
|
-
clearSessionMarker(marker);
|
|
190
151
|
await substrate.close();
|
|
191
152
|
}
|
|
192
153
|
const teardown = await cage.teardownProvenEmpty();
|
|
@@ -194,40 +155,18 @@ export async function runHarness({
|
|
|
194
155
|
}
|
|
195
156
|
|
|
196
157
|
/**
|
|
197
|
-
* The
|
|
198
|
-
*
|
|
199
|
-
*
|
|
200
|
-
* default is ANNOUNCED, never silently assumed.
|
|
158
|
+
* The verifier is chosen ONCE, at `oathe init` (machine-wide, per-folder override via
|
|
159
|
+
* `oathe config verifier <engine>`). Launch never prompts: an explicit choice passes
|
|
160
|
+
* silently; a still-default value is ANNOUNCED on stderr — never silently assumed.
|
|
201
161
|
* @returns {Promise<{chosen: string, prompted: boolean}>}
|
|
202
162
|
*/
|
|
203
|
-
export function ensureVerifierChoice({ config,
|
|
204
|
-
const
|
|
205
|
-
if (config.source('verifier')
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
`);
|
|
209
|
-
return Promise.resolve({ chosen: current, prompted: false });
|
|
163
|
+
export function ensureVerifierChoice({ config, err = process.stderr } = {}) {
|
|
164
|
+
const chosen = config.get('verifier');
|
|
165
|
+
if (config.source('verifier') === 'default') {
|
|
166
|
+
err?.write?.(`verifier: ${chosen} (default — \`oathe init\` records the machine choice; `
|
|
167
|
+
+ 'override per folder with `oathe config verifier <engine>`)\n');
|
|
210
168
|
}
|
|
211
|
-
|
|
212
|
-
out.write(`
|
|
213
|
-
Who verifies this folder's work? ${menu} (Enter = ${current})
|
|
214
|
-
> `);
|
|
215
|
-
return new Promise((resolve) => {
|
|
216
|
-
const onAnswer = (data) => {
|
|
217
|
-
stdin.removeListener('data', onAnswer);
|
|
218
|
-
stdin.pause?.();
|
|
219
|
-
const raw = String(data).trim();
|
|
220
|
-
const byIndex = VERIFIER_ENGINES[Number(raw) - 1];
|
|
221
|
-
const chosen = byIndex ?? (VERIFIER_ENGINES.includes(raw) ? raw : current);
|
|
222
|
-
config.set('verifier', chosen, { scope: 'workspace' });
|
|
223
|
-
out.write(` verifier: ${chosen} (recorded in ${config.workspacePath})
|
|
224
|
-
|
|
225
|
-
`);
|
|
226
|
-
resolve({ chosen, prompted: true });
|
|
227
|
-
};
|
|
228
|
-
stdin.on('data', onAnswer);
|
|
229
|
-
stdin.resume?.();
|
|
230
|
-
});
|
|
169
|
+
return Promise.resolve({ chosen, prompted: false });
|
|
231
170
|
}
|
|
232
171
|
|
|
233
172
|
/**
|
|
@@ -254,11 +193,3 @@ export function waitForLaunch({ harness, pauseMs, stdin, out }) {
|
|
|
254
193
|
stdin.resume?.();
|
|
255
194
|
});
|
|
256
195
|
}
|
|
257
|
-
|
|
258
|
-
export function runClaude(o = {}) {
|
|
259
|
-
return runHarness({ ...o, harness: 'claude' });
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
export function runCodex(o = {}) {
|
|
263
|
-
return runHarness({ ...o, harness: 'codex' });
|
|
264
|
-
}
|
package/src/manifest.mjs
CHANGED
|
@@ -6,6 +6,8 @@ import crypto from 'node:crypto';
|
|
|
6
6
|
import fs from 'node:fs';
|
|
7
7
|
import path from 'node:path';
|
|
8
8
|
|
|
9
|
+
import { atomicWriteJson } from './fslock.mjs';
|
|
10
|
+
|
|
9
11
|
export function sha256Hex(text) {
|
|
10
12
|
return crypto.createHash('sha256').update(text).digest('hex');
|
|
11
13
|
}
|
|
@@ -35,9 +37,11 @@ export class InstallManifest {
|
|
|
35
37
|
}
|
|
36
38
|
|
|
37
39
|
save() {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
// Atomic (temp-then-rename): concurrent hooks and servers read this file; a torn manifest
|
|
41
|
+
// would break doctor/uninstall. Serializing whole load→mutate→save cycles is the caller's
|
|
42
|
+
// job (withFileLock), because a lock inside save() alone cannot prevent lost updates.
|
|
43
|
+
atomicWriteJson(this.manifestPath,
|
|
44
|
+
{ format: MANIFEST_FORMAT, saved_at: this.clock(), rows: this.rows, backups: this.backups });
|
|
41
45
|
}
|
|
42
46
|
|
|
43
47
|
/** One row per (harness, file, kind, detail identity); a re-run replaces its own row. */
|