yolont 0.3.1 → 0.5.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 CHANGED
@@ -153,7 +153,7 @@ that replay your last 20 reviews with the new weights before you save.
153
153
  - **It knows a refactor from a feature.** A refactor that changes behavior gets flagged. A bug
154
154
  fix without a regression test gets asked for one.
155
155
  - **Fails closed.** No gitleaks, no LLM call. Tokens are only ever sent to their own host.
156
- No telemetry.
156
+ No telemetry (just an opt-out npm version check).
157
157
 
158
158
  ---
159
159
 
package/dist/cli.js CHANGED
@@ -1,8 +1,77 @@
1
1
  #!/usr/bin/env node
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __esm = (fn, res, err) => function __init() {
5
+ if (err) throw err[0];
6
+ try {
7
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
8
+ } catch (e) {
9
+ throw err = [e], e;
10
+ }
11
+ };
12
+ var __export = (target, all) => {
13
+ for (var name in all)
14
+ __defProp(target, name, { get: all[name], enumerable: true });
15
+ };
16
+
17
+ // local/setup/version.ts
18
+ var version_exports = {};
19
+ __export(version_exports, {
20
+ installKind: () => installKind,
21
+ installLatest: () => installLatest,
22
+ isNewer: () => isNewer,
23
+ latestVersion: () => latestVersion,
24
+ ownVersion: () => ownVersion
25
+ });
26
+ import { spawnSync } from "node:child_process";
27
+ import { existsSync as existsSync11, readFileSync as readFileSync13 } from "node:fs";
28
+ import { dirname as dirname7, join as join14 } from "node:path";
29
+ import { fileURLToPath as fileURLToPath2 } from "node:url";
30
+ function ownVersion(from = dirname7(fileURLToPath2(import.meta.url))) {
31
+ for (let dir = from, i = 0; i < 5; dir = dirname7(dir), i++) {
32
+ const file = join14(dir, "package.json");
33
+ if (!existsSync11(file)) continue;
34
+ try {
35
+ const pkg = JSON.parse(readFileSync13(file, "utf8"));
36
+ if (pkg.name === "yolont") return pkg.version;
37
+ } catch {
38
+ }
39
+ }
40
+ return void 0;
41
+ }
42
+ function isNewer(latest, current) {
43
+ const parts = (v) => v.split(/[-+]/)[0].split(".").map((n) => Number(n) || 0);
44
+ const [a, b] = [parts(latest), parts(current)];
45
+ for (let i = 0; i < 3; i++) if ((a[i] ?? 0) !== (b[i] ?? 0)) return (a[i] ?? 0) > (b[i] ?? 0);
46
+ return false;
47
+ }
48
+ async function latestVersion(timeoutMs = 1500) {
49
+ if (process.env.YOLONT_NO_UPDATE_CHECK || process.env.CI) return void 0;
50
+ try {
51
+ const res = await fetch("https://registry.npmjs.org/yolont/latest", { signal: AbortSignal.timeout(timeoutMs) });
52
+ if (!res.ok) return void 0;
53
+ return (await res.json()).version;
54
+ } catch {
55
+ return void 0;
56
+ }
57
+ }
58
+ function installKind(script = process.argv[1] ?? "") {
59
+ if (/[\\/]_npx[\\/]/.test(script)) return "npx";
60
+ if (/[\\/]node_modules[\\/]yolont[\\/]/.test(script) || /[\\/]bin[\\/]yolont$/.test(script)) return "npm";
61
+ return "source";
62
+ }
63
+ function installLatest(version) {
64
+ return spawnSync("npm", ["install", "-g", `yolont@${version}`], { stdio: "inherit", shell: process.platform === "win32" }).status === 0;
65
+ }
66
+ var init_version = __esm({
67
+ "local/setup/version.ts"() {
68
+ "use strict";
69
+ }
70
+ });
2
71
 
3
72
  // local/cli.ts
4
- import { existsSync as existsSync14 } from "node:fs";
5
- import { join as join17, resolve as resolve2 } from "node:path";
73
+ import { existsSync as existsSync15 } from "node:fs";
74
+ import { join as join18, resolve as resolve2 } from "node:path";
6
75
  import { parseArgs } from "node:util";
