greprag 0.5.4 → 0.6.0

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/skill/SKILL.md CHANGED
@@ -1,41 +1,188 @@
1
1
  ---
2
2
  name: greprag
3
3
  description: |
4
- GrepRAG — surface episodic project memory for the current session.
5
- Pulls what shipped, what was decided, and what's open from the last 7 days.
4
+ GrepRAG — agentic setup + episodic project memory.
6
5
 
7
- Use when: "/greprag", "what did we do last week", "catch me up", "memory briefing",
8
- "what's been happening in this project", "session context", "what shipped recently".
6
+ Single entry point. Runs `greprag status` to learn what's configured,
7
+ walks the user through any missing setup (email signup, hooks, project
8
+ anchor), then surfaces the current project's memory briefing.
9
+
10
+ Use when: "/greprag", "set up greprag", "greprag status", "configure
11
+ memory", "memory briefing", "catch me up", "what did we do last week",
12
+ "what's been happening in this project", "session context".
9
13
  metadata:
10
14
  author: travsteward
11
- version: "1.0.0"
15
+ version: "3.1.0"
12
16
  repository: https://github.com/travsteward/greprag
13
17
  license: MIT
14
18
  ---
15
19
 
16
20
  # GrepRAG Advisor
17
21
 
18
- Pull episodic memory for the current project and surface a structured briefing.
22
+ The agent drives all setup and runs the briefing. Single source of truth: `greprag status --json`.
23
+
24
+ ## Step 1 — Get the status
25
+
26
+ ```bash
27
+ greprag status --json
28
+ ```
29
+
30
+ Parse the JSON. The keys to check, in this order:
31
+
32
+ 1. `auth.api_key_present`
33
+ 2. `hooks.session_start_recap`, `hooks.stop_store`, `hooks.user_prompt_submit_notify`
34
+ 3. `project.anchor_found`
35
+ 4. `project.memory_capture`, `project.session_start_recap`, `project.inbox_notify`
36
+
37
+ For each gap, walk the user through the fix. When everything is configured, skip to Step 6 (briefing).
38
+
39
+ ## Step 2 — Auth (only if `auth.api_key_present === false`)
40
+
41
+ The user has no API key yet. Run the email OTP signup:
42
+
43
+ 1. Ask for their email. If `userEmail` is in conversation context (CLAUDE.md, profile), use that and confirm.
44
+
45
+ 2. Request the code:
46
+ ```bash
47
+ curl -sf -X POST "https://api.greprag.com/v1/auth/request-code" \
48
+ -H "Content-Type: application/json" \
49
+ -d "{\"email\":\"<EMAIL>\"}"
50
+ ```
51
+
52
+ 3. Read the verification email via the `gmail` skill. Find the most recent message from `noreply@greprag.com` with subject "Your GrepRAG verification code". Extract the 6-digit code. Retry once after 10 seconds if not present.
53
+
54
+ 4. Verify and capture the key:
55
+ ```bash
56
+ curl -sf -X POST "https://api.greprag.com/v1/auth/verify-code" \
57
+ -H "Content-Type: application/json" \
58
+ -d "{\"email\":\"<EMAIL>\",\"code\":\"<6-DIGIT-CODE>\"}"
59
+ ```
60
+ Response: `{"ok":true,"apiKey":"grp_live_...","userId":"...","tenantId":"..."}`.
61
+
62
+ 5. Write the key into `~/.claude/settings.json` under `env.GREPRAG_API_KEY`. Also set `env.MEMORY_HOOK_ENABLED = "true"`. (Read the file, edit the JSON in-place, write it back.)
63
+
64
+ Re-run `greprag status --json` and continue.
65
+
66
+ ## Step 3 — Hooks (only if either hook is `false`)
67
+
68
+ Edit `~/.claude/settings.json` to add the missing hook(s):
69
+
70
+ - **SessionStart recap** (under `hooks.SessionStart`):
71
+ ```json
72
+ { "matcher": "", "hooks": [{ "type": "command", "command": "greprag-hook recap", "timeout": 3000 }] }
73
+ ```
74
+ - **Stop store** (under `hooks.Stop`):
75
+ ```json
76
+ { "matcher": "", "hooks": [{ "type": "command", "command": "greprag-hook store", "timeout": 10000 }] }
77
+ ```
78
+
79
+ Append the missing entries to the existing arrays (create the arrays if absent). Don't overwrite existing hooks from other tools.
80
+
81
+ ## Step 4 — Project anchor (only if `project.anchor_found === false`)
82
+
83
+ The current folder has no `.claude/project.json`. Ask the user:
84
+
85
+ > "GrepRAG isn't set up for this project yet. Set up memory for this folder? (y/n)"
19
86
 
