@alas-ide/codex-acp 2.5.0-alas.3 → 2.5.0-alas.4

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 (2) hide show
  1. package/dist/index.js +37 -20
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -33488,6 +33488,18 @@ function parsePatch(uniDiff) {
33488
33488
 
33489
33489
  // src/GitPatch.ts
33490
33490
  var DIFF_PATCH_MAX_BYTES = 1024 * 1024;
33491
+ var NEUTRAL_DIFF_PATCH_META_KEY = "diffPatch";
33492
+ var DIFF_PATCH_VERSION = 1;
33493
+ var DIFF_PATCH_FORMAT = "git_patch";
33494
+ function neutralDiffPatchCapability() {
33495
+ return { version: DIFF_PATCH_VERSION, format: DIFF_PATCH_FORMAT };
33496
+ }
33497
+ function clientRequestsNeutralDiffPatch(capabilities) {
33498
+ const declared = capabilities?._meta?.[NEUTRAL_DIFF_PATCH_META_KEY];
33499
+ if (declared === null || typeof declared !== "object" || Array.isArray(declared)) return false;
33500
+ const version2 = declared["version"];
33501
+ return typeof version2 === "number" && Number.isInteger(version2) && version2 >= 1;
33502
+ }
33491
33503
  var BINARY_PROBE_LENGTH = 8e3;
33492
33504
  var NO_NEWLINE_MARKER = "\";
33493
33505
  var HUNK_HEADER = /^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/;
@@ -33707,29 +33719,31 @@ var FileChangeReporter = class {
33707
33719
  }
33708
33720
  };
33709
33721
  function createPatchContent(change, diffPatch) {
33710
- const supportsDiffPatch = diffPatch === "air";
33722
+ const wrapper = diffPatch === "air" || diffPatch === "neutral" ? diffPatch : null;
33711
33723
  try {
33712
33724
  if (diffPatch === "acpV2") return createAcpV2Content(change);
33713
33725
  switch (change.kind.type) {
33714
33726
  case "add":
33715
- return createWholeFileContent(change, "add", supportsDiffPatch);
33727
+ return createWholeFileContent(change, "add", wrapper);
33716
33728
  case "delete":
33717
- return createWholeFileContent(change, "delete", supportsDiffPatch);
33729
+ return createWholeFileContent(change, "delete", wrapper);
33718
33730
  case "update":
33719
- return createUpdateFileContent(change, change.kind.move_path, supportsDiffPatch);
33731
+ return createUpdateFileContent(change, change.kind.move_path, wrapper);
33720
33732
  }
33721
33733
  } catch (error62) {
33722
33734
  logger.log(`Error processing file update change: ${error62}`);
33723
33735
  return [];
33724
33736
  }
33725
33737
  }
