@granular-software/fractory 0.0.0-stage → 0.1.24
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/LICENSE +4 -0
- package/README.md +28 -2
- package/dist/activity-volume.d.ts +18 -0
- package/dist/activity-volume.js +94 -0
- package/dist/annotations.d.ts +118 -0
- package/dist/annotations.js +304 -0
- package/dist/benchmark-cli.d.ts +1 -0
- package/dist/benchmark-cli.js +95 -0
- package/dist/benchmark-worker.d.ts +2 -0
- package/dist/benchmark-worker.js +22 -0
- package/dist/benchmarks.d.ts +19 -0
- package/dist/benchmarks.js +414 -0
- package/dist/bin.d.ts +2 -0
- package/dist/bin.js +63 -0
- package/dist/block-cli.d.ts +1 -0
- package/dist/block-cli.js +88 -0
- package/dist/block-documents.d.ts +35 -0
- package/dist/block-documents.js +84 -0
- package/dist/change-impact.d.ts +55 -0
- package/dist/change-impact.js +223 -0
- package/dist/check-source.d.ts +2 -0
- package/dist/check-source.js +66 -0
- package/dist/checks-model.d.ts +64 -0
- package/dist/checks-model.js +36 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +359 -0
- package/dist/code-model.d.ts +38 -0
- package/dist/code-model.js +94 -0
- package/dist/code-store.d.ts +9 -0
- package/dist/code-store.js +79 -0
- package/dist/compare-artifact.d.ts +6 -0
- package/dist/compare-artifact.js +277 -0
- package/dist/compare.d.ts +81 -0
- package/dist/compare.js +291 -0
- package/dist/compiler.d.ts +10 -0
- package/dist/compiler.js +1083 -0
- package/dist/compose.d.ts +9 -0
- package/dist/compose.js +72 -0
- package/dist/core.d.ts +86 -0
- package/dist/core.js +206 -0
- package/dist/coverage-cli.d.ts +1 -0
- package/dist/coverage-cli.js +42 -0
- package/dist/declaration-sources.d.ts +3 -0
- package/dist/declaration-sources.js +51 -0
- package/dist/declared-graph.d.ts +3 -0
- package/dist/declared-graph.js +66 -0
- package/dist/display-name.d.ts +2 -0
- package/dist/display-name.js +8 -0
- package/dist/error-heat.d.ts +58 -0
- package/dist/error-heat.js +96 -0
- package/dist/evidence.d.ts +3 -0
- package/dist/evidence.js +68 -0
- package/dist/factory-graph.d.ts +4 -0
- package/dist/factory-graph.js +318 -0
- package/dist/factory-model.d.ts +97 -0
- package/dist/factory-model.js +1 -0
- package/dist/git-code.d.ts +47 -0
- package/dist/git-code.js +352 -0
- package/dist/git-refs.d.ts +4 -0
- package/dist/git-refs.js +37 -0
- package/dist/history-activity.d.ts +4 -0
- package/dist/history-activity.js +129 -0
- package/dist/history-churn.d.ts +36 -0
- package/dist/history-churn.js +302 -0
- package/dist/history-git.d.ts +21 -0
- package/dist/history-git.js +125 -0
- package/dist/history-ledger.d.ts +43 -0
- package/dist/history-ledger.js +450 -0
- package/dist/history-ownership.d.ts +10 -0
- package/dist/history-ownership.js +75 -0
- package/dist/history-source.d.ts +13 -0
- package/dist/history-source.js +100 -0
- package/dist/integrations-cli.d.ts +2 -0
- package/dist/integrations-cli.js +159 -0
- package/dist/issue-cache.d.ts +9 -0
- package/dist/issue-cache.js +68 -0
- package/dist/issue-cli.d.ts +1 -0
- package/dist/issue-cli.js +89 -0
- package/dist/issue-links.d.ts +15 -0
- package/dist/issue-links.js +125 -0
- package/dist/linear-issues.d.ts +19 -0
- package/dist/linear-issues.js +124 -0
- package/dist/local-runtime.d.ts +8 -0
- package/dist/local-runtime.js +59 -0
- package/dist/map-activity.d.ts +73 -0
- package/dist/map-activity.js +234 -0
- package/dist/map-model.d.ts +5 -0
- package/dist/map-model.js +166 -0
- package/dist/map-quality.d.ts +14 -0
- package/dist/map-quality.js +56 -0
- package/dist/mapping-coverage.d.ts +87 -0
- package/dist/mapping-coverage.js +404 -0
- package/dist/model.d.ts +182 -0
- package/dist/model.js +66 -0
- package/dist/operation-benchmark-worker.d.ts +2 -0
- package/dist/operation-benchmark-worker.js +60 -0
- package/dist/operation-benchmark.d.ts +29 -0
- package/dist/operation-benchmark.js +1 -0
- package/dist/otel-metrics.d.ts +21 -0
- package/dist/otel-metrics.js +146 -0
- package/dist/performance-model.d.ts +185 -0
- package/dist/performance-model.js +396 -0
- package/dist/product-map.d.ts +69 -0
- package/dist/product-map.js +168 -0
- package/dist/provider-access.cjs +207 -0
- package/dist/provider-access.d.cts +14 -0
- package/dist/reports-cli.d.ts +1 -0
- package/dist/reports-cli.js +111 -0
- package/dist/reports-model.d.ts +27 -0
- package/dist/reports-model.js +39 -0
- package/dist/reports.d.ts +23 -0
- package/dist/reports.js +223 -0
- package/dist/repository-map.d.ts +22 -0
- package/dist/repository-map.js +151 -0
- package/dist/resource-cache.d.ts +17 -0
- package/dist/resource-cache.js +65 -0
- package/dist/review-cli.d.ts +19 -0
- package/dist/review-cli.js +224 -0
- package/dist/review.d.ts +48 -0
- package/dist/review.js +289 -0
- package/dist/runtime-metrics.d.ts +26 -0
- package/dist/runtime-metrics.js +290 -0
- package/dist/scope.d.ts +12 -0
- package/dist/scope.js +94 -0
- package/dist/sentry-activity.d.ts +39 -0
- package/dist/sentry-activity.js +174 -0
- package/dist/sentry.d.ts +130 -0
- package/dist/sentry.js +369 -0
- package/dist/service-release.d.ts +16 -0
- package/dist/service-release.js +14 -0
- package/dist/setup-cli.d.ts +2 -0
- package/dist/setup-cli.js +52 -0
- package/dist/setup-kit.cjs +163 -0
- package/dist/setup-kit.d.cts +32 -0
- package/dist/source-index.d.ts +37 -0
- package/dist/source-index.js +166 -0
- package/dist/source-review-git.d.ts +7 -0
- package/dist/source-review-git.js +103 -0
- package/dist/source-review.d.ts +16 -0
- package/dist/source-review.js +493 -0
- package/dist/telemetry.d.ts +17 -0
- package/dist/telemetry.js +51 -0
- package/dist/time-window.d.ts +9 -0
- package/dist/time-window.js +35 -0
- package/dist/trace-evidence.d.ts +23 -0
- package/dist/trace-evidence.js +55 -0
- package/dist/trace-model.d.ts +26 -0
- package/dist/trace-model.js +1 -0
- package/dist/tracing.d.ts +44 -0
- package/dist/tracing.js +123 -0
- package/dist/work-check.d.ts +17 -0
- package/dist/work-check.js +110 -0
- package/dist/work-cli.d.ts +1 -0
- package/dist/work-cli.js +148 -0
- package/dist/work-context.d.ts +57 -0
- package/dist/work-context.js +568 -0
- package/dist/work-intents.d.ts +6 -0
- package/dist/work-intents.js +140 -0
- package/dist/work-items.d.ts +58 -0
- package/dist/work-items.js +86 -0
- package/dist/work-model.d.ts +110 -0
- package/dist/work-model.js +261 -0
- package/dist/work-review-git.d.ts +8 -0
- package/dist/work-review-git.js +111 -0
- package/dist/work-review.d.ts +26 -0
- package/dist/work-review.js +426 -0
- package/dist/work-switcher-model.d.ts +43 -0
- package/dist/work-switcher-model.js +79 -0
- package/dist/work-switcher.d.ts +6 -0
- package/dist/work-switcher.js +171 -0
- package/dist/working-cli.d.ts +1 -0
- package/dist/working-cli.js +33 -0
- package/dist/working-code.d.ts +74 -0
- package/dist/working-code.js +421 -0
- package/dist/workspace-notes.d.ts +71 -0
- package/dist/workspace-notes.js +177 -0
- package/dist/workspace-tests.d.ts +21 -0
- package/dist/workspace-tests.js +573 -0
- package/package.json +547 -4
- package/src/activity-volume.ts +149 -0
- package/src/annotations.ts +481 -0
- package/src/benchmark-cli.ts +118 -0
- package/src/benchmark-worker.ts +22 -0
- package/src/benchmarks.ts +493 -0
- package/src/bin.ts +54 -0
- package/src/block-cli.ts +106 -0
- package/src/block-documents.ts +117 -0
- package/src/change-impact.ts +280 -0
- package/src/check-source.ts +82 -0
- package/src/checks-model.ts +108 -0
- package/src/cli.ts +440 -0
- package/src/code-model.ts +159 -0
- package/src/code-store.ts +98 -0
- package/src/compare-artifact.ts +314 -0
- package/src/compare.ts +440 -0
- package/src/compiler.ts +1326 -0
- package/src/compose.ts +94 -0
- package/src/core.ts +357 -0
- package/src/coverage-cli.ts +52 -0
- package/src/declaration-sources.ts +69 -0
- package/src/declared-graph.ts +74 -0
- package/src/display-name.ts +8 -0
- package/src/error-heat.ts +161 -0
- package/src/evidence.ts +94 -0
- package/src/factory-graph.ts +378 -0
- package/src/factory-model.ts +73 -0
- package/src/git-code.ts +461 -0
- package/src/git-refs.ts +43 -0
- package/src/history-activity.ts +146 -0
- package/src/history-churn.ts +416 -0
- package/src/history-git.ts +163 -0
- package/src/history-ledger.ts +636 -0
- package/src/history-ownership.ts +116 -0
- package/src/history-source.ts +117 -0
- package/src/integrations-cli.ts +187 -0
- package/src/issue-cache.ts +96 -0
- package/src/issue-cli.ts +137 -0
- package/src/issue-links.ts +153 -0
- package/src/linear-issues.ts +154 -0
- package/src/local-runtime.ts +70 -0
- package/src/map-activity.ts +309 -0
- package/src/map-model.ts +213 -0
- package/src/map-quality.ts +61 -0
- package/src/mapping-coverage.ts +570 -0
- package/src/model.ts +221 -0
- package/src/operation-benchmark-worker.ts +60 -0
- package/src/operation-benchmark.ts +28 -0
- package/src/otel-metrics.ts +176 -0
- package/src/performance-model.ts +575 -0
- package/src/product-map.ts +236 -0
- package/src/provider-access.cjs +207 -0
- package/src/provider-access.d.cts +14 -0
- package/src/reports-cli.ts +125 -0
- package/src/reports-model.ts +73 -0
- package/src/reports.ts +276 -0
- package/src/repository-map.ts +189 -0
- package/src/resource-cache.ts +76 -0
- package/src/review-cli.ts +256 -0
- package/src/review.ts +376 -0
- package/src/runtime-metrics.ts +386 -0
- package/src/scope.ts +103 -0
- package/src/sentry-activity.ts +234 -0
- package/src/sentry.ts +545 -0
- package/src/service-release.ts +18 -0
- package/src/setup-cli.ts +58 -0
- package/src/setup-kit.cjs +163 -0
- package/src/setup-kit.d.cts +32 -0
- package/src/source-index.ts +205 -0
- package/src/source-review-git.ts +129 -0
- package/src/source-review.ts +637 -0
- package/src/telemetry.ts +68 -0
- package/src/time-window.ts +51 -0
- package/src/trace-evidence.ts +80 -0
- package/src/trace-model.ts +26 -0
- package/src/tracing.ts +165 -0
- package/src/work-check.ts +143 -0
- package/src/work-cli.ts +195 -0
- package/src/work-context.ts +713 -0
- package/src/work-intents.ts +196 -0
- package/src/work-items.ts +151 -0
- package/src/work-model.ts +400 -0
- package/src/work-review-git.ts +130 -0
- package/src/work-review.ts +573 -0
- package/src/work-switcher-model.ts +121 -0
- package/src/work-switcher.ts +191 -0
- package/src/working-cli.ts +38 -0
- package/src/working-code.ts +582 -0
- package/src/workspace-notes.ts +203 -0
- package/src/workspace-tests.ts +654 -0
- package/toolkit/GUIDE.md +305 -0
- package/toolkit/SKILL.md +131 -0
- package/toolkit/bin/fractory +2 -0
- package/toolkit/build.json +1 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { readRepositoryMap } from "./repository-map";
|
|
2
|
+
import { resolve, join } from "node:path";
|
|
3
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
4
|
+
import { BenchmarkRunner } from "./benchmarks";
|
|
5
|
+
import {
|
|
6
|
+
compareBenchmark,
|
|
7
|
+
benchmarkComparisonReason,
|
|
8
|
+
durationLabel,
|
|
9
|
+
} from "./performance-model";
|
|
10
|
+
import type { DefinitionGraph } from "./model";
|
|
11
|
+
export async function runBenchmark(args: string[]) {
|
|
12
|
+
if (args.includes("--help"))
|
|
13
|
+
return "fractal benchmark [--block ID] [--file PATH] [--run] [--baseline RUN_ID] [--functions] [--compare RUN --against REFERENCE] [--json] [--root PATH]\nRuns attached product operations on their configured test deployment. --functions includes local Tinybench checks. Measurements are separate from production metrics.";
|
|
14
|
+
const option = (key: string) => {
|
|
15
|
+
const i = args.indexOf(key);
|
|
16
|
+
if (i < 0) return undefined;
|
|
17
|
+
if (!args[i + 1] || args[i + 1].startsWith("--"))
|
|
18
|
+
throw Error(key + " needs a value");
|
|
19
|
+
return args[i + 1];
|
|
20
|
+
};
|
|
21
|
+
const root = resolve(option("--root") || process.cwd());
|
|
22
|
+
const graph = readRepositoryMap(root);
|
|
23
|
+
if (!graph)
|
|
24
|
+
throw Error("No Fractory map in this repository. Run fractory setup.");
|
|
25
|
+
const runner = new BenchmarkRunner(root, graph),
|
|
26
|
+
block = option("--block"),
|
|
27
|
+
file = option("--file");
|
|
28
|
+
if (option("--baseline")) runner.baseline(option("--baseline")!);
|
|
29
|
+
if (option("--compare")) {
|
|
30
|
+
const view = runner.view(),
|
|
31
|
+
current = view.runs.find((r) => r.id === option("--compare")),
|
|
32
|
+
baseline = view.runs.find((r) => r.id === option("--against"));
|
|
33
|
+
if (!current || !baseline)
|
|
34
|
+
throw Error(
|
|
35
|
+
"Choose two recorded run IDs with --compare RUN --against REFERENCE.",
|
|
36
|
+
);
|
|
37
|
+
return JSON.stringify(
|
|
38
|
+
{
|
|
39
|
+
operation: current.file,
|
|
40
|
+
current: {
|
|
41
|
+
id: current.id,
|
|
42
|
+
target: current.target,
|
|
43
|
+
fixture: current.fixture,
|
|
44
|
+
status: current.status,
|
|
45
|
+
},
|
|
46
|
+
reference: {
|
|
47
|
+
id: baseline.id,
|
|
48
|
+
target: baseline.target,
|
|
49
|
+
fixture: baseline.fixture,
|
|
50
|
+
status: baseline.status,
|
|
51
|
+
},
|
|
52
|
+
sameDeployedRevision:
|
|
53
|
+
!!current.target &&
|
|
54
|
+
current.target.revision === baseline.target?.revision,
|
|
55
|
+
cases: current.cases.map((c) => ({
|
|
56
|
+
name: c.name,
|
|
57
|
+
currentMeanMs: c.meanMs,
|
|
58
|
+
referenceMeanMs: baseline.cases.find((b) => b.name === c.name)
|
|
59
|
+
?.meanMs,
|
|
60
|
+
result: compareBenchmark(current, baseline, c.name),
|
|
61
|
+
reason: benchmarkComparisonReason(current, baseline, c.name),
|
|
62
|
+
})),
|
|
63
|
+
},
|
|
64
|
+
null,
|
|
65
|
+
2,
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
const ids = new Set([block || graph.id]);
|
|
69
|
+
for (let added = true; added; ) {
|
|
70
|
+
added = false;
|
|
71
|
+
for (const node of graph.elements)
|
|
72
|
+
if (node.parent && ids.has(node.parent) && !ids.has(node.id)) {
|
|
73
|
+
ids.add(node.id);
|
|
74
|
+
added = true;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
const plans = runner
|
|
78
|
+
.view()
|
|
79
|
+
.plans.filter(
|
|
80
|
+
(plan) =>
|
|
81
|
+
(file || args.includes("--functions") || plan.kind === "operation") &&
|
|
82
|
+
(!file || plan.file === file) &&
|
|
83
|
+
plan.blocks.some((id) => ids.has(id)),
|
|
84
|
+
);
|
|
85
|
+
if (
|
|
86
|
+
(block && !graph.elements.some((node) => node.id === block)) ||
|
|
87
|
+
(file && !plans.length)
|
|
88
|
+
)
|
|
89
|
+
throw Error("Choose a mapped block and an attached benchmark.");
|
|
90
|
+
if (args.includes("--run"))
|
|
91
|
+
for (const plan of plans) {
|
|
92
|
+
const started = runner.start(plan.file);
|
|
93
|
+
const finished = await runner.wait(started.id);
|
|
94
|
+
if (finished.status !== "passed") process.exitCode = 1;
|
|
95
|
+
}
|
|
96
|
+
const view = runner.view();
|
|
97
|
+
const result = plans.map((plan) => {
|
|
98
|
+
const current = view.runs.find((run) => run.file === plan.file),
|
|
99
|
+
baseline = view.runs.find((run) => run.id === view.baselines[plan.file]);
|
|
100
|
+
return {
|
|
101
|
+
...plan,
|
|
102
|
+
current,
|
|
103
|
+
baseline: baseline?.id,
|
|
104
|
+
comparison: current?.cases.map((item) => ({
|
|
105
|
+
name: item.name,
|
|
106
|
+
change: compareBenchmark(current, baseline, item.name),
|
|
107
|
+
})),
|
|
108
|
+
};
|
|
109
|
+
});
|
|
110
|
+
return args.includes("--json")
|
|
111
|
+
? JSON.stringify(result, null, 2)
|
|
112
|
+
: result
|
|
113
|
+
.map(
|
|
114
|
+
({ label, file, current, baseline, kind }) =>
|
|
115
|
+
`${label}\n${file}\n${current ? `${current.status} · ${current.id}${baseline === current.id ? " · baseline" : ""}\n${current.error || current.cases.map((item) => `${item.name}: ${durationLabel(item.meanMs)} ±${durationLabel(item.marginMs)} · ${item.samples} ${kind === "operation" ? "attempts" : "samples"}`).join("\n")}${current.target ? `\n${current.target.name} · ${current.target.revision.slice(0, 8)} · ${current.target.measurement} timing` : ""}` : "Not run"}`,
|
|
116
|
+
)
|
|
117
|
+
.join("\n\n");
|
|
118
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** Isolated Bun entrypoint; application code is loaded only after an explicit run. */
|
|
2
|
+
export const benchmarkWorker = `
|
|
3
|
+
import { writeFileSync } from 'node:fs';
|
|
4
|
+
import { pathToFileURL } from 'node:url';
|
|
5
|
+
const [file, report] = process.argv.slice(1);
|
|
6
|
+
try {
|
|
7
|
+
const { default: bench } = await import(pathToFileURL(file).href);
|
|
8
|
+
if (!bench || typeof bench.run !== 'function' || typeof bench.warmup !== 'function' || !Array.isArray(bench.tasks)) throw Error('Export a Tinybench Bench instance as default.');
|
|
9
|
+
if (bench.tasks.length < 1 || bench.tasks.length > 12) throw Error('Keep each suite between 1 and 12 cases.');
|
|
10
|
+
bench.time = Math.max(100, Math.min(1000, bench.time || 250));
|
|
11
|
+
bench.iterations = Math.max(20, Math.min(100000, bench.iterations || 20));
|
|
12
|
+
bench.warmupTime = 100; bench.warmupIterations = 20;
|
|
13
|
+
await bench.warmup(); await bench.run();
|
|
14
|
+
const cases = bench.tasks.map(task => {
|
|
15
|
+
const r = task.result; if (r?.error) throw r.error;
|
|
16
|
+
if (!r || !Number.isFinite(r.mean) || r.mean <= 0 || !r.samples.length) throw Error('No valid timing samples for ' + task.name);
|
|
17
|
+
const sorted = [...r.samples].sort((a,b) => a-b);
|
|
18
|
+
return { name: task.name, samples: sorted.length, meanMs: r.mean, marginMs: Number.isFinite(r.moe) ? r.moe : r.mean, p95Ms: sorted[Math.min(sorted.length-1, Math.ceil(sorted.length*.95)-1)], hz: r.hz };
|
|
19
|
+
});
|
|
20
|
+
writeFileSync(report, JSON.stringify({ cases, runtime: Bun.version }));
|
|
21
|
+
} catch (error) { console.error(error); process.exitCode = 1; }
|
|
22
|
+
`;
|
|
@@ -0,0 +1,493 @@
|
|
|
1
|
+
import { spawn, execFileSync, type ChildProcess } from "node:child_process";
|
|
2
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
3
|
+
import {
|
|
4
|
+
existsSync,
|
|
5
|
+
readFileSync,
|
|
6
|
+
readdirSync,
|
|
7
|
+
mkdirSync,
|
|
8
|
+
writeFileSync,
|
|
9
|
+
renameSync,
|
|
10
|
+
unlinkSync,
|
|
11
|
+
statSync,
|
|
12
|
+
} from "node:fs";
|
|
13
|
+
import { join, dirname, relative } from "node:path";
|
|
14
|
+
import { cpus, platform, arch, hostname, release } from "node:os";
|
|
15
|
+
import ts from "typescript";
|
|
16
|
+
import { checkedPath } from "./workspace-notes";
|
|
17
|
+
import { benchmarkWorker } from "./benchmark-worker";
|
|
18
|
+
import { operationBenchmarkWorker } from "./operation-benchmark-worker";
|
|
19
|
+
import type { DefinitionGraph } from "./model";
|
|
20
|
+
import type { BenchmarkRun, BenchmarkView } from "./performance-model";
|
|
21
|
+
export { Bench } from "tinybench";
|
|
22
|
+
const hash = (value: string) =>
|
|
23
|
+
createHash("sha256").update(value).digest("hex");
|
|
24
|
+
function alive(run: BenchmarkRun) {
|
|
25
|
+
if (
|
|
26
|
+
!run.runnerPid ||
|
|
27
|
+
!run.heartbeatAt ||
|
|
28
|
+
Date.now() - run.heartbeatAt > 30000
|
|
29
|
+
)
|
|
30
|
+
return false;
|
|
31
|
+
try {
|
|
32
|
+
process.kill(run.runnerPid, 0);
|
|
33
|
+
return true;
|
|
34
|
+
} catch {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export function benchmarkPlans(
|
|
39
|
+
root: string,
|
|
40
|
+
graph: DefinitionGraph,
|
|
41
|
+
): BenchmarkView["plans"] {
|
|
42
|
+
const plans = new Map<string, BenchmarkView["plans"][number]>();
|
|
43
|
+
for (const node of graph.elements)
|
|
44
|
+
for (const file of node.attachments?.benchmarks || []) {
|
|
45
|
+
if (!/\.bench\.[cm]?[jt]sx?$/.test(file)) continue;
|
|
46
|
+
try {
|
|
47
|
+
if (statSync(checkedPath(root, file)).size > 128000) continue;
|
|
48
|
+
} catch {
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
const plan: BenchmarkView["plans"][number] = plans.get(file) || {
|
|
52
|
+
file,
|
|
53
|
+
blocks: [],
|
|
54
|
+
label:
|
|
55
|
+
node.label ||
|
|
56
|
+
file
|
|
57
|
+
.split("/")
|
|
58
|
+
.at(-1)!
|
|
59
|
+
.replace(/\.bench\.[^.]+$/, "")
|
|
60
|
+
.replace(/-/g, " "),
|
|
61
|
+
};
|
|
62
|
+
// Metadata is read as syntax; listing never imports or runs a suite.
|
|
63
|
+
const syntax = ts.createSourceFile(
|
|
64
|
+
file,
|
|
65
|
+
readFileSync(checkedPath(root, file), "utf8"),
|
|
66
|
+
ts.ScriptTarget.Latest,
|
|
67
|
+
true,
|
|
68
|
+
);
|
|
69
|
+
let definition: ts.ObjectLiteralExpression | undefined;
|
|
70
|
+
for (const statement of syntax.statements)
|
|
71
|
+
if (ts.isExportAssignment(statement)) {
|
|
72
|
+
let value = statement.expression;
|
|
73
|
+
while (
|
|
74
|
+
ts.isSatisfiesExpression(value) ||
|
|
75
|
+
ts.isAsExpression(value) ||
|
|
76
|
+
ts.isParenthesizedExpression(value)
|
|
77
|
+
)
|
|
78
|
+
value = value.expression;
|
|
79
|
+
if (ts.isObjectLiteralExpression(value)) definition = value;
|
|
80
|
+
}
|
|
81
|
+
if (definition) {
|
|
82
|
+
const literals = Object.fromEntries(
|
|
83
|
+
definition.properties.flatMap((property) =>
|
|
84
|
+
ts.isPropertyAssignment(property) &&
|
|
85
|
+
property.name &&
|
|
86
|
+
ts.isIdentifier(property.name) &&
|
|
87
|
+
ts.isStringLiteral(property.initializer)
|
|
88
|
+
? [[property.name.text, property.initializer.text]]
|
|
89
|
+
: [],
|
|
90
|
+
),
|
|
91
|
+
);
|
|
92
|
+
if (literals.kind === "operation") {
|
|
93
|
+
plan.kind = "operation";
|
|
94
|
+
if (literals.name) plan.label = literals.name;
|
|
95
|
+
for (const key of ["description", "startsWhen", "endsWhen"] as const)
|
|
96
|
+
if (literals[key]) plan[key] = literals[key];
|
|
97
|
+
const attempts = definition.properties.find(
|
|
98
|
+
(p) =>
|
|
99
|
+
ts.isPropertyAssignment(p) &&
|
|
100
|
+
p.name?.getText(syntax) === "attempts",
|
|
101
|
+
);
|
|
102
|
+
if (
|
|
103
|
+
attempts &&
|
|
104
|
+
ts.isPropertyAssignment(attempts) &&
|
|
105
|
+
ts.isNumericLiteral(attempts.initializer)
|
|
106
|
+
)
|
|
107
|
+
plan.attempts = Number(attempts.initializer.text);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
plan.kind ||= "function";
|
|
111
|
+
plan.blocks.push(node.implementationBlock || node.id);
|
|
112
|
+
plans.set(file, plan);
|
|
113
|
+
}
|
|
114
|
+
return [...plans.values()].map((plan) => ({
|
|
115
|
+
...plan,
|
|
116
|
+
blocks: [...new Set(plan.blocks)],
|
|
117
|
+
}));
|
|
118
|
+
}
|
|
119
|
+
function fingerprint(root: string, graph: DefinitionGraph, file: string) {
|
|
120
|
+
const paths = new Set([file, "bun.lock", "package.json"]);
|
|
121
|
+
const nodes = graph.elements.filter((node) =>
|
|
122
|
+
node.attachments?.benchmarks?.includes(file),
|
|
123
|
+
);
|
|
124
|
+
for (const node of nodes)
|
|
125
|
+
for (const source of node.sources || (node.source ? [node.source] : []))
|
|
126
|
+
paths.add(source.file);
|
|
127
|
+
const visited = new Set<string>(),
|
|
128
|
+
values: string[] = [];
|
|
129
|
+
const visit = (file: string) => {
|
|
130
|
+
if (visited.has(file)) return;
|
|
131
|
+
visited.add(file);
|
|
132
|
+
if (visited.size > 512)
|
|
133
|
+
throw Error("Benchmark source fingerprint exceeds 512 files");
|
|
134
|
+
let text: string;
|
|
135
|
+
try {
|
|
136
|
+
const path = checkedPath(root, file);
|
|
137
|
+
if (statSync(path).size > 4 * 1024 * 1024)
|
|
138
|
+
throw Error("Source too large");
|
|
139
|
+
text = readFileSync(path, "utf8");
|
|
140
|
+
} catch {
|
|
141
|
+
values.push(file + ":unavailable");
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
values.push(file + ":" + hash(text));
|
|
145
|
+
if (!/\.[cm]?[jt]sx?$/.test(file)) return;
|
|
146
|
+
for (const entry of ts.preProcessFile(text).importedFiles) {
|
|
147
|
+
if (!entry.fileName.startsWith(".")) continue;
|
|
148
|
+
const base = join(dirname(file), entry.fileName).replace(/\.js$/, "");
|
|
149
|
+
const candidate = [
|
|
150
|
+
base,
|
|
151
|
+
base + ".ts",
|
|
152
|
+
base + ".tsx",
|
|
153
|
+
base + ".js",
|
|
154
|
+
join(base, "index.ts"),
|
|
155
|
+
].find((name) => {
|
|
156
|
+
try {
|
|
157
|
+
return statSync(checkedPath(root, name)).isFile();
|
|
158
|
+
} catch {
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
if (candidate) visit(candidate);
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
for (const path of paths) visit(path);
|
|
166
|
+
return hash(values.sort().join("\n"));
|
|
167
|
+
}
|
|
168
|
+
export class BenchmarkRunner {
|
|
169
|
+
private active?: { run: BenchmarkRun; child?: ChildProcess };
|
|
170
|
+
private completions = new Map<string, Promise<BenchmarkRun>>();
|
|
171
|
+
async wait(id: string): Promise<BenchmarkRun> {
|
|
172
|
+
const completion = this.completions.get(id);
|
|
173
|
+
if (completion) return completion;
|
|
174
|
+
const run = this.view().runs.find((run) => run.id === id);
|
|
175
|
+
if (run && (run.status === "passed" || run.status === "failed")) return run;
|
|
176
|
+
throw Error("This runner does not own an active benchmark with that ID.");
|
|
177
|
+
}
|
|
178
|
+
constructor(
|
|
179
|
+
readonly root: string,
|
|
180
|
+
private graph: DefinitionGraph,
|
|
181
|
+
) {}
|
|
182
|
+
private directory() {
|
|
183
|
+
return checkedPath(this.root, ".fractal/benchmarks", true);
|
|
184
|
+
}
|
|
185
|
+
view(): BenchmarkView {
|
|
186
|
+
const runs: BenchmarkRun[] = [];
|
|
187
|
+
if (existsSync(this.directory()))
|
|
188
|
+
for (const file of readdirSync(this.directory())
|
|
189
|
+
.filter((file) => /^[a-f0-9-]{36}\.json$/.test(file))
|
|
190
|
+
.sort(
|
|
191
|
+
(a, b) =>
|
|
192
|
+
statSync(join(this.directory(), b)).mtimeMs -
|
|
193
|
+
statSync(join(this.directory(), a)).mtimeMs,
|
|
194
|
+
)
|
|
195
|
+
.slice(0, 300)) {
|
|
196
|
+
try {
|
|
197
|
+
const path = checkedPath(this.root, `.fractal/benchmarks/${file}`);
|
|
198
|
+
if (statSync(path).size > 256000) continue;
|
|
199
|
+
const run = JSON.parse(readFileSync(path, "utf8"));
|
|
200
|
+
if (run.id && Array.isArray(run.cases))
|
|
201
|
+
runs.push(
|
|
202
|
+
(run.status === "running" || run.status === "queued") &&
|
|
203
|
+
!alive(run)
|
|
204
|
+
? {
|
|
205
|
+
...run,
|
|
206
|
+
status: "failed",
|
|
207
|
+
error: "Interrupted when the benchmark host stopped",
|
|
208
|
+
}
|
|
209
|
+
: run,
|
|
210
|
+
);
|
|
211
|
+
} catch {}
|
|
212
|
+
}
|
|
213
|
+
if (this.active) {
|
|
214
|
+
const index = runs.findIndex((run) => run.id === this.active!.run.id);
|
|
215
|
+
if (index >= 0) runs.splice(index, 1);
|
|
216
|
+
runs.push(this.active.run);
|
|
217
|
+
}
|
|
218
|
+
let baselines: Record<string, string> = {};
|
|
219
|
+
try {
|
|
220
|
+
baselines = JSON.parse(
|
|
221
|
+
readFileSync(
|
|
222
|
+
checkedPath(this.root, ".fractal/benchmarks/baselines.json"),
|
|
223
|
+
"utf8",
|
|
224
|
+
),
|
|
225
|
+
);
|
|
226
|
+
} catch {}
|
|
227
|
+
for (const id of Object.values(baselines))
|
|
228
|
+
if (/^[a-f0-9-]{36}$/.test(id) && !runs.some((run) => run.id === id))
|
|
229
|
+
try {
|
|
230
|
+
const path = checkedPath(this.root, `.fractal/benchmarks/${id}.json`);
|
|
231
|
+
if (statSync(path).size < 256000)
|
|
232
|
+
runs.push(JSON.parse(readFileSync(path, "utf8")));
|
|
233
|
+
} catch {}
|
|
234
|
+
const sorted = runs.sort((a, b) => b.at.localeCompare(a.at));
|
|
235
|
+
return {
|
|
236
|
+
plans: benchmarkPlans(this.root, this.graph),
|
|
237
|
+
runs: sorted.filter(
|
|
238
|
+
(run, index) =>
|
|
239
|
+
index < 100 || Object.values(baselines).includes(run.id),
|
|
240
|
+
),
|
|
241
|
+
baselines,
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
private save(run: BenchmarkRun) {
|
|
245
|
+
mkdirSync(this.directory(), { recursive: true });
|
|
246
|
+
const path = checkedPath(
|
|
247
|
+
this.root,
|
|
248
|
+
`.fractal/benchmarks/${run.id}.json`,
|
|
249
|
+
true,
|
|
250
|
+
),
|
|
251
|
+
temporary = path + ".tmp";
|
|
252
|
+
writeFileSync(temporary, JSON.stringify(run), { mode: 0o600 });
|
|
253
|
+
renameSync(temporary, path);
|
|
254
|
+
}
|
|
255
|
+
start(file: string) {
|
|
256
|
+
if (
|
|
257
|
+
this.active ||
|
|
258
|
+
this.view().runs.some(
|
|
259
|
+
(run) => run.status === "running" || run.status === "queued",
|
|
260
|
+
)
|
|
261
|
+
)
|
|
262
|
+
throw Error(
|
|
263
|
+
"A benchmark is already running. Wait or stop it before starting another.",
|
|
264
|
+
);
|
|
265
|
+
const plan = benchmarkPlans(this.root, this.graph).find(
|
|
266
|
+
(plan) => plan.file === file,
|
|
267
|
+
);
|
|
268
|
+
if (!plan) throw Error("Choose a benchmark attached to this factory.");
|
|
269
|
+
const source = checkedPath(this.root, file),
|
|
270
|
+
status = this.git(["status", "--porcelain", "-uno"]),
|
|
271
|
+
baseCommit = this.git(["rev-parse", "HEAD"]);
|
|
272
|
+
const untracked = this.git([
|
|
273
|
+
"ls-files",
|
|
274
|
+
"--others",
|
|
275
|
+
"--exclude-standard",
|
|
276
|
+
"-z",
|
|
277
|
+
]);
|
|
278
|
+
const codeDigest = fingerprint(this.root, this.graph, file);
|
|
279
|
+
const machine = [platform(), arch(), cpus()[0]?.model || "unknown"].join(
|
|
280
|
+
" · ",
|
|
281
|
+
);
|
|
282
|
+
const run: BenchmarkRun = {
|
|
283
|
+
id: randomUUID(),
|
|
284
|
+
file,
|
|
285
|
+
blockIds: plan.blocks,
|
|
286
|
+
at: new Date().toISOString(),
|
|
287
|
+
status: "running",
|
|
288
|
+
baseCommit,
|
|
289
|
+
commit: status || untracked ? null : baseCommit || null,
|
|
290
|
+
codeDigest,
|
|
291
|
+
scenario: hash(readFileSync(source, "utf8")),
|
|
292
|
+
environment: "",
|
|
293
|
+
machine,
|
|
294
|
+
cases: [],
|
|
295
|
+
output: "",
|
|
296
|
+
kind: plan.kind || "function",
|
|
297
|
+
runnerPid: process.pid,
|
|
298
|
+
heartbeatAt: Date.now(),
|
|
299
|
+
};
|
|
300
|
+
this.active = { run };
|
|
301
|
+
this.save(run);
|
|
302
|
+
let resolveCompletion!: (run: BenchmarkRun) => void;
|
|
303
|
+
let rejectCompletion!: (error: unknown) => void;
|
|
304
|
+
const completion = new Promise<BenchmarkRun>((resolve, reject) => {
|
|
305
|
+
resolveCompletion = resolve;
|
|
306
|
+
rejectCompletion = reject;
|
|
307
|
+
});
|
|
308
|
+
// The UI observes saved heartbeats; the CLI awaits this exact worker instead of reparsing the map.
|
|
309
|
+
void completion.catch(() => {});
|
|
310
|
+
this.completions.set(run.id, completion);
|
|
311
|
+
if (this.completions.size > 24)
|
|
312
|
+
this.completions.delete(this.completions.keys().next().value!);
|
|
313
|
+
const outputFile = checkedPath(
|
|
314
|
+
this.root,
|
|
315
|
+
`.fractal/benchmarks/${run.id}.result.tmp`,
|
|
316
|
+
true,
|
|
317
|
+
);
|
|
318
|
+
const child = spawn(
|
|
319
|
+
"bun",
|
|
320
|
+
[
|
|
321
|
+
"-e",
|
|
322
|
+
`const version = Bun.version; console.log('__FRACTORY_RUNTIME__' + version);\n${plan.kind === "operation" ? operationBenchmarkWorker : benchmarkWorker}`,
|
|
323
|
+
source,
|
|
324
|
+
outputFile,
|
|
325
|
+
],
|
|
326
|
+
{
|
|
327
|
+
cwd: dirname(source),
|
|
328
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
329
|
+
env: { ...process.env, ELECTRON_RUN_AS_NODE: undefined },
|
|
330
|
+
},
|
|
331
|
+
);
|
|
332
|
+
this.active.child = child;
|
|
333
|
+
const started = Date.now();
|
|
334
|
+
let runtime = "unknown";
|
|
335
|
+
const consume = (data: Buffer) => {
|
|
336
|
+
const text = data.toString();
|
|
337
|
+
runtime = /__FRACTORY_RUNTIME__([^\s]+)/.exec(text)?.[1] || runtime;
|
|
338
|
+
run.output = (
|
|
339
|
+
run.output + text.replace(/__FRACTORY_RUNTIME__[^\n]*\n?/, "")
|
|
340
|
+
).slice(-20000);
|
|
341
|
+
};
|
|
342
|
+
child.stdout?.on("data", consume);
|
|
343
|
+
child.stderr?.on("data", consume);
|
|
344
|
+
const heartbeat = setInterval(() => {
|
|
345
|
+
run.heartbeatAt = Date.now();
|
|
346
|
+
this.save(run);
|
|
347
|
+
}, 2000);
|
|
348
|
+
let timedOut = false,
|
|
349
|
+
ended = false;
|
|
350
|
+
const timer = setTimeout(
|
|
351
|
+
() => {
|
|
352
|
+
timedOut = true;
|
|
353
|
+
child.kill("SIGKILL");
|
|
354
|
+
},
|
|
355
|
+
plan.kind === "operation" ? 15 * 60_000 : 90000,
|
|
356
|
+
);
|
|
357
|
+
const complete = (code: number | null, error?: string) => {
|
|
358
|
+
if (ended) return;
|
|
359
|
+
ended = true;
|
|
360
|
+
clearTimeout(timer);
|
|
361
|
+
clearInterval(heartbeat);
|
|
362
|
+
run.durationMs = Date.now() - started;
|
|
363
|
+
run.environment = hash(
|
|
364
|
+
hostname() +
|
|
365
|
+
"|" +
|
|
366
|
+
release() +
|
|
367
|
+
"|" +
|
|
368
|
+
machine +
|
|
369
|
+
"|bun:" +
|
|
370
|
+
runtime +
|
|
371
|
+
"|tinybench:2.9.0",
|
|
372
|
+
);
|
|
373
|
+
try {
|
|
374
|
+
if (code !== 0 || error)
|
|
375
|
+
throw Error(
|
|
376
|
+
error ||
|
|
377
|
+
(timedOut
|
|
378
|
+
? plan.kind === "operation"
|
|
379
|
+
? "Benchmark exceeded 15 minutes"
|
|
380
|
+
: "Benchmark exceeded 90 seconds"
|
|
381
|
+
: "Benchmark process failed"),
|
|
382
|
+
);
|
|
383
|
+
const report = JSON.parse(readFileSync(outputFile, "utf8"));
|
|
384
|
+
if (typeof report.runtime === "string")
|
|
385
|
+
run.environment = hash(
|
|
386
|
+
hostname() +
|
|
387
|
+
"|" +
|
|
388
|
+
release() +
|
|
389
|
+
"|" +
|
|
390
|
+
machine +
|
|
391
|
+
"|bun:" +
|
|
392
|
+
report.runtime +
|
|
393
|
+
"|tinybench:2.9.0",
|
|
394
|
+
);
|
|
395
|
+
if (
|
|
396
|
+
!Array.isArray(report.cases) ||
|
|
397
|
+
report.cases.length > 12 ||
|
|
398
|
+
report.cases.some(
|
|
399
|
+
(item: any) =>
|
|
400
|
+
!Number.isFinite(item.meanMs) ||
|
|
401
|
+
!Number.isFinite(item.marginMs) ||
|
|
402
|
+
!Number.isFinite(item.p95Ms) ||
|
|
403
|
+
item.samples < (plan.kind === "operation" ? 1 : 20),
|
|
404
|
+
)
|
|
405
|
+
)
|
|
406
|
+
throw Error("No valid benchmark results");
|
|
407
|
+
if (fingerprint(this.root, this.graph, file) !== codeDigest)
|
|
408
|
+
throw Error(
|
|
409
|
+
"Source changed during this run. Run again on a stable checkout.",
|
|
410
|
+
);
|
|
411
|
+
run.cases = report.cases;
|
|
412
|
+
if (plan.kind === "operation") {
|
|
413
|
+
if (
|
|
414
|
+
report.kind !== "operation" ||
|
|
415
|
+
!report.target ||
|
|
416
|
+
!report.fixtureDigest
|
|
417
|
+
)
|
|
418
|
+
throw Error("No product-operation measurement returned.");
|
|
419
|
+
run.target = report.target;
|
|
420
|
+
run.fixture = report.fixture;
|
|
421
|
+
run.fixtureVersion = report.fixtureVersion;
|
|
422
|
+
run.fixtureDescription = report.fixtureDescription;
|
|
423
|
+
run.scenario = hash(run.scenario + ":" + report.fixtureDigest);
|
|
424
|
+
run.machine = report.target.name;
|
|
425
|
+
run.environment = hash(
|
|
426
|
+
report.target.url +
|
|
427
|
+
":" +
|
|
428
|
+
report.target.measurement +
|
|
429
|
+
(report.target.measurement === "client" ? ":" + hostname() : ""),
|
|
430
|
+
);
|
|
431
|
+
}
|
|
432
|
+
run.status = "passed";
|
|
433
|
+
} catch (cause) {
|
|
434
|
+
run.status = "failed";
|
|
435
|
+
run.error = cause instanceof Error ? cause.message : "Benchmark failed";
|
|
436
|
+
} finally {
|
|
437
|
+
if (existsSync(outputFile)) unlinkSync(outputFile);
|
|
438
|
+
try {
|
|
439
|
+
this.save(run);
|
|
440
|
+
resolveCompletion(structuredClone(run));
|
|
441
|
+
} catch (error) {
|
|
442
|
+
rejectCompletion(error);
|
|
443
|
+
}
|
|
444
|
+
if (this.active?.run.id === run.id) this.active = undefined;
|
|
445
|
+
}
|
|
446
|
+
};
|
|
447
|
+
child.on("error", (error) => complete(null, error.message));
|
|
448
|
+
child.on("close", (code) => complete(code));
|
|
449
|
+
return run;
|
|
450
|
+
}
|
|
451
|
+
stop(id: string) {
|
|
452
|
+
if (this.active?.run.id !== id)
|
|
453
|
+
throw Error("This benchmark is not running");
|
|
454
|
+
this.active.child?.kill("SIGTERM");
|
|
455
|
+
}
|
|
456
|
+
baseline(id: string) {
|
|
457
|
+
const view = this.view(),
|
|
458
|
+
run = view.runs.find((run) => run.id === id);
|
|
459
|
+
if (
|
|
460
|
+
!run ||
|
|
461
|
+
run.status !== "passed" ||
|
|
462
|
+
!view.plans.some((plan) => plan.file === run.file)
|
|
463
|
+
)
|
|
464
|
+
throw Error("Choose a successful attached benchmark run.");
|
|
465
|
+
const path = checkedPath(
|
|
466
|
+
this.root,
|
|
467
|
+
".fractal/benchmarks/baselines.json",
|
|
468
|
+
true,
|
|
469
|
+
),
|
|
470
|
+
temporary = path + ".tmp";
|
|
471
|
+
writeFileSync(
|
|
472
|
+
temporary,
|
|
473
|
+
JSON.stringify({ ...view.baselines, [run.file]: id }),
|
|
474
|
+
{ mode: 0o600 },
|
|
475
|
+
);
|
|
476
|
+
renameSync(temporary, path);
|
|
477
|
+
return this.view();
|
|
478
|
+
}
|
|
479
|
+
private git(args: string[]) {
|
|
480
|
+
try {
|
|
481
|
+
return execFileSync("git", ["-c", "core.fsmonitor=false", ...args], {
|
|
482
|
+
cwd: this.root,
|
|
483
|
+
encoding: "utf8",
|
|
484
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
485
|
+
timeout: 5000,
|
|
486
|
+
maxBuffer: 4 * 1024 * 1024,
|
|
487
|
+
env: { ...process.env, GIT_OPTIONAL_LOCKS: "0" },
|
|
488
|
+
}).trim();
|
|
489
|
+
} catch {
|
|
490
|
+
return "";
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
}
|
package/src/bin.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/** Keep native Git activity independent of the legacy inspector's definition/compiler imports. */
|
|
3
|
+
const args = process.argv.slice(2);
|
|
4
|
+
if (!args.length) args.push("help");
|
|
5
|
+
try {
|
|
6
|
+
let output: string;
|
|
7
|
+
if (args[0] === "work") {
|
|
8
|
+
const { runWork } = await import("./work-cli");
|
|
9
|
+
output = await runWork(args);
|
|
10
|
+
} else if (args[0] === "reports") {
|
|
11
|
+
const { runReports } = await import("./reports-cli");
|
|
12
|
+
output = await runReports(args);
|
|
13
|
+
} else if (args[0] === "integrations") {
|
|
14
|
+
const { runIntegrations } = await import("./integrations-cli");
|
|
15
|
+
output = await runIntegrations(args);
|
|
16
|
+
} else if (["setup", "doctor", "guide", "open"].includes(args[0])) {
|
|
17
|
+
const { runSetup } = await import("./setup-cli");
|
|
18
|
+
output = runSetup(args);
|
|
19
|
+
} else if (args[0] === "benchmark") {
|
|
20
|
+
const { runBenchmark } = await import("./benchmark-cli");
|
|
21
|
+
output = await runBenchmark(args);
|
|
22
|
+
} else if (args[0] === "coverage") {
|
|
23
|
+
const { runCoverage } = await import("./coverage-cli");
|
|
24
|
+
output = await runCoverage(args);
|
|
25
|
+
} else if (["block", "tests"].includes(args[0])) {
|
|
26
|
+
const { runBlock } = await import("./block-cli");
|
|
27
|
+
output = await runBlock(args);
|
|
28
|
+
} else if (args[0] === "review") {
|
|
29
|
+
const { runReview } = await import("./review-cli");
|
|
30
|
+
output = runReview(args);
|
|
31
|
+
} else if (args[0] === "issues") {
|
|
32
|
+
const { runIssues } = await import("./issue-cli");
|
|
33
|
+
output = await runIssues(args);
|
|
34
|
+
} else if (args[0] === "working" && !args.includes("--help")) {
|
|
35
|
+
const { runWorking } = await import("./working-cli");
|
|
36
|
+
output = await runWorking(args);
|
|
37
|
+
} else {
|
|
38
|
+
const { run, runSentry } = await import("./cli");
|
|
39
|
+
output =
|
|
40
|
+
args[0] === "sentry" &&
|
|
41
|
+
!args.includes("--event-file") &&
|
|
42
|
+
!args.includes("--help")
|
|
43
|
+
? await runSentry(args)
|
|
44
|
+
: run(args);
|
|
45
|
+
}
|
|
46
|
+
console.log(output);
|
|
47
|
+
} catch (error) {
|
|
48
|
+
console.error(
|
|
49
|
+
`fractory: ${error instanceof Error ? error.message : String(error)}`,
|
|
50
|
+
);
|
|
51
|
+
process.exitCode = 1;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export {};
|