@boxes-dev/dvb-runtime 1.0.1092 → 1.0.1094

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/bin/dvb.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- !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]="37db650b-046c-51ef-b444-0f7c0907da74")}catch(e){}}();
3
+ !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]="87fe665b-b866-5692-8a17-9feb9f823c01")}catch(e){}}();
4
4
  import { createRequire as __dvbCreateRequire } from "node:module";
5
5
  import { dirname as __dvbDirname } from "node:path";
6
6
  import { fileURLToPath as __dvbFileURLToPath } from "node:url";
@@ -26885,6 +26885,13 @@ var init_companion = __esm({
26885
26885
  return this.expectedState;
26886
26886
  }
26887
26887
  clientInformation(context34) {
26888
+ if (!this.clientInformationValue) {
26889
+ const metadata = this.discoveryStateValue?.authorizationServerMetadata;
26890
+ if (metadata && !metadata.registration_endpoint && !(metadata.client_id_metadata_document_supported === true && this.clientMetadataUrl)) {
26891
+ throw new McpOAuthCompanionError("client_registration_unsupported", "This MCP's provider requires a registered app for sign-in, so boxes.dev can't sign in to it. If the provider gives you an access token, add it to this MCP as a header instead.");
26892
+ }
26893
+ return void 0;
26894
+ }
26888
26895
  if (context34 && this.clientInformationValue?.issuer && !sameUrl(this.clientInformationValue.issuer, context34.issuer)) {
26889
26896
  return void 0;
26890
26897
  }
@@ -27863,7 +27870,7 @@ var init_utils = __esm({
27863
27870
 
27864
27871
  // ../../../../shared/devboxCore/dist/agentConfigImport/claude.js
27865
27872
  import path from "node:path";
27866
- var CLAUDE_LEGACY_ROOT_ALLOWLIST, CLAUDE_DESKTOP_ROOT_ALLOWLIST, CLAUDE_PROJECT_ALLOWLIST, resolveClaudeConfigDirCandidates, resolveClaudeStateBaseDir, buildClaudeStateCandidatePaths, normalizeLocalRepoRootCandidates, buildBootstrapClaudeProjectStateWithAllowlist, buildClaudeStateWithRootAllowlist, buildBootstrapClaudeState, mergeBootstrapClaudeStateIntoRemoteState, mergeClaudeSettingsForDevbox, classifyClaudeMcpServers, classifyClaudeAgentConfig, buildClaudePortableItem, buildClaudePortableFileItems;
27873
+ var CLAUDE_LEGACY_ROOT_ALLOWLIST, CLAUDE_DESKTOP_ROOT_ALLOWLIST, CLAUDE_PROJECT_ALLOWLIST, resolveClaudeConfigDirCandidates, resolveClaudeStateBaseDir, buildClaudeStateCandidatePaths, normalizeLocalRepoRootCandidates, buildBootstrapClaudeProjectStateWithAllowlist, buildClaudeStateWithRootAllowlist, buildBootstrapClaudeState, mergeBootstrapClaudeStateIntoRemoteState, selectClaudeSettingsForDevbox, mergeClaudeSettingsForDevbox, classifyClaudeMcpServers, classifyClaudeAgentConfig, buildClaudePortableItem, buildClaudePortableFileItems, CLAUDE_HOOKS_ITEM_ID, hasCommandHook, buildClaudeHooksItem;
27867
27874
  var init_claude = __esm({
27868
27875
  "../../../../shared/devboxCore/dist/agentConfigImport/claude.js"() {
27869
27876
  "use strict";
@@ -27996,6 +28003,14 @@ var init_claude = __esm({
27996
28003
  base.projects = projects;
27997
28004
  return base;
27998
28005
  };
28006
+ selectClaudeSettingsForDevbox = ({ settings, includeSettings, includeHooks }) => {
28007
+ const { hooks, ...rest } = settings ?? {};
28008
+ const selected = includeSettings ? rest : {};
28009
+ if (includeHooks && hooks !== void 0) {
28010
+ selected.hooks = hooks;
28011
+ }
28012
+ return mergeClaudeSettingsForDevbox(selected);
28013
+ };
27999
28014
  mergeClaudeSettingsForDevbox = (settings) => {
28000
28015
  const base = settings ? { ...settings } : {};
28001
28016
  delete base.enabledPlugins;
@@ -28108,6 +28123,33 @@ var init_claude = __esm({
28108
28123
  }
28109
28124
  return items;
28110
28125
  };
28126
+ CLAUDE_HOOKS_ITEM_ID = "claude:hooks";
28127
+ hasCommandHook = (hooks) => Object.values(hooks).some((matchers) => Array.isArray(matchers) && matchers.some((matcher) => isJsonRecord(matcher) && Array.isArray(matcher.hooks) && matcher.hooks.some((hook) => isJsonRecord(hook) && hook.type === "command")));
28128
+ buildClaudeHooksItem = ({ settings, settingsPath }) => {
28129
+ const hooks = settings?.hooks;
28130
+ if (!isJsonRecord(hooks) || Object.keys(hooks).length === 0) {
28131
+ return null;
28132
+ }
28133
+ const portability = hasCommandHook(hooks) ? {
28134
+ portability: "local_risk",
28135
+ defaultSelected: false,
28136
+ reason: "These hooks run commands that may rely on scripts or tools from this computer. If something they need isn't on the Template box, Claude may not be able to respond."
28137
+ } : {
28138
+ portability: "portable",
28139
+ defaultSelected: true,
28140
+ reason: "Portable Claude configuration."
28141
+ };
28142
+ return {
28143
+ id: CLAUDE_HOOKS_ITEM_ID,
28144
+ agent: "claude",
28145
+ category: "settings",
28146
+ label: "Claude hooks",
28147
+ path: settingsPath,
28148
+ parentItemId: null,
28149
+ secretRefs: [],
28150
+ ...portability
28151
+ };
28152
+ };
28111
28153
  }
28112
28154
  });
28113
28155
 
@@ -70354,9 +70396,9 @@ var init_sentry = __esm({
70354
70396
  uncaughtExceptionMonitorInstalled = false;
70355
70397
  currentDevboxSentryUser = null;
70356
70398
  readBuildMetadata = () => {
70357
- const rawPackageVersion = "1.0.1092";
70358
- const rawGitSha = "c33e3fee06c68f6f8f775a039865743a5c7fa5c8";
70359
- const rawSentryRelease = "boxes-dev-dvb@1.0.1092+c33e3fee06c68f6f8f775a039865743a5c7fa5c8";
70399
+ const rawPackageVersion = "1.0.1094";
70400
+ const rawGitSha = "6df6dd088ab8880d887c654f30e84a6a315d5d38";
70401
+ const rawSentryRelease = "boxes-dev-dvb@1.0.1094+6df6dd088ab8880d887c654f30e84a6a315d5d38";
70360
70402
  const packageVersion = typeof rawPackageVersion === "string" ? rawPackageVersion : void 0;
70361
70403
  const gitSha = typeof rawGitSha === "string" ? rawGitSha : void 0;
70362
70404
  const sentryRelease = typeof rawSentryRelease === "string" ? rawSentryRelease : void 0;
@@ -71637,11 +71679,12 @@ var init_projectRepos = __esm({
71637
71679
  });
71638
71680
 
71639
71681
  // ../../../../shared/devboxCore/dist/forkStartupScript.js
71640
- var FORK_STARTUP_BRANCH_NAME_PATTERN, normalizeForkStartupBranchName, buildRecommendedForkStartupScript;
71682
+ var FORK_STARTUP_BRANCH_NAME_PATTERN, FORK_STARTUP_RELATIVE_PATH_SEGMENT_PATTERN, normalizeForkStartupBranchName, buildRecommendedForkStartupScript, normalizeForkStartupRelativePath, buildRecommendedForkStartupScriptForRepositories;
71641
71683
  var init_forkStartupScript = __esm({
71642
71684
  "../../../../shared/devboxCore/dist/forkStartupScript.js"() {
71643
71685
  "use strict";
71644
71686
  FORK_STARTUP_BRANCH_NAME_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._/-]*$/u;
71687
+ FORK_STARTUP_RELATIVE_PATH_SEGMENT_PATTERN = /^[A-Za-z0-9._-]+$/u;
71645
71688
  normalizeForkStartupBranchName = (value) => {
71646
71689
  const branch = value?.trim() ?? "";
71647
71690
  if (!branch || branch.startsWith("-") || branch.endsWith("/") || branch.endsWith(".") || branch.includes("..") || branch.includes("//") || branch.includes("@{") || branch.endsWith(".lock") || !FORK_STARTUP_BRANCH_NAME_PATTERN.test(branch)) {
@@ -71665,6 +71708,49 @@ var init_forkStartupScript = __esm({
71665
71708
  "git clean -fd"
71666
71709
  ].join("\n");
71667
71710
  };
71711
+ normalizeForkStartupRelativePath = (value) => {
71712
+ const relativePath = value.trim();
71713
+ if (!relativePath || relativePath.startsWith("/") || relativePath.includes("\\")) {
71714
+ return null;
71715
+ }
71716
+ if (relativePath === ".") {
71717
+ return relativePath;
71718
+ }
71719
+ const segments = relativePath.split("/");
71720
+ if (segments.some((segment) => segment === "" || segment === "." || segment === ".." || !FORK_STARTUP_RELATIVE_PATH_SEGMENT_PATTERN.test(segment))) {
71721
+ return null;
71722
+ }
71723
+ return segments.join("/");
71724
+ };
71725
+ buildRecommendedForkStartupScriptForRepositories = (repositories) => {
71726
+ if (repositories.length === 0) {
71727
+ return null;
71728
+ }
71729
+ const normalized = repositories.map((repository) => ({
71730
+ relativePath: normalizeForkStartupRelativePath(repository.relativePath),
71731
+ defaultBranch: normalizeForkStartupBranchName(repository.defaultBranch)
71732
+ }));
71733
+ if (normalized.some((repository) => repository.relativePath === null || repository.defaultBranch === null)) {
71734
+ return null;
71735
+ }
71736
+ const resolved = normalized;
71737
+ if (resolved.length === 1 && resolved[0]?.relativePath === ".") {
71738
+ return buildRecommendedForkStartupScript(resolved[0].defaultBranch);
71739
+ }
71740
+ if (resolved.some((repository) => repository.relativePath === ".")) {
71741
+ return null;
71742
+ }
71743
+ const uniquePaths = new Set(resolved.map((repository) => repository.relativePath.toLowerCase()));
71744
+ if (uniquePaths.size !== resolved.length) {
71745
+ return null;
71746
+ }
71747
+ return resolved.map(({ relativePath, defaultBranch }) => [
71748
+ `# Refresh ./${relativePath} from origin/${defaultBranch}`,
71749
+ `git -C ${relativePath} fetch origin`,
71750
+ `git -C ${relativePath} checkout -f -B ${defaultBranch} origin/${defaultBranch}`,
71751
+ `git -C ${relativePath} clean -fd`
71752
+ ].join("\n")).join("\n\n");
71753
+ };
71668
71754
  }
71669
71755
  });
71670
71756
 
@@ -74962,7 +75048,7 @@ so future devboxes will inherit those changes.
74962
75048
  });
74963
75049
 
74964
75050
  // ../../../../shared/devboxCore/dist/remoteSetupPrompt.js
74965
- var REMOTE_SETUP_APPLY_E2B_TEMPLATE, renderTemplate, LEGACY_AGENT_SETUP_BLOCK, ORDINARY_AGENT_SETUP_BLOCK, joinPosixPath, buildRemoteSetupEntrypointsBlock, buildRemoteSetupCompletionBlock, buildRemoteSetupGitConfigReviewBlock, buildRemoteSetupDatabaseRestoreBlock, getSurfacePromptValues, renderRemoteSetupApplyPrompt;
75051
+ var REMOTE_SETUP_APPLY_E2B_TEMPLATE, renderTemplate, LEGACY_AGENT_SETUP_BLOCK, ORDINARY_AGENT_SETUP_BLOCK, joinPosixPath, buildRemoteSetupEntrypointsBlock, buildRemoteSetupCompletionBlock, buildRemoteSetupGitConfigReviewBlock, buildRemoteSetupDatabaseRestoreBlock, quotePosixShellArgument, buildTemplateMaintenanceValidationCommand, buildRemoteSetupTemplateMaintenanceBlock, getSurfacePromptValues, renderRemoteSetupApplyPrompt;
74966
75052
  var init_remoteSetupPrompt = __esm({
74967
75053
  "../../../../shared/devboxCore/dist/remoteSetupPrompt.js"() {
74968
75054
  "use strict";
@@ -75127,7 +75213,7 @@ Things to ensure:
75127
75213
  - Any configured services actually start and run (view their logs and debug if they don't).
75128
75214
  - The app entrypoint(s) run without errors from a fresh terminal session.
75129
75215
  - Core dependencies (node, npm/pnpm, etc.) are on the PATH and work in a fresh terminal session.
75130
-
75216
+ {{template_maintenance_block}}
75131
75217
  When doing these steps, lean careful / conservative:
75132
75218
 
75133
75219
  - Do not delete user files or reset git history.
@@ -75253,6 +75339,82 @@ below.`;
75253
75339
  ""
75254
75340
  ].join("\n");
75255
75341
  };
75342
+ quotePosixShellArgument = (value) => `'${value.replace(/'/gu, `'\\''`)}'`;
75343
+ buildTemplateMaintenanceValidationCommand = ({ scriptPath, workdir, timeoutSeconds }) => {
75344
+ if (!Number.isSafeInteger(timeoutSeconds) || timeoutSeconds < 1) {
75345
+ throw new Error("Template maintenance timeout must be a positive integer.");
75346
+ }
75347
+ const runnerScript = [
75348
+ 'runner="" context=""',
75349
+ 'cd "$1"',
75350
+ 'export TERM=xterm-256color PATH="/opt/devbox-tools/bin:$PATH"',
75351
+ 'script="$(cat "$2")"',
75352
+ 'script="${script#"${script%%[![:space:]]*}"}"',
75353
+ 'script="${script%"${script##*[![:space:]]}"}"',
75354
+ '{ test -n "$script" || { echo "The maintenance script is empty." >&2; false; }; }',
75355
+ 'runner="$(mktemp)"',
75356
+ 'context="$(mktemp)"',
75357
+ 'printf "%s\\n" "$4" > "$context"',
75358
+ 'export BOXES_TEMPLATE_MAINTENANCE_CONTEXT_FILE="$context"',
75359
+ 'printf "%s\\n" "#!/usr/bin/env bash" "set -e -o pipefail" "$script" > "$runner"',
75360
+ 'timeout -k 5 "$3" /bin/bash "$runner" < /dev/null'
75361
+ ].join(" && ");
75362
+ return [
75363
+ "env -i HOME=/home/boxes USER=boxes LOGNAME=boxes SHELL=/bin/bash LANG=C.UTF-8 \\",
75364
+ " PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin \\",
75365
+ ` /bin/bash -l -c '${runnerScript}; status=$?; rm -f "$runner" "$context"; exit "$status"' \\`,
75366
+ ` template-maintenance-check ${quotePosixShellArgument(workdir)} ${quotePosixShellArgument(scriptPath)} ${String(timeoutSeconds)} '${JSON.stringify({ version: 1, sources: ["manual"], repositories: [] })}'`
75367
+ ].join("\n");
75368
+ };
75369
+ buildRemoteSetupTemplateMaintenanceBlock = ({ templateMaintenance, completionMode, setupTodoPath }) => {
75370
+ if (templateMaintenance === null) {
75371
+ return "";
75372
+ }
75373
+ const { scriptPath, workdir, timeoutSeconds } = templateMaintenance;
75374
+ return [
75375
+ "",
75376
+ "Template maintenance script:",
75377
+ "",
75378
+ `- This project's Template maintenance script is staged at \`${scriptPath}\`.`,
75379
+ " boxes.dev saves this file's contents as the project's maintenance script",
75380
+ " when setup finishes. Maintenance runs on this Template box when a watched",
75381
+ " dependency or tooling file changes, or when the user runs it. After a",
75382
+ " successful run, boxes.dev saves a snapshot so new devboxes start from the",
75383
+ " updated environment.",
75384
+ "- The script must actually update the environment: fetch and fast-forward",
75385
+ " the default branch, then install locked dependencies and refresh tooling",
75386
+ " without prompts. It must exit nonzero with a clear message on a dirty",
75387
+ " checkout, a branch other than the default branch, a missing required",
75388
+ " environment value, or a failed update. Never skip an update and exit 0.",
75389
+ ` It must finish within ${String(timeoutSeconds)} seconds and be safe to run repeatedly.`,
75390
+ " It may read boxes.dev-managed environment files but must not contain",
75391
+ " credentials. It must not save snapshots itself.",
75392
+ "- The runner starts from a login shell, then runs the script with",
75393
+ ` noninteractive bash and \`set -e -o pipefail\` in \`${workdir}\`, with`,
75394
+ " `HOME=/home/boxes`, `TERM=xterm-256color`, and `/opt/devbox-tools/bin`",
75395
+ " first on PATH. Interactive setup in `~/.bashrc`, such as nvm or another",
75396
+ " version manager's shell hook, is not loaded; load what the script needs",
75397
+ " explicitly.",
75398
+ "- After the rest of setup works, run this command, which reproduces the",
75399
+ " runner's environment, closed stdin, and timeout. It provides a manual-run",
75400
+ " context file in `BOXES_TEMPLATE_MAINTENANCE_CONTEXT_FILE`; manual runs",
75401
+ " should update the whole environment even without triggering repositories.",
75402
+ " Run it twice; both runs must exit 0.",
75403
+ "",
75404
+ "```bash",
75405
+ buildTemplateMaintenanceValidationCommand(templateMaintenance),
75406
+ "```",
75407
+ "",
75408
+ `- Correct the script only by editing \`${scriptPath}\`, then run both checks`,
75409
+ " again. Do not discard local changes, switch branches, or edit tracked",
75410
+ " files to make it pass. If it still cannot pass, for example because the",
75411
+ " imported checkout has local changes or is on another branch, leave the",
75412
+ " best correct script in that file and record the failing command, error,",
75413
+ ` and next step in \`${setupTodoPath}\`.`,
75414
+ completionMode === "onbox_command" ? "- Finish all edits to this file before you run `dvb-onbox setup complete`." : "- Finish all edits to this file before you finish setup.",
75415
+ ""
75416
+ ].join("\n");
75417
+ };
75256
75418
  getSurfacePromptValues = (surface) => {
75257
75419
  switch (surface) {
75258
75420
  case "cli":
@@ -75276,7 +75438,7 @@ below.`;
75276
75438
  };
75277
75439
  }
75278
75440
  };
75279
- renderRemoteSetupApplyPrompt = ({ surface, completionMode, agentRuntime = "legacy_setup", setupPath, entrypoints, setupTodoPath, gitConfigReviewPath, databaseCopyManifest, stagedDatabaseDumpDir, stagedDatabaseDumpManifestPath, databaseRestoreStatusPath }) => {
75441
+ renderRemoteSetupApplyPrompt = ({ surface, completionMode, agentRuntime = "legacy_setup", setupPath, entrypoints, setupTodoPath, gitConfigReviewPath, databaseCopyManifest, stagedDatabaseDumpDir, stagedDatabaseDumpManifestPath, databaseRestoreStatusPath, templateMaintenance }) => {
75280
75442
  const surfaceValues = getSurfacePromptValues(surface);
75281
75443
  return renderTemplate(REMOTE_SETUP_APPLY_E2B_TEMPLATE, {
75282
75444
  setup_path: setupPath,
@@ -75293,6 +75455,11 @@ below.`;
75293
75455
  stagedDatabaseDumpManifestPath,
75294
75456
  databaseRestoreStatusPath
75295
75457
  }),
75458
+ template_maintenance_block: buildRemoteSetupTemplateMaintenanceBlock({
75459
+ templateMaintenance,
75460
+ completionMode,
75461
+ setupTodoPath
75462
+ }),
75296
75463
  artifact_source_label: surfaceValues.artifactSourceLabel,
75297
75464
  staged_external_index_contract: surfaceValues.stagedExternalIndexContract
75298
75465
  }).trim();
@@ -75740,7 +75907,7 @@ var init_packageVersion = __esm({
75740
75907
  return path18.join(process.cwd(), "dvb");
75741
75908
  };
75742
75909
  readEmbeddedPackageVersion = () => {
75743
- const raw = "1.0.1092";
75910
+ const raw = "1.0.1094";
75744
75911
  return trimVersion(raw);
75745
75912
  };
75746
75913
  readNearestPackageMetadata = (basePath) => {
@@ -143566,7 +143733,7 @@ var init_onboxAgentPermissionRequestPresentation = __esm({
143566
143733
  const boxScope = permission === "message-agents" ? `Allow will let agents on this ${box} message your other agents in this project and receive their messages until you turn it off. A message will start an idle agent and wake its devbox if it's asleep.` : permission === "message-teammates-agents" ? `Allow will let agents on this ${box} message your teammates\u2019 agents until you turn it off. Your teammates\u2019 agents will also be able to message agents here once you allow their messages. An allowed message will start an idle agent and wake this ${box} if it's asleep.` : `Allow will enable this permission on this ${box} until you turn it off.`;
143567
143734
  return {
143568
143735
  question: permissionQuestions[permission],
143569
- scope: isOnboxAgentThreadGrantPermission(permission) ? threadGrantScope(permission, teamTemplateName) : permission === "destroy-devbox" ? `This will allow every agent on this devbox to request its deletion after all agents finish. Files will be permanently deleted and thread history archived. You can turn this off in Agent permissions.${projectScopeAvailable ? " Project approval will extend this permission to your existing and future devboxes, except those you've configured separately. Agents will only be able to destroy their own devbox." : ""}` : permission === "destroy-created-devboxes" ? `This will allow agents on this ${box} to request deletion of devboxes they created. Each devbox will be deleted after all of its agents finish. Its files will be permanently deleted, and its thread history will be archived. You can turn this off in Agent permissions.${projectScopeAvailable ? " Project approval will also apply to your existing and future devboxes, except those you've configured separately." : ""}` : `${boxScope}${projectScopeAvailable ? " Project approval will also apply to your existing and future devboxes, except those you've configured separately." : ""}`,
143736
+ scope: isOnboxAgentThreadGrantPermission(permission) ? threadGrantScope(permission, teamTemplateName) : permission === "destroy-devbox" ? `This will allow every agent on this devbox to request its deletion after all agents finish. Files will be permanently deleted and thread history archived. You can turn this off in Agent permissions.${projectScopeAvailable ? " Project approval will extend this permission to your existing and future devboxes, except those you've configured separately. Agents will only be able to destroy their own devbox." : ""}` : permission === "destroy-created-devboxes" ? `This will allow agents on this ${box} to request deletion of devboxes they created. Each devbox will be deleted after all of its agents finish. Its files will be permanently deleted, and its thread history will be archived.${sourceBoxKind === "devbox" ? " Agents will also be able to archive threads created by agents on this devbox." : ""} You can turn this off in Agent permissions.${projectScopeAvailable ? " Project approval will also apply to your existing and future devboxes, except those you've configured separately." : ""}` : `${boxScope}${projectScopeAvailable ? " Project approval will also apply to your existing and future devboxes, except those you've configured separately." : ""}`,
143570
143737
  automationsSectionSentence: permission === "edit-automations" ? {
143571
143738
  before: "Manage these in the ",
143572
143739
  linkText: "automations",
@@ -234828,13 +234995,13 @@ import { createHash as createHash11 } from "node:crypto";
234828
234995
  import fs34 from "node:fs/promises";
234829
234996
  import os20 from "node:os";
234830
234997
  import path42 from "node:path";
234831
- var AGENT_CONFIG_SCAN_VERSION, CLAUDE_STATE_VARIANT_PATTERN, nowIso3, trim4, readFileIfExists, statIfExists, pathExistsAsKind, findFirstExistingFile, findFirstExistingDirectory, listClaudeStateVariantPaths, directorySize, sizeForPath, buildMaskedSecret, withLocalItemMetadata, stablePathHash, buildCredentialFileItems, readClaudeStateSource, resolveClaudeFilePath, resolveClaudeDirectoryPath, scanClaudeAgentConfig, scanCodexAgentConfig, buildDefaultSelection, createEmptyDesktopAgentConfigScan, scanDesktopAgentConfig;
234998
+ var AGENT_CONFIG_SCAN_VERSION, CLAUDE_STATE_VARIANT_PATTERN, nowIso3, trim4, readFileIfExists, statIfExists, pathExistsAsKind, findFirstExistingFile, findFirstExistingDirectory, listClaudeStateVariantPaths, directorySize, sizeForPath, buildMaskedSecret, withLocalItemMetadata, stablePathHash, buildCredentialFileItems, readClaudeStateSource, resolveClaudeFilePath, resolveClaudeDirectoryPath, scanClaudeAgentConfig, scanCodexAgentConfig, buildDefaultSelection, createEmptyDesktopAgentConfigScan, upgradeDesktopAgentConfigScan, scanDesktopAgentConfig;
234832
234999
  var init_agentConfigScan = __esm({
234833
235000
  "../../../../shared/initPrep/src/agentConfigScan.mjs"() {
234834
235001
  "use strict";
234835
235002
  init_agentConfigFiles();
234836
235003
  init_devboxCore2();
234837
- AGENT_CONFIG_SCAN_VERSION = 1;
235004
+ AGENT_CONFIG_SCAN_VERSION = 2;
234838
235005
  CLAUDE_STATE_VARIANT_PATTERN = /^\.claude.*\.json$/;
234839
235006
  nowIso3 = () => (/* @__PURE__ */ new Date()).toISOString();
234840
235007
  trim4 = (value) => typeof value === "string" ? value.trim() : "";
@@ -235038,6 +235205,10 @@ var init_agentConfigScan = __esm({
235038
235205
  homeDir: homeDir2,
235039
235206
  relativePath: "settings.json"
235040
235207
  });
235208
+ const settingsSource = parseJsonRecordBestEffort(
235209
+ settingsPath ? await readFileIfExists(settingsPath) : null,
235210
+ settingsPath
235211
+ );
235041
235212
  const portableFileItems = buildClaudePortableFileItems({
235042
235213
  claudeMdPath: await resolveClaudeFilePath({
235043
235214
  configuredConfigDir,
@@ -235061,12 +235232,17 @@ var init_agentConfigScan = __esm({
235061
235232
  relativePath: "agents"
235062
235233
  })
235063
235234
  });
235235
+ const hooksItem = buildClaudeHooksItem({
235236
+ settings: settingsSource.data,
235237
+ settingsPath
235238
+ });
235239
+ const fileItems = hooksItem ? [...portableFileItems, hooksItem] : portableFileItems;
235064
235240
  const classifiedItems = classifyClaudeAgentConfig({
235065
235241
  localState: stateSource.data,
235066
235242
  localRepoRoot
235067
235243
  });
235068
235244
  const items = await Promise.all([
235069
- ...portableFileItems.map(
235245
+ ...fileItems.map(
235070
235246
  (item) => withLocalItemMetadata(item, {
235071
235247
  kind: "claude_file",
235072
235248
  sourcePath: item.path
@@ -235087,7 +235263,10 @@ var init_agentConfigScan = __esm({
235087
235263
  ]);
235088
235264
  return {
235089
235265
  items,
235090
- parseWarnings: stateSource.parseWarnings,
235266
+ parseWarnings: [
235267
+ ...stateSource.parseWarnings,
235268
+ ...settingsSource.parseWarnings
235269
+ ],
235091
235270
  sources: {
235092
235271
  statePath: stateSource.path,
235093
235272
  settingsPath
@@ -235158,6 +235337,49 @@ var init_agentConfigScan = __esm({
235158
235337
  agentConfigSelection: {}
235159
235338
  };
235160
235339
  };
235340
+ upgradeDesktopAgentConfigScan = async ({
235341
+ agentConfig,
235342
+ agentConfigSelection
235343
+ }) => {
235344
+ if (agentConfig?.version !== 1 || !Array.isArray(agentConfig.items)) {
235345
+ return { agentConfig, agentConfigSelection };
235346
+ }
235347
+ const items = [...agentConfig.items];
235348
+ const settingsIndex = items.findIndex(
235349
+ (item2) => item2.id === "claude:settings"
235350
+ );
235351
+ const settingsPath = settingsIndex === -1 ? null : items[settingsIndex].source?.sourcePath ?? items[settingsIndex].path;
235352
+ const hooksItem = buildClaudeHooksItem({
235353
+ settings: parseJsonRecordBestEffort(
235354
+ settingsPath ? await readFileIfExists(settingsPath) : null,
235355
+ settingsPath
235356
+ ).data,
235357
+ settingsPath
235358
+ });
235359
+ if (!hooksItem) {
235360
+ return {
235361
+ agentConfig: { ...agentConfig, version: AGENT_CONFIG_SCAN_VERSION },
235362
+ agentConfigSelection
235363
+ };
235364
+ }
235365
+ const item = await withLocalItemMetadata(hooksItem, {
235366
+ kind: "claude_file",
235367
+ sourcePath: hooksItem.path
235368
+ });
235369
+ items.splice(settingsIndex + 1, 0, item);
235370
+ return {
235371
+ agentConfig: {
235372
+ ...agentConfig,
235373
+ version: AGENT_CONFIG_SCAN_VERSION,
235374
+ items,
235375
+ totalSizeBytes: (agentConfig.totalSizeBytes ?? 0) + item.sizeBytes
235376
+ },
235377
+ agentConfigSelection: {
235378
+ ...agentConfigSelection,
235379
+ [item.id]: agentConfigSelection?.["claude:settings"] === true && item.defaultSelected
235380
+ }
235381
+ };
235382
+ };
235161
235383
  scanDesktopAgentConfig = async ({
235162
235384
  env: env3 = process.env,
235163
235385
  homeDir: homeDir2 = os20.homedir(),
@@ -238827,6 +239049,8 @@ var init_agentConfigBundle = __esm({
238827
239049
  }
238828
239050
  };
238829
239051
  stageClaudeSettingsPayload = async ({
239052
+ includeHooks,
239053
+ includeSettings,
238830
239054
  inventoryAccumulator,
238831
239055
  item,
238832
239056
  manifest,
@@ -238836,7 +239060,11 @@ var init_agentConfigBundle = __esm({
238836
239060
  const bytes = sourcePath ? await readFileIfExists2(sourcePath) : null;
238837
239061
  const parsed = parseJsonRecordBestEffort(bytes, sourcePath ?? item.id);
238838
239062
  manifest.parseWarnings.push(...parsed.parseWarnings);
238839
- const settings = mergeClaudeSettingsForDevbox(parsed.data);
239063
+ const settings = selectClaudeSettingsForDevbox({
239064
+ settings: parsed.data,
239065
+ includeSettings,
239066
+ includeHooks
239067
+ });
238840
239068
  const payloadPath = await stageAgentConfigJsonPayload({
238841
239069
  content: settings,
238842
239070
  inventoryAccumulator,
@@ -239107,8 +239335,10 @@ var init_agentConfigBundle = __esm({
239107
239335
  if (item.category === "credential_file" || item.category === "mcp_server") {
239108
239336
  continue;
239109
239337
  }
239110
- if (item.id === "claude:settings") {
239111
- manifest.claude.settingsPayloadPath = await stageClaudeSettingsPayload({
239338
+ if (item.id === "claude:settings" || item.id === CLAUDE_HOOKS_ITEM_ID) {
239339
+ manifest.claude.settingsPayloadPath ??= await stageClaudeSettingsPayload({
239340
+ includeHooks: selectedItemIds.has(CLAUDE_HOOKS_ITEM_ID),
239341
+ includeSettings: selectedItemIds.has("claude:settings"),
239112
239342
  inventoryAccumulator,
239113
239343
  item,
239114
239344
  manifest,
@@ -248494,6 +248724,7 @@ var init_localPrepService = __esm({
248494
248724
  );
248495
248725
  }
248496
248726
  assertGitSigningReadyForBundle(state.gitSigningSetup ?? null);
248727
+ Object.assign(state, await upgradeDesktopAgentConfigScan(state));
248497
248728
  await cleanupPreparedBundleArtifacts(state.bundle);
248498
248729
  state.phase = "packaging_bundle";
248499
248730
  state.currentMessage = "Preparing approved bundle contents.";
@@ -263466,7 +263697,7 @@ var init_check2 = __esm({
263466
263697
  0
263467
263698
  );
263468
263699
  lines.push(
263469
- `Template maintenance: configured (${String(maintenance.timeoutSeconds)}s timeout; schedule off; no initial run)`
263700
+ `Template maintenance: configured (${String(maintenance.timeoutSeconds)}s timeout; schedule off; setup will test it twice)`
263470
263701
  );
263471
263702
  lines.push(
263472
263703
  `Maintenance watches: ${String(maintenance.watches.length)} ${maintenance.watches.length === 1 ? "repository" : "repositories"}, ${String(watchedPathCount)} ${watchedPathCount === 1 ? "path" : "paths"} (fresh baseline at setup)`
@@ -263861,7 +264092,8 @@ var init_detect = __esm({
263861
264092
  agent: item.agent,
263862
264093
  category: item.category,
263863
264094
  label: item.label,
263864
- defaultSelected: item.defaultSelected
264095
+ defaultSelected: item.defaultSelected,
264096
+ reason: item.reason
263865
264097
  }));
263866
264098
  if (json3) {
263867
264099
  console.log(JSON.stringify({ items }, null, 2));
@@ -263874,6 +264106,9 @@ var init_detect = __esm({
263874
264106
  console.log(
263875
264107
  ` ${item.defaultSelected ? "[default]" : "[not default]"} ${item.id} - ${item.agent}/${item.category}: ${item.label}`
263876
264108
  );
264109
+ if (!item.defaultSelected) {
264110
+ console.log(` ${item.reason}`);
264111
+ }
263877
264112
  }
263878
264113
  return;
263879
264114
  }
@@ -266132,6 +266367,7 @@ var init_seed = __esm({
266132
266367
  push(` # ${unselected.length} detected item(s) not included by default:`);
266133
266368
  for (const item of unselected.slice(0, 8)) {
266134
266369
  push(` # ${item.id} (${item.agent}/${item.category}: ${item.label})`);
266370
+ push(` # ${item.reason}`);
266135
266371
  }
266136
266372
  if (unselected.length > 8) {
266137
266373
  push(` # (${unselected.length - 8} more; see detect agent-config)`);
@@ -266155,22 +266391,25 @@ var init_seed = __esm({
266155
266391
  push("agentThreads:");
266156
266392
  push(" import: none");
266157
266393
  push("");
266158
- const rootRepo = repos.length === 1 && repos[0]?.relPath === "." ? repos[0] : null;
266159
- const startupBranch = rootRepo?.origin === null ? null : normalizeForkStartupBranchName(rootRepo?.originDefaultBranch);
266394
+ const startupScript = buildRecommendedForkStartupScriptForRepositories(
266395
+ repos.map((repo) => ({
266396
+ relativePath: repo.relPath,
266397
+ defaultBranch: repo.origin ? repo.originDefaultBranch : null
266398
+ }))
266399
+ );
266160
266400
  push(
266161
266401
  "# Lifecycle commands run for every devbox created from this Template box."
266162
266402
  );
266403
+ push("# The generated Git block declares each repository's default branch.");
266163
266404
  push(
266164
- "# Keep startup focused on bringing a new devbox up to date. Use teardown"
266405
+ "# Keep its paths in sync with project.repositories. Add application setup"
266165
266406
  );
266166
- push("# only when the project needs cleanup before a devbox is removed.");
266407
+ push("# after that block. Use teardown only for cleanup before removal.");
266167
266408
  push("devboxLifecycle:");
266168
266409
  push(" startupTimeoutSeconds: 60");
266169
- if (rootRepo?.origin && startupBranch) {
266410
+ if (startupScript) {
266170
266411
  push(" startupScript: |");
266171
- for (const line of buildRecommendedForkStartupScript(startupBranch).split(
266172
- "\n"
266173
- )) {
266412
+ for (const line of startupScript.split("\n")) {
266174
266413
  push(` ${line}`);
266175
266414
  }
266176
266415
  } else {
@@ -266179,16 +266418,16 @@ var init_seed = __esm({
266179
266418
  push(" teardownTimeoutSeconds: 30");
266180
266419
  push(' teardownScript: ""');
266181
266420
  push("");
266421
+ push("# Template box maintenance, recommended for most projects. Design the");
266422
+ push("# script and GitHub watch paths together: watch lockfiles and tooling");
266423
+ push("# files, not application source. The script fast-forwards the default");
266182
266424
  push(
266183
- "# Optional Template box maintenance. When enabled, design the script and"
266184
- );
266185
- push(
266186
- "# GitHub watch paths together so repository changes trigger the upkeep"
266425
+ "# branch, installs without prompts, and fails clearly on local changes"
266187
266426
  );
266188
266427
  push(
266189
- "# they require. Setup saves a fresh baseline, leaves the schedule off,"
266428
+ "# or another branch. Setup tests it twice, saves a fresh baseline, and"
266190
266429
  );
266191
- push("# and does not run the script immediately.");
266430
+ push("# leaves the schedule off. See the manifest guide for requirements.");
266192
266431
  push(
266193
266432
  "# Set timeoutSeconds to an integer from 1 through 480 (at most 8 minutes)."
266194
266433
  );
@@ -266343,7 +266582,8 @@ var init_start = __esm({
266343
266582
  label: item.label,
266344
266583
  agent: item.agent,
266345
266584
  category: item.category,
266346
- defaultSelected: item.defaultSelected
266585
+ defaultSelected: item.defaultSelected,
266586
+ reason: item.reason
266347
266587
  })) ?? [],
266348
266588
  agentThreadItems: threadScan?.agentThreadHistory.items.filter((item) => item["scope"] === "current_project").map((item) => ({
266349
266589
  id: item.id,
@@ -269826,7 +270066,8 @@ var init_remote2 = __esm({
269826
270066
  databaseCopyManifest,
269827
270067
  stagedDatabaseDumpDir,
269828
270068
  stagedDatabaseDumpManifestPath,
269829
- databaseRestoreStatusPath
270069
+ databaseRestoreStatusPath,
270070
+ templateMaintenance: null
269830
270071
  });
269831
270072
  };
269832
270073
  openBrowser2 = async (url3) => openBrowser(url3);
@@ -287909,7 +288150,7 @@ var init_finalizeFlow = __esm({
287909
288150
  import { randomUUID as randomUUID34 } from "node:crypto";
287910
288151
  import fs75 from "node:fs/promises";
287911
288152
  import path96 from "node:path";
287912
- var throwInitCanceled, resolveDefaultProjectRoot, requireInteractiveConsent, promptProjectRoot, confirmSkippedRepos, findAncestorProjectMarker2, confirmAncestorProject, readStandaloneChildProjectIds, confirmStandaloneChildProjects, resolveReadOnlyProjectId, formatZeroRepoError, buildStatusSelection, claimProjectIdentity, resolveInitProjectSelection;
288153
+ var DETECTING_PROJECT_TITLE, throwInitCanceled, resolveDefaultProjectRoot, requireInteractiveConsent, promptProjectRoot, confirmSkippedRepos, findAncestorProjectMarker2, confirmAncestorProject, readStandaloneChildProjectIds, confirmStandaloneChildProjects, resolveReadOnlyProjectId, formatZeroRepoError, buildStatusSelection, claimProjectIdentity, resolveInitProjectSelection;
287913
288154
  var init_projectSelection3 = __esm({
287914
288155
  "src/devbox/commands/init/projectSelection.ts"() {
287915
288156
  "use strict";
@@ -287917,6 +288158,7 @@ var init_projectSelection3 = __esm({
287917
288158
  init_devboxCore();
287918
288159
  init_devboxCore();
287919
288160
  init_repo2();
288161
+ DETECTING_PROJECT_TITLE = "Detecting project";
287920
288162
  throwInitCanceled = () => {
287921
288163
  Pt("Init canceled.");
287922
288164
  throw new Error("Init canceled.");
@@ -287939,7 +288181,8 @@ var init_projectSelection3 = __esm({
287939
288181
  };
287940
288182
  promptProjectRoot = async ({
287941
288183
  initialProjectRoot,
287942
- parsed
288184
+ parsed,
288185
+ status
287943
288186
  }) => {
287944
288187
  if (parsed.yes) {
287945
288188
  return initialProjectRoot;
@@ -287948,6 +288191,7 @@ var init_projectSelection3 = __esm({
287948
288191
  message: `Use ${initialProjectRoot} as the project for this Template box?`,
287949
288192
  parsed
287950
288193
  });
288194
+ status.stop();
287951
288195
  let current = initialProjectRoot;
287952
288196
  for (; ; ) {
287953
288197
  const answer = await qt({
@@ -287962,6 +288206,7 @@ var init_projectSelection3 = __esm({
287962
288206
  throwInitCanceled();
287963
288207
  }
287964
288208
  if (answer === "yes") {
288209
+ status.stage(DETECTING_PROJECT_TITLE);
287965
288210
  return current;
287966
288211
  }
287967
288212
  const next = await Qt({
@@ -287977,7 +288222,8 @@ var init_projectSelection3 = __esm({
287977
288222
  };
287978
288223
  confirmSkippedRepos = async ({
287979
288224
  discovery,
287980
- parsed
288225
+ parsed,
288226
+ status
287981
288227
  }) => {
287982
288228
  if (discovery.skippedRepos.length === 0) return;
287983
288229
  const indexed = discovery.repos.map((repo) => repo.relPath).join(", ");
@@ -287985,6 +288231,7 @@ var init_projectSelection3 = __esm({
287985
288231
  const message = `This project has repos boxes.dev can index (${indexed || "none"}) and repos boxes.dev will skip (${skipped}).`;
287986
288232
  if (parsed.yes) return;
287987
288233
  requireInteractiveConsent({ message, parsed });
288234
+ status.stop();
287988
288235
  const proceed = await Mt2({
287989
288236
  message: `${message} Continue with the indexed repos only?`,
287990
288237
  active: "Continue",
@@ -287997,6 +288244,7 @@ var init_projectSelection3 = __esm({
287997
288244
  if (!proceed) {
287998
288245
  throw new Error("Init canceled.");
287999
288246
  }
288247
+ status.stage(DETECTING_PROJECT_TITLE);
288000
288248
  };
288001
288249
  findAncestorProjectMarker2 = async (projectRoot) => {
288002
288250
  let current = path96.dirname(projectRoot);
@@ -288015,11 +288263,13 @@ var init_projectSelection3 = __esm({
288015
288263
  confirmAncestorProject = async ({
288016
288264
  ancestor,
288017
288265
  parsed,
288018
- projectRoot
288266
+ projectRoot,
288267
+ status
288019
288268
  }) => {
288020
288269
  const message = `${projectRoot} is inside an existing boxes.dev project at ${ancestor.projectRoot}.`;
288021
288270
  if (parsed.yes) return;
288022
288271
  requireInteractiveConsent({ message, parsed });
288272
+ status.stop();
288023
288273
  const proceed = await Mt2({
288024
288274
  message: `${message} Create a separate overlapping project anyway?`,
288025
288275
  active: "Create separate project",
@@ -288032,6 +288282,7 @@ var init_projectSelection3 = __esm({
288032
288282
  if (!proceed) {
288033
288283
  throw new Error("Init canceled.");
288034
288284
  }
288285
+ status.stage(DETECTING_PROJECT_TITLE);
288035
288286
  };
288036
288287
  readStandaloneChildProjectIds = async (discovery) => {
288037
288288
  if (discovery.projectRootIsGitRepo) return [];
@@ -288047,12 +288298,14 @@ var init_projectSelection3 = __esm({
288047
288298
  };
288048
288299
  confirmStandaloneChildProjects = async ({
288049
288300
  childProjects,
288050
- parsed
288301
+ parsed,
288302
+ status
288051
288303
  }) => {
288052
288304
  if (childProjects.length === 0 || parsed.yes) return;
288053
288305
  const childList = childProjects.map((entry) => `${entry.relPath} (${entry.projectId})`).join(", ");
288054
288306
  const message = `Some child repos are already initialized as standalone boxes.dev projects: ${childList}.`;
288055
288307
  requireInteractiveConsent({ message, parsed });
288308
+ status.stop();
288056
288309
  const proceed = await Mt2({
288057
288310
  message: `${message} Include them in this multi-repo project without changing their standalone project ids?`,
288058
288311
  active: "Include repos",
@@ -288065,6 +288318,7 @@ var init_projectSelection3 = __esm({
288065
288318
  if (!proceed) {
288066
288319
  throw new Error("Init canceled.");
288067
288320
  }
288321
+ status.stage(DETECTING_PROJECT_TITLE);
288068
288322
  };
288069
288323
  resolveReadOnlyProjectId = async (discovery) => {
288070
288324
  if (discovery.projectRootIsGitRepo) {
@@ -288127,14 +288381,15 @@ var init_projectSelection3 = __esm({
288127
288381
  return false;
288128
288382
  };
288129
288383
  resolveInitProjectSelection = async ({
288130
- parsed
288384
+ parsed,
288385
+ status
288131
288386
  }) => {
288132
288387
  const initialProjectRoot = await resolveDefaultProjectRoot(process.cwd());
288133
- const projectRoot = parsed.status ? initialProjectRoot : await promptProjectRoot({ initialProjectRoot, parsed });
288388
+ const projectRoot = parsed.status ? initialProjectRoot : await promptProjectRoot({ initialProjectRoot, parsed, status });
288134
288389
  if (!parsed.status) {
288135
288390
  const ancestor = await findAncestorProjectMarker2(projectRoot);
288136
288391
  if (ancestor) {
288137
- await confirmAncestorProject({ ancestor, parsed, projectRoot });
288392
+ await confirmAncestorProject({ ancestor, parsed, projectRoot, status });
288138
288393
  }
288139
288394
  }
288140
288395
  const discovery = await discoverProjectRepos(projectRoot);
@@ -288152,10 +288407,11 @@ var init_projectSelection3 = __esm({
288152
288407
  "This linked Git worktree may be missing local config such as .env files. Continue if it has the config your app needs, or restart setup from the checkout where your app runs."
288153
288408
  );
288154
288409
  }
288155
- await confirmSkippedRepos({ discovery, parsed });
288410
+ await confirmSkippedRepos({ discovery, parsed, status });
288156
288411
  await confirmStandaloneChildProjects({
288157
288412
  childProjects: await readStandaloneChildProjectIds(discovery),
288158
- parsed
288413
+ parsed,
288414
+ status
288159
288415
  });
288160
288416
  const existingProjectId = await resolveReadOnlyProjectId(discovery);
288161
288417
  const projectId = existingProjectId ?? randomUUID34();
@@ -290917,8 +291173,8 @@ var init_init = __esm({
290917
291173
  }
290918
291174
  const repoDetection = await runInitStep({
290919
291175
  enabled: progressEnabled,
290920
- title: "Detecting project",
290921
- fn: async () => await resolveInitProjectSelection({ parsed })
291176
+ title: DETECTING_PROJECT_TITLE,
291177
+ fn: async ({ status }) => await resolveInitProjectSelection({ parsed, status })
290922
291178
  });
290923
291179
  const { accountScope } = await runInitStep({
290924
291180
  enabled: progressEnabled,
@@ -293209,9 +293465,13 @@ var init_mcp = __esm({
293209
293465
  `${connection.displayName} was added, but connecting it to the agents didn't finish: ${reason}`
293210
293466
  );
293211
293467
  }
293468
+ const failure = `${connection.displayName} was added, but signing in for ${MCP_AGENT_LABELS[signingIn]} didn't finish: ${reason}`;
293469
+ if (error55 instanceof McpOAuthCompanionError && error55.code === "client_registration_unsupported") {
293470
+ throw new Error(failure);
293471
+ }
293212
293472
  const selector = readableSelector(connection, await session.listAll());
293213
293473
  throw new Error(
293214
- `${connection.displayName} was added, but signing in for ${MCP_AGENT_LABELS[signingIn]} didn't finish: ${reason} To try again, run: dvb mcp authorize ${selector} --agent ${signingIn}`
293474
+ `${failure} To try again, run: dvb mcp authorize ${selector} --agent ${signingIn}`
293215
293475
  );
293216
293476
  }
293217
293477
  connection = await session.get(created.connectionId);
@@ -300991,4 +301251,4 @@ react/cjs/react-jsx-runtime.development.js:
300991
301251
  *)
300992
301252
  */
300993
301253
 
300994
- //# debugId=37db650b-046c-51ef-b444-0f7c0907da74
301254
+ //# debugId=87fe665b-b866-5692-8a17-9feb9f823c01