greprag 5.13.0 → 5.15.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.
Files changed (41) hide show
  1. package/README.md +7 -6
  2. package/dist/commands/checkpoint-helpers.js +4 -1
  3. package/dist/commands/checkpoint-helpers.js.map +1 -1
  4. package/dist/commands/init.d.ts +2 -0
  5. package/dist/commands/init.js +270 -2
  6. package/dist/commands/init.js.map +1 -1
  7. package/dist/commands/lore.js +7 -5
  8. package/dist/commands/lore.js.map +1 -1
  9. package/dist/commands/memory.d.ts +31 -0
  10. package/dist/commands/memory.js +514 -0
  11. package/dist/commands/memory.js.map +1 -0
  12. package/dist/commands/project.d.ts +16 -0
  13. package/dist/commands/project.js +430 -0
  14. package/dist/commands/project.js.map +1 -0
  15. package/dist/hook.d.ts +1 -1
  16. package/dist/hook.js +9 -10
  17. package/dist/hook.js.map +1 -1
  18. package/dist/index.js +57 -19
  19. package/dist/index.js.map +1 -1
  20. package/dist/project-anchor.d.ts +1 -1
  21. package/dist/project-anchor.js +1 -1
  22. package/dist/session-id.d.ts +30 -25
  23. package/dist/session-id.js +39 -33
  24. package/dist/session-id.js.map +1 -1
  25. package/package.json +2 -1
  26. package/plugin/.claude-plugin/marketplace.json +13 -0
  27. package/plugin/plugins/greprag-inbox/.claude-plugin/plugin.json +7 -0
  28. package/plugin/plugins/greprag-inbox/monitors/monitors.json +8 -0
  29. package/skill/commander/SKILL.md +2 -2
  30. package/skill/content-advisor/SKILL.md +1 -1
  31. package/skill/greprag/SKILL.md +61 -661
  32. package/skill/greprag/docs/corpus.md +98 -0
  33. package/skill/greprag/docs/discord-handoff.md +47 -0
  34. package/skill/greprag/docs/discover.md +28 -0
  35. package/skill/greprag/docs/doctor.md +22 -0
  36. package/skill/greprag/docs/inbox-watch.md +57 -0
  37. package/skill/greprag/docs/inbox.md +100 -0
  38. package/skill/greprag/docs/lore.md +70 -0
  39. package/skill/greprag/docs/memory-advanced.md +23 -0
  40. package/skill/greprag/docs/per-project-flags.md +14 -0
  41. package/skill/greprag/docs/setup.md +208 -0
