@aryam/fixmap-core 0.7.4 → 0.8.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/compare.d.ts +24 -0
- package/dist/compare.js +127 -0
- package/dist/compare.js.map +1 -0
- package/dist/exclude.d.ts +17 -0
- package/dist/exclude.js +90 -0
- package/dist/exclude.js.map +1 -0
- package/dist/explain.d.ts +4 -0
- package/dist/explain.js +23 -0
- package/dist/explain.js.map +1 -1
- package/dist/index.d.ts +8 -2
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/dist/languages.d.ts +25 -0
- package/dist/languages.js +133 -0
- package/dist/languages.js.map +1 -0
- package/dist/plan.d.ts +11 -1
- package/dist/plan.js +37 -1
- package/dist/plan.js.map +1 -1
- package/dist/rank.d.ts +3 -0
- package/dist/rank.js +62 -9
- package/dist/rank.js.map +1 -1
- package/dist/repo-scan.d.ts +1 -1
- package/dist/repo-scan.js +53 -3
- package/dist/repo-scan.js.map +1 -1
- package/dist/report.d.ts +3 -0
- package/dist/report.js +60 -8
- package/dist/report.js.map +1 -1
- package/dist/signals.js +15 -1
- package/dist/signals.js.map +1 -1
- package/dist/text.d.ts +3 -0
- package/dist/text.js +14 -0
- package/dist/text.js.map +1 -0
- package/dist/types.d.ts +19 -1
- package/dist/verify.js +18 -2
- package/dist/verify.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { FixMapReport, RankedFile } from "./types.js";
|
|
2
|
+
export type RankDelta = {
|
|
3
|
+
path: string;
|
|
4
|
+
status: "entered" | "left" | "moved" | "unchanged";
|
|
5
|
+
/** 1-based, absent on the side where the file was not listed. */
|
|
6
|
+
previousRank?: number;
|
|
7
|
+
currentRank?: number;
|
|
8
|
+
previousScore?: number;
|
|
9
|
+
currentScore?: number;
|
|
10
|
+
previousConfidence?: RankedFile["confidence"];
|
|
11
|
+
currentConfidence?: RankedFile["confidence"];
|
|
12
|
+
};
|
|
13
|
+
export type ReportComparison = {
|
|
14
|
+
summary: string;
|
|
15
|
+
entered: RankDelta[];
|
|
16
|
+
left: RankDelta[];
|
|
17
|
+
moved: RankDelta[];
|
|
18
|
+
unchanged: RankDelta[];
|
|
19
|
+
groundingChanged: boolean;
|
|
20
|
+
previousGrounding?: string;
|
|
21
|
+
currentGrounding?: string;
|
|
22
|
+
};
|
|
23
|
+
export declare function compareReports(previous: FixMapReport, current: FixMapReport): ReportComparison;
|
|
24
|
+
export declare function renderComparisonMarkdown(comparison: ReportComparison): string;
|
package/dist/compare.js
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
// The loop FixMap is actually for: plan, add an identifier the task was missing, re-plan,
|
|
2
|
+
// and watch whether the real file moved up. Doing that meant saving two JSON reports and
|
|
3
|
+
// diffing them by eye, which buries the one number that matters — did the fix site rise? —
|
|
4
|
+
// under everything that stayed the same.
|
|
5
|
+
//
|
|
6
|
+
// This compares two reports the caller already has. Nothing is scanned or re-ranked, so a
|
|
7
|
+
// comparison can be run long after the plans were made.
|
|
8
|
+
export function compareReports(previous, current) {
|
|
9
|
+
const previousByPath = indexByPath(previous.contextFiles);
|
|
10
|
+
const currentByPath = indexByPath(current.contextFiles);
|
|
11
|
+
const entered = [];
|
|
12
|
+
const left = [];
|
|
13
|
+
const moved = [];
|
|
14
|
+
const unchanged = [];
|
|
15
|
+
for (const [path, currentEntry] of currentByPath) {
|
|
16
|
+
const previousEntry = previousByPath.get(path);
|
|
17
|
+
if (!previousEntry) {
|
|
18
|
+
entered.push({
|
|
19
|
+
path,
|
|
20
|
+
status: "entered",
|
|
21
|
+
currentRank: currentEntry.rank,
|
|
22
|
+
currentScore: currentEntry.file.score,
|
|
23
|
+
currentConfidence: currentEntry.file.confidence
|
|
24
|
+
});
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
const delta = {
|
|
28
|
+
path,
|
|
29
|
+
status: previousEntry.rank === currentEntry.rank &&
|
|
30
|
+
previousEntry.file.score === currentEntry.file.score &&
|
|
31
|
+
previousEntry.file.confidence === currentEntry.file.confidence
|
|
32
|
+
? "unchanged"
|
|
33
|
+
: "moved",
|
|
34
|
+
previousRank: previousEntry.rank,
|
|
35
|
+
currentRank: currentEntry.rank,
|
|
36
|
+
previousScore: previousEntry.file.score,
|
|
37
|
+
currentScore: currentEntry.file.score,
|
|
38
|
+
previousConfidence: previousEntry.file.confidence,
|
|
39
|
+
currentConfidence: currentEntry.file.confidence
|
|
40
|
+
};
|
|
41
|
+
(delta.status === "moved" ? moved : unchanged).push(delta);
|
|
42
|
+
}
|
|
43
|
+
for (const [path, previousEntry] of previousByPath) {
|
|
44
|
+
if (!currentByPath.has(path)) {
|
|
45
|
+
left.push({
|
|
46
|
+
path,
|
|
47
|
+
status: "left",
|
|
48
|
+
previousRank: previousEntry.rank,
|
|
49
|
+
previousScore: previousEntry.file.score,
|
|
50
|
+
previousConfidence: previousEntry.file.confidence
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
// Rank ascending, so the reader's eye lands on the top of the list first.
|
|
55
|
+
entered.sort((a, b) => (a.currentRank ?? 0) - (b.currentRank ?? 0));
|
|
56
|
+
left.sort((a, b) => (a.previousRank ?? 0) - (b.previousRank ?? 0));
|
|
57
|
+
moved.sort((a, b) => (a.currentRank ?? 0) - (b.currentRank ?? 0));
|
|
58
|
+
unchanged.sort((a, b) => (a.currentRank ?? 0) - (b.currentRank ?? 0));
|
|
59
|
+
const previousGrounding = previous.analysis?.grounding.specificity;
|
|
60
|
+
const currentGrounding = current.analysis?.grounding.specificity;
|
|
61
|
+
return {
|
|
62
|
+
summary: buildSummary(entered, left, moved, previous.contextFiles[0], current.contextFiles[0]),
|
|
63
|
+
entered,
|
|
64
|
+
left,
|
|
65
|
+
moved,
|
|
66
|
+
unchanged,
|
|
67
|
+
groundingChanged: previousGrounding !== currentGrounding,
|
|
68
|
+
...(previousGrounding ? { previousGrounding } : {}),
|
|
69
|
+
...(currentGrounding ? { currentGrounding } : {})
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
function indexByPath(files) {
|
|
73
|
+
return new Map(files.map((file, index) => [file.path, { rank: index + 1, file }]));
|
|
74
|
+
}
|
|
75
|
+
function buildSummary(entered, left, moved, previousLeader, currentLeader) {
|
|
76
|
+
if (entered.length === 0 && left.length === 0 && moved.length === 0) {
|
|
77
|
+
return "Both plans rank the same files in the same order. Refining the task changed nothing.";
|
|
78
|
+
}
|
|
79
|
+
const parts = [
|
|
80
|
+
entered.length > 0 ? `${entered.length} entered` : "",
|
|
81
|
+
left.length > 0 ? `${left.length} left` : "",
|
|
82
|
+
moved.length > 0 ? `${moved.length} moved` : ""
|
|
83
|
+
].filter(Boolean);
|
|
84
|
+
// The leading file is the one an agent opens, so a change there is the headline.
|
|
85
|
+
const lead = previousLeader?.path !== currentLeader?.path
|
|
86
|
+
? ` The leading file changed from ${previousLeader?.path ?? "nothing"} to ${currentLeader?.path ?? "nothing"}.`
|
|
87
|
+
: "";
|
|
88
|
+
return `${parts.join(", ")}.${lead}`;
|
|
89
|
+
}
|
|
90
|
+
export function renderComparisonMarkdown(comparison) {
|
|
91
|
+
const lines = ["# FixMap Plan Comparison", "", comparison.summary, ""];
|
|
92
|
+
if (comparison.groundingChanged) {
|
|
93
|
+
lines.push(`Task grounding changed from **${comparison.previousGrounding ?? "unknown"}** ` +
|
|
94
|
+
`to **${comparison.currentGrounding ?? "unknown"}**.`, "");
|
|
95
|
+
}
|
|
96
|
+
appendSection(lines, "Entered", comparison.entered, (delta) => `\`${delta.path}\` at rank ${delta.currentRank} (${delta.currentConfidence}, score ${delta.currentScore})`);
|
|
97
|
+
appendSection(lines, "Left", comparison.left, (delta) => `\`${delta.path}\` was rank ${delta.previousRank} (${delta.previousConfidence}, score ${delta.previousScore})`);
|
|
98
|
+
appendSection(lines, "Moved", comparison.moved, (delta) => `\`${delta.path}\` ${describeMove(delta)}`);
|
|
99
|
+
if (comparison.unchanged.length > 0) {
|
|
100
|
+
lines.push(`## Unchanged`, "", `${comparison.unchanged.length} file(s) held their rank, score, and confidence.`, "");
|
|
101
|
+
}
|
|
102
|
+
return `${lines.join("\n").trimEnd()}\n`;
|
|
103
|
+
}
|
|
104
|
+
function describeMove(delta) {
|
|
105
|
+
const direction = (delta.previousRank ?? 0) > (delta.currentRank ?? 0)
|
|
106
|
+
? "rose"
|
|
107
|
+
: (delta.previousRank ?? 0) < (delta.currentRank ?? 0) ? "fell" : "held";
|
|
108
|
+
const rank = direction === "held"
|
|
109
|
+
? `stayed at rank ${delta.currentRank}`
|
|
110
|
+
: `${direction} from rank ${delta.previousRank} to ${delta.currentRank}`;
|
|
111
|
+
const score = `score ${delta.previousScore} to ${delta.currentScore}`;
|
|
112
|
+
const confidence = delta.previousConfidence === delta.currentConfidence
|
|
113
|
+
? `${delta.currentConfidence} confidence`
|
|
114
|
+
: `confidence ${delta.previousConfidence} to ${delta.currentConfidence}`;
|
|
115
|
+
return `${rank}, ${score}, ${confidence}`;
|
|
116
|
+
}
|
|
117
|
+
function appendSection(lines, title, deltas, format) {
|
|
118
|
+
if (deltas.length === 0) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
lines.push(`## ${title}`, "");
|
|
122
|
+
for (const delta of deltas) {
|
|
123
|
+
lines.push(`- ${format(delta)}`);
|
|
124
|
+
}
|
|
125
|
+
lines.push("");
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=compare.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compare.js","sourceRoot":"","sources":["../src/compare.ts"],"names":[],"mappings":"AAAA,0FAA0F;AAC1F,yFAAyF;AACzF,2FAA2F;AAC3F,yCAAyC;AACzC,EAAE;AACF,0FAA0F;AAC1F,wDAAwD;AA2BxD,MAAM,UAAU,cAAc,CAAC,QAAsB,EAAE,OAAqB;IAC1E,MAAM,cAAc,GAAG,WAAW,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;IAC1D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,iBAAiB;QACrE,CAAC,CAAC,GAAG,KAAK,CAAC,iBAAiB,aAAa;QACzC,CAAC,CAAC,cAAc,KAAK,CAAC,kBAAkB,OAAO,KAAK,CAAC,iBAAiB,EAAE,CAAC;IAC3E,OAAO,GAAG,IAAI,KAAK,KAAK,KAAK,UAAU,EAAE,CAAC;AAC5C,CAAC;AAED,SAAS,aAAa,CACpB,KAAe,EACf,KAAa,EACb,MAAmB,EACnB,MAAoC;IAEpC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,OAAO;IACT,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,MAAM,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;IAC9B,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,KAAK,CAAC,IAAI,CAAC,KAAK,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACnC,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type PathExcluder = {
|
|
2
|
+
/** True when the path is excluded and should not be ranked. */
|
|
3
|
+
excludes: (path: string) => boolean;
|
|
4
|
+
/** The pattern that matched, for `--explain` to quote back. */
|
|
5
|
+
reasonFor: (path: string) => string | undefined;
|
|
6
|
+
patterns: string[];
|
|
7
|
+
};
|
|
8
|
+
export declare const NO_EXCLUSIONS: PathExcluder;
|
|
9
|
+
/**
|
|
10
|
+
* Builds a matcher from gitignore-flavored patterns. Deliberately a small subset — `*`,
|
|
11
|
+
* `**`, a leading `/` to anchor at the root, and a trailing `/` to mean "this directory
|
|
12
|
+
* and everything under it". A bare `apps/web` matches the directory too, because that is
|
|
13
|
+
* what someone typing `--exclude apps/web` means.
|
|
14
|
+
*/
|
|
15
|
+
export declare function buildPathExcluder(patterns: string[]): PathExcluder;
|
|
16
|
+
/** Reads `.fixmapignore` from a repository root, if it has one. */
|
|
17
|
+
export declare function parseIgnoreFile(contents: string): string[];
|
package/dist/exclude.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// Some directories are not wrong, just not the answer.
|
|
2
|
+
//
|
|
3
|
+
// FixMap's built-in penalties know about examples/, demos/ and generated output because
|
|
4
|
+
// those are conventions. They cannot know that a particular repository keeps a marketing
|
|
5
|
+
// site under apps/web whose copy deliberately contains every symptom word the product
|
|
6
|
+
// documents — which is precisely why dogfooding FixMap on FixMap kept surfacing demo pages
|
|
7
|
+
// beside real implementation (#105, #128). No penalty tuned in the ranker can settle that;
|
|
8
|
+
// only the repository knows.
|
|
9
|
+
//
|
|
10
|
+
// So this is opt-in and blunt: paths the caller names are not candidates at all. Nothing
|
|
11
|
+
// changes for anyone who does not ask, which matters because the ranker's boilerplate
|
|
12
|
+
// threshold is computed as a share of the candidate set — quietly removing files from that
|
|
13
|
+
// set would reshuffle scoring everywhere.
|
|
14
|
+
const COMMENT = /^\s*#/;
|
|
15
|
+
export const NO_EXCLUSIONS = {
|
|
16
|
+
excludes: () => false,
|
|
17
|
+
reasonFor: () => undefined,
|
|
18
|
+
patterns: []
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Builds a matcher from gitignore-flavored patterns. Deliberately a small subset — `*`,
|
|
22
|
+
* `**`, a leading `/` to anchor at the root, and a trailing `/` to mean "this directory
|
|
23
|
+
* and everything under it". A bare `apps/web` matches the directory too, because that is
|
|
24
|
+
* what someone typing `--exclude apps/web` means.
|
|
25
|
+
*/
|
|
26
|
+
export function buildPathExcluder(patterns) {
|
|
27
|
+
const cleaned = patterns
|
|
28
|
+
.map((pattern) => pattern.trim())
|
|
29
|
+
.filter((pattern) => pattern.length > 0 && !COMMENT.test(pattern));
|
|
30
|
+
if (cleaned.length === 0) {
|
|
31
|
+
return NO_EXCLUSIONS;
|
|
32
|
+
}
|
|
33
|
+
const matchers = cleaned.map((pattern) => ({ pattern, test: compile(pattern) }));
|
|
34
|
+
const cache = new Map();
|
|
35
|
+
const reasonFor = (path) => {
|
|
36
|
+
if (cache.has(path)) {
|
|
37
|
+
return cache.get(path);
|
|
38
|
+
}
|
|
39
|
+
const hit = matchers.find((matcher) => matcher.test(path))?.pattern;
|
|
40
|
+
cache.set(path, hit);
|
|
41
|
+
return hit;
|
|
42
|
+
};
|
|
43
|
+
return {
|
|
44
|
+
excludes: (path) => reasonFor(path) !== undefined,
|
|
45
|
+
reasonFor,
|
|
46
|
+
patterns: cleaned
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/** Reads `.fixmapignore` from a repository root, if it has one. */
|
|
50
|
+
export function parseIgnoreFile(contents) {
|
|
51
|
+
return contents.split(/\r?\n/);
|
|
52
|
+
}
|
|
53
|
+
function compile(pattern) {
|
|
54
|
+
const anchored = pattern.startsWith("/");
|
|
55
|
+
const directoryOnly = pattern.endsWith("/");
|
|
56
|
+
const body = pattern.replace(/^\//, "").replace(/\/$/, "");
|
|
57
|
+
if (body.length === 0) {
|
|
58
|
+
return () => false;
|
|
59
|
+
}
|
|
60
|
+
const source = `${anchored ? "^" : "(?:^|/)"}${globToRegExp(body)}${directoryOnly ? "/" : "(?:/|$)"}`;
|
|
61
|
+
const expression = new RegExp(source);
|
|
62
|
+
return (path) => expression.test(directoryOnly ? `${path}/` : path);
|
|
63
|
+
}
|
|
64
|
+
function globToRegExp(glob) {
|
|
65
|
+
let source = "";
|
|
66
|
+
for (let index = 0; index < glob.length; index += 1) {
|
|
67
|
+
const character = glob[index];
|
|
68
|
+
if (character === "*") {
|
|
69
|
+
if (glob[index + 1] === "*") {
|
|
70
|
+
// `**` crosses directory separators; `*` does not.
|
|
71
|
+
source += ".*";
|
|
72
|
+
index += 1;
|
|
73
|
+
if (glob[index + 1] === "/") {
|
|
74
|
+
index += 1;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
source += "[^/]*";
|
|
79
|
+
}
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
if (character === "?") {
|
|
83
|
+
source += "[^/]";
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
source += character.replace(/[.+^${}()|[\]\\]/g, "\\$&");
|
|
87
|
+
}
|
|
88
|
+
return source;
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=exclude.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exclude.js","sourceRoot":"","sources":["../src/exclude.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,EAAE;AACF,wFAAwF;AACxF,yFAAyF;AACzF,sFAAsF;AACtF,2FAA2F;AAC3F,2FAA2F;AAC3F,6BAA6B;AAC7B,EAAE;AACF,yFAAyF;AACzF,sFAAsF;AACtF,2FAA2F;AAC3F,0CAA0C;AAE1C,MAAM,OAAO,GAAG,OAAO,CAAC;AAUxB,MAAM,CAAC,MAAM,aAAa,GAAiB;IACzC,QAAQ,EAAE,GAAG,EAAE,CAAC,KAAK;IACrB,SAAS,EAAE,GAAG,EAAE,CAAC,SAAS;IAC1B,QAAQ,EAAE,EAAE;CACb,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,QAAkB;IAClD,MAAM,OAAO,GAAG,QAAQ;SACrB,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;SAChC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;IAErE,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,aAAa,CAAC;IACvB,CAAC;IAED,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC;IACjF,MA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|
|
1
2
|
import type { RankedFile, RepoMap } from "./types.js";
|
|
2
3
|
export type FileExplanation = {
|
|
3
4
|
path: string;
|
|
@@ -12,4 +13,7 @@ export type FileExplanation = {
|
|
|
12
13
|
export declare function explainFile(repo: RepoMap, input: {
|
|
13
14
|
issueText?: string | undefined;
|
|
14
15
|
diffText?: string | undefined;
|
|
16
|
+
exclude?: PathExcluder | undefined;
|
|
15
17
|
}, targetPath: string): FileExplanation;
|
|
18
|
+
/** Renders one file's explanation. The summary carries the answer; reasons show the working. */
|
|
19
|
+
export declare function renderExplanationMarkdown(explanation: FileExplanation): string;
|
package/dist/explain.js
CHANGED
|
@@ -9,6 +9,18 @@ import { REPORT_SCORE_CUTOFF, rankContextFiles } from "./rank.js";
|
|
|
9
9
|
import { extractFileMentions } from "./signals.js";
|
|
10
10
|
export function explainFile(repo, input, targetPath) {
|
|
11
11
|
const path = targetPath.replace(/\\/g, "/").replace(/^\.\//, "");
|
|
12
|
+
// Asked first, because an excluded file has no score to report and "scored below the
|
|
13
|
+
// cutoff" would be a false explanation for a deliberate omission.
|
|
14
|
+
const excludedBy = input.exclude?.reasonFor(path);
|
|
15
|
+
if (excludedBy) {
|
|
16
|
+
return {
|
|
17
|
+
path,
|
|
18
|
+
status: "excluded",
|
|
19
|
+
reasons: [],
|
|
20
|
+
summary: `Excluded: matched the exclusion pattern "${excludedBy}". ` +
|
|
21
|
+
"Remove it from .fixmapignore or --exclude to let this file rank."
|
|
22
|
+
};
|
|
23
|
+
}
|
|
12
24
|
const reported = rankContextFiles(repo, input);
|
|
13
25
|
const position = reported.findIndex((file) => file.path === path);
|
|
14
26
|
if (position !== -1) {
|
|
@@ -45,6 +57,17 @@ export function explainFile(repo, input, targetPath) {
|
|
|
45
57
|
"Name a symbol, error string, or path from this file in the task to raise it."
|
|
46
58
|
};
|
|
47
59
|
}
|
|
60
|
+
/** Renders one file's explanation. The summary carries the answer; reasons show the working. */
|
|
61
|
+
export function renderExplanationMarkdown(explanation) {
|
|
62
|
+
const lines = [`# Why ${explanation.path}`, "", explanation.summary];
|
|
63
|
+
if (explanation.reasons.length > 0) {
|
|
64
|
+
lines.push("", "## Signals", "");
|
|
65
|
+
for (const reason of explanation.reasons) {
|
|
66
|
+
lines.push(`- ${reason}`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return `${lines.join("\n")}\n`;
|
|
70
|
+
}
|
|
48
71
|
// Mirrors the candidate filter in rankContextFiles. `explain.test.ts` asserts the two
|
|
49
72
|
// agree on every file in a fixture, so this cannot drift silently.
|
|
50
73
|
function describeExclusion(repo, input, path) {
|
package/dist/explain.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"explain.js","sourceRoot":"","sources":["../src/explain.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,EAAE;AACF,uFAAuF;AACvF,sFAAsF;AACtF,sFAAsF;AACtF,uCAAuC;
|
|
1
|
+
{"version":3,"file":"explain.js","sourceRoot":"","sources":["../src/explain.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,EAAE;AACF,uFAAuF;AACvF,sFAAsF;AACtF,sFAAsF;AACtF,uCAAuC;AAGvC,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAClE,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAcnD,MAAM,UAAU,WAAW,CACzB,IAAa,EACb,KAIC,EACD,UAAkB;IAElB,MAAM,IAAI,GAAG,UAAU,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IAEjE,qFAAqF;IACrF,kEAAkE;IAClE,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;IAClD,IAAI,UAAU,EAAE,CAAC;Q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.d.ts
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
export { buildFixMapReport } from "./plan.js";
|
|
1
|
+
export { buildFixMapReport, resolveExclusions } from "./plan.js";
|
|
2
|
+
export { buildPathExcluder, NO_EXCLUSIONS } from "./exclude.js";
|
|
3
|
+
export type { PathExcluder } from "./exclude.js";
|
|
4
|
+
export { compareReports, renderComparisonMarkdown } from "./compare.js";
|
|
5
|
+
export type { ReportComparison } from "./compare.js";
|
|
2
6
|
export { renderVerifyMarkdown, verifyPlan } from "./verify.js";
|
|
3
|
-
export { explainFile } from "./explain.js";
|
|
7
|
+
export { explainFile, renderExplanationMarkdown } from "./explain.js";
|
|
4
8
|
export type { FileExplanation } from "./explain.js";
|
|
5
9
|
export { analyzeTaskGrounding, buildGroundedTaskTokens, buildNextAction, buildRankingShape } from "./grounding.js";
|
|
6
10
|
export { buildImportGraph, findImportProximity } from "./import-graph.js";
|
|
11
|
+
export { detectPrimaryLanguage } from "./languages.js";
|
|
12
|
+
export type { LanguageDetection, PrimaryLanguage } from "./languages.js";
|
|
7
13
|
export { rankContextFiles } from "./rank.js";
|
|
8
14
|
export { buildRiskNotes, buildSummary, buildTestRoutes, renderJsonReport, renderMarkdownReport } from "./report.js";
|
|
9
15
|
export { scanRepo } from "./repo-scan.js";
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
export { buildFixMapReport } from "./plan.js";
|
|
1
|
+
export { buildFixMapReport, resolveExclusions } from "./plan.js";
|
|
2
|
+
export { buildPathExcluder, NO_EXCLUSIONS } from "./exclude.js";
|
|
3
|
+
export { compareReports, renderComparisonMarkdown } from "./compare.js";
|
|
2
4
|
export { renderVerifyMarkdown, verifyPlan } from "./verify.js";
|
|
3
|
-
export { explainFile } from "./explain.js";
|
|
5
|
+
export { explainFile, renderExplanationMarkdown } from "./explain.js";
|
|
4
6
|
export { analyzeTaskGrounding, buildGroundedTaskTokens, buildNextAction, buildRankingShape } from "./grounding.js";
|
|
5
7
|
export { buildImportGraph, findImportProximity } from "./import-graph.js";
|
|
8
|
+
export { detectPrimaryLanguage } from "./languages.js";
|
|
6
9
|
export { rankContextFiles } from "./rank.js";
|
|
7
10
|
export { buildRiskNotes, buildSummary, buildTestRoutes, renderJsonReport, renderMarkdownReport } from "./report.js";
|
|
8
11
|
export { scanRepo } from "./repo-scan.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAEhE,OAAO,EAAE,cAAc,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAExE,OAAO,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AAEtE,OAAO,EACL,oBAAoB,EACpB,uBAAuB,EACvB,eAAe,EACf,iBAAiB,EAClB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACpH,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { RepoFile, RepoMap } from "./types.js";
|
|
2
|
+
export type PrimaryLanguage = "node" | "python" | "go" | "rust" | "unknown";
|
|
3
|
+
export type LanguageDetection = {
|
|
4
|
+
language: PrimaryLanguage;
|
|
5
|
+
/** Why, in a form a diagnostic can quote: a manifest name, or a share of code files. */
|
|
6
|
+
evidence: string;
|
|
7
|
+
};
|
|
8
|
+
export declare function detectPrimaryLanguage(repo: RepoMap): LanguageDetection;
|
|
9
|
+
/**
|
|
10
|
+
* The command this project's toolchain runs its tests with, when the toolchain is
|
|
11
|
+
* unambiguous about it. Go and Rust each have exactly one, which is why they can be routed
|
|
12
|
+
* rather than merely suggested.
|
|
13
|
+
*
|
|
14
|
+
* Python is deliberately absent. pytest, tox, unittest and nox are all plausible for a
|
|
15
|
+
* repository carrying a pyproject.toml, and FixMap cannot read which one it configures —
|
|
16
|
+
* `.toml` and `.cfg` are outside the sampled source extensions. Guessing would produce a
|
|
17
|
+
* command that fails, so Python gets a named suggestion in the no-test-route diagnostic
|
|
18
|
+
* instead of a routed command that claims more than FixMap knows.
|
|
19
|
+
*/
|
|
20
|
+
export declare function manifestTestCommand(language: PrimaryLanguage, packageDir: string): {
|
|
21
|
+
command: string;
|
|
22
|
+
reason: string;
|
|
23
|
+
} | undefined;
|
|
24
|
+
/** The runner to name when there is nothing to route, so the warning is actionable. */
|
|
25
|
+
export declare function suggestedRunner(language: PrimaryLanguage, files: RepoFile[]): string | undefined;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
// What language is this repository actually written in?
|
|
2
|
+
//
|
|
3
|
+
// The question sounds trivial and the obvious answer is wrong. Asking "does any file end
|
|
4
|
+
// in .py" labeled clap-rs/clap — a Rust project — as Python, because it keeps a handful of
|
|
5
|
+
// helper scripts, and then told the reader to go look at pyproject.toml. Incidental files
|
|
6
|
+
// are everywhere: CI helpers, codegen scripts, a docs site inside a Go monorepo.
|
|
7
|
+
//
|
|
8
|
+
// A repository declares its language at the root, in the manifest its toolchain requires.
|
|
9
|
+
// That declaration is deliberate where a file extension is incidental, so it decides
|
|
10
|
+
// first. Only when the root is silent, or says two things at once, does the shape of the
|
|
11
|
+
// code get a vote.
|
|
12
|
+
/** Root manifests, in the sense of "the file this toolchain requires at the top level". */
|
|
13
|
+
const ROOT_MANIFESTS = {
|
|
14
|
+
"cargo.toml": "rust",
|
|
15
|
+
"go.mod": "go",
|
|
16
|
+
"pyproject.toml": "python",
|
|
17
|
+
"setup.py": "python",
|
|
18
|
+
"setup.cfg": "python",
|
|
19
|
+
"package.json": "node"
|
|
20
|
+
};
|
|
21
|
+
const EXTENSION_LANGUAGES = {
|
|
22
|
+
".py": "python",
|
|
23
|
+
".go": "go",
|
|
24
|
+
".rs": "rust",
|
|
25
|
+
".ts": "node",
|
|
26
|
+
".tsx": "node",
|
|
27
|
+
".js": "node",
|
|
28
|
+
".jsx": "node",
|
|
29
|
+
".mjs": "node",
|
|
30
|
+
".cjs": "node"
|
|
31
|
+
};
|
|
32
|
+
export function detectPrimaryLanguage(repo) {
|
|
33
|
+
const manifests = rootManifestLanguages(repo.files);
|
|
34
|
+
if (manifests.size === 1) {
|
|
35
|
+
const [language, manifest] = [...manifests][0];
|
|
36
|
+
return { language, evidence: manifest };
|
|
37
|
+
}
|
|
38
|
+
// Two toolchains declare themselves at the root — a Rust crate with a docs site, say.
|
|
39
|
+
// Neither manifest settles it, so the code does, restricted to the languages that
|
|
40
|
+
// actually claimed the root.
|
|
41
|
+
const shares = countCodeFiles(repo.files);
|
|
42
|
+
const candidates = manifests.size > 1 ? [...manifests.keys()] : [...shares.keys()];
|
|
43
|
+
const leader = candidates
|
|
44
|
+
.map((language) => ({ language, count: shares.get(language) ?? 0 }))
|
|
45
|
+
.sort((a, b) => b.count - a.count || a.language.localeCompare(b.language))[0];
|
|
46
|
+
if (!leader || leader.count === 0) {
|
|
47
|
+
return { language: "unknown", evidence: "no root manifest and no recognizable source files" };
|
|
48
|
+
}
|
|
49
|
+
const total = [...shares.values()].reduce((sum, count) => sum + count, 0);
|
|
50
|
+
const share = Math.round((leader.count / total) * 100);
|
|
51
|
+
const manifest = manifests.get(leader.language);
|
|
52
|
+
return {
|
|
53
|
+
language: leader.language,
|
|
54
|
+
evidence: manifest
|
|
55
|
+
? `${manifest} and ${share}% of source files`
|
|
56
|
+
: `${share}% of source files`
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function rootManifestLanguages(files) {
|
|
60
|
+
const found = new Map();
|
|
61
|
+
for (const file of files) {
|
|
62
|
+
if (file.path.includes("/")) {
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
const language = ROOT_MANIFESTS[file.path.toLowerCase()];
|
|
66
|
+
if (language && !found.has(language)) {
|
|
67
|
+
found.set(language, file.path);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return found;
|
|
71
|
+
}
|
|
72
|
+
function countCodeFiles(files) {
|
|
73
|
+
const counts = new Map();
|
|
74
|
+
for (const file of files) {
|
|
75
|
+
if (file.isTest) {
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
const language = EXTENSION_LANGUAGES[file.extension];
|
|
79
|
+
if (language) {
|
|
80
|
+
counts.set(language, (counts.get(language) ?? 0) + 1);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return counts;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* The command this project's toolchain runs its tests with, when the toolchain is
|
|
87
|
+
* unambiguous about it. Go and Rust each have exactly one, which is why they can be routed
|
|
88
|
+
* rather than merely suggested.
|
|
89
|
+
*
|
|
90
|
+
* Python is deliberately absent. pytest, tox, unittest and nox are all plausible for a
|
|
91
|
+
* repository carrying a pyproject.toml, and FixMap cannot read which one it configures —
|
|
92
|
+
* `.toml` and `.cfg` are outside the sampled source extensions. Guessing would produce a
|
|
93
|
+
* command that fails, so Python gets a named suggestion in the no-test-route diagnostic
|
|
94
|
+
* instead of a routed command that claims more than FixMap knows.
|
|
95
|
+
*/
|
|
96
|
+
export function manifestTestCommand(language, packageDir) {
|
|
97
|
+
if (language === "go") {
|
|
98
|
+
return {
|
|
99
|
+
command: "go test ./...",
|
|
100
|
+
reason: "go.mod at the repository root"
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
if (language === "rust") {
|
|
104
|
+
return packageDir
|
|
105
|
+
? {
|
|
106
|
+
command: `cargo test --manifest-path ${packageDir}/Cargo.toml`,
|
|
107
|
+
reason: `nearest crate (${packageDir}) declared by Cargo.toml`
|
|
108
|
+
}
|
|
109
|
+
: { command: "cargo test", reason: "Cargo.toml at the repository root" };
|
|
110
|
+
}
|
|
111
|
+
return undefined;
|
|
112
|
+
}
|
|
113
|
+
/** The runner to name when there is nothing to route, so the warning is actionable. */
|
|
114
|
+
export function suggestedRunner(language, files) {
|
|
115
|
+
if (language === "python") {
|
|
116
|
+
const names = new Set(files.map((file) => file.path.toLowerCase()));
|
|
117
|
+
if (names.has("tox.ini")) {
|
|
118
|
+
return "tox";
|
|
119
|
+
}
|
|
120
|
+
if (names.has("pytest.ini") || names.has("pyproject.toml") || names.has("setup.cfg")) {
|
|
121
|
+
return "pytest";
|
|
122
|
+
}
|
|
123
|
+
return "pytest or unittest";
|
|
124
|
+
}
|
|
125
|
+
if (language === "go") {
|
|
126
|
+
return "go test ./...";
|
|
127
|
+
}
|
|
128
|
+
if (language === "rust") {
|
|
129
|
+
return "cargo test";
|
|
130
|
+
}
|
|
131
|
+
return undefined;
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=languages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"languages.js","sourceRoot":"","sources":["../src/languages.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,EAAE;AACF,yFAAyF;AACzF,2FAA2F;AAC3F,0FAA0F;AAC1F,iFAAiF;AACjF,EAAE;AACF,0FAA0F;AAC1F,qFAAqF;AACrF,yFAAyF;AAC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AED,uFAAuF;AACvF,MAAM,UAAU,eAAe,CAAC,QAAyB,EAAE,KAAiB;IAC1E,IAAI,QAAQ,KAAK,QAAQ,EAAE,CAAC;QAC1B,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;QACpE,IAAI,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;YACzB,OAAO,KAAK,CAAC;QACf,CAAC;QACD,IAAI,KAAK,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,KAAK,CAAC,GAAG,CAAC,gBAAgB,CAAC,IAAI,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;YACrF,OAAO,QAAQ,CAAC;QAClB,CAAC;QACD,OAAO,oBAAoB,CAAC;IAC9B,CAAC;IACD,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;QACtB,OAAO,eAAe,CAAC;IACzB,CAAC;IACD,IAAI,QAAQ,KAAK,MAAM,EAAE,CAAC;QACxB,OAAO,YAAY,CAAC;IACtB,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
package/dist/plan.d.ts
CHANGED
|
@@ -1,2 +1,12 @@
|
|
|
1
|
+
import type { PathExcluder } from "./exclude.js";
|
|
1
2
|
import type { FixMapInput, FixMapReport } from "./types.js";
|
|
2
|
-
export declare function buildFixMapReport(input: Pick<FixMapInput, "repoRoot" | "issueText" | "diffSpec" | "baseRef" | "headRef">
|
|
3
|
+
export declare function buildFixMapReport(input: Pick<FixMapInput, "repoRoot" | "issueText" | "diffSpec" | "baseRef" | "headRef" | "workingTree" | "includeUntracked"> & {
|
|
4
|
+
limit?: number | undefined;
|
|
5
|
+
exclude?: string[] | undefined;
|
|
6
|
+
}): Promise<FixMapReport>;
|
|
7
|
+
/**
|
|
8
|
+
* Command-line exclusions and `.fixmapignore` combine rather than override. A repository
|
|
9
|
+
* that ships an ignore file has said something durable about itself; a flag is one run's
|
|
10
|
+
* refinement of that, not a replacement for it.
|
|
11
|
+
*/
|
|
12
|
+
export declare function resolveExclusions(repoRoot: string, patterns: string[]): Promise<PathExcluder>;
|
package/dist/plan.js
CHANGED
|
@@ -1,7 +1,43 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { buildPathExcluder, parseIgnoreFile, NO_EXCLUSIONS } from "./exclude.js";
|
|
1
4
|
import { buildReportFromRepo } from "./report.js";
|
|
2
5
|
import { scanRepo } from "./repo-scan.js";
|
|
3
6
|
export async function buildFixMapReport(input) {
|
|
4
7
|
const repo = await scanRepo(input);
|
|
5
|
-
|
|
8
|
+
const exclude = await resolveExclusions(input.repoRoot, input.exclude ?? []);
|
|
9
|
+
const report = buildReportFromRepo(repo, {
|
|
10
|
+
issueText: input.issueText,
|
|
11
|
+
limit: input.limit,
|
|
12
|
+
exclude
|
|
13
|
+
});
|
|
14
|
+
if (exclude.patterns.length > 0) {
|
|
15
|
+
report.diagnostics.push({
|
|
16
|
+
code: "paths-excluded",
|
|
17
|
+
severity: "info",
|
|
18
|
+
message: `${exclude.patterns.length} exclusion ${exclude.patterns.length === 1 ? "pattern" : "patterns"} ` +
|
|
19
|
+
`removed paths from ranking: ${exclude.patterns.join(", ")}. ` +
|
|
20
|
+
"Run --explain on a file you expected to see if this is why it is absent."
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
return report;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Command-line exclusions and `.fixmapignore` combine rather than override. A repository
|
|
27
|
+
* that ships an ignore file has said something durable about itself; a flag is one run's
|
|
28
|
+
* refinement of that, not a replacement for it.
|
|
29
|
+
*/
|
|
30
|
+
export async function resolveExclusions(repoRoot, patterns) {
|
|
31
|
+
const combined = [...await readIgnoreFile(repoRoot), ...patterns];
|
|
32
|
+
return combined.length > 0 ? buildPathExcluder(combined) : NO_EXCLUSIONS;
|
|
33
|
+
}
|
|
34
|
+
async function readIgnoreFile(repoRoot) {
|
|
35
|
+
try {
|
|
36
|
+
return parseIgnoreFile(await readFile(join(repoRoot, ".fixmapignore"), "utf8"));
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
// Having no ignore file is the normal case, not an error worth reporting.
|
|
40
|
+
return [];
|
|
41
|
+
}
|
|
6
42
|
}
|
|
7
43
|
//# sourceMappingURL=plan.js.map
|
package/dist/plan.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plan.js","sourceRoot":"","sources":["../src/plan.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAG1C,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,
|
|
1
|
+
{"version":3,"file":"plan.js","sourceRoot":"","sources":["../src/plan.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAEjF,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAG1C,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,KAGkE;IAElE,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,KAAK,CAAC,CAAC;IACnC,MAAM,OAAO,GAAG,MAAM,iBAAiB,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;IAE7E,MAAM,MAAM,GAAG,mBAAmB,CAAC,IAAI,EAAE;QACvC,SAAS,EAAE,KAAK,CAAC,SA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