@vite-hub/workspace 0.4.1 → 0.5.1

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 (116) hide show
  1. package/README.md +62 -19
  2. package/dist/{abort-BCwpdrN0.js → abort-CQGxJBqa.js} +1 -2
  3. package/dist/{asset-registry-DfBV5kmw.js → asset-registry-0CdRAjIV.js} +2 -3
  4. package/dist/blob-database/postgres.d.ts +423 -0
  5. package/dist/blob-database/postgres.js +1 -0
  6. package/dist/blob-database-sources-CQPAyCz3.js +8 -0
  7. package/dist/blob-database.d.ts +29 -449
  8. package/dist/blob-database.js +636 -210
  9. package/dist/checkout.d.ts +1 -2
  10. package/dist/checkout.js +3 -4
  11. package/dist/cloudflare.d.ts +1 -5
  12. package/dist/cloudflare.js +1 -2
  13. package/dist/{config-B-863EgC.js → config-CsgNNVAI.js} +1 -2
  14. package/dist/{config-CDeGd0RB.d.ts → config-DeA287c0.d.ts} +1 -5
  15. package/dist/{config-D1QENneP.js → config-jo5QgE1w.js} +18 -27
  16. package/dist/{discard-CNNtCozM.js → discard-BkoLmmmN.js} +1 -2
  17. package/dist/durability.d.ts +10 -4
  18. package/dist/durability.js +47 -6
  19. package/dist/{error-diagnostics-B5s9kNEA.js → error-diagnostics-B4me-ouV.js} +11 -4
  20. package/dist/{error-diagnostics-CQ4BUqRe.js → error-diagnostics-kKXseq8d.js} +10 -3
  21. package/dist/{path-uxLkzrZm.d.ts → errors-CnFDXxeJ.d.ts} +0 -3
  22. package/dist/{file-CqG9zqiF.js → file-BrNAXQgY.js} +4 -8
  23. package/dist/{target-Dm9dHAVJ.js → file-metadata-Bpsvjw_X.js} +3 -32
  24. package/dist/{files-B6wpAhEx.js → files--z2dLC5z.js} +3 -4
  25. package/dist/files.d.ts +12 -8
  26. package/dist/files.js +7 -6
  27. package/dist/{github-DKAlO0Vh.js → github-k--_LCrX.js} +7 -9
  28. package/dist/{glob-BOqSKzSg.js → glob-BEutagp1.js} +9 -10
  29. package/dist/{glob-Cjxms1t7.js → glob-BreFjNAV.js} +3 -4
  30. package/dist/history-schema-BR4UDPHL.d.ts +434 -0
  31. package/dist/history-schema-postgres-DZepCSBq.js +40 -0
  32. package/dist/{host-Bf1a2uo_.js → host-C8yZizfk.js} +153 -22
  33. package/dist/{hosted-zG7HJaE4.js → hosted-8BTKAtMX.js} +27 -21
  34. package/dist/{hosted-vercel-blob-AbXG8fvR.js → hosted-vercel-blob-B6kygYqn.js} +10 -12
  35. package/dist/hosted-vercel-blob.d.ts +1 -3
  36. package/dist/hosted-vercel-blob.js +1 -2
  37. package/dist/hosted.d.ts +1 -3
  38. package/dist/hosted.js +1 -2
  39. package/dist/index.d.ts +11 -41
  40. package/dist/index.js +34 -116
  41. package/dist/internal/path.d.ts +1 -1
  42. package/dist/internal/path.js +1 -2
  43. package/dist/internal/workspace.d.ts +10 -0
  44. package/dist/internal/workspace.js +85 -0
  45. package/dist/{lifecycle-D8FdpBod.js → lifecycle-IReZfi0b.js} +15 -13
  46. package/dist/lineage.d.ts +1 -3
  47. package/dist/lineage.js +1 -2
  48. package/dist/loader.d.ts +1 -7
  49. package/dist/loader.js +4 -6
  50. package/dist/{mcp-resources-DntxtmDU.js → mcp-resources-DeJnbOaw.js} +4 -5
  51. package/dist/{memory-D5jq9HZW.js → memory-BlSRrBH1.js} +19 -13
  52. package/dist/{metadata-target-DDoOQNp1.js → metadata-target-CaGLY4ay.js} +214 -77
  53. package/dist/{object-Da1zyPCR.js → object-CAK6UYR5.js} +1 -2
  54. package/dist/{operation-definition-nmRu_O3V.d.ts → operation-definition-CqZkx1Rm.d.ts} +8 -6
  55. package/dist/{operations-DsY2MQnG.js → operations-CtRDU3cA.js} +34 -29
  56. package/dist/{operations-D8uCpzhM.js → operations-DfbqHWAe.js} +7 -8
  57. package/dist/operations.d.ts +2 -6
  58. package/dist/operations.js +2 -2
  59. package/dist/{path--wrT_Azm.js → path-Bb9OIc_F.js} +3 -19
  60. package/dist/{path-zHxQUbqa.d.ts → path-C0uZxDdW.d.ts} +0 -2
  61. package/dist/{path-DrSIenjj.js → path-CuYE8-X6.js} +2 -4
  62. package/dist/{plugins-CsrXCA1Q.d.ts → plugins-CLc32jvL.d.ts} +1 -3
  63. package/dist/{provider-sm9uzkLg.js → provider-CN14ewvx.js} +30 -22
  64. package/dist/providers/github/store.d.ts +2 -4
  65. package/dist/providers/github/store.js +1 -2
  66. package/dist/{registry-CFl1Htyc.d.ts → registry-B0g19sdy.d.ts} +5 -8
  67. package/dist/{registry-DmVfUe4K.js → registry-BbUg9vJB.js} +10 -6
  68. package/dist/registry-s2Ob9PeX.d.ts +9 -0
  69. package/dist/{request-scope-Dw5n8bMC.js → request-scope-CXCI_wCb.js} +4 -4
  70. package/dist/{results-DgkZUmTL.js → results-z-HpV9EP.js} +1 -2
  71. package/dist/{rolldown-runtime-rQ84J-ij.js → rolldown-runtime-DnNXxpGL.js} +2 -3
  72. package/dist/rule-keys-BLEbi1h5.js +18 -0
  73. package/dist/rules-BPDXypZV.js +267 -0
  74. package/dist/runtime/assets.d.ts +2 -3
  75. package/dist/runtime/assets.js +5 -6
  76. package/dist/runtime/empty-assets-registry.d.ts +1 -3
  77. package/dist/runtime/empty-assets-registry.js +1 -2
  78. package/dist/runtime/empty-registry.d.ts +2 -4
  79. package/dist/runtime/empty-registry.js +1 -2
  80. package/dist/runtime/registry.d.ts +2 -2
  81. package/dist/runtime/registry.js +2 -3
  82. package/dist/runtime/request.d.ts +1 -3
  83. package/dist/runtime/request.js +2 -3
  84. package/dist/runtime/state.d.ts +5 -4
  85. package/dist/runtime/state.js +18 -7
  86. package/dist/runtime/workspace.d.ts +1 -1
  87. package/dist/runtime/workspace.js +1 -2
  88. package/dist/runtime.d.ts +9 -24
  89. package/dist/runtime.js +29 -25
  90. package/dist/{search-C_RfoM2j.js → search-C_nVorq7.js} +3 -4
  91. package/dist/{server-Cd4-iCh5.js → server-aa1a4rkV.js} +8 -10
  92. package/dist/server.d.ts +3 -4
  93. package/dist/server.js +1 -2
  94. package/dist/{shared-ovXVSV3-.js → shared-C20Wh1mp.js} +23 -19
  95. package/dist/source-metadata.d.ts +2 -6
  96. package/dist/source-metadata.js +4 -5
  97. package/dist/state-BdDfBtOR.d.ts +17 -0
  98. package/dist/{store-NZoRto-Y.js → store-cx3OqNTi.js} +42 -44
  99. package/dist/{sync-CrT8zjwc.js → sync-BBfR4g5y.js} +6 -7
  100. package/dist/test.d.ts +1 -1
  101. package/dist/test.js +1 -2
  102. package/dist/{types-1Z-tKK3g.d.ts → types-Bel5IDmF.d.ts} +52 -6
  103. package/dist/{use-CjbF8EO9.d.ts → use-CpphIBof.d.ts} +20 -32
  104. package/dist/{use-B0o5HoBl.js → use-D0DyTMxM.js} +19 -21
  105. package/dist/use-tools-CAK10LTc.d.ts +10 -0
  106. package/dist/{state-Cb_hIyAw.js → use-tools-CHduR5k6.js} +8 -24
  107. package/dist/{utils-Dw-WULEZ.js → utils-DXP9xfXo.js} +80 -273
  108. package/dist/vite.d.ts +30 -19
  109. package/dist/vite.js +1481 -1617
  110. package/dist/vitehub-grants-Co713QTg.js +36 -0
  111. package/dist/workspace-BOuxrZrP.d.ts +5 -0
  112. package/dist/{workspace-DvKu5PRa.js → workspace-CLuPkyZR.js} +28 -36
  113. package/package.json +34 -24
  114. package/dist/registry-CwryP59t.d.ts +0 -9
  115. package/dist/state-C-YtsaiJ.d.ts +0 -35
  116. package/dist/workspace-CIXgHeyX.d.ts +0 -7
