@spotpatch/vite 1.2.2 → 1.3.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.
package/dist/index.js CHANGED
@@ -481,7 +481,7 @@ import path2 from "path";
481
481
  // package.json
482
482
  var package_default = {
483
483
  name: "@spotpatch/vite",
484
- version: "1.2.2",
484
+ version: "1.3.0",
485
485
  description: "Vite development plugin for SpotPatch.",
486
486
  license: "MIT",
487
487
  repository: {
@@ -646,6 +646,7 @@ import { createHash, randomBytes as randomBytes2 } from "crypto";
646
646
  import {
647
647
  applyPreparedAgentChange,
648
648
  executeAgentChange,
649
+ inspectAgentWorkspace,
649
650
  probeProviderCapability,
650
651
  resolveProviderCredential,
651
652
  revertPreparedAgentChange
@@ -684,6 +685,7 @@ var DEFAULT_DEPENDENCIES = Object.freeze({
684
685
  applyChange: applyPreparedAgentChange,
685
686
  createJobId: () => randomBytes2(16).toString("base64url"),
686
687
  executeChange: executeAgentChange,
688
+ inspectWorkspace: inspectAgentWorkspace,
687
689
  now: () => (/* @__PURE__ */ new Date()).toISOString(),
688
690
  probeCapability: probeProviderCapability,
689
691
  resolveCredential: resolveProviderCredential,
@@ -903,6 +905,7 @@ function createAgentJobManager(options) {
903
905
  provider: job.provider,
904
906
  root: options.root,
905
907
  signal: job.controller.signal,
908
+ workingTreeMode: job.workingTreeMode,
906
909
  ...options.fetch === void 0 ? {} : { fetch: options.fetch }
907
910
  });
908
911
  job.preparedChange = preparedChange;
@@ -1039,7 +1042,8 @@ function createAgentJobManager(options) {
1039
1042
  runPromise: void 0,
1040
1043
  sequence: 0,
1041
1044
  status: "queued",
1042
- updatedAt: timestamp
1045
+ updatedAt: timestamp,
1046
+ workingTreeMode: request.workingTreeMode
1043
1047
  };
1044
1048
  jobs.set(id, job);
1045
1049
  emitSnapshot(job);
@@ -1094,6 +1098,12 @@ function createAgentJobManager(options) {
1094
1098
  return () => {
1095
1099
  job.listeners.delete(listener);
1096
1100
  };
1101
+ },
1102
+ workspaceHealth(signal) {
1103
+ if (closed) {
1104
+ throw new SpotPatchError(ERROR_CODES.AI_DISABLED);
1105
+ }
1106
+ return dependencies.inspectWorkspace(options.root, signal);
1097
1107
  }
1098
1108
  });
1099
1109
  }
@@ -1115,7 +1125,8 @@ import {
1115
1125
  SpotPatchError as SpotPatchError6,
1116
1126
  agentCapabilityRequestSchema,
1117
1127
  agentJobActionRequestSchema,
1118
- agentJobCreateRequestSchema
1128
+ agentJobCreateRequestSchema,
1129
+ agentWorkspaceHealthRequestSchema
1119
1130
  } from "@spotpatch/shared";
1120
1131
 
1121
1132
  // src/server/agent-request.ts
@@ -1601,7 +1612,8 @@ async function authorizeAgentJobRequest(input) {
1601
1612
  annotation,
1602
1613
  providerProfileId: input.request.providerProfileId,
1603
1614
  modelProfileId: input.request.modelProfileId,
1604
- providerDataConsent: true
1615
+ providerDataConsent: true,
1616
+ workingTreeMode: input.request.workingTreeMode
1605
1617
  });
1606
1618
  }
1607
1619
 
