@primitive.ai/prim 0.1.0-alpha.12 → 0.1.0-alpha.120

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 (56) hide show
  1. package/README.md +540 -38
  2. package/SKILL.md +315 -75
  3. package/assets/primitive-gameplan/SKILL.md +134 -0
  4. package/assets/primitive-gameplan/claude-hooks.json +28 -0
  5. package/assets/primitive-gameplan/scripts/activate.mjs +37 -0
  6. package/dist/chunk-2AKDX4RU.js +209 -0
  7. package/dist/chunk-4GLVJLEQ.js +55 -0
  8. package/dist/chunk-5BQ2NEMP.js +22695 -0
  9. package/dist/chunk-A6M2M5A2.js +36 -0
  10. package/dist/chunk-CCGFRNAA.js +1871 -0
  11. package/dist/chunk-D235RJNO.js +164 -0
  12. package/dist/chunk-EYBE724K.js +135 -0
  13. package/dist/chunk-EZXEWFDG.js +210 -0
  14. package/dist/chunk-GYQOZGGF.js +168 -0
  15. package/dist/chunk-HXICZG5J.js +503 -0
  16. package/dist/chunk-JSBRDJBE.js +30 -0
  17. package/dist/chunk-KZB4ABIB.js +13 -0
  18. package/dist/chunk-L52OD62C.js +1444 -0
  19. package/dist/chunk-LBCPRHNG.js +175 -0
  20. package/dist/chunk-LTTF4MBE.js +439 -0
  21. package/dist/chunk-MWNRXAEB.js +1572 -0
  22. package/dist/chunk-NQFRQ56V.js +262 -0
  23. package/dist/chunk-OYHYCK4K.js +13 -0
  24. package/dist/chunk-P2O7NLVN.js +1341 -0
  25. package/dist/chunk-R2NUH4B7.js +96 -0
  26. package/dist/chunk-SLDZJD6Q.js +157 -0
  27. package/dist/chunk-TC4FTRYO.js +253 -0
  28. package/dist/chunk-U67RBNIZ.js +844 -0
  29. package/dist/chunk-VOC4KOOP.js +258 -0
  30. package/dist/chunk-YTF6OCF3.js +459 -0
  31. package/dist/daemon/server.js +26444 -0
  32. package/dist/hook-runtime/daemon/server.js +26445 -0
  33. package/dist/hook-runtime/hooks/post-commit.js +23836 -0
  34. package/dist/hook-runtime/hooks/post-rewrite.js +23735 -0
  35. package/dist/hook-runtime/hooks/post-tool-use.js +36151 -0
  36. package/dist/hook-runtime/hooks/pre-commit.js +1737 -0
  37. package/dist/hook-runtime/hooks/pre-tool-use-worker.js +35067 -0
  38. package/dist/hook-runtime/hooks/pre-tool-use.js +96 -0
  39. package/dist/hook-runtime/hooks/prim-hook.js +36211 -0
  40. package/dist/hook-runtime/hooks/session-end.js +1188 -0
  41. package/dist/hook-runtime/hooks/session-start.js +33950 -0
  42. package/dist/hook-runtime/index.js +71245 -0
  43. package/dist/hook-runtime/statusline-main.js +892 -0
  44. package/dist/hooks/post-commit.js +197 -0
  45. package/dist/hooks/post-rewrite.js +206 -0
  46. package/dist/hooks/post-tool-use.js +295 -0
  47. package/dist/hooks/pre-commit.js +16 -108
  48. package/dist/hooks/pre-tool-use-worker.js +238 -0
  49. package/dist/hooks/pre-tool-use.js +87 -0
  50. package/dist/hooks/prim-hook.js +245 -0
  51. package/dist/hooks/session-end.js +67 -0
  52. package/dist/hooks/session-start.js +312 -0
  53. package/dist/index.js +10998 -572
  54. package/dist/statusline-main.js +891 -0
  55. package/package.json +49 -16
  56. package/dist/chunk-3APLWTLB.js +0 -165
package/README.md CHANGED
@@ -1,13 +1,45 @@
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 resolve
14
+ > the decision and retry. Automatic decision capture in active repositories is separate.
15
+
16
+ When Enforcement is enabled, automatic V4 checks wait at most **two seconds**.
17
+ Confirmed conflicts found in that window retain the existing review/warning
18
+ behavior. Otherwise work proceeds silently, including on timeout, incomplete
19
+ coverage, authentication problems, or service failure. Admitted evaluations
20
+ continue in the backend for internal review; later results cannot stop or undo
21
+ an edit and do not send a user notification.
22
+
23
+ Explicit inspection and recovery retain their longer wait:
24
+
25
+ ```bash
26
+ prim decisions preflight status <checkId>
27
+ prim decisions preflight resume <checkId>
28
+ ```
29
+
30
+ There is no V3 fallback. Re-run `prim <agent> install` and `prim doctor` to repair
31
+ the two-second hook timeout and fail-open settings. Claude uses its default
32
+ failure behavior, Cursor uses `failClosed: false`, and Hermes uses
33
+ `fail_closed: false`. Codex also permits the action if the hook fails. Reload or
34
+ restart the host as directed by the installer. Older installations retain their
35
+ blocking behavior until upgraded and repaired.
36
+
8
37
  ## Installation
