@bman654/clodex 2.6.1 → 2.6.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/cli.js CHANGED
@@ -374,7 +374,7 @@ import { join } from "path";
374
374
  // package.json
375
375
  var package_default = {
376
376
  name: "@bman654/clodex",
377
- version: "2.6.1",
377
+ version: "2.6.3",
378
378
  publishConfig: {
379
379
  access: "public"
380
380
  },
@@ -17061,7 +17061,7 @@ function collectPristineFacts(args) {
17061
17061
  }
17062
17062
 
17063
17063
  // src/patch-transforms.ts
17064
- var PATCH_TRANSFORMS_VERSION = 6;
17064
+ var PATCH_TRANSFORMS_VERSION = 8;
17065
17065
  var NATIVE_EFFORT_LEVELS = ["low", "medium", "high", "xhigh", "max"];
17066
17066
  var BASE_EFFORT_LEVELS = ["low", "medium", "high"];
17067
17067
  function projectNativeEffort(effort) {
@@ -17240,14 +17240,18 @@ function applyClodexPatches(source, config) {
17240
17240
  // old adhoc-patch ASCII-only constraint no longer applies.)
17241
17241
  (a) => "{value:" + q(a) + ",label:" + q(a.charAt(0).toUpperCase() + a.slice(1)) + ",description:" + q(displayFor(a, ALIAS_TO_ID[a])) + "}"
17242
17242
  ).join(",");
17243
- const inject = missing.length ? "[" + entries + "].forEach(function(_o){if(!e.some(function(_i){return _i.value===_o.value}))e.push(_o)});" : "";
17243
+ const injectInto = (options) => missing.length ? "[" + entries + "].forEach(function(_o){if(!" + options + ".some(function(_i){return _i.value===_o.value}))" + options + ".push(_o)});" : "";
17244
+ const pickerSite = "PATCH 5: model picker options";
17245
+ const modelSelections = [...js.matchAll(/\(([\w$]+)==="opus"\|\|\1==="sonnet"\)/g)];
17244
17246
  if (ALIASES.length === 0) {
17245
- log12("SKIP", "PATCH 5: model picker options", "no aliases configured");
17247
+ log12("SKIP", pickerSite, "no aliases configured");
17248
+ } else if (modelSelections.length !== 1) {
17249
+ log12("FAIL", pickerSite, "model selection appears " + modelSelections.length + " times (expected 1)");
17246
17250
  } else {
17247
17251
  applyOnce(
17248
- "PATCH 5: model picker options",
17249
- /(\?\[[\w$]+,r\]:\[r\];for\(let [\w$]+ of [\w$]+\)[\w$]+\(e,[\w$]+,t\);)/,
17250
- (m) => m + inject,
17252
+ pickerSite,
17253
+ /\(([\w$]+)==="opus"\|\|\1==="sonnet"\)[^;{}]*\?\[\1,([\w$]+)\]:\[\2\];for\(let ([\w$]+) of [\w$]+\)[\w$]+\(([\w$]+),\3,[\w$]+\);/,
17254
+ (m, _selected, _requested, _item, options) => m + injectInto(options),
17251
17255
  { required: false, noopIsSkip: true }
17252
17256
  );
17253
17257
  }
@@ -17370,11 +17374,87 @@ function applyClodexPatches(source, config) {
17370
17374
  '"OTEL_"',
17371
17375
  "CLAUDE_CODE_OTEL_DIAG_STDERR"
17372
17376
  ];
17377
+ const blockEndIndex = (text5, open2) => {
17378
+ const depths = [0];
17379
+ const templates = [false];
17380
+ for (let i = open2; i < text5.length; i++) {
17381
+ const ch = text5[i];
17382
+ const inTemplate = templates[templates.length - 1];
17383
+ if (inTemplate) {
17384
+ if (ch === "\\") {
17385
+ i++;
17386
+ continue;
17387
+ }
17388
+ if (ch === "`") {
17389
+ templates.pop();
17390
+ depths.pop();
17391
+ continue;
17392
+ }
17393
+ if (ch === "$" && text5[i + 1] === "{") {
17394
+ templates.push(false);
17395
+ depths.push(0);
17396
+ i++;
17397
+ }
17398
+ continue;
17399
+ }
17400
+ if (ch === "\\") {
17401
+ i++;
17402
+ continue;
17403
+ }
17404
+ if (ch === '"' || ch === "'") {
17405
+ const quote = ch;
17406
+ for (i++; i < text5.length; i++) {
17407
+ if (text5[i] === "\\") {
17408
+ i++;
17409
+ continue;
17410
+ }
17411
+ if (text5[i] === quote) break;
17412
+ }
17413
+ continue;
17414
+ }
17415
+ if (ch === "`") {
17416
+ templates.push(true);
17417
+ depths.push(0);
17418
+ continue;
17419
+ }
17420
+ if (ch === "/" && text5[i + 1] === "/") {
17421
+ while (i < text5.length && text5[i] !== "\n") i++;
17422
+ continue;
17423
+ }
17424
+ if (ch === "/" && text5[i + 1] === "*") {
17425
+ i = text5.indexOf("*/", i + 2);
17426
+ if (i < 0) return -1;
17427
+ i++;
17428
+ continue;
17429
+ }
17430
+ if (ch === "{") {
17431
+ depths[depths.length - 1]++;
17432
+ continue;
17433
+ }
17434
+ if (ch === "}") {
17435
+ if (depths[depths.length - 1] === 0 && templates.length > 1) {
17436
+ templates.pop();
17437
+ depths.pop();
17438
+ continue;
17439
+ }
17440
+ depths[depths.length - 1]--;
17441
+ if (depths.length === 1 && depths[0] === 0) return i;
17442
+ }
17443
+ }
17444
+ return -1;
17445
+ };
17446
+ const passthroughSites = source.includes(marker) ? 1 : (source.match(/\)return process\.env;let [\w$]+=\{/g) ?? []).length;
17447
+ if (passthroughSites !== 1) {
17448
+ log12("FAIL", patchName, "child env passthrough appears " + passthroughSites + " times (expected 1)");
17449
+ fail("clodex patch: required patch failed: " + patchName);
17450
+ }
17373
17451
  applyOnce(
17374
17452
  patchName,
17375
- /(function [\w$]+\(\)\{)(let [\w$]+=[\w$]+\(\),[\w$]+=Object\.keys\([\w$]+\)\.length>0,[^;{}]*?[\w$]+=[\w$]+\(process\.env\.CLAUDE_CODE_REMOTE\)\?(?:(?!\}\s*function )[\s\S])*?for\(let [\w$]+ of [\w$]+\)delete [\w$]+\[[\w$]+\],delete [\w$]+\[`INPUT_\$\{[\w$]+\}`\];return [\w$]+)(\})/,
17376
- (_match, head, body, tail) => {
17377
- const targetIsValid = requiredBodyLiterals.every((literal) => body.includes(literal)) && !/\bfunction\s*[\w$]*\(/.test(body);
17453
+ /(function [\w$]+\(\)\{)(let (?:[^;{}]|\{[^;{}]*\})*?[\w$]+\(process\.env\.CLAUDE_CODE_REMOTE\)\?(?:(?!\}\s*function )[\s\S])*?\)return process\.env;let ([\w$]+)=\{(?:(?!\}\s*function )[\s\S])*?return \3)(\})/,
17454
+ (match, head, body, _copyVar, tail) => {
17455
+ const at = js.indexOf(match);
17456
+ const bound = at < 0 ? -1 : blockEndIndex(js, at + head.length - 1) - at - (match.length - 1);
17457
+ const targetIsValid = requiredBodyLiterals.every((literal) => body.includes(literal)) && !/\bfunction\s*[\w$]*\(/.test(body) && bound === 0;
17378
17458
  if (!targetIsValid) {
17379
17459
  log12("FAIL", patchName, "target validation failed");
17380
17460
  fail("clodex patch: child network environment target validation failed");