@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/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@primitive.ai/prim",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
4
|
-
"description": "CLI for
|
|
3
|
+
"version": "0.1.0-alpha.121",
|
|
4
|
+
"description": "CLI for Primitive's decision graph — passive decision capture, conflict gate, and team presence",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -19,51 +19,85 @@
|
|
|
19
19
|
"primitive",
|
|
20
20
|
"prim",
|
|
21
21
|
"cli",
|
|
22
|
-
"
|
|
23
|
-
"
|
|
22
|
+
"decisions",
|
|
23
|
+
"decision-graph",
|
|
24
24
|
"pre-commit"
|
|
25
25
|
],
|
|
26
26
|
"engines": {
|
|
27
|
-
"node": "
|
|
27
|
+
"node": "^22.23.4 || ^24.22.1 || ^26.12.1"
|
|
28
28
|
},
|
|
29
29
|
"packageManager": "pnpm@9.15.9",
|
|
30
30
|
"bin": {
|
|
31
31
|
"prim": "dist/index.js",
|
|
32
|
-
"prim-pre-commit": "dist/hooks/pre-commit.js"
|
|
32
|
+
"prim-pre-commit": "dist/hooks/pre-commit.js",
|
|
33
|
+
"prim-post-commit": "dist/hooks/post-commit.js",
|
|
34
|
+
"prim-post-rewrite": "dist/hooks/post-rewrite.js",
|
|
35
|
+
"prim-hook": "dist/hooks/prim-hook.js",
|
|
36
|
+
"prim-pre-tool-use": "dist/hooks/pre-tool-use.js",
|
|
37
|
+
"prim-post-tool-use": "dist/hooks/post-tool-use.js",
|
|
38
|
+
"prim-session-start": "dist/hooks/session-start.js",
|
|
39
|
+
"prim-session-end": "dist/hooks/session-end.js",
|
|
40
|
+
"prim-daemon-server": "dist/daemon/server.js",
|
|
41
|
+
"prim-statusline": "dist/statusline-main.js"
|
|
33
42
|
},
|
|
34
43
|
"main": "./dist/index.js",
|
|
35
44
|
"files": [
|
|
36
45
|
"dist",
|
|
46
|
+
"assets",
|
|
37
47
|
"LICENSE",
|
|
38
48
|
"README.md",
|
|
39
|
-
"SKILL.md"
|
|
49
|
+
"SKILL.md",
|
|
50
|
+
"skills/prim-welcome"
|
|
40
51
|
],
|
|
41
52
|
"scripts": {
|
|
42
|
-
"build": "tsup src/index.ts src/hooks/pre-commit.ts --format esm --clean",
|
|
43
|
-
"
|
|
44
|
-
"
|
|
53
|
+
"build": "tsup src/index.ts src/hooks/pre-commit.ts src/hooks/post-commit.ts src/hooks/post-rewrite.ts src/hooks/prim-hook.ts src/hooks/pre-tool-use.ts src/hooks/pre-tool-use-worker.ts src/hooks/post-tool-use.ts src/hooks/session-start.ts src/hooks/session-end.ts --format esm --clean && tsup src/statusline-main.ts src/daemon/server.ts --format esm --splitting false && tsup --config tsup.hook-runtime.config.ts",
|
|
54
|
+
"contracts:generate": "node scripts/generate-cli-contract.mjs --write",
|
|
55
|
+
"contracts:check": "node scripts/generate-cli-contract.mjs --check",
|
|
56
|
+
"contracts:provenance": "node scripts/update-cli-contract.mjs --check",
|
|
57
|
+
"check:decision-identity-golden": "node scripts/check-decision-identity-golden.mjs",
|
|
58
|
+
"check:gameplan-companion": "node scripts/check-gameplan-companion.mjs",
|
|
59
|
+
"check:gameplan-e2e": "node scripts/check-gameplan-e2e.mjs",
|
|
60
|
+
"check:gameplan-package": "node scripts/check-gameplan-package.mjs",
|
|
61
|
+
"check:approval-copy-golden": "node scripts/check-approval-copy-golden.mjs",
|
|
62
|
+
"contracts:update": "node scripts/update-cli-contract.mjs",
|
|
63
|
+
"postbuild": "chmod +x ./dist/index.js ./dist/statusline-main.js ./dist/hooks/pre-commit.js ./dist/hooks/post-commit.js ./dist/hooks/post-rewrite.js ./dist/hooks/prim-hook.js ./dist/hooks/pre-tool-use.js ./dist/hooks/post-tool-use.js ./dist/hooks/session-start.js ./dist/hooks/session-end.js ./dist/daemon/server.js && node scripts/check-hook-runtime.mjs",
|
|
64
|
+
"dev": "tsup src/index.ts src/statusline-main.ts src/hooks/pre-commit.ts src/hooks/post-commit.ts src/hooks/post-rewrite.ts src/hooks/prim-hook.ts src/hooks/pre-tool-use.ts src/hooks/pre-tool-use-worker.ts src/hooks/post-tool-use.ts src/hooks/session-start.ts src/hooks/session-end.ts src/daemon/server.ts --format esm --watch --clean --splitting false",
|
|
45
65
|
"clean": "rm -rf dist coverage",
|
|
46
|
-
"lint": "biome check src/",
|
|
47
|
-
"format": "biome check --fix src/",
|
|
48
|
-
"format:check": "biome check src/",
|
|
66
|
+
"lint": "biome check src/ scripts/",
|
|
67
|
+
"format": "biome check --fix src/ scripts/",
|
|
68
|
+
"format:check": "biome check src/ scripts/",
|
|
49
69
|
"typecheck": "tsc --noEmit",
|
|
70
|
+
"check:reconcile-golden": "node scripts/check-reconcile-golden.mjs",
|
|
50
71
|
"test": "vitest run",
|
|
72
|
+
"test:preflight-host": "node scripts/check-codex-preflight-host.mjs",
|
|
73
|
+
"test:preflight-host:claude": "node scripts/check-claude-preflight-host.mjs",
|
|
74
|
+
"test:preflight-v4": "node scripts/check-preflight-v4-e2e.mjs",
|
|
51
75
|
"test:watch": "vitest",
|
|
52
|
-
"test:coverage": "vitest run --coverage"
|
|
76
|
+
"test:coverage": "vitest run --coverage",
|
|
77
|
+
"check:shell-targets-golden": "node scripts/check-shell-targets-golden.mjs"
|
|
53
78
|
},
|
|
54
79
|
"dependencies": {
|
|
80
|
+
"@lezer/common": "^1.5.4",
|
|
81
|
+
"@lezer/javascript": "^1.5.6",
|
|
82
|
+
"@lezer/python": "^1.1.19",
|
|
55
83
|
"commander": "^12.1.0",
|
|
56
84
|
"diff": "^5.2.0",
|
|
57
|
-
"
|
|
85
|
+
"unbash": "4.0.3",
|
|
86
|
+
"update-notifier": "^7.3.1",
|
|
87
|
+
"ws": "8.21.0",
|
|
88
|
+
"yaml": "^2.9.0"
|
|
58
89
|
},
|
|
59
90
|
"devDependencies": {
|
|
60
91
|
"@biomejs/biome": "^1.9.0",
|
|
61
92
|
"@types/diff": "^5.2.0",
|
|
62
93
|
"@types/node": "^25.5.0",
|
|
63
94
|
"@types/update-notifier": "^6.0.8",
|
|
64
|
-
"@
|
|
95
|
+
"@types/ws": "8.18.1",
|
|
96
|
+
"@vitest/coverage-v8": "^4.1.12",
|
|
97
|
+
"ajv": "8.20.0",
|
|
98
|
+
"json-schema-to-typescript": "15.0.4",
|
|
65
99
|
"tsup": "^8.0.0",
|
|
66
100
|
"typescript": "^5.5.0",
|
|
67
|
-
"vitest": "^
|
|
101
|
+
"vitest": "^4.1.12"
|
|
68
102
|
}
|
|
69
103
|
}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: prim-welcome
|
|
3
|
+
description: Welcome a new Primitive user right after `prim setup` finishes - explain Primitive, offer a one-minute conflict demo, confirm capture is on, show the team's recent Decisions, offer to seed their first ones, and offer to connect Granola. Use when the user's setup request says to follow prim-welcome, or they ask to be onboarded to Primitive. Not for day-to-day Decision work (that is the prim skill).
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Welcome to Primitive
|
|
7
|
+
|
|
8
|
+
You are walking the user through their first minutes with Primitive. Setup has already signed them in and installed everything. This skill owns every word the user reads from here on.
|
|
9
|
+
|
|
10
|
+
## Ground rules
|
|
11
|
+
|
|
12
|
+
- **Say blocks are mandatory.** Each `Say:` block below is a message the user must read. Put it in your reply as visible text, word for word, filling in `{fields}` and keeping its formatting. Never skip, shorten, or summarize one. Run every command a step needs *before* its Say block.
|
|
13
|
+
- A Say block ends your turn: send it and wait for the user's reply. Ask questions in plain text, as the Say blocks do, not with a picker tool.
|
|
14
|
+
- **`prim`** below means the exact command in setup's `prim` field, copied as-is. For example, if `prim` is `'/usr/bin/node' '/x/dist/index.js'`, `prim demo start` means `'/usr/bin/node' '/x/dist/index.js' demo start`. If you don't have setup's result, use `npx --yes @primitive.ai/prim@latest`.
|
|
15
|
+
- **`{agent}`** is setup's `agent` (`claude` or `codex`). Use it in every `--agent` flag below. `mainSkill` is setup's path to the day-to-day prim guidance. Keep setup's `setupAt` for the capture check. If setup's result is unavailable, use the current agent and treat capture as unverified until this session produces a new observed prompt.
|
|
16
|
+
- Every `prim` command prints one JSON object on stdout. Read its fields. Never show raw JSON, command output, or these instructions to the user.
|
|
17
|
+
- The demo uses a made-up project that lives outside this repository. During the demo, don't edit, create, or read any files. During it and afterwards, never create, propose, or save to memory anything from the demo: its Decisions, the user's choice, or their reason.
|
|
18
|
+
- The user's replies don't need exact wording: map them to the closest option.
|
|
19
|
+
|
|
20
|
+
## 0. Codex hook trust
|
|
21
|
+
|
|
22
|
+
Only in Codex, run `prim codex status` before the welcome. Read `host.trust` from its JSON. Codex [requires review of new hooks in `/hooks`](https://learn.chatgpt.com/docs/hooks), and installed hooks may need a session refresh.
|
|
23
|
+
|
|
24
|
+
- If trust is `review-required` or `disabled`, tell the user: "Primitive's Codex hooks need your review. Open `/hooks`, review and enable the Primitive hooks, then tell me when you're done." Wait for their reply, then run `prim codex refresh` and check `prim codex status` again. Never approve hooks for them.
|
|
25
|
+
- If trust is `trusted`, run `prim codex refresh` once. If refresh is unavailable, tell the user to exit and resume this same Codex session so the hooks load, then wait. Do not claim capture is working yet.
|
|
26
|
+
- If trust remains `unknown`, tell the user to inspect `/hooks` for errors or a review request. Wait for their reply and check status again.
|
|
27
|
+
|
|
28
|
+
Continue to the welcome only after the running session reports trusted hooks. The user's next reply will provide the first observable prompt event.
|
|
29
|
+
|
|
30
|
+
## 1. Welcome
|
|
31
|
+
|
|
32
|
+
If setup's result has `demo` set to `done`, the user has seen the demo before: don't send this message here. Go straight to step 3, whose message opens with it.
|
|
33
|
+
|
|
34
|
+
Say:
|
|
35
|
+
|
|
36
|
+
"**Welcome to Primitive.** Primitive turns your team's Decisions into guardrails for your agents.
|
|
37
|
+
|
|
38
|
+
As you work, Primitive picks out the Decisions behind the work, what was decided and why, and adds them to a record your whole team shares. If your org has Enforcement on, Primitive also checks the changes against those Decisions as we make them, and flags or stops one that conflicts.
|
|
39
|
+
|
|
40
|
+
Setup signed you in, connected this repository to GitHub, and turned Primitive on here.
|
|
41
|
+
|
|
42
|
+
Want to see it catch a conflict? It takes about a minute and uses a fictional project.
|
|
43
|
+
|
|
44
|
+
Reply **show me**, or **skip**."
|
|
45
|
+
|
|
46
|
+
If setup's `steps.github` isn't `ok`, leave out "connected this repository to GitHub," from that sentence.
|
|
47
|
+
|
|
48
|
+
This message has no picker: send it in full and end your turn.
|
|
49
|
+
|
|
50
|
+
- **show me** → step 2
|
|
51
|
+
- **skip** → run `prim demo skip`, then step 3
|
|
52
|
+
|
|
53
|
+
## 2. Demo
|
|
54
|
+
|
|
55
|
+
### 2a. The task
|
|
56
|
+
|
|
57
|
+
In Codex, first run `prim doctor --agent codex --compact`. Start the demo only if `capture.state` is `observed`, `capture.hooks` is `ready`, and `capture.observedAt` is at or after setup's `setupAt`. The user's **show me** reply should supply that observation. If it did not, explain that this session has not shown a working prompt hook; run `prim codex refresh` once if available, otherwise ask the user to resume this same session. Wait for another user reply and recheck before starting. Do not pause capture for a demo while hook execution is unverified.
|
|
58
|
+
|
|
59
|
+
Run `prim demo start`. When `stage` is `prompt`, say:
|
|
60
|
+
|
|
61
|
+
"**Primitive Demo · fictional project**
|
|
62
|
+
|
|
63
|
+
For the sake of demonstration, imagine you've just joined {story.org}'s team, and your first task is adding CSV export for user records. Send this as your next message:
|
|
64
|
+
|
|
65
|
+
> {story.task}
|
|
66
|
+
|
|
67
|
+
(Primitive is paused while we do this, so none of the demo is recorded.)"
|
|
68
|
+
|
|
69
|
+
### 2b. The conflict
|
|
70
|
+
|
|
71
|
+
When the user sends the task, run `prim demo attempt`. Don't implement the task. When `stage` is `conflict`, say:
|
|
72
|
+
|
|
73
|
+
"**Primitive caught a conflict.**
|
|
74
|
+
|
|
75
|
+
Your task exports user names *and email addresses*. That conflicts with a Decision {conflict.author} made on {conflict.date}:
|
|
76
|
+
|
|
77
|
+
> **{conflict.intent}**
|
|
78
|
+
|
|
79
|
+
**Why {conflict.author} decided this:** {conflict.rationale}
|
|
80
|
+
|
|
81
|
+
`{conflict.file}` today:
|
|
82
|
+
|
|
83
|
+
```ts
|
|
84
|
+
{conflict.code}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
How do you want to resolve it?
|
|
88
|
+
|
|
89
|
+
Reply **adhere** to keep {conflict.author}'s Decision and export names only, or **supersede** to replace it and export names and emails."
|
|
90
|
+
|
|
91
|
+
This message has no picker: send it in full and end your turn. The user needs its formatting and the rationale to decide.
|
|
92
|
+
|
|
93
|
+
- **adhere** → step 2d with `--choice adhere`
|
|
94
|
+
- **supersede** → step 2c
|
|
95
|
+
|
|
96
|
+
### 2c. The reason
|
|
97
|
+
|
|
98
|
+
Say:
|
|
99
|
+
|
|
100
|
+
"In a sentence, why should this Decision change?
|
|
101
|
+
|
|
102
|
+
(This is just for the demo, so any answer works.)"
|
|
103
|
+
|
|
104
|
+
Use the user's answer, unchanged, as `{reason}`. Never write a reason for them. Choosing supersede already approved the replacement, as in the real product, so don't ask for confirmation: go to step 2d with `--choice supersede --reason '{reason}'` (single-quote the reason, writing each `'` inside it as `'\''`).
|
|
105
|
+
|
|
106
|
+
### 2d. Resolve
|
|
107
|
+
|
|
108
|
+
Run `prim demo resolve` with the choice above. When `stage` is `completed`, keep its `outcome` and `diff` for step 3 and go on to step 3. Say nothing yet.
|
|
109
|
+
|
|
110
|
+
### If a demo step doesn't land
|
|
111
|
+
|
|
112
|
+
- `stage` is `pending`: run the same command once more.
|
|
113
|
+
- `stage` is `error` with `reason` `invalid` after the reason step (for example, a reason over 500 characters): ask for a shorter reason, then retry.
|
|
114
|
+
- Still `pending`, any other `error`, or the command fails: run `prim demo skip`, keep a plain-words cause for step 3, and go to step 3. Plain words for each `reason`: `repo-active` → "Primitive was turned back on partway through"; `not-a-repo` → "this folder isn't a git repository"; `not-started` → "the demo hadn't started"; otherwise use `detail`.
|
|
115
|
+
- The user asks to stop: run `prim demo skip`, then go to step 3.
|
|
116
|
+
|
|
117
|
+
`prim demo skip` and a completed demo both end the pause: capture resumes with the user's next message.
|
|
118
|
+
|
|
119
|
+
## 3. Wrap up
|
|
120
|
+
|
|
121
|
+
Run both of these first:
|
|
122
|
+
|
|
123
|
+
1. `prim doctor --agent {agent} --compact`. Read `capture`, not the overall `status` alone. Capture is verified for this session only when doctor `status` is not `fail`, `capture.hooks` is `ready`, `capture.observedAt` is at or after setup's `setupAt`, and `capture.state` is `observed` or `paused` with `resumeOnNextPrompt: true`. An ending pause means the next trusted user-prompt hook resumes capture. Otherwise report `capture.detail` and any relevant failed checks; never claim capture is on from an overall `warn` result alone.
|
|
124
|
+
2. `prim welcome --after-demo --team-sample --agent {agent}`. Read its `org` and `recent` fields. If it fails, treat `org` as `unknown` and `recent` as empty.
|
|
125
|
+
|
|
126
|
+
Then say one message, built from these parts in order. It ends your turn.
|
|
127
|
+
|
|
128
|
+
**Welcome**, only if step 1 was skipped because the demo was `done`: the step 1 message without its last two paragraphs.
|
|
129
|
+
|
|
130
|
+
**a. Demo result.** If the demo completed:
|
|
131
|
+
|
|
132
|
+
"**Resolved.** You {outcome.choice: adhere → kept, supersede → replaced} {outcome.author}'s Decision, and the export changed to match:
|
|
133
|
+
|
|
134
|
+
```diff
|
|
135
|
+
{diff}
|
|
136
|
+
```"
|
|
137
|
+
|
|
138
|
+
If `outcome.email` is `queued` or `accepted`, add: "A summary of the Decision is on its way to {outcome.recipient}."
|
|
139
|
+
|
|
140
|
+
If the demo didn't finish: "The demo couldn't finish ({cause}), so it was skipped." If the user skipped it, leave part a out.
|
|
141
|
+
|
|
142
|
+
**b. Capture.** If capture is on:
|
|
143
|
+
|
|
144
|
+
"**Primitive is on for this repository.** From your next message on, it works in the background as you work."
|
|
145
|
+
|
|
146
|
+
If capture is unverified, off, or blocked: "**Primitive is installed, but capture needs attention:**" followed by `capture.detail` and the relevant agent-hook check's `detail`. For Codex, use `/hooks` for review or enablement; if hooks are trusted but the running session did not refresh, use `prim codex refresh` or resume this same session.
|
|
147
|
+
|
|
148
|
+
**c. Recent team Decisions**, only if `recent` isn't empty:
|
|
149
|
+
|
|
150
|
+
"**Recent Decisions on your team**"
|
|
151
|
+
|
|
152
|
+
followed by a numbered list with one item per `recent` entry, in order, each in this two-line shape (the second line indented under the first):
|
|
153
|
+
|
|
154
|
+
"1. **[{intent}]({url})**
|
|
155
|
+
_{author} · {area} · {date}_"
|
|
156
|
+
|
|
157
|
+
Leave out `{area}` and its `·` when an entry has none.
|
|
158
|
+
|
|
159
|
+
**d. How to work with it:**
|
|
160
|
+
|
|
161
|
+
"**How to work with Primitive**
|
|
162
|
+
|
|
163
|
+
- **It's automatic.** Primitive derives Decisions from your work as you go; you don't have to do anything.
|
|
164
|
+
- **Record one explicitly** when you want control over exactly how a Decision is worded and explained, for example: *Add a Decision to Primitive: we keep user emails out of exports, because...*
|
|
165
|
+
- **Ask before you change things**, for example: *What Decisions govern the files I'm about to touch?* or *What has the team decided about auth lately?*
|
|
166
|
+
|
|
167
|
+
See every Decision at https://app.getprimitive.ai."
|
|
168
|
+
|
|
169
|
+
**e. First Decisions**, only if `org` is `seed` (the user hasn't recorded a Decision yet):
|
|
170
|
+
|
|
171
|
+
"You haven't recorded any Decisions yet. Primitive can suggest a few from this conversation and this repository's shared memory files. You approve each one, and approved Decisions are visible to your team. Reply **yes** or **not now**."
|
|
172
|
+
|
|
173
|
+
**f. Granola**, only if you didn't say part e: the Granola question from step 4.
|
|
174
|
+
|
|
175
|
+
If you said part e, wait for the reply:
|
|
176
|
+
|
|
177
|
+
- **yes**: read the prim guidance at setup's `mainSkill` path (for Codex, the managed prim block in `AGENTS.md`) and follow its "Onboarding: seed the graph from memory" section, from its step 1. Leave out everything from the demo. End the final message of that section with the Granola question from step 4.
|
|
178
|
+
- **not now**: say "You can add a Decision to Primitive any time by asking for it." followed by the Granola question from step 4.
|
|
179
|
+
|
|
180
|
+
## 4. Granola
|
|
181
|
+
|
|
182
|
+
The Granola question:
|
|
183
|
+
|
|
184
|
+
"One more thing: do you use **Granola** for meeting notes? Primitive can capture Decisions from your meetings. When you connect, you choose whether it can read your public notes, private notes, or both.
|
|
185
|
+
|
|
186
|
+
Reply **yes** or **no**."
|
|
187
|
+
|
|
188
|
+
When the user replies:
|
|
189
|
+
|
|
190
|
+
- **yes**: open https://app.getprimitive.ai/settings in their browser (`open <url>` on macOS, `xdg-open <url>` on Linux), then say:
|
|
191
|
+
|
|
192
|
+
"Primitive's Settings are open in your browser. Under **Integrations → Granola**, connect your account and paste your Granola API key (the **Set up your API key** link there opens it in Granola), then click **Sync now**. Primitive will capture Decisions from your meetings once they've synced."
|
|
193
|
+
|
|
194
|
+
If the browser couldn't open, replace "Primitive's Settings are open in your browser." with "Open https://app.getprimitive.ai/settings."
|
|
195
|
+
- **no**: say "No problem. You can connect Granola any time under Settings → Integrations at https://app.getprimitive.ai/settings."
|
|
196
|
+
|
|
197
|
+
Then stop. Don't offer further options.
|
package/dist/chunk-3APLWTLB.js
DELETED
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
// src/client.ts
|
|
2
|
-
import { existsSync, readFileSync, writeFileSync } from "fs";
|
|
3
|
-
import { homedir } from "os";
|
|
4
|
-
import { join, resolve } from "path";
|
|
5
|
-
function loadEnvFile() {
|
|
6
|
-
const envVars = {};
|
|
7
|
-
const candidates = [".env.local", ".env"];
|
|
8
|
-
for (const file of candidates) {
|
|
9
|
-
const filePath = resolve(process.cwd(), file);
|
|
10
|
-
if (existsSync(filePath)) {
|
|
11
|
-
const content = readFileSync(filePath, "utf-8");
|
|
12
|
-
for (const line of content.split("\n")) {
|
|
13
|
-
const trimmed = line.trim();
|
|
14
|
-
if (!trimmed || trimmed.startsWith("#")) continue;
|
|
15
|
-
const eqIdx = trimmed.indexOf("=");
|
|
16
|
-
if (eqIdx === -1) continue;
|
|
17
|
-
const key = trimmed.slice(0, eqIdx).trim();
|
|
18
|
-
const value = trimmed.slice(eqIdx + 1).trim();
|
|
19
|
-
envVars[key] = value;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
return envVars;
|
|
24
|
-
}
|
|
25
|
-
var TOKEN_FILE_PATH = join(homedir(), ".config", "prim", "token");
|
|
26
|
-
var REFRESH_TOKEN_PATH = TOKEN_FILE_PATH.replace("/token", "/refresh_token");
|
|
27
|
-
var TOKEN_EXPIRES_PATH = join(homedir(), ".config", "prim", "token_expires_at");
|
|
28
|
-
var REFRESH_THRESHOLD_MS = 6e4;
|
|
29
|
-
function isTokenExpiringSoon() {
|
|
30
|
-
if (!existsSync(TOKEN_EXPIRES_PATH)) return false;
|
|
31
|
-
const expiresAt = Number(readFileSync(TOKEN_EXPIRES_PATH, "utf-8").trim());
|
|
32
|
-
return !Number.isNaN(expiresAt) && Date.now() >= expiresAt - REFRESH_THRESHOLD_MS;
|
|
33
|
-
}
|
|
34
|
-
function getJwtExpiry(token) {
|
|
35
|
-
const parts = token.split(".");
|
|
36
|
-
if (parts.length !== 3) return void 0;
|
|
37
|
-
try {
|
|
38
|
-
const payload = JSON.parse(Buffer.from(parts[1], "base64url").toString());
|
|
39
|
-
return payload.exp ? payload.exp * 1e3 : void 0;
|
|
40
|
-
} catch {
|
|
41
|
-
return void 0;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
function saveTokenExpiry(token, expiresIn) {
|
|
45
|
-
const expiresAt = expiresIn ? Date.now() + expiresIn * 1e3 : getJwtExpiry(token);
|
|
46
|
-
if (expiresAt) {
|
|
47
|
-
writeFileSync(TOKEN_EXPIRES_PATH, String(expiresAt), { mode: 384 });
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
function getTokenExpiresAt() {
|
|
51
|
-
if (!existsSync(TOKEN_EXPIRES_PATH)) return void 0;
|
|
52
|
-
const val = Number(readFileSync(TOKEN_EXPIRES_PATH, "utf-8").trim());
|
|
53
|
-
return Number.isNaN(val) ? void 0 : val;
|
|
54
|
-
}
|
|
55
|
-
function getAuthToken() {
|
|
56
|
-
if (process.env.PRIM_TOKEN) {
|
|
57
|
-
return process.env.PRIM_TOKEN;
|
|
58
|
-
}
|
|
59
|
-
if (existsSync(TOKEN_FILE_PATH)) {
|
|
60
|
-
const token = readFileSync(TOKEN_FILE_PATH, "utf-8").trim();
|
|
61
|
-
if (token) {
|
|
62
|
-
return token;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
const envVars = loadEnvFile();
|
|
66
|
-
if (envVars.PRIM_TOKEN) {
|
|
67
|
-
return envVars.PRIM_TOKEN;
|
|
68
|
-
}
|
|
69
|
-
return void 0;
|
|
70
|
-
}
|
|
71
|
-
var API_URL = "https://api.getprimitive.ai";
|
|
72
|
-
function getSiteUrl() {
|
|
73
|
-
return API_URL;
|
|
74
|
-
}
|
|
75
|
-
async function refreshToken() {
|
|
76
|
-
if (!existsSync(REFRESH_TOKEN_PATH)) {
|
|
77
|
-
return void 0;
|
|
78
|
-
}
|
|
79
|
-
const refreshTokenValue = readFileSync(REFRESH_TOKEN_PATH, "utf-8").trim();
|
|
80
|
-
if (!refreshTokenValue) {
|
|
81
|
-
return void 0;
|
|
82
|
-
}
|
|
83
|
-
const siteUrl = getSiteUrl();
|
|
84
|
-
const response = await fetch(`${siteUrl}/mcp/broker/refresh`, {
|
|
85
|
-
method: "POST",
|
|
86
|
-
headers: { "Content-Type": "application/json" },
|
|
87
|
-
body: JSON.stringify({ refresh_token: refreshTokenValue })
|
|
88
|
-
});
|
|
89
|
-
if (!response.ok) {
|
|
90
|
-
return void 0;
|
|
91
|
-
}
|
|
92
|
-
const data = await response.json();
|
|
93
|
-
if (!data.access_token) {
|
|
94
|
-
return void 0;
|
|
95
|
-
}
|
|
96
|
-
writeFileSync(TOKEN_FILE_PATH, data.access_token, { mode: 384 });
|
|
97
|
-
if (data.refresh_token) {
|
|
98
|
-
writeFileSync(REFRESH_TOKEN_PATH, data.refresh_token, { mode: 384 });
|
|
99
|
-
}
|
|
100
|
-
saveTokenExpiry(data.access_token, data.expires_in);
|
|
101
|
-
return data.access_token;
|
|
102
|
-
}
|
|
103
|
-
var _cachedToken;
|
|
104
|
-
async function request(method, path, body, options) {
|
|
105
|
-
const siteUrl = getSiteUrl();
|
|
106
|
-
const url = `${siteUrl}${path}`;
|
|
107
|
-
if (!_cachedToken) {
|
|
108
|
-
_cachedToken = getAuthToken();
|
|
109
|
-
}
|
|
110
|
-
if (_cachedToken && isTokenExpiringSoon()) {
|
|
111
|
-
const newToken = await refreshToken();
|
|
112
|
-
if (newToken) {
|
|
113
|
-
_cachedToken = newToken;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
const doFetch = async (token) => {
|
|
117
|
-
const headers = {
|
|
118
|
-
"Content-Type": "application/json"
|
|
119
|
-
};
|
|
120
|
-
if (token) {
|
|
121
|
-
headers.Authorization = `Bearer ${token}`;
|
|
122
|
-
}
|
|
123
|
-
return fetch(url, {
|
|
124
|
-
method,
|
|
125
|
-
headers,
|
|
126
|
-
body: body !== void 0 ? JSON.stringify(body) : void 0,
|
|
127
|
-
signal: options?.signal
|
|
128
|
-
});
|
|
129
|
-
};
|
|
130
|
-
let res = await doFetch(_cachedToken);
|
|
131
|
-
if (res.status === 401) {
|
|
132
|
-
const newToken = await refreshToken();
|
|
133
|
-
if (newToken) {
|
|
134
|
-
_cachedToken = newToken;
|
|
135
|
-
res = await doFetch(newToken);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
if (!res.ok) {
|
|
139
|
-
if (res.status === 401) {
|
|
140
|
-
throw new Error("Authentication expired. Run `prim auth login` to re-authenticate.");
|
|
141
|
-
}
|
|
142
|
-
const errorBody = await res.json().catch(() => null);
|
|
143
|
-
throw new Error(errorBody?.error ?? `HTTP ${res.status}`);
|
|
144
|
-
}
|
|
145
|
-
return res.json();
|
|
146
|
-
}
|
|
147
|
-
function getClient() {
|
|
148
|
-
return {
|
|
149
|
-
get: (path, options) => request("GET", path, void 0, options),
|
|
150
|
-
post: (path, body, options) => request("POST", path, body, options),
|
|
151
|
-
patch: (path, body, options) => request("PATCH", path, body, options),
|
|
152
|
-
delete: (path, options) => request("DELETE", path, void 0, options)
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
export {
|
|
157
|
-
TOKEN_FILE_PATH,
|
|
158
|
-
REFRESH_TOKEN_PATH,
|
|
159
|
-
TOKEN_EXPIRES_PATH,
|
|
160
|
-
saveTokenExpiry,
|
|
161
|
-
getTokenExpiresAt,
|
|
162
|
-
getAuthToken,
|
|
163
|
-
getSiteUrl,
|
|
164
|
-
getClient
|
|
165
|
-
};
|