@vite-hub/shell 0.5.0 → 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.
@@ -1,6 +1,6 @@
1
1
  import { BinCmdOperator, LangVariant, RedirOperator, createSourceIndex, walk } from "sh-syntax";
2
2
  import { defineDiagnostics } from "nostics";
3
- //#region src/error-diagnostics.ts
3
+ // src/error-diagnostics.ts
4
4
  const dynamicError = { why: ({ message }) => message === void 0 ? "" : String(message) };
5
5
  const shellErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
6
6
  docsBase: "https://vitehub.dev/docs/shell/diagnostics",
@@ -103,8 +103,7 @@ const shellErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
103
103
  }
104
104
  }
105
105
  });
106
- //#endregion
107
- //#region src/command/sh-syntax.ts
106
+ // src/command/sh-syntax.ts
108
107
  let parser;
109
108
  async function parseShell(text, options) {
110
109
  parser ??= loadParser().catch((error) => {
@@ -133,8 +132,7 @@ async function bundledWasmModule() {
133
132
  if (wasm instanceof Uint8Array) return { module: await WebAssembly.compile(wasm) };
134
133
  return { module: wasm instanceof WebAssembly.Module ? wasm : void 0 };
135
134
  }
136
- //#endregion
137
- //#region src/command/parse.ts
135
+ // src/command/parse.ts
138
136
  function wordText(word, source, toIndex = createSourceIndex(source)) {
139
137
  return word.parts.map((part) => wordPartText(part, source, toIndex, false)).join("");
140
138
  }
@@ -338,8 +336,7 @@ function stripLineContinuations(command) {
338
336
  }
339
337
  return result;
340
338
  }
341
- //#endregion
342
- //#region src/command/analyze.ts
339
+ // src/command/analyze.ts
343
340
  const defaultMaxInputBytes = 65536;
344
341
  const defaultTimeoutMs = 100;
345
342
  async function analyzeShellCommand(command, options = {}) {
@@ -417,5 +414,4 @@ async function withTimeout(promise, timeoutMs) {
417
414
  if (timeout) clearTimeout(timeout);
418
415
  }
419
416
  }
420
- //#endregion
421
417
  export { splitShellCommandSegments as n, shellErrorDiagnostics as r, analyzeShellCommand as t };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,4 @@
1
- import { a as ShellBoundary, c as ShellObservationEvent, d as ShellRuntimeExecOptions, f as ShellSession, i as ShellAnalyzeResult, l as ShellProcess, n as CreateShellSessionOptions, o as ShellDriver, p as ShellSessionPolicy, r as ShellAnalyzeOptions, s as ShellObservation, t as CreateShellRuntimeOptions, u as ShellRuntime } from "./types-wPMXgnB0.js";
2
- //#region src/command/analyze.d.ts
1
+ import { a as ShellBoundary, c as ShellObservationEvent, d as ShellRuntimeExecOptions, f as ShellSession, i as ShellAnalyzeResult, l as ShellProcess, n as CreateShellSessionOptions, o as ShellDriver, p as ShellSessionPolicy, r as ShellAnalyzeOptions, s as ShellObservation, t as CreateShellRuntimeOptions, u as ShellRuntime } from "./types-0p6rVKwI.js";
3
2
  export declare function analyzeShellCommand(command: string, options?: ShellAnalyzeOptions): Promise<ShellAnalyzeResult>;
4
- //#endregion
5
- //#region src/runtime/session.d.ts
6
3
  export declare function createShellRuntime(options: CreateShellRuntimeOptions): ShellRuntime;
7
- //#endregion
8
4
  export type { CreateShellRuntimeOptions, CreateShellSessionOptions, ShellAnalyzeOptions, ShellAnalyzeResult, ShellBoundary, ShellDriver, ShellObservation, ShellObservationEvent, ShellProcess, ShellRuntime, ShellRuntimeExecOptions, ShellSession, ShellSessionPolicy };
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- import { t as analyzeShellCommand } from "./analyze-psY4ydry.js";
2
- import { t as createShellRuntime } from "./session-DOtQ5C_n.js";
1
+ import { t as analyzeShellCommand } from "./analyze-3W0Rnm5v.js";
2
+ import { t as createShellRuntime } from "./session-ChhAKsnl.js";
3
3
  export { analyzeShellCommand, createShellRuntime };
@@ -1,7 +1,6 @@
1
- import { o as ShellDriver } from "./types-wPMXgnB0.js";
1
+ import { o as ShellDriver } from "./types-0p6rVKwI.js";
2
2
  import { BashOptions } from "just-bash/browser";
3
3
  import { IFileSystem } from "just-bash";
4
- //#region src/providers/just-bash.d.ts
5
4
  interface JustBashFileSystem extends IFileSystem {
6
5
  readonly writeFs: boolean;
7
6
  }
@@ -33,5 +32,4 @@ interface ShellNetworkRequestResult {
33
32
  content: string | Uint8Array;
34
33
  }
35
34
  declare function createJustBashDriver(options: JustBashDriverOptions): ShellDriver;
36
- //#endregion
37
35
  export { ShellNetworkGrantExecutor as a, createJustBashDriver as c, JustBashFileSystem as i, JustBashExecutionLimitProfile as n, ShellNetworkRequest as o, JustBashExecutionLimits as r, ShellNetworkRequestResult as s, JustBashDriverOptions as t };
@@ -1,2 +1,2 @@
1
- import { a as ShellNetworkGrantExecutor, c as createJustBashDriver, i as JustBashFileSystem, n as JustBashExecutionLimitProfile, o as ShellNetworkRequest, r as JustBashExecutionLimits, s as ShellNetworkRequestResult, t as JustBashDriverOptions } from "../just-bash-CHpGR1dZ.js";
1
+ import { a as ShellNetworkGrantExecutor, c as createJustBashDriver, i as JustBashFileSystem, n as JustBashExecutionLimitProfile, o as ShellNetworkRequest, r as JustBashExecutionLimits, s as ShellNetworkRequestResult, t as JustBashDriverOptions } from "../just-bash-3Rfl6Fim.js";
2
2
  export { JustBashDriverOptions, JustBashExecutionLimitProfile, JustBashExecutionLimits, JustBashFileSystem, ShellNetworkGrantExecutor, ShellNetworkRequest, ShellNetworkRequestResult, createJustBashDriver };
@@ -1,5 +1,5 @@
1
- import { r as shellErrorDiagnostics, t as analyzeShellCommand } from "../analyze-psY4ydry.js";
2
- //#region src/providers/just-bash.ts
1
+ import { r as shellErrorDiagnostics, t as analyzeShellCommand } from "../analyze-3W0Rnm5v.js";
2
+ // src/providers/just-bash.ts
3
3
  function createJustBashDriver(options) {
4
4
  const commands = options.commands?.slice();
5
5
  const networkGrants = options.networkGrants;
@@ -297,5 +297,4 @@ function boundOutput(content, maxLength) {
297
297
  truncated: true
298
298
  };
299
299
  }
300
- //#endregion
301
300
  export { createJustBashDriver };
@@ -1,5 +1,5 @@
1
- import { r as shellErrorDiagnostics, t as analyzeShellCommand } from "./analyze-psY4ydry.js";
2
- //#region src/runtime/session.ts
1
+ import { r as shellErrorDiagnostics, t as analyzeShellCommand } from "./analyze-3W0Rnm5v.js";
2
+ // src/runtime/session.ts
3
3
  function applyOutputLimit(result, maxLength) {
4
4
  const limit = normalizeLimit(maxLength);
5
5
  if (limit === void 0) return result;
@@ -303,5 +303,4 @@ function createShellRuntime(options) {
303
303
  }
304
304
  };
305
305
  }
306
- //#endregion
307
306
  export { createShellRuntime as t };
@@ -1,5 +1,4 @@
1
1
  import { ExecutionBudget } from "@vite-hub/runtime";
2
- //#region src/runtime/types.d.ts
3
2
  type ShellObservationEvent = "command_finished" | "command_timed_out" | "policy_denied" | "session_disposed";
4
3
  interface ShellRuntimeExecOptions {
5
4
  budget?: ExecutionBudget;
@@ -118,5 +117,4 @@ interface CreateShellSessionOptions {
118
117
  env?: Record<string, string>;
119
118
  policy?: ShellSessionPolicy;
120
119
  }
121
- //#endregion
122
120
  export { ShellBoundary as a, ShellObservationEvent as c, ShellRuntimeExecOptions as d, ShellSession as f, ShellAnalyzeResult as i, ShellProcess as l, CreateShellSessionOptions as n, ShellDriver as o, ShellSessionPolicy as p, ShellAnalyzeOptions as r, ShellObservation as s, CreateShellRuntimeOptions as t, ShellRuntime as u };
@@ -1,8 +1,7 @@
1
- import { o as ShellDriver, s as ShellObservation } from "./types-wPMXgnB0.js";
2
- import { a as ShellNetworkGrantExecutor } from "./just-bash-CHpGR1dZ.js";
1
+ import { o as ShellDriver, s as ShellObservation } from "./types-0p6rVKwI.js";
2
+ import { a as ShellNetworkGrantExecutor } from "./just-bash-3Rfl6Fim.js";
3
3
  import { ExecutionBudget } from "@vite-hub/runtime";
4
4
  import { IFileSystem } from "just-bash";
5
- //#region src/workspace/types.d.ts
6
5
  type ShellContent = string | Uint8Array;
7
6
  interface ShellReadFileOptions {
8
7
  encoding?: "utf8" | "binary";
@@ -51,16 +50,12 @@ interface WritableShellWorkspace extends ReadonlyShellWorkspace {
51
50
  mkdir(path: string, options?: ShellMkdirOptions): Promise<void>;
52
51
  rm(path: string, options?: ShellRmOptions): Promise<void>;
53
52
  }
54
- //#endregion
55
- //#region src/workspace/filesystem.d.ts
56
53
  interface WorkspaceShellFileSystem extends IFileSystem {
57
54
  readonly writeFs: boolean;
58
55
  }
59
56
  export declare const workspaceMountPoint = "/workspace";
60
57
  export declare function createReadonlyWorkspaceFs(workspace: ReadonlyShellWorkspace): WorkspaceShellFileSystem;
61
58
  export declare function createWritableWorkspaceFs(workspace: WritableShellWorkspace): WorkspaceShellFileSystem;
62
- //#endregion
63
- //#region src/workspace/inspection.d.ts
64
59
  interface WorkspaceInspectionCommandOptions {
65
60
  budget?: ExecutionBudget;
66
61
  budgetCharged?: boolean;
@@ -75,9 +70,6 @@ interface WorkspaceInspectionCommandOptions {
75
70
  timeout?: number;
76
71
  }
77
72
  export declare function runWorkspaceInspectionCommand(_input: SearchableShellWorkspace, command: string, options: WorkspaceInspectionCommandOptions): Promise<ShellObservation>;
78
- //#endregion
79
- //#region src/workspace/path.d.ts
80
73
  export declare function cleanWorkspaceShellPath(path?: string): string;
81
74
  export declare function cleanWorkspaceMutationPath(path: string): string;
82
- //#endregion
83
75
  export type { ReadonlyShellWorkspace, SearchableShellWorkspace, ShellContent, ShellEntry, ShellListOptions, ShellMkdirOptions, ShellReadFileOptions, ShellRmOptions, ShellSearchHit, ShellSearchQuery, ShellStat, WorkspaceShellFileSystem, WritableShellWorkspace };
package/dist/workspace.js CHANGED
@@ -1,9 +1,9 @@
1
- import { n as splitShellCommandSegments, r as shellErrorDiagnostics } from "./analyze-psY4ydry.js";
2
- import { t as createShellRuntime } from "./session-DOtQ5C_n.js";
1
+ import { n as splitShellCommandSegments, r as shellErrorDiagnostics } from "./analyze-3W0Rnm5v.js";
3
2
  import { createJustBashDriver } from "./providers/just-bash.js";
3
+ import { t as createShellRuntime } from "./session-ChhAKsnl.js";
4
4
  import { Buffer } from "node:buffer";
5
5
  import { posix } from "node:path";
6
- //#region src/workspace/filesystem.ts
6
+ // src/workspace/filesystem.ts
7
7
  const workspaceMountPoint = "/workspace";
8
8
  function createEscapeError(path) {
9
9
  return shellErrorDiagnostics.SHELL_R0013({ message: `[vitehub] Workspace path escapes the workspace root: "${path}".` });
@@ -269,8 +269,7 @@ function createReadonlyWorkspaceFs(workspace) {
269
269
  function createWritableWorkspaceFs(workspace) {
270
270
  return new WorkspaceFileSystem(workspace, true);
271
271
  }
272
- //#endregion
273
- //#region src/workspace/command-analysis.ts
272
+ // src/workspace/command-analysis.ts
274
273
  async function analyzeWorkspaceInspectionCommand(command) {
275
274
  return (await splitShellCommandSegments(command)).map((segment) => ({
276
275
  ...segment,
@@ -456,8 +455,7 @@ function hasRecursiveGrepFlag(words) {
456
455
  }
457
456
  return false;
458
457
  }
459
- //#endregion
460
- //#region src/workspace/path.ts
458
+ // src/workspace/path.ts
461
459
  function cleanWorkspaceShellPath(path = ".") {
462
460
  const input = path || ".";
463
461
  if (input === "." || input === "./" || input === "/" || input === "/workspace") return "";
@@ -474,8 +472,7 @@ function normalizeSafeShellPath(path) {
474
472
  if (normalized === ".." || normalized.startsWith("../")) throw shellErrorDiagnostics.SHELL_R0021({ message: `[vitehub] Workspace path escapes the workspace root: "${path}".` });
475
473
  return normalized;
476
474
  }
477
- //#endregion
478
- //#region src/workspace/inspection.ts
475
+ // src/workspace/inspection.ts
479
476
  async function runWorkspaceInspectionCommand(_input, command, options) {
480
477
  throwIfAborted(options.signal);
481
478
  const maxOutputLength = options.maxOutputLength === void 0 ? 3e4 : normalizeOutputLength(options.maxOutputLength);
@@ -949,5 +946,4 @@ function resolvedWorkspaceCwd(cwd, path) {
949
946
  const resolvedPath = normalizedCwd ? posix.join(normalizedCwd, path) : path;
950
947
  return posix.join(workspaceMountPoint, resolvedPath);
951
948
  }
952
- //#endregion
953
949
  export { cleanWorkspaceMutationPath, cleanWorkspaceShellPath, createReadonlyWorkspaceFs, createWritableWorkspaceFs, runWorkspaceInspectionCommand, workspaceMountPoint };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vite-hub/shell",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "Unified shell runtimes for ViteHub.",
5
5
  "keywords": [
6
6
  "bash",
@@ -45,17 +45,17 @@
45
45
  "./package.json": "./package.json"
46
46
  },
47
47
  "dependencies": {
48
- "@vite-hub/runtime": "0.5.0",
49
- "just-bash": "^3.6.0",
48
+ "@vite-hub/runtime": "0.5.1",
49
+ "just-bash": "^3.6.1",
50
50
  "nostics": "1.4.0",
51
51
  "sh-syntax": "0.8.7"
52
52
  },
53
53
  "devDependencies": {
54
- "@types/node": "^24.19.1",
54
+ "@types/node": "^24.19.2",
55
55
  "publint": "^0.3.25",
56
56
  "typescript": "^6.0.3",
57
- "vite-plus": "^0.3.3",
58
- "vitest": "^4.1.11"
57
+ "vite-plus": "^1.7.0",
58
+ "vitest": "5.1.0"
59
59
  },
60
60
  "engines": {
61
61
  "node": ">=24.15.0"