greprag 5.49.10 → 5.49.12
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/arm-reminder.d.ts +10 -3
- package/dist/commands/arm-reminder.js +18 -6
- package/dist/commands/arm-reminder.js.map +1 -1
- package/dist/commands/collision-check.d.ts +1 -2
- package/dist/commands/collision-check.js +1 -2
- package/dist/commands/collision-check.js.map +1 -1
- package/dist/commands/inbox-drain.d.ts +9 -10
- package/dist/commands/inbox-drain.js +9 -10
- package/dist/commands/inbox-drain.js.map +1 -1
- package/dist/commands/inbox-primer-reminder.d.ts +10 -5
- package/dist/commands/inbox-primer-reminder.js +35 -21
- package/dist/commands/inbox-primer-reminder.js.map +1 -1
- package/dist/commands/poll-registry.d.ts +52 -9
- package/dist/commands/poll-registry.js +176 -9
- package/dist/commands/poll-registry.js.map +1 -1
- package/dist/commands/procedure.d.ts +15 -0
- package/dist/commands/procedure.js +167 -0
- package/dist/commands/procedure.js.map +1 -0
- package/dist/commands/reminder-registry.d.ts +5 -0
- package/dist/commands/reminder-registry.js +7 -3
- package/dist/commands/reminder-registry.js.map +1 -1
- package/dist/commands/reminder-types.d.ts +7 -5
- package/dist/hook.js +26 -46
- package/dist/hook.js.map +1 -1
- package/dist/index.js +4 -12
- package/dist/index.js.map +1 -1
- package/dist/procedure.d.ts +88 -0
- package/dist/procedure.js +269 -0
- package/dist/procedure.js.map +1 -0
- package/package.json +1 -1
- package/dist/commands/checkpoint-reminder.d.ts +0 -14
- package/dist/commands/checkpoint-reminder.js +0 -50
- package/dist/commands/checkpoint-reminder.js.map +0 -1
- package/dist/commands/frontdesk-reminder.d.ts +0 -23
- package/dist/commands/frontdesk-reminder.js +0 -43
- package/dist/commands/frontdesk-reminder.js.map +0 -1
- package/dist/commands/inbox-poll.d.ts +0 -47
- package/dist/commands/inbox-poll.js +0 -261
- package/dist/commands/inbox-poll.js.map +0 -1
- package/dist/commands/inbox-spool.d.ts +0 -27
- package/dist/commands/inbox-spool.js +0 -151
- package/dist/commands/inbox-spool.js.map +0 -1
- package/dist/commands/lore.d.ts +0 -35
- package/dist/commands/lore.js +0 -504
- package/dist/commands/lore.js.map +0 -1
- package/dist/front-desk-mail.d.ts +0 -50
- package/dist/front-desk-mail.js +0 -206
- package/dist/front-desk-mail.js.map +0 -1
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
2
|
+
/** Poll registry — local pidfile tracking for the asyncRewake idle-liveness
|
|
3
|
+
* polls (`greprag inbox poll`), kept in its OWN namespace `~/.greprag/polls/`
|
|
4
|
+
* so it NEVER touches the Monitor watcher's `~/.greprag/watchers/` registry.
|
|
3
5
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* adr/monitor-resilience.md
|
|
9
|
-
*
|
|
6
|
+
* WHY SEPARATE: `notify`'s `isLocallyArmed` reads the watcher registry to decide
|
|
7
|
+
* whether to inject the Monitor arm directive. If a poll registered there, the
|
|
8
|
+
* Monitor arm would go silent and the poll would REPLACE Monitor instead of
|
|
9
|
+
* running ALONGSIDE it. The two liveness mechanisms must be independent until a
|
|
10
|
+
* deliberate cutover. adr: adr/monitor-resilience.md
|
|
11
|
+
*
|
|
12
|
+
* The cleanup model mirrors the SHIPPED watcher count-cap (and reuses its pure
|
|
13
|
+
* `capSurplusVerdict`): per session, keep the K freshest LIVE polls, reap only
|
|
14
|
+
* the surplus, never below K. No death-judgment — a count + a floor — so it can
|
|
15
|
+
* never false-kill the live poll. Reload-orphans (if asyncRewake does not adopt
|
|
16
|
+
* a process across reload) are bounded here AND self-clean via the poll's own
|
|
17
|
+
* max-lifetime ceiling. */
|
|
10
18
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
11
19
|
if (k2 === undefined) k2 = k;
|
|
12
20
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -41,12 +49,23 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
41
49
|
};
|
|
42
50
|
})();
|
|
43
51
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
52
|
+
exports.DEFAULT_POLL_CAP = void 0;
|
|
53
|
+
exports.registerPoll = registerPoll;
|
|
54
|
+
exports.deregisterPoll = deregisterPoll;
|
|
55
|
+
exports.isPollArmed = isPollArmed;
|
|
56
|
+
exports.listLivePolls = listLivePolls;
|
|
44
57
|
exports.readPollCursor = readPollCursor;
|
|
45
58
|
exports.writePollCursor = writePollCursor;
|
|
46
59
|
exports.clearPollCursor = clearPollCursor;
|
|
60
|
+
exports.reapSurplusPolls = reapSurplusPolls;
|
|
47
61
|
const fs = __importStar(require("fs"));
|
|
48
62
|
const path = __importStar(require("path"));
|
|
63
|
+
const child_process_1 = require("child_process");
|
|
64
|
+
const watcher_registry_1 = require("./watcher-registry");
|
|
49
65
|
const POLL_DIRNAME = 'polls';
|
|
66
|
+
/** Default per-session poll floor: keep this many freshest live polls, reap the
|
|
67
|
+
* surplus, never below it. K=2 = the live one + one margin (a reload overlap). */
|
|
68
|
+
exports.DEFAULT_POLL_CAP = 2;
|
|
50
69
|
function grepragHome() {
|
|
51
70
|
const home = process.env.HOME || process.env.USERPROFILE || '';
|
|
52
71
|
return home ? path.join(home, '.greprag') : null;
|
|
@@ -55,11 +74,105 @@ function pollsDir() {
|
|
|
55
74
|
const h = grepragHome();
|
|
56
75
|
return h ? path.join(h, POLL_DIRNAME) : null;
|
|
57
76
|
}
|
|
77
|
+
function pollfilePath(short) {
|
|
78
|
+
const dir = pollsDir();
|
|
79
|
+
return dir ? path.join(dir, `${short}.json`) : null;
|
|
80
|
+
}
|
|
81
|
+
/** True iff `pid` is a live process. `process.kill(pid, 0)` probes existence
|
|
82
|
+
* without signalling; EPERM = exists (another user), ESRCH = gone. */
|
|
83
|
+
function pidAlive(pid) {
|
|
84
|
+
if (!Number.isFinite(pid) || pid <= 0)
|
|
85
|
+
return false;
|
|
86
|
+
try {
|
|
87
|
+
process.kill(pid, 0);
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
catch (e) {
|
|
91
|
+
return e?.code === 'EPERM';
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
function readPollEntries(short) {
|
|
95
|
+
try {
|
|
96
|
+
const p = pollfilePath(short);
|
|
97
|
+
if (!p)
|
|
98
|
+
return [];
|
|
99
|
+
const parsed = JSON.parse(fs.readFileSync(p, 'utf-8'));
|
|
100
|
+
const arr = Array.isArray(parsed) ? parsed : [parsed];
|
|
101
|
+
return arr.filter((r) => !!r && typeof r.pid === 'number');
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
return [];
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function writePollEntries(short, entries) {
|
|
108
|
+
try {
|
|
109
|
+
const dir = pollsDir();
|
|
110
|
+
if (!dir)
|
|
111
|
+
return;
|
|
112
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
113
|
+
const p = path.join(dir, `${short}.json`);
|
|
114
|
+
if (entries.length === 0) {
|
|
115
|
+
fs.rmSync(p, { force: true });
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
fs.writeFileSync(p, JSON.stringify(entries));
|
|
119
|
+
}
|
|
120
|
+
catch { /* best-effort — a failed write only means a re-arm, never a crash */ }
|
|
121
|
+
}
|
|
122
|
+
function allShorts() {
|
|
123
|
+
try {
|
|
124
|
+
const dir = pollsDir();
|
|
125
|
+
if (!dir || !fs.existsSync(dir))
|
|
126
|
+
return [];
|
|
127
|
+
return fs.readdirSync(dir).filter(f => f.endsWith('.json')).map(f => f.slice(0, -5));
|
|
128
|
+
}
|
|
129
|
+
catch {
|
|
130
|
+
return [];
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
/** APPEND this poll's entry (pruning dead entries as it goes). Best-effort. */
|
|
134
|
+
function registerPoll(short, pid) {
|
|
135
|
+
const entries = readPollEntries(short).filter(r => r.pid !== pid && pidAlive(r.pid));
|
|
136
|
+
entries.push({ short, pid, startedAt: Date.now() });
|
|
137
|
+
writePollEntries(short, entries);
|
|
138
|
+
}
|
|
139
|
+
/** Remove THIS poll's entry (on the poll's own exit — message-wake or ceiling). */
|
|
140
|
+
function deregisterPoll(short, pid) {
|
|
141
|
+
writePollEntries(short, readPollEntries(short).filter(r => r.pid !== pid));
|
|
142
|
+
}
|
|
143
|
+
/** Does this session have ANY live poll right now? The re-arm gate: a gated arm
|
|
144
|
+
* (PostToolUse / UserPromptSubmit) skips when true so per-tool fires don't pile
|
|
145
|
+
* up; SessionStart never gates (it always arms a fresh, reload-adopted poll).
|
|
146
|
+
* Sweeps dead entries as it reads. */
|
|
147
|
+
function isPollArmed(short) {
|
|
148
|
+
const entries = readPollEntries(short);
|
|
149
|
+
const alive = entries.filter(r => pidAlive(r.pid));
|
|
150
|
+
if (alive.length !== entries.length)
|
|
151
|
+
writePollEntries(short, alive);
|
|
152
|
+
return alive.length > 0;
|
|
153
|
+
}
|
|
154
|
+
/** Every live poll on this machine, freshest first. */
|
|
155
|
+
function listLivePolls() {
|
|
156
|
+
const out = [];
|
|
157
|
+
for (const short of allShorts()) {
|
|
158
|
+
const entries = readPollEntries(short);
|
|
159
|
+
const alive = entries.filter(r => pidAlive(r.pid));
|
|
160
|
+
if (alive.length !== entries.length)
|
|
161
|
+
writePollEntries(short, alive);
|
|
162
|
+
out.push(...alive);
|
|
163
|
+
}
|
|
164
|
+
return out.sort((a, b) => (b.startedAt || 0) - (a.startedAt || 0));
|
|
165
|
+
}
|
|
166
|
+
// ---- Cursor (gap-recovery so the long-poll never loses a message) ----------
|
|
167
|
+
// Each poll resumes the SSE stream from the last id it persisted (`?since=`),
|
|
168
|
+
// so a message that arrives between one poll exiting and the next arming is
|
|
169
|
+
// REPLAYED, not lost. The cursor is per-session, shared across poll invocations.
|
|
58
170
|
function cursorPath(short) {
|
|
59
171
|
const dir = pollsDir();
|
|
60
172
|
return dir ? path.join(dir, `${short}.cursor`) : null;
|
|
61
173
|
}
|
|
62
|
-
/** Last message id this session
|
|
174
|
+
/** Last message id this session's polls have seen, or null (first poll → live
|
|
175
|
+
* tail only; no replay of pre-existing history). */
|
|
63
176
|
function readPollCursor(short) {
|
|
64
177
|
try {
|
|
65
178
|
const p = cursorPath(short);
|
|
@@ -82,7 +195,10 @@ function writePollCursor(short, id) {
|
|
|
82
195
|
}
|
|
83
196
|
catch { /* best-effort — at worst one message is re-delivered */ }
|
|
84
197
|
}
|
|
85
|
-
/** Drop the cursor (→ next
|
|
198
|
+
/** Drop the cursor (→ next poll live-tails from now). Called when the server
|
|
199
|
+
* rejects the stored `since` (the message it points to was pruned/deleted): a
|
|
200
|
+
* stale cursor would otherwise 4xx forever, permanently wedging delivery for
|
|
201
|
+
* this session. Clearing it trades replay of the gap for restored liveness. */
|
|
86
202
|
function clearPollCursor(short) {
|
|
87
203
|
try {
|
|
88
204
|
const p = cursorPath(short);
|
|
@@ -91,4 +207,55 @@ function clearPollCursor(short) {
|
|
|
91
207
|
}
|
|
92
208
|
catch { /* best-effort */ }
|
|
93
209
|
}
|
|
210
|
+
/** Count-cap every session's polls: keep the K freshest LIVE polls, kill only the
|
|
211
|
+
* surplus, never below K. Snapshot-free (per-session file reads + pidAlive); a
|
|
212
|
+
* `taskkill` only on genuine surplus. Run at SessionStart (recap hook) and via
|
|
213
|
+
* `greprag inbox poll-reap`. Reuses the watcher's pure `capSurplusVerdict` — the
|
|
214
|
+
* same liveness-safety guarantee, applied to the poll namespace.
|
|
215
|
+
* adr: adr/monitor-resilience.md */
|
|
216
|
+
function reapSurplusPolls(K = exports.DEFAULT_POLL_CAP) {
|
|
217
|
+
let scanned = 0;
|
|
218
|
+
let surplus = 0;
|
|
219
|
+
const killed = [];
|
|
220
|
+
for (const short of allShorts()) {
|
|
221
|
+
const alive = readPollEntries(short).filter(r => pidAlive(r.pid));
|
|
222
|
+
scanned += alive.length;
|
|
223
|
+
const { keep, kill } = (0, watcher_registry_1.capSurplusVerdict)(alive, K);
|
|
224
|
+
if (kill.length === 0) {
|
|
225
|
+
writePollEntries(short, alive);
|
|
226
|
+
continue;
|
|
227
|
+
}
|
|
228
|
+
surplus += kill.length;
|
|
229
|
+
const survivors = keep.slice();
|
|
230
|
+
for (const w of kill) {
|
|
231
|
+
if (killProcess(w.pid))
|
|
232
|
+
killed.push(w.pid);
|
|
233
|
+
else
|
|
234
|
+
survivors.push(w); // kill failed → keep tracking, retry next pass
|
|
235
|
+
}
|
|
236
|
+
writePollEntries(short, survivors);
|
|
237
|
+
}
|
|
238
|
+
return { scanned, surplus, killed };
|
|
239
|
+
}
|
|
240
|
+
/** Force-kill a poll process. A poll has no children (single SSE process), so a
|
|
241
|
+
* plain kill suffices — but `taskkill /T` is used on Windows for symmetry with
|
|
242
|
+
* the watcher and to catch any incidental child. */
|
|
243
|
+
function killProcess(pid) {
|
|
244
|
+
try {
|
|
245
|
+
if (process.platform === 'win32') {
|
|
246
|
+
(0, child_process_1.execFileSync)('taskkill.exe', ['/PID', String(pid), '/T', '/F'], // proc-allow: poll count-cap surplus kill, mirrors watcher-registry
|
|
247
|
+
{ timeout: 5_000, stdio: 'ignore', windowsHide: true });
|
|
248
|
+
}
|
|
249
|
+
else {
|
|
250
|
+
try {
|
|
251
|
+
process.kill(pid, 'SIGKILL');
|
|
252
|
+
}
|
|
253
|
+
catch { /* already gone */ }
|
|
254
|
+
}
|
|
255
|
+
return true;
|
|
256
|
+
}
|
|
257
|
+
catch {
|
|
258
|
+
return false;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
94
261
|
//# sourceMappingURL=poll-registry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"poll-registry.js","sourceRoot":"","sources":["../../src/commands/poll-registry.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"poll-registry.js","sourceRoot":"","sources":["../../src/commands/poll-registry.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;4BAe4B;;;;;;;;;;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AAC,EAAE,IAAI,EAAE,IAAI,CAAC,EAAG,oEAAoE;YACnI,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC;QAC5D,CAAC;aAAM,CAAC;YACN,IAAI,CAAC;gBAAC,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;YAAC,CAAC;YAAC,MAAM,CAAC,CAAC,kBAAkB,CAAC,CAAC;QACpE,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QAAC,OAAO,KAAK,CAAC;IAAC,CAAC;AAC3B,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** `greprag procedure` — manage the project's operational recipes
|
|
2
|
+
* (docs/procedure-system.md). PROOF slice: seed + inspect + dry-run match.
|
|
3
|
+
*
|
|
4
|
+
* Subcommands:
|
|
5
|
+
* list — show this project's procedures
|
|
6
|
+
* show <verb> — print one procedure + its injection text
|
|
7
|
+
* seed [--git] — write the git-ecosystem seed set (commit/merge/push/deploy/release)
|
|
8
|
+
* register --verb V --steps "..." [--caveats "..."] [--endpoint "..."] [--trigger T ...] [--destructive]
|
|
9
|
+
* rm <verb> — remove a procedure
|
|
10
|
+
* match "<text>" — dry-run: what would inject for this prompt
|
|
11
|
+
*
|
|
12
|
+
* Identity comes from the project anchor (git-root-derived), same key the
|
|
13
|
+
* hot-path hook uses. Zero network — the store is the local file beside the
|
|
14
|
+
* matchset cache. */
|
|
15
|
+
export declare function runProcedure(args: string[]): Promise<void>;
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/** `greprag procedure` — manage the project's operational recipes
|
|
3
|
+
* (docs/procedure-system.md). PROOF slice: seed + inspect + dry-run match.
|
|
4
|
+
*
|
|
5
|
+
* Subcommands:
|
|
6
|
+
* list — show this project's procedures
|
|
7
|
+
* show <verb> — print one procedure + its injection text
|
|
8
|
+
* seed [--git] — write the git-ecosystem seed set (commit/merge/push/deploy/release)
|
|
9
|
+
* register --verb V --steps "..." [--caveats "..."] [--endpoint "..."] [--trigger T ...] [--destructive]
|
|
10
|
+
* rm <verb> — remove a procedure
|
|
11
|
+
* match "<text>" — dry-run: what would inject for this prompt
|
|
12
|
+
*
|
|
13
|
+
* Identity comes from the project anchor (git-root-derived), same key the
|
|
14
|
+
* hot-path hook uses. Zero network — the store is the local file beside the
|
|
15
|
+
* matchset cache. */
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.runProcedure = runProcedure;
|
|
18
|
+
const procedure_1 = require("../procedure");
|
|
19
|
+
const project_anchor_1 = require("../project-anchor");
|
|
20
|
+
function getFlag(args, flag) {
|
|
21
|
+
const idx = args.indexOf(flag);
|
|
22
|
+
if (idx === -1 || idx + 1 >= args.length)
|
|
23
|
+
return undefined;
|
|
24
|
+
return args[idx + 1];
|
|
25
|
+
}
|
|
26
|
+
/** Collect every `--trigger X` occurrence (repeatable flag). */
|
|
27
|
+
function collectFlags(args, flag) {
|
|
28
|
+
const out = [];
|
|
29
|
+
for (let i = 0; i < args.length - 1; i++) {
|
|
30
|
+
if (args[i] === flag)
|
|
31
|
+
out.push(args[i + 1]);
|
|
32
|
+
}
|
|
33
|
+
return out;
|
|
34
|
+
}
|
|
35
|
+
function resolveProjectId() {
|
|
36
|
+
const anchor = (0, project_anchor_1.readAnchor)(process.cwd());
|
|
37
|
+
return { projectId: anchor.projectId, projectName: anchor.projectName };
|
|
38
|
+
}
|
|
39
|
+
function printProcedure(p) {
|
|
40
|
+
const tag = p.destructive ? ' [DESTRUCTIVE — seed-only]' : '';
|
|
41
|
+
console.log(` ${p.verb} (${p.status})${tag}`);
|
|
42
|
+
console.log(` triggers: ${p.triggers.join(', ')}`);
|
|
43
|
+
console.log(` steps: ${p.steps}`);
|
|
44
|
+
if (p.caveats)
|
|
45
|
+
console.log(` gate: ${p.caveats}`);
|
|
46
|
+
if (p.endpoint)
|
|
47
|
+
console.log(` endpoint: ${p.endpoint}`);
|
|
48
|
+
}
|
|
49
|
+
async function runProcedure(args) {
|
|
50
|
+
const sub = args[0];
|
|
51
|
+
const rest = args.slice(1);
|
|
52
|
+
const { projectId, projectName } = resolveProjectId();
|
|
53
|
+
switch (sub) {
|
|
54
|
+
case 'list': {
|
|
55
|
+
const store = (0, procedure_1.readProcedureStore)(projectId);
|
|
56
|
+
if (store.procedures.length === 0) {
|
|
57
|
+
console.log(`No procedures for ${projectName}. Seed the git set: greprag procedure seed --git`);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
console.log(`Procedures for ${projectName} (${store.procedures.length}):`);
|
|
61
|
+
for (const p of store.procedures)
|
|
62
|
+
printProcedure(p);
|
|
63
|
+
console.log(`\n store: ${(0, procedure_1.procedureStorePath)(projectId)}`);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
case 'show': {
|
|
67
|
+
const verb = rest[0];
|
|
68
|
+
if (!verb) {
|
|
69
|
+
console.error('Usage: greprag procedure show <verb>');
|
|
70
|
+
process.exit(1);
|
|
71
|
+
}
|
|
72
|
+
const store = (0, procedure_1.readProcedureStore)(projectId);
|
|
73
|
+
const p = store.procedures.find(x => x.verb === verb);
|
|
74
|
+
if (!p) {
|
|
75
|
+
console.error(`No procedure "${verb}" for ${projectName}.`);
|
|
76
|
+
process.exit(1);
|
|
77
|
+
}
|
|
78
|
+
printProcedure(p);
|
|
79
|
+
console.log(`\n --- injection text (what the agent sees) ---`);
|
|
80
|
+
console.log((0, procedure_1.buildProcedureInjection)(p));
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
case 'seed': {
|
|
84
|
+
// --git is the only seed set today; default to it so bare `seed` works.
|
|
85
|
+
const store = (0, procedure_1.readProcedureStore)(projectId);
|
|
86
|
+
let next = store;
|
|
87
|
+
for (const p of procedure_1.GIT_SEED_SET) {
|
|
88
|
+
next = (0, procedure_1.upsertProcedure)(next, p, /* force */ true);
|
|
89
|
+
}
|
|
90
|
+
(0, procedure_1.writeProcedureStore)(projectId, next);
|
|
91
|
+
console.log(`Seeded ${procedure_1.GIT_SEED_SET.length} git-ecosystem procedures for ${projectName}:`);
|
|
92
|
+
for (const p of procedure_1.GIT_SEED_SET)
|
|
93
|
+
console.log(` • ${p.verb}${p.destructive ? ' (destructive — seed-only)' : ''}`);
|
|
94
|
+
console.log(`\n store: ${(0, procedure_1.procedureStorePath)(projectId)}`);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
case 'register': {
|
|
98
|
+
const verb = getFlag(rest, '--verb');
|
|
99
|
+
const steps = getFlag(rest, '--steps');
|
|
100
|
+
if (!verb || !steps) {
|
|
101
|
+
console.error('Usage: greprag procedure register --verb <v> --steps "<...>" [--caveats "<...>"] [--endpoint "<...>"] [--trigger <t> ...] [--destructive]');
|
|
102
|
+
process.exit(1);
|
|
103
|
+
}
|
|
104
|
+
const triggers = collectFlags(rest, '--trigger');
|
|
105
|
+
const proc = {
|
|
106
|
+
verb,
|
|
107
|
+
triggers: triggers.length ? triggers : [verb],
|
|
108
|
+
steps,
|
|
109
|
+
caveats: getFlag(rest, '--caveats'),
|
|
110
|
+
endpoint: getFlag(rest, '--endpoint'),
|
|
111
|
+
status: 'seeded',
|
|
112
|
+
destructive: rest.includes('--destructive') || undefined,
|
|
113
|
+
};
|
|
114
|
+
const store = (0, procedure_1.readProcedureStore)(projectId);
|
|
115
|
+
(0, procedure_1.writeProcedureStore)(projectId, (0, procedure_1.upsertProcedure)(store, proc, /* force */ true));
|
|
116
|
+
console.log(`Registered procedure "${verb}" for ${projectName}.`);
|
|
117
|
+
printProcedure(proc);
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
case 'rm': {
|
|
121
|
+
const verb = rest[0];
|
|
122
|
+
if (!verb) {
|
|
123
|
+
console.error('Usage: greprag procedure rm <verb>');
|
|
124
|
+
process.exit(1);
|
|
125
|
+
}
|
|
126
|
+
const store = (0, procedure_1.readProcedureStore)(projectId);
|
|
127
|
+
if (!store.procedures.some(p => p.verb === verb)) {
|
|
128
|
+
console.error(`No procedure "${verb}" for ${projectName}.`);
|
|
129
|
+
process.exit(1);
|
|
130
|
+
}
|
|
131
|
+
(0, procedure_1.writeProcedureStore)(projectId, (0, procedure_1.removeProcedure)(store, verb));
|
|
132
|
+
console.log(`Removed procedure "${verb}".`);
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
case 'match': {
|
|
136
|
+
const text = rest.join(' ').trim();
|
|
137
|
+
if (!text) {
|
|
138
|
+
console.error('Usage: greprag procedure match "<prompt text>"');
|
|
139
|
+
process.exit(1);
|
|
140
|
+
}
|
|
141
|
+
const store = (0, procedure_1.readProcedureStore)(projectId);
|
|
142
|
+
const m = (0, procedure_1.matchProcedure)(text, store);
|
|
143
|
+
if (!m) {
|
|
144
|
+
const raw = (0, procedure_1.matchProcedure)(text, store, { ignoreIntentGuard: true });
|
|
145
|
+
if (raw) {
|
|
146
|
+
console.log(`No injection — "${raw.procedure.verb}" matched on "${raw.trigger}" but the intent guard suppressed it (reads as a mention, not a request).`);
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
console.log(`No procedure matches: "${text}"`);
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
console.log(`Matched "${m.procedure.verb}" via trigger "${m.trigger}". Would inject:\n`);
|
|
153
|
+
console.log((0, procedure_1.buildProcedureInjection)(m.procedure));
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
default:
|
|
157
|
+
console.log('greprag procedure — operational recipes for this repo (docs/procedure-system.md)');
|
|
158
|
+
console.log(' list list this project\'s procedures');
|
|
159
|
+
console.log(' show <verb> print one + its injection text');
|
|
160
|
+
console.log(' seed --git write the git-ecosystem seed set');
|
|
161
|
+
console.log(' register --verb ... hand-roll a procedure');
|
|
162
|
+
console.log(' rm <verb> remove a procedure');
|
|
163
|
+
console.log(' match "<text>" dry-run: what would inject for this prompt');
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
//# sourceMappingURL=procedure.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"procedure.js","sourceRoot":"","sources":["../../src/commands/procedure.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;sBAasB;;AAsCtB,oCA6GC;AAjJD,4CAIsB;AACtB,sDAA+C;AAE/C,SAAS,OAAO,CAAC,IAAc,EAAE,IAAY;IAC3C,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/B,IAAI,GAAG,KAAK,CAAC,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,IAAI,CAAC,MAAM;QAAE,OAAO,SAAS,CAAC;IAC3D,OAAO,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;AACvB,CAAC;AAED,gEAAgE;AAChE,SAAS,YAAY,CAAC,IAAc,EAAE,IAAY;IAChD,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QACzC,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI;YAAE,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAC9C,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,gBAAgB;IACvB,MAAM,MAAM,GAAG,IAAA,2BAAU,EAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IACzC,OAAO,EAAE,SAAS,EAAE,MAAM,CAAC,SAAS,EAAE,WAAW,EAAE,MAAM,CAAC,WAAW,EAAE,CAAC;AAC1E,CAAC;AAED,SAAS,cAAc,CAAC,CAAY;IAClC,MAAM,GAAG,GAAG,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,4BAA4B,CAAC,CA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16,11 @@ export declare const REGISTRY: ReminderModule[];
|
|
|
16
16
|
* modules (they read env.toolCommand). Announces are always prompt-side (SessionStart). */
|
|
17
17
|
export declare const promptModules: (registry?: ReminderModule[]) => ReminderModule[];
|
|
18
18
|
export declare const commandModules: (registry?: ReminderModule[]) => ReminderModule[];
|
|
19
|
+
/** PostCompact re-announce set (docs/reminder-interrupt.md). A compaction wipes the
|
|
20
|
+
* SessionStart announces from context, so the announce modules re-present afterward —
|
|
21
|
+
* by DEFAULT all of them; a module opts out with `reannounceOnCompact: false`. The
|
|
22
|
+
* hook renders these (announce-only — no memory recap body) on the PostCompact event. */
|
|
23
|
+
export declare const compactReannounceModules: (registry?: ReminderModule[]) => ReminderModule[];
|
|
19
24
|
export interface FiredReminder {
|
|
20
25
|
id: string;
|
|
21
26
|
tier: Detection['tier'];
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* PURE over ReminderEnv — the hook assembles env (i/o) and emits the returned lines;
|
|
6
6
|
* a broken module never blocks a turn (fail-open per module). */
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.commandModules = exports.promptModules = exports.REGISTRY = void 0;
|
|
8
|
+
exports.compactReannounceModules = exports.commandModules = exports.promptModules = exports.REGISTRY = void 0;
|
|
9
9
|
exports.collectReminders = collectReminders;
|
|
10
10
|
exports.bootOrder = bootOrder;
|
|
11
11
|
exports.collectAnnounces = collectAnnounces;
|
|
@@ -13,7 +13,6 @@ const inbox_primer_reminder_1 = require("./inbox-primer-reminder");
|
|
|
13
13
|
const load_primer_reminder_1 = require("./load-primer-reminder");
|
|
14
14
|
const corpus_reminder_1 = require("./corpus-reminder");
|
|
15
15
|
const setup_reminder_1 = require("./setup-reminder");
|
|
16
|
-
const frontdesk_reminder_1 = require("./frontdesk-reminder");
|
|
17
16
|
const assistant_reminder_1 = require("./assistant-reminder");
|
|
18
17
|
const memory_reflex_1 = require("./memory-reflex");
|
|
19
18
|
const arm_reminder_1 = require("./arm-reminder");
|
|
@@ -33,7 +32,6 @@ exports.REGISTRY = [
|
|
|
33
32
|
corpus_reminder_1.corpusAnnounceModule,
|
|
34
33
|
setup_reminder_1.setupWarningModule,
|
|
35
34
|
version_reminder_1.versionUpgradeModule, // Deficiency-gated announce — silent unless a newer release exists
|
|
36
|
-
frontdesk_reminder_1.frontDeskModule,
|
|
37
35
|
assistant_reminder_1.assistantDoctrineModule,
|
|
38
36
|
memory_reflex_1.memoryPrimerModule,
|
|
39
37
|
arm_reminder_1.watcherArmModule,
|
|
@@ -47,6 +45,12 @@ const promptModules = (registry = exports.REGISTRY) => registry.filter((m) => (m
|
|
|
47
45
|
exports.promptModules = promptModules;
|
|
48
46
|
const commandModules = (registry = exports.REGISTRY) => registry.filter((m) => m.source === 'command');
|
|
49
47
|
exports.commandModules = commandModules;
|
|
48
|
+
/** PostCompact re-announce set (docs/reminder-interrupt.md). A compaction wipes the
|
|
49
|
+
* SessionStart announces from context, so the announce modules re-present afterward —
|
|
50
|
+
* by DEFAULT all of them; a module opts out with `reannounceOnCompact: false`. The
|
|
51
|
+
* hook renders these (announce-only — no memory recap body) on the PostCompact event. */
|
|
52
|
+
const compactReannounceModules = (registry = exports.REGISTRY) => registry.filter((m) => m.reannounceOnCompact !== false);
|
|
53
|
+
exports.compactReannounceModules = compactReannounceModules;
|
|
50
54
|
/** Per-turn: every module's live reminder line (skipping silent), in registry order.
|
|
51
55
|
* Stacking — a turn may carry several. A detector or reminder that throws drops that
|
|
52
56
|
* module for the turn; it never blocks the others or the turn. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reminder-registry.js","sourceRoot":"","sources":["../../src/commands/reminder-registry.ts"],"names":[],"mappings":";AAAA;;;;kEAIkE;;;
|
|
1
|
+
{"version":3,"file":"reminder-registry.js","sourceRoot":"","sources":["../../src/commands/reminder-registry.ts"],"names":[],"mappings":";AAAA;;;;kEAIkE;;;AA0DlE,4CAaC;AAMD,8BAkBC;AAID,4CAUC;AA1GD,mE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YACpC,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YACxB,IAAI,CAAC;gBAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,sCAAsC;QACzD,CAAC;QACD,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QACtB,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QACjB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC;IACF,KAAK,MAAM,CAAC,IAAI,QAAQ;QAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IACnC,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;yDACyD;AACzD,SAAgB,gBAAgB,CAC9B,GAAgB,EAAE,WAA6B,gBAAQ;IAEvD,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,KAAK,MAAM,CAAC,IAAI,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC;QACpC,IAAI,CAAC,GAAkB,IAAI,CAAC;QAC5B,IAAI,CAAC;YAAC,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QAAC,CAAC;QAAC,MAAM,CAAC;YAAC,SAAS;QAAC,CAAC;QAChD,IAAI,CAAC;YAAE,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACrB,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -33,8 +33,6 @@ export interface ReminderEnv {
|
|
|
33
33
|
/** Precomputed identity setup/drift warning — the hook owns the anchor logic AND its
|
|
34
34
|
* rate-limit stamp (a side-effect), so this module half is a pass-through. */
|
|
35
35
|
setupWarning?: string | null;
|
|
36
|
-
/** Front-desk unread count (the SessionStart count announce). */
|
|
37
|
-
frontDeskUnread?: number;
|
|
38
36
|
/** Precomputed assistant-doctrine context — the hook owns the doctrine-file read, so
|
|
39
37
|
* this module half is a pass-through. Null for any non-assistant project. */
|
|
40
38
|
assistantDoctrine?: string | null;
|
|
@@ -51,9 +49,6 @@ export interface ReminderEnv {
|
|
|
51
49
|
* searches them before answering from training data. Empty/undefined → the
|
|
52
50
|
* corpus announce stays silent. adr: adr/corpus-tags.md */
|
|
53
51
|
corpusApiDocs?: string[];
|
|
54
|
-
/** Envelope-only "you've got mail" front-desk notice — the hook owns the network +
|
|
55
|
-
* per-machine dedup; the front-desk module routes it as its per-turn reminder. */
|
|
56
|
-
frontDeskNotice?: string | null;
|
|
57
52
|
/** Auto-surfaced episodic-memory injection — the hook owns the recall-intent gate +
|
|
58
53
|
* the search + the confidence gate + framing; the memory-reflex module routes the
|
|
59
54
|
* framed string as its per-turn reminder. Null = nothing cleared the gate this turn. */
|
|
@@ -94,6 +89,13 @@ export interface ReminderModule {
|
|
|
94
89
|
detect: (env: ReminderEnv) => Detection;
|
|
95
90
|
/** SessionStart schema, loaded once (teach method + why). null = nothing to announce. */
|
|
96
91
|
announce: (env: ReminderEnv) => string | null;
|
|
92
|
+
/** Re-present this announce after a PostCompact (compaction wipes the SessionStart
|
|
93
|
+
* announces from context, so by DEFAULT every announce re-fires post-compact). Set
|
|
94
|
+
* `false` to opt a module out — e.g. a one-shot/noisy startup-only announce that should
|
|
95
|
+
* NOT repeat every compaction. Default (undefined) = re-announce. The PostCompact pass
|
|
96
|
+
* emits announces only; the heavy memory recap body stays startup-only.
|
|
97
|
+
* docs/reminder-interrupt.md, adr: adr/monitor-resilience.md */
|
|
98
|
+
reannounceOnCompact?: boolean;
|
|
97
99
|
/** Per-turn thin line for a live detection; null when silent. */
|
|
98
100
|
reminder: (d: Detection, env: ReminderEnv) => string | null;
|
|
99
101
|
}
|