@spotpatch/agent 1.2.4 → 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.cjs CHANGED
@@ -1872,7 +1872,7 @@ var AGENT_TOOL_DEFINITIONS = Object.freeze([
1872
1872
  }),
1873
1873
  Object.freeze({
1874
1874
  name: AGENT_TOOL_NAMES.readFile,
1875
- description: "Read a bounded inclusive line range from one allowed UTF-8 text file. Choose paths returned by list_files or search_text. A retryable TOOL_PATH_DENIED result means no file was read or changed: do not retry that path; discover an allowed path instead.",
1875
+ description: "Read a bounded inclusive line range from one allowed UTF-8 text file. Choose an exact path supplied by trusted SpotPatch context or returned by list_files or search_text. A retryable TOOL_PATH_DENIED result means no file was read or changed: do not retry that path; discover an allowed path instead.",
1876
1876
  parameters: Object.freeze({
1877
1877
  type: "object",
1878
1878
  properties: Object.freeze({
@@ -1926,6 +1926,11 @@ var AGENT_TOOL_DEFINITIONS = Object.freeze([
1926
1926
  })
1927
1927
  })
1928
1928
  ]);
1929
+ var AGENT_TOOL_DEFINITIONS_WITHOUT_CHECKS = Object.freeze(
1930
+ AGENT_TOOL_DEFINITIONS.filter(
1931
+ (definition) => definition.name !== AGENT_TOOL_NAMES.runCheck
1932
+ )
1933
+ );
1929
1934
 
1930
1935
  // src/tools/tool-executor.ts
1931
1936
  var SEARCH_READ_CONCURRENCY = 8;
@@ -2861,6 +2866,7 @@ var import_shared19 = require("@spotpatch/shared");
2861
2866
  var MAX_PROJECT_CONVENTION_CHARACTERS = 3500;
2862
2867
  var MAX_VALIDATION_CHECK_CHARACTERS = 1200;
2863
2868
  var MINIMUM_SELECTION_CONTEXT_CHARACTERS = 1024;
2869
+ var VALIDATION_SYSTEM_INSTRUCTION = "- Run each relevant configured check after the final write so failures can be corrected. Do not rerun an unchanged check, and do not claim a check passed unless run_check returned a passed status.\n";
2864
2870
  var AGENT_SYSTEM_INSTRUCTIONS = `You are editing code only inside a disposable, isolated Git worktree.
2865
2871
 
2866
2872
  Follow these rules exactly:
@@ -2877,8 +2883,11 @@ Follow these rules exactly:
2877
2883
  - If any tool returns a retryable TOOL_ARGUMENTS_INVALID result, no file changed. Retry once with a new tool call ID using only the declared fields and value types.
2878
2884
  - If read_file returns a retryable TOOL_PATH_DENIED result, no file was read or changed. Do not retry that path. Use list_files or search_text and choose an allowed path returned by the tool; never probe protected, external, generated, credential, environment, or lock files.
2879
2885
  - Never modify credentials, environment files, lockfiles, generated output, Git metadata, or dependencies.
2880
- - Run each relevant configured check after the final write so failures can be corrected. Do not rerun an unchanged check, and do not claim a check passed unless run_check returned a passed status.
2886
+ ${VALIDATION_SYSTEM_INSTRUCTION.trimEnd()}
2881
2887
  - Finish with a concise factual summary after all needed tool calls. Do not include secrets or absolute paths.`;
2888
+ function resolveAgentSystemInstructions(trustedFast) {
2889
+ return trustedFast ? AGENT_SYSTEM_INSTRUCTIONS.replace(VALIDATION_SYSTEM_INSTRUCTION, "") : AGENT_SYSTEM_INSTRUCTIONS;
2890
+ }
2882
2891
  function redactedJson(value) {
2883
2892
  return JSON.stringify(
2884
2893
  value,
@@ -3070,7 +3079,8 @@ function composeAgentUserPrompt(annotation, maximumCharacters, context = {}) {
3070
3079
  (target, index) => `Target ${String(index + 1)}:
3071
3080
  ${(0, import_shared19.redactSensitiveText)(target.instruction.trim())}`
3072
3081
  ).join("\n\n");
3073
- const requestBlock = `${requestPrefix}${request}`;
3082
+ const trustedFastBlock = context.trustedFast ? "\n\nTrusted direct execution is enabled. Start from each target's supplied code.relativePath or source.relativePath. When an exact path is present, do not call list_files first. Read each affected file once unless a write is rejected, make the smallest exact replacement that satisfies the request, and finish immediately after the successful write. No project validation check is available in this mode." : "";
3083
+ const requestBlock = `${requestPrefix}${request}${trustedFastBlock}`;
3074
3084
  const checksPrefix = "\n\nConfigured validation checks (IDs and labels only):\n<validation_checks>\n";
3075
3085
  const checksSuffix = "\n</validation_checks>";
3076
3086
  if (requestBlock.length + contextPrefix.length + suffix.length + MINIMUM_SELECTION_CONTEXT_CHARACTERS > maximumCharacters) {
@@ -3173,6 +3183,8 @@ async function executeToolCalls(calls, turn, executor, callbacks, signal) {
3173
3183
  return Object.freeze(results);
3174
3184
  }
3175
3185
  async function executeAgentChange(options) {
3186
+ const trustedFast = options.execution.applyMode === "trusted-auto";
3187
+ const activeChecks = trustedFast ? Object.freeze({}) : options.execution.checks;
3176
3188
  const controller = new AbortController();
3177
3189
  const unlink = linkSignal(options.signal, controller);
3178
3190
  let jobTimedOut = false;
@@ -3204,7 +3216,7 @@ async function executeAgentChange(options) {
3204
3216
  })
3205
3217
  );
3206
3218
  const executor = createAgentToolExecutor({
3207
- checks: options.execution.checks,
3219
+ checks: activeChecks,
3208
3220
  limits: options.execution.limits,
3209
3221
  worktreeRoot: worktree.root,
3210
3222
  onCheck(result2) {
@@ -3220,16 +3232,17 @@ async function executeAgentChange(options) {
3220
3232
  provider: options.provider,
3221
3233
  model: options.model,
3222
3234
  credential: options.credential,
3223
- instructions: AGENT_SYSTEM_INSTRUCTIONS,
3235
+ instructions: resolveAgentSystemInstructions(trustedFast),
3224
3236
  userPrompt: composeAgentUserPrompt(
3225
3237
  options.annotation,
3226
3238
  options.promptMaxCharacters ?? 16e3,
3227
3239
  Object.freeze({
3228
- checks: options.execution.checks,
3229
- projectConventions
3240
+ checks: activeChecks,
3241
+ projectConventions,
3242
+ trustedFast
3230
3243
  })
3231
3244
  ),
3232
- tools: AGENT_TOOL_DEFINITIONS,
3245
+ tools: trustedFast ? AGENT_TOOL_DEFINITIONS_WITHOUT_CHECKS : AGENT_TOOL_DEFINITIONS,
3233
3246
  limits: options.execution.limits,
3234
3247
  ...options.fetch === void 0 ? {} : { fetch: options.fetch }
3235
3248
  });
@@ -3266,7 +3279,7 @@ async function executeAgentChange(options) {
3266
3279
  options.callbacks?.onPhase?.(
3267
3280
  Object.freeze({
3268
3281
  phase: "validating",
3269
- message: "Validating proposed changes."
3282
+ message: trustedFast ? "Preparing trusted change for direct apply." : "Validating proposed changes."
3270
3283
  })
3271
3284
  );
3272
3285
  const initialChangeSet = await collectAgentChangeSet(
@@ -3275,7 +3288,7 @@ async function executeAgentChange(options) {
3275
3288
  options.execution.limits,
3276
3289
  controller.signal
3277
3290
  );
3278
- const requiredChecks = initialChangeSet.diff.length === 0 ? [] : Object.values(options.execution.checks).filter((check) => check.required);
3291
+ const requiredChecks = initialChangeSet.diff.length === 0 ? [] : Object.values(activeChecks).filter((check) => check.required);
3279
3292
  const finalChecks = [];
3280
3293
  let ranFinalCheck = false;
3281
3294
  for (const check of requiredChecks) {