@primitive.ai/prim 0.1.0-alpha.11 → 0.1.0-alpha.110

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 (48) hide show
  1. package/README.md +450 -38
  2. package/SKILL.md +366 -0
  3. package/dist/chunk-2IRLFOEL.js +766 -0
  4. package/dist/chunk-2Q3OGSTV.js +164 -0
  5. package/dist/chunk-43ZKL27W.js +258 -0
  6. package/dist/chunk-4GLVJLEQ.js +55 -0
  7. package/dist/chunk-5BLGBSDM.js +233 -0
  8. package/dist/chunk-5LRKJTLA.js +155 -0
  9. package/dist/chunk-7VIMU2HR.js +209 -0
  10. package/dist/chunk-AOJ254C2.js +511 -0
  11. package/dist/chunk-CTRAJCPN.js +964 -0
  12. package/dist/chunk-EZXEWFDG.js +210 -0
  13. package/dist/chunk-GA2RXPJL.js +168 -0
  14. package/dist/chunk-HTRFPXMD.js +135 -0
  15. package/dist/chunk-IQZA65NV.js +1871 -0
  16. package/dist/chunk-JJI7FU24.js +439 -0
  17. package/dist/chunk-KGBMU76T.js +175 -0
  18. package/dist/chunk-KQ4WBK5R.js +262 -0
  19. package/dist/chunk-NH3VC7YO.js +264 -0
  20. package/dist/chunk-OYHYCK4K.js +13 -0
  21. package/dist/chunk-PO5QAYD7.js +1499 -0
  22. package/dist/chunk-UDBBJWQH.js +20383 -0
  23. package/dist/chunk-W4ZEPZLK.js +36 -0
  24. package/dist/chunk-XG7S3LIL.js +1372 -0
  25. package/dist/daemon/server.js +24051 -0
  26. package/dist/hook-runtime/daemon/server.js +24051 -0
  27. package/dist/hook-runtime/hooks/post-commit.js +21524 -0
  28. package/dist/hook-runtime/hooks/post-rewrite.js +21423 -0
  29. package/dist/hook-runtime/hooks/post-tool-use.js +28917 -0
  30. package/dist/hook-runtime/hooks/pre-commit.js +1657 -0
  31. package/dist/hook-runtime/hooks/pre-tool-use.js +28425 -0
  32. package/dist/hook-runtime/hooks/prim-hook.js +28977 -0
  33. package/dist/hook-runtime/hooks/session-end.js +1176 -0
  34. package/dist/hook-runtime/hooks/session-start.js +31553 -0
  35. package/dist/hook-runtime/index.js +59630 -0
  36. package/dist/hook-runtime/statusline-main.js +886 -0
  37. package/dist/hooks/post-commit.js +196 -0
  38. package/dist/hooks/post-rewrite.js +205 -0
  39. package/dist/hooks/post-tool-use.js +292 -0
  40. package/dist/hooks/pre-commit.js +15 -108
  41. package/dist/hooks/pre-tool-use.js +470 -0
  42. package/dist/hooks/prim-hook.js +242 -0
  43. package/dist/hooks/session-end.js +64 -0
  44. package/dist/hooks/session-start.js +309 -0
  45. package/dist/index.js +10651 -427
  46. package/dist/statusline-main.js +886 -0
  47. package/package.json +41 -16
  48. package/dist/chunk-3APLWTLB.js +0 -165
package/README.md CHANGED
@@ -1,13 +1,24 @@
1
1
  # @primitive.ai/prim
2
2
 