9
38
 
10
- Requires Node.js 20+.
39
+ Requires Node.js 22.23.4+, 24.22.1+, or 26.12.1+ within those major versions.
40
+ Node.js 20 is no longer supported. After updating Node.js, restart the daemon
41
+ with `prim daemon restart` and rerun your agent's `prim <agent> install` command
42
+ and `prim hooks install` to repin their runtimes to the updated executable.
11
43
 
12
44
  ```bash
13
45
  npm install -g @primitive.ai/prim
@@ -19,21 +51,129 @@ Or run directly without installing:
19
51
  npx @primitive.ai/prim
20
52
  ```
21
53
 
54
+ In commands such as `npx --yes @primitive.ai/prim@latest ...`, the first `--yes`
55
+ belongs to **npm**: it skips npm's package-install confirmation. It does not approve a
56
+ Primitive action. Prim's own global `--yes` comes after the package name, for example
57
+ `npx --yes @primitive.ai/prim@latest --yes decisions create ... --attribution user`,
58
+ and applies only to that Prim invocation.
59
+
22
60
  ## Quick Start
23
61
 
62
+ One command does the whole install — auth, session hooks, daemon, git hooks,
63
+ skill, and the welcome:
64
+
24
65
  ```bash
25
- # Authenticate via browser (WorkOS OAuth)
66
+ prim setup # add --agent cursor, codex, or hermes; --no-daemon explicitly opts out
67
+ ```
68
+
69
+ After successful setup, the optional **author story** puts you in a new engineer's
70
+ shoes in a disposable project:
71
+
72
+ ```text
73
+ Implement CSV export → Your earlier Decision blocks email → Accept or Supercede
74
+ → Real outcome email
75
+ ```
76
+
77
+ Enter the feature prompt in the same agent chat. The real semantic evaluator checks
78
+ it against your private, fictional prior Decision. Choose a name-only export or
79
+ approve the displayed replacement with your own short reason. A real email explains
80
+ what your Decision protected or why it changed. Continue once that email is queued;
81
+ queued and provider-accepted do not mean delivered to your inbox.
82
+
83
+ The compact diagrams and actual file evidence live in each JSON `presentation`.
84
+ Your agent renders them once. After owned-file cleanup, participants without real
85
+ Decisions enter the existing individually approved creation flow. Existing Decisions
86
+ remain intact; unavailable history is not treated as an empty graph.
87
+
88
+ Use `prim setup --skip-demo` to remember a skip, or
89
+ `prim demo --agent <claude|codex|cursor|hermes>` to replay. Direct terminal `prim demo`
90
+ uses the same prompts. Setup defaults to compact diagnostics; `prim setup --details`
91
+ shows full child output. Default agent setup returns one JSON result with `welcome`,
92
+ `onboarding`, and its `nextAction`. Existing completed tours do not replay automatically.
93
+
94
+ Agent hooks must acknowledge isolation before any sample is shown. Passive capture
95
+ then stays excluded for this session, including resumes; start a new session to
96
+ resume it. Other sessions, real-work enforcement and explicitly approved real
97
+ Decision creation remain available. Synthetic records never join the team's graph.
98
+ This exercises a real evaluator and demo-only blocking policy, not native production
99
+ Enforcement or live ingestion. Backend/email unavailability leaves the optional
100
+ story pending while successful setup remains successful.
101
+
102
+ Or run the steps individually:
103
+
104
+ ```bash
105
+ # 1. Authenticate via browser (WorkOS OAuth)
26
106
  prim auth login
27
107
 
28
- # List your specs
29
- prim spec list
108
+ # 2. Wire the session hooks (decision capture + presence)
109
+ prim claude install # or: prim cursor install / prim codex install / prim hermes install
30
110
 
31
- # Install the pre-commit hook
111
+ # 3. Start the companion daemon (latency + team presence)
112
+ prim daemon start
113
+
114
+ # 4. Install the git hooks (pre-commit decision check + post-commit capture)
32
115
  prim hooks install
33
116
  ```
34
117
 
