react-doctor 0.5.1-dev.94f9f4f → 0.5.1-dev.a48fb06

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
@@ -1,5 +1,5 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="f25bdf09-ff57-565e-b47b-46ef237158c2")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="10847467-aed6-53d3-b6bd-1ed24087b9e7")}catch(e){}}();
3
3
  import { createRequire } from "node:module";
4
4
  import * as NodeChildProcess from "node:child_process";
5
5
  import { execFile, execFileSync, spawn, spawnSync } from "node:child_process";
@@ -21009,7 +21009,7 @@ const recurDefaults = /* @__PURE__ */ memoize((ast) => {
21009
21009
  * @since 4.0.0
21010
21010
  */
21011
21011
  function makeEffect(schema) {
21012
- const parser = run$2(recurDefaults(toType(schema.ast)));
21012
+ const parser = run$1(recurDefaults(toType(schema.ast)));
21013
21013
  return (input, options) => {
21014
21014
  return parser(input, options?.disableChecks ? options?.parseOptions ? {
21015
21015
  ...options.parseOptions,
@@ -21054,7 +21054,7 @@ function make$25(schema) {
21054
21054
  }
21055
21055
  /** @internal */
21056
21056
  function _is(ast) {
21057
- const parser = asExit(run$2(toType(ast)));
21057
+ const parser = asExit(run$1(toType(ast)));
21058
21058
  return (input) => {
21059
21059
  return isSuccess(parser(input, defaultParseOptions));
21060
21060
  };
@@ -21073,7 +21073,7 @@ function _is(ast) {
21073
21073
  * @since 4.0.0
21074
21074
  */
21075
21075
  function decodeUnknownEffect(schema, options) {
21076
- const parser = run$2(schema.ast);
21076
+ const parser = run$1(schema.ast);
21077
21077
  return options === void 0 ? parser : (input, overrideOptions) => parser(input, mergeParseOptions(options, overrideOptions));
21078
21078
  }
21079
21079
  /**
@@ -21104,7 +21104,7 @@ function decodeUnknownOption$1(schema, options) {
21104
21104
  * @since 4.0.0
21105
21105
  */
21106
21106
  function encodeUnknownEffect(schema, options) {
21107
- const parser = run$2(flip$1(schema.ast));
21107
+ const parser = run$1(flip$1(schema.ast));
21108
21108
  return options === void 0 ? parser : (input, overrideOptions) => parser(input, mergeParseOptions(options, overrideOptions));
21109
21109
  }
21110
21110
  /**
@@ -21126,7 +21126,7 @@ const mergeParseOptions = (options, overrideOptions) => overrideOptions === void
21126
21126
  ...overrideOptions
21127
21127
  };
21128
21128
  /** @internal */
21129
- function run$2(ast) {
21129
+ function run$1(ast) {
21130
21130
  const parser = recur$1(ast);
21131
21131
  return (input, options) => flatMapEager(parser(some(input), options ?? defaultParseOptions), (oa) => {
21132
21132
  if (oa._tag === "None") return fail$4(new InvalidValue(oa));
@@ -28330,7 +28330,7 @@ const ensuring = /* @__PURE__ */ dual(2, (self, finalizer) => fromChannel(ensuri
28330
28330
  * @category destructors
28331
28331
  * @since 2.0.0
28332
28332
  */
28333
- const run$1 = /* @__PURE__ */ dual(2, (self, sink) => scopedWith((scope) => toPullScoped(self.channel, scope).pipe(flatMap$2((upstream) => sink.transform(upstream, scope)), map$3(([a]) => a))));
28333
+ const run = /* @__PURE__ */ dual(2, (self, sink) => scopedWith((scope) => toPullScoped(self.channel, scope).pipe(flatMap$2((upstream) => sink.transform(upstream, scope)), map$3(([a]) => a))));
28334
28334
  /**
28335
28335
  * Runs the stream and collects all elements into an array.
28336
28336
  *
@@ -35068,7 +35068,7 @@ const layer$3 = /* @__PURE__ */ effect(ChildProcessSpawner, /* @__PURE__ */ gen(
35068
35068
  evaluate: () => nodeStream,
35069
35069
  onError: (error) => toPlatformError(`fromWritable(fd${fd})`, toError(error), command)
35070
35070
  });
35071
- if (config.stream) yield* forkScoped(run$1(config.stream, sink));
35071
+ if (config.stream) yield* forkScoped(run(config.stream, sink));
35072
35072
  inputSinks.set(fd, sink);
35073
35073
  break;
35074
35074
  }
@@ -35097,7 +35097,7 @@ const layer$3 = /* @__PURE__ */ effect(ChildProcessSpawner, /* @__PURE__ */ gen(
35097
35097
  endOnDone: config.endOnDone,
35098
35098
  encoding: config.encoding
35099
35099
  });
35100
- if (isStream(config.stream)) return as(forkScoped(run$1(config.stream, sink)), sink);
35100
+ if (isStream(config.stream)) return as(forkScoped(run(config.stream, sink)), sink);
35101
35101
  return succeed$2(sink);
35102
35102
  });
35103
35103
  const setupChildOutputStreams = (command, childProcess, stdoutConfig, stderrConfig) => {
@@ -40271,6 +40271,42 @@ var Files = class Files extends Service()("react-doctor/Files") {
40271
40271
  }));
40272
40272
  };
40273
40273
  };
40274
+ const HUNK_HEADER_PATTERN = /^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@/;
40275
+ /**
40276
+ * Parses a `git diff --unified=0` patch into the inclusive 1-based line ranges
40277
+ * each file added or modified on the new side. Files are keyed by the path in
40278
+ * the `+++ b/<path>` header (with `--relative`, relative to the diff's cwd).
40279
+ * Added/renamed/modified files appear; pure deletions (`+++ /dev/null`) are
40280
+ * skipped because they have no new-side line to report on.
40281
+ */
40282
+ const parseChangedLineRanges = (patch) => {
40283
+ const rangesByFile = /* @__PURE__ */ new Map();
40284
+ let currentRanges = null;
40285
+ for (const line of patch.split("\n")) {
40286
+ if (line.startsWith("+++ ")) {
40287
+ const target = line.slice(4).trim();
40288
+ if (target === "/dev/null") {
40289
+ currentRanges = null;
40290
+ continue;
40291
+ }
40292
+ const file = target.startsWith("b/") ? target.slice(2) : target;
40293
+ currentRanges = rangesByFile.get(file) ?? [];
40294
+ rangesByFile.set(file, currentRanges);
40295
+ continue;
40296
+ }
40297
+ if (currentRanges === null) continue;
40298
+ const hunk = HUNK_HEADER_PATTERN.exec(line);
40299
+ if (hunk === null) continue;
40300
+ const start = Number(hunk[1]);
40301
+ const lineCount = hunk[2] === void 0 ? 1 : Number(hunk[2]);
40302
+ if (lineCount <= 0) continue;
40303
+ currentRanges.push([start, start + lineCount - 1]);
40304
+ }
40305
+ return [...rangesByFile].filter(([, ranges]) => ranges.length > 0).map(([file, ranges]) => ({
40306
+ file,
40307
+ ranges
40308
+ }));
40309
+ };
40274
40310
  const trimOrNull = (value) => {
40275
40311
  const trimmed = value.trim();
40276
40312
  return trimmed.length === 0 ? null : trimmed;
@@ -40636,6 +40672,22 @@ var Git = class Git extends Service()("react-doctor/Git") {
40636
40672
  status: result.status,
40637
40673
  stdout: result.stdout
40638
40674
  };
40675
+ }),
40676
+ changedLineRanges: ({ directory, baseRef, cached, files }) => gen(function* () {
40677
+ if (files.length === 0) return [];
40678
+ if (baseRef !== void 0 && !isSafeGitRevision(baseRef)) return null;
40679
+ const result = yield* runGit(directory, [
40680
+ "diff",
40681
+ "--unified=0",
40682
+ "--diff-filter=ACMR",
40683
+ "--relative",
40684
+ ...cached ? ["--cached"] : [],
40685
+ ...baseRef !== void 0 ? [baseRef] : [],
40686
+ "--",
40687
+ ...files
40688
+ ]);
40689
+ if (result.status !== 0) return null;
40690
+ return parseChangedLineRanges(result.stdout);
40639
40691
  })
40640
40692
  });
40641
40693
  })).pipe(provide$2(layer$3.pipe(provide$2(mergeAll$1(layer$2, layer$1)))));
@@ -40666,7 +40718,8 @@ var Git = class Git extends Service()("react-doctor/Git") {
40666
40718
  status: matches.length === 0 ? 1 : 0,
40667
40719
  stdout
40668
40720
  };
40669
- })
40721
+ }),
40722
+ changedLineRanges: () => succeed$2(snapshot.changedLineRanges ?? [])
40670
40723
  }));
40671
40724
  };
40672
40725
  const estimateArgsLength = (args) => args.reduce((total, argument) => total + argument.length + 1, 0);