3
- The official CLI for [Primitive](https://getprimitive.ai). Manage specs, contexts, projects, and git hooks from the command line.
3
+ The official CLI for [Primitive](https://getprimitive.ai)'s **decision graph**. It
4
+ passively captures the decisions your team makes while coding and reports team
5
+ presence — from the command line and via session + git hooks.
4
6
 
5
7
  > [!WARNING]
6
8
  > This project is in **alpha**. Commands and APIs may change between releases.
7
9
 
10
+ > [!NOTE]
11
+ > **Conflict Gates** check each edit against the decision graph and surface any
12
+ > load-bearing decision it conflicts with. When **Enforcement** is enabled for your
13
+ > organization, gates can warn, pause, or block a conflicting edit until you reconcile
14
+ > the decision and retry. Automatic decision capture in active repositories is separate.
15
+
8
16
  ## Installation
9
17
 
10
- Requires Node.js 20+.
18
+ Requires Node.js 22.23.4+, 24.22.1+, or 26.12.1+ within those major versions.
19
+ Node.js 20 is no longer supported. After updating Node.js, restart the daemon
20
+ with `prim daemon restart` and rerun your agent's `prim <agent> install` command
21
+ and `prim hooks install` to repin their runtimes to the updated executable.
11
22
 
12
23
  ```bash
13
24
  npm install -g @primitive.ai/prim
@@ -19,21 +30,129 @@ Or run directly without installing:
19
30
  npx @primitive.ai/prim
20
31
  ```
21
32
 
33
+ In commands such as `npx --yes @primitive.ai/prim@latest ...`, the first `--yes`
34
+ belongs to **npm**: it skips npm's package-install confirmation. It does not approve a
35
+ Primitive action. Prim's own global `--yes` comes after the package name, for example
36
+ `npx --yes @primitive.ai/prim@latest --yes decisions create ... --attribution user`,
37
+ and applies only to that Prim invocation.
38
+
22
39
  ## Quick Start
23
40
 
41
+ One command does the whole install — auth, session hooks, daemon, git hooks,
42
+ skill, and the welcome:
43
+
24
44
  ```bash
25
- # Authenticate via browser (WorkOS OAuth)
45
+ prim setup # add --agent cursor, codex, or hermes; --no-daemon explicitly opts out
46
+ ```
47
+
48
+ After successful setup, the optional **author story** puts you in a new engineer's
49
+ shoes in a disposable project:
50
+
51
+ ```text
52
+ Implement CSV export → Your earlier Decision blocks email → Accept or Supercede
53
+ → Real outcome email
54
+ ```
55
+
56
+ Enter the feature prompt in the same agent chat. The real semantic evaluator checks
57
+ it against your private, fictional prior Decision. Choose a name-only export or
58
+ approve the displayed replacement with your own short reason. A real email explains
59
+ what your Decision protected or why it changed. Continue once that email is queued;
60
+ queued and provider-accepted do not mean delivered to your inbox.
61
+
62
+ The compact diagrams and actual file evidence live in each JSON `presentation`.
63
+ Your agent renders them once. After owned-file cleanup, participants without real
64
+ Decisions enter the existing individually approved creation flow. Existing Decisions
65
+ remain intact; unavailable history is not treated as an empty graph.
66
+
67
+ Use `prim setup --skip-demo` to remember a skip, or
68
+ `prim demo --agent <claude|codex|cursor|hermes>` to replay. Direct terminal `prim demo`
69
+ uses the same prompts. Setup defaults to compact diagnostics; `prim setup --details`
70
+ shows full child output. Default agent setup returns one JSON result with `welcome`,
71
+ `onboarding`, and its `nextAction`. Existing completed tours do not replay automatically.
72
+
73
+ Agent hooks must acknowledge isolation before any sample is shown. Passive capture
74
+ then stays excluded for this session, including resumes; start a new session to
75
+ resume it. Other sessions, real-work enforcement and explicitly approved real
76
+ Decision creation remain available. Synthetic records never join the team's graph.
77
+ This exercises a real evaluator and demo-only blocking policy, not native production
78
+ Enforcement or live ingestion. Backend/email unavailability leaves the optional
79
+ story pending while successful setup remains successful.
80
+
81
+ Or run the steps individually:
82
+
83
+ ```bash
84
+ # 1. Authenticate via browser (WorkOS OAuth)
26
85
  prim auth login
27
86
 
28
- # List your specs
29
- prim spec list
87
+ # 2. Wire the session hooks (decision capture + presence)
88
+ prim claude install # or: prim cursor install / prim codex install / prim hermes install
89
+
90
+ # 3. Start the companion daemon (latency + team presence)
91
+ prim daemon start
30
92
 
31
- # Install the pre-commit hook
93
+ # 4. Install the git hooks (pre-commit decision check + post-commit capture)
32
94
  prim hooks install
33
95
  ```
34
96
 
97
+ `prim setup` (and `prim claude preauth`) also pre-authorize prim so an agent's own
98
+ calls never stall on a permission prompt: a scoped `Bash(npx --yes @primitive.ai/prim*)`
99
+ allow-rule for default mode (it covers both the `@latest` onboarding form and the bare
100
+ day-to-day form), plus an `autoMode.environment` trust line so auto mode's safety
101
+ classifier treats prim as trusted tooling rather than untrusted downloaded code.
102
+
103
+ ### Set up with your coding agent
104
+
105
+ Paste this into Claude Code (or any coding agent). The command is in **your** message,
106
+ so the agent runs it directly — instead of fetching a doc and executing a command from
107
+ it, which an auto-mode safety classifier blocks as untrusted-origin code:
108
+
109
+ ```text
110
+ Install the Primitive CLI and activate passive decision capture for this repository: run `npx --yes @primitive.ai/prim@latest setup` and show concise progress plus actionable warnings. Drive setup and its onboarding nextAction yourself; I'll handle browser authorization and any hook-trust review the agent requires. This request authorizes setup's built-in activation of this repository and an idempotent retry of that step, but not activation in another repository or creation of a Decision. If enable or health fails, surface the actual error; do not claim fresh activation approval is required. Then show me the welcome.
111
+ ```
112
+
113
+ That single command runs the whole install and current-repository activation in one
114
+ process (auth → session hooks → daemon → skill → activate this repository and wire its git hooks → welcome). The detailed
115
+ step-by-step the agent follows — and the manual fallback — live in
116
+ [`setup.md`](./setup.md).
117
+
35
118
  ## Commands
36
119
 
120
+ ### Setup
121
+
122
+ ```bash
123
+ prim setup # Run the whole install in one shot
124
+ prim setup --agent cursor # Same, for Cursor IDE and Cursor CLI
125
+ prim setup --agent codex # Same, for OpenAI Codex
126
+ prim setup --agent hermes # Same, for Hermes Agent (global-only config)
127
+ prim setup --no-daemon # Stop it and persistently opt out of supervised delivery
128
+ prim setup --global-hooks-path # Also route every repository's git hooks through prim
129
+ ```
130
+
131
+ Orchestrates auth → session hooks → supervised daemon → git hooks (`--scope project`, or `--global-hooks-path`) → skill → activate this repo (which wires its git hooks) → capture-health gate → welcome,
132
+ re-running each underlying command so every step behaves exactly as if run by
133
+ hand (including the browser login). Idempotent — safe to re-run.
134
+
135
+ Setup wires the current repository's git hooks and never changes git's global
136
+ config on its own: a global `core.hooksPath` reroutes every repository on the
137
+ machine. Pass `--global-hooks-path` to opt in; `prim --yes setup` does not.
138
+
139
+ ### Uninstall
140
+
141
+ ```bash
142
+ prim uninstall
143
+ ```
144
+
145
+ Stops the companion daemon, removes the current repository's Prim-owned agent
146
+ and Git-hook surfaces when run inside a Git repository, removes the user-scoped
147
+ Claude, Cursor, Codex, Hermes, and Git-hook surfaces, then deletes only schema-valid
148
+ Prim runtime bytes. Foreign configuration is retained; ambiguous ownership
149
+ makes the command fail closed and retain the runtimes. If a removal races or
150
+ fails after one runtime changes, its JSON result reports each runtime's exact
151
+ state so rerunning can safely finish cleanup. Authentication,
152
+ undelivered journals, repository bindings, and agent skill guidance are kept.
153
+ Use `prim skill uninstall --agent <claude|cursor|codex|hermes> --scope <project|user>`
154
+ when you also want to remove a known skill target.
155
+
37
156
  ### Auth
38
157
 
39
158
  ```bash
@@ -41,59 +160,352 @@ prim auth login # Authenticate via browser
41
160
  prim auth set-token <token> # Save a bearer token (e.g. for CI)
42
161
  prim auth clear # Remove saved tokens
43
162
  prim auth status # Check authentication status
163
+ prim auth api-keys mint --name <name> [--expires-at <epoch-ms>] # Mint a user key; secret prints once
164
+ prim auth api-keys list [--limit <count>] [--after <api-key-id>] # List user-key metadata
165
+ prim auth api-keys revoke <api-key-id> # Revoke a user key
166
+ ```
167
+
168
+ ### GitHub
169
+
170
+ ```bash
171
+ prim github connect # Install or reuse the Primitive GitHub App for this checkout
172
+ prim github connect --no-browser # Print the installation URL without opening it
173
+ ```
174
+
175
+ The command first reuses existing repository access. When access is missing, it creates a
176
+ server-owned GitHub App installation intent, opens its installation URL unless browser opening is
177
+ suppressed, polls the same intent, then verifies and persists this checkout's binding. A completed
178
+ installation without admin access to this repository remains truthfully unbound.
179
+
180
+ ### Session integration
181
+
182
+ Wires the agent's session hooks so the decisions you make are captured into the
183
+ graph, and presence is reported. Each hook
184
+ self-resolves the CLI at run time (PATH, then a local install, then
185
+ `npx --yes @latest`), so it keeps working with no global install.
186
+
187
+ Installs into the current project by default — the repo's `.claude/settings.json`
188
+ or `.cursor/hooks.json`, resolved from the git root (so any subdirectory works);
189
+ pass `--scope user` to install machine-wide. Codex defaults to user scope
190
+ (`~/.codex/hooks.json`): Codex reads a project `.codex/hooks.json` only from the
191
+ checkout it lives in and trusts it by absolute path, so a project install covers
192
+ that checkout only, not the repo's other worktrees. Hermes is the exception: it reads
193
+ shell hooks only from the global `~/.hermes/config.yaml`, so `prim hermes install`
194
+ is always user-scoped — and prim merges in place, leaving the rest of that file
195
+ (providers, models, your own hooks) untouched.
196
+
197
+ ```bash
198
+ prim claude install # Install Claude Code hooks (project scope; uninstall / status)
199
+ prim claude install --scope user # Install machine-wide instead
200
+ prim cursor install # Install native Cursor hooks (project scope)
201
+ prim cursor install --scope user # Install hooks, skill, and CLI footer machine-wide
202
+ prim codex install # Install OpenAI Codex hooks (user scope; --scope project for this checkout only)
203
+ prim hermes install # Install Hermes Agent hooks (global ~/.hermes/config.yaml)
204
+ ```
205
+
206
+ Passive capture is repo-scoped even when these integrations are installed at user
207
+ scope. `prim enable` marks the current Git repo active; `prim disable` makes it
208
+ inactive. A project-scoped install activates its repo automatically. In an inactive
209
+ repo, session content is not passively captured. Here “inactive” means Prim's normal
210
+ effective capture check is false, including an explicit local `prim.active=false`.
211
+
212
+ An agent may still deliberately record one Decision from an inactive repo with
213
+ `prim decisions create`, but each invocation needs its own user approval. An explicit
214
+ request such as “record this Decision” supplies that approval for that one create; for
215
+ a proactive suggestion, the agent must show the proposed Decision and ask first. The
216
+ agent then passes Prim's global `--yes` for that invocation. This one-time approval does
217
+ not activate passive capture, and neither npm's `npx --yes`, setup approval, nor an
218
+ earlier create counts as approval for another Decision.
219
+
220
+ When a person runs `prim decisions create` interactively in an inactive repo, Prim
221
+ asks for that one-time approval itself. In non-interactive use it creates nothing
222
+ unless Prim's global `--yes` is present.
223
+
224
+ #### Claude decision feedback
225
+
226
+ Claude Code receives eventual, human-visible feedback when automatic capture
227
+ creates a `change` Decision. A later Claude `Stop` or fresh
228
+ `SessionStart` in the same Git worktree can display:
229
+
230
+ ```text
231
+ [prim] response → created Decision (dec_a1b2c3d4): Use the stable API (https://app.getprimitive.ai/decisions/r571n1dqjdrtyxxpf0fnzee4gn8aed6q)
44
232
  ```
45
233
 
46
- ### Specs
234
+ An author-private draft uses an actionable publish prompt instead:
47
235
 
48
- Specs are documents that drive implementation. They can be synced to a project DAG and mapped to file patterns for automatic pre-commit hook integration.
236
+ ```text
237
+ [prim] publish this Decision draft (dec_a1b2c3d4)? Use the stable API (https://app.getprimitive.ai/decisions/r571n1dqjdrtyxxpf0fnzee4gn8aed6q) Run `prim decisions publish decision-full-1` to share it with your team.
238
+ ```
239
+
240
+ This is a hook `systemMessage` for the person using Claude Code; it is not
241
+ injected into the model's context. Delivery is at-least-once at the stdout
242
+ handoff boundary: prim acknowledges only after writing the hook response, so a
243
+ failed acknowledgment can show the same notification again. Notifications are
244
+ eligible for 24 hours. The originating session gets limited preference, but any
245
+ concurrent Claude session in the same worktree may consume the backlog. A hook
246
+ claims at most 40 notifications and renders at most 8,000 Unicode code points;
247
+ `hasMore` work is left for a later Stop or SessionStart rather than extending
248
+ the current hook.
249
+
250
+ Worktree scope comes from an opaque UUID stored under the worktree's Git
251
+ metadata (equivalent to `git rev-parse --git-path prim/workspace-id`), never an
252
+ absolute repository path. Linked worktrees receive distinct IDs, moving a
253
+ worktree preserves its ID, and a clone creates a new one. A corrupt or
254
+ unwritable identity is never silently replaced: capture falls back to the
255
+ legacy envelope. Disable/uninstall does not delete the identity.
256
+
257
+ Feedback uses the invoking CLI's credentials for direct HTTPS calls rather
258
+ than the daemon, avoiding cross-organization token ambiguity. One absolute
259
+ three-second in-process budget covers token refresh, lease, parsing, rendering,
260
+ and acknowledgment. This is not a hard three-second wall clock: it cannot
261
+ preempt shell/PATH or `npx` resolution, Node startup, Claude's own hook
262
+ scheduling, or synchronous filesystem work. The Git fallback has a separate
263
+ short timeout.
264
+
265
+ Alternatives considered:
266
+
267
+ | Option | Benefit | Limitation |
268
+ | --- | --- | --- |
269
+ | Existing hooks + direct HTTPS (current) | No new install surface; uses the invoking credentials | In-process budget is not a host-enforced wall clock |
270
+ | Claude's native hook timeout | Host-enforced termination | Settings migration; may kill a cold `npx` startup |
271
+ | Daemon routing | Lower steady-state latency | Daemon token/org may not match a concurrent session |
272
+ | Dedicated feedback binary | Lower startup overhead | New distribution and install migration |
273
+ | Synchronous pre-Stop classification | Stronger same-turn immediacy | Adds model latency and cost to the hook path |
274
+ | Detached delivery | Does not block Stop | Cannot return the current hook's `systemMessage` |
275
+
276
+ Run `prim claude status` to verify both existing feedback handlers are installed
277
+ and `prim doctor` to inspect server capability. No new
278
+ hook registration or binary is required when upgrading an existing correct
279
+ installation.
280
+
281
+ ### Daemon
282
+
283
+ A supervised long-lived companion process that continuously drains captured
284
+ Moves, accelerates decision-graph reads, and powers the "team: N online"
285
+ presence count. `prim setup` requires it to be live on the current version with
286
+ an authenticated, healthy heartbeat unless the explicit `--no-daemon` opt-out is
287
+ supplied. Hooks still fail soft if it later degrades.
288
+
289
+ `prim daemon start` (and `restart`/`ensure`) does not gate on delivery. While
290
+ Moves are past the 30s delivery SLA it reports them as draining in the
291
+ background when the daemon's last sweep recorded no failure, or when the drains
292
+ that failed acknowledged Moves before failing; another bucket delivering in the
293
+ same sweep does not count. Journal buckets the daemon holds back (unbound,
294
+ another organization, identity unavailable) read as delivery held back, and a
295
+ failure with no progress reads as delivery failing; both are a ⚠ warning,
296
+ still exit 0. Its JSON adds `draining`, `deliveryRetained`, `deliveryFailing`,
297
+ and `ingestion` in those states. Start's JSON `healthy` means the start
298
+ succeeded, so it can differ from `daemon status --json`, which stays degraded
299
+ until the backlog drains. Setup's own health check reports a backlog the
300
+ daemon is draining as a warning and fails on held-back buckets and on failures
301
+ recorded without progress; standalone `prim doctor` still fails a missed SLA.
49
302
 
50
303
  ```bash
51
- prim spec list # List all specs
52
- prim spec list --project-id <id> # Find spec for a root project
53
- prim spec get <id> # Show spec details
54
- prim spec get <id> --text-only # Print raw spec text
55
- prim spec update <id> --file spec.md # Update spec from file
56
- prim spec update <id> --name "New" # Rename a spec
57
- prim spec sync <id> # Trigger spec-to-project sync
58
- prim spec map <id> -p "src/auth/**" # Map file patterns to a spec
59
- prim spec unmap <id> # Clear all file patterns
60
- prim spec unmap <id> -p "src/auth/**" # Remove specific pattern
61
- prim spec auto-map <id> # Auto-detect file patterns
304
+ prim daemon start # start (stop / restart / status)
62
305
  ```
63
306
 
64
- ### Contexts
307
+ Ordinary commands may upgrade an older daemon in the background. When an
308
+ installed CLI runs an attended, allowlisted command (for example `auth`,
309
+ `decisions`, `moves`, `skill`, or an agent's `install`/`status`) on macOS and
310
+ finds the launchd daemon on an older version, or on its own version but unable
311
+ to run (say, after a Node upgrade deleted the binary it pinned), it starts a
312
+ detached `prim daemon ensure`, at most once an hour whatever version it
313
+ targets. It never downgrades, never repoints the daemon at another deployment
314
+ or config root, and never runs from hooks or their background drains, `daemon`,
315
+ `doctor`, `setup` or its steps, `auth clear`, removal commands, a development
316
+ checkout, or as root. Set `PRIM_DAEMON_DRIFT_HEAL=0` to turn it off.
317
+
318
+ ### Decisions
319
+
320
+ Read and respond to the decision graph.
321
+
322
+ ```bash
323
+ prim decisions recent # Recent decisions feed (--author <name> for one teammate's)
324
+ prim decisions show <id> # Drill into one decision
325
+ prim decisions cascade <id> # Blast radius of a decision
326
+ prim decisions check --files <…> # Active decisions referencing files (warn-only)
327
+ prim decisions confirm <id> # Answer a rationale-confirmation prompt
328
+ prim decisions create --intent <…> --attribution <user|agent> # Record with explicit origin
329
+ prim decisions link <child> --on <parent> # Relate: <child> depends on <parent>
330
+ prim decisions unlink <child> --on <parent> # Remove that dependency
331
+ ```
332
+
333
+ `<id>` accepts a full decision ID or its short ID. STDOUT is machine-readable
334
+ JSON; human-readable status goes to STDERR.
335
+
336
+ `decisions check` uses the checkout's current Primitive repository binding and
337
+ Git branch. Paths are relative to the repository root, including from a
338
+ subdirectory; paths for files that do not exist yet are supported. Discovery
339
+ includes exact file, directory, glob, and repository scopes and applies each
340
+ Decision's effective window and audience. It does not run the Conflict Gate.
341
+ Missing bindings, older servers that cannot confirm repository-scoped discovery,
342
+ and bounded partial results report `unavailable` or `truncated`; they are not a
343
+ verified empty result. Reconnect a missing or stale binding with `prim enable`.
344
+
345
+ When passive capture is inactive in the current repo, an approved one-time create is:
346
+
347
+ ```bash
348
+ npx --yes @primitive.ai/prim@latest --yes decisions create --intent "…" --attribution user
349
+ ```
350
+
351
+ Here npm's first `--yes` only permits package resolution; Prim's second `--yes`
352
+ confirms this create. It does not enable the repo or authorize a later create.
353
+
354
+ Every create requires `--attribution user|agent`. Use `user` only when the person
355
+ directly stated, selected, or confirmed the exact recorded choice. Use `agent` when
356
+ the agent introduced that exact choice while pursuing a broader request. A broad task
357
+ prompt or permission to implement does not make the resulting agent choice a user
358
+ Decision. If the origin is ambiguous, confirm the exact choice with the person before
359
+ creating it; do not guess.
360
+
361
+ `link` / `unlink` curate the dependency edges the automatic linker would otherwise
362
+ own — `<child>` depends on `<parent>`. Both are idempotent and refuse any link that
363
+ would create a cycle (exit 2); an unresolved id exits 4.
364
+
365
+ ### Reconcile
65
366
 
66
367
  ```bash
67
- prim context list # List all contexts
68
- prim context list --scope project # Filter by scope
69
- prim context list --project-id <id> # List contexts for a project
70
- prim context get <id> # Get context details
71
- prim context create -s project -n "Name" # Create a context
72
- prim context create -s project -n "Name" --file path/to/file
73
- prim context update <id> --name "New" # Update a context
74
- prim context delete <id> # Delete a context
75
- prim context link <id> --project <pid> # Link context to project
76
- prim context unlink <id> --project <pid> # Unlink context from project
368
+ prim reconcile <id> # Mint a single-use bypass for a decision Conflict Gates flagged
77
369
  ```
78
370
 
79
- ### Projects
371
+ Record what happened after resolving a specific conflict:
80
372
 
81
373
  ```bash
82
- prim project create -n "Project name" # Create a project
83
- prim project create -n "Project name" -d "Description" # Create with description
84
- prim project create -n "Project name" --spec <contextId> # Create and link a spec
374
+ prim reconcile <id> --check <checkId> --outcome followed
375
+ prim reconcile <id> --check <checkId> --outcome superseded
85
376
  ```
86
377
 
378
+ Use `followed` when you retained the Decision. Use `superseded` only after a
379
+ replacement Decision has been persisted with `prim decisions supersede`.
380
+ The conflict output supplies the check ID. Only the person whose edit was
381
+ checked can resolve that check. Repeating the same outcome is safe; changing an
382
+ already recorded outcome is rejected. These declarations do not issue a bypass.
383
+
384
+ Without `--check` and `--outcome`, when Conflict Gates **Enforcement** is enabled
385
+ for your organization, `prim reconcile <id>` authorizes one retry for the named decision.
386
+
87
387
  ### Hooks
88
388
 
89
389
  ```bash
90
- prim hooks install # Install pre-commit hook
91
- prim hooks uninstall # Remove pre-commit hook
390
+ prim hooks install # Wire the pre-commit, post-commit, and post-rewrite hooks
391
+ prim hooks install --scope user --global-hooks-path # Route every repository through prim (exits 3, with the reason on STDERR, if it installs nothing; 1 if prim's hook runtime is not staged)
392
+ prim hooks snippet post-commit # Print the block that wires one hook, to place by hand
393
+ prim hooks uninstall # Remove prim's blocks (and any hook file prim created)
92
394
  ```
93
395
 
94
- The pre-commit hook automatically syncs specs when you commit changes to files matching a spec's file patterns (configured via `prim spec map`).
396
+ The pre-commit hook checks staged files against the live decision graph
397
+ (warn-only — it never blocks the commit). The post-commit and post-rewrite hooks
398
+ record each commit and each amend/rebase as capture boundaries for
399
+ classification. All three act only in repos where prim is active (`prim enable`).
400
+ Supports [Husky](https://typicode.github.io/husky/) — `prim hooks install`
401
+ detects Husky and offers to install into `.husky/`.
402
+
403
+ Each hook file gets one short block, inserted right after the shebang so it runs
404
+ before any `exit` or `exec`. The block names no version and no machine path: it
405
+ runs prim's staged entrypoint (`~/.config/prim/prim-git-hook-v1`) and does
406
+ nothing on a machine without prim, so a tracked `.husky/*` file never changes
407
+ across prim releases. `prim enable` and `prim hooks install` write it once and
408
+ never move or rewrite a current block, reformatted or not. Agent session hooks
409
+ only repair Git-private hook files under `.git` and prim's own hooks dir, and
410
+ never add the pre-commit check. prim never edits a hooks dir outside the
411
+ repository, such as a global `core.hooksPath` every repository shares, unless
412
+ you run `prim hooks install --scope user --global-hooks-path` or answer yes at
413
+ its terminal prompt. In a Husky v8 hook the block goes
414
+ after the `husky.sh` line, so it runs once and honors `HUSKY=0`. `prim doctor`
415
+ only reports; it never rewrites a hook.
416
+
417
+ `prim doctor` also checks evidence rather than file contents: each post-commit
418
+ run that reaches prim leaves a stamp in the checkout's git dir, and doctor's
419
+ `hook-fired` check fails when a local commit made since the hooks were wired
420
+ never reached prim. That catches an `exit` before prim's block, hand wiring
421
+ that broke, or a git client whose environment cannot find prim. The check
422
+ applies in manual mode too: once a repository is enabled, doctor expects your
423
+ own wiring to reach prim. `prim disable` ends the expectation, so commits made
424
+ while disabled are never judged. Turning prim off with `git config prim.active
425
+ false` directly ends it too, once an agent session starts while it is off; if
426
+ doctor still flags a commit made while it was off, run `prim disable` then
427
+ `prim enable`.
428
+
429
+ To wire the hooks yourself (lefthook, a custom Husky layout, …), run
430
+ `git config prim.gitHooks manual` (or `--global`) first: prim then never writes
431
+ a hook file. That setting is the only signal prim honors. It does not guess
432
+ from a hook that already mentions prim, so without it, `prim enable` adds its
433
+ block. Paste the block from `prim hooks snippet <hook>`, or have your hook
434
+ manager run `~/.config/prim/prim-git-hook-v1 <hook> "$@"` (post-rewrite also
435
+ needs Git's stdin).
436
+
437
+ ### Presence statusline
438
+
439
+ ```bash
440
+ prim statusline # Render the team-presence statusline (reads the daemon)
441
+ ```
442
+
443
+ Claude Code and Cursor CLI each have one custom status-line slot. Their user-scope
444
+ installations use a staged, lightweight Primitive renderer when that slot is empty
445
+ or already Primitive's; an existing custom status line is preserved even with
446
+ `--force` and reported explicitly. Cursor's Primitive footer replaces Cursor's
447
+ default footer and requires a Cursor CLI restart after installation or removal. Use
448
+ `prim daemon status` or `prim doctor` for the same health signal in that case.
449
+
450
+ ### Welcome
451
+
452
+ ```bash
453
+ prim welcome # Brief orientation to the decision graph (shown after setup)
454
+ ```
455
+
456
+ ### Session & journal
457
+
458
+ Lower-level plumbing for the capture pipeline — org binding and the local move
459
+ journal. Capture works automatically once the session hooks are installed **and the
460
+ repo is active**; these are for inspecting and steering it (e.g. multi-org machines).
461
+
462
+ ```bash
463
+ prim session start <id> # Pin a Claude Code session to an org (list / drop <id>)
464
+ prim moves bind # Pin the current directory to an org via .prim/workspace.json (drop)
465
+ prim moves status # Per-bucket pending stats for the local journal
466
+ prim moves tail # Pretty-print recent journal entries
467
+ prim moves flush # Drain the local journals to the server (also runs from hooks)
468
+ ```
469
+
470
+ Any other command except `uninstall` and a `setup` that starts the daemon (or
471
+ one of its steps) that finds Moves waiting over a minute (or cannot tell how
472
+ long) hands them to a detached background `prim moves flush` and never waits for
473
+ it. It starts none while a live daemon on the same version and deployment, with
474
+ a healthy heartbeat and no recorded ingestion failure, already owns the drain.
475
+
476
+ Move uploads include `X-Prim-Uploader-Version` (the uploader process's version)
477
+ and `X-Prim-Client-Instance-Id` (the opaque installation ID also used by presence
478
+ heartbeats). These let server traces distinguish the uploader from the version
479
+ that originally captured a replayed move. The ID is stored in
480
+ `client_instance_id` under the Prim config directory (`~/.config/prim` by default,
481
+ or `PRIM_CONFIG_DIR` / `XDG_CONFIG_HOME/prim`). Compare that file with the trace's
482
+ `uploaderClientInstanceId` to correlate an installation; it contains no hostname.
483
+ If the identity cannot be read or created immediately, uploads omit that header
484
+ and continue. Invalid stored identities are never silently replaced. Older
485
+ clients remain unattributed until updated and their uploader process restarted.
486
+
487
+ ### Skill
488
+
489
+ ```bash
490
+ prim skill install --agent claude # Install the decision-graph guide for Claude Code
491
+ prim skill install --agent cursor # Install the native Cursor skill
492
+ prim skill install --agent codex # …or write the guide into another agent's rules file
493
+ prim skill uninstall --agent claude # Remove it
494
+ prim skill status --agent claude # Report whether it's installed
495
+ ```
95
496
 
96
- Supports [Husky](https://typicode.github.io/husky/) — `prim hooks install` detects Husky and offers to install into `.husky/pre-commit`.
497
+ Teaches your agent how to work with the decision graph. For **Claude Code**
498
+ (`--agent claude`) this installs a skills-directory plugin at
499
+ `<repo>/.claude/skills/prim/` (or `~/.claude/skills/prim/` with `--scope user`)
500
+ — a `.claude-plugin/plugin.json` + `SKILL.md` that auto-loads as the model-invoked
501
+ `prim@skills-dir` skill, no marketplace step; restart Claude Code or run
502
+ `/reload-plugins` after installing. For **Cursor**, it installs an owned `SKILL.md`
503
+ at `<repo>/.cursor/skills/prim/` (or `~/.cursor/skills/prim/` with `--scope user`)
504
+ without overwriting foreign or locally edited files. For the remaining agents it
505
+ writes a managed block into the rules file that agent reads (`--agent codex` →
506
+ AGENTS.md or `--agent hermes` → .hermes.md). A bare
507
+ `prim skill install` (no `--agent`) auto-detects a rules file and writes the
508
+ block; pass `--target <path>` for an explicit file.
97
509
 
98
510
  ## Development
99
511