opencode-acp 1.15.0-pr.380.114 → 1.15.0-pr.381.115
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 +15 -0
- package/README.zh-CN.md +14 -0
- package/dist/index.js +60 -102
- package/dist/index.js.map +1 -1
- package/dist/lib/config-validation.d.ts.map +1 -1
- package/dist/lib/config.d.ts +0 -7
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/state/persistence.d.ts +3 -14
- package/dist/lib/state/persistence.d.ts.map +1 -1
- package/dist/lib/state/state.d.ts +2 -3
- package/dist/lib/state/state.d.ts.map +1 -1
- package/dist/lib/state/types.d.ts +0 -6
- package/dist/lib/state/types.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -425,6 +425,21 @@ Each level overrides the previous, so project settings take priority over global
|
|
|
425
425
|
},
|
|
426
426
|
},
|
|
427
427
|
},
|
|
428
|
+
// Message filters — strip/deduplicate third-party plugin injections
|
|
429
|
+
// (e.g. oh-my-opencode system reminders) from visible context before
|
|
430
|
+
// ACP processes them. Filtered content is never counted toward context
|
|
431
|
+
// usage. Five built-in OMO filters are on by default (v1.14.8+);
|
|
432
|
+
// per-filter reference and examples: CONFIGURATION.md → messageFilters
|
|
433
|
+
"messageFilters": {
|
|
434
|
+
"enabled": true,
|
|
435
|
+
"filters": {
|
|
436
|
+
"omo-system-reminder": { "enabled": true },
|
|
437
|
+
"omo-context": { "enabled": true },
|
|
438
|
+
"omo-task-directive": { "enabled": true },
|
|
439
|
+
"omo-todo-continuation": { "enabled": true },
|
|
440
|
+
"omo-mode-injection": { "enabled": true },
|
|
441
|
+
},
|
|
442
|
+
},
|
|
428
443
|
}
|
|
429
444
|
```
|
|
430
445
|
|
package/README.zh-CN.md
CHANGED
|
@@ -376,6 +376,20 @@ ACP 使用自己的配置文件,按以下顺序搜索:
|
|
|
376
376
|
},
|
|
377
377
|
},
|
|
378
378
|
},
|
|
379
|
+
// 消息过滤器——在 ACP 处理之前,从可见上下文中剥离/去重第三方插件注入
|
|
380
|
+
// (例如 oh-my-opencode 的 system reminder)。被过滤的内容不计入上下文使用量。
|
|
381
|
+
// 5 个内置 OMO 过滤器默认开启(v1.14.8+);
|
|
382
|
+
// 按过滤器的参考与示例见 CONFIGURATION.zh-CN.md → messageFilters
|
|
383
|
+
"messageFilters": {
|
|
384
|
+
"enabled": true,
|
|
385
|
+
"filters": {
|
|
386
|
+
"omo-system-reminder": { "enabled": true },
|
|
387
|
+
"omo-context": { "enabled": true },
|
|
388
|
+
"omo-task-directive": { "enabled": true },
|
|
389
|
+
"omo-todo-continuation": { "enabled": true },
|
|
390
|
+
"omo-mode-injection": { "enabled": true },
|
|
391
|
+
},
|
|
392
|
+
},
|
|
379
393
|
}
|
|
380
394
|
```
|
|
381
395
|
|
package/dist/index.js
CHANGED
|
@@ -869,7 +869,6 @@ var VALID_CONFIG_KEYS = /* @__PURE__ */ new Set([
|
|
|
869
869
|
"autoUpdate",
|
|
870
870
|
"debug",
|
|
871
871
|
"logLevel",
|
|
872
|
-
"storagePath",
|
|
873
872
|
"showUpdateToasts",
|
|
874
873
|
"allowSubAgents",
|
|
875
874
|
"pruneNotification",
|
|
@@ -960,9 +959,6 @@ function validateConfigTypes(config) {
|
|
|
960
959
|
if (config.debug !== void 0 && typeof config.debug !== "boolean") {
|
|
961
960
|
errors.push({ key: "debug", expected: "boolean", actual: typeof config.debug });
|
|
962
961
|
}
|
|
963
|
-
if (config.storagePath !== void 0 && typeof config.storagePath !== "string") {
|
|
964
|
-
errors.push({ key: "storagePath", expected: "string", actual: typeof config.storagePath });
|
|
965
|
-
}
|
|
966
962
|
if (config.allowSubAgents !== void 0 && typeof config.allowSubAgents !== "boolean") {
|
|
967
963
|
errors.push({ key: "allowSubAgents", expected: "boolean", actual: typeof config.allowSubAgents });
|
|
968
964
|
}
|
|
@@ -1999,7 +1995,6 @@ function mergeLayer(config, data) {
|
|
|
1999
1995
|
autoUpdate: data.autoUpdate ?? config.autoUpdate,
|
|
2000
1996
|
debug: data.debug ?? config.debug,
|
|
2001
1997
|
logLevel: data.logLevel ?? config.logLevel,
|
|
2002
|
-
storagePath: data.storagePath ?? config.storagePath,
|
|
2003
1998
|
allowSubAgents: data.allowSubAgents ?? data.experimental?.allowSubAgents ?? config.allowSubAgents,
|
|
2004
1999
|
pruneNotification: data.pruneNotification ?? config.pruneNotification,
|
|
2005
2000
|
pruneNotificationType: data.pruneNotificationType ?? config.pruneNotificationType,
|
|
@@ -2354,7 +2349,7 @@ Each entry needs a topic \u2014 either its own or the top-level fallback.`;
|
|
|
2354
2349
|
import * as fs from "fs/promises";
|
|
2355
2350
|
import { existsSync as existsSync2 } from "fs";
|
|
2356
2351
|
import { homedir as homedir2 } from "os";
|
|
2357
|
-
import {
|
|
2352
|
+
import { join as join2 } from "path";
|
|
2358
2353
|
|
|
2359
2354
|
// lib/state/utils.ts
|
|
2360
2355
|
var isMessageCompacted = (state, msg) => {
|
|
@@ -2637,7 +2632,7 @@ function resetOnCompaction(state) {
|
|
|
2637
2632
|
}
|
|
2638
2633
|
|
|
2639
2634
|
// lib/state/persistence.ts
|
|
2640
|
-
function
|
|
2635
|
+
function getStorageDir() {
|
|
2641
2636
|
return join2(
|
|
2642
2637
|
process.env.XDG_DATA_HOME || join2(homedir2(), ".local", "share"),
|
|
2643
2638
|
"opencode",
|
|
@@ -2646,33 +2641,14 @@ function getDefaultStorageDir() {
|
|
|
2646
2641
|
"acp"
|
|
2647
2642
|
);
|
|
2648
2643
|
}
|
|
2649
|
-
function
|
|
2650
|
-
|
|
2651
|
-
if (!trimmed) {
|
|
2652
|
-
return getDefaultStorageDir();
|
|
2653
|
-
}
|
|
2654
|
-
if (trimmed === "~") {
|
|
2655
|
-
return homedir2();
|
|
2656
|
-
}
|
|
2657
|
-
if (trimmed.startsWith("~/")) {
|
|
2658
|
-
return join2(homedir2(), trimmed.slice(2));
|
|
2659
|
-
}
|
|
2660
|
-
if (isAbsolute(trimmed)) {
|
|
2661
|
-
return trimmed;
|
|
2662
|
-
}
|
|
2663
|
-
return join2(projectDir, trimmed);
|
|
2664
|
-
}
|
|
2665
|
-
function getStorageDir(override) {
|
|
2666
|
-
return override || getDefaultStorageDir();
|
|
2644
|
+
function getSessionFilePath(sessionId) {
|
|
2645
|
+
return join2(getStorageDir(), `${sessionId}.json`);
|
|
2667
2646
|
}
|
|
2668
|
-
function
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
const dir = getStorageDir(storageDir);
|
|
2674
|
-
if (!existsSync2(dir)) {
|
|
2675
|
-
await fs.mkdir(dir, { recursive: true });
|
|
2647
|
+
async function writePersistedSessionState(sessionId, state, logger) {
|
|
2648
|
+
const filePath = getSessionFilePath(sessionId);
|
|
2649
|
+
const storageDir = getStorageDir();
|
|
2650
|
+
if (!existsSync2(storageDir)) {
|
|
2651
|
+
await fs.mkdir(storageDir, { recursive: true });
|
|
2676
2652
|
}
|
|
2677
2653
|
const content = JSON.stringify(state, null, 2);
|
|
2678
2654
|
await fs.writeFile(filePath, content, "utf-8");
|
|
@@ -2714,11 +2690,11 @@ async function saveSessionState(sessionState, logger, sessionName) {
|
|
|
2714
2690
|
modelProviderID: sessionState.modelProviderID,
|
|
2715
2691
|
modelID: sessionState.modelID
|
|
2716
2692
|
};
|
|
2717
|
-
await writePersistedSessionState(sessionState.sessionId, state, logger
|
|
2693
|
+
await writePersistedSessionState(sessionState.sessionId, state, logger);
|
|
2718
2694
|
}
|
|
2719
|
-
async function loadSessionState(sessionId, logger
|
|
2695
|
+
async function loadSessionState(sessionId, logger) {
|
|
2720
2696
|
try {
|
|
2721
|
-
const filePath = getSessionFilePath(sessionId
|
|
2697
|
+
const filePath = getSessionFilePath(sessionId);
|
|
2722
2698
|
if (!existsSync2(filePath)) {
|
|
2723
2699
|
return null;
|
|
2724
2700
|
}
|
|
@@ -2794,11 +2770,6 @@ async function loadSessionState(sessionId, logger, storageDir) {
|
|
|
2794
2770
|
}
|
|
2795
2771
|
}
|
|
2796
2772
|
|
|
2797
|
-
// lib/state/state.ts
|
|
2798
|
-
import { existsSync as existsSync3 } from "fs";
|
|
2799
|
-
import { join as join3 } from "path";
|
|
2800
|
-
import { cwd } from "process";
|
|
2801
|
-
|
|
2802
2773
|
// lib/message-ids.ts
|
|
2803
2774
|
var MESSAGE_REF_REGEX = /^m(\d{4,5})$/;
|
|
2804
2775
|
var BLOCK_REF_REGEX = /^b([1-9]\d*)$/;
|
|
@@ -4475,12 +4446,10 @@ async function updatePerTurnState(state, logger, messages) {
|
|
|
4475
4446
|
}
|
|
4476
4447
|
var REGISTRY_SOFT_CAP = 32;
|
|
4477
4448
|
var SessionStateRegistry = class {
|
|
4478
|
-
constructor(logger
|
|
4449
|
+
constructor(logger) {
|
|
4479
4450
|
this.logger = logger;
|
|
4480
|
-
this.projectDir = projectDir;
|
|
4481
4451
|
}
|
|
4482
4452
|
logger;
|
|
4483
|
-
projectDir;
|
|
4484
4453
|
states = /* @__PURE__ */ new Map();
|
|
4485
4454
|
compressionTiming = {
|
|
4486
4455
|
startsByCallId: /* @__PURE__ */ new Map(),
|
|
@@ -4533,8 +4502,7 @@ var SessionStateRegistry = class {
|
|
|
4533
4502
|
sessionId,
|
|
4534
4503
|
this.logger,
|
|
4535
4504
|
messages,
|
|
4536
|
-
config
|
|
4537
|
-
this.projectDir
|
|
4505
|
+
config
|
|
4538
4506
|
);
|
|
4539
4507
|
} catch (err) {
|
|
4540
4508
|
this.logger.error("Failed to initialize session state", {
|
|
@@ -4598,7 +4566,6 @@ function createSessionState() {
|
|
|
4598
4566
|
modelProviderID: void 0,
|
|
4599
4567
|
modelID: void 0,
|
|
4600
4568
|
systemPromptTokens: void 0,
|
|
4601
|
-
storageDir: void 0,
|
|
4602
4569
|
qualityGateRetryPending: false
|
|
4603
4570
|
};
|
|
4604
4571
|
}
|
|
@@ -4640,30 +4607,21 @@ function resetSessionState(state) {
|
|
|
4640
4607
|
state.modelProviderID = void 0;
|
|
4641
4608
|
state.modelID = void 0;
|
|
4642
4609
|
state.systemPromptTokens = void 0;
|
|
4643
|
-
state.storageDir = void 0;
|
|
4644
4610
|
state.qualityGateRetryPending = false;
|
|
4645
4611
|
}
|
|
4646
|
-
async function ensureSessionInitialized(client, state, sessionId, logger, messages, config
|
|
4612
|
+
async function ensureSessionInitialized(client, state, sessionId, logger, messages, config) {
|
|
4647
4613
|
if (state.sessionId === sessionId) {
|
|
4648
4614
|
return;
|
|
4649
4615
|
}
|
|
4650
4616
|
resetSessionState(state);
|
|
4651
4617
|
state.sessionId = sessionId;
|
|
4652
|
-
state.storageDir = config?.storagePath ? resolveStorageDir(config.storagePath, projectDir ?? cwd()) : void 0;
|
|
4653
4618
|
const isSubAgent = await isSubAgentSession(client, sessionId);
|
|
4654
4619
|
state.isSubAgent = isSubAgent;
|
|
4655
4620
|
state.lastCompaction = findLastCompactionTimestamp(messages);
|
|
4656
4621
|
state.currentTurn = countTurns(state, messages);
|
|
4657
4622
|
state.nudges.turnNudgeAnchors = collectTurnNudgeAnchors(messages);
|
|
4658
|
-
const persisted = await loadSessionState(sessionId, logger
|
|
4623
|
+
const persisted = await loadSessionState(sessionId, logger);
|
|
4659
4624
|
if (persisted === null) {
|
|
4660
|
-
const defaultPath = join3(getDefaultStorageDir(), `${sessionId}.json`);
|
|
4661
|
-
if (state.storageDir && existsSync3(defaultPath)) {
|
|
4662
|
-
logger.warn(
|
|
4663
|
-
"storagePath is set but no valid state was found there; a state file exists at the default location \u2014 move it manually to keep history",
|
|
4664
|
-
{ sessionId, storageDir: state.storageDir, defaultPath }
|
|
4665
|
-
);
|
|
4666
|
-
}
|
|
4667
4625
|
if (config) {
|
|
4668
4626
|
const rebuilt = rebuildCompressionState(state, messages, config, logger);
|
|
4669
4627
|
if (rebuilt > 0) {
|
|
@@ -9527,10 +9485,10 @@ function hideFailedCompressCalls(messages) {
|
|
|
9527
9485
|
|
|
9528
9486
|
// lib/logger.ts
|
|
9529
9487
|
import { writeFile as writeFile2, mkdir as mkdir2 } from "fs/promises";
|
|
9530
|
-
import { join as
|
|
9531
|
-
import { existsSync as
|
|
9488
|
+
import { join as join3 } from "path";
|
|
9489
|
+
import { existsSync as existsSync3 } from "fs";
|
|
9532
9490
|
import { homedir as homedir3 } from "os";
|
|
9533
|
-
var LOG_VERSION = true ? "1.15.0-pr.
|
|
9491
|
+
var LOG_VERSION = true ? "1.15.0-pr.381.115" : "dev";
|
|
9534
9492
|
var LEVEL_RANK = {
|
|
9535
9493
|
debug: 10,
|
|
9536
9494
|
info: 20,
|
|
@@ -9550,8 +9508,8 @@ var Logger = class {
|
|
|
9550
9508
|
constructor(enabled, level) {
|
|
9551
9509
|
const resolved = level !== void 0 && LEVEL_RANK[level] !== void 0 ? level : void 0;
|
|
9552
9510
|
this.level = resolved ?? (enabled ? "debug" : "warn");
|
|
9553
|
-
const configHome = process.env.XDG_CONFIG_HOME ||
|
|
9554
|
-
this.logDir =
|
|
9511
|
+
const configHome = process.env.XDG_CONFIG_HOME || join3(homedir3(), ".config");
|
|
9512
|
+
this.logDir = join3(configHome, "opencode", "logs", "acp");
|
|
9555
9513
|
}
|
|
9556
9514
|
/** Back-compat view of the old flag: true only at full debug verbosity. */
|
|
9557
9515
|
get enabled() {
|
|
@@ -9561,7 +9519,7 @@ var Logger = class {
|
|
|
9561
9519
|
return LEVEL_RANK[level] >= LEVEL_RANK[this.level];
|
|
9562
9520
|
}
|
|
9563
9521
|
async ensureLogDir() {
|
|
9564
|
-
if (!
|
|
9522
|
+
if (!existsSync3(this.logDir)) {
|
|
9565
9523
|
await mkdir2(this.logDir, { recursive: true });
|
|
9566
9524
|
}
|
|
9567
9525
|
}
|
|
@@ -9613,11 +9571,11 @@ var Logger = class {
|
|
|
9613
9571
|
const dataStr = this.formatData(data);
|
|
9614
9572
|
const logLine = `${timestamp} ${level.padEnd(5)} ${component}: ${message}${dataStr ? " | " + dataStr : ""} | v=${LOG_VERSION}
|
|
9615
9573
|
`;
|
|
9616
|
-
const dailyLogDir =
|
|
9617
|
-
if (!
|
|
9574
|
+
const dailyLogDir = join3(this.logDir, "daily");
|
|
9575
|
+
if (!existsSync3(dailyLogDir)) {
|
|
9618
9576
|
await mkdir2(dailyLogDir, { recursive: true });
|
|
9619
9577
|
}
|
|
9620
|
-
const logFile =
|
|
9578
|
+
const logFile = join3(dailyLogDir, `${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}.log`);
|
|
9621
9579
|
await writeFile2(logFile, logLine, { flag: "a" });
|
|
9622
9580
|
} catch (error) {
|
|
9623
9581
|
}
|
|
@@ -9728,18 +9686,18 @@ var Logger = class {
|
|
|
9728
9686
|
async saveContext(sessionId, messages) {
|
|
9729
9687
|
if (this.level !== "debug") return;
|
|
9730
9688
|
try {
|
|
9731
|
-
const contextDir =
|
|
9732
|
-
if (!
|
|
9689
|
+
const contextDir = join3(this.logDir, "context", sessionId);
|
|
9690
|
+
if (!existsSync3(contextDir)) {
|
|
9733
9691
|
await mkdir2(contextDir, { recursive: true });
|
|
9734
9692
|
}
|
|
9735
9693
|
const minimized = this.minimizeForDebug(messages).filter(
|
|
9736
9694
|
(msg) => msg.parts && msg.parts.length > 0
|
|
9737
9695
|
);
|
|
9738
9696
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
9739
|
-
const contextFile =
|
|
9697
|
+
const contextFile = join3(contextDir, `${timestamp}.json`);
|
|
9740
9698
|
await writeFile2(contextFile, JSON.stringify(minimized, null, 2));
|
|
9741
|
-
const versionFile =
|
|
9742
|
-
if (!
|
|
9699
|
+
const versionFile = join3(contextDir, "_version");
|
|
9700
|
+
if (!existsSync3(versionFile)) {
|
|
9743
9701
|
await writeFile2(versionFile, LOG_VERSION);
|
|
9744
9702
|
}
|
|
9745
9703
|
} catch (error) {
|
|
@@ -9748,8 +9706,8 @@ var Logger = class {
|
|
|
9748
9706
|
};
|
|
9749
9707
|
|
|
9750
9708
|
// lib/prompts/store.ts
|
|
9751
|
-
import { existsSync as
|
|
9752
|
-
import { join as
|
|
9709
|
+
import { existsSync as existsSync4, mkdirSync as mkdirSync2, readFileSync as readFileSync2, writeFileSync as writeFileSync2, statSync as statSync2 } from "fs";
|
|
9710
|
+
import { join as join4, dirname as dirname2 } from "path";
|
|
9753
9711
|
import { homedir as homedir4 } from "os";
|
|
9754
9712
|
|
|
9755
9713
|
// lib/prompts/system.ts
|
|
@@ -10079,8 +10037,8 @@ function createBundledRuntimePrompts() {
|
|
|
10079
10037
|
function findOpencodeDir2(startDir) {
|
|
10080
10038
|
let current = startDir;
|
|
10081
10039
|
while (current !== "/") {
|
|
10082
|
-
const candidate =
|
|
10083
|
-
if (
|
|
10040
|
+
const candidate = join4(current, ".opencode");
|
|
10041
|
+
if (existsSync4(candidate)) {
|
|
10084
10042
|
try {
|
|
10085
10043
|
if (statSync2(candidate).isDirectory()) {
|
|
10086
10044
|
return candidate;
|
|
@@ -10097,13 +10055,13 @@ function findOpencodeDir2(startDir) {
|
|
|
10097
10055
|
return null;
|
|
10098
10056
|
}
|
|
10099
10057
|
function resolvePromptPaths(workingDirectory) {
|
|
10100
|
-
const configHome = process.env.XDG_CONFIG_HOME ||
|
|
10101
|
-
const globalRoot =
|
|
10102
|
-
const defaultsDir =
|
|
10103
|
-
const globalOverridesDir =
|
|
10104
|
-
const configDirOverridesDir = process.env.OPENCODE_CONFIG_DIR ?
|
|
10058
|
+
const configHome = process.env.XDG_CONFIG_HOME || join4(homedir4(), ".config");
|
|
10059
|
+
const globalRoot = join4(configHome, "opencode", "acp-prompts");
|
|
10060
|
+
const defaultsDir = join4(globalRoot, "defaults");
|
|
10061
|
+
const globalOverridesDir = join4(globalRoot, "overrides");
|
|
10062
|
+
const configDirOverridesDir = process.env.OPENCODE_CONFIG_DIR ? join4(process.env.OPENCODE_CONFIG_DIR, "acp-prompts", "overrides") : null;
|
|
10105
10063
|
const opencodeDir = findOpencodeDir2(workingDirectory);
|
|
10106
|
-
const projectOverridesDir = opencodeDir ?
|
|
10064
|
+
const projectOverridesDir = opencodeDir ? join4(opencodeDir, "acp-prompts", "overrides") : null;
|
|
10107
10065
|
return {
|
|
10108
10066
|
defaultsDir,
|
|
10109
10067
|
globalOverridesDir,
|
|
@@ -10203,7 +10161,7 @@ function buildDefaultsReadmeContent() {
|
|
|
10203
10161
|
`;
|
|
10204
10162
|
}
|
|
10205
10163
|
function readFileIfExists(filePath) {
|
|
10206
|
-
if (!
|
|
10164
|
+
if (!existsSync4(filePath)) {
|
|
10207
10165
|
return null;
|
|
10208
10166
|
}
|
|
10209
10167
|
try {
|
|
@@ -10274,16 +10232,16 @@ var PromptStore = class {
|
|
|
10274
10232
|
const candidates = [];
|
|
10275
10233
|
if (this.paths.projectOverridesDir) {
|
|
10276
10234
|
candidates.push({
|
|
10277
|
-
path:
|
|
10235
|
+
path: join4(this.paths.projectOverridesDir, fileName)
|
|
10278
10236
|
});
|
|
10279
10237
|
}
|
|
10280
10238
|
if (this.paths.configDirOverridesDir) {
|
|
10281
10239
|
candidates.push({
|
|
10282
|
-
path:
|
|
10240
|
+
path: join4(this.paths.configDirOverridesDir, fileName)
|
|
10283
10241
|
});
|
|
10284
10242
|
}
|
|
10285
10243
|
candidates.push({
|
|
10286
|
-
path:
|
|
10244
|
+
path: join4(this.paths.globalOverridesDir, fileName)
|
|
10287
10245
|
});
|
|
10288
10246
|
return candidates;
|
|
10289
10247
|
}
|
|
@@ -10306,7 +10264,7 @@ var PromptStore = class {
|
|
|
10306
10264
|
const managedContent = buildDefaultPromptFileContent(
|
|
10307
10265
|
bundledEditable || BUNDLED_EDITABLE_PROMPTS[definition.runtimeField]
|
|
10308
10266
|
);
|
|
10309
|
-
const filePath =
|
|
10267
|
+
const filePath = join4(this.paths.defaultsDir, definition.fileName);
|
|
10310
10268
|
try {
|
|
10311
10269
|
const existing = readFileIfExists(filePath);
|
|
10312
10270
|
if (existing === managedContent) {
|
|
@@ -10320,7 +10278,7 @@ var PromptStore = class {
|
|
|
10320
10278
|
});
|
|
10321
10279
|
}
|
|
10322
10280
|
}
|
|
10323
|
-
const readmePath =
|
|
10281
|
+
const readmePath = join4(this.paths.defaultsDir, DEFAULTS_README_FILE);
|
|
10324
10282
|
const readmeContent = buildDefaultsReadmeContent();
|
|
10325
10283
|
try {
|
|
10326
10284
|
const existing = readFileIfExists(readmePath);
|
|
@@ -10617,8 +10575,8 @@ ${report}`;
|
|
|
10617
10575
|
|
|
10618
10576
|
// lib/commands/export.ts
|
|
10619
10577
|
import * as fs2 from "fs/promises";
|
|
10620
|
-
import { existsSync as
|
|
10621
|
-
import { dirname as dirname3, isAbsolute
|
|
10578
|
+
import { existsSync as existsSync5 } from "fs";
|
|
10579
|
+
import { dirname as dirname3, isAbsolute, join as join5, resolve } from "path";
|
|
10622
10580
|
var ALL_TIERS = [1, 2, 3];
|
|
10623
10581
|
var TIER_NAMES = {
|
|
10624
10582
|
1: "Tier 1 \u2014 Capture",
|
|
@@ -10729,9 +10687,9 @@ function parseTiers(raw) {
|
|
|
10729
10687
|
}
|
|
10730
10688
|
return result;
|
|
10731
10689
|
}
|
|
10732
|
-
function resolveDefaultOutputPath(sessionId,
|
|
10690
|
+
function resolveDefaultOutputPath(sessionId, cwd) {
|
|
10733
10691
|
const short = (sessionId || "session").slice(0, 8);
|
|
10734
|
-
return
|
|
10692
|
+
return join5(cwd, ".opencode", `acp-export-${short}.md`);
|
|
10735
10693
|
}
|
|
10736
10694
|
function formatTokens2(n) {
|
|
10737
10695
|
if (!Number.isFinite(n) || n <= 0) return "0";
|
|
@@ -10858,15 +10816,15 @@ async function handleExportCommand(ctx, args) {
|
|
|
10858
10816
|
await sendExportNotice(client, sessionId, ctx, markdown);
|
|
10859
10817
|
return;
|
|
10860
10818
|
}
|
|
10861
|
-
const
|
|
10862
|
-
const targetPath = options.outputPath !== "" ?
|
|
10819
|
+
const cwd = ctx.workingDirectory || process.cwd();
|
|
10820
|
+
const targetPath = options.outputPath !== "" ? isAbsolute(options.outputPath) ? options.outputPath : resolve(cwd, options.outputPath) : resolveDefaultOutputPath(sessionId, cwd);
|
|
10863
10821
|
try {
|
|
10864
10822
|
const dir = dirname3(targetPath);
|
|
10865
|
-
if (!
|
|
10823
|
+
if (!existsSync5(dir)) {
|
|
10866
10824
|
await fs2.mkdir(dir, { recursive: true });
|
|
10867
10825
|
}
|
|
10868
10826
|
const flag = options.append ? "a" : "w";
|
|
10869
|
-
if (options.append &&
|
|
10827
|
+
if (options.append && existsSync5(targetPath)) {
|
|
10870
10828
|
await fs2.appendFile(targetPath, `
|
|
10871
10829
|
|
|
10872
10830
|
---
|
|
@@ -11809,7 +11767,7 @@ function findBiliProxyProviders(provider) {
|
|
|
11809
11767
|
|
|
11810
11768
|
// lib/update.ts
|
|
11811
11769
|
import { readFile as readFile2, rm } from "fs/promises";
|
|
11812
|
-
import { basename, dirname as dirname4, join as
|
|
11770
|
+
import { basename, dirname as dirname4, join as join6 } from "path";
|
|
11813
11771
|
import { fileURLToPath } from "url";
|
|
11814
11772
|
var PACKAGE_NAME = "opencode-acp";
|
|
11815
11773
|
function startAutoUpdate(ctx, enabled, logger) {
|
|
@@ -11856,7 +11814,7 @@ async function checkAutoUpdate(signal, logger) {
|
|
|
11856
11814
|
logger?.info("Auto-update skipped: package dir not found");
|
|
11857
11815
|
return { updated: false };
|
|
11858
11816
|
}
|
|
11859
|
-
const pkg = await readPackageJson(
|
|
11817
|
+
const pkg = await readPackageJson(join6(packageDir, "package.json"));
|
|
11860
11818
|
if (!pkg?.name || !pkg.version) {
|
|
11861
11819
|
logger?.info("Auto-update skipped: package.json unreadable", { packageDir });
|
|
11862
11820
|
return { updated: false };
|
|
@@ -11897,7 +11855,7 @@ async function checkAutoUpdate(signal, logger) {
|
|
|
11897
11855
|
async function findPackageDir(name) {
|
|
11898
11856
|
let dir = dirname4(fileURLToPath(import.meta.url));
|
|
11899
11857
|
for (; ; ) {
|
|
11900
|
-
const pkg = await readPackageJson(
|
|
11858
|
+
const pkg = await readPackageJson(join6(dir, "package.json"));
|
|
11901
11859
|
if (pkg?.name === name) return dir;
|
|
11902
11860
|
const parent = dirname4(dir);
|
|
11903
11861
|
if (parent === dir) return void 0;
|
|
@@ -11909,7 +11867,7 @@ async function updateTarget(packageDir, name) {
|
|
|
11909
11867
|
const nodeModulesDir = basename(packageParent).startsWith("@") ? dirname4(packageParent) : packageParent;
|
|
11910
11868
|
if (basename(nodeModulesDir) !== "node_modules") return void 0;
|
|
11911
11869
|
const wrapperDir = dirname4(nodeModulesDir);
|
|
11912
|
-
const wrapperPkg = await readPackageJson(
|
|
11870
|
+
const wrapperPkg = await readPackageJson(join6(wrapperDir, "package.json"));
|
|
11913
11871
|
const spec = wrapperSpec(wrapperDir, name) ?? wrapperPkg?.dependencies?.[name];
|
|
11914
11872
|
if (!spec || !isAutoUpdatableSpec(spec)) return void 0;
|
|
11915
11873
|
return { removeDir: wrapperDir, spec };
|
|
@@ -12021,14 +11979,14 @@ var server = (async (ctx) => {
|
|
|
12021
11979
|
}
|
|
12022
11980
|
const logger = new Logger(config.debug, config.debug ? "debug" : config.logLevel);
|
|
12023
11981
|
logger.info("ACP plugin initialized", {
|
|
12024
|
-
version: true ? "1.15.0-pr.
|
|
11982
|
+
version: true ? "1.15.0-pr.381.115" : "dev",
|
|
12025
11983
|
workspace: ctx.directory,
|
|
12026
11984
|
logLevel: logger.level,
|
|
12027
11985
|
debug: config.debug,
|
|
12028
11986
|
autoUpdate: config.autoUpdate,
|
|
12029
11987
|
secureMode: isSecureMode()
|
|
12030
11988
|
});
|
|
12031
|
-
const registry4 = new SessionStateRegistry(logger
|
|
11989
|
+
const registry4 = new SessionStateRegistry(logger);
|
|
12032
11990
|
const prompts = new PromptStore(logger, ctx.directory, config.experimental.customPrompts);
|
|
12033
11991
|
const hostPermissions = {
|
|
12034
11992
|
global: void 0,
|