20
- ## Steps
87
+ If yes, ask three preferences:
88
+ - "Capture turns into memory here? (y/n)" → `memory_capture`
89
+ - "Inject the recap briefing at SessionStart here? (y/n)" → `session_start_recap`
90
+ - "How should this project handle inbox notifications? (1) every turn (recommended) / (2) only at session start / (3) off" → `inbox_notify`: `every_turn` | `session_start_only` | `off`
21
91
 
22
- ### 1. Get project ID
92
+ **Path heuristic**: if `project.cwd` contains `AppData/Roaming/Claude/local-agent-mode-sessions/` or starts with `/tmp/` or `/var/tmp/`, the cwd is an ephemeral session path. Tell the user:
23
93
 
94
+ > "This looks like an ephemeral Claude session directory. Anchor here (won't persist across sessions) or at the stable parent (persists)? (1=here, 2=stable parent)"
95
+
96
+ If they pick stable parent, walk up to the nearest stable directory (e.g., `~/AppData/Roaming/Claude/` on Windows, `~` on Unix) and place the anchor there.
97
+
98
+ If `project.is_deterministic_fallback === true` AND there's existing memory under that UUID (check via `curl -sf "https://api.greprag.com/v1/memory/by-period?projectId=<project_id>&from=2020-01-01T00:00:00Z&to=$(date -u +%Y-%m-%dT%H:%M:%SZ)&limit=1" -H "Authorization: Bearer ${GREPRAG_API_KEY}"` — if `count > 0`), ask:
99
+
100
+ > "Found existing memory under this folder's implicit UUID. Reuse it to keep continuity? (y/n)"
101
+
102
+ If yes, use the existing `project_id` in the new anchor file. If no, mint a fresh UUID via `node -e "console.log(crypto.randomUUID())"`.
103
+
104
+ Write the file:
105
+ ```bash
106
+ mkdir -p <cwd>/.claude
107
+ cat > <cwd>/.claude/project.json <<EOF
108
+ {
109
+ "project_id": "<UUID>",
110
+ "project_name": "<basename, lowercased>",
111
+ "memory_capture": <true|false>,
112
+ "session_start_recap": <true|false>,
113
+ "inbox_notify": "<every_turn|session_start_only|off>",
114
+ "created": "<ISO-NOW>"
115
+ }
116
+ EOF
117
+ ```
118
+
119
+ Then register the anchor with the server so inbox addressing (`<email>/<project_name>`) resolves:
24
120
  ```bash
25
- greprag project-id
121
+ curl -sf -X POST "https://api.greprag.com/v1/inbox/projects/register" \
122
+ -H "Authorization: Bearer ${GREPRAG_API_KEY}" \
123
+ -H "Content-Type: application/json" \
124
+ -d "{\"project_id\":\"<UUID>\",\"project_name\":\"<basename>\"}"
26
125
  ```
27
126
 
28
- If the command errors or returns empty: tell the user "GrepRAG not initialized for this project run `greprag init`" and stop.
127
+ If registration returns 409 (project_name conflict with another project under this tenant), ask the user for a unique handle and retry.
128
+
129
+ ## Step 5 — Per-project flags (when the user asks to flip them)
130
+
131
+ If the user says "turn off recaps here", "stop capturing memory in this folder", or "only notify me of inbox at session start":
132
+
133
+ 1. Read `<anchor_path>` from status
134
+ 2. Edit the JSON in-place — flip `memory_capture`, `session_start_recap`, or `inbox_notify`
135
+ 3. Write it back
136
+
137
+ Hooks honor these flags on next fire — no restart needed.
29
138
 
30
- ### 2. Check API key
139
+ ## Step 5b Inbox operations
31
140
 
