@oathe/oathe 0.0.1 → 0.2.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.
Files changed (71) hide show
  1. package/.claude-plugin/marketplace.json +14 -0
  2. package/LICENSE +202 -21
  3. package/NOTICE +7 -0
  4. package/README.md +104 -12
  5. package/assets/oathe-hero.svg +92 -0
  6. package/bin/oathe.mjs +376 -0
  7. package/docs/PRIVACY.md +45 -0
  8. package/package.json +33 -23
  9. package/plugin/.claude-plugin/plugin.json +10 -0
  10. package/plugin/.mcp.json +13 -0
  11. package/plugin/hooks/frame-note.mjs +24 -0
  12. package/plugin/hooks/heartbeat.mjs +49 -0
  13. package/plugin/hooks/hooks.json +39 -0
  14. package/plugin/hooks/lib.mjs +83 -0
  15. package/plugin/hooks/render-board.mjs +11 -0
  16. package/plugin/skills/oathe-work/SKILL.md +33 -0
  17. package/src/atif.mjs +633 -0
  18. package/src/blocks.mjs +192 -0
  19. package/src/board-render.mjs +106 -0
  20. package/src/config.mjs +169 -0
  21. package/src/context.mjs +35 -0
  22. package/src/doctor.mjs +108 -0
  23. package/src/harness.mjs +271 -0
  24. package/src/init.mjs +92 -0
  25. package/src/launch-env.mjs +25 -0
  26. package/src/launch.mjs +259 -0
  27. package/src/manifest.mjs +89 -0
  28. package/src/mcp/oathe-tools.mjs +517 -0
  29. package/src/paths.mjs +49 -0
  30. package/src/plans.mjs +50 -0
  31. package/src/runtime/discharge.mjs +57 -0
  32. package/src/runtime/provider.mjs +154 -0
  33. package/src/runtime/simple-cage.mjs +67 -0
  34. package/src/runtime/sql-acceptance-lane.mjs +89 -0
  35. package/src/session-host.mjs +81 -0
  36. package/src/substrate.mjs +337 -0
  37. package/src/successor.mjs +31 -0
  38. package/src/traces.mjs +242 -0
  39. package/src/uninstall.mjs +45 -0
  40. package/src/verifier.mjs +322 -0
  41. package/src/workspace.mjs +47 -0
  42. package/vendor/ddl/001_core.sql +312 -0
  43. package/vendor/ddl/002_claim.sql +438 -0
  44. package/vendor/ddl/003_verification.sql +480 -0
  45. package/vendor/ddl/004_delegation.sql +397 -0
  46. package/vendor/ddl/005_escalation.sql +303 -0
  47. package/vendor/ddl/006_dependency.sql +384 -0
  48. package/vendor/ddl/007_assignment.sql +502 -0
  49. package/vendor/ddl/008_effect_receipt.sql +290 -0
  50. package/vendor/ddl/009_verified_edge.sql +452 -0
  51. package/vendor/ddl/010_parent_child_verification.sql +320 -0
  52. package/vendor/ddl/011_confirm.sql +288 -0
  53. package/vendor/ddl/012_evaluator_lane.sql +444 -0
  54. package/vendor/ddl/013_claim_terminal.sql +279 -0
  55. package/vendor/ddl/014_claim_settlement.sql +327 -0
  56. package/vendor/ddl/015_claim_yield.sql +213 -0
  57. package/vendor/ddl/016_reopened_reclaim.sql +285 -0
  58. package/vendor/ddl/017_claim_yield_causes.sql +357 -0
  59. package/vendor/ddl/018_receiptless_unknown.sql +249 -0
  60. package/vendor/ddl/019_verification_contract_freeze.sql +335 -0
  61. package/vendor/ddl/020_context_compilation.sql +105 -0
  62. package/vendor/ddl/021_execution_attempt_closure.sql +95 -0
  63. package/vendor/ddl/022_verification_clause.sql +106 -0
  64. package/vendor/ddl/023_executor_role.sql +66 -0
  65. package/vendor/ddl/024_executor_role_hardening.sql +439 -0
  66. package/vendor/ddl/025_running_attempt_uniqueness.sql +102 -0
  67. package/vendor/ddl/026_acceptance_authority.sql +230 -0
  68. package/vendor/ddl/027_ownership_return.sql +836 -0
  69. package/vendor/ddl/028_attempt_bind_ownership.sql +173 -0
  70. package/vendor/ddl/manifest.json +183 -0
  71. package/index.js +0 -33
