greprag 5.6.1 → 5.7.1
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/dist/commands/fact.d.ts +3 -2
- package/dist/commands/fact.js +3 -2
- package/dist/commands/fact.js.map +1 -1
- package/dist/commands/init.js +43 -31
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/lore.d.ts +28 -0
- package/dist/commands/lore.js +357 -0
- package/dist/commands/lore.js.map +1 -0
- package/dist/commands/status.d.ts +1 -1
- package/dist/commands/status.js +4 -2
- package/dist/commands/status.js.map +1 -1
- package/dist/hook.js +34 -47
- package/dist/hook.js.map +1 -1
- package/dist/index.js +37 -14
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/skill/greprag/SKILL.md +49 -63
- package/skill/lore-advisor/SKILL.md +183 -0
- package/skill/templates/chip-spawn.md +15 -0
- package/skill/templates/agent-coordination.md +0 -254
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// adr: adr/lore-rename.md
|
|
3
|
+
/** greprag lore — per-project LEARNINGS substrate.
|
|
4
|
+
*
|
|
5
|
+
* Lore = what was learned (Old English `lār`). Project-specific emergent
|
|
6
|
+
* knowledge — discovered constraints, gotchas, tribal knowledge that drifts
|
|
7
|
+
* as the codebase evolves. Reviewed via /lore-advisor. Distinct from static
|
|
8
|
+
* project knowledge (which lives in CLAUDE.md / docs / code structure).
|
|
9
|
+
*
|
|
10
|
+
* Pull-based: agents seed lore they wish a future spawned chip had known;
|
|
11
|
+
* future chips query the relevant scope at spawn time and skip the
|
|
12
|
+
* discovery they would otherwise repeat. All server work delegates to
|
|
13
|
+
* FactsService in @greprag/core via /v1/facts/:projectId — the CLI is a
|
|
14
|
+
* thin HTTP printer + project resolver.
|
|
15
|
+
*
|
|
16
|
+
* Note: the server-side route + DB column stay named `facts` (internal —
|
|
17
|
+
* surface-only rename in v5.7.0). The CLI maps `lore` commands to `facts` URLs.
|
|
18
|
+
*
|
|
19
|
+
* Subcommands:
|
|
20
|
+
* add "<text>" --scope <S> [--project <name>] [--source-session <id>]
|
|
21
|
+
* query [--scope <S>] [--query "<intent>"] [--project <name>]
|
|
22
|
+
* [--limit <N=10>] [--format markdown|json]
|
|
23
|
+
* list [--project <name>] [--format markdown|json]
|
|
24
|
+
* delete <nodeId> [--project <name>]
|
|
25
|
+
* scopes [--project <name>]
|
|
26
|
+
*
|
|
27
|
+
* Project resolution: without --project, uses the current cwd's project
|
|
28
|
+
* anchor (readAnchor). With --project <name>, hits /v1/projects to
|
|
29
|
+
* resolve name → projectId (case-insensitive). */
|
|
30
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
31
|
+
if (k2 === undefined) k2 = k;
|
|
32
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
33
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
34
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
35
|
+
}
|
|
36
|
+
Object.defineProperty(o, k2, desc);
|
|
37
|
+
}) : (function(o, m, k, k2) {
|
|
38
|
+
if (k2 === undefined) k2 = k;
|
|
39
|
+
o[k2] = m[k];
|
|
40
|
+
}));
|
|
41
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
42
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
43
|
+
}) : function(o, v) {
|
|
44
|
+
o["default"] = v;
|
|
45
|
+
});
|
|
46
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
47
|
+
var ownKeys = function(o) {
|
|
48
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
49
|
+
var ar = [];
|
|
50
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
51
|
+
return ar;
|
|
52
|
+
};
|
|
53
|
+
return ownKeys(o);
|
|
54
|
+
};
|
|
55
|
+
return function (mod) {
|
|
56
|
+
if (mod && mod.__esModule) return mod;
|
|
57
|
+
var result = {};
|
|
58
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
59
|
+
__setModuleDefault(result, mod);
|
|
60
|
+
return result;
|
|
61
|
+
};
|
|
62
|
+
})();
|
|
63
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
64
|
+
exports.runLore = runLore;
|
|
65
|
+
const fs = __importStar(require("fs"));
|
|
66
|
+
const path = __importStar(require("path"));
|
|
67
|
+
const project_anchor_1 = require("../project-anchor");
|
|
68
|
+
const API_URL_DEFAULT = 'https://api.greprag.com';
|
|
69
|
+
// ---------- Config / env (mirrors corpus.ts) ------------------------------
|
|
70
|
+
function loadEnvFile(filePath) {
|
|
71
|
+
try {
|
|
72
|
+
const content = fs.readFileSync(filePath, 'utf-8');
|
|
73
|
+
for (const line of content.split('\n')) {
|
|
74
|
+
const trimmed = line.trim();
|
|
75
|
+
if (!trimmed || trimmed.startsWith('#'))
|
|
76
|
+
continue;
|
|
77
|
+
const eqIdx = trimmed.indexOf('=');
|
|
78
|
+
if (eqIdx < 1)
|
|
79
|
+
continue;
|
|
80
|
+
const key = trimmed.slice(0, eqIdx).trim();
|
|
81
|
+
let value = trimmed.slice(eqIdx + 1).trim();
|
|
82
|
+
if ((value.startsWith('"') && value.endsWith('"')) ||
|
|
83
|
+
(value.startsWith("'") && value.endsWith("'"))) {
|
|
84
|
+
value = value.slice(1, -1);
|
|
85
|
+
}
|
|
86
|
+
if (!process.env[key])
|
|
87
|
+
process.env[key] = value;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
catch { /* file missing — fine */ }
|
|
91
|
+
}
|
|
92
|
+
function getConfig() {
|
|
93
|
+
const homeDir = process.env.HOME || process.env.USERPROFILE || '';
|
|
94
|
+
if (homeDir)
|
|
95
|
+
loadEnvFile(path.join(homeDir, '.greprag', '.env'));
|
|
96
|
+
if (!process.env.GREPRAG_API_KEY)
|
|
97
|
+
loadEnvFile(path.join(process.cwd(), '.env'));
|
|
98
|
+
return {
|
|
99
|
+
apiUrl: process.env.GREPRAG_API_URL || API_URL_DEFAULT,
|
|
100
|
+
apiKey: process.env.GREPRAG_API_KEY || '',
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
async function apiCall(url, apiKey, body) {
|
|
104
|
+
const res = await fetch(url, {
|
|
105
|
+
method: 'POST',
|
|
106
|
+
headers: { 'Authorization': `Bearer ${apiKey}`, 'Content-Type': 'application/json' },
|
|
107
|
+
body: JSON.stringify(body),
|
|
108
|
+
});
|
|
109
|
+
if (!res.ok)
|
|
110
|
+
throw new Error(`API ${res.status}: ${await res.text()}`);
|
|
111
|
+
return res.json();
|
|
112
|
+
}
|
|
113
|
+
async function apiGet(url, apiKey) {
|
|
114
|
+
const res = await fetch(url, { headers: { 'Authorization': `Bearer ${apiKey}` } });
|
|
115
|
+
if (!res.ok)
|
|
116
|
+
throw new Error(`API ${res.status}: ${await res.text()}`);
|
|
117
|
+
return res.json();
|
|
118
|
+
}
|
|
119
|
+
async function apiDelete(url, apiKey) {
|
|
120
|
+
const res = await fetch(url, {
|
|
121
|
+
method: 'DELETE',
|
|
122
|
+
headers: { 'Authorization': `Bearer ${apiKey}` },
|
|
123
|
+
});
|
|
124
|
+
if (!res.ok)
|
|
125
|
+
throw new Error(`API ${res.status}: ${await res.text()}`);
|
|
126
|
+
return res.json();
|
|
127
|
+
}
|
|
128
|
+
// ---------- Helpers --------------------------------------------------------
|
|
129
|
+
function getFlag(args, flag) {
|
|
130
|
+
const idx = args.indexOf(flag);
|
|
131
|
+
if (idx === -1 || idx + 1 >= args.length)
|
|
132
|
+
return undefined;
|
|
133
|
+
return args[idx + 1];
|
|
134
|
+
}
|
|
135
|
+
function abortNotConfigured() {
|
|
136
|
+
console.error('Not configured. Run: greprag init');
|
|
137
|
+
process.exit(1);
|
|
138
|
+
}
|
|
139
|
+
/** Resolve which project a lore command operates on. --project <name> wins
|
|
140
|
+
* via the tenant's projects registry; otherwise the cwd's anchor decides. */
|
|
141
|
+
async function resolveProject(args, apiUrl, apiKey) {
|
|
142
|
+
const projectArg = getFlag(args, '--project');
|
|
143
|
+
if (!projectArg) {
|
|
144
|
+
const anchor = (0, project_anchor_1.readAnchor)(process.cwd());
|
|
145
|
+
return { projectId: anchor.projectId, projectName: anchor.projectName };
|
|
146
|
+
}
|
|
147
|
+
const r = await apiGet(`${apiUrl}/v1/projects`, apiKey);
|
|
148
|
+
const needle = projectArg.trim().toLowerCase();
|
|
149
|
+
const match = (r.projects || []).find(p => p.project_name.toLowerCase() === needle);
|
|
150
|
+
if (!match) {
|
|
151
|
+
throw new Error(`project "${projectArg}" not found under this tenant. ` +
|
|
152
|
+
`Register it via 'greprag init' in that directory, then retry.`);
|
|
153
|
+
}
|
|
154
|
+
return { projectId: match.project_id, projectName: match.project_name };
|
|
155
|
+
}
|
|
156
|
+
/** Try to read the current session's UUID from the harness env (Claude Code
|
|
157
|
+
* exposes it as CLAUDE_SESSION_ID on hook invocations). Falls back to
|
|
158
|
+
* undefined — callers should pass --source-session explicitly when they
|
|
159
|
+
* know it. */
|
|
160
|
+
function readSessionEnv() {
|
|
161
|
+
return process.env.CLAUDE_SESSION_ID || process.env.GREPRAG_SESSION_ID || null;
|
|
162
|
+
}
|
|
163
|
+
// ---------- add -----------------------------------------------------------
|
|
164
|
+
async function addCmd(args) {
|
|
165
|
+
const cfg = getConfig();
|
|
166
|
+
if (!cfg.apiKey)
|
|
167
|
+
abortNotConfigured();
|
|
168
|
+
const text = args[0];
|
|
169
|
+
if (!text || text.startsWith('--')) {
|
|
170
|
+
console.error('Usage: greprag lore add "<text>" --scope <scope> [--project <name>] [--source-session <id>]');
|
|
171
|
+
process.exit(1);
|
|
172
|
+
}
|
|
173
|
+
const scope = getFlag(args, '--scope');
|
|
174
|
+
if (!scope) {
|
|
175
|
+
console.error('Usage: greprag lore add "<text>" --scope <scope> [--project <name>]');
|
|
176
|
+
process.exit(1);
|
|
177
|
+
}
|
|
178
|
+
const sourceSession = getFlag(args, '--source-session') || readSessionEnv();
|
|
179
|
+
const { projectId, projectName } = await resolveProject(args, cfg.apiUrl, cfg.apiKey);
|
|
180
|
+
const result = await apiCall(`${cfg.apiUrl}/v1/facts/${projectId}`, cfg.apiKey, {
|
|
181
|
+
text, scope,
|
|
182
|
+
sourceSessionId: sourceSession,
|
|
183
|
+
projectName,
|
|
184
|
+
});
|
|
185
|
+
if (!result.ok || !result.nodeId)
|
|
186
|
+
throw new Error(result.error || 'add failed');
|
|
187
|
+
console.log(`Added lore [${result.nodeId}] scope=${scope} project=${projectName}`);
|
|
188
|
+
}
|
|
189
|
+
// ---------- query ---------------------------------------------------------
|
|
190
|
+
async function queryCmd(args) {
|
|
191
|
+
const cfg = getConfig();
|
|
192
|
+
if (!cfg.apiKey)
|
|
193
|
+
abortNotConfigured();
|
|
194
|
+
const scope = getFlag(args, '--scope');
|
|
195
|
+
const queryStr = getFlag(args, '--query');
|
|
196
|
+
const limit = parseInt(getFlag(args, '--limit') || '10', 10);
|
|
197
|
+
const format = (getFlag(args, '--format') || 'markdown').toLowerCase();
|
|
198
|
+
if (format !== 'markdown' && format !== 'json') {
|
|
199
|
+
console.error('--format must be markdown or json');
|
|
200
|
+
process.exit(1);
|
|
201
|
+
}
|
|
202
|
+
const { projectId, projectName } = await resolveProject(args, cfg.apiUrl, cfg.apiKey);
|
|
203
|
+
const params = new URLSearchParams();
|
|
204
|
+
if (scope)
|
|
205
|
+
params.set('scope', scope);
|
|
206
|
+
if (queryStr)
|
|
207
|
+
params.set('query', queryStr);
|
|
208
|
+
params.set('limit', String(limit));
|
|
209
|
+
const result = await apiGet(`${cfg.apiUrl}/v1/facts/${projectId}?${params.toString()}`, cfg.apiKey);
|
|
210
|
+
if (!result.ok || !result.facts)
|
|
211
|
+
throw new Error(result.error || 'query failed');
|
|
212
|
+
if (format === 'json') {
|
|
213
|
+
console.log(JSON.stringify({
|
|
214
|
+
project: projectName,
|
|
215
|
+
scope: scope ?? null,
|
|
216
|
+
query: queryStr ?? null,
|
|
217
|
+
lore: result.facts,
|
|
218
|
+
}, null, 2));
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
if (result.facts.length === 0) {
|
|
222
|
+
const scopeNote = scope ? ` (scope=${scope})` : '';
|
|
223
|
+
const queryNote = queryStr ? ` matching "${queryStr}"` : '';
|
|
224
|
+
console.log(`No lore in ${projectName}${scopeNote}${queryNote}.`);
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
for (let i = 0; i < result.facts.length; i++) {
|
|
228
|
+
console.log(`${i + 1}. ${result.facts[i].text}`);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
// ---------- list ----------------------------------------------------------
|
|
232
|
+
async function listCmd(args) {
|
|
233
|
+
const cfg = getConfig();
|
|
234
|
+
if (!cfg.apiKey)
|
|
235
|
+
abortNotConfigured();
|
|
236
|
+
const format = (getFlag(args, '--format') || 'text').toLowerCase();
|
|
237
|
+
if (format !== 'text' && format !== 'json' && format !== 'markdown') {
|
|
238
|
+
console.error('--format must be text, markdown, or json');
|
|
239
|
+
process.exit(1);
|
|
240
|
+
}
|
|
241
|
+
const { projectId, projectName } = await resolveProject(args, cfg.apiUrl, cfg.apiKey);
|
|
242
|
+
const result = await apiGet(`${cfg.apiUrl}/v1/facts/${projectId}/list`, cfg.apiKey);
|
|
243
|
+
if (!result.ok || !result.facts)
|
|
244
|
+
throw new Error(result.error || 'list failed');
|
|
245
|
+
if (format === 'json') {
|
|
246
|
+
console.log(JSON.stringify({
|
|
247
|
+
project: projectName,
|
|
248
|
+
lore: result.facts,
|
|
249
|
+
}, null, 2));
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
if (result.facts.length === 0) {
|
|
253
|
+
console.log(`No lore seeded in ${projectName} yet.`);
|
|
254
|
+
console.log('Add some: greprag lore add "<text>" --scope <scope>');
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
// Group by scope (server already orders scope ASC, createdAt DESC).
|
|
258
|
+
const grouped = new Map();
|
|
259
|
+
for (const f of result.facts) {
|
|
260
|
+
const scope = f.scope || '(no scope)';
|
|
261
|
+
if (!grouped.has(scope))
|
|
262
|
+
grouped.set(scope, []);
|
|
263
|
+
grouped.get(scope).push(f);
|
|
264
|
+
}
|
|
265
|
+
console.log(`\n${result.facts.length} lore entr${result.facts.length === 1 ? 'y' : 'ies'} in ${projectName}:\n`);
|
|
266
|
+
for (const [scope, rows] of grouped) {
|
|
267
|
+
console.log(`## ${scope} (${rows.length})`);
|
|
268
|
+
for (const f of rows) {
|
|
269
|
+
const date = f.createdAt ? f.createdAt.slice(0, 10) : '';
|
|
270
|
+
console.log(` [${f.nodeId}] ${date} ${f.text}`);
|
|
271
|
+
}
|
|
272
|
+
console.log('');
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
// ---------- delete --------------------------------------------------------
|
|
276
|
+
async function deleteCmd(args) {
|
|
277
|
+
const cfg = getConfig();
|
|
278
|
+
if (!cfg.apiKey)
|
|
279
|
+
abortNotConfigured();
|
|
280
|
+
const nodeId = args[0];
|
|
281
|
+
if (!nodeId || nodeId.startsWith('--')) {
|
|
282
|
+
console.error('Usage: greprag lore delete <nodeId> [--project <name>]');
|
|
283
|
+
process.exit(1);
|
|
284
|
+
}
|
|
285
|
+
if (!/^[0-9a-f]{8}$/i.test(nodeId)) {
|
|
286
|
+
console.error('nodeId must be 8 hex chars (printed in `greprag lore list`).');
|
|
287
|
+
process.exit(1);
|
|
288
|
+
}
|
|
289
|
+
const { projectId, projectName } = await resolveProject(args, cfg.apiUrl, cfg.apiKey);
|
|
290
|
+
const result = await apiDelete(`${cfg.apiUrl}/v1/facts/${projectId}/${nodeId}`, cfg.apiKey);
|
|
291
|
+
if (!result.ok)
|
|
292
|
+
throw new Error(result.error || 'delete failed');
|
|
293
|
+
console.log(`Deleted lore [${nodeId}] from ${projectName}`);
|
|
294
|
+
}
|
|
295
|
+
// ---------- scopes --------------------------------------------------------
|
|
296
|
+
async function scopesCmd(args) {
|
|
297
|
+
const cfg = getConfig();
|
|
298
|
+
if (!cfg.apiKey)
|
|
299
|
+
abortNotConfigured();
|
|
300
|
+
const { projectId, projectName } = await resolveProject(args, cfg.apiUrl, cfg.apiKey);
|
|
301
|
+
const result = await apiGet(`${cfg.apiUrl}/v1/facts/${projectId}/scopes`, cfg.apiKey);
|
|
302
|
+
if (!result.ok || !result.scopes)
|
|
303
|
+
throw new Error(result.error || 'scopes failed');
|
|
304
|
+
if (result.scopes.length === 0) {
|
|
305
|
+
console.log(`No scopes in ${projectName} yet.`);
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
for (const s of result.scopes)
|
|
309
|
+
console.log(s);
|
|
310
|
+
}
|
|
311
|
+
// ---------- Dispatch ------------------------------------------------------
|
|
312
|
+
const SUB_HELP = `
|
|
313
|
+
greprag lore — per-project LEARNINGS substrate.
|
|
314
|
+
|
|
315
|
+
Subcommands:
|
|
316
|
+
add "<text>" --scope <S> [--project <name>] [--source-session <id>]
|
|
317
|
+
Append a new lore entry under the given scope.
|
|
318
|
+
query [--scope <S>] [--query "<intent>"] [--project <name>]
|
|
319
|
+
[--limit N=10] [--format markdown|json]
|
|
320
|
+
Read lore. With --query, lexical-rank by
|
|
321
|
+
relevance. Without, most recent first.
|
|
322
|
+
list [--project <name>] [--format markdown|json]
|
|
323
|
+
Every lore entry grouped by scope (for review).
|
|
324
|
+
delete <nodeId> [--project <name>]
|
|
325
|
+
Drop one lore entry by its 8-char nodeId.
|
|
326
|
+
scopes [--project <name>] Distinct scope labels present in this project.
|
|
327
|
+
|
|
328
|
+
Examples:
|
|
329
|
+
greprag lore add "Migrations live at repo root, not packages/api/migrations." --scope chip-startup
|
|
330
|
+
greprag lore query --scope chip-startup --limit 10 --format markdown
|
|
331
|
+
greprag lore query --query "where do migrations live" --limit 5
|
|
332
|
+
greprag lore list
|
|
333
|
+
greprag lore delete a3f2c1d4
|
|
334
|
+
greprag lore scopes
|
|
335
|
+
`.trim();
|
|
336
|
+
async function runLore(args) {
|
|
337
|
+
const sub = args[0];
|
|
338
|
+
const rest = args.slice(1);
|
|
339
|
+
switch (sub) {
|
|
340
|
+
case 'add': return addCmd(rest);
|
|
341
|
+
case 'query': return queryCmd(rest);
|
|
342
|
+
case 'list': return listCmd(rest);
|
|
343
|
+
case 'delete': return deleteCmd(rest);
|
|
344
|
+
case 'scopes': return scopesCmd(rest);
|
|
345
|
+
case undefined:
|
|
346
|
+
case 'help':
|
|
347
|
+
case '--help':
|
|
348
|
+
case '-h':
|
|
349
|
+
console.log(SUB_HELP);
|
|
350
|
+
return;
|
|
351
|
+
default:
|
|
352
|
+
console.error(`Unknown subcommand: ${sub}\n`);
|
|
353
|
+
console.log(SUB_HELP);
|
|
354
|
+
process.exit(1);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
//# sourceMappingURL=lore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lore.js","sourceRoot":"","sources":["../../src/commands/lore.ts"],"names":[],"mappings":";AAAA,0BAA0B;AAC1B;;;;;;;;;;;;;;;;;;;;;;;;;;mDA0BmD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwVnD,0BAoBC;AA1WD,uCAAyB;AACzB,2CAA6B;AAC7B,sDAA+C;AAE/C,MAAM,eAAe,GAAG,yBAAyB,CAAC;AAElD,6EAA6E;AAE7E,SAAS,WAAW,CAAC,QAAgB;IACnC,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QACnD,KAAK,MAAM,IAAI,IAAI,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;YACvC,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;YAC5B,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,UAAU,CAAC,GAAG,CAA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CAAI,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC;QACnC,KAAK,OAAO,CAAC,CAAE,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC;QACrC,KAAK,MAAM,CAAC,CAAG,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC;QACpC,KAAK,QAAQ,CAAC,CAAC,OAAO,SAAS,CAAC,IAAI,CAAC,CAAC;QACtC,KAAK,QAAQ,CAAC,CAAC,OAAO,SAAS,CAAC,IAAI,CAAC,CAAC;QACtC,KAAK,SAAS,CAAC;QACf,KAAK,MAAM,CAAC;QACZ,KAAK,QAAQ,CAAC;QACd,KAAK,IAAI;YACP,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YACtB,OAAO;QACT;YACE,OAAO,CAAC,KAAK,CAAC,uBAAuB,GAAG,IAAI,CAAC,CAAC;YAC9C,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YACtB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;AACH,CAAC"}
|
package/dist/commands/status.js
CHANGED
|
@@ -121,10 +121,12 @@ function buildStatus(cwd) {
|
|
|
121
121
|
hooks: {
|
|
122
122
|
session_start_recap: hasGrepragHook(settings.hooks?.SessionStart, 'recap'),
|
|
123
123
|
stop_store: hasGrepragHook(settings.hooks?.Stop, 'store'),
|
|
124
|
-
|
|
124
|
+
pre_tool_use_spawn_check: hasGrepragHook(settings.hooks?.PreToolUse, 'pre-spawn-check'),
|
|
125
125
|
// user_prompt_submit_notify removed in v5.6.1 — the inbox-count polling
|
|
126
126
|
// it surfaced was the eavesdrop vector. Live inbox delivery is now the
|
|
127
127
|
// Monitor watcher's exclusive job.
|
|
128
|
+
// post_tool_use_spawn_reminder removed in v5.6.2 — validation moved to
|
|
129
|
+
// PreToolUse pre-spawn-check + SessionStart auto-armed watcher.
|
|
128
130
|
},
|
|
129
131
|
project: {
|
|
130
132
|
cwd: path.resolve(cwd),
|
|
@@ -155,7 +157,7 @@ function renderHuman(s) {
|
|
|
155
157
|
`Hooks:`,
|
|
156
158
|
` SessionStart recap: ${check(s.hooks.session_start_recap)}`,
|
|
157
159
|
` Stop store: ${check(s.hooks.stop_store)}`,
|
|
158
|
-
`
|
|
160
|
+
` PreToolUse pre-spawn-check:${check(s.hooks.pre_tool_use_spawn_check)}`,
|
|
159
161
|
``,
|
|
160
162
|
`Project (${s.project.cwd}):`,
|
|
161
163
|
` Anchor found: ${check(s.project.anchor_found)}${s.project.is_deterministic_fallback ? ' (using deterministic-hash fallback)' : ''}`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status.js","sourceRoot":"","sources":["../../src/commands/status.ts"],"names":[],"mappings":";AAAA;;;;;;;;uDAQuD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"status.js","sourceRoot":"","sources":["../../src/commands/status.ts"],"names":[],"mappings":";AAAA;;;;;;;;uDAQuD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqGvD,kCAoDC;AA+BD,8BASC;AA/LD,uCAAyB;AACzB,2CAA6B;AAC7B,sDAA+C;AAC/C,yCAA4D;AA8C5D,SAAS,eAAe;IACtB,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,EAAE,CAAC;IAC/D,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,EAAE,eAAe,CAAC,CAAC;AACrD,CAAC;AAED,SAAS,YAAY,CAAC,YAAoB;IACxC,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,YAAY,EAAE,OAAO,CAAC,CAAmB,CAAC;IAC9E,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC;AAED,SAAS,cAAc,CACrB,WAAuE,EACvE,UAAkB;IAElB,IAA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|
@@ -1010,60 +1010,47 @@ async function notify(_input) {
|
|
|
1010
1010
|
// Intentional no-op. See docstring above.
|
|
1011
1011
|
return;
|
|
1012
1012
|
}
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
const ownIdToken = '<your-own-session-id>';
|
|
1041
|
-
const text = `[GrepRAG] Chip spawned. The chip will report back via greprag inbox; `
|
|
1042
|
-
+ `mid-task replies are invisible without an SSE watcher. `
|
|
1043
|
-
+ `Arm THIS under \`Monitor\` (persistent:true) THIS TURN, and make sure `
|
|
1044
|
-
+ `your chip prompt's Block 2 sends with --to <email>/${ownIdToken} `
|
|
1045
|
-
+ `(scope mismatch = silent delivery failure):\n`
|
|
1046
|
-
+ ` \`while true; do greprag inbox watch --session ${ownIdToken} --json; `
|
|
1047
|
-
+ `echo "[wrapper] watcher exited, restarting in 1s" >&2; sleep 1; done\`\n`
|
|
1048
|
-
+ `Substitute ${ownIdToken} with the short id from your SessionStart hook `
|
|
1049
|
-
+ `("Your greprag session id: <8-hex>"). It is always present in a current session. `
|
|
1050
|
-
+ `The \`--project <parent-project>\` form exists ONLY for the rare case of `
|
|
1051
|
-
+ `orchestrating multiple chips in parallel and wanting all reports on one stream — `
|
|
1052
|
-
+ `do not default to it. Cross-project broadcasts pollute sibling chips' inboxes. `
|
|
1053
|
-
+ `See ~/.claude/docs/agent-coordination.md § Block 3 + Parent-side: watch for the report.`;
|
|
1013
|
+
function handlePreSpawnCheck(input) {
|
|
1014
|
+
if (input.tool_name !== 'mcp__ccd_session__spawn_task')
|
|
1015
|
+
return;
|
|
1016
|
+
const title = input.tool_input?.title ?? '';
|
|
1017
|
+
const prompt = input.tool_input?.prompt ?? '';
|
|
1018
|
+
const violations = [];
|
|
1019
|
+
if (!title.startsWith('Chip: ')) {
|
|
1020
|
+
violations.push(`title "${title}" missing required "Chip: " prefix. ` +
|
|
1021
|
+
`Format: "Chip: <imperative verb phrase>" — e.g. "Chip: Fix stale README badge". ` +
|
|
1022
|
+
`The prefix distinguishes chip-spawned sessions from IDE/human sessions in FleetView.`);
|
|
1023
|
+
}
|
|
1024
|
+
if (!/\bgit\s+worktree\s+add\b/.test(prompt)) {
|
|
1025
|
+
violations.push(`prompt missing worktree setup. ` +
|
|
1026
|
+
`Block 1 requires the chip to open with: \`git worktree add .claude/worktrees/<slug> -b chip/<slug>\` ` +
|
|
1027
|
+
`then \`cd\` into it. Chips never edit the main checkout.`);
|
|
1028
|
+
}
|
|
1029
|
+
if (!/\bgreprag\s+send\b/.test(prompt)) {
|
|
1030
|
+
violations.push(`prompt missing report-back instruction. ` +
|
|
1031
|
+
`Block 2 requires the chip to send a status message via: ` +
|
|
1032
|
+
`\`greprag send "<status>: <commit> on chip/<slug>" --to <handle>@greprag.com/<parent-session-id> ` +
|
|
1033
|
+
`--from-session <own-session-id> --artifact commit:<hash>\`.`);
|
|
1034
|
+
}
|
|
1035
|
+
if (violations.length === 0)
|
|
1036
|
+
return;
|
|
1037
|
+
const reason = `Chip prompt rejected by greprag PreToolUse validator. Fix the following and re-call spawn_task:\n - ` +
|
|
1038
|
+
violations.join('\n - ') +
|
|
1039
|
+
`\n\nFull conventions: ~/.claude/CLAUDE.md § Chip Spawning.`;
|
|
1054
1040
|
const payload = {
|
|
1055
1041
|
hookSpecificOutput: {
|
|
1056
|
-
hookEventName: '
|
|
1057
|
-
|
|
1042
|
+
hookEventName: 'PreToolUse',
|
|
1043
|
+
permissionDecision: 'deny',
|
|
1044
|
+
permissionDecisionReason: reason,
|
|
1058
1045
|
},
|
|
1059
1046
|
};
|
|
1060
1047
|
process.stdout.write(JSON.stringify(payload) + '\n');
|
|
1061
1048
|
}
|
|
1062
1049
|
async function main() {
|
|
1063
1050
|
const subcommand = process.argv[2];
|
|
1064
|
-
const validSubs = new Set(['store', 'recap', 'notify', 'session-id', 'spawn-
|
|
1051
|
+
const validSubs = new Set(['store', 'recap', 'notify', 'session-id', 'pre-spawn-check']);
|
|
1065
1052
|
if (!validSubs.has(subcommand)) {
|
|
1066
|
-
process.stderr.write(`Usage: greprag-hook <store|recap|notify|session-id|spawn-
|
|
1053
|
+
process.stderr.write(`Usage: greprag-hook <store|recap|notify|session-id|pre-spawn-check>\n`);
|
|
1067
1054
|
process.exit(1);
|
|
1068
1055
|
}
|
|
1069
1056
|
let input = {};
|
|
@@ -1095,8 +1082,8 @@ async function main() {
|
|
|
1095
1082
|
const cfg = getConfig(cwd);
|
|
1096
1083
|
(0, session_id_1.handleSessionIdHook)(input, { armWatcher: cfg.enabled && !!cfg.apiKey });
|
|
1097
1084
|
}
|
|
1098
|
-
else if (subcommand === 'spawn-
|
|
1099
|
-
|
|
1085
|
+
else if (subcommand === 'pre-spawn-check') {
|
|
1086
|
+
handlePreSpawnCheck(input);
|
|
1100
1087
|
}
|
|
1101
1088
|
else {
|
|
1102
1089
|
await store(input);
|