@oathe/oathe 0.4.1 → 0.4.3

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/bin/oathe.mjs CHANGED
@@ -8,7 +8,7 @@ import { parseArgs } from 'node:util';
8
8
  import { isTraceSubjectSql } from '../src/statements.mjs';
9
9
  import { byName, launchable, verifierCapable } from '../src/harnesses/catalog.mjs';
10
10
 
11
- const VERBS = ['init', ...launchable(), 'claim', 'ls', 'note', 'amend', 'done', 'verify', 'trace', 'notch', 'yield', 'config', 'doctor', 'uninstall', 'status', 'version', 'hook', 'mcp'];
11
+ const VERBS = ['init', ...launchable(), 'claim', 'ls', 'note', 'amend', 'done', 'verify', 'trace', 'notch', 'yield', 'config', 'doctor', 'uninstall', 'status', 'version', 'update', 'hook', 'mcp'];
12
12
 
13
13
  const USAGE = `usage: oathe <verb> [args]
14
14
 
@@ -26,7 +26,8 @@ ${launchable().map((name) => ` ${name.padEnd(6)} [--hermetic] [args…] ${byNa
26
26
  yield <task-id> <note> yield: the task goes back on the board, unowned
27
27
  doctor [--surface] verify every managed surface (--surface: the resolution report only)
28
28
  status the substrate half of doctor
29
- version the package version (upgrade: npm i -g @oathe/oathe@latest && oathe init)
29
+ version the package version on PATH
30
+ update [--yes] [--harness a,b] the upgrade as one verb: npm i -g @oathe/oathe@latest through this node's npm, then init through the new bin
30
31
  config <key> [value] [--global] read or write a config key (workspace scope by default)
31
32
  uninstall [--purge-db] remove exactly what init recorded (the database stays put)
32
33
  hook <name> · mcp internal: the plugin's hook/server entry points (bin-addressed)
@@ -540,6 +541,21 @@ const handlers = {
540
541
  summary('version', 'ok');
541
542
  },
542
543
 
544
+ async update(argv) {
545
+ const { values } = parseFlags('update', {
546
+ args: argv, options: { yes: { type: 'boolean', default: false }, harness: { type: 'string' } }, allowPositionals: false,
547
+ });
548
+ const [{ runUpdate }, { buildPaths }] = await Promise.all([import('../src/update.mjs'), import('../src/paths.mjs')]);
549
+ const initArgs = [...(values.yes ? ['--yes'] : []), ...(values.harness ? ['--harness', values.harness] : [])];
550
+ const out = runUpdate({ packageRoot: buildPaths(process.env).packageRoot, args: initArgs });
551
+ if (out.initStatus !== 0) {
552
+ const e = new Error(`update installed ${out.after} but the new bin's init exited ${out.initStatus} — read its output above and run \`oathe init\` again`);
553
+ e.code = 'OATHE_UPDATE_INIT_FAILED';
554
+ throw e;
555
+ }
556
+ summary('update', 'ok');
557
+ },
558
+
543
559
  async doctor(argv) {
544
560
  const { values } = parseFlags('doctor', {
545
561
  args: argv, options: { surface: { type: 'boolean', default: false } }, allowPositionals: false,
@@ -6,7 +6,7 @@
6
6
  <key>CFBundleName</key><string>Oathe Notch</string>
7
7
  <key>CFBundleExecutable</key><string>OatheNotch</string>
8
8
  <key>CFBundlePackageType</key><string>APPL</string>
9
- <key>CFBundleShortVersionString</key><string>0.4.1</string>
9
+ <key>CFBundleShortVersionString</key><string>0.4.3</string>
10
10
  <key>LSMinimumSystemVersion</key><string>14.0</string>
11
11
  <key>LSUIElement</key><true/>
12
12
  </dict>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oathe/oathe",
3
- "version": "0.4.1",
3
+ "version": "0.4.3",
4
4
  "description": "Auto save and verified completion for AI coding agents — a durable local task board that outlives any one session. D0 preview.",
5
5
  "type": "module",
6
6
  "engines": {
@@ -12,7 +12,7 @@
12
12
  "scripts": {
13
13
  "preinstall": "node bin/node-floor.mjs",
14
14
  "test": "npm run test:unit && npm run test:heavy",
15
- "test:unit": "node --test tests/activation.test.mjs tests/atif.test.mjs tests/blocks.test.mjs tests/board-render.test.mjs tests/breach-digest.test.mjs tests/config.test.mjs tests/cursor-harness.test.mjs tests/discharge.test.mjs tests/evidence-budget.test.mjs tests/fslock.test.mjs tests/harness-contract.test.mjs tests/harness-docs.test.mjs tests/harness-docs-drift.test.mjs tests/harbor-conformance.test.mjs tests/harness.test.mjs tests/notch-frame.test.mjs tests/home.test.mjs tests/horizon-census.test.mjs tests/manifest.test.mjs tests/mcp-connection.test.mjs tests/node-floor.test.mjs tests/notch.test.mjs tests/packaging.test.mjs tests/paths.test.mjs tests/registry.test.mjs tests/runtime-provider.test.mjs tests/sessions.test.mjs tests/setup.test.mjs tests/speaker.test.mjs tests/successor.test.mjs tests/trace-census.test.mjs tests/trace-fixture-tools.test.mjs tests/trace-fixtures.test.mjs tests/traces.test.mjs tests/ux-contract.test.mjs tests/verify-dispatch.test.mjs tests/welcome.test.mjs tests/workspace-resolver.test.mjs tests/workspace.test.mjs",
15
+ "test:unit": "node --test tests/activation.test.mjs tests/atif.test.mjs tests/blocks.test.mjs tests/board-render.test.mjs tests/breach-digest.test.mjs tests/config.test.mjs tests/cursor-harness.test.mjs tests/discharge.test.mjs tests/evidence-budget.test.mjs tests/fslock.test.mjs tests/harness-contract.test.mjs tests/harness-docs.test.mjs tests/harness-docs-drift.test.mjs tests/harbor-conformance.test.mjs tests/harness.test.mjs tests/notch-frame.test.mjs tests/home.test.mjs tests/horizon-census.test.mjs tests/manifest.test.mjs tests/mcp-connection.test.mjs tests/node-floor.test.mjs tests/notch.test.mjs tests/packaging.test.mjs tests/paths.test.mjs tests/registry.test.mjs tests/runtime-provider.test.mjs tests/sessions.test.mjs tests/setup.test.mjs tests/speaker.test.mjs tests/successor.test.mjs tests/trace-census.test.mjs tests/trace-fixture-tools.test.mjs tests/trace-fixtures.test.mjs tests/update.test.mjs tests/traces.test.mjs tests/ux-contract.test.mjs tests/verify-dispatch.test.mjs tests/welcome.test.mjs tests/workspace-resolver.test.mjs tests/workspace.test.mjs",
16
16
  "test:heavy": "node --test --test-concurrency=2 tests/amend.test.mjs tests/cli.test.mjs tests/harness-install-contract.test.mjs tests/harness-live-contract.test.mjs tests/init.test.mjs tests/integration.test.mjs tests/launch.test.mjs tests/lineage.test.mjs tests/oathe-tools.test.mjs tests/pager.test.mjs tests/plugin.test.mjs tests/session-host.test.mjs tests/simple-cage.test.mjs tests/sql-acceptance-lane.test.mjs tests/substrate.test.mjs tests/vendor-scripts.test.mjs tests/verifier.test.mjs",
17
17
  "lint": "npx -y eslint@10.9.1 .",
18
18
  "pack:dry-run": "npm pack --dry-run --ignore-scripts",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "oathe",
3
3
  "displayName": "Oathe",
4
- "version": "0.4.1",
4
+ "version": "0.4.3",
5
5
  "description": "Claims are speech acts: your session opens on this folder's board, records progress as statements, and yields what it cannot finish. Horizons move only by deliberate acts — never by session liveness.",
6
6
  "author": {
7
7
  "name": "Oathe"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oathe",
3
- "version": "0.4.1",
3
+ "version": "0.4.3",
4
4
  "description": "Claims are speech acts: your session opens on this folder's board, records progress as statements, and yields what it cannot finish. Horizons move only by deliberate acts — never by session liveness.",
5
5
  "author": {
6
6
  "name": "Oathe"
package/src/update.mjs ADDED
@@ -0,0 +1,86 @@
1
+ // oathe — `oathe update`: the documented upgrade, `npm i -g @oathe/oathe@latest && oathe init`,
2
+ // as one verb (founder's word, 2026-09-03). Three facts it holds:
3
+ // - the npm it calls is the one BESIDE the node running this bin (process.execPath), never
4
+ // PATH's — on an nvm machine PATH can lead to another node's npm, and then the upgrade lands
5
+ // somewhere this bin never looks (the trap the 0.4.1 trial hit);
6
+ // - init runs through the NEW bin — the one under npm's global PREFIX (`npm prefix -g`),
7
+ // which is node's own directory by default but not with `npm config set prefix …` (a
8
+ // Greptile P1 on PR #33 caught the execPath-sibling shortcut) — as a child with the terminal
9
+ // attached: this process still holds the old modules, and init's one screen needs the TTY;
10
+ // - a checkout is refused typed — it updates by git — and npm's failure is refused with npm's
11
+ // own last word, never a bland "done".
12
+
13
+ import fs from 'node:fs';
14
+ import path from 'node:path';
15
+ import { spawnSync } from 'node:child_process';
16
+
17
+ import { defaultExec } from './harnesses/harness.mjs';
18
+
19
+ export class UpdateError extends Error {
20
+ constructor(code, message, details = {}) {
21
+ super(message);
22
+ this.name = 'UpdateError';
23
+ this.code = code;
24
+ this.details = details;
25
+ }
26
+ }
27
+
28
+ /** A sibling of the node that runs this process — npm ships with node, so this is npm's own home. */
29
+ export function siblingBin(name, { execPath = process.execPath } = {}) {
30
+ return path.join(path.dirname(execPath), name);
31
+ }
32
+
33
+ /** One npm query, refused typed when npm cannot answer it. */
34
+ function npmQuery(exec, npm, args, code) {
35
+ const r = exec.run(npm, args);
36
+ if (r.status !== 0) {
37
+ throw new UpdateError(code, `update refused — \`${npm} ${args.join(' ')}\` failed: ${lastLine(r.stderr) || `exit ${r.status}`}`, { npm, args });
38
+ }
39
+ return r.stdout.trim();
40
+ }
41
+
42
+ /** The new bin, with the terminal attached — init's screen must reach the person. */
43
+ function defaultHandoff(bin, args, { env }) {
44
+ const r = spawnSync(bin, args, { stdio: 'inherit', env });
45
+ return { status: r.status ?? 1 };
46
+ }
47
+
48
+ const lastLine = (text) => String(text ?? '').trim().split('\n').filter(Boolean).at(-1) ?? '';
49
+ const realpathOrSelf = (p) => { try { return fs.realpathSync(p); } catch { return p; } };
50
+
51
+ /**
52
+ * @param {{packageRoot: string, execPath?: string, exec?: {run: Function}, handoff?: Function,
53
+ * env?: NodeJS.ProcessEnv, args?: string[], out?: {write: Function}, tag?: string}} o
54
+ * @returns {{before: string, after: string, initStatus: number}}
55
+ */
56
+ export function runUpdate({
57
+ packageRoot, execPath = process.execPath, exec = defaultExec, handoff = defaultHandoff,
58
+ env = process.env, args = [], out = process.stdout, tag = 'latest',
59
+ }) {
60
+ const readPkg = () => JSON.parse(fs.readFileSync(path.join(packageRoot, 'package.json'), 'utf8'));
61
+ const pkg = readPkg();
62
+ const npm = siblingBin('npm', { execPath });
63
+ const globalRoot = path.join(npmQuery(exec, npm, ['root', '-g'], 'OATHE_UPDATE_NPM_UNAVAILABLE'), ...pkg.name.split('/'));
64
+ if (realpathOrSelf(globalRoot) !== realpathOrSelf(packageRoot)) {
65
+ throw new UpdateError('OATHE_UPDATE_NOT_GLOBAL',
66
+ `update refused — this oathe runs from ${packageRoot}, not from npm's global install `
67
+ + `(${globalRoot}); a checkout updates with git, and \`npm i -g ${pkg.name}@${tag}\` installs the published package`,
68
+ { packageRoot, globalRoot });
69
+ }
70
+ const before = pkg.version;
71
+ out.write(`update: ${pkg.name} ${before} → @${tag} (${npm})\n`);
72
+ const install = exec.run(npm, ['i', '-g', `${pkg.name}@${tag}`]);
73
+ if (install.status !== 0) {
74
+ throw new UpdateError('OATHE_UPDATE_FAILED',
75
+ `update refused — \`npm i -g ${pkg.name}@${tag}\` failed (exit ${install.status}): ${lastLine(install.stderr) || lastLine(install.stdout)}`,
76
+ { status: install.status });
77
+ }
78
+ if (lastLine(install.stdout)) out.write(`update: ${lastLine(install.stdout)}\n`);
79
+ const after = readPkg().version; // npm replaced the files under this same root
80
+ out.write(`update: ${before} → ${after}${after === before ? ' (already current)' : ''} — running init through the new bin\n`);
81
+ // The new bin lives under npm's global prefix — node's directory by default, elsewhere with a
82
+ // custom prefix — never assumed from where node is.
83
+ const prefix = npmQuery(exec, npm, ['prefix', '-g'], 'OATHE_UPDATE_NPM_UNAVAILABLE');
84
+ const init = handoff(path.join(prefix, 'bin', 'oathe'), ['init', ...args], { env });
85
+ return { before, after, initStatus: init.status };
86
+ }