@primitive.ai/prim 0.1.0-alpha.1 → 0.1.0-alpha.100

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