@ariestools/toolchain 8.7.21 → 8.7.22

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/xy.mjs CHANGED
@@ -12167,7 +12167,7 @@ const workspaceConfigCache = /* @__PURE__ */ new Map();
12167
12167
  /** In-flight workspace loads — concurrent jobs for the same dir share one search. */
12168
12168
  const workspaceConfigLoadPromises = /* @__PURE__ */ new Map();
12169
12169
  const deprecationWarned = /* @__PURE__ */ new Set();
12170
- function isRecord$7(value) {
12170
+ function isRecord$8(value) {
12171
12171
  return typeof value === "object" && value !== null && !Array.isArray(value);
12172
12172
  }
12173
12173
  const explorerState = {};
@@ -12246,12 +12246,12 @@ function warnOnce(key, message) {
12246
12246
  */
12247
12247
  function resolveCommandField(cfg, commandName, configPath) {
12248
12248
  const configKey = canonicalRuleConfigKey(commandName);
12249
- const commands = isRecord$7(cfg.commands) ? cfg.commands : void 0;
12249
+ const commands = isRecord$8(cfg.commands) ? cfg.commands : void 0;
12250
12250
  const fromCommands = commands?.[configKey];
12251
- if (isRecord$7(fromCommands)) return fromCommands;
12251
+ if (isRecord$8(fromCommands)) return fromCommands;
12252
12252
  for (const alias of deprecatedRuleConfigAliases(configKey)) {
12253
12253
  const fromAlias = commands?.[alias];
12254
- if (!isRecord$7(fromAlias)) continue;
12254
+ if (!isRecord$8(fromAlias)) continue;
12255
12255
  warnOnce(`${configPath ?? "unknown"}:commands.${alias}`, `[xy] Deprecated: "commands.${alias}" in ${configPath ?? "xy.config"} — use "commands.${configKey}"`);
12256
12256
  return fromAlias;
12257
12257
  }
@@ -12263,7 +12263,7 @@ function resolveCommandField(cfg, commandName, configPath) {
12263
12263
  return {};
12264
12264
  }
12265
12265
  function mergeRuleConfigs(target, source) {
12266
- if (isRecord$7(target) && isRecord$7(source)) return {
12266
+ if (isRecord$8(target) && isRecord$8(source)) return {
12267
12267
  ...target,
12268
12268
  ...source
12269
12269
  };
@@ -21027,7 +21027,7 @@ function formatSecureDownloads(downloads) {
21027
21027
  notation: "compact"
21028
21028
  }).format(downloads).toLowerCase();
21029
21029
  }
21030
- function pad$1(raw, colored, width) {
21030
+ function pad$2(raw, colored, width) {
21031
21031
  return colored + " ".repeat(Math.max(0, width - raw.length));
21032
21032
  }
21033
21033
  const columns = [
@@ -21081,7 +21081,7 @@ function renderSecurityAuditRows(rows) {
21081
21081
  for (const row of rows) {
21082
21082
  const line = columns.map((column, index) => {
21083
21083
  const raw = column.value(row);
21084
- return pad$1(raw, column.color(row, raw), widths[index]);
21084
+ return pad$2(raw, column.color(row, raw), widths[index]);
21085
21085
  }).join(" ");
21086
21086
  console.log(line);
21087
21087
  }
@@ -22690,10 +22690,10 @@ function classifyCell(prefix, column, hasValue) {
22690
22690
  if (column === "patch") return "yellow";
22691
22691
  return "red";
22692
22692
  }
22693
- function pad(raw, colored, width) {
22693
+ function pad$1(raw, colored, width) {
22694
22694
  return colored + " ".repeat(Math.max(0, width - raw.length));
22695
22695
  }
22696
- function dot(isSelected) {
22696
+ function dot$1(isSelected) {
22697
22697
  return isSelected ? chalk.green("●") : chalk.dim("○");
22698
22698
  }
22699
22699
  function valueOf(dep, column) {
@@ -22715,9 +22715,9 @@ function renderCell(dep, column, selection, width) {
22715
22715
  const raw = value ?? "-";
22716
22716
  const cls = classifyCell(dep.preferredRangePrefix, column, value != null && value.length > 0);
22717
22717
  const colored = COLOR[cls](raw);
22718
- return `${value != null && value.length > 0 ? dot(selection === selectionFor(column)) : " "} ${pad(raw, colored, width)}`;
22718
+ return `${value != null && value.length > 0 ? dot$1(selection === selectionFor(column)) : " "} ${pad$1(raw, colored, width)}`;
22719
22719
  }
22720
- function renderHeader(w, shouldIncludeNext, shouldIncludeDowngrade) {
22720
+ function renderHeader$1(w, shouldIncludeNext, shouldIncludeDowngrade) {
22721
22721
  const parts = [
22722
22722
  " ",
22723
22723
  chalk.bold("Package".padEnd(w.name)),
@@ -22732,7 +22732,7 @@ function renderHeader(w, shouldIncludeNext, shouldIncludeDowngrade) {
22732
22732
  const totalWidth = w.name + w.current + w.patch + w.minor + w.major + (shouldIncludeNext ? w.next + 2 : 0) + (shouldIncludeDowngrade ? w.downgrade + 2 : 0) + 24;
22733
22733
  return `${header}\n${chalk.gray("─".repeat(totalWidth))}`;
22734
22734
  }
22735
- function renderRow(dep, selection, isActive, w, shouldIncludeNext, shouldIncludeDowngrade) {
22735
+ function renderRow$1(dep, selection, isActive, w, shouldIncludeNext, shouldIncludeDowngrade) {
22736
22736
  const pointer = isActive ? chalk.cyan("❯") : " ";
22737
22737
  const rawName = dep.name;
22738
22738
  const name = chalk[isActive ? "white" : "gray"](rawName);
@@ -22743,7 +22743,7 @@ function renderRow(dep, selection, isActive, w, shouldIncludeNext, shouldInclude
22743
22743
  const major = renderCell(dep, "major", selection, w.major);
22744
22744
  const next = shouldIncludeNext ? ` ${renderCell(dep, "next", selection, w.next)}` : "";
22745
22745
  const downgrade = shouldIncludeDowngrade ? ` ${renderCell(dep, "downgrade", selection, w.downgrade)}` : "";
22746
- return `${pointer} ${pad(rawName, name, w.name)} ${pad(rawCurrent, current, w.current)} ${patch} ${minor} ${major}${next}${downgrade}`;
22746
+ return `${pointer} ${pad$1(rawName, name, w.name)} ${pad$1(rawCurrent, current, w.current)} ${patch} ${minor} ${major}${next}${downgrade}`;
22747
22747
  }
22748
22748
  function getAvailableSelections(dep) {
22749
22749
  const available = [-1];
@@ -22807,7 +22807,7 @@ function getTargetVersion(dep, selection) {
22807
22807
  if (selection === 3) return dep.next;
22808
22808
  if (selection === 4) return dep.downgrade;
22809
22809
  }
22810
- function computeWidths(rows) {
22810
+ function computeWidths$1(rows) {
22811
22811
  let name = 7;
22812
22812
  let current = 7;
22813
22813
  let patch = 5;
@@ -22834,12 +22834,12 @@ function computeWidths(rows) {
22834
22834
  patch
22835
22835
  };
22836
22836
  }
22837
- function renderPage(rows, cursor, selections, w, pageSize, shouldIncludeNext, shouldIncludeDowngrade) {
22837
+ function renderPage$1(rows, cursor, selections, w, pageSize, shouldIncludeNext, shouldIncludeDowngrade) {
22838
22838
  const total = rows.length;
22839
22839
  const start = total > pageSize ? Math.max(0, Math.min(cursor - Math.floor(pageSize / 2), total - pageSize)) : 0;
22840
22840
  const end = Math.min(start + pageSize, total);
22841
22841
  const lines = [];
22842
- for (let i = start; i < end; i++) lines.push(renderRow(rows[i], selections[i], i === cursor, w, shouldIncludeNext, shouldIncludeDowngrade));
22842
+ for (let i = start; i < end; i++) lines.push(renderRow$1(rows[i], selections[i], i === cursor, w, shouldIncludeNext, shouldIncludeDowngrade));
22843
22843
  if (total > pageSize) {
22844
22844
  if (start > 0) lines.unshift(chalk.dim(" ↑ more"));
22845
22845
  if (end < total) lines.push(chalk.dim(" ↓ more"));
@@ -22855,7 +22855,7 @@ const updoPrompt = createPrompt((config, done) => {
22855
22855
  latest: isLatest,
22856
22856
  risk
22857
22857
  })));
22858
- const widthsRef = useRef(computeWidths(rows));
22858
+ const widthsRef = useRef(computeWidths$1(rows));
22859
22859
  useKeypress((key) => {
22860
22860
  if (key.name === "escape" || key.ctrl && key.name === "c") {
22861
22861
  done([]);
@@ -22886,8 +22886,8 @@ const updoPrompt = createPrompt((config, done) => {
22886
22886
  });
22887
22887
  const w = widthsRef.current;
22888
22888
  const isIncludeDowngrade = rows.some((r) => r.downgrade !== void 0);
22889
- const header = renderHeader(w, isIncludeNext, isIncludeDowngrade);
22890
- const page = renderPage(rows, cursor, selectionsRef.current, w, 20, isIncludeNext, isIncludeDowngrade);
22889
+ const header = renderHeader$1(w, isIncludeNext, isIncludeDowngrade);
22890
+ const page = renderPage$1(rows, cursor, selectionsRef.current, w, 20, isIncludeNext, isIncludeDowngrade);
22891
22891
  const selectedCount = selectionsRef.current.filter((s) => s >= 0).length;
22892
22892
  return `${header}\n${page}\n${chalk.gray(` ${selectedCount} isSelected ↑/↓ navigate space cycle version enter confirm`)}`;
22893
22893
  });
@@ -23957,7 +23957,7 @@ const RULE_LEVELS$2 = /* @__PURE__ */ new Set([
23957
23957
  "off",
23958
23958
  "warn"
23959
23959
  ]);
23960
- function isRecord$6(value) {
23960
+ function isRecord$7(value) {
23961
23961
  return typeof value === "object" && value !== null && !Array.isArray(value);
23962
23962
  }
23963
23963
  function isValidWeight(value) {
@@ -23974,7 +23974,7 @@ function parseTupleRuleSetting(location, setting) {
23974
23974
  if (setting.length !== 2) throw new TypeError(`${location} tuple must be [level, options]`);
23975
23975
  const [level, options] = setting;
23976
23976
  if (!isRuleLevel$5(level)) throw new TypeError(`${location} level must be "error", "warn", or "off"`);
23977
- if (!isRecord$6(options)) throw new TypeError(`${location} options must be an object`);
23977
+ if (!isRecord$7(options)) throw new TypeError(`${location} options must be an object`);
23978
23978
  return {
23979
23979
  enabled: level !== "off",
23980
23980
  level,
@@ -24007,7 +24007,7 @@ function parseRuleSetting(location, setting) {
24007
24007
  weight: parseWeight(location, setting)
24008
24008
  };
24009
24009
  if (Array.isArray(setting)) return parseTupleRuleSetting(location, setting);
24010
- if (isRecord$6(setting)) return parseObjectRuleSetting(location, setting);
24010
+ if (isRecord$7(setting)) return parseObjectRuleSetting(location, setting);
24011
24011
  throw new TypeError(`${location} must be a boolean, rule level, number, "infinite", [level, options], or { enabled?, level?, weight? } object`);
24012
24012
  }
24013
24013
  function validateRuleIds(location, rules) {
@@ -25776,7 +25776,7 @@ function renderHumanApiExposure(results, options = {}) {
25776
25776
  }
25777
25777
  //#endregion
25778
25778
  //#region src/actions/api-exposure/apiExposure.ts
25779
- function resolveTargetWorkspaces$1(targetPackage, inputWorkspaces) {
25779
+ function resolveTargetWorkspaces$2(targetPackage, inputWorkspaces) {
25780
25780
  const pm = getPackageManager();
25781
25781
  const allWorkspaces = pm.listWorkspaces();
25782
25782
  const workspaceNames = new Set(allWorkspaces.map((ws) => ws.name));
@@ -25844,7 +25844,7 @@ function collectDiagnostics(results, failOn) {
25844
25844
  const apiExposure = async ({ dep, failOn, format, minBand, pkg, verbose, workspaces: inputWorkspaces }) => {
25845
25845
  const effectiveFormat = format ?? (isJsonMode() ? "json" : "human");
25846
25846
  const targetPackage = typeof pkg === "string" && pkg !== "undefined" && pkg.length > 0 ? pkg : void 0;
25847
- const { targetWorkspaces, workspaceNames } = resolveTargetWorkspaces$1(targetPackage, inputWorkspaces);
25847
+ const { targetWorkspaces, workspaceNames } = resolveTargetWorkspaces$2(targetPackage, inputWorkspaces);
25848
25848
  if (targetWorkspaces.length === 0) {
25849
25849
  console.error(chalk.red(`Workspace not found: ${targetPackage}`));
25850
25850
  return {
@@ -28360,6 +28360,444 @@ const compileAll = ({ shouldExitOnFail, jobs, isVerbose, incremental, incrementa
28360
28360
  return shouldExitOnFail === void 0 ? safeExitAsync(action) : safeExitAsync(action, shouldExitOnFail);
28361
28361
  };
28362
28362
  //#endregion
28363
+ //#region src/actions/deplint/editXyConfigPackages.ts
28364
+ /** Config filenames cosmiconfig resolves for module name `xy`, in preference order. */
28365
+ const XY_CONFIG_FILE_NAMES = [
28366
+ "xy.config.ts",
28367
+ "xy.config.mts",
28368
+ "xy.config.cts",
28369
+ "xy.config.js",
28370
+ "xy.config.mjs",
28371
+ "xy.config.cjs",
28372
+ ".xyrc.json",
28373
+ ".xyrc"
28374
+ ];
28375
+ function findXyConfigFile(dir) {
28376
+ for (const name of XY_CONFIG_FILE_NAMES) {
28377
+ const candidate = PATH.join(dir, name);
28378
+ if (fs.existsSync(candidate)) return candidate;
28379
+ }
28380
+ }
28381
+ function isJsonConfigPath(configPath) {
28382
+ const base = PATH.basename(configPath);
28383
+ return base === ".xyrc.json" || base.endsWith(".json");
28384
+ }
28385
+ function getPropertyName$2(prop) {
28386
+ if (ts.isPropertyAssignment(prop)) {
28387
+ const { name } = prop;
28388
+ if (ts.isIdentifier(name) || ts.isStringLiteral(name) || ts.isNoSubstitutionTemplateLiteral(name)) return name.text;
28389
+ }
28390
+ if (ts.isShorthandPropertyAssignment(prop)) return prop.name.text;
28391
+ }
28392
+ function isWhitespace$1(char) {
28393
+ return char !== void 0 && /\s/.test(char);
28394
+ }
28395
+ /**
28396
+ * Find `deplint.packages` (whether under `commands.deplint` or a deprecated
28397
+ * top-level `deplint`) as a property assignment whose value is an object.
28398
+ */
28399
+ function findDeplintPackagesAssignment(sourceFile) {
28400
+ let found;
28401
+ function visit(node) {
28402
+ if (found !== void 0) return;
28403
+ if (ts.isPropertyAssignment(node) && getPropertyName$2(node) === "packages" && ts.isObjectLiteralExpression(node.initializer)) {
28404
+ const parentObject = node.parent;
28405
+ if (ts.isObjectLiteralExpression(parentObject) && ts.isPropertyAssignment(parentObject.parent) && getPropertyName$2(parentObject.parent) === "deplint") {
28406
+ found = node;
28407
+ return;
28408
+ }
28409
+ }
28410
+ ts.forEachChild(node, visit);
28411
+ }
28412
+ visit(sourceFile);
28413
+ return found;
28414
+ }
28415
+ function findDeplintObjectAssignment(sourceFile) {
28416
+ let found;
28417
+ function visit(node) {
28418
+ if (found !== void 0) return;
28419
+ if (ts.isPropertyAssignment(node) && getPropertyName$2(node) === "deplint" && ts.isObjectLiteralExpression(node.initializer)) {
28420
+ found = node;
28421
+ return;
28422
+ }
28423
+ ts.forEachChild(node, visit);
28424
+ }
28425
+ visit(sourceFile);
28426
+ return found;
28427
+ }
28428
+ function findCommandsObjectAssignment(sourceFile) {
28429
+ let found;
28430
+ function visit(node) {
28431
+ if (found !== void 0) return;
28432
+ if (ts.isPropertyAssignment(node) && getPropertyName$2(node) === "commands" && ts.isObjectLiteralExpression(node.initializer)) {
28433
+ found = node;
28434
+ return;
28435
+ }
28436
+ ts.forEachChild(node, visit);
28437
+ }
28438
+ visit(sourceFile);
28439
+ return found;
28440
+ }
28441
+ function findDefaultExportObject(sourceFile) {
28442
+ for (const statement of sourceFile.statements) {
28443
+ if (ts.isExportAssignment(statement) && !statement.isExportEquals && ts.isObjectLiteralExpression(statement.expression)) return statement.expression;
28444
+ if (!ts.isVariableStatement(statement)) continue;
28445
+ for (const decl of statement.declarationList.declarations) if (decl.initializer && ts.isObjectLiteralExpression(decl.initializer) && ts.isIdentifier(decl.name) && decl.name.text === "config") return decl.initializer;
28446
+ }
28447
+ for (const statement of sourceFile.statements) {
28448
+ if (!ts.isVariableStatement(statement)) continue;
28449
+ for (const decl of statement.declarationList.declarations) if (decl.initializer && ts.isObjectLiteralExpression(decl.initializer)) return decl.initializer;
28450
+ }
28451
+ }
28452
+ function quotePackageKey(name) {
28453
+ if (/^[A-Za-z_$][\w$]*$/.test(name)) return name;
28454
+ return `'${name.replaceAll("\\", String.raw`\\`).replaceAll("'", String.raw`\'`)}'`;
28455
+ }
28456
+ function formatPackageConfigValue(config) {
28457
+ const parts = [];
28458
+ if (config.placement !== void 0) parts.push(`placement: '${config.placement}'`);
28459
+ if (config.presence !== void 0) parts.push(`presence: '${config.presence}'`);
28460
+ if (config.peerOptional !== void 0) parts.push(`peerOptional: ${config.peerOptional}`);
28461
+ if (config.refType !== void 0) parts.push(`refType: '${config.refType}'`);
28462
+ return `{ ${parts.join(", ")} }`;
28463
+ }
28464
+ function detectIndent$1(text, packagesObject, sourceFile) {
28465
+ if (packagesObject.properties.length > 0) {
28466
+ const start = packagesObject.properties[0].getStart(sourceFile);
28467
+ let lineStart = start;
28468
+ while (lineStart > 0 && text[lineStart - 1] !== "\n" && text[lineStart - 1] !== "\r") lineStart -= 1;
28469
+ const indent = text.slice(lineStart, start).match(/^[ \t]*/)?.[0];
28470
+ if (indent !== void 0 && indent.length > 0) return indent;
28471
+ }
28472
+ const braceStart = packagesObject.getStart(sourceFile);
28473
+ let lineStart = braceStart;
28474
+ while (lineStart > 0 && text[lineStart - 1] !== "\n" && text[lineStart - 1] !== "\r") lineStart -= 1;
28475
+ return `${text.slice(lineStart, braceStart).match(/^[ \t]*/)?.[0] ?? ""} `;
28476
+ }
28477
+ function findPackageProperty(packagesObject, dependency) {
28478
+ for (const prop of packagesObject.properties) {
28479
+ if (!ts.isPropertyAssignment(prop)) continue;
28480
+ if (getPropertyName$2(prop) === dependency) return prop;
28481
+ }
28482
+ }
28483
+ function removePropertyFromObject(text, prop, sourceFile) {
28484
+ let start = prop.getFullStart();
28485
+ let end = prop.getEnd();
28486
+ let cursor = end;
28487
+ while (isWhitespace$1(text[cursor])) cursor++;
28488
+ if (text[cursor] === ",") end = cursor + 1;
28489
+ else {
28490
+ let back = prop.getStart(sourceFile) - 1;
28491
+ while (back >= 0 && isWhitespace$1(text[back])) back--;
28492
+ if (text[back] === ",") start = back;
28493
+ }
28494
+ return `${text.slice(0, start)}${text.slice(end)}`;
28495
+ }
28496
+ function upsertPackagePropertyInObject(text, packagesAssignment, sourceFile, dependency, config) {
28497
+ if (!ts.isObjectLiteralExpression(packagesAssignment.initializer)) throw new TypeError("deplint.packages must be an object literal");
28498
+ const packagesObject = packagesAssignment.initializer;
28499
+ const existing = findPackageProperty(packagesObject, dependency);
28500
+ if (config === void 0) {
28501
+ if (existing === void 0) return text;
28502
+ return removePropertyFromObject(text, existing, sourceFile);
28503
+ }
28504
+ if (existing !== void 0) {
28505
+ const valueText = formatPackageConfigValue(config);
28506
+ const valueStart = existing.initializer.getStart(sourceFile);
28507
+ const valueEnd = existing.initializer.getEnd();
28508
+ return `${text.slice(0, valueStart)}${valueText}${text.slice(valueEnd)}`;
28509
+ }
28510
+ const valueText = formatPackageConfigValue(config);
28511
+ const keyText = quotePackageKey(dependency);
28512
+ const indent = detectIndent$1(text, packagesObject, sourceFile);
28513
+ const entry = `${keyText}: ${valueText}`;
28514
+ const openBraceEnd = packagesObject.getStart(sourceFile) + 1;
28515
+ const insertion = `\n${indent}${entry},`;
28516
+ return `${text.slice(0, openBraceEnd)}${insertion}${text.slice(openBraceEnd)}`;
28517
+ }
28518
+ function insertPackagesIntoDeplint(text, deplintAssignment, sourceFile, dependency, config) {
28519
+ if (!ts.isObjectLiteralExpression(deplintAssignment.initializer)) throw new TypeError("deplint must be an object literal");
28520
+ const deplintObject = deplintAssignment.initializer;
28521
+ const indent = detectIndent$1(text, deplintObject, sourceFile);
28522
+ const packagesBlock = `packages: {\n${indent} ${quotePackageKey(dependency)}: ${formatPackageConfigValue(config)},\n${indent}}`;
28523
+ const openBraceEnd = deplintObject.getStart(sourceFile) + 1;
28524
+ const insertion = `\n${indent}${packagesBlock},`;
28525
+ return `${text.slice(0, openBraceEnd)}${insertion}${text.slice(openBraceEnd)}`;
28526
+ }
28527
+ function insertDeplintIntoCommands(text, commandsAssignment, sourceFile, dependency, config) {
28528
+ if (!ts.isObjectLiteralExpression(commandsAssignment.initializer)) throw new TypeError("commands must be an object literal");
28529
+ const commandsObject = commandsAssignment.initializer;
28530
+ const indent = detectIndent$1(text, commandsObject, sourceFile);
28531
+ const block = [
28532
+ "deplint: {",
28533
+ `${indent} packages: {`,
28534
+ `${indent} ${quotePackageKey(dependency)}: ${formatPackageConfigValue(config)},`,
28535
+ `${indent} },`,
28536
+ `${indent}}`
28537
+ ].join("\n");
28538
+ const openBraceEnd = commandsObject.getStart(sourceFile) + 1;
28539
+ const insertion = `\n${indent}${block},`;
28540
+ return `${text.slice(0, openBraceEnd)}${insertion}${text.slice(openBraceEnd)}`;
28541
+ }
28542
+ function insertCommandsIntoConfigObject(text, configObject, sourceFile, dependency, config) {
28543
+ const indent = detectIndent$1(text, configObject, sourceFile);
28544
+ const block = [
28545
+ "commands: {",
28546
+ `${indent} deplint: {`,
28547
+ `${indent} packages: {`,
28548
+ `${indent} ${quotePackageKey(dependency)}: ${formatPackageConfigValue(config)},`,
28549
+ `${indent} },`,
28550
+ `${indent} },`,
28551
+ `${indent}}`
28552
+ ].join("\n");
28553
+ const openBraceEnd = configObject.getStart(sourceFile) + 1;
28554
+ const insertion = `\n${indent}${block},`;
28555
+ return `${text.slice(0, openBraceEnd)}${insertion}${text.slice(openBraceEnd)}`;
28556
+ }
28557
+ /**
28558
+ * Apply package placement edits to TypeScript/JS xy.config source text.
28559
+ * Edits are applied last-to-first so offsets remain valid.
28560
+ */
28561
+ function applyPackageEditsToTsSource(text, edits) {
28562
+ if (edits.length === 0) return text;
28563
+ let result = text;
28564
+ for (const edit of edits) {
28565
+ const sourceFile = ts.createSourceFile("xy.config.ts", result, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
28566
+ const packagesAssignment = findDeplintPackagesAssignment(sourceFile);
28567
+ if (packagesAssignment !== void 0) {
28568
+ result = upsertPackagePropertyInObject(result, packagesAssignment, sourceFile, edit.dependency, edit.config);
28569
+ continue;
28570
+ }
28571
+ if (edit.config === void 0) continue;
28572
+ const deplintAssignment = findDeplintObjectAssignment(sourceFile);
28573
+ if (deplintAssignment !== void 0) {
28574
+ result = insertPackagesIntoDeplint(result, deplintAssignment, sourceFile, edit.dependency, edit.config);
28575
+ continue;
28576
+ }
28577
+ const commandsAssignment = findCommandsObjectAssignment(sourceFile);
28578
+ if (commandsAssignment !== void 0) {
28579
+ result = insertDeplintIntoCommands(result, commandsAssignment, sourceFile, edit.dependency, edit.config);
28580
+ continue;
28581
+ }
28582
+ const configObject = findDefaultExportObject(sourceFile);
28583
+ if (configObject !== void 0) {
28584
+ result = insertCommandsIntoConfigObject(result, configObject, sourceFile, edit.dependency, edit.config);
28585
+ continue;
28586
+ }
28587
+ throw new Error("Unable to locate a config object literal to insert commands.deplint.packages");
28588
+ }
28589
+ return result;
28590
+ }
28591
+ function isRecord$6(value) {
28592
+ return typeof value === "object" && value !== null && !Array.isArray(value);
28593
+ }
28594
+ function readJsonPackageConfig(value) {
28595
+ if (!isRecord$6(value)) return void 0;
28596
+ const config = {};
28597
+ if (typeof value.placement === "string") config.placement = value.placement;
28598
+ if (typeof value.presence === "string") config.presence = value.presence;
28599
+ if (typeof value.peerOptional === "boolean") config.peerOptional = value.peerOptional;
28600
+ if (typeof value.refType === "string") config.refType = value.refType;
28601
+ return config;
28602
+ }
28603
+ function resolveJsonDeplintObject(root) {
28604
+ const commands = isRecord$6(root.commands) ? root.commands : void 0;
28605
+ if (commands !== void 0 && isRecord$6(commands.deplint)) return commands.deplint;
28606
+ if (isRecord$6(root.deplint)) return root.deplint;
28607
+ if (!isRecord$6(root.commands)) root.commands = {};
28608
+ const cmds = root.commands;
28609
+ const deplint = {};
28610
+ cmds.deplint = deplint;
28611
+ return deplint;
28612
+ }
28613
+ /**
28614
+ * Apply package placement edits to a JSON xy config (e.g. `.xyrc.json`).
28615
+ */
28616
+ function applyPackageEditsToJsonSource(text, edits) {
28617
+ if (edits.length === 0) return text;
28618
+ const root = JSON.parse(text);
28619
+ const deplint = resolveJsonDeplintObject(root);
28620
+ const packages = isRecord$6(deplint.packages) ? deplint.packages : deplint.packages = {};
28621
+ for (const edit of edits) if (edit.config === void 0) delete packages[edit.dependency];
28622
+ else packages[edit.dependency] = edit.config;
28623
+ if (Object.keys(packages).length === 0) delete deplint.packages;
28624
+ return `${JSON.stringify(root, null, 2)}\n`;
28625
+ }
28626
+ function readPackageConfigFromObjectLiteral(objectLiteral) {
28627
+ const config = {};
28628
+ for (const prop of objectLiteral.properties) {
28629
+ if (!ts.isPropertyAssignment(prop)) continue;
28630
+ const key = getPropertyName$2(prop);
28631
+ if (key === void 0) continue;
28632
+ const { initializer } = prop;
28633
+ if ([
28634
+ "placement",
28635
+ "refType",
28636
+ "presence"
28637
+ ].includes(key)) {
28638
+ if (ts.isStringLiteral(initializer) || ts.isNoSubstitutionTemplateLiteral(initializer)) if (key === "placement") config.placement = initializer.text;
28639
+ else if (key === "refType") config.refType = initializer.text;
28640
+ else config.presence = initializer.text;
28641
+ } else if (key === "peerOptional" && (initializer.kind === ts.SyntaxKind.TrueKeyword || initializer.kind === ts.SyntaxKind.FalseKeyword)) config.peerOptional = initializer.kind === ts.SyntaxKind.TrueKeyword;
28642
+ }
28643
+ return config;
28644
+ }
28645
+ /** Read `commands.deplint.packages` (or top-level `deplint.packages`) from a config file. */
28646
+ function readPackagesFromConfigFile(configPath) {
28647
+ const text = fs.readFileSync(configPath, "utf8");
28648
+ const result = /* @__PURE__ */ new Map();
28649
+ if (isJsonConfigPath(configPath)) try {
28650
+ const root = JSON.parse(text);
28651
+ const commands = isRecord$6(root.commands) ? root.commands : void 0;
28652
+ const deplint = commands !== void 0 && isRecord$6(commands.deplint) ? commands.deplint : isRecord$6(root.deplint) ? root.deplint : void 0;
28653
+ const packages = deplint !== void 0 && isRecord$6(deplint.packages) ? deplint.packages : void 0;
28654
+ if (packages === void 0) return result;
28655
+ for (const [name, value] of Object.entries(packages)) {
28656
+ const config = readJsonPackageConfig(value);
28657
+ if (config !== void 0) result.set(name, config);
28658
+ }
28659
+ return result;
28660
+ } catch {
28661
+ return result;
28662
+ }
28663
+ const packagesAssignment = findDeplintPackagesAssignment(ts.createSourceFile(PATH.basename(configPath), text, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS));
28664
+ if (packagesAssignment === void 0 || !ts.isObjectLiteralExpression(packagesAssignment.initializer)) return result;
28665
+ for (const prop of packagesAssignment.initializer.properties) {
28666
+ if (!ts.isPropertyAssignment(prop)) continue;
28667
+ const name = getPropertyName$2(prop);
28668
+ if (name === void 0 || !ts.isObjectLiteralExpression(prop.initializer)) continue;
28669
+ result.set(name, readPackageConfigFromObjectLiteral(prop.initializer));
28670
+ }
28671
+ return result;
28672
+ }
28673
+ function createMinimalXyConfigSource(dependency, config) {
28674
+ return [
28675
+ "import type { XyConfig } from '@ariestools/toolchain'",
28676
+ "",
28677
+ "const config: XyConfig = {",
28678
+ " commands: {",
28679
+ " deplint: {",
28680
+ " packages: {",
28681
+ ` ${quotePackageKey(dependency)}: ${formatPackageConfigValue(config)},`,
28682
+ " },",
28683
+ " },",
28684
+ " },",
28685
+ "}",
28686
+ "",
28687
+ "export default config",
28688
+ ""
28689
+ ].join("\n");
28690
+ }
28691
+ /**
28692
+ * Apply package config edits to the xy config for a directory.
28693
+ * Creates `xy.config.ts` when the directory has no config and there are adds.
28694
+ * Returns the path written, or `undefined` when no file changed.
28695
+ */
28696
+ function applyPackageEditsToConfigDir(dir, edits) {
28697
+ if (edits.length === 0) return void 0;
28698
+ const existingPath = findXyConfigFile(dir);
28699
+ const hasAdds = edits.some((edit) => edit.config !== void 0);
28700
+ if (existingPath === void 0) {
28701
+ if (!hasAdds) return void 0;
28702
+ const firstAdd = edits.find((edit) => edit.config !== void 0);
28703
+ if (firstAdd?.config === void 0) return void 0;
28704
+ const configPath = PATH.join(dir, "xy.config.ts");
28705
+ let text = createMinimalXyConfigSource(firstAdd.dependency, firstAdd.config);
28706
+ const remaining = edits.filter((edit) => edit !== firstAdd);
28707
+ if (remaining.length > 0) text = applyPackageEditsToTsSource(text, remaining);
28708
+ fs.writeFileSync(configPath, text, "utf8");
28709
+ return configPath;
28710
+ }
28711
+ const before = fs.readFileSync(existingPath, "utf8");
28712
+ const after = isJsonConfigPath(existingPath) ? applyPackageEditsToJsonSource(before, edits) : applyPackageEditsToTsSource(before, edits);
28713
+ if (after === before) return void 0;
28714
+ fs.writeFileSync(existingPath, after, "utf8");
28715
+ return existingPath;
28716
+ }
28717
+ const PICK_PLACEMENTS = /* @__PURE__ */ new Set([
28718
+ "dep",
28719
+ "dev",
28720
+ "peer"
28721
+ ]);
28722
+ function placementFromConfig(config) {
28723
+ const placement = config?.placement ?? config?.refType;
28724
+ if (placement !== void 0 && PICK_PLACEMENTS.has(placement)) return placement;
28725
+ }
28726
+ //#endregion
28727
+ //#region src/actions/deplint/collectPickRows.ts
28728
+ const AEI_REVIEW_RULE_ID = "dep.dependencies.aei-review";
28729
+ function resolveDir(cwd, location) {
28730
+ return PATH.isAbsolute(location) ? location : PATH.resolve(cwd, location);
28731
+ }
28732
+ function scopeLabel(workspace) {
28733
+ if (workspace.location === "." || workspace.location === "") return "root";
28734
+ return workspace.name;
28735
+ }
28736
+ function rowKey(editDir, dependency) {
28737
+ return `${editDir}\0${dependency}`;
28738
+ }
28739
+ /**
28740
+ * Collect interactive pick rows from:
28741
+ * 1. `dep.dependencies.aei-review` diagnostics (borderline AEI scores)
28742
+ * 2. Packages already declared under `commands.deplint.packages` in xy configs
28743
+ *
28744
+ * Each row targets a single config directory (workspace or monorepo root).
28745
+ * Borderline items that already have placement config are skipped by deplint
28746
+ * itself; they only appear via the configured-packages scan.
28747
+ */
28748
+ function collectDeplintPickRows(cwd, workspaces, diagnostics) {
28749
+ const rows = /* @__PURE__ */ new Map();
28750
+ for (const workspace of workspaces) {
28751
+ const editDir = resolveDir(cwd, workspace.location);
28752
+ const configPath = findXyConfigFile(editDir);
28753
+ if (configPath === void 0) continue;
28754
+ const packages = readPackagesFromConfigFile(configPath);
28755
+ for (const [dependency, config] of packages) {
28756
+ const key = rowKey(editDir, dependency);
28757
+ const currentPlacement = placementFromConfig(config);
28758
+ rows.set(key, {
28759
+ currentConfig: config,
28760
+ currentPlacement,
28761
+ dependency,
28762
+ editDir,
28763
+ existingConfigPath: configPath,
28764
+ initialSelection: currentPlacement ?? "none",
28765
+ reason: "configured",
28766
+ scope: scopeLabel(workspace),
28767
+ workspaces: []
28768
+ });
28769
+ }
28770
+ }
28771
+ for (const diagnostic of diagnostics) {
28772
+ if (diagnostic.id !== AEI_REVIEW_RULE_ID) continue;
28773
+ const dependency = diagnostic.dependency;
28774
+ if (dependency === void 0 || dependency.length === 0) continue;
28775
+ const editDir = resolveDir(cwd, diagnostic.workspace.location);
28776
+ const key = rowKey(editDir, dependency);
28777
+ const existing = rows.get(key);
28778
+ if (existing !== void 0) {
28779
+ existing.reason = "both";
28780
+ if (!existing.workspaces.includes(diagnostic.workspace.name)) existing.workspaces.push(diagnostic.workspace.name);
28781
+ continue;
28782
+ }
28783
+ const configPath = findXyConfigFile(editDir);
28784
+ rows.set(key, {
28785
+ dependency,
28786
+ editDir,
28787
+ existingConfigPath: configPath,
28788
+ initialSelection: "none",
28789
+ reason: "review",
28790
+ scope: scopeLabel(diagnostic.workspace),
28791
+ workspaces: [diagnostic.workspace.name]
28792
+ });
28793
+ }
28794
+ return rows.values().toArray().toSorted((a, b) => {
28795
+ const scopeCmp = a.scope.localeCompare(b.scope);
28796
+ if (scopeCmp !== 0) return scopeCmp;
28797
+ return a.dependency.localeCompare(b.dependency);
28798
+ });
28799
+ }
28800
+ //#endregion
28363
28801
  //#region src/actions/deplint/reporters.ts
28364
28802
  function pluralize(word, count) {
28365
28803
  return `${word}${count === 1 ? "" : "s"}`;
@@ -30621,6 +31059,100 @@ const misplacedPeerDependenciesRule = {
30621
31059
  }
30622
31060
  };
30623
31061
  //#endregion
31062
+ //#region src/actions/deplint/rulesRedundantPlacement.ts
31063
+ function isDeclaredDependency(context, dependency) {
31064
+ const { dependencies, devDependencies, peerDependencies } = context.packageParams;
31065
+ return dependencies.includes(dependency) || peerDependencies.includes(dependency) || devDependencies.includes(dependency);
31066
+ }
31067
+ function isDevOnlyDeclaration(context, dependency) {
31068
+ const { dependencies, devDependencies, peerDependencies } = context.packageParams;
31069
+ return devDependencies.includes(dependency) && !dependencies.includes(dependency) && !peerDependencies.includes(dependency);
31070
+ }
31071
+ function classificationToPlacement(classification) {
31072
+ switch (classification) {
31073
+ case "dependency": return "dep";
31074
+ case "peer": return "peer";
31075
+ case "peer-with-default": return "peer-with-default";
31076
+ case "review": return "review";
31077
+ }
31078
+ }
31079
+ /**
31080
+ * Map natural classifier output + package shape to a placement string that
31081
+ * can be compared with `commands.deplint.packages.<name>.placement`.
31082
+ *
31083
+ * Returns `undefined` when there is no single natural placement (e.g. the
31084
+ * dep is not declared here, or only a `dev` placement would make sense and
31085
+ * that is never produced by the classifier for mixed listings).
31086
+ */
31087
+ function naturalPlacementForDependency(context, dependency) {
31088
+ if (!isDeclaredDependency(context, dependency)) return void 0;
31089
+ if (context.workspaceNames?.has(dependency) ?? false) return "dep";
31090
+ if (context.packageParams.dependencyVersions[dependency]?.startsWith("workspace:")) return "dep";
31091
+ if (context.isTerminalPackage) return isDevOnlyDeclaration(context, dependency) ? void 0 : "dep";
31092
+ if (dependency.startsWith("@types/")) return isDevOnlyDeclaration(context, dependency) ? "dev" : void 0;
31093
+ if (isDevOnlyDeclaration(context, dependency)) return void 0;
31094
+ return classificationToPlacement(context.classifyDependency(dependency));
31095
+ }
31096
+ /**
31097
+ * A local placement override is redundant when:
31098
+ * - it is declared in this workspace's own xy config (not only inherited)
31099
+ * - presence is inferred (allowed/required still justify keeping the entry)
31100
+ * - peerOptional is not forced (that flag is independent of placement)
31101
+ * - the natural classifier placement matches the configured placement
31102
+ * - natural placement is not `review` (borderline still needs a human decision)
31103
+ */
31104
+ function isRedundantPackagePlacement(context, dependency, policy) {
31105
+ if (policy.placement === void 0) return void 0;
31106
+ if (policy.presence !== "inferred") return void 0;
31107
+ if (policy.peerOptional !== void 0) return void 0;
31108
+ if (context.localConfigPath === void 0) return void 0;
31109
+ if (!context.localPackagePolicies.has(dependency)) return void 0;
31110
+ const natural = naturalPlacementForDependency(context, dependency);
31111
+ if (natural === void 0 || natural === "review") return void 0;
31112
+ if (natural !== policy.placement) return void 0;
31113
+ return {
31114
+ natural,
31115
+ placement: policy.placement
31116
+ };
31117
+ }
31118
+ const redundantPackagePlacementRule = {
31119
+ category: "workspace",
31120
+ id: "dep.package.redundant-placement",
31121
+ meta: {
31122
+ description: "Package placement overrides in xy.config that match the natural classifier and can be removed",
31123
+ fixable: ["config"],
31124
+ severity: "warning"
31125
+ },
31126
+ evaluate(context) {
31127
+ if (context.localConfigPath === void 0 || context.localPackagePolicies.size === 0) return;
31128
+ for (const [dependency, policy] of context.localPackagePolicies) {
31129
+ const match = isRedundantPackagePlacement(context, dependency, policy);
31130
+ if (match === void 0) continue;
31131
+ context.report({
31132
+ data: {
31133
+ configPath: context.localConfigPath,
31134
+ dependency,
31135
+ natural: match.natural,
31136
+ placement: match.placement
31137
+ },
31138
+ dependency,
31139
+ file: context.localConfigPath,
31140
+ message: `placement "${match.placement}" for ${dependency} matches the natural classifier — remove the useless override from xy.config (run \`xy deplint --fix\`)`
31141
+ });
31142
+ }
31143
+ },
31144
+ resolveFixes(diagnostic) {
31145
+ const data = diagnostic.data;
31146
+ if (!data) return [];
31147
+ return [{
31148
+ action: "remove-package-config",
31149
+ configPath: data.configPath,
31150
+ dependency: data.dependency,
31151
+ detail: `removed redundant placement "${data.placement}" from xy.config`
31152
+ }];
31153
+ }
31154
+ };
31155
+ //#endregion
30624
31156
  //#region src/actions/deplint/versionMismatchFixes.ts
30625
31157
  function sectionLookupsFor(context) {
30626
31158
  const { dependencies, devDependencies, peerDependencies, dependencyVersions, devDependencyVersions, peerDependencyVersions } = context.packageParams;
@@ -31280,6 +31812,7 @@ const builtInDeplintPlugin = {
31280
31812
  name: "builtin",
31281
31813
  rules: [
31282
31814
  requiredPackagesRule,
31815
+ redundantPackagePlacementRule,
31283
31816
  unlistedDependenciesRule,
31284
31817
  unusedDependenciesRule,
31285
31818
  misplacedDependenciesRule,
@@ -31373,7 +31906,6 @@ function buildDependencyClassifier(workspace, options, isTerminal, peerDependenc
31373
31906
  if (!isAeiClassifierMode(classifier)) return (dependency) => shouldBePeerDependency(dependency, workspace.location, peerDependencies, externalDistImports, options.workspaceNames) ? "peer" : "dependency";
31374
31907
  let recommendations;
31375
31908
  return (dependency) => {
31376
- if (options.forcePeerWithDefault?.has(dependency) ?? false) return "peer-with-default";
31377
31909
  if (recommendations === void 0) {
31378
31910
  const result = analyzeWorkspaceApiExposure({
31379
31911
  cache: sharedAeiProgramCache,
@@ -31453,6 +31985,8 @@ function buildWorkspaceContext(workspace, options = {}) {
31453
31985
  forcePeerWithDefault: options.forcePeerWithDefault ?? /* @__PURE__ */ new Set(),
31454
31986
  forcePeers: options.forcePeers ?? /* @__PURE__ */ new Set(),
31455
31987
  isTerminalPackage: packageClassification.isTerminalPackage,
31988
+ localConfigPath: options.localConfigPath,
31989
+ localPackagePolicies: options.localPackagePolicies ?? /* @__PURE__ */ new Map(),
31456
31990
  packageKind: packageClassification.kind,
31457
31991
  packageJsonPath,
31458
31992
  packageParams,
@@ -31544,6 +32078,8 @@ async function loadWorkspaceEvaluationContext(workspace, options, workspaceNames
31544
32078
  const requiredPackages = new Map(packageEntries.flatMap(([name, policy]) => policy.presence === "required" && policy.placement !== void 0 ? [[name, policy.placement]] : []));
31545
32079
  const forcePeerOptional = /* @__PURE__ */ new Map();
31546
32080
  for (const [name, policy] of packageEntries) if (typeof policy.peerOptional === "boolean") forcePeerOptional.set(name, policy.peerOptional);
32081
+ const localConfigPath = findXyConfigFile(PATH.isAbsolute(workspace.location) ? workspace.location : PATH.resolve(INIT_CWD(), workspace.location));
32082
+ const localPackagePolicies = localConfigPath === void 0 ? /* @__PURE__ */ new Map() : normalizeDeplintPackagePolicies(Object.fromEntries(readPackagesFromConfigFile(localConfigPath)));
31547
32083
  const rangeStyleOptions = rules.find((rule) => rule.id === "dep.peerDependencies.range-style")?.options ?? {};
31548
32084
  const peerRangeForm = resolvePeerRangeFormOption(rangeStyleOptions);
31549
32085
  const peerRangeBound = resolvePeerRangeBoundOption(rangeStyleOptions);
@@ -31564,6 +32100,8 @@ async function loadWorkspaceEvaluationContext(workspace, options, workspaceNames
31564
32100
  forcePeerOptional,
31565
32101
  forcePeerWithDefault,
31566
32102
  forcePeers,
32103
+ localConfigPath,
32104
+ localPackagePolicies,
31567
32105
  peerRangeBound,
31568
32106
  peerRangeForm,
31569
32107
  phases: options.profile === true ? contextPhases : void 0,
@@ -31785,25 +32323,78 @@ var DeplintPackageEditor = class {
31785
32323
  };
31786
32324
  //#endregion
31787
32325
  //#region src/actions/deplint/fixer.ts
31788
- function applyDeplintFixes(diagnostics) {
31789
- const editors = /* @__PURE__ */ new Map();
32326
+ function isConfigFix(fix) {
32327
+ return fix.action === "remove-package-config";
32328
+ }
32329
+ function listConfigFixEntries(diagnostics) {
32330
+ return diagnostics.flatMap((diagnostic) => {
32331
+ return (diagnostic.fixes ?? []).flatMap((fix) => {
32332
+ if (!isConfigFix(fix)) return [];
32333
+ return [{
32334
+ configPath: fix.configPath,
32335
+ dependency: fix.dependency,
32336
+ detail: fix.detail,
32337
+ workspace: diagnostic.workspace
32338
+ }];
32339
+ });
32340
+ });
32341
+ }
32342
+ function groupByConfigDir(entries) {
32343
+ const byDir = /* @__PURE__ */ new Map();
32344
+ for (const entry of entries) {
32345
+ const dir = PATH.dirname(entry.configPath);
32346
+ const list = byDir.get(dir) ?? [];
32347
+ list.push(entry);
32348
+ byDir.set(dir, list);
32349
+ }
32350
+ return byDir;
32351
+ }
32352
+ function applyConfigFixesForDir(dir, entries, cwd) {
32353
+ const written = applyPackageEditsToConfigDir(dir, [...new Set(entries.map((entry) => entry.dependency))].map((dependency) => ({
32354
+ config: void 0,
32355
+ dependency
32356
+ })));
32357
+ if (written === void 0) return [];
32358
+ const credited = /* @__PURE__ */ new Set();
31790
32359
  const applied = [];
31791
- for (const diagnostic of diagnostics) {
31792
- const fixes = diagnostic.fixes ?? [];
31793
- for (const fix of fixes) {
31794
- const workspaceKey = diagnostic.workspace.location;
31795
- let editor = editors.get(workspaceKey);
31796
- if (!editor) {
31797
- editor = new DeplintPackageEditor(diagnostic.workspace);
31798
- editors.set(workspaceKey, editor);
31799
- }
31800
- const appliedFix = editor.applyFix(fix);
31801
- if (appliedFix) applied.push(appliedFix);
31802
- }
32360
+ for (const entry of entries) {
32361
+ if (credited.has(entry.dependency)) continue;
32362
+ credited.add(entry.dependency);
32363
+ applied.push({
32364
+ dependency: entry.dependency,
32365
+ detail: `${entry.detail} (${PATH.relative(cwd, written) || PATH.basename(written)})`,
32366
+ workspace: entry.workspace
32367
+ });
31803
32368
  }
32369
+ return applied;
32370
+ }
32371
+ function applyConfigFixes(diagnostics) {
32372
+ const cwd = INIT_CWD();
32373
+ return groupByConfigDir(listConfigFixEntries(diagnostics)).entries().flatMap(([dir, entries]) => applyConfigFixesForDir(dir, entries, cwd)).toArray();
32374
+ }
32375
+ function getOrCreateEditor(editors, diagnostic) {
32376
+ const workspaceKey = diagnostic.workspace.location;
32377
+ const existing = editors.get(workspaceKey);
32378
+ if (existing !== void 0) return existing;
32379
+ const editor = new DeplintPackageEditor(diagnostic.workspace);
32380
+ editors.set(workspaceKey, editor);
32381
+ return editor;
32382
+ }
32383
+ function applyManifestFixes(diagnostics) {
32384
+ const editors = /* @__PURE__ */ new Map();
32385
+ const applied = diagnostics.flatMap((diagnostic) => {
32386
+ return (diagnostic.fixes ?? []).flatMap((fix) => {
32387
+ if (isConfigFix(fix)) return [];
32388
+ const appliedFix = getOrCreateEditor(editors, diagnostic).applyFix(fix);
32389
+ return appliedFix === void 0 ? [] : [appliedFix];
32390
+ });
32391
+ });
31804
32392
  for (const editor of editors.values()) editor.save();
31805
32393
  return applied;
31806
32394
  }
32395
+ function applyDeplintFixes(diagnostics) {
32396
+ return [...applyManifestFixes(diagnostics), ...applyConfigFixes(diagnostics)];
32397
+ }
31807
32398
  //#endregion
31808
32399
  //#region src/actions/deplint/fetchPackageManifest.ts
31809
32400
  /**
@@ -32137,7 +32728,7 @@ function missingWorkspaceResult(targetPackage) {
32137
32728
  exitCode: 1
32138
32729
  };
32139
32730
  }
32140
- function resolveTargetWorkspaces(targetPackage, inputWorkspaces) {
32731
+ function resolveTargetWorkspaces$1(targetPackage, inputWorkspaces) {
32141
32732
  const pm = getPackageManager();
32142
32733
  const allWorkspaces = pm.listWorkspaces();
32143
32734
  const workspaceNames = pm.name === "pnpm" ? new Set(allWorkspaces.map((ws) => ws.name)) : void 0;
@@ -32150,7 +32741,7 @@ function resolveTargetWorkspaces(targetPackage, inputWorkspaces) {
32150
32741
  const deplint = async ({ pkg, classifier, deps, devDeps, fix, peerDeps, profile, verbose, cliExclude, format, jobs, workspaces: inputWorkspaces }) => {
32151
32742
  const effectiveFormat = format ?? (isJsonMode() ? "json" : "human");
32152
32743
  const targetPackage = typeof pkg === "string" && pkg !== "undefined" && pkg.length > 0 ? pkg : void 0;
32153
- const { targetWorkspaces, workspaceNames } = resolveTargetWorkspaces(targetPackage, inputWorkspaces);
32744
+ const { targetWorkspaces, workspaceNames } = resolveTargetWorkspaces$1(targetPackage, inputWorkspaces);
32154
32745
  if (targetPackage === void 0 && inputWorkspaces !== void 0 && targetWorkspaces.length === 0) return emptyResult$7();
32155
32746
  if (targetWorkspaces.length === 0) return missingWorkspaceResult(targetPackage);
32156
32747
  const result = await runDeplint(targetWorkspaces, {
@@ -32182,6 +32773,275 @@ const deplint = async ({ pkg, classifier, deps, devDeps, fix, peerDeps, profile,
32182
32773
  };
32183
32774
  };
32184
32775
  //#endregion
32776
+ //#region src/actions/deplint/interactivePick.ts
32777
+ const SELECTIONS = [
32778
+ "none",
32779
+ "dep",
32780
+ "dev",
32781
+ "peer"
32782
+ ];
32783
+ function pad(raw, colored, width) {
32784
+ return colored + " ".repeat(Math.max(0, width - raw.length));
32785
+ }
32786
+ function dot(isSelected) {
32787
+ return isSelected ? chalk.green("●") : chalk.dim("○");
32788
+ }
32789
+ function reasonLabel(reason) {
32790
+ if (reason === "review") return "borderline";
32791
+ if (reason === "configured") return "configured";
32792
+ return "both";
32793
+ }
32794
+ function reasonColor(reason) {
32795
+ if (reason === "review") return chalk.yellow;
32796
+ if (reason === "configured") return chalk.cyan;
32797
+ return chalk.magenta;
32798
+ }
32799
+ function currentLabel(row) {
32800
+ const configured = row.currentConfig?.placement ?? row.currentConfig?.refType;
32801
+ if (configured !== void 0) return configured;
32802
+ if (row.reason === "review" || row.reason === "both") return "review";
32803
+ return "-";
32804
+ }
32805
+ function computeWidths(rows) {
32806
+ let scope = 5;
32807
+ let dependency = 9;
32808
+ let current = 7;
32809
+ let reason = 6;
32810
+ for (const row of rows) {
32811
+ scope = Math.max(scope, row.scope.length);
32812
+ dependency = Math.max(dependency, row.dependency.length);
32813
+ current = Math.max(current, currentLabel(row).length);
32814
+ reason = Math.max(reason, reasonLabel(row.reason).length);
32815
+ }
32816
+ return {
32817
+ current,
32818
+ dependency,
32819
+ reason,
32820
+ scope
32821
+ };
32822
+ }
32823
+ function renderChoice(selection, choice, width) {
32824
+ const raw = choice;
32825
+ const selected = selection === choice;
32826
+ const colored = selected ? chalk.white(raw) : chalk.dim(raw);
32827
+ return `${dot(selected)} ${pad(raw, colored, width)}`;
32828
+ }
32829
+ function renderHeader(w) {
32830
+ const choiceWidth = 4;
32831
+ const header = [
32832
+ " ",
32833
+ chalk.bold("Scope".padEnd(w.scope)),
32834
+ chalk.bold("Package".padEnd(w.dependency)),
32835
+ chalk.bold("Current".padEnd(w.current)),
32836
+ chalk.bold("Why".padEnd(w.reason)),
32837
+ chalk.bold(` ${"none".padEnd(choiceWidth)}`),
32838
+ chalk.bold(` ${"dep".padEnd(choiceWidth)}`),
32839
+ chalk.bold(` ${"dev".padEnd(choiceWidth)}`),
32840
+ chalk.bold(` ${"peer".padEnd(choiceWidth)}`)
32841
+ ].join(" ");
32842
+ const totalWidth = w.scope + w.dependency + w.current + w.reason + 24 + 28;
32843
+ return `${header}\n${chalk.gray("─".repeat(totalWidth))}`;
32844
+ }
32845
+ function renderRow(row, selection, isActive, w) {
32846
+ const pointer = isActive ? chalk.cyan("❯") : " ";
32847
+ const scope = chalk[isActive ? "white" : "gray"](row.scope);
32848
+ const dependency = chalk[isActive ? "white" : "gray"](row.dependency);
32849
+ const currentRaw = currentLabel(row);
32850
+ const current = currentRaw === "review" ? chalk.yellow(currentRaw) : chalk.gray(currentRaw);
32851
+ const reasonRaw = reasonLabel(row.reason);
32852
+ const reason = reasonColor(row.reason)(reasonRaw);
32853
+ const choiceWidth = 4;
32854
+ const none = renderChoice(selection, "none", choiceWidth);
32855
+ const dep = renderChoice(selection, "dep", choiceWidth);
32856
+ const dev = renderChoice(selection, "dev", choiceWidth);
32857
+ const peer = renderChoice(selection, "peer", choiceWidth);
32858
+ return [
32859
+ `${pointer} ${pad(row.scope, scope, w.scope)}`,
32860
+ pad(row.dependency, dependency, w.dependency),
32861
+ pad(currentRaw, current, w.current),
32862
+ pad(reasonRaw, reason, w.reason),
32863
+ none,
32864
+ dep,
32865
+ dev,
32866
+ peer
32867
+ ].join(" ");
32868
+ }
32869
+ function renderPage(rows, cursor, selections, w, pageSize) {
32870
+ const total = rows.length;
32871
+ const start = total > pageSize ? Math.max(0, Math.min(cursor - Math.floor(pageSize / 2), total - pageSize)) : 0;
32872
+ const end = Math.min(start + pageSize, total);
32873
+ const lines = [];
32874
+ for (let i = start; i < end; i++) lines.push(renderRow(rows[i], selections[i], i === cursor, w));
32875
+ if (total > pageSize) {
32876
+ if (start > 0) lines.unshift(chalk.dim(" ↑ more"));
32877
+ if (end < total) lines.push(chalk.dim(" ↓ more"));
32878
+ }
32879
+ return lines.join("\n");
32880
+ }
32881
+ function cycleSelection(current) {
32882
+ const idx = SELECTIONS.indexOf(current);
32883
+ return SELECTIONS[(idx + 1) % SELECTIONS.length];
32884
+ }
32885
+ /**
32886
+ * Detect whether the user's selection should write a config change.
32887
+ * - dep/dev/peer rows: change when selection differs from current placement
32888
+ * - peer-with-default / presence-only config: `none` keeps the entry; dep/dev/peer replaces it
32889
+ * - review-only rows: `none` leaves unconfigured; dep/dev/peer adds config
32890
+ */
32891
+ function selectionChanged(row, selection) {
32892
+ if (row.currentPlacement !== void 0) return selection !== row.currentPlacement;
32893
+ if (row.currentConfig !== void 0) return selection !== "none";
32894
+ return selection !== "none";
32895
+ }
32896
+ const pickPrompt = createPrompt((config, done) => {
32897
+ const { rows } = config;
32898
+ const [cursor, setCursor] = useState(0);
32899
+ const [tick, setTick] = useState(0);
32900
+ const selectionsRef = useRef(rows.map((row) => row.initialSelection));
32901
+ const widthsRef = useRef(computeWidths(rows));
32902
+ useKeypress((key) => {
32903
+ if (key.name === "escape" || key.ctrl && key.name === "c") {
32904
+ done([]);
32905
+ return;
32906
+ }
32907
+ if (isEnterKey(key)) {
32908
+ const results = [];
32909
+ for (const [i, row] of rows.entries()) {
32910
+ const selection = selectionsRef.current[i];
32911
+ if (!selectionChanged(row, selection)) continue;
32912
+ results.push({
32913
+ dependency: row.dependency,
32914
+ editDir: row.editDir,
32915
+ previousConfig: row.currentConfig,
32916
+ selection
32917
+ });
32918
+ }
32919
+ done(results);
32920
+ return;
32921
+ }
32922
+ if (isUpKey(key)) setCursor(Math.max(0, cursor - 1));
32923
+ else if (isDownKey(key)) setCursor(Math.min(rows.length - 1, cursor + 1));
32924
+ else if (isSpaceKey(key)) {
32925
+ selectionsRef.current[cursor] = cycleSelection(selectionsRef.current[cursor]);
32926
+ setTick(tick + 1);
32927
+ }
32928
+ });
32929
+ const w = widthsRef.current;
32930
+ const header = renderHeader(w);
32931
+ const page = renderPage(rows, cursor, selectionsRef.current, w, 20);
32932
+ const changedCount = selectionsRef.current.filter((selection, i) => selectionChanged(rows[i], selection)).length;
32933
+ return `${header}\n${page}\n${chalk.gray(` ${changedCount} changed ↑/↓ navigate space cycle placement enter confirm`)}`;
32934
+ });
32935
+ async function interactiveDeplintPick(rows) {
32936
+ if (rows.length === 0) {
32937
+ console.log(chalk.green("\nNo borderline or configured deplint packages to review."));
32938
+ return [];
32939
+ }
32940
+ if (!process.stdout.isTTY) {
32941
+ console.log(chalk.yellow("Non-interactive environment detected, skipping selection."));
32942
+ return [];
32943
+ }
32944
+ try {
32945
+ return await pickPrompt({ rows });
32946
+ } catch (error) {
32947
+ if (error instanceof ExitPromptError) return [];
32948
+ throw error;
32949
+ }
32950
+ }
32951
+ function decisionToPackageConfig(decision) {
32952
+ if (decision.selection === "none") return {
32953
+ config: void 0,
32954
+ dependency: decision.dependency
32955
+ };
32956
+ const placement = decision.selection;
32957
+ const previous = decision.previousConfig;
32958
+ return {
32959
+ config: {
32960
+ placement,
32961
+ ...previous?.presence !== void 0 && { presence: previous.presence },
32962
+ ...previous?.peerOptional !== void 0 && { peerOptional: previous.peerOptional }
32963
+ },
32964
+ dependency: decision.dependency
32965
+ };
32966
+ }
32967
+ //#endregion
32968
+ //#region src/actions/deplint/deplintPick.ts
32969
+ function emptyPickResult(rows = 0, decisions = 0, changedFiles = []) {
32970
+ return {
32971
+ envelope: { data: {
32972
+ changedFiles,
32973
+ decisions,
32974
+ rows
32975
+ } },
32976
+ exitCode: 0
32977
+ };
32978
+ }
32979
+ function resolveTargetWorkspaces(targetPackage) {
32980
+ const pm = getPackageManager();
32981
+ const allWorkspaces = pm.listWorkspaces();
32982
+ if (targetPackage === void 0) return allWorkspaces;
32983
+ const target = pm.findWorkspace(targetPackage);
32984
+ return target ? [target] : [];
32985
+ }
32986
+ function groupEditsByDir(decisions) {
32987
+ const editsByDir = /* @__PURE__ */ new Map();
32988
+ for (const decision of decisions) {
32989
+ const edit = decisionToPackageConfig(decision);
32990
+ const list = editsByDir.get(decision.editDir) ?? [];
32991
+ list.push(edit);
32992
+ editsByDir.set(decision.editDir, list);
32993
+ }
32994
+ return editsByDir;
32995
+ }
32996
+ function applyGroupedEdits(editsByDir, cwd) {
32997
+ const changedFiles = [];
32998
+ for (const [dir, edits] of editsByDir) {
32999
+ const written = applyPackageEditsToConfigDir(dir, edits);
33000
+ if (written !== void 0) changedFiles.push(written);
33001
+ }
33002
+ if (changedFiles.length === 0) {
33003
+ console.log(chalk.gray("No config files modified."));
33004
+ return changedFiles;
33005
+ }
33006
+ console.log(chalk.green(`\nUpdated ${changedFiles.length} config file(s):`));
33007
+ for (const file of changedFiles) console.log(chalk.green(` ${PATH.relative(cwd, file) || PATH.basename(file)}`));
33008
+ console.log(chalk.gray("\nRun `xy deplint --fix` to apply placements to package.json manifests."));
33009
+ return changedFiles;
33010
+ }
33011
+ const deplintPick = async ({ classifier, jobs, pkg, verbose } = {}) => {
33012
+ const cwd = INIT_CWD();
33013
+ const targetPackage = typeof pkg === "string" && pkg !== "undefined" && pkg.length > 0 ? pkg : void 0;
33014
+ const targetWorkspaces = resolveTargetWorkspaces(targetPackage);
33015
+ if (targetPackage !== void 0 && targetWorkspaces.length === 0) {
33016
+ console.error(chalk.red(`Workspace not found: ${targetPackage}`));
33017
+ return {
33018
+ envelope: {
33019
+ errorCount: 1,
33020
+ errors: [{ message: `Workspace not found: ${targetPackage}` }]
33021
+ },
33022
+ exitCode: 1
33023
+ };
33024
+ }
33025
+ if (targetWorkspaces.length === 0) return emptyPickResult();
33026
+ const pm = getPackageManager();
33027
+ const workspaceNames = pm.name === "pnpm" ? new Set(pm.listWorkspaces().map((ws) => ws.name)) : void 0;
33028
+ console.log(chalk.gray("Scanning deplint borderline packages and xy.config placements..."));
33029
+ const rows = collectDeplintPickRows(cwd, targetWorkspaces, (await runDeplint(targetWorkspaces, {
33030
+ classifier,
33031
+ jobs,
33032
+ progress: verbose === true ? createHumanDeplintProgressReporter({ isVerbose: true }) : void 0,
33033
+ reporter: "json"
33034
+ }, workspaceNames)).diagnostics);
33035
+ console.log(chalk.gray(` ${rows.length} item(s) (${rows.filter((r) => r.reason === "review" || r.reason === "both").length} borderline, ${rows.filter((r) => r.reason === "configured" || r.reason === "both").length} configured)`));
33036
+ const decisions = await interactiveDeplintPick(rows);
33037
+ if (decisions.length === 0) {
33038
+ console.log(chalk.gray("No placement changes selected."));
33039
+ return emptyPickResult(rows.length);
33040
+ }
33041
+ const changedFiles = applyGroupedEdits(groupEditsByDir(decisions), cwd);
33042
+ return emptyPickResult(rows.length, decisions.length, changedFiles);
33043
+ };
33044
+ //#endregion
32185
33045
  //#region src/actions/lintNextWorker.ts
32186
33046
  const lintNextIgnorePatterns = ["packages/**"];
32187
33047
  const lintNextResultMarker = "__XY_LINT_NEXT_RESULT__";
@@ -53642,10 +54502,36 @@ const cycleCommand = {
53642
54502
  }
53643
54503
  };
53644
54504
  //#endregion
53645
- //#region src/xy/lint/deplintCommand.ts
53646
- const deplintCommand = {
53647
- command: "deplint [package]",
53648
- describe: "Deplint - Run Deplint",
54505
+ //#region src/xy/lint/deplintPickCommand.ts
54506
+ const deplintPickCommand = {
54507
+ builder: (yargs) => {
54508
+ return packagePositionalParam(yargs).option("classifier", {
54509
+ choices: [
54510
+ "aei",
54511
+ "aei-next",
54512
+ "legacy"
54513
+ ],
54514
+ description: "Dep-vs-peer classifier: legacy (external ⇒ peer), aei (API Exposure Index), or aei-next (AEI + peer-with-default)",
54515
+ type: "string"
54516
+ });
54517
+ },
54518
+ command: "pick [package]",
54519
+ describe: "Interactively configure borderline AEI packages and existing deplint package placements in xy.config",
54520
+ handler: async (argv) => {
54521
+ if (Boolean(argv.verbose)) console.log("Deplint pick");
54522
+ const pkg = typeof argv.package === "string" ? argv.package : void 0;
54523
+ await withEnvelope("deplint pick", () => deplintPick({
54524
+ classifier: argv.classifier,
54525
+ jobs: argv.jobs,
54526
+ pkg,
54527
+ verbose: !!Boolean(argv.verbose)
54528
+ }));
54529
+ }
54530
+ };
54531
+ //#endregion
54532
+ //#region src/xy/lint/deplintRunCommand.ts
54533
+ const deplintRunCommand = {
54534
+ aliases: ["$0"],
53649
54535
  builder: (yargs) => {
53650
54536
  return packagePositionalParam(yargs).option("deps", {
53651
54537
  alias: "d",
@@ -53689,6 +54575,8 @@ const deplintCommand = {
53689
54575
  type: "boolean"
53690
54576
  });
53691
54577
  },
54578
+ command: "run [package]",
54579
+ describe: "Run deplint",
53692
54580
  handler: async (argv) => {
53693
54581
  if (Boolean(argv.verbose)) console.log("Deplint");
53694
54582
  const pkg = typeof argv.package === "string" ? argv.package : void 0;
@@ -53713,6 +54601,16 @@ const deplintCommand = {
53713
54601
  }
53714
54602
  };
53715
54603
  //#endregion
54604
+ //#region src/xy/lint/deplintCommand.ts
54605
+ const deplintCommand = {
54606
+ builder: (yargs) => {
54607
+ return yargs.command(deplintRunCommand).command(deplintPickCommand);
54608
+ },
54609
+ command: "deplint",
54610
+ describe: "Deplint - Run dependency lint, or pick package placements interactively",
54611
+ handler: () => {}
54612
+ };
54613
+ //#endregion
53716
54614
  //#region src/xy/lint/fixCommand.ts
53717
54615
  const fixCommand = {
53718
54616
  builder: (yargs) => {