141
+ When the user asks "check my inbox", "any messages?", or runs `/greprag inbox`:
142
+
143
+ ```bash
144
+ greprag inbox # list unread (auto-marks read)
145
+ greprag inbox --all # full history
146
+ greprag inbox keep <id> # extend a read message's TTL
147
+ greprag inbox delete <id>
148
+ ```
149
+
150
+ To send a plain message:
32
151
  ```bash
33
- echo $GREPRAG_API_KEY
152
+ greprag send "<markdown body>" --to <address>
34
153
  ```
35
154
 
36
- If empty: tell the user "GREPRAG_API_KEY not set run `greprag init`" and stop.
155
+ To send a **rich message** with back-pointers — preferred whenever the message refers to a memory row, a shipped artifact, or specific code lines:
156
+ ```bash
157
+ greprag send "Quick heads up — the auth bug I described yesterday repros here." \
158
+ --to alice@example.com/paybot \
159
+ --memory 04f3e0d4-aa12-44ef-9a01-bb3df2c7e911 \
160
+ --file src/auth/handler.ts:42 \
161
+ --file src/middleware/check.ts:10-15 \
162
+ --artifact commit:7a4d35b \
163
+ --artifact pr:#42
164
+ ```
37
165
 
38
- ### 3. Fetch episodic context
166
+ Flags (all repeatable, all optional):
167
+ - `--memory <uuid>` — point to a memory row (turn, ship event, episodic summary)
168
+ - `--artifact <type:id>` — point to a shipped thing. Types: `commit`, `pr`, `deploy`, `release`, `push`, `merge`
169
+ - `--file <path[:lines]>` — point to a code location. Lines are `42` or `10-15`
170
+ - `--ref-json '<json>'` — escape hatch for a fully-formed references object (mutually exclusive with the above)
171
+
172
+ **When to populate references vs. when to leave them off:**
173
+ - Short chat messages ("pinging you", "deploy is up", "ack") — no references, just body.
174
+ - Bug reports, follow-ups, design decisions — always add the specific code lines (`--file`) and any ship event that's relevant (`--artifact`).
175
+ - Cross-referencing prior memory — pull memory IDs from a `greprag inbox` listing or from the recap and pass via `--memory`. The recipient agent can fetch the row directly.
176
+ - Don't hallucinate references. If you can't name a real file path or artifact ID, leave the flag off.
177
+
178
+ Address formats (all valid):
179
+ - `alice@example.com` — recipient's tenant inbox by real email
180
+ - `alice@example.com/paybot` — recipient's paybot project inbox
181
+ - `alice@greprag.com` — same recipient by their auto-claimed greprag handle (tenant_id alias)
182
+
183
+ Auto-read semantics: any message returned by `greprag inbox` (without `--all`) is marked read in the same call. Once read, it stops appearing in notifications. TTL deletes read messages after 14 days. Use `keep` to extend before expiry.
184
+
185
+ ## Step 6 — Briefing (when everything is configured)
39
186
 
40
187
  ```bash
41
188
  PROJECT_ID=$(greprag project-id)
@@ -50,21 +197,19 @@ curl -sf "https://api.greprag.com/v1/memory/by-period?projectId=${PROJECT_ID}&fr
50
197
  -H "Authorization: Bearer ${GREPRAG_API_KEY}"
51
198
  ```
52
199
 
53
- ### 4. Present
54
-
55
- If both responses have empty `memories` arrays: "No episodic memory yet for this project — compaction runs hourly. Check back after the first active session."
200
+ If both responses have empty `memories`: "No episodic memory yet for this project — compaction runs hourly. Check back after the first active session."
56
201
 
57
- Otherwise format as a briefing:
202
+ Otherwise present verbatim:
58
203
 
59
204
  ---
60
205
  **[project_name] — memory briefing**
61
206
 
62
- **This week** *(omit section if no weekly row)*:
207
+ **This week** *(omit if no weekly row)*:
63
208
  [weekly summary verbatim]
64
209
 
65
210
  **Recent days**:
66
- [each daily row, newest first, prefixed with its date — "May 21:", "May 20:", etc.]
211
+ [each daily row, newest first, prefixed with its date]
67
212
 
68
213
  ---
69
214
 
70
- Do not rewrite or summarize the episodic content. Present it verbatim — the compactor already shaped it. The briefing is input to this session's context, not a report to the user.
215
+ Do not rewrite or summarize. Present verbatim — the compactor already shaped it.