118
+ `prim setup` (and `prim claude preauth`) also pre-authorize prim so an agent's own
119
+ calls never stall on a permission prompt: a scoped `Bash(npx --yes @primitive.ai/prim*)`
120
+ allow-rule for default mode (it covers both the `@latest` onboarding form and the bare
121
+ day-to-day form), plus an `autoMode.environment` trust line so auto mode's safety
122
+ classifier treats prim as trusted tooling rather than untrusted downloaded code.
123
+
124
+ ### Set up with your coding agent
125
+
126
+ Paste this into Claude Code (or any coding agent). The command is in **your** message,
127
+ so the agent runs it directly — instead of fetching a doc and executing a command from
128
+ it, which an auto-mode safety classifier blocks as untrusted-origin code:
129
+
130
+ ```text
131
+ 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.
132
+ ```
133
+
134
+ That single command runs the whole install and current-repository activation in one
135
+ process (auth → session hooks → daemon → skill → activate this repository and wire its git hooks → welcome). The detailed
136
+ step-by-step the agent follows — and the manual fallback — live in
137
+ [`setup.md`](./setup.md).
138
+
35
139
  ## Commands
36
140
 
141
+ ### Setup
142
+
143
+ ```bash
144
+ prim setup # Run the whole install in one shot
145
+ prim setup --agent cursor # Same, for Cursor IDE and Cursor CLI
146
+ prim setup --agent codex # Same, for OpenAI Codex
147
+ prim setup --agent hermes # Same, for Hermes Agent (global-only config)
148
+ prim setup --no-daemon # Stop it and persistently opt out of supervised delivery
149
+ prim setup --global-hooks-path # Also route every repository's git hooks through prim
150
+ ```
151
+
152
+ 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,
153
+ re-running each underlying command so every step behaves exactly as if run by
154
+ hand (including the browser login). Idempotent — safe to re-run.
155
+
156
+ Setup wires the current repository's git hooks and never changes git's global
157
+ config on its own: a global `core.hooksPath` reroutes every repository on the
158
+ machine. Pass `--global-hooks-path` to opt in; `prim --yes setup` does not.
159
+
160
+ ### Uninstall
161
+
162
+ ```bash
163
+ prim uninstall
164
+ ```
165
+
166
+ Stops the companion daemon, removes the current repository's Prim-owned agent
167
+ and Git-hook surfaces when run inside a Git repository, removes the user-scoped
168
+ Claude, Cursor, Codex, Hermes, and Git-hook surfaces, then deletes only schema-valid
169
+ Prim runtime bytes. Foreign configuration is retained; ambiguous ownership
170
+ makes the command fail closed and retain the runtimes. If a removal races or
171
+ fails after one runtime changes, its JSON result reports each runtime's exact
172
+ state so rerunning can safely finish cleanup. Authentication,
173
+ undelivered journals, repository bindings, and agent skill guidance are kept.
174
+ Use `prim skill uninstall --agent <claude|cursor|codex|hermes> --scope <project|user>`
175
+ when you also want to remove a known skill target.
176
+
37
177
  ### Auth
38
178
 
