react-doctor 0.2.15-dev.01ec05c → 0.2.15-dev.3fae9dd

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]="540e80ff-13a0-5cd7-8313-53bd820f256d")}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]="d012dbb2-27e9-5092-9eab-c7fa4573f0b2")}catch(e){}}();
3
3
  import { createRequire } from "node:module";
4
4
  import { execFileSync, spawn, spawnSync } from "node:child_process";
5
5
  import * as Path from "node:path";
@@ -7254,15 +7254,6 @@ const formatReactDoctorError = (error) => error.reason.message;
7254
7254
  const isSplittableReactDoctorError = (error) => error instanceof ReactDoctorError && error.reason._tag === "OxlintBatchExceeded";
7255
7255
  const isReactDoctorError = (error) => error instanceof ReactDoctorError;
7256
7256
  /**
7257
- * Diff-base failures stem from the caller's `--diff` argument or local
7258
- * git state — a malformed ref/range, or a base branch that simply hasn't
7259
- * been fetched — not from a bug in react-doctor. The CLI renders these
7260
- * as a plain message and exits non-zero WITHOUT capturing them to Sentry
7261
- * or pointing the user at a bug report: they're expected, user-actionable
7262
- * conditions, not crashes to triage.
7263
- */
7264
- const isUserInputError = (error) => error instanceof ReactDoctorError && (error.reason._tag === "GitBaseBranchInvalid" || error.reason._tag === "GitBaseBranchMissing");
7265
- /**
7266
7257
  * Tagged-reason → legacy thrown-class boundary shared by every public
7267
7258
  * shell (`inspect()` in `react-doctor`, `diagnose()` in `@react-doctor/api`).
7268
7259
  *
@@ -8984,11 +8975,6 @@ const trimOrNull = (value) => {
8984
8975
  * `@{` reflog suffix, or any character outside `[A-Za-z0-9_./-]`.
8985
8976
  */
8986
8977
  const SAFE_GIT_REVISION_PATTERN = /^[A-Za-z0-9_./-]+$/;
