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