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
@@ -44,6 +44,7 @@ var __importStar = (this && this.__importStar) || (function () {
44
44
  })();
45
45
  Object.defineProperty(exports, "__esModule", { value: true });
46
46
  exports.truncateSessionId = truncateSessionId;
47
+ exports.sessionIdFromEnv = sessionIdFromEnv;
47
48
  exports.readIdentityAlias = readIdentityAlias;
48
49
  exports.buildSessionIdContext = buildSessionIdContext;
49
50
  exports.handleSessionIdHook = handleSessionIdHook;
@@ -65,6 +66,25 @@ function truncateSessionId(sessionId) {
65
66
  const candidate = hex.slice(0, 8);
66
67
  return /^[0-9a-f]{8}$/.test(candidate) ? candidate : null;
67
68
  }
69
+ /** Resolve the running session's id from the environment, truncated to 8-hex.
70
+ *
71
+ * Claude Code sets `CLAUDE_CODE_SESSION_ID` on every subprocess it spawns —
72
+ * the Bash tool, hook processes, AND plugin monitors all inherit it (verified
73
+ * against the 2.1.x binary: the child-env builder sets it unconditionally and
74
+ * it is also written to the global process env). So any greprag command run
75
+ * inside a session self-discovers its own id with no flag and no transcript
76
+ * spelunking. `CLAUDE_SESSION_ID` / `GREPRAG_SESSION_ID` are kept as
77
+ * back-compat / test-injection fallbacks. Returns null when none is set or
78
+ * the value can't be truncated to a valid 8-hex id.
79
+ *
80
+ * Note: the env var is `CLAUDE_CODE_SESSION_ID` (with `CODE`); the legacy
81
+ * `CLAUDE_SESSION_ID` name was never actually set by Claude Code. */
82
+ function sessionIdFromEnv() {
83
+ return truncateSessionId(process.env.CLAUDE_CODE_SESSION_ID
84
+ || process.env.CLAUDE_SESSION_ID
85
+ || process.env.GREPRAG_SESSION_ID
86
+ || null);
87
+ }
68
88
  /** Read the cached identity handle. Returns the alias part (before `@`) so
69
89
  * it can be substituted in `<handle>@greprag.com/<id>` templates without
70
90
  * doubling the domain. Returns null on any read/parse error — caller
@@ -92,52 +112,38 @@ function readIdentityAlias() {
92
112
  /** Build the `additionalContext` body. Kept as a named export so tests
93
113
  * can assert on shape without going through stdin/stdout.
94
114
  *
95
- * Two-segment grammar per adr/address-grammar.md. Examples are grounded
96
- * in *this* session's id so the agent copy/pastes rather than composes.
97
- *
98
- * When `armWatcher` is true, the message LEADS with
99
- * `STOP IMMEDIATELY AND READ THIS. RUN THIS NOW:` followed by the
100
- * literal Monitor command for THIS session. The earlier
101
- * `ARM YOUR INBOX WATCHER NOW.` lead was skipped in practice — agents
102
- * treated it as informational rather than as a precondition. STOP +
103
- * RUN combines two imperatives models react to strongly (stop reading
104
- * past, do this thing now), and `RUN THIS NOW:` sits immediately
105
- * before the actual command so the action is structurally adjacent to
106
- * its trigger phrase. The agent can infer the command's role from
107
- * reading it (`greprag inbox watch` + the reply-to line on the next
108
- * sentence ties messages to the same address) — no need to label.
115
+ * Emits awareness only: the agent's own 8-hex session id plus the
116
+ * two-segment reply-to address (grammar per adr/address-grammar.md),
117
+ * grounded in *this* session's id so the agent copy/pastes rather than
118
+ * composes. `alias` substitutes the literal `<handle>` placeholder in the
119
+ * reply-address line; defaults to null (leave placeholder) for callers
120
+ * without an identity cache.
109
121
  *
110
- * `alias` substitutes the literal `<handle>` placeholder in the
111
- * reply-address line. Defaults to null (leave placeholder) so callers
112
- * that don't have an identity cache get the same shape as before. */
113
- function buildSessionIdContext(short, armWatcher = false, alias = null) {
122
+ * Arming the inbox watcher is NO LONGER done here. The old SessionStart
123
+ * arm-directive (`STOP IMMEDIATELY ... RUN THIS NOW: Monitor ...`) depended
124
+ * on the agent choosing to make a Monitor tool call and was skipped in
125
+ * practice. It is replaced by the `greprag-inbox` plugin monitor, which
126
+ * Claude Code auto-starts at session start with no agent cooperation —
127
+ * see adr/session-id-awareness.md. */
128
+ function buildSessionIdContext(short, alias = null) {
114
129
  const handle = alias || '<handle>';
115
- const ref = (`Your greprag session id: ${short}. `
130
+ return (`Your greprag session id: ${short}. `
116
131
  + `Reply to you: ${handle}@greprag.com/${short} `
117
132
  + `(target = 8-hex/UUID session id, or project name).`);
118
- if (!armWatcher)
119
- return ref;
120
- return (`STOP IMMEDIATELY AND READ THIS. RUN THIS NOW: `
121
- + `Monitor (persistent:true): `
122
- + `\`while true; do greprag inbox watch --session ${short} --json; `
123
- + `echo "[restart]" >&2; sleep 1; done\`. `
124
- + ref);
125
133
  }
126
134
  /** Handle `greprag-hook session-id`. Reads the Claude Code hook payload
127
135
  * from `input.session_id`, emits a JSON response with hookSpecificOutput.
128
136
  * additionalContext to stdout. Silent on missing session_id (other hook
129
137
  * entries in the chain still fire).
130
138
  *
131
- * `opts.armWatcher` (default false) toggles the "arm Monitor watcher"
132
- * directive in the emitted text. Caller (hook.ts main) reads greprag
133
- * config and passes true only when the API key + hook-enabled flag are
134
- * both set — no point telling an unconfigured project to arm a watcher
135
- * that would just loop on auth errors.
139
+ * Emits session-id awareness only. Arming the inbox watcher moved to the
140
+ * `greprag-inbox` plugin monitor (see buildSessionIdContext +
141
+ * adr/session-id-awareness.md).
136
142
  *
137
143
  * Reads the identity alias from `~/.greprag/identity.json` here so the
138
144
  * emitted reply-address line carries the operator's real handle instead
139
145
  * of the literal `<handle>` placeholder. */
140
- function handleSessionIdHook(input, opts = {}) {
146
+ function handleSessionIdHook(input) {
141
147
  const short = truncateSessionId(input.session_id);
142
148
  if (!short)
143
149
  return;
@@ -145,7 +151,7 @@ function handleSessionIdHook(input, opts = {}) {
145
151
  const payload = {
146
152
  hookSpecificOutput: {
147
153
  hookEventName: 'SessionStart',
148
- additionalContext: buildSessionIdContext(short, opts.armWatcher === true, alias),
154
+ additionalContext: buildSessionIdContext(short, alias),
149
155
  },
150
156
  };
151
157
  process.stdout.write(JSON.stringify(payload) + '\n');
@@ -1 +1 @@
1
- {"version":3,"file":"session-id.js","sourceRoot":"","sources":["../src/session-id.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYH,8CAMC;AASD,8CAaC;AAuBD,sDAmBC;AAgBD,kDAcC;AA9GD,2CAA6B;AAC7B,u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5.13.0",
3
+ "version": "5.15.0",
4
4
  "description": "GrepRAG — agent memory for Claude Code. 2-command setup.",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -15,6 +15,7 @@
15
15
  "files": [
16
16
  "dist",
17
17
  "skill",
18
+ "plugin",
18
19
  "scripts"
19
20
  ],
20
21
  "devDependencies": {
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "greprag",
3
+ "owner": { "name": "GrepRAG", "email": "travis@greprag.com" },
4
+ "metadata": { "description": "GrepRAG bundled plugins." },
5
+ "plugins": [
6
+ {
7
+ "name": "greprag-inbox",
8
+ "description": "Auto-arms the GrepRAG inbox watcher (session-scoped) at session start so cross-session messages arrive mid-task without the agent invoking anything.",
9
+ "source": "./plugins/greprag-inbox",
10
+ "category": "productivity"
11
+ }
12
+ ]
13
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "name": "greprag-inbox",
3
+ "version": "0.1.0",
4
+ "description": "Auto-arms the GrepRAG inbox watcher (session-scoped) at session start.",
5
+ "author": { "name": "GrepRAG", "email": "travis@greprag.com" },
6
+ "homepage": "https://greprag.com"
7
+ }
@@ -0,0 +1,8 @@
1
+ [
2
+ {
3
+ "name": "greprag-inbox-watch",
4
+ "when": "always",
5
+ "description": "GrepRAG inbox (session-scoped live tail)",
6
+ "command": "while true; do greprag inbox watch --session-from-env --json; echo '[greprag inbox watch] watcher exited, restarting in 1s' >&2; sleep 1; done"
7
+ }
8
+ ]
@@ -124,9 +124,9 @@ If `references.discord.emergency_route` is non-null, this session was auto-linke
124
124
 
125
125
  Example first reply:
126
126
 
127
- > Picked this up in `<project-name>` / session `<session-8hex>` (no handoff was active, so I'm the most-recent armed watcher). Auto-pin is 10 min slides while you keep replying. Want to redirect? `/commander handoff` from another session, or just say "redirect to <project>".
127
+ > Picked this up in `<project-name>` / session `<session-8hex>` (no handoff was active, so I'm the most-recently-active armed session). Auto-pin is 10 min; it extends to 30 once you reply again. Want to redirect? `/commander handoff` from another session, or just say "redirect to <project>".
128
128
 
129
- The auto-pin TTL is short (10 min) and slides forward 30 min with each subsequent DM, so a real conversation keeps flowing here. If the operator goes quiet for the TTL window, the pin expires and the next DM re-runs the router (possibly landing in a different session if the topology has changed).
129
+ How the bot chose this session: among all armed session-scoped watchers under your tenant, it picks the **most-recently-active** one — ranked by `max(last turn end, arm time)` — so a session that just finished a turn (idle, waiting) outranks one grinding a long task or gone dark. The auto-pin starts at a **genuine 10-min leash**, so one stray DM into the wrong session self-heals fast if you go quiet; your *next* DM (pin now live) extends it to ≥30 min so a real back-and-forth keeps flowing here. If the picked session turns out to be dead — or nothing is armed at all — the bot replies that your message is filed and will be delivered the moment a session reconnects (it never vanishes), and clears the dead auto-pin so the next DM re-runs the router.
130
130
 
131
131
  For long agent turns where you're drafting >10s, refresh the typing indicator between work steps:
132
132
 
@@ -3,7 +3,7 @@ name: content-advisor
3
3
  version: 0.1.0
4
4
  description: |
5
5
  Cross-venture content strategist for a multi-venture portfolio. Reads
6
- GrepRAG Odyssey (episodic project memory — ship-events, dailies, weeklies) across every
6
+ GrepRAG memory (episodic project memory; marketed as Odyssey — ship-events, dailies, weeklies) across every
7
7
  paired project, cross-checks recent writing activity (OpenWriter drafts,
8
8
  newsletter sends, X posts, blog commits), and produces a ranked list of
9
9
  the next content pieces to ship — each one ready to hand off to a