@tarquinen/opencode-dcp 3.1.11 → 3.1.13
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 +14 -9
- package/dist/index.js +106 -49
- package/dist/index.js.map +1 -1
- package/dist/lib/commands/context.d.ts +15 -0
- package/dist/lib/commands/context.d.ts.map +1 -1
- package/dist/lib/commands/help.d.ts +1 -0
- package/dist/lib/commands/help.d.ts.map +1 -1
- package/dist/lib/commands/manual.d.ts +1 -1
- package/dist/lib/commands/manual.d.ts.map +1 -1
- package/dist/lib/commands/stats.d.ts +10 -0
- package/dist/lib/commands/stats.d.ts.map +1 -1
- package/dist/lib/compress/pipeline.d.ts.map +1 -1
- package/dist/lib/hooks.d.ts +0 -2
- package/dist/lib/hooks.d.ts.map +1 -1
- package/dist/lib/messages/index.d.ts +0 -1
- package/dist/lib/messages/index.d.ts.map +1 -1
- package/dist/lib/messages/inject/utils.d.ts +0 -7
- package/dist/lib/messages/inject/utils.d.ts.map +1 -1
- package/dist/lib/state/persistence.d.ts +3 -0
- package/dist/lib/state/persistence.d.ts.map +1 -1
- package/dist/lib/state/state.d.ts +1 -0
- package/dist/lib/state/state.d.ts.map +1 -1
- package/dist/lib/tui/commands.d.ts +3 -0
- package/dist/lib/tui/commands.d.ts.map +1 -0
- package/dist/lib/tui/data.d.ts +14 -0
- package/dist/lib/tui/data.d.ts.map +1 -0
- package/dist/lib/tui/dialogs.d.ts +30 -0
- package/dist/lib/tui/dialogs.d.ts.map +1 -0
- package/dist/lib/tui/format.d.ts +4 -0
- package/dist/lib/tui/format.d.ts.map +1 -0
- package/dist/lib/tui/modals.d.ts +10 -0
- package/dist/lib/tui/modals.d.ts.map +1 -0
- package/dist/lib/tui/types.d.ts +15 -0
- package/dist/lib/tui/types.d.ts.map +1 -0
- package/dist/lib/tui/ui.d.ts +48 -0
- package/dist/lib/tui/ui.d.ts.map +1 -0
- package/dist/tui.d.ts +7 -0
- package/dist/tui.d.ts.map +1 -0
- package/lib/auth.ts +37 -0
- package/lib/commands/compression-targets.ts +137 -0
- package/lib/commands/context.ts +305 -0
- package/lib/commands/decompress.ts +275 -0
- package/lib/commands/help.ts +76 -0
- package/lib/commands/index.ts +11 -0
- package/lib/commands/manual.ts +127 -0
- package/lib/commands/recompress.ts +224 -0
- package/lib/commands/stats.ts +159 -0
- package/lib/commands/sweep.ts +268 -0
- package/lib/compress/index.ts +3 -0
- package/lib/compress/message-utils.ts +250 -0
- package/lib/compress/message.ts +145 -0
- package/lib/compress/pipeline.ts +108 -0
- package/lib/compress/protected-content.ts +208 -0
- package/lib/compress/range-utils.ts +308 -0
- package/lib/compress/range.ts +192 -0
- package/lib/compress/search.ts +267 -0
- package/lib/compress/state.ts +268 -0
- package/lib/compress/timing.ts +77 -0
- package/lib/compress/types.ts +108 -0
- package/lib/compress-permission.ts +25 -0
- package/lib/config.ts +1007 -0
- package/lib/hooks.ts +375 -0
- package/lib/host-permissions.ts +101 -0
- package/lib/logger.ts +226 -0
- package/lib/message-ids.ts +172 -0
- package/lib/messages/index.ts +8 -0
- package/lib/messages/inject/inject.ts +215 -0
- package/lib/messages/inject/subagent-results.ts +82 -0
- package/lib/messages/inject/utils.ts +374 -0
- package/lib/messages/priority.ts +102 -0
- package/lib/messages/prune.ts +233 -0
- package/lib/messages/query.ts +72 -0
- package/lib/messages/reasoning-strip.ts +40 -0
- package/lib/messages/shape.ts +50 -0
- package/lib/messages/sync.ts +124 -0
- package/lib/messages/utils.ts +185 -0
- package/lib/prompts/compress-message.ts +43 -0
- package/lib/prompts/compress-range.ts +60 -0
- package/lib/prompts/context-limit-nudge.ts +18 -0
- package/lib/prompts/extensions/nudge.ts +43 -0
- package/lib/prompts/extensions/system.ts +32 -0
- package/lib/prompts/extensions/tool.ts +35 -0
- package/lib/prompts/index.ts +29 -0
- package/lib/prompts/iteration-nudge.ts +6 -0
- package/lib/prompts/store.ts +467 -0
- package/lib/prompts/system.ts +33 -0
- package/lib/prompts/turn-nudge.ts +10 -0
- package/lib/protected-patterns.ts +128 -0
- package/lib/state/index.ts +4 -0
- package/lib/state/persistence.ts +305 -0
- package/lib/state/state.ts +208 -0
- package/lib/state/tool-cache.ts +98 -0
- package/lib/state/types.ts +111 -0
- package/lib/state/utils.ts +345 -0
- package/lib/strategies/deduplication.ts +127 -0
- package/lib/strategies/index.ts +2 -0
- package/lib/strategies/purge-errors.ts +88 -0
- package/lib/subagents/subagent-results.ts +74 -0
- package/lib/token-utils.ts +164 -0
- package/lib/tui/commands.ts +31 -0
- package/lib/tui/data.ts +73 -0
- package/lib/tui/dialogs.tsx +235 -0
- package/lib/tui/format.ts +25 -0
- package/lib/tui/modals.tsx +92 -0
- package/lib/tui/types.ts +16 -0
- package/lib/tui/ui.tsx +219 -0
- package/lib/ui/notification.ts +347 -0
- package/lib/ui/utils.ts +304 -0
- package/lib/update.ts +185 -0
- package/package.json +17 -5
- package/tui.tsx +26 -0
package/README.md
CHANGED
|
@@ -17,6 +17,17 @@ opencode plugin @tarquinen/opencode-dcp@latest --global
|
|
|
17
17
|
|
|
18
18
|
This installs the package and adds it to your global OpenCode config.
|
|
19
19
|
|
|
20
|
+
## Project Status
|
|
21
|
+
|
|
22
|
+
Development on DCP has slowed because most new context-management work has moved to [Sleev](https://sleev.ai) and the `sleev` CLI. Sleev is a local proxy for Claude Code, Codex, and OpenCode that builds on DCP's core ideas with newer context-management features and will work with any harness/client.
|
|
23
|
+
|
|
24
|
+
DCP remains available for OpenCode plugin users, but new features are landing in Sleev first. If you are starting fresh, we recommend trying Sleev:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npm i -g sleev
|
|
28
|
+
sleev
|
|
29
|
+
```
|
|
30
|
+
|
|
20
31
|
## How It Works
|
|
21
32
|
|
|
22
33
|
DCP reduces context size through a compress tool and automatic cleanup. Your session history is never modified — DCP replaces pruned content with placeholders before sending requests to your LLM.
|
|
@@ -176,16 +187,10 @@ Each level overrides the previous, so project settings take priority over global
|
|
|
176
187
|
|
|
177
188
|
### Commands
|
|
178
189
|
|
|
179
|
-
DCP provides a
|
|
190
|
+
DCP provides a TUI panel and one prompt-producing slash command:
|
|
180
191
|
|
|
181
|
-
- `/dcp` —
|
|
182
|
-
- `/dcp
|
|
183
|
-
- `/dcp stats` — Shows cumulative pruning statistics across all sessions.
|
|
184
|
-
- `/dcp sweep` — Prunes all tools since the last user message. Accepts an optional count: `/dcp sweep 10` prunes the last 10 tools. Respects `commands.protectedTools`.
|
|
185
|
-
- `/dcp manual [on|off]` — Toggle manual mode or set explicit state. When on, the AI will not autonomously use context management tools.
|
|
186
|
-
- `/dcp compress [focus]` — Trigger a single compress tool execution. Optional focus text directs what content to compress, following the active `compress.mode`.
|
|
187
|
-
- `/dcp decompress <n>` — Restore a specific active compression by ID (for example `/dcp decompress 2`). Running without an argument shows available compression IDs, token sizes, and topics.
|
|
188
|
-
- `/dcp recompress <n>` — Re-apply a user-decompressed compression by ID (for example `/dcp recompress 2`). Running without an argument shows recompressible IDs, token sizes, and topics.
|
|
192
|
+
- `/dcp` — Opens the DCP panel with context, stats, and manual-mode controls.
|
|
193
|
+
- `/dcp-compress [focus]` — Asks the model to run one compression pass. Optional focus text directs what content to compress, following the active `compress.mode`.
|
|
189
194
|
|
|
190
195
|
### Prompt Overrides
|
|
191
196
|
|
package/dist/index.js
CHANGED
|
@@ -2387,6 +2387,8 @@ var SoftIssue = class extends Error {
|
|
|
2387
2387
|
this.kind = kind;
|
|
2388
2388
|
this.messageId = messageId;
|
|
2389
2389
|
}
|
|
2390
|
+
kind;
|
|
2391
|
+
messageId;
|
|
2390
2392
|
};
|
|
2391
2393
|
function validateArgs(args) {
|
|
2392
2394
|
if (typeof args.topic !== "string" || args.topic.trim().length === 0) {
|
|
@@ -2851,6 +2853,7 @@ async function saveSessionState(sessionState, logger, sessionName) {
|
|
|
2851
2853
|
}
|
|
2852
2854
|
const state = {
|
|
2853
2855
|
sessionName,
|
|
2856
|
+
manualMode: !!sessionState.manualMode,
|
|
2854
2857
|
prune: {
|
|
2855
2858
|
tools: Object.fromEntries(sessionState.prune.tools),
|
|
2856
2859
|
messages: serializePruneMessagesState(sessionState.prune.messages)
|
|
@@ -2939,6 +2942,43 @@ async function loadSessionState(sessionId, logger) {
|
|
|
2939
2942
|
return null;
|
|
2940
2943
|
}
|
|
2941
2944
|
}
|
|
2945
|
+
function emptyPersistedState(manualMode) {
|
|
2946
|
+
return {
|
|
2947
|
+
manualMode,
|
|
2948
|
+
prune: {
|
|
2949
|
+
tools: {},
|
|
2950
|
+
messages: {
|
|
2951
|
+
byMessageId: {},
|
|
2952
|
+
blocksById: {},
|
|
2953
|
+
activeBlockIds: [],
|
|
2954
|
+
activeByAnchorMessageId: {},
|
|
2955
|
+
nextBlockId: 1,
|
|
2956
|
+
nextRunId: 1
|
|
2957
|
+
}
|
|
2958
|
+
},
|
|
2959
|
+
nudges: {
|
|
2960
|
+
contextLimitAnchors: [],
|
|
2961
|
+
turnNudgeAnchors: [],
|
|
2962
|
+
iterationNudgeAnchors: []
|
|
2963
|
+
},
|
|
2964
|
+
stats: {
|
|
2965
|
+
pruneTokenCounter: 0,
|
|
2966
|
+
totalPruneTokens: 0
|
|
2967
|
+
},
|
|
2968
|
+
lastUpdated: (/* @__PURE__ */ new Date()).toISOString()
|
|
2969
|
+
};
|
|
2970
|
+
}
|
|
2971
|
+
async function loadManualModeSetting(sessionId, logger) {
|
|
2972
|
+
const state = await loadSessionState(sessionId, logger);
|
|
2973
|
+
return typeof state?.manualMode === "boolean" ? state.manualMode : void 0;
|
|
2974
|
+
}
|
|
2975
|
+
async function saveManualModeSetting(sessionId, manualMode, logger) {
|
|
2976
|
+
const existing = await loadSessionState(sessionId, logger);
|
|
2977
|
+
const state = existing ?? emptyPersistedState(manualMode);
|
|
2978
|
+
state.manualMode = manualMode;
|
|
2979
|
+
state.lastUpdated = (/* @__PURE__ */ new Date()).toISOString();
|
|
2980
|
+
await writePersistedSessionState(sessionId, state, logger);
|
|
2981
|
+
}
|
|
2942
2982
|
async function loadAllSessionStats(logger) {
|
|
2943
2983
|
const result = {
|
|
2944
2984
|
totalTokens: 0,
|
|
@@ -3047,6 +3087,7 @@ var checkSession = async (client, state, logger, messages, manualModeDefault) =>
|
|
|
3047
3087
|
});
|
|
3048
3088
|
}
|
|
3049
3089
|
state.currentTurn = countTurns(state, messages);
|
|
3090
|
+
await refreshManualMode(state, lastSessionId, logger, manualModeDefault);
|
|
3050
3091
|
};
|
|
3051
3092
|
function createSessionState() {
|
|
3052
3093
|
return {
|
|
@@ -3134,6 +3175,9 @@ async function ensureSessionInitialized(client, state, sessionId, logger, messag
|
|
|
3134
3175
|
if (persisted === null) {
|
|
3135
3176
|
return;
|
|
3136
3177
|
}
|
|
3178
|
+
if (typeof persisted.manualMode === "boolean") {
|
|
3179
|
+
state.manualMode = persisted.manualMode ? "active" : false;
|
|
3180
|
+
}
|
|
3137
3181
|
state.prune.tools = loadPruneMap(persisted.prune.tools);
|
|
3138
3182
|
state.prune.messages = loadPruneMessagesState(persisted.prune.messages);
|
|
3139
3183
|
state.nudges.contextLimitAnchors = new Set(persisted.nudges.contextLimitAnchors || []);
|
|
@@ -3153,6 +3197,14 @@ async function ensureSessionInitialized(client, state, sessionId, logger, messag
|
|
|
3153
3197
|
await saveSessionState(state, logger);
|
|
3154
3198
|
}
|
|
3155
3199
|
}
|
|
3200
|
+
async function refreshManualMode(state, sessionId, logger, manualModeDefault) {
|
|
3201
|
+
if (state.manualMode === "compress-pending") {
|
|
3202
|
+
return;
|
|
3203
|
+
}
|
|
3204
|
+
const persisted = await loadManualModeSetting(sessionId, logger);
|
|
3205
|
+
const enabled = persisted ?? manualModeDefault;
|
|
3206
|
+
state.manualMode = enabled ? "active" : false;
|
|
3207
|
+
}
|
|
3156
3208
|
|
|
3157
3209
|
// lib/state/tool-cache.ts
|
|
3158
3210
|
var MAX_TOOL_CACHE_SIZE = 1e3;
|
|
@@ -3866,6 +3918,7 @@ async function sendIgnoredMessage(client, sessionID, text, params, logger) {
|
|
|
3866
3918
|
|
|
3867
3919
|
// lib/compress/pipeline.ts
|
|
3868
3920
|
async function prepareSession(ctx, toolCtx, title) {
|
|
3921
|
+
await refreshManualMode(ctx.state, toolCtx.sessionID, ctx.logger, ctx.config.manualMode.enabled);
|
|
3869
3922
|
if (ctx.state.manualMode && ctx.state.manualMode !== "compress-pending") {
|
|
3870
3923
|
throw new Error(
|
|
3871
3924
|
"Manual mode: compress blocked. Do not retry until `<compress triggered manually>` appears in user context."
|
|
@@ -5858,12 +5911,6 @@ function listPriorityRefsBeforeIndex(messages, priorities, anchorIndex, priority
|
|
|
5858
5911
|
|
|
5859
5912
|
// lib/messages/inject/utils.ts
|
|
5860
5913
|
var MESSAGE_MODE_NUDGE_PRIORITY = "high";
|
|
5861
|
-
function computeInputBudget(limit) {
|
|
5862
|
-
if (!limit.context) {
|
|
5863
|
-
return void 0;
|
|
5864
|
-
}
|
|
5865
|
-
return limit.input ?? Math.max(0, limit.context - (limit.output ?? 0));
|
|
5866
|
-
}
|
|
5867
5914
|
function getNudgeFrequency(config) {
|
|
5868
5915
|
return Math.max(1, Math.floor(config.compress.nudgeFrequency || 1));
|
|
5869
5916
|
}
|
|
@@ -6347,7 +6394,7 @@ function renderSystemPrompt(prompts, protectedToolsExtension, manual, subagent)
|
|
|
6347
6394
|
}
|
|
6348
6395
|
|
|
6349
6396
|
// lib/commands/context.ts
|
|
6350
|
-
function
|
|
6397
|
+
function analyzeContextTokens(state, messages) {
|
|
6351
6398
|
const breakdown = {
|
|
6352
6399
|
system: 0,
|
|
6353
6400
|
user: 0,
|
|
@@ -6526,7 +6573,7 @@ function formatContextMessage(breakdown) {
|
|
|
6526
6573
|
}
|
|
6527
6574
|
async function handleContextCommand(ctx) {
|
|
6528
6575
|
const { client, state, logger, sessionId, messages } = ctx;
|
|
6529
|
-
const breakdown =
|
|
6576
|
+
const breakdown = analyzeContextTokens(state, messages);
|
|
6530
6577
|
const message = formatContextMessage(breakdown);
|
|
6531
6578
|
const params = getCurrentParams(state, messages, logger);
|
|
6532
6579
|
await sendIgnoredMessage(client, sessionId, message, params, logger);
|
|
@@ -6830,23 +6877,20 @@ async function handleDecompressCommand(ctx) {
|
|
|
6830
6877
|
}
|
|
6831
6878
|
|
|
6832
6879
|
// lib/commands/help.ts
|
|
6833
|
-
var
|
|
6834
|
-
["
|
|
6835
|
-
["
|
|
6836
|
-
["
|
|
6837
|
-
["/dcp manual [on|off]", "Toggle manual mode or set explicit state"]
|
|
6880
|
+
var TUI_COMMANDS = [
|
|
6881
|
+
["DCP Context", "Show token usage breakdown for current session"],
|
|
6882
|
+
["DCP Stats", "Show DCP pruning statistics"],
|
|
6883
|
+
["DCP Help", "Show this help in a modal"]
|
|
6838
6884
|
];
|
|
6839
6885
|
var TOOL_COMMANDS = {
|
|
6840
|
-
compress: ["/dcp
|
|
6886
|
+
compress: ["/dcp-compress [focus]", "Trigger manual compress tool execution"],
|
|
6841
6887
|
decompress: ["/dcp decompress <n>", "Restore selected compression"],
|
|
6842
6888
|
recompress: ["/dcp recompress <n>", "Re-apply a user-decompressed compression"]
|
|
6843
6889
|
};
|
|
6844
6890
|
function getVisibleCommands(state, config) {
|
|
6845
|
-
const commands = [...
|
|
6891
|
+
const commands = [...TUI_COMMANDS];
|
|
6846
6892
|
if (compressPermission(state, config) !== "deny") {
|
|
6847
6893
|
commands.push(TOOL_COMMANDS.compress);
|
|
6848
|
-
commands.push(TOOL_COMMANDS.decompress);
|
|
6849
|
-
commands.push(TOOL_COMMANDS.recompress);
|
|
6850
6894
|
}
|
|
6851
6895
|
return commands;
|
|
6852
6896
|
}
|
|
@@ -6860,6 +6904,9 @@ function formatHelpMessage(state, config) {
|
|
|
6860
6904
|
lines.push("");
|
|
6861
6905
|
lines.push(` ${"Manual mode:".padEnd(colWidth)}${state.manualMode ? "ON" : "OFF"}`);
|
|
6862
6906
|
lines.push("");
|
|
6907
|
+
lines.push(" Open the command palette for DCP modal commands.");
|
|
6908
|
+
lines.push(" Use /dcp-compress [focus] when you want DCP to ask the model to run compression.");
|
|
6909
|
+
lines.push("");
|
|
6863
6910
|
for (const [cmd, desc] of commands) {
|
|
6864
6911
|
lines.push(` ${cmd.padEnd(colWidth)}${desc}`);
|
|
6865
6912
|
}
|
|
@@ -6876,7 +6923,7 @@ async function handleHelpCommand(ctx) {
|
|
|
6876
6923
|
}
|
|
6877
6924
|
|
|
6878
6925
|
// lib/commands/manual.ts
|
|
6879
|
-
var MANUAL_MODE_ON = "Manual mode is now ON. Use /dcp
|
|
6926
|
+
var MANUAL_MODE_ON = "Manual mode is now ON. Use /dcp-compress to trigger context tools manually.";
|
|
6880
6927
|
var MANUAL_MODE_OFF = "Manual mode is now OFF.";
|
|
6881
6928
|
var COMPRESS_TRIGGER_PROMPT = [
|
|
6882
6929
|
"<compress triggered manually>",
|
|
@@ -6912,6 +6959,7 @@ async function handleManualToggleCommand(ctx, modeArg) {
|
|
|
6912
6959
|
params,
|
|
6913
6960
|
logger
|
|
6914
6961
|
);
|
|
6962
|
+
await saveManualModeSetting(sessionId, !!state.manualMode, logger);
|
|
6915
6963
|
logger.info("Manual mode toggled", { manualMode: state.manualMode });
|
|
6916
6964
|
}
|
|
6917
6965
|
async function handleManualTriggerCommand(ctx, tool3, userFocus) {
|
|
@@ -7160,6 +7208,29 @@ function formatCompressionTime(ms) {
|
|
|
7160
7208
|
}
|
|
7161
7209
|
async function handleStatsCommand(ctx) {
|
|
7162
7210
|
const { client, state, logger, sessionId, messages } = ctx;
|
|
7211
|
+
const report = await buildStatsReport(state, logger);
|
|
7212
|
+
const message = formatStatsMessage(
|
|
7213
|
+
report.sessionTokens,
|
|
7214
|
+
report.sessionSummaryTokens,
|
|
7215
|
+
report.sessionTools,
|
|
7216
|
+
report.sessionMessages,
|
|
7217
|
+
report.sessionDurationMs,
|
|
7218
|
+
report.allTime
|
|
7219
|
+
);
|
|
7220
|
+
const params = getCurrentParams(state, messages, logger);
|
|
7221
|
+
await sendIgnoredMessage(client, sessionId, message, params, logger);
|
|
7222
|
+
logger.info("Stats command executed", {
|
|
7223
|
+
sessionTokens: report.sessionTokens,
|
|
7224
|
+
sessionSummaryTokens: report.sessionSummaryTokens,
|
|
7225
|
+
sessionTools: report.sessionTools,
|
|
7226
|
+
sessionMessages: report.sessionMessages,
|
|
7227
|
+
sessionDurationMs: report.sessionDurationMs,
|
|
7228
|
+
allTimeTokens: report.allTime.totalTokens,
|
|
7229
|
+
allTimeTools: report.allTime.totalTools,
|
|
7230
|
+
allTimeMessages: report.allTime.totalMessages
|
|
7231
|
+
});
|
|
7232
|
+
}
|
|
7233
|
+
async function buildStatsReport(state, logger) {
|
|
7163
7234
|
const sessionTokens = state.stats.totalPruneTokens;
|
|
7164
7235
|
const sessionSummaryTokens = Array.from(state.prune.messages.blocksById.values()).reduce(
|
|
7165
7236
|
(total, block) => block.active ? total + block.summaryTokens : total,
|
|
@@ -7185,26 +7256,14 @@ async function handleStatsCommand(ctx) {
|
|
|
7185
7256
|
}
|
|
7186
7257
|
}
|
|
7187
7258
|
const allTime = await loadAllSessionStats(logger);
|
|
7188
|
-
|
|
7259
|
+
return {
|
|
7189
7260
|
sessionTokens,
|
|
7190
7261
|
sessionSummaryTokens,
|
|
7191
7262
|
sessionTools,
|
|
7192
7263
|
sessionMessages,
|
|
7193
7264
|
sessionDurationMs,
|
|
7194
7265
|
allTime
|
|
7195
|
-
|
|
7196
|
-
const params = getCurrentParams(state, messages, logger);
|
|
7197
|
-
await sendIgnoredMessage(client, sessionId, message, params, logger);
|
|
7198
|
-
logger.info("Stats command executed", {
|
|
7199
|
-
sessionTokens,
|
|
7200
|
-
sessionSummaryTokens,
|
|
7201
|
-
sessionTools,
|
|
7202
|
-
sessionMessages,
|
|
7203
|
-
sessionDurationMs,
|
|
7204
|
-
allTimeTokens: allTime.totalTokens,
|
|
7205
|
-
allTimeTools: allTime.totalTools,
|
|
7206
|
-
allTimeMessages: allTime.totalMessages
|
|
7207
|
-
});
|
|
7266
|
+
};
|
|
7208
7267
|
}
|
|
7209
7268
|
|
|
7210
7269
|
// lib/commands/sweep.ts
|
|
@@ -7402,10 +7461,7 @@ var INTERNAL_AGENT_SIGNATURES = [
|
|
|
7402
7461
|
function createSystemPromptHandler(state, logger, config, prompts) {
|
|
7403
7462
|
return async (input, output) => {
|
|
7404
7463
|
if (input.model?.limit?.context) {
|
|
7405
|
-
|
|
7406
|
-
if (inputBudget !== void 0) {
|
|
7407
|
-
state.modelContextLimit = inputBudget;
|
|
7408
|
-
}
|
|
7464
|
+
state.modelContextLimit = input.model.limit.context;
|
|
7409
7465
|
logger.debug("Cached model context limit", { limit: state.modelContextLimit });
|
|
7410
7466
|
}
|
|
7411
7467
|
if (state.isSubAgent && !config.experimental.allowSubAgents) {
|
|
@@ -7487,7 +7543,7 @@ function createCommandExecuteHandler(client, state, logger, config, workingDirec
|
|
|
7487
7543
|
if (!config.commands.enabled) {
|
|
7488
7544
|
return;
|
|
7489
7545
|
}
|
|
7490
|
-
if (input.command === "dcp") {
|
|
7546
|
+
if (input.command === "dcp" || input.command === "dcp-compress") {
|
|
7491
7547
|
const messagesResponse = await client.session.messages({
|
|
7492
7548
|
path: { id: input.sessionID }
|
|
7493
7549
|
});
|
|
@@ -7506,8 +7562,9 @@ function createCommandExecuteHandler(client, state, logger, config, workingDirec
|
|
|
7506
7562
|
return;
|
|
7507
7563
|
}
|
|
7508
7564
|
const args = (input.arguments || "").trim().split(/\s+/).filter(Boolean);
|
|
7509
|
-
const
|
|
7510
|
-
const
|
|
7565
|
+
const isCompressCommand = input.command === "dcp-compress";
|
|
7566
|
+
const subcommand = isCompressCommand ? "compress" : args[0]?.toLowerCase() || "";
|
|
7567
|
+
const subArgs = isCompressCommand ? args : args.slice(1);
|
|
7511
7568
|
const commandCtx = {
|
|
7512
7569
|
client,
|
|
7513
7570
|
state,
|
|
@@ -7518,11 +7575,11 @@ function createCommandExecuteHandler(client, state, logger, config, workingDirec
|
|
|
7518
7575
|
};
|
|
7519
7576
|
if (subcommand === "context") {
|
|
7520
7577
|
await handleContextCommand(commandCtx);
|
|
7521
|
-
|
|
7578
|
+
return;
|
|
7522
7579
|
}
|
|
7523
7580
|
if (subcommand === "stats") {
|
|
7524
7581
|
await handleStatsCommand(commandCtx);
|
|
7525
|
-
|
|
7582
|
+
return;
|
|
7526
7583
|
}
|
|
7527
7584
|
if (subcommand === "sweep") {
|
|
7528
7585
|
await handleSweepCommand({
|
|
@@ -7530,11 +7587,11 @@ function createCommandExecuteHandler(client, state, logger, config, workingDirec
|
|
|
7530
7587
|
args: subArgs,
|
|
7531
7588
|
workingDirectory
|
|
7532
7589
|
});
|
|
7533
|
-
|
|
7590
|
+
return;
|
|
7534
7591
|
}
|
|
7535
7592
|
if (subcommand === "manual") {
|
|
7536
7593
|
await handleManualToggleCommand(commandCtx, subArgs[0]?.toLowerCase());
|
|
7537
|
-
|
|
7594
|
+
return;
|
|
7538
7595
|
}
|
|
7539
7596
|
if (subcommand === "compress") {
|
|
7540
7597
|
const userFocus = subArgs.join(" ").trim();
|
|
@@ -7551,7 +7608,7 @@ function createCommandExecuteHandler(client, state, logger, config, workingDirec
|
|
|
7551
7608
|
output.parts.length = 0;
|
|
7552
7609
|
output.parts.push({
|
|
7553
7610
|
type: "text",
|
|
7554
|
-
text: rawArgs ? `/dcp ${rawArgs}` : `/dcp ${subcommand}`
|
|
7611
|
+
text: isCompressCommand ? rawArgs ? `/dcp-compress ${rawArgs}` : "/dcp-compress" : rawArgs ? `/dcp ${rawArgs}` : `/dcp ${subcommand}`
|
|
7555
7612
|
});
|
|
7556
7613
|
return;
|
|
7557
7614
|
}
|
|
@@ -7560,17 +7617,17 @@ function createCommandExecuteHandler(client, state, logger, config, workingDirec
|
|
|
7560
7617
|
...commandCtx,
|
|
7561
7618
|
args: subArgs
|
|
7562
7619
|
});
|
|
7563
|
-
|
|
7620
|
+
return;
|
|
7564
7621
|
}
|
|
7565
7622
|
if (subcommand === "recompress") {
|
|
7566
7623
|
await handleRecompressCommand({
|
|
7567
7624
|
...commandCtx,
|
|
7568
7625
|
args: subArgs
|
|
7569
7626
|
});
|
|
7570
|
-
|
|
7627
|
+
return;
|
|
7571
7628
|
}
|
|
7572
7629
|
await handleHelpCommand(commandCtx);
|
|
7573
|
-
|
|
7630
|
+
return;
|
|
7574
7631
|
}
|
|
7575
7632
|
};
|
|
7576
7633
|
}
|
|
@@ -7881,9 +7938,9 @@ var server = (async (ctx) => {
|
|
|
7881
7938
|
}
|
|
7882
7939
|
if (config.commands.enabled && config.compress.permission !== "deny") {
|
|
7883
7940
|
opencodeConfig.command ??= {};
|
|
7884
|
-
opencodeConfig.command["dcp"] = {
|
|
7941
|
+
opencodeConfig.command["dcp-compress"] = {
|
|
7885
7942
|
template: "",
|
|
7886
|
-
description: "
|
|
7943
|
+
description: "Trigger DCP manual compression with: /dcp-compress [focus]"
|
|
7887
7944
|
};
|
|
7888
7945
|
}
|
|
7889
7946
|
const toolsToAdd = [];
|