@aryam/fixmap 0.8.9 → 0.9.1

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.
@@ -0,0 +1,60 @@
1
+ export type BenchmarkArm = "bm25" | "fixmap" | "impact";
2
+ export type BenchmarkCaseResult = {
3
+ commit: string;
4
+ task: string;
5
+ expected: string[];
6
+ mentionsExpectedPath: boolean;
7
+ arms: Record<BenchmarkArm, {
8
+ top5Paths: string[];
9
+ top1Hit: boolean;
10
+ top3Hit: boolean;
11
+ top5Hit: boolean;
12
+ }>;
13
+ impactSecondary: {
14
+ hits: number;
15
+ of: number;
16
+ } | null;
17
+ };
18
+ export type RepositoryBenchmark = {
19
+ benchmarkVersion: 1;
20
+ generatedAt: string;
21
+ repository: string;
22
+ requestedCommits: number;
23
+ eligibleCases: number;
24
+ skipped: Record<string, number>;
25
+ safeguards: {
26
+ parentSnapshots: true;
27
+ historyCutoff: "target-parent";
28
+ maxChangedFiles: number;
29
+ primaryTargets: "changed-maintained-non-test-code";
30
+ sameScannedCorpus: true;
31
+ checkoutFiltersDisabled: true;
32
+ repositoryCodeExecuted: false;
33
+ };
34
+ cohorts: Record<"all" | "mentioned" | "unmentioned", Record<BenchmarkArm, BenchmarkScore>>;
35
+ impactSecondary: {
36
+ hits: number;
37
+ of: number;
38
+ recall: number | null;
39
+ };
40
+ cases: BenchmarkCaseResult[];
41
+ };
42
+ export type BenchmarkScore = {
43
+ cases: number;
44
+ top1: Rate;
45
+ top3: Rate;
46
+ top5: Rate;
47
+ };
48
+ type Rate = {
49
+ hits: number;
50
+ of: number;
51
+ rate: number | null;
52
+ interval95: [number, number] | null;
53
+ };
54
+ export declare function benchmarkRepository(input: {
55
+ repoRoot: string;
56
+ last?: number;
57
+ progress?: (message: string) => void;
58
+ }): Promise<RepositoryBenchmark>;
59
+ export declare function renderRepositoryBenchmark(result: RepositoryBenchmark): string;
60
+ export {};
@@ -0,0 +1,308 @@
1
+ import { execFile } from "node:child_process";
2
+ import { mkdir, mkdtemp, rm } from "node:fs/promises";
3
+ import { tmpdir } from "node:os";
4
+ import { basename, join, resolve } from "node:path";
5
+ import { promisify } from "node:util";
6
+ import { buildReportFromRepo, isBackupPath, isGeneratedPath, moduleStem, rankByBm25, retrievalQueryTerms, scanRepo, taskMentionsExpectedPath } from "@aryam/fixmap-core";
7
+ const exec = promisify(execFile);
8
+ const MAX_CHANGED_FILES = 30;
9
+ const MAX_BENCHMARK_CASES = 100;
10
+ const MAX_TASK_CHARS = 20_000;
11
+ const GIT_BUFFER = 24 * 1024 * 1024;
12
+ export async function benchmarkRepository(input) {
13
+ const repoRoot = resolve(input.repoRoot);
14
+ const requested = input.last ?? 20;
15
+ if (!Number.isSafeInteger(requested) || requested < 1 || requested > MAX_BENCHMARK_CASES) {
16
+ throw new Error(`--last must be a whole number from 1 to ${MAX_BENCHMARK_CASES}.`);
17
+ }
18
+ await assertGitRepository(repoRoot);
19
+ const checkoutConfig = await safeCheckoutConfig(repoRoot);
20
+ const candidates = await listCandidateCommits(repoRoot, Math.min(MAX_BENCHMARK_CASES * 5, requested * 5));
21
+ const repository = await repositoryLabel(repoRoot);
22
+ const skipped = {};
23
+ const results = [];
24
+ for (const candidate of candidates) {
25
+ if (results.length >= requested)
26
+ break;
27
+ if (candidate.changedFiles.length === 0) {
28
+ increment(skipped, "empty-change");
29
+ continue;
30
+ }
31
+ if (candidate.changedFiles.length > MAX_CHANGED_FILES) {
32
+ increment(skipped, "oversized-change");
33
+ continue;
34
+ }
35
+ if (retrievalQueryTerms(candidate.task).length < 2) {
36
+ increment(skipped, "insufficient-task-text");
37
+ continue;
38
+ }
39
+ input.progress?.(`Benchmarking ${results.length + 1}/${requested}: ${candidate.hash.slice(0, 8)}`);
40
+ const row = await benchmarkCommit(repoRoot, candidate, checkoutConfig);
41
+ if (!row) {
42
+ increment(skipped, "no-preexisting-target");
43
+ continue;
44
+ }
45
+ results.push(row);
46
+ }
47
+ if (results.length === 0) {
48
+ throw new Error("No eligible historical changes were found. Use a repository with descriptive commit messages and at least one prior revision.");
49
+ }
50
+ const all = results;
51
+ const mentioned = results.filter((row) => row.mentionsExpectedPath);
52
+ const unmentioned = results.filter((row) => !row.mentionsExpectedPath);
53
+ const impactSecondaryRows = results.map((row) => row.impactSecondary).filter((row) => row !== null);
54
+ const secondaryHits = impactSecondaryRows.reduce((sum, row) => sum + row.hits, 0);
55
+ const secondaryOf = impactSecondaryRows.reduce((sum, row) => sum + row.of, 0);
56
+ return {
57
+ benchmarkVersion: 1,
58
+ generatedAt: new Date().toISOString(),
59
+ repository,
60
+ requestedCommits: requested,
61
+ eligibleCases: results.length,
62
+ skipped,
63
+ safeguards: {
64
+ parentSnapshots: true,
65
+ historyCutoff: "target-parent",
66
+ maxChangedFiles: MAX_CHANGED_FILES,
67
+ primaryTargets: "changed-maintained-non-test-code",
68
+ sameScannedCorpus: true,
69
+ checkoutFiltersDisabled: true,
70
+ repositoryCodeExecuted: false
71
+ },
72
+ cohorts: {
73
+ all: scoreArms(all),
74
+ mentioned: scoreArms(mentioned),
75
+ unmentioned: scoreArms(unmentioned)
76
+ },
77
+ impactSecondary: {
78
+ hits: secondaryHits,
79
+ of: secondaryOf,
80
+ recall: secondaryOf === 0 ? null : round(secondaryHits / secondaryOf)
81
+ },
82
+ cases: results
83
+ };
84
+ }
85
+ async function benchmarkCommit(repoRoot, candidate, checkoutConfig) {
86
+ const temporaryRoot = await mkdtemp(join(tmpdir(), "fixmap-benchmark-"));
87
+ const snapshot = join(temporaryRoot, "snapshot");
88
+ const emptyHooks = join(temporaryRoot, "hooks-disabled");
89
+ await mkdir(emptyHooks);
90
+ let worktreeAdded = false;
91
+ try {
92
+ await runGit(repoRoot, [
93
+ "-c", `core.hooksPath=${emptyHooks}`,
94
+ ...checkoutConfig,
95
+ "worktree", "add", "--detach", snapshot, candidate.parent
96
+ ]);
97
+ worktreeAdded = true;
98
+ const repo = await scanRepo({ repoRoot: snapshot, includeHistory: true, useCache: false });
99
+ const fileByPath = new Map(repo.files.map((file) => [file.path, file]));
100
+ const changedExisting = candidate.changedFiles.filter((path) => fileByPath.has(path));
101
+ const maintainedStems = new Set(repo.files
102
+ .filter((file) => !isGeneratedPath(file.path) && !isBackupPath(file.path))
103
+ .map((file) => moduleStem(file.path)));
104
+ // Primary retrieval compares like with like: changed maintained implementation code,
105
+ // excluding tests. Generated twins cannot become impossible expected answers when all
106
+ // three retrieval arms deliberately prefer their maintained source.
107
+ const expected = changedExisting.filter((path) => {
108
+ const file = fileByPath.get(path);
109
+ return file?.kind === "code" &&
110
+ !file.isTest &&
111
+ !isBackupPath(path) &&
112
+ !(isGeneratedPath(path) && maintainedStems.has(moduleStem(path)));
113
+ });
114
+ if (expected.length === 0)
115
+ return undefined;
116
+ const report = buildReportFromRepo(repo, { issueText: candidate.task, limit: 5 });
117
+ const fixmap = report.contextFiles.map((file) => file.path).slice(0, 5);
118
+ const bm25 = rankByBm25(repo.files, candidate.task, 5);
119
+ const impact = uniquePaths([
120
+ ...(fixmap[0] ? [fixmap[0]] : []),
121
+ ...(report.impact?.files.map((file) => file.path) ?? []),
122
+ ...fixmap.slice(1)
123
+ ]).slice(0, 5);
124
+ const primary = fixmap.find((path) => expected.includes(path));
125
+ const secondaryExpected = primary
126
+ ? changedExisting.filter((path) => path !== primary && fileByPath.get(path)?.kind === "code")
127
+ : [];
128
+ const impactSecondary = primary && secondaryExpected.length > 0
129
+ ? { hits: secondaryExpected.filter((path) => report.impact?.files.some((file) => file.path === path)).length, of: secondaryExpected.length }
130
+ : null;
131
+ return {
132
+ commit: candidate.hash,
133
+ task: candidate.task,
134
+ expected,
135
+ mentionsExpectedPath: taskMentionsExpectedPath(candidate.task, expected),
136
+ arms: {
137
+ bm25: scoreCase(bm25, expected),
138
+ fixmap: scoreCase(fixmap, expected),
139
+ impact: scoreCase(impact, expected)
140
+ },
141
+ impactSecondary
142
+ };
143
+ }
144
+ finally {
145
+ if (worktreeAdded) {
146
+ try {
147
+ await runGit(repoRoot, ["-c", `core.hooksPath=${emptyHooks}`, ...checkoutConfig, "worktree", "remove", "--force", snapshot]);
148
+ }
149
+ catch (error) {
150
+ throw new Error(`Could not remove temporary benchmark worktree "${snapshot}": ${error instanceof Error ? error.message : String(error)}`);
151
+ }
152
+ }
153
+ await rm(temporaryRoot, { recursive: true, force: true });
154
+ }
155
+ }
156
+ async function listCandidateCommits(repoRoot, limit) {
157
+ const hashes = (await runGit(repoRoot, ["rev-list", "--no-merges", `--max-count=${limit}`, "HEAD"]))
158
+ .split(/\r?\n/).filter(Boolean);
159
+ const candidates = [];
160
+ for (const hash of hashes) {
161
+ const parents = (await runGit(repoRoot, ["show", "-s", "--format=%P", hash])).trim().split(/\s+/).filter(Boolean);
162
+ if (parents.length !== 1)
163
+ continue;
164
+ const task = (await runGit(repoRoot, ["show", "-s", "--format=%B", hash])).slice(0, MAX_TASK_CHARS).trim();
165
+ const changedFiles = (await runGit(repoRoot, [
166
+ "-c", "core.quotepath=false", "diff-tree", "--no-ext-diff", "--no-commit-id", "--name-only", "-r", "-z", hash
167
+ ])).split("\0").filter(Boolean).map((path) => path.replace(/\\/g, "/"));
168
+ candidates.push({ hash, parent: parents[0], task, changedFiles: [...new Set(changedFiles)] });
169
+ }
170
+ return candidates;
171
+ }
172
+ async function safeCheckoutConfig(repoRoot) {
173
+ let names = [];
174
+ try {
175
+ const output = await runGit(repoRoot, [
176
+ "config", "--null", "--name-only", "--get-regexp", "^filter\\..*\\.(clean|smudge|process|required)$"
177
+ ]);
178
+ names = output.split("\0").filter(Boolean);
179
+ }
180
+ catch {
181
+ // `git config --get-regexp` exits 1 when no matching filter is configured.
182
+ }
183
+ const drivers = [...new Set(names.flatMap((name) => {
184
+ const match = name.match(/^filter\.(.+)\.(?:clean|smudge|process|required)$/i);
185
+ return match?.[1] ? [match[1]] : [];
186
+ }))].sort((left, right) => left.localeCompare(right));
187
+ const options = [
188
+ "-c", "core.fsmonitor=false",
189
+ "-c", "core.symlinks=false"
190
+ ];
191
+ for (const driver of drivers) {
192
+ options.push("-c", `filter.${driver}.smudge=`, "-c", `filter.${driver}.process=`, "-c", `filter.${driver}.required=false`);
193
+ }
194
+ return options;
195
+ }
196
+ async function assertGitRepository(repoRoot) {
197
+ try {
198
+ if ((await runGit(repoRoot, ["rev-parse", "--is-inside-work-tree"])).trim() !== "true")
199
+ throw new Error("not a worktree");
200
+ await runGit(repoRoot, ["rev-parse", "--verify", "HEAD"]);
201
+ }
202
+ catch {
203
+ throw new Error(`Benchmark needs a local Git repository with at least one commit: ${repoRoot}`);
204
+ }
205
+ }
206
+ async function repositoryLabel(repoRoot) {
207
+ try {
208
+ const remote = (await runGit(repoRoot, ["remote", "get-url", "origin"])).trim();
209
+ const match = remote.match(/github\.com[/:]([^/]+\/[^/]+?)(?:\.git)?$/i);
210
+ if (match?.[1])
211
+ return match[1];
212
+ }
213
+ catch { /* Local-only repositories have no origin; basename is non-sensitive and stable. */ }
214
+ return basename(repoRoot);
215
+ }
216
+ async function runGit(cwd, args) {
217
+ const { stdout } = await exec("git", args, {
218
+ cwd,
219
+ maxBuffer: GIT_BUFFER,
220
+ env: { ...process.env, GIT_TERMINAL_PROMPT: "0", GIT_CONFIG_NOSYSTEM: "1" }
221
+ });
222
+ return stdout;
223
+ }
224
+ function scoreCase(paths, expected) {
225
+ return {
226
+ top5Paths: paths,
227
+ top1Hit: expected.includes(paths[0] ?? ""),
228
+ top3Hit: expected.some((path) => paths.slice(0, 3).includes(path)),
229
+ top5Hit: expected.some((path) => paths.slice(0, 5).includes(path))
230
+ };
231
+ }
232
+ function scoreArms(rows) {
233
+ return {
234
+ bm25: scoreRows(rows, "bm25"),
235
+ fixmap: scoreRows(rows, "fixmap"),
236
+ impact: scoreRows(rows, "impact")
237
+ };
238
+ }
239
+ function scoreRows(rows, arm) {
240
+ return {
241
+ cases: rows.length,
242
+ top1: rate(rows, arm, "top1Hit"),
243
+ top3: rate(rows, arm, "top3Hit"),
244
+ top5: rate(rows, arm, "top5Hit")
245
+ };
246
+ }
247
+ function rate(rows, arm, key) {
248
+ const hits = rows.filter((row) => row.arms[arm][key]).length;
249
+ return {
250
+ hits,
251
+ of: rows.length,
252
+ rate: rows.length === 0 ? null : round(hits / rows.length),
253
+ interval95: wilsonInterval(hits, rows.length)
254
+ };
255
+ }
256
+ function wilsonInterval(hits, total) {
257
+ if (total === 0)
258
+ return null;
259
+ const z = 1.959963984540054;
260
+ const proportion = hits / total;
261
+ const denominator = 1 + (z * z) / total;
262
+ const center = (proportion + (z * z) / (2 * total)) / denominator;
263
+ const margin = (z / denominator) * Math.sqrt((proportion * (1 - proportion)) / total + (z * z) / (4 * total * total));
264
+ return [round(Math.max(0, center - margin)), round(Math.min(1, center + margin))];
265
+ }
266
+ function round(value) {
267
+ return Number(value.toFixed(3));
268
+ }
269
+ function uniquePaths(paths) {
270
+ return [...new Set(paths)];
271
+ }
272
+ function increment(counts, key) {
273
+ counts[key] = (counts[key] ?? 0) + 1;
274
+ }
275
+ export function renderRepositoryBenchmark(result) {
276
+ const unmentioned = result.cohorts.unmentioned;
277
+ const percent = (rate) => rate === null ? "n/a" : `${Math.round(rate * 100)}%`;
278
+ const lines = [
279
+ "# FixMap Repository Benchmark",
280
+ "",
281
+ `Evaluated ${result.eligibleCases} eligible historical changes from ${result.repository}.`,
282
+ "Every case used the target commit's parent snapshot and history ending at that parent.",
283
+ "",
284
+ "## Unmentioned tasks",
285
+ "",
286
+ "| Arm | Top 1 | Top 3 | Top 5 |",
287
+ "| --- | ---: | ---: | ---: |",
288
+ `| BM25 over code | ${percent(unmentioned.bm25.top1.rate)} | ${percent(unmentioned.bm25.top3.rate)} | ${percent(unmentioned.bm25.top5.rate)} |`,
289
+ `| FixMap context | ${percent(unmentioned.fixmap.top1.rate)} | ${percent(unmentioned.fixmap.top3.rate)} | ${percent(unmentioned.fixmap.top5.rate)} |`,
290
+ `| FixMap + Impact Graph | ${percent(unmentioned.impact.top1.rate)} | ${percent(unmentioned.impact.top3.rate)} | ${percent(unmentioned.impact.top5.rate)} |`,
291
+ "",
292
+ `Impact secondary-file recall: ${result.impactSecondary.of === 0 ? "n/a" : `${result.impactSecondary.hits}/${result.impactSecondary.of} (${percent(result.impactSecondary.recall)})`}.`,
293
+ "",
294
+ "## Safeguards",
295
+ "",
296
+ "- Source was scanned from each target's parent revision.",
297
+ "- Co-change history stopped at that parent revision.",
298
+ `- Merges and commits touching more than ${result.safeguards.maxChangedFiles} files were excluded.`,
299
+ "- BM25, FixMap, and Impact Graph saw the same scanned files.",
300
+ "- Primary hits were scored only against changed maintained non-test code; generated twins, backups, and tests were excluded. Secondary impact recall may include changed tests.",
301
+ "- Repository code, dependencies, scripts, and hooks were not executed.",
302
+ "",
303
+ "A historical commit message is not the same input as its original issue. Treat this as a repository-specific backtest, not proof of agent savings.",
304
+ ""
305
+ ];
306
+ return lines.join("\n");
307
+ }
308
+ //# sourceMappingURL=benchmark.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"benchmark.js","sourceRoot":"","sources":["../src/benchmark.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EACL,mBAAmB,EACnB,YAAY,EACZ,eAAe,EACf,UAAU,EACV,UAAU,EACV,mBAAmB,EACnB,QAAQ,EACR,wBAAwB,EACzB,MAAM,oBAAoB,CAAC;AAE5B,MAAM,IAAI,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AACjC,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAC7B,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAChC,MAAM,cAAc,GAAG,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 +1,7 @@
1
1
  import { type FixMapReport } from "@aryam/fixmap-core";