@@ -0,0 +1,208 @@
1
+ # Setup
2
+
3
+ Routes for each gap surfaced by `greprag status --json`. Re-run status after each fix and continue down the list.
4
+
5
+ ## opencode
6
+
7
+ OpenCode users install once:
8
+
9
+ ```bash
10
+ greprag init --opencode
11
+ ```
12
+
13
+ Plugin at `~/.config/opencode/plugins/greprag-memory.ts` runs silently — injects recap via system prompt, stores turns automatically. The `/greprag` skill works on-demand in both. Both surfaces share the same anchor (`.claude/project.json` or `.opencode/project.json`) and API key.
14
+
15
+ ## bulk-register
16
+
17
+ When several repos exist but only one is inbox-addressable:
18
+
19
+ ```bash
20
+ greprag init --all
21
+ ```
22
+
23
+ Runs standard init for cwd, then registers every sibling git repo at depth 1 (default scan root: parent of the current repo).
24
+
25
+ ## auth
26
+
27
+ Trigger: `auth.api_key_present === false`.
28
+
29
+ 1. Ask for email. If `userEmail` is in conversation context (CLAUDE.md, profile), use that and confirm.
30
+
31
+ 2. Request the code:
32
+ ```bash
33
+ curl -sf -X POST "https://api.greprag.com/v1/auth/request-code" \
34
+ -H "Content-Type: application/json" \
35
+ -d "{\"email\":\"<EMAIL>\"}"
36
+ ```
37
+
38
+ 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.
39
+
40
+ 4. Verify and capture the key:
41
+ ```bash
42
+ curl -sf -X POST "https://api.greprag.com/v1/auth/verify-code" \
43
+ -H "Content-Type: application/json" \
44
+ -d "{\"email\":\"<EMAIL>\",\"code\":\"<6-DIGIT-CODE>\"}"
45
+ ```
46
+ Response: `{"ok":true,"apiKey":"grp_live_...","userId":"...","tenantId":"..."}`.
47
+
48
+ 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.
49
+
50
+ ## hooks
51
+
52
+ Trigger: any of `hooks.session_start_recap`, `hooks.stop_store`, `hooks.post_tool_use_spawn_reminder` is false.
53
+
54
+ Append missing entries to the existing arrays in `~/.claude/settings.json` (create the arrays if absent). Don't overwrite hooks from other tools.
55
+
56
+ - **SessionStart recap** (under `hooks.SessionStart`):
57
+ ```json
58
+ { "matcher": "", "hooks": [{ "type": "command", "command": "greprag-hook recap", "timeout": 3000 }] }
59
+ ```
60
+ - **Stop store** (under `hooks.Stop`):
61
+ ```json
62
+ { "matcher": "", "hooks": [{ "type": "command", "command": "greprag-hook store", "timeout": 10000 }] }
63
+ ```
64
+ - **PreToolUse pre-spawn-check** (under `hooks.PreToolUse`):
65
+ ```json
66
+ { "matcher": "mcp__ccd_session__spawn_task", "hooks": [{ "type": "command", "command": "greprag-hook pre-spawn-check", "timeout": 3000 }] }
67
+ ```
68
+ Fires before every `spawn_task` chip dispatch. Validates against `~/.claude/CLAUDE.md § Chip Spawning`: title prefix `Chip: `, Block 1 (`git worktree add` in prompt), Block 2 (`greprag send` in prompt). Returns `permissionDecision: "deny"` with remediation on failure; the agent re-composes.
69
+
70
+ The legacy `user_prompt_submit_notify` hook was removed in v5.6.1 — live inbox delivery is now the Monitor watcher's job. Do not install it.
71
+
72
+ **Removing the legacy PostToolUse spawn-reminder hook** (only on upgrade from v0.x → v0.12+): if `hooks.PostToolUse` contains an entry with `matcher: "mcp__ccd_session__spawn_task"` and `command: "greprag-hook spawn-reminder"`, delete it. The behavior is now ambient — SessionStart auto-arms the watcher in every greprag-enabled session.
73
+
74
+ ## conventions
75
+
76
+ Two pieces install together: a loud pointer in `~/.claude/CLAUDE.md` and the protocol body at `~/.claude/docs/chip-spawn.md`. The PreToolUse `pre-spawn-check` hook enforces title + Block 1/2 at the tool boundary, so an agent that skips the doc still can't ship a bad chip.
77
+
78
+ Detect:
79
+ ```bash
80
+ if grep -q "greprag-conventions:start v5" ~/.claude/CLAUDE.md; then echo V5
81
+ elif grep -q "greprag-conventions:start v4" ~/.claude/CLAUDE.md; then echo V4_UPGRADE
82
+ elif grep -qE "greprag-conventions:start v[1-3]" ~/.claude/CLAUDE.md; then echo OLD_UPGRADE
83
+ else echo MISSING; fi
84
+ test -f ~/.claude/docs/chip-spawn.md && echo DOC_OK || echo DOC_MISSING
85
+ ```
86
+
87
+ **If `MISSING`**, insert into `~/.claude/CLAUDE.md` immediately after the `## Inbox` section (use Edit, marker comments verbatim):
88
+
89
+ ```markdown
90
+ <!-- greprag-conventions:start v5 -->
91
+ **CHIP SPAWN METHOD** → before calling `spawn_task`, read `~/.claude/docs/chip-spawn.md`. Non-negotiable.
92
+ <!-- greprag-conventions:end v5 -->
93
+ ```
94
+
95
+ **If `V4_UPGRADE`**, replace the entire `<!-- greprag-conventions:start v4 -->` … `<!-- greprag-conventions:end v4 -->` block (inclusive of markers) with the v5 pointer above. Tell the user "Upgrading v4 → v5 (moves inline body to ~/.claude/docs/chip-spawn.md)."
96
+
97
+ **If `OLD_UPGRADE`** (v1/v2/v3), same replacement pattern: delete the old block (markers inclusive) and insert v5. Also delete the legacy deep doc:
98
+ ```bash
99
+ rm -f ~/.claude/docs/agent-coordination.md
100
+ ```
101
+
102
+ **If `DOC_MISSING`**, re-run `greprag init` — it's idempotent and re-copies `chip-spawn.md` from the npm package.
103
+
104
+ Re-run the grep to confirm. Markers must stay verbatim — they're how subsequent `/greprag` runs detect "already installed."
105
+
106
+ ## permissions
107
+
108
+ Trigger: `Monitor` not in `~/.claude/settings.json` `permissions.allow`.
109
+
110
+ Without it, every inbox-watcher firing prompts for approval, breaking the reply-listening convention. Recommended baseline:
111
+
112
+ ```json
113
+ {
114
+ "permissions": {
115
+ "allow": [
116
+ "Bash(*)",
117
+ "Monitor",
118
+ "Read", "Edit", "Write", "Grep", "Glob",
119
+ "WebFetch", "WebSearch", "Skill", "Agent", "Task"
120
+ ]
121
+ }
122
+ }
123
+ ```
124
+
125
+ `Bash(*)` covers `greprag *` and `greprag-hook *`. `Monitor` is its own tool and prompts independently.
126
+
127
+ Per-command minimum for tighter Bash policies:
128
+ - `Bash(greprag *)`
129
+ - `Bash(greprag-hook *)`
130
+ - `Monitor`
131
+
132
+ Tell the user the proposed change before editing. Don't silently broaden their permission posture.
133
+
134
+ ## channels
135
+
136
+ Trigger: any channel plugin (`discord`, `telegram`, `imessage`, `fakechat`) enabled in global or any project `settings.json`:
137
+
138
+ ```bash
139
+ grep -lE '"(discord|telegram|imessage|fakechat)@claude-plugins-official":\s*true' \
140
+ ~/.claude/settings.json \
141
+ $(find . -maxdepth 3 -path '*/.claude/settings.json' 2>/dev/null) 2>/dev/null
142
+ ```
143
+
144
+ Tell the user: channel push delivery requires the `--channels` flag at session launch — being in `settings.json` and `.mcp.json` is not enough.
145
+
146
+ - **Setting enables the MCP server to load** → tools (e.g. `reply`, `fetch_messages`) become available.
147
+ - **`--channels plugin:<name>@<marketplace>` at launch enables push** → inbound `notifications/claude/channel` events surface as `<channel>` blocks in session context.
148
+
149
+ Without `--channels`, the bot can be DM'd and the bun server receives the event, but Claude Code's harness filters it. Observed symptom: "typing indicator fires, then bot times out without replying."
150
+
151
+ Flag is hidden from `claude --help` on 2.1.149 (research preview) but accepted on 2.1.80+. **FleetView / Claude Desktop's CCD launcher does not pass `--channels`** — push delivery works only from terminal-launched sessions:
152
+
153
+ ```bash
154
+ cd <project-with-plugin>
155
+ claude --channels plugin:discord@claude-plugins-official
156
+ ```
157
+
158
+ FleetView sessions can poll the plugin's REST tools as a workaround; realtime path is terminal-only.
159
+
160
+ Scope the plugin to a single project's `.claude/settings.json`, not global. Discord allows one gateway connection per bot token; multiple sessions with the plugin enabled race for the token and Discord drops all but one.
161
+
162
+ ## anchor
163
+
164
+ Trigger: `project.anchor_found === false`.
165
+
166
+ Ask: "GrepRAG isn't set up for this project yet. Set up memory for this folder? (y/n)"
167
+
168
+ If yes, three preferences:
169
+ - "Capture turns into memory here? (y/n)" → `memory_capture`
170
+ - "Inject the recap briefing at SessionStart here? (y/n)" → `session_start_recap`
171
+ - "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`
172
+
173
+ **Path heuristic**: if `project.cwd` contains `AppData/Roaming/Claude/local-agent-mode-sessions/` or starts with `/tmp/` or `/var/tmp/`, it's ephemeral. Ask:
174
+
175
+ > "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)"
176
+
177
+ If stable parent, walk up to nearest stable dir (`~/AppData/Roaming/Claude/` on Windows, `~` on Unix).
178
+
179
+ If `project.is_deterministic_fallback === true` AND 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:
180
+
181
+ > "Found existing memory under this folder's implicit UUID. Reuse it to keep continuity? (y/n)"
182
+
183
+ If yes, use the existing `project_id` in the new anchor. If no, mint fresh: `node -e "console.log(crypto.randomUUID())"`.
184
+
185
+ Write the file:
186
+ ```bash
187
+ mkdir -p <cwd>/.claude
188
+ cat > <cwd>/.claude/project.json <<EOF
189
+ {
190
+ "project_id": "<UUID>",
191
+ "project_name": "<basename, lowercased>",
192
+ "memory_capture": <true|false>,
193
+ "session_start_recap": <true|false>,
194
+ "inbox_notify": "<every_turn|session_start_only|off>",
195
+ "created": "<ISO-NOW>"
196
+ }
197
+ EOF
198
+ ```
199
+
200
+ Register so inbox addressing (`<email>/<project_name>`) resolves:
201
+ ```bash
202
+ curl -sf -X POST "https://api.greprag.com/v1/inbox/projects/register" \
203
+ -H "Authorization: Bearer ${GREPRAG_API_KEY}" \
204
+ -H "Content-Type: application/json" \
205
+ -d "{\"project_id\":\"<UUID>\",\"project_name\":\"<basename>\"}"
206
+ ```
207
+
208
+ On 409 (project_name conflict under this tenant), ask the user for a unique handle and retry.