package/dist/index.js CHANGED
@@ -1,20 +1,20 @@
1
- import { n as __exportAll } from "./rolldown-runtime-rQ84J-ij.js";
2
- import { r as isWorkspaceConflict, s as workspaceError, t as normalizeSafeWorkspacePath } from "./path-DrSIenjj.js";
3
- import { i as assertWorkspaceRules, n as resolveWorkspaceStoreTarget } from "./target-Dm9dHAVJ.js";
4
- import { t as workspaceErrorDiagnostics } from "./error-diagnostics-B5s9kNEA.js";
5
- import { _ as registerWorkspacePlugin, g as resolveWorkspaceAutoCommit } from "./utils-Dw-WULEZ.js";
6
- import { t as createWorkspace } from "./workspace-DvKu5PRa.js";
7
- import { m as url } from "./config-D1QENneP.js";
8
- import { r as resolveRegisteredWorkspaceDefinition } from "./registry-DmVfUe4K.js";
9
- import { r as useWorkspaceFiles } from "./use-B0o5HoBl.js";
10
- import { r as withFileSourceOptions, t as file } from "./file-CqG9zqiF.js";
11
- import { t as github } from "./github-DKAlO0Vh.js";
12
- import { t as glob } from "./glob-BOqSKzSg.js";
13
- import { t as mcpResources } from "./mcp-resources-DntxtmDU.js";
14
- import { a as createWorkspaceTools, i as useWorkspace, t as invalidateWorkspaceStore } from "./state-Cb_hIyAw.js";
1
+ import { n as __exportAll } from "./rolldown-runtime-DnNXxpGL.js";
2
+ import { t as assertWorkspaceRules } from "./rule-keys-BLEbi1h5.js";
3
+ import { t as workspaceErrorDiagnostics } from "./error-diagnostics-B4me-ouV.js";
4
+ import { t as createWorkspace } from "./workspace-CLuPkyZR.js";
5
+ import { r as isWorkspaceConflict, s as workspaceError, t as normalizeSafeWorkspacePath } from "./path-CuYE8-X6.js";
6
+ import { r as withFileSourceOptions, t as file } from "./file-BrNAXQgY.js";
7
+ import { m as url } from "./config-jo5QgE1w.js";
8
+ import { t as github } from "./github-k--_LCrX.js";
9
+ import { t as glob } from "./glob-BEutagp1.js";
10
+ import { t as mcpResources } from "./mcp-resources-DeJnbOaw.js";
11
+ import { n as createWorkspaceTools, t as useWorkspace } from "./use-tools-CHduR5k6.js";
12
+ import { t as isWorkspaceName } from "./registry-BbUg9vJB.js";
13
+ import { r as registerWorkspacePlugin } from "./rules-BPDXypZV.js";
14
+ import { r as useWorkspaceFiles } from "./use-D0DyTMxM.js";
15
15
  import { lookup } from "mrmime";