2
2
  import { type DoctorReport } from "./doctor.js";
3
+ import type { RepositoryBenchmark } from "./benchmark.js";
4
+ import type { WatchRepositoryInput, WatchUpdate } from "./watch.js";
3
5
  import { type RepositoryPlanInput } from "./repository-source.js";
4
6
  export type CliOptions = {
5
7
  command: string;
@@ -10,7 +12,7 @@ export type CliOptions = {
10
12
  baseRef?: string | undefined;
11
13
  headRef?: string | undefined;
12
14
  checkoutRef?: string | undefined;
13
- format: "markdown" | "json";
15
+ format: "markdown" | "json" | "agent";
14
16
  output?: string | undefined;
15
17
  explainPath?: string | undefined;
16
18
  reportPath?: string | undefined;
@@ -33,8 +35,16 @@ export type CliDependencies = {
33
35
  stdout?: (text: string) => void;
34
36
  writeReport?: (path: string, contents: string) => Promise<void>;
35
37
  readIssueFile?: (path: string | number) => string | Buffer;
38
+ benchmarkRepository?: (input: {
39
+ repoRoot: string;
40
+ last?: number;
41
+ progress?: (message: string) => void;
42
+ }) => Promise<RepositoryBenchmark>;
43
+ renderBenchmark?: (result: RepositoryBenchmark) => string;
44
+ watchRepository?: (input: WatchRepositoryInput) => Promise<WatchUpdate | undefined>;
45
+ renderWatchUpdate?: (update: WatchUpdate, format: "markdown" | "json") => string;
36
46
  };
37
- export declare const USAGE = "FixMap maps an issue, prompt, or diff to context files, test routes, and review risks.\n\nUsage:\n fixmap owner/repository#123\n fixmap https://github.com/owner/repository/issues/123\n fixmap plan --issue \"Users cannot reset passwords\"\n fixmap plan --issue https://github.com/owner/repository/issues/123\n fixmap plan --issue https://github.com/owner/repository/pull/123\n fixmap plan --issue-file task.md\n fixmap plan --issue -\n fixmap plan --issue \"Fix login\" --repo https://github.com/owner/repository\n fixmap plan --issue \"Fix login\" --repo https://github.com/owner/repository --ref release-2.x\n fixmap plan --diff main...HEAD\n fixmap plan --working-tree --include-untracked --limit 12 --exclude \"docs/**\"\n fixmap plan --no-cache --issue \"Fix login\" --repo .\n fixmap plan --issue \"Fix login\" --format json --output plan.json\n fixmap plan --issue \"Fix login in auth middleware\" --compare plan.json\n fixmap plan --base main --head HEAD --format json\n fixmap verify --report plan.json --diff main...HEAD\n fixmap verify --report plan.json --working-tree\n fixmap verify --report plan.json --working-tree --fail-on warning\n fixmap doctor --format json\n fixmap validate plan.json\n fixmap features\n fixmap setup [--agent claude|cursor|copilot|agents|all] [--repo <path>]\n fixmap mcp [--repo <path>]\n\nCommands:\n plan Generate a FixMap report for a task or diff\n verify Compare a saved report against the diff that followed it\n doctor Check the FixMap install for stale global or npx shadows\n validate Validate a saved FixMap JSON report\n features List every FixMap capability and its command\n setup Install a discoverable /fixmap command for coding agents\n mcp Run FixMap as an MCP server over stdio for AI coding agents\n\nOptions:\n --issue <text|url> Task text, or a public GitHub issue or pull request URL\n --issue-file <file> Read task text from a UTF-8 or UTF-16 file (use - for stdin)\n --diff <spec> Git diff spec, such as main...HEAD (the repository scan can still rank untracked candidates)\n --base <ref> Base ref for diffing when --diff is not given\n --head <ref> Head ref for diffing (defaults to HEAD)\n --working-tree Map staged and unstaged changes against HEAD\n --include-untracked With --working-tree, also include untracked files\n --no-cache Bypass the exact git-state repository scan cache\n --repo <source> Local path or public GitHub HTTPS URL (defaults to current directory)\n --ref <branch|tag> Branch or tag to scan when --repo is a remote GitHub URL\n --limit <n> Maximum context files to report (default 8, max 20)\n --exclude <glob> Path pattern to leave out of ranking (repeatable)\n --format <fmt> Output format: markdown (default) or json\n --output <file> Write the report or verification to a file instead of stdout\n --explain <path> Explain why one file was ranked where it was, or left out\n --compare <file> Compare this plan against an earlier JSON report\n --report <file> Verify command only: the JSON report the change was planned from\n --fail-on <level> Verify exit policy: error (default) or warning\n --help, -h Show this help\n --version, -v Show the FixMap version\n\nA repository may also list exclusion patterns in .fixmapignore, one per line. Supported\nsyntax is *, **, ?, repository-root-leading /, directory-trailing /, comments, and ! negation.\nAbsolute paths pasted from inside the repository are normalized to repository-relative patterns.\nSet FIXMAP_PROGRESS=1 to print scan and clone phases to stderr.\nSet FIXMAP_CACHE_DIR to move the OS scan cache, and FIXMAP_VERBOSE_USAGE=1 to include this full help after argument errors.\n";
47
+ export declare const USAGE = "FixMap maps an issue, prompt, or diff to context files, test routes, and review risks.\n\nUsage:\n fixmap owner/repository#123\n fixmap https://github.com/owner/repository/issues/123\n fixmap plan --issue \"Users cannot reset passwords\"\n fixmap plan --issue https://github.com/owner/repository/issues/123\n fixmap plan --issue https://github.com/owner/repository/pull/123\n fixmap plan --issue-file task.md\n fixmap plan --issue -\n fixmap plan --issue \"Fix login\" --repo https://github.com/owner/repository\n fixmap plan --issue \"Fix login\" --repo https://github.com/owner/repository --ref release-2.x\n fixmap plan --diff main...HEAD\n fixmap plan --working-tree --include-untracked --limit 12 --exclude \"docs/**\"\n fixmap plan --no-cache --issue \"Fix login\" --repo .\n fixmap plan --issue \"Fix login\" --format json --output plan.json\n fixmap plan --issue \"Fix login\" --format agent\n fixmap plan --issue \"Fix login in auth middleware\" --compare plan.json\n fixmap plan --base main --head HEAD --format json\n fixmap verify --report plan.json --diff main...HEAD\n fixmap verify --report plan.json --working-tree\n fixmap verify --report plan.json --working-tree --fail-on warning\n fixmap doctor --format json\n fixmap validate plan.json\n fixmap benchmark --repo . --last 50\n fixmap context --issue \"Fix login\" --budget 10000\n fixmap graph --issue \"Fix login\" --format mermaid\n fixmap watch --report plan.json --repo .\n fixmap features\n fixmap setup [--agent claude|cursor|copilot|agents|all] [--repo <path>]\n fixmap mcp [--repo <path>]\n\nCommands:\n plan Generate a FixMap report for a task or diff\n verify Compare a saved report against the diff that followed it\n doctor Check the FixMap install for stale global or npx shadows\n validate Validate a saved FixMap JSON report\n benchmark Backtest BM25, FixMap, and Impact Graph on pre-change snapshots\n context Package the highest-value source ranges within a token budget\n graph Export the evidence-backed Impact Graph as Mermaid or JSON\n watch Recheck working-tree drift and impact whenever edits change\n features List every FixMap capability and its command\n setup Install a discoverable /fixmap command for coding agents\n mcp Run FixMap as an MCP server over stdio for AI coding agents\n\nOptions:\n --issue <text|url> Task text, or a public GitHub issue or pull request URL\n --issue-file <file> Read task text from a UTF-8 or UTF-16 file (use - for stdin)\n --diff <spec> Git diff spec, such as main...HEAD (the repository scan can still rank untracked candidates)\n --base <ref> Base ref for diffing when --diff is not given\n --head <ref> Head ref for diffing (defaults to HEAD)\n --working-tree Map staged and unstaged changes against HEAD\n --include-untracked With --working-tree, also include untracked files\n --no-cache Bypass the exact git-state repository scan cache\n --repo <source> Local path or public GitHub HTTPS URL (defaults to current directory)\n --ref <branch|tag> Branch or tag to scan when --repo is a remote GitHub URL\n --limit <n> Maximum context files to report (default 8, max 20)\n --exclude <glob> Path pattern to leave out of ranking (repeatable)\n --format <fmt> Output format: markdown (default), json, or compact agent\n --output <file> Write the report or verification to a file instead of stdout\n --explain <path> Explain why one file was ranked where it was, or left out\n --compare <file> Compare this plan against an earlier JSON report\n --report <file> Verify command only: the JSON report the change was planned from\n --fail-on <level> Verify exit policy: error (default) or warning\n --help, -h Show this help\n --version, -v Show the FixMap version\n\nA repository may also list exclusion patterns in .fixmapignore, one per line. Supported\nsyntax is *, **, ?, repository-root-leading /, directory-trailing /, comments, and ! negation.\nAbsolute paths pasted from inside the repository are normalized to repository-relative patterns.\nSet FIXMAP_PROGRESS=1 to print scan and clone phases to stderr.\nSet FIXMAP_CACHE_DIR to move the OS scan cache, and FIXMAP_VERBOSE_USAGE=1 to include this full help after argument errors.\n";
38
48
  export declare function runCli(args: string[], dependencies?: CliDependencies): Promise<number>;
39
49
  export declare function expandIssueShorthand(args: string[]): string[];
40
50
  export declare const MAX_CONTEXT_FILE_LIMIT = 20;
@@ -3,7 +3,7 @@ import { realpath, stat, writeFile } from "node:fs/promises";
3
3
  import { homedir } from "node:os";
4
4
  import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
5
5
  import { fileURLToPath } from "node:url";
6
- import { compareReports, explainFile, quoteCliValue as formatCliValue, renderComparisonMarkdown, renderExplanationMarkdown, renderJsonReport, renderVerifyMarkdown, resolveExclusions, verifyPlan, renderMarkdownReport, scanRepo, stripByteOrderMark, validateFixMapReport } from "@aryam/fixmap-core";
6
+ import { compareReports, explainFile, quoteCliValue as formatCliValue, renderComparisonMarkdown, renderExplanationMarkdown, renderAgentReport, renderJsonReport, renderVerifyMarkdown, resolveExclusions, verifyPlan, renderMarkdownReport, scanRepo, stripByteOrderMark, validateFixMapReport } from "@aryam/fixmap-core";
7
7
  import { runDoctorChecks, renderDoctorReport } from "./doctor.js";
8
8
  import { installAgentCommands, renderFeatureCatalog } from "./agent-setup.js";
9
9
  import { clarifyMissingPath } from "./explain-path.js";
@@ -24,6 +24,7 @@ Usage:
24
24
  fixmap plan --working-tree --include-untracked --limit 12 --exclude "docs/**"
25
25
  fixmap plan --no-cache --issue "Fix login" --repo .
26
26
  fixmap plan --issue "Fix login" --format json --output plan.json
27
+ fixmap plan --issue "Fix login" --format agent
27
28
  fixmap plan --issue "Fix login in auth middleware" --compare plan.json
28
29
  fixmap plan --base main --head HEAD --format json
29
30
  fixmap verify --report plan.json --diff main...HEAD
@@ -31,6 +32,10 @@ Usage:
31
32
  fixmap verify --report plan.json --working-tree --fail-on warning
32
33
  fixmap doctor --format json
33
34
  fixmap validate plan.json
35
+ fixmap benchmark --repo . --last 50
36
+ fixmap context --issue "Fix login" --budget 10000
37
+ fixmap graph --issue "Fix login" --format mermaid
38
+ fixmap watch --report plan.json --repo .
34
39
  fixmap features
35
40
  fixmap setup [--agent claude|cursor|copilot|agents|all] [--repo <path>]
36
41
  fixmap mcp [--repo <path>]
@@ -40,6 +45,10 @@ Commands:
40
45
  verify Compare a saved report against the diff that followed it
41
46
  doctor Check the FixMap install for stale global or npx shadows
42
47
  validate Validate a saved FixMap JSON report
48
+ benchmark Backtest BM25, FixMap, and Impact Graph on pre-change snapshots
49
+ context Package the highest-value source ranges within a token budget
50
+ graph Export the evidence-backed Impact Graph as Mermaid or JSON
51
+ watch Recheck working-tree drift and impact whenever edits change
43
52
  features List every FixMap capability and its command
44
53
  setup Install a discoverable /fixmap command for coding agents
45
54
  mcp Run FixMap as an MCP server over stdio for AI coding agents
@@ -57,7 +66,7 @@ Options:
57
66
  --ref <branch|tag> Branch or tag to scan when --repo is a remote GitHub URL
58
67
  --limit <n> Maximum context files to report (default 8, max 20)
59
68
  --exclude <glob> Path pattern to leave out of ranking (repeatable)
60
- --format <fmt> Output format: markdown (default) or json
69
+ --format <fmt> Output format: markdown (default), json, or compact agent
61
70
  --output <file> Write the report or verification to a file instead of stdout
62
71
  --explain <path> Explain why one file was ranked where it was, or left out
63
72
  --compare <file> Compare this plan against an earlier JSON report
@@ -77,6 +86,7 @@ const MCP_USAGE = `Usage: fixmap mcp [--repo <path>]\n\nRuns the FixMap MCP serv
77
86
  const FEATURES_USAGE = `Usage: fixmap features [--format markdown|json]\n\nLists every FixMap capability and the command that exposes it.\n`;
78
87
  const SETUP_USAGE = `Usage: fixmap setup [--agent claude|cursor|copilot|agents|all] [--repo <path>] [--force]\n\nInstalls a /fixmap command that lists and runs FixMap workflows.\n`;
79
88
  const VALIDATE_USAGE = `Usage: fixmap validate <report.json> [--format markdown|json]\n\nChecks a saved report against FixMap's structural compatibility contract.\n`;
89
+ const BENCHMARK_USAGE = `Usage: fixmap benchmark [--repo <local-path>] [--last <1-100>] [--format markdown|json] [--output <file>]\n\nBacktests BM25, FixMap, and Impact Graph against historical parent snapshots without executing repository code.\n`;
80
90
  export async function runCli(args, dependencies = {}) {
81
91
  const stdout = dependencies.stdout ?? ((text) => process.stdout.write(text));
82
92
  const stderr = dependencies.stderr ?? ((text) => process.stderr.write(text));
@@ -313,6 +323,110 @@ export async function runCli(args, dependencies = {}) {
313
323
  return 1;
314
324
  }
315
325
  }
326
+ if (args[0] === "benchmark") {
327
+ if (args[1] === "--help" || args[1] === "-h") {
328
+ stdout(BENCHMARK_USAGE);
329
+ return 0;
330
+ }
331
+ let repoRoot = process.cwd();
332
+ let last;
333
+ let format = "markdown";
334
+ let output;
335
+ const seen = new Set();
336
+ for (let index = 1; index < args.length; index += 1) {
337
+ const raw = args[index];
338
+ const separator = raw.indexOf("=");
339
+ const flag = separator === -1 ? raw : raw.slice(0, separator);
340
+ const inline = separator === -1 ? undefined : raw.slice(separator + 1);
341
+ if (!new Set(["--repo", "--last", "--format", "--output"]).has(flag) || seen.has(flag)) {
342
+ stderr(`${seen.has(flag) ? `Pass ${flag} only once.` : `Unknown benchmark option: ${raw}`}\n\n${BENCHMARK_USAGE}`);
343
+ return 1;
344
+ }
345
+ seen.add(flag);
346
+ const following = args[index + 1];
347
+ const value = inline ?? (following && !following.startsWith("-") ? following : undefined);
348
+ if (inline === undefined && value !== undefined)
349
+ index += 1;
350
+ if (!value?.trim()) {
351
+ stderr(`${flag} requires a value.\n\n${BENCHMARK_USAGE}`);
352
+ return 1;
353
+ }
354
+ if (flag === "--repo")
355
+ repoRoot = expandHomePath(value.trim());
356
+ else if (flag === "--output")
357
+ output = expandHomePath(value.trim());
358
+ else if (flag === "--format") {
359
+ const normalized = value.trim().toLowerCase();
360
+ if (normalized !== "markdown" && normalized !== "json") {
361
+ stderr(`--format must be markdown or json.\n\n${BENCHMARK_USAGE}`);
362
+ return 1;
363
+ }
364
+ format = normalized;
365
+ }
366
+ else {
367
+ const parsed = Number(value);
368
+ if (!/^\d+$/.test(value) || !Number.isSafeInteger(parsed) || parsed < 1 || parsed > 100) {
369
+ stderr(`--last must be a whole number from 1 to 100.\n\n${BENCHMARK_USAGE}`);
370
+ return 1;
371
+ }
372
+ last = parsed;
373
+ }
374
+ }
375
+ if (/^https?:\/\//i.test(repoRoot)) {
376
+ stderr(`benchmark --repo needs a local Git checkout so history cutoffs can be enforced.\n\n${BENCHMARK_USAGE}`);
377
+ return 1;
378
+ }
379
+ try {
380
+ const benchmarkModule = dependencies.benchmarkRepository && dependencies.renderBenchmark
381
+ ? undefined
382
+ : await import("./benchmark.js");
383
+ const result = await (dependencies.benchmarkRepository ?? benchmarkModule.benchmarkRepository)({
384
+ repoRoot,
385
+ ...(last === undefined ? {} : { last }),
386
+ progress: (message) => {
387
+ if (progressRequested(process.env.FIXMAP_PROGRESS) || process.stderr.isTTY)
388
+ stderr(`${message}\n`);
389
+ }
390
+ });
391
+ const rendered = format === "json"
392
+ ? `${JSON.stringify(result, null, 2)}\n`
393
+ : (dependencies.renderBenchmark ?? benchmarkModule.renderRepositoryBenchmark)(result);
394
+ if (output)
395
+ await (dependencies.writeReport ?? ((path, contents) => writeFile(path, contents, "utf8")))(output, rendered);
396
+ else
397
+ stdout(rendered);
398
+ return 0;
399
+ }
400
+ catch (error) {
401
+ stderr(`${error instanceof Error ? error.message : String(error)}\n`);
402
+ return 1;
403
+ }
404
+ }
405
+ if (args[0] === "context") {
406
+ const { runContextCommand } = await import("./analysis-commands.js");
407
+ return runContextCommand(args.slice(1), {
408
+ stdout,
409
+ stderr,
410
+ ...(dependencies.writeReport ? { writeOutput: dependencies.writeReport } : {})
411
+ });
412
+ }
413
+ if (args[0] === "graph") {
414
+ const { runGraphCommand } = await import("./analysis-commands.js");
415
+ return runGraphCommand(args.slice(1), {
416
+ stdout,
417
+ stderr,
418
+ ...(dependencies.writeReport ? { writeOutput: dependencies.writeReport } : {})
419
+ });
420
+ }
421
+ if (args[0] === "watch") {
422
+ const { runWatchCommand } = await import("./watch-command.js");
423
+ return runWatchCommand(args.slice(1), {
424
+ stdout,
425
+ stderr,
426
+ watchRepository: dependencies.watchRepository,
427
+ renderWatchUpdate: dependencies.renderWatchUpdate
428
+ });
429
+ }
316
430
  if (args[0] === "doctor") {
317
431
  if (args[1] === "--help" || args[1] === "-h") {
318
432
  stdout(DOCTOR_USAGE);
@@ -621,7 +735,11 @@ export async function runCli(args, dependencies = {}) {
621
735
  : "\nComparison complete. Refine the task or inspect the files that entered, moved, or changed confidence, then rerun the plan.\n");
622
736
  return unresolvedChangeRequest ? 1 : 0;
623
737
  }
624
- const rendered = options.format === "json" ? renderJsonReport(report) : renderMarkdownReport(report);
738
+ const rendered = options.format === "json"
739
+ ? renderJsonReport(report)
740
+ : options.format === "agent"
741
+ ? renderAgentReport(report)
742
+ : renderMarkdownReport(report);
625
743
  if (options.output) {
626
744
  try {
627
745
  await (dependencies.writeReport ?? ((path, contents) => writeFile(path, contents, "utf8")))(options.output, rendered);
@@ -878,11 +996,11 @@ export function parseArgs(args) {
878
996
  else if (arg === "--format") {
879
997
  consumeValue();
880
998
  const normalized = value?.trim().toLowerCase();
881
- if (normalized === "markdown" || normalized === "json") {
999
+ if (normalized === "markdown" || normalized === "json" || normalized === "agent") {
882
1000
  format = normalized;
883
1001
  }
884
1002
  else {
885
- invalidValues.push(`--format received ${JSON.stringify(value ?? "(missing)")}; expected "markdown" or "json"`);
1003
+ invalidValues.push(`--format received ${JSON.stringify(value ?? "(missing)")}; expected "markdown", "json", or "agent"`);
886
1004
  }
887
1005
  }
888
1006
  else if (arg === "--report") {
@@ -1249,6 +1367,7 @@ async function runVerify(options, io) {
1249
1367
  workingTree: options.workingTree,
1250
1368
  includeUntracked: options.includeUntracked,
1251
1369
  useCache: !options.noCache,
1370
+ includeHistory: true,
1252
1371
  internalExclude: localPlanArtifactExclusions(options)
1253
1372
  });
1254
1373
  const unresolvedDiff = repo.diagnostics.find((diagnostic) => diagnostic.code === "diff-unavailable");