7
76
 
8
77
  // local/db/client.ts
@@ -1396,6 +1465,14 @@ var OpenCodeZenProvider = class {
1396
1465
  }
1397
1466
  opts;
1398
1467
  sessionId;
1468
+ /** Errors name the host the request went to (api.openai.com, opencode.ai, …), not a fixed brand. */
1469
+ get label() {
1470
+ try {
1471
+ return new URL(this.opts.baseUrl ?? "https://opencode.ai/zen/v1").host;
1472
+ } catch {
1473
+ return "LLM gateway";
1474
+ }
1475
+ }
1399
1476
  async review(input) {
1400
1477
  const schema = buildReviewJsonSchema(input.categories.map((c) => c.name), input.zones?.map((h) => h.zone.id), !!input.reviewerFocus);
1401
1478
  const { toolCallArgs, content } = await this.stream({
@@ -1416,13 +1493,13 @@ var OpenCodeZenProvider = class {
1416
1493
  });
1417
1494
  const raw = toolCallArgs || content;
1418
1495
  if (!raw) {
1419
- throw new LlmParseError("OpenCode Zen response had neither a tool call nor message content");
1496
+ throw new LlmParseError(`${this.label} response had neither a tool call nor message content`);
1420
1497
  }
1421
1498
  let json;
1422
1499
  try {
1423
1500
  json = JSON.parse(raw);
1424
1501
  } catch (err) {
1425
- throw new LlmParseError(`OpenCode Zen response was not valid JSON: ${err.message}`, raw);
1502
+ throw new LlmParseError(`${this.label} response was not valid JSON: ${err.message}`, raw);
1426
1503
  }
1427
1504
  const parsed = LlmReviewResponseSchema.safeParse(json);
1428
1505
  if (!parsed.success) {
@@ -1432,7 +1509,7 @@ var OpenCodeZenProvider = class {
1432
1509
  }
1433
1510
  async complete(prompt) {
1434
1511
  const { content } = await this.stream({ model: this.opts.model, stream: true, messages: [{ role: "user", content: prompt }] });
1435
- if (!content) throw new LlmParseError("OpenCode Zen response had no message content");
1512
+ if (!content) throw new LlmParseError(`${this.label} response had no message content`);
1436
1513
  return content;
1437
1514
  }
1438
1515
  /** POSTs a streamed chat completion; returns the concatenated tool-call args and message content (reasoning deltas ignored). */
@@ -1451,7 +1528,7 @@ var OpenCodeZenProvider = class {
1451
1528
  body: JSON.stringify(body)
1452
1529
  });
1453
1530
  if (!res.ok) {
1454
- throw new LlmParseError(`OpenCode Zen request failed: ${res.status} ${await res.text()}`);
1531
+ throw new LlmParseError(`${this.label} request failed: ${res.status} ${await res.text()}`);
1455
1532
  }
1456
1533
  let toolCallArgs = "";
1457
1534
  let content = "";
@@ -4940,9 +5017,9 @@ function removeForge(host) {
4940
5017
  }
4941
5018
  var PROVIDER_PRESETS = [
4942
5019
  { label: "Anthropic (Claude API)", provider: "anthropic", name: "anthropic", model: "claude-opus-5-5", hint: "or claude-sonnet-5-5 \u2014 cheaper" },
4943
- { label: "OpenCode Zen", provider: "openai-compatible", name: "opencode-zen", baseUrl: "https://opencode.ai/zen/v1", model: "deepseek-v4-flash-free", hint: "has a free tier" },
5020
+ { label: "OpenCode", provider: "openai-compatible", name: "opencode", baseUrl: "https://opencode.ai/zen/v1", model: "deepseek-v4.1-flash", hint: "formerly Zen \xB7 key from opencode.ai/console" },
4944
5021
  { label: "OpenRouter", provider: "openai-compatible", name: "openrouter", baseUrl: "https://openrouter.ai/api/v1" },
4945
- { label: "OpenAI", provider: "openai-compatible", name: "openai", baseUrl: "https://api.openai.com/v1" },
5022
+ { label: "OpenAI", provider: "openai-compatible", name: "openai", baseUrl: "https://api.openai.com/v1", hint: "an OpenAI model id (gpt-\u2026), not another gateway's" },
4946
5023
  { label: "Other OpenAI-compatible gateway", provider: "openai-compatible", name: "gateway" },
4947
5024
  { label: "Ollama (local, offline)", provider: "ollama", name: "ollama", baseUrl: "http://localhost:11434", model: "qwen2.5-coder", hint: "no key" }
4948
5025
  ];
@@ -5594,12 +5671,12 @@ async function startDashboard(opts = {}) {
5594
5671
  }
5595
5672
 
5596
5673
  // local/cli.ts
5597
- import { mkdirSync as mkdirSync11, readFileSync as readFileSync14, writeFileSync as writeFileSync11 } from "node:fs";
5674
+ import { mkdirSync as mkdirSync11, readFileSync as readFileSync15, writeFileSync as writeFileSync11 } from "node:fs";
5598
5675
  import { parseEnv } from "node:util";
5599
5676
  import { password as password2 } from "@clack/prompts";
5600
5677
 
5601
5678
  // local/setup/wizard.ts
5602
- import { execFileSync as execFileSync3, spawnSync } from "node:child_process";
5679
+ import { execFileSync as execFileSync3, spawnSync as spawnSync2 } from "node:child_process";
5603
5680
 
5604
5681
  // local/setup/ui.ts
5605
5682
  import pc2 from "picocolors";
@@ -5679,12 +5756,13 @@ function panel(title, rows) {
5679
5756
  }
5680
5757
 
5681
5758
  // local/setup/wizard.ts
5682
- import { existsSync as existsSync11, mkdtempSync, readFileSync as readFileSync13, rmSync as rmSync3, statSync, writeFileSync as writeFileSync9 } from "node:fs";
5759
+ import { existsSync as existsSync12, mkdtempSync, readFileSync as readFileSync14, rmSync as rmSync3, statSync, writeFileSync as writeFileSync9 } from "node:fs";
5683
5760
  import { homedir as homedir2, tmpdir as tmpdir2, userInfo as userInfo2 } from "node:os";
5684
5761
  import { emitKeypressEvents } from "node:readline";
5685
- import { join as join14, resolve } from "node:path";
5762
+ import { join as join15, resolve } from "node:path";
5686
5763
  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";
5687
5764
  import pc3 from "picocolors";
5765
+ init_version();
5688
5766
  var Cancelled = class extends Error {
5689
5767
  };
5690
5768
  var Back = class extends Error {
@@ -5736,7 +5814,9 @@ function originAddress() {
5736
5814
  }
5737
5815
  var gitlabBases2 = () => loadConfig().forges.filter((f) => f.type === "gitlab" && f.url).map(forgeUrl);
5738
5816
  async function runSetup(opts) {
5739
- header("PR reviews that look twice \xB7 Esc = back \xB7 Ctrl-C = quit");
5817
+ const version = ownVersion();
5818
+ latestCheck = latestVersion();
5819
+ header(`${version ? `v${version} \xB7 ` : ""}PR reviews that look twice \xB7 Esc = back \xB7 Ctrl-C = quit`);
5740
5820
  await offerInstallOnce();
5741
5821
  await askIconsOnce();
5742
5822
  intro2(opts.review ? "Yolont" : "Yolont setup");
@@ -5796,14 +5876,32 @@ async function reviewThenCheckQuit(ctx, mrIid) {
5796
5876
  if (lastKey === "ctrl-c") throw new Cancelled();
5797
5877
  }
5798
5878
  var STEP_ICONS = { forge: "git", llm: "llm", conventions: "conventions", zones: "zones", weights: "weights" };
5799
- var runningFromNpx = (script = process.argv[1] ?? "") => /[\\/]_npx[\\/]/.test(script);
5879
+ var runningFromNpx = (script = process.argv[1] ?? "") => installKind(script) === "npx";
5880
+ var latestCheck = Promise.resolve(void 0);
5881
+ async function newerVersion() {
5882
+ const [current, latest] = [ownVersion(), await Promise.race([latestCheck, new Promise((r) => setTimeout(() => r(void 0), 300))])];
5883
+ return current && latest && isNewer(latest, current) ? latest : void 0;
5884
+ }
5885
+ async function updateMenu(latest) {
5886
+ const kind = installKind();
5887
+ if (kind === "source") {
5888
+ log2.info(`This is a source checkout. Update it with ${pc3.bold("git pull && npm ci")}, or install the package: ${pc3.bold(`npm install -g yolont@${latest}`)}`);
5889
+ return;
5890
+ }
5891
+ if (kind === "npx") {
5892
+ log2.info(`Run ${pc3.bold("npx yolont@latest")} next time, or install it once: ${pc3.bold(`npm install -g yolont@${latest}`)}`);
5893
+ return;
5894
+ }
5895
+ if (!await ask(confirm2({ message: `Update to v${latest}? (npm install -g yolont@${latest})`, initialValue: true }))) return;
5896
+ if (installLatest(latest)) {
5897
+ outro2(`Updated to v${latest}. Run ${pc3.bold("yolont")} again to use it.`);
5898
+ process.exit(0);
5899
+ }
5900
+ log2.warn("npm couldn't update it (often a permissions issue): https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally");
5901
+ }
5800
5902
  async function offerInstallOnce() {
5801
5903
  if (!runningFromNpx() || loadConfig().installOffered || !process.stdout.isTTY) return;
5802
- let version = "latest";
5803
- try {
5804
- version = JSON.parse(readFileSync13(new URL("../package.json", import.meta.url), "utf8")).version ?? version;
5805
- } catch {
5806
- }
5904
+ const version = ownVersion() ?? "latest";
5807
5905
  const ok = await confirm2({ message: `Install the \`yolont\` command, so next time you just type \`yolont\`? (npm install -g yolont@${version})`, initialValue: true });
5808
5906
  if (isCancel2(ok)) return;
5809
5907
  saveConfig({ ...loadConfig(), installOffered: true });
@@ -5811,8 +5909,7 @@ async function offerInstallOnce() {
5811
5909
  log2.info(pc3.dim("OK. Install it any time with `npm install -g yolont`."));
5812
5910
  return;
5813
5911
  }
5814
- const res = spawnSync("npm", ["install", "-g", `yolont@${version}`], { stdio: "inherit", shell: process.platform === "win32" });
5815
- if (res.status === 0) log2.success(`Installed. From now on run ${pc3.bold("yolont")} (no npx).`);
5912
+ if (installLatest(version)) log2.success(`Installed. From now on run ${pc3.bold("yolont")} (no npx).`);
5816
5913
  else
5817
5914
  log2.warn(
5818
5915
  `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`
@@ -5825,19 +5922,21 @@ async function askIconsOnce() {
5825
5922
  saveConfig({ ...loadConfig(), icons: ok ? "nerd" : "plain" });
5826
5923
  log2.info(pc3.dim(ok ? "Nerd Font icons on. Turn off with `icons: plain` in config.yaml." : "Plain text. Install a Nerd Font and set `icons: nerd` in config.yaml for icons."));
5827
5924
  }
5828
- function statusPanel(ctx, teamLabel) {
5925
+ function statusPanel(ctx, teamLabel, latest) {
5829
5926
  const config = loadConfig();
5830
5927
  const llm = config.llmProfiles.find((p) => p.name === config.defaultLlmProfile);
5831
5928
  panel("Yolont", [
5832
5929
  [`${icon(ctx.forge.type === "github" ? "github" : "gitlab")}Project`, `${pc3.bold(ctx.address.projectPath)} ${pc3.dim(`\xB7 ${ctx.address.host}`)}`],
5833
5930
  [`${icon("llm")}LLM`, llm ? `${llm.name} ${pc3.dim(`\xB7 ${llm.model}`)}` : pc3.yellow("not set")],
5834
5931
  [`${icon("memory")}Memory`, teamLabel.replace(/^Memory repo( · )?/, "") || "\u2014"],
5835
- [`${icon("type")}Change type`, CHANGE_TYPE_MODES[config.changeType ?? "label"].label]
5932
+ [`${icon("type")}Change type`, CHANGE_TYPE_MODES[config.changeType ?? "label"].label],
5933
+ [`${icon("sync")}Version`, `v${ownVersion() ?? "?"}${latest ? pc3.yellow(` \xB7 v${latest} is out`) : ""}`]
5836
5934
  ]);
5837
5935
  }
5838
5936
  var STEP_LABELS = { forge: "Git host & token", llm: "LLM", conventions: "Conventions", zones: "Zones", weights: "Scoring weights" };
5839
5937
  async function mainMenu(ctx, opts) {
5840
- statusPanel(ctx, await teamMenuLabel(ctx.address));
5938
+ const latest = await newerVersion();
5939
+ statusPanel(ctx, await teamMenuLabel(ctx.address), latest);
5841
5940
  for (; ; ) {
5842
5941
  const missing = missingSteps({ host: ctx.address.host, projectPath: ctx.address.projectPath });
5843
5942
  const teamLabel = await teamMenuLabel(ctx.address);
@@ -5848,6 +5947,7 @@ async function mainMenu(ctx, opts) {
5848
5947
  message: `${ctx.address.projectPath} \xB7 ${ctx.address.host}`,
5849
5948
  options: [
5850
5949
  { value: "review", label: `${icon("review")}${pc3.bold("Review an open MR/PR")}` },
5950
+ ...latest ? [{ value: "update", label: pc3.yellow(`${icon("sync")}Update to v${latest}`), hint: `you have v${ownVersion()}` }] : [],
5851
5951
  ...Object.keys(STEP_LABELS).map((s) => ({
5852
5952
  value: s,
5853
5953
  label: `${missing.includes(s) ? pc3.red(nerdIcons() ? icon("missing") : "\u2717 ") : pc3.green(nerdIcons() ? icon("ok") : "\u2713 ")}${icon(STEP_ICONS[s])}${STEP_LABELS[s]}`
@@ -5864,6 +5964,10 @@ async function mainMenu(ctx, opts) {
5864
5964
  throw err;
5865
5965
  }
5866
5966
  if (choice === "exit") return;
5967
+ if (choice === "update") {
5968
+ await orBack(() => updateMenu(latest));
5969
+ continue;
5970
+ }
5867
5971
  if (choice === "remove") {
5868
5972
  await orBack(() => removeMenu(ctx.address));
5869
5973
  continue;
@@ -6297,14 +6401,14 @@ async function testOrConfirm(profile, key2) {
6297
6401
  }
6298
6402
  }
6299
6403
  function editInEditor(initial, name = "conventions.md") {
6300
- const dir = mkdtempSync(join14(tmpdir2(), "yolont-edit-"));
6301
- const file = join14(dir, name);
6404
+ const dir = mkdtempSync(join15(tmpdir2(), "yolont-edit-"));
6405
+ const file = join15(dir, name);
6302
6406
  try {
6303
6407
  writeFileSync9(file, initial);
6304
6408
  const editor = process.env.VISUAL || process.env.EDITOR || "vi";
6305
- const r = spawnSync(`${editor} "${file}"`, { stdio: "inherit", shell: true });
6409
+ const r = spawnSync2(`${editor} "${file}"`, { stdio: "inherit", shell: true });
6306
6410
  if (r.status !== 0) log2.warn(`${editor} exited with ${r.status ?? r.signal}; keeping what was saved.`);
6307
- return readFileSync13(file, "utf8");
6411
+ return readFileSync14(file, "utf8");
6308
6412
  } finally {
6309
6413
  rmSync3(dir, { recursive: true, force: true });
6310
6414
  }
@@ -6337,9 +6441,9 @@ async function conventionsStep(forge, address, change, opts) {
6337
6441
  log2.info(`Conventions come from the repo's ${cur.path} \u2014 edit them there (it's what CI uses too).`);
6338
6442
  return;
6339
6443
  }
6340
- if (cur.path && opts.conventions === "edit") return approve(host, projectPath, editInEditor(readFileSync13(cur.path, "utf8")), "", null);
6444
+ if (cur.path && opts.conventions === "edit") return approve(host, projectPath, editInEditor(readFileSync14(cur.path, "utf8")), "", null);
6341
6445
  if (cur.path && !opts.conventions) {
6342
- const text0 = readFileSync13(cur.path, "utf8");
6446
+ const text0 = readFileSync14(cur.path, "utf8");
6343
6447
  const keep = await ask(
6344
6448
  select2({
6345
6449
  message: `Conventions: ${cur.path} (${lineCount(text0)} lines)`,
@@ -6372,7 +6476,7 @@ async function conventionsStep(forge, address, change, opts) {
6372
6476
  })
6373
6477
  );
6374
6478
  if (how === "repo") return approve(host, projectPath, repoFile, "", null);
6375
- if (how === "suggest") return approve(host, projectPath, readFileSync13(suggestion, "utf8"), "", null);
6479
+ if (how === "suggest") return approve(host, projectPath, readFileSync14(suggestion, "utf8"), "", null);
6376
6480
  if (how === "editor") return approve(host, projectPath, "", "", null);
6377
6481
  if (how === "file") {
6378
6482
  const text0 = await pickConventionsFile();
@@ -6439,7 +6543,7 @@ async function pickConventionsFile() {
6439
6543
  const input = normalizePastedPath(raw, homedir2());
6440
6544
  if (!input) return null;
6441
6545
  const p = resolve(input);
6442
- if (!existsSync11(p)) {
6546
+ if (!existsSync12(p)) {
6443
6547
  log2.warn(`Not found: ${p}`);
6444
6548
  continue;
6445
6549
  }
@@ -6447,7 +6551,7 @@ async function pickConventionsFile() {
6447
6551
  log2.warn(`That's a folder, not a file: ${p}`);
6448
6552
  continue;
6449
6553
  }
6450
- const text0 = readFileSync13(p, "utf8");
6554
+ const text0 = readFileSync14(p, "utf8");
6451
6555
  if (text0.includes("\0")) {
6452
6556
  log2.warn("That looks like a binary file.");
6453
6557
  continue;
@@ -6499,7 +6603,7 @@ async function zonesStep(forge, address, change, opts) {
6499
6603
  return;
6500
6604
  }
6501
6605
  if (cur.path && (opts.zones === "edit" || !opts.zones)) {
6502
- const raw0 = readFileSync13(cur.path, "utf8");
6606
+ const raw0 = readFileSync14(cur.path, "utf8");
6503
6607
  if (opts.zones === "edit") return saveZonesLoop(host, projectPath, editInEditor(raw0, "zones.yaml"), cur.graph);
6504
6608
  const keep = await ask(
6505
6609
  select2({
@@ -6698,27 +6802,27 @@ function importEnv(env2, base) {
6698
6802
  }
6699
6803
 
6700
6804
  // local/legacyMigrate.ts
6701
- import { copyFileSync as copyFileSync2, existsSync as existsSync12, mkdirSync as mkdirSync10, writeFileSync as writeFileSync10 } from "node:fs";
6702
- import { join as join15 } from "node:path";
6805
+ import { copyFileSync as copyFileSync2, existsSync as existsSync13, mkdirSync as mkdirSync10, writeFileSync as writeFileSync10 } from "node:fs";
6806
+ import { join as join16 } from "node:path";
6703
6807
  import { DatabaseSync as DatabaseSync2 } from "node:sqlite";
6704
- var MARKER = join15(DATA_DIR, ".legacy-migrated");
6808
+ var MARKER = join16(DATA_DIR, ".legacy-migrated");
6705
6809
  function migrateLegacyState(host, installRoot = INSTALL_ROOT) {
6706
- if (existsSync12(MARKER)) return [];
6810
+ if (existsSync13(MARKER)) return [];
6707
6811
  const copied = [];
6708
6812
  mkdirSync10(DATA_DIR, { recursive: true });
6709
- const legacyDb = join15(installRoot, "local", "data", "pr-score.db");
6710
- if (existsSync12(legacyDb) && !existsSync12(DB_PATH)) {
6813
+ const legacyDb = join16(installRoot, "local", "data", "pr-score.db");
6814
+ if (existsSync13(legacyDb) && !existsSync13(DB_PATH)) {
6711
6815
  const src = new DatabaseSync2(legacyDb);
6712
6816
  src.exec(`VACUUM INTO '${DB_PATH.replace(/'/g, "''")}'`);
6713
6817
  src.close();
6714
6818
  copied.push(DB_PATH);
6715
6819
  }
6716
- const legacySessions = join15(installRoot, "local", "data", "review-sessions.json");
6717
- if (existsSync12(legacySessions) && !existsSync12(SESSIONS_PATH)) {
6820
+ const legacySessions = join16(installRoot, "local", "data", "review-sessions.json");
6821
+ if (existsSync13(legacySessions) && !existsSync13(SESSIONS_PATH)) {
6718
6822
  copyFileSync2(legacySessions, SESSIONS_PATH);
6719
6823
  copied.push(SESSIONS_PATH);
6720
6824
  }
6721
- if (host && existsSync12(DB_PATH)) {
6825
+ if (host && existsSync13(DB_PATH)) {
6722
6826
  const db = new DatabaseSync2(DB_PATH);
6723
6827
  const hasProjects = !!db.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = 'projects'").get();
6724
6828
  const projects = hasProjects ? db.prepare("SELECT path_with_namespace FROM projects").all() : [];
@@ -6726,13 +6830,13 @@ function migrateLegacyState(host, installRoot = INSTALL_ROOT) {
6726
6830
  for (const { path_with_namespace: path } of projects) {
6727
6831
  const slug = slugifyProjectPath(path);
6728
6832
  const pairs = [
6729
- [join15(installRoot, "conventions", `${slug}.md`), "conventions.md"],
6730
- [join15(installRoot, "zones", `${slug}.yaml`), "zones.yaml"],
6731
- [join15(installRoot, "zones", `${slug}.graph.json`), "zones.graph.json"]
6833
+ [join16(installRoot, "conventions", `${slug}.md`), "conventions.md"],
6834
+ [join16(installRoot, "zones", `${slug}.yaml`), "zones.yaml"],
6835
+ [join16(installRoot, "zones", `${slug}.graph.json`), "zones.graph.json"]
6732
6836
  ];
6733
6837
  for (const [from, name] of pairs) {
6734
- const to = join15(userProjectDir(host, path), name);
6735
- if (!existsSync12(from) || existsSync12(to)) continue;
6838
+ const to = join16(userProjectDir(host, path), name);
6839
+ if (!existsSync13(from) || existsSync13(to)) continue;
6736
6840
  mkdirSync10(userProjectDir(host, path), { recursive: true });
6737
6841
  copyFileSync2(from, to);
6738
6842
  copied.push(to);
@@ -6746,20 +6850,20 @@ function migrateLegacyState(host, installRoot = INSTALL_ROOT) {
6746
6850
 
6747
6851
  // local/zones/graph.ts
6748
6852
  import { execFileSync as execFileSync4 } from "node:child_process";
6749
- import { existsSync as existsSync13 } from "node:fs";
6750
- import { join as join16 } from "node:path";
6853
+ import { existsSync as existsSync14 } from "node:fs";
6854
+ import { join as join17 } from "node:path";
6751
6855
  import madge from "madge";
6752
6856
  var CODE_FILE = /\.[cm]?[jt]sx?$/;
6753
6857
  async function buildZoneGraph(repo, zones) {
6754
6858
  const git4 = (...args) => execFileSync4("git", ["-C", repo, ...args], { encoding: "utf8", maxBuffer: 64 * 1024 * 1024 });
6755
6859
  const repoFiles = git4("ls-files").split("\n").filter((f) => CODE_FILE.test(f) && !f.endsWith(".d.ts"));
6756
- const tsConfig = join16(repo, "tsconfig.json");
6860
+ const tsConfig = join17(repo, "tsconfig.json");
6757
6861
  const result = await madge(
6758
- repoFiles.map((f) => join16(repo, f)),
6862
+ repoFiles.map((f) => join17(repo, f)),
6759
6863
  {
6760
6864
  baseDir: repo,
6761
6865
  fileExtensions: ["ts", "tsx", "js", "jsx", "mjs", "cjs"],
6762
- tsConfig: existsSync13(tsConfig) ? tsConfig : void 0,
6866
+ tsConfig: existsSync14(tsConfig) ? tsConfig : void 0,
6763
6867
  excludeRegExp: [/node_modules/],
6764
6868
  // Lazy routes (`import()`) are exactly what must NOT count as first-load; type-only
6765
6869
  // imports never reach the bundle.
@@ -6797,8 +6901,8 @@ async function runConfigCommand(args) {
6797
6901
  if (sub === "import-env") {
6798
6902
  if (!arg) throw new Error("Usage: yolont config import-env <path to .env>");
6799
6903
  const path = resolve2(arg);
6800
- if (!existsSync14(path)) throw new Error(`No env file at ${path}`);
6801
- const { config: next, secrets, skipped } = importEnv(parseEnv(readFileSync14(path, "utf8")), config);
6904
+ if (!existsSync15(path)) throw new Error(`No env file at ${path}`);
6905
+ const { config: next, secrets, skipped } = importEnv(parseEnv(readFileSync15(path, "utf8")), config);
6802
6906
  for (const [name, value] of Object.entries(secrets)) setSecret(name, value);
6803
6907
  saveConfig(next);
6804
6908
  console.log(`Wrote ${CONFIG_PATH}; ${Object.keys(secrets).length} secret(s) saved to ${secretBackend()}.`);
@@ -6820,7 +6924,7 @@ async function runConfigCommand(args) {
6820
6924
  return;
6821
6925
  }
6822
6926
  if (sub && sub !== "show") throw new Error("Usage: yolont config [show | import-env <path> | set-secret <name> | delete-secret <name>]");
6823
- console.log(`Config: ${CONFIG_PATH}${existsSync14(CONFIG_PATH) ? "" : " (not created yet)"}`);
6927
+ console.log(`Config: ${CONFIG_PATH}${existsSync15(CONFIG_PATH) ? "" : " (not created yet)"}`);
6824
6928
  console.log(`Secrets: ${secretBackend()}${secretBackend() === "keychain" ? "" : ` \u2014 ${CREDENTIALS_PATH}`}`);
6825
6929
  console.log("\nForges:");
6826
6930
  for (const f of config.forges) console.log(` ${f.host === config.defaultForge ? "*" : " "} ${f.host} ${f.type} ${forgeUrl(f)} token ${maskSecret(getSecret(`forge:${f.host}`))}`);
@@ -6833,6 +6937,11 @@ Jev: key ${maskSecret(getSecret("jev"))}${config.jev?.disabled ? " (disabled)" :
6833
6937
  async function main() {
6834
6938
  const [command, ...rest] = process.argv.slice(2);
6835
6939
  if (command === "config") return runConfigCommand(rest);
6940
+ if (command === "--version" || command === "-v" || command === "version") {
6941
+ const { ownVersion: ownVersion2 } = await Promise.resolve().then(() => (init_version(), version_exports));
6942
+ console.log(ownVersion2() ?? "unknown");
6943
+ return;
6944
+ }
6836
6945
  applyConfigToEnv(loadConfig());
6837
6946
  const sandboxed = !!(process.env.YOLONT_CONFIG_DIR || process.env.YOLONT_DATA_DIR);
6838
6947
  const migrated = sandboxed ? [] : migrateLegacyState(process.env.CI_SERVER_URL);
@@ -6957,7 +7066,7 @@ ${migrated.map((p) => ` ${p}`).join("\n")}`);
6957
7066
  console.log(`[zones] building import graph of ${values.repo} (can take a while on big repos)\u2026`);
6958
7067
  const graph = await buildZoneGraph(values.repo, zones);
6959
7068
  mkdirSync11(files.dir, { recursive: true });
6960
- const out = join17(files.dir, "zones.graph.json");
7069
+ const out = join18(files.dir, "zones.graph.json");
6961
7070
  writeFileSync11(out, `${JSON.stringify(graph, null, 2)}
6962
7071
  `);
6963
7072
  for (const [id, files2] of Object.entries(graph.reachable)) console.log(` ${id}: ${files2.length} file(s) reachable via import`);