opencode-acp 1.0.0 → 1.0.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.
- package/README.md +4 -2
- package/dist/index.js +65 -26
- package/dist/index.js.map +1 -1
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/prompts/store.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -285,17 +285,19 @@ ACP is a drop-in replacement for DCP. To migrate:
|
|
|
285
285
|
|
|
286
286
|
**What's preserved:**
|
|
287
287
|
|
|
288
|
-
- Session state (compression blocks, message ID mappings) --
|
|
288
|
+
- Session state (compression blocks, message ID mappings) -- auto-migrated from `plugin/dcp/` to `~/.local/share/opencode/storage/plugin/acp/`
|
|
289
289
|
- Config file `~/.config/opencode/dcp.jsonc` -- ACP reads the same config
|
|
290
290
|
- Prompt overrides in `~/.config/opencode/dcp-prompts/`
|
|
291
291
|
|
|
292
292
|
**What changes:**
|
|
293
293
|
|
|
294
|
+
- Storage directory: `plugin/dcp/` to `plugin/acp/` (auto-migrated on first launch)
|
|
295
|
+
- Log directory: `logs/dcp/` to `logs/acp/`
|
|
294
296
|
- Slash command: `/dcp` to `/acp` (both work for backward compatibility)
|
|
295
297
|
- Notification headers: `DCP` to `ACP`
|
|
296
298
|
- Context usage label: `DCP threshold` to `ACP threshold`
|
|
297
299
|
|
|
298
|
-
|
|
300
|
+
Config file names (`dcp.jsonc`, `dcp-prompts/`) keep the `dcp` naming for backward compatibility.
|
|
299
301
|
|
|
300
302
|
---
|
|
301
303
|
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// lib/config.ts
|
|
2
|
-
import { readFileSync, writeFileSync, existsSync, mkdirSync, statSync } from "fs";
|
|
2
|
+
import { readFileSync, writeFileSync, existsSync, mkdirSync, statSync, copyFileSync } from "fs";
|
|
3
3
|
import { join, dirname } from "path";
|
|
4
4
|
import { homedir } from "os";
|
|
5
5
|
|
|
@@ -1420,8 +1420,10 @@ var defaultConfig = {
|
|
|
1420
1420
|
}
|
|
1421
1421
|
};
|
|
1422
1422
|
var GLOBAL_CONFIG_DIR = process.env.XDG_CONFIG_HOME ? join(process.env.XDG_CONFIG_HOME, "opencode") : join(homedir(), ".config", "opencode");
|
|
1423
|
-
var GLOBAL_CONFIG_PATH_JSONC = join(GLOBAL_CONFIG_DIR, "
|
|
1424
|
-
var GLOBAL_CONFIG_PATH_JSON = join(GLOBAL_CONFIG_DIR, "
|
|
1423
|
+
var GLOBAL_CONFIG_PATH_JSONC = join(GLOBAL_CONFIG_DIR, "acp.jsonc");
|
|
1424
|
+
var GLOBAL_CONFIG_PATH_JSON = join(GLOBAL_CONFIG_DIR, "acp.json");
|
|
1425
|
+
var LEGACY_GLOBAL_CONFIG_PATH_JSONC = join(GLOBAL_CONFIG_DIR, "dcp.jsonc");
|
|
1426
|
+
var LEGACY_GLOBAL_CONFIG_PATH_JSON = join(GLOBAL_CONFIG_DIR, "dcp.json");
|
|
1425
1427
|
function findOpencodeDir(startDir) {
|
|
1426
1428
|
let current = startDir;
|
|
1427
1429
|
while (current !== "/") {
|
|
@@ -1438,21 +1440,25 @@ function findOpencodeDir(startDir) {
|
|
|
1438
1440
|
return null;
|
|
1439
1441
|
}
|
|
1440
1442
|
function getConfigPaths(ctx) {
|
|
1441
|
-
const global = existsSync(GLOBAL_CONFIG_PATH_JSONC) ? GLOBAL_CONFIG_PATH_JSONC : existsSync(GLOBAL_CONFIG_PATH_JSON) ? GLOBAL_CONFIG_PATH_JSON : null;
|
|
1443
|
+
const global = existsSync(GLOBAL_CONFIG_PATH_JSONC) ? GLOBAL_CONFIG_PATH_JSONC : existsSync(GLOBAL_CONFIG_PATH_JSON) ? GLOBAL_CONFIG_PATH_JSON : existsSync(LEGACY_GLOBAL_CONFIG_PATH_JSONC) ? LEGACY_GLOBAL_CONFIG_PATH_JSONC : existsSync(LEGACY_GLOBAL_CONFIG_PATH_JSON) ? LEGACY_GLOBAL_CONFIG_PATH_JSON : null;
|
|
1442
1444
|
let configDir = null;
|
|
1443
1445
|
const opencodeConfigDir = process.env.OPENCODE_CONFIG_DIR;
|
|
1444
1446
|
if (opencodeConfigDir) {
|
|
1445
|
-
const configJsonc = join(opencodeConfigDir, "
|
|
1446
|
-
const configJson = join(opencodeConfigDir, "
|
|
1447
|
-
|
|
1447
|
+
const configJsonc = join(opencodeConfigDir, "acp.jsonc");
|
|
1448
|
+
const configJson = join(opencodeConfigDir, "acp.json");
|
|
1449
|
+
const legacyJsonc = join(opencodeConfigDir, "dcp.jsonc");
|
|
1450
|
+
const legacyJson = join(opencodeConfigDir, "dcp.json");
|
|
1451
|
+
configDir = existsSync(configJsonc) ? configJsonc : existsSync(configJson) ? configJson : existsSync(legacyJsonc) ? legacyJsonc : existsSync(legacyJson) ? legacyJson : null;
|
|
1448
1452
|
}
|
|
1449
1453
|
let project = null;
|
|
1450
1454
|
if (ctx?.directory) {
|
|
1451
1455
|
const opencodeDir = findOpencodeDir(ctx.directory);
|
|
1452
1456
|
if (opencodeDir) {
|
|
1453
|
-
const projectJsonc = join(opencodeDir, "
|
|
1454
|
-
const projectJson = join(opencodeDir, "
|
|
1455
|
-
|
|
1457
|
+
const projectJsonc = join(opencodeDir, "acp.jsonc");
|
|
1458
|
+
const projectJson = join(opencodeDir, "acp.json");
|
|
1459
|
+
const legacyJsonc = join(opencodeDir, "dcp.jsonc");
|
|
1460
|
+
const legacyJson = join(opencodeDir, "dcp.json");
|
|
1461
|
+
project = existsSync(projectJsonc) ? projectJsonc : existsSync(projectJson) ? projectJson : existsSync(legacyJsonc) ? legacyJsonc : existsSync(legacyJson) ? legacyJson : null;
|
|
1456
1462
|
}
|
|
1457
1463
|
}
|
|
1458
1464
|
return { global, configDir, project };
|
|
@@ -1461,11 +1467,21 @@ function createDefaultConfig() {
|
|
|
1461
1467
|
if (!existsSync(GLOBAL_CONFIG_DIR)) {
|
|
1462
1468
|
mkdirSync(GLOBAL_CONFIG_DIR, { recursive: true });
|
|
1463
1469
|
}
|
|
1464
|
-
|
|
1470
|
+
if (!existsSync(GLOBAL_CONFIG_PATH_JSONC)) {
|
|
1471
|
+
if (existsSync(LEGACY_GLOBAL_CONFIG_PATH_JSONC)) {
|
|
1472
|
+
copyFileSync(LEGACY_GLOBAL_CONFIG_PATH_JSONC, GLOBAL_CONFIG_PATH_JSONC);
|
|
1473
|
+
console.log("[ACP] Migrated config from dcp.jsonc to acp.jsonc");
|
|
1474
|
+
} else if (existsSync(LEGACY_GLOBAL_CONFIG_PATH_JSON)) {
|
|
1475
|
+
copyFileSync(LEGACY_GLOBAL_CONFIG_PATH_JSON, GLOBAL_CONFIG_PATH_JSONC);
|
|
1476
|
+
console.log("[ACP] Migrated config from dcp.json to acp.jsonc");
|
|
1477
|
+
} else {
|
|
1478
|
+
const configContent = `{
|
|
1465
1479
|
"$schema": "https://raw.githubusercontent.com/Opencode-DCP/opencode-dynamic-context-pruning/master/dcp.schema.json"
|
|
1466
1480
|
}
|
|
1467
1481
|
`;
|
|
1468
|
-
|
|
1482
|
+
writeFileSync(GLOBAL_CONFIG_PATH_JSONC, configContent, "utf-8");
|
|
1483
|
+
}
|
|
1484
|
+
}
|
|
1469
1485
|
}
|
|
1470
1486
|
function loadConfigFile(configPath) {
|
|
1471
1487
|
let fileContent = "";
|
|
@@ -1627,7 +1643,21 @@ function scheduleParseWarning(ctx, title, message) {
|
|
|
1627
1643
|
function getConfig(ctx) {
|
|
1628
1644
|
let config = deepCloneConfig(defaultConfig);
|
|
1629
1645
|
const configPaths = getConfigPaths(ctx);
|
|
1630
|
-
if (!
|
|
1646
|
+
if (!existsSync(GLOBAL_CONFIG_PATH_JSONC) && !existsSync(GLOBAL_CONFIG_PATH_JSON)) {
|
|
1647
|
+
if (existsSync(GLOBAL_CONFIG_DIR) || existsSync(LEGACY_GLOBAL_CONFIG_PATH_JSONC) || existsSync(LEGACY_GLOBAL_CONFIG_PATH_JSON)) {
|
|
1648
|
+
if (!existsSync(GLOBAL_CONFIG_DIR)) {
|
|
1649
|
+
mkdirSync(GLOBAL_CONFIG_DIR, { recursive: true });
|
|
1650
|
+
}
|
|
1651
|
+
if (existsSync(LEGACY_GLOBAL_CONFIG_PATH_JSONC)) {
|
|
1652
|
+
copyFileSync(LEGACY_GLOBAL_CONFIG_PATH_JSONC, GLOBAL_CONFIG_PATH_JSONC);
|
|
1653
|
+
console.log("[ACP] Migrated config from dcp.jsonc to acp.jsonc");
|
|
1654
|
+
} else if (existsSync(LEGACY_GLOBAL_CONFIG_PATH_JSON)) {
|
|
1655
|
+
copyFileSync(LEGACY_GLOBAL_CONFIG_PATH_JSON, GLOBAL_CONFIG_PATH_JSONC);
|
|
1656
|
+
console.log("[ACP] Migrated config from dcp.json to acp.jsonc");
|
|
1657
|
+
}
|
|
1658
|
+
}
|
|
1659
|
+
}
|
|
1660
|
+
if (!configPaths.global && !existsSync(GLOBAL_CONFIG_PATH_JSONC)) {
|
|
1631
1661
|
createDefaultConfig();
|
|
1632
1662
|
}
|
|
1633
1663
|
const layers = [
|
|
@@ -2910,19 +2940,19 @@ var STORAGE_DIR = join2(
|
|
|
2910
2940
|
"plugin",
|
|
2911
2941
|
"acp"
|
|
2912
2942
|
);
|
|
2913
|
-
function migrateFromLegacyIfNeeded() {
|
|
2943
|
+
function migrateFromLegacyIfNeeded(logger) {
|
|
2914
2944
|
if (existsSyncSync(STORAGE_DIR)) return;
|
|
2915
2945
|
if (!existsSyncSync(LEGACY_STORAGE_DIR)) return;
|
|
2916
2946
|
try {
|
|
2917
2947
|
cpSync(LEGACY_STORAGE_DIR, STORAGE_DIR, { recursive: true });
|
|
2918
|
-
|
|
2948
|
+
logger.info(`[ACP] Migrated storage from ${LEGACY_STORAGE_DIR} \u2192 ${STORAGE_DIR}`);
|
|
2919
2949
|
} catch (e) {
|
|
2920
|
-
|
|
2950
|
+
logger.warn(`[ACP] Storage migration failed: ${e.message}`);
|
|
2921
2951
|
}
|
|
2922
2952
|
}
|
|
2923
|
-
async function ensureStorageDir() {
|
|
2953
|
+
async function ensureStorageDir(logger) {
|
|
2924
2954
|
if (!existsSync2(STORAGE_DIR)) {
|
|
2925
|
-
migrateFromLegacyIfNeeded();
|
|
2955
|
+
migrateFromLegacyIfNeeded(logger);
|
|
2926
2956
|
await fs.mkdir(STORAGE_DIR, { recursive: true });
|
|
2927
2957
|
}
|
|
2928
2958
|
}
|
|
@@ -2930,7 +2960,7 @@ function getSessionFilePath(sessionId) {
|
|
|
2930
2960
|
return join2(STORAGE_DIR, `${sessionId}.json`);
|
|
2931
2961
|
}
|
|
2932
2962
|
async function writePersistedSessionState(sessionId, state, logger) {
|
|
2933
|
-
await ensureStorageDir();
|
|
2963
|
+
await ensureStorageDir(logger);
|
|
2934
2964
|
const filePath = getSessionFilePath(sessionId);
|
|
2935
2965
|
const content = JSON.stringify(state, null, 2);
|
|
2936
2966
|
await fs.writeFile(filePath, content, "utf-8");
|
|
@@ -4888,7 +4918,7 @@ var Logger = class {
|
|
|
4888
4918
|
};
|
|
4889
4919
|
|
|
4890
4920
|
// lib/prompts/store.ts
|
|
4891
|
-
import { existsSync as existsSync4, mkdirSync as mkdirSync2, readFileSync as readFileSync2, writeFileSync as writeFileSync2, statSync as statSync2 } from "fs";
|
|
4921
|
+
import { existsSync as existsSync4, mkdirSync as mkdirSync2, readFileSync as readFileSync2, writeFileSync as writeFileSync2, statSync as statSync2, cpSync as cpSync2 } from "fs";
|
|
4892
4922
|
import { join as join4, dirname as dirname2 } from "path";
|
|
4893
4923
|
import { homedir as homedir4 } from "os";
|
|
4894
4924
|
|
|
@@ -5228,12 +5258,21 @@ function findOpencodeDir2(startDir) {
|
|
|
5228
5258
|
}
|
|
5229
5259
|
function resolvePromptPaths(workingDirectory) {
|
|
5230
5260
|
const configHome = process.env.XDG_CONFIG_HOME || join4(homedir4(), ".config");
|
|
5231
|
-
const globalRoot = join4(configHome, "opencode", "
|
|
5261
|
+
const globalRoot = join4(configHome, "opencode", "acp-prompts");
|
|
5262
|
+
const legacyGlobalRoot = join4(configHome, "opencode", "dcp-prompts");
|
|
5263
|
+
if (!existsSync4(globalRoot) && existsSync4(legacyGlobalRoot)) {
|
|
5264
|
+
try {
|
|
5265
|
+
cpSync2(legacyGlobalRoot, globalRoot, { recursive: true });
|
|
5266
|
+
console.log("[ACP] Migrated prompts from dcp-prompts to acp-prompts");
|
|
5267
|
+
} catch (e) {
|
|
5268
|
+
console.warn(`[ACP] Prompts migration failed: ${e.message}`);
|
|
5269
|
+
}
|
|
5270
|
+
}
|
|
5232
5271
|
const defaultsDir = join4(globalRoot, "defaults");
|
|
5233
5272
|
const globalOverridesDir = join4(globalRoot, "overrides");
|
|
5234
|
-
const configDirOverridesDir = process.env.OPENCODE_CONFIG_DIR ? join4(process.env.OPENCODE_CONFIG_DIR, "
|
|
5273
|
+
const configDirOverridesDir = process.env.OPENCODE_CONFIG_DIR ? join4(process.env.OPENCODE_CONFIG_DIR, "acp-prompts", "overrides") : null;
|
|
5235
5274
|
const opencodeDir = findOpencodeDir2(workingDirectory);
|
|
5236
|
-
const projectOverridesDir = opencodeDir ? join4(opencodeDir, "
|
|
5275
|
+
const projectOverridesDir = opencodeDir ? join4(opencodeDir, "acp-prompts", "overrides") : null;
|
|
5237
5276
|
return {
|
|
5238
5277
|
defaultsDir,
|
|
5239
5278
|
globalOverridesDir,
|
|
@@ -5319,9 +5358,9 @@ function buildDefaultsReadmeContent() {
|
|
|
5319
5358
|
);
|
|
5320
5359
|
lines.push("");
|
|
5321
5360
|
lines.push("Override precedence (highest first):");
|
|
5322
|
-
lines.push("1. `.opencode/
|
|
5323
|
-
lines.push("2. `$OPENCODE_CONFIG_DIR/
|
|
5324
|
-
lines.push("3. `~/.config/opencode/
|
|
5361
|
+
lines.push("1. `.opencode/acp-prompts/overrides/` (project)");
|
|
5362
|
+
lines.push("2. `$OPENCODE_CONFIG_DIR/acp-prompts/overrides/` (config dir)");
|
|
5363
|
+
lines.push("3. `~/.config/opencode/acp-prompts/overrides/` (global)");
|
|
5325
5364
|
lines.push("");
|
|
5326
5365
|
lines.push("## Prompt Files");
|
|
5327
5366
|
lines.push("");
|