39
179
  ```bash
@@ -41,59 +181,389 @@ prim auth login # Authenticate via browser
41
181
  prim auth set-token <token> # Save a bearer token (e.g. for CI)
42
182
  prim auth clear # Remove saved tokens
43
183
  prim auth status # Check authentication status
184
+ prim auth api-keys mint --name <name> [--expires-at <epoch-ms>] # Mint a user key; secret prints once
185
+ prim auth api-keys list [--limit <count>] [--after <api-key-id>] # List user-key metadata
186
+ prim auth api-keys revoke <api-key-id> # Revoke a user key
187
+ ```
188
+
189
+ ### GitHub
190
+
191
+ ```bash
192
+ prim github connect # Install or reuse the Primitive GitHub App for this checkout
193
+ prim github connect --no-browser # Print the installation URL without opening it
194
+ ```
195
+
196
+ The command first reuses existing repository access. When access is missing, it creates a
197
+ server-owned GitHub App installation intent, opens its installation URL unless browser opening is
198
+ suppressed, polls the same intent, then verifies and persists this checkout's binding. A completed
199
+ installation without admin access to this repository remains truthfully unbound.
200
+
201
+ ### Session integration
202
+
203
+ Wires the agent's session hooks so the decisions you make are captured into the
204
+ graph, and presence is reported. Each hook
205
+ self-resolves the CLI at run time (PATH, then a local install, then
206
+ `npx --yes @latest`), so it keeps working with no global install.
207
+
208
+ Installs into the current project by default — the repo's `.claude/settings.json`
209
+ or `.cursor/hooks.json`, resolved from the git root (so any subdirectory works);
210
+ pass `--scope user` to install machine-wide. Codex defaults to user scope
211
+ (`~/.codex/hooks.json`): Codex reads a project `.codex/hooks.json` only from the
212
+ checkout it lives in and trusts it by absolute path, so a project install covers
213
+ that checkout only, not the repo's other worktrees. Hermes is the exception: it reads
214
+ shell hooks only from the global `~/.hermes/config.yaml`, so `prim hermes install`
215
+ is always user-scoped — and prim merges in place, leaving the rest of that file
216
+ (providers, models, your own hooks) untouched.
217
+
218
+ ```bash
219
+ prim claude install # Install Claude Code hooks (project scope; uninstall / status)
220
+ prim claude install --scope user # Install machine-wide instead
221
+ prim cursor install # Install native Cursor hooks (project scope)
222
+ prim cursor install --scope user # Install hooks, skill, and CLI footer machine-wide
223
+ prim codex install # Install OpenAI Codex hooks (user scope; --scope project for this checkout only)
224
+ prim hermes install # Install Hermes Agent hooks (global ~/.hermes/config.yaml)
225
+ ```
226
+
227
+ For `$write-gameplan` or `$write-workstream` authoring in Codex, install the
228
+ separate Primitive planning companion from the target repository after the
229
+ public `$write-gameplan` skill is available:
230
+
231
+ ```bash
232
+ prim setup --agent codex
233
+ prim gameplan install --agent codex
234
+ prim gameplan status
235
+ ```
236
+
237
+ `gameplan install` adds the companion to this repository and a prompt dispatcher
238
+ to the user's Codex hooks, including linked worktrees. It does not replace the
239
+ public planning skill or install Conflict Gates; `setup` handles the latter.
240
+ Review `/hooks` in Codex and start a fresh session. `prim gameplan uninstall`
241
+ removes this repository's companion and leaves the shared user hook in place;
242
+ pass `--remove-user-hook` only when no other repository needs it. A Decision
243
+ scoped only to a code path named inside a gameplan is surfaced during planning,
244
+ but the edit gate sees the changed gameplan path.
245
+
246
+ Passive capture is repo-scoped even when these integrations are installed at user
247
+ scope. `prim enable` marks the current Git repo active; `prim disable` makes it
248
+ inactive. A project-scoped install activates its repo automatically. In an inactive
249
+ repo, session content is not passively captured. Here “inactive” means Prim's normal
250
+ effective capture check is false, including an explicit local `prim.active=false`.
251
+
252
+ An agent may still deliberately record one Decision from an inactive repo with
253
+ `prim decisions create`, but each invocation needs its own user approval. An explicit
254
+ request such as “record this Decision” supplies that approval for that one create; for
255
+ a proactive suggestion, the agent must show the proposed Decision and ask first. The
256
+ agent then passes Prim's global `--yes` for that invocation. This one-time approval does
257
+ not activate passive capture, and neither npm's `npx --yes`, setup approval, nor an
258
+ earlier create counts as approval for another Decision.
259
+
260
+ When a person runs `prim decisions create` interactively in an inactive repo, Prim
261
+ asks for that one-time approval itself. In non-interactive use it creates nothing
262
+ unless Prim's global `--yes` is present.
263
+
264
+ #### Claude decision feedback
265
+
266
+ Claude Code receives eventual, human-visible feedback when automatic capture
267
+ creates a `change` Decision. A later Claude `Stop` or fresh
268
+ `SessionStart` in the same Git worktree can display:
269
+
270
+ ```text
271
+ [prim] response → created Decision (dec_a1b2c3d4): Use the stable API (https://app.getprimitive.ai/decisions/r571n1dqjdrtyxxpf0fnzee4gn8aed6q)
44
272
  ```
45
273
 
