@ariestools/toolchain 8.7.5 → 8.7.6

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.
@@ -1 +1 @@
1
- {"version":3,"file":"analyzePackage.d.ts","sourceRoot":"","sources":["../../../../src/actions/api-exposure/analyzer/analyzePackage.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAMrD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAC5D,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,cAAc,CAAA;AAG/D,OAAO,KAAK,EAOV,0BAA0B,EAC3B,MAAM,aAAa,CAAA;AAMpB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AAGtD,MAAM,WAAW,oBAAoB;IACnC,KAAK,CAAC,EAAE,kBAAkB,CAAA;IAC1B,MAAM,EAAE,2BAA2B,CAAA;IACnC,qEAAqE;IACrE,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CAAA;IACtC,SAAS,EAAE,SAAS,CAAA;IACpB,oEAAoE;IACpE,cAAc,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;CAC7B;AA2QD;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,EAC1C,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,cAAc,GAC/D,EAAE,oBAAoB,GAAG,0BAA0B,CAsDnD"}
1
+ {"version":3,"file":"analyzePackage.d.ts","sourceRoot":"","sources":["../../../../src/actions/api-exposure/analyzer/analyzePackage.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAMrD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAC5D,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,cAAc,CAAA;AAG/D,OAAO,KAAK,EAOV,0BAA0B,EAC3B,MAAM,aAAa,CAAA;AAMpB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AAGtD,MAAM,WAAW,oBAAoB;IACnC,KAAK,CAAC,EAAE,kBAAkB,CAAA;IAC1B,MAAM,EAAE,2BAA2B,CAAA;IACnC,qEAAqE;IACrE,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CAAA;IACtC,SAAS,EAAE,SAAS,CAAA;IACpB,oEAAoE;IACpE,cAAc,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;CAC7B;AAkSD;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,EAC1C,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,cAAc,GAC/D,EAAE,oBAAoB,GAAG,0BAA0B,CAsDnD"}
@@ -11,9 +11,11 @@ export interface DependencySignals {
11
11
  /**
12
12
  * True when the install tree holds more than one version of the dependency —
13
13
  * the duplication-risk condition of the tree-shaking modifier
14
- * (API-EXPOSURE-INDEX.md section 9). Only the pnpm virtual store can be read
15
- * cheaply; on other layouts the answer is unknown, so the modifier keeps its
16
- * historical behavior and applies.
14
+ * (API-EXPOSURE-INDEX.md section 9). The pnpm lockfile is the authoritative
15
+ * source; the `.pnpm` virtual store directory is the fallback (it can hold
16
+ * stale entries from prior installs, so it may over-report). On other
17
+ * layouts the answer is unknown, so the modifier keeps its historical
18
+ * behavior and applies.
17
19
  */
18
20
  export declare function hasInstalledVersionMultiplicity(workspaceDir: string, dependency: string): boolean;
19
21
  /** Walks up from `startDir` looking for `node_modules/<dependency>/package.json`. */
@@ -1 +1 @@
1
- {"version":3,"file":"depSignals.d.ts","sourceRoot":"","sources":["../../../../src/actions/api-exposure/analyzer/depSignals.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAEhD,gEAAgE;AAChE,eAAO,MAAM,qBAAqB,iBAAiB,CAAA;AAoBnD,MAAM,WAAW,iBAAiB;IAChC,iEAAiE;IACjE,GAAG,EAAE,OAAO,CAAA;IACZ,QAAQ,EAAE,aAAa,EAAE,CAAA;IACzB,gDAAgD;IAChD,eAAe,EAAE,OAAO,CAAA;CACzB;AA0BD;;;;;;GAMG;AACH,wBAAgB,+BAA+B,CAAC,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAUjG;AAED,qFAAqF;AACrF,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAS1F;AA6FD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,iBAAiB,GAAG,SAAS,CAiC5G"}
1
+ {"version":3,"file":"depSignals.d.ts","sourceRoot":"","sources":["../../../../src/actions/api-exposure/analyzer/depSignals.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAEhD,gEAAgE;AAChE,eAAO,MAAM,qBAAqB,iBAAiB,CAAA;AAoBnD,MAAM,WAAW,iBAAiB;IAChC,iEAAiE;IACjE,GAAG,EAAE,OAAO,CAAA;IACZ,QAAQ,EAAE,aAAa,EAAE,CAAA;IACzB,gDAAgD;IAChD,eAAe,EAAE,OAAO,CAAA;CACzB;AAgFD;;;;;;;;GAQG;AACH,wBAAgB,+BAA+B,CAAC,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAmBjG;AAED,qFAAqF;AACrF,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAS1F;AAqKD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,iBAAiB,GAAG,SAAS,CAqC5G"}
@@ -1 +1 @@
1
- {"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../../../src/actions/api-exposure/rules.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAEnD;;;;GAIG;AACH,eAAO,MAAM,SAAS,EAAE,iBAAiB,EAiLxC,CAAA;AAID,eAAO,MAAM,YAAY,EAAE,WAAW,CAAC,MAAM,CAA+B,CAAA;AAE5E,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,iBAAiB,GAAG,SAAS,CAEpE"}
1
+ {"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../../../src/actions/api-exposure/rules.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAEnD;;;;GAIG;AACH,eAAO,MAAM,SAAS,EAAE,iBAAiB,EAuLxC,CAAA;AAID,eAAO,MAAM,YAAY,EAAE,WAAW,CAAC,MAAM,CAA+B,CAAA;AAE5E,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,iBAAiB,GAAG,SAAS,CAEpE"}
package/dist/bin/xy.mjs CHANGED
@@ -23556,6 +23556,12 @@ const AEI_RULES = [
23556
23556
  id: "aei.signal.global-registry",
23557
23557
  kind: "dep-signal"
23558
23558
  },
23559
+ {
23560
+ defaultWeight: 40,
23561
+ description: "Dependency creates React contexts at module scope (a duplicate copy forks the context)",
23562
+ id: "aei.signal.creates-context",
23563
+ kind: "dep-signal"
23564
+ },
23559
23565
  {
23560
23566
  defaultWeight: 30,
23561
23567
  description: "Dependency exports mutable objects",
@@ -24076,14 +24082,71 @@ function findPnpmVirtualStoreEntries(startDir) {
24076
24082
  current = parent;
24077
24083
  }
24078
24084
  }
24085
+ /** Walks up from `startDir` looking for a `pnpm-lock.yaml`. */
24086
+ function findPnpmLockfile(startDir) {
24087
+ let current = PATH.resolve(startDir);
24088
+ while (true) {
24089
+ const candidate = PATH.join(current, "pnpm-lock.yaml");
24090
+ if (fs.existsSync(candidate)) return candidate;
24091
+ const parent = PATH.dirname(current);
24092
+ if (parent === current) return void 0;
24093
+ current = parent;
24094
+ }
24095
+ }
24096
+ const lockfileVersionsCache = /* @__PURE__ */ new Map();
24097
+ /**
24098
+ * Package-key lines of the lockfile's `packages:` section, e.g.
24099
+ * ` '@mui/material@9.2.0':` (v9), ` react@19.2.7:` (v9 unquoted) or
24100
+ * ` /@mui/material@9.2.0(react@19.2.7):` (v6).
24101
+ */
24102
+ const LOCKFILE_PACKAGE_KEY = /^ {2}['"]?\/?((?:@[^/'"\s]+\/)?[^@/'"\s]+)@([^('":\s]+)/;
24103
+ /**
24104
+ * Resolved versions per package name from the lockfile's `packages:` section.
24105
+ * The lockfile is authoritative for what an install produces — unlike the
24106
+ * `.pnpm` virtual store directory, which can hold stale entries from prior
24107
+ * installs.
24108
+ */
24109
+ function readLockfileVersions(lockfilePath) {
24110
+ if (lockfileVersionsCache.has(lockfilePath)) return lockfileVersionsCache.get(lockfilePath);
24111
+ let versions;
24112
+ try {
24113
+ const lines = fs.readFileSync(lockfilePath, "utf8").split("\n");
24114
+ versions = /* @__PURE__ */ new Map();
24115
+ let inPackagesSection = false;
24116
+ for (const line of lines) {
24117
+ if (line.length > 0 && line[0] !== " " && line[0] !== "#") {
24118
+ inPackagesSection = line.startsWith("packages:");
24119
+ continue;
24120
+ }
24121
+ if (!inPackagesSection) continue;
24122
+ const match = LOCKFILE_PACKAGE_KEY.exec(line);
24123
+ if (match === null) continue;
24124
+ const [, name, version] = match;
24125
+ const set = versions.get(name) ?? /* @__PURE__ */ new Set();
24126
+ set.add(version);
24127
+ versions.set(name, set);
24128
+ }
24129
+ } catch {
24130
+ versions = void 0;
24131
+ }
24132
+ lockfileVersionsCache.set(lockfilePath, versions);
24133
+ return versions;
24134
+ }
24079
24135
  /**
24080
24136
  * True when the install tree holds more than one version of the dependency —
24081
24137
  * the duplication-risk condition of the tree-shaking modifier
24082
- * (API-EXPOSURE-INDEX.md section 9). Only the pnpm virtual store can be read
24083
- * cheaply; on other layouts the answer is unknown, so the modifier keeps its
24084
- * historical behavior and applies.
24138
+ * (API-EXPOSURE-INDEX.md section 9). The pnpm lockfile is the authoritative
24139
+ * source; the `.pnpm` virtual store directory is the fallback (it can hold
24140
+ * stale entries from prior installs, so it may over-report). On other
24141
+ * layouts the answer is unknown, so the modifier keeps its historical
24142
+ * behavior and applies.
24085
24143
  */
24086
24144
  function hasInstalledVersionMultiplicity(workspaceDir, dependency) {
24145
+ const lockfilePath = findPnpmLockfile(workspaceDir);
24146
+ if (lockfilePath !== void 0) {
24147
+ const lockfileVersions = readLockfileVersions(lockfilePath);
24148
+ if (lockfileVersions !== void 0) return (lockfileVersions.get(dependency)?.size ?? 0) > 1;
24149
+ }
24087
24150
  const entries = findPnpmVirtualStoreEntries(workspaceDir);
24088
24151
  if (entries === void 0) return true;
24089
24152
  const prefix = `${dependency.replace("/", "+")}@`;
@@ -24134,6 +24197,69 @@ function hasEsmSurface(manifest) {
24134
24197
  if (typeof exportsField === "object" && exportsField !== null) return firstStringDeep(exportsField, ["import"]) !== void 0 || JSON.stringify(exportsField).includes("\"import\"");
24135
24198
  return false;
24136
24199
  }
24200
+ const CONTEXT_CREATION_PATTERN = /\bcreateContext\s*\(/;
24201
+ /** Bounds for the shipped-runtime context scan (large deps like MUI). */
24202
+ const MAX_CONTEXT_SCAN_FILES = 400;
24203
+ const MAX_CONTEXT_SCAN_BYTES = 8e6;
24204
+ const RUNTIME_FILE_PATTERN = /\.(?:js|mjs|cjs)$/;
24205
+ const createsContextCache = /* @__PURE__ */ new Map();
24206
+ /** Collects shipped runtime files, capped, skipping nested node_modules. */
24207
+ function collectRuntimeFiles(dir, collected) {
24208
+ if (collected.length >= MAX_CONTEXT_SCAN_FILES * 4) return;
24209
+ let entries;
24210
+ try {
24211
+ entries = fs.readdirSync(dir, { withFileTypes: true });
24212
+ } catch {
24213
+ return;
24214
+ }
24215
+ for (const entry of entries) {
24216
+ if (collected.length >= MAX_CONTEXT_SCAN_FILES * 4) return;
24217
+ const entryPath = PATH.join(dir, entry.name);
24218
+ if (entry.isDirectory()) {
24219
+ if (entry.name !== "node_modules") collectRuntimeFiles(entryPath, collected);
24220
+ } else if (entry.isFile() && RUNTIME_FILE_PATTERN.test(entry.name)) collected.push(entryPath);
24221
+ }
24222
+ }
24223
+ /**
24224
+ * Bounded scan of the dependency's shipped runtime for module-scope context
24225
+ * creation (`createContext(`). Context-named files are scanned first — the
24226
+ * conventional home of the pattern — so large dependencies resolve within
24227
+ * the scan budget.
24228
+ */
24229
+ function createsSharedContext(dependencyDir) {
24230
+ const cached = createsContextCache.get(dependencyDir);
24231
+ if (cached !== void 0) return cached;
24232
+ const files = [];
24233
+ collectRuntimeFiles(dependencyDir, files);
24234
+ const prioritized = files.toSorted((a, b) => Number(/context/i.test(b)) - Number(/context/i.test(a)));
24235
+ let scannedFiles = 0;
24236
+ let scannedBytes = 0;
24237
+ let result = false;
24238
+ for (const file of prioritized) {
24239
+ if (scannedFiles >= MAX_CONTEXT_SCAN_FILES || scannedBytes >= MAX_CONTEXT_SCAN_BYTES) break;
24240
+ try {
24241
+ const content = fs.readFileSync(file, "utf8");
24242
+ scannedFiles += 1;
24243
+ scannedBytes += content.length;
24244
+ if (CONTEXT_CREATION_PATTERN.test(content)) {
24245
+ result = true;
24246
+ break;
24247
+ }
24248
+ } catch {
24249
+ continue;
24250
+ }
24251
+ }
24252
+ createsContextCache.set(dependencyDir, result);
24253
+ return result;
24254
+ }
24255
+ /**
24256
+ * True for packages in the React-singleton class: React itself and libraries
24257
+ * designed to share the host's React copy. Scopes the context scan so
24258
+ * unrelated uses of `createContext` (e.g. `node:vm`) don't fire the signal.
24259
+ */
24260
+ function isReactAdjacent(dependency, manifest) {
24261
+ return dependency === "react" || dependency === "react-dom" || Object.hasOwn(manifest.peerDependencies ?? {}, "react");
24262
+ }
24137
24263
  /** Syntactic scan of the dependency's types entry point. */
24138
24264
  function scanTypesSurface(typesEntry) {
24139
24265
  let sourceCode;
@@ -24187,6 +24313,7 @@ function getDependencySignals(workspaceDir, dependency) {
24187
24313
  if (manifest.peerDependencies !== void 0 && Object.keys(manifest.peerDependencies).length > 0) report("aei.signal.declares-peers", `${dependency} declares peerDependencies of its own`);
24188
24314
  const sideEffectsFree = manifest.sideEffects === false;
24189
24315
  if (sideEffectsFree) report("aei.signal.side-effects-free", `${dependency} declares sideEffects: false`);
24316
+ if (isReactAdjacent(dependency, manifest) && createsSharedContext(dependencyDir)) report("aei.signal.creates-context", `${dependency} creates React contexts at module scope — a duplicate copy forks the context`);
24190
24317
  const typesEntry = resolveTypesEntry(dependencyDir, manifest);
24191
24318
  const surface = typesEntry === void 0 ? void 0 : scanTypesSurface(typesEntry);
24192
24319
  if (surface !== void 0) {
@@ -24656,35 +24783,48 @@ function typesAliasesOf(target) {
24656
24783
  return target.startsWith("@") ? [`@types/${target.slice(1).replace("/", "__")}`] : [`@types/${target}`];
24657
24784
  }
24658
24785
  /**
24659
- * True when `target` is provided by the dependency closure of one of the
24660
- * package's declared deps (depth-limited, mirroring the peer-chain walk).
24661
- * An exposed-but-unlisted package that arrives this way is version-managed
24662
- * by the declaring intermediary, so the analyzer must not conclude `peer`
24663
- * on its own — the emitted d.ts (deplint's dist type-import rule) is the
24664
- * enforcement point for whether it must also be declared here.
24786
+ * Resolves a provider package's real directory and its declared runtime
24787
+ * dependencies. The realpath matters under pnpm's non-hoisted layout: a
24788
+ * provider's own dependencies are only resolvable from its virtual-store
24789
+ * directory, not from the workspace that (transitively) links it.
24665
24790
  */
24666
- function readDeclaredDependencies(workspaceDir, dep) {
24667
- const manifestPath = findDepPackageJson(workspaceDir, dep);
24668
- if (manifestPath === void 0) return [];
24791
+ function resolveProvider(baseDir, dep) {
24792
+ const manifestPath = findDepPackageJson(baseDir, dep);
24793
+ if (manifestPath === void 0) return void 0;
24669
24794
  try {
24670
24795
  const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
24671
- return Object.keys(manifest.dependencies ?? {});
24796
+ let dir = PATH.dirname(manifestPath);
24797
+ try {
24798
+ dir = fs.realpathSync(dir);
24799
+ } catch {}
24800
+ return {
24801
+ dependencies: Object.keys(manifest.dependencies ?? {}),
24802
+ dir
24803
+ };
24672
24804
  } catch {
24673
- return [];
24805
+ return;
24674
24806
  }
24675
24807
  }
24676
24808
  function isProvidedByDeclaredDeps(workspaceDir, declared, targets) {
24677
24809
  const targetSet = new Set(targets);
24678
24810
  const visited = /* @__PURE__ */ new Set();
24679
- let frontier = [...declared];
24811
+ let frontier = [...declared].map((name) => ({
24812
+ baseDir: workspaceDir,
24813
+ name
24814
+ }));
24680
24815
  for (let depth = 0; depth <= PROVIDED_CLOSURE_DEPTH; depth++) {
24681
- const unvisited = frontier.filter((entry) => !visited.has(entry));
24682
24816
  const next = [];
24683
- for (const dep of unvisited) {
24684
- visited.add(dep);
24685
- const dependencies = readDeclaredDependencies(workspaceDir, dep);
24686
- if (dependencies.some((dependency) => targetSet.has(dependency))) return true;
24687
- next.push(...dependencies);
24817
+ const unvisited = frontier.filter(({ name }) => !visited.has(name));
24818
+ for (const { baseDir, name } of unvisited) {
24819
+ visited.add(name);
24820
+ const provider = resolveProvider(baseDir, name);
24821
+ if (provider !== void 0) {
24822
+ if (provider.dependencies.some((dependency) => targetSet.has(dependency))) return true;
24823
+ next.push(...provider.dependencies.map((dependency) => ({
24824
+ baseDir: provider.dir,
24825
+ name: dependency
24826
+ })));
24827
+ }
24688
24828
  }
24689
24829
  frontier = next;
24690
24830
  }
@@ -24773,7 +24913,7 @@ function isProvidedBySections(dependency, findings, sections, workspaceDir) {
24773
24913
  */
24774
24914
  function resolveRecommendation(scored, findings, { config, dependency, isSelfOrInternal, isTerminal, refTypes, sections, workspaceDir }) {
24775
24915
  const classification = config.classificationFor(dependency) ?? refTypes?.get(dependency);
24776
- if (classification !== void 0) return [classification === "peer" ? "peer" : "dependency", "override"];
24916
+ if (classification !== void 0 && !(isTerminal === true && classification === "peer")) return [classification === "peer" ? "peer" : "dependency", "override"];
24777
24917
  if (isTerminal === true) {
24778
24918
  if (sections.isPrivate && currentSectionOf(dependency, sections) === "devDependencies") return void 0;
24779
24919
  return ["dependency", "terminal"];