@dev.fast/whiteboard 0.3.3 → 0.3.4-preview.20261019.125

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.
Files changed (115) hide show
  1. package/dist/{account-alias-xOdmMnDH.js → account-alias-ClRtWF_-.js} +8 -6
  2. package/dist/{agent-cli-DT7MdaqL.js → agent-cli-C6AM9dml.js} +15 -10
  3. package/dist/agent-cli-DKpWo-4F.js +2 -0
  4. package/dist/{agent-client-BRBzv3AV.js → agent-client-G4KxB8zB.js} +13 -3
  5. package/dist/{authoring-tools-DGSEag8y.js → authoring-tools-Dfo0uOSj.js} +34 -27
  6. package/dist/{background-server-WKzI_a98.js → background-server-BF_lLFxY.js} +5 -5
  7. package/dist/{background-server-C_REWFkG.js → background-server-DJfYWRoN.js} +1 -1
  8. package/dist/build-info.json +1 -1
  9. package/dist/{cli-BBSDi_dX.js → cli-CqOiiTW_.js} +1 -1
  10. package/dist/{cli-runner-DshTBske.js → cli-runner-D8CsXff4.js} +26 -26
  11. package/dist/cli.js +2 -2
  12. package/dist/{client-BN_FDxFr.js → client-lKVF_Elo.js} +253 -47
  13. package/dist/{fuzzy-match-bFX6wm8j.js → fuzzy-match-DH9lZivo.js} +42 -14
  14. package/dist/{headless-host-CS4Gv0c5.js → headless-host-C4bhVPZx.js} +513 -140
  15. package/dist/{headless-host-CzvYpKOX.js → headless-host-CeNnXxiL.js} +1 -1
  16. package/dist/lens-selection-CyJapcsl.js +214 -0
  17. package/dist/{local-data-DtQTIzHX.js → local-data-BdqqCYUD.js} +2434 -328
  18. package/dist/{mcp-DpKnnmHH.js → mcp-B2mvDEhC.js} +5 -9
  19. package/dist/{package-paths-jMg6JxDP.js → package-paths-Cm1tR8c4.js} +1 -1
  20. package/dist/{profile-DaqmODhc.js → profile-DcigfSms.js} +20 -8
  21. package/dist/profile-DthRnZ7x.js +2 -0
  22. package/dist/{remote-attach-DCngg8cl.js → remote-attach-DGwVRmY5.js} +4 -4
  23. package/dist/{remote-extensions-BCAbQZTv.js → remote-extensions-CferWwM9.js} +3 -3
  24. package/dist/{remote-extensions-Cf3L-ZGG.js → remote-extensions-D8W2IgKH.js} +1 -1
  25. package/dist/{remote-language-server-UWQgpoh-.js → remote-language-server-By-rEosC.js} +5 -5
  26. package/dist/{remote-uninstall-CcDOcGyi.js → remote-uninstall-DgHnDAFH.js} +6 -6
  27. package/dist/{request-origin-Zcn_CjX4.js → request-origin-DDmfnytX.js} +38 -10
  28. package/dist/{review-app-launcher-tqSQPlbu.js → review-app-launcher-CG3TFZEx.js} +2 -2
  29. package/dist/{review-home-paths-Lc02WFuX.js → review-home-paths-D1JVitqN.js} +19 -17
  30. package/dist/{review-telemetry-BHWJsnoD.js → review-telemetry-Myzm7o6-.js} +5 -5
  31. package/dist/runtime-Bj2tD33R.js +27 -0
  32. package/dist/runtime.d.ts +1 -1
  33. package/dist/runtime.js +1 -1
  34. package/dist/{s3-77-qkEhs.js → s3-DtJFWC0G.js} +1 -1
  35. package/dist/{s3-config-DDWWMh5x.js → s3-config-BTO12tCC.js} +1 -1
  36. package/dist/{s3-config-0xuCh-F_.js → s3-config-CSy3fx8H.js} +1 -1
  37. package/dist/server/desktop-host.js +29 -76
  38. package/dist/{server-discovery-BVqrE1_-.js → server-discovery-Bwa_6Tsj.js} +3 -3
  39. package/dist/sharing/index.d.ts +486 -70
  40. package/dist/sharing/index.js +1 -1
  41. package/dist/{src-DsM3jO8G.js → src-BiWNbcF_.js} +89 -12
  42. package/dist/{src-BMPuxWv4.js → src-WPaQn75m.js} +208 -73
  43. package/dist/{stored-document-migration-CChxtFAy.js → stored-document-migration-dFbewRTG.js} +270 -269
  44. package/dist/{thread-state-5pYr6_zM.js → thread-state-Do5LX10I.js} +7 -2
  45. package/dist/{tool-failure-BFt2xj9i.js → tool-failure-C9J3r7KD.js} +10 -3
  46. package/instructions/authoring.md +3 -2
  47. package/package.json +4 -4
  48. package/src/agent-connect.ts +8 -2
  49. package/src/ask/agents.ts +51 -9
  50. package/src/ask/checkout-files.ts +2 -5
  51. package/src/ask/thread-state.ts +4 -0
  52. package/src/ask/thread.ts +16 -0
  53. package/src/ask/threads.ts +24 -3
  54. package/src/cli-runner.ts +4 -1
  55. package/src/diff-selection-migration.ts +48 -34
  56. package/src/heading-anchors.ts +42 -0
  57. package/src/lens-selection.ts +38 -2
  58. package/src/review-api/README.md +52 -13
  59. package/src/review-api/activity.ts +1 -4
  60. package/src/review-api/agent-cli.ts +9 -1
  61. package/src/review-api/anchor-quotes.ts +14 -7
  62. package/src/review-api/ask-history.ts +137 -51
  63. package/src/review-api/authoring-tools.ts +45 -30
  64. package/src/review-api/blocks/definition.ts +1 -1
  65. package/src/review-api/blocks/markdown.ts +2 -2
  66. package/src/review-api/board-order.ts +144 -0
  67. package/src/review-api/checkout-groups.ts +560 -0
  68. package/src/review-api/document-headings.ts +58 -27
  69. package/src/review-api/document-text.ts +31 -2
  70. package/src/review-api/document.ts +281 -34
  71. package/src/review-api/foreign-references.ts +328 -0
  72. package/src/review-api/github-provider.ts +51 -13
  73. package/src/review-api/http.ts +702 -123
  74. package/src/review-api/instructions.ts +0 -19
  75. package/src/review-api/link-preview.ts +113 -0
  76. package/src/review-api/local-data.ts +310 -46
  77. package/src/review-api/mcp.ts +3 -11
  78. package/src/review-api/onboarding.ts +1 -1
  79. package/src/review-api/profile.ts +37 -6
  80. package/src/review-api/public-tools.ts +24 -2
  81. package/src/review-api/pull-request.ts +82 -49
  82. package/src/review-api/request-origin.ts +10 -0
  83. package/src/review-api/review-progress.ts +61 -27
  84. package/src/review-api/scratchpad-plan-upgrade.ts +250 -0
  85. package/src/review-api/store-migrations.ts +357 -0
  86. package/src/review-api/store-schema.ts +38 -29
  87. package/src/review-api/store.ts +2144 -480
  88. package/src/review-api/workspaces.ts +52 -13
  89. package/src/review-api/worktree-events.ts +3 -5
  90. package/src/review-api/worktree-source.ts +3 -7
  91. package/src/review-api/worktree-structural.integration.ts +72 -0
  92. package/src/review-stack.ts +15 -23
  93. package/src/runtime.ts +4 -30
  94. package/src/server/desktop-host.ts +6 -1
  95. package/src/server/desktop-server.ts +1 -31
  96. package/src/server/headless-host.ts +0 -2
  97. package/src/server/hono-http.ts +2 -1
  98. package/src/server/legacy-tutorial-cleanup.ts +2 -3
  99. package/src/server/review-gateway-list.ts +3 -5
  100. package/src/server/review-gateway-memory.ts +1 -1
  101. package/src/server/review-lifecycle-telemetry.ts +2 -2
  102. package/src/server/review-server-core.ts +1 -5
  103. package/src/server/structural-comparisons.ts +47 -0
  104. package/src/sharing/export.ts +36 -7
  105. package/src/sharing/host.ts +34 -14
  106. package/src/sharing/import.ts +156 -24
  107. package/src/sharing/repository.ts +128 -20
  108. package/src/startup-trace.ts +3 -3
  109. package/src/stored-document-migration.ts +110 -19
  110. package/src/ui-telemetry-events.ts +25 -9
  111. package/dist/agent-cli-DeCrUC2s.js +0 -2
  112. package/dist/profile-Cz7L781D.js +0 -2
  113. package/dist/runtime-CKiWhGrf.js +0 -52
  114. package/instructions/scratchpad.md +0 -23
  115. package/src/review-preferences.ts +0 -88
@@ -1,2 +1,2 @@
1
- import { a as sharedReviewId, c as verifyShareRepository, i as SharedReviewStore, l as exportShare, n as ShareClient, o as validateShareBundle } from "../client-BN_FDxFr.js";
1
+ import { a as sharedReviewId, c as verifyShareRepository, i as SharedReviewStore, l as exportShare, n as ShareClient, o as validateShareBundle } from "../client-lKVF_Elo.js";
2
2
  export { ShareClient, SharedReviewStore, exportShare, sharedReviewId, validateShareBundle, verifyShareRepository };
@@ -177,6 +177,12 @@ z.union([StructuralDiffEventSchema, ReviewStructuralDiffErrorSchema]);
177
177
  const REVIEW_CLIENT_HEADER = "x-review-client";
178
178
  const REVIEW_CLIENT_REMOTE = "remote";
179
179
  const REVIEW_HOST_HEADER = "x-review-host";
180
+ const PULL_REQUEST_STATES = [
181
+ "open",
182
+ "draft",
183
+ "merged",
184
+ "closed"
185
+ ];
180
186
  const requiredString$1 = z.string({ error: "must be a string" }).refine((value) => value.trim().length > 0, "must be a string");
181
187
  const stringAllowEmpty = z.string({ error: "must be a string" });
182
188
  const positiveInteger = z.number({ error: "must be a positive integer" }).int("must be a positive integer").positive("must be a positive integer");
@@ -405,9 +411,38 @@ const ReviewStackLayerSchema = z.strictObject({
405
411
  "earlier",
406
412
  "current",
407
413
  "later"
408
- ])
414
+ ]),
415
+ /** The layer's PR state, as last read from GitHub. */
416
+ pullRequestState: z.enum(PULL_REQUEST_STATES).optional()
417
+ });
418
+ z.strictObject({
419
+ /** Bottom first. */
420
+ layers: z.array(ReviewStackLayerSchema),
421
+ /** The branch the stack sits on, as `main`. */
422
+ base: requiredString$1.optional()
423
+ });
424
+ const ReviewPlaceBoardSchema = z.strictObject({
425
+ reviewId: requiredString$1,
426
+ title: stringAllowEmpty,
427
+ icon: z.enum(["board", "code"])
428
+ });
429
+ const ReviewPlaceSiblingSchema = ReviewPlaceBoardSchema.extend({
430
+ pullRequestNumber: positiveInteger.optional(),
431
+ pullRequestState: z.enum(PULL_REQUEST_STATES).optional()
432
+ });
433
+ z.strictObject({
434
+ /** The board's PR state and branches, as last read from GitHub. */
435
+ pullRequestState: z.enum(PULL_REQUEST_STATES).optional(),
436
+ baseBranch: requiredString$1.optional(),
437
+ headBranch: requiredString$1.optional(),
438
+ /** The board itself. */
439
+ board: ReviewPlaceBoardSchema.optional(),
440
+ parent: ReviewPlaceBoardSchema.optional(),
441
+ /** Empty for a top-level board. */
442
+ siblings: z.array(ReviewPlaceSiblingSchema),
443
+ /** A top-level board's children in sibling order; absent for a child. */
444
+ children: z.array(ReviewPlaceSiblingSchema).optional()
409
445
  });
410
- z.strictObject({ layers: z.array(ReviewStackLayerSchema) });
411
446
  const ReviewCliInstallTargetSchema = z.enum([
412
447
  "claude",
413
448
  "codex",
@@ -673,13 +708,7 @@ const revealArgsSchema = z.strictObject({
673
708
  path: ["endLine"]
674
709
  });
675
710
  });
676
- /** The one scratchpad's fixed review id. */
677
- const SCRATCHPAD_REVIEW_ID = "scratchpad";
678
- const apiReviewIdSchema = z.union([
679
- z.uuid(),
680
- z.string().regex(/^shared-[a-f0-9]{64}$/),
681
- z.literal(SCRATCHPAD_REVIEW_ID)
682
- ]);
711
+ const apiReviewIdSchema = z.union([z.uuid(), z.string().regex(/^shared-[a-f0-9]{64}$/)]);
683
712
  const ReviewVerbRequestSchema = z.discriminatedUnion("name", [
684
713
  z.strictObject({
685
714
  name: z.literal("authoringCapabilities"),
@@ -727,7 +756,9 @@ const ReviewVerbRequestSchema = z.discriminatedUnion("name", [
727
756
  name: z.literal("openReview"),
728
757
  args: z.strictObject({
729
758
  reviewUuid: apiReviewIdSchema,
730
- active: z.boolean()
759
+ active: z.boolean(),
760
+ /** Block to scroll to after opening. */
761
+ blockId: requiredString$1.optional()
731
762
  })
732
763
  }),
733
764
  z.strictObject({
@@ -797,7 +828,38 @@ z.discriminatedUnion("event", [
797
828
  }),
798
829
  z.strictObject({
799
830
  event: z.literal("showReviewView"),
800
- view: reviewViewSchema
831
+ view: reviewViewSchema,
832
+ /** The board to switch, from its sidebar; else the one asking. */
833
+ reviewId: requiredString$1.optional()
834
+ }),
835
+ z.strictObject({
836
+ event: z.literal("revealBlock"),
837
+ reviewId: requiredString$1,
838
+ blockId: requiredString$1
839
+ }),
840
+ z.strictObject({
841
+ event: z.literal("selectLens"),
842
+ reviewId: requiredString$1,
843
+ lensId: requiredString$1.nullable()
844
+ }),
845
+ z.strictObject({
846
+ event: z.literal("markLens"),
847
+ reviewId: requiredString$1,
848
+ lensId: requiredString$1
849
+ }),
850
+ z.strictObject({
851
+ event: z.literal("pickCommit"),
852
+ reviewId: requiredString$1,
853
+ commit: requiredString$1.nullable()
854
+ }),
855
+ z.strictObject({
856
+ event: z.literal("openAskThread"),
857
+ reviewId: requiredString$1,
858
+ threadId: requiredString$1
859
+ }),
860
+ z.strictObject({
861
+ event: z.literal("toggleAskColumn"),
862
+ reviewId: requiredString$1
801
863
  })
802
864
  ]);
803
865
  z.discriminatedUnion("ok", [z.strictObject({
@@ -1005,6 +1067,21 @@ function parseReviewBugReportResponse(value) {
1005
1067
  return ReviewBugReportResponseSchema.parse(value);
1006
1068
  }
1007
1069
  //#endregion
1070
+ //#region ../review-protocol/src/board-icons.ts
1071
+ /** A board has code attached when its target is commits, a PR or a working
1072
+ * tree, even one with nothing to compare. A plan's target is its project. */
1073
+ const boardIconKind = (target) => target && target.kind !== "project" ? "code" : "board";
1074
+ /** What a board with no title is called wherever its title shows. */
1075
+ const UNTITLED_BOARD = "Untitled";
1076
+ /**
1077
+ * A board's title as every surface shows it. A person's new board keeps an
1078
+ * empty title until they name it; it reads "Untitled" everywhere. A title
1079
+ * someone typed, "Untitled" included, shows as typed.
1080
+ */
1081
+ function boardTitle(title) {
1082
+ return title?.trim() ? title : UNTITLED_BOARD;
1083
+ }
1084
+ //#endregion
1008
1085
  //#region ../review-protocol/src/index.ts
1009
1086
  function parseReviewDesktopDiscovery(value) {
1010
1087
  return parseZod(ReviewDesktopDiscoverySchema, value);
@@ -1039,4 +1116,4 @@ function formatIssuePath(path) {
1039
1116
  return output;
1040
1117
  }
1041
1118
  //#endregion
1042
- export { ReviewSelectedDiffSchema as A, ReviewApiSelectionSourceSchema as C, ReviewFeedbackSchema as D, ReviewFeedbackContactSchema as E, reviewDiffrSummarizerInputSchema as M, decodeStructuralDiffEvent as N, ReviewGatewayHostSchema as O, structuralChangeCounts as P, REVIEW_THEME_CHOICES as S, ReviewConnectRequestSchema as T, REVIEW_REMOTE_AGENT_IDS as _, parseReviewVerbRequest as a, REVIEW_REMOTE_INSTALL_LOCK as b, ReviewBugReportMetaV2Schema as c, REVIEW_CLIENT_HEADER as d, REVIEW_CLIENT_REMOTE as f, REVIEW_HOST_HEADER as g, REVIEW_DIFF_LAYOUT_SCOPES as h, parseReviewDesktopVerbResult as i, SCRATCHPAD_REVIEW_ID as j, ReviewOnboardingRunRequestSchema as k, ReviewBugReportRequestSchema as l, REVIEW_DIFF_LAYOUTS as m, parseReviewDesktopDiscovery as n, parseReviewVerbResponse as o, REVIEW_CLI_INSTALL_TARGET_LABELS as p, parseReviewDesktopVerbFrame as r, parseZod as s, parseReviewCliInstallApplyRequest as t, parseReviewBugReportResponse as u, REVIEW_REMOTE_ATTACH_BEGIN as v, ReviewCliInstallStampSchema as w, REVIEW_REMOTE_WRAPPER_MARK as x, REVIEW_REMOTE_ATTACH_END as y };
1119
+ export { ReviewGatewayHostSchema as A, REVIEW_REMOTE_WRAPPER_MARK as C, ReviewConnectRequestSchema as D, ReviewCliInstallStampSchema as E, structuralChangeCounts as F, ReviewSelectedDiffSchema as M, reviewDiffrSummarizerInputSchema as N, ReviewFeedbackContactSchema as O, decodeStructuralDiffEvent as P, REVIEW_REMOTE_INSTALL_LOCK as S, ReviewApiSelectionSourceSchema as T, REVIEW_DIFF_LAYOUT_SCOPES as _, parseReviewVerbRequest as a, REVIEW_REMOTE_ATTACH_BEGIN as b, boardIconKind as c, ReviewBugReportRequestSchema as d, parseReviewBugReportResponse as f, REVIEW_DIFF_LAYOUTS as g, REVIEW_CLI_INSTALL_TARGET_LABELS as h, parseReviewDesktopVerbResult as i, ReviewOnboardingRunRequestSchema as j, ReviewFeedbackSchema as k, boardTitle as l, REVIEW_CLIENT_REMOTE as m, parseReviewDesktopDiscovery as n, parseReviewVerbResponse as o, REVIEW_CLIENT_HEADER as p, parseReviewDesktopVerbFrame as r, parseZod as s, parseReviewCliInstallApplyRequest as t, ReviewBugReportMetaV2Schema as u, REVIEW_HOST_HEADER as v, REVIEW_THEME_CHOICES as w, REVIEW_REMOTE_ATTACH_END as x, REVIEW_REMOTE_AGENT_IDS as y };
@@ -684,22 +684,179 @@ var import_lib = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((export
684
684
  }
685
685
  module.exports = gitUrlParse;
686
686
  })))(), 1);
687
+ /** A quick query: a ref, a config value, a status. */
688
+ const QUICK_TIMEOUT_MS = 3e4;
689
+ /** A read that grows with the repository or a file in it, or a jj call. */
690
+ const LARGE_READ_TIMEOUT_MS = 3e5;
691
+ /** Talking to a remote. */
692
+ const NETWORK_TIMEOUT_MS = 6e5;
693
+ const NETWORK_COMMANDS = /* @__PURE__ */ new Set([
694
+ "fetch",
695
+ "clone",
696
+ "pull",
697
+ "push"
698
+ ]);
699
+ const LARGE_READS = /* @__PURE__ */ new Set([
700
+ "archive",
701
+ "blame",
702
+ "cat-file",
703
+ "diff",
704
+ "diff-tree",
705
+ "format-patch",
706
+ "grep",
707
+ "log",
708
+ "ls-files",
709
+ "ls-tree",
710
+ "rev-list",
711
+ "show"
712
+ ]);
713
+ /** The subcommand, past git's global options and their values. */
714
+ function subcommand(args) {
715
+ for (let i = 0; i < args.length; i++) {
716
+ const arg = args[i];
717
+ if ([
718
+ "-C",
719
+ "-c",
720
+ "--git-dir",
721
+ "--work-tree",
722
+ "-R"
723
+ ].includes(arg)) i++;
724
+ else if (!arg.startsWith("-")) return arg;
725
+ }
726
+ }
727
+ /** How long a call may run when its caller doesn't say. */
728
+ function defaultVcsTimeout(tool, args) {
729
+ const command = subcommand(args);
730
+ if (command && NETWORK_COMMANDS.has(command)) return NETWORK_TIMEOUT_MS;
731
+ if (tool === "jj" || command && LARGE_READS.has(command)) return LARGE_READ_TIMEOUT_MS;
732
+ return QUICK_TIMEOUT_MS;
733
+ }
734
+ const COMMIT_ID = /^(?:[a-f0-9]{40}|[a-f0-9]{64})$/;
735
+ /** Thrown before anything runs when an operand could be misread. */
736
+ var VcsOperandError = class extends Error {};
737
+ function refused(kind, value) {
738
+ throw new VcsOperandError(`Refusing ${kind} ${JSON.stringify(value)}.`);
739
+ }
740
+ /** Whether a value could be read as an option, or carries a control
741
+ * character or a line break. */
742
+ const unsafe = (value) => !value || value.startsWith("-") || /[\0-\x1f\x7f]/.test(value);
743
+ const unsafeRef = (value) => unsafe(value) || /[\s:~^?*[\\]|\.\.|@\{/.test(value);
744
+ function checkRefSide(value) {
745
+ if (!COMMIT_ID.test(value) && unsafeRef(value)) refused("ref", value);
746
+ }
747
+ /** Operands are objects; flags written in the code are strings. */
748
+ const isOperand = (arg) => Object(arg) === arg;
749
+ /** The arguments as the process gets them: operands checked, so none can
750
+ * be read as an option, and paths after `--`. (`--end-of-options` would say
751
+ * the same to git, but older gits refuse it in some commands.) */
752
+ function renderVcsArgs(args) {
753
+ const out = [];
754
+ let paths = false;
755
+ for (const arg of args) {
756
+ if (!isOperand(arg)) {
757
+ if (arg === "--") paths = true;
758
+ out.push(arg);
759
+ continue;
760
+ }
761
+ if ("path" in arg) {
762
+ if (!arg.path || /\0/.test(arg.path)) refused("path", arg.path);
763
+ if (!paths) {
764
+ out.push("--");
765
+ paths = true;
766
+ }
767
+ out.push(arg.path);
768
+ continue;
769
+ }
770
+ let rendered;
771
+ if ("commit" in arg) {
772
+ if (!COMMIT_ID.test(arg.commit)) refused("commit", arg.commit);
773
+ rendered = arg.commit;
774
+ } else if ("rev" in arg) {
775
+ if (unsafe(arg.rev)) refused("revision", arg.rev);
776
+ rendered = arg.rev;
777
+ } else if ("ref" in arg) {
778
+ if (unsafeRef(arg.ref)) refused("ref", arg.ref);
779
+ rendered = arg.ref;
780
+ } else if ("refspec" in arg) {
781
+ checkRefSide(arg.refspec.from);
782
+ checkRefSide(arg.refspec.to);
783
+ rendered = `${arg.refspec.force ? "+" : ""}${arg.refspec.from}:${arg.refspec.to}`;
784
+ } else if ("remote" in arg) {
785
+ if (unsafe(arg.remote) || /\s/.test(arg.remote)) refused("remote", arg.remote);
786
+ rendered = arg.remote;
787
+ } else {
788
+ if (unsafe(arg.value)) refused("value", arg.value);
789
+ rendered = arg.value;
790
+ }
791
+ out.push(rendered);
792
+ }
793
+ return out;
794
+ }
795
+ const LOCAL_GIT_ENV_KEYS = [
796
+ "GIT_ALTERNATE_OBJECT_DIRECTORIES",
797
+ "GIT_COMMON_DIR",
798
+ "GIT_CONFIG",
799
+ "GIT_CONFIG_COUNT",
800
+ "GIT_CONFIG_PARAMETERS",
801
+ "GIT_DIR",
802
+ "GIT_GRAFT_FILE",
803
+ "GIT_IMPLICIT_WORK_TREE",
804
+ "GIT_INDEX_FILE",
805
+ "GIT_INTERNAL_SUPER_PREFIX",
806
+ "GIT_NO_REPLACE_OBJECTS",
807
+ "GIT_OBJECT_DIRECTORY",
808
+ "GIT_PREFIX",
809
+ "GIT_QUARANTINE_PATH",
810
+ "GIT_REPLACE_REF_BASE",
811
+ "GIT_SHALLOW_FILE",
812
+ "GIT_WORK_TREE"
813
+ ];
814
+ /** The process environment without the variables that would redirect git
815
+ * to another repository's objects, index or work tree. */
816
+ function localGitEnvironment() {
817
+ const env = { ...process.env };
818
+ for (const key of LOCAL_GIT_ENV_KEYS) delete env[key];
819
+ return env;
820
+ }
821
+ /** The environment a version-control process runs with. A git call that
822
+ * names its repository (`-C`, `--git-dir`) and brings no environment of its
823
+ * own drops the variables that would redirect it to another. */
824
+ function vcsEnvironment(tool, args, env) {
825
+ const next = { ...env ?? (tool === "git" && (args[0] === "-C" || args[0] === "--git-dir") ? localGitEnvironment() : process.env) };
826
+ if (!args.some((arg) => [
827
+ "fetch",
828
+ "clone",
829
+ "pull",
830
+ "push"
831
+ ].includes(arg))) next.GIT_NO_LAZY_FETCH = "1";
832
+ next.GIT_TERMINAL_PROMPT = "0";
833
+ next.GH_PROMPT_DISABLED = "1";
834
+ return next;
835
+ }
687
836
  let observer = null;
688
837
  function setLocalVcsCommandObserver(next) {
689
838
  observer = next;
690
839
  }
691
840
  const execFilePromise = promisify(execFile);
692
- async function execFileAsync(file, args, options = {}) {
841
+ async function runVcs(tool, vcsArgs, { input, ...options } = {}) {
842
+ const args = renderVcsArgs(vcsArgs);
693
843
  const finish = observer?.start({
694
- file,
844
+ tool,
695
845
  args,
696
846
  cwd: options.cwd === void 0 ? void 0 : String(options.cwd)
697
847
  });
698
848
  try {
699
- const result = await execFilePromise(file, args, {
849
+ const running = execFilePromise(tool, args, {
700
850
  ...options,
851
+ env: vcsEnvironment(tool, args, options.env),
852
+ timeout: options.timeout ?? defaultVcsTimeout(tool, args),
701
853
  encoding: options.encoding ?? "utf8"
702
854
  });
855
+ if (input !== void 0) {
856
+ running.child.stdin?.on("error", () => {});
857
+ running.child.stdin?.end(input);
858
+ }
859
+ const result = await running;
703
860
  finish?.({ ok: true });
704
861
  return {
705
862
  stdout: String(result.stdout),
@@ -710,14 +867,19 @@ async function execFileAsync(file, args, options = {}) {
710
867
  throw error;
711
868
  }
712
869
  }
713
- function execFileSyncObserved(file, args, options) {
870
+ function runVcsSync(tool, vcsArgs, options) {
871
+ const args = renderVcsArgs(vcsArgs);
714
872
  const finish = observer?.start({
715
- file,
873
+ tool,
716
874
  args,
717
875
  cwd: options.cwd === void 0 ? void 0 : String(options.cwd)
718
876
  });
719
877
  try {
720
- const output = execFileSync(file, args, options);
878
+ const output = execFileSync(tool, args, {
879
+ ...options,
880
+ env: vcsEnvironment(tool, args, options.env),
881
+ timeout: options.timeout ?? defaultVcsTimeout(tool, args)
882
+ });
721
883
  finish?.({ ok: true });
722
884
  return String(output);
723
885
  } catch (error) {
@@ -726,14 +888,18 @@ function execFileSyncObserved(file, args, options) {
726
888
  }
727
889
  }
728
890
  /** Long-lived child; the observer sees one spawn, completed once the process is up. */
729
- function spawnObserved(file, args, options) {
891
+ function spawnObserved(tool, vcsArgs, options) {
892
+ const args = renderVcsArgs(vcsArgs);
730
893
  const finish = observer?.start({
731
- file,
894
+ tool,
732
895
  args,
733
896
  cwd: options.cwd === void 0 ? void 0 : String(options.cwd)
734
897
  });
735
898
  try {
736
- const child = spawn(file, args, options);
899
+ const child = spawn(tool, args, {
900
+ ...options,
901
+ env: vcsEnvironment(tool, args, options.env)
902
+ });
737
903
  let finished = false;
738
904
  const complete = (ok) => {
739
905
  if (finished) return;
@@ -1013,25 +1179,6 @@ function normalizeEntry(entry) {
1013
1179
  }
1014
1180
  //#endregion
1015
1181
  //#region ../local-vcs/src/vcs.ts
1016
- const LOCAL_GIT_ENV_KEYS = [
1017
- "GIT_ALTERNATE_OBJECT_DIRECTORIES",
1018
- "GIT_COMMON_DIR",
1019
- "GIT_CONFIG",
1020
- "GIT_CONFIG_COUNT",
1021
- "GIT_CONFIG_PARAMETERS",
1022
- "GIT_DIR",
1023
- "GIT_GRAFT_FILE",
1024
- "GIT_IMPLICIT_WORK_TREE",
1025
- "GIT_INDEX_FILE",
1026
- "GIT_INTERNAL_SUPER_PREFIX",
1027
- "GIT_NO_REPLACE_OBJECTS",
1028
- "GIT_OBJECT_DIRECTORY",
1029
- "GIT_PREFIX",
1030
- "GIT_QUARANTINE_PATH",
1031
- "GIT_REPLACE_REF_BASE",
1032
- "GIT_SHALLOW_FILE",
1033
- "GIT_WORK_TREE"
1034
- ];
1035
1182
  /** Neither git nor jj could be started, so no folder can be recognized as a repository. */
1036
1183
  var LocalVcsToolsMissingError = class extends Error {
1037
1184
  constructor() {
@@ -1188,7 +1335,7 @@ async function gitArgs(rootPath, args) {
1188
1335
  /** Run git against the repo's shared git dir, optionally tolerating failure. */
1189
1336
  async function git(rootPath, args, options = {}) {
1190
1337
  try {
1191
- const { stdout, stderr } = await execFileAsync("git", await gitArgs(rootPath, args), {
1338
+ const { stdout, stderr } = await runVcs("git", await gitArgs(rootPath, args), {
1192
1339
  maxBuffer: 67108864,
1193
1340
  signal: options.signal
1194
1341
  });
@@ -1216,7 +1363,7 @@ async function git(rootPath, args, options = {}) {
1216
1363
  */
1217
1364
  async function gitAt(cwd, args, options = {}) {
1218
1365
  try {
1219
- const { stdout, stderr } = await execFileAsync("git", [
1366
+ const { stdout, stderr } = await runVcs("git", [
1220
1367
  "-C",
1221
1368
  cwd,
1222
1369
  ...args
@@ -1302,10 +1449,10 @@ function createLocalVcs(kind, rootPath) {
1302
1449
  async function jjRevisionIsConflicted(rootPath, revision) {
1303
1450
  if ((await detectLocalVcs(rootPath))?.kind !== "jj") return null;
1304
1451
  try {
1305
- const { stdout } = await execFileAsync("jj", [
1452
+ const { stdout } = await runVcs("jj", [
1306
1453
  "log",
1307
1454
  "-r",
1308
- revision,
1455
+ { rev: revision },
1309
1456
  "--no-graph",
1310
1457
  "-T",
1311
1458
  "if(conflict, \"true\", \"false\")",
@@ -1364,7 +1511,7 @@ async function listTrackedFilesAtCommit(input) {
1364
1511
  "list",
1365
1512
  "--ignore-working-copy",
1366
1513
  "-r",
1367
- input.commit
1514
+ { rev: input.commit }
1368
1515
  ], { cwd: input.rootPath }).catch(() => null);
1369
1516
  if (output !== null) return splitLines(output);
1370
1517
  if (!await canUseGitFallback(input.rootPath, input.kind)) return [];
@@ -1376,7 +1523,7 @@ async function listTrackedFilesAtCommit(input) {
1376
1523
  "-r",
1377
1524
  "-z",
1378
1525
  "--name-only",
1379
- input.commit
1526
+ { rev: input.commit }
1380
1527
  ], { cwd: input.rootPath }).catch(() => null);
1381
1528
  return output === null ? [] : output.split("\0").filter(Boolean);
1382
1529
  }
@@ -1401,7 +1548,7 @@ function listTrackedFilesForKind(input) {
1401
1548
  "-r",
1402
1549
  "-z",
1403
1550
  "--name-only",
1404
- input.ref
1551
+ { rev: input.ref }
1405
1552
  ], { cwd: input.rootPath }) : commandOutputSync("git", [
1406
1553
  "-C",
1407
1554
  input.rootPath,
@@ -1442,7 +1589,7 @@ async function readJjFileAtCommit(input) {
1442
1589
  "file",
1443
1590
  "show",
1444
1591
  "-r",
1445
- input.commit,
1592
+ { rev: input.commit },
1446
1593
  "--ignore-working-copy",
1447
1594
  "--",
1448
1595
  toJjRootFilePattern(input.relativePath)
@@ -1518,7 +1665,7 @@ async function withWorkingTreeIndex(input, read) {
1518
1665
  env.GIT_WORK_TREE = input.rootPath;
1519
1666
  }
1520
1667
  await fs.promises.mkdir(path.join(scratch, "objects"));
1521
- const git = (args) => execFileAsync("git", [
1668
+ const git = (args) => runVcs("git", [
1522
1669
  "-c",
1523
1670
  "core.splitIndex=false",
1524
1671
  "-C",
@@ -1530,7 +1677,7 @@ async function withWorkingTreeIndex(input, read) {
1530
1677
  maxBuffer: 33554432
1531
1678
  });
1532
1679
  if (input.kind === "git") {
1533
- const index = (await execFileAsync("git", [
1680
+ const index = (await runVcs("git", [
1534
1681
  "-C",
1535
1682
  input.rootPath,
1536
1683
  "rev-parse",
@@ -1600,7 +1747,7 @@ async function listCommitRange(input) {
1600
1747
  const vcs = await knownOrDetectedVcs(input.rootPath, input.kind);
1601
1748
  if (!vcs) throw new Error(`No Git or jj repository found for ${input.rootPath}.`);
1602
1749
  try {
1603
- const { stdout } = await execFileAsync("git", [
1750
+ const { stdout } = await runVcs("git", [
1604
1751
  "-C",
1605
1752
  vcs.rootPath,
1606
1753
  "log",
@@ -1608,7 +1755,7 @@ async function listCommitRange(input) {
1608
1755
  "--format=%H%x00%P%x00%an%x00%aI%x00%s%x00",
1609
1756
  "--numstat",
1610
1757
  "-z",
1611
- `${input.baseRef}..${input.headRef}`
1758
+ { rev: `${input.baseRef}..${input.headRef}` }
1612
1759
  ], {
1613
1760
  cwd: vcs.rootPath,
1614
1761
  maxBuffer: 26214400
@@ -1668,7 +1815,7 @@ async function readJjCommitRange(rootPath, baseRef, headRef) {
1668
1815
  "log",
1669
1816
  "--no-graph",
1670
1817
  "-r",
1671
- `::${headRef} ~ ::${baseRef}`,
1818
+ { rev: `::${headRef} ~ ::${baseRef}` },
1672
1819
  "-T",
1673
1820
  "commit_id ++ \"\\0\" ++ parents.map(|p| p.commit_id()).join(\" \") ++ \"\\0\" ++ author.name() ++ \"\\0\" ++ author.timestamp().format(\"%+\") ++ \"\\0\" ++ description.first_line() ++ \"\\0\"",
1674
1821
  "--ignore-working-copy"
@@ -1841,7 +1988,7 @@ function toNameStatusEntries(summary) {
1841
1988
  }))].sort((left, right) => left.path.localeCompare(right.path));
1842
1989
  }
1843
1990
  async function readGitDiffNameStatus(input) {
1844
- const refRange = input.mergeBase === false ? [input.baseRef, input.headRef] : [`${input.baseRef}...${input.headRef}`];
1991
+ const refRange = input.mergeBase === false ? [{ rev: input.baseRef }, { rev: input.headRef }] : [{ rev: `${input.baseRef}...${input.headRef}` }];
1845
1992
  return parseGitDiffNameStatus(await commandOutput("git", [
1846
1993
  "-C",
1847
1994
  input.rootPath,
@@ -1862,9 +2009,9 @@ async function readJjDiffNameStatus(input) {
1862
2009
  "diff",
1863
2010
  "--summary",
1864
2011
  "--from",
1865
- input.baseRef,
2012
+ { rev: input.baseRef },
1866
2013
  "--to",
1867
- input.headRef,
2014
+ { rev: input.headRef },
1868
2015
  "--ignore-working-copy"
1869
2016
  ], {
1870
2017
  cwd: input.rootPath,
@@ -1906,7 +2053,7 @@ async function resolveGitRevisionCommit(rootPath, revision) {
1906
2053
  rootPath,
1907
2054
  "rev-parse",
1908
2055
  "--verify",
1909
- `${revision}^{commit}`
2056
+ { rev: `${revision}^{commit}` }
1910
2057
  ]);
1911
2058
  }
1912
2059
  function resolveGitRevisionCommitSync(rootPath, revision) {
@@ -1915,7 +2062,7 @@ function resolveGitRevisionCommitSync(rootPath, revision) {
1915
2062
  rootPath,
1916
2063
  "rev-parse",
1917
2064
  "--verify",
1918
- `${revision}^{commit}`
2065
+ { rev: `${revision}^{commit}` }
1919
2066
  ]);
1920
2067
  }
1921
2068
  async function resolveJjRevisionCommit(rootPath, revision) {
@@ -1925,7 +2072,7 @@ async function resolveJjRevisionCommit(rootPath, revision) {
1925
2072
  "log",
1926
2073
  "--no-graph",
1927
2074
  "-r",
1928
- revision,
2075
+ { rev: revision },
1929
2076
  "-T",
1930
2077
  "commit_id ++ \"\\n\"",
1931
2078
  "--ignore-working-copy"
@@ -1938,7 +2085,7 @@ function resolveJjRevisionCommitSync(rootPath, revision) {
1938
2085
  "log",
1939
2086
  "--no-graph",
1940
2087
  "-r",
1941
- revision,
2088
+ { rev: revision },
1942
2089
  "-T",
1943
2090
  "commit_id ++ \"\\n\"",
1944
2091
  "--ignore-working-copy"
@@ -1955,8 +2102,8 @@ async function resolveGitMergeBase(rootPath, baseRef, headRef) {
1955
2102
  "-C",
1956
2103
  rootPath,
1957
2104
  "merge-base",
1958
- baseRef,
1959
- headRef
2105
+ { rev: baseRef },
2106
+ { rev: headRef }
1960
2107
  ]);
1961
2108
  }
1962
2109
  async function resolveJjMergeBase(rootPath, baseRef, headRef) {
@@ -1966,7 +2113,7 @@ async function resolveJjMergeBase(rootPath, baseRef, headRef) {
1966
2113
  "log",
1967
2114
  "--no-graph",
1968
2115
  "-r",
1969
- `heads(::${baseRef} & ::${headRef})`,
2116
+ { rev: `heads(::${baseRef} & ::${headRef})` },
1970
2117
  "-T",
1971
2118
  "commit_id ++ \"\n\"",
1972
2119
  "--ignore-working-copy"
@@ -1979,7 +2126,7 @@ function readGitFileAtRevisionSync(input) {
1979
2126
  "-C",
1980
2127
  input.rootPath,
1981
2128
  "show",
1982
- `${commit}:${input.relativePath}`
2129
+ { rev: `${commit}:${input.relativePath}` }
1983
2130
  ], {
1984
2131
  maxBuffer: 10485760,
1985
2132
  trim: false
@@ -1998,7 +2145,7 @@ function readJjFileAtRevisionSync(input) {
1998
2145
  "file",
1999
2146
  "show",
2000
2147
  "-r",
2001
- input.ref,
2148
+ { rev: input.ref },
2002
2149
  "--ignore-working-copy",
2003
2150
  "--",
2004
2151
  toJjRootFilePattern(input.relativePath)
@@ -2014,8 +2161,8 @@ function readJjFileAtRevisionSync(input) {
2014
2161
  }
2015
2162
  async function readGitDiff(input) {
2016
2163
  const paths = input.literalPaths ? input.paths ?? [] : normalizeDiffPaths(input.paths);
2017
- const diffRefs = input.headRef ? input.mergeBase === false ? [input.baseRef, input.headRef] : [`${input.baseRef}...${input.headRef}`] : [input.baseRef];
2018
- const { stdout } = await execFileAsync("git", [
2164
+ const diffRefs = input.headRef ? input.mergeBase === false ? [{ rev: input.baseRef }, { rev: input.headRef }] : [{ rev: `${input.baseRef}...${input.headRef}` }] : [{ rev: input.baseRef }];
2165
+ const { stdout } = await runVcs("git", [
2019
2166
  ...input.literalPaths ? ["--literal-pathspecs"] : [],
2020
2167
  "-C",
2021
2168
  input.rootPath,
@@ -2038,8 +2185,8 @@ async function readGitDiff(input) {
2038
2185
  }
2039
2186
  async function readGitDiffFileSummaries(input) {
2040
2187
  const paths = normalizeDiffPaths(input.paths);
2041
- const diffRefs = input.headRef ? input.mergeBase === false ? [input.baseRef, input.headRef] : [`${input.baseRef}...${input.headRef}`] : [input.baseRef];
2042
- const { stdout } = await execFileAsync("git", [
2188
+ const diffRefs = input.headRef ? input.mergeBase === false ? [{ rev: input.baseRef }, { rev: input.headRef }] : [{ rev: `${input.baseRef}...${input.headRef}` }] : [{ rev: input.baseRef }];
2189
+ const { stdout } = await runVcs("git", [
2043
2190
  "-C",
2044
2191
  input.rootPath,
2045
2192
  "diff",
@@ -2062,7 +2209,7 @@ async function readGitDiffFileSummaries(input) {
2062
2209
  }
2063
2210
  async function readJjDiff(input) {
2064
2211
  const paths = input.literalPaths ? input.paths ?? [] : normalizeDiffPaths(input.paths);
2065
- const { stdout } = await execFileAsync("jj", [
2212
+ const { stdout } = await runVcs("jj", [
2066
2213
  "-R",
2067
2214
  input.rootPath,
2068
2215
  "--color",
@@ -2294,18 +2441,16 @@ function commandOutputSync(command, args, options = {}) {
2294
2441
  return runCommandOutputSync(command, args, options);
2295
2442
  }
2296
2443
  function runCommandOutput(command, args, options) {
2297
- return execFileAsync(command, args, {
2444
+ return runVcs(command, args, {
2298
2445
  cwd: options.cwd,
2299
- env: commandEnvironment(command, args),
2300
2446
  maxBuffer: options.maxBuffer
2301
2447
  }).then(({ stdout }) => options.trim === false ? stdout : stdout.trim());
2302
2448
  }
2303
2449
  function runCommandOutputSync(command, args, options) {
2304
2450
  try {
2305
- const output = execFileSyncObserved(command, args, {
2451
+ const output = runVcsSync(command, args, {
2306
2452
  cwd: options.cwd,
2307
2453
  encoding: "utf8",
2308
- env: commandEnvironment(command, args),
2309
2454
  maxBuffer: options.maxBuffer,
2310
2455
  stdio: [
2311
2456
  "ignore",
@@ -2318,16 +2463,6 @@ function runCommandOutputSync(command, args, options) {
2318
2463
  return null;
2319
2464
  }
2320
2465
  }
2321
- function commandEnvironment(command, args) {
2322
- if (command !== "git" || args[0] !== "-C" && args[0] !== "--git-dir") return;
2323
- return localGitEnvironment();
2324
- }
2325
- /** Drop per-repository git env vars that would redirect an explicit object store. */
2326
- function localGitEnvironment() {
2327
- const env = { ...process.env };
2328
- for (const key of LOCAL_GIT_ENV_KEYS) delete env[key];
2329
- return env;
2330
- }
2331
2466
  //#endregion
2332
2467
  //#region ../../node_modules/graceful-fs/polyfills.js
2333
2468
  var require_polyfills = /* @__PURE__ */ __commonJSMin(((exports, module) => {
@@ -3678,4 +3813,4 @@ var require_adapter = /* @__PURE__ */ __commonJSMin(((exports, module) => {
3678
3813
  module.exports.checkSync = checkSync;
3679
3814
  })))();
3680
3815
  //#endregion
3681
- export { setLocalVcsCommandObserver as C, __toESM as E, splitGitPatchFiles as S, __require as T, parseGitRemote as _, diff as a, resolveRepoContextSync as b, diffFileSummariesWorkingTree as c, git as d, gitAt as f, listTrackedFilesAtCommit as g, listCommitRange as h, detectLocalVcs as i, diffTrees as l, jjRevisionIsConflicted as m, createBlobBatchReader as n, diffFileSummaries as o, gitCommonDir as p, defaultBranch as r, diffFileSummariesTrees as s, LocalVcsToolsMissingError as t, diffWorkingTree as u, readFileAtCommit as v, __commonJSMin as w, resolveRevision as x, resolveRepoContext as y };
3816
+ export { __require as A, resolveRevision as C, runVcsSync as D, runVcs as E, setLocalVcsCommandObserver as O, resolveRepoContextSync as S, renderVcsArgs as T, listTrackedFilesAtCommit as _, diff as a, readFileAtCommit as b, diffFileSummariesWorkingTree as c, git as d, gitAt as f, listCommitRange as g, jjRevisionIsConflicted as h, detectLocalVcs as i, __toESM as j, __commonJSMin as k, diffTrees as l, gitCommonDirSync as m, createBlobBatchReader as n, diffFileSummaries as o, gitCommonDir as p, defaultBranch as r, diffFileSummariesTrees as s, LocalVcsToolsMissingError as t, diffWorkingTree as u, parseGitRemote as v, splitGitPatchFiles as w, resolveRepoContext as x, parseGitRemoteSlug as y };