@@ -0,0 +1,83 @@
1
+ // oathe plugin hooks — the shared spine. The plugin ships INSIDE the package, so hooks import
2
+ // the package's own modules relatively; ${CLAUDE_PLUGIN_ROOT} only locates the script itself.
3
+ //
4
+ // A hook must NEVER break a session: every entry point runs through failSoft, which turns any
5
+ // substrate absence into a quiet note (SessionStart) or silence (Stop/PreCompact) and exit 0.
6
+
7
+ import { Substrate } from '../../src/substrate.mjs';
8
+ import { buildPaths } from '../../src/paths.mjs';
9
+ import { workspaceRef } from '../../src/workspace.mjs';
10
+ import { OatheConfig } from '../../src/config.mjs';
11
+ import { harnessForTracePath } from '../../src/traces.mjs';
12
+ import { launchedHarness } from '../../src/launch-env.mjs';
13
+
14
+ /** The hook's JSON input on stdin (Claude and Codex both deliver {cwd, hook_event_name, …}). */
15
+ export async function readHookInput() {
16
+ let raw = '';
17
+ for await (const chunk of process.stdin) raw += chunk;
18
+ try { return JSON.parse(raw); } catch { return {}; }
19
+ }
20
+
21
+ export function buildHookContext(input, env = process.env) {
22
+ const paths = buildPaths(env);
23
+ const cwd = input.cwd || process.cwd();
24
+ const config = new OatheConfig({ env, cwd });
25
+ // The session identity both harnesses hand every hook — the trace linkage rides on it.
26
+ const session = input.session_id
27
+ ? {
28
+ sessionId: input.session_id,
29
+ transcriptPath: input.transcript_path ?? null,
30
+ harness: harnessForTracePath(input.transcript_path ?? ''),
31
+ }
32
+ : null;
33
+ return {
34
+ session,
35
+ substrate: new Substrate({ database: config.get('db'), paths, env, config }),
36
+ workspace: workspaceRef(cwd),
37
+ identity: {
38
+ orgId: config.get('org'),
39
+ principalId: config.get('principal') || env.USER || 'operator',
40
+ department: config.get('department'),
41
+ },
42
+ config,
43
+ cwd,
44
+ };
45
+ }
46
+
47
+ /**
48
+ * The SessionStart hook's JSON frame: `context` reaches the MODEL as additional context,
49
+ * `message` is the line the USER sees when the session loads — the visible confirmation that
50
+ * oathe is watching this folder.
51
+ */
52
+ export function emitSessionStart({ context, message }) {
53
+ process.stdout.write(`${JSON.stringify({
54
+ hookSpecificOutput: { hookEventName: 'SessionStart', additionalContext: context },
55
+ systemMessage: message,
56
+ })}\n`);
57
+ }
58
+
59
+ /**
60
+ * Run `fn`; on any failure print `quietNote` (when given) as a visible session-load line and
61
+ * exit 0 regardless. The board being unavailable is information for the session, never an
62
+ * error that blocks it.
63
+ */
64
+ export async function failSoft(fn, { quietNote = null } = {}) {
65
+ // The opt-in gate: the plugin reaches every session on the machine, but only a session the
66
+ // oathe launcher started carries the marker. Everything else is a silent noop — no output,
67
+ // no substrate contact — because that session never asked to be on the board.
68
+ if (!launchedHarness()) process.exit(0);
69
+ let substrate = null;
70
+ try {
71
+ const input = await readHookInput();
72
+ const ctx = buildHookContext(input);
73
+ substrate = ctx.substrate;
74
+ await fn(ctx, input);
75
+ } catch (e) {
76
+ const detail = String(e?.message || e);
77
+ if (quietNote) emitSessionStart({ context: quietNote, message: `${quietNote} (${detail.slice(0, 120)})` });
78
+ process.stderr.write(`oathe hook: ${detail}\n`);
79
+ } finally {
80
+ if (substrate) await substrate.close().catch(() => {});
81
+ }
82
+ process.exit(0);
83
+ }
@@ -0,0 +1,11 @@
1
+ // SessionStart — the board, delivered twice over: the full list as additional context for the
2
+ // MODEL, and one visible line for the USER. The rendering itself lives in src/board-render.mjs,
3
+ // shared with the launcher (which prints the same board into scrollback before the TUI starts).
4
+
5
+ import { failSoft, emitSessionStart } from './lib.mjs';
6
+ import { renderBoard } from '../../src/board-render.mjs';
7
+
8
+ await failSoft(async ({ substrate, workspace, identity, config }) => {
9
+ const { context, message } = await renderBoard({ client: substrate, identity, workspace, config });
10
+ emitSessionStart({ context, message });
11
+ }, { quietNote: 'Oathe board unavailable — substrate not initialized; run `oathe init`' });
@@ -0,0 +1,33 @@
1
+ ---
2
+ name: oathe-work
3
+ description: Use when working in a workspace with an Oathe board (the SessionStart context shows one) — before starting any substantive task, when reporting progress, when picking prior work back up, and when stopping. Claims are speech acts recorded in the cell substrate via the oathe_* MCP tools.
4
+ ---
5
+
6
+ # Working the Oathe board
7
+
8
+ The board in this session's opening context is the durable record of this folder's work.
9
+ The substrate refuses dishonesty by construction — work with it, not around it.
10
+
11
+ ## The loop
12
+
13
+ 1. **Claim before you build.** Substantive work starts with `oathe_claim {task_id, objective}`.
14
+ A claim takes responsibility; it never mints the work as done. A task without a real plan
15
+ is honestly `plan_status: "unknown"` — never fabricate one.
16
+ 2. **Statements as you go.** Record findings and progress with
17
+ `oathe_statement {task_id, proposition, evidence_ref}`. A statement is a statement, not
18
+ truth — nothing settles by saying it.
19
+ 3. **Pick up, don't re-derive.** When the user says "continue <task>" (or the board shows a
20
+ lease of yours), call `oathe_pickup {task_id}`: the successor sequence returns the compiled
21
+ frame for the obligation. The obligation, not the conversation, is what comes back.
22
+ 4. **Say done when it is done.** Finished work closes with
23
+ `oathe_done {task_id, proposition, evidence_ref}` — a completion statement plus the
24
+ substrate's own terminal. Completion is ASSERTED, not settled: verification is still owed.
25
+ 5. **Yield what you cannot finish.** Stopping without finishing means
26
+ `oathe_yield {task_id, note}` — the task goes back on the board, unowned, with a declared
27
+ cause. Walking away silently leaves a lease to expire, which the board will show.
28
+
29
+ ## Refusals are the product
30
+
31
+ A second claimant is refused. A statement against no claim is refused. A yield without a
32
+ declared cause is refused. When a tool returns a typed error, report it faithfully — do not
33
+ retry blindly and do not soften it into success.