8987
- /** Human-readable summary of the `isSafeGitRevision` contract, reused across error details. */
8988
- const GIT_REF_NAME_RULE = "must match [A-Za-z0-9_./-] without leading '-', '..', or '@{'";
8989
- /** git's two range operators: two-dot (direct) and three-dot (merge-base). */
8990
- const DIFF_RANGE_OPERATOR = "..";
8991
- const SYMMETRIC_DIFF_RANGE_OPERATOR = "...";
8992
8978
  const isSafeGitRevision = (candidate) => {
8993
8979
  if (candidate.length === 0) return false;
8994
8980
  if (candidate.startsWith("-")) return false;
@@ -8996,31 +8982,6 @@ const isSafeGitRevision = (candidate) => {
8996
8982
  if (candidate.includes("..") || candidate.includes("@{")) return false;
8997
8983
  return SAFE_GIT_REVISION_PATTERN.test(candidate);
8998
8984
  };
8999
- /**
9000
- * Splits a git revision range into its endpoints: three-dot `A...B`
9001
- * (symmetric, merge-base) or two-dot `A..B` (direct). Returns `null`
9002
- * when `value` carries no range operator so the caller falls back to
9003
- * single-base resolution.
9004
- *
9005
- * Only the first operator is split on; any leftover `..` stays inside an
9006
- * endpoint so `isSafeGitRevision` rejects malformed input like
9007
- * `A..B..C` instead of silently guessing which pair the user meant.
9008
- */
9009
- const parseGitDiffRange = (value) => {
9010
- const symmetricIndex = value.indexOf(SYMMETRIC_DIFF_RANGE_OPERATOR);
9011
- if (symmetricIndex !== -1) return {
9012
- base: value.slice(0, symmetricIndex),
9013
- head: value.slice(symmetricIndex + 3),
9014
- symmetric: true
9015
- };
9016
- const rangeIndex = value.indexOf(DIFF_RANGE_OPERATOR);
9017
- if (rangeIndex !== -1) return {
9018
- base: value.slice(0, rangeIndex),
9019
- head: value.slice(rangeIndex + 2),
9020
- symmetric: false
9021
- };
9022
- return null;
9023
- };
9024
8985
  const parseGithubRepoFromRemoteUrl = (remoteUrl) => {
9025
8986
  const withoutGitSuffix = remoteUrl.trim().replace(/\.git$/, "");
9026
8987
  const sshMatch = /^git@github\.com:([^/\s]+)\/([^/\s]+)$/.exec(withoutGitSuffix);
@@ -9172,49 +9133,6 @@ var Git = class Git extends Context.Service()("react-doctor/Git") {
9172
9133
  if (result.status !== 0) return null;
9173
9134
  return parseGithubViewerPermission(result.stdout);
9174
9135
  }).pipe(Effect.catch(() => Effect.succeed(null)));
9175
- /**
9176
- * Resolves a `--diff A..B` / `A...B` commit range into a changed-file
9177
- * selection. Each endpoint is validated with `isSafeGitRevision`
9178
- * BEFORE it reaches `git` (so the range syntax can't smuggle a
9179
- * `--upload-pack=…`-style option past the CVE-2018-17456 guard) and
9180
- * verified to exist, then the diff runs between the two commits with
9181
- * the same `--diff-filter=ACMR` shape the single-base path uses.
9182
- */
9183
- const resolveDiffRange = (input) => Effect.gen(function* () {
9184
- if (input.range.base.length === 0 && input.range.head.length === 0) return yield* Effect.fail(new ReactDoctorError({ reason: new GitBaseBranchInvalid({ detail: `Diff range "${input.raw}" must name at least one commit (e.g. "main..feature").` }) }));
9185
- const baseRef = input.range.base.length === 0 ? "HEAD" : input.range.base;
9186
- const headRef = input.range.head.length === 0 ? "HEAD" : input.range.head;
9187
- for (const endpoint of [baseRef, headRef]) if (!isSafeGitRevision(endpoint)) return yield* Effect.fail(new ReactDoctorError({ reason: new GitBaseBranchInvalid({ detail: `Diff range "${input.raw}" has an invalid endpoint "${endpoint}" (${GIT_REF_NAME_RULE}).` }) }));
9188
- for (const endpoint of [baseRef, headRef]) if (!(yield* branchExists(input.directory, endpoint))) return yield* Effect.fail(new ReactDoctorError({ reason: new GitBaseBranchMissing({ branch: endpoint }) }));
9189
- let diffBaseRef = baseRef;
9190
- if (input.range.symmetric) {
9191
- const mergeBase = yield* runGit(input.directory, [
9192
- "merge-base",
9193
- baseRef,
9194
- headRef
9195
- ]);
9196
- if (mergeBase.status !== 0) return null;
9197
- const mergeBaseRef = trimOrNull(mergeBase.stdout);
9198
- if (mergeBaseRef === null) return null;
9199
- diffBaseRef = mergeBaseRef;
9200
- }
9201
- const diff = yield* runGit(input.directory, [
9202
- "diff",
9203
- "-z",
9204
- "--name-only",
9205
- "--diff-filter=ACMR",
9206
- "--relative",
9207
- diffBaseRef,
9208
- headRef
9209
- ]);
9210
- if (diff.status !== 0) return null;
9211
- return {
9212
- currentBranch: headRef,
9213
- baseBranch: baseRef,
9214
- changedFiles: splitNullSeparated(diff.stdout),
9215
- isCurrentChanges: false
9216
- };
9217
- });
9218
9136
  return Git.of({
9219
9137
  currentBranch,
9220
9138
  defaultBranch,
@@ -9224,15 +9142,7 @@ var Git = class Git extends Context.Service()("react-doctor/Git") {
9224
9142
  branchExists,
9225
9143
  diffSelection: ({ directory, explicitBaseBranch }) => Effect.gen(function* () {
9226
9144
  if (explicitBaseBranch !== void 0 && explicitBaseBranch.trim().length === 0) return yield* Effect.fail(new ReactDoctorError({ reason: new GitBaseBranchInvalid({ detail: "Diff base branch cannot be empty." }) }));
9227
- if (explicitBaseBranch !== void 0) {
9228
- const range = parseGitDiffRange(explicitBaseBranch);
9229
- if (range !== null) return yield* resolveDiffRange({
9230
- directory,
9231
- range,
9232
- raw: explicitBaseBranch
9233
- });
9234
- if (!isSafeGitRevision(explicitBaseBranch)) return yield* Effect.fail(new ReactDoctorError({ reason: new GitBaseBranchInvalid({ detail: `Diff base branch "${explicitBaseBranch}" is not a valid git ref name (${GIT_REF_NAME_RULE}).` }) }));
9235
- }
9145
+ if (explicitBaseBranch !== void 0 && !isSafeGitRevision(explicitBaseBranch)) return yield* Effect.fail(new ReactDoctorError({ reason: new GitBaseBranchInvalid({ detail: `Diff base branch "${explicitBaseBranch}" is not a valid git ref name (must match [A-Za-z0-9_./-] without leading '-', '..', or '@{').` }) }));
9236
9146
  const resolvedCurrentBranch = yield* currentBranch(directory);
9237
9147
  if (resolvedCurrentBranch === null && explicitBaseBranch === void 0) return null;
9238
9148
  const baseBranch = explicitBaseBranch ?? (yield* defaultBranch(directory));
@@ -11614,13 +11524,12 @@ const buildSkippedChecks = (input) => {
11614
11524
  * Git service runs through Effect's `ChildProcess` (true subprocess
11615
11525
  * spawn, not `spawnSync`).
11616
11526
  *
11617
- * Failures propagate as the tagged `ReactDoctorError` (rejected by
11618
- * `Effect.runPromise`) rather than being flattened into a plain
11619
- * `Error`. The message is unchanged — `ReactDoctorError.message`
11620
- * defers to `reason.message` — so message-matching callers keep
11621
- * working, while the CLI can now dispatch on `error.reason._tag` to
11622
- * render diff-base mistakes (`GitBaseBranchInvalid` /
11623
- * `GitBaseBranchMissing`) as clean user errors instead of crashes.
11527
+ * Tagged-reason errors are dispatched via `Effect.catchReasons`
11528
+ * (a v4-native API for narrowing inside a `Schema.TaggedErrorClass`
11529
+ * union without manual `instanceof` checks). The recovered branches
11530
+ * raise plain `Error`s so existing thrown-class consumers continue
11531
+ * to work — anything else (real `GitInvocationFailed`, etc.)
11532
+ * propagates as the tagged `ReactDoctorError` through `Effect.runPromise`.
11624
11533
  */
11625
11534
  const getDiffInfo = (directory, explicitBaseBranch) => Effect.runPromise(Effect.gen(function* () {
11626
11535
  const selection = yield* (yield* Git).diffSelection({
@@ -11634,7 +11543,10 @@ const getDiffInfo = (directory, explicitBaseBranch) => Effect.runPromise(Effect.
11634
11543
  changedFiles: [...selection.changedFiles],
11635
11544
  ...selection.isCurrentChanges ? { isCurrentChanges: true } : {}
11636
11545
  };
11637
- }).pipe(Effect.provide(Git.layerNode)));
11546
+ }).pipe(Effect.provide(Git.layerNode), Effect.catchReasons("ReactDoctorError", {
11547
+ GitBaseBranchInvalid: (reason) => Effect.die(new Error(reason.detail)),
11548
+ GitBaseBranchMissing: (reason) => Effect.die(new Error(reason.message))
11549
+ })));
11638
11550
  const filterSourceFiles = (filePaths) => filePaths.filter(isLintableSourceFile);
11639
11551
  var import_picocolors = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
11640
11552
  let p = process || {}, argv = p.argv || [], env = p.env || {};
@@ -11889,7 +11801,7 @@ const makeNoopConsole = () => ({
11889
11801
  });
11890
11802
  //#endregion
11891
11803
  //#region src/cli/utils/version.ts
11892
- const VERSION = "0.2.15-dev.01ec05c";
11804
+ const VERSION = "0.2.15-dev.3fae9dd";
11893
11805
  //#endregion
11894
11806
  //#region src/cli/utils/json-mode.ts
11895
11807
  let context = null;
@@ -12205,13 +12117,13 @@ const isDevVersion = (version) => version === "0.0.0" || version.includes("-");
12205
12117
  * uploads source-map artifacts under, so stack frames symbolicate. Honors the
12206
12118
  * standard `SENTRY_RELEASE` override.
12207
12119
  */
12208
- const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.2.15-dev.01ec05c`;
12120
+ const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.2.15-dev.3fae9dd`;
12209
12121
  /**
12210
12122
  * Deployment environment shown in Sentry's environment filter. Defaults to
12211
12123
  * `production` for tagged releases and `development` for dev/unbuilt versions,
12212
12124
  * overridable via the standard `SENTRY_ENVIRONMENT` env var.
12213
12125
  */
12214
- const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.2.15-dev.01ec05c") ? "development" : "production");
12126
+ const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.2.15-dev.3fae9dd") ? "development" : "production");
12215
12127
  /**
12216
12128
  * Performance-tracing sample rate in `[0, 1]`. Reads `SENTRY_TRACES_SAMPLE_RATE`
12217
12129
  * (set to `0` to disable tracing) and falls back to
@@ -16677,21 +16589,6 @@ const handleError = (error, options = {}) => {
16677
16589
  if (options.shouldExit !== false) process.exit(1);
16678
16590
  process.exitCode = 1;
16679
16591
  };
16680
- /**
16681
- * Renderer for expected, user-actionable failures (see `isUserInputError`):
16682
- * a bad `--diff` value or a base branch that isn't fetched. Prints just the
16683
- * (already human-readable) message — no "Something went wrong", prefilled
16684
- * issue, Discord link, or Sentry reference — because there is no bug to report.
16685
- */
16686
- const handleUserError = (error, options = {}) => {
16687
- Effect.runSync(Effect.gen(function* () {
16688
- yield* Console.error("");
16689
- yield* Console.error(highlighter.error(formatErrorForReport(error)));
16690
- yield* Console.error("");
16691
- }));
16692
- if (options.shouldExit !== false) process.exit(1);
16693
- process.exitCode = 1;
16694
- };
16695
16592
  //#endregion
16696
16593
  //#region src/cli/utils/build-handoff-payload.ts
16697
16594
  const buildHandoffPayload = (input) => {
@@ -18895,17 +18792,12 @@ const inspectAction = async (directory, flags) => {
18895
18792
  })) printAgentInstallHint();
18896
18793
  }
18897
18794
  } catch (error) {
18898
- const isUserError = isUserInputError(error);
18899
- const sentryEventId = isUserError ? void 0 : await reportErrorToSentry(error);
18795
+ const sentryEventId = await reportErrorToSentry(error);
18900
18796
  if (isJsonMode) {
18901
18797
  writeJsonErrorReport(error);
18902
18798
  process.exitCode = 1;
18903
18799
  return;
18904
18800
  }
18905
- if (isUserError) {
18906
- handleUserError(error);
18907
- return;
18908
- }
18909
18801
  handleError(error, { sentryEventId });
18910
18802
  }
18911
18803
  };
@@ -19765,4 +19657,4 @@ program.parseAsync(argv).then(() => flushSentry()).catch(async (error) => {
19765
19657
  export {};
19766
19658
 
19767
19659
  //# sourceMappingURL=cli.js.map
19768
- //# debugId=540e80ff-13a0-5cd7-8313-53bd820f256d
19660
+ //# debugId=d012dbb2-27e9-5092-9eab-c7fa4573f0b2
package/dist/index.d.ts CHANGED
@@ -726,12 +726,20 @@ declare class ReactDoctorError extends ReactDoctorError_base {
726
726
  }
727
727
  declare const isReactDoctorError: (error: unknown) => error is ReactDoctorError;
728
728
  /**
729
- * Diff-base failures stem from the caller's `--diff` argument or local
730
- * git state — a malformed ref/range, or a base branch that simply hasn't
731
- * been fetched — not from a bug in react-doctor. The CLI renders these
732
- * as a plain message and exits non-zero WITHOUT capturing them to Sentry
733
- * or pointing the user at a bug report: they're expected, user-actionable
734
- * conditions, not crashes to triage.
729
+ * Tagged-reason → legacy thrown-class boundary shared by every public
730
+ * shell (`inspect()` in `react-doctor`, `diagnose()` in `@react-doctor/api`).
731
+ *
732
+ * `Effect.catchReasons` dispatches on the tagged-error sub-channel
733
+ * without manual `instanceof` checks. Each handler converts a tagged
734
+ * reason into the historical thrown class advertised by the legacy
735
+ * public-API contract (via `Effect.die`, which `Effect.runPromise`
736
+ * re-throws unchanged). The `orElse` branch re-`die`s the original
737
+ * `ReactDoctorError` instance so advanced callers can still narrow on
738
+ * `error.reason._tag` while grep-stderr users keep the same
739
+ * `error.message` they always saw.
740
+ *
741
+ * Adding a new legacy thrown class is a one-line change on the
742
+ * `Effect.catchReasons` map — both shells pick it up automatically.
735
743
  */
736
744
  //#endregion
737
745
  //#region src/build-json-report-error.d.ts
@@ -764,13 +772,12 @@ declare const buildJsonReport: (input: BuildJsonReportInput) => JsonReport; //#e
764
772
  * Git service runs through Effect's `ChildProcess` (true subprocess
765
773
  * spawn, not `spawnSync`).
766
774
  *
767
- * Failures propagate as the tagged `ReactDoctorError` (rejected by
768
- * `Effect.runPromise`) rather than being flattened into a plain
769
- * `Error`. The message is unchanged — `ReactDoctorError.message`
770
- * defers to `reason.message` — so message-matching callers keep
771
- * working, while the CLI can now dispatch on `error.reason._tag` to
772
- * render diff-base mistakes (`GitBaseBranchInvalid` /
773
- * `GitBaseBranchMissing`) as clean user errors instead of crashes.
775
+ * Tagged-reason errors are dispatched via `Effect.catchReasons`
776
+ * (a v4-native API for narrowing inside a `Schema.TaggedErrorClass`
777
+ * union without manual `instanceof` checks). The recovered branches
778
+ * raise plain `Error`s so existing thrown-class consumers continue
779
+ * to work — anything else (real `GitInvocationFailed`, etc.)
780
+ * propagates as the tagged `ReactDoctorError` through `Effect.runPromise`.
774
781
  */
775
782
  declare const getDiffInfo: (directory: string, explicitBaseBranch?: string) => Promise<DiffInfo | null>;
776
783
  declare const filterSourceFiles: (filePaths: string[]) => string[]; //#endregion
package/dist/index.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]="4536fc6c-0d5d-50d5-83e0-910624b3a687")}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]="df20b0d3-9e4e-52e0-8991-ce8a6349a04a")}catch(e){}}();
3
3
  import { createRequire } from "node:module";