@@ -42445,25 +42498,36 @@ const decodeArtifact = decodeUnknownOption(Struct({ score: optional(Struct({
42445
42498
  const SCORE_AXES = [
42446
42499
  {
42447
42500
  key: "supplyChain",
42448
- label: "supply chain"
42501
+ label: "supply chain",
42502
+ gates: true
42449
42503
  },
42450
42504
  {
42451
42505
  key: "vulnerability",
42452
- label: "vulnerability"
42506
+ label: "vulnerability",
42507
+ gates: true
42453
42508
  },
42454
42509
  {
42455
42510
  key: "maintenance",
42456
- label: "maintenance"
42511
+ label: "maintenance",
42512
+ gates: false
42457
42513
  },
42458
42514
  {
42459
42515
  key: "quality",
42460
- label: "quality"
42516
+ label: "quality",
42517
+ gates: false
42461
42518
  },
42462
42519
  {
42463
42520
  key: "license",
42464
- label: "license"
42521
+ label: "license",
42522
+ gates: false
42465
42523
  }
42466
42524
  ];
42525
+ const GATED_AXES = SCORE_AXES.filter((axis) => axis.gates);
42526
+ const worstGatedAxis = (score) => {
42527
+ let worst = GATED_AXES[0];
42528
+ for (const axis of GATED_AXES) if (score[axis.key] < score[worst.key]) worst = axis;
42529
+ return worst;
42530
+ };
42467
42531
  const clampScore = (value) => {
42468
42532
  if (!Number.isFinite(value)) return 50;
42469
42533
  return Math.min(Math.max(value, 0), 100);
@@ -42604,15 +42668,14 @@ const fetchSocketScore = (dependency) => tryPromise(async (signal) => {
42604
42668
  "socket.purl": toPurl(dependency)
42605
42669
  } }));
42606
42670
  const formatAxisScores = (score) => SCORE_AXES.map((axis) => `${axis.label} ${toHundred(score[axis.key])}`).join(", ");
42607
- const buildLowScoreDiagnostic = (dependency, score, options) => {
42608
- const overall = toHundred(score.overall);
42671
+ const buildLowScoreDiagnostic = (dependency, score, failingAxis, options) => {
42609
42672
  const packagePageUrl = `${SOCKET_PACKAGE_PAGE_BASE}/${dependency.name}/overview/${dependency.version}`;
42610
42673
  return {
42611
42674
  filePath: "package.json",
42612
42675
  plugin: SUPPLY_CHAIN_PLUGIN,
42613
42676
  rule: SUPPLY_CHAIN_RULE,
42614
42677
  severity: options.severity,
42615
- message: `\`${dependency.name}\` (declared in package.json as "${dependency.spec}", scored at ${dependency.version}) has a Socket supply-chain score of ${overall}/100 (below the minimum of ${options.minScore}). Axis scores — ${formatAxisScores(score)}.`,
42678
+ message: `\`${dependency.name}\` (declared in package.json as "${dependency.spec}", scored at ${dependency.version}) has a Socket ${failingAxis.label} score of ${toHundred(score[failingAxis.key])}/100 (below the minimum of ${options.minScore}). Axis scores — ${formatAxisScores(score)}.`,
42616
42679
  help: `Update or replace the \`"${dependency.name}": "${dependency.spec}"\` entry in package.json. Review ${dependency.name} on Socket: ${packagePageUrl}. Or raise \`supplyChain.minScore\` if you have vetted and accepted this package.`,
42617
42680
  url: packagePageUrl,
42618
42681
  line: dependency.line,
@@ -42647,7 +42710,9 @@ const collectSupplyChainScores = (input) => gen(function* () {
42647
42710
  * Scores every direct dependency in the project's `package.json` against
42648
42711
  * Socket.dev's free PURL endpoint (the same one Socket Firewall's free tier
42649
42712
  * uses — no API key) and returns a diagnostic for each dependency whose
42650
- * Socket `overall` score is below the configured `minScore`.
42713
+ * worst Socket *security* axis — supply chain or vulnerability — is below
42714
+ * the configured `minScore`. The quality / maintenance / license axes are
42715
+ * reported as context but never gate (see GATED_AXES).
42651
42716
  *
42652
42717
  * Lookups run with bounded concurrency via `Effect.forEach`. The check is
42653
42718
  * total/fail-open: each per-package lookup already recovers to `null`
@@ -42665,8 +42730,9 @@ const checkSupplyChain = (input) => gen(function* () {
42665
42730
  for (let index = 0; index < dependencies.length; index += 1) {
42666
42731
  const score = scores[index];
42667
42732
  if (!score) continue;
42668
- if (toHundred(score.overall) >= options.minScore) continue;
42669
- diagnostics.push(buildLowScoreDiagnostic(dependencies[index], score, options));
42733
+ const worstAxis = worstGatedAxis(score);
42734
+ if (toHundred(score[worstAxis.key]) >= options.minScore) continue;
42735
+ diagnostics.push(buildLowScoreDiagnostic(dependencies[index], score, worstAxis, options));
42670
42736
  }
42671
42737
  return diagnostics;
42672
42738
  });
@@ -42674,7 +42740,8 @@ const checkSupplyChain = (input) => gen(function* () {
42674
42740
  * `SupplyChain` scores the project's direct dependencies against Socket.dev's
42675
42741
  * free, keyless PURL endpoint — the same lookup Socket Firewall's free tier
42676
42742
  * (`sfw`) performs — and streams a diagnostic for each dependency whose
42677
- * Socket score falls below the configured `supplyChain.minScore`.
42743
+ * worst Socket security axis (supply chain or vulnerability) falls below
42744
+ * the configured `supplyChain.minScore`.
42678
42745
  *
42679
42746
  * Runs by default (one network request per dependency); the orchestrator
42680
42747
  * provides `layerOf([])` only when the user opts out via
@@ -43366,6 +43433,21 @@ const getDiffInfo = (directory, explicitBaseBranch) => runPromise(gen(function*
43366
43433
  }).pipe(provide(Git.layerNode)));
43367
43434
  const filterSourceFiles = (filePaths) => filePaths.filter(isLintableSourceFile);
43368
43435
  /**
43436
+ * Programmatic façade over `Git.changedLineRanges` (the `lines` scope). Diffs
43437
+ * `files` with `--unified=0` against `baseRef` (or the index when `cached`),
43438
+ * returning per-file changed line ranges relative to `directory`. Returns
43439
+ * `null` when the ranges can't be computed (git unavailable / unsafe ref /
43440
+ * non-zero exit) so the caller degrades to file-level scope; an empty array
43441
+ * means git succeeded but the files added no lines.
43442
+ */
43443
+ const getChangedLineRanges = (input) => runPromise(gen(function* () {
43444
+ const ranges = yield* (yield* Git).changedLineRanges(input);
43445
+ return ranges === null ? null : ranges.map((entry) => ({
43446
+ file: entry.file,
43447
+ ranges: entry.ranges
43448
+ }));
43449
+ }).pipe(provide(Git.layerNode)));
43450
+ /**
43369
43451
  * Canonical URL for a rule's documentation page — its reviewer-tested fix
43370
43452
  * recipe rendered for humans — served at
43371
43453
  * `https://react.doctor/docs/rules/<plugin>/<rule>`. The CLI links here
@@ -43511,6 +43593,7 @@ const isNonInteractiveEnvironment = () => NON_INTERACTIVE_ENVIRONMENT_VARIABLES.
43511
43593
  //#region src/cli/utils/constants.ts
43512
43594
  const STAGED_FILES_TEMP_DIR_PREFIX = "react-doctor-staged-";
43513
43595
  const BASELINE_FILES_TEMP_DIR_PREFIX = "react-doctor-baseline-";
43596
+ const GH_DEFAULT_BRANCH_PROBE_TIMEOUT_MS = 5e3;
43514
43597
  const CI_TRUST_COMPANIES = "PayPal, Rippling, and Alibaba";
43515
43598
  const WELCOME_EXPLANATION_HOLD_MS = 1e3;
43516
43599
  const CATEGORY_COUNTUP_SETTLE_HOLD_MS = 1e3;
@@ -43590,7 +43673,7 @@ const makeNoopConsole = () => ({
43590
43673
  });
43591
43674
  //#endregion
43592
43675
  //#region src/cli/utils/version.ts
43593
- const VERSION = "0.5.1-dev.94f9f4f";
43676
+ const VERSION = "0.5.1-dev.a48fb06";
43594
43677
  //#endregion
43595
43678
  //#region src/cli/utils/json-mode.ts
43596
43679
  let context = null;
@@ -43948,13 +44031,13 @@ const isDevVersion = (version) => version === "0.0.0" || version.includes("-");
43948
44031
  * uploads source-map artifacts under, so stack frames symbolicate. Honors the
43949
44032
  * standard `SENTRY_RELEASE` override.
43950
44033
  */
43951
- const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.5.1-dev.94f9f4f`;
44034
+ const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.5.1-dev.a48fb06`;
43952
44035
  /**
43953
44036
  * Deployment environment shown in Sentry's environment filter. Defaults to
43954
44037
  * `production` for tagged releases and `development` for dev/unbuilt versions,
43955
44038
  * overridable via the standard `SENTRY_ENVIRONMENT` env var.
43956
44039
  */
43957
- const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.5.1-dev.94f9f4f") ? "development" : "production");
44040
+ const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.5.1-dev.a48fb06") ? "development" : "production");
43958
44041
  /**
43959
44042
  * Performance-tracing sample rate in `[0, 1]`. Reads `SENTRY_TRACES_SAMPLE_RATE`
43960
44043
  * (set to `0` to disable tracing) and falls back to
@@ -47593,6 +47676,7 @@ const buildConfigAttributes = (input) => {
47593
47676
  const ruleKeys = Object.keys(ruleOverrides);
47594
47677
  return {
47595
47678
  mode: input.mode,
47679
+ scope: input.scope,
47596
47680
  parallel: input.parallel,
47597
47681
  workerCount: input.workerCount ?? null,
47598
47682
  lint: input.lint,
@@ -47601,6 +47685,7 @@ const buildConfigAttributes = (input) => {
47601
47685
  noScore: input.noScore,
47602
47686
  respectInlineDisables: input.respectInlineDisables,
47603
47687
  showWarnings: input.showWarnings,
47688
+ usedOutputDir: input.usedOutputDir,
47604
47689
  ignoredTagCount: input.ignoredTagCount,
47605
47690
  hasCustomConfig: input.hasCustomConfig,
47606
47691
  rulesConfigured: ruleKeys.length,
@@ -47634,6 +47719,9 @@ const recordRunEvent = (rootSpan, input) => {
47634
47719
  } catch {}
47635
47720
  };
47636
47721
  //#endregion
47722
+ //#region src/cli/utils/path-format.ts
47723
+ const toForwardSlashes = (filePath) => filePath.replaceAll("\\", "/");
47724
+ //#endregion
47637
47725
  //#region src/cli/utils/materialize-baseline-files.ts
47638
47726
  /**
47639
47727
  * Materializes the `ref` version of `files` into `tempDirectory` (via
@@ -48415,15 +48503,22 @@ const printNoScoreHeader = (noScoreMessage) => gen(function* () {
48415
48503
  });
48416
48504
  //#endregion
48417
48505
  //#region src/cli/utils/write-diagnostics-directory.ts
48418
- const writeDiagnosticsDirectory = (diagnostics) => {
48419
- const outputDirectory = Path.join(tmpdir(), `react-doctor-${randomUUID()}`);
48420
- NFS.mkdirSync(outputDirectory, { recursive: true });
48421
- for (const [ruleKey, ruleDiagnostics] of buildSortedRuleGroups(diagnostics)) {
48422
- const fileName = ruleKey.replace(/\//g, "--") + ".txt";
48423
- NFS.writeFileSync(Path.join(outputDirectory, fileName), formatRuleSummary(ruleKey, ruleDiagnostics));
48506
+ const ruleDumpFileName = (ruleKey) => ruleKey.replace(/\//g, "--") + ".txt";
48507
+ const readPreviousRuleDumpFileNames = (directory) => {
48508
+ try {
48509
+ const previous = JSON.parse(NFS.readFileSync(Path.join(directory, "diagnostics.json"), "utf8"));
48510
+ return new Set(previous.filter((d) => typeof d?.plugin === "string" && typeof d?.rule === "string").map((d) => ruleDumpFileName(`${d.plugin}/${d.rule}`)));
48511
+ } catch {
48512
+ return /* @__PURE__ */ new Set();
48424
48513
  }
48425
- NFS.writeFileSync(Path.join(outputDirectory, "diagnostics.json"), JSON.stringify(diagnostics));
48426
- return outputDirectory;
48514
+ };
48515
+ const writeDiagnosticsDirectory = (diagnostics, outputDirectory) => {
48516
+ const directory = outputDirectory ? Path.resolve(outputDirectory) : Path.join(tmpdir(), `react-doctor-${randomUUID()}`);
48517
+ if (outputDirectory) for (const fileName of readPreviousRuleDumpFileNames(directory)) NFS.rmSync(Path.join(directory, fileName), { force: true });
48518
+ NFS.mkdirSync(directory, { recursive: true });
48519
+ for (const [ruleKey, ruleDiagnostics] of buildSortedRuleGroups(diagnostics)) NFS.writeFileSync(Path.join(directory, ruleDumpFileName(ruleKey)), formatRuleSummary(ruleKey, ruleDiagnostics));
48520
+ NFS.writeFileSync(Path.join(directory, "diagnostics.json"), JSON.stringify(diagnostics));
48521
+ return directory;
48427
48522
  };
48428
48523
  //#endregion
48429
48524
  //#region src/cli/utils/render-summary.ts
@@ -48460,6 +48555,16 @@ const printFooter = (input) => gen(function* () {
48460
48555
  yield* log(` ${highlighter.bold("GitHub:")} ${highlighter.info(CANONICAL_GITHUB_URL)}`);
48461
48556
  yield* printFooterDescription("Report issues and star the repository!");
48462
48557
  });
48558
+ const printDiagnosticsDump = (diagnostics, outputDirectory, verbose, stream = "stdout") => gen(function* () {
48559
+ const writtenDirectory = yield* try_({
48560
+ try: () => writeDiagnosticsDirectory(diagnostics, outputDirectory),
48561
+ catch: (cause) => cause
48562
+ }).pipe(orElseSucceed(() => null));
48563
+ if (writtenDirectory !== null && (verbose || outputDirectory)) {
48564
+ const pathLine = highlighter.gray(` Full diagnostics written to ${writtenDirectory}`);
48565
+ yield* stream === "stderr" || Boolean(outputDirectory) && isJsonModeActive() ? sync(() => process.stderr.write(`${pathLine}\n`)) : log(pathLine);
48566
+ }
48567
+ });
48463
48568
  const printSummary = (input) => gen(function* () {
48464
48569
  if (input.scoreResult) {
48465
48570
  const animateProjection = Boolean(input.animateProjection) && input.potentialScore != null && !input.verbose;
@@ -48470,11 +48575,7 @@ const printSummary = (input) => gen(function* () {
48470
48575
  if (animateProjection) yield* animateScoreProjection(input.scoreResult, input.potentialScore, 5);
48471
48576
  }
48472
48577
  } else yield* printNoScoreHeader(input.noScoreMessage);
48473
- const diagnosticsDirectory = yield* try_({
48474
- try: () => writeDiagnosticsDirectory(input.diagnostics),
48475
- catch: (cause) => cause
48476
- }).pipe(orElseSucceed(() => null));
48477
- if (diagnosticsDirectory !== null && input.verbose) yield* log(highlighter.gray(` Full diagnostics written to ${diagnosticsDirectory}`));
48578
+ yield* printDiagnosticsDump(input.diagnostics, input.outputDirectory, input.verbose);
48478
48579
  });
48479
48580
  //#endregion
48480
48581
  //#region src/cli/utils/should-auto-select-current-choice.ts
@@ -48796,6 +48897,7 @@ const buildScanResultCacheKey = (input) => {
48796
48897
  ignoredTags: [...input.options.ignoredTags].sort(),
48797
48898
  concurrency: input.options.concurrency,
48798
48899
  baselineRef: input.options.baseline?.ref,
48900
+ changedLineRanges: input.options.changedLineRanges ?? void 0,
48799
48901
  noScore: input.options.noScore,
48800
48902
  isCi: input.options.isCi,
48801
48903
  suppressRendering: input.options.suppressRendering,
@@ -48844,6 +48946,16 @@ const recordOnboardingCompletion = (options) => {
48844
48946
  })) markOnboardingComplete();
48845
48947
  };
48846
48948
  const formatCategorySelection = (categoryFilters) => [...categoryFilters].join(", ");
48949
+ const buildChangedLineMatcher = (directory, changedLineRanges) => {
48950
+ const rangesByFile = /* @__PURE__ */ new Map();
48951
+ for (const entry of changedLineRanges) rangesByFile.set(toForwardSlashes(entry.file), entry.ranges);
48952
+ return (diagnostic) => {
48953
+ const relativePath = toForwardSlashes(path.isAbsolute(diagnostic.filePath) ? path.relative(directory, diagnostic.filePath) : diagnostic.filePath);
48954
+ const ranges = rangesByFile.get(relativePath);
48955
+ if (ranges === void 0) return false;
48956
+ return ranges.some(([start, end]) => diagnostic.line >= start && diagnostic.line <= end);
48957
+ };
48958
+ };
48847
48959
  const buildIgnoredTags = (userConfig) => {
48848
48960
  const tags = /* @__PURE__ */ new Set();
48849
48961
  if (userConfig?.ignore?.tags) for (const tag of userConfig.ignore.tags) tags.add(tag);
@@ -48853,6 +48965,7 @@ const mergeInspectOptions = (inputOptions, userConfig) => ({
48853
48965
  lint: inputOptions.lint ?? userConfig?.lint ?? true,
48854
48966
  deadCode: inputOptions.deadCode ?? userConfig?.deadCode ?? true,
48855
48967
  verbose: inputOptions.verbose ?? userConfig?.verbose ?? false,
48968
+ outputDirectory: inputOptions.outputDirectory || null,
48856
48969
  scoreOnly: inputOptions.scoreOnly ?? false,
48857
48970
  noScore: inputOptions.noScore ?? userConfig?.noScore ?? false,
48858
48971
  isCi: inputOptions.isCi ?? false,
@@ -48871,9 +48984,16 @@ const mergeInspectOptions = (inputOptions, userConfig) => ({
48871
48984
  suppressRendering: inputOptions.suppressRendering ?? false,
48872
48985
  concurrency: inputOptions.concurrency,
48873
48986
  baseline: inputOptions.baseline ?? null,
48987
+ changedLineRanges: inputOptions.changedLineRanges ?? null,
48874
48988
  supplyChainManifestChanged: inputOptions.supplyChainManifestChanged ?? false
48875
48989
  });
48990
+ const deriveScope = (options) => {
48991
+ if (options.baseline) return "changed";
48992
+ if (options.changedLineRanges !== null) return "lines";
48993
+ return options.includePaths.length > 0 ? "files" : "full";
48994
+ };
48876
48995
  const buildRunEventConfig = (options, userConfig, hasCustomConfig) => ({
48996
+ scope: deriveScope(options),
48877
48997
  parallel: options.concurrency !== void 0,
48878
48998
  workerCount: options.concurrency,
48879
48999
  lint: options.lint,
@@ -48882,6 +49002,7 @@ const buildRunEventConfig = (options, userConfig, hasCustomConfig) => ({
48882
49002
  noScore: options.noScore,
48883
49003
  respectInlineDisables: options.respectInlineDisables,
48884
49004
  showWarnings: options.warnings,
49005
+ usedOutputDir: options.outputDirectory !== null,
48885
49006
  ignoredTagCount: options.ignoredTags.size,
48886
49007
  hasCustomConfig,
48887
49008
  userConfig
@@ -49095,6 +49216,9 @@ const runInspectWithRuntime = async (directory, options, userConfig, hasConfigOv
49095
49216
  inspectDiagnostics = comparison.displayDiagnostics;
49096
49217
  baselineDelta = comparison.baselineDelta;
49097
49218
  }
49219
+ } else if (options.changedLineRanges !== null && isDiffMode) {
49220
+ const isOnChangedLine = buildChangedLineMatcher(directory, options.changedLineRanges);
49221
+ inspectDiagnostics = output.diagnostics.filter(isOnChangedLine);
49098
49222
  }
49099
49223
  const baselineDegraded = Boolean(options.baseline) && isDiffMode && baselineDelta === void 0;
49100
49224
  const score = didLintFail ? null : output.score;
@@ -49209,15 +49333,16 @@ const finalizeAndRender = (input) => gen(function* () {
49209
49333
  ...baselineDelta ? { baselineDelta } : {}
49210
49334
  });
49211
49335
  if (options.suppressRendering) return buildResult();
49336
+ const surfaceDiagnostics = filterDiagnosticsForSurface([...diagnostics], options.outputSurface, userConfig);
49337
+ const printedDiagnostics = filterDiagnosticsByCategories(surfaceDiagnostics, options.categoryFilters);
49212
49338
  if (options.scoreOnly) {
49339
+ if (options.outputDirectory !== null) yield* printDiagnosticsDump(printedDiagnostics, options.outputDirectory, false, "stderr");
49213
49340
  if (score) yield* log(`${score.score}`);
49214
49341
  else yield* log(highlighter.gray(noScoreMessage));
49215
49342
  return buildResult();
49216
49343
  }
49217
49344
  const animateRender = !options.silent && !options.verbose && canAnimateOnboarding(process.stdout);
49218
49345
  const pause = onboardingSectionPause(animateRender);
49219
- const surfaceDiagnostics = filterDiagnosticsForSurface([...diagnostics], options.outputSurface, userConfig);
49220
- const printedDiagnostics = filterDiagnosticsByCategories(surfaceDiagnostics, options.categoryFilters);
49221
49346
  const demotedDiagnosticCount = diagnostics.length - surfaceDiagnostics.length;
49222
49347
  const lintSourceFileCount = options.includePaths.length > 0 ? options.includePaths.length : project.sourceFileCount;
49223
49348
  if (printedDiagnostics.length === 0) {
@@ -49235,6 +49360,7 @@ const finalizeAndRender = (input) => gen(function* () {
49235
49360
  yield* log(highlighter.gray(" Score not shown — some checks could not complete."));
49236
49361
  } else if (score) yield* printScoreHeader(score);
49237
49362
  else yield* printNoScoreHeader(noScoreMessage);
49363
+ if (options.outputDirectory !== null) yield* printDiagnosticsDump(printedDiagnostics, options.outputDirectory);
49238
49364
  return buildResult();
49239
49365
  }
49240
49366
  yield* pause;
@@ -49259,6 +49385,7 @@ const finalizeAndRender = (input) => gen(function* () {
49259
49385
  totalSourceFileCount: lintSourceFileCount,
49260
49386
  noScoreMessage,
49261
49387
  verbose: options.verbose,
49388
+ outputDirectory: options.outputDirectory,
49262
49389
  animateProjection: animateRender
49263
49390
  });
49264
49391
  if (hasSkippedChecks) {
@@ -49430,9 +49557,9 @@ const isExpectedUserError = (error) => error instanceof CliInputError || isProje
49430
49557
  //#region src/cli/utils/build-handoff-payload.ts
49431
49558
  const buildHandoffPayload = (input) => {
49432
49559
  const topGroups = buildSortedRuleGroups(input.diagnostics).slice(0, 3);
49433
- let diagnosticsDirectory = null;
49560
+ let outputDirectory = null;
49434
49561
  try {
49435
- diagnosticsDirectory = writeDiagnosticsDirectory([...input.diagnostics]);
49562
+ outputDirectory = writeDiagnosticsDirectory([...input.diagnostics], input.outputDirectory);
49436
49563
  } catch {}
49437
49564
  const lines = [
49438
49565
  "Before fixing anything, first ask me whether I'd like to add React Doctor to CI so every pull request is scanned automatically. Explain that:",
@@ -49459,7 +49586,7 @@ const buildHandoffPayload = (input) => {
49459
49586
  if (remainingFiles > 0) lines.push(` - +${remainingFiles} more files`);
49460
49587
  });
49461
49588
  lines.push("");
49462
- if (diagnosticsDirectory) lines.push(`Full results for all ${input.diagnostics.length} issues (diagnostics.json + a .txt per rule): ${diagnosticsDirectory}`, "");
49589
+ if (outputDirectory) lines.push(`Full results for all ${input.diagnostics.length} issues (diagnostics.json + a .txt per rule): ${outputDirectory}`, "");
49463
49590
  lines.push("Read each file and fix the root cause — don't suppress or silence the rule.", "", "Verify against the real thing, don't assume: confirm each change matches the canonical fix recipe you fetched for that rule, then re-run `npx react-doctor@latest --verbose` and check the issue is actually gone against the real tool before moving on.", "", "Teach me as you go: for every issue you touch, explain it in plain language (no jargon) — what the problem is, why it's a problem, and how serious it is in human terms. Describe the real-world impact and severity concretely (e.g. \"this crashes the page for users on Safari\" vs. \"this is a minor cleanup with no user impact\") so I understand why it matters, not just what changed.", "", "Then work through the rest from the full results above.");
49464
49591
  return lines.join("\n");
49465
49592
  };
@@ -49691,7 +49818,7 @@ const installReactDoctorScriptStep = (projectRoot) => {
49691
49818
  };
49692
49819
  //#endregion
49693
49820
  //#region src/cli/utils/install-github-workflow.ts
49694
- const buildWorkflowContent = () => `# React Doctor — finds security, performance, correctness, accessibility,
49821
+ const buildWorkflowContent = (defaultBranch) => `# React Doctor — finds security, performance, correctness, accessibility,
49695
49822
  # bundle-size, and architecture issues in React codebases.
49696
49823
  #
49697
49824
  # Docs: https://www.react.doctor/ci
@@ -49703,9 +49830,9 @@ on:
49703
49830
  # Scans the PR's changed files and posts a sticky summary comment listing only the new issues introduced relative to the merge base of the target branch.
49704
49831
  pull_request:
49705
49832
  types: [opened, synchronize, reopened, ready_for_review]
49706
- # Scans \`main\` on every push to track the health-score trend and catch regressions that slipped past PR review.
49833
+ # Scans \`${defaultBranch}\` on every push to track the health-score trend and catch regressions that slipped past PR review.
49707
49834
  push:
49708
- branches: [main]
49835
+ branches: ["${defaultBranch}"]
49709
49836
 
49710
49837
  permissions:
49711
49838
  contents: read
@@ -49725,10 +49852,15 @@ jobs:
49725
49852
  - uses: actions/checkout@v5
49726
49853
 
49727
49854
  - uses: millionco/react-doctor@v2
49728
- # Common configuration knobs — uncomment any to override the default.
49855
+ # Advisory by default: React Doctor reports findings on every PR — a
49856
+ # sticky summary comment, inline review comments, and a commit status
49857
+ # with the health score — but never fails the check, so it won't red-X
49858
+ # a teammate's PR on day one. When your team trusts the signal, graduate
49859
+ # the gate: uncomment the block below and set blocking to "error" (fail
49860
+ # on new error-severity findings) or "warning" (fail on any finding).
49729
49861
  # Full reference: https://www.react.doctor/ci
49730
49862
  # with:
49731
- # blocking: warning # Gate level: "error" (default) | "warning" | "none" (advisory)
49863
+ # blocking: error # Gate level: "none" (advisory, the default) | "warning" | "error"
49732
49864
  # scope: full # On PRs, scan the whole project instead of just changed files
49733
49865
  # comment: false # Disable the sticky PR summary comment
49734
49866
  # review-comments: false # Disable inline review comments on changed lines
@@ -49760,7 +49892,7 @@ const upgradeWorkflowActionToV2 = (content) => {
49760
49892
  changed: upgraded !== content
49761
49893
  };
49762
49894
  };
49763
- const installReactDoctorWorkflow = (projectRoot) => {
49895
+ const installReactDoctorWorkflow = (projectRoot, defaultBranch = "main") => {
49764
49896
  const workflowPath = getReactDoctorWorkflowPath(projectRoot);
49765
49897
  if (NFS.existsSync(workflowPath)) return {
49766
49898
  status: "exists",
@@ -49768,7 +49900,7 @@ const installReactDoctorWorkflow = (projectRoot) => {
49768
49900
  };
49769
49901
  try {
49770
49902
  NFS.mkdirSync(Path.dirname(workflowPath), { recursive: true });
49771
- NFS.writeFileSync(workflowPath, buildWorkflowContent());
49903
+ NFS.writeFileSync(workflowPath, buildWorkflowContent(defaultBranch));
49772
49904
  return {
49773
49905
  status: "created",
49774
49906
  workflowPath
@@ -49944,19 +50076,14 @@ const askUpgradeActionVersion = async (prompt = prompts) => {
49944
50076
  return upgradeChoice === UPGRADE_YES_CHOICE ? "yes" : "no";
49945
50077
  };
49946
50078
  //#endregion
49947
- //#region src/cli/utils/open-workflow-pull-request.ts
49948
- const NEW_BRANCH_PREFIX = "react-doctor/add-github-actions";
49949
- const DEFAULT_COMMIT_MESSAGE = "ci: add React Doctor GitHub Actions workflow";
49950
- const DEFAULT_PR_TITLE = "Add React Doctor to GitHub Actions";
49951
- const DEFAULT_PR_BODY = `Adds a [React Doctor](https://www.react.doctor) scan to every pull request and every push to the default branch. The workflow file is documented inline.
49952
-
49953
- Docs: https://www.react.doctor/ci`;
50079
+ //#region src/cli/utils/run-command.ts
49954
50080
  const execFileAsync$1 = promisify(execFile);
49955
- const run = async (command, args, cwd) => {
50081
+ const runCommand = async (command, args, cwd, timeoutMs) => {
49956
50082
  try {
49957
50083
  const { stdout, stderr } = await execFileAsync$1(command, [...args], {
49958
50084
  cwd,
49959
- encoding: "utf8"
50085
+ encoding: "utf8",
50086
+ timeout: timeoutMs
49960
50087
  });
49961
50088
  return {
49962
50089
  success: true,
@@ -49972,7 +50099,18 @@ const run = async (command, args, cwd) => {
49972
50099
  };
49973
50100
  }
49974
50101
  };
49975
- const detectDefaultBranch = async (cwd) => {
50102
+ //#endregion
50103
+ //#region src/cli/utils/detect-default-branch.ts
50104
+ const detectDefaultBranch = async (cwd, run = runCommand) => {
50105
+ const repoView = await run("gh", [
50106
+ "repo",
50107
+ "view",
50108
+ "--json",
50109
+ "defaultBranchRef",
50110
+ "--jq",
50111
+ ".defaultBranchRef.name"
50112
+ ], cwd, GH_DEFAULT_BRANCH_PROBE_TIMEOUT_MS);
50113
+ if (repoView.success && repoView.stdout !== "" && repoView.stdout !== "null") return repoView.stdout;
49976
50114
  const symRef = await run("git", ["symbolic-ref", "refs/remotes/origin/HEAD"], cwd);
49977
50115
  if (symRef.success) {
49978
50116
  const branchMatch = symRef.stdout.match(/refs\/remotes\/origin\/(.+)$/);
@@ -49990,8 +50128,16 @@ const detectDefaultBranch = async (cwd) => {
49990
50128
  ], cwd)).success) return "master";
49991
50129
  return null;
49992
50130
  };
50131
+ //#endregion
50132
+ //#region src/cli/utils/open-workflow-pull-request.ts
50133
+ const NEW_BRANCH_PREFIX = "react-doctor/add-github-actions";
50134
+ const DEFAULT_COMMIT_MESSAGE = "ci: add React Doctor GitHub Actions workflow";
50135
+ const DEFAULT_PR_TITLE = "Add React Doctor to GitHub Actions";
50136
+ const DEFAULT_PR_BODY = `Adds a [React Doctor](https://www.react.doctor) scan to every pull request and every push to the default branch. The workflow file is documented inline.
50137
+
50138
+ Docs: https://www.react.doctor/ci`;
49993
50139
  const findUniqueBranchName = async (cwd) => {
49994
- if (!(await run("git", [
50140
+ if (!(await runCommand("git", [
49995
50141
  "rev-parse",
49996
50142
  "--verify",
49997
50143
  NEW_BRANCH_PREFIX
@@ -50003,7 +50149,7 @@ const openWorkflowPullRequest = async (params) => {
50003
50149
  const commitMessage = params.commitMessage ?? DEFAULT_COMMIT_MESSAGE;
50004
50150
  const prTitle = params.prTitle ?? DEFAULT_PR_TITLE;
50005
50151
  const prBody = params.prBody ?? DEFAULT_PR_BODY;
50006
- const repoRootProbe = await run("git", ["rev-parse", "--show-toplevel"], Path.dirname(workflowPath));
50152
+ const repoRootProbe = await runCommand("git", ["rev-parse", "--show-toplevel"], Path.dirname(workflowPath));
50007
50153
  if (!repoRootProbe.success) return {
50008
50154
  status: "not-attempted",
50009
50155
  reason: "not-a-git-repo"
@@ -50013,16 +50159,16 @@ const openWorkflowPullRequest = async (params) => {
50013
50159
  status: "not-attempted",
50014
50160
  reason: "gh-not-installed"
50015
50161
  };
50016
- if (!(await run("gh", ["auth", "status"], cwd)).success) return {
50162
+ if (!(await runCommand("gh", ["auth", "status"], cwd)).success) return {
50017
50163
  status: "not-attempted",
50018
50164
  reason: "gh-not-authenticated"
50019
50165
  };
50020
- const defaultBranch = await detectDefaultBranch(cwd);
50166
+ const defaultBranch = params.baseBranch ?? await detectDefaultBranch(cwd);
50021
50167
  if (!defaultBranch) return {
50022
50168
  status: "not-attempted",
50023
50169
  reason: "no-default-branch"
50024
50170
  };
50025
- const previousBranchProbe = await run("git", [
50171
+ const previousBranchProbe = await runCommand("git", [
50026
50172
  "rev-parse",
50027
50173
  "--abbrev-ref",
50028
50174
  "HEAD"
@@ -50032,13 +50178,13 @@ const openWorkflowPullRequest = async (params) => {
50032
50178
  reason: "detached-head"
50033
50179
  };
50034
50180
  const previousBranch = previousBranchProbe.stdout;
50035
- await run("git", [
50181
+ await runCommand("git", [
50036
50182
  "fetch",
50037
50183
  "origin",
50038
50184
  defaultBranch
50039
50185
  ], cwd);
50040
50186
  const newBranch = await findUniqueBranchName(cwd);
50041
- if (!(await run("git", [
50187
+ if (!(await runCommand("git", [
50042
50188
  "checkout",
50043
50189
  "-b",
50044
50190
  newBranch,
@@ -50048,14 +50194,14 @@ const openWorkflowPullRequest = async (params) => {
50048
50194
  reason: "checkout-failed"
50049
50195
  };
50050
50196
  const restoreToPreviousBranch = async (deleteNewBranch) => {
50051
- await run("git", ["checkout", previousBranch], cwd);
50052
- if (deleteNewBranch) await run("git", [
50197
+ await runCommand("git", ["checkout", previousBranch], cwd);
50198
+ if (deleteNewBranch) await runCommand("git", [
50053
50199
  "branch",
50054
50200
  "-D",
50055
50201
  newBranch
50056
50202
  ], cwd);
50057
50203
  };
50058
- if (!(await run("git", [
50204
+ if (!(await runCommand("git", [
50059
50205
  "add",
50060
50206
  "--",
50061
50207
  Path.relative(cwd, workflowPath)
@@ -50066,7 +50212,7 @@ const openWorkflowPullRequest = async (params) => {
50066
50212
  reason: "git-add-failed"
50067
50213
  };
50068
50214
  }
50069
- if (!(await run("git", [
50215
+ if (!(await runCommand("git", [
50070
50216
  "commit",
50071
50217
  "-m",
50072
50218
  commitMessage
@@ -50077,7 +50223,7 @@ const openWorkflowPullRequest = async (params) => {
50077
50223
  reason: "git-commit-failed"
50078
50224
  };
50079
50225
  }
50080
- if (!(await run("git", [
50226
+ if (!(await runCommand("git", [
50081
50227
  "push",
50082
50228
  "-u",
50083
50229
  "origin",
@@ -50089,7 +50235,7 @@ const openWorkflowPullRequest = async (params) => {
50089
50235
  reason: "git-push-failed"
50090
50236
  };
50091
50237
  }
50092
- const prCreate = await run("gh", [
50238
+ const prCreate = await runCommand("gh", [
50093
50239
  "pr",
50094
50240
  "create",
50095
50241
  "--title",
@@ -50113,9 +50259,9 @@ const openWorkflowPullRequest = async (params) => {
50113
50259
  };
50114
50260
  const stageWorkflowFile = async (params) => {
50115
50261
  const workflowPath = Path.resolve(params.workflowPath);
50116
- const repoRootProbe = await run("git", ["rev-parse", "--show-toplevel"], Path.dirname(workflowPath));
50262
+ const repoRootProbe = await runCommand("git", ["rev-parse", "--show-toplevel"], Path.dirname(workflowPath));
50117
50263
  if (!repoRootProbe.success) return false;
50118
- return (await run("git", [
50264
+ return (await runCommand("git", [
50119
50265
  "add",
50120
50266
  "--",
50121
50267
  Path.relative(repoRootProbe.stdout, workflowPath)
@@ -50144,7 +50290,8 @@ const setUpGitHubActions = async (options) => {
50144
50290
  installReactDoctorScriptStep(projectRoot);
50145
50291
  } catch {}
50146
50292
  const workflowSpinner = spinner("Adding GitHub Actions workflow...").start();
50147
- const workflowResult = installReactDoctorWorkflow(projectRoot);
50293
+ const defaultBranch = await detectDefaultBranch(projectRoot) ?? "main";
50294
+ const workflowResult = installReactDoctorWorkflow(projectRoot, defaultBranch);
50148
50295
  const didCreateWorkflow = reportWorkflowResult(workflowSpinner, workflowResult, projectRoot);
50149
50296
  cliLogger.break();
50150
50297
  if (workflowResult.status === "failed") {
@@ -50153,7 +50300,10 @@ const setUpGitHubActions = async (options) => {
50153
50300
  }
50154
50301
  if (workflowResult.status === "created") {
50155
50302
  const pullRequestSpinner = spinner("Opening a pull request for review...").start();
50156
- const pullRequestResult = await openWorkflowPullRequest({ workflowPath: workflowResult.workflowPath });
50303
+ const pullRequestResult = await openWorkflowPullRequest({
50304
+ workflowPath: workflowResult.workflowPath,
50305
+ baseBranch: defaultBranch
50306
+ });
50157
50307
  if (pullRequestResult.status === "pr-opened") pullRequestSpinner.succeed(`Opened pull request for review: ${highlighter.info(pullRequestResult.url)}`);
50158
50308
  else if (pullRequestResult.status === "branch-pushed") pullRequestSpinner.warn(`Pushed branch ${highlighter.bold(pullRequestResult.branch)} but couldn't open a PR. Open one with: gh pr create --head ${pullRequestResult.branch}`);
50159
50309
  else {
@@ -50994,8 +51144,8 @@ const installReactDoctorAgentHooksStep = (projectRoot, selectedAgents) => {
50994
51144
  throw error;
50995
51145
  }
50996
51146
  };
50997
- const installReactDoctorWorkflowStep = (projectRoot) => {
50998
- return reportWorkflowResult(spinner("Adding GitHub Actions workflow...").start(), installReactDoctorWorkflow(projectRoot), projectRoot);
51147
+ const installReactDoctorWorkflowStep = async (projectRoot) => {
51148
+ return reportWorkflowResult(spinner("Adding GitHub Actions workflow...").start(), installReactDoctorWorkflow(projectRoot, await detectDefaultBranch(projectRoot) ?? void 0), projectRoot);
50999
51149
  };
51000
51150
  const upgradeReactDoctorWorkflowStep = (projectRoot) => {
51001
51151
  const workflowSpinner = spinner("Upgrading GitHub Actions workflow to v2...").start();
@@ -51063,7 +51213,7 @@ const runInstallReactDoctor = async (options = {}) => {
51063
51213
  let didInstallWorkflow = false;
51064
51214
  if (!options.dryRun && (shouldInstallWorkflow || shouldUpgradeWorkflow)) {
51065
51215
  cliLogger.break();
51066
- if (shouldInstallWorkflow) didInstallWorkflow = installReactDoctorWorkflowStep(projectRoot);
51216
+ if (shouldInstallWorkflow) didInstallWorkflow = await installReactDoctorWorkflowStep(projectRoot);
51067
51217
  else if (upgradeReactDoctorWorkflowStep(projectRoot)) recordActionUpgradeDecision(projectRoot, "accepted");
51068
51218
  }
51069
51219
  const setupActionChoices = [...gitHookPath === null || gitHookPath === void 0 ? [] : [{
@@ -51335,7 +51485,8 @@ const handoffToAgent = async (input) => {
51335
51485
  if (handoffTarget === void 0 || handoffTarget === SKIP_CHOICE) return;
51336
51486
  const payload = buildHandoffPayload({
51337
51487
  diagnostics: input.diagnostics,
51338
- projectName: input.projectName
51488
+ projectName: input.projectName,
51489
+ outputDirectory: input.outputDirectory
51339
51490
  });
51340
51491
  if (handoffTarget === CLIPBOARD_CHOICE) {
51341
51492
  if (await copyToClipboard(payload)) cliLogger.log("Copied the prompt to your clipboard.");
@@ -51530,9 +51681,6 @@ const reportErrorToSentry = async (error) => {
51530
51681
  }
51531
51682
  };
51532
51683
  //#endregion
51533
- //#region src/cli/utils/path-format.ts
51534
- const toForwardSlashes = (filePath) => filePath.replaceAll("\\", "/");
51535
- //#endregion
51536
51684
  //#region src/cli/utils/read-changed-files-from.ts
51537
51685
  const isSafeRelativePath = (filePath) => {
51538
51686
  if (filePath.length === 0) return false;
@@ -51618,6 +51766,7 @@ const printMultiProjectSummary = (input) => gen(function* () {
51618
51766
  totalSourceFileCount,
51619
51767
  noScoreMessage: "Score unavailable.",
51620
51768
  verbose,
51769
+ outputDirectory: input.outputDirectory,
51621
51770
  animateProjection: animateRender
51622
51771
  });
51623
51772
  const entries = completedScans.map((scan) => {
@@ -51718,6 +51867,7 @@ const resolveCliInspectOptions = (flags, userConfig) => {
51718
51867
  lint: flags.lint,
51719
51868
  deadCode: flags.deadCode,
51720
51869
  verbose: flags.verbose,
51870
+ outputDirectory: flags.outputDir,
51721
51871
  respectInlineDisables: flags.respectInlineDisables === false ? false : void 0,
51722
51872
  warnings: wantsWarningGate ? true : flags.warnings,
51723
51873
  scoreOnly: flags.score === true,
@@ -51729,22 +51879,101 @@ const resolveCliInspectOptions = (flags, userConfig) => {
51729
51879
  };
51730
51880
  };
51731
51881
  //#endregion
51732
- //#region src/cli/utils/resolve-diff-mode.ts
51733
- const resolveDiffMode = async (diffInfo, effectiveDiff, shouldSkipPrompts, isQuiet) => {
51734
- if (effectiveDiff !== void 0 && effectiveDiff !== false) {
51735
- if (diffInfo) return true;
51736
- if (!isQuiet) {
51737
- if (typeof effectiveDiff === "string") cliLogger.warn(`Could not compute diff against "${effectiveDiff}" (merge-base failed or HEAD has no history). Running full scan.`);
51738
- else cliLogger.warn("No feature branch or uncommitted changes detected. Running full scan.");
51739
- cliLogger.break();
51740
- }
51741
- return false;
51882
+ //#region src/cli/utils/resolve-scope.ts
51883
+ const SCOPE_VALUES = new Set([
51884
+ "full",
51885
+ "files",
51886
+ "changed",
51887
+ "lines"
51888
+ ]);
51889
+ const isScopeValue = (value) => SCOPE_VALUES.has(value);
51890
+ const coerceDeprecatedDiff = (value) => {
51891
+ if (value === void 0) return void 0;
51892
+ if (value === false || value === "false") return { scope: "full" };
51893
+ if (value === true || value === "true") return { scope: "changed" };
51894
+ if (value === "") return void 0;
51895
+ return {
51896
+ scope: "changed",
51897
+ base: value
51898
+ };
51899
+ };
51900
+ /**
51901
+ * Resolves the *requested* scope from flags + config without touching git.
51902
+ * Precedence mirrors `pickBlockingLevel`: flags win over config, and the new
51903
+ * `--scope` wins over the deprecated `--diff` alias on each side
51904
+ * (`flags.scope` > `flags.diff` > `config.scope` > `config.diff`). Returns
51905
+ * `scope: undefined` when nothing is set so the caller can default to `full`
51906
+ * or offer the interactive prompt.
51907
+ */
51908
+ const resolveScope = (flags, userConfig) => {
51909
+ const base = flags.base ?? userConfig?.base;
51910
+ if (typeof flags.scope === "string" && flags.scope.length > 0) {
51911
+ if (isScopeValue(flags.scope)) return {
51912
+ scope: flags.scope,
51913
+ base,
51914
+ usedDeprecatedDiff: false
51915
+ };
51916
+ cliLogger.warn(`Invalid --scope "${flags.scope}". Expected one of: full, files, changed, lines. Ignoring.`);
51742
51917
  }
51743
- if (effectiveDiff === false || !diffInfo) return false;
51744
- const changedSourceFiles = filterSourceFiles(diffInfo.changedFiles);
51745
- if (changedSourceFiles.length === 0) return false;
51746
- if (shouldSkipPrompts) return false;
51747
- if (isQuiet) return false;
51918
+ const flagDiff = coerceDeprecatedDiff(flags.diff);
51919
+ if (flagDiff !== void 0) return {
51920
+ scope: flagDiff.scope,
51921
+ base: base ?? flagDiff.base,
51922
+ usedDeprecatedDiff: true
51923
+ };
51924
+ if (userConfig?.scope !== void 0) {
51925
+ if (isScopeValue(userConfig.scope)) return {
51926
+ scope: userConfig.scope,
51927
+ base,
51928
+ usedDeprecatedDiff: false
51929
+ };
51930
+ cliLogger.warn(`Invalid scope "${userConfig.scope}" in config. Expected one of: full, files, changed, lines. Ignoring.`);
51931
+ }
51932
+ const configDiff = coerceDeprecatedDiff(userConfig?.diff);
51933
+ if (configDiff !== void 0) return {
51934
+ scope: configDiff.scope,
51935
+ base: base ?? configDiff.base,
51936
+ usedDeprecatedDiff: true
51937
+ };
51938
+ return {
51939
+ scope: void 0,
51940
+ base,
51941
+ usedDeprecatedDiff: false
51942
+ };
51943
+ };
51944
+ const warnDeprecatedDiff = (flags, userConfig) => {
51945
+ const usedFlag = flags.diff !== void 0;
51946
+ if (!usedFlag && userConfig?.diff === void 0) return;
51947
+ const targetScope = coerceDeprecatedDiff(usedFlag ? flags.diff : userConfig?.diff)?.scope ?? "changed";
51948
+ if (usedFlag) {
51949
+ const baseHint = targetScope === "changed" ? " (add `--base <ref>` to pin the base)" : "";
51950
+ cliLogger.warn(`The \`--diff\` flag is deprecated; use \`--scope ${targetScope}\`${baseHint} instead.`);
51951
+ return;
51952
+ }
51953
+ cliLogger.warn(`The \`diff\` config option is deprecated; use \`scope: "${targetScope}"\` instead.`);
51954
+ };
51955
+ const warnDiffUnavailable = (requested, isQuiet) => {
51956
+ if (isQuiet) return;
51957
+ if (typeof requested.base === "string") cliLogger.warn(`Could not compute diff against "${requested.base}" (merge-base failed or HEAD has no history). Running full scan.`);
51958
+ else cliLogger.warn("No feature branch or uncommitted changes detected. Running full scan.");
51959
+ cliLogger.break();
51960
+ };
51961
+ /**
51962
+ * Resolves the requested scope against the detected diff into the final scope.
51963
+ * An explicit non-`full` scope needs a usable `diffInfo`; without one it warns
51964
+ * and falls back to `full`. When nothing was requested, an interactive run on a
51965
+ * branch with changed source files is offered the "full vs changed" prompt.
51966
+ */
51967
+ const finalizeScope = async ({ requested, diffInfo, skipPrompts, isQuiet }) => {
51968
+ if (requested.scope !== void 0) {
51969
+ if (requested.scope === "full") return "full";
51970
+ if (diffInfo !== null) return requested.scope;
51971
+ warnDiffUnavailable(requested, isQuiet);
51972
+ return "full";
51973
+ }
51974
+ if (diffInfo === null || skipPrompts || isQuiet) return "full";
51975
+ const changedSourceFiles = filterSourceFiles([...diffInfo.changedFiles]);
51976
+ if (changedSourceFiles.length === 0) return "full";
51748
51977
  const { scanScope } = await prompts({
51749
51978
  type: "select",
51750
51979
  name: "scanScope",
@@ -51756,29 +51985,13 @@ const resolveDiffMode = async (diffInfo, effectiveDiff, shouldSkipPrompts, isQui
51756
51985
  }, {
51757
51986
  title: diffInfo.isCurrentChanges ? `Uncommitted changes (${changedSourceFiles.length})` : `Changed files on ${diffInfo.currentBranch ?? "this branch"} (${changedSourceFiles.length})`,
51758
51987
  description: diffInfo.isCurrentChanges ? "Compare working tree changes against HEAD" : `Compare against ${diffInfo.baseBranch} from the branch merge-base`,
51759
- value: "branch"
51988
+ value: "changed"
51760
51989
  }],
51761
51990
  initial: diffInfo.isCurrentChanges ? 0 : 1
51762
51991
  });
51763
- return scanScope === "branch";
51764
- };
51765
- //#endregion
51766
- //#region src/cli/utils/coerce-diff-value.ts
51767
- const coerceDiffValue = (value) => {
51768
- if (value === void 0) return void 0;
51769
- if (typeof value === "boolean") return value;
51770
- if (typeof value === "string") {
51771
- if (value.length === 0) return void 0;
51772
- if (value === "false") return false;
51773
- if (value === "true") return true;
51774
- return value;
51775
- }
51776
- process.stderr.write(`[react-doctor] invalid diff value (expected boolean or string): ${typeof value}. Falling back to no diff.\n`);
51992
+ return scanScope === "changed" ? "changed" : "full";
51777
51993
  };
51778
51994
  //#endregion
51779
- //#region src/cli/utils/resolve-effective-diff.ts
51780
- const resolveEffectiveDiff = (flags, userConfig) => coerceDiffValue(flags.diff ?? userConfig?.diff);
51781
- //#endregion
51782
51995
  //#region src/cli/utils/resolve-project-relative-directory.ts
51783
51996
  /**
51784
51997
  * The scanned project's directory relative to the diff root, forward-slashed —
@@ -51809,6 +52022,30 @@ const resolveProjectDiffIncludePaths = (rootDirectory, projectDirectory, diffInf
51809
52022
  return projectRelativePath.length > 0 ? [projectRelativePath] : [];
51810
52023
  });
51811
52024
  };
52025
+ /**
52026
+ * Re-keys repo-relative changed line ranges (from `getChangedLineRanges`) to
52027
+ * the scanned project, mirroring `resolveProjectDiffIncludePaths`'s boundary
52028
+ * rule so the `lines` scope filter inside `inspect()` matches the project-
52029
+ * relative diagnostic paths. Files outside the project are dropped.
52030
+ */
52031
+ const resolveProjectChangedLineRanges = (rootDirectory, projectDirectory, ranges) => {
52032
+ const relativeProjectDirectory = resolveProjectRelativeDirectory(rootDirectory, projectDirectory);
52033
+ if (relativeProjectDirectory === null) return [];
52034
+ if (relativeProjectDirectory.length === 0) return ranges.map((entry) => ({
52035
+ file: toForwardSlashes(entry.file),
52036
+ ranges: entry.ranges
52037
+ }));
52038
+ const projectPrefix = `${relativeProjectDirectory}/`;
52039
+ return ranges.flatMap((entry) => {
52040
+ const normalizedFilePath = toForwardSlashes(entry.file);
52041
+ if (!normalizedFilePath.startsWith(projectPrefix)) return [];
52042
+ const projectRelativePath = normalizedFilePath.slice(projectPrefix.length);
52043
+ return projectRelativePath.length > 0 ? [{
52044
+ file: projectRelativePath,
52045
+ ranges: entry.ranges
52046
+ }] : [];
52047
+ });
52048
+ };
51812
52049
  //#endregion
51813
52050
  //#region src/cli/utils/build-diagnostic-issue-url.ts
51814
52051
  const formatRuleIdentifier = (diagnostic) => `${diagnostic.plugin}/${diagnostic.rule}`;
@@ -52041,10 +52278,12 @@ const warnDeprecatedFailOn = (flags, userConfig) => {
52041
52278
  };
52042
52279
  //#endregion
52043
52280
  //#region src/cli/utils/validate-mode-flags.ts
52281
+ const usedDiffAlias = (flags) => flags.diff !== void 0 && flags.diff !== false && flags.diff !== "false" && flags.diff !== "";
52282
+ const usedScope = (flags) => typeof flags.scope === "string" && flags.scope.length > 0;
52044
52283
  const validateModeFlags = (flags) => {
52045
- const coercedDiff = coerceDiffValue(flags.diff);
52046
- const exclusiveModes = [flags.staged ? "--staged" : null, coercedDiff !== void 0 && coercedDiff !== false ? "--diff" : null].filter((modeName) => modeName !== null);
52047
- if (exclusiveModes.length > 1) throw new CliInputError(`Cannot combine ${exclusiveModes.join(" and ")}; pick one mode.`);
52284
+ if (usedScope(flags) && usedDiffAlias(flags)) throw new CliInputError("Cannot combine --scope and --diff; --diff is the deprecated alias.");
52285
+ if (flags.staged && usedDiffAlias(flags)) throw new CliInputError("Cannot combine --staged and --diff; pick one mode.");
52286
+ if (flags.staged && (flags.scope === "full" || flags.scope === "changed")) throw new CliInputError(`Cannot combine --staged with --scope ${flags.scope}; use --scope files or --scope lines, or drop --scope.`);
52048
52287
  if (flags.score && flags.json) throw new CliInputError("Cannot combine --score and --json; pick one output mode.");
52049
52288
  if (flags.score && flags.telemetry === false) throw new CliInputError("Cannot combine --score with --no-telemetry; --score prints the score that --no-telemetry disables.");
52050
52289
  if (flags.sfw) {
@@ -52052,7 +52291,8 @@ const validateModeFlags = (flags) => {
52052
52291
  flags.json ? "--json" : null,
52053
52292
  flags.score ? "--score" : null,
52054
52293
  flags.staged ? "--staged" : null,
52055
- coercedDiff !== void 0 && coercedDiff !== false ? "--diff" : null
52294
+ usedScope(flags) ? "--scope" : null,
52295
+ usedDiffAlias(flags) ? "--diff" : null
52056
52296
  ].find((name) => name !== null);
52057
52297
  if (conflictingFlag) throw new CliInputError(`Cannot combine --sfw with ${conflictingFlag}; --sfw is a standalone demo listing.`);
52058
52298
  }
@@ -52148,6 +52388,7 @@ const inspectAction = async (directory, flags) => {
52148
52388
  const resolvedDirectory = scanTarget.resolvedDirectory;
52149
52389
  setJsonReportDirectory(resolvedDirectory);
52150
52390
  warnDeprecatedFailOn(flags, userConfig);
52391
+ warnDeprecatedDiff(flags, userConfig);
52151
52392
  if (scanTarget.didRedirectViaRootDir && !isQuiet) {
52152
52393
  cliLogger.dim(`Redirected to ${highlighter.info(toRelativePath(resolvedDirectory, requestedDirectory))} via react-doctor config "rootDir".`);
52153
52394
  cliLogger.break();
@@ -52209,11 +52450,22 @@ const inspectAction = async (directory, flags) => {
52209
52450
  });
52210
52451
  throw error;
52211
52452
  });
52453
+ const stagedWantsLines = resolveScope(flags, userConfig).scope === "lines";
52454
+ const stagedLineRanges = stagedWantsLines ? await getChangedLineRanges({
52455
+ directory: resolvedDirectory,
52456
+ cached: true,
52457
+ files: snapshot.stagedFiles
52458
+ }) : null;
52459
+ if (stagedWantsLines && stagedLineRanges === null && !isQuiet) {
52460
+ cliLogger.warn("Could not determine staged changed lines; reporting all issues in staged files.");
52461
+ cliLogger.break();
52462
+ }
52212
52463
  try {
52213
52464
  const scanResult = await inspect(snapshot.tempDirectory, {
52214
52465
  ...scanOptions,
52215
52466
  includePaths: snapshot.stagedFiles,
52216
- configOverride: userConfig
52467
+ configOverride: userConfig,
52468
+ changedLineRanges: stagedLineRanges ?? void 0
52217
52469
  });
52218
52470
  const remappedDiagnostics = scanResult.diagnostics.map((diagnostic) => ({
52219
52471
  ...diagnostic,
@@ -52250,10 +52502,33 @@ const inspectAction = async (directory, flags) => {
52250
52502
  }
52251
52503
  const projectDirectories = await selectProjects(resolvedDirectory, flags.project, skipPrompts);
52252
52504
  const changedFilesDiffInfo = flags.changedFilesFrom ? buildChangedFilesDiffInfo(readChangedFilesFrom(Path.resolve(flags.changedFilesFrom))) : null;
52253
- const effectiveDiff = resolveEffectiveDiff(flags, userConfig);
52254
- const diffInfo = changedFilesDiffInfo ?? (changedFilesDiffInfo === null && (effectiveDiff !== void 0 && effectiveDiff !== false || !skipPrompts && !isQuiet) ? await getDiffInfo(resolvedDirectory, typeof effectiveDiff === "string" ? effectiveDiff : void 0) : null);
52255
- const isDiffMode = changedFilesDiffInfo !== null || await resolveDiffMode(diffInfo, effectiveDiff, skipPrompts, isQuiet);
52256
- const baselineRef = isDiffMode && diffInfo && !diffInfo.isCurrentChanges ? diffInfo.baseSha ? await resolveMergeBaseRef(resolvedDirectory, diffInfo.baseSha) : diffInfo.diffBaseRef ?? await resolveMergeBaseRef(resolvedDirectory, diffInfo.baseBranch) : null;
52505
+ const requestedScope = resolveScope(flags, userConfig);
52506
+ const scopeRequest = requestedScope.scope === void 0 && changedFilesDiffInfo !== null ? {
52507
+ ...requestedScope,
52508
+ scope: "changed"
52509
+ } : requestedScope;
52510
+ const wantsDiffMode = scopeRequest.scope !== void 0 && scopeRequest.scope !== "full";
52511
+ const shouldDetectDiff = changedFilesDiffInfo === null && (wantsDiffMode || scopeRequest.scope === void 0 && !skipPrompts && !isQuiet);
52512
+ const diffInfo = changedFilesDiffInfo ?? (shouldDetectDiff ? await getDiffInfo(resolvedDirectory, scopeRequest.base) : null);
52513
+ const scope = await finalizeScope({
52514
+ requested: scopeRequest,
52515
+ diffInfo,
52516
+ skipPrompts,
52517
+ isQuiet
52518
+ });
52519
+ const isDiffMode = scope !== "full";
52520
+ const comparisonBaseRef = isDiffMode && diffInfo && !diffInfo.isCurrentChanges ? diffInfo.baseSha ? await resolveMergeBaseRef(resolvedDirectory, diffInfo.baseSha) : diffInfo.diffBaseRef ?? await resolveMergeBaseRef(resolvedDirectory, diffInfo.baseBranch) : null;
52521
+ const baselineRef = scope === "changed" ? comparisonBaseRef : null;
52522
+ const linesBaseRef = diffInfo?.isCurrentChanges ? "HEAD" : comparisonBaseRef;
52523
+ const changedLineRanges = scope === "lines" && diffInfo !== null && (diffInfo.isCurrentChanges || linesBaseRef !== null) && diffInfo !== null ? await getChangedLineRanges({
52524
+ directory: resolvedDirectory,
52525
+ baseRef: linesBaseRef ?? void 0,
52526
+ files: [...diffInfo.changedFiles]
52527
+ }) : null;
52528
+ if (scope === "lines" && changedLineRanges === null && !isQuiet) {
52529
+ cliLogger.warn("Could not determine changed lines (no base ref or git diff failed); reporting all issues in changed files.");
52530
+ cliLogger.break();
52531
+ }
52257
52532
  setJsonReportMode(baselineRef ? "baseline" : isDiffMode ? "diff" : "full");
52258
52533
  if (isDiffMode && diffInfo && !isQuiet) {
52259
52534
  if (diffInfo.isCurrentChanges) cliLogger.log("Scanning uncommitted changes");
@@ -52290,6 +52565,7 @@ const inspectAction = async (directory, flags) => {
52290
52565
  configOverride: userConfig,
52291
52566
  suppressRendering: isMultiProject,
52292
52567
  baseline: baselineRef ? { ref: baselineRef } : void 0,
52568
+ changedLineRanges: scope === "lines" && changedLineRanges !== null ? resolveProjectChangedLineRanges(resolvedDirectory, projectDirectory, changedLineRanges) : void 0,
52293
52569
  supplyChainManifestChanged
52294
52570
  });
52295
52571
  allDiagnostics.push(...scanResult.diagnostics);
@@ -52306,16 +52582,20 @@ const inspectAction = async (directory, flags) => {
52306
52582
  categoryFilters,
52307
52583
  userConfig,
52308
52584
  verbose: Boolean(flags.verbose),
52585
+ outputDirectory: flags.outputDir,
52309
52586
  isOffline: !shouldShowShareLink,
52310
52587
  projectName: Path.basename(resolvedDirectory)
52311
52588
  }));
52312
52589
  }
52590
+ const selectedSurfaceDiagnostics = filterDiagnosticsByCategories(filterDiagnosticsForSurface(allDiagnostics, scanOptions.outputSurface ?? "cli", userConfig), categoryFilters);
52591
+ const didScansWriteDump = isMultiProject ? !isQuiet && completedScans.length > 0 : completedScans.length > 0;
52592
+ if (flags.outputDir && !didScansWriteDump) await runPromise(printDiagnosticsDump(selectedSurfaceDiagnostics, flags.outputDir, false, isQuiet ? "stderr" : "stdout"));
52313
52593
  finalizeScans({
52314
52594
  diagnostics: allDiagnostics,
52315
52595
  completedScans,
52316
52596
  mode: baselineRef ? "baseline" : isDiffMode ? "diff" : "full",
52317
52597
  diff: isDiffMode ? diffInfo : null,
52318
- baselineIntended: isDiffMode && diffInfo !== null && !diffInfo.isCurrentChanges,
52598
+ baselineIntended: scope === "changed" && diffInfo !== null && !diffInfo.isCurrentChanges,
52319
52599
  isJsonMode,
52320
52600
  isScoreOnly,
52321
52601
  flags,
@@ -52324,13 +52604,13 @@ const inspectAction = async (directory, flags) => {
52324
52604
  resolvedDirectory,
52325
52605
  startTime
52326
52606
  });
52327
- const selectedSurfaceDiagnostics = filterDiagnosticsByCategories(filterDiagnosticsForSurface(allDiagnostics, scanOptions.outputSurface ?? "cli", userConfig), categoryFilters);
52328
52607
  if (!isQuiet && !skipPrompts && process.stdout.isTTY === true && !isCiOrCodingAgentEnvironment() && selectedSurfaceDiagnostics.length > 0) {
52329
52608
  await handoffToAgent({
52330
52609
  diagnostics: selectedSurfaceDiagnostics,
52331
52610
  projectName: Path.basename(resolvedDirectory),
52332
52611
  rootDirectory: resolvedDirectory,
52333
- interactive: true
52612
+ interactive: true,
52613
+ outputDirectory: flags.outputDir
52334
52614
  });
52335
52615
  return;
52336
52616
  }
@@ -53122,11 +53402,14 @@ const ROOT_FLAG_SPEC = {
53122
53402
  "--yes"
53123
53403
  ]),
53124
53404
  longOptionsWithRequiredValues: new Set([
53405
+ "--base",
53125
53406
  "--category",
53126
53407
  "--changed-files-from",
53127
53408
  "--blocking",
53409
+ "--output-dir",
53128
53410
  "--fail-on",
53129
- "--project"
53411
+ "--project",
53412
+ "--scope"
53130
53413
  ]),
53131
53414
  longOptionsWithOptionalValues: new Set(["--diff"]),
53132
53415
  shortOptionsWithoutValues: new Set([
@@ -53309,7 +53592,7 @@ ${highlighter.dim("Learn more:")}
53309
53592
  ${highlighter.info(CANONICAL_GITHUB_URL)}
53310
53593
  `;
53311
53594
  const collectCategoryOption = (value, previousValues) => [...previousValues ?? [], value];
53312
- const program = new Command().name("react-doctor").description("Diagnose React codebase health").version(VERSION, "-v, --version", "display the version number").argument("[directory]", "project directory to scan", ".").option("--lint", "enable linting").option("--no-lint", "skip linting").option("--dead-code", "enable dead-code analysis (default)").option("--no-dead-code", "skip dead-code analysis (unused files / exports / dependencies, circular imports)").option("--verbose", "show every rule and per-file details (default shows top 3 rules)").option("--score", "output only the score").option("--json", "output a single structured JSON report (suppresses other output)").option("--json-compact", "with --json, emit compact JSON (no indentation)").option("-y, --yes", "skip prompts, scan all workspace projects").option("--no-parallel", "lint serially with one worker (default: parallel across CPU cores; set the worker count with REACT_DOCTOR_PARALLEL)").option("--project <name>", "select workspace project (comma-separated for multiple)").option("--diff [base]", "scan only files changed vs base branch (pass `false` to force a full scan, overriding config)").addOption(new Option("--changed-files-from <file>", "scan source files listed in a newline-delimited changed-files file").hideHelp()).option("--no-score", "skip the score API, the share URL, and crash reporting").addOption(new Option("--category <category>", "only show diagnostics in a category (repeatable; e.g. Security)").argParser(collectCategoryOption)).option("--no-telemetry", "alias for --no-score (skip the score API, share URL, and crash reporting)").option("--staged", "scan only staged (git index) files for pre-commit hooks").option("--blocking <level>", "severity that fails CI: error (default), warning, or none (advisory)").addOption(new Option("--fail-on <level>", "[deprecated] alias for --blocking <level>").hideHelp()).option("--no-respect-inline-disables", "audit mode: neutralize inline lint suppressions before scanning").option("--warnings", "show warning-severity diagnostics (default)").option("--no-warnings", "hide warning-severity diagnostics (errors only)").option("--sfw", "demo: print the Socket.dev supply-chain score of every direct dependency, then exit").option("--color", "force colored output").option("--no-color", "disable colored output (also honors NO_COLOR)").addHelpText("after", renderRootHelpEpilog);
53595
+ const program = new Command().name("react-doctor").description("Diagnose React codebase health").version(VERSION, "-v, --version", "display the version number").argument("[directory]", "project directory to scan", ".").option("--lint", "enable linting").option("--no-lint", "skip linting").option("--dead-code", "enable dead-code analysis (default)").option("--no-dead-code", "skip dead-code analysis (unused files / exports / dependencies, circular imports)").option("--verbose", "show every rule and per-file details (default shows top 3 rules)").option("--output-dir <dir>", "directory for the full diagnostics dump (default: a temp folder)").option("--score", "output only the score").option("--json", "output a single structured JSON report (suppresses other output)").option("--json-compact", "with --json, emit compact JSON (no indentation)").option("-y, --yes", "skip prompts, scan all workspace projects").option("--no-parallel", "lint serially with one worker (default: parallel across CPU cores; set the worker count with REACT_DOCTOR_PARALLEL)").option("--project <name>", "select workspace project (comma-separated for multiple)").option("--scope <value>", "how much to scan/report: full (default), files, changed (only new issues vs base), or lines (only changed lines)").option("--base <ref>", "base git ref for files/changed/lines scope (auto-detected when omitted)").addOption(new Option("--diff [base]", "[deprecated] alias for --scope changed (pass `false` to force a full scan)").hideHelp()).addOption(new Option("--changed-files-from <file>", "scan source files listed in a newline-delimited changed-files file").hideHelp()).option("--no-score", "skip the score API, the share URL, and crash reporting").addOption(new Option("--category <category>", "only show diagnostics in a category (repeatable; e.g. Security)").argParser(collectCategoryOption)).option("--no-telemetry", "alias for --no-score (skip the score API, share URL, and crash reporting)").option("--staged", "scan only staged (git index) files for pre-commit hooks").option("--blocking <level>", "severity that fails CI: error (default), warning, or none (advisory)").addOption(new Option("--fail-on <level>", "[deprecated] alias for --blocking <level>").hideHelp()).option("--no-respect-inline-disables", "audit mode: neutralize inline lint suppressions before scanning").option("--warnings", "show warning-severity diagnostics (default)").option("--no-warnings", "hide warning-severity diagnostics (errors only)").option("--sfw", "demo: print the Socket.dev supply-chain score of every direct dependency, then exit").option("--color", "force colored output").option("--no-color", "disable colored output (also honors NO_COLOR)").addHelpText("after", renderRootHelpEpilog);
53313
53596
  program.action(inspectAction);
53314
53597
  program.command("why <location>").description("Explain why a rule fired (or why a suppression didn't apply) at a file:line").option("--project <name>", "select workspace project (comma-separated for multiple)").option("-c, --cwd <cwd>", "working directory", process.cwd()).option("--color", "force colored output").option("--no-color", "disable colored output (also honors NO_COLOR)").action((location, options) => whyAction(location, options));
53315
53598
  program.command("install").alias("setup").description("Install the react-doctor skill into your coding agents and optional git hook").option("-y, --yes", "skip prompts, install for all detected agents").option("--dry-run", "show what would be installed without writing files").option("--agent-hooks", "install native non-blocking agent hooks for Claude Code and Cursor").option("-c, --cwd <cwd>", "working directory", process.cwd()).option("--color", "force colored output").option("--no-color", "disable colored output (also honors NO_COLOR)").addHelpText("after", renderInstallHelpEpilog).action(installAction);
@@ -53352,4 +53635,4 @@ Promise.resolve().then(() => assertNoRemovedFlags(process.argv)).then(() => prog
53352
53635
  export {};
53353
53636
 
53354
53637
  //# sourceMappingURL=cli.js.map
53355
- //# debugId=f25bdf09-ff57-565e-b47b-46ef237158c2
53638
+ //# debugId=10847467-aed6-53d3-b6bd-1ed24087b9e7