16
16
  import { markdown as markdown$1, sourceIgnores } from "@vite-hub/source";
17
- //#region src/core/define.ts
17
+ // src/core/define.ts
18
18
  const workspaceDefinitionKeys = /* @__PURE__ */ new Set([
19
19
  "bindings",
20
20
  "commit",
@@ -40,8 +40,7 @@ function defineWorkspace(definition) {
40
40
  for (const plugin of definition.plugins ?? []) assertWorkspaceRules(plugin?.rules);
41
41
  return definition;
42
42
  }
43
- //#endregion
44
- //#region src/sources/custom.ts
43
+ // src/sources/custom.ts
45
44
  function custom(source) {
46
45
  if (!Object.hasOwn(source, "files") || !Array.isArray(source.files)) return source;
47
46
  const { files: inputFiles, ...options } = source;
@@ -49,31 +48,33 @@ function custom(source) {
49
48
  ...file,
50
49
  path: normalizeSafeWorkspacePath(file.path)
51
50
  }));
51
+ async function getItem(key, context) {
52
+ const file = files.find((file) => file.path === key);
53
+ if (!file) throw workspaceError(`[vitehub] Custom Workspace Source file does not exist: ${key}.`);
54
+ const { content, ...item } = file;
55
+ return {
56
+ ...item,
57
+ content: typeof content === "function" ? await content(context) : content,
58
+ key,
59
+ mediaType: item.mediaType || lookup(key) || void 0
60
+ };
61
+ }
52
62
  return {
53
63
  ...options,
54
64
  async getKeys() {
55
65
  return files.map((file) => file.path);
56
66
  },
57
- async getItem(key, context) {
58
- const file = files.find((file) => file.path === key);
59
- if (!file) throw workspaceError(`[vitehub] Custom Workspace Source file does not exist: ${key}.`);
60
- const { content, ...item } = file;
61
- return {
62
- ...item,
63
- content: typeof content === "function" ? await content(context) : content,
64
- key,
65
- mediaType: item.mediaType || lookup(key) || void 0
66
- };
67
- }
67
+ getItem,
68
+ ...files.every((file) => typeof file.content !== "function") ? { async getItems(context) {
69
+ return await Promise.all(files.map((file) => getItem(file.path, context)));
70
+ } } : {}
68
71
  };
69
72
  }
70
- //#endregion
71
- //#region src/sources/markdown.ts
73
+ // src/sources/markdown.ts
72
74
  function markdown(options) {
73
75
  return withFileSourceOptions(markdown$1(options), options);
74
76
  }
