@vite-hub/workspace 0.7.0 → 0.9.0

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 (48) hide show
  1. package/README.md +1 -1
  2. package/dist/blob-database.js +2 -2
  3. package/dist/checkout.d.ts +0 -6
  4. package/dist/checkout.js +1 -30
  5. package/dist/{config--ZzAvhMp.js → config-B-S_Z4G0.js} +6 -15
  6. package/dist/durability.js +2 -2
  7. package/dist/{error-diagnostics-CHgE8TQM.js → error-diagnostics-Dn4sQcKL.js} +3 -4
  8. package/dist/{file-DQ5-TBTD.js → file-B3KxJyxb.js} +1 -1
  9. package/dist/{files-D1UkSjzX.js → files-DSOjTK36.js} +1 -1
  10. package/dist/files.d.ts +0 -6
  11. package/dist/files.js +4 -4
  12. package/dist/{github-BECfOMaw.js → github-DDUrrKt8.js} +3 -3
  13. package/dist/{glob-BIsxLusH.js → glob-BfZVRPCk.js} +1 -1
  14. package/dist/{host-BYBRcSnh.js → host-CcCDXyJI.js} +3 -3
  15. package/dist/hosted-vercel-blob.js +4 -4
  16. package/dist/hosted.js +5 -20
  17. package/dist/index.js +12 -12
  18. package/dist/internal/path.js +1 -1
  19. package/dist/internal/workspace.js +2 -2
  20. package/dist/{lifecycle-BK7WNfcP.js → lifecycle-CXiS7Dks.js} +4 -4
  21. package/dist/loader.js +1 -1
  22. package/dist/{mcp-resources-F4SJF4_P.js → mcp-resources-B2J0YCD2.js} +1 -1
  23. package/dist/{metadata-target-DPGF6L68.js → metadata-target-oc00D8g2.js} +2 -8
  24. package/dist/{object-CAK6UYR5.js → object-DNOrQSl5.js} +5 -1
  25. package/dist/{operations-DJ_7W0gs.js → operations-DWPC8nrk.js} +3 -11
  26. package/dist/operations.js +22 -16
  27. package/dist/{provider-fcI7kJ5k.js → provider-DBJeUNFI.js} +27 -28
  28. package/dist/providers/github/store.js +3 -35
  29. package/dist/{registry-CFeUQsja.js → registry-CqDWpDe9.js} +2 -2
  30. package/dist/{request-scope-jH4H0Sbm.js → request-scope-DZJbe-tP.js} +0 -2
  31. package/dist/{rule-keys-xMpiTLq1.js → rule-keys-DQYcSewo.js} +1 -1
  32. package/dist/{rules-DYQCKYdt.js → rules-sItt6TP-.js} +2 -10
  33. package/dist/runtime/request.js +1 -1
  34. package/dist/runtime/state.js +6 -6
  35. package/dist/runtime/workspace.js +1 -1
  36. package/dist/runtime.js +13 -13
  37. package/dist/server.js +4 -4
  38. package/dist/{shared-PFnkYidS.js → shared-CaAKcBBr.js} +10 -14
  39. package/dist/source-metadata.js +3 -3
  40. package/dist/{sync-CUkCuP_g.js → sync-ztyvA0Va.js} +3 -3
  41. package/dist/test.js +1 -1
  42. package/dist/{use-BCMkT-kC.js → use-BskfWVjx.js} +6 -6
  43. package/dist/{use-tools-CcXs2hFA.js → use-tools-D_eorKu1.js} +3 -3
  44. package/dist/{utils-Bv1NBg8r.js → utils-BoFJcaT1.js} +2 -3
  45. package/dist/vite.js +155 -121
  46. package/dist/{workspace-D1m00MCM.js → workspace-Dbo5iYIc.js} +10 -10
  47. package/dist/{workspace-inspection-scanner-BlJ8bCAB.js → workspace-inspection-scanner-6QrvwVJG.js} +0 -5
  48. package/package.json +12 -12
@@ -1,9 +1,9 @@
1
1
  import { v as redactInspectionText } from "./operations.js";
2
2
  import { i as workspaceConflict } from "./internal/path.js";
3
- import { t as workspaceErrorDiagnostics } from "./error-diagnostics-CHgE8TQM.js";
4
- import { d as normalizeHistoryPath } from "./utils-Bv1NBg8r.js";
3
+ import { t as workspaceErrorDiagnostics } from "./error-diagnostics-Dn4sQcKL.js";
4
+ import { d as normalizeHistoryPath } from "./utils-BoFJcaT1.js";
5
5
  import { r as contentToBytes } from "./path-DYHw5KNk.js";
6
- import { r as useWorkspaceFiles } from "./use-BCMkT-kC.js";
6
+ import { r as useWorkspaceFiles } from "./use-BskfWVjx.js";
7
7
  import { readDerivedFrom, staleDerivedFiles } from "./lineage.js";
8
8
  // src/runtime/operations.ts