@@ -1667,6 +1679,9 @@ function matchAgentRequestPath(path11) {
1667
1679
  if (path11 === SPOTPATCH_ENDPOINTS.agentCapability) {
1668
1680
  return Object.freeze({ kind: "capability" });
1669
1681
  }
1682
+ if (path11 === SPOTPATCH_ENDPOINTS.agentWorkspaceHealth) {
1683
+ return Object.freeze({ kind: "workspace-health" });
1684
+ }
1670
1685
  if (path11 === SPOTPATCH_ENDPOINTS.agentJobs) {
1671
1686
  return Object.freeze({ kind: "create-job" });
1672
1687
  }
@@ -1783,6 +1798,28 @@ async function handleCreateJob(request, response, options, writeSuccess) {
1783
1798
  const data = requireAgentManager(options).create(authorizedRequest);
1784
1799
  writeSuccess(response, 202, data);
1785
1800
  }
1801
+ async function handleWorkspaceHealth(request, response, options, writeSuccess) {
1802
+ if (request.method !== "POST") {
1803
+ throw new SpotPatchError6(ERROR_CODES6.INVALID_REQUEST);
1804
+ }
1805
+ const parsed = agentWorkspaceHealthRequestSchema.safeParse(
1806
+ await readJsonRequestBody(request)
1807
+ );
1808
+ if (!parsed.success) {
1809
+ throw new SpotPatchError6(ERROR_CODES6.INVALID_REQUEST);
1810
+ }
1811
+ const controller = new AbortController();
1812
+ const abort = () => {
1813
+ controller.abort("agent-workspace-health-client-disconnected");
1814
+ };
1815
+ response.once("close", abort);
1816
+ try {
1817
+ const data = await requireAgentManager(options).workspaceHealth(controller.signal);
1818
+ writeSuccess(response, 200, data);
1819
+ } finally {
1820
+ response.removeListener("close", abort);
1821
+ }
1822
+ }
1786
1823
  async function handleJobAction(request, response, options, route, writeSuccess) {
1787
1824
  const manager = requireAgentManager(options);
1788
1825
  if (request.method !== "POST") {
@@ -1814,6 +1851,10 @@ async function handleAgentRequest(request, response, options, route, writeSucces
1814
1851
  await handleCreateJob(request, response, options, writeSuccess);
1815
1852
  return;
1816
1853
  }
1854
+ if (route.kind === "workspace-health") {
1855
+ await handleWorkspaceHealth(request, response, options, writeSuccess);
1856
+ return;
1857
+ }
1817
1858
  await handleJobAction(request, response, options, route, writeSuccess);
1818
1859
  }
1819
1860
 
@@ -1994,7 +2035,15 @@ var STATUS_BY_ERROR = Object.freeze({
1994
2035
  [ERROR_CODES8.AGENT_LIMIT_EXCEEDED]: 413,
1995
2036
  [ERROR_CODES8.AGENT_CANCELLED]: 409,
1996
2037
  [ERROR_CODES8.WORKTREE_DIRTY]: 409,
2038
+ [ERROR_CODES8.WORKTREE_NOT_REPOSITORY]: 409,
2039
+ [ERROR_CODES8.WORKTREE_OPERATION_IN_PROGRESS]: 409,
2040
+ [ERROR_CODES8.WORKTREE_CONFLICTED]: 409,
2041
+ [ERROR_CODES8.WORKTREE_LOCAL_CHANGES_TOO_LARGE]: 413,
2042
+ [ERROR_CODES8.WORKTREE_UNTRACKED_UNSUPPORTED]: 409,
2043
+ [ERROR_CODES8.WORKTREE_LOCAL_CHANGES_UNSUPPORTED]: 409,
1997
2044
  [ERROR_CODES8.TOOL_DENIED]: 403,
2045
+ [ERROR_CODES8.TOOL_INPUT_INVALID]: 422,
2046
+ [ERROR_CODES8.TOOL_PATH_DENIED]: 403,
1998
2047
  [ERROR_CODES8.PATCH_REJECTED]: 422,
1999
2048
  [ERROR_CODES8.VALIDATION_FAILED]: 422,
2000
2049
  [ERROR_CODES8.APPLY_CONFLICT]: 409,
@@ -2018,8 +2067,16 @@ var PUBLIC_MESSAGES = Object.freeze({
2018
2067
  [ERROR_CODES8.AGENT_BUSY]: "Another Agent job is already running.",
2019
2068
  [ERROR_CODES8.AGENT_LIMIT_EXCEEDED]: "The Agent job exceeded a safety limit.",
2020
2069
  [ERROR_CODES8.AGENT_CANCELLED]: "The Agent job was cancelled.",
2021
- [ERROR_CODES8.WORKTREE_DIRTY]: "The project worktree must be clean.",
2070
+ [ERROR_CODES8.WORKTREE_DIRTY]: "Local changes require explicit inclusion consent.",
2071
+ [ERROR_CODES8.WORKTREE_NOT_REPOSITORY]: "The project root is not a Git repository.",
2072
+ [ERROR_CODES8.WORKTREE_OPERATION_IN_PROGRESS]: "A Git operation is currently in progress.",
2073
+ [ERROR_CODES8.WORKTREE_CONFLICTED]: "The local workspace contains unresolved merge conflicts.",
2074
+ [ERROR_CODES8.WORKTREE_LOCAL_CHANGES_TOO_LARGE]: "The local workspace exceeds the safe isolation size limit.",
2075
+ [ERROR_CODES8.WORKTREE_UNTRACKED_UNSUPPORTED]: "An untracked path cannot be isolated safely.",
2076
+ [ERROR_CODES8.WORKTREE_LOCAL_CHANGES_UNSUPPORTED]: "The local workspace state cannot be isolated safely.",
2022
2077
  [ERROR_CODES8.TOOL_DENIED]: "The Agent tool request was denied.",
2078
+ [ERROR_CODES8.TOOL_INPUT_INVALID]: "The Agent tool input was invalid.",
2079
+ [ERROR_CODES8.TOOL_PATH_DENIED]: "The Agent tool path was denied.",
2023
2080
  [ERROR_CODES8.PATCH_REJECTED]: "The proposed patch was rejected.",
2024
2081
  [ERROR_CODES8.VALIDATION_FAILED]: "The proposed change failed validation.",
2025
2082
  [ERROR_CODES8.APPLY_CONFLICT]: "The change conflicts with the current worktree.",