75
- //#endregion
76
- //#region src/sources/index.ts
77
+ // src/sources/index.ts
77
78
  var sources_exports = /* @__PURE__ */ __exportAll({
78
79
  custom: () => custom,
79
80
  file: () => file,
@@ -83,87 +84,4 @@ var sources_exports = /* @__PURE__ */ __exportAll({
83
84
  mcpResources: () => mcpResources,
84
85
  url: () => url
85
86
  });
86
- const modelWorkspaceGlobPatternLimits = Object.freeze({
87
- maxBytes: 2048,
88
- maxComplexity: 1024,
89
- maxPatterns: 16
90
- });
91
- function boundedAdd(left, right, limit) {
92
- if (left > limit - right) return limit + 1;
93
- return left + right;
94
- }
95
- function boundedMultiply(left, right, limit) {
96
- if (left && right > Math.floor(limit / left)) return limit + 1;
97
- return left * right;
98
- }
99
- function boundedUtf8Bytes(value, limit) {
100
- let bytes = 0;
101
- for (let index = 0; index < value.length; index++) {
102
- const codePoint = value.codePointAt(index);
103
- if (codePoint > 65535) index++;
104
- bytes += codePoint <= 127 ? 1 : codePoint <= 2047 ? 2 : codePoint <= 65535 ? 3 : 4;
105
- if (bytes > limit) return limit + 1;
106
- }
107
- return bytes;
108
- }
109
- function sequenceComplexity(content, limit) {
110
- const parts = content.split("..");
111
- if (parts.length < 2 || parts.length > 3) return void 0;
112
- const [rawStart, rawEnd, rawStep] = parts;
113
- const numeric = /^-?\d+$/;
114
- let start;
115
- let end;
116
- if (numeric.test(rawStart) && numeric.test(rawEnd)) {
117
- start = Number(rawStart);
118
- end = Number(rawEnd);
119
- } else if (rawStart?.length === 1 && rawEnd?.length === 1) {
120
- start = rawStart.codePointAt(0);
121
- end = rawEnd.codePointAt(0);
122
- } else return;
123
- const step = rawStep === void 0 ? 1 : Math.abs(Number(rawStep));
124
- if (!Number.isSafeInteger(start) || !Number.isSafeInteger(end) || !Number.isSafeInteger(step) || step === 0) return limit + 1;
125
- return Math.floor(Math.abs(end - start) / step) + 1;
126
- }
127
- function patternComplexity(pattern, limit) {
128
- let complexity = 1;
129
- for (let index = 0; index < pattern.length; index++) {
130
- if (pattern[index] === "}") return limit + 1;
131
- if (pattern[index] !== "{") continue;
132
- const closing = pattern.indexOf("}", index + 1);
133
- if (closing === -1) return limit + 1;
134
- const content = pattern.slice(index + 1, closing);
135
- if (!content) return limit + 1;
136
- if (content.includes("{") || content.includes("}")) return limit + 1;
137
- const alternatives = content.split(",");
138
- let braceComplexity;
139
- if (alternatives.length > 1) {
140
- braceComplexity = 0;
141
- for (const alternative of alternatives) {
142
- braceComplexity = boundedAdd(braceComplexity, patternComplexity(alternative, limit), limit);
143
- if (braceComplexity > limit) break;
144
- }
145
- } else braceComplexity = sequenceComplexity(content, limit) ?? patternComplexity(content, limit);
146
- complexity = boundedMultiply(complexity, braceComplexity, limit);
147
- if (complexity > limit) return complexity;
148
- index = closing;
149
- }
150
- return complexity;
151
- }
152
- function assertModelWorkspaceGlobPattern(pattern, limits = modelWorkspaceGlobPatternLimits) {
153
- const patterns = Array.isArray(pattern) ? pattern : [pattern];
154
- if (patterns.length > limits.maxPatterns) throw workspaceErrorDiagnostics.WORKSPACE_R0018({ message: `[vitehub] Workspace glob accepts at most ${limits.maxPatterns} model-facing patterns.` });
155
- let bytes = 0;
156
- for (const item of patterns) {
157
- bytes = boundedAdd(bytes, boundedUtf8Bytes(item, limits.maxBytes), limits.maxBytes);
158
- if (bytes > limits.maxBytes) break;
159
- }
160
- if (bytes > limits.maxBytes) throw workspaceErrorDiagnostics.WORKSPACE_R0019({ message: `[vitehub] Workspace glob pattern input exceeds the model-facing limit of ${limits.maxBytes} bytes.` });
161
- let complexity = 0;
162
- for (const item of patterns) {
163
- const normalized = item.replace(/\\/g, "/");
164
- complexity = boundedAdd(complexity, patternComplexity(normalized, limits.maxComplexity), limits.maxComplexity);
165
- if (complexity > limits.maxComplexity) throw workspaceErrorDiagnostics.WORKSPACE_R0020({ message: `[vitehub] Workspace glob pattern complexity exceeds the model-facing limit of ${limits.maxComplexity} expansions.` });
166
- }
167
- }
168
- //#endregion
169
- export { assertModelWorkspaceGlobPattern, createWorkspace, createWorkspaceTools, custom, defineWorkspace, file, github, glob, invalidateWorkspaceStore, isWorkspaceConflict, markdown, mcpResources, modelWorkspaceGlobPatternLimits, normalizeSafeWorkspacePath, registerWorkspacePlugin, resolveRegisteredWorkspaceDefinition, resolveWorkspaceAutoCommit, resolveWorkspaceStoreTarget, sources_exports as source, sourceIgnores, url, useWorkspace, useWorkspaceFiles };
87
+ export { createWorkspace, createWorkspaceTools, custom, defineWorkspace, file, github, glob, isWorkspaceConflict, isWorkspaceName, markdown, mcpResources, registerWorkspacePlugin, sources_exports as source, sourceIgnores, url, useWorkspace, useWorkspaceFiles };
@@ -1,2 +1,2 @@
1
- import { n as normalizeSafeWorkspacePath, t as SafeWorkspacePathOptions } from "../path-zHxQUbqa.js";
1
+ import { n as normalizeSafeWorkspacePath, t as SafeWorkspacePathOptions } from "../path-C0uZxDdW.js";
2
2
  export { SafeWorkspacePathOptions, normalizeSafeWorkspacePath };
@@ -1,2 +1 @@
1
- import { t as normalizeSafeWorkspacePath } from "../path-DrSIenjj.js";
2
- export { normalizeSafeWorkspacePath };
1
+ export { t as normalizeSafeWorkspacePath } from "../path-CuYE8-X6.js";
@@ -0,0 +1,10 @@
1
+ import { L as WorkspaceDefinition, j as WorkspaceAutoCommitPlan, z as WorkspaceDiff } from "../types-Bel5IDmF.js";
2
+ export declare function resolveWorkspaceAutoCommit(definition: WorkspaceDefinition, diff: WorkspaceDiff): WorkspaceAutoCommitPlan | undefined;
3
+ interface WorkspaceGlobPatternLimits {
4
+ maxBytes: number;
5
+ maxComplexity: number;
6
+ maxPatterns: number;
7
+ }
8
+ export declare const modelWorkspaceGlobPatternLimits: Readonly<WorkspaceGlobPatternLimits>;
9
+ export declare function assertModelWorkspaceGlobPattern(pattern: string | readonly string[], limits?: Readonly<WorkspaceGlobPatternLimits>): void;
10
+ export type { WorkspaceGlobPatternLimits };
@@ -0,0 +1,85 @@
1
+ import { n as resolveWorkspaceAutoCommit } from "../rules-BPDXypZV.js";
2
+ import { t as workspaceErrorDiagnostics } from "../error-diagnostics-B4me-ouV.js";
3
+ const modelWorkspaceGlobPatternLimits = Object.freeze({
4
+ maxBytes: 2048,
5
+ maxComplexity: 1024,
6
+ maxPatterns: 16
7
+ });
8
+ function boundedAdd(left, right, limit) {
9
+ if (left > limit - right) return limit + 1;
10
+ return left + right;
11
+ }
12
+ function boundedMultiply(left, right, limit) {
13
+ if (left && right > Math.floor(limit / left)) return limit + 1;
14
+ return left * right;
15
+ }
16
+ function boundedUtf8Bytes(value, limit) {
17
+ let bytes = 0;
18
+ for (let index = 0; index < value.length; index++) {
19
+ const codePoint = value.codePointAt(index);
20
+ if (codePoint > 65535) index++;
21
+ bytes += codePoint <= 127 ? 1 : codePoint <= 2047 ? 2 : codePoint <= 65535 ? 3 : 4;
22
+ if (bytes > limit) return limit + 1;
23
+ }
24
+ return bytes;
25
+ }
26
+ function sequenceComplexity(content, limit) {
27
+ const parts = content.split("..");
28
+ if (parts.length < 2 || parts.length > 3) return void 0;
29
+ const [rawStart, rawEnd, rawStep] = parts;
30
+ const numeric = /^-?\d+$/;
31
+ let start;
32
+ let end;
33
+ if (numeric.test(rawStart) && numeric.test(rawEnd)) {
34
+ start = Number(rawStart);
35
+ end = Number(rawEnd);
36
+ } else if (rawStart?.length === 1 && rawEnd?.length === 1) {
37
+ start = rawStart.codePointAt(0);
38
+ end = rawEnd.codePointAt(0);
39
+ } else return;
40
+ const step = rawStep === void 0 ? 1 : Math.abs(Number(rawStep));
41
+ if (!Number.isSafeInteger(start) || !Number.isSafeInteger(end) || !Number.isSafeInteger(step) || step === 0) return limit + 1;
42
+ return Math.floor(Math.abs(end - start) / step) + 1;
43
+ }
44
+ function patternComplexity(pattern, limit) {
45
+ let complexity = 1;
46
+ for (let index = 0; index < pattern.length; index++) {
47
+ if (pattern[index] === "}") return limit + 1;
48
+ if (pattern[index] !== "{") continue;
49
+ const closing = pattern.indexOf("}", index + 1);
50
+ if (closing === -1) return limit + 1;
51
+ const content = pattern.slice(index + 1, closing);
52
+ if (!content) return limit + 1;
53
+ if (content.includes("{") || content.includes("}")) return limit + 1;
54
+ const alternatives = content.split(",");
55
+ let braceComplexity;
56
+ if (alternatives.length > 1) {
57
+ braceComplexity = 0;
58
+ for (const alternative of alternatives) {
59
+ braceComplexity = boundedAdd(braceComplexity, patternComplexity(alternative, limit), limit);
60
+ if (braceComplexity > limit) break;
61
+ }
62
+ } else braceComplexity = sequenceComplexity(content, limit) ?? patternComplexity(content, limit);
63
+ complexity = boundedMultiply(complexity, braceComplexity, limit);
64
+ if (complexity > limit) return complexity;
65
+ index = closing;
66
+ }
67
+ return complexity;
68
+ }
69
+ function assertModelWorkspaceGlobPattern(pattern, limits = modelWorkspaceGlobPatternLimits) {
70
+ const patterns = Array.isArray(pattern) ? pattern : [pattern];
71
+ if (patterns.length > limits.maxPatterns) throw workspaceErrorDiagnostics.WORKSPACE_R0018({ message: `[vitehub] Workspace glob accepts at most ${limits.maxPatterns} model-facing patterns.` });
72
+ let bytes = 0;
73
+ for (const item of patterns) {
74
+ bytes = boundedAdd(bytes, boundedUtf8Bytes(item, limits.maxBytes), limits.maxBytes);
75
+ if (bytes > limits.maxBytes) break;
76
+ }
77
+ if (bytes > limits.maxBytes) throw workspaceErrorDiagnostics.WORKSPACE_R0019({ message: `[vitehub] Workspace glob pattern input exceeds the model-facing limit of ${limits.maxBytes} bytes.` });
78
+ let complexity = 0;
79
+ for (const item of patterns) {
80
+ const normalized = item.replace(/\\/g, "/");
81
+ complexity = boundedAdd(complexity, patternComplexity(normalized, limits.maxComplexity), limits.maxComplexity);
82
+ if (complexity > limits.maxComplexity) throw workspaceErrorDiagnostics.WORKSPACE_R0020({ message: `[vitehub] Workspace glob pattern complexity exceeds the model-facing limit of ${limits.maxComplexity} expansions.` });
83
+ }
84
+ }
85
+ export { assertModelWorkspaceGlobPattern, modelWorkspaceGlobPatternLimits, resolveWorkspaceAutoCommit };
@@ -1,14 +1,14 @@
1
- import { n as __exportAll } from "./rolldown-runtime-rQ84J-ij.js";
2
- import { s as workspaceError } from "./path-DrSIenjj.js";
3
- import { f as sha256, l as normalizeWorkspacePath, t as contentStreamChunks } from "./path--wrT_Azm.js";
4
- import { s as invalidateWorkspaceSourceMaterialization } from "./workspace-DvKu5PRa.js";
5
- import { a as normalizeWorkspaceSources, c as sourceMountIntersectsPath, f as prepareWorkspaceSource, n as createSourceContext } from "./config-D1QENneP.js";
6
- import { A as removeWorkspaceOwnedFile, C as withWorkspaceStoreMutation, D as readWorkspaceFileOwner, M as registerWorkspaceStoreAlias, N as workspaceStoreIdentity, O as recordWorkspaceFileOwner, _ as reconcileRemovedStartupSources, d as invalidateSourceSnapshot, j as withWorkspaceFileCheckpoint, k as removeWorkspaceFileOwner, m as readCurrentSourceSnapshot, y as sourceSnapshotOwnsAnyPath } from "./metadata-target-DDoOQNp1.js";
7
- import { n as useWorkspaceAssets } from "./asset-registry-DfBV5kmw.js";
8
- import { t as files } from "./files-B6wpAhEx.js";
1
+ import { n as __exportAll } from "./rolldown-runtime-DnNXxpGL.js";
2
+ import { n as useWorkspaceAssets } from "./asset-registry-0CdRAjIV.js";
3
+ import { t as files } from "./files--z2dLC5z.js";
4
+ import { d as sha256, l as normalizeWorkspacePath, t as contentStreamChunks } from "./path-Bb9OIc_F.js";
5
+ import { s as workspaceError } from "./path-CuYE8-X6.js";
6
+ import { a as normalizeWorkspaceSources, c as sourceMountIntersectsPath, f as prepareWorkspaceSource, n as createSourceContext } from "./config-jo5QgE1w.js";
7
+ import { A as removeWorkspaceOwnedFile, C as withWorkspaceStoreMutation, D as readWorkspaceFileOwner, M as registerWorkspaceStoreAlias, N as workspaceStoreIdentity, O as recordWorkspaceFileOwner, _ as reconcileRemovedStartupSources, d as invalidateSourceSnapshot, j as withWorkspaceFileCheckpoint, k as removeWorkspaceFileOwner, m as readCurrentSourceSnapshot, y as sourceSnapshotOwnsAnyPath } from "./metadata-target-CaGLY4ay.js";
8
+ import { s as invalidateWorkspaceSourceMaterialization } from "./workspace-CLuPkyZR.js";
9
9
  import { getViteHubErrorShape } from "@vite-hub/runtime";
10
10
  import { createHash } from "node:crypto";
11
- //#region src/lifecycle.ts
11
+ // src/lifecycle.ts
12
12
  var lifecycle_exports = /* @__PURE__ */ __exportAll({ syncWorkspaceDefinition: () => syncWorkspaceDefinition });
13
13
  const buildSourcesMetaKey = (workspace) => `workspace:${encodeURIComponent(workspace)}:build-sources`;
14
14
  const buildFilesMetaKey = (workspace) => `workspace:${encodeURIComponent(workspace)}:build-files`;
@@ -226,7 +226,9 @@ async function createBuildLoaderStore(workspace, store, sources, mutationStore =
226
226
  }
227
227
  });
