@chrisdudek/yg 5.0.1 → 5.0.3

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/dist/bin.js CHANGED
@@ -1018,10 +1018,24 @@ async function fetchOllamaModels(endpoint) {
1018
1018
  }
1019
1019
  }
1020
1020
 
1021
- // src/llm/reviewer-test.ts
1021
+ // src/utils/binary-check.ts
1022
1022
  import { execFile } from "child_process";
1023
1023
  import { promisify } from "util";
1024
1024
  var execFileAsync = promisify(execFile);
1025
+ async function binaryAvailable(binary) {
1026
+ try {
1027
+ await execFileAsync(binary, ["--version"], {
1028
+ timeout: 1e4,
1029
+ shell: process.platform === "win32"
1030
+ });
1031
+ return true;
1032
+ } catch (err) {
1033
+ debugWrite(`[binary-check] ${binary} --version: ${err.message}`);
1034
+ return false;
1035
+ }
1036
+ }
1037
+
1038
+ // src/llm/reviewer-test.ts
1025
1039
  var CLI_BINARIES = {
1026
1040
  "claude-code": "claude",
1027
1041
  "codex": "codex",
@@ -1053,14 +1067,10 @@ async function testCliProvider(provider) {
1053
1067
  if (!binary) {
1054
1068
  return { ok: false, error: `Unsupported CLI provider: ${provider}` };
1055
1069
  }
1056
- try {
1057
- await execFileAsync("which", [binary], { timeout: 5e3 });
1070
+ if (await binaryAvailable(binary)) {
1058
1071
  return { ok: true };
1059
- } catch (err) {
1060
- const msg = `'${binary}' not found on PATH`;
1061
- debugWrite(`[reviewer-test] testCliProvider(${provider}): ${err.message}`);
1062
- return { ok: false, error: msg };
1063
1072
  }
1073
+ return { ok: false, error: `'${binary}' could not be run \u2014 is it installed and on PATH?` };
1064
1074
  }
1065
1075
  async function testAnthropic(apiKey, model, endpoint) {
1066
1076
  const res = await fetch(`${endpoint}/messages`, {
@@ -5379,9 +5389,25 @@ async function walkRepoFiles(projectRoot) {
5379
5389
  // src/io/hash.ts
5380
5390
  var require3 = createRequire2(import.meta.url);
5381
5391
  var ignoreFactory2 = require3("ignore");
5392
+ var CR = 13;
5393
+ var LF = 10;
5394
+ function normalizeLineEndings(bytes) {
5395
+ if (!bytes.includes(CR)) return bytes;
5396
+ const out = Buffer.allocUnsafe(bytes.length);
5397
+ let w = 0;
5398
+ for (let i = 0; i < bytes.length; i++) {
5399
+ if (bytes[i] === CR) {
5400
+ out[w++] = LF;
5401
+ if (bytes[i + 1] === LF) i++;
5402
+ } else {
5403
+ out[w++] = bytes[i];
5404
+ }
5405
+ }
5406
+ return out.subarray(0, w);
5407
+ }
5382
5408
  async function hashFile(filePath) {
5383
5409
  const content14 = await readFile14(filePath);
5384
- return createHash("sha256").update(content14).digest("hex");
5410
+ return hashBytes(content14);
5385
5411
  }
5386
5412
  async function loadRootGitignoreStack2(projectRoot) {
5387
5413
  if (!projectRoot) return [];
@@ -5406,7 +5432,7 @@ function hashString(content14) {
5406
5432
  return createHash("sha256").update(content14).digest("hex");
5407
5433
  }
5408
5434
  function hashBytes(bytes) {
5409
- return createHash("sha256").update(bytes).digest("hex");
5435
+ return createHash("sha256").update(normalizeLineEndings(bytes)).digest("hex");
5410
5436
  }
5411
5437
  async function collectDirectoryFilePaths(directoryPath, rootDirectoryPath, options) {
5412
5438
  let stack = options.gitignoreStack ?? [];
@@ -13208,10 +13234,7 @@ async function apiFetch(url, init2, providerName, timeoutMs = 6e4) {
13208
13234
 
13209
13235
  // src/llm/cli-base.ts
13210
13236
  import { spawn } from "child_process";
13211
- import { execFile as execFile2 } from "child_process";
13212
13237
  import { tmpdir } from "os";
13213
- import { promisify as promisify2 } from "util";
13214
- var execFileAsync2 = promisify2(execFile2);
13215
13238
  function coerceBool(v) {
13216
13239
  if (typeof v === "boolean") return v;
13217
13240
  if (typeof v === "string") {
@@ -13310,13 +13333,7 @@ var CliAgentProvider = class {
13310
13333
  this.timeout = config.timeout ?? 3e5;
13311
13334
  }
13312
13335
  async isAvailable() {
13313
- try {
13314
- await execFileAsync2("which", [this.binary], { timeout: 5e3 });
13315
- return true;
13316
- } catch (err) {
13317
- debugWrite(`[${this.binary}] isAvailable: ${err.message}`);
13318
- return false;
13319
- }
13336
+ return binaryAvailable(this.binary);
13320
13337
  }
13321
13338
  async verifyAspect(prompt) {
13322
13339
  const fallback = { satisfied: false, reason: "Reviewer unavailable", errorSource: "provider" };
@@ -16015,8 +16032,8 @@ import path51 from "path";
16015
16032
 
16016
16033
  // src/utils/git-introspect.ts
16017
16034
  import { exec } from "child_process";
16018
- import { promisify as promisify3 } from "util";
16019
- var execp = promisify3(exec);
16035
+ import { promisify as promisify2 } from "util";
16036
+ var execp = promisify2(exec);
16020
16037
  async function isMergeCommit(repoCwd, ref) {
16021
16038
  try {
16022
16039
  const { stdout } = await execp(`git rev-list --parents -n 1 ${ref}`, { cwd: repoCwd });
package/dist/structure.js CHANGED
@@ -795,6 +795,22 @@ var ignoreFactory = require2("ignore");
795
795
  // src/io/hash.ts
796
796
  var require3 = createRequire3(import.meta.url);
797
797
  var ignoreFactory2 = require3("ignore");
798
+ var CR = 13;
799
+ var LF = 10;
800
+ function normalizeLineEndings(bytes) {
801
+ if (!bytes.includes(CR)) return bytes;
802
+ const out = Buffer.allocUnsafe(bytes.length);
803
+ let w = 0;
804
+ for (let i = 0; i < bytes.length; i++) {
805
+ if (bytes[i] === CR) {
806
+ out[w++] = LF;
807
+ if (bytes[i + 1] === LF) i++;
808
+ } else {
809
+ out[w++] = bytes[i];
810
+ }
811
+ }
812
+ return out.subarray(0, w);
813
+ }
798
814
  async function loadRootGitignoreStack2(projectRoot) {
799
815
  if (!projectRoot) return [];
800
816
  try {
@@ -818,7 +834,7 @@ function hashString(content) {
818
834
  return createHash("sha256").update(content).digest("hex");
819
835
  }
820
836
  function hashBytes(bytes) {
821
- return createHash("sha256").update(bytes).digest("hex");
837
+ return createHash("sha256").update(normalizeLineEndings(bytes)).digest("hex");
822
838
  }
823
839
  async function collectDirectoryFilePaths(directoryPath, rootDirectoryPath, options) {
824
840
  let stack = options.gitignoreStack ?? [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chrisdudek/yg",
3
- "version": "5.0.1",
3
+ "version": "5.0.3",
4
4
  "description": "Architecture rules your AI coding agent can't ignore. It gets the rules for a file before it edits, and every change is checked — by a free local script or an LLM reviewer — before it moves on. Works with Claude Code, Cursor, Copilot, Codex, Cline.",
5
5
  "type": "module",
6
6
  "bin": {