@agentclientprotocol/codex-acp 1.11.1-preview.4 → 1.11.1-preview.5
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 +122 -69
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -22772,6 +22772,111 @@ function reversePatch(structuredPatch) {
|
|
|
22772
22772
|
return reversed;
|
|
22773
22773
|
}
|
|
22774
22774
|
|
|
22775
|
+
// src/DiffStats.ts
|
|
22776
|
+
var DiffStatsCalculator = class {
|
|
22777
|
+
addedFile(text) {
|
|
22778
|
+
return { version: 1, added: this.lineCount(text), removed: 0 };
|
|
22779
|
+
}
|
|
22780
|
+
deletedFile(text) {
|
|
22781
|
+
return { version: 1, added: 0, removed: this.lineCount(text) };
|
|
22782
|
+
}
|
|
22783
|
+
update(patch) {
|
|
22784
|
+
if (patch.isBinary || patch.hunks.length === 0) return null;
|
|
22785
|
+
let added = 0;
|
|
22786
|
+
let removed = 0;
|
|
22787
|
+
let previousOldEnd = 1;
|
|
22788
|
+
let previousNewEnd = 1;
|
|
22789
|
+
for (const hunk of patch.hunks) {
|
|
22790
|
+
const { oldStart, oldLines, newStart, newLines } = hunk;
|
|
22791
|
+
if (![oldStart, oldLines, newStart, newLines].every(Number.isSafeInteger) || oldStart < previousOldEnd || newStart < previousNewEnd || oldLines < 0 || newLines < 0 || newStart - oldStart !== added - removed) return null;
|
|
22792
|
+
let oldConsumed = 0;
|
|
22793
|
+
let newConsumed = 0;
|
|
22794
|
+
let previousWasContent = false;
|
|
22795
|
+
for (const line of hunk.lines) {
|
|
22796
|
+
switch (line[0]) {
|
|
22797
|
+
case "+":
|
|
22798
|
+
added++;
|
|
22799
|
+
newConsumed++;
|
|
22800
|
+
previousWasContent = true;
|
|
22801
|
+
break;
|
|
22802
|
+
case "-":
|
|
22803
|
+
removed++;
|
|
22804
|
+
oldConsumed++;
|
|
22805
|
+
previousWasContent = true;
|
|
22806
|
+
break;
|
|
22807
|
+
case " ":
|
|
22808
|
+
case void 0:
|
|
22809
|
+
oldConsumed++;
|
|
22810
|
+
newConsumed++;
|
|
22811
|
+
previousWasContent = true;
|
|
22812
|
+
break;
|
|
22813
|
+
case "\\":
|
|
22814
|
+
if (!previousWasContent || line.replace(/\r$/, "") !== "\") return null;
|
|
22815
|
+
previousWasContent = false;
|
|
22816
|
+
break;
|
|
22817
|
+
default:
|
|
22818
|
+
return null;
|
|
22819
|
+
}
|
|
22820
|
+
}
|
|
22821
|
+
if (oldConsumed !== oldLines || newConsumed !== newLines) return null;
|
|
22822
|
+
previousOldEnd = oldStart + oldLines;
|
|
22823
|
+
previousNewEnd = newStart + newLines;
|
|
22824
|
+
}
|
|
22825
|
+
return { version: 1, added, removed };
|
|
22826
|
+
}
|
|
22827
|
+
lineCount(text) {
|
|
22828
|
+
let count = 0;
|
|
22829
|
+
for (let offset = text.indexOf("\n"); offset >= 0; offset = text.indexOf("\n", offset + 1)) count++;
|
|
22830
|
+
for (let offset = text.indexOf("\r"); offset >= 0; offset = text.indexOf("\r", offset + 1)) {
|
|
22831
|
+
if (text[offset + 1] !== "\n") count++;
|
|
22832
|
+
}
|
|
22833
|
+
if (text.length > 0 && !text.endsWith("\n") && !text.endsWith("\r")) count++;
|
|
22834
|
+
return count;
|
|
22835
|
+
}
|
|
22836
|
+
};
|
|
22837
|
+
|
|
22838
|
+
// src/AirExtension.ts
|
|
22839
|
+
var JETBRAINS_META_KEY = "jetbrains";
|
|
22840
|
+
var AIR_META_KEY = "air";
|
|
22841
|
+
var AIR_EXTENSION_VERSION_KEY = "version";
|
|
22842
|
+
var AIR_EXTENSION_CAPABILITIES_KEY = "capabilities";
|
|
22843
|
+
var AIR_DIFF_STATS_KEY = "diffStats";
|
|
22844
|
+
var AIR_SESSION_FAILURE_KEY = "sessionFailure";
|
|
22845
|
+
var AIR_AGENT_FILE_CHANGE_REPORT_KEY = "agentFileChangeReport";
|
|
22846
|
+
var AIR_NATIVE_SUBAGENT_SESSIONS_KEY = "nativeSubagentSessions";
|
|
22847
|
+
var AIR_ASYNC_TASKS_KEY = "asyncTasks";
|
|
22848
|
+
var AIR_RECOMMENDED_CONFIG_VALUE_KEY = "recommendedValue";
|
|
22849
|
+
var AIR_ASYNC_TASKS_BACKGROUNDED_KEY = "backgrounded";
|
|
22850
|
+
var AIR_AGENT_FILE_CHANGE_REPORT_REQUEST_KEY = "agentFileChangeReportRequest";
|
|
22851
|
+
var AIR_EXTENSION_VERSION = 1;
|
|
22852
|
+
function withAirMeta(meta3, key, value) {
|
|
22853
|
+
const root = asRecord(meta3);
|
|
22854
|
+
const jetbrains = asRecord(root[JETBRAINS_META_KEY]);
|
|
22855
|
+
const air = asRecord(jetbrains[AIR_META_KEY]);
|
|
22856
|
+
return {
|
|
22857
|
+
...root,
|
|
22858
|
+
[JETBRAINS_META_KEY]: {
|
|
22859
|
+
...jetbrains,
|
|
22860
|
+
[AIR_META_KEY]: {
|
|
22861
|
+
...air,
|
|
22862
|
+
[AIR_EXTENSION_VERSION_KEY]: AIR_EXTENSION_VERSION,
|
|
22863
|
+
[key]: value
|
|
22864
|
+
}
|
|
22865
|
+
}
|
|
22866
|
+
};
|
|
22867
|
+
}
|
|
22868
|
+
function clientSupportsAirCapability(capabilities, capability) {
|
|
22869
|
+
const meta3 = asRecord(capabilities?._meta);
|
|
22870
|
+
const jetbrains = asRecord(meta3[JETBRAINS_META_KEY]);
|
|
22871
|
+
const air = asRecord(jetbrains[AIR_META_KEY]);
|
|
22872
|
+
const version2 = air[AIR_EXTENSION_VERSION_KEY];
|
|
22873
|
+
const supported = air[AIR_EXTENSION_CAPABILITIES_KEY];
|
|
22874
|
+
return typeof version2 === "number" && Number.isInteger(version2) && version2 >= AIR_EXTENSION_VERSION && Array.isArray(supported) && supported.includes(capability);
|
|
22875
|
+
}
|
|
22876
|
+
function asRecord(value) {
|
|
22877
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
22878
|
+
}
|
|
22879
|
+
|
|
22775
22880
|
// src/CodexToolCallMapper.ts
|
|
22776
22881
|
import { readFile } from "node:fs/promises";
|
|
22777
22882
|
import path2 from "node:path";
|
|
@@ -22843,6 +22948,7 @@ function commandToolName(source) {
|
|
|
22843
22948
|
|
|
22844
22949
|
// src/CodexToolCallMapper.ts
|
|
22845
22950
|
var CONTEXT_COMPACTION_META = createContextCompactionMeta();
|
|
22951
|
+
var DIFF_STATS = new DiffStatsCalculator();
|
|
22846
22952
|
function toAcpStatus(status) {
|
|
22847
22953
|
switch (status) {
|
|
22848
22954
|
case "inProgress":
|
|
@@ -23507,53 +23613,43 @@ async function createAddFileContent(change) {
|
|
|
23507
23613
|
newText: change.diff,
|
|
23508
23614
|
// app-server always returns file content instead of diff
|
|
23509
23615
|
path: change.path,
|
|
23510
|
-
_meta: {
|
|
23511
|
-
kind: "add"
|
|
23512
|
-
}
|
|
23616
|
+
_meta: withAirMeta({ kind: "add" }, AIR_DIFF_STATS_KEY, DIFF_STATS.addedFile(change.diff))
|
|
23513
23617
|
};
|
|
23514
23618
|
}
|
|
23515
23619
|
async function createUpdateFileContent(change) {
|
|
23516
23620
|
if (change.kind.type !== "update") return null;
|
|
23517
23621
|
const unifiedDiff = recoverCorruptedDiff(change.diff);
|
|
23622
|
+
const patches = parsePatch(unifiedDiff);
|
|
23623
|
+
if (patches.length !== 1) return null;
|
|
23624
|
+
const patch = patches[0];
|
|
23518
23625
|
const movePath = change.kind.move_path;
|
|
23519
23626
|
const oldContent = await readFileContent(change.path);
|
|
23520
23627
|
if (oldContent !== null) {
|
|
23521
|
-
const patchedContent = applyPatch(oldContent,
|
|
23628
|
+
const patchedContent = applyPatch(oldContent, patch);
|
|
23522
23629
|
if (patchedContent === false) {
|
|
23523
|
-
const
|
|
23524
|
-
if (
|
|
23525
|
-
|
|
23526
|
-
if (revertedContent2 !== false) {
|
|
23527
|
-
return createUpdateDiffContent(change.path, revertedContent2, oldContent);
|
|
23528
|
-
}
|
|
23630
|
+
const revertedContent2 = applyPatch(oldContent, reversePatch(patch));
|
|
23631
|
+
if (revertedContent2 !== false) {
|
|
23632
|
+
return createUpdateDiffContent(change.path, revertedContent2, oldContent, patch);
|
|
23529
23633
|
}
|
|
23530
23634
|
return null;
|
|
23531
23635
|
}
|
|
23532
|
-
return createUpdateDiffContent(movePath ?? change.path, oldContent, patchedContent);
|
|
23636
|
+
return createUpdateDiffContent(movePath ?? change.path, oldContent, patchedContent, patch);
|
|
23533
23637
|
}
|
|
23534
23638
|
if (!movePath) return null;
|
|
23535
23639
|
const newContent = await readFileContent(movePath);
|
|
23536
23640
|
if (newContent === null) return null;
|
|
23537
|
-
const
|
|
23538
|
-
if (!revertedPatch) return null;
|
|
23539
|
-
const revertedContent = applyPatch(newContent, revertedPatch);
|
|
23641
|
+
const revertedContent = applyPatch(newContent, reversePatch(patch));
|
|
23540
23642
|
if (revertedContent === false) return null;
|
|
23541
|
-
return createUpdateDiffContent(movePath, revertedContent, newContent);
|
|
23542
|
-
}
|
|
23543
|
-
function revertPatch(unifiedDiff) {
|
|
23544
|
-
const [patch] = parsePatch(unifiedDiff);
|
|
23545
|
-
if (!patch) return null;
|
|
23546
|
-
return reversePatch(patch);
|
|
23643
|
+
return createUpdateDiffContent(movePath, revertedContent, newContent, patch);
|
|
23547
23644
|
}
|
|
23548
|
-
function createUpdateDiffContent(path9, oldText, newText) {
|
|
23645
|
+
function createUpdateDiffContent(path9, oldText, newText, patch) {
|
|
23646
|
+
const stats = DIFF_STATS.update(patch);
|
|
23549
23647
|
return {
|
|
23550
23648
|
type: "diff",
|
|
23551
23649
|
oldText,
|
|
23552
23650
|
newText,
|
|
23553
23651
|
path: path9,
|
|
23554
|
-
_meta: {
|
|
23555
|
-
kind: "update"
|
|
23556
|
-
}
|
|
23652
|
+
_meta: stats ? withAirMeta({ kind: "update" }, AIR_DIFF_STATS_KEY, stats) : { kind: "update" }
|
|
23557
23653
|
};
|
|
23558
23654
|
}
|
|
23559
23655
|
async function createDeleteFileContent(change) {
|
|
@@ -23563,9 +23659,7 @@ async function createDeleteFileContent(change) {
|
|
|
23563
23659
|
// app-server always returns file content instead of diff
|
|
23564
23660
|
newText: "",
|
|
23565
23661
|
path: change.path,
|
|
23566
|
-
_meta: {
|
|
23567
|
-
kind: "delete"
|
|
23568
|
-
}
|
|
23662
|
+
_meta: withAirMeta({ kind: "delete" }, AIR_DIFF_STATS_KEY, DIFF_STATS.deletedFile(change.diff))
|
|
23569
23663
|
};
|
|
23570
23664
|
}
|
|
23571
23665
|
async function readFileContent(filePath) {
|
|
@@ -23677,47 +23771,6 @@ function sameThreadGoalSnapshot(left, right) {
|
|
|
23677
23771
|
// src/CodexEventHandler.ts
|
|
23678
23772
|
import { randomUUID } from "node:crypto";
|
|
23679
23773
|
|
|
23680
|
-
// src/AirExtension.ts
|
|
23681
|
-
var JETBRAINS_META_KEY = "jetbrains";
|
|
23682
|
-
var AIR_META_KEY = "air";
|
|
23683
|
-
var AIR_EXTENSION_VERSION_KEY = "version";
|
|
23684
|
-
var AIR_EXTENSION_CAPABILITIES_KEY = "capabilities";
|
|
23685
|
-
var AIR_SESSION_FAILURE_KEY = "sessionFailure";
|
|
23686
|
-
var AIR_AGENT_FILE_CHANGE_REPORT_KEY = "agentFileChangeReport";
|
|
23687
|
-
var AIR_NATIVE_SUBAGENT_SESSIONS_KEY = "nativeSubagentSessions";
|
|
23688
|
-
var AIR_ASYNC_TASKS_KEY = "asyncTasks";
|
|
23689
|
-
var AIR_RECOMMENDED_CONFIG_VALUE_KEY = "recommendedValue";
|
|
23690
|
-
var AIR_ASYNC_TASKS_BACKGROUNDED_KEY = "backgrounded";
|
|
23691
|
-
var AIR_AGENT_FILE_CHANGE_REPORT_REQUEST_KEY = "agentFileChangeReportRequest";
|
|
23692
|
-
var AIR_EXTENSION_VERSION = 1;
|
|
23693
|
-
function withAirMeta(meta3, key, value) {
|
|
23694
|
-
const root = asRecord(meta3);
|
|
23695
|
-
const jetbrains = asRecord(root[JETBRAINS_META_KEY]);
|
|
23696
|
-
const air = asRecord(jetbrains[AIR_META_KEY]);
|
|
23697
|
-
return {
|
|
23698
|
-
...root,
|
|
23699
|
-
[JETBRAINS_META_KEY]: {
|
|
23700
|
-
...jetbrains,
|
|
23701
|
-
[AIR_META_KEY]: {
|
|
23702
|
-
...air,
|
|
23703
|
-
[AIR_EXTENSION_VERSION_KEY]: AIR_EXTENSION_VERSION,
|
|
23704
|
-
[key]: value
|
|
23705
|
-
}
|
|
23706
|
-
}
|
|
23707
|
-
};
|
|
23708
|
-
}
|
|
23709
|
-
function clientSupportsAirCapability(capabilities, capability) {
|
|
23710
|
-
const meta3 = asRecord(capabilities?._meta);
|
|
23711
|
-
const jetbrains = asRecord(meta3[JETBRAINS_META_KEY]);
|
|
23712
|
-
const air = asRecord(jetbrains[AIR_META_KEY]);
|
|
23713
|
-
const version2 = air[AIR_EXTENSION_VERSION_KEY];
|
|
23714
|
-
const supported = air[AIR_EXTENSION_CAPABILITIES_KEY];
|
|
23715
|
-
return typeof version2 === "number" && Number.isInteger(version2) && version2 >= AIR_EXTENSION_VERSION && Array.isArray(supported) && supported.includes(capability);
|
|
23716
|
-
}
|
|
23717
|
-
function asRecord(value) {
|
|
23718
|
-
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
23719
|
-
}
|
|
23720
|
-
|
|
23721
23774
|
// src/subagents/CodexAgentPath.ts
|
|
23722
23775
|
function normalizeAgentPath(path9) {
|
|
23723
23776
|
const normalized = path9.trim().replace(/\/+$/, "");
|
|
@@ -27431,7 +27484,7 @@ var package_default = {
|
|
|
27431
27484
|
publishConfig: {
|
|
27432
27485
|
access: "public"
|
|
27433
27486
|
},
|
|
27434
|
-
version: "1.11.1-preview.
|
|
27487
|
+
version: "1.11.1-preview.5",
|
|
27435
27488
|
description: "",
|
|
27436
27489
|
main: "dist/index.js",
|
|
27437
27490
|
bin: {
|