yolont 0.5.0 → 0.6.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 +3 -2
- package/dist/cli.js +255 -95
- package/dist/cli.js.map +4 -4
- package/docs/GUIDE.md +10 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -18,8 +18,9 @@ it's just:
|
|
|
18
18
|
yolont
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
You need Node 22.13
|
|
22
|
-
files to write: the wizard asks for
|
|
21
|
+
You need Node 22.13+. No [gitleaks](https://github.com/gitleaks/gitleaks)? The wizard offers to
|
|
22
|
+
download the official build (checksum-verified). No config files to write: the wizard asks for
|
|
23
|
+
what it needs.
|
|
23
24
|
|
|
24
25
|
*(YOLO + n't = **yolont**: you only live once, so don't merge like it.
|
|
25
26
|
[The long story](docs/GUIDE.md#0-why-yolont).)*
|
package/dist/cli.js
CHANGED
|
@@ -14,6 +14,122 @@ var __export = (target, all) => {
|
|
|
14
14
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
+
// local/paths.ts
|
|
18
|
+
import { existsSync, renameSync } from "node:fs";
|
|
19
|
+
import { homedir } from "node:os";
|
|
20
|
+
import { dirname, join } from "node:path";
|
|
21
|
+
import { fileURLToPath } from "node:url";
|
|
22
|
+
function adopt(base) {
|
|
23
|
+
const dir = join(base, "yolont");
|
|
24
|
+
const old = join(base, "ethos");
|
|
25
|
+
if (existsSync(dir) || !existsSync(old)) return dir;
|
|
26
|
+
try {
|
|
27
|
+
renameSync(old, dir);
|
|
28
|
+
return dir;
|
|
29
|
+
} catch {
|
|
30
|
+
return old;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function userProjectDir(host, pathWithNamespace) {
|
|
34
|
+
return join(CONFIG_DIR, "projects", bareHost(host).replace(/:/g, "_"), ...pathWithNamespace.toLowerCase().split("/"));
|
|
35
|
+
}
|
|
36
|
+
function bareHost(hostOrUrl) {
|
|
37
|
+
return (/^[a-z]+:\/\//i.test(hostOrUrl) ? new URL(hostOrUrl).host : hostOrUrl).toLowerCase();
|
|
38
|
+
}
|
|
39
|
+
var __dirname, INSTALL_ROOT, DEFAULT_RUBRIC_PATH, BUILTIN_CONVENTIONS_DIR, DEFAULT_CONVENTIONS_PATH, ZONE_TEMPLATES_DIR, env, win, CONFIG_DIR, DATA_DIR, DB_PATH, SESSIONS_PATH;
|
|
40
|
+
var init_paths = __esm({
|
|
41
|
+
"local/paths.ts"() {
|
|
42
|
+
"use strict";
|
|
43
|
+
__dirname = dirname(fileURLToPath(import.meta.url));
|
|
44
|
+
INSTALL_ROOT = join(__dirname, "..");
|
|
45
|
+
DEFAULT_RUBRIC_PATH = join(INSTALL_ROOT, ".pr-reviewer", "rubric.yml");
|
|
46
|
+
BUILTIN_CONVENTIONS_DIR = join(INSTALL_ROOT, "conventions");
|
|
47
|
+
DEFAULT_CONVENTIONS_PATH = join(BUILTIN_CONVENTIONS_DIR, "default.md");
|
|
48
|
+
ZONE_TEMPLATES_DIR = join(INSTALL_ROOT, "templates", "zones");
|
|
49
|
+
env = process.env;
|
|
50
|
+
win = process.platform === "win32";
|
|
51
|
+
for (const [k, v] of Object.entries(env)) if (k.startsWith("ETHOS_") && env[`YOLONT_${k.slice(6)}`] === void 0) env[`YOLONT_${k.slice(6)}`] = v;
|
|
52
|
+
CONFIG_DIR = env.YOLONT_CONFIG_DIR ?? adopt(win ? env.APPDATA ?? join(homedir(), "AppData", "Roaming") : env.XDG_CONFIG_HOME || join(homedir(), ".config"));
|
|
53
|
+
DATA_DIR = env.YOLONT_DATA_DIR ?? adopt(win ? env.LOCALAPPDATA ?? join(homedir(), "AppData", "Local") : env.XDG_DATA_HOME || join(homedir(), ".local", "share"));
|
|
54
|
+
DB_PATH = join(DATA_DIR, "yolont.db");
|
|
55
|
+
if (!existsSync(DB_PATH) && existsSync(join(DATA_DIR, "ethos.db"))) {
|
|
56
|
+
for (const ext of ["", "-wal", "-shm"]) {
|
|
57
|
+
const from = join(DATA_DIR, `ethos.db${ext}`);
|
|
58
|
+
if (existsSync(from)) renameSync(from, `${DB_PATH}${ext}`);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
SESSIONS_PATH = join(DATA_DIR, "sessions.json");
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
// local/setup/gitleaks.ts
|
|
66
|
+
var gitleaks_exports = {};
|
|
67
|
+
__export(gitleaks_exports, {
|
|
68
|
+
GITLEAKS_VERSION: () => GITLEAKS_VERSION,
|
|
69
|
+
LOCAL_GITLEAKS: () => LOCAL_GITLEAKS,
|
|
70
|
+
gitleaksAsset: () => gitleaksAsset,
|
|
71
|
+
gitleaksWorks: () => gitleaksWorks,
|
|
72
|
+
installGitleaks: () => installGitleaks,
|
|
73
|
+
useLocalGitleaks: () => useLocalGitleaks
|
|
74
|
+
});
|
|
75
|
+
import { spawnSync } from "node:child_process";
|
|
76
|
+
import { createHash } from "node:crypto";
|
|
77
|
+
import { chmodSync as chmodSync2, copyFileSync as copyFileSync2, existsSync as existsSync11, mkdirSync as mkdirSync10, mkdtempSync, rmSync as rmSync3, writeFileSync as writeFileSync9 } from "node:fs";
|
|
78
|
+
import { tmpdir as tmpdir2 } from "node:os";
|
|
79
|
+
import { join as join14 } from "node:path";
|
|
80
|
+
function useLocalGitleaks(env2 = process.env) {
|
|
81
|
+
if (!env2.YOLONT_GITLEAKS && existsSync11(LOCAL_GITLEAKS)) env2.YOLONT_GITLEAKS = LOCAL_GITLEAKS;
|
|
82
|
+
}
|
|
83
|
+
function gitleaksAsset(platform = process.platform, arch = process.arch) {
|
|
84
|
+
const os = platform === "win32" ? "windows" : platform;
|
|
85
|
+
const key2 = `${os}_${arch === "x64" ? "x64" : arch === "arm64" ? "arm64" : arch}`;
|
|
86
|
+
const sha256 = SHA256[key2];
|
|
87
|
+
return sha256 ? { name: `gitleaks_${GITLEAKS_VERSION}_${key2}.${os === "windows" ? "zip" : "tar.gz"}`, sha256 } : void 0;
|
|
88
|
+
}
|
|
89
|
+
async function installGitleaks() {
|
|
90
|
+
const asset = gitleaksAsset();
|
|
91
|
+
if (!asset) throw new Error(`No official gitleaks build for ${process.platform}/${process.arch}.`);
|
|
92
|
+
const res = await fetch(`https://github.com/gitleaks/gitleaks/releases/download/v${GITLEAKS_VERSION}/${asset.name}`, { signal: AbortSignal.timeout(12e4) });
|
|
93
|
+
if (!res.ok) throw new Error(`Download failed: HTTP ${res.status}`);
|
|
94
|
+
const bytes = Buffer.from(await res.arrayBuffer());
|
|
95
|
+
const got = createHash("sha256").update(bytes).digest("hex");
|
|
96
|
+
if (got !== asset.sha256) throw new Error(`Checksum mismatch for ${asset.name} (got ${got}). Not installed.`);
|
|
97
|
+
const dir = mkdtempSync(join14(tmpdir2(), "yolont-gitleaks-dl-"));
|
|
98
|
+
try {
|
|
99
|
+
const archive = join14(dir, asset.name);
|
|
100
|
+
writeFileSync9(archive, bytes);
|
|
101
|
+
const exe = win2 ? "gitleaks.exe" : "gitleaks";
|
|
102
|
+
const tar = spawnSync("tar", ["-xf", archive, "-C", dir, exe], { stdio: "ignore" });
|
|
103
|
+
if (tar.status !== 0 || !existsSync11(join14(dir, exe))) throw new Error("Couldn't unpack the archive (is `tar` installed?).");
|
|
104
|
+
mkdirSync10(join14(DATA_DIR, "bin"), { recursive: true });
|
|
105
|
+
copyFileSync2(join14(dir, exe), LOCAL_GITLEAKS);
|
|
106
|
+
if (!win2) chmodSync2(LOCAL_GITLEAKS, 493);
|
|
107
|
+
} finally {
|
|
108
|
+
rmSync3(dir, { recursive: true, force: true });
|
|
109
|
+
}
|
|
110
|
+
process.env.YOLONT_GITLEAKS = LOCAL_GITLEAKS;
|
|
111
|
+
return LOCAL_GITLEAKS;
|
|
112
|
+
}
|
|
113
|
+
var GITLEAKS_VERSION, SHA256, win2, LOCAL_GITLEAKS, gitleaksWorks;
|
|
114
|
+
var init_gitleaks = __esm({
|
|
115
|
+
"local/setup/gitleaks.ts"() {
|
|
116
|
+
"use strict";
|
|
117
|
+
init_paths();
|
|
118
|
+
GITLEAKS_VERSION = "8.30.1";
|
|
119
|
+
SHA256 = {
|
|
120
|
+
darwin_arm64: "b40ab0ae55c505963e365f271a8d3846efbc170aa17f2607f13df610a9aeb6a5",
|
|
121
|
+
darwin_x64: "dfe101a4db2255fc85120ac7f3d25e4342c3c20cf749f2c20a18081af1952709",
|
|
122
|
+
linux_arm64: "e4a487ee7ccd7d3a7f7ec08657610aa3606637dab924210b3aee62570fb4b080",
|
|
123
|
+
linux_x64: "551f6fc83ea457d62a0d98237cbad105af8d557003051f41f3e7ca7b3f2470eb",
|
|
124
|
+
windows_arm64: "b95f5e4f5c425cedca7ee203d9afd29597e692c4924a12ed42f970537c72cc0f",
|
|
125
|
+
windows_x64: "d29144deff3a68aa93ced33dddf84b7fdc26070add4aa0f4513094c8332afc4e"
|
|
126
|
+
};
|
|
127
|
+
win2 = process.platform === "win32";
|
|
128
|
+
LOCAL_GITLEAKS = join14(DATA_DIR, "bin", win2 ? "gitleaks.exe" : "gitleaks");
|
|
129
|
+
gitleaksWorks = () => spawnSync(process.env.YOLONT_GITLEAKS || "gitleaks", ["version"], { stdio: "ignore" }).status === 0;
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
|
|
17
133
|
// local/setup/version.ts
|
|
18
134
|
var version_exports = {};
|
|
19
135
|
__export(version_exports, {
|
|
@@ -23,14 +139,14 @@ __export(version_exports, {
|
|
|
23
139
|
latestVersion: () => latestVersion,
|
|
24
140
|
ownVersion: () => ownVersion
|
|
25
141
|
});
|
|
26
|
-
import { spawnSync } from "node:child_process";
|
|
27
|
-
import { existsSync as
|
|
28
|
-
import { dirname as dirname7, join as
|
|
142
|
+
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
143
|
+
import { existsSync as existsSync12, readFileSync as readFileSync13 } from "node:fs";
|
|
144
|
+
import { dirname as dirname7, join as join15 } from "node:path";
|
|
29
145
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
30
146
|
function ownVersion(from = dirname7(fileURLToPath2(import.meta.url))) {
|
|
31
147
|
for (let dir = from, i = 0; i < 5; dir = dirname7(dir), i++) {
|
|
32
|
-
const file =
|
|
33
|
-
if (!
|
|
148
|
+
const file = join15(dir, "package.json");
|
|
149
|
+
if (!existsSync12(file)) continue;
|
|
34
150
|
try {
|
|
35
151
|
const pkg = JSON.parse(readFileSync13(file, "utf8"));
|
|
36
152
|
if (pkg.name === "yolont") return pkg.version;
|
|
@@ -61,7 +177,7 @@ function installKind(script = process.argv[1] ?? "") {
|
|
|
61
177
|
return "source";
|
|
62
178
|
}
|
|
63
179
|
function installLatest(version) {
|
|
64
|
-
return
|
|
180
|
+
return spawnSync2("npm", ["install", "-g", `yolont@${version}`], { stdio: "inherit", shell: process.platform === "win32" }).status === 0;
|
|
65
181
|
}
|
|
66
182
|
var init_version = __esm({
|
|
67
183
|
"local/setup/version.ts"() {
|
|
@@ -70,57 +186,16 @@ var init_version = __esm({
|
|
|
70
186
|
});
|
|
71
187
|
|
|
72
188
|
// local/cli.ts
|
|
73
|
-
import { existsSync as
|
|
74
|
-
import { join as
|
|
189
|
+
import { existsSync as existsSync16 } from "node:fs";
|
|
190
|
+
import { join as join19, resolve as resolve2 } from "node:path";
|
|
75
191
|
import { parseArgs } from "node:util";
|
|
76
192
|
|
|
77
193
|
// local/db/client.ts
|
|
194
|
+
init_paths();
|
|
78
195
|
import { DatabaseSync } from "node:sqlite";
|
|
79
196
|
import { mkdirSync, readFileSync } from "node:fs";
|
|
80
197
|
import { dirname as dirname2, join as join2 } from "node:path";
|
|
81
198
|
|
|
82
|
-
// local/paths.ts
|
|
83
|
-
import { existsSync, renameSync } from "node:fs";
|
|
84
|
-
import { homedir } from "node:os";
|
|
85
|
-
import { dirname, join } from "node:path";
|
|
86
|
-
import { fileURLToPath } from "node:url";
|
|
87
|
-
var __dirname = dirname(fileURLToPath(import.meta.url));
|
|
88
|
-
var INSTALL_ROOT = join(__dirname, "..");
|
|
89
|
-
var DEFAULT_RUBRIC_PATH = join(INSTALL_ROOT, ".pr-reviewer", "rubric.yml");
|
|
90
|
-
var BUILTIN_CONVENTIONS_DIR = join(INSTALL_ROOT, "conventions");
|
|
91
|
-
var DEFAULT_CONVENTIONS_PATH = join(BUILTIN_CONVENTIONS_DIR, "default.md");
|
|
92
|
-
var ZONE_TEMPLATES_DIR = join(INSTALL_ROOT, "templates", "zones");
|
|
93
|
-
var env = process.env;
|
|
94
|
-
var win = process.platform === "win32";
|
|
95
|
-
for (const [k, v] of Object.entries(env)) if (k.startsWith("ETHOS_") && env[`YOLONT_${k.slice(6)}`] === void 0) env[`YOLONT_${k.slice(6)}`] = v;
|
|
96
|
-
function adopt(base) {
|
|
97
|
-
const dir = join(base, "yolont");
|
|
98
|
-
const old = join(base, "ethos");
|
|
99
|
-
if (existsSync(dir) || !existsSync(old)) return dir;
|
|
100
|
-
try {
|
|
101
|
-
renameSync(old, dir);
|
|
102
|
-
return dir;
|
|
103
|
-
} catch {
|
|
104
|
-
return old;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
var CONFIG_DIR = env.YOLONT_CONFIG_DIR ?? adopt(win ? env.APPDATA ?? join(homedir(), "AppData", "Roaming") : env.XDG_CONFIG_HOME || join(homedir(), ".config"));
|
|
108
|
-
var DATA_DIR = env.YOLONT_DATA_DIR ?? adopt(win ? env.LOCALAPPDATA ?? join(homedir(), "AppData", "Local") : env.XDG_DATA_HOME || join(homedir(), ".local", "share"));
|
|
109
|
-
var DB_PATH = join(DATA_DIR, "yolont.db");
|
|
110
|
-
if (!existsSync(DB_PATH) && existsSync(join(DATA_DIR, "ethos.db"))) {
|
|
111
|
-
for (const ext of ["", "-wal", "-shm"]) {
|
|
112
|
-
const from = join(DATA_DIR, `ethos.db${ext}`);
|
|
113
|
-
if (existsSync(from)) renameSync(from, `${DB_PATH}${ext}`);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
var SESSIONS_PATH = join(DATA_DIR, "sessions.json");
|
|
117
|
-
function userProjectDir(host, pathWithNamespace) {
|
|
118
|
-
return join(CONFIG_DIR, "projects", bareHost(host).replace(/:/g, "_"), ...pathWithNamespace.toLowerCase().split("/"));
|
|
119
|
-
}
|
|
120
|
-
function bareHost(hostOrUrl) {
|
|
121
|
-
return (/^[a-z]+:\/\//i.test(hostOrUrl) ? new URL(hostOrUrl).host : hostOrUrl).toLowerCase();
|
|
122
|
-
}
|
|
123
|
-
|
|
124
199
|
// src/rubric/schema.ts
|
|
125
200
|
import { z } from "zod";
|
|
126
201
|
var CategoryTypeSchema = z.enum(["deterministic", "llm", "hybrid"]);
|
|
@@ -235,6 +310,7 @@ function clamp(value, min, max) {
|
|
|
235
310
|
}
|
|
236
311
|
|
|
237
312
|
// local/db/repo.ts
|
|
313
|
+
init_paths();
|
|
238
314
|
var DEFAULT_PENALTIES = SeverityPenaltiesSchema.parse({});
|
|
239
315
|
function upsertProject(db, project2) {
|
|
240
316
|
const row = db.prepare(
|
|
@@ -851,13 +927,36 @@ import { tmpdir } from "node:os";
|
|
|
851
927
|
import { join as join3 } from "node:path";
|
|
852
928
|
import { promisify } from "node:util";
|
|
853
929
|
var execFileAsync = promisify(execFile);
|
|
930
|
+
function locateInDiff(diffText, patchLine) {
|
|
931
|
+
let file = "(diff)";
|
|
932
|
+
let oldLine = 0;
|
|
933
|
+
let newLine = 0;
|
|
934
|
+
const lines = diffText.split("\n");
|
|
935
|
+
for (let i = 0; i < Math.min(patchLine, lines.length); i++) {
|
|
936
|
+
const l = lines[i];
|
|
937
|
+
const hunk = /^@@ -(\d+)(?:,\d+)? \+(\d+)/.exec(l);
|
|
938
|
+
const isLast = i === patchLine - 1;
|
|
939
|
+
if (l.startsWith("diff --git ")) file = l.replace(/^diff --git a\/.* b\//, "");
|
|
940
|
+
else if (l.startsWith("+++ ") && l !== "+++ /dev/null") file = l.slice(4).replace(/^b\//, "");
|
|
941
|
+
else if (hunk) [oldLine, newLine] = [Number(hunk[1]), Number(hunk[2])];
|
|
942
|
+
else if (l.startsWith("-") && !l.startsWith("--- ")) {
|
|
943
|
+
if (isLast) return { file, line: oldLine };
|
|
944
|
+
oldLine++;
|
|
945
|
+
} else if (l.startsWith("+") || l.startsWith(" ")) {
|
|
946
|
+
if (isLast) return { file, line: newLine };
|
|
947
|
+
newLine++;
|
|
948
|
+
if (l.startsWith(" ")) oldLine++;
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
return { file, line: 0 };
|
|
952
|
+
}
|
|
854
953
|
async function scanDiffForSecrets(diffText) {
|
|
855
954
|
const dir = await mkdtemp(join3(tmpdir(), "yolont-gitleaks-"));
|
|
856
955
|
const sourceFile = join3(dir, "diff.patch");
|
|
857
956
|
const reportFile = join3(dir, "report.json");
|
|
858
957
|
try {
|
|
859
958
|
await writeFile(sourceFile, diffText, "utf8");
|
|
860
|
-
await execFileAsync("gitleaks", [
|
|
959
|
+
await execFileAsync(process.env.YOLONT_GITLEAKS || "gitleaks", [
|
|
861
960
|
"detect",
|
|
862
961
|
"--no-git",
|
|
863
962
|
"--source",
|
|
@@ -874,8 +973,7 @@ async function scanDiffForSecrets(diffText) {
|
|
|
874
973
|
const entries = raw.trim().length > 0 ? JSON.parse(raw) : [];
|
|
875
974
|
const findings = entries.map((e) => ({
|
|
876
975
|
ruleId: e.RuleID ?? "unknown-rule",
|
|
877
|
-
|
|
878
|
-
line: e.StartLine ?? 0,
|
|
976
|
+
...locateInDiff(diffText, e.StartLine ?? 0),
|
|
879
977
|
description: e.Description ?? "Potential secret detected"
|
|
880
978
|
}));
|
|
881
979
|
return { score: findings.length === 0 ? 100 : 0, findings, scannerFailed: false };
|
|
@@ -2009,6 +2107,7 @@ function nodeId(zoneId) {
|
|
|
2009
2107
|
}
|
|
2010
2108
|
|
|
2011
2109
|
// local/conventions/resolve.ts
|
|
2110
|
+
init_paths();
|
|
2012
2111
|
import { execFileSync } from "node:child_process";
|
|
2013
2112
|
import { existsSync as existsSync6, readdirSync as readdirSync2 } from "node:fs";
|
|
2014
2113
|
import { join as join8 } from "node:path";
|
|
@@ -2609,12 +2708,14 @@ async function probeForgeType(host, fetchImpl = fetch) {
|
|
|
2609
2708
|
}
|
|
2610
2709
|
|
|
2611
2710
|
// local/config/config.ts
|
|
2711
|
+
init_paths();
|
|
2612
2712
|
import { existsSync as existsSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync5, writeFileSync as writeFileSync2 } from "node:fs";
|
|
2613
2713
|
import { dirname as dirname4, join as join5 } from "node:path";
|
|
2614
2714
|
import yaml3 from "js-yaml";
|
|
2615
2715
|
import { z as z5 } from "zod";
|
|
2616
2716
|
|
|
2617
2717
|
// local/config/secrets.ts
|
|
2718
|
+
init_paths();
|
|
2618
2719
|
import { createCipheriv, createDecipheriv, randomBytes, scryptSync } from "node:crypto";
|
|
2619
2720
|
import { chmodSync, existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync as readFileSync4, writeFileSync } from "node:fs";
|
|
2620
2721
|
import { createRequire } from "node:module";
|
|
@@ -2826,7 +2927,11 @@ function reapplyConfigToEnv(env2 = process.env) {
|
|
|
2826
2927
|
return applyConfigToEnv(loadConfig(), env2);
|
|
2827
2928
|
}
|
|
2828
2929
|
|
|
2930
|
+
// local/sync/source.ts
|
|
2931
|
+
init_paths();
|
|
2932
|
+
|
|
2829
2933
|
// local/forge.ts
|
|
2934
|
+
init_paths();
|
|
2830
2935
|
function envToken(type, host, env2) {
|
|
2831
2936
|
if (type === "gitlab") return env2.CI_SERVER_URL && bareHost(env2.CI_SERVER_URL) === host ? env2.GITLAB_API_TOKEN : void 0;
|
|
2832
2937
|
return host === "github.com" ? env2.GITHUB_TOKEN || env2.GH_TOKEN || void 0 : void 0;
|
|
@@ -3679,6 +3784,7 @@ function resolveProjectFiles(host, pathWithNamespace, cwd) {
|
|
|
3679
3784
|
}
|
|
3680
3785
|
|
|
3681
3786
|
// local/mining/backfill.ts
|
|
3787
|
+
init_paths();
|
|
3682
3788
|
async function runBackfill(opts) {
|
|
3683
3789
|
const db = openDb();
|
|
3684
3790
|
const client = opts.forge;
|
|
@@ -4062,7 +4168,11 @@ function leastSquaresSlope(values) {
|
|
|
4062
4168
|
return denominator === 0 ? 0 : numerator / denominator;
|
|
4063
4169
|
}
|
|
4064
4170
|
|
|
4171
|
+
// local/review/interactiveReview.ts
|
|
4172
|
+
init_paths();
|
|
4173
|
+
|
|
4065
4174
|
// local/review/sessionCache.ts
|
|
4175
|
+
init_paths();
|
|
4066
4176
|
import { existsSync as existsSync7, mkdirSync as mkdirSync6, readFileSync as readFileSync8, writeFileSync as writeFileSync5 } from "node:fs";
|
|
4067
4177
|
import { dirname as dirname6 } from "node:path";
|
|
4068
4178
|
var MAX_SESSIONS = 3;
|
|
@@ -4194,8 +4304,18 @@ async function runInteractiveReview(opts) {
|
|
|
4194
4304
|
s.stop(
|
|
4195
4305
|
secretsResult.scannerFailed ? "gitleaks failed to run" : secretsResult.findings.length > 0 ? `${secretsResult.findings.length} potential secret(s) found` : "clean"
|
|
4196
4306
|
);
|
|
4197
|
-
if (
|
|
4198
|
-
log.warn(
|
|
4307
|
+
if (secretsResult.scannerFailed) {
|
|
4308
|
+
log.warn(
|
|
4309
|
+
`gitleaks couldn't run: ${secretsResult.scannerError}
|
|
4310
|
+
Install or update it (v8+): https://github.com/gitleaks/gitleaks#installing \u2014 the LLM is skipped until it runs (fail-closed, same as CI).`
|
|
4311
|
+
);
|
|
4312
|
+
} else if (secretsResult.findings.length > 0) {
|
|
4313
|
+
const list = secretsResult.findings.map((f) => ` ${f.file}:${f.line} ${f.ruleId} (${f.description})`).join("\n");
|
|
4314
|
+
log.warn(
|
|
4315
|
+
`gitleaks flagged these lines, so the LLM is skipped (fail-closed, same as CI):
|
|
4316
|
+
${list}
|
|
4317
|
+
Not a real secret (a test fixture, a hash)? Add a \`gitleaks:allow\` comment on that line and push again.`
|
|
4318
|
+
);
|
|
4199
4319
|
}
|
|
4200
4320
|
if (typeMode === "label") {
|
|
4201
4321
|
const h = hintFromMr(mr);
|
|
@@ -4635,6 +4755,7 @@ async function runSyncReplies(opts) {
|
|
|
4635
4755
|
|
|
4636
4756
|
// local/backoffice/server.ts
|
|
4637
4757
|
import fastifyStatic from "@fastify/static";
|
|
4758
|
+
init_paths();
|
|
4638
4759
|
import Fastify from "fastify";
|
|
4639
4760
|
import { randomBytes as randomBytes3, timingSafeEqual } from "node:crypto";
|
|
4640
4761
|
import { join as join13 } from "node:path";
|
|
@@ -4689,6 +4810,7 @@ import { existsSync as existsSync10, readFileSync as readFileSync12 } from "node
|
|
|
4689
4810
|
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
4690
4811
|
import { existsSync as existsSync8, lstatSync, mkdirSync as mkdirSync7, readdirSync as readdirSync3, readFileSync as readFileSync9, writeFileSync as writeFileSync6 } from "node:fs";
|
|
4691
4812
|
import { join as join10 } from "node:path";
|
|
4813
|
+
init_paths();
|
|
4692
4814
|
var DEFAULT_CONVENTIONS_MAX_LINES = 300;
|
|
4693
4815
|
var conventionsMaxLines = () => loadConfig().conventionsMaxLines ?? DEFAULT_CONVENTIONS_MAX_LINES;
|
|
4694
4816
|
var targetLines = () => Math.floor(conventionsMaxLines() * 0.8);
|
|
@@ -4961,10 +5083,14 @@ function currentConventions(host, path) {
|
|
|
4961
5083
|
return { path: p, fromRepo: !!p && !p.startsWith(projectSettingsDir(host, path)) };
|
|
4962
5084
|
}
|
|
4963
5085
|
|
|
5086
|
+
// local/backoffice/settings.ts
|
|
5087
|
+
init_paths();
|
|
5088
|
+
|
|
4964
5089
|
// local/setup/state.ts
|
|
4965
5090
|
import { existsSync as existsSync9, mkdirSync as mkdirSync8, readFileSync as readFileSync10, writeFileSync as writeFileSync7 } from "node:fs";
|
|
4966
5091
|
import { join as join11 } from "node:path";
|
|
4967
5092
|
import yaml5 from "js-yaml";
|
|
5093
|
+
init_paths();
|
|
4968
5094
|
var statePath = (host, path) => join11(userProjectDir(host, path), "setup.yaml");
|
|
4969
5095
|
function readSetupState(host, path) {
|
|
4970
5096
|
const p = statePath(host, path);
|
|
@@ -5110,6 +5236,7 @@ function currentWeights(host, path) {
|
|
|
5110
5236
|
import { mkdirSync as mkdirSync9, readFileSync as readFileSync11, writeFileSync as writeFileSync8 } from "node:fs";
|
|
5111
5237
|
import { join as join12 } from "node:path";
|
|
5112
5238
|
import yaml6 from "js-yaml";
|
|
5239
|
+
init_paths();
|
|
5113
5240
|
function templatesFor(stack) {
|
|
5114
5241
|
const ids = [];
|
|
5115
5242
|
if (stack.includes("nextjs")) ids.push("nextjs");
|
|
@@ -5671,12 +5798,12 @@ async function startDashboard(opts = {}) {
|
|
|
5671
5798
|
}
|
|
5672
5799
|
|
|
5673
5800
|
// local/cli.ts
|
|
5674
|
-
import { mkdirSync as
|
|
5801
|
+
import { mkdirSync as mkdirSync12, readFileSync as readFileSync15, writeFileSync as writeFileSync12 } from "node:fs";
|
|
5675
5802
|
import { parseEnv } from "node:util";
|
|
5676
5803
|
import { password as password2 } from "@clack/prompts";
|
|
5677
5804
|
|
|
5678
5805
|
// local/setup/wizard.ts
|
|
5679
|
-
import { execFileSync as execFileSync3, spawnSync as
|
|
5806
|
+
import { execFileSync as execFileSync3, spawnSync as spawnSync3 } from "node:child_process";
|
|
5680
5807
|
|
|
5681
5808
|
// local/setup/ui.ts
|
|
5682
5809
|
import pc2 from "picocolors";
|
|
@@ -5756,12 +5883,14 @@ function panel(title, rows) {
|
|
|
5756
5883
|
}
|
|
5757
5884
|
|
|
5758
5885
|
// local/setup/wizard.ts
|
|
5759
|
-
import { existsSync as
|
|
5760
|
-
import { homedir as homedir2, tmpdir as
|
|
5886
|
+
import { existsSync as existsSync13, mkdtempSync as mkdtempSync2, readFileSync as readFileSync14, rmSync as rmSync4, statSync, writeFileSync as writeFileSync10 } from "node:fs";
|
|
5887
|
+
import { homedir as homedir2, tmpdir as tmpdir3, userInfo as userInfo2 } from "node:os";
|
|
5761
5888
|
import { emitKeypressEvents } from "node:readline";
|
|
5762
|
-
import { join as
|
|
5889
|
+
import { join as join16, resolve } from "node:path";
|
|
5763
5890
|
import { autocompleteMultiselect, confirm as confirm2, intro as intro2, isCancel as isCancel2, log as log2, multiselect as multiselect2, note, outro as outro2, password, select as select2, spinner as spinner2, text as text2 } from "@clack/prompts";
|
|
5764
5891
|
import pc3 from "picocolors";
|
|
5892
|
+
init_paths();
|
|
5893
|
+
init_gitleaks();
|
|
5765
5894
|
init_version();
|
|
5766
5895
|
var Cancelled = class extends Error {
|
|
5767
5896
|
};
|
|
@@ -5818,6 +5947,7 @@ async function runSetup(opts) {
|
|
|
5818
5947
|
latestCheck = latestVersion();
|
|
5819
5948
|
header(`${version ? `v${version} \xB7 ` : ""}PR reviews that look twice \xB7 Esc = back \xB7 Ctrl-C = quit`);
|
|
5820
5949
|
await offerInstallOnce();
|
|
5950
|
+
await ensureGitleaks();
|
|
5821
5951
|
await askIconsOnce();
|
|
5822
5952
|
intro2(opts.review ? "Yolont" : "Yolont setup");
|
|
5823
5953
|
trackKeys();
|
|
@@ -5915,6 +6045,31 @@ async function offerInstallOnce() {
|
|
|
5915
6045
|
`Couldn't install it (often a permissions issue with npm's global folder). Run \`npm install -g yolont\` yourself; for permission errors see https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally`
|
|
5916
6046
|
);
|
|
5917
6047
|
}
|
|
6048
|
+
async function ensureGitleaks() {
|
|
6049
|
+
if (gitleaksWorks() || !process.stdout.isTTY) return;
|
|
6050
|
+
const help = "https://github.com/gitleaks/gitleaks#installing";
|
|
6051
|
+
if (!gitleaksAsset()) {
|
|
6052
|
+
log2.warn(`gitleaks (the secret scanner) isn't installed, so reviews will skip the LLM. Install it: ${help}`);
|
|
6053
|
+
return;
|
|
6054
|
+
}
|
|
6055
|
+
const ok = await confirm2({
|
|
6056
|
+
message: `gitleaks (the secret scanner) isn't installed. Without it, reviews never reach the LLM. Download the official v${GITLEAKS_VERSION} (checksum-verified) into ${LOCAL_GITLEAKS}?`,
|
|
6057
|
+
initialValue: true
|
|
6058
|
+
});
|
|
6059
|
+
if (isCancel2(ok) || !ok) {
|
|
6060
|
+
log2.warn(`Reviews will skip the LLM until gitleaks is installed: ${help}`);
|
|
6061
|
+
return;
|
|
6062
|
+
}
|
|
6063
|
+
const s = spinner2();
|
|
6064
|
+
s.start(`Downloading gitleaks v${GITLEAKS_VERSION}`);
|
|
6065
|
+
try {
|
|
6066
|
+
await installGitleaks();
|
|
6067
|
+
s.stop(gitleaksWorks() ? `gitleaks v${GITLEAKS_VERSION} installed.` : pc3.yellow("Downloaded, but it doesn't run on this machine."));
|
|
6068
|
+
} catch (err) {
|
|
6069
|
+
s.stop(pc3.red(`gitleaks install failed: ${describeFetchError(err)}`));
|
|
6070
|
+
log2.warn(`Install it yourself: ${help}`);
|
|
6071
|
+
}
|
|
6072
|
+
}
|
|
5918
6073
|
async function askIconsOnce() {
|
|
5919
6074
|
if (loadConfig().icons || !process.stdout.isTTY) return;
|
|
5920
6075
|
const ok = await confirm2({ message: `Do these look like icons (not boxes or "?")? ${iconSample()}`, initialValue: true });
|
|
@@ -6401,16 +6556,16 @@ async function testOrConfirm(profile, key2) {
|
|
|
6401
6556
|
}
|
|
6402
6557
|
}
|
|
6403
6558
|
function editInEditor(initial, name = "conventions.md") {
|
|
6404
|
-
const dir =
|
|
6405
|
-
const file =
|
|
6559
|
+
const dir = mkdtempSync2(join16(tmpdir3(), "yolont-edit-"));
|
|
6560
|
+
const file = join16(dir, name);
|
|
6406
6561
|
try {
|
|
6407
|
-
|
|
6562
|
+
writeFileSync10(file, initial);
|
|
6408
6563
|
const editor = process.env.VISUAL || process.env.EDITOR || "vi";
|
|
6409
|
-
const r =
|
|
6564
|
+
const r = spawnSync3(`${editor} "${file}"`, { stdio: "inherit", shell: true });
|
|
6410
6565
|
if (r.status !== 0) log2.warn(`${editor} exited with ${r.status ?? r.signal}; keeping what was saved.`);
|
|
6411
6566
|
return readFileSync14(file, "utf8");
|
|
6412
6567
|
} finally {
|
|
6413
|
-
|
|
6568
|
+
rmSync4(dir, { recursive: true, force: true });
|
|
6414
6569
|
}
|
|
6415
6570
|
}
|
|
6416
6571
|
function llmOrNull2() {
|
|
@@ -6543,7 +6698,7 @@ async function pickConventionsFile() {
|
|
|
6543
6698
|
const input = normalizePastedPath(raw, homedir2());
|
|
6544
6699
|
if (!input) return null;
|
|
6545
6700
|
const p = resolve(input);
|
|
6546
|
-
if (!
|
|
6701
|
+
if (!existsSync13(p)) {
|
|
6547
6702
|
log2.warn(`Not found: ${p}`);
|
|
6548
6703
|
continue;
|
|
6549
6704
|
}
|
|
@@ -6802,27 +6957,28 @@ function importEnv(env2, base) {
|
|
|
6802
6957
|
}
|
|
6803
6958
|
|
|
6804
6959
|
// local/legacyMigrate.ts
|
|
6805
|
-
import { copyFileSync as
|
|
6806
|
-
import { join as
|
|
6960
|
+
import { copyFileSync as copyFileSync3, existsSync as existsSync14, mkdirSync as mkdirSync11, writeFileSync as writeFileSync11 } from "node:fs";
|
|
6961
|
+
import { join as join17 } from "node:path";
|
|
6807
6962
|
import { DatabaseSync as DatabaseSync2 } from "node:sqlite";
|
|
6808
|
-
|
|
6963
|
+
init_paths();
|
|
6964
|
+
var MARKER = join17(DATA_DIR, ".legacy-migrated");
|
|
6809
6965
|
function migrateLegacyState(host, installRoot = INSTALL_ROOT) {
|
|
6810
|
-
if (
|
|
6966
|
+
if (existsSync14(MARKER)) return [];
|
|
6811
6967
|
const copied = [];
|
|
6812
|
-
|
|
6813
|
-
const legacyDb =
|
|
6814
|
-
if (
|
|
6968
|
+
mkdirSync11(DATA_DIR, { recursive: true });
|
|
6969
|
+
const legacyDb = join17(installRoot, "local", "data", "pr-score.db");
|
|
6970
|
+
if (existsSync14(legacyDb) && !existsSync14(DB_PATH)) {
|
|
6815
6971
|
const src = new DatabaseSync2(legacyDb);
|
|
6816
6972
|
src.exec(`VACUUM INTO '${DB_PATH.replace(/'/g, "''")}'`);
|
|
6817
6973
|
src.close();
|
|
6818
6974
|
copied.push(DB_PATH);
|
|
6819
6975
|
}
|
|
6820
|
-
const legacySessions =
|
|
6821
|
-
if (
|
|
6822
|
-
|
|
6976
|
+
const legacySessions = join17(installRoot, "local", "data", "review-sessions.json");
|
|
6977
|
+
if (existsSync14(legacySessions) && !existsSync14(SESSIONS_PATH)) {
|
|
6978
|
+
copyFileSync3(legacySessions, SESSIONS_PATH);
|
|
6823
6979
|
copied.push(SESSIONS_PATH);
|
|
6824
6980
|
}
|
|
6825
|
-
if (host &&
|
|
6981
|
+
if (host && existsSync14(DB_PATH)) {
|
|
6826
6982
|
const db = new DatabaseSync2(DB_PATH);
|
|
6827
6983
|
const hasProjects = !!db.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = 'projects'").get();
|
|
6828
6984
|
const projects = hasProjects ? db.prepare("SELECT path_with_namespace FROM projects").all() : [];
|
|
@@ -6830,40 +6986,43 @@ function migrateLegacyState(host, installRoot = INSTALL_ROOT) {
|
|
|
6830
6986
|
for (const { path_with_namespace: path } of projects) {
|
|
6831
6987
|
const slug = slugifyProjectPath(path);
|
|
6832
6988
|
const pairs = [
|
|
6833
|
-
[
|
|
6834
|
-
[
|
|
6835
|
-
[
|
|
6989
|
+
[join17(installRoot, "conventions", `${slug}.md`), "conventions.md"],
|
|
6990
|
+
[join17(installRoot, "zones", `${slug}.yaml`), "zones.yaml"],
|
|
6991
|
+
[join17(installRoot, "zones", `${slug}.graph.json`), "zones.graph.json"]
|
|
6836
6992
|
];
|
|
6837
6993
|
for (const [from, name] of pairs) {
|
|
6838
|
-
const to =
|
|
6839
|
-
if (!
|
|
6840
|
-
|
|
6841
|
-
|
|
6994
|
+
const to = join17(userProjectDir(host, path), name);
|
|
6995
|
+
if (!existsSync14(from) || existsSync14(to)) continue;
|
|
6996
|
+
mkdirSync11(userProjectDir(host, path), { recursive: true });
|
|
6997
|
+
copyFileSync3(from, to);
|
|
6842
6998
|
copied.push(to);
|
|
6843
6999
|
}
|
|
6844
7000
|
}
|
|
6845
7001
|
}
|
|
6846
|
-
if (host)
|
|
7002
|
+
if (host) writeFileSync11(MARKER, `${(/* @__PURE__ */ new Date()).toISOString()}
|
|
6847
7003
|
`);
|
|
6848
7004
|
return copied;
|
|
6849
7005
|
}
|
|
6850
7006
|
|
|
7007
|
+
// local/cli.ts
|
|
7008
|
+
init_paths();
|
|
7009
|
+
|
|
6851
7010
|
// local/zones/graph.ts
|
|
6852
7011
|
import { execFileSync as execFileSync4 } from "node:child_process";
|
|
6853
|
-
import { existsSync as
|
|
6854
|
-
import { join as
|
|
7012
|
+
import { existsSync as existsSync15 } from "node:fs";
|
|
7013
|
+
import { join as join18 } from "node:path";
|
|
6855
7014
|
import madge from "madge";
|
|
6856
7015
|
var CODE_FILE = /\.[cm]?[jt]sx?$/;
|
|
6857
7016
|
async function buildZoneGraph(repo, zones) {
|
|
6858
7017
|
const git4 = (...args) => execFileSync4("git", ["-C", repo, ...args], { encoding: "utf8", maxBuffer: 64 * 1024 * 1024 });
|
|
6859
7018
|
const repoFiles = git4("ls-files").split("\n").filter((f) => CODE_FILE.test(f) && !f.endsWith(".d.ts"));
|
|
6860
|
-
const tsConfig =
|
|
7019
|
+
const tsConfig = join18(repo, "tsconfig.json");
|
|
6861
7020
|
const result = await madge(
|
|
6862
|
-
repoFiles.map((f) =>
|
|
7021
|
+
repoFiles.map((f) => join18(repo, f)),
|
|
6863
7022
|
{
|
|
6864
7023
|
baseDir: repo,
|
|
6865
7024
|
fileExtensions: ["ts", "tsx", "js", "jsx", "mjs", "cjs"],
|
|
6866
|
-
tsConfig:
|
|
7025
|
+
tsConfig: existsSync15(tsConfig) ? tsConfig : void 0,
|
|
6867
7026
|
excludeRegExp: [/node_modules/],
|
|
6868
7027
|
// Lazy routes (`import()`) are exactly what must NOT count as first-load; type-only
|
|
6869
7028
|
// imports never reach the bundle.
|
|
@@ -6901,7 +7060,7 @@ async function runConfigCommand(args) {
|
|
|
6901
7060
|
if (sub === "import-env") {
|
|
6902
7061
|
if (!arg) throw new Error("Usage: yolont config import-env <path to .env>");
|
|
6903
7062
|
const path = resolve2(arg);
|
|
6904
|
-
if (!
|
|
7063
|
+
if (!existsSync16(path)) throw new Error(`No env file at ${path}`);
|
|
6905
7064
|
const { config: next, secrets, skipped } = importEnv(parseEnv(readFileSync15(path, "utf8")), config);
|
|
6906
7065
|
for (const [name, value] of Object.entries(secrets)) setSecret(name, value);
|
|
6907
7066
|
saveConfig(next);
|
|
@@ -6924,7 +7083,7 @@ async function runConfigCommand(args) {
|
|
|
6924
7083
|
return;
|
|
6925
7084
|
}
|
|
6926
7085
|
if (sub && sub !== "show") throw new Error("Usage: yolont config [show | import-env <path> | set-secret <name> | delete-secret <name>]");
|
|
6927
|
-
console.log(`Config: ${CONFIG_PATH}${
|
|
7086
|
+
console.log(`Config: ${CONFIG_PATH}${existsSync16(CONFIG_PATH) ? "" : " (not created yet)"}`);
|
|
6928
7087
|
console.log(`Secrets: ${secretBackend()}${secretBackend() === "keychain" ? "" : ` \u2014 ${CREDENTIALS_PATH}`}`);
|
|
6929
7088
|
console.log("\nForges:");
|
|
6930
7089
|
for (const f of config.forges) console.log(` ${f.host === config.defaultForge ? "*" : " "} ${f.host} ${f.type} ${forgeUrl(f)} token ${maskSecret(getSecret(`forge:${f.host}`))}`);
|
|
@@ -6943,6 +7102,7 @@ async function main() {
|
|
|
6943
7102
|
return;
|
|
6944
7103
|
}
|
|
6945
7104
|
applyConfigToEnv(loadConfig());
|
|
7105
|
+
(await Promise.resolve().then(() => (init_gitleaks(), gitleaks_exports))).useLocalGitleaks();
|
|
6946
7106
|
const sandboxed = !!(process.env.YOLONT_CONFIG_DIR || process.env.YOLONT_DATA_DIR);
|
|
6947
7107
|
const migrated = sandboxed ? [] : migrateLegacyState(process.env.CI_SERVER_URL);
|
|
6948
7108
|
if (migrated.length > 0) console.error(`[yolont] copied pre-Yolont data to the user dirs:
|
|
@@ -7065,9 +7225,9 @@ ${migrated.map((p) => ` ${p}`).join("\n")}`);
|
|
|
7065
7225
|
}
|
|
7066
7226
|
console.log(`[zones] building import graph of ${values.repo} (can take a while on big repos)\u2026`);
|
|
7067
7227
|
const graph = await buildZoneGraph(values.repo, zones);
|
|
7068
|
-
|
|
7069
|
-
const out =
|
|
7070
|
-
|
|
7228
|
+
mkdirSync12(files.dir, { recursive: true });
|
|
7229
|
+
const out = join19(files.dir, "zones.graph.json");
|
|
7230
|
+
writeFileSync12(out, `${JSON.stringify(graph, null, 2)}
|
|
7071
7231
|
`);
|
|
7072
7232
|
for (const [id, files2] of Object.entries(graph.reachable)) console.log(` ${id}: ${files2.length} file(s) reachable via import`);
|
|
7073
7233
|
console.log(`[zones] wrote ${out}${graph.sha ? ` (@ ${graph.sha.slice(0, 8)})` : ""} \u2014 for CI, commit it to the target repo as .yolont/zones.graph.json`);
|