4
4
  import * as Schema from "effect/Schema";
5
5
  import * as fs$1 from "node:fs";
@@ -5928,11 +5928,6 @@ const trimOrNull = (value) => {
5928
5928
  * `@{` reflog suffix, or any character outside `[A-Za-z0-9_./-]`.
5929
5929
  */
5930
5930
  const SAFE_GIT_REVISION_PATTERN = /^[A-Za-z0-9_./-]+$/;
5931
- /** Human-readable summary of the `isSafeGitRevision` contract, reused across error details. */
5932
- const GIT_REF_NAME_RULE = "must match [A-Za-z0-9_./-] without leading '-', '..', or '@{'";
5933
- /** git's two range operators: two-dot (direct) and three-dot (merge-base). */
5934
- const DIFF_RANGE_OPERATOR = "..";
5935
- const SYMMETRIC_DIFF_RANGE_OPERATOR = "...";
5936
5931
  const isSafeGitRevision = (candidate) => {
5937
5932
  if (candidate.length === 0) return false;
5938
5933
  if (candidate.startsWith("-")) return false;
@@ -5940,31 +5935,6 @@ const isSafeGitRevision = (candidate) => {
5940
5935
  if (candidate.includes("..") || candidate.includes("@{")) return false;
5941
5936
  return SAFE_GIT_REVISION_PATTERN.test(candidate);
5942
5937
  };
5943
- /**
5944
- * Splits a git revision range into its endpoints: three-dot `A...B`
5945
- * (symmetric, merge-base) or two-dot `A..B` (direct). Returns `null`
5946
- * when `value` carries no range operator so the caller falls back to
5947
- * single-base resolution.
5948
- *
5949
- * Only the first operator is split on; any leftover `..` stays inside an
5950
- * endpoint so `isSafeGitRevision` rejects malformed input like
5951
- * `A..B..C` instead of silently guessing which pair the user meant.
5952
- */
5953
- const parseGitDiffRange = (value) => {
5954
- const symmetricIndex = value.indexOf(SYMMETRIC_DIFF_RANGE_OPERATOR);
5955
- if (symmetricIndex !== -1) return {
5956
- base: value.slice(0, symmetricIndex),
5957
- head: value.slice(symmetricIndex + 3),
5958
- symmetric: true
5959
- };
5960
- const rangeIndex = value.indexOf(DIFF_RANGE_OPERATOR);
5961
- if (rangeIndex !== -1) return {
5962
- base: value.slice(0, rangeIndex),
5963
- head: value.slice(rangeIndex + 2),
5964
- symmetric: false
5965
- };
5966
- return null;
5967
- };
5968
5938
  const parseGithubRepoFromRemoteUrl = (remoteUrl) => {
5969
5939
  const withoutGitSuffix = remoteUrl.trim().replace(/\.git$/, "");
5970
5940
  const sshMatch = /^git@github\.com:([^/\s]+)\/([^/\s]+)$/.exec(withoutGitSuffix);
@@ -6116,49 +6086,6 @@ var Git = class Git extends Context.Service()("react-doctor/Git") {
6116
6086
  if (result.status !== 0) return null;
6117
6087
  return parseGithubViewerPermission(result.stdout);
6118
6088
  }).pipe(Effect.catch(() => Effect.succeed(null)));
6119
- /**
6120
- * Resolves a `--diff A..B` / `A...B` commit range into a changed-file
6121
- * selection. Each endpoint is validated with `isSafeGitRevision`
6122
- * BEFORE it reaches `git` (so the range syntax can't smuggle a
6123
- * `--upload-pack=…`-style option past the CVE-2018-17456 guard) and
6124
- * verified to exist, then the diff runs between the two commits with
6125
- * the same `--diff-filter=ACMR` shape the single-base path uses.
6126
- */
6127
- const resolveDiffRange = (input) => Effect.gen(function* () {
6128
- if (input.range.base.length === 0 && input.range.head.length === 0) return yield* Effect.fail(new ReactDoctorError({ reason: new GitBaseBranchInvalid({ detail: `Diff range "${input.raw}" must name at least one commit (e.g. "main..feature").` }) }));
6129
- const baseRef = input.range.base.length === 0 ? "HEAD" : input.range.base;
6130
- const headRef = input.range.head.length === 0 ? "HEAD" : input.range.head;
6131
- for (const endpoint of [baseRef, headRef]) if (!isSafeGitRevision(endpoint)) return yield* Effect.fail(new ReactDoctorError({ reason: new GitBaseBranchInvalid({ detail: `Diff range "${input.raw}" has an invalid endpoint "${endpoint}" (${GIT_REF_NAME_RULE}).` }) }));
6132
- for (const endpoint of [baseRef, headRef]) if (!(yield* branchExists(input.directory, endpoint))) return yield* Effect.fail(new ReactDoctorError({ reason: new GitBaseBranchMissing({ branch: endpoint }) }));
6133
- let diffBaseRef = baseRef;
6134
- if (input.range.symmetric) {
6135
- const mergeBase = yield* runGit(input.directory, [
6136
- "merge-base",
6137
- baseRef,
6138
- headRef
6139
- ]);
6140
- if (mergeBase.status !== 0) return null;
6141
- const mergeBaseRef = trimOrNull(mergeBase.stdout);
6142
- if (mergeBaseRef === null) return null;
6143
- diffBaseRef = mergeBaseRef;
6144
- }
6145
- const diff = yield* runGit(input.directory, [
6146
- "diff",
6147
- "-z",
6148
- "--name-only",
6149
- "--diff-filter=ACMR",
6150
- "--relative",
6151
- diffBaseRef,
6152
- headRef
6153
- ]);
6154
- if (diff.status !== 0) return null;
6155
- return {
6156
- currentBranch: headRef,
6157
- baseBranch: baseRef,
6158
- changedFiles: splitNullSeparated(diff.stdout),
6159
- isCurrentChanges: false
6160
- };
6161
- });
6162
6089
  return Git.of({
6163
6090
  currentBranch,
6164
6091
  defaultBranch,
@@ -6168,15 +6095,7 @@ var Git = class Git extends Context.Service()("react-doctor/Git") {
6168
6095
  branchExists,
6169
6096
  diffSelection: ({ directory, explicitBaseBranch }) => Effect.gen(function* () {
6170
6097
  if (explicitBaseBranch !== void 0 && explicitBaseBranch.trim().length === 0) return yield* Effect.fail(new ReactDoctorError({ reason: new GitBaseBranchInvalid({ detail: "Diff base branch cannot be empty." }) }));
6171
- if (explicitBaseBranch !== void 0) {
6172
- const range = parseGitDiffRange(explicitBaseBranch);
6173
- if (range !== null) return yield* resolveDiffRange({
6174
- directory,
6175
- range,
6176
- raw: explicitBaseBranch
6177
- });
6178
- if (!isSafeGitRevision(explicitBaseBranch)) return yield* Effect.fail(new ReactDoctorError({ reason: new GitBaseBranchInvalid({ detail: `Diff base branch "${explicitBaseBranch}" is not a valid git ref name (${GIT_REF_NAME_RULE}).` }) }));
6179
- }
6098
+ if (explicitBaseBranch !== void 0 && !isSafeGitRevision(explicitBaseBranch)) return yield* Effect.fail(new ReactDoctorError({ reason: new GitBaseBranchInvalid({ detail: `Diff base branch "${explicitBaseBranch}" is not a valid git ref name (must match [A-Za-z0-9_./-] without leading '-', '..', or '@{').` }) }));
6180
6099
  const resolvedCurrentBranch = yield* currentBranch(directory);
6181
6100
  if (resolvedCurrentBranch === null && explicitBaseBranch === void 0) return null;
6182
6101
  const baseBranch = explicitBaseBranch ?? (yield* defaultBranch(directory));
@@ -8534,13 +8453,12 @@ const buildSkippedChecks = (input) => {
8534
8453
  * Git service runs through Effect's `ChildProcess` (true subprocess
8535
8454
  * spawn, not `spawnSync`).
8536
8455
  *
8537
- * Failures propagate as the tagged `ReactDoctorError` (rejected by
8538
- * `Effect.runPromise`) rather than being flattened into a plain
8539
- * `Error`. The message is unchanged — `ReactDoctorError.message`
8540
- * defers to `reason.message` — so message-matching callers keep
8541
- * working, while the CLI can now dispatch on `error.reason._tag` to
8542
- * render diff-base mistakes (`GitBaseBranchInvalid` /
8543
- * `GitBaseBranchMissing`) as clean user errors instead of crashes.
8456
+ * Tagged-reason errors are dispatched via `Effect.catchReasons`
8457
+ * (a v4-native API for narrowing inside a `Schema.TaggedErrorClass`
8458
+ * union without manual `instanceof` checks). The recovered branches
8459
+ * raise plain `Error`s so existing thrown-class consumers continue
8460
+ * to work — anything else (real `GitInvocationFailed`, etc.)
8461
+ * propagates as the tagged `ReactDoctorError` through `Effect.runPromise`.
8544
8462
  */
8545
8463
  const getDiffInfo = (directory, explicitBaseBranch) => Effect.runPromise(Effect.gen(function* () {
8546
8464
  const selection = yield* (yield* Git).diffSelection({
@@ -8554,7 +8472,10 @@ const getDiffInfo = (directory, explicitBaseBranch) => Effect.runPromise(Effect.
8554
8472
  changedFiles: [...selection.changedFiles],
8555
8473
  ...selection.isCurrentChanges ? { isCurrentChanges: true } : {}
8556
8474
  };
8557
- }).pipe(Effect.provide(Git.layerNode)));
8475
+ }).pipe(Effect.provide(Git.layerNode), Effect.catchReasons("ReactDoctorError", {
8476
+ GitBaseBranchInvalid: (reason) => Effect.die(new Error(reason.detail)),
8477
+ GitBaseBranchMissing: (reason) => Effect.die(new Error(reason.message))
8478
+ })));
8558
8479
  const filterSourceFiles = (filePaths) => filePaths.filter(isLintableSourceFile);
8559
8480
  var import_picocolors = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
8560
8481
  let p = process || {}, argv = p.argv || [], env = p.env || {};
@@ -8699,4 +8620,4 @@ const toJsonReport = (result, options) => buildJsonReport({
8699
8620
  export { AmbiguousProjectError, NoReactDependencyError, NotADirectoryError, PackageJsonNotFoundError, ProjectNotFoundError, ReactDoctorError, buildJsonReport, buildJsonReportError, clearCaches, diagnose, filterSourceFiles, getDiffInfo, isProjectDiscoveryError, isReactDoctorError, summarizeDiagnostics, toJsonReport };
8700
8621
 
8701
8622
  //# sourceMappingURL=index.js.map
8702
- //# debugId=4536fc6c-0d5d-50d5-83e0-910624b3a687
8623
+ //# debugId=df20b0d3-9e4e-52e0-8991-ce8a6349a04a
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-doctor",
3
- "version": "0.2.15-dev.01ec05c",
3
+ "version": "0.2.15-dev.3fae9dd",
4
4
  "description": "Diagnose and fix React codebases for security, performance, correctness, accessibility, bundle-size, and architecture issues",
5
5
  "keywords": [
6
6
  "accessibility",
@@ -63,7 +63,7 @@
63
63
  "oxlint": "^1.66.0",
64
64
  "prompts": "^2.4.2",
65
65
  "typescript": ">=5.0.4 <7",
66
- "oxlint-plugin-react-doctor": "0.2.15-dev.01ec05c"
66
+ "oxlint-plugin-react-doctor": "0.2.15-dev.3fae9dd"
67
67
  },
68
68
  "devDependencies": {
69
69
  "@types/babel__code-frame": "^7.27.0",