46
- ### Specs
274
+ An author-private draft uses an actionable publish prompt instead:
47
275
 
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.
276
+ ```text
277
+ [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.
278
+ ```
279
+
280
+ This is a hook `systemMessage` for the person using Claude Code; it is not
281
+ injected into the model's context. Delivery is at-least-once at the stdout
282
+ handoff boundary: prim acknowledges only after writing the hook response, so a
283
+ failed acknowledgment can show the same notification again. Notifications are
284
+ eligible for 24 hours. The originating session gets limited preference, but any
285
+ concurrent Claude session in the same worktree may consume the backlog. A hook
286
+ claims at most 40 notifications and renders at most 8,000 Unicode code points;
287
+ `hasMore` work is left for a later Stop or SessionStart rather than extending
288
+ the current hook.
289
+
290
+ Worktree scope comes from an opaque UUID stored under the worktree's Git
291
+ metadata (equivalent to `git rev-parse --git-path prim/workspace-id`), never an
292
+ absolute repository path. Linked worktrees receive distinct IDs, moving a
293
+ worktree preserves its ID, and a clone creates a new one. A corrupt or
294
+ unwritable identity is never silently replaced: capture falls back to the
295
+ legacy envelope. Disable/uninstall does not delete the identity.
296
+
297
+ Feedback uses the invoking CLI's credentials for direct HTTPS calls rather
298
+ than the daemon, avoiding cross-organization token ambiguity. One absolute
299
+ three-second in-process budget covers token refresh, lease, parsing, rendering,
300
+ and acknowledgment. This is not a hard three-second wall clock: it cannot
301
+ preempt shell/PATH or `npx` resolution, Node startup, Claude's own hook
302
+ scheduling, or synchronous filesystem work. The Git fallback has a separate
303
+ short timeout.
304
+
305
+ Alternatives considered:
306
+
307
+ | Option | Benefit | Limitation |
308
+ | --- | --- | --- |
309
+ | Existing hooks + direct HTTPS (current) | No new install surface; uses the invoking credentials | In-process budget is not a host-enforced wall clock |
310
+ | Claude's native hook timeout | Host-enforced termination | Settings migration; may kill a cold `npx` startup |
311
+ | Daemon routing | Lower steady-state latency | Daemon token/org may not match a concurrent session |
312
+ | Dedicated feedback binary | Lower startup overhead | New distribution and install migration |
313
+ | Synchronous pre-Stop classification | Stronger same-turn immediacy | Adds model latency and cost to the hook path |
314
+ | Detached delivery | Does not block Stop | Cannot return the current hook's `systemMessage` |
315
+
316
+ Run `prim claude status` to verify both existing feedback handlers are installed
317
+ and `prim doctor` to inspect server capability. No new
318
+ hook registration or binary is required when upgrading an existing correct
319
+ installation.
320
+
321
+ ### Daemon
322
+
323
+ A supervised long-lived companion process that continuously drains captured
324
+ Moves, accelerates decision-graph reads, and powers the "team: N online"
325
+ presence count. `prim setup` requires it to be live on the current version with
326
+ an authenticated, healthy heartbeat unless the explicit `--no-daemon` opt-out is
327
+ supplied. Hooks still fail soft if it later degrades.
328
+
329
+ `prim daemon start` (and `restart`/`ensure`) does not gate on delivery. While
330
+ Moves are past the 30s delivery SLA it reports them as draining in the
331
+ background when the daemon's last sweep recorded no failure, or when the drains
332
+ that failed acknowledged Moves before failing; another bucket delivering in the
333
+ same sweep does not count. Journal buckets the daemon holds back (unbound,
334
+ another organization, identity unavailable) read as delivery held back, and a
335
+ failure with no progress reads as delivery failing; both are a ⚠ warning,
336
+ still exit 0. Its JSON adds `draining`, `deliveryRetained`, `deliveryFailing`,
337
+ and `ingestion` in those states. Start's JSON `healthy` means the start
338
+ succeeded, so it can differ from `daemon status --json`, which stays degraded
339
+ until the backlog drains. Setup's own health check reports a backlog the
340
+ daemon is draining as a warning and fails on held-back buckets and on failures
341
+ recorded without progress; standalone `prim doctor` still fails a missed SLA.
49
342
 
50
343
  ```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
344
+ prim daemon start # start (stop / restart / status)
62
345
  ```
63
346
 
