@aryam/fixmap 0.8.8 → 0.9.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/README.md +79 -4
- package/dist/agent-setup.d.ts +113 -0
- package/dist/agent-setup.js +369 -0
- package/dist/agent-setup.js.map +1 -0
- package/dist/analysis-commands.d.ts +11 -0
- package/dist/analysis-commands.js +186 -0
- package/dist/analysis-commands.js.map +1 -0
- package/dist/analysis-source.d.ts +23 -0
- package/dist/analysis-source.js +69 -0
- package/dist/analysis-source.js.map +1 -0
- package/dist/benchmark.d.ts +60 -0
- package/dist/benchmark.js +308 -0
- package/dist/benchmark.js.map +1 -0
- package/dist/cli-runner.d.ts +15 -3
- package/dist/cli-runner.js +618 -49
- package/dist/cli-runner.js.map +1 -1
- package/dist/doctor.d.ts +5 -0
- package/dist/doctor.js +56 -8
- package/dist/doctor.js.map +1 -1
- package/dist/explain-path.d.ts +3 -0
- package/dist/explain-path.js +28 -0
- package/dist/explain-path.js.map +1 -0
- package/dist/mcp.d.ts +8 -3
- package/dist/mcp.js +190 -35
- package/dist/mcp.js.map +1 -1
- package/dist/repository-source.d.ts +8 -2
- package/dist/repository-source.js +41 -8
- package/dist/repository-source.js.map +1 -1
- package/dist/watch-command.d.ts +7 -0
- package/dist/watch-command.js +141 -0
- package/dist/watch-command.js.map +1 -0
- package/dist/watch.d.ts +27 -0
- package/dist/watch.js +148 -0
- package/dist/watch.js.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type ContextPack, type FixMapGraph } from "@aryam/fixmap-core";
|
|
2
|
+
import { type AnalysisSourceInput, type AnalyzedRepository } from "./analysis-source.js";
|
|
3
|
+
type CommandIo = {
|
|
4
|
+
stdout: (text: string) => void;
|
|
5
|
+
stderr: (text: string) => void;
|
|
6
|
+
writeOutput?: (path: string, contents: string) => Promise<void>;
|
|
7
|
+
analyze?: (input: AnalysisSourceInput) => Promise<AnalyzedRepository>;
|
|
8
|
+
};
|
|
9
|
+
export declare function runContextCommand(args: string[], io: CommandIo): Promise<number>;
|
|
10
|
+
export declare function runGraphCommand(args: string[], io: CommandIo): Promise<number>;
|
|
11
|
+
export type { ContextPack, FixMapGraph };
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { writeFile } from "node:fs/promises";
|
|
2
|
+
import { homedir } from "node:os";
|
|
3
|
+
import { resolve } from "node:path";
|
|
4
|
+
import { buildFixMapGraph, renderContextPackMarkdown, renderFixMapGraphMermaid } from "@aryam/fixmap-core";
|
|
5
|
+
import { analyzeRepository, contextFromAnalysis } from "./analysis-source.js";
|
|
6
|
+
import { isSafeGitRefName, parseRepositorySource, tryParseGitHubIssueSource } from "./repository-source.js";
|
|
7
|
+
const CONTEXT_USAGE = `Usage: fixmap context --issue <text|public-url> [--repo <path|public-url>] [--budget <256-200000>] [--format markdown|json] [--output <file>]\n fixmap context --working-tree [--include-untracked] [--repo <local-path>] [--budget <tokens>]\n\nBuilds a deterministic, task-aware source package from primary and impact files. The budget applies to estimated source tokens; FixMap never executes repository code or calls a model.\n`;
|
|
8
|
+
const GRAPH_USAGE = `Usage: fixmap graph --issue <text|public-url> [--repo <path|public-url>] [--format mermaid|json] [--output <file>]\n fixmap graph --working-tree [--include-untracked] [--repo <local-path>]\n\nExports the evidence-backed Impact Graph as Mermaid or structured JSON.\n`;
|
|
9
|
+
export async function runContextCommand(args, io) {
|
|
10
|
+
if (args[0] === "--help" || args[0] === "-h") {
|
|
11
|
+
io.stdout(CONTEXT_USAGE);
|
|
12
|
+
return 0;
|
|
13
|
+
}
|
|
14
|
+
const options = parseAnalysisArgs(args, "context", io.stderr);
|
|
15
|
+
if (!options)
|
|
16
|
+
return 1;
|
|
17
|
+
try {
|
|
18
|
+
const analysis = await (io.analyze ?? analyzeRepository)({ ...options, internalExclude: options.output ? [options.output] : [] });
|
|
19
|
+
const pack = contextFromAnalysis(analysis, options.budget);
|
|
20
|
+
const rendered = options.format === "json" ? `${JSON.stringify(pack, null, 2)}\n` : renderContextPackMarkdown(pack);
|
|
21
|
+
await emit(rendered, options.output, io);
|
|
22
|
+
return pack.snippets.length > 0 ? 0 : 1;
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
io.stderr(`${error instanceof Error ? error.message : String(error)}\n`);
|
|
26
|
+
return 1;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export async function runGraphCommand(args, io) {
|
|
30
|
+
if (args[0] === "--help" || args[0] === "-h") {
|
|
31
|
+
io.stdout(GRAPH_USAGE);
|
|
32
|
+
return 0;
|
|
33
|
+
}
|
|
34
|
+
const options = parseAnalysisArgs(args, "graph", io.stderr);
|
|
35
|
+
if (!options)
|
|
36
|
+
return 1;
|
|
37
|
+
try {
|
|
38
|
+
const analysis = await (io.analyze ?? analyzeRepository)({ ...options, internalExclude: options.output ? [options.output] : [] });
|
|
39
|
+
const graph = buildFixMapGraph(analysis.report);
|
|
40
|
+
const rendered = options.format === "json" ? `${JSON.stringify(graph, null, 2)}\n` : renderFixMapGraphMermaid(graph);
|
|
41
|
+
await emit(rendered, options.output, io);
|
|
42
|
+
return graph.nodes.length > 0 ? 0 : 1;
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
io.stderr(`${error instanceof Error ? error.message : String(error)}\n`);
|
|
46
|
+
return 1;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function parseAnalysisArgs(args, command, stderr) {
|
|
50
|
+
const usage = command === "context" ? CONTEXT_USAGE : GRAPH_USAGE;
|
|
51
|
+
const valueFlags = new Set([
|
|
52
|
+
"--issue", "--repo", "--ref", "--format", "--output", "--limit", "--exclude", "--diff", "--base", "--head",
|
|
53
|
+
...(command === "context" ? ["--budget"] : [])
|
|
54
|
+
]);
|
|
55
|
+
const booleanFlags = new Set(["--working-tree", "--include-untracked", "--no-cache"]);
|
|
56
|
+
const seen = new Set();
|
|
57
|
+
const options = {
|
|
58
|
+
format: command === "context" ? "markdown" : "mermaid",
|
|
59
|
+
budget: 10_000,
|
|
60
|
+
useCache: true,
|
|
61
|
+
exclude: []
|
|
62
|
+
};
|
|
63
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
64
|
+
const raw = args[index];
|
|
65
|
+
const separator = raw.indexOf("=");
|
|
66
|
+
const flag = separator === -1 ? raw : raw.slice(0, separator);
|
|
67
|
+
const inline = separator === -1 ? undefined : raw.slice(separator + 1);
|
|
68
|
+
if (!valueFlags.has(flag) && !booleanFlags.has(flag)) {
|
|
69
|
+
stderr(`Unknown ${command} option: ${raw}\n\n${usage}`);
|
|
70
|
+
return undefined;
|
|
71
|
+
}
|
|
72
|
+
if (flag !== "--exclude" && seen.has(flag)) {
|
|
73
|
+
stderr(`Pass ${flag} only once.\n\n${usage}`);
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
76
|
+
seen.add(flag);
|
|
77
|
+
if (booleanFlags.has(flag)) {
|
|
78
|
+
if (inline !== undefined) {
|
|
79
|
+
stderr(`${flag} does not take a value.\n\n${usage}`);
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
if (flag === "--working-tree")
|
|
83
|
+
options.workingTree = true;
|
|
84
|
+
else if (flag === "--include-untracked")
|
|
85
|
+
options.includeUntracked = true;
|
|
86
|
+
else
|
|
87
|
+
options.useCache = false;
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
const following = args[index + 1];
|
|
91
|
+
const value = inline ?? (following && !following.startsWith("-") ? following : undefined);
|
|
92
|
+
if (inline === undefined && value !== undefined)
|
|
93
|
+
index += 1;
|
|
94
|
+
if (!value?.trim()) {
|
|
95
|
+
stderr(`${flag} requires a value.\n\n${usage}`);
|
|
96
|
+
return undefined;
|
|
97
|
+
}
|
|
98
|
+
const normalized = value.trim();
|
|
99
|
+
if (flag === "--issue")
|
|
100
|
+
options.issueText = normalized;
|
|
101
|
+
else if (flag === "--repo")
|
|
102
|
+
options.repo = expandHomePath(normalized);
|
|
103
|
+
else if (flag === "--ref") {
|
|
104
|
+
if (!isSafeGitRefName(normalized)) {
|
|
105
|
+
stderr(`--ref requires a safe branch or tag name.\n\n${usage}`);
|
|
106
|
+
return undefined;
|
|
107
|
+
}
|
|
108
|
+
options.checkoutRef = normalized;
|
|
109
|
+
}
|
|
110
|
+
else if (flag === "--output")
|
|
111
|
+
options.output = expandHomePath(normalized);
|
|
112
|
+
else if (flag === "--diff")
|
|
113
|
+
options.diffSpec = normalized;
|
|
114
|
+
else if (flag === "--base")
|
|
115
|
+
options.baseRef = normalized;
|
|
116
|
+
else if (flag === "--head")
|
|
117
|
+
options.headRef = normalized;
|
|
118
|
+
else if (flag === "--exclude")
|
|
119
|
+
options.exclude.push(normalized);
|
|
120
|
+
else if (flag === "--format")
|
|
121
|
+
options.format = normalized.toLowerCase();
|
|
122
|
+
else {
|
|
123
|
+
const parsed = Number(normalized);
|
|
124
|
+
const minimum = flag === "--budget" ? 256 : 1;
|
|
125
|
+
const maximum = flag === "--budget" ? 200_000 : 20;
|
|
126
|
+
if (!/^\d+$/.test(normalized) || !Number.isSafeInteger(parsed) || parsed < minimum || parsed > maximum) {
|
|
127
|
+
stderr(`${flag} must be a whole number from ${minimum} to ${maximum}.\n\n${usage}`);
|
|
128
|
+
return undefined;
|
|
129
|
+
}
|
|
130
|
+
if (flag === "--budget")
|
|
131
|
+
options.budget = parsed;
|
|
132
|
+
else
|
|
133
|
+
options.limit = parsed;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
const formats = command === "context" ? ["markdown", "json"] : ["mermaid", "json"];
|
|
137
|
+
if (!formats.includes(options.format)) {
|
|
138
|
+
stderr(`--format must be ${formats.join(" or ")}.\n\n${usage}`);
|
|
139
|
+
return undefined;
|
|
140
|
+
}
|
|
141
|
+
if (!options.issueText && !options.diffSpec && !options.baseRef && !options.workingTree) {
|
|
142
|
+
stderr(`${command} needs --issue, --diff, --base/--head, or --working-tree.\n\n${usage}`);
|
|
143
|
+
return undefined;
|
|
144
|
+
}
|
|
145
|
+
if (options.includeUntracked && !options.workingTree) {
|
|
146
|
+
stderr(`--include-untracked only applies with --working-tree.\n\n${usage}`);
|
|
147
|
+
return undefined;
|
|
148
|
+
}
|
|
149
|
+
if (options.workingTree && (options.diffSpec || options.baseRef || options.headRef)) {
|
|
150
|
+
stderr(`Use either --working-tree or --diff/--base, not both.\n\n${usage}`);
|
|
151
|
+
return undefined;
|
|
152
|
+
}
|
|
153
|
+
if (options.diffSpec && (options.baseRef || options.headRef)) {
|
|
154
|
+
stderr(`Use either --diff or --base/--head, not both.\n\n${usage}`);
|
|
155
|
+
return undefined;
|
|
156
|
+
}
|
|
157
|
+
if (options.headRef && !options.baseRef) {
|
|
158
|
+
stderr(`--head requires --base.\n\n${usage}`);
|
|
159
|
+
return undefined;
|
|
160
|
+
}
|
|
161
|
+
if (options.checkoutRef) {
|
|
162
|
+
const inferredRepository = options.issueText
|
|
163
|
+
? tryParseGitHubIssueSource(options.issueText)?.repositoryUrl
|
|
164
|
+
: undefined;
|
|
165
|
+
const repository = parseRepositorySource(options.repo ?? inferredRepository ?? process.cwd());
|
|
166
|
+
if (repository.kind !== "github") {
|
|
167
|
+
stderr(`--ref only applies when --repo is a remote GitHub URL or the issue URL infers one.\n\n${usage}`);
|
|
168
|
+
return undefined;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return options;
|
|
172
|
+
}
|
|
173
|
+
async function emit(contents, output, io) {
|
|
174
|
+
if (output)
|
|
175
|
+
await (io.writeOutput ?? ((path, text) => writeFile(path, text, "utf8")))(output, contents);
|
|
176
|
+
else
|
|
177
|
+
io.stdout(contents);
|
|
178
|
+
}
|
|
179
|
+
function expandHomePath(path) {
|
|
180
|
+
if (path === "~")
|
|
181
|
+
return homedir();
|
|
182
|
+
if (path.startsWith("~/") || path.startsWith("~\\"))
|
|
183
|
+
return resolve(homedir(), path.slice(2));
|
|
184
|
+
return path;
|
|
185
|
+
}
|
|
186
|
+
//# sourceMappingURL=analysis-commands.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O,CAAC,OAAO,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9F,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type ContextPack, type FixMapReport, type RepoMap } from "@aryam/fixmap-core";
|
|
2
|
+
import { type RepositorySourceDependencies } from "./repository-source.js";
|
|
3
|
+
export type AnalysisSourceInput = {
|
|
4
|
+
repo?: string | undefined;
|
|
5
|
+
issueText?: string | undefined;
|
|
6
|
+
diffSpec?: string | undefined;
|
|
7
|
+
baseRef?: string | undefined;
|
|
8
|
+
headRef?: string | undefined;
|
|
9
|
+
checkoutRef?: string | undefined;
|
|
10
|
+
workingTree?: boolean | undefined;
|
|
11
|
+
includeUntracked?: boolean | undefined;
|
|
12
|
+
useCache?: boolean | undefined;
|
|
13
|
+
limit?: number | undefined;
|
|
14
|
+
exclude?: string[] | undefined;
|
|
15
|
+
internalExclude?: string[] | undefined;
|
|
16
|
+
};
|
|
17
|
+
export type AnalyzedRepository = {
|
|
18
|
+
task: string;
|
|
19
|
+
report: FixMapReport;
|
|
20
|
+
repo: RepoMap;
|
|
21
|
+
};
|
|
22
|
+
export declare function analyzeRepository(input: AnalysisSourceInput, dependencies?: RepositorySourceDependencies): Promise<AnalyzedRepository>;
|
|
23
|
+
export declare function contextFromAnalysis(analysis: AnalyzedRepository, budgetTokens: number): ContextPack;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { buildFixMapAnalysis, buildContextPack } from "@aryam/fixmap-core";
|
|
2
|
+
import { fetchPublicGitHubIssue, findLocalGitHubRepositoryUrl, parseGitHubIssueSource, parseRepositorySource, RepositorySourceError, withRepositorySource } from "./repository-source.js";
|
|
3
|
+
const MAX_ISSUE_BODY_CHARS = 20_000;
|
|
4
|
+
export async function analyzeRepository(input, dependencies = {}) {
|
|
5
|
+
const issueSource = input.issueText ? parseGitHubIssueSource(input.issueText) : undefined;
|
|
6
|
+
const source = parseRepositorySource(input.repo ?? issueSource?.repositoryUrl ?? process.cwd());
|
|
7
|
+
const localRepositoryUrl = issueSource && source.kind === "local"
|
|
8
|
+
? await findLocalGitHubRepositoryUrl(source.repoRoot)
|
|
9
|
+
: undefined;
|
|
10
|
+
if (issueSource &&
|
|
11
|
+
((source.kind === "github" && source.displayUrl.toLowerCase() !== issueSource.repositoryUrl.toLowerCase()) ||
|
|
12
|
+
(source.kind === "local" && localRepositoryUrl && localRepositoryUrl.toLowerCase() !== issueSource.repositoryUrl.toLowerCase()))) {
|
|
13
|
+
const actualRepository = source.kind === "github" ? source.displayUrl : localRepositoryUrl;
|
|
14
|
+
throw new RepositorySourceError(`GitHub issue "${issueSource.displayUrl}" belongs to ${issueSource.repositoryUrl}, ` +
|
|
15
|
+
`but the scanned repository is ${actualRepository}. Remove --repo or use the matching repository.`);
|
|
16
|
+
}
|
|
17
|
+
if (source.kind === "github" &&
|
|
18
|
+
(input.diffSpec !== undefined || input.baseRef !== undefined || input.headRef !== undefined || input.workingTree || input.includeUntracked)) {
|
|
19
|
+
throw new RepositorySourceError("Git diff and working-tree options need a local checkout. A GitHub URL is fetched as a " +
|
|
20
|
+
"single-commit shallow clone of the selected branch, so it has no history for a diff range " +
|
|
21
|
+
"to resolve against and no working tree to compare. Clone the repository and pass --repo " +
|
|
22
|
+
"with a local path, or use --issue alone.");
|
|
23
|
+
}
|
|
24
|
+
let task = input.issueText ?? "";
|
|
25
|
+
let issueDiagnostic;
|
|
26
|
+
if (issueSource) {
|
|
27
|
+
const issue = await (dependencies.fetchPublicIssue ?? fetchPublicGitHubIssue)(issueSource);
|
|
28
|
+
const body = issue.body.slice(0, MAX_ISSUE_BODY_CHARS);
|
|
29
|
+
task = [issue.title, body].filter(Boolean).join("\n\n");
|
|
30
|
+
issueDiagnostic = {
|
|
31
|
+
code: issueSource.isPullRequest ? "remote-pull-fetched" : "remote-issue-fetched",
|
|
32
|
+
severity: "info",
|
|
33
|
+
message: `Fetched ${issueSource.displayUrl} anonymously for context selection.`
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
return withRepositorySource(source, async (resolved) => {
|
|
37
|
+
const { report, repo } = await buildFixMapAnalysis({
|
|
38
|
+
repoRoot: resolved.repoRoot,
|
|
39
|
+
issueText: task,
|
|
40
|
+
diffSpec: input.diffSpec,
|
|
41
|
+
baseRef: input.baseRef,
|
|
42
|
+
headRef: input.headRef,
|
|
43
|
+
workingTree: input.workingTree,
|
|
44
|
+
includeUntracked: input.includeUntracked,
|
|
45
|
+
useCache: input.useCache,
|
|
46
|
+
includeHistory: true,
|
|
47
|
+
limit: input.limit,
|
|
48
|
+
exclude: input.exclude,
|
|
49
|
+
internalExclude: input.internalExclude
|
|
50
|
+
});
|
|
51
|
+
report.diagnostics.unshift(...[issueDiagnostic, resolved.diagnostic].filter((entry) => entry !== undefined));
|
|
52
|
+
return { task, report, repo };
|
|
53
|
+
}, dependencies, (result, cleanupError, temporaryRoot) => {
|
|
54
|
+
result.report.diagnostics.push({
|
|
55
|
+
code: "remote-checkout-cleanup-failed",
|
|
56
|
+
severity: "warning",
|
|
57
|
+
message: `Analysis completed, but temporary checkout "${temporaryRoot}" could not be removed: ${cleanupError instanceof Error ? cleanupError.message : String(cleanupError)}.`
|
|
58
|
+
});
|
|
59
|
+
}, input.checkoutRef);
|
|
60
|
+
}
|
|
61
|
+
export function contextFromAnalysis(analysis, budgetTokens) {
|
|
62
|
+
return buildContextPack({
|
|
63
|
+
report: analysis.report,
|
|
64
|
+
repo: analysis.repo,
|
|
65
|
+
task: analysis.task,
|
|
66
|
+
budgetTokens
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=analysis-source.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analysis-source.js","sourceRoot":"","sources":["../src/analysis-source.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAKjB,MAAM,oBAAoB,CAAC;AAC5B,O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
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 {};
|