@mneme-ai/core 2.43.0 → 2.45.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/argus10/homoglyph_banner.d.ts +35 -0
- package/dist/argus10/homoglyph_banner.d.ts.map +1 -0
- package/dist/argus10/homoglyph_banner.js +85 -0
- package/dist/argus10/homoglyph_banner.js.map +1 -0
- package/dist/argus10/index.d.ts +1 -0
- package/dist/argus10/index.d.ts.map +1 -1
- package/dist/argus10/index.js +2 -0
- package/dist/argus10/index.js.map +1 -1
- package/dist/auto_init/dev_tooling_detector.d.ts +21 -0
- package/dist/auto_init/dev_tooling_detector.d.ts.map +1 -0
- package/dist/auto_init/dev_tooling_detector.js +57 -0
- package/dist/auto_init/dev_tooling_detector.js.map +1 -0
- package/dist/auto_init/index.d.ts +52 -0
- package/dist/auto_init/index.d.ts.map +1 -0
- package/dist/auto_init/index.js +186 -0
- package/dist/auto_init/index.js.map +1 -0
- package/dist/auto_init/retroactive_cleanse.d.ts +67 -0
- package/dist/auto_init/retroactive_cleanse.d.ts.map +1 -0
- package/dist/auto_init/retroactive_cleanse.js +197 -0
- package/dist/auto_init/retroactive_cleanse.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -1
- package/dist/squadron/acgv.d.ts.map +1 -1
- package/dist/squadron/acgv.js +68 -0
- package/dist/squadron/acgv.js.map +1 -1
- package/dist/squadron/auto_number_ground.d.ts +38 -0
- package/dist/squadron/auto_number_ground.d.ts.map +1 -0
- package/dist/squadron/auto_number_ground.js +183 -0
- package/dist/squadron/auto_number_ground.js.map +1 -0
- package/dist/squadron/shell_strip_detective.d.ts +35 -0
- package/dist/squadron/shell_strip_detective.d.ts.map +1 -0
- package/dist/squadron/shell_strip_detective.js +54 -0
- package/dist/squadron/shell_strip_detective.js.map +1 -0
- package/dist/truth_gate/claims.d.ts.map +1 -1
- package/dist/truth_gate/claims.js +23 -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 +123 -0
- package/dist/truth_gate/probes.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v2.44.0 — HOMOGLYPH ATTACK BANNER.
|
|
3
|
+
*
|
|
4
|
+
* When ARGUS search candidates contain cross-script characters
|
|
5
|
+
* (Cyrillic letter inside a Latin word; Greek inside Latin; etc),
|
|
6
|
+
* surface a USER-VISIBLE banner with codepoint + position so the
|
|
7
|
+
* operator immediately sees the attack shape.
|
|
8
|
+
*
|
|
9
|
+
* Pure deterministic, no I/O.
|
|
10
|
+
*/
|
|
11
|
+
export type Script = "latin" | "cyrillic" | "greek" | "other";
|
|
12
|
+
export interface HomoglyphAttack {
|
|
13
|
+
candidateIndex: number;
|
|
14
|
+
candidateText: string;
|
|
15
|
+
/** The non-Latin script char masquerading inside a Latin token. */
|
|
16
|
+
script: Script;
|
|
17
|
+
/** Hex form of the suspicious codepoint, e.g. "U+0435". */
|
|
18
|
+
codepoint: string;
|
|
19
|
+
/** The actual character. */
|
|
20
|
+
character: string;
|
|
21
|
+
/** UTF-16 position within the candidate text. */
|
|
22
|
+
position: number;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Walk each candidate, find tokens that mix Latin with another script.
|
|
26
|
+
* Returns one attack record per suspicious codepoint.
|
|
27
|
+
*/
|
|
28
|
+
export declare function detectHomoglyphAttacks(candidates: ReadonlyArray<{
|
|
29
|
+
text: string;
|
|
30
|
+
}>): HomoglyphAttack[];
|
|
31
|
+
/**
|
|
32
|
+
* Render attacks as a multi-line warning banner for CLI/MCP output.
|
|
33
|
+
*/
|
|
34
|
+
export declare function formatBanner(attacks: ReadonlyArray<HomoglyphAttack>): string;
|
|
35
|
+
//# sourceMappingURL=homoglyph_banner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"homoglyph_banner.d.ts","sourceRoot":"","sources":["../../src/argus10/homoglyph_banner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,MAAM,MAAM,MAAM,GAAG,OAAO,GAAG,UAAU,GAAG,OAAO,GAAG,OAAO,CAAC;AAS9D,MAAM,WAAW,eAAe;IAC9B,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,mEAAmE;IACnE,MAAM,EAAE,MAAM,CAAC;IACf,2DAA2D;IAC3D,SAAS,EAAE,MAAM,CAAC;IAClB,4BAA4B;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,iDAAiD;IACjD,QAAQ,EAAE,MAAM,CAAC;CAClB;AAMD;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,aAAa,CAAC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG,eAAe,EAAE,CAwCrG;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,aAAa,CAAC,eAAe,CAAC,GAAG,MAAM,CAW5E"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v2.44.0 — HOMOGLYPH ATTACK BANNER.
|
|
3
|
+
*
|
|
4
|
+
* When ARGUS search candidates contain cross-script characters
|
|
5
|
+
* (Cyrillic letter inside a Latin word; Greek inside Latin; etc),
|
|
6
|
+
* surface a USER-VISIBLE banner with codepoint + position so the
|
|
7
|
+
* operator immediately sees the attack shape.
|
|
8
|
+
*
|
|
9
|
+
* Pure deterministic, no I/O.
|
|
10
|
+
*/
|
|
11
|
+
function scriptOf(cp) {
|
|
12
|
+
if ((cp >= 0x41 && cp <= 0x5A) || (cp >= 0x61 && cp <= 0x7A))
|
|
13
|
+
return "latin";
|
|
14
|
+
if (cp >= 0x0400 && cp <= 0x04FF)
|
|
15
|
+
return "cyrillic";
|
|
16
|
+
if (cp >= 0x0370 && cp <= 0x03FF)
|
|
17
|
+
return "greek";
|
|
18
|
+
return "other";
|
|
19
|
+
}
|
|
20
|
+
function hexCp(cp) {
|
|
21
|
+
return "U+" + cp.toString(16).toUpperCase().padStart(4, "0");
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Walk each candidate, find tokens that mix Latin with another script.
|
|
25
|
+
* Returns one attack record per suspicious codepoint.
|
|
26
|
+
*/
|
|
27
|
+
export function detectHomoglyphAttacks(candidates) {
|
|
28
|
+
const out = [];
|
|
29
|
+
for (let ci = 0; ci < candidates.length; ci++) {
|
|
30
|
+
const text = candidates[ci].text;
|
|
31
|
+
// Split on whitespace + punctuation to find tokens.
|
|
32
|
+
const tokens = text.split(/(\s+|[.,;:!?()[\]{}<>"'`])/);
|
|
33
|
+
let offset = 0;
|
|
34
|
+
for (const tok of tokens) {
|
|
35
|
+
if (!tok || /^\s+$/.test(tok)) {
|
|
36
|
+
offset += tok.length;
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
// Determine the dominant script in the token.
|
|
40
|
+
const scripts = new Set();
|
|
41
|
+
for (const ch of tok) {
|
|
42
|
+
const cp = ch.codePointAt(0);
|
|
43
|
+
const s = scriptOf(cp);
|
|
44
|
+
if (s !== "other")
|
|
45
|
+
scripts.add(s);
|
|
46
|
+
}
|
|
47
|
+
// Attack pattern: token contains Latin + another script.
|
|
48
|
+
if (scripts.has("latin") && (scripts.has("cyrillic") || scripts.has("greek"))) {
|
|
49
|
+
// Surface every non-Latin char individually with its position.
|
|
50
|
+
let i = 0;
|
|
51
|
+
for (const ch of tok) {
|
|
52
|
+
const cp = ch.codePointAt(0);
|
|
53
|
+
const s = scriptOf(cp);
|
|
54
|
+
if (s === "cyrillic" || s === "greek") {
|
|
55
|
+
out.push({
|
|
56
|
+
candidateIndex: ci,
|
|
57
|
+
candidateText: text,
|
|
58
|
+
script: s,
|
|
59
|
+
codepoint: hexCp(cp),
|
|
60
|
+
character: ch,
|
|
61
|
+
position: offset + i,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
i += ch.length;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
offset += tok.length;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return out;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Render attacks as a multi-line warning banner for CLI/MCP output.
|
|
74
|
+
*/
|
|
75
|
+
export function formatBanner(attacks) {
|
|
76
|
+
if (attacks.length === 0)
|
|
77
|
+
return "";
|
|
78
|
+
const lines = [];
|
|
79
|
+
lines.push("🚨 HOMOGLYPH ATTACK DETECTED");
|
|
80
|
+
for (const a of attacks) {
|
|
81
|
+
lines.push(` candidate #${a.candidateIndex}: "${a.candidateText}"`, ` ${a.script} ${a.codepoint} '${a.character}' at position ${a.position} masquerading as a Latin letter`);
|
|
82
|
+
}
|
|
83
|
+
return lines.join("\n");
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=homoglyph_banner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"homoglyph_banner.js","sourceRoot":"","sources":["../../src/argus10/homoglyph_banner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,SAAS,QAAQ,CAAC,EAAU;IAC1B,IAAI,CAAC,EAAE,IAAI,IAAI,IAAI,EAAE,IAAI,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,IAAI,IAAI,EAAE,IAAI,IAAI,CAAC;QAAE,OAAO,OAAO,CAAC;IAC7E,IAAI,EAAE,IAAI,MAAM,IAAI,EAAE,IAAI,MAAM;QAAE,OAAO,UAAU,CAAC;IACpD,IAAI,EAAE,IAAI,MAAM,IAAI,EAAE,IAAI,MAAM;QAAE,OAAO,OAAO,CAAC;IACjD,OAAO,OAAO,CAAC;AACjB,CAAC;AAeD,SAAS,KAAK,CAAC,EAAU;IACvB,OAAO,IAAI,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC,Q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modality, lexCode,
|
|
|
22
22
|
export { buildBloom, membershipFraction, prefilterCandidates, type BloomFilter, } from "./bloom_prefilter.js";
|
|
23
23
|
export { phantomDecide, partitionEyes, CHEAP_EYE_IDS, EXPENSIVE_EYE_IDS, type PhantomDecision, } from "./phantom_eye.js";
|
|
24
24
|
export { VENDOR_ADAPTERS, listAdapters, countAdapters, findAdapter, adaptersByTransport, type VendorAdapter, type VendorTransport, } from "./vendor_adapters.js";
|
|
25
|
+
export { detectHomoglyphAttacks, formatBanner, type HomoglyphAttack, type Script as HomoglyphScript, } from "./homoglyph_banner.js";
|
|
25
26
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/argus10/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,YAAY,EACV,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,EAC7D,eAAe,EAAE,gBAAgB,EAAE,iBAAiB,GACrD,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,YAAY,EACZ,iBAAiB,EAAE,sBAAsB,EAAE,oBAAoB,EAC/D,kBAAkB,EAAE,oBAAoB,EACxC,OAAO,EAAE,cAAc,EAAE,aAAa,GACvC,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,UAAU,EACV,wBAAwB,EAAE,uBAAuB,EAAE,sBAAsB,EACzE,qBAAqB,EAAE,4BAA4B,EACnD,sBAAsB,GACvB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,mBAAmB,EACnB,KAAK,cAAc,GACpB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,aAAa,EAAE,cAAc,EAAE,UAAU,EACzC,KAAK,YAAY,GAClB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,WAAW,EAAE,iBAAiB,GAC/B,MAAM,aAAa,CAAC;AAGrB,OAAO,EACL,qBAA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AClB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,WAAW,EAAE,iBAAiB,GAC/B,MAAM,aAAa,CAAC;AAGrB,OAAO,EACL,qBAAqB,EACrB,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,GAC3B,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,oBAAoB,EACpB,OAAO,EAAE,YAAY,EAAE,UAAU,GAClC,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,UAAU,EAAE,kBAAkB,EAAE,mBAAmB,EACnD,KAAK,WAAW,GACjB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,aAAa,EAAE,aAAa,EAAE,aAAa,EAAE,iBAAiB,EAC9D,KAAK,eAAe,GACrB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,eAAe,EAAE,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,mBAAmB,EAC9E,KAAK,aAAa,EAAE,KAAK,eAAe,GACzC,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EACL,sBAAsB,EAAE,YAAY,EACpC,KAAK,eAAe,EAAE,KAAK,MAAM,IAAI,eAAe,GACrD,MAAM,uBAAuB,CAAC"}
|
package/dist/argus10/index.js
CHANGED
|
@@ -22,4 +22,6 @@ export { MULTIMODAL_EYES, EYE_11_image_modality, EYE_12_code_modality, lexCode,
|
|
|
22
22
|
export { buildBloom, membershipFraction, prefilterCandidates, } from "./bloom_prefilter.js";
|
|
23
23
|
export { phantomDecide, partitionEyes, CHEAP_EYE_IDS, EXPENSIVE_EYE_IDS, } from "./phantom_eye.js";
|
|
24
24
|
export { VENDOR_ADAPTERS, listAdapters, countAdapters, findAdapter, adaptersByTransport, } from "./vendor_adapters.js";
|
|
25
|
+
// v2.44.0 — Homoglyph attack banner (per-candidate cross-script detection).
|
|
26
|
+
export { detectHomoglyphAttacks, formatBanner, } from "./homoglyph_banner.js";
|
|
25
27
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/argus10/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAOH,OAAO,EACL,YAAY,EACZ,iBAAiB,EAAE,sBAAsB,EAAE,oBAAoB,EAC/D,kBAAkB,EAAE,oBAAoB,EACxC,OAAO,EAAE,cAAc,EAAE,aAAa,GACvC,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,UAAU,EACV,wBAAwB,EAAE,uBAAuB,EAAE,sBAAsB,EACzE,qBAAqB,EAAE,4BAA4B,EACnD,sBAAsB,GACvB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,mBAAmB,GAEpB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,aAAa,EAAE,cAAc,EAAE,UAAU,GAE1C,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,WAAW,EAAE,iBAAiB,GAC/B,MAAM,aAAa,CAAC;AAErB,gCAAgC;AAChC,OAAO,EACL,qBAAqB,GAGtB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,oBAAoB,EACpB,OAAO,EAAE,YAAY,EAAE,UAAU,GAClC,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,UAAU,EAAE,kBAAkB,EAAE,mBAAmB,GAEpD,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,aAAa,EAAE,aAAa,EAAE,aAAa,EAAE,iBAAiB,GAE/D,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,eAAe,EAAE,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,mBAAmB,GAE/E,MAAM,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/argus10/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAOH,OAAO,EACL,YAAY,EACZ,iBAAiB,EAAE,sBAAsB,EAAE,oBAAoB,EAC/D,kBAAkB,EAAE,oBAAoB,EACxC,OAAO,EAAE,cAAc,EAAE,aAAa,GACvC,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,UAAU,EACV,wBAAwB,EAAE,uBAAuB,EAAE,sBAAsB,EACzE,qBAAqB,EAAE,4BAA4B,EACnD,sBAAsB,GACvB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,mBAAmB,GAEpB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,aAAa,EAAE,cAAc,EAAE,UAAU,GAE1C,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,WAAW,EAAE,iBAAiB,GAC/B,MAAM,aAAa,CAAC;AAErB,gCAAgC;AAChC,OAAO,EACL,qBAAqB,GAGtB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,oBAAoB,EACpB,OAAO,EAAE,YAAY,EAAE,UAAU,GAClC,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,UAAU,EAAE,kBAAkB,EAAE,mBAAmB,GAEpD,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,aAAa,EAAE,aAAa,EAAE,aAAa,EAAE,iBAAiB,GAE/D,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,eAAe,EAAE,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,mBAAmB,GAE/E,MAAM,sBAAsB,CAAC;AAE9B,4EAA4E;AAC5E,OAAO,EACL,sBAAsB,EAAE,YAAY,GAErC,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v2.45.0 — DEV-TOOLING DETECTOR (closes caveat #3).
|
|
3
|
+
*
|
|
4
|
+
* The bug: user's own `D:\typecrypt\` scratch folder has CLAUDE.md +
|
|
5
|
+
* AGENTS.md + .cursorrules + .windsurfrules + .mneme/ but is NOT a git
|
|
6
|
+
* repo. AUTO-INIT shouldn't poison such folders with a fake .gitignore.
|
|
7
|
+
*
|
|
8
|
+
* Heuristic: "this folder is an AI-dev scratch dir" when:
|
|
9
|
+
* - NOT a git repo (no .git/HEAD)
|
|
10
|
+
* - AND has ≥ 3 AI-tooling fingerprint files at the root
|
|
11
|
+
*
|
|
12
|
+
* Pure read; no I/O writes.
|
|
13
|
+
*/
|
|
14
|
+
export interface DevToolingVerdict {
|
|
15
|
+
isDevTooling: boolean;
|
|
16
|
+
isGitRepo: boolean;
|
|
17
|
+
fingerprints: string[];
|
|
18
|
+
reason: string;
|
|
19
|
+
}
|
|
20
|
+
export declare function detectDevTooling(cwd: string): DevToolingVerdict;
|
|
21
|
+
//# sourceMappingURL=dev_tooling_detector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev_tooling_detector.d.ts","sourceRoot":"","sources":["../../src/auto_init/dev_tooling_detector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAkBH,MAAM,WAAW,iBAAiB;IAChC,YAAY,EAAE,OAAO,CAAC;IACtB,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,iBAAiB,CA2B/D"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v2.45.0 — DEV-TOOLING DETECTOR (closes caveat #3).
|
|
3
|
+
*
|
|
4
|
+
* The bug: user's own `D:\typecrypt\` scratch folder has CLAUDE.md +
|
|
5
|
+
* AGENTS.md + .cursorrules + .windsurfrules + .mneme/ but is NOT a git
|
|
6
|
+
* repo. AUTO-INIT shouldn't poison such folders with a fake .gitignore.
|
|
7
|
+
*
|
|
8
|
+
* Heuristic: "this folder is an AI-dev scratch dir" when:
|
|
9
|
+
* - NOT a git repo (no .git/HEAD)
|
|
10
|
+
* - AND has ≥ 3 AI-tooling fingerprint files at the root
|
|
11
|
+
*
|
|
12
|
+
* Pure read; no I/O writes.
|
|
13
|
+
*/
|
|
14
|
+
import { existsSync } from "node:fs";
|
|
15
|
+
import { join } from "node:path";
|
|
16
|
+
const FINGERPRINTS = [
|
|
17
|
+
"CLAUDE.md",
|
|
18
|
+
"AGENTS.md",
|
|
19
|
+
".cursorrules",
|
|
20
|
+
".windsurfrules",
|
|
21
|
+
".windsurf",
|
|
22
|
+
".cursor",
|
|
23
|
+
".aider.conf.yml",
|
|
24
|
+
".continuerc",
|
|
25
|
+
"GEMINI.md",
|
|
26
|
+
".mneme",
|
|
27
|
+
];
|
|
28
|
+
export function detectDevTooling(cwd) {
|
|
29
|
+
// Defensive: bad path → not a tooling folder (autoInit will fail elsewhere).
|
|
30
|
+
if (!cwd || !existsSync(cwd)) {
|
|
31
|
+
return { isDevTooling: false, isGitRepo: false, fingerprints: [], reason: "path does not exist" };
|
|
32
|
+
}
|
|
33
|
+
const isGitRepo = existsSync(join(cwd, ".git")) || existsSync(join(cwd, ".git", "HEAD"));
|
|
34
|
+
const fingerprints = [];
|
|
35
|
+
for (const f of FINGERPRINTS) {
|
|
36
|
+
if (existsSync(join(cwd, f)))
|
|
37
|
+
fingerprints.push(f);
|
|
38
|
+
}
|
|
39
|
+
// Rule: NOT a git repo + ≥3 AI fingerprints → tooling folder.
|
|
40
|
+
if (!isGitRepo && fingerprints.length >= 3) {
|
|
41
|
+
return {
|
|
42
|
+
isDevTooling: true,
|
|
43
|
+
isGitRepo: false,
|
|
44
|
+
fingerprints,
|
|
45
|
+
reason: `not a git repo + ${fingerprints.length} AI-fingerprint files (${fingerprints.slice(0, 3).join(", ")}...) — looks like an AI-dev scratch folder, not a customer repo`,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
isDevTooling: false,
|
|
50
|
+
isGitRepo,
|
|
51
|
+
fingerprints,
|
|
52
|
+
reason: isGitRepo
|
|
53
|
+
? "is a git repo (customer-facing)"
|
|
54
|
+
: `not a git repo but only ${fingerprints.length} fingerprint(s) — too few to flag as tooling`,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=dev_tooling_detector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev_tooling_detector.js","sourceRoot":"","sources":["../../src/auto_init/dev_tooling_detector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,MAAM,YAAY,GAAG;IACnB,WAAW;IACX,WAAW;IACX,cAAc;IACd,gBAAgB;IAChB,WAAW;IACX,SAAS;IACT,iBAAiB;IACjB,aAAa;IACb,WAAW;IACX,QAAQ;CACT,CAAC;AASF,MAAM,UAAU,gBAAgB,CAAC,GAAW;IAC1C,6EAA6E;IAC7E,IAAI,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QAC7B,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE,EAAE,MAAM,EAAE,qBAAqB,EAAE,CAAC;IACpG,CAAC;IACD,MAAM,SAAS,GAAG,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACzF,MAAM,YAAY,GAAa,EAAE,CAAC;IAClC,KAAK,MAAM,CAAC,IAAI,YAAY,EAAE,CAAC;QAC7B,IAAI,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;YAAE,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACrD,CAAC;IACD,8DAA8D;IAC9D,IAAI,CAAC,SAAS,IAAI,YAAY,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;QAC3C,OAAO;YACL,YAAY,EAAE,IAAI;YAClB,SAAS,EAAE,KAAK;YAChB,YAAY;YACZ,MAAM,EAAE,oBAAoB,YAAY,CAAC,MAAM,0BAA0B,YAAY,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,iEAAiE;SAC9K,CAAC;IACJ,CAAC;IACD,OAAO;QACL,YAAY,EAAE,KAAK;QACnB,SAAS;QACT,YAAY;QACZ,MAAM,EAAE,SAAS;YACf,CAAC,CAAC,iCAAiC;YACnC,CAAC,CAAC,2BAA2B,YAAY,CAAC,MAAM,8CAA8C;KACjG,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v2.45.0 — AUTO-INIT (closes caveat #1).
|
|
3
|
+
*
|
|
4
|
+
* The bug from user's v2.41 audit: "ลูกค้าต้องรัน `mneme init` ก่อน;
|
|
5
|
+
* ถ้าใช้ผ่าน MCP โดยตรงโดยไม่รัน init → อาจไม่มี .gitignore ถูก create".
|
|
6
|
+
*
|
|
7
|
+
* Fix: every MCP tool call (and every CLI invocation that touches the
|
|
8
|
+
* repo) auto-bootstraps in <50ms. Idempotent + defensive — never throws,
|
|
9
|
+
* never duplicates entries, skips DEV-TOOLING folders.
|
|
10
|
+
*
|
|
11
|
+
* User experience after install:
|
|
12
|
+
* 1. user installs Mneme
|
|
13
|
+
* 2. user opens Cursor / Claude Code / etc
|
|
14
|
+
* 3. AI agent calls ANY mneme.* MCP tool → server boot runs autoInit
|
|
15
|
+
* silently
|
|
16
|
+
* 4. .mneme/ + .gitignore entries appear automatically
|
|
17
|
+
* 5. user NEVER typed `mneme init`
|
|
18
|
+
*
|
|
19
|
+
* Pure deterministic on the idempotent path (already-init → no writes).
|
|
20
|
+
*/
|
|
21
|
+
import { detectDevTooling } from "./dev_tooling_detector.js";
|
|
22
|
+
declare const GITIGNORE_SENTINEL_BEGIN = "# BEGIN MNEME AUTO-INIT (do not edit between sentinels) \u2014 v2.45.0+";
|
|
23
|
+
declare const GITIGNORE_SENTINEL_END = "# END MNEME AUTO-INIT";
|
|
24
|
+
declare const GITIGNORE_PAYLOAD: string[];
|
|
25
|
+
export interface AutoInitResult {
|
|
26
|
+
ok: boolean;
|
|
27
|
+
/** True when no work was needed (.mneme/ + sentinel-block already present). */
|
|
28
|
+
alreadyInit?: boolean;
|
|
29
|
+
/** Why autoInit became a no-op (e.g. dev-tooling folder, no write access). */
|
|
30
|
+
skippedReason?: string;
|
|
31
|
+
/** Paths created or modified. */
|
|
32
|
+
created: string[];
|
|
33
|
+
/** Wall time ms. */
|
|
34
|
+
dtMs: number;
|
|
35
|
+
/** Why ok=false, if applicable. */
|
|
36
|
+
reason?: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Idempotent bootstrap. Safe to call before EVERY MCP tool dispatch.
|
|
40
|
+
* Returns ok=false (never throws) when path is invalid or filesystem
|
|
41
|
+
* refuses writes.
|
|
42
|
+
*/
|
|
43
|
+
export declare function autoInit(cwd: string): AutoInitResult;
|
|
44
|
+
/**
|
|
45
|
+
* Best-effort guard: call this at the TOP of every MCP CallTool handler
|
|
46
|
+
* + every CLI command. Never blocks, never throws. Returns silently.
|
|
47
|
+
*/
|
|
48
|
+
export declare function autoInitSilent(cwd: string): void;
|
|
49
|
+
export { GITIGNORE_PAYLOAD, GITIGNORE_SENTINEL_BEGIN, GITIGNORE_SENTINEL_END };
|
|
50
|
+
export { detectDevTooling };
|
|
51
|
+
export type { DevToolingVerdict } from "./dev_tooling_detector.js";
|
|
52
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/auto_init/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAIH,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAK7D,QAAA,MAAM,wBAAwB,4EAAuE,CAAC;AACtG,QAAA,MAAM,sBAAsB,0BAA4B,CAAC;AACzD,QAAA,MAAM,iBAAiB,UAiBtB,CAAC;AAEF,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,OAAO,CAAC;IACZ,+EAA+E;IAC/E,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,8EAA8E;IAC9E,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iCAAiC;IACjC,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,oBAAoB;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,mCAAmC;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAyDD;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAsDpD;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAEhD;AAED,OAAO,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,CAAC;AAC/E,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAC5B,YAAY,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v2.45.0 — AUTO-INIT (closes caveat #1).
|
|
3
|
+
*
|
|
4
|
+
* The bug from user's v2.41 audit: "ลูกค้าต้องรัน `mneme init` ก่อน;
|
|
5
|
+
* ถ้าใช้ผ่าน MCP โดยตรงโดยไม่รัน init → อาจไม่มี .gitignore ถูก create".
|
|
6
|
+
*
|
|
7
|
+
* Fix: every MCP tool call (and every CLI invocation that touches the
|
|
8
|
+
* repo) auto-bootstraps in <50ms. Idempotent + defensive — never throws,
|
|
9
|
+
* never duplicates entries, skips DEV-TOOLING folders.
|
|
10
|
+
*
|
|
11
|
+
* User experience after install:
|
|
12
|
+
* 1. user installs Mneme
|
|
13
|
+
* 2. user opens Cursor / Claude Code / etc
|
|
14
|
+
* 3. AI agent calls ANY mneme.* MCP tool → server boot runs autoInit
|
|
15
|
+
* silently
|
|
16
|
+
* 4. .mneme/ + .gitignore entries appear automatically
|
|
17
|
+
* 5. user NEVER typed `mneme init`
|
|
18
|
+
*
|
|
19
|
+
* Pure deterministic on the idempotent path (already-init → no writes).
|
|
20
|
+
*/
|
|
21
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync, statSync } from "node:fs";
|
|
22
|
+
import { join } from "node:path";
|
|
23
|
+
import { detectDevTooling } from "./dev_tooling_detector.js";
|
|
24
|
+
// Entries appended to .gitignore. Each on its own line. Sentinel-bracketed
|
|
25
|
+
// so we can find + update them atomically without touching user-authored
|
|
26
|
+
// entries above/below.
|
|
27
|
+
const GITIGNORE_SENTINEL_BEGIN = "# BEGIN MNEME AUTO-INIT (do not edit between sentinels) — v2.45.0+";
|
|
28
|
+
const GITIGNORE_SENTINEL_END = "# END MNEME AUTO-INIT";
|
|
29
|
+
const GITIGNORE_PAYLOAD = [
|
|
30
|
+
".mneme/",
|
|
31
|
+
"CLAUDE.md",
|
|
32
|
+
"AGENTS.md",
|
|
33
|
+
".cursorrules",
|
|
34
|
+
".windsurfrules",
|
|
35
|
+
".windsurf/",
|
|
36
|
+
".cursor/",
|
|
37
|
+
".continuerc",
|
|
38
|
+
"GEMINI.md",
|
|
39
|
+
".aider.conf.yml",
|
|
40
|
+
".aider.chat.history.md",
|
|
41
|
+
".aider.input.history",
|
|
42
|
+
// Mneme local state never goes to git
|
|
43
|
+
".mneme/lie-vaccines.jsonl",
|
|
44
|
+
".mneme/cli-activity.jsonl",
|
|
45
|
+
".mneme/honest_mirror_weights.json",
|
|
46
|
+
];
|
|
47
|
+
function ensureMnemeDir(cwd, created) {
|
|
48
|
+
const dir = join(cwd, ".mneme");
|
|
49
|
+
if (existsSync(dir))
|
|
50
|
+
return true;
|
|
51
|
+
try {
|
|
52
|
+
mkdirSync(dir, { recursive: true });
|
|
53
|
+
created.push(".mneme/");
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function ensureGitignoreSentinelBlock(cwd, created) {
|
|
61
|
+
const path = join(cwd, ".gitignore");
|
|
62
|
+
let body = "";
|
|
63
|
+
let existed = false;
|
|
64
|
+
try {
|
|
65
|
+
if (existsSync(path)) {
|
|
66
|
+
body = readFileSync(path, "utf8");
|
|
67
|
+
existed = true;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
// Already has our sentinel block? Idempotent return.
|
|
74
|
+
if (body.includes(GITIGNORE_SENTINEL_BEGIN) && body.includes(GITIGNORE_SENTINEL_END)) {
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
// Build the block. If user already has SOME of our entries above
|
|
78
|
+
// (legacy install), our sentinel block is still safe — git collapses
|
|
79
|
+
// duplicates without warning.
|
|
80
|
+
const block = [
|
|
81
|
+
"",
|
|
82
|
+
GITIGNORE_SENTINEL_BEGIN,
|
|
83
|
+
...GITIGNORE_PAYLOAD,
|
|
84
|
+
GITIGNORE_SENTINEL_END,
|
|
85
|
+
"",
|
|
86
|
+
].join("\n");
|
|
87
|
+
// Strip duplicates from PAYLOAD that may have been written by an
|
|
88
|
+
// older / manual install (avoid the literal duplicate-line audit
|
|
89
|
+
// catch). We only de-dupe lines that exactly match one of our
|
|
90
|
+
// payload entries.
|
|
91
|
+
const payloadSet = new Set(GITIGNORE_PAYLOAD);
|
|
92
|
+
const dedupedLines = body.split("\n").filter((ln, i, arr) => {
|
|
93
|
+
const t = ln.trim();
|
|
94
|
+
if (!payloadSet.has(t))
|
|
95
|
+
return true;
|
|
96
|
+
// Keep the FIRST occurrence only
|
|
97
|
+
return arr.findIndex((x) => x.trim() === t) === i;
|
|
98
|
+
});
|
|
99
|
+
const cleanBody = dedupedLines.join("\n");
|
|
100
|
+
// Append our sentinel block.
|
|
101
|
+
const final = cleanBody.endsWith("\n") || cleanBody.length === 0 ? cleanBody + block : cleanBody + "\n" + block;
|
|
102
|
+
try {
|
|
103
|
+
writeFileSync(path, final);
|
|
104
|
+
if (!existed)
|
|
105
|
+
created.push(".gitignore");
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Idempotent bootstrap. Safe to call before EVERY MCP tool dispatch.
|
|
114
|
+
* Returns ok=false (never throws) when path is invalid or filesystem
|
|
115
|
+
* refuses writes.
|
|
116
|
+
*/
|
|
117
|
+
export function autoInit(cwd) {
|
|
118
|
+
const t0 = Date.now();
|
|
119
|
+
const created = [];
|
|
120
|
+
if (!cwd) {
|
|
121
|
+
return { ok: false, reason: "empty cwd", created, dtMs: Date.now() - t0 };
|
|
122
|
+
}
|
|
123
|
+
// Quick existence check (path must exist + be readable)
|
|
124
|
+
try {
|
|
125
|
+
const st = statSync(cwd);
|
|
126
|
+
if (!st.isDirectory()) {
|
|
127
|
+
return { ok: false, reason: "cwd is not a directory", created, dtMs: Date.now() - t0 };
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
catch (e) {
|
|
131
|
+
return { ok: false, reason: `cwd inaccessible: ${e.message?.slice(0, 80) ?? "err"}`, created, dtMs: Date.now() - t0 };
|
|
132
|
+
}
|
|
133
|
+
// Skip dev-tooling folders (user's own scratch dirs — closes caveat #3).
|
|
134
|
+
const tooling = detectDevTooling(cwd);
|
|
135
|
+
if (tooling.isDevTooling) {
|
|
136
|
+
return {
|
|
137
|
+
ok: true,
|
|
138
|
+
skippedReason: `dev-tooling folder detected: ${tooling.reason}`,
|
|
139
|
+
created,
|
|
140
|
+
dtMs: Date.now() - t0,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
// Hot path: both already in place?
|
|
144
|
+
const mnemeExists = existsSync(join(cwd, ".mneme"));
|
|
145
|
+
let alreadyInit = false;
|
|
146
|
+
if (mnemeExists) {
|
|
147
|
+
const giPath = join(cwd, ".gitignore");
|
|
148
|
+
if (existsSync(giPath)) {
|
|
149
|
+
try {
|
|
150
|
+
const body = readFileSync(giPath, "utf8");
|
|
151
|
+
if (body.includes(GITIGNORE_SENTINEL_BEGIN)) {
|
|
152
|
+
alreadyInit = true;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
catch { /* fall through to write */ }
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
if (alreadyInit) {
|
|
159
|
+
return { ok: true, alreadyInit: true, created, dtMs: Date.now() - t0 };
|
|
160
|
+
}
|
|
161
|
+
// Cold path: ensure both .mneme/ + .gitignore sentinel block.
|
|
162
|
+
const mnemeOk = ensureMnemeDir(cwd, created);
|
|
163
|
+
const giOk = ensureGitignoreSentinelBlock(cwd, created);
|
|
164
|
+
if (!mnemeOk || !giOk) {
|
|
165
|
+
return {
|
|
166
|
+
ok: false,
|
|
167
|
+
reason: `partial init: mneme=${mnemeOk} gitignore=${giOk}`,
|
|
168
|
+
created,
|
|
169
|
+
dtMs: Date.now() - t0,
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
return { ok: true, alreadyInit: false, created, dtMs: Date.now() - t0 };
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Best-effort guard: call this at the TOP of every MCP CallTool handler
|
|
176
|
+
* + every CLI command. Never blocks, never throws. Returns silently.
|
|
177
|
+
*/
|
|
178
|
+
export function autoInitSilent(cwd) {
|
|
179
|
+
try {
|
|
180
|
+
autoInit(cwd);
|
|
181
|
+
}
|
|
182
|
+
catch { /* never bubble */ }
|
|
183
|
+
}
|
|
184
|
+
export { GITIGNORE_PAYLOAD, GITIGNORE_SENTINEL_BEGIN, GITIGNORE_SENTINEL_END };
|
|
185
|
+
export { detectDevTooling };
|
|
186
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","s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IAAI,CAAC,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;QACtB,OAAO;YACL,EAAE,EAAE,KAAK;YACT,MAAM,EAAE,uBAAuB,OAAO,cAAc,IAAI,EAAE;YAC1D,OAAO;YACP,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE;SACtB,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC;AAC1E,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,GAAW;IACxC,IAAI,CAAC;QAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IAAC,CAAC;IAAC,MAAM,CAAC,CAAC,kBAAkB,CAAC,CAAC;AACrD,CAAC;AAED,OAAO,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,CAAC;AAC/E,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v2.45.0 — RETROACTIVE CLEANSE (closes caveat #2).
|
|
3
|
+
*
|
|
4
|
+
* The bug: "ถ้า repo ลูกค้าเคย commit ไฟล์เหล่านี้ก่อนติด Mneme,
|
|
5
|
+
* .gitignore ใหม่ จะ block ของใหม่ — แต่ของเก่าใน history ยังอยู่".
|
|
6
|
+
*
|
|
7
|
+
* AI-fingerprint files (CLAUDE.md / AGENTS.md / .cursorrules /
|
|
8
|
+
* .windsurfrules / .mneme/) committed BEFORE Mneme install stay in git
|
|
9
|
+
* history forever. The user shouldn't have to remember `git filter-repo`.
|
|
10
|
+
*
|
|
11
|
+
* Fix: a single MCP tool the AI agent can invoke on the user's behalf.
|
|
12
|
+
* Three modes (DRY-RUN default):
|
|
13
|
+
*
|
|
14
|
+
* scan — read-only; lists AI-fingerprint files seen in git history
|
|
15
|
+
* uncommit — runs `git rm --cached <file>` (SAFE: keeps disk copy,
|
|
16
|
+
* history stays; future commits won't track)
|
|
17
|
+
* filter-repo — destructive history rewrite via `git filter-repo`
|
|
18
|
+
* (requires confirm:true; emits HMAC receipt)
|
|
19
|
+
*
|
|
20
|
+
* Pure-defensive: never throws; returns structured envelope every time.
|
|
21
|
+
*/
|
|
22
|
+
export type CleanseMode = "scan" | "uncommit" | "filter-repo";
|
|
23
|
+
export interface CleanseFinding {
|
|
24
|
+
path: string;
|
|
25
|
+
/** First commit (oldest) where this file appears. */
|
|
26
|
+
firstCommit?: string;
|
|
27
|
+
/** Most recent commit touching it. */
|
|
28
|
+
lastCommit?: string;
|
|
29
|
+
/** Number of commits that touched it. */
|
|
30
|
+
commitCount: number;
|
|
31
|
+
/** Whether file is also in current working tree. */
|
|
32
|
+
inWorkingTree: boolean;
|
|
33
|
+
}
|
|
34
|
+
export interface CleanseAction {
|
|
35
|
+
path: string;
|
|
36
|
+
command: string;
|
|
37
|
+
executed: boolean;
|
|
38
|
+
ok?: boolean;
|
|
39
|
+
stderr?: string;
|
|
40
|
+
}
|
|
41
|
+
export interface CleanseResult {
|
|
42
|
+
ok: boolean;
|
|
43
|
+
mode: CleanseMode;
|
|
44
|
+
dryRun: boolean;
|
|
45
|
+
/** Files matched by scan. */
|
|
46
|
+
findings: CleanseFinding[];
|
|
47
|
+
/** Planned commands (always populated; in dryRun NONE executed). */
|
|
48
|
+
plan: string[];
|
|
49
|
+
/** Executed commands (empty when dryRun=true). */
|
|
50
|
+
actions: CleanseAction[];
|
|
51
|
+
/** Why ok=false. */
|
|
52
|
+
reason?: string;
|
|
53
|
+
/** HMAC over (mode + repoRoot + findings + actions) for audit trail. */
|
|
54
|
+
hmac?: string;
|
|
55
|
+
/** Wall ms. */
|
|
56
|
+
dtMs: number;
|
|
57
|
+
}
|
|
58
|
+
export interface CleanseInput {
|
|
59
|
+
repoRoot: string;
|
|
60
|
+
mode: CleanseMode;
|
|
61
|
+
/** Default TRUE for safety. Pass false to actually mutate. */
|
|
62
|
+
dryRun?: boolean;
|
|
63
|
+
/** Required true when mode='filter-repo' (destructive history rewrite). */
|
|
64
|
+
confirm?: boolean;
|
|
65
|
+
}
|
|
66
|
+
export declare function cleanse(input: CleanseInput): CleanseResult;
|
|
67
|
+
//# sourceMappingURL=retroactive_cleanse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retroactive_cleanse.d.ts","sourceRoot":"","sources":["../../src/auto_init/retroactive_cleanse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAyBH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,UAAU,GAAG,aAAa,CAAC;AAE9D,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,qDAAqD;IACrD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sCAAsC;IACtC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,yCAAyC;IACzC,WAAW,EAAE,MAAM,CAAC;IACpB,oDAAoD;IACpD,aAAa,EAAE,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;IAClB,EAAE,CAAC,EAAE,OAAO,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,OAAO,CAAC;IACZ,IAAI,EAAE,WAAW,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;IAChB,6BAA6B;IAC7B,QAAQ,EAAE,cAAc,EAAE,CAAC;IAC3B,oEAAoE;IACpE,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,kDAAkD;IAClD,OAAO,EAAE,aAAa,EAAE,CAAC;IACzB,oBAAoB;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,wEAAwE;IACxE,IAAI,CA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