greprag 5.38.0 → 5.40.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/dist/commands/discover.d.ts +1 -1
- package/dist/commands/discover.js +6 -5
- package/dist/commands/discover.js.map +1 -1
- package/dist/commands/fix.d.ts +28 -0
- package/dist/commands/fix.js +455 -37
- package/dist/commands/fix.js.map +1 -1
- package/dist/commands/init.js +18 -1
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/mechanic.d.ts +64 -0
- package/dist/commands/mechanic.js +374 -0
- package/dist/commands/mechanic.js.map +1 -0
- package/dist/fix-trigger.d.ts +43 -0
- package/dist/fix-trigger.js +270 -0
- package/dist/fix-trigger.js.map +1 -0
- package/dist/guard.d.ts +92 -0
- package/dist/guard.js +404 -0
- package/dist/guard.js.map +1 -0
- package/dist/hook.js +117 -70
- package/dist/hook.js.map +1 -1
- package/dist/index.js +66 -46
- package/dist/index.js.map +1 -1
- package/dist/secret-scrubber.d.ts +48 -0
- package/dist/secret-scrubber.js +368 -0
- package/dist/secret-scrubber.js.map +1 -0
- package/package.json +1 -1
- package/skill/greprag/SKILL.md +6 -3
- package/skill/greprag/docs/corpus.md +15 -0
- package/skill/greprag/docs/discover.md +1 -1
- package/skill/greprag/docs/email.md +46 -0
- package/skill/greprag/docs/fix.md +86 -0
- package/skill/greprag/docs/inbox-watch.md +5 -4
- package/skill/greprag/docs/inbox.md +10 -8
- package/skill/greprag/docs/setup.md +1 -1
- package/skill/mechanic/SKILL.md +22 -2
- package/skill/templates/chip-spawn.md +30 -8
- package/skill/templates/workshop-chip.md +43 -0
- package/skill/greprag/docs/lore.md +0 -70
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/** greprag mechanic — the consumer control plane for repairs (docs/mechanic-repairs.md
|
|
3
|
+
* Part 4; D6/D7/D8). Repairs-as-data makes the harness remotely manageable:
|
|
4
|
+
* one thin dispatcher installed at init, everything else is rows you can see,
|
|
5
|
+
* flip, and audit. This command is the see/flip/audit surface.
|
|
6
|
+
*
|
|
7
|
+
* Thin client by rule: all judgment (born-shadow, transition gating,
|
|
8
|
+
* external-never-auto-graduates) is server-side — the CLI renders rows and
|
|
9
|
+
* POSTs transitions with actor:"operator". The ONE local-first verb is
|
|
10
|
+
* off/on: the kill-switch file is checked by the dispatcher BEFORE any
|
|
11
|
+
* network call, so the panic switch works with the server down or
|
|
12
|
+
* compromised (D8).
|
|
13
|
+
*
|
|
14
|
+
* Subcommand surface — runMechanic dispatches:
|
|
15
|
+
* status inventory: every live (shadow|active) repair,
|
|
16
|
+
* grouped by status; ⚑ marks shadow rows ready
|
|
17
|
+
* to graduate (≥3 fires or ≥7 days — D7)
|
|
18
|
+
* enable <nodeId> ratify: shadow → active (actor: operator)
|
|
19
|
+
* disable <nodeId> [--retire] active → shadow (least destructive default);
|
|
20
|
+
* --retire = terminal retired
|
|
21
|
+
* why <nodeId> provenance: friction → fix → repair chain
|
|
22
|
+
* off [--note "<t>"] / on panic switch — suspend/resume ALL repairs
|
|
23
|
+
* (local file, no network)
|
|
24
|
+
*
|
|
25
|
+
* All network verbs accept [--project <name>]. */
|
|
26
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
27
|
+
if (k2 === undefined) k2 = k;
|
|
28
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
29
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
30
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
31
|
+
}
|
|
32
|
+
Object.defineProperty(o, k2, desc);
|
|
33
|
+
}) : (function(o, m, k, k2) {
|
|
34
|
+
if (k2 === undefined) k2 = k;
|
|
35
|
+
o[k2] = m[k];
|
|
36
|
+
}));
|
|
37
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
38
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
39
|
+
}) : function(o, v) {
|
|
40
|
+
o["default"] = v;
|
|
41
|
+
});
|
|
42
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
43
|
+
var ownKeys = function(o) {
|
|
44
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
45
|
+
var ar = [];
|
|
46
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
47
|
+
return ar;
|
|
48
|
+
};
|
|
49
|
+
return ownKeys(o);
|
|
50
|
+
};
|
|
51
|
+
return function (mod) {
|
|
52
|
+
if (mod && mod.__esModule) return mod;
|
|
53
|
+
var result = {};
|
|
54
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
55
|
+
__setModuleDefault(result, mod);
|
|
56
|
+
return result;
|
|
57
|
+
};
|
|
58
|
+
})();
|
|
59
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
60
|
+
exports.killSwitchPath = killSwitchPath;
|
|
61
|
+
exports.readyToGraduate = readyToGraduate;
|
|
62
|
+
exports.renderStatus = renderStatus;
|
|
63
|
+
exports.killSwitchOff = killSwitchOff;
|
|
64
|
+
exports.killSwitchOn = killSwitchOn;
|
|
65
|
+
exports.runMechanic = runMechanic;
|
|
66
|
+
const fs = __importStar(require("fs"));
|
|
67
|
+
const path = __importStar(require("path"));
|
|
68
|
+
const os = __importStar(require("os"));
|
|
69
|
+
const project_anchor_1 = require("../project-anchor");
|
|
70
|
+
const API_URL_DEFAULT = 'https://api.greprag.com';
|
|
71
|
+
/** D8 contract path — MUST match the dispatcher's check verbatim
|
|
72
|
+
* (docs/mechanic-engine-contracts.md "Client paths"). */
|
|
73
|
+
function killSwitchPath() {
|
|
74
|
+
const home = process.env.HOME || process.env.USERPROFILE || os.homedir();
|
|
75
|
+
return path.join(home, '.greprag', 'state', 'mechanic-off.json');
|
|
76
|
+
}
|
|
77
|
+
// ---------- Config / env --------------------------------------------------
|
|
78
|
+
function loadEnvFile(filePath) {
|
|
79
|
+
try {
|
|
80
|
+
const content = fs.readFileSync(filePath, 'utf-8');
|
|
81
|
+
for (const line of content.split('\n')) {
|
|
82
|
+
const trimmed = line.trim();
|
|
83
|
+
if (!trimmed || trimmed.startsWith('#'))
|
|
84
|
+
continue;
|
|
85
|
+
const eqIdx = trimmed.indexOf('=');
|
|
86
|
+
if (eqIdx < 1)
|
|
87
|
+
continue;
|
|
88
|
+
const key = trimmed.slice(0, eqIdx).trim();
|
|
89
|
+
let value = trimmed.slice(eqIdx + 1).trim();
|
|
90
|
+
if ((value.startsWith('"') && value.endsWith('"')) ||
|
|
91
|
+
(value.startsWith("'") && value.endsWith("'"))) {
|
|
92
|
+
value = value.slice(1, -1);
|
|
93
|
+
}
|
|
94
|
+
if (!process.env[key])
|
|
95
|
+
process.env[key] = value;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
catch { /* file missing — fine */ }
|
|
99
|
+
}
|
|
100
|
+
function getConfig() {
|
|
101
|
+
const homeDir = process.env.HOME || process.env.USERPROFILE || '';
|
|
102
|
+
if (homeDir)
|
|
103
|
+
loadEnvFile(path.join(homeDir, '.greprag', '.env'));
|
|
104
|
+
if (!process.env.GREPRAG_API_KEY)
|
|
105
|
+
loadEnvFile(path.join(process.cwd(), '.env'));
|
|
106
|
+
return {
|
|
107
|
+
apiUrl: process.env.GREPRAG_API_URL || API_URL_DEFAULT,
|
|
108
|
+
apiKey: process.env.GREPRAG_API_KEY || '',
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
async function apiGet(url, apiKey) {
|
|
112
|
+
const res = await fetch(url, { headers: { 'Authorization': `Bearer ${apiKey}` } });
|
|
113
|
+
if (!res.ok)
|
|
114
|
+
throw new Error(`API ${res.status}: ${await res.text()}`);
|
|
115
|
+
return res.json();
|
|
116
|
+
}
|
|
117
|
+
async function apiPost(url, apiKey, body) {
|
|
118
|
+
const res = await fetch(url, {
|
|
119
|
+
method: 'POST',
|
|
120
|
+
headers: { 'Authorization': `Bearer ${apiKey}`, 'Content-Type': 'application/json' },
|
|
121
|
+
body: JSON.stringify(body),
|
|
122
|
+
});
|
|
123
|
+
const json = await res.json().catch(() => null);
|
|
124
|
+
if (!res.ok) {
|
|
125
|
+
const detail = json && (json.errors?.join('; ') || json.error);
|
|
126
|
+
throw new Error(detail ? `API ${res.status}: ${detail}` : `API ${res.status}`);
|
|
127
|
+
}
|
|
128
|
+
return json;
|
|
129
|
+
}
|
|
130
|
+
// ---------- Helpers --------------------------------------------------------
|
|
131
|
+
function getFlag(args, flag) {
|
|
132
|
+
const idx = args.indexOf(flag);
|
|
133
|
+
if (idx === -1 || idx + 1 >= args.length)
|
|
134
|
+
return undefined;
|
|
135
|
+
return args[idx + 1];
|
|
136
|
+
}
|
|
137
|
+
function abortNotConfigured() {
|
|
138
|
+
console.error('Not configured. Run: greprag init');
|
|
139
|
+
process.exit(1);
|
|
140
|
+
}
|
|
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/inbox/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
|
+
return { projectId: match.project_id, projectName: match.project_name };
|
|
153
|
+
}
|
|
154
|
+
async function fetchMatchset(cfg, projectId) {
|
|
155
|
+
const r = await apiGet(`${cfg.apiUrl}/v1/fix/triggers/matchset?projectId=${projectId}`, cfg.apiKey);
|
|
156
|
+
if (!r.ok)
|
|
157
|
+
throw new Error(r.error || 'matchset failed');
|
|
158
|
+
return r.repairs ?? [];
|
|
159
|
+
}
|
|
160
|
+
function findRow(rows, nodeId) {
|
|
161
|
+
const row = rows.find(r => r.nodeId.toLowerCase() === nodeId.toLowerCase());
|
|
162
|
+
if (!row) {
|
|
163
|
+
throw new Error(`no live (shadow|active) repair with nodeId ${nodeId} in this project. ` +
|
|
164
|
+
`Retired/cold rows leave the matchset — see 'greprag mechanic status'.`);
|
|
165
|
+
}
|
|
166
|
+
return row;
|
|
167
|
+
}
|
|
168
|
+
function requireNodeId(args, usage) {
|
|
169
|
+
const nodeId = args[0];
|
|
170
|
+
if (!nodeId || nodeId.startsWith('--') || !/^[0-9a-f]{8}$/i.test(nodeId)) {
|
|
171
|
+
console.error(usage);
|
|
172
|
+
process.exit(1);
|
|
173
|
+
}
|
|
174
|
+
return nodeId;
|
|
175
|
+
}
|
|
176
|
+
/** D7 graduation readiness: 3 fires or 7 days in shadow, whichever first. */
|
|
177
|
+
function readyToGraduate(repair, nowIso) {
|
|
178
|
+
if (repair.status !== 'shadow')
|
|
179
|
+
return false;
|
|
180
|
+
if ((repair.fireCount ?? 0) >= 3)
|
|
181
|
+
return true;
|
|
182
|
+
if (!repair.createdAt)
|
|
183
|
+
return false;
|
|
184
|
+
const now = nowIso ? Date.parse(nowIso) : Date.now();
|
|
185
|
+
return now - Date.parse(repair.createdAt) >= 7 * 24 * 60 * 60 * 1000;
|
|
186
|
+
}
|
|
187
|
+
// ---------- status ----------------------------------------------------------
|
|
188
|
+
function statusLine(r) {
|
|
189
|
+
const rep = r.repair;
|
|
190
|
+
const action = rep.trigger?.action ?? (rep.verb === 'record' ? '—' : '?');
|
|
191
|
+
const last = rep.lastFiredAt ? rep.lastFiredAt.slice(0, 16).replace('T', ' ') : 'never';
|
|
192
|
+
const flag = readyToGraduate(rep) ? ' ⚑ ready to graduate' : '';
|
|
193
|
+
return ` [${r.nodeId}] ${rep.verb} · ${action} · fires=${rep.fireCount ?? 0}` +
|
|
194
|
+
` · last=${last} · trust=${r.trust} · ${rep.cadence ?? '—'}${flag}`;
|
|
195
|
+
}
|
|
196
|
+
function renderStatus(rows, projectName) {
|
|
197
|
+
if (rows.length === 0) {
|
|
198
|
+
return `No live repairs in ${projectName}. Repairs are authored from fixes — see /mechanic.`;
|
|
199
|
+
}
|
|
200
|
+
const byStatus = new Map();
|
|
201
|
+
for (const r of rows) {
|
|
202
|
+
const s = r.repair.status || '?';
|
|
203
|
+
if (!byStatus.has(s))
|
|
204
|
+
byStatus.set(s, []);
|
|
205
|
+
byStatus.get(s).push(r);
|
|
206
|
+
}
|
|
207
|
+
const lines = [`${rows.length} live repair${rows.length === 1 ? '' : 's'} in ${projectName}:`];
|
|
208
|
+
for (const status of ['active', 'shadow']) {
|
|
209
|
+
const group = byStatus.get(status);
|
|
210
|
+
if (!group)
|
|
211
|
+
continue;
|
|
212
|
+
byStatus.delete(status);
|
|
213
|
+
lines.push('', `## ${status} (${group.length})`);
|
|
214
|
+
for (const r of group)
|
|
215
|
+
lines.push(statusLine(r));
|
|
216
|
+
}
|
|
217
|
+
for (const [status, group] of byStatus) {
|
|
218
|
+
lines.push('', `## ${status} (${group.length})`);
|
|
219
|
+
for (const r of group)
|
|
220
|
+
lines.push(statusLine(r));
|
|
221
|
+
}
|
|
222
|
+
lines.push('', `Graduate: greprag mechanic enable <nodeId> · provenance: greprag mechanic why <nodeId>`);
|
|
223
|
+
return lines.join('\n');
|
|
224
|
+
}
|
|
225
|
+
async function statusCmd(args) {
|
|
226
|
+
const cfg = getConfig();
|
|
227
|
+
if (!cfg.apiKey)
|
|
228
|
+
abortNotConfigured();
|
|
229
|
+
const format = (getFlag(args, '--format') || 'text').toLowerCase();
|
|
230
|
+
const { projectId, projectName } = await resolveProject(args, cfg.apiUrl, cfg.apiKey);
|
|
231
|
+
const rows = await fetchMatchset(cfg, projectId);
|
|
232
|
+
if (fs.existsSync(killSwitchPath())) {
|
|
233
|
+
console.log('⛔ KILL SWITCH ON — all repairs suspended. Resume: greprag mechanic on\n');
|
|
234
|
+
}
|
|
235
|
+
if (format === 'json') {
|
|
236
|
+
console.log(JSON.stringify({ project: projectName, repairs: rows }, null, 2));
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
console.log(renderStatus(rows, projectName));
|
|
240
|
+
}
|
|
241
|
+
// ---------- enable / disable ------------------------------------------------
|
|
242
|
+
async function transitionCmd(args, mode) {
|
|
243
|
+
const cfg = getConfig();
|
|
244
|
+
if (!cfg.apiKey)
|
|
245
|
+
abortNotConfigured();
|
|
246
|
+
const nodeId = requireNodeId(args, `Usage: greprag mechanic ${mode} <nodeId>${mode === 'disable' ? ' [--retire]' : ''} [--project <name>]`);
|
|
247
|
+
const { projectId } = await resolveProject(args, cfg.apiUrl, cfg.apiKey);
|
|
248
|
+
const row = findRow(await fetchMatchset(cfg, projectId), nodeId);
|
|
249
|
+
// enable = operator ratification (shadow → active). disable defaults to the
|
|
250
|
+
// least destructive rung: active → shadow (logging continues, effect off);
|
|
251
|
+
// --retire is the terminal flag-flip.
|
|
252
|
+
const to = mode === 'enable' ? 'active' : (args.includes('--retire') ? 'retired' : 'shadow');
|
|
253
|
+
if (mode === 'disable' && row.repair.status === 'shadow' && to === 'shadow') {
|
|
254
|
+
console.log(`[${nodeId}] is already shadow (logging only). Terminal: --retire.`);
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
const r = await apiPost(`${cfg.apiUrl}/v1/fix/${row.id}/repair-status`, cfg.apiKey, { to, actor: 'operator' });
|
|
258
|
+
console.log(`[${nodeId}] ${row.repair.status} → ${r.status} (${row.repair.verb})`);
|
|
259
|
+
}
|
|
260
|
+
// ---------- why — provenance ------------------------------------------------
|
|
261
|
+
async function whyCmd(args) {
|
|
262
|
+
const cfg = getConfig();
|
|
263
|
+
if (!cfg.apiKey)
|
|
264
|
+
abortNotConfigured();
|
|
265
|
+
const nodeId = requireNodeId(args, 'Usage: greprag mechanic why <nodeId> [--project <name>]');
|
|
266
|
+
const { projectId, projectName } = await resolveProject(args, cfg.apiUrl, cfg.apiKey);
|
|
267
|
+
const row = findRow(await fetchMatchset(cfg, projectId), nodeId);
|
|
268
|
+
// The fix row carries creation provenance (the friction side of the chain).
|
|
269
|
+
const list = await apiGet(`${cfg.apiUrl}/v1/fix/${projectId}/list`, cfg.apiKey);
|
|
270
|
+
const fix = (list.fix ?? []).find(f => f.nodeId.toLowerCase() === nodeId.toLowerCase());
|
|
271
|
+
const rep = row.repair;
|
|
272
|
+
console.log(`\n[${row.nodeId}] in ${projectName} — friction → fix → repair\n`);
|
|
273
|
+
console.log(`FIX (${row.scope || 'no scope'}, trust=${row.trust})`);
|
|
274
|
+
console.log(` ${row.text}`);
|
|
275
|
+
if (fix) {
|
|
276
|
+
console.log(` logged ${fix.createdAt?.slice(0, 10) ?? '?'}${fix.sourceSessionId ? ` from session ${fix.sourceSessionId.slice(0, 8)}` : ''}`);
|
|
277
|
+
}
|
|
278
|
+
console.log(`\nREPAIR`);
|
|
279
|
+
console.log(` verb=${rep.verb} status=${rep.status} cadence=${rep.cadence ?? '—'} createdBy=${rep.createdBy ?? '?'}`);
|
|
280
|
+
if (rep.trigger) {
|
|
281
|
+
console.log(` trigger: ${rep.trigger.event ?? '?'} / matcher=${rep.trigger.matcher ?? '—'} / action=${rep.trigger.action ?? '?'}`);
|
|
282
|
+
}
|
|
283
|
+
console.log(` created=${rep.createdAt?.slice(0, 10) ?? '?'} ratified=${rep.ratifiedAt?.slice(0, 10) ?? 'never'} bornUnder=${rep.bornUnder ?? '?'}`);
|
|
284
|
+
console.log(` fires=${rep.fireCount ?? 0} last=${rep.lastFiredAt ?? 'never'}`);
|
|
285
|
+
const log = rep.fireLog ?? [];
|
|
286
|
+
if (log.length > 0) {
|
|
287
|
+
console.log(`\nFIRE LOG (last ${Math.min(log.length, 5)})`);
|
|
288
|
+
for (const f of log.slice(-5)) {
|
|
289
|
+
console.log(` ${f.firedAt.slice(0, 16).replace('T', ' ')} ${f.shadow ? '[shadow]' : '[live]'} ${f.sessionId.slice(0, 8)} ${f.matchedContext ?? ''}`);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
else {
|
|
293
|
+
console.log(`\n(fire log lives server-side; the matchset carries counts only)`);
|
|
294
|
+
}
|
|
295
|
+
console.log('');
|
|
296
|
+
}
|
|
297
|
+
// ---------- off / on — the D8 panic switch -----------------------------------
|
|
298
|
+
function killSwitchOff(note) {
|
|
299
|
+
const file = killSwitchPath();
|
|
300
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
301
|
+
// Local-first by design (D8): the dispatcher checks this file before any
|
|
302
|
+
// network call, so this works with the server down or compromised. The
|
|
303
|
+
// who/when note rides in the file body for the audit trail.
|
|
304
|
+
fs.writeFileSync(file, JSON.stringify({
|
|
305
|
+
off: true,
|
|
306
|
+
by: os.userInfo().username,
|
|
307
|
+
at: new Date().toISOString(),
|
|
308
|
+
note: note ?? null,
|
|
309
|
+
}, null, 2) + '\n');
|
|
310
|
+
return file;
|
|
311
|
+
}
|
|
312
|
+
function killSwitchOn() {
|
|
313
|
+
const file = killSwitchPath();
|
|
314
|
+
if (!fs.existsSync(file))
|
|
315
|
+
return false;
|
|
316
|
+
fs.unlinkSync(file);
|
|
317
|
+
return true;
|
|
318
|
+
}
|
|
319
|
+
// ---------- Dispatch ----------------------------------------------------------
|
|
320
|
+
const MECHANIC_HELP = `greprag mechanic — consumer control plane for repairs (see docs/mechanic-repairs.md)
|
|
321
|
+
|
|
322
|
+
USAGE
|
|
323
|
+
greprag mechanic status [--format json] Inventory: every live (shadow|active) repair,
|
|
324
|
+
grouped by status. ⚑ = shadow row ready to
|
|
325
|
+
graduate (≥3 fires or ≥7 days).
|
|
326
|
+
greprag mechanic enable <nodeId> Ratify: shadow → active. Operator-gated;
|
|
327
|
+
the server enforces the lifecycle rules.
|
|
328
|
+
greprag mechanic disable <nodeId> [--retire] Default = least destructive: active → shadow
|
|
329
|
+
(effect off, logging continues). --retire is
|
|
330
|
+
terminal — the row leaves the matchset.
|
|
331
|
+
greprag mechanic why <nodeId> Provenance: the friction → fix → repair chain.
|
|
332
|
+
greprag mechanic off [--note "<t>"] PANIC SWITCH — suspend ALL repairs. Local file
|
|
333
|
+
(~/.greprag/state/mechanic-off.json), no
|
|
334
|
+
network: works with the server down.
|
|
335
|
+
greprag mechanic on Remove the kill switch; repairs resume.
|
|
336
|
+
|
|
337
|
+
Network verbs accept [--project <name>].
|
|
338
|
+
|
|
339
|
+
LIFECYCLE (born shadow → graduate → retire)
|
|
340
|
+
Repairs are born shadow: they match and log but inject nothing. Graduation is
|
|
341
|
+
evidence-first — 'status' flags rows with fire history; 'enable' is your ratification.
|
|
342
|
+
Nothing goes live without the operator.`;
|
|
343
|
+
async function runMechanic(args) {
|
|
344
|
+
const sub = args[0];
|
|
345
|
+
const rest = args.slice(1);
|
|
346
|
+
if (!sub || sub === '--help' || sub === '-h' || sub === 'help') {
|
|
347
|
+
console.log(MECHANIC_HELP);
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
350
|
+
switch (sub) {
|
|
351
|
+
case 'status': return statusCmd(rest);
|
|
352
|
+
case 'enable': return transitionCmd(rest, 'enable');
|
|
353
|
+
case 'disable': return transitionCmd(rest, 'disable');
|
|
354
|
+
case 'why': return whyCmd(rest);
|
|
355
|
+
case 'off': {
|
|
356
|
+
const file = killSwitchOff(getFlag(rest, '--note'));
|
|
357
|
+
console.log(`⛔ Kill switch ON — all repairs suspended (${file}).`);
|
|
358
|
+
console.log('Resume: greprag mechanic on');
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
361
|
+
case 'on': {
|
|
362
|
+
if (killSwitchOn())
|
|
363
|
+
console.log('✅ Kill switch removed — repairs resume next pull.');
|
|
364
|
+
else
|
|
365
|
+
console.log('Kill switch was not set — repairs already live.');
|
|
366
|
+
return;
|
|
367
|
+
}
|
|
368
|
+
default:
|
|
369
|
+
console.error(`Unknown mechanic subcommand: ${sub}\n`);
|
|
370
|
+
console.log(MECHANIC_HELP);
|
|
371
|
+
process.exit(1);
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AAC;;gBAChF,OAAO,CAAC,GAAG,CAAC,iDAAiD,CAAC,CAAC;YACpE,OAAO;QACT,CAAC;QACD;YACE,OAAO,CAAC,KAAK,CAAC,gCAAgC,GAAG,IAAI,CAAC,CAAC;YACvD,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;YAC3B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/** fix-trigger — repair-trigger condition interpreter (CLI MIRROR).
|
|
2
|
+
*
|
|
3
|
+
* MIRROR of packages/core/src/fix-trigger.ts (the canonical source — the SAME
|
|
4
|
+
* module the server validates repair rows with). The CLI ships as a
|
|
5
|
+
* zero-dependency `tsc` artifact — greprag-hook cannot import @greprag/core
|
|
6
|
+
* at runtime (core carries `pg`) — so, exactly like src/secret-scrubber.ts,
|
|
7
|
+
* the pure interpreter is mirrored here. KEEP IN SYNC with core; everything
|
|
8
|
+
* below the Grammar marker is byte-identical, and the sync guard in
|
|
9
|
+
* tests/test-guard-dispatch.cjs fails the build on drift.
|
|
10
|
+
*
|
|
11
|
+
* docs/mechanic-repairs.md D3/D5/D8; contracts: docs/mechanic-engine-contracts.md.
|
|
12
|
+
*/
|
|
13
|
+
export interface FixFieldClause {
|
|
14
|
+
/** Key into the event's tool_input — `command` for Bash, `file_path` for
|
|
15
|
+
* Write/Edit, `url` for WebFetch. Dot-paths reach nested fields. */
|
|
16
|
+
field: string;
|
|
17
|
+
op: string;
|
|
18
|
+
value?: unknown;
|
|
19
|
+
/** Regex flags, whitelist 'imsu'. Only meaningful for op: 'regex'. */
|
|
20
|
+
flags?: string;
|
|
21
|
+
}
|
|
22
|
+
export type FixCondition = true | FixFieldClause | {
|
|
23
|
+
all: FixCondition[];
|
|
24
|
+
} | {
|
|
25
|
+
any: FixCondition[];
|
|
26
|
+
} | {
|
|
27
|
+
not: FixCondition;
|
|
28
|
+
};
|
|
29
|
+
/** The closed operator set. */
|
|
30
|
+
export declare const FIX_TRIGGER_OPS: readonly ["contains", "not_contains", "equals", "regex", "path_under", "path_equals", "starts_with", "gt", "lt"];
|
|
31
|
+
export type TriggerLogger = (msg: string, detail?: Record<string, unknown>) => void;
|
|
32
|
+
/** Normalize a path to lowercase forward-slash segments with '.'/'..' resolved
|
|
33
|
+
* (no fs access — pure string work). Drive letters keep their colon segment. */
|
|
34
|
+
export declare function normalizePathSegments(p: string): string[];
|
|
35
|
+
/** Compile a regex under the safety rails; null when rejected. */
|
|
36
|
+
export declare function compileSafeRegex(pattern: string, flags: string | undefined, log?: TriggerLogger): RegExp | null;
|
|
37
|
+
/** Evaluate a condition against one event's tool_input. Pure, never throws:
|
|
38
|
+
* every malformed shape evaluates false (and logs via the optional logger). */
|
|
39
|
+
export declare function evaluateCondition(condition: unknown, toolInput: Record<string, unknown>, log?: TriggerLogger, depth?: number): boolean;
|
|
40
|
+
/** Authoring-time validation: is this a well-formed condition the interpreter
|
|
41
|
+
* will honor? Returns the list of problems (empty = valid). Used server-side
|
|
42
|
+
* before a repair row is stored, so a row can't be born unevaluable. */
|
|
43
|
+
export declare function validateCondition(condition: unknown, depth?: number): string[];
|