9
9
  const invalidRequestCodes = /* @__PURE__ */ new Set([
@@ -12,7 +12,6 @@ const invalidRequestCodes = /* @__PURE__ */ new Set([
12
12
  "WORKSPACE_R0070",
13
13
  "WORKSPACE_R0071"
14
14
  ]);
15
- /** Gives an operation error the HTTP status and the redacted message that the CLI and the Console report. */
16
15
  function withStatus(error, status, message = error.message) {
17
16
  return Object.defineProperties(error, {
18
17
  status: {
@@ -29,7 +28,6 @@ function withStatus(error, status, message = error.message) {
29
28
  }
30
29
  });
31
30
  }
32
- /** The status of each Workspace code that the operations throw. A failure that sets its own client status keeps it. */
33
31
  const operationStatus = {
34
32
  WORKSPACE_CONFLICT: 409,
35
33
  WORKSPACE_FORBIDDEN: 403,
@@ -37,7 +35,6 @@ const operationStatus = {
37
35
  WORKSPACE_NOT_FOUND: 404,
38
36
  WORKSPACE_SOURCE_READ_ONLY: 403
39
37
  };
40
- /** Reads the code of a ViteHub error or a Workspace diagnostic. */
41
38
  function errorCode(error) {
42
39
  const code = Object(error) === error ? Reflect.get(Object(error), "code") : void 0;
43
40
  return typeof code === "string" ? code : void 0;
@@ -46,7 +43,6 @@ function isoTime(value) {
46
43
  const time = Date.parse(value);
47
44
  return Number.isNaN(time) ? value : new Date(time).toISOString();
48
45
  }
49
- /** The author of a revision: a string, or a person `{ id, name, email }` as Content and `vitehub push` record it. */
50
46
  function authorName(author) {
51
47
  if (typeof author === "string") return author || void 0;
52
48
  if (Object(author) !== author) return void 0;
@@ -174,7 +170,6 @@ function decodeContent(file) {
174
170
  if (file.encoding === "utf8") return file.content;
175
171
  return Uint8Array.from(atob(file.content), (character) => character.charCodeAt(0));
176
172
  }
177
- /** The files of a revision by path, with the digest of each. */
178
173
  async function filesOf(view) {
179
174
  const files = /* @__PURE__ */ new Map();
180
175
  for (const entry of await view.list("", { recursive: true })) if (entry.type === "file") files.set(entry.path, entry);
@@ -231,14 +226,12 @@ async function listChanges(workspace, history, request) {
231
226
  }
232
227
  return result;
233
228
  }
234
- /** The new content of a file. A file that exists at the base revision keeps its media type and metadata. */
235
229
  function replacement(content, before) {
236
230
  const file = { content };
237
231
  if (before?.mediaType) file.mediaType = before.mediaType;
238
232
  if (before?.metadata) file.metadata = Object.fromEntries(Object.entries(before.metadata).filter(([key]) => key !== "source"));
239
233
  return file;
240
234
  }
241
- /** The caller of a commit in the shape that Content records: the surface, the person, and the Agent Actor. */
242
235
  function callerMetadata(context) {
243
236
  const author = Object.fromEntries([
244
237
  "id",
@@ -254,7 +247,6 @@ function callerMetadata(context) {
254
247
  ...context.actor?.id ? { agent: { actor: context.actor.id } } : {}
255
248
  };
256
249
  }
257
- /** An Agent tool or an MCP client: a model decides the call, for the person it works for. */
258
250
  function modelSurface(context) {
259
251
  return context.surface === "agent" || context.surface === "mcp";
260
252
  }
@@ -1,6 +1,7 @@
1
1
  import { t as internalErrorDiagnostics } from "./error-diagnostics-CsiNo_oI.js";
2
- import { n as isRecordOrFunction, t as isRecord } from "./object-CAK6UYR5.js";
2
+ import { n as isRecord, r as isRecordOrFunction } from "./object-DNOrQSl5.js";
3
3
  import { t as workspaceCommitRequestBytes } from "./results-z-HpV9EP.js";
4
+ import "node:module";
4
5
  import { basename, dirname, join, parse, resolve } from "node:path";
5
6
  import { mkdirSync, readFileSync, realpathSync, rmSync, statSync, writeFileSync } from "node:fs";
6
7
  import "node:fs/promises";
@@ -433,12 +434,6 @@ function createNativePackageLoading(ssrPackageEntries = []) {
433
434
  };
434
435
  }
435
436
  const nativePackageDistFile = /\/node_modules\/@vite-hub\/(?:agent|connections|runtime|workspace)\/dist\/.+\.js$/;
436
- /**
437
- * Generated code imports the runtime files of its owner by path. Vite gives Node only bare package names, so in the
438
- * Nitro environment of `vite dev` it would inline a second copy of a package that Node already loaded, with its own
439
- * registries. This returns a module that lets Node load the file instead, so the app and the generated code share one
440
- * instance. Use it as the `load` hook result for the file. It returns nothing for other files and environments.
441
- */
442
437
  function loadNativePackageModule(id) {
443
438
  const file = id.startsWith("file:") ? fileURLToPath(id) : id;
444
439
  if (!nativePackageDistFile.test(file.replace(/\\/g, "/"))) return;
@@ -521,14 +516,27 @@ function isMissingProjectMarker(error) {
521
516
  const code = error.code;
522
517
  return code === "ENOENT" || code === "ENOTDIR";
523
518
  }
524
- function viteHubEnvPublicModulePath(root) {
525
- return resolve(root, ".vitehub", "env", "public.mjs");
519
+ /**
520
+ * The generated-code folder of an owner, relative to the project root: `.vitehub` for the app, `.vitehub/cli` and
521
+ * `.vitehub/node-test` for the others. State that the processes share, such as the Email outbox or the Env secret,
522
+ * stays in `.vitehub`, and so do the declaration files that TypeScript reads, because their contents follow only the
523
+ * Definitions.
524
+ */
525
+ function viteHubGeneratedCodeDir(owner = "app") {
526
+ return owner === "app" ? ".vitehub" : `.vitehub/${owner}`;
527
+ }
528
+ /** The absolute generated-code folder of an owner. See {@link viteHubGeneratedCodeDir}. */
529
+ function viteHubGeneratedCodeRoot(projectRoot, owner = "app") {
530
+ return resolve(projectRoot, viteHubGeneratedCodeDir(owner));
531
+ }
532
+ function viteHubEnvPublicModulePath(root, owner) {
533
+ return resolve(viteHubGeneratedCodeRoot(root, owner), "env", "public.mjs");
526
534
  }
527
- function viteHubEnvServerModulePath(root) {
528
- return resolve(root, ".vitehub", "env", "server.mjs");
535
+ function viteHubEnvServerModulePath(root, owner) {
536
+ return resolve(viteHubGeneratedCodeRoot(root, owner), "env", "server.mjs");
529
537
  }
530
- function viteHubEnvDescriptionModulePath(root) {
531
- return resolve(root, ".vitehub", "env", "description.mjs");
538
+ function viteHubEnvDescriptionModulePath(root, owner) {
539
+ return resolve(viteHubGeneratedCodeRoot(root, owner), "env", "description.mjs");
532
540
  }
533
541
  function createViteHubEnvImportAliases(root) {
534
542
  return {
@@ -692,7 +700,6 @@ function base64url(bytes) {
692
700
  for (const byte of bytes) binary += String.fromCharCode(byte);
693
701
  return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
694
702
  }
695
- /** The bytes of a base64url value, or `undefined` when it is not canonical base64url without padding. */
696
703
  function fromBase64url(value) {
697
704
  if (!/^[\w-]*$/.test(value) || value.length % 4 === 1) return void 0;
698
705
  const bytes = Uint8Array.from(atob(value.replace(/-/g, "+").replace(/_/g, "/")), (character) => character.charCodeAt(0));
@@ -719,7 +726,6 @@ function consoleSignedText(fields) {
719
726
  fields.caller
720
727
  ].join("\n");
721
728
  }
722
- /** The path and query of a URL, the part of the request target that the signature covers. */
723
729
  function requestTarget(url) {
724
730
  return `${url.pathname}${url.search}`;
725
731
  }
@@ -1104,7 +1110,7 @@ function table(rows) {
1104
1110
  return rows.map((row) => row.map((cell, column) => column === row.length - 1 ? cell : cell.padEnd(widths[column])).join(" ")).join("\n");
1105
1111
  }
1106
1112
  // src/operations.ts
1107
- const runtime = () => import("./operations-DJ_7W0gs.js");
1113
+ const runtime = () => import("./operations-DWPC8nrk.js");
1108
1114
  const name = v.pipe(v.string(), v.check((value) => value.trim() !== "", "Name a Workspace."));
1109
1115
  const nonEmpty = (message) => v.pipe(v.string(), v.check((value) => value !== "", message));
1110
1116
  function defineWorkspaceOperation(definition, kind = "read") {
@@ -1,4 +1,4 @@
1
- import { M as readForgeEnv, j as forgeEnv, t as assertNoGitHubRepositoryKey } from "./shared-PFnkYidS.js";
1
+ import { M as readForgeEnv, j as forgeEnv, t as assertNoGitHubRepositoryKey } from "./shared-CaAKcBBr.js";
2
2
  import { a as workspaceConflictError, o as workspaceError, t as assertWorkspaceDigest } from "./internal/path.js";
3
3
  import { createGitHubWorkspaceStore } from "./providers/github/store.js";
4
4
  import { t as getWorkspaceRuntimeConfig } from "./config-CsgNNVAI.js";
@@ -8,7 +8,7 @@ import { a as isExcludedWorkspacePath, d as resolveInside, f as sha256, l as nor
8
8
  import { a as provideWorkspaceStoreTarget } from "./vitehub-grants-Co713QTg.js";
9
9
  import { a as replacementRecoveryError, i as replaceStorePath } from "./replacement-CVZVsflC.js";
10
10
  import { r as vitehubOwnedPrefix, t as createMemoryWorkspaceStore } from "./memory-BCZl_ZsJ.js";
11
- import { t as workspaceErrorDiagnostics } from "./error-diagnostics-CHgE8TQM.js";
11
+ import { t as workspaceErrorDiagnostics } from "./error-diagnostics-Dn4sQcKL.js";
12
12
  import { basename, dirname, join, relative, resolve, sep } from "node:path";
13
13
  import { createHash, randomUUID } from "node:crypto";
14
14
  import { constants, createReadStream, createWriteStream, readFileSync, readlinkSync } from "node:fs";
@@ -574,7 +574,6 @@ async function withWorkspacePathLock(root, path, operation, readOnly = false, he
574
574
  function isGitMetadataName(name) {
575
575
  return name === ".git" || process.platform === "win32" && name.toLowerCase() === ".git";
576
576
  }
577
- /** Check whether a path belongs to a Git worktree before classifying Git errors. */
578
577
  async function hasGitMetadata(root) {
579
578
  let current = resolve(root);
580
579
  while (true) {
@@ -587,7 +586,6 @@ async function hasGitMetadata(root) {
587
586
  current = parent;
588
587
  }
589
588
  }
590
- /** Paths that Git ignores under a checkout root. Ignored directories are listed once, not descended. */
591
589
  async function gitIgnoredWorkspacePaths(root) {
592
590
  const { execFile } = await import("node:child_process");
593
591
  const gitMetadata = await hasGitMetadata(root);
@@ -622,7 +620,6 @@ async function gitIgnoredWorkspacePaths(root) {
622
620
  resolveOutput(stdout);
623
621
  }))).split("\0").filter(Boolean).map((path) => path.replace(/\/$/, ""))];
624
622
  }
625
- /** Include ignore rules from Git roots that contain a non-root listing prefix. */
626
623
  async function gitIgnoredWorkspacePathsForPrefix(root, current, excluded) {
627
624
  const { relative, sep } = await import("node:path");
628
625
  const relativePrefix = relative(root, current);
@@ -692,11 +689,6 @@ async function prepareProcessMetadataRoot(root) {
692
689
  }
693
690
  await prepared;
694
691
  }
695
- /**
696
- * Keeps the lock order of withWorkspacePathLock in memory: shared reads on
697
- * each parent path and an exclusive lock on the target path for a write. Use
698
- * it only for a store root that one process owns.
699
- */
700
692
  async function withProcessPathLock(root, path, operation, readOnly = false) {
701
693
  const parts = normalizeWorkspacePath(path).split("/").filter(Boolean);
702
694
  const paths = parts.map((_, index) => parts.slice(0, index + 1).join("/"));
@@ -1223,25 +1215,33 @@ var LocalWorkspaceStore = class {
1223
1215
  groups.set(key, group);
1224
1216
  }
1225
1217
  const independent = this.#processLocks ? filtered.map((entry) => [entry]) : [...groups.values()];
1226
- for (let index = 0; index < independent.length; index += 64) await Promise.all(independent.slice(index, index + 64).map(async (group) => {
1227
- if (this.#processLocks) {
1228
- for (const entry of group) {
1229
- const info = await this.#pathLock(this.root, entry.path, () => this.#stat(entry.path, includeDigest), true);
1230
- if (info) entries.push(info);
1218
+ for (let index = 0; index < independent.length; index += 64) {
1219
+ const batch = independent.slice(index, index + 64).map(async (group) => {
1220
+ if (this.#processLocks) {
1221
+ for (const entry of group) {
1222
+ const info = await this.#pathLock(this.root, entry.path, () => this.#stat(entry.path, includeDigest), true);
1223
+ if (info) entries.push(info);
1224
+ }
1225
+ return;
1231
1226
  }
1232
- return;
1227
+ const heldReadPrefix = normalizedPrefix || group[0].path.split("/")[0];
1228
+ let offset = 0;
1229
+ while (offset < group.length) await withWorkspacePathLock(this.root, heldReadPrefix, async () => {
1230
+ const startedAt = Date.now();
1231
+ do {
1232
+ const entry = group[offset++];
1233
+ const info = await withWorkspacePathLock(this.root, entry.path, () => this.#stat(entry.path, includeDigest), true, heldReadPrefix);
1234
+ if (info) entries.push(info);
1235
+ } while (offset < group.length && Date.now() - startedAt < readBatchDurationMs);
1236
+ }, true);
1237
+ });
1238
+ try {
1239
+ await Promise.all(batch);
1240
+ } catch (error) {
1241
+ await Promise.allSettled(batch);
1242
+ throw error;
1233
1243
  }
1234
- const heldReadPrefix = normalizedPrefix || group[0].path.split("/")[0];
1235
- let offset = 0;
1236
- while (offset < group.length) await withWorkspacePathLock(this.root, heldReadPrefix, async () => {
1237
- const startedAt = Date.now();
1238
- do {
1239
- const entry = group[offset++];
1240
- const info = await withWorkspacePathLock(this.root, entry.path, () => this.#stat(entry.path, includeDigest), true, heldReadPrefix);
1241
- if (info) entries.push(info);
1242
- } while (offset < group.length && Date.now() - startedAt < readBatchDurationMs);
1243
- }, true);
1244
- }));
1244
+ }
1245
1245
  return entries.sort((a, b) => a.path.localeCompare(b.path));
1246
1246
  }
1247
1247
  async glob(pattern, options = {}) {
@@ -1594,7 +1594,6 @@ const workspaceStoreDrivers = /* @__PURE__ */ new Set([
1594
1594
  "memory",
1595
1595
  "vercel"
1596
1596
  ]);
1597
- /** Driver names that ViteHub renamed to the host name. `npx @vite-hub/codemods driver-key` moves them. */
1598
1597
  const renamedWorkspaceStoreDrivers = /* @__PURE__ */ new Map([["cloudflare-artifacts", "cloudflare"], ["vercel-blob", "vercel"]]);
1599
1598
  function normalizeWorkspaceStoreOptions(store, input = {}) {
1600
1599
  if (isWorkspaceStore(store)) return;
@@ -1,12 +1,12 @@
1
1
  import { i as workspaceConflict, n as isWorkspaceConflict, normalizeSafeWorkspacePath, o as workspaceError, t as assertWorkspaceDigest } from "../../internal/path.js";
2
2
  import { t as createWorkspaceGlobMatcher } from "../../glob-BIg9O4yY.js";
3
3
  import { a as isExcludedWorkspacePath, c as normalizeSafeWorkspacePattern, i as decodeFile, l as normalizeWorkspacePath, n as contentStreamToBytes, r as contentToBytes } from "../../path-DYHw5KNk.js";
4
- import { d as normalizeHistoryPath, f as normalizeHistoryRef, m as rejectHistoryHead, n as createSnapshotFromEntries, p as readHistoryDeleteRef, r as diffSnapshots, u as historyConflict } from "../../utils-Bv1NBg8r.js";
4
+ import { d as normalizeHistoryPath, f as normalizeHistoryRef, m as rejectHistoryHead, n as createSnapshotFromEntries, p as readHistoryDeleteRef, r as diffSnapshots, u as historyConflict } from "../../utils-BoFJcaT1.js";
5
5
  import { t as workspaceStoreDiscard } from "../../discard-BkoLmmmN.js";
6
6
  import { a as provideWorkspaceStoreTarget, n as provideWorkspaceRevisionMaterializer } from "../../vitehub-grants-Co713QTg.js";
7
7
  import { i as replaceStorePath } from "../../replacement-CVZVsflC.js";
8
- import { C as githubKVKey, D as writeWorkspaceKV, O as BoundedMap, S as resolveGitHubRootOption, T as readWorkspaceKV, _ as requireGitHubOption, a as gitFileMode, b as resolveGitHubRefsOption, c as githubRequestStatus, d as preloadGitHubFiles, f as readCurrentHead, g as readGitHubFile, i as gitBlobSha, l as joinGitPath, m as readGitHubBranchState, n as commitGitHubChanges, o as githubBranchMovedConflict, p as readGitHubArchive, r as connectGitHubRepository, s as githubRequest, t as assertNoGitHubRepositoryKey, u as loadForge, v as resolveGitHubBranchOption, x as resolveGitHubRepositoryOption, y as resolveGitHubCredential } from "../../shared-PFnkYidS.js";
9
- import { t as workspaceErrorDiagnostics } from "../../error-diagnostics-CHgE8TQM.js";
8
+ import { C as githubKVKey, D as writeWorkspaceKV, O as BoundedMap, S as resolveGitHubRootOption, T as readWorkspaceKV, _ as requireGitHubOption, a as gitFileMode, b as resolveGitHubRefsOption, c as githubRequestStatus, d as preloadGitHubFiles, f as readCurrentHead, g as readGitHubFile, i as gitBlobSha, l as joinGitPath, m as readGitHubBranchState, n as commitGitHubChanges, o as githubBranchMovedConflict, p as readGitHubArchive, r as connectGitHubRepository, s as githubRequest, t as assertNoGitHubRepositoryKey, u as loadForge, v as resolveGitHubBranchOption, x as resolveGitHubRepositoryOption, y as resolveGitHubCredential } from "../../shared-CaAKcBBr.js";
9
+ import { t as workspaceErrorDiagnostics } from "../../error-diagnostics-Dn4sQcKL.js";
10
10
  import { ViteHubError } from "@vite-hub/runtime";
11
11
  import { lookup } from "mrmime";
12
12
  import { posix } from "node:path";
@@ -153,7 +153,6 @@ const reservedTrailerPattern = /^Vitehub-Metadata:/m;
153
153
  /** The most bytes of commit metadata as JSON, and of a commit message, that the Store writes. */
154
154
  const githubMaxMetadataBytes = 65536;
155
155
  const githubMaxMessageBytes = 16384;
156
- /** Paths per GitHub file history request. */
157
156
  const lastChangedBatch = 100;
158
157
  const lastChangedHistoryLimit = 100;
159
158
  const pathHistory = v.object({ nodes: v.array(v.object({
@@ -177,10 +176,6 @@ function isNoHistoryError(error) {
177
176
  const status = githubRequestStatus(error);
178
177
  return status === 404 || status === 409;
179
178
  }
180
- /**
181
- * GitHub answers a compare of two commits without a merge base with 404 "No common ancestor between <base> and <head>."
182
- * Any other failure, such as a 422 "Validation failed, or the endpoint has been spammed", proves nothing.
183
- */
184
179
  function isUnrelatedHistoryError(error) {
185
180
  for (let current = error; current instanceof Error; current = current.cause) {
186
181
  const body = Reflect.get(current, "body");
@@ -188,10 +183,6 @@ function isUnrelatedHistoryError(error) {
188
183
  }
189
184
  return false;
190
185
  }
191
- /**
192
- * GitHub answers a lookup of a commit that the repository does not have with 422 "No commit found for SHA: <sha>." Any
193
- * other failure, such as a 422 "Validation failed, or the endpoint has been spammed", proves nothing.
194
- */
195
186
  function isMissingCommitError(error) {
196
187
  const status = githubRequestStatus(error);
197
188
  if (status !== 404 && status !== 422) return false;
@@ -212,7 +203,6 @@ function pageFromCursor(ref, cursor) {
212
203
  if (cursorRef !== ref || !Number.isSafeInteger(page) || page < 1) throw workspaceErrorDiagnostics.WORKSPACE_R0070({ message: `[vitehub] History cursor does not belong to ref "${ref}".` });
213
204
  return page;
214
205
  }
215
- /** The page number of the next GitHub page, from the Forge cursor. */
216
206
  function nextPage(nextUrl) {
217
207
  if (!nextUrl) return void 0;
218
208
  const page = Number(new URL(nextUrl).searchParams.get("page"));
@@ -228,7 +218,6 @@ function entryMetadata(entry) {
228
218
  function mediaType(path) {
229
219
  return lookup(path) || "application/octet-stream";
230
220
  }
231
- /** The message of a commit without its metadata trailer, and the metadata that the trailer holds. */
232
221
  function readCommitMessage(message) {
233
222
  if (!message) return {};
234
223
  const match = metadataTrailerPattern.exec(message);
@@ -248,10 +237,6 @@ function readCommitMessage(message) {
248
237
  metadata
249
238
  };
250
239
  }
251
- /**
252
- * The Git author of a history commit: `metadata.author` with a `name` and an `email`, as Content and the
253
- * `workspace.commit` operation record the signed-in user. Without both, the account of the token is the author.
254
- */
255
240
  function commitAuthor(metadata) {
256
241
  const author = metadata?.author;
257
242
  if (!author || typeof author !== "object") return void 0;
@@ -273,7 +258,6 @@ function messageWithMetadata(message, metadata) {
273
258
  limit("metadata", new TextEncoder().encode(json).byteLength, githubMaxMetadataBytes);
274
259
  return `${message}\n\n${metadataTrailer}${json}`;
275
260
  }
276
- /** A revision from its commit. Without `entries`, the revision leaves out `files` and `bytes`. */
277
261
  function publicRevision(commit, ref, entries, url, suppliedMetadata) {
278
262
  const stored = readCommitMessage(commit.message);
279
263
  suppliedMetadata ??= stored.metadata;
@@ -1393,10 +1377,6 @@ var GitHubWorkspaceStore = class {
1393
1377
  provideWorkspaceStoreTarget(this, () => this.#storeTarget());
1394
1378
  provideWorkspaceRevisionMaterializer(this, this.#revisionMaterializer);
1395
1379
  }
1396
- /**
1397
- * The repository, branch, root, and token resolve on first use. The Store is created when the Workspace Definition
1398
- * loads, even in a build that has no token, and a missing option fails at the first request.
1399
- */
1400
1380
  get #connection() {
1401
1381
  return this.#resolved ||= (() => {
1402
1382
  const repository = requireGitHubOption("a repository", resolveGitHubRepositoryOption(this.options));
@@ -1429,7 +1409,6 @@ var GitHubWorkspaceStore = class {
1429
1409
  root: this.#root
1430
1410
  }));
1431
1411
  }
1432
- /** Drops the staged writes. The next call loads the branch again, as the first call does. */
1433
1412
  async [workspaceStoreDiscard]() {
1434
1413
  await this.#mutate(async () => {
1435
1414
  this.#dirty = false;
@@ -1628,7 +1607,6 @@ var GitHubWorkspaceStore = class {
1628
1607
  await this.#rebase(options);
1629
1608
  });
1630
1609
  }
1631
- /** Move the staged writes onto the current branch head. A path that changed on both sides fails with its name in `details.paths`. */
1632
1610
  async #rebase(options, loaded) {
1633
1611
  const remote = loaded ?? await readGitHubBranchState({
1634
1612
  branch: this.#branch,
@@ -1692,11 +1670,6 @@ var GitHubWorkspaceStore = class {
1692
1670
  }
1693
1671
  this.#dirty = await this.#hasRemoteChanges();
1694
1672
  }
1695
- /**
1696
- * Commit the staged writes. When the branch moved since the Store loaded, for example because another isolate
1697
- * committed, the Store moves the staged writes onto the new head and commits once more. A path that changed on
1698
- * both sides, or a second move, fails with `WORKSPACE_CONFLICT`.
1699
- */
1700
1673
  async #snapshot(options, retry = true) {
1701
1674
  await this.#ensure({ refresh: "expired" });
1702
1675
  const snapshot = await createSnapshotFromEntries(await this.#listEntries("", { recursive: true }), options.name);
@@ -1825,11 +1798,6 @@ var GitHubWorkspaceStore = class {
1825
1798
  this.#dirty = true;
1826
1799
  });
1827
1800
  }
1828
- /**
1829
- * Load the branch once. Without staged writes, `refresh: true` reads the head again, and `"expired"` reads it again
1830
- * when the Store loaded it more than `githubHeadCacheMs` ago. A Store that one isolate keeps for many requests so
1831
- * sees commits from other writers before it stages new writes.
1832
- */
1833
1801
  async #ensure(options) {
1834
1802
  const wasReady = !!this.#ready;
1835
1803
  this.#ready ||= this.#load().catch((error) => {
@@ -1,7 +1,7 @@
1
1
  import { s as workspaceNotFoundError } from "./internal/path.js";
2
- import { t as createWorkspace } from "./workspace-D1m00MCM.js";
2
+ import { t as createWorkspace } from "./workspace-Dbo5iYIc.js";
3
3
  import { setWorkspaceRuntimeRegistry, workspaceRuntimeRegistryState } from "./runtime/registry.js";
4
- import { t as workspaceErrorDiagnostics } from "./error-diagnostics-CHgE8TQM.js";
4
+ import { t as workspaceErrorDiagnostics } from "./error-diagnostics-Dn4sQcKL.js";
5
5
  import { getViteHubErrorShape, isRuntimeDiagnostic } from "@vite-hub/runtime";
6
6
  // src/core/registry.ts
7
7
  const workspaceRegistryStateKey = Symbol.for("vitehub.workspace.registryState");
@@ -5,7 +5,6 @@ import { registerRunScope } from "@vite-hub/runtime/internal/run-scope";
5
5
  const runtimeGlobal = globalThis;
6
6
  const storageKey = Symbol.for("vitehub.workspace.request");
7
7
  const writersKey = Symbol.for("vitehub.workspace.writers");
8
- /** Writes made outside a request and a run, such as at startup, which no request may drop. */
9
8
  const outsideRequest = { staged: /* @__PURE__ */ new Set() };
10
9
  function requestStorage() {
11
10
  const existing = runtimeGlobal[storageKey];
@@ -16,7 +15,6 @@ function requestStorage() {
16
15
  runtimeGlobal[storageKey] = storage;
17
16
  return storage;
18
17
  }
19
- /** The requests that staged writes in each Store since its last snapshot. */
20
18
  function writers() {
21
19
  return runtimeGlobal[writersKey] ??= /* @__PURE__ */ new WeakMap();
22
20
  }
@@ -1,4 +1,4 @@
1
- import { t as workspaceErrorDiagnostics } from "./error-diagnostics-CHgE8TQM.js";
1
+ import { t as workspaceErrorDiagnostics } from "./error-diagnostics-Dn4sQcKL.js";
2
2
  // src/core/rule-keys.ts
3
3
  /** The rule fields that a more specific rule replaces only when it sets them. */
4
4
  const cascadingRuleKeys = [
@@ -1,7 +1,7 @@
1
1
  import { o as workspaceError } from "./internal/path.js";
2
2
  import { l as normalizeWorkspacePath, r as contentToBytes } from "./path-DYHw5KNk.js";
3
- import { t as workspaceErrorDiagnostics } from "./error-diagnostics-CHgE8TQM.js";
4
- import { n as cascadingRuleKeys, t as assertWorkspaceRules } from "./rule-keys-xMpiTLq1.js";
3
+ import { t as workspaceErrorDiagnostics } from "./error-diagnostics-Dn4sQcKL.js";
4
+ import { n as cascadingRuleKeys, t as assertWorkspaceRules } from "./rule-keys-DQYcSewo.js";
5
5
  import { lookup } from "mrmime";
6
6
  import { minimatch } from "minimatch";
7
7
  // src/core/plugins.ts
@@ -68,7 +68,6 @@ function mergeHooks(left = {}, right = {}) {
68
68
  "write:validate": [...toArray(left["write:validate"]), ...toArray(right["write:validate"])]
69
69
  };
70
70
  }
71
- /** Merges rules on the same pattern field by field. A later rule replaces only the fields it sets, and validators add up. */
72
71
  function mergeRules(left, right = {}) {
73
72
  assertWorkspaceRules(right);
74
73
  const merged = { ...left };
@@ -117,11 +116,6 @@ function normalizePolicy(definition) {
117
116
  rules: normalizeRules(rules)
118
117
  };
119
118
  }
120
- /**
121
- * Resolves every rule that matches the path, from the least to the most specific. A more specific rule replaces a
122
- * field only when it sets that field, so `"docs/**": { maxBytes }` keeps a broader `write: false`. Validators of every
123
- * matching rule run, the least specific first.
124
- */
125
119
  function matchRule(policy, path) {
126
120
  const normalized = normalizeWorkspacePath(path);
127
121
  let matched;
@@ -156,7 +150,6 @@ function writeAllowed(write, operation, exists) {
156
150
  function sizeOf(content) {
157
151
  return content === void 0 ? 0 : contentToBytes(content).byteLength;
158
152
  }
159
- /** The media type that a file write stores: the one the caller passed, else the one its path implies. */
160
153
  function writeMediaType(input) {
161
154
  return input.mediaType || lookup(input.path) || "application/octet-stream";
162
155
  }
@@ -172,7 +165,6 @@ function assertRuleAllows(input, matched) {
172
165
  if (!allowed.includes(mediaType)) throw workspaceError(`[vitehub] Workspace rule "${origins.mediaType}" does not allow media type ${mediaType}: ${input.path}.`);
173
166
  }
174
167
  }
175
- /** Stores the media type that the rule checked, so the stored file cannot get another type from the Store. */
176
168
  function withCheckedMediaType(input, matched) {
177
169
  if (!matched?.rule.mediaType || input.operation !== "writeFile" || input.mediaType) return input;
178
170
  return {
@@ -1,4 +1,4 @@
1
- import { t as runWorkspaceRequest } from "../request-scope-jH4H0Sbm.js";
1
+ import { t as runWorkspaceRequest } from "../request-scope-DZJbe-tP.js";
2
2
  // src/runtime/request.ts
3
3
  /** Nitro middleware: runs the rest of the request in its own Workspace request scope. */
4
4
  function workspaceRequestMiddleware(_event, next) {
@@ -1,10 +1,10 @@
1
- import { a as setWorkspaceRegistry, i as resolveRegisteredWorkspaceDefinition, o as setWorkspaceRuntimeDefinitions, r as registerWorkspace } from "../registry-CFeUQsja.js";
1
+ import { a as setWorkspaceRegistry, i as resolveRegisteredWorkspaceDefinition, o as setWorkspaceRuntimeDefinitions, r as registerWorkspace } from "../registry-CqDWpDe9.js";
2
2
  import { t as setWorkspaceAssetsRegistry } from "../asset-registry-DJyE42kr.js";
3
- import { n as invalidateCachedWorkspaceStore, r as resetWorkspaceStoreCache } from "../workspace-D1m00MCM.js";
4
- import { A as setActiveCloudflareEnv } from "../shared-PFnkYidS.js";
5
- import { t as useWorkspace } from "../use-tools-CcXs2hFA.js";
6
- import { r as useWorkspaceFiles } from "../use-BCMkT-kC.js";
7
- import { d as setWorkspaceHostedStoreLoader, u as getWorkspaceHostedStoreLoader } from "../provider-fcI7kJ5k.js";
3
+ import { n as invalidateCachedWorkspaceStore, r as resetWorkspaceStoreCache } from "../workspace-Dbo5iYIc.js";
4
+ import { A as setActiveCloudflareEnv } from "../shared-CaAKcBBr.js";
5
+ import { t as useWorkspace } from "../use-tools-D_eorKu1.js";
6
+ import { r as useWorkspaceFiles } from "../use-BskfWVjx.js";
7
+ import { d as setWorkspaceHostedStoreLoader, u as getWorkspaceHostedStoreLoader } from "../provider-DBJeUNFI.js";
8
8
  import { n as setWorkspaceRuntimeConfig, t as getWorkspaceRuntimeConfig } from "../config-CsgNNVAI.js";
9
9
  // src/runtime/state.ts
10
10
  async function invalidateWorkspaceStore(name) {
@@ -1 +1 @@
1
- export { t as createWorkspace } from "../workspace-D1m00MCM.js";
1
+ export { t as createWorkspace } from "../workspace-Dbo5iYIc.js";
package/dist/runtime.js CHANGED
@@ -1,21 +1,21 @@
1
1
  import { n as setWorkspaceRuntimeConfig, t as getWorkspaceRuntimeConfig } from "./config-CsgNNVAI.js";
2
- import { d as setWorkspaceHostedStoreLoader, u as getWorkspaceHostedStoreLoader } from "./provider-fcI7kJ5k.js";
3
- import { i as setWorkspaceDependencyRuntimeLoaders, n as createWorkspaceTools, r as getWorkspaceDependencyRuntimeLoaders, t as useWorkspace } from "./use-tools-CcXs2hFA.js";
2
+ import { d as setWorkspaceHostedStoreLoader, u as getWorkspaceHostedStoreLoader } from "./provider-DBJeUNFI.js";
3
+ import { i as setWorkspaceDependencyRuntimeLoaders, n as createWorkspaceTools, r as getWorkspaceDependencyRuntimeLoaders, t as useWorkspace } from "./use-tools-D_eorKu1.js";
4
4
  import { invalidateWorkspaceStore, setWorkspaceRuntimeAssetsRegistry, setWorkspaceRuntimeRegistry } from "./runtime/state.js";
5
- import { _ as isWorkspaceSourceRequestOnly, a as normalizeWorkspaceSources, b as markLiveWorkspaceSource, f as prepareWorkspaceSource, h as getWorkspaceSourceRequestDescriptor, i as normalizeWorkspaceSourceMetadata, l as workspaceSourceGrantPaths, o as normalizeWorkspaceSourcesMetadata, r as normalizeWorkspaceSource, t as copyWorkspaceSourceMetadata, u as ownSourceOption, v as workspaceSourceRequestDescriptorPath } from "./config--ZzAvhMp.js";
5
+ import { _ as isWorkspaceSourceRequestOnly, a as normalizeWorkspaceSources, b as markLiveWorkspaceSource, f as prepareWorkspaceSource, h as getWorkspaceSourceRequestDescriptor, i as normalizeWorkspaceSourceMetadata, l as workspaceSourceGrantPaths, o as normalizeWorkspaceSourcesMetadata, r as normalizeWorkspaceSource, t as copyWorkspaceSourceMetadata, u as ownSourceOption, v as workspaceSourceRequestDescriptorPath } from "./config-B-S_Z4G0.js";
6
6
  import { o as workspaceError } from "./internal/path.js";
7
7
  import { l as normalizeWorkspacePath, u as readStoredFile } from "./path-DYHw5KNk.js";
8
- import { a as createWorkspaceHistoryReader, c as forwardWorkspaceHistoryFiles, i as createWorkspaceHistory, l as forwardWorkspaceHistoryMerge } from "./utils-Bv1NBg8r.js";
9
- import { t as workspaceErrorDiagnostics } from "./error-diagnostics-CHgE8TQM.js";
10
- import { r as registerWorkspacePlugin, t as createWorkspaceWritePolicy } from "./rules-DYQCKYdt.js";
11
- import { _ as attachWorkspaceSourceRequestExecution, a as isInternalWorkspaceMetaKey, b as workspaceSourceRequestMatches, c as isWorkspaceSourceSyncMetaKey, g as copyWorkspacePath, h as appendWorkspaceFile, m as appendCondition, o as createWorkspaceSourceView, p as resolveWorkspacePath, r as resetWorkspaceStoreCache, v as createWorkspaceSourceRequestExecution, x as createBasicWorkspaceSession, y as getWorkspaceSourceRequestExecution } from "./workspace-D1m00MCM.js";
8
+ import { a as createWorkspaceHistoryReader, c as forwardWorkspaceHistoryFiles, i as createWorkspaceHistory, l as forwardWorkspaceHistoryMerge } from "./utils-BoFJcaT1.js";
9
+ import { t as workspaceErrorDiagnostics } from "./error-diagnostics-Dn4sQcKL.js";
10
+ import { r as registerWorkspacePlugin, t as createWorkspaceWritePolicy } from "./rules-sItt6TP-.js";
11
+ import { _ as attachWorkspaceSourceRequestExecution, a as isInternalWorkspaceMetaKey, b as workspaceSourceRequestMatches, c as isWorkspaceSourceSyncMetaKey, g as copyWorkspacePath, h as appendWorkspaceFile, m as appendCondition, o as createWorkspaceSourceView, p as resolveWorkspacePath, r as resetWorkspaceStoreCache, v as createWorkspaceSourceRequestExecution, x as createBasicWorkspaceSession, y as getWorkspaceSourceRequestExecution } from "./workspace-Dbo5iYIc.js";
12
12
  import { t as createMemoryWorkspaceStore } from "./memory-BCZl_ZsJ.js";
13
- import { M as registerWorkspaceStoreAlias, a as resolveWorkspaceMetadataMutationTarget, i as forwardWorkspaceMetadataView, n as createWorkspaceMetadataTarget, o as resolveWorkspaceMetadataTarget, r as forwardWorkspaceMetadataTarget, s as setWorkspaceMetadata, t as attachWorkspaceMetadataTarget } from "./metadata-target-DPGF6L68.js";
13
+ import { M as registerWorkspaceStoreAlias, a as resolveWorkspaceMetadataMutationTarget, i as forwardWorkspaceMetadataView, n as createWorkspaceMetadataTarget, o as resolveWorkspaceMetadataTarget, r as forwardWorkspaceMetadataTarget, s as setWorkspaceMetadata, t as attachWorkspaceMetadataTarget } from "./metadata-target-oc00D8g2.js";
14
14
  import { a as provideWorkspaceStoreTarget, i as forwardWorkspaceStoreTarget, o as resolveWorkspaceStoreTarget } from "./vitehub-grants-Co713QTg.js";
15
15
  import { n as getWorkspaceReplacement, r as prepareWorkspaceReplacement, t as attachWorkspaceReplacement } from "./replacement-CVZVsflC.js";
16
- import { t as isRecord } from "./object-CAK6UYR5.js";
17
- import { i as resolveRegisteredWorkspaceDefinition, o as setWorkspaceRuntimeDefinitions, r as registerWorkspace } from "./registry-CFeUQsja.js";
18
- import { r as useWorkspaceFiles } from "./use-BCMkT-kC.js";
16
+ import { n as isRecord } from "./object-DNOrQSl5.js";
17
+ import { i as resolveRegisteredWorkspaceDefinition, o as setWorkspaceRuntimeDefinitions, r as registerWorkspace } from "./registry-CqDWpDe9.js";
18
+ import { r as useWorkspaceFiles } from "./use-BskfWVjx.js";
19
19
  import { join, resolve } from "node:path";
20
20
  import { randomUUID } from "node:crypto";
21
21
  import { lstat, readdir, rename, rm } from "node:fs/promises";
@@ -288,7 +288,7 @@ function createWritableFacadeStore(workspace, sourceSync) {
288
288
  async function startOverlayWorkspaceSession(_definition, workspace, options) {
289
289
  const host = options?.host;
290
290
  if (host) {
291
- const { createHostedWorkspaceSession } = await import("./host-BYBRcSnh.js").then((n) => n.n);
291
+ const { createHostedWorkspaceSession } = await import("./host-CcCDXyJI.js").then((n) => n.n);
292
292
  return await createHostedWorkspaceSession(workspace, {
293
293
  ...options,
294
294
  host
@@ -554,7 +554,7 @@ async function createWorkspaceSourceResolutionFacade(workspace, definition, opti
554
554
  },
555
555
  stat: writeFs.stat,
556
556
  sync: async (options) => {
557
- const { syncWorkspaceSources } = await import("./sync-CUkCuP_g.js");
557
+ const { syncWorkspaceSources } = await import("./sync-ztyvA0Va.js");
558
558
  return await syncWorkspaceSources(resolvedDefinition, syncStore, options);
559
559
  },
560
560
  writeFile: writeFs.writeFile
package/dist/server.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import { s as matchesAny } from "./path-DYHw5KNk.js";
2
2
  import { normalizeSafeWorkspacePath } from "./internal/path.js";
3
- import { i as workspaceDefinitionPlugins, n as resolveWorkspaceAutoCommit } from "./rules-DYQCKYdt.js";
4
- import { r as useWorkspaceFiles } from "./use-BCMkT-kC.js";
5
- import { r as withWorkspaceProgress } from "./host-BYBRcSnh.js";
6
- import { t as workspaceErrorDiagnostics } from "./error-diagnostics-CHgE8TQM.js";
3
+ import { i as workspaceDefinitionPlugins, n as resolveWorkspaceAutoCommit } from "./rules-sItt6TP-.js";
4
+ import { r as useWorkspaceFiles } from "./use-BskfWVjx.js";
5
+ import { r as withWorkspaceProgress } from "./host-CcCDXyJI.js";
6
+ import { t as workspaceErrorDiagnostics } from "./error-diagnostics-Dn4sQcKL.js";
7
7
  import { getViteHubErrorShape } from "@vite-hub/runtime";
8
8
  import { lookup } from "mrmime";
9
9
  // ../internal/src/secret.ts