64
- ### Contexts
347
+ Ordinary commands may upgrade an older daemon in the background. When an
348
+ installed CLI runs an attended, allowlisted command (for example `auth`,
349
+ `decisions`, `moves`, `skill`, or an agent's `install`/`status`) on macOS and
350
+ finds the launchd daemon on an older version, or on its own version but unable
351
+ to run (say, after a Node upgrade deleted the binary it pinned), it starts a
352
+ detached `prim daemon ensure`, at most once an hour whatever version it
353
+ targets. It never downgrades, never repoints the daemon at another deployment
354
+ or config root, and never runs from hooks or their background drains, `daemon`,
355
+ `doctor`, `setup` or its steps, `auth clear`, removal commands, a development
356
+ checkout, or as root. Set `PRIM_DAEMON_DRIFT_HEAL=0` to turn it off.
357
+
358
+ ### Decisions
359
+
360
+ Read and respond to the decision graph.
65
361
 
66
362
  ```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
363
+ prim decisions recent # Recent decisions feed (--author <name> for one teammate's)
364
+ prim decisions show <id> # Drill into one decision
365
+ prim decisions cascade <id> # Blast radius of a decision
366
+ prim decisions check --files <…> # Active decisions referencing files (warn-only)
367
+ prim decisions confirm <id> # Answer a rationale-confirmation prompt
368
+ prim decisions create --intent <…> --attribution <user|agent> # Record with explicit origin
369
+ prim decisions link <child> --on <parent> # Relate: <child> depends on <parent>
370
+ prim decisions unlink <child> --on <parent> # Remove that dependency
77
371
  ```
78
372
 
79
- ### Projects
373
+ `<id>` uses the canonical `dec_<8 hex>` Decision ID; bare short IDs and legacy full IDs remain accepted as inputs. STDOUT is machine-readable
374
+ JSON; human-readable status goes to STDERR.
375
+
376
+ `decisions check` uses the checkout's current Primitive repository binding and
377
+ Git branch. Paths are relative to the repository root, including from a
378
+ subdirectory; paths for files that do not exist yet are supported. Discovery
379
+ includes exact file, directory, glob, and repository scopes and applies each
380
+ Decision's effective window and audience. It does not run the Conflict Gate.
381
+ Missing bindings, older servers that cannot confirm repository-scoped discovery,
382
+ and bounded partial results report `unavailable` or `truncated`; they are not a
383
+ verified empty result. Reconnect a missing or stale binding with `prim enable`.
384
+
385
+ When passive capture is inactive in the current repo, an approved one-time create is:
80
386
 
81
387
  ```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
388
+ npx --yes @primitive.ai/prim@latest --yes decisions create --intent "…" --attribution user
85
389
  ```
86
390
 
391
+ Here npm's first `--yes` only permits package resolution; Prim's second `--yes`
392
+ confirms this create. It does not enable the repo or authorize a later create.
393
+
394
+ Every create requires `--attribution user|agent`. Use `user` only when the person
395
+ directly stated, selected, or confirmed the exact recorded choice. Use `agent` when
396
+ the agent introduced that exact choice while pursuing a broader request. A broad task
397
+ prompt or permission to implement does not make the resulting agent choice a user
398
+ Decision. If the origin is ambiguous, confirm the exact choice with the person before
399
+ creating it; do not guess.
400
+
401
+ `link` / `unlink` curate the dependency edges the automatic linker would otherwise
402
+ own — `<child>` depends on `<parent>`. Both are idempotent and refuse any link that
403
+ would create a cycle (exit 2); an unresolved id exits 4.
404
+
405
+ ### Bash script coverage
406
+
407
+ Conflict Gates also inspect Bash writes expressed as Python `-c`, Node.js
408
+ `-e`/`--eval`, or quoted stdin heredocs. Static paths passed to Python `Path`
409
+ writes or writable `open`, and Node.js `fs`/`fs.promises` writeFile/appendFile
410
+ calls, participate in the existing preflight check. Simple path variables and
411
+ direct import aliases are supported. Analysis never executes the script.
412
+
413
+ Script coverage remains unverified: dynamic paths, reassignment, nested scopes,
414
+ directory changes, wrappers, external scripts, and unsupported syntax can hide
415
+ other writes. Unknown commands display a “not verified” warning in active repos;
416
+ recognized read-only commands stay quiet. Known conflicts still prompt or block
417
+ according to the existing policy. Embedded parsing stops at 64 KiB, targets are
418
+ bounded to 32, and shell proposal truncation at 6,144 bytes is disclosed.
419
+
420
+ ### Reconcile
421
+
422
+ ```bash
423
+ prim reconcile <id> # Rejected: human_approval_required (exit 2)
424
+ ```
425
+
426
+ Record what happened after resolving a specific conflict:
427
+
428
+ ```bash
429
+ prim reconcile <id> --check <checkId> --outcome followed
430
+ prim reconcile <id> --check <checkId> --outcome superseded
431
+ ```
432
+
433
+ Use `followed` when you retained the Decision. Use `superseded` only after a
434
+ replacement Decision has been persisted with `prim decisions supersede`.
435
+ The conflict output supplies the check ID. Only the person whose edit was
436
+ checked can resolve that check. Repeating the same outcome is safe; changing an
437
+ already recorded outcome is rejected. These declarations do not issue a bypass.
438
+
439
+ Bypasses are disabled until an agent host can supply verifiable human approval.
440
+ Bare `prim reconcile <id>` rejects locally, including with `--yes`,
441
+ `--non-interactive`, or `--flag`. Sandbox escalation and automatic approval
442
+ review do not authorize an override. A blocked edit must remain blocked or be
443
+ changed to respect the governing Decisions.
444
+
87
445
  ### Hooks
88
446
 
89
447
  ```bash
90
- prim hooks install # Install pre-commit hook
91
- prim hooks uninstall # Remove pre-commit hook
448
+ prim hooks install # Wire the pre-commit, post-commit, and post-rewrite hooks
449
+ 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)
450
+ prim hooks snippet post-commit # Print the block that wires one hook, to place by hand
451
+ prim hooks uninstall # Remove prim's blocks (and any hook file prim created)
92
452
  ```
93
453
 
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`).
454
+ The pre-commit hook checks staged files against the live decision graph
455
+ (warn-only — it never blocks the commit). The post-commit and post-rewrite hooks
456
+ record each commit and each amend/rebase as capture boundaries for
457
+ classification. All three act only in repos where prim is active (`prim enable`).
458
+ Supports [Husky](https://typicode.github.io/husky/) — `prim hooks install`
459
+ detects Husky and offers to install into `.husky/`.
460
+
461
+ Each hook file gets one short block, inserted right after the shebang so it runs
462
+ before any `exit` or `exec`. The block names no version and no machine path: it
463
+ runs prim's staged entrypoint (`~/.config/prim/prim-git-hook-v1`) and does
464
+ nothing on a machine without prim, so a tracked `.husky/*` file never changes
465
+ across prim releases. `prim enable` and `prim hooks install` write it once and
466
+ never move or rewrite a current block, reformatted or not. Agent session hooks
467
+ only repair Git-private hook files under `.git` and prim's own hooks dir, and
468
+ never add the pre-commit check. prim never edits a hooks dir outside the
469
+ repository, such as a global `core.hooksPath` every repository shares, unless
470
+ you run `prim hooks install --scope user --global-hooks-path` or answer yes at
471
+ its terminal prompt. In a Husky v8 hook the block goes
472
+ after the `husky.sh` line, so it runs once and honors `HUSKY=0`. `prim doctor`
473
+ only reports; it never rewrites a hook.
95
474
 
96
- Supports [Husky](https://typicode.github.io/husky/) — `prim hooks install` detects Husky and offers to install into `.husky/pre-commit`.
475
+ `prim doctor` also checks evidence rather than file contents: each post-commit
476
+ run that reaches prim leaves a stamp in the checkout's git dir, and doctor's
477
+ `hook-fired` check fails when a local commit made since the hooks were wired
478
+ never reached prim. That catches an `exit` before prim's block, hand wiring
479
+ that broke, or a git client whose environment cannot find prim. The check
480
+ applies in manual mode too: once a repository is enabled, doctor expects your
481
+ own wiring to reach prim. `prim disable` ends the expectation, so commits made
482
+ while disabled are never judged. Turning prim off with `git config prim.active
483
+ false` directly ends it too, once an agent session starts while it is off; if
484
+ doctor still flags a commit made while it was off, run `prim disable` then
485
+ `prim enable`.
486
+
487
+ To wire the hooks yourself (lefthook, a custom Husky layout, …), run
488
+ `git config prim.gitHooks manual` (or `--global`) first: prim then never writes
489
+ a hook file. That setting is the only signal prim honors. It does not guess
490
+ from a hook that already mentions prim, so without it, `prim enable` adds its
491
+ block. Paste the block from `prim hooks snippet <hook>`, or have your hook
492
+ manager run `~/.config/prim/prim-git-hook-v1 <hook> "$@"` (post-rewrite also
493
+ needs Git's stdin).
494
+
495
+ ### Presence statusline
496
+
497
+ ```bash
498
+ prim statusline # Render the team-presence statusline (reads the daemon)
499
+ ```
500
+
501
+ Claude Code and Cursor CLI each have one custom status-line slot. Their user-scope
502
+ installations use a staged, lightweight Primitive renderer when that slot is empty
503
+ or already Primitive's; an existing custom status line is preserved even with
504
+ `--force` and reported explicitly. Cursor's Primitive footer replaces Cursor's
505
+ default footer and requires a Cursor CLI restart after installation or removal. Use
506
+ `prim daemon status` or `prim doctor` for the same health signal in that case.
507
+
508
+ ### Welcome
509
+
510
+ ```bash
511
+ prim welcome # Brief orientation to the decision graph (shown after setup)
512
+ ```
513
+
514
+ ### Session & journal
515
+
516
+ Lower-level plumbing for the capture pipeline — org binding and the local move
517
+ journal. Capture works automatically once the session hooks are installed **and the
518
+ repo is active**; these are for inspecting and steering it (e.g. multi-org machines).
519
+
520
+ ```bash
521
+ prim session start <id> # Pin a Claude Code session to an org (list / drop <id>)
522
+ prim moves bind # Pin the current directory to an org via .prim/workspace.json (drop)
523
+ prim moves status # Per-bucket pending stats for the local journal
524
+ prim moves tail # Pretty-print recent journal entries
525
+ prim moves flush # Drain the local journals to the server (also runs from hooks)
526
+ ```
527
+
528
+ Any other command except `uninstall` and a `setup` that starts the daemon (or
529
+ one of its steps) that finds Moves waiting over a minute (or cannot tell how
530
+ long) hands them to a detached background `prim moves flush` and never waits for
531
+ it. It starts none while a live daemon on the same version and deployment, with
532
+ a healthy heartbeat and no recorded ingestion failure, already owns the drain.
533
+
534
+ Move uploads include `X-Prim-Uploader-Version` (the uploader process's version)
535
+ and `X-Prim-Client-Instance-Id` (the opaque installation ID also used by presence
536
+ heartbeats). These let server traces distinguish the uploader from the version
537
+ that originally captured a replayed move. The ID is stored in
538
+ `client_instance_id` under the Prim config directory (`~/.config/prim` by default,
539
+ or `PRIM_CONFIG_DIR` / `XDG_CONFIG_HOME/prim`). Compare that file with the trace's
540
+ `uploaderClientInstanceId` to correlate an installation; it contains no hostname.
541
+ If the identity cannot be read or created immediately, uploads omit that header
542
+ and continue. Invalid stored identities are never silently replaced. Older
543
+ clients remain unattributed until updated and their uploader process restarted.
544
+
545
+ ### Skill
546
+
547
+ ```bash
548
+ prim skill install --agent claude # Install the decision-graph guide for Claude Code
549
+ prim skill install --agent cursor # Install the native Cursor skill
550
+ prim skill install --agent codex # …or write the guide into another agent's rules file
551
+ prim skill uninstall --agent claude # Remove it
552
+ prim skill status --agent claude # Report whether it's installed
553
+ ```
554
+
555
+ Teaches your agent how to work with the decision graph. For **Claude Code**
556
+ (`--agent claude`) this installs a skills-directory plugin at
557
+ `<repo>/.claude/skills/prim/` (or `~/.claude/skills/prim/` with `--scope user`)
558
+ — a `.claude-plugin/plugin.json` + `SKILL.md` that auto-loads as the model-invoked
559
+ `prim@skills-dir` skill, no marketplace step; restart Claude Code or run
560
+ `/reload-plugins` after installing. For **Cursor**, it installs an owned `SKILL.md`
561
+ at `<repo>/.cursor/skills/prim/` (or `~/.cursor/skills/prim/` with `--scope user`)
562
+ without overwriting foreign or locally edited files. For the remaining agents it
563
+ writes a managed block into the rules file that agent reads (`--agent codex` →
564
+ AGENTS.md or `--agent hermes` → .hermes.md). A bare
565
+ `prim skill install` (no `--agent`) auto-detects a rules file and writes the
566
+ block; pass `--target <path>` for an explicit file.
97
567
 
98
568
  ## Development
99
569
 
@@ -106,6 +576,38 @@ pnpm typecheck # Type-check
106
576
  pnpm lint # Lint
107
577
  ```
108
578
 
579
+ ### Actual host validation
580
+
581
+ After `pnpm build`, optional E2E checks drive a real host's tool loop against a
582
+ local deterministic model provider. They use temporary HOME/configuration and a
583
+ sentinel file, synthetic credentials, and no real model requests or user account.
584
+ They never install or upgrade the host or change your host settings.
585
+
586
+ ```bash
587
+ pnpm test:preflight-host # Installed Codex
588
+ pnpm test:preflight-host:claude # Claude 2.1.284+ on PATH
589
+ pnpm test:preflight-host:claude --binary /path/to/compatible/claude
590
+ # CLI_CLAUDE_BIN also selects the Claude binary.
591
+ ```
592
+
593
+ Each check covers completed allow, confirmed conflict, paused evaluation, malformed
594
+ backend JSON, CLI deadline expiry, hook crash, and host watchdog expiry. Only the
595
+ confirmed conflict prevents the sentinel write. The hook budget and watchdog are
596
+ two seconds; no fixture waits minutes. Unsupported Claude versions fail before
597
+ the fixture runs.
598
+ The separate `pnpm test:preflight-v4 --schema /path/to/cli-http-v1.schema.json`
599
+ check validates the built CLI against a supplied authoritative backend contract.
600
+
109
601
  ## License
110
602
 
111
603
  [MIT](LICENSE)
604
+
605
+ ### Decision identifiers
606
+
607
+ Decision IDs printed by prim are `dec_` followed by eight lowercase hexadecimal
608
+ characters. Use the same ID in commands and at
609
+ `https://app.getprimitive.ai/decisions/dec_<short>`. Public JSON fields such as
610
+ `id`, `decisionId`, and relationship references use this prefixed ID; the
611
+ `shortId` compatibility field contains the eight characters without the prefix.
612
+ Existing full record IDs remain accepted as inputs. Upgrade the backend before
613
+ this CLI; an unavailable identity produces an error rather than a storage ID.