@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.
- package/README.md +62 -19
- package/dist/{abort-BCwpdrN0.js → abort-CQGxJBqa.js} +1 -2
- package/dist/{asset-registry-DfBV5kmw.js → asset-registry-0CdRAjIV.js} +2 -3
- package/dist/blob-database/postgres.d.ts +423 -0
- package/dist/blob-database/postgres.js +1 -0
- package/dist/blob-database-sources-CQPAyCz3.js +8 -0
- package/dist/blob-database.d.ts +29 -449
- package/dist/blob-database.js +636 -210
- package/dist/checkout.d.ts +1 -2
- package/dist/checkout.js +3 -4
- package/dist/cloudflare.d.ts +1 -5
- package/dist/cloudflare.js +1 -2
- package/dist/{config-B-863EgC.js → config-CsgNNVAI.js} +1 -2
- package/dist/{config-CDeGd0RB.d.ts → config-DeA287c0.d.ts} +1 -5
- package/dist/{config-D1QENneP.js → config-jo5QgE1w.js} +18 -27
- package/dist/{discard-CNNtCozM.js → discard-BkoLmmmN.js} +1 -2
- package/dist/durability.d.ts +10 -4
- package/dist/durability.js +47 -6
- package/dist/{error-diagnostics-B5s9kNEA.js → error-diagnostics-B4me-ouV.js} +11 -4
- package/dist/{error-diagnostics-CQ4BUqRe.js → error-diagnostics-kKXseq8d.js} +10 -3
- package/dist/{path-uxLkzrZm.d.ts → errors-CnFDXxeJ.d.ts} +0 -3
- package/dist/{file-CqG9zqiF.js → file-BrNAXQgY.js} +4 -8
- package/dist/{target-Dm9dHAVJ.js → file-metadata-Bpsvjw_X.js} +3 -32
- package/dist/{files-B6wpAhEx.js → files--z2dLC5z.js} +3 -4
- package/dist/files.d.ts +12 -8
- package/dist/files.js +7 -6
- package/dist/{github-DKAlO0Vh.js → github-k--_LCrX.js} +7 -9
- package/dist/{glob-BOqSKzSg.js → glob-BEutagp1.js} +9 -10
- package/dist/{glob-Cjxms1t7.js → glob-BreFjNAV.js} +3 -4
- package/dist/history-schema-BR4UDPHL.d.ts +434 -0
- package/dist/history-schema-postgres-DZepCSBq.js +40 -0
- package/dist/{host-Bf1a2uo_.js → host-C8yZizfk.js} +153 -22
- package/dist/{hosted-zG7HJaE4.js → hosted-8BTKAtMX.js} +27 -21
- package/dist/{hosted-vercel-blob-AbXG8fvR.js → hosted-vercel-blob-B6kygYqn.js} +10 -12
- package/dist/hosted-vercel-blob.d.ts +1 -3
- package/dist/hosted-vercel-blob.js +1 -2
- package/dist/hosted.d.ts +1 -3
- package/dist/hosted.js +1 -2
- package/dist/index.d.ts +11 -41
- package/dist/index.js +34 -116
- package/dist/internal/path.d.ts +1 -1
- package/dist/internal/path.js +1 -2
- package/dist/internal/workspace.d.ts +10 -0
- package/dist/internal/workspace.js +85 -0
- package/dist/{lifecycle-D8FdpBod.js → lifecycle-IReZfi0b.js} +15 -13
- package/dist/lineage.d.ts +1 -3
- package/dist/lineage.js +1 -2
- package/dist/loader.d.ts +1 -7
- package/dist/loader.js +4 -6
- package/dist/{mcp-resources-DntxtmDU.js → mcp-resources-DeJnbOaw.js} +4 -5
- package/dist/{memory-D5jq9HZW.js → memory-BlSRrBH1.js} +19 -13
- package/dist/{metadata-target-DDoOQNp1.js → metadata-target-CaGLY4ay.js} +214 -77
- package/dist/{object-Da1zyPCR.js → object-CAK6UYR5.js} +1 -2
- package/dist/{operation-definition-nmRu_O3V.d.ts → operation-definition-CqZkx1Rm.d.ts} +8 -6
- package/dist/{operations-DsY2MQnG.js → operations-CtRDU3cA.js} +34 -29
- package/dist/{operations-D8uCpzhM.js → operations-DfbqHWAe.js} +7 -8
- package/dist/operations.d.ts +2 -6
- package/dist/operations.js +2 -2
- package/dist/{path--wrT_Azm.js → path-Bb9OIc_F.js} +3 -19
- package/dist/{path-zHxQUbqa.d.ts → path-C0uZxDdW.d.ts} +0 -2
- package/dist/{path-DrSIenjj.js → path-CuYE8-X6.js} +2 -4
- package/dist/{plugins-CsrXCA1Q.d.ts → plugins-CLc32jvL.d.ts} +1 -3
- package/dist/{provider-sm9uzkLg.js → provider-CN14ewvx.js} +30 -22
- package/dist/providers/github/store.d.ts +2 -4
- package/dist/providers/github/store.js +1 -2
- package/dist/{registry-CFl1Htyc.d.ts → registry-B0g19sdy.d.ts} +5 -8
- package/dist/{registry-DmVfUe4K.js → registry-BbUg9vJB.js} +10 -6
- package/dist/registry-s2Ob9PeX.d.ts +9 -0
- package/dist/{request-scope-Dw5n8bMC.js → request-scope-CXCI_wCb.js} +4 -4
- package/dist/{results-DgkZUmTL.js → results-z-HpV9EP.js} +1 -2
- package/dist/{rolldown-runtime-rQ84J-ij.js → rolldown-runtime-DnNXxpGL.js} +2 -3
- package/dist/rule-keys-BLEbi1h5.js +18 -0
- package/dist/rules-BPDXypZV.js +267 -0
- package/dist/runtime/assets.d.ts +2 -3
- package/dist/runtime/assets.js +5 -6
- package/dist/runtime/empty-assets-registry.d.ts +1 -3
- package/dist/runtime/empty-assets-registry.js +1 -2
- package/dist/runtime/empty-registry.d.ts +2 -4
- package/dist/runtime/empty-registry.js +1 -2
- package/dist/runtime/registry.d.ts +2 -2
- package/dist/runtime/registry.js +2 -3
- package/dist/runtime/request.d.ts +1 -3
- package/dist/runtime/request.js +2 -3
- package/dist/runtime/state.d.ts +5 -4
- package/dist/runtime/state.js +18 -7
- package/dist/runtime/workspace.d.ts +1 -1
- package/dist/runtime/workspace.js +1 -2
- package/dist/runtime.d.ts +9 -24
- package/dist/runtime.js +29 -25
- package/dist/{search-C_RfoM2j.js → search-C_nVorq7.js} +3 -4
- package/dist/{server-Cd4-iCh5.js → server-aa1a4rkV.js} +8 -10
- package/dist/server.d.ts +3 -4
- package/dist/server.js +1 -2
- package/dist/{shared-ovXVSV3-.js → shared-C20Wh1mp.js} +23 -19
- package/dist/source-metadata.d.ts +2 -6
- package/dist/source-metadata.js +4 -5
- package/dist/state-BdDfBtOR.d.ts +17 -0
- package/dist/{store-NZoRto-Y.js → store-cx3OqNTi.js} +42 -44
- package/dist/{sync-CrT8zjwc.js → sync-BBfR4g5y.js} +6 -7
- package/dist/test.d.ts +1 -1
- package/dist/test.js +1 -2
- package/dist/{types-1Z-tKK3g.d.ts → types-Bel5IDmF.d.ts} +52 -6
- package/dist/{use-CjbF8EO9.d.ts → use-CpphIBof.d.ts} +20 -32
- package/dist/{use-B0o5HoBl.js → use-D0DyTMxM.js} +19 -21
- package/dist/use-tools-CAK10LTc.d.ts +10 -0
- package/dist/{state-Cb_hIyAw.js → use-tools-CHduR5k6.js} +8 -24
- package/dist/{utils-Dw-WULEZ.js → utils-DXP9xfXo.js} +80 -273
- package/dist/vite.d.ts +30 -19
- package/dist/vite.js +1481 -1617
- package/dist/vitehub-grants-Co713QTg.js +36 -0
- package/dist/workspace-BOuxrZrP.d.ts +5 -0
- package/dist/{workspace-DvKu5PRa.js → workspace-CLuPkyZR.js} +28 -36
- package/package.json +34 -24
- package/dist/registry-CwryP59t.d.ts +0 -9
- package/dist/state-C-YtsaiJ.d.ts +0 -35
- 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-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { t as
|
|
5
|
-
import {
|
|
6
|
-
import { t as
|
|
7
|
-
import { m as url } from "./config-
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { t as
|
|
12
|
-
import { t as
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 };
|
package/dist/internal/path.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as normalizeSafeWorkspacePath, t as SafeWorkspacePathOptions } from "../path-
|
|
1
|
+
import { n as normalizeSafeWorkspacePath, t as SafeWorkspacePathOptions } from "../path-C0uZxDdW.js";
|
|
2
2
|
export { SafeWorkspacePathOptions, normalizeSafeWorkspacePath };
|
package/dist/internal/path.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
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-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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 {
|
|
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 {
|
|
2
|
-
import {
|
|
3
|
-
|
|
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
|
-
|
|
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-
|
|
2
|
-
import { t as normalizeSafeWorkspacePath } from "./path-
|
|
3
|
-
import { b as markLiveWorkspaceSource, d as withWorkspaceRuntimeOptions, f as prepareWorkspaceSource, u as ownSourceOption } from "./config-
|
|
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
|
-
|
|
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-
|
|
2
|
-
import {
|
|
3
|
-
import { a as isExcludedWorkspacePath,
|
|
4
|
-
import { t as createWorkspaceGlobMatcher } from "./glob-
|
|
5
|
-
|
|
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
|
-
|
|
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
|
-
|
|
15
|
-
|
|
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
|
-
|
|
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 };
|