@oathe/oathe 0.2.3 → 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 +15 -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 +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 +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 -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/harness.mjs
DELETED
|
@@ -1,271 +0,0 @@
|
|
|
1
|
-
// oathe — the harness layer. One base class holds what every harness shares (detection inputs,
|
|
2
|
-
// manifest access, exec seam); each subclass owns the ONE way its harness is onboarded:
|
|
3
|
-
// Claude via owned JSON paths in ~/.claude/settings.json, Codex via its sanctioned CLIs with
|
|
4
|
-
// post-verification (its config stanzas are Codex-managed bookkeeping — writing them by hand
|
|
5
|
-
// is how two managers end up owning one file).
|
|
6
|
-
|
|
7
|
-
import fs from 'node:fs';
|
|
8
|
-
import path from 'node:path';
|
|
9
|
-
import { spawnSync } from 'node:child_process';
|
|
10
|
-
|
|
11
|
-
import { JsonEntries } from './blocks.mjs';
|
|
12
|
-
import { sha256Hex } from './manifest.mjs';
|
|
13
|
-
|
|
14
|
-
export class HarnessOnboardError extends Error {
|
|
15
|
-
constructor(code, message, details = {}) {
|
|
16
|
-
super(message);
|
|
17
|
-
this.name = 'HarnessOnboardError';
|
|
18
|
-
this.code = code;
|
|
19
|
-
this.details = details;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const defaultExec = {
|
|
24
|
-
run(cmd, args) {
|
|
25
|
-
const r = spawnSync(cmd, args, { encoding: 'utf8' });
|
|
26
|
-
return { status: r.status ?? 1, stdout: r.stdout ?? '', stderr: r.stderr ?? '' };
|
|
27
|
-
},
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export class Harness {
|
|
31
|
-
/**
|
|
32
|
-
* @param {{name: string, home: string, envPath?: string, paths: object,
|
|
33
|
-
* exec?: {run: (cmd: string, args: string[]) => {status: number, stdout: string, stderr: string}}}} o
|
|
34
|
-
*/
|
|
35
|
-
constructor({ name, home, envPath = process.env.PATH ?? '', paths, exec = defaultExec }) {
|
|
36
|
-
this.name = name;
|
|
37
|
-
this.home = home;
|
|
38
|
-
this.envPath = envPath;
|
|
39
|
-
this.paths = paths;
|
|
40
|
-
this.exec = exec;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/** The harness's config home (e.g. ~/.claude) — subclasses name theirs. */
|
|
44
|
-
get configHome() {
|
|
45
|
-
return path.join(this.home, `.${this.name}`);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
binOnPath(bin) {
|
|
49
|
-
return this.envPath.split(':').filter(Boolean).some((dir) => {
|
|
50
|
-
try { fs.accessSync(path.join(dir, bin), fs.constants.X_OK); return true; } catch { return false; }
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/** @returns {{name: string, installed: boolean, evidence: object}} */
|
|
55
|
-
detect() {
|
|
56
|
-
const binFound = this.binOnPath(this.name);
|
|
57
|
-
const homeFound = fs.existsSync(this.configHome);
|
|
58
|
-
return {
|
|
59
|
-
name: this.name,
|
|
60
|
-
installed: binFound && homeFound,
|
|
61
|
-
evidence: { bin_on_path: binFound, config_home: homeFound ? this.configHome : null },
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export class ClaudeHarness extends Harness {
|
|
67
|
-
constructor(o) {
|
|
68
|
-
super({ ...o, name: 'claude' });
|
|
69
|
-
this.entries = new JsonEntries();
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
get settingsPath() {
|
|
73
|
-
return path.join(this.configHome, 'settings.json');
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/** The exact keys oathe owns in settings.json — the whole Claude install. */
|
|
77
|
-
#ownedEntries() {
|
|
78
|
-
return [
|
|
79
|
-
{
|
|
80
|
-
// "directory" is what the INSTALLED CLI's settings schema accepts (verified empirically
|
|
81
|
-
// on 2.1.241: the pre-existing custom-plugins entry validates, a "local" entry is
|
|
82
|
-
// rejected with "Invalid input" and the whole file is skipped). The docs say "local";
|
|
83
|
-
// the binary outranks the docs.
|
|
84
|
-
path: ['extraKnownMarketplaces', 'oathe'],
|
|
85
|
-
value: { source: { source: 'directory', path: this.paths.packageRoot } },
|
|
86
|
-
},
|
|
87
|
-
{ path: ['enabledPlugins', 'oathe@oathe'], value: true },
|
|
88
|
-
];
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
get registryDir() {
|
|
92
|
-
return path.join(this.configHome, 'plugins');
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
get installedFile() {
|
|
96
|
-
return path.join(this.registryDir, 'installed_plugins.json');
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
#readRegistry(file) {
|
|
100
|
-
try { return JSON.parse(fs.readFileSync(file, 'utf8')); } catch { return null; }
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
#installedVersion() {
|
|
104
|
-
return this.#readRegistry(this.installedFile)?.plugins?.['oathe@oathe']?.[0]?.version ?? null;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
#marketplaceKnown() {
|
|
108
|
-
return this.#readRegistry(path.join(this.registryDir, 'known_marketplaces.json'))?.oathe !== undefined;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
#cli(args) {
|
|
112
|
-
const result = this.exec.run('claude', args);
|
|
113
|
-
if (result.status !== 0) {
|
|
114
|
-
throw new HarnessOnboardError('CLAUDE_CLI_FAILED',
|
|
115
|
-
`claude ${args.join(' ')} exited ${result.status}: ${result.stderr.trim()}`, { args });
|
|
116
|
-
}
|
|
117
|
-
return result;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
onboard({ manifest, version }) {
|
|
121
|
-
const entries = this.#ownedEntries();
|
|
122
|
-
const before = fs.existsSync(this.settingsPath) ? fs.readFileSync(this.settingsPath, 'utf8') : '';
|
|
123
|
-
manifest.backupOnce(this.settingsPath);
|
|
124
|
-
const { content, changed } = this.entries.apply(before, entries);
|
|
125
|
-
if (changed) {
|
|
126
|
-
fs.mkdirSync(path.dirname(this.settingsPath), { recursive: true });
|
|
127
|
-
fs.writeFileSync(this.settingsPath, content);
|
|
128
|
-
}
|
|
129
|
-
manifest.upsert({
|
|
130
|
-
harness: this.name,
|
|
131
|
-
file: this.settingsPath,
|
|
132
|
-
kind: 'json-path',
|
|
133
|
-
detail: { paths: entries.map((e) => e.path) },
|
|
134
|
-
blockVersion: version,
|
|
135
|
-
sha256: sha256Hex(JSON.stringify(entries)),
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
// MATERIALIZE via the CLI. The settings entries above are the declarative pin, but the CLI's
|
|
139
|
-
// own registry (installed_plugins.json) is what sessions load from — and the install is a
|
|
140
|
-
// CACHED COPY keyed by version, so a version change must evict the stale copy.
|
|
141
|
-
const installed = this.#installedVersion();
|
|
142
|
-
let materialized = false;
|
|
143
|
-
if (installed !== version) {
|
|
144
|
-
if (!this.#marketplaceKnown()) this.#cli(['plugin', 'marketplace', 'add', this.paths.packageRoot]);
|
|
145
|
-
if (installed !== null) this.#cli(['plugin', 'uninstall', 'oathe@oathe']);
|
|
146
|
-
this.#cli(['plugin', 'install', 'oathe@oathe']);
|
|
147
|
-
if (this.#installedVersion() !== version) {
|
|
148
|
-
throw new HarnessOnboardError('CLAUDE_VERIFICATION_FAILED',
|
|
149
|
-
'verification failed: `claude plugin install oathe@oathe` reported success but '
|
|
150
|
-
+ `${this.installedFile} does not record version ${version} — refusing to record an `
|
|
151
|
-
+ 'install that cannot be proven');
|
|
152
|
-
}
|
|
153
|
-
materialized = true;
|
|
154
|
-
}
|
|
155
|
-
manifest.upsert({
|
|
156
|
-
harness: this.name,
|
|
157
|
-
file: this.installedFile,
|
|
158
|
-
kind: 'cli-managed',
|
|
159
|
-
detail: {
|
|
160
|
-
id: 'plugin-install',
|
|
161
|
-
proof: 'oathe@oathe',
|
|
162
|
-
undo: [['plugin', 'uninstall', 'oathe@oathe'], ['plugin', 'marketplace', 'remove', 'oathe']],
|
|
163
|
-
},
|
|
164
|
-
blockVersion: version,
|
|
165
|
-
sha256: sha256Hex('oathe@oathe'),
|
|
166
|
-
});
|
|
167
|
-
return [
|
|
168
|
-
{ action: 'settings-owned-paths', file: this.settingsPath, changed },
|
|
169
|
-
{ action: materialized ? 'plugin-installed' : 'plugin-already-current', file: this.installedFile },
|
|
170
|
-
];
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
offboard({ manifest }) {
|
|
174
|
-
const rows = manifest.removeWhere((r) => r.harness === this.name);
|
|
175
|
-
const actions = [];
|
|
176
|
-
for (const row of rows.filter((r) => r.kind === 'cli-managed')) {
|
|
177
|
-
for (const undo of row.detail?.undo ?? []) {
|
|
178
|
-
const result = this.exec.run('claude', undo);
|
|
179
|
-
actions.push({ action: `claude-undo-${undo.join('-')}`, status: result.status });
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
if (!fs.existsSync(this.settingsPath)) return [...actions, { action: 'settings-absent' }];
|
|
183
|
-
const before = fs.readFileSync(this.settingsPath, 'utf8');
|
|
184
|
-
const ownedPaths = rows.flatMap((r) => r.detail?.paths ?? []);
|
|
185
|
-
const { content, changed } = this.entries.remove(before, ownedPaths);
|
|
186
|
-
if (changed) fs.writeFileSync(this.settingsPath, content);
|
|
187
|
-
return [...actions, { action: 'settings-owned-paths-removed', file: this.settingsPath, changed }];
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
export class CodexHarness extends Harness {
|
|
192
|
-
constructor(o) {
|
|
193
|
-
super({ ...o, name: 'codex' });
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
get configPath() {
|
|
197
|
-
return path.join(this.configHome, 'config.toml');
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* The sanctioned registrations, each with the CLI that makes it, the config.toml stanza that
|
|
202
|
-
* proves it landed, and the CLI that undoes it.
|
|
203
|
-
*/
|
|
204
|
-
#registrations() {
|
|
205
|
-
return [
|
|
206
|
-
{
|
|
207
|
-
id: 'marketplace',
|
|
208
|
-
add: ['plugin', 'marketplace', 'add', this.paths.packageRoot],
|
|
209
|
-
proof: '[marketplaces.oathe]',
|
|
210
|
-
undo: ['plugin', 'marketplace', 'remove', 'oathe'],
|
|
211
|
-
},
|
|
212
|
-
{
|
|
213
|
-
id: 'plugin',
|
|
214
|
-
add: ['plugin', 'add', 'oathe@oathe'],
|
|
215
|
-
proof: '[plugins."oathe@oathe"]',
|
|
216
|
-
undo: ['plugin', 'remove', 'oathe@oathe'],
|
|
217
|
-
},
|
|
218
|
-
{
|
|
219
|
-
id: 'mcp-server',
|
|
220
|
-
add: ['mcp', 'add', 'oathe', '--', 'oathe', 'mcp'],
|
|
221
|
-
proof: '[mcp_servers.oathe]',
|
|
222
|
-
undo: ['mcp', 'remove', 'oathe'],
|
|
223
|
-
},
|
|
224
|
-
];
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
onboard({ manifest, version }) {
|
|
228
|
-
manifest.backupOnce(this.configPath);
|
|
229
|
-
for (const reg of this.#registrations()) {
|
|
230
|
-
const result = this.exec.run('codex', reg.add);
|
|
231
|
-
if (result.status !== 0) {
|
|
232
|
-
throw new HarnessOnboardError('CODEX_CLI_FAILED',
|
|
233
|
-
`codex ${reg.add.join(' ')} exited ${result.status}: ${result.stderr.trim()}`, { reg: reg.id });
|
|
234
|
-
}
|
|
235
|
-
const config = fs.existsSync(this.configPath) ? fs.readFileSync(this.configPath, 'utf8') : '';
|
|
236
|
-
if (!config.includes(reg.proof)) {
|
|
237
|
-
throw new HarnessOnboardError('CODEX_VERIFICATION_FAILED',
|
|
238
|
-
`verification failed: codex ${reg.add.join(' ')} reported success but ${this.configPath} `
|
|
239
|
-
+ `carries no ${reg.proof} stanza — refusing to record an install that cannot be proven`,
|
|
240
|
-
{ reg: reg.id });
|
|
241
|
-
}
|
|
242
|
-
manifest.upsert({
|
|
243
|
-
harness: this.name,
|
|
244
|
-
file: this.configPath,
|
|
245
|
-
kind: 'cli-managed',
|
|
246
|
-
detail: { id: reg.id, proof: reg.proof, undo: reg.undo },
|
|
247
|
-
blockVersion: version,
|
|
248
|
-
sha256: sha256Hex(reg.proof),
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
|
-
return this.#registrations().map((r) => ({ action: `codex-${r.id}` }));
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
offboard({ manifest }) {
|
|
255
|
-
const rows = manifest.removeWhere((r) => r.harness === this.name);
|
|
256
|
-
const actions = [];
|
|
257
|
-
// Undo in reverse install order, so the plugin is gone before its marketplace is.
|
|
258
|
-
for (const row of rows.reverse()) {
|
|
259
|
-
const undo = row.detail?.undo;
|
|
260
|
-
if (!undo) continue;
|
|
261
|
-
const result = this.exec.run('codex', undo);
|
|
262
|
-
actions.push({ action: `codex-undo-${row.detail.id}`, status: result.status });
|
|
263
|
-
}
|
|
264
|
-
return actions;
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
/** @returns {Array<{name: string, installed: boolean, evidence: object}>} */
|
|
269
|
-
export function census(harnesses) {
|
|
270
|
-
return harnesses.map((h) => h.detect());
|
|
271
|
-
}
|