228
228
  });
229
- return Reflect.get(target, property, target)?.bind(target);
229
+ if (property === "writeFiles") return void 0;
230
+ const value = Reflect.get(target, property, target);
231
+ return typeof value === "function" ? value.bind(target) : value;
230
232
  } });
231
233
  }
232
234
  const STORE_MUTATIONS = /* @__PURE__ */ new Set([
@@ -238,7 +240,8 @@ const STORE_MUTATIONS = /* @__PURE__ */ new Set([
238
240
  "snapshot",
239
241
  "writeFile",
240
242
  "writeFileConditional",
241
- "writeFileStream"
243
+ "writeFileStream",
244
+ "writeFiles"
242
245
  ]);
243
246
  function createAbortFencedStore(store, abortSignal) {
244
247
  const active = /* @__PURE__ */ new Set();
@@ -265,7 +268,7 @@ function createAbortFencedStore(store, abortSignal) {
265
268
  };
266
269
  const fenced = new Proxy(store, { get(target, property) {
267
270
  const value = Reflect.get(target, property, target);
268
- if (!STORE_MUTATIONS.has(String(property))) return value?.bind(target);
271
+ if (!STORE_MUTATIONS.has(String(property))) return typeof value === "function" ? value.bind(target) : value;
269
272
  if (value === void 0) return void 0;
270
273
  return (...args) => {
271
274
  abortSignal.throwIfAborted();
@@ -592,5 +595,4 @@ function createMountedBuildSource(source, workspace) {
592
595
  }
593
596
  };
594
597
  }
595
- //#endregion
596
598
  export { syncWorkspaceDefinition as n, lifecycle_exports as t };
package/dist/lineage.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- //#region src/lineage.d.ts
2
1
  /** Where a derived file, such as a translation, came from: a Workspace path and the SHA-256 of its bytes then. */
3
2
  export interface WorkspaceDerivedFrom {
4
3
  path: string;
@@ -22,5 +21,4 @@ export declare function lineageDigest(bytes: Uint8Array): string;
22
21
  */
23
22
  export declare function readDerivedFrom(path: string, bytes: Uint8Array): WorkspaceDerivedFrom | undefined;
24
23
  /** The derived files of a file set whose source changed or is gone, sorted by path. */
25
- export declare function staleDerivedFiles(files: ReadonlyMap<string, Uint8Array>): WorkspaceStaleFile[];
26
- //#endregion
24
+ export declare function staleDerivedFiles(files: ReadonlyMap<string, Uint8Array>): WorkspaceStaleFile[];
package/dist/lineage.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { createHash } from "node:crypto";
2
2
  import { parse } from "yaml";
3
- //#region src/lineage.ts
3
+ // src/lineage.ts
4
4
  /** The digest that `derivedFrom.digest` holds: `sha256-` and the hex SHA-256 of the file bytes. */
5
5
  function lineageDigest(bytes) {
6
6
  return `sha256-${createHash("sha256").update(bytes).digest("hex")}`;
@@ -72,5 +72,4 @@ function staleDerivedFiles(files) {
72
72
  }
73
73
  return stale.sort((left, right) => left.path < right.path ? -1 : 1);
74
74
  }
75
- //#endregion
76
75
  export { lineageDigest, readDerivedFrom, staleDerivedFiles };
package/dist/loader.d.ts CHANGED
@@ -1,16 +1,10 @@
1
- import { N as WorkspaceContent, Zt as WorkspaceSourceItem, dt as WorkspaceLoader } from "./types-1Z-tKK3g.js";
2
- //#region src/loaders/files.d.ts
1
+ import { P as WorkspaceContent, mt as WorkspaceLoader, tn as WorkspaceSourceItem } from "./types-Bel5IDmF.js";
3
2
  interface FilesLoaderOptions {
4
3
  include?: string | string[];
5
4
  exclude?: string | string[];
6
5
  transform?: (item: WorkspaceSourceItem) => WorkspaceContent | WorkspaceSourceItem | Promise<WorkspaceContent | WorkspaceSourceItem>;
7
6
  }
8
7
  export declare function files(options?: FilesLoaderOptions): WorkspaceLoader;
9
- //#endregion
10
- //#region src/loaders/json.d.ts
11
8
  export declare function json(options?: FilesLoaderOptions): WorkspaceLoader;
12
- //#endregion
13
- //#region src/loaders/text.d.ts
14
9
  export declare function text(options?: FilesLoaderOptions): WorkspaceLoader;
15
- //#endregion
16
10
  export type { FilesLoaderOptions };
package/dist/loader.js CHANGED
@@ -1,6 +1,6 @@
1
- import { o as isWorkspaceBytes } from "./path--wrT_Azm.js";
2
- import { t as files } from "./files-B6wpAhEx.js";
3
- //#region src/loaders/json.ts
1
+ import { t as files } from "./files--z2dLC5z.js";
2
+ import { o as isWorkspaceBytes } from "./path-Bb9OIc_F.js";
3
+ // src/loaders/json.ts
4
4
  function json(options = {}) {
5
5
  return files({
6
6
  ...options,
@@ -14,10 +14,8 @@ function json(options = {}) {
14
14
  }
15
15
  });
16
16
  }
17
- //#endregion
18
- //#region src/loaders/text.ts
17
+ // src/loaders/text.ts
19
18
  function text(options = {}) {
20
19
  return files(options);
21
20
  }
22
- //#endregion
23
21
  export { files, json, text };
@@ -1,8 +1,8 @@
1
- import { n as __exportAll } from "./rolldown-runtime-rQ84J-ij.js";
2
- import { t as normalizeSafeWorkspacePath } from "./path-DrSIenjj.js";
3
- import { b as markLiveWorkspaceSource, d as withWorkspaceRuntimeOptions, f as prepareWorkspaceSource, u as ownSourceOption } from "./config-D1QENneP.js";
1
+ import { n as __exportAll } from "./rolldown-runtime-DnNXxpGL.js";
2
+ import { t as normalizeSafeWorkspacePath } from "./path-CuYE8-X6.js";
3
+ import { b as markLiveWorkspaceSource, d as withWorkspaceRuntimeOptions, f as prepareWorkspaceSource, u as ownSourceOption } from "./config-jo5QgE1w.js";
4
4
  import { mcpResources } from "@vite-hub/source/mcp";
5
- //#region src/sources/mcp-resources.ts
5
+ // src/sources/mcp-resources.ts
6
6
  var mcp_resources_exports = /* @__PURE__ */ __exportAll({ mcpResources: () => mcpResources$1 });
7
7
  function mcpResources$1(options) {
8
8
  const livePaths = {};
@@ -35,5 +35,4 @@ function resetLivePaths(paths, mountPath, keys) {
35
35
  paths[path] = key;
36
36
  }
37
37
  }
38
- //#endregion
39
38
  export { mcp_resources_exports as n, mcpResources$1 as t };
@@ -1,18 +1,18 @@
1
- import { n as assertWorkspaceDigest, o as workspaceConflictError, s as workspaceError } from "./path-DrSIenjj.js";
2
- import { o as copyJsonFileMetadata, r as workspaceStoreTarget } from "./target-Dm9dHAVJ.js";
3
- import { a as isExcludedWorkspacePath, f as sha256, l as normalizeWorkspacePath, o as isWorkspaceBytes } from "./path--wrT_Azm.js";
4
- import { t as createWorkspaceGlobMatcher } from "./glob-Cjxms1t7.js";
5
- //#region ../internal/src/owned-paths.ts
1
+ import { n as assertWorkspaceDigest, o as workspaceConflictError, s as workspaceError } from "./path-CuYE8-X6.js";
2
+ import { t as copyJsonFileMetadata } from "./file-metadata-Bpsvjw_X.js";
3
+ import { a as isExcludedWorkspacePath, d as sha256, l as normalizeWorkspacePath, o as isWorkspaceBytes } from "./path-Bb9OIc_F.js";
4
+ import { t as createWorkspaceGlobMatcher } from "./glob-BreFjNAV.js";
5
+ import { a as provideWorkspaceStoreTarget } from "./vitehub-grants-Co713QTg.js";
6
+ // ../internal/src/owned-paths.ts
6
7
  /** Every Blob path that ViteHub writes for itself starts with this prefix. */
7
8
  const vitehubOwnedPrefix = "_vitehub/";
8
- //#endregion
9
- //#region src/storage/memory.ts
9
+ // src/storage/memory.ts
10
10
  function now() {
11
11
  return Date.now();
12
12
  }
13
13
  var MemoryWorkspaceStore = class MemoryWorkspaceStore {
14
- [workspaceStoreTarget]() {
15
- return { provider: "memory" };
14
+ constructor() {
15
+ provideWorkspaceStoreTarget(this, () => ({ provider: "memory" }));
16
16
  }
17
17
  #nodes = /* @__PURE__ */ new Map([["", {
18
18
  type: "directory",
@@ -159,10 +159,17 @@ var MemoryWorkspaceStore = class MemoryWorkspaceStore {
159
159
  };
160
160
  }
161
161
  async getMeta(key) {
162
- return this.#meta.get(key);
162
+ return structuredClone(this.#meta.get(key));
163
163
  }
164
164
  async setMeta(key, value) {
165
- this.#meta.set(key, value);
165
+ try {
166
+ this.#meta.set(key, structuredClone(value));
167
+ } catch (error) {
168
+ if (!(error instanceof DOMException && error.name === "DataCloneError")) throw error;
169
+ const json = JSON.stringify(value);
170
+ if (json === void 0) this.#meta.delete(key);
171
+ else this.#meta.set(key, JSON.parse(json));
172
+ }
166
173
  }
167
174
  #writeFile(path, file) {
168
175
  file = {
@@ -200,7 +207,7 @@ var MemoryWorkspaceStore = class MemoryWorkspaceStore {
200
207
  }
201
208
  async #entry(path, node) {
202
209
  const content = node.content || "";
203
- const size = node.type === "file" ? typeof content === "string" ? new TextEncoder().encode(content).byteLength : content.byteLength : void 0;
210
+ const size = node.type === "file" ? node.size ??= typeof content === "string" ? new TextEncoder().encode(content).byteLength : content.byteLength : void 0;
204
211
  return {
205
212
  path,
206
213
  type: node.type,
@@ -243,5 +250,4 @@ function forkMemoryWorkspaceStore(store) {
243
250
  if (!(store instanceof MemoryWorkspaceStore)) throw workspaceError("[vitehub] Only memory Workspace Stores can be forked.");
244
251
  return store.fork();
245
252
  }
246
- //#endregion
247
253
  export { forkMemoryWorkspaceStore as n, vitehubOwnedPrefix as r, createMemoryWorkspaceStore as t };