@aryam/fixmap-core 0.7.3 → 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/browser.d.ts +5 -2
- package/dist/browser.js +7 -1
- package/dist/browser.js.map +1 -1
- 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 +5 -1
- package/dist/explain.js +29 -3
- package/dist/explain.js.map +1 -1
- package/dist/grounding.js +1 -1
- package/dist/grounding.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 +30 -103
- package/dist/plan.js.map +1 -1
- package/dist/rank.d.ts +3 -0
- package/dist/rank.js +132 -16
- package/dist/rank.js.map +1 -1
- package/dist/repo-scan.d.ts +1 -1
- package/dist/repo-scan.js +64 -3
- package/dist/repo-scan.js.map +1 -1
- package/dist/report.d.ts +6 -0
- package/dist/report.js +201 -4
- package/dist/report.js.map +1 -1
- package/dist/signals.js +28 -12
- 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 +21 -2
- package/dist/verify.js +31 -3
- package/dist/verify.js.map +1 -1
- package/package.json +1 -1
|
@@ -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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,SAAS,CAAC;AACnB,CAAC;AAED,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,116 +1,43 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { buildPathExcluder, parseIgnoreFile, NO_EXCLUSIONS } from "./exclude.js";
|
|
4
|
+
import { buildReportFromRepo } from "./report.js";
|
|
4
5
|
import { scanRepo } from "./repo-scan.js";
|
|
5
|
-
import { extractTaskSignals } from "./signals.js";
|
|
6
|
-
import { findGatedTestDiagnostics } from "./test-gates.js";
|
|
7
|
-
const MAX_REPORTED_TERMS = 8;
|
|
8
6
|
export async function buildFixMapReport(input) {
|
|
9
7
|
const repo = await scanRepo(input);
|
|
10
|
-
const
|
|
8
|
+
const exclude = await resolveExclusions(input.repoRoot, input.exclude ?? []);
|
|
9
|
+
const report = buildReportFromRepo(repo, {
|
|
11
10
|
issueText: input.issueText,
|
|
12
|
-
|
|
11
|
+
limit: input.limit,
|
|
12
|
+
exclude
|
|
13
13
|
});
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
});
|
|
18
|
-
const ranking = buildRankingShape(contextFiles);
|
|
19
|
-
const contextPaths = contextFiles.map((file) => file.path);
|
|
20
|
-
const testRoutes = buildTestRoutes(repo, contextPaths);
|
|
21
|
-
const routedTestPaths = [...new Set(testRoutes.flatMap((route) => route.relatedFiles))];
|
|
22
|
-
return {
|
|
23
|
-
summary: buildSummary(contextFiles.length, testRoutes.length),
|
|
24
|
-
contextFiles,
|
|
25
|
-
testRoutes,
|
|
26
|
-
risks: buildRiskNotes(contextPaths, repo.changedFiles),
|
|
27
|
-
changedFiles: repo.changedFiles,
|
|
28
|
-
diagnostics: [
|
|
29
|
-
...repo.diagnostics,
|
|
30
|
-
...findGatedTestDiagnostics(repo.files, routedTestPaths),
|
|
31
|
-
...findTaskDiagnostics(grounding, ranking),
|
|
32
|
-
...findEmptyResultDiagnostics(repo, contextFiles, input.issueText ?? "")
|
|
33
|
-
],
|
|
34
|
-
analysis: {
|
|
35
|
-
grounding,
|
|
36
|
-
ranking,
|
|
37
|
-
nextAction: buildNextAction(grounding, ranking, contextFiles)
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
function findTaskDiagnostics(grounding, ranking) {
|
|
42
|
-
const diagnostics = [];
|
|
43
|
-
if (grounding.unresolvedIdentifiers.length > 0) {
|
|
44
|
-
diagnostics.push({
|
|
45
|
-
code: "unresolved-identifier",
|
|
46
|
-
severity: "warning",
|
|
47
|
-
message: `Identifier${grounding.unresolvedIdentifiers.length === 1 ? "" : "s"} not found exactly in the scanned repository: ` +
|
|
48
|
-
`${grounding.unresolvedIdentifiers.join(", ")}. Component words from unresolved identifiers were ignored, ` +
|
|
49
|
-
"and unsupported recommendations were capped at low confidence."
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
if (grounding.partiallyResolvedIdentifiers.length > 0) {
|
|
53
|
-
diagnostics.push({
|
|
54
|
-
code: "partially-resolved-identifier",
|
|
14
|
+
if (exclude.patterns.length > 0) {
|
|
15
|
+
report.diagnostics.push({
|
|
16
|
+
code: "paths-excluded",
|
|
55
17
|
severity: "info",
|
|
56
|
-
message:
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
if (grounding.unverifiedIdentifiers.length > 0) {
|
|
61
|
-
diagnostics.push({
|
|
62
|
-
code: "identifier-unverified",
|
|
63
|
-
severity: "warning",
|
|
64
|
-
message: `Identifier${grounding.unverifiedIdentifiers.length === 1 ? "" : "s"} could not be verified because one or more source files exceeded the text-sampling limit: ` +
|
|
65
|
-
`${grounding.unverifiedIdentifiers.join(", ")}. FixMap did not claim that the identifier was absent, and confidence was capped at low without another anchor.`
|
|
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."
|
|
66
21
|
});
|
|
67
22
|
}
|
|
68
|
-
|
|
69
|
-
diagnostics.push({
|
|
70
|
-
code: "vague-task",
|
|
71
|
-
severity: "warning",
|
|
72
|
-
message: "The task is broad and has no verified symbol, file, or diff anchor. Treat the ranking as subsystem guidance only, " +
|
|
73
|
-
"or add a failing behavior, error string, command, symbol, or file path."
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
if (ranking.clustered && grounding.specificity !== "anchored") {
|
|
77
|
-
diagnostics.push({
|
|
78
|
-
code: "flat-ranking",
|
|
79
|
-
severity: "warning",
|
|
80
|
-
message: "The leading files have tightly clustered scores, so FixMap cannot identify a decisive edit point. " +
|
|
81
|
-
"Use them as a starting neighborhood and verify the exact file before editing."
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
return diagnostics;
|
|
23
|
+
return report;
|
|
85
24
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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"));
|
|
92
37
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
changedFiles: repo.changedFiles
|
|
97
|
-
});
|
|
98
|
-
const terms = [...signals.tokens].sort();
|
|
99
|
-
if (terms.length === 0 && signals.identifiers.size === 0 && signals.fileMentions.size === 0) {
|
|
100
|
-
return [{
|
|
101
|
-
code: "no-task-terms",
|
|
102
|
-
severity: "warning",
|
|
103
|
-
message: "No context files: the task text contained no searchable term. Every word was a common word, " +
|
|
104
|
-
"a language keyword, or shorter than three characters. Name the failing behavior, a symbol, or a file path."
|
|
105
|
-
}];
|
|
38
|
+
catch {
|
|
39
|
+
// Having no ignore file is the normal case, not an error worth reporting.
|
|
40
|
+
return [];
|
|
106
41
|
}
|
|
107
|
-
const preview = terms.slice(0, MAX_REPORTED_TERMS).join(", ");
|
|
108
|
-
const remainder = terms.length > MAX_REPORTED_TERMS ? ` (+${terms.length - MAX_REPORTED_TERMS} more)` : "";
|
|
109
|
-
return [{
|
|
110
|
-
code: "no-context-match",
|
|
111
|
-
severity: "warning",
|
|
112
|
-
message: `No context files: no file in the ${repo.files.length} scanned matched the task terms ${preview}${remainder}. ` +
|
|
113
|
-
"The repository may not contain this behavior, or it may name it differently."
|
|
114
|
-
}];
|
|
115
42
|
}
|
|
116
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,
|
|
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,OAA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AAa,CAAC;AAC3E,CAAC;AAED,KAAK,UAAU,cAAc,CAAC,QAAgB;IAC5C,IAAI,CAAC;QACH,OAAO,eAAe,CAAC,MAAM,QAAQ,CAAC,IAAI,CAAC,QAAQ,EAAE,eAAe,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;IAClF,CAAC;IAAC,MAAM,CAAC;QACP,0EAA0E;QAC1E,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC"}
|
package/dist/rank.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import type { PathExcluder } from "./exclude.js";
|
|
1
2
|
import type { RankedFile, RepoMap } from "./types.js";
|
|
2
3
|
export declare const REPORT_SCORE_CUTOFF = 4;
|
|
4
|
+
export declare const DEFAULT_CONTEXT_FILE_LIMIT = 8;
|
|
3
5
|
export declare function rankContextFiles(repo: RepoMap, input: {
|
|
4
6
|
issueText?: string | undefined;
|
|
5
7
|
diffText?: string | undefined;
|
|
8
|
+
exclude?: PathExcluder | undefined;
|
|
6
9
|
}, limit?: number, minScore?: number): RankedFile[];
|
package/dist/rank.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { NO_EXCLUSIONS } from "./exclude.js";
|
|
1
2
|
import { buildImportGraph, findImportProximity } from "./import-graph.js";
|
|
2
3
|
import { analyzeTaskGrounding, buildGroundedTaskTokens } from "./grounding.js";
|
|
3
4
|
import { isBackupPath, isGeneratedPath, moduleStem } from "./paths.js";
|
|
@@ -16,7 +17,8 @@ const COMPILED_TO_SOURCE_MENTION_EXTENSIONS = {
|
|
|
16
17
|
const MAX_FILES_PER_MENTION = 5;
|
|
17
18
|
const MAX_PROXIMITY_SEEDS = 5;
|
|
18
19
|
const IMPORT_PROXIMITY_BOOSTS = { 1: 4, 2: 2 };
|
|
19
|
-
const EXAMPLE_CODE_PENALTY =
|
|
20
|
+
const EXAMPLE_CODE_PENALTY = 8;
|
|
21
|
+
const PRESENTATION_CODE_PENALTY = 8;
|
|
20
22
|
const TYPE_DECLARATION_PENALTY = 4;
|
|
21
23
|
const BACKUP_COPY_PENALTY = 10;
|
|
22
24
|
const BUNDLED_OUTPUT_PENALTY = 12;
|
|
@@ -38,15 +40,20 @@ const MEMBER_MENTION_BOOST = 8;
|
|
|
38
40
|
// mentions "color" in 55% of its files because that is what chalk does, and suppressing
|
|
39
41
|
// the word left a color-detection task with no signal at all.
|
|
40
42
|
const WIDESPREAD_TOKEN_SHARE = 0.85;
|
|
41
|
-
const DEFINITION_IDENTIFIER_BOOST =
|
|
43
|
+
const DEFINITION_IDENTIFIER_BOOST = 24;
|
|
42
44
|
const DEFINITION_LITERAL_BOOST = 8;
|
|
43
45
|
const MAX_DEFINITION_IDENTIFIERS = 2;
|
|
44
46
|
const TASK_MATCHED_DEFINITION_BOOST = 4;
|
|
47
|
+
// How close to the leader a file must score to share its "high" label. Two points matches
|
|
48
|
+
// the window `isClusteredRanking` already treats as indistinguishable.
|
|
49
|
+
const HIGH_CONFIDENCE_MARGIN = 2;
|
|
45
50
|
export const REPORT_SCORE_CUTOFF = 4;
|
|
46
|
-
export
|
|
51
|
+
export const DEFAULT_CONTEXT_FILE_LIMIT = 8;
|
|
52
|
+
export function rankContextFiles(repo, input, limit = DEFAULT_CONTEXT_FILE_LIMIT,
|
|
47
53
|
// `explainFile` lowers this to see what a file scored below the reporting cutoff.
|
|
48
54
|
// Ranking never calls it with anything but the default.
|
|
49
55
|
minScore = REPORT_SCORE_CUTOFF) {
|
|
56
|
+
const exclude = input.exclude ?? NO_EXCLUSIONS;
|
|
50
57
|
const signals = extractTaskSignals({
|
|
51
58
|
issueText: input.issueText ?? "",
|
|
52
59
|
diffText: input.diffText ?? "",
|
|
@@ -60,11 +67,15 @@ minScore = REPORT_SCORE_CUTOFF) {
|
|
|
60
67
|
});
|
|
61
68
|
const mentionedPaths = matchMentionedPaths(signals.fileMentions, repo.files.map((file) => file.path));
|
|
62
69
|
const taskTargetsEvaluation = hasAny(taskTokens, ["benchmark", "benchmarks", "evaluation", "evaluate"]);
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
70
|
+
// Excluded before anything else reads the candidate set. The boilerplate threshold below
|
|
71
|
+
// is a share of that set, so removing files later would leave scoring computed against a
|
|
72
|
+
// population that no longer exists.
|
|
73
|
+
const scannable = repo.files.filter((file) => !exclude.excludes(file.path) &&
|
|
74
|
+
(mentionedPaths.has(file.path) ||
|
|
75
|
+
(file.isSource &&
|
|
76
|
+
!file.isTest &&
|
|
77
|
+
!LOCKFILES.has(file.path.split("/").pop() ?? "") &&
|
|
78
|
+
(!file.path.startsWith("benchmarks/") || taskTargetsEvaluation))));
|
|
68
79
|
// Generated output is kept only when the source it came from is absent. chalk's sole
|
|
69
80
|
// color-detection implementation lives in `source/vendor/`, so it stays; a committed
|
|
70
81
|
// bundle beside the module it was built from does not, because editing it is always
|
|
@@ -76,14 +87,19 @@ minScore = REPORT_SCORE_CUTOFF) {
|
|
|
76
87
|
signals.changedFiles.has(file.path) ||
|
|
77
88
|
!isGeneratedPath(file.path) ||
|
|
78
89
|
!maintainedStems.has(moduleStem(file.path)));
|
|
79
|
-
const contentTokensByPath = new Map(candidates.map((file) => [file.path,
|
|
90
|
+
const contentTokensByPath = new Map(candidates.map((file) => [file.path, tokenizeFileContent(file.textSample)]));
|
|
80
91
|
const commonTokens = findCommonTokens(contentTokensByPath);
|
|
92
|
+
const allTaskTermsAreWidespread = taskTokens.size > 0 &&
|
|
93
|
+
[...taskTokens].every((token) => commonTokens.has(token));
|
|
81
94
|
const definitionSignals = buildDefinitionSignals(signals.identifiers);
|
|
82
95
|
const taskText = [input.issueText ?? "", input.diffText ?? ""].join("\n");
|
|
83
96
|
const taskTargetsDocumentation = targetsDocumentation(taskText);
|
|
84
97
|
const taskTargetsConfiguration = hasAny(taskTokens, ["config", "configuration", "workflow", "action", "ci", "yaml"]);
|
|
85
98
|
const taskTargetsDeployment = hasAny(taskTokens, DEPLOYMENT_TERMS);
|
|
86
99
|
const taskTargetsExamples = /\b(?:demos?|examples?|samples?)\b/i.test(taskText.replace(/\bfor example\b/gi, ""));
|
|
100
|
+
const taskTargetsPresentation = hasAny(taskTokens, [
|
|
101
|
+
"browser", "button", "client", "display", "form", "frontend", "layout", "page", "screen", "ui", "visitor", "web", "website"
|
|
102
|
+
]);
|
|
87
103
|
const taskTargetsTypeDeclarations = /\b(?:typescript|types?|type definitions?|declarations?|typings?|\.d\.(?:ts|mts|cts))\b/i.test(taskText);
|
|
88
104
|
const scored = candidates
|
|
89
105
|
.map((file) => {
|
|
@@ -105,11 +121,16 @@ minScore = REPORT_SCORE_CUTOFF) {
|
|
|
105
121
|
reasons.push(`path matches task terms: ${pathOverlap.join(", ")}`);
|
|
106
122
|
}
|
|
107
123
|
const contentTokens = contentTokensByPath.get(file.path) ?? new Set();
|
|
108
|
-
const contentOverlap = [...contentTokens].filter((token) => taskTokens.has(token) && !commonTokens.has(token));
|
|
124
|
+
const contentOverlap = [...contentTokens].filter((token) => taskTokens.has(token) && (allTaskTermsAreWidespread || !commonTokens.has(token)));
|
|
109
125
|
if (contentOverlap.length > 0) {
|
|
110
126
|
score += Math.min(contentOverlap.length, 8) * 2;
|
|
111
127
|
reasons.push(`content matches task terms: ${contentOverlap.slice(0, 8).join(", ")}`);
|
|
112
128
|
}
|
|
129
|
+
const regexTokenOverlap = findRegexTokenOverlap(file.textSample, taskTokens);
|
|
130
|
+
if (regexTokenOverlap.length > 0) {
|
|
131
|
+
score += Math.min(regexTokenOverlap.length, 2) * 12;
|
|
132
|
+
reasons.push(`regex literal matches task tokens: ${regexTokenOverlap.join(", ")}`);
|
|
133
|
+
}
|
|
113
134
|
const matchedMembers = [...signals.memberMentions]
|
|
114
135
|
.filter((member) => hasExactIdentifier(file.textSample, member))
|
|
115
136
|
.slice(0, 3);
|
|
@@ -131,7 +152,9 @@ minScore = REPORT_SCORE_CUTOFF) {
|
|
|
131
152
|
score += definedIdentifiers.length * DEFINITION_IDENTIFIER_BOOST;
|
|
132
153
|
reasons.push(`defines task identifiers: ${definedIdentifiers.join(", ")}`);
|
|
133
154
|
}
|
|
134
|
-
const taskMatchedDefinitions = signals.exactFragments.length === 0
|
|
155
|
+
const taskMatchedDefinitions = signals.exactFragments.length === 0 &&
|
|
156
|
+
!taskTargetsDocumentation &&
|
|
157
|
+
!taskTargetsPresentation
|
|
135
158
|
? findTaskMatchedDefinitions(file.textSample, taskTokens)
|
|
136
159
|
.filter((identifier) => !definedIdentifiers.includes(identifier))
|
|
137
160
|
.slice(0, MAX_DEFINITION_IDENTIFIERS)
|
|
@@ -174,11 +197,21 @@ minScore = REPORT_SCORE_CUTOFF) {
|
|
|
174
197
|
if (file.kind === "code" &&
|
|
175
198
|
isAuxiliaryCodePath(file.path) &&
|
|
176
199
|
!taskTargetsExamples &&
|
|
200
|
+
!taskTargetsPresentation &&
|
|
177
201
|
!isChanged &&
|
|
178
202
|
!mentionedPaths.has(file.path)) {
|
|
179
203
|
score -= EXAMPLE_CODE_PENALTY;
|
|
180
204
|
reasons.push("example or demo code deprioritized for an implementation task");
|
|
181
205
|
}
|
|
206
|
+
if (file.kind === "code" &&
|
|
207
|
+
isPresentationCodePath(file.path) &&
|
|
208
|
+
!taskTargetsPresentation &&
|
|
209
|
+
!taskTargetsExamples &&
|
|
210
|
+
!isChanged &&
|
|
211
|
+
!mentionedPaths.has(file.path)) {
|
|
212
|
+
score -= PRESENTATION_CODE_PENALTY;
|
|
213
|
+
reasons.push("presentation or demo surface deprioritized for a non-UI implementation task");
|
|
214
|
+
}
|
|
182
215
|
if (isTypeDeclarationPath(file.path) &&
|
|
183
216
|
!taskTargetsTypeDeclarations &&
|
|
184
217
|
!isChanged &&
|
|
@@ -214,14 +247,44 @@ minScore = REPORT_SCORE_CUTOFF) {
|
|
|
214
247
|
.sort((a, b) => b.score - a.score || a.path.localeCompare(b.path))
|
|
215
248
|
.slice(0, limit);
|
|
216
249
|
const clustered = isClusteredRanking(ranked);
|
|
250
|
+
const leadIsContested = hasContestedLead(ranked);
|
|
217
251
|
return ranked
|
|
218
|
-
.map((entry) => ({
|
|
252
|
+
.map((entry, position) => ({
|
|
219
253
|
path: entry.path,
|
|
220
254
|
score: entry.score,
|
|
221
|
-
confidence: confidenceForEntry(entry, grounding, clustered
|
|
255
|
+
confidence: confidenceForEntry(entry, grounding, clustered, {
|
|
256
|
+
position,
|
|
257
|
+
topScore: ranked[0]?.score ?? entry.score,
|
|
258
|
+
leadIsContested
|
|
259
|
+
}),
|
|
222
260
|
reasons: entry.reasons.length > 0 ? entry.reasons : ["source file baseline"]
|
|
223
261
|
}));
|
|
224
262
|
}
|
|
263
|
+
/**
|
|
264
|
+
* Is the leading file's claim disputed by a definition site behind it?
|
|
265
|
+
*
|
|
266
|
+
* #102 established that a file defining the symbol a task names is a better answer than a
|
|
267
|
+
* file that merely talks about it a lot, however dense that talk is. So when the leader
|
|
268
|
+
* carries no definition evidence of its own and something below it does, the lead is not
|
|
269
|
+
* decisive — it is one of two plausible answers, and the one below has the stronger kind
|
|
270
|
+
* of evidence. Saying "high" there is the expensive failure, because an agent that opens
|
|
271
|
+
* only the first result never sees the competitor.
|
|
272
|
+
*
|
|
273
|
+
* Score margin is deliberately not part of this. A definition site six points back is
|
|
274
|
+
* still the definition site; ranking it lower is exactly the vocabulary-density bias the
|
|
275
|
+
* boost exists to correct, so a margin would reintroduce the thing being guarded against.
|
|
276
|
+
*/
|
|
277
|
+
function hasContestedLead(ranked) {
|
|
278
|
+
const leader = ranked[0];
|
|
279
|
+
if (!leader || hasDefinitionEvidence(leader)) {
|
|
280
|
+
return false;
|
|
281
|
+
}
|
|
282
|
+
return ranked.slice(1).some((entry) => hasDefinitionEvidence(entry));
|
|
283
|
+
}
|
|
284
|
+
function hasDefinitionEvidence(entry) {
|
|
285
|
+
return entry.reasons.some((reason) => reason.startsWith("defines task identifiers:") ||
|
|
286
|
+
reason.startsWith("exact task literal at definition:"));
|
|
287
|
+
}
|
|
225
288
|
function applyImportProximity(scored, repo) {
|
|
226
289
|
const seedEntries = scored
|
|
227
290
|
.filter((entry) => entry.score >= 8 && hasDirectEvidence(entry))
|
|
@@ -253,11 +316,24 @@ function proximityReason(hit) {
|
|
|
253
316
|
}
|
|
254
317
|
return hit.direction === "imported-by" ? `imported by ranked file ${hit.seed}` : `imports ranked file ${hit.seed}`;
|
|
255
318
|
}
|
|
256
|
-
function confidenceForEntry(entry, grounding, clustered) {
|
|
319
|
+
function confidenceForEntry(entry, grounding, clustered, shape) {
|
|
257
320
|
if (entry.isChanged || entry.reasons.includes("explicitly named in the task")) {
|
|
258
321
|
return "high";
|
|
259
322
|
}
|
|
260
323
|
let confidence = entry.score >= 14 ? "high" : entry.score >= 8 ? "medium" : "low";
|
|
324
|
+
// An absolute threshold alone says nothing about whether this file beat the others.
|
|
325
|
+
// On a real Zod task the top eight scored 43, 24, 22, 20, 20, 20, 19, 19 and every one
|
|
326
|
+
// of them was labeled high — teaching an agent that the eighth guess is as safe to edit
|
|
327
|
+
// as a leader nineteen points ahead. High is now reserved for a file that actually leads,
|
|
328
|
+
// ties the lead, or carries definition-site evidence of its own; the rest are a
|
|
329
|
+
// neighborhood to read, which is what medium already means.
|
|
330
|
+
const leads = shape.position === 0 || entry.score >= shape.topScore - HIGH_CONFIDENCE_MARGIN;
|
|
331
|
+
if (!leads && !hasDirectEvidence(entry)) {
|
|
332
|
+
confidence = capConfidence(confidence, "medium");
|
|
333
|
+
}
|
|
334
|
+
if (shape.position === 0 && shape.leadIsContested) {
|
|
335
|
+
confidence = capConfidence(confidence, "medium");
|
|
336
|
+
}
|
|
261
337
|
const supportedIdentifierCount = grounding.identifiers.filter((identifier) => identifier.status === "exact-definition" ||
|
|
262
338
|
identifier.status === "exact-text" ||
|
|
263
339
|
identifier.status === "partial-definition").length;
|
|
@@ -341,7 +417,47 @@ function compiledSourcePathVariants(path) {
|
|
|
341
417
|
return [];
|
|
342
418
|
}
|
|
343
419
|
function isAuxiliaryCodePath(path) {
|
|
344
|
-
|
|
420
|
+
const parts = path.split("/");
|
|
421
|
+
const stem = (parts.at(-1) ?? "").replace(/\.[^.]+$/, "").toLowerCase();
|
|
422
|
+
return parts.slice(0, -1).some((segment) => AUXILIARY_CODE_DIRS.has(segment.toLowerCase())) ||
|
|
423
|
+
/^(?:demo|example|sample)(?:[-_.]|$)/.test(stem);
|
|
424
|
+
}
|
|
425
|
+
function isPresentationCodePath(path) {
|
|
426
|
+
const name = path.split("/").at(-1)?.toLowerCase() ?? "";
|
|
427
|
+
return /^(?:page|layout|demo|sample-repo)\.[cm]?[jt]sx?$/.test(name);
|
|
428
|
+
}
|
|
429
|
+
function tokenizeFileContent(text) {
|
|
430
|
+
const tokens = tokenizeText(text);
|
|
431
|
+
for (const match of text.matchAll(/\b([A-Za-z])\{(\d+),(\d+)\}/g)) {
|
|
432
|
+
const character = match[1]?.toLowerCase();
|
|
433
|
+
const minimum = Number(match[2]);
|
|
434
|
+
const maximum = Math.min(Number(match[3]), 8);
|
|
435
|
+
if (!character || !Number.isSafeInteger(minimum) || !Number.isSafeInteger(maximum)) {
|
|
436
|
+
continue;
|
|
437
|
+
}
|
|
438
|
+
for (let length = Math.max(3, minimum); length <= maximum; length += 1) {
|
|
439
|
+
tokens.add(character.repeat(length));
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
return tokens;
|
|
443
|
+
}
|
|
444
|
+
function findRegexTokenOverlap(text, taskTokens) {
|
|
445
|
+
const overlap = new Set();
|
|
446
|
+
for (const match of text.matchAll(/\b([A-Za-z])\{(\d+),(\d+)\}/g)) {
|
|
447
|
+
const character = match[1]?.toLowerCase();
|
|
448
|
+
const minimum = Number(match[2]);
|
|
449
|
+
const maximum = Math.min(Number(match[3]), 8);
|
|
450
|
+
if (!character || !Number.isSafeInteger(minimum) || !Number.isSafeInteger(maximum)) {
|
|
451
|
+
continue;
|
|
452
|
+
}
|
|
453
|
+
for (let length = Math.max(3, minimum); length <= maximum; length += 1) {
|
|
454
|
+
const token = character.repeat(length);
|
|
455
|
+
if (taskTokens.has(token)) {
|
|
456
|
+
overlap.add(token);
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
return [...overlap].slice(0, 2);
|
|
345
461
|
}
|
|
346
462
|
function isBundledOutput(textSample) {
|
|
347
463
|
if (textSample.length < MIN_BUNDLE_SAMPLE_BYTES) {
|
|
@@ -355,7 +471,7 @@ function isTypeDeclarationPath(path) {
|
|
|
355
471
|
}
|
|
356
472
|
function targetsDocumentation(taskText) {
|
|
357
473
|
const documentation = "(?:docs?|documentation|readme|guide|copy)";
|
|
358
|
-
const action = "(?:add|edit|update|write|rewrite|revise|remove|correct|document)";
|
|
474
|
+
const action = "(?:add|edit|update|write|rewrite|revise|remove|correct|document|improve)";
|
|
359
475
|
return (new RegExp(`\\b${action}\\b[^\\n.]{0,60}\\b${documentation}\\b`, "i").test(taskText) ||
|
|
360
476
|
new RegExp(`\\b${documentation}\\b[^\\n.]{0,60}\\b${action}\\b`, "i").test(taskText));
|
|
361
477
|
}
|