@tarquinen/opencode-dcp 3.2.5-beta0 → 3.2.6-beta0
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/index.ts +141 -0
- package/lib/analysis/tokens.ts +225 -0
- package/lib/auth.ts +37 -0
- package/lib/commands/compression-targets.ts +137 -0
- package/lib/commands/context.ts +132 -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 +125 -0
- package/lib/commands/recompress.ts +224 -0
- package/lib/commands/stats.ts +148 -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 +137 -0
- package/lib/compress/pipeline.ts +106 -0
- package/lib/compress/protected-content.ts +154 -0
- package/lib/compress/range-utils.ts +308 -0
- package/lib/compress/range.ts +180 -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 +1071 -0
- package/lib/hooks.ts +378 -0
- package/lib/host-permissions.ts +101 -0
- package/lib/logger.ts +235 -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 +238 -0
- package/lib/messages/query.ts +56 -0
- package/lib/messages/reasoning-strip.ts +40 -0
- package/lib/messages/sync.ts +124 -0
- package/lib/messages/utils.ts +187 -0
- package/lib/prompts/compress-message.ts +42 -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 +256 -0
- package/lib/state/state.ts +190 -0
- package/lib/state/tool-cache.ts +98 -0
- package/lib/state/types.ts +112 -0
- package/lib/state/utils.ts +334 -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 +162 -0
- package/lib/ui/notification.ts +346 -0
- package/lib/ui/utils.ts +287 -0
- package/package.json +9 -2
- package/tui/data/context.ts +177 -0
- package/tui/index.tsx +34 -0
- package/tui/routes/summary.tsx +175 -0
- package/tui/shared/names.ts +9 -0
- package/tui/shared/theme.ts +58 -0
- package/tui/shared/types.ts +38 -0
- package/tui/slots/sidebar-content.tsx +502 -0
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import type { PluginConfig } from "../config"
|
|
2
|
+
import type { Logger } from "../logger"
|
|
3
|
+
import type { PromptStore } from "../prompts/store"
|
|
4
|
+
import type { CompressionBlock, CompressionMode, SessionState, WithParts } from "../state"
|
|
5
|
+
|
|
6
|
+
export interface ToolContext {
|
|
7
|
+
client: any
|
|
8
|
+
state: SessionState
|
|
9
|
+
logger: Logger
|
|
10
|
+
config: PluginConfig
|
|
11
|
+
prompts: PromptStore
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface CompressRangeEntry {
|
|
15
|
+
startId: string
|
|
16
|
+
endId: string
|
|
17
|
+
summary: string
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface CompressRangeToolArgs {
|
|
21
|
+
topic: string
|
|
22
|
+
content: CompressRangeEntry[]
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface CompressMessageEntry {
|
|
26
|
+
messageId: string
|
|
27
|
+
topic: string
|
|
28
|
+
summary: string
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface CompressMessageToolArgs {
|
|
32
|
+
topic: string
|
|
33
|
+
content: CompressMessageEntry[]
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface BoundaryReference {
|
|
37
|
+
kind: "message" | "compressed-block"
|
|
38
|
+
rawIndex: number
|
|
39
|
+
messageId?: string
|
|
40
|
+
blockId?: number
|
|
41
|
+
anchorMessageId?: string
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface SearchContext {
|
|
45
|
+
rawMessages: WithParts[]
|
|
46
|
+
rawMessagesById: Map<string, WithParts>
|
|
47
|
+
rawIndexById: Map<string, number>
|
|
48
|
+
summaryByBlockId: Map<number, CompressionBlock>
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface SelectionResolution {
|
|
52
|
+
startReference: BoundaryReference
|
|
53
|
+
endReference: BoundaryReference
|
|
54
|
+
messageIds: string[]
|
|
55
|
+
messageTokenById: Map<string, number>
|
|
56
|
+
toolIds: string[]
|
|
57
|
+
requiredBlockIds: number[]
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface ResolvedMessageCompression {
|
|
61
|
+
entry: CompressMessageEntry
|
|
62
|
+
selection: SelectionResolution
|
|
63
|
+
anchorMessageId: string
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface ResolvedRangeCompression {
|
|
67
|
+
index: number
|
|
68
|
+
entry: CompressRangeEntry
|
|
69
|
+
selection: SelectionResolution
|
|
70
|
+
anchorMessageId: string
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export interface ResolvedMessageCompressionsResult {
|
|
74
|
+
plans: ResolvedMessageCompression[]
|
|
75
|
+
skippedIssues: string[]
|
|
76
|
+
skippedCount: number
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export interface ParsedBlockPlaceholder {
|
|
80
|
+
raw: string
|
|
81
|
+
blockId: number
|
|
82
|
+
startIndex: number
|
|
83
|
+
endIndex: number
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export interface InjectedSummaryResult {
|
|
87
|
+
expandedSummary: string
|
|
88
|
+
consumedBlockIds: number[]
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export interface AppliedCompressionResult {
|
|
92
|
+
compressedTokens: number
|
|
93
|
+
messageIds: string[]
|
|
94
|
+
newlyCompressedMessageIds: string[]
|
|
95
|
+
newlyCompressedToolIds: string[]
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export interface CompressionStateInput {
|
|
99
|
+
topic: string
|
|
100
|
+
batchTopic: string
|
|
101
|
+
startId: string
|
|
102
|
+
endId: string
|
|
103
|
+
mode: CompressionMode
|
|
104
|
+
runId: number
|
|
105
|
+
compressMessageId: string
|
|
106
|
+
compressCallId?: string
|
|
107
|
+
summaryTokens: number
|
|
108
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { PluginConfig } from "./config"
|
|
2
|
+
import { type HostPermissionSnapshot, resolveEffectiveCompressPermission } from "./host-permissions"
|
|
3
|
+
import type { SessionState, WithParts } from "./state"
|
|
4
|
+
import { getLastUserMessage } from "./messages/query"
|
|
5
|
+
|
|
6
|
+
export const compressPermission = (
|
|
7
|
+
state: SessionState,
|
|
8
|
+
config: PluginConfig,
|
|
9
|
+
): "ask" | "allow" | "deny" => {
|
|
10
|
+
return state.compressPermission ?? config.compress.permission
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const syncCompressPermissionState = (
|
|
14
|
+
state: SessionState,
|
|
15
|
+
config: PluginConfig,
|
|
16
|
+
hostPermissions: HostPermissionSnapshot,
|
|
17
|
+
messages: WithParts[],
|
|
18
|
+
): void => {
|
|
19
|
+
const activeAgent = getLastUserMessage(messages)?.info.agent
|
|
20
|
+
state.compressPermission = resolveEffectiveCompressPermission(
|
|
21
|
+
config.compress.permission,
|
|
22
|
+
hostPermissions,
|
|
23
|
+
activeAgent,
|
|
24
|
+
)
|
|
25
|
+
}
|