greprag 5.41.0 → 5.42.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/archive/glyph-font.d.ts +22 -0
- package/dist/archive/glyph-font.js +72 -0
- package/dist/archive/glyph-font.js.map +1 -0
- package/dist/archive/page-renderer.d.ts +67 -0
- package/dist/archive/page-renderer.js +197 -0
- package/dist/archive/page-renderer.js.map +1 -0
- package/dist/archive/png-codec.d.ts +21 -0
- package/dist/archive/png-codec.js +197 -0
- package/dist/archive/png-codec.js.map +1 -0
- package/dist/archive/transcript-extract.d.ts +39 -0
- package/dist/archive/transcript-extract.js +187 -0
- package/dist/archive/transcript-extract.js.map +1 -0
- package/dist/ccr-store.d.ts +49 -0
- package/dist/ccr-store.js +171 -0
- package/dist/ccr-store.js.map +1 -0
- package/dist/commands/archive.d.ts +81 -0
- package/dist/commands/archive.js +358 -0
- package/dist/commands/archive.js.map +1 -0
- package/dist/commands/context-governor.d.ts +82 -0
- package/dist/commands/context-governor.js +344 -0
- package/dist/commands/context-governor.js.map +1 -0
- package/dist/commands/crush-stats.d.ts +36 -0
- package/dist/commands/crush-stats.js +142 -0
- package/dist/commands/crush-stats.js.map +1 -0
- package/dist/commands/crush.d.ts +24 -0
- package/dist/commands/crush.js +183 -0
- package/dist/commands/crush.js.map +1 -0
- package/dist/commands/inbox-watch-supervisor.js +8 -65
- package/dist/commands/inbox-watch-supervisor.js.map +1 -1
- package/dist/commands/init.js +93 -0
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/pipe-wrap.d.ts +75 -0
- package/dist/commands/pipe-wrap.js +255 -0
- package/dist/commands/pipe-wrap.js.map +1 -0
- package/dist/commands/watcher-registry.d.ts +1 -8
- package/dist/commands/watcher-registry.js +10 -47
- package/dist/commands/watcher-registry.js.map +1 -1
- package/dist/crush/adaptive-sizer.d.ts +40 -0
- package/dist/crush/adaptive-sizer.js +156 -0
- package/dist/crush/adaptive-sizer.js.map +1 -0
- package/dist/crush/crush-keywords.d.ts +40 -0
- package/dist/crush/crush-keywords.js +110 -0
- package/dist/crush/crush-keywords.js.map +1 -0
- package/dist/crush/crush-types.d.ts +38 -0
- package/dist/crush/crush-types.js +36 -0
- package/dist/crush/crush-types.js.map +1 -0
- package/dist/crush/index.d.ts +16 -0
- package/dist/crush/index.js +48 -0
- package/dist/crush/index.js.map +1 -0
- package/dist/crush/json-crusher.d.ts +38 -0
- package/dist/crush/json-crusher.js +250 -0
- package/dist/crush/json-crusher.js.map +1 -0
- package/dist/crush/json-detectors.d.ts +48 -0
- package/dist/crush/json-detectors.js +211 -0
- package/dist/crush/json-detectors.js.map +1 -0
- package/dist/crush/log-compressor.d.ts +60 -0
- package/dist/crush/log-compressor.js +394 -0
- package/dist/crush/log-compressor.js.map +1 -0
- package/dist/crush/search-compressor.d.ts +60 -0
- package/dist/crush/search-compressor.js +210 -0
- package/dist/crush/search-compressor.js.map +1 -0
- package/dist/hook.js +49 -1
- package/dist/hook.js.map +1 -1
- package/dist/index.js +487 -449
- package/dist/index.js.map +1 -1
- package/dist/session-id.js +7 -12
- package/dist/session-id.js.map +1 -1
- package/package.json +2 -2
- package/skill/mechanic/SKILL.md +1 -1
- package/skill/templates/chip-spawn.md +4 -2
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* MIRRORED FILE — canonical source: packages/core/src/crush/index.ts.
|
|
4
|
+
* Byte-identical copy lives at packages/cli/src/crush/index.ts (the CLI is a
|
|
5
|
+
* zero-dep artifact and cannot import @greprag/core). KEEP IN SYNC —
|
|
6
|
+
* the sync guard in tests/test-crush.cjs fails the build on drift.
|
|
7
|
+
*
|
|
8
|
+
* Crush engine — pure tool-output compressors (Headroom ports).
|
|
9
|
+
* String in -> { output, stats } out. Zero deps, no I/O.
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.classifyImportance = exports.containsAnyKeyword = exports.containsKeyword = exports.JSON_ERROR_KEYWORDS = exports.ERROR_KEYWORDS = exports.findKnee = exports.computeUniqueBigramCurve = exports.computeOptimalK = exports.detectStructuralOutliers = exports.detectSequentialPattern = exports.detectRareStatusValues = exports.detectErrorItems = exports.classifyArray = exports.DEFAULT_JSON_CONFIG = exports.computeKSplit = exports.crushJson = exports.DEFAULT_LOG_CONFIG = exports.normalizeForDedupe = exports.parseLogLines = exports.isSummaryLine = exports.classifyLevel = exports.detectFormat = exports.crushLog = exports.DEFAULT_SEARCH_CONFIG = exports.parseMatchLine = exports.crushSearch = exports.makePassthrough = exports.estimateTokens = void 0;
|
|
13
|
+
var crush_types_1 = require("./crush-types");
|
|
14
|
+
Object.defineProperty(exports, "estimateTokens", { enumerable: true, get: function () { return crush_types_1.estimateTokens; } });
|
|
15
|
+
Object.defineProperty(exports, "makePassthrough", { enumerable: true, get: function () { return crush_types_1.makePassthrough; } });
|
|
16
|
+
var search_compressor_1 = require("./search-compressor");
|
|
17
|
+
Object.defineProperty(exports, "crushSearch", { enumerable: true, get: function () { return search_compressor_1.crushSearch; } });
|
|
18
|
+
Object.defineProperty(exports, "parseMatchLine", { enumerable: true, get: function () { return search_compressor_1.parseMatchLine; } });
|
|
19
|
+
Object.defineProperty(exports, "DEFAULT_SEARCH_CONFIG", { enumerable: true, get: function () { return search_compressor_1.DEFAULT_SEARCH_CONFIG; } });
|
|
20
|
+
var log_compressor_1 = require("./log-compressor");
|
|
21
|
+
Object.defineProperty(exports, "crushLog", { enumerable: true, get: function () { return log_compressor_1.crushLog; } });
|
|
22
|
+
Object.defineProperty(exports, "detectFormat", { enumerable: true, get: function () { return log_compressor_1.detectFormat; } });
|
|
23
|
+
Object.defineProperty(exports, "classifyLevel", { enumerable: true, get: function () { return log_compressor_1.classifyLevel; } });
|
|
24
|
+
Object.defineProperty(exports, "isSummaryLine", { enumerable: true, get: function () { return log_compressor_1.isSummaryLine; } });
|
|
25
|
+
Object.defineProperty(exports, "parseLogLines", { enumerable: true, get: function () { return log_compressor_1.parseLogLines; } });
|
|
26
|
+
Object.defineProperty(exports, "normalizeForDedupe", { enumerable: true, get: function () { return log_compressor_1.normalizeForDedupe; } });
|
|
27
|
+
Object.defineProperty(exports, "DEFAULT_LOG_CONFIG", { enumerable: true, get: function () { return log_compressor_1.DEFAULT_LOG_CONFIG; } });
|
|
28
|
+
var json_crusher_1 = require("./json-crusher");
|
|
29
|
+
Object.defineProperty(exports, "crushJson", { enumerable: true, get: function () { return json_crusher_1.crushJson; } });
|
|
30
|
+
Object.defineProperty(exports, "computeKSplit", { enumerable: true, get: function () { return json_crusher_1.computeKSplit; } });
|
|
31
|
+
Object.defineProperty(exports, "DEFAULT_JSON_CONFIG", { enumerable: true, get: function () { return json_crusher_1.DEFAULT_JSON_CONFIG; } });
|
|
32
|
+
var json_detectors_1 = require("./json-detectors");
|
|
33
|
+
Object.defineProperty(exports, "classifyArray", { enumerable: true, get: function () { return json_detectors_1.classifyArray; } });
|
|
34
|
+
Object.defineProperty(exports, "detectErrorItems", { enumerable: true, get: function () { return json_detectors_1.detectErrorItems; } });
|
|
35
|
+
Object.defineProperty(exports, "detectRareStatusValues", { enumerable: true, get: function () { return json_detectors_1.detectRareStatusValues; } });
|
|
36
|
+
Object.defineProperty(exports, "detectSequentialPattern", { enumerable: true, get: function () { return json_detectors_1.detectSequentialPattern; } });
|
|
37
|
+
Object.defineProperty(exports, "detectStructuralOutliers", { enumerable: true, get: function () { return json_detectors_1.detectStructuralOutliers; } });
|
|
38
|
+
var adaptive_sizer_1 = require("./adaptive-sizer");
|
|
39
|
+
Object.defineProperty(exports, "computeOptimalK", { enumerable: true, get: function () { return adaptive_sizer_1.computeOptimalK; } });
|
|
40
|
+
Object.defineProperty(exports, "computeUniqueBigramCurve", { enumerable: true, get: function () { return adaptive_sizer_1.computeUniqueBigramCurve; } });
|
|
41
|
+
Object.defineProperty(exports, "findKnee", { enumerable: true, get: function () { return adaptive_sizer_1.findKnee; } });
|
|
42
|
+
var crush_keywords_1 = require("./crush-keywords");
|
|
43
|
+
Object.defineProperty(exports, "ERROR_KEYWORDS", { enumerable: true, get: function () { return crush_keywords_1.ERROR_KEYWORDS; } });
|
|
44
|
+
Object.defineProperty(exports, "JSON_ERROR_KEYWORDS", { enumerable: true, get: function () { return crush_keywords_1.JSON_ERROR_KEYWORDS; } });
|
|
45
|
+
Object.defineProperty(exports, "containsKeyword", { enumerable: true, get: function () { return crush_keywords_1.containsKeyword; } });
|
|
46
|
+
Object.defineProperty(exports, "containsAnyKeyword", { enumerable: true, get: function () { return crush_keywords_1.containsAnyKeyword; } });
|
|
47
|
+
Object.defineProperty(exports, "classifyImportance", { enumerable: true, get: function () { return crush_keywords_1.classifyImportance; } });
|
|
48
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/crush/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AAEH,6CAA0G;AAAvD,6GAAA,cAAc,OAAA;AAAE,8GAAA,eAAe,OAAA;AAClF,yDAAiH;AAAxG,gHAAA,WAAW,OAAA;AAAE,mHAAA,cAAc,OAAA;AAAE,0HAAA,qBAAqB,OAAA;AAC3D,mDAY0B;AAXxB,0GAAA,QAAQ,OAAA;AACR,8GAAA,YAAY,OAAA;AACZ,+GAAA,aAAa,OAAA;AACb,+GAAA,aAAa,OAAA;AACb,+GAAA,aAAa,OAAA;AACb,oHAAA,kBAAkB,OAAA;AAClB,oHAAA,kBAAkB,OAAA;AAMpB,+CAAkG;AAAzF,yGAAA,SAAS,OAAA;AAAE,6GAAA,aAAa,OAAA;AAAE,mHAAA,mBAAmB,OAAA;AACtD,mDAQ0B;AAPxB,+GAAA,aAAa,OAAA;AACb,kHAAA,gBAAgB,OAAA;AAChB,wHAAA,sBAAsB,OAAA;AACtB,yHAAA,uBAAuB,OAAA;AACvB,0HAAA,wBAAwB,OAAA;AAI1B,mDAAuF;AAA9E,iHAAA,eAAe,OAAA;AAAE,0HAAA,wBAAwB,OAAA;AAAE,0GAAA,QAAQ,OAAA;AAC5D,mDAM0B;AALxB,gHAAA,cAAc,OAAA;AACd,qHAAA,mBAAmB,OAAA;AACnB,iHAAA,eAAe,OAAA;AACf,oHAAA,kBAAkB,OAAA;AAClB,oHAAA,kBAAkB,OAAA"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MIRRORED FILE — canonical source: packages/core/src/crush/json-crusher.ts.
|
|
3
|
+
* Byte-identical copy lives at packages/cli/src/crush/json-crusher.ts (the CLI is a
|
|
4
|
+
* zero-dep artifact and cannot import @greprag/core). KEEP IN SYNC —
|
|
5
|
+
* the sync guard in tests/test-crush.cjs fails the build on drift.
|
|
6
|
+
*
|
|
7
|
+
* JSON-array crusher — TypeScript port of the SIMPLE core of Headroom's
|
|
8
|
+
* smart_crusher: statistical sampling + error preservation. Classifies
|
|
9
|
+
* each array, keeps errors / structural outliers / rare statuses /
|
|
10
|
+
* first+last blocks, and replaces the dropped bulk with a count marker
|
|
11
|
+
* string (`"[... N items omitted ...]"`).
|
|
12
|
+
*
|
|
13
|
+
* The full Headroom orchestration (TOIN semantics, relevance planning,
|
|
14
|
+
* lossless compaction, change points) is intentionally not ported.
|
|
15
|
+
*/
|
|
16
|
+
import { CrushResult } from './crush-types';
|
|
17
|
+
export interface JsonCrusherConfig {
|
|
18
|
+
/** Arrays smaller than this are left alone. */
|
|
19
|
+
minItemsToAnalyze: number;
|
|
20
|
+
/** Target maximum items kept per crushed array. */
|
|
21
|
+
maxItemsAfterCrush: number;
|
|
22
|
+
/** Fraction of the budget pinned to the array head. */
|
|
23
|
+
firstFraction: number;
|
|
24
|
+
/** Fraction of the budget pinned to the array tail. */
|
|
25
|
+
lastFraction: number;
|
|
26
|
+
bias: number;
|
|
27
|
+
}
|
|
28
|
+
export declare const DEFAULT_JSON_CONFIG: JsonCrusherConfig;
|
|
29
|
+
/** First/last slot split for a keep-budget. Never exceeds kTotal. */
|
|
30
|
+
export declare function computeKSplit(kTotal: number, firstFraction: number, lastFraction: number): {
|
|
31
|
+
first: number;
|
|
32
|
+
last: number;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Compress JSON containing large arrays. Non-JSON input, or JSON with
|
|
36
|
+
* no qualifying arrays, passes through unchanged.
|
|
37
|
+
*/
|
|
38
|
+
export declare function crushJson(content: string, config?: Partial<JsonCrusherConfig>): CrushResult;
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* MIRRORED FILE — canonical source: packages/core/src/crush/json-crusher.ts.
|
|
4
|
+
* Byte-identical copy lives at packages/cli/src/crush/json-crusher.ts (the CLI is a
|
|
5
|
+
* zero-dep artifact and cannot import @greprag/core). KEEP IN SYNC —
|
|
6
|
+
* the sync guard in tests/test-crush.cjs fails the build on drift.
|
|
7
|
+
*
|
|
8
|
+
* JSON-array crusher — TypeScript port of the SIMPLE core of Headroom's
|
|
9
|
+
* smart_crusher: statistical sampling + error preservation. Classifies
|
|
10
|
+
* each array, keeps errors / structural outliers / rare statuses /
|
|
11
|
+
* first+last blocks, and replaces the dropped bulk with a count marker
|
|
12
|
+
* string (`"[... N items omitted ...]"`).
|
|
13
|
+
*
|
|
14
|
+
* The full Headroom orchestration (TOIN semantics, relevance planning,
|
|
15
|
+
* lossless compaction, change points) is intentionally not ported.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.DEFAULT_JSON_CONFIG = void 0;
|
|
19
|
+
exports.computeKSplit = computeKSplit;
|
|
20
|
+
exports.crushJson = crushJson;
|
|
21
|
+
const adaptive_sizer_1 = require("./adaptive-sizer");
|
|
22
|
+
const crush_types_1 = require("./crush-types");
|
|
23
|
+
const json_detectors_1 = require("./json-detectors");
|
|
24
|
+
exports.DEFAULT_JSON_CONFIG = {
|
|
25
|
+
minItemsToAnalyze: 10,
|
|
26
|
+
maxItemsAfterCrush: 15,
|
|
27
|
+
firstFraction: 0.3,
|
|
28
|
+
lastFraction: 0.15,
|
|
29
|
+
bias: 1.0,
|
|
30
|
+
};
|
|
31
|
+
/** First/last slot split for a keep-budget. Never exceeds kTotal. */
|
|
32
|
+
function computeKSplit(kTotal, firstFraction, lastFraction) {
|
|
33
|
+
if (kTotal <= 1)
|
|
34
|
+
return { first: kTotal, last: 0 };
|
|
35
|
+
const first = Math.max(1, Math.round(kTotal * firstFraction));
|
|
36
|
+
const last = Math.max(1, Math.round(kTotal * lastFraction));
|
|
37
|
+
if (first + last > kTotal)
|
|
38
|
+
return { first: Math.max(1, kTotal - 1), last: kTotal > 1 ? 1 : 0 };
|
|
39
|
+
return { first, last };
|
|
40
|
+
}
|
|
41
|
+
/** Find a common-ish id field whose values run sequentially, for marker enrichment. */
|
|
42
|
+
function sequentialIdField(items) {
|
|
43
|
+
const first = items[0];
|
|
44
|
+
if (typeof first !== 'object' || first === null || Array.isArray(first))
|
|
45
|
+
return null;
|
|
46
|
+
for (const key of Object.keys(first)) {
|
|
47
|
+
if (!/^(id|.*_id|index|seq|n)$/i.test(key))
|
|
48
|
+
continue;
|
|
49
|
+
const values = items.map((it) => typeof it === 'object' && it !== null && !Array.isArray(it) ? it[key] ?? null : null);
|
|
50
|
+
if ((0, json_detectors_1.detectSequentialPattern)(values))
|
|
51
|
+
return key;
|
|
52
|
+
}
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
function omittedMarker(droppedCount, items, droppedIndices) {
|
|
56
|
+
const idField = sequentialIdField(items);
|
|
57
|
+
if (idField && droppedIndices.length > 0) {
|
|
58
|
+
const firstDropped = items[droppedIndices[0]];
|
|
59
|
+
const lastDropped = items[droppedIndices[droppedIndices.length - 1]];
|
|
60
|
+
const idOf = (v) => typeof v === 'object' && v !== null && !Array.isArray(v) ? v[idField] ?? null : null;
|
|
61
|
+
const lo = idOf(firstDropped);
|
|
62
|
+
const hi = idOf(lastDropped);
|
|
63
|
+
if (lo !== null && hi !== null) {
|
|
64
|
+
return `[... ${droppedCount} items omitted (${idField} ${lo}..${hi}) ...]`;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return `[... ${droppedCount} items omitted ...]`;
|
|
68
|
+
}
|
|
69
|
+
/** Crush one array of objects: errors + outliers always kept; first/last + fill to budget. */
|
|
70
|
+
function crushDictArray(items, config) {
|
|
71
|
+
const n = items.length;
|
|
72
|
+
const serialized = items.map((it) => JSON.stringify(it));
|
|
73
|
+
const budget = (0, adaptive_sizer_1.computeOptimalK)(serialized, config.bias, 5, config.maxItemsAfterCrush);
|
|
74
|
+
const keep = new Set();
|
|
75
|
+
// Errors are never dropped (preservation guarantee).
|
|
76
|
+
for (const idx of (0, json_detectors_1.detectErrorItems)(items))
|
|
77
|
+
keep.add(idx);
|
|
78
|
+
// Structural outliers (rare fields + rare statuses).
|
|
79
|
+
for (const idx of (0, json_detectors_1.detectStructuralOutliers)(items))
|
|
80
|
+
keep.add(idx);
|
|
81
|
+
// First/last blocks from the remaining budget.
|
|
82
|
+
const remaining = Math.max(0, budget - keep.size);
|
|
83
|
+
if (remaining > 0) {
|
|
84
|
+
const { first, last } = computeKSplit(remaining, config.firstFraction, config.lastFraction);
|
|
85
|
+
for (let i = 0; i < Math.min(first, n); i++)
|
|
86
|
+
keep.add(i);
|
|
87
|
+
for (let i = Math.max(0, n - last); i < n; i++)
|
|
88
|
+
keep.add(i);
|
|
89
|
+
// Fill any leftover slots with an even sample of the middle.
|
|
90
|
+
let leftover = budget - keep.size;
|
|
91
|
+
if (leftover > 0) {
|
|
92
|
+
const step = Math.max(1, Math.floor(n / (leftover + 1)));
|
|
93
|
+
for (let i = step; i < n && leftover > 0; i += step) {
|
|
94
|
+
if (!keep.has(i)) {
|
|
95
|
+
keep.add(i);
|
|
96
|
+
leftover--;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
if (keep.size >= n) {
|
|
102
|
+
return { items: [...items], originalCount: n, keptCount: n, crushed: false };
|
|
103
|
+
}
|
|
104
|
+
const keptIndices = [...keep].sort((a, b) => a - b);
|
|
105
|
+
const droppedIndices = [];
|
|
106
|
+
for (let i = 0; i < n; i++) {
|
|
107
|
+
if (!keep.has(i))
|
|
108
|
+
droppedIndices.push(i);
|
|
109
|
+
}
|
|
110
|
+
// Survivors in original order, with one marker at the first gap.
|
|
111
|
+
const out = [];
|
|
112
|
+
let markerPlaced = false;
|
|
113
|
+
for (let i = 0; i < n; i++) {
|
|
114
|
+
if (keep.has(i)) {
|
|
115
|
+
out.push(items[i]);
|
|
116
|
+
}
|
|
117
|
+
else if (!markerPlaced) {
|
|
118
|
+
out.push(omittedMarker(droppedIndices.length, items, droppedIndices));
|
|
119
|
+
markerPlaced = true;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return { items: out, originalCount: n, keptCount: keptIndices.length, crushed: true };
|
|
123
|
+
}
|
|
124
|
+
/** Crush a scalar (string/number) array: keep first/last + statistical outliers. */
|
|
125
|
+
function crushScalarArray(items, config) {
|
|
126
|
+
const n = items.length;
|
|
127
|
+
const serialized = items.map((it) => JSON.stringify(it));
|
|
128
|
+
const budget = (0, adaptive_sizer_1.computeOptimalK)(serialized, config.bias, 5, config.maxItemsAfterCrush);
|
|
129
|
+
if (budget >= n) {
|
|
130
|
+
return { items: [...items], originalCount: n, keptCount: n, crushed: false };
|
|
131
|
+
}
|
|
132
|
+
const keep = new Set();
|
|
133
|
+
// Numeric outliers: beyond 2 standard deviations from the mean.
|
|
134
|
+
const numbers = items.every((it) => typeof it === 'number') ? items : null;
|
|
135
|
+
if (numbers) {
|
|
136
|
+
const mean = numbers.reduce((s, v) => s + v, 0) / n;
|
|
137
|
+
const variance = numbers.reduce((s, v) => s + (v - mean) ** 2, 0) / n;
|
|
138
|
+
const std = Math.sqrt(variance);
|
|
139
|
+
if (std > 0) {
|
|
140
|
+
for (let i = 0; i < n; i++) {
|
|
141
|
+
if (Math.abs(numbers[i] - mean) > 2 * std)
|
|
142
|
+
keep.add(i);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
// String error items.
|
|
147
|
+
if (!numbers) {
|
|
148
|
+
for (let i = 0; i < n; i++) {
|
|
149
|
+
const it = items[i];
|
|
150
|
+
if (typeof it === 'string') {
|
|
151
|
+
const lower = it.toLowerCase();
|
|
152
|
+
if (/(error|exception|failed|failure|fatal|panic|timeout)/.test(lower))
|
|
153
|
+
keep.add(i);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
const remaining = Math.max(0, budget - keep.size);
|
|
158
|
+
if (remaining > 0) {
|
|
159
|
+
const { first, last } = computeKSplit(remaining, config.firstFraction, config.lastFraction);
|
|
160
|
+
for (let i = 0; i < Math.min(first, n); i++)
|
|
161
|
+
keep.add(i);
|
|
162
|
+
for (let i = Math.max(0, n - last); i < n; i++)
|
|
163
|
+
keep.add(i);
|
|
164
|
+
}
|
|
165
|
+
if (keep.size >= n) {
|
|
166
|
+
return { items: [...items], originalCount: n, keptCount: n, crushed: false };
|
|
167
|
+
}
|
|
168
|
+
const out = [];
|
|
169
|
+
let dropped = 0;
|
|
170
|
+
let markerAt = -1;
|
|
171
|
+
for (let i = 0; i < n; i++) {
|
|
172
|
+
if (keep.has(i)) {
|
|
173
|
+
out.push(items[i]);
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
dropped++;
|
|
177
|
+
if (markerAt === -1) {
|
|
178
|
+
markerAt = out.length;
|
|
179
|
+
out.push(''); // placeholder, replaced below
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
if (markerAt >= 0)
|
|
184
|
+
out[markerAt] = `[... ${dropped} items omitted ...]`;
|
|
185
|
+
return { items: out, originalCount: n, keptCount: n - dropped, crushed: true };
|
|
186
|
+
}
|
|
187
|
+
/** Recursively walk a JSON value, crushing qualifying arrays in place. */
|
|
188
|
+
function walkAndCrush(value, config, totals) {
|
|
189
|
+
if (Array.isArray(value)) {
|
|
190
|
+
const recursed = value.map((v) => walkAndCrush(v, config, totals));
|
|
191
|
+
if (recursed.length < config.minItemsToAnalyze)
|
|
192
|
+
return recursed;
|
|
193
|
+
const kind = (0, json_detectors_1.classifyArray)(recursed);
|
|
194
|
+
let outcome = null;
|
|
195
|
+
if (kind === 'dict_array')
|
|
196
|
+
outcome = crushDictArray(recursed, config);
|
|
197
|
+
else if (kind === 'string_array' || kind === 'number_array')
|
|
198
|
+
outcome = crushScalarArray(recursed, config);
|
|
199
|
+
if (outcome && outcome.crushed) {
|
|
200
|
+
totals.original += outcome.originalCount;
|
|
201
|
+
totals.kept += outcome.keptCount;
|
|
202
|
+
totals.crushedArrays++;
|
|
203
|
+
return outcome.items;
|
|
204
|
+
}
|
|
205
|
+
totals.original += recursed.length;
|
|
206
|
+
totals.kept += recursed.length;
|
|
207
|
+
return recursed;
|
|
208
|
+
}
|
|
209
|
+
if (typeof value === 'object' && value !== null) {
|
|
210
|
+
const out = {};
|
|
211
|
+
for (const [k, v] of Object.entries(value)) {
|
|
212
|
+
out[k] = walkAndCrush(v, config, totals);
|
|
213
|
+
}
|
|
214
|
+
return out;
|
|
215
|
+
}
|
|
216
|
+
return value;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Compress JSON containing large arrays. Non-JSON input, or JSON with
|
|
220
|
+
* no qualifying arrays, passes through unchanged.
|
|
221
|
+
*/
|
|
222
|
+
function crushJson(content, config = {}) {
|
|
223
|
+
const cfg = { ...exports.DEFAULT_JSON_CONFIG, ...config };
|
|
224
|
+
let parsed;
|
|
225
|
+
try {
|
|
226
|
+
parsed = JSON.parse(content);
|
|
227
|
+
}
|
|
228
|
+
catch {
|
|
229
|
+
return (0, crush_types_1.makePassthrough)(content, 'json', 'not valid JSON');
|
|
230
|
+
}
|
|
231
|
+
const totals = { original: 0, kept: 0, crushedArrays: 0 };
|
|
232
|
+
const crushedValue = walkAndCrush(parsed, cfg, totals);
|
|
233
|
+
if (totals.crushedArrays === 0) {
|
|
234
|
+
return (0, crush_types_1.makePassthrough)(content, 'json', 'no qualifying arrays', totals.original);
|
|
235
|
+
}
|
|
236
|
+
const output = JSON.stringify(crushedValue);
|
|
237
|
+
return {
|
|
238
|
+
output,
|
|
239
|
+
stats: {
|
|
240
|
+
sourceType: 'json',
|
|
241
|
+
originalChars: content.length,
|
|
242
|
+
compressedChars: output.length,
|
|
243
|
+
compressionRatio: output.length / Math.max(content.length, 1),
|
|
244
|
+
originalUnits: totals.original,
|
|
245
|
+
keptUnits: totals.kept,
|
|
246
|
+
passthrough: false,
|
|
247
|
+
},
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
//# sourceMappingURL=json-crusher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-crusher.js","sourceRoot":"","sources":["../../src/crush/json-crusher.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAiCH,sCAMC;AAkMD,8BA8BC;AArQD,qDAAmD;AACnD,+CAA6D;AAC7D,qDAM0B;AAcb,QAAA,mBAAmB,GAAsB;IACpD,iBAAiB,EAAE,EAAE;IACrB,kBAAkB,EAAE,EAAE;IACtB,aAAa,EAAE,GAAG;IAClB,YAAY,EAAE,IAAI;IAClB,IAAI,EAAE,GAAG;CACV,CAAC;AAEF,qEAAqE;AACrE,SAAgB,aAAa,CAAC,MAAc,EAAE,aAAqB,EAAE,YAAoB;IACvF,IAAI,MAAM,IAAI,CAAC;QAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;IACnD,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,aAAa,CAAC,CAAC,CAAC;IAC9D,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,MA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AC9B,gBAAgB,EAAE,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;YAC7D,aAAa,EAAE,MAAM,CAAC,QAAQ;YAC9B,SAAS,EAAE,MAAM,CAAC,IAAI;YACtB,WAAW,EAAE,KAAK;SACnB;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MIRRORED FILE — canonical source: packages/core/src/crush/json-detectors.ts.
|
|
3
|
+
* Byte-identical copy lives at packages/cli/src/crush/json-detectors.ts (the CLI is a
|
|
4
|
+
* zero-dep artifact and cannot import @greprag/core). KEEP IN SYNC —
|
|
5
|
+
* the sync guard in tests/test-crush.cjs fails the build on drift.
|
|
6
|
+
*
|
|
7
|
+
* Array classification + outlier/sequence detectors for the JSON
|
|
8
|
+
* crusher — port of the simple core of Headroom's smart_crusher
|
|
9
|
+
* (classifier.rs, outliers.rs, statistics.rs).
|
|
10
|
+
*
|
|
11
|
+
* Carries Headroom's documented fixes:
|
|
12
|
+
* - Zero-padded string IDs ("001", "002", ...) are NOT sequential
|
|
13
|
+
* numerics — if every parseable value originated as a string, the
|
|
14
|
+
* field is categorical and the padding matters.
|
|
15
|
+
* - Rare-status detection must not short-circuit at >10 distinct
|
|
16
|
+
* values: cardinality cap raised to 50 with a Pareto check (smallest
|
|
17
|
+
* K values covering >=80%; rare iff K <= 5), so datasets with dozens
|
|
18
|
+
* of error codes keep their rare-error preservation.
|
|
19
|
+
*/
|
|
20
|
+
export type JsonValue = null | boolean | number | string | JsonValue[] | {
|
|
21
|
+
[key: string]: JsonValue;
|
|
22
|
+
};
|
|
23
|
+
export type ArrayType = 'dict_array' | 'string_array' | 'number_array' | 'bool_array' | 'nested_array' | 'mixed_array' | 'empty';
|
|
24
|
+
/** Classify a JSON array by element types (walks every element). */
|
|
25
|
+
export declare function classifyArray(items: readonly JsonValue[]): ArrayType;
|
|
26
|
+
/**
|
|
27
|
+
* Detect whether values form a sequential numeric pattern (IDs: 1,2,3…).
|
|
28
|
+
*
|
|
29
|
+
* Zero-padding fix: string values that parse as integers are counted,
|
|
30
|
+
* but if EVERY numeric value originated as a string the field is
|
|
31
|
+
* refused as sequential (padded codes are categorical).
|
|
32
|
+
*/
|
|
33
|
+
export declare function detectSequentialPattern(values: readonly JsonValue[]): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Detect items with rare values in status-like categorical fields
|
|
36
|
+
* (Pareto check, cardinality 2..=50). Returns item indices.
|
|
37
|
+
*/
|
|
38
|
+
export declare function detectRareStatusValues(items: readonly JsonValue[], commonFields: ReadonlySet<string>): number[];
|
|
39
|
+
/**
|
|
40
|
+
* Detect structural outliers: items carrying a rare field (<20% of the
|
|
41
|
+
* array) plus rare-status items. Returns sorted, deduped indices.
|
|
42
|
+
*/
|
|
43
|
+
export declare function detectStructuralOutliers(items: readonly JsonValue[]): number[];
|
|
44
|
+
/**
|
|
45
|
+
* Detect items containing error keywords — these are NEVER dropped.
|
|
46
|
+
* Scans each object item's full serialization, case-insensitively.
|
|
47
|
+
*/
|
|
48
|
+
export declare function detectErrorItems(items: readonly JsonValue[]): number[];
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* MIRRORED FILE — canonical source: packages/core/src/crush/json-detectors.ts.
|
|
4
|
+
* Byte-identical copy lives at packages/cli/src/crush/json-detectors.ts (the CLI is a
|
|
5
|
+
* zero-dep artifact and cannot import @greprag/core). KEEP IN SYNC —
|
|
6
|
+
* the sync guard in tests/test-crush.cjs fails the build on drift.
|
|
7
|
+
*
|
|
8
|
+
* Array classification + outlier/sequence detectors for the JSON
|
|
9
|
+
* crusher — port of the simple core of Headroom's smart_crusher
|
|
10
|
+
* (classifier.rs, outliers.rs, statistics.rs).
|
|
11
|
+
*
|
|
12
|
+
* Carries Headroom's documented fixes:
|
|
13
|
+
* - Zero-padded string IDs ("001", "002", ...) are NOT sequential
|
|
14
|
+
* numerics — if every parseable value originated as a string, the
|
|
15
|
+
* field is categorical and the padding matters.
|
|
16
|
+
* - Rare-status detection must not short-circuit at >10 distinct
|
|
17
|
+
* values: cardinality cap raised to 50 with a Pareto check (smallest
|
|
18
|
+
* K values covering >=80%; rare iff K <= 5), so datasets with dozens
|
|
19
|
+
* of error codes keep their rare-error preservation.
|
|
20
|
+
*/
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.classifyArray = classifyArray;
|
|
23
|
+
exports.detectSequentialPattern = detectSequentialPattern;
|
|
24
|
+
exports.detectRareStatusValues = detectRareStatusValues;
|
|
25
|
+
exports.detectStructuralOutliers = detectStructuralOutliers;
|
|
26
|
+
exports.detectErrorItems = detectErrorItems;
|
|
27
|
+
const crush_keywords_1 = require("./crush-keywords");
|
|
28
|
+
/** Classify a JSON array by element types (walks every element). */
|
|
29
|
+
function classifyArray(items) {
|
|
30
|
+
if (items.length === 0)
|
|
31
|
+
return 'empty';
|
|
32
|
+
let hasBool = false, hasNumber = false, hasString = false, hasObject = false, hasArray = false, hasNull = false;
|
|
33
|
+
for (const item of items) {
|
|
34
|
+
if (item === null)
|
|
35
|
+
hasNull = true;
|
|
36
|
+
else if (typeof item === 'boolean')
|
|
37
|
+
hasBool = true;
|
|
38
|
+
else if (typeof item === 'number')
|
|
39
|
+
hasNumber = true;
|
|
40
|
+
else if (typeof item === 'string')
|
|
41
|
+
hasString = true;
|
|
42
|
+
else if (Array.isArray(item))
|
|
43
|
+
hasArray = true;
|
|
44
|
+
else
|
|
45
|
+
hasObject = true;
|
|
46
|
+
}
|
|
47
|
+
if (hasBool && !hasNumber && !hasString && !hasObject && !hasArray && !hasNull)
|
|
48
|
+
return 'bool_array';
|
|
49
|
+
if (hasObject && !hasBool && !hasNumber && !hasString && !hasArray && !hasNull)
|
|
50
|
+
return 'dict_array';
|
|
51
|
+
if (hasString && !hasBool && !hasNumber && !hasObject && !hasArray && !hasNull)
|
|
52
|
+
return 'string_array';
|
|
53
|
+
if (hasNumber && !hasBool && !hasString && !hasObject && !hasArray && !hasNull)
|
|
54
|
+
return 'number_array';
|
|
55
|
+
if (hasArray && !hasBool && !hasNumber && !hasString && !hasObject && !hasNull)
|
|
56
|
+
return 'nested_array';
|
|
57
|
+
return 'mixed_array';
|
|
58
|
+
}
|
|
59
|
+
function isPlainObject(v) {
|
|
60
|
+
return typeof v === 'object' && v !== null && !Array.isArray(v);
|
|
61
|
+
}
|
|
62
|
+
function stringifyScalar(v) {
|
|
63
|
+
if (typeof v === 'string')
|
|
64
|
+
return v;
|
|
65
|
+
return JSON.stringify(v);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Detect whether values form a sequential numeric pattern (IDs: 1,2,3…).
|
|
69
|
+
*
|
|
70
|
+
* Zero-padding fix: string values that parse as integers are counted,
|
|
71
|
+
* but if EVERY numeric value originated as a string the field is
|
|
72
|
+
* refused as sequential (padded codes are categorical).
|
|
73
|
+
*/
|
|
74
|
+
function detectSequentialPattern(values) {
|
|
75
|
+
if (values.length < 5)
|
|
76
|
+
return false;
|
|
77
|
+
const nums = [];
|
|
78
|
+
let hadNonStringNumeric = false;
|
|
79
|
+
for (const v of values) {
|
|
80
|
+
if (typeof v === 'number') {
|
|
81
|
+
nums.push(v);
|
|
82
|
+
hadNonStringNumeric = true;
|
|
83
|
+
}
|
|
84
|
+
else if (typeof v === 'string' && /^[+-]?\d+$/.test(v.trim())) {
|
|
85
|
+
nums.push(parseInt(v.trim(), 10));
|
|
86
|
+
// Deliberately NOT setting hadNonStringNumeric (the fix).
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
if (nums.length < 5)
|
|
90
|
+
return false;
|
|
91
|
+
if (!hadNonStringNumeric)
|
|
92
|
+
return false;
|
|
93
|
+
const sorted = [...nums].sort((a, b) => a - b);
|
|
94
|
+
const diffs = [];
|
|
95
|
+
for (let i = 1; i < sorted.length; i++)
|
|
96
|
+
diffs.push(sorted[i] - sorted[i - 1]);
|
|
97
|
+
if (diffs.length === 0)
|
|
98
|
+
return false;
|
|
99
|
+
const avg = diffs.reduce((s, d) => s + d, 0) / diffs.length;
|
|
100
|
+
if (avg < 0.5 || avg > 2.0)
|
|
101
|
+
return false;
|
|
102
|
+
const consistent = diffs.filter((d) => d >= 0.5 && d <= 2.0).length;
|
|
103
|
+
return consistent / diffs.length > 0.8;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Detect items with rare values in status-like categorical fields
|
|
107
|
+
* (Pareto check, cardinality 2..=50). Returns item indices.
|
|
108
|
+
*/
|
|
109
|
+
function detectRareStatusValues(items, commonFields) {
|
|
110
|
+
const outliers = [];
|
|
111
|
+
const sortedFields = [...commonFields].sort();
|
|
112
|
+
for (const field of sortedFields) {
|
|
113
|
+
const values = [];
|
|
114
|
+
for (const item of items) {
|
|
115
|
+
if (isPlainObject(item) && field in item)
|
|
116
|
+
values.push(item[field]);
|
|
117
|
+
}
|
|
118
|
+
const uniqueValues = new Set();
|
|
119
|
+
for (const v of values) {
|
|
120
|
+
if (v !== null)
|
|
121
|
+
uniqueValues.add(stringifyScalar(v));
|
|
122
|
+
}
|
|
123
|
+
// Cardinality cap: 2..=50 (the >10 short-circuit fix).
|
|
124
|
+
if (uniqueValues.size < 2 || uniqueValues.size > 50)
|
|
125
|
+
continue;
|
|
126
|
+
const counts = new Map();
|
|
127
|
+
for (const v of values) {
|
|
128
|
+
const key = v === null ? '__none__' : stringifyScalar(v);
|
|
129
|
+
counts.set(key, (counts.get(key) ?? 0) + 1);
|
|
130
|
+
}
|
|
131
|
+
if (counts.size === 0)
|
|
132
|
+
continue;
|
|
133
|
+
// Pareto: smallest K values covering >=80% of items.
|
|
134
|
+
const sortedCounts = [...counts.entries()].sort((a, b) => b[1] - a[1] || (a[0] < b[0] ? -1 : 1));
|
|
135
|
+
const threshold = Math.ceil(values.length * 0.8);
|
|
136
|
+
let cumulative = 0;
|
|
137
|
+
const topK = new Set();
|
|
138
|
+
for (const [value, count] of sortedCounts) {
|
|
139
|
+
cumulative += count;
|
|
140
|
+
topK.add(value);
|
|
141
|
+
if (cumulative >= threshold)
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
144
|
+
// Above K=5 the distribution is too uniform to call anything rare.
|
|
145
|
+
if (topK.size > 5)
|
|
146
|
+
continue;
|
|
147
|
+
for (let i = 0; i < items.length; i++) {
|
|
148
|
+
const item = items[i];
|
|
149
|
+
if (!isPlainObject(item) || !(field in item))
|
|
150
|
+
continue;
|
|
151
|
+
const v = item[field];
|
|
152
|
+
const key = v === null ? '__none__' : stringifyScalar(v);
|
|
153
|
+
if (!topK.has(key))
|
|
154
|
+
outliers.push(i);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return outliers;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Detect structural outliers: items carrying a rare field (<20% of the
|
|
161
|
+
* array) plus rare-status items. Returns sorted, deduped indices.
|
|
162
|
+
*/
|
|
163
|
+
function detectStructuralOutliers(items) {
|
|
164
|
+
if (items.length < 5)
|
|
165
|
+
return [];
|
|
166
|
+
const fieldCounts = new Map();
|
|
167
|
+
for (const item of items) {
|
|
168
|
+
if (!isPlainObject(item))
|
|
169
|
+
continue;
|
|
170
|
+
for (const key of Object.keys(item)) {
|
|
171
|
+
fieldCounts.set(key, (fieldCounts.get(key) ?? 0) + 1);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
const n = items.length;
|
|
175
|
+
const commonFields = new Set();
|
|
176
|
+
const rareFields = new Set();
|
|
177
|
+
for (const [field, count] of fieldCounts) {
|
|
178
|
+
if (count >= n * 0.8)
|
|
179
|
+
commonFields.add(field);
|
|
180
|
+
if (count < n * 0.2)
|
|
181
|
+
rareFields.add(field);
|
|
182
|
+
}
|
|
183
|
+
const outliers = new Set();
|
|
184
|
+
for (let i = 0; i < items.length; i++) {
|
|
185
|
+
const item = items[i];
|
|
186
|
+
if (!isPlainObject(item))
|
|
187
|
+
continue;
|
|
188
|
+
if (Object.keys(item).some((k) => rareFields.has(k)))
|
|
189
|
+
outliers.add(i);
|
|
190
|
+
}
|
|
191
|
+
for (const idx of detectRareStatusValues(items, commonFields))
|
|
192
|
+
outliers.add(idx);
|
|
193
|
+
return [...outliers].sort((a, b) => a - b);
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Detect items containing error keywords — these are NEVER dropped.
|
|
197
|
+
* Scans each object item's full serialization, case-insensitively.
|
|
198
|
+
*/
|
|
199
|
+
function detectErrorItems(items) {
|
|
200
|
+
const out = [];
|
|
201
|
+
for (let i = 0; i < items.length; i++) {
|
|
202
|
+
const item = items[i];
|
|
203
|
+
if (!isPlainObject(item))
|
|
204
|
+
continue;
|
|
205
|
+
const serialized = JSON.stringify(item).toLowerCase();
|
|
206
|
+
if (crush_keywords_1.JSON_ERROR_KEYWORDS.some((kw) => serialized.includes(kw)))
|
|
207
|
+
out.push(i);
|
|
208
|
+
}
|
|
209
|
+
return out;
|
|
210
|
+
}
|
|
211
|
+
//# sourceMappingURL=json-detectors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-detectors.js","sourceRoot":"","sources":["../../src/crush/json-detectors.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;GAkBG;;AAgBH,sCAsBC;AAkBD,0DAwBC;AAMD,wDAiDC;AAMD,4DA4BC;AAMD,4CASC;AAtLD,qDAAuD;AAavD,oEAAoE;AACpE,SAAgB,aAAa,CAAC,KAA2B;IACvD,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,OAAO,CAAC;IACvC,IAAI,OAAO,GAAG,KAAK,EACjB,SAAS,GAAG,KAAK,EACjB,SAAS,GAAG,KAAK,EACjB,SAAS,GAAG,KAAK,EACjB,QAAQ,GAAG,KAAK,EAChB,OAAO,GAAG,KAAK,CAAC;IAClB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,I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