@mneme-ai/core 2.31.0 → 2.33.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/agent_manifest.d.ts +1 -1
- package/dist/agent_manifest.d.ts.map +1 -1
- package/dist/agent_manifest.js +29 -0
- package/dist/agent_manifest.js.map +1 -1
- package/dist/citizen_court/citizen_court.test.d.ts +2 -0
- package/dist/citizen_court/citizen_court.test.d.ts.map +1 -0
- package/dist/citizen_court/citizen_court.test.js +121 -0
- package/dist/citizen_court/citizen_court.test.js.map +1 -0
- package/dist/citizen_court/court.d.ts +48 -0
- package/dist/citizen_court/court.d.ts.map +1 -0
- package/dist/citizen_court/court.js +178 -0
- package/dist/citizen_court/court.js.map +1 -0
- package/dist/citizen_court/hsc.d.ts +11 -0
- package/dist/citizen_court/hsc.d.ts.map +1 -0
- package/dist/citizen_court/hsc.js +74 -0
- package/dist/citizen_court/hsc.js.map +1 -0
- package/dist/citizen_court/index.d.ts +13 -0
- package/dist/citizen_court/index.d.ts.map +1 -0
- package/dist/citizen_court/index.js +12 -0
- package/dist/citizen_court/index.js.map +1 -0
- package/dist/citizen_court/types.d.ts +104 -0
- package/dist/citizen_court/types.d.ts.map +1 -0
- package/dist/citizen_court/types.js +16 -0
- package/dist/citizen_court/types.js.map +1 -0
- package/dist/coercion/audit.d.ts +22 -0
- package/dist/coercion/audit.d.ts.map +1 -0
- package/dist/coercion/audit.js +169 -0
- package/dist/coercion/audit.js.map +1 -0
- package/dist/coercion/coercion.test.d.ts +2 -0
- package/dist/coercion/coercion.test.d.ts.map +1 -0
- package/dist/coercion/coercion.test.js +69 -0
- package/dist/coercion/coercion.test.js.map +1 -0
- package/dist/coercion/index.d.ts +11 -0
- package/dist/coercion/index.d.ts.map +1 -0
- package/dist/coercion/index.js +10 -0
- package/dist/coercion/index.js.map +1 -0
- package/dist/coercion/types.d.ts +53 -0
- package/dist/coercion/types.d.ts.map +1 -0
- package/dist/coercion/types.js +17 -0
- package/dist/coercion/types.js.map +1 -0
- package/dist/flywheel/controller.d.ts +51 -0
- package/dist/flywheel/controller.d.ts.map +1 -0
- package/dist/flywheel/controller.js +187 -0
- package/dist/flywheel/controller.js.map +1 -0
- package/dist/flywheel/flywheel.test.d.ts +2 -0
- package/dist/flywheel/flywheel.test.d.ts.map +1 -0
- package/dist/flywheel/flywheel.test.js +264 -0
- package/dist/flywheel/flywheel.test.js.map +1 -0
- package/dist/flywheel/fuse.d.ts +16 -0
- package/dist/flywheel/fuse.d.ts.map +1 -0
- package/dist/flywheel/fuse.js +140 -0
- package/dist/flywheel/fuse.js.map +1 -0
- package/dist/flywheel/harvest.d.ts +32 -0
- package/dist/flywheel/harvest.d.ts.map +1 -0
- package/dist/flywheel/harvest.js +327 -0
- package/dist/flywheel/harvest.js.map +1 -0
- package/dist/flywheel/index.d.ts +26 -0
- package/dist/flywheel/index.d.ts.map +1 -0
- package/dist/flywheel/index.js +19 -0
- package/dist/flywheel/index.js.map +1 -0
- package/dist/flywheel/liveness.d.ts +34 -0
- package/dist/flywheel/liveness.d.ts.map +1 -0
- package/dist/flywheel/liveness.js +63 -0
- package/dist/flywheel/liveness.js.map +1 -0
- package/dist/flywheel/personal_cheatsheet.d.ts +34 -0
- package/dist/flywheel/personal_cheatsheet.d.ts.map +1 -0
- package/dist/flywheel/personal_cheatsheet.js +95 -0
- package/dist/flywheel/personal_cheatsheet.js.map +1 -0
- package/dist/flywheel/prescribe.d.ts +20 -0
- package/dist/flywheel/prescribe.d.ts.map +1 -0
- package/dist/flywheel/prescribe.js +119 -0
- package/dist/flywheel/prescribe.js.map +1 -0
- package/dist/flywheel/reciprocity.d.ts +36 -0
- package/dist/flywheel/reciprocity.d.ts.map +1 -0
- package/dist/flywheel/reciprocity.js +113 -0
- package/dist/flywheel/reciprocity.js.map +1 -0
- package/dist/flywheel/types.d.ts +117 -0
- package/dist/flywheel/types.d.ts.map +1 -0
- package/dist/flywheel/types.js +25 -0
- package/dist/flywheel/types.js.map +1 -0
- package/dist/flywheel/vendor_bulletin.d.ts +44 -0
- package/dist/flywheel/vendor_bulletin.d.ts.map +1 -0
- package/dist/flywheel/vendor_bulletin.js +118 -0
- package/dist/flywheel/vendor_bulletin.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +38 -0
- package/dist/index.js.map +1 -1
- package/dist/mnemnet/aggregate.d.ts +33 -0
- package/dist/mnemnet/aggregate.d.ts.map +1 -0
- package/dist/mnemnet/aggregate.js +184 -0
- package/dist/mnemnet/aggregate.js.map +1 -0
- package/dist/mnemnet/dp.d.ts +13 -0
- package/dist/mnemnet/dp.d.ts.map +1 -0
- package/dist/mnemnet/dp.js +32 -0
- package/dist/mnemnet/dp.js.map +1 -0
- package/dist/mnemnet/index.d.ts +12 -0
- package/dist/mnemnet/index.d.ts.map +1 -0
- package/dist/mnemnet/index.js +11 -0
- package/dist/mnemnet/index.js.map +1 -0
- package/dist/mnemnet/mnemnet.test.d.ts +2 -0
- package/dist/mnemnet/mnemnet.test.d.ts.map +1 -0
- package/dist/mnemnet/mnemnet.test.js +147 -0
- package/dist/mnemnet/mnemnet.test.js.map +1 -0
- package/dist/mnemnet/types.d.ts +77 -0
- package/dist/mnemnet/types.d.ts.map +1 -0
- package/dist/mnemnet/types.js +14 -0
- package/dist/mnemnet/types.js.map +1 -0
- package/dist/pulsecost/budget.d.ts +20 -0
- package/dist/pulsecost/budget.d.ts.map +1 -0
- package/dist/pulsecost/budget.js +108 -0
- package/dist/pulsecost/budget.js.map +1 -0
- package/dist/pulsecost/index.d.ts +6 -0
- package/dist/pulsecost/index.d.ts.map +1 -0
- package/dist/pulsecost/index.js +5 -0
- package/dist/pulsecost/index.js.map +1 -0
- package/dist/pulsecost/pulsecost.test.d.ts +2 -0
- package/dist/pulsecost/pulsecost.test.d.ts.map +1 -0
- package/dist/pulsecost/pulsecost.test.js +64 -0
- package/dist/pulsecost/pulsecost.test.js.map +1 -0
- package/dist/pulsecost/types.d.ts +53 -0
- package/dist/pulsecost/types.d.ts.map +1 -0
- package/dist/pulsecost/types.js +22 -0
- package/dist/pulsecost/types.js.map +1 -0
- package/dist/truth_gate/claims.d.ts.map +1 -1
- package/dist/truth_gate/claims.js +29 -0
- package/dist/truth_gate/claims.js.map +1 -1
- package/dist/truth_gate/probes.d.ts.map +1 -1
- package/dist/truth_gate/probes.js +71 -0
- package/dist/truth_gate/probes.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v2.32.0 — FLYWHEEL HARVEST stage.
|
|
3
|
+
*
|
|
4
|
+
* Pulls raw findings from every source primitive's existing ledger.
|
|
5
|
+
* Pure file reads + JSONL parsing — NO new state, NO new primitive
|
|
6
|
+
* call. Every reader is best-effort: a missing file = empty list
|
|
7
|
+
* (FLYWHEEL still emits a useful report on a fresh install).
|
|
8
|
+
*/
|
|
9
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
10
|
+
import { join } from "node:path";
|
|
11
|
+
function daysBetween(isoA, isoB) {
|
|
12
|
+
const a = Date.parse(isoA);
|
|
13
|
+
const b = Date.parse(isoB);
|
|
14
|
+
if (Number.isNaN(a) || Number.isNaN(b))
|
|
15
|
+
return 0;
|
|
16
|
+
return Math.max(0, Math.round((b - a) / 86_400_000));
|
|
17
|
+
}
|
|
18
|
+
function safeJsonl(p, limit) {
|
|
19
|
+
if (!existsSync(p))
|
|
20
|
+
return [];
|
|
21
|
+
try {
|
|
22
|
+
const body = readFileSync(p, "utf8");
|
|
23
|
+
const lines = body.split("\n").filter(Boolean);
|
|
24
|
+
const slice = lines.slice(-limit);
|
|
25
|
+
const out = [];
|
|
26
|
+
for (const ln of slice) {
|
|
27
|
+
try {
|
|
28
|
+
out.push(JSON.parse(ln));
|
|
29
|
+
}
|
|
30
|
+
catch { /* skip */ }
|
|
31
|
+
}
|
|
32
|
+
return out;
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return [];
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export function harvestTruthGate(repoRoot, limit) {
|
|
39
|
+
const p = join(repoRoot, ".mneme", "truth_gate", "matrix.jsonl");
|
|
40
|
+
const rows = safeJsonl(p, limit);
|
|
41
|
+
const now = new Date().toISOString();
|
|
42
|
+
const out = [];
|
|
43
|
+
for (const r of rows) {
|
|
44
|
+
const at = r.finishedAt ?? now;
|
|
45
|
+
for (const d of r.drifted ?? []) {
|
|
46
|
+
if (!d.claimId)
|
|
47
|
+
continue;
|
|
48
|
+
out.push({
|
|
49
|
+
source: "truth_gate",
|
|
50
|
+
id: `${d.claimId}`,
|
|
51
|
+
headline: d.headline ?? `TRUTH GATE drift on ${d.claimId}`,
|
|
52
|
+
severity: "warn",
|
|
53
|
+
firstSeen: at, lastSeen: at,
|
|
54
|
+
ageDays: daysBetween(at, now),
|
|
55
|
+
detail: { claimId: d.claimId },
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return out;
|
|
60
|
+
}
|
|
61
|
+
export function harvestGauntlet(repoRoot, limit) {
|
|
62
|
+
const p = join(repoRoot, ".mneme", "tune", "scorecard.jsonl");
|
|
63
|
+
const rows = safeJsonl(p, limit);
|
|
64
|
+
const now = new Date().toISOString();
|
|
65
|
+
const out = [];
|
|
66
|
+
const last = rows[rows.length - 1];
|
|
67
|
+
if (!last)
|
|
68
|
+
return out;
|
|
69
|
+
const at = last.finishedAt ?? now;
|
|
70
|
+
for (const f of last.findings ?? []) {
|
|
71
|
+
if (!f.id || typeof f.stars !== "number")
|
|
72
|
+
continue;
|
|
73
|
+
if (f.stars >= 10)
|
|
74
|
+
continue;
|
|
75
|
+
out.push({
|
|
76
|
+
source: "peak_gauntlet",
|
|
77
|
+
id: f.id,
|
|
78
|
+
headline: f.title ? `${f.id} ${f.stars}★: ${f.title}` : `${f.id} ${f.stars}★`,
|
|
79
|
+
severity: f.stars <= 5 ? "block" : "warn",
|
|
80
|
+
firstSeen: at, lastSeen: at,
|
|
81
|
+
ageDays: daysBetween(at, now),
|
|
82
|
+
detail: { stars: f.stars, title: f.title },
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
return out;
|
|
86
|
+
}
|
|
87
|
+
export function harvestHonestMirror(repoRoot, limit) {
|
|
88
|
+
const p = join(repoRoot, ".mneme", "honest_mirror", "reports.jsonl");
|
|
89
|
+
const rows = safeJsonl(p, limit);
|
|
90
|
+
const now = new Date().toISOString();
|
|
91
|
+
const out = [];
|
|
92
|
+
for (const r of rows) {
|
|
93
|
+
if (r.trafficLight === "green")
|
|
94
|
+
continue;
|
|
95
|
+
const at = r.finishedAt ?? now;
|
|
96
|
+
for (const v of r.perVendor ?? []) {
|
|
97
|
+
if (!v.vendor || typeof v.delta !== "number")
|
|
98
|
+
continue;
|
|
99
|
+
// Skip mock vendors — their deterministic answers can't match real
|
|
100
|
+
// commit diffs, so they're not an honest calibration signal (same
|
|
101
|
+
// filter TRUTH GATE applies in probes.ts).
|
|
102
|
+
if (v.vendor.startsWith("mock") || v.vendor.includes("@mock"))
|
|
103
|
+
continue;
|
|
104
|
+
const abs = Math.abs(v.delta);
|
|
105
|
+
if (abs < 0.1)
|
|
106
|
+
continue;
|
|
107
|
+
out.push({
|
|
108
|
+
source: "honest_mirror",
|
|
109
|
+
id: `vendor:${v.vendor}`,
|
|
110
|
+
headline: `${v.vendor} calibration Δ=${(v.delta * 100).toFixed(0)}%`,
|
|
111
|
+
severity: abs >= 0.25 ? "block" : "warn",
|
|
112
|
+
firstSeen: at, lastSeen: at,
|
|
113
|
+
ageDays: daysBetween(at, now),
|
|
114
|
+
detail: { vendor: v.vendor, delta: v.delta, weight: v.weight },
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return out;
|
|
119
|
+
}
|
|
120
|
+
export function harvestRewind(repoRoot, limit) {
|
|
121
|
+
const p = join(repoRoot, ".mneme", "rewind", "cards.jsonl");
|
|
122
|
+
const rows = safeJsonl(p, limit);
|
|
123
|
+
const now = new Date().toISOString();
|
|
124
|
+
const out = [];
|
|
125
|
+
for (const r of rows) {
|
|
126
|
+
if (r.regression !== "regression")
|
|
127
|
+
continue;
|
|
128
|
+
const at = r.runAt ?? now;
|
|
129
|
+
out.push({
|
|
130
|
+
source: "rewind",
|
|
131
|
+
id: `vendor:${r.vendor ?? "?"}@${r.vendorVersion ?? "?"}`,
|
|
132
|
+
headline: r.headline ?? `REWIND regression for ${r.vendor}@${r.vendorVersion}`,
|
|
133
|
+
severity: Math.abs(r.delta ?? 0) >= 0.15 ? "block" : "warn",
|
|
134
|
+
firstSeen: at, lastSeen: at,
|
|
135
|
+
ageDays: daysBetween(at, now),
|
|
136
|
+
detail: { vendor: r.vendor, vendorVersion: r.vendorVersion, delta: r.delta, weight: r.weight },
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
return out;
|
|
140
|
+
}
|
|
141
|
+
export function harvestHgp(repoRoot, limit) {
|
|
142
|
+
const p = join(repoRoot, ".mneme", "hgp", "registry.jsonl");
|
|
143
|
+
const rows = safeJsonl(p, limit);
|
|
144
|
+
// Collapse by id, pick top-N by severity (recompute on collapsed view).
|
|
145
|
+
const byId = new Map();
|
|
146
|
+
for (const r of rows) {
|
|
147
|
+
if (!r.hgpId)
|
|
148
|
+
continue;
|
|
149
|
+
const cur = byId.get(r.hgpId);
|
|
150
|
+
if (!cur) {
|
|
151
|
+
byId.set(r.hgpId, { ...r });
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
cur.lastSeen = (r.lastSeen ?? cur.lastSeen);
|
|
155
|
+
cur.observeCount = (cur.observeCount ?? 0) + (r.observeCount ?? 0);
|
|
156
|
+
cur.vendorCounts = { ...cur.vendorCounts };
|
|
157
|
+
for (const [v, c] of Object.entries(r.vendorCounts ?? {})) {
|
|
158
|
+
cur.vendorCounts[v] = (cur.vendorCounts[v] ?? 0) + c;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
const now = new Date().toISOString();
|
|
162
|
+
const out = [];
|
|
163
|
+
for (const r of byId.values()) {
|
|
164
|
+
const sev = (r.severity ?? 0);
|
|
165
|
+
if (sev < 0.3)
|
|
166
|
+
continue;
|
|
167
|
+
out.push({
|
|
168
|
+
source: "hgp",
|
|
169
|
+
id: r.hgpId,
|
|
170
|
+
headline: `${r.hgpId} severity ${sev.toFixed(2)} · ${r.observeCount ?? 0} obs · ${Object.keys(r.vendorCounts ?? {}).length} vendor(s)`,
|
|
171
|
+
severity: sev >= 0.7 ? "block" : "warn",
|
|
172
|
+
firstSeen: r.firstSeen ?? now,
|
|
173
|
+
lastSeen: r.lastSeen ?? now,
|
|
174
|
+
ageDays: daysBetween(r.lastSeen ?? now, now),
|
|
175
|
+
detail: { hgpId: r.hgpId, simhash: r.simhash, observeCount: r.observeCount, vendorCounts: r.vendorCounts, sample: r.sample },
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
return out;
|
|
179
|
+
}
|
|
180
|
+
export function harvestCitizenCourt(repoRoot, limit) {
|
|
181
|
+
const p = join(repoRoot, ".mneme", "citizen_court", "verdicts.jsonl");
|
|
182
|
+
const rows = safeJsonl(p, limit);
|
|
183
|
+
const now = new Date().toISOString();
|
|
184
|
+
// Aggregate per-vendor loss count over the window. Only surface as
|
|
185
|
+
// a finding when a vendor lost >= 3 decisive votes (small-sample
|
|
186
|
+
// suppression mirrors HSC banding rules).
|
|
187
|
+
const losses = new Map();
|
|
188
|
+
for (const r of rows) {
|
|
189
|
+
if (!r.votedMostTruthful || r.votedMostTruthful === "ABSTAIN")
|
|
190
|
+
continue;
|
|
191
|
+
const parties = new Set([
|
|
192
|
+
...(r.primaryVendor ? [r.primaryVendor] : []),
|
|
193
|
+
...(r.reveals ?? []).map((rv) => rv.vendor ?? "").filter(Boolean),
|
|
194
|
+
]);
|
|
195
|
+
for (const p of parties) {
|
|
196
|
+
if (p === r.votedMostTruthful)
|
|
197
|
+
continue;
|
|
198
|
+
const cur = losses.get(p) ?? { count: 0, lastAt: r.at ?? now };
|
|
199
|
+
cur.count++;
|
|
200
|
+
if (r.at && r.at > cur.lastAt)
|
|
201
|
+
cur.lastAt = r.at;
|
|
202
|
+
losses.set(p, cur);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
const out = [];
|
|
206
|
+
for (const [vendor, info] of losses.entries()) {
|
|
207
|
+
if (info.count < 3)
|
|
208
|
+
continue;
|
|
209
|
+
out.push({
|
|
210
|
+
source: "citizen_court",
|
|
211
|
+
id: `vendor:${vendor}`,
|
|
212
|
+
headline: `CITIZEN COURT: ${vendor} lost ${info.count} verdict(s)`,
|
|
213
|
+
severity: info.count >= 10 ? "block" : "warn",
|
|
214
|
+
firstSeen: info.lastAt, lastSeen: info.lastAt,
|
|
215
|
+
ageDays: daysBetween(info.lastAt, now),
|
|
216
|
+
detail: { vendor, lossCount: info.count },
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
return out;
|
|
220
|
+
}
|
|
221
|
+
export function harvestCommandHistory(repoRoot, limit) {
|
|
222
|
+
const p = join(repoRoot, ".mneme", "flywheel", "cmd_history.jsonl");
|
|
223
|
+
return safeJsonl(p, limit);
|
|
224
|
+
}
|
|
225
|
+
// ── Marketing diff harvest ──────────────────────────────────────────
|
|
226
|
+
// Scans README + docs/*.md for numeric / categorical assertions that
|
|
227
|
+
// LOOK like measurable claims but have no probe binding in TRUTH GATE.
|
|
228
|
+
// Recommends ADDING a probe (heal action).
|
|
229
|
+
const NUMERIC_CLAIM_RX = /\b(\d{1,5})\s*(\/\s*\d{1,5})?\s*(primitives|tools|tests|cards|claims|HGP-IDs|findings|vendors|attack vectors|stars|points)\b/gi;
|
|
230
|
+
const SUPERLATIVE_RX = /\b(world-first|world's first|the only|first ever|never before|no AI tool)\b/gi;
|
|
231
|
+
export function harvestMarketing(repoRoot, knownBoundClaimIds) {
|
|
232
|
+
const candidates = [];
|
|
233
|
+
for (const file of ["README.md", "docs/FUNCTIONS-EN.md", "docs/FUNCTIONS-TH.md"]) {
|
|
234
|
+
const p = join(repoRoot, file);
|
|
235
|
+
if (!existsSync(p))
|
|
236
|
+
continue;
|
|
237
|
+
try {
|
|
238
|
+
const body = readFileSync(p, "utf8");
|
|
239
|
+
for (const m of body.matchAll(NUMERIC_CLAIM_RX)) {
|
|
240
|
+
candidates.push({ file, text: m[0], kind: "numeric" });
|
|
241
|
+
}
|
|
242
|
+
for (const m of body.matchAll(SUPERLATIVE_RX)) {
|
|
243
|
+
candidates.push({ file, text: m[0], kind: "superlative" });
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
catch { /* skip */ }
|
|
247
|
+
}
|
|
248
|
+
// Dedup by (file, text).
|
|
249
|
+
const seen = new Set();
|
|
250
|
+
const unique = [];
|
|
251
|
+
for (const c of candidates) {
|
|
252
|
+
const k = `${c.file}|${c.text.toLowerCase()}`;
|
|
253
|
+
if (seen.has(k))
|
|
254
|
+
continue;
|
|
255
|
+
seen.add(k);
|
|
256
|
+
unique.push(c);
|
|
257
|
+
}
|
|
258
|
+
// For v2.32.0 we report all UNIQUE claim candidates as candidates
|
|
259
|
+
// for binding — TRUTH GATE catalog growth is tracked separately.
|
|
260
|
+
// A future version will simhash-match candidates to known bound
|
|
261
|
+
// claim ids; for now we surface them all as info-level findings.
|
|
262
|
+
void knownBoundClaimIds;
|
|
263
|
+
const now = new Date().toISOString();
|
|
264
|
+
const out = [];
|
|
265
|
+
for (const c of unique) {
|
|
266
|
+
out.push({
|
|
267
|
+
source: "marketing_diff",
|
|
268
|
+
id: `${c.file}::${c.text.slice(0, 40).toLowerCase().replace(/\s+/g, "_")}`,
|
|
269
|
+
headline: `${c.kind} claim in ${c.file}: "${c.text}"`,
|
|
270
|
+
severity: "info",
|
|
271
|
+
firstSeen: now, lastSeen: now,
|
|
272
|
+
ageDays: 0,
|
|
273
|
+
detail: { file: c.file, text: c.text, kind: c.kind },
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
return out;
|
|
277
|
+
}
|
|
278
|
+
export function harvestLiveness(repoRoot, registrySnapshot, minDeleteAge) {
|
|
279
|
+
const p = join(repoRoot, ".mneme", "flywheel", "primitive_ledger.jsonl");
|
|
280
|
+
const beats = safeJsonl(p, 10000);
|
|
281
|
+
// FIRST-RUN GRACE: if the ledger has fewer than 5 heartbeats, we
|
|
282
|
+
// haven't seen enough live traffic to call anything "dormant" yet.
|
|
283
|
+
// Skip the dormant check until the system has been used a bit.
|
|
284
|
+
// Without this guard, the FIRST flywheel.run on a fresh install
|
|
285
|
+
// would flag every shipped primitive as dormant (correct logic but
|
|
286
|
+
// useless signal — nothing has had a chance to fire).
|
|
287
|
+
if (beats.length < 5)
|
|
288
|
+
return [];
|
|
289
|
+
const lastSeenByName = new Map();
|
|
290
|
+
const shippedByName = new Map();
|
|
291
|
+
for (const b of beats) {
|
|
292
|
+
if (!b.name)
|
|
293
|
+
continue;
|
|
294
|
+
const cur = lastSeenByName.get(b.name);
|
|
295
|
+
if (!cur || b.at > cur)
|
|
296
|
+
lastSeenByName.set(b.name, b.at);
|
|
297
|
+
if (b.shippedAt && !shippedByName.has(b.name))
|
|
298
|
+
shippedByName.set(b.name, b.shippedAt);
|
|
299
|
+
}
|
|
300
|
+
const now = new Date().toISOString();
|
|
301
|
+
const out = [];
|
|
302
|
+
for (const prim of registrySnapshot) {
|
|
303
|
+
const last = lastSeenByName.get(prim.name);
|
|
304
|
+
// Only treat as dormant if we have a known shipped date. Without
|
|
305
|
+
// shippedAt, we can't honestly say it's "old" — could be a brand
|
|
306
|
+
// new primitive that just hasn't beat yet.
|
|
307
|
+
const shipped = shippedByName.get(prim.name);
|
|
308
|
+
if (last)
|
|
309
|
+
continue; // alive
|
|
310
|
+
if (!shipped)
|
|
311
|
+
continue; // unknown age — don't flag
|
|
312
|
+
const ageDays = daysBetween(shipped, now);
|
|
313
|
+
if (ageDays < minDeleteAge)
|
|
314
|
+
continue;
|
|
315
|
+
out.push({
|
|
316
|
+
source: "primitive_registry",
|
|
317
|
+
id: prim.name,
|
|
318
|
+
headline: `Dormant primitive: ${prim.name} (shipped ${ageDays}d ago, never invoked)`,
|
|
319
|
+
severity: ageDays >= 90 ? "block" : "warn",
|
|
320
|
+
firstSeen: shipped, lastSeen: shipped,
|
|
321
|
+
ageDays,
|
|
322
|
+
detail: { name: prim.name, sinceVersion: prim.sinceVersion ?? "?" },
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
return out;
|
|
326
|
+
}
|
|
327
|
+
//# sourceMappingURL=harvest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"harvest.js","sourceRoot":"","sources":["../../src/flywheel/harvest.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAIjC,SAAS,WAAW,CAAC,IAAY,EAAE,IAAY;IAC7C,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAAC,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACvD,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QAAE,OAAO,CAAC,CAAC;IACjD,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC;AACvD,CAAC;AAED,SAAS,SAAS,CAAI,CAAS,EAAE,KAAa;IAC5C,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;QAAE,OAAO,EAAE,CAAC;IAC9B,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,YAAY,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;QACrC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,I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,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACrC,MAAM,GAAG,GAAiB,EAAE,CAAC;IAC7B,KAAK,MAAM,IAAI,IAAI,gBAAgB,EAAE,CAAC;QACpC,MAAM,IAAI,GAAG,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC3C,iEAAiE;QACjE,iEAAiE;QACjE,2CAA2C;QAC3C,MAAM,OAAO,GAAG,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7C,IAAI,IAAI;YAAE,SAAS,CAAC,QAAQ;QAC5B,IAAI,CAAC,OAAO;YAAE,SAAS,CAAC,2BAA2B;QACnD,MAAM,OAAO,GAAG,WAAW,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QAC1C,IAAI,OAAO,GAAG,YAAY;YAAE,SAAS;QACrC,GAAG,CAAC,IAAI,CAAC;YACP,MAAM,EAAE,oBAAoB;YAC5B,EAAE,EAAE,IAAI,CAAC,IAAI;YACb,QAAQ,EAAE,sBAAsB,IAAI,CAAC,IAAI,aAAa,OAAO,uBAAuB;YACpF,QAAQ,EAAE,OAAO,IAAI,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM;YAC1C,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO;YACrC,OAAO;YACP,MAAM,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,CAAC,YAAY,IAAI,GAAG,EAAE;SACpE,CAAC,CAAC;IACL,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v2.32.0 — FLYWHEEL public surface.
|
|
3
|
+
*
|
|
4
|
+
* Self-reflective release organ that closes 4 historic Mneme
|
|
5
|
+
* weakness loops: tool sprawl + solo-dev asymmetry + wiring lag +
|
|
6
|
+
* marketing drift. 5-stage controller HARVEST → FUSE → PRESCRIBE
|
|
7
|
+
* → EXECUTE → RECIPROCITY. Composes with TRUTH GATE + PEAK GAUNTLET
|
|
8
|
+
* + HONEST MIRROR + REWIND + HGP via the SAME
|
|
9
|
+
* .mneme/aletheia/honest_mirror_weights.json feedback file.
|
|
10
|
+
*/
|
|
11
|
+
export type { Severity, SignalSource, RawFinding, FusedFinding, ActionKind, PrescribedAction, ReciprocityEntry, FlywheelReport, FlywheelOptions, } from "./types.js";
|
|
12
|
+
export { harvestTruthGate, harvestGauntlet, harvestHonestMirror, harvestRewind, harvestHgp, harvestCommandHistory, harvestMarketing, harvestLiveness, } from "./harvest.js";
|
|
13
|
+
export type { MarketingClaim } from "./harvest.js";
|
|
14
|
+
export { fuse, distinctClusterCount } from "./fuse.js";
|
|
15
|
+
export { prescribe } from "./prescribe.js";
|
|
16
|
+
export { computeCheatsheet, recordCommand, readHistory, renderCheatsheetMarkdown, } from "./personal_cheatsheet.js";
|
|
17
|
+
export type { CheatsheetEntry, CheatsheetSnapshot } from "./personal_cheatsheet.js";
|
|
18
|
+
export { heartbeat, readHeartbeats, lastSeenMap, } from "./liveness.js";
|
|
19
|
+
export type { PrimitiveSnapshot } from "./liveness.js";
|
|
20
|
+
export { gatherBulletinData, renderBulletinMarkdown, } from "./vendor_bulletin.js";
|
|
21
|
+
export type { BulletinData } from "./vendor_bulletin.js";
|
|
22
|
+
export { computeTrustDelta, recordResponse, readLedger as readReciprocityLedger, applyToAletheiaWeights, } from "./reciprocity.js";
|
|
23
|
+
export type { RecordResponseParams } from "./reciprocity.js";
|
|
24
|
+
export { runFlywheel, listReports, readLatestReport, verifyReport, blockingActions, __resetFlywheelChainForTest, } from "./controller.js";
|
|
25
|
+
export type { RunInput, ReportLedgerEntry } from "./controller.js";
|
|
26
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/flywheel/index.ts"],"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|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v2.32.0 — FLYWHEEL public surface.
|
|
3
|
+
*
|
|
4
|
+
* Self-reflective release organ that closes 4 historic Mneme
|
|
5
|
+
* weakness loops: tool sprawl + solo-dev asymmetry + wiring lag +
|
|
6
|
+
* marketing drift. 5-stage controller HARVEST → FUSE → PRESCRIBE
|
|
7
|
+
* → EXECUTE → RECIPROCITY. Composes with TRUTH GATE + PEAK GAUNTLET
|
|
8
|
+
* + HONEST MIRROR + REWIND + HGP via the SAME
|
|
9
|
+
* .mneme/aletheia/honest_mirror_weights.json feedback file.
|
|
10
|
+
*/
|
|
11
|
+
export { harvestTruthGate, harvestGauntlet, harvestHonestMirror, harvestRewind, harvestHgp, harvestCommandHistory, harvestMarketing, harvestLiveness, } from "./harvest.js";
|
|
12
|
+
export { fuse, distinctClusterCount } from "./fuse.js";
|
|
13
|
+
export { prescribe } from "./prescribe.js";
|
|
14
|
+
export { computeCheatsheet, recordCommand, readHistory, renderCheatsheetMarkdown, } from "./personal_cheatsheet.js";
|
|
15
|
+
export { heartbeat, readHeartbeats, lastSeenMap, } from "./liveness.js";
|
|
16
|
+
export { gatherBulletinData, renderBulletinMarkdown, } from "./vendor_bulletin.js";
|
|
17
|
+
export { computeTrustDelta, recordResponse, readLedger as readReciprocityLedger, applyToAletheiaWeights, } from "./reciprocity.js";
|
|
18
|
+
export { runFlywheel, listReports, readLatestReport, verifyReport, blockingActions, __resetFlywheelChainForTest, } from "./controller.js";
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/flywheel/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAOH,OAAO,EACL,gBAAgB,EAAE,eAAe,EAAE,mBAAmB,EACtD,aAAa,EAAE,UAAU,EAAE,qBAAqB,EAChD,gBAAgB,EAAE,eAAe,GAClC,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,IAAI,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EACL,iBAAiB,EAAE,aAAa,EAAE,WAAW,EAAE,wBAAwB,GACxE,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EACL,SAAS,EAAE,cAAc,EAAE,WAAW,GACvC,MAAM,eAAe,CAAC;AAGvB,OAAO,EACL,kBAAkB,EAAE,sBAAsB,GAC3C,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EACL,iBAAiB,EAAE,cAAc,EAAE,UAAU,IAAI,qBAAqB,EACtE,sBAAsB,GACvB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,WAAW,EAAE,WAAW,EAAE,gBAAgB,EAAE,YAAY,EAAE,eAAe,EACzE,2BAA2B,GAC5B,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v2.32.0 — Primitive liveness ledger.
|
|
3
|
+
*
|
|
4
|
+
* Every time an MCP tool fires (or the universal CLI router invokes
|
|
5
|
+
* a primitive), the caller can push a heartbeat row to
|
|
6
|
+
* .mneme/flywheel/primitive_ledger.jsonl. FLYWHEEL HARVEST reads this
|
|
7
|
+
* to detect dormant primitives.
|
|
8
|
+
*
|
|
9
|
+
* v2.32.0 ships the ledger primitive + harvest reader; wiring every
|
|
10
|
+
* MCP tool to auto-push a heartbeat is a v2.32.x enhancement to avoid
|
|
11
|
+
* cross-package coupling in v1. For now, tests + manual probes push
|
|
12
|
+
* heartbeats explicitly.
|
|
13
|
+
*/
|
|
14
|
+
interface Heartbeat {
|
|
15
|
+
name: string;
|
|
16
|
+
at: string;
|
|
17
|
+
shippedAt?: string;
|
|
18
|
+
}
|
|
19
|
+
export declare function heartbeat(repoRoot: string, name: string, shippedAt?: string): void;
|
|
20
|
+
export declare function readHeartbeats(repoRoot: string, limit?: number): Heartbeat[];
|
|
21
|
+
/** Last-seen per primitive name. */
|
|
22
|
+
export declare function lastSeenMap(repoRoot: string): Map<string, string>;
|
|
23
|
+
/**
|
|
24
|
+
* Snapshot of every primitive currently registered (name +
|
|
25
|
+
* sinceVersion). Caller supplies this — we keep the dependency
|
|
26
|
+
* surface tiny by accepting a parameter (so flywheel doesn't have to
|
|
27
|
+
* cross-import the agent_manifest catalog).
|
|
28
|
+
*/
|
|
29
|
+
export interface PrimitiveSnapshot {
|
|
30
|
+
name: string;
|
|
31
|
+
sinceVersion?: string;
|
|
32
|
+
}
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=liveness.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"liveness.d.ts","sourceRoot":"","sources":["../../src/flywheel/liveness.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAKH,UAAU,SAAS;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAYD,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAMlF;AAED,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,SAAQ,GAAG,SAAS,EAAE,CAW3E;AAED,oCAAoC;AACpC,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAOjE;AAED;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v2.32.0 — Primitive liveness ledger.
|
|
3
|
+
*
|
|
4
|
+
* Every time an MCP tool fires (or the universal CLI router invokes
|
|
5
|
+
* a primitive), the caller can push a heartbeat row to
|
|
6
|
+
* .mneme/flywheel/primitive_ledger.jsonl. FLYWHEEL HARVEST reads this
|
|
7
|
+
* to detect dormant primitives.
|
|
8
|
+
*
|
|
9
|
+
* v2.32.0 ships the ledger primitive + harvest reader; wiring every
|
|
10
|
+
* MCP tool to auto-push a heartbeat is a v2.32.x enhancement to avoid
|
|
11
|
+
* cross-package coupling in v1. For now, tests + manual probes push
|
|
12
|
+
* heartbeats explicitly.
|
|
13
|
+
*/
|
|
14
|
+
import { existsSync, mkdirSync, appendFileSync, readFileSync } from "node:fs";
|
|
15
|
+
import { join } from "node:path";
|
|
16
|
+
function dirOf(repoRoot) {
|
|
17
|
+
const d = join(repoRoot, ".mneme", "flywheel");
|
|
18
|
+
if (!existsSync(d))
|
|
19
|
+
mkdirSync(d, { recursive: true });
|
|
20
|
+
return d;
|
|
21
|
+
}
|
|
22
|
+
function ledgerPath(repoRoot) {
|
|
23
|
+
return join(dirOf(repoRoot), "primitive_ledger.jsonl");
|
|
24
|
+
}
|
|
25
|
+
export function heartbeat(repoRoot, name, shippedAt) {
|
|
26
|
+
try {
|
|
27
|
+
const row = { name, at: new Date().toISOString() };
|
|
28
|
+
if (shippedAt)
|
|
29
|
+
row.shippedAt = shippedAt;
|
|
30
|
+
appendFileSync(ledgerPath(repoRoot), JSON.stringify(row) + "\n", "utf8");
|
|
31
|
+
}
|
|
32
|
+
catch { /* best-effort */ }
|
|
33
|
+
}
|
|
34
|
+
export function readHeartbeats(repoRoot, limit = 10000) {
|
|
35
|
+
const p = ledgerPath(repoRoot);
|
|
36
|
+
if (!existsSync(p))
|
|
37
|
+
return [];
|
|
38
|
+
try {
|
|
39
|
+
const body = readFileSync(p, "utf8");
|
|
40
|
+
const out = [];
|
|
41
|
+
for (const ln of body.split("\n").filter(Boolean).slice(-limit)) {
|
|
42
|
+
try {
|
|
43
|
+
out.push(JSON.parse(ln));
|
|
44
|
+
}
|
|
45
|
+
catch { /* skip */ }
|
|
46
|
+
}
|
|
47
|
+
return out;
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
return [];
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/** Last-seen per primitive name. */
|
|
54
|
+
export function lastSeenMap(repoRoot) {
|
|
55
|
+
const out = new Map();
|
|
56
|
+
for (const b of readHeartbeats(repoRoot)) {
|
|
57
|
+
const cur = out.get(b.name);
|
|
58
|
+
if (!cur || b.at > cur)
|
|
59
|
+
out.set(b.name, b.at);
|
|
60
|
+
}
|
|
61
|
+
return out;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=liveness.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"liveness.js","sourceRoot":"","sources":["../../src/flywheel/liveness.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC9E,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAQjC,SAAS,KAAK,CAAC,QAAgB;IAC7B,MAAM,CAAC,GAAG,IAAI,CAAC,QAAQ,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;IAC/C,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;QAAE,SAAS,CAAC,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACtD,OAAO,CAAC,CAAC;AACX,CAAC;AAED,SAAS,UAAU,CAAC,QAAgB;IAClC,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,wBAAwB,CAAC,CAAC;AACzD,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,QAAgB,EAAE,IAAY,EAAE,SAAkB;IAC1E,IAAI,CAAC;QACH,MAAM,GAAG,GAAc,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC;QAC9D,IA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AAI,CAAC,CAAC,EAAE,GAAG,GAAG;YAAE,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;IAChD,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v2.32.0 — Personal cheatsheet engine.
|
|
3
|
+
*
|
|
4
|
+
* Reads .mneme/flywheel/cmd_history.jsonl, counts invocations per
|
|
5
|
+
* command, returns top-3 along with a header explaining that the
|
|
6
|
+
* cheatsheet *shrinks* over time as the user specializes.
|
|
7
|
+
*
|
|
8
|
+
* Fresh-install fallback: if < 5 history rows, return the global
|
|
9
|
+
* recommended top-5 — the highest-leverage commands for new users.
|
|
10
|
+
*/
|
|
11
|
+
interface CmdHistoryRow {
|
|
12
|
+
command: string;
|
|
13
|
+
at: string;
|
|
14
|
+
}
|
|
15
|
+
export declare function recordCommand(repoRoot: string, command: string): void;
|
|
16
|
+
export declare function readHistory(repoRoot: string, limit?: number): CmdHistoryRow[];
|
|
17
|
+
export interface CheatsheetEntry {
|
|
18
|
+
command: string;
|
|
19
|
+
why: string;
|
|
20
|
+
invocations?: number;
|
|
21
|
+
}
|
|
22
|
+
export interface CheatsheetSnapshot {
|
|
23
|
+
entries: CheatsheetEntry[];
|
|
24
|
+
/** "personalized" | "fresh_install" */
|
|
25
|
+
mode: "personalized" | "fresh_install";
|
|
26
|
+
/** ISO of latest row used. */
|
|
27
|
+
basedOn: string | null;
|
|
28
|
+
/** Plain-English explanation for the user. */
|
|
29
|
+
header: string;
|
|
30
|
+
}
|
|
31
|
+
export declare function computeCheatsheet(repoRoot: string): CheatsheetSnapshot;
|
|
32
|
+
export declare function renderCheatsheetMarkdown(snap: CheatsheetSnapshot): string;
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=personal_cheatsheet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"personal_cheatsheet.d.ts","sourceRoot":"","sources":["../../src/flywheel/personal_cheatsheet.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAaH,UAAU,aAAa;IAAG,OAAO,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;CAAE;AAYxD,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAIrE;AAED,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,SAAO,GAAG,aAAa,EAAE,CAY3E;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,eAAe,EAAE,CAAC;IAC3B,uCAAuC;IACvC,IAAI,EAAE,cAAc,GAAG,eAAe,CAAC;IACvC,8BAA8B;IAC9B,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,8CAA8C;IAC9C,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,kBAAkB,CAwBtE;AAED,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,kBAAkB,GAAG,MAAM,CAazE"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v2.32.0 — Personal cheatsheet engine.
|
|
3
|
+
*
|
|
4
|
+
* Reads .mneme/flywheel/cmd_history.jsonl, counts invocations per
|
|
5
|
+
* command, returns top-3 along with a header explaining that the
|
|
6
|
+
* cheatsheet *shrinks* over time as the user specializes.
|
|
7
|
+
*
|
|
8
|
+
* Fresh-install fallback: if < 5 history rows, return the global
|
|
9
|
+
* recommended top-5 — the highest-leverage commands for new users.
|
|
10
|
+
*/
|
|
11
|
+
import { existsSync, mkdirSync, appendFileSync, readFileSync } from "node:fs";
|
|
12
|
+
import { join } from "node:path";
|
|
13
|
+
const GLOBAL_TOP5 = [
|
|
14
|
+
{ command: "mneme verify \"<claim>\"", why: "Truth-check ANY factual claim before relaying — refuses to hallucinate." },
|
|
15
|
+
{ command: "mneme welcome", why: "Install handoff + what's changed since last session — start here." },
|
|
16
|
+
{ command: "mneme flywheel run", why: "Run the self-reflective audit — closes the 4 loops every release." },
|
|
17
|
+
{ command: "mneme honest_mirror calibrate", why: "Tune vendor trust on YOUR own past commits — eval-aware-defeating." },
|
|
18
|
+
{ command: "mneme rewind run", why: "Track vendor regression on YOUR repo as new model versions ship." },
|
|
19
|
+
];
|
|
20
|
+
function dirOf(repoRoot) {
|
|
21
|
+
const d = join(repoRoot, ".mneme", "flywheel");
|
|
22
|
+
if (!existsSync(d))
|
|
23
|
+
mkdirSync(d, { recursive: true });
|
|
24
|
+
return d;
|
|
25
|
+
}
|
|
26
|
+
function historyPath(repoRoot) {
|
|
27
|
+
return join(dirOf(repoRoot), "cmd_history.jsonl");
|
|
28
|
+
}
|
|
29
|
+
export function recordCommand(repoRoot, command) {
|
|
30
|
+
try {
|
|
31
|
+
appendFileSync(historyPath(repoRoot), JSON.stringify({ command, at: new Date().toISOString() }) + "\n", "utf8");
|
|
32
|
+
}
|
|
33
|
+
catch { /* best-effort */ }
|
|
34
|
+
}
|
|
35
|
+
export function readHistory(repoRoot, limit = 1000) {
|
|
36
|
+
const p = historyPath(repoRoot);
|
|
37
|
+
if (!existsSync(p))
|
|
38
|
+
return [];
|
|
39
|
+
try {
|
|
40
|
+
const body = readFileSync(p, "utf8");
|
|
41
|
+
const lines = body.split("\n").filter(Boolean);
|
|
42
|
+
const out = [];
|
|
43
|
+
for (const ln of lines.slice(-limit)) {
|
|
44
|
+
try {
|
|
45
|
+
out.push(JSON.parse(ln));
|
|
46
|
+
}
|
|
47
|
+
catch { /* skip */ }
|
|
48
|
+
}
|
|
49
|
+
return out;
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
return [];
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
export function computeCheatsheet(repoRoot) {
|
|
56
|
+
const history = readHistory(repoRoot, 5000);
|
|
57
|
+
if (history.length < 5) {
|
|
58
|
+
return {
|
|
59
|
+
entries: GLOBAL_TOP5.map((g) => ({ ...g })),
|
|
60
|
+
mode: "fresh_install",
|
|
61
|
+
basedOn: history.length === 0 ? null : history[history.length - 1].at,
|
|
62
|
+
header: "Fresh install — here are the 5 highest-leverage commands. Use Mneme for a few days and the cheatsheet auto-shrinks to YOUR top-3.",
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
// Count invocations per command, keep top-3.
|
|
66
|
+
const counts = new Map();
|
|
67
|
+
for (const row of history)
|
|
68
|
+
counts.set(row.command, (counts.get(row.command) ?? 0) + 1);
|
|
69
|
+
const sorted = Array.from(counts.entries()).sort((a, b) => b[1] - a[1]).slice(0, 3);
|
|
70
|
+
return {
|
|
71
|
+
entries: sorted.map(([command, n]) => ({
|
|
72
|
+
command,
|
|
73
|
+
why: GLOBAL_TOP5.find((g) => command.startsWith(g.command.split(" ")[0]))?.why ?? "Frequently used by you.",
|
|
74
|
+
invocations: n,
|
|
75
|
+
})),
|
|
76
|
+
mode: "personalized",
|
|
77
|
+
basedOn: history[history.length - 1].at,
|
|
78
|
+
header: `Personal cheatsheet: top-3 commands you actually use (from ${history.length} invocations).`,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
export function renderCheatsheetMarkdown(snap) {
|
|
82
|
+
const lines = [];
|
|
83
|
+
lines.push(`# Mneme — Personal Cheatsheet`);
|
|
84
|
+
lines.push(``);
|
|
85
|
+
lines.push(`> ${snap.header}`);
|
|
86
|
+
lines.push(``);
|
|
87
|
+
for (const e of snap.entries) {
|
|
88
|
+
lines.push(`- \`${e.command}\` — ${e.why}${typeof e.invocations === "number" ? ` (${e.invocations}×)` : ""}`);
|
|
89
|
+
}
|
|
90
|
+
lines.push(``);
|
|
91
|
+
lines.push(`---`);
|
|
92
|
+
lines.push(`Mode: ${snap.mode} · basedOn: ${snap.basedOn ?? "(no history yet)"}`);
|
|
93
|
+
return lines.join("\n");
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=personal_cheatsheet.js.map
|