33726
- function createWholeFileContent(change, kind, supportsDiffPatch) {
33738
+ function createWholeFileContent(change, kind, wrapper) {
33727
33739
  if (!fitsDiffLimit(change.diff)) {
33728
33740
  logger.log("Skipped the diff of a file that is too large", { path: change.path });
33729
33741
  return [];
33730
33742
  }
33731
- const patch = !supportsDiffPatch ? null : kind === "add" ? createAddedFileGitPatch(change.path, change.diff) : createDeletedFileGitPatch(change.path, change.diff);
33732
- if (patch !== null) return [createPatchOnlyContent(change.path, kind, patch)];
33743
+ if (wrapper !== null) {
33744
+ const patch = kind === "add" ? createAddedFileGitPatch(change.path, change.diff) : createDeletedFileGitPatch(change.path, change.diff);
33745
+ if (patch !== null) return [createPatchOnlyContent(change.path, kind, patch, wrapper)];
33746
+ }
33733
33747
  return [{
33734
33748
  type: "diff",
33735
33749
  oldText: kind === "add" ? null : change.diff,
@@ -33738,16 +33752,16 @@ function createWholeFileContent(change, kind, supportsDiffPatch) {
33738
33752
  _meta: { kind }
33739
33753
  }];
33740
33754
  }
33741
- function createUpdateFileContent(change, movePath, supportsDiffPatch) {
33755
+ function createUpdateFileContent(change, movePath, wrapper) {
33742
33756
  const unifiedDiff = recoverCorruptedDiff(change.diff);
33743
33757
  const targetPath = movePath ?? change.path;
33744
33758
  if (!fitsDiffLimit(unifiedDiff)) {
33745
33759
  logger.log("Skipped the diff of a file change that is too large", { path: targetPath });
33746
33760
  return [];
33747
33761
  }
33748
- const gitPatch = supportsDiffPatch ? createUpdateGitPatch(change.path, targetPath, unifiedDiff) : null;
33749
- if (gitPatch !== null) {
33750
- return [createPatchOnlyContent(targetPath, "update", gitPatch)];
33762
+ if (wrapper !== null) {
33763
+ const gitPatch = createUpdateGitPatch(change.path, targetPath, unifiedDiff);
33764
+ if (gitPatch !== null) return [createPatchOnlyContent(targetPath, "update", gitPatch, wrapper)];
33751
33765
  }
33752
33766
  if (movePath !== null && unifiedDiff.trim().length === 0) {
33753
33767
  return [{ type: "diff", oldText: "", newText: "", path: targetPath, _meta: { kind: "update" } }];
@@ -33829,17 +33843,14 @@ function parseSinglePatch(diff) {
33829
33843
  return null;
33830
33844
  }
33831
33845
  }
33832
- function createPatchOnlyContent(path16, kind, patch) {
33846
+ function createPatchOnlyContent(path16, kind, patch, wrapper) {
33847
+ const diffPatch = { version: DIFF_PATCH_VERSION, format: DIFF_PATCH_FORMAT, text: patch };
33833
33848
  return {
33834
33849
  type: "diff",
33835
33850
  oldText: null,
33836
33851
  newText: "",
33837
33852
  path: path16,
33838
- _meta: withAirMeta({ kind }, AIR_DIFF_PATCH_KEY, {
33839
- version: 1,
33840
- format: "git_patch",
33841
- text: patch
33842
- })
33853
+ _meta: wrapper === "air" ? withAirMeta({ kind }, AIR_DIFF_PATCH_KEY, diffPatch) : { kind, [NEUTRAL_DIFF_PATCH_META_KEY]: diffPatch }
33843
33854
  };
33844
33855
  }
33845
33856
  function recoverCorruptedDiff(diff) {
@@ -34746,7 +34757,8 @@ var ClientCapabilities = class _ClientCapabilities {
34746
34757
  planContentDelta: clientSupportsAirCapability(capabilities, AIR_PLAN_CONTENT_DELTA_KEY),
34747
34758
  diffPatch
34748
34759
  },
34749
- diffPatchFormat: diffPatch ? "air" : "none",
34760
+ // A client that declares both forms gets only the client-neutral one.
34761
+ diffPatchFormat: clientRequestsNeutralDiffPatch(capabilities) ? "neutral" : diffPatch ? "air" : "none",
34750
34762
  permissionPromptFields: false
34751
34763
  });
34752
34764
  }
@@ -40611,7 +40623,7 @@ var package_default = {
40611
40623
  publishConfig: {
40612
40624
  access: "public"
40613
40625
  },
40614
- version: "2.5.0-alas.3",
40626
+ version: "2.5.0-alas.4",
40615
40627
  description: "",
40616
40628
  main: "dist/index.js",
40617
40629
  bin: {
@@ -40689,7 +40701,7 @@ var package_default = {
40689
40701
  alasDownstream: {
40690
40702
  upstreamVersion: "2.5.0",
40691
40703
  upstreamCommit: "34e08970aa324a2be985f5080674d5aa91d7666f",
40692
- sourceCommit: "de8d4c961871fc0584ca1bd89f31a8de95066c65"
40704
+ sourceCommit: "8af13bd4134b9a24acfd06b85418642f3c2742b6"
40693
40705
  }
40694
40706
  };
40695
40707
 
@@ -52553,6 +52565,11 @@ var CodexAcpServer = class {
52553
52565
  ...this.neutralForkPointSupported ? {
52554
52566
  [NEUTRAL_FORK_POINT_META_KEY]: neutralForkPointCapability()
52555
52567
  } : {},
52568
+ // The client-neutral diff patch, see `docs/air-extensions.md`. ACP v2 has its own diff patch,
52569
+ // so `ClientCapabilities.fromV2` never selects it.
52570
+ ...protocolVersion === 1 && this.capabilities.diffPatchFormat === "neutral" ? {
52571
+ [NEUTRAL_DIFF_PATCH_META_KEY]: neutralDiffPatchCapability()
52572
+ } : {},
52556
52573
  // The session index for a client that opted in without AIR, see `docs/air-extensions.md`.
52557
52574
  ...neutralSessionIndex ? {
52558
52575
  [NEUTRAL_SESSION_INDEX_META_KEY]: neutralSessionIndex
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "2.5.0-alas.3",
6
+ "version": "2.5.0-alas.4",
7
7
  "description": "",
8
8
  "main": "dist/index.js",
9
9
  "bin": {
@@ -81,6 +81,6 @@
81
81
  "alasDownstream": {
82
82
  "upstreamVersion": "2.5.0",
83
83
  "upstreamCommit": "34e08970aa324a2be985f5080674d5aa91d7666f",
84
- "sourceCommit": "de8d4c961871fc0584ca1bd89f31a8de95066c65"
84
+ "sourceCommit": "8af13bd4134b9a24acfd06b85418642f3c2742b6"
85
85
  }
86
86
  }