@cmmd-center/forge 0.13.143 → 0.13.145

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 (31) hide show
  1. package/dist/bin.cjs +107 -8
  2. package/dist/bin.mjs +131 -32
  3. package/dist/client/assets/{CanvasPanel-56JpVM3f.js → CanvasPanel-BeSvnc85.js} +2 -2
  4. package/dist/client/assets/{DiffPanel-pmakeIqK.js → DiffPanel-AFcxOGec.js} +2 -2
  5. package/dist/client/assets/{DiffPanel.logic-CvzRtf9Z.js → DiffPanel.logic-B6HwSAPK.js} +2 -2
  6. package/dist/client/assets/{DiffWorkerPoolProvider-bRo5fmip.js → DiffWorkerPoolProvider-CPaAxbdi.js} +2 -2
  7. package/dist/client/assets/{PullRequestCodePanel-zwJjqgbf.js → PullRequestCodePanel-D6FHc9jK.js} +2 -2
  8. package/dist/client/assets/{ThemeEditorPanel-BdgROB68.js → ThemeEditorPanel-BCJuZ6ai.js} +2 -2
  9. package/dist/client/assets/{Virtualizer-BGTVJkSt.js → Virtualizer-dYU21qI9.js} +2 -2
  10. package/dist/client/assets/{WorkerPoolContext-DWhPtVaq.js → WorkerPoolContext-CV6s1EQI.js} +2 -2
  11. package/dist/client/assets/{cmmdAuthRedirect-Cpw3QgrC.js → cmmdAuthRedirect-DRkKjx0G.js} +2 -2
  12. package/dist/client/assets/{cmmdForgeRuntimeListResource-Bg8MVxpi.js → cmmdForgeRuntimeListResource-Dms9ZD2I.js} +4 -4
  13. package/dist/client/assets/{currentForgeWorkspaceStore-Buphl0ru.js → currentForgeWorkspaceStore-H6HxAqJy.js} +2 -2
  14. package/dist/client/assets/{dialog-BSwJ44Xn.js → dialog-C0bK23D8.js} +2 -2
  15. package/dist/client/assets/index-DH8z2b5W.js +301 -0
  16. package/dist/client/assets/{popover-ZNCjh9sJ.js → popover-ClRgm7hB.js} +2 -2
  17. package/dist/client/assets/{scroll-area-By2Wg8Aw.js → scroll-area-BHqISEYq.js} +2 -2
  18. package/dist/client/assets/{sidebarV2CustomSnoozeDialog-B_dtRwFZ.js → sidebarV2CustomSnoozeDialog-lbAJoff_.js} +2 -2
  19. package/dist/client/assets/src-B_wrKHuq.js +3 -0
  20. package/dist/client/assets/{switch-opCmyrUy.js → switch-BWQHMJkU.js} +2 -2
  21. package/dist/client/assets/{themePalette-DchQFoHe.js → themePalette-BWvBK22X.js} +2 -2
  22. package/dist/client/assets/{toggle-CGX6qKVS.js → toggle-CORC1vE9.js} +2 -2
  23. package/dist/client/assets/{toggle-group-BRN0oZh2.js → toggle-group-C9nAr6VB.js} +2 -2
  24. package/dist/client/assets/{tooltip-Bh_PspOm.js → tooltip-CrS-TEbN.js} +2 -2
  25. package/dist/client/assets/{utils-MX9zGa4a.js → utils-xQJ3ak-X.js} +2 -2
  26. package/dist/client/index.html +18 -18
  27. package/dist/forge-build.json +1 -1
  28. package/dist/{open-2-reBrpv.mjs → open-yHTUkd2Y.mjs} +3 -3
  29. package/package.json +1 -1
  30. package/dist/client/assets/index-CVgA7DDp.js +0 -301
  31. package/dist/client/assets/src-e9jwz4Nc.js +0 -3
package/dist/bin.cjs CHANGED
@@ -18122,9 +18122,11 @@ const ThreadTurnStartBootstrapCreateThread = require_Schema$1.Struct({
18122
18122
  createdAt: IsoDateTime
18123
18123
  });
18124
18124
  const ThreadTurnStartBootstrapPrepareWorktree = require_Schema$1.Struct({
18125
- projectCwd: TrimmedNonEmptyString,
18125
+ projectId: require_Schema$1.optional(ProjectId),
18126
+ projectCwd: require_Schema$1.optional(TrimmedNonEmptyString),
18126
18127
  baseBranch: require_Schema$1.NullOr(TrimmedNonEmptyString),
18127
- branch: require_Schema$1.optional(TrimmedNonEmptyString)
18128
+ branch: require_Schema$1.optional(TrimmedNonEmptyString),
18129
+ startFromOrigin: require_Schema$1.optional(require_Schema$1.Boolean)
18128
18130
  });
18129
18131
  const ThreadTurnStartBootstrap = require_Schema$1.Struct({
18130
18132
  createThread: require_Schema$1.optional(ThreadTurnStartBootstrapCreateThread),
@@ -66431,7 +66433,7 @@ function normalizeNumberish(value) {
66431
66433
  }
66432
66434
  //#endregion
66433
66435
  //#region package.json
66434
- var version$1 = "0.13.143";
66436
+ var version$1 = "0.13.145";
66435
66437
  //#endregion
66436
66438
  //#region src/sentry.ts
66437
66439
  const SERVER_APP_NAME = "forge-server";
@@ -94617,14 +94619,62 @@ const dispatchBootstrapThreadCreate = (input) => require_Schema$1.gen(function*
94617
94619
  });
94618
94620
  return !threadAlreadyExists;
94619
94621
  });
94622
+ /** Reject a removed or unknown project before any Git operation uses its checkout. */
94623
+ const requireBootstrapProject = (input) => {
94624
+ const project = input.readModel.projects.find((candidate) => candidate.id === input.projectId);
94625
+ return project && project.deletedAt === null ? require_Schema$1.succeed(project) : require_Schema$1.fail(/* @__PURE__ */ new Error(`Worktree project '${input.projectId}' does not exist.`));
94626
+ };
94627
+ /** Require the target thread to be live before preparing its worktree. */
94628
+ const requireBootstrapThread = (input) => {
94629
+ const thread = input.readModel.threads.find((candidate) => candidate.id === input.threadId);
94630
+ return thread && thread.deletedAt === null ? require_Schema$1.succeed(thread) : require_Schema$1.fail(/* @__PURE__ */ new Error(`Worktree thread '${input.threadId}' does not exist.`));
94631
+ };
94632
+ /** Resolve a CMMD Work Session's checkout from Forge's persisted project identity. */
94633
+ const resolveAuthoritativeBootstrapProjectCwd = (input) => require_Schema$1.gen(function* () {
94634
+ const projectId = input.bootstrapWorktree.projectId;
94635
+ if (projectId === void 0) return yield* require_Schema$1.fail(/* @__PURE__ */ new Error("Missing project identity."));
94636
+ const project = yield* requireBootstrapProject({
94637
+ readModel: input.readModel,
94638
+ projectId
94639
+ });
94640
+ const thread = yield* requireBootstrapThread({
94641
+ readModel: input.readModel,
94642
+ threadId: input.command.threadId
94643
+ });
94644
+ if (thread.projectId !== projectId) return yield* require_Schema$1.fail(/* @__PURE__ */ new Error(`Worktree project '${projectId}' does not match thread project '${thread.projectId}'.`));
94645
+ const createdThreadProjectId = input.command.bootstrap?.createThread?.projectId;
94646
+ if (createdThreadProjectId && createdThreadProjectId !== projectId) return yield* require_Schema$1.fail(/* @__PURE__ */ new Error(`Worktree project '${projectId}' does not match created thread project '${createdThreadProjectId}'.`));
94647
+ if (input.bootstrapWorktree.branch === void 0) return yield* require_Schema$1.fail(/* @__PURE__ */ new Error("Authoritative worktree preparation requires a branch."));
94648
+ if (input.bootstrapWorktree.startFromOrigin && input.bootstrapWorktree.baseBranch !== "main") return yield* require_Schema$1.fail(/* @__PURE__ */ new Error("Authoritative Work Session worktrees must start from origin/main."));
94649
+ return project.workspaceRoot;
94650
+ });
94651
+ /** Keep legacy path-based commands working while routing identified projects through Forge records. */
94652
+ const resolveBootstrapProjectCwd = (input) => require_Schema$1.gen(function* () {
94653
+ const { bootstrapWorktree } = input;
94654
+ if (bootstrapWorktree.projectId === void 0) {
94655
+ if (!bootstrapWorktree.projectCwd) return yield* require_Schema$1.fail(/* @__PURE__ */ new Error("Worktree preparation requires a project checkout path."));
94656
+ return bootstrapWorktree.projectCwd;
94657
+ }
94658
+ return yield* resolveAuthoritativeBootstrapProjectCwd({
94659
+ readModel: yield* input.orchestrationEngine.getReadModel(),
94660
+ command: input.command,
94661
+ bootstrapWorktree
94662
+ });
94663
+ });
94620
94664
  const prepareBootstrapWorktree = (input) => require_Schema$1.gen(function* () {
94621
94665
  const bootstrapWorktree = input.command.bootstrap?.prepareWorktree;
94622
94666
  if (!bootstrapWorktree) return null;
94667
+ const projectCwd = yield* resolveBootstrapProjectCwd({
94668
+ orchestrationEngine: input.orchestrationEngine,
94669
+ command: input.command,
94670
+ bootstrapWorktree
94671
+ });
94623
94672
  const requestedAt = (/* @__PURE__ */ new Date()).toISOString();
94624
94673
  const baseBranchLabel = bootstrapWorktree.baseBranch ?? "<default>";
94625
94674
  const requestedPayload = {
94626
94675
  turnRequestedAt: input.command.createdAt,
94627
- projectCwd: bootstrapWorktree.projectCwd,
94676
+ ...bootstrapWorktree.projectId ? { projectId: bootstrapWorktree.projectId } : {},
94677
+ projectCwd,
94628
94678
  baseBranch: bootstrapWorktree.baseBranch,
94629
94679
  branch: bootstrapWorktree.branch,
94630
94680
  command: `git worktree add -b ${bootstrapWorktree.branch} <generated-path> ${baseBranchLabel}`
@@ -94639,11 +94689,38 @@ const prepareBootstrapWorktree = (input) => require_Schema$1.gen(function* () {
94639
94689
  payload: requestedPayload,
94640
94690
  tone: "info"
94641
94691
  });
94692
+ if (bootstrapWorktree.startFromOrigin) {
94693
+ if (!input.git.fetch) return yield* require_Schema$1.fail(/* @__PURE__ */ new Error("Git fetch is unavailable for origin worktree preparation."));
94694
+ yield* input.git.fetch({
94695
+ cwd: projectCwd,
94696
+ remote: "origin",
94697
+ ref: bootstrapWorktree.baseBranch ?? "main"
94698
+ }).pipe(require_Schema$1.catchCause((cause) => {
94699
+ if (require_Schema$1.hasInterruptsOnly(cause)) return require_Schema$1.failCause(cause);
94700
+ const error = require_Schema$1.squash(cause);
94701
+ const detail = error instanceof Error ? error.message : "Unknown fetch failure.";
94702
+ return appendWorktreeActivity({
94703
+ orchestrationEngine: input.orchestrationEngine,
94704
+ threadId: input.command.threadId,
94705
+ commandId: bootstrapCommandId(input.command, "bootstrap-worktree-failed"),
94706
+ kind: "worktree.failed",
94707
+ summary: "Worktree preparation failed",
94708
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
94709
+ payload: {
94710
+ ...requestedPayload,
94711
+ detail,
94712
+ stage: "fetch"
94713
+ },
94714
+ tone: "error"
94715
+ }).pipe(require_Schema$1.andThen(require_Schema$1.failCause(cause)));
94716
+ }));
94717
+ }
94642
94718
  const worktree = yield* input.git.createWorktree({
94643
- cwd: bootstrapWorktree.projectCwd,
94719
+ cwd: projectCwd,
94644
94720
  branch: bootstrapWorktree.baseBranch,
94645
94721
  newBranch: bootstrapWorktree.branch,
94646
94722
  path: null,
94723
+ ...bootstrapWorktree.startFromOrigin ? { startFromOrigin: true } : {},
94647
94724
  onStage: (update) => appendWorktreeActivity({
94648
94725
  orchestrationEngine: input.orchestrationEngine,
94649
94726
  threadId: input.command.threadId,
@@ -94735,7 +94812,7 @@ const prepareBootstrapWorktree = (input) => require_Schema$1.gen(function* () {
94735
94812
  });
94736
94813
  return {
94737
94814
  worktreePath,
94738
- projectCwd: bootstrapWorktree.projectCwd
94815
+ projectCwd
94739
94816
  };
94740
94817
  });
94741
94818
  const dispatchBootstrapTurnStart$1 = (input, command) => require_Schema$1.gen(function* () {
@@ -236026,6 +236103,13 @@ function createGitCommandError(operation, cwd, args, detail, cause) {
236026
236103
  ...cause !== void 0 ? { cause } : {}
236027
236104
  });
236028
236105
  }
236106
+ function isValidGitRef(value) {
236107
+ if (value.length === 0 || value.startsWith("-") || value.endsWith(".") || value.endsWith("/") || value.endsWith(".lock") || value.includes("..") || value.includes("@{") || /[~^:?*[\\]/.test(value) || [...value].some((character) => {
236108
+ const code = character.charCodeAt(0);
236109
+ return code <= 32 || code === 127;
236110
+ })) return false;
236111
+ return value.split("/").every((part) => part.length > 0 && part !== "." && part !== "..");
236112
+ }
236029
236113
  function quoteGitCommand(args) {
236030
236114
  return `git ${args.join(" ")}`;
236031
236115
  }
@@ -237038,7 +237122,7 @@ const makeGitCore = require_Schema$1.fn("makeGitCore")(function* (options) {
237038
237122
  }) ?? require_Schema$1.void_;
237039
237123
  yield* report("resolve", "running");
237040
237124
  const base = input.branch ?? (yield* resolveDefaultBaseBranch(input.cwd));
237041
- const startPoint = yield* resolveWorktreeStartPoint({
237125
+ const startPoint = input.startFromOrigin ? `origin/${base}` : yield* resolveWorktreeStartPoint({
237042
237126
  cwd: input.cwd,
237043
237127
  base,
237044
237128
  creatingNewBranch: input.newBranch !== void 0
@@ -237108,6 +237192,20 @@ const makeGitCore = require_Schema$1.fn("makeGitCore")(function* (options) {
237108
237192
  fallbackErrorMessage: "git fetch pull request branch failed"
237109
237193
  });
237110
237194
  });
237195
+ const fetch = require_Schema$1.fn("fetch")(function* (input) {
237196
+ if (!isValidGitRef(input.ref)) return yield* require_Schema$1.fail(createGitCommandError("GitCore.fetch", input.cwd, [
237197
+ "fetch",
237198
+ input.remote,
237199
+ input.ref
237200
+ ], `Invalid Git ref: ${input.ref}`));
237201
+ yield* runGit("GitCore.fetch", input.cwd, [
237202
+ "fetch",
237203
+ "--quiet",
237204
+ "--no-tags",
237205
+ input.remote,
237206
+ input.ref
237207
+ ]);
237208
+ });
237111
237209
  const fetchRemoteBranch = require_Schema$1.fn("fetchRemoteBranch")(function* (input) {
237112
237210
  yield* runGit("GitCore.fetchRemoteBranch.fetch", input.cwd, [
237113
237211
  "fetch",
@@ -237305,6 +237403,7 @@ const makeGitCore = require_Schema$1.fn("makeGitCore")(function* (options) {
237305
237403
  listBranches,
237306
237404
  createWorktree,
237307
237405
  fetchPullRequestBranch,
237406
+ fetch,
237308
237407
  ensureRemote,
237309
237408
  fetchRemoteBranch,
237310
237409
  setBranchUpstream,
@@ -300774,7 +300873,7 @@ function resolveBuildCommitFromEnv(env) {
300774
300873
  * environment descriptor down instead of reporting an honest "unknown".
300775
300874
  */
300776
300875
  function readBakedBuildCommit() {
300777
- return "bbf42772eb03753c72fd6043fdc17df49c776702";
300876
+ return "ccee17906caa33ee1121ad57b882116aac6ca527";
300778
300877
  }
300779
300878
  async function resolveServerBuildCommit(input) {
300780
300879
  if (isFullCommitSha(input.baked)) return input.baked;
package/dist/bin.mjs CHANGED
@@ -23,7 +23,7 @@ import { createCipheriv, createDecipheriv, createHash, createHmac, createPublicK
23
23
  import * as FS$1 from "node:fs";
24
24
  import fs, { accessSync, chmodSync, constants, createReadStream, existsSync, mkdirSync, mkdtempSync, promises, readFile, readFileSync, readdir, readdirSync, realpathSync, rmSync, statSync, unlinkSync, writeFileSync } from "node:fs";
25
25
  import * as NodeOS from "node:os";
26
- import $U, { homedir, networkInterfaces, tmpdir } from "node:os";
26
+ import os, { homedir, networkInterfaces, tmpdir } from "node:os";
27
27
  import * as Path$1 from "node:path";
28
28
  import path, { basename, delimiter, dirname, extname, isAbsolute, join, posix, relative, resolve, sep } from "node:path";
29
29
  import { pathToFileURL } from "node:url";
@@ -18062,9 +18062,11 @@ const ThreadTurnStartBootstrapCreateThread = Struct({
18062
18062
  createdAt: IsoDateTime
18063
18063
  });
18064
18064
  const ThreadTurnStartBootstrapPrepareWorktree = Struct({
18065
- projectCwd: TrimmedNonEmptyString,
18065
+ projectId: optional$4(ProjectId),
18066
+ projectCwd: optional$4(TrimmedNonEmptyString),
18066
18067
  baseBranch: NullOr(TrimmedNonEmptyString),
18067
- branch: optional$4(TrimmedNonEmptyString)
18068
+ branch: optional$4(TrimmedNonEmptyString),
18069
+ startFromOrigin: optional$4(Boolean$1)
18068
18070
  });
18069
18071
  const ThreadTurnStartBootstrap = Struct({
18070
18072
  createThread: optional$4(ThreadTurnStartBootstrapCreateThread),
@@ -50751,7 +50753,7 @@ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
50751
50753
  const min = forceColor || 0;
50752
50754
  if (env.TERM === "dumb") return min;
50753
50755
  if (process$1.platform === "win32") {
50754
- const osRelease = $U.release().split(".");
50756
+ const osRelease = os.release().split(".");
50755
50757
  if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) return Number(osRelease[2]) >= 14931 ? 3 : 2;
50756
50758
  return 1;
50757
50759
  }
@@ -53194,7 +53196,7 @@ var require_ProcessDetector = /* @__PURE__ */ __commonJSMin(((exports) => {
53194
53196
  exports.processDetector = void 0;
53195
53197
  const api_1 = (init_esm$1(), __toCommonJS(esm_exports$1));
53196
53198
  const semconv_1 = require_semconv$1();
53197
- const os$3 = __require("os");
53199
+ const os$4 = __require("os");
53198
53200
  /**
53199
53201
  * ProcessDetector will be used to detect the resources related current process running
53200
53202
  * and being instrumented from the NodeJS Process module.
@@ -53216,7 +53218,7 @@ var require_ProcessDetector = /* @__PURE__ */ __commonJSMin(((exports) => {
53216
53218
  };
53217
53219
  if (process.argv.length > 1) attributes[semconv_1.ATTR_PROCESS_COMMAND] = process.argv[1];
53218
53220
  try {
53219
- const userInfo = os$3.userInfo();
53221
+ const userInfo = os$4.userInfo();
53220
53222
  attributes[semconv_1.ATTR_PROCESS_OWNER] = userInfo.username;
53221
53223
  } catch (e) {
53222
53224
  api_1.diag.debug(`error obtaining process owner: ${e}`);
@@ -66139,7 +66141,7 @@ function normalizeNumberish(value) {
66139
66141
  }
66140
66142
  //#endregion
66141
66143
  //#region package.json
66142
- var version$1 = "0.13.143";
66144
+ var version$1 = "0.13.145";
66143
66145
  //#endregion
66144
66146
  //#region src/sentry.ts
66145
66147
  const SERVER_APP_NAME = "forge-server";
@@ -75906,7 +75908,7 @@ var require_node_gyp_build = /* @__PURE__ */ __commonJSMin(((exports, module) =>
75906
75908
  var fs$6 = __require("fs");
75907
75909
  var path$5 = __require("path");
75908
75910
  var url$1 = __require("url");
75909
- var os$2 = __require("os");
75911
+ var os$3 = __require("os");
75910
75912
  var runtimeRequire = typeof __webpack_require__ === "function" ? __non_webpack_require__ : __require;
75911
75913
  var vars = process.config && process.config.variables || {};
75912
75914
  var prebuildsOnly = !!process.env.PREBUILDS_ONLY;
@@ -75914,8 +75916,8 @@ var require_node_gyp_build = /* @__PURE__ */ __commonJSMin(((exports, module) =>
75914
75916
  var abi = versions.modules;
75915
75917
  if (versions.deno || process.isBun) abi = "unsupported";
75916
75918
  var runtime = isElectron() ? "electron" : isNwjs() ? "node-webkit" : "node";
75917
- var arch = process.env.npm_config_arch || os$2.arch();
75918
- var platform = process.env.npm_config_platform || os$2.platform();
75919
+ var arch = process.env.npm_config_arch || os$3.arch();
75920
+ var platform = process.env.npm_config_platform || os$3.platform();
75919
75921
  var libc = process.env.LIBC || (isMusl(platform) ? "musl" : "glibc");
75920
75922
  var armv = process.env.ARM_VERSION || (arch === "arm64" ? "8" : vars.arm_version) || "";
75921
75923
  var uv = (versions.uv || "").split(".")[0];
@@ -93759,7 +93761,7 @@ const launchDetached = (launch) => gen(function* () {
93759
93761
  });
93760
93762
  const OpenLive = effect(Open, gen(function* () {
93761
93763
  const open = yield* tryPromise({
93762
- try: () => import("./open-2-reBrpv.mjs"),
93764
+ try: () => import("./open-yHTUkd2Y.mjs"),
93763
93765
  catch: (cause) => new OpenError$1({
93764
93766
  message: "failed to load browser opener",
93765
93767
  cause
@@ -94257,14 +94259,62 @@ const dispatchBootstrapThreadCreate = (input) => gen(function* () {
94257
94259
  });
94258
94260
  return !threadAlreadyExists;
94259
94261
  });
94262
+ /** Reject a removed or unknown project before any Git operation uses its checkout. */
94263
+ const requireBootstrapProject = (input) => {
94264
+ const project = input.readModel.projects.find((candidate) => candidate.id === input.projectId);
94265
+ return project && project.deletedAt === null ? succeed(project) : fail(/* @__PURE__ */ new Error(`Worktree project '${input.projectId}' does not exist.`));
94266
+ };
94267
+ /** Require the target thread to be live before preparing its worktree. */
94268
+ const requireBootstrapThread = (input) => {
94269
+ const thread = input.readModel.threads.find((candidate) => candidate.id === input.threadId);
94270
+ return thread && thread.deletedAt === null ? succeed(thread) : fail(/* @__PURE__ */ new Error(`Worktree thread '${input.threadId}' does not exist.`));
94271
+ };
94272
+ /** Resolve a CMMD Work Session's checkout from Forge's persisted project identity. */
94273
+ const resolveAuthoritativeBootstrapProjectCwd = (input) => gen(function* () {
94274
+ const projectId = input.bootstrapWorktree.projectId;
94275
+ if (projectId === void 0) return yield* fail(/* @__PURE__ */ new Error("Missing project identity."));
94276
+ const project = yield* requireBootstrapProject({
94277
+ readModel: input.readModel,
94278
+ projectId
94279
+ });
94280
+ const thread = yield* requireBootstrapThread({
94281
+ readModel: input.readModel,
94282
+ threadId: input.command.threadId
94283
+ });
94284
+ if (thread.projectId !== projectId) return yield* fail(/* @__PURE__ */ new Error(`Worktree project '${projectId}' does not match thread project '${thread.projectId}'.`));
94285
+ const createdThreadProjectId = input.command.bootstrap?.createThread?.projectId;
94286
+ if (createdThreadProjectId && createdThreadProjectId !== projectId) return yield* fail(/* @__PURE__ */ new Error(`Worktree project '${projectId}' does not match created thread project '${createdThreadProjectId}'.`));
94287
+ if (input.bootstrapWorktree.branch === void 0) return yield* fail(/* @__PURE__ */ new Error("Authoritative worktree preparation requires a branch."));
94288
+ if (input.bootstrapWorktree.startFromOrigin && input.bootstrapWorktree.baseBranch !== "main") return yield* fail(/* @__PURE__ */ new Error("Authoritative Work Session worktrees must start from origin/main."));
94289
+ return project.workspaceRoot;
94290
+ });
94291
+ /** Keep legacy path-based commands working while routing identified projects through Forge records. */
94292
+ const resolveBootstrapProjectCwd = (input) => gen(function* () {
94293
+ const { bootstrapWorktree } = input;
94294
+ if (bootstrapWorktree.projectId === void 0) {
94295
+ if (!bootstrapWorktree.projectCwd) return yield* fail(/* @__PURE__ */ new Error("Worktree preparation requires a project checkout path."));
94296
+ return bootstrapWorktree.projectCwd;
94297
+ }
94298
+ return yield* resolveAuthoritativeBootstrapProjectCwd({
94299
+ readModel: yield* input.orchestrationEngine.getReadModel(),
94300
+ command: input.command,
94301
+ bootstrapWorktree
94302
+ });
94303
+ });
94260
94304
  const prepareBootstrapWorktree = (input) => gen(function* () {
94261
94305
  const bootstrapWorktree = input.command.bootstrap?.prepareWorktree;
94262
94306
  if (!bootstrapWorktree) return null;
94307
+ const projectCwd = yield* resolveBootstrapProjectCwd({
94308
+ orchestrationEngine: input.orchestrationEngine,
94309
+ command: input.command,
94310
+ bootstrapWorktree
94311
+ });
94263
94312
  const requestedAt = (/* @__PURE__ */ new Date()).toISOString();
94264
94313
  const baseBranchLabel = bootstrapWorktree.baseBranch ?? "<default>";
94265
94314
  const requestedPayload = {
94266
94315
  turnRequestedAt: input.command.createdAt,
94267
- projectCwd: bootstrapWorktree.projectCwd,
94316
+ ...bootstrapWorktree.projectId ? { projectId: bootstrapWorktree.projectId } : {},
94317
+ projectCwd,
94268
94318
  baseBranch: bootstrapWorktree.baseBranch,
94269
94319
  branch: bootstrapWorktree.branch,
94270
94320
  command: `git worktree add -b ${bootstrapWorktree.branch} <generated-path> ${baseBranchLabel}`
@@ -94279,11 +94329,38 @@ const prepareBootstrapWorktree = (input) => gen(function* () {
94279
94329
  payload: requestedPayload,
94280
94330
  tone: "info"
94281
94331
  });
94332
+ if (bootstrapWorktree.startFromOrigin) {
94333
+ if (!input.git.fetch) return yield* fail(/* @__PURE__ */ new Error("Git fetch is unavailable for origin worktree preparation."));
94334
+ yield* input.git.fetch({
94335
+ cwd: projectCwd,
94336
+ remote: "origin",
94337
+ ref: bootstrapWorktree.baseBranch ?? "main"
94338
+ }).pipe(catchCause((cause) => {
94339
+ if (hasInterruptsOnly(cause)) return failCause$1(cause);
94340
+ const error = squash(cause);
94341
+ const detail = error instanceof Error ? error.message : "Unknown fetch failure.";
94342
+ return appendWorktreeActivity({
94343
+ orchestrationEngine: input.orchestrationEngine,
94344
+ threadId: input.command.threadId,
94345
+ commandId: bootstrapCommandId(input.command, "bootstrap-worktree-failed"),
94346
+ kind: "worktree.failed",
94347
+ summary: "Worktree preparation failed",
94348
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
94349
+ payload: {
94350
+ ...requestedPayload,
94351
+ detail,
94352
+ stage: "fetch"
94353
+ },
94354
+ tone: "error"
94355
+ }).pipe(andThen(failCause$1(cause)));
94356
+ }));
94357
+ }
94282
94358
  const worktree = yield* input.git.createWorktree({
94283
- cwd: bootstrapWorktree.projectCwd,
94359
+ cwd: projectCwd,
94284
94360
  branch: bootstrapWorktree.baseBranch,
94285
94361
  newBranch: bootstrapWorktree.branch,
94286
94362
  path: null,
94363
+ ...bootstrapWorktree.startFromOrigin ? { startFromOrigin: true } : {},
94287
94364
  onStage: (update) => appendWorktreeActivity({
94288
94365
  orchestrationEngine: input.orchestrationEngine,
94289
94366
  threadId: input.command.threadId,
@@ -94375,7 +94452,7 @@ const prepareBootstrapWorktree = (input) => gen(function* () {
94375
94452
  });
94376
94453
  return {
94377
94454
  worktreePath,
94378
- projectCwd: bootstrapWorktree.projectCwd
94455
+ projectCwd
94379
94456
  };
94380
94457
  });
94381
94458
  const dispatchBootstrapTurnStart$1 = (input, command) => gen(function* () {
@@ -192145,7 +192222,7 @@ var Vce = {
192145
192222
  function Ve() {
192146
192223
  return Vce;
192147
192224
  }
192148
- var Us = $U.homedir(), lk = $U.tmpdir(), { env: Vc } = process$1, Yce = (e) => {
192225
+ var Us = os.homedir(), lk = os.tmpdir(), { env: Vc } = process$1, Yce = (e) => {
192149
192226
  let t = path.join(Us, "Library");
192150
192227
  return {
192151
192228
  data: path.join(t, "Application Support", e),
@@ -202345,12 +202422,12 @@ function qZ(e, t) {
202345
202422
  }
202346
202423
  return n;
202347
202424
  }
202348
- var os$1 = "https://code.claude.com/docs/en", kKe = [
202425
+ var os$2 = "https://code.claude.com/docs/en", kKe = [
202349
202426
  {
202350
202427
  matches: (e) => e.path === "permissions.defaultMode" && e.code === "invalid_value",
202351
202428
  tip: {
202352
202429
  suggestion: "Valid modes: \"acceptEdits\" (ask before file changes), \"plan\" (analysis only), \"bypassPermissions\" (auto-accept all), or \"default\" (standard behavior)",
202353
- docLink: `${os$1}/iam#permission-modes`
202430
+ docLink: `${os$2}/iam#permission-modes`
202354
202431
  }
202355
202432
  },
202356
202433
  {
@@ -202365,7 +202442,7 @@ var os$1 = "https://code.claude.com/docs/en", kKe = [
202365
202442
  matches: (e) => e.path.startsWith("env.") && e.code === "invalid_type",
202366
202443
  tip: {
202367
202444
  suggestion: "Environment variables must be strings. Wrap numbers and booleans in quotes. Example: \"DEBUG\": \"true\", \"PORT\": \"3000\"",
202368
- docLink: `${os$1}/settings#environment-variables`
202445
+ docLink: `${os$2}/settings#environment-variables`
202369
202446
  }
202370
202447
  },
202371
202448
  {
@@ -202376,14 +202453,14 @@ var os$1 = "https://code.claude.com/docs/en", kKe = [
202376
202453
  matches: (e) => e.path.startsWith("hooks.") && e.code === "invalid_key",
202377
202454
  tip: {
202378
202455
  suggestion: "Not a recognized hook event. Common events: PreToolUse, PostToolUse, UserPromptSubmit, SessionStart, SessionEnd, Stop. Check spelling and capitalization.",
202379
- docLink: `${os$1}/hooks`
202456
+ docLink: `${os$2}/hooks`
202380
202457
  }
202381
202458
  },
202382
202459
  {
202383
202460
  matches: (e) => /\.hooks\.\d+\.command$/.test(e.path) && e.code === "invalid_type" && e.received === "undefined",
202384
202461
  tip: {
202385
202462
  suggestion: "Command hooks require `command`. For exec form (no shell), set `command` to the executable and `args` to its arguments: {\"type\": \"command\", \"command\": \"echo\", \"args\": [\"hi\"]}. For shell form, set `command` to the full shell string: {\"type\": \"command\", \"command\": \"echo hi\"}.",
202386
- docLink: `${os$1}/hooks#exec-form-and-shell-form`
202463
+ docLink: `${os$2}/hooks#exec-form-and-shell-form`
202387
202464
  }
202388
202465
  },
202389
202466
  {
@@ -202398,7 +202475,7 @@ var os$1 = "https://code.claude.com/docs/en", kKe = [
202398
202475
  matches: (e) => e.code === "unrecognized_keys",
202399
202476
  tip: {
202400
202477
  suggestion: "Check for typos or refer to the documentation for valid fields",
202401
- docLink: `${os$1}/settings`
202478
+ docLink: `${os$2}/settings`
202402
202479
  }
202403
202480
  },
202404
202481
  {
@@ -202413,13 +202490,13 @@ var os$1 = "https://code.claude.com/docs/en", kKe = [
202413
202490
  matches: (e) => e.path === "permissions.additionalDirectories" && e.code === "invalid_type",
202414
202491
  tip: {
202415
202492
  suggestion: "Must be an array of directory paths. Example: [\"~/projects\", \"/tmp/workspace\"]. You can also use --add-dir flag or /add-dir command",
202416
- docLink: `${os$1}/iam#working-directories`
202493
+ docLink: `${os$2}/iam#working-directories`
202417
202494
  }
202418
202495
  }
202419
202496
  ], AKe = {
202420
- permissions: `${os$1}/iam#configuring-permissions`,
202421
- env: `${os$1}/settings#environment-variables`,
202422
- hooks: `${os$1}/hooks`
202497
+ permissions: `${os$2}/iam#configuring-permissions`,
202498
+ env: `${os$2}/settings#environment-variables`,
202499
+ hooks: `${os$2}/hooks`
202423
202500
  };
202424
202501
  function GZ(e) {
202425
202502
  let t = kKe.find((r) => r.matches(e));
@@ -235562,6 +235639,13 @@ function createGitCommandError(operation, cwd, args, detail, cause) {
235562
235639
  ...cause !== void 0 ? { cause } : {}
235563
235640
  });
235564
235641
  }
235642
+ function isValidGitRef(value) {
235643
+ if (value.length === 0 || value.startsWith("-") || value.endsWith(".") || value.endsWith("/") || value.endsWith(".lock") || value.includes("..") || value.includes("@{") || /[~^:?*[\\]/.test(value) || [...value].some((character) => {
235644
+ const code = character.charCodeAt(0);
235645
+ return code <= 32 || code === 127;
235646
+ })) return false;
235647
+ return value.split("/").every((part) => part.length > 0 && part !== "." && part !== "..");
235648
+ }
235565
235649
  function quoteGitCommand(args) {
235566
235650
  return `git ${args.join(" ")}`;
235567
235651
  }
@@ -236570,7 +236654,7 @@ const GitCoreLive = effect(GitCore, fn$1("makeGitCore")(function* (options) {
236570
236654
  }) ?? void_$1;
236571
236655
  yield* report("resolve", "running");
236572
236656
  const base = input.branch ?? (yield* resolveDefaultBaseBranch(input.cwd));
236573
- const startPoint = yield* resolveWorktreeStartPoint({
236657
+ const startPoint = input.startFromOrigin ? `origin/${base}` : yield* resolveWorktreeStartPoint({
236574
236658
  cwd: input.cwd,
236575
236659
  base,
236576
236660
  creatingNewBranch: input.newBranch !== void 0
@@ -236640,6 +236724,20 @@ const GitCoreLive = effect(GitCore, fn$1("makeGitCore")(function* (options) {
236640
236724
  fallbackErrorMessage: "git fetch pull request branch failed"
236641
236725
  });
236642
236726
  });
236727
+ const fetch = fn$1("fetch")(function* (input) {
236728
+ if (!isValidGitRef(input.ref)) return yield* fail(createGitCommandError("GitCore.fetch", input.cwd, [
236729
+ "fetch",
236730
+ input.remote,
236731
+ input.ref
236732
+ ], `Invalid Git ref: ${input.ref}`));
236733
+ yield* runGit("GitCore.fetch", input.cwd, [
236734
+ "fetch",
236735
+ "--quiet",
236736
+ "--no-tags",
236737
+ input.remote,
236738
+ input.ref
236739
+ ]);
236740
+ });
236643
236741
  const fetchRemoteBranch = fn$1("fetchRemoteBranch")(function* (input) {
236644
236742
  yield* runGit("GitCore.fetchRemoteBranch.fetch", input.cwd, [
236645
236743
  "fetch",
@@ -236837,6 +236935,7 @@ const GitCoreLive = effect(GitCore, fn$1("makeGitCore")(function* (options) {
236837
236935
  listBranches,
236838
236936
  createWorktree,
236839
236937
  fetchPullRequestBranch,
236938
+ fetch,
236840
236939
  ensureRemote,
236841
236940
  fetchRemoteBranch,
236842
236941
  setBranchUpstream,
@@ -271207,7 +271306,7 @@ var import_multicast_dns = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMi
271207
271306
  var dgram = __require("dgram");
271208
271307
  var thunky = require_thunky();
271209
271308
  var events = __require("events");
271210
- var os = __require("os");
271309
+ var os$1 = __require("os");
271211
271310
  var noop = function() {};
271212
271311
  module.exports = function(opts) {
271213
271312
  if (!opts) opts = {};
@@ -271338,14 +271437,14 @@ var import_multicast_dns = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMi
271338
271437
  return that;
271339
271438
  };
271340
271439
  function defaultInterface() {
271341
- var networks = os.networkInterfaces();
271440
+ var networks = os$1.networkInterfaces();
271342
271441
  var names = Object.keys(networks);
271343
271442
  for (var i = 0; i < names.length; i++) {
271344
271443
  var net = networks[names[i]];
271345
271444
  for (var j = 0; j < net.length; j++) {
271346
271445
  var iface = net[j];
271347
271446
  if (isIPv4(iface.family) && !iface.internal) {
271348
- if (os.platform() === "darwin" && names[i] === "en0") return iface.address;
271447
+ if (os$1.platform() === "darwin" && names[i] === "en0") return iface.address;
271349
271448
  return "0.0.0.0";
271350
271449
  }
271351
271450
  }
@@ -271353,7 +271452,7 @@ var import_multicast_dns = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMi
271353
271452
  return "127.0.0.1";
271354
271453
  }
271355
271454
  function allInterfaces() {
271356
- var networks = os.networkInterfaces();
271455
+ var networks = os$1.networkInterfaces();
271357
271456
  var names = Object.keys(networks);
271358
271457
  var res = [];
271359
271458
  for (var i = 0; i < names.length; i++) {
@@ -300218,7 +300317,7 @@ function resolveBuildCommitFromEnv(env) {
300218
300317
  * environment descriptor down instead of reporting an honest "unknown".
300219
300318
  */
300220
300319
  function readBakedBuildCommit() {
300221
- return "bbf42772eb03753c72fd6043fdc17df49c776702";
300320
+ return "ccee17906caa33ee1121ad57b882116aac6ca527";
300222
300321
  }
300223
300322
  async function resolveServerBuildCommit(input) {
300224
300323
  if (isFullCommitSha(input.baked)) return input.baked;
@@ -325746,7 +325845,7 @@ const connectLoginCommand = make$33("login", {
325746
325845
  })).json();
325747
325846
  },
325748
325847
  openBrowser: async (url) => {
325749
- const open = (await import("./open-2-reBrpv.mjs")).default;
325848
+ const open = (await import("./open-yHTUkd2Y.mjs")).default;
325750
325849
  await open(url);
325751
325850
  return true;
325752
325851
  },