@lexwdex-org/opencode-dcp 3.5.0 → 5.0.0
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.en.md +60 -47
- package/README.md +45 -66
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +699 -1105
- package/dist/index.js.map +1 -1
- package/dist/lib/config.d.ts +7 -32
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/dtc/digest.d.ts +16 -0
- package/dist/lib/dtc/digest.d.ts.map +1 -0
- package/dist/lib/dtc/engine.d.ts +64 -0
- package/dist/lib/dtc/engine.d.ts.map +1 -0
- package/dist/lib/dtc/state.d.ts +28 -0
- package/dist/lib/dtc/state.d.ts.map +1 -0
- package/dist/lib/dtc/types.d.ts +45 -0
- package/dist/lib/dtc/types.d.ts.map +1 -0
- package/dist/lib/hooks.d.ts +60 -31
- package/dist/lib/hooks.d.ts.map +1 -1
- package/dist/lib/prune-tool.d.ts +3 -2
- package/dist/lib/prune-tool.d.ts.map +1 -1
- package/dist/lib/session-events.d.ts +7 -0
- package/dist/lib/session-events.d.ts.map +1 -0
- package/dist/lib/text.d.ts +19 -0
- package/dist/lib/text.d.ts.map +1 -0
- package/package.json +2 -3
- package/dist/lib/auto-prune.d.ts +0 -20
- package/dist/lib/auto-prune.d.ts.map +0 -1
- package/dist/lib/prompts/compaction.d.ts +0 -4
- package/dist/lib/prompts/compaction.d.ts.map +0 -1
- package/dist/lib/prompts/store.d.ts +0 -17
- package/dist/lib/prompts/store.d.ts.map +0 -1
- package/dist/lib/prune-service.d.ts +0 -104
- package/dist/lib/prune-service.d.ts.map +0 -1
- package/dist/lib/session-boundary.d.ts +0 -90
- package/dist/lib/session-boundary.d.ts.map +0 -1
- package/dist/lib/session-model.d.ts +0 -8
- package/dist/lib/session-model.d.ts.map +0 -1
- package/dist/lib/summarize.d.ts +0 -38
- package/dist/lib/summarize.d.ts.map +0 -1
package/dist/lib/config.d.ts
CHANGED
|
@@ -1,44 +1,24 @@
|
|
|
1
1
|
import type { PluginInput } from "@opencode-ai/plugin";
|
|
2
|
+
import { type DtcConfig } from "./dtc/engine";
|
|
2
3
|
export interface Commands {
|
|
3
4
|
enabled: boolean;
|
|
4
5
|
}
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
export interface SummarizeConfig {
|
|
9
|
-
failureCooldownMs: number;
|
|
10
|
-
}
|
|
11
|
-
export interface AutoPruneSignals {
|
|
12
|
-
topicDrift: boolean;
|
|
13
|
-
volume: boolean;
|
|
14
|
-
idleGap: boolean;
|
|
15
|
-
}
|
|
16
|
-
export interface AutoPruneConfig {
|
|
6
|
+
/** DTC engine knobs plus the master switch for request-time compression. */
|
|
7
|
+
export interface DtcPluginConfig extends DtcConfig {
|
|
17
8
|
enabled: boolean;
|
|
18
|
-
/** Per-signal switches; only topic changes are enabled by default (LD1). */
|
|
19
|
-
signals: AutoPruneSignals;
|
|
20
|
-
minMessages: number;
|
|
21
|
-
volumeThreshold: number;
|
|
22
|
-
driftThreshold: number;
|
|
23
|
-
idleGapMs: number;
|
|
24
|
-
cooldownMs: number;
|
|
25
9
|
}
|
|
26
10
|
export interface ToolConfig {
|
|
27
11
|
enabled: boolean;
|
|
28
12
|
}
|
|
29
|
-
export type DcpLanguage = "zh" | "en";
|
|
30
13
|
export interface PluginConfig {
|
|
31
14
|
enabled: boolean;
|
|
32
15
|
autoUpdate: boolean;
|
|
33
16
|
debug: boolean;
|
|
34
|
-
language: DcpLanguage;
|
|
35
17
|
commands: Commands;
|
|
36
|
-
|
|
37
|
-
summarize: SummarizeConfig;
|
|
38
|
-
autoPrune: AutoPruneConfig;
|
|
18
|
+
dtc: DtcPluginConfig;
|
|
39
19
|
tool: ToolConfig;
|
|
40
20
|
}
|
|
41
|
-
export declare const
|
|
21
|
+
export declare const DEFAULT_DTC: DtcPluginConfig;
|
|
42
22
|
export declare const VALID_CONFIG_KEYS: Set<string>;
|
|
43
23
|
export declare const DEPRECATED_CONFIG_KEYS: Set<string>;
|
|
44
24
|
export declare function getDeprecatedConfigKeys(userConfig: Record<string, any>): string[];
|
|
@@ -49,13 +29,8 @@ interface ValidationError {
|
|
|
49
29
|
actual: string;
|
|
50
30
|
}
|
|
51
31
|
export declare function validateConfigTypes(config: Record<string, any>): ValidationError[];
|
|
52
|
-
/**
|
|
53
|
-
|
|
54
|
-
* the per-signal switches. The hint fires on every config load where this
|
|
55
|
-
* holds (same always-fires, stateless mechanism as the compress.* hints — no
|
|
56
|
-
* persistent "one-time" flag).
|
|
57
|
-
*/
|
|
58
|
-
export declare function needsSignalsMigrationHint(configData: Record<string, any>): boolean;
|
|
32
|
+
/** Legacy autoPrune.driftThreshold migrates to dtc.driftThreshold. */
|
|
33
|
+
export declare function legacyDriftThreshold(configData: Record<string, any>): number | undefined;
|
|
59
34
|
export declare function getConfig(ctx: PluginInput): PluginConfig;
|
|
60
35
|
export {};
|
|
61
36
|
//# sourceMappingURL=config.d.ts.map
|
package/dist/lib/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../lib/config.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../lib/config.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,EAAgB,KAAK,SAAS,EAAE,MAAM,cAAc,CAAA;AAE3D,MAAM,WAAW,QAAQ;IACrB,OAAO,EAAE,OAAO,CAAA;CACnB;AAED,4EAA4E;AAC5E,MAAM,WAAW,eAAgB,SAAQ,SAAS;IAC9C,OAAO,EAAE,OAAO,CAAA;CACnB;AAED,MAAM,WAAW,UAAU;IACvB,OAAO,EAAE,OAAO,CAAA;CACnB;AAED,MAAM,WAAW,YAAY;IACzB,OAAO,EAAE,OAAO,CAAA;IAChB,UAAU,EAAE,OAAO,CAAA;IACnB,KAAK,EAAE,OAAO,CAAA;IACd,QAAQ,EAAE,QAAQ,CAAA;IAClB,GAAG,EAAE,eAAe,CAAA;IACpB,IAAI,EAAE,UAAU,CAAA;CACnB;AAED,eAAO,MAAM,WAAW,EAAE,eAGzB,CAAA;AAED,eAAO,MAAM,iBAAiB,aAgB5B,CAAA;AAMF,eAAO,MAAM,sBAAsB,aA2DjC,CAAA;AAeF,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,EAAE,CAEjF;AAED,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,EAAE,CAI9E;AAED,UAAU,eAAe;IACrB,GAAG,EAAE,MAAM,CAAA;IACX,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;CACjB;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,eAAe,EAAE,CAwElF;AAED,sEAAsE;AACtE,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,GAAG,SAAS,CASxF;AAmQD,wBAAgB,SAAS,CAAC,GAAG,EAAE,WAAW,GAAG,YAAY,CAsCxD"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { MessageLike, Turn } from "./types";
|
|
2
|
+
/** Builds the one-block digest that replaces a distant turn's content. */
|
|
3
|
+
export declare function digestTurn(messages: MessageLike[], turn: Turn, index: number): string;
|
|
4
|
+
/** Stable cache key: identity of the opening message + shape of the content. */
|
|
5
|
+
export declare function digestKey(messages: MessageLike[], turn: Turn): string;
|
|
6
|
+
/**
|
|
7
|
+
* Stateless topic-boundary scanner over the head region: a boundary is a
|
|
8
|
+
* substantial user message whose similarity to its predecessor drops below
|
|
9
|
+
* the drift threshold. Returns turn positions (indices into `turns`).
|
|
10
|
+
*/
|
|
11
|
+
export declare function findTopicBoundaries(messages: MessageLike[], turns: Turn[], driftThreshold: number): number[];
|
|
12
|
+
/** Token estimate of a message slice, summing every string payload. Parts
|
|
13
|
+
* folded with the host's compacted marker count as the short placeholder the
|
|
14
|
+
* host serializer will actually emit, not the stored output. */
|
|
15
|
+
export declare function estimateSlice(messages: MessageLike[], start: number, end: number): number;
|
|
16
|
+
//# sourceMappingURL=digest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"digest.d.ts","sourceRoot":"","sources":["../../../lib/dtc/digest.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAY,IAAI,EAAE,MAAM,SAAS,CAAA;AA8C1D,0EAA0E;AAC1E,wBAAgB,UAAU,CAAC,QAAQ,EAAE,WAAW,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAuBrF;AAcD,gFAAgF;AAChF,wBAAgB,SAAS,CAAC,QAAQ,EAAE,WAAW,EAAE,EAAE,IAAI,EAAE,IAAI,GAAG,MAAM,CAiBrE;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAC/B,QAAQ,EAAE,WAAW,EAAE,EACvB,KAAK,EAAE,IAAI,EAAE,EACb,cAAc,EAAE,MAAM,GACvB,MAAM,EAAE,CAaV;AAED;;gEAEgE;AAChE,wBAAgB,aAAa,CAAC,QAAQ,EAAE,WAAW,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAiBzF"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { Logger } from "../logger";
|
|
2
|
+
import type { DtcState } from "./state";
|
|
3
|
+
import type { MessageLike, Turn } from "./types";
|
|
4
|
+
/**
|
|
5
|
+
* The dynamic tiered compression engine. Runs inside the host's
|
|
6
|
+
* `experimental.chat.messages.transform` hook on every model request and
|
|
7
|
+
* rewrites ONLY string payloads of the request-scoped message copies:
|
|
8
|
+
*
|
|
9
|
+
* - messages and parts are never added, removed, or reordered
|
|
10
|
+
* - part IDs, tool-call pairing, and roles are never touched
|
|
11
|
+
* - distant tool outputs are folded with the host's own `time.compacted`
|
|
12
|
+
* marker, so the wire rendering is the host's native one
|
|
13
|
+
*
|
|
14
|
+
* Nothing here writes to the session; the host rebuilds this array from
|
|
15
|
+
* storage on every request, so all mutations are inherently request-scoped.
|
|
16
|
+
*/
|
|
17
|
+
export interface DtcConfig {
|
|
18
|
+
/** Turns kept completely verbatim at the end (never folded). */
|
|
19
|
+
tailTurns: number;
|
|
20
|
+
/** Below this fraction of the context window, no folding happens at all. */
|
|
21
|
+
lowWatermarkRatio: number;
|
|
22
|
+
/** Folding escalates until the estimate fits this fraction. */
|
|
23
|
+
targetRatio: number;
|
|
24
|
+
/** Jaccard similarity below which consecutive turns count as a topic change. */
|
|
25
|
+
driftThreshold: number;
|
|
26
|
+
/** C-zone tool outputs are head+tail truncated to this many characters. */
|
|
27
|
+
toolOutputKeepChars: number;
|
|
28
|
+
}
|
|
29
|
+
export declare const DTC_DEFAULTS: DtcConfig;
|
|
30
|
+
export type FoldLevel = 0 | 1 | 2 | 3;
|
|
31
|
+
export interface TransformStats {
|
|
32
|
+
messages: number;
|
|
33
|
+
userTurns: number;
|
|
34
|
+
level: FoldLevel;
|
|
35
|
+
estimatedBefore: number;
|
|
36
|
+
estimatedAfter: number;
|
|
37
|
+
contextTokens: number;
|
|
38
|
+
foldedTools: number;
|
|
39
|
+
foldedTexts: number;
|
|
40
|
+
reducedInputs: number;
|
|
41
|
+
foldedErrors: number;
|
|
42
|
+
digestedTurns: number;
|
|
43
|
+
skipped: "short" | "unknown-context" | "compaction" | undefined;
|
|
44
|
+
}
|
|
45
|
+
export interface TransformDeps {
|
|
46
|
+
state: DtcState;
|
|
47
|
+
config: DtcConfig;
|
|
48
|
+
logger?: Logger;
|
|
49
|
+
now?: () => number;
|
|
50
|
+
}
|
|
51
|
+
/** Splits the array into turns at user messages (compaction-part users are
|
|
52
|
+
* host machinery, not conversational turns — same rule as the fork's own
|
|
53
|
+
* `turns()` in session/compaction.ts). */
|
|
54
|
+
export declare function segmentTurns(messages: MessageLike[]): Turn[];
|
|
55
|
+
export declare function transformMessages(messages: MessageLike[], deps: TransformDeps): TransformStats;
|
|
56
|
+
/**
|
|
57
|
+
* Reduces a tool call's arguments to their target identity: path-like keys
|
|
58
|
+
* stay, `command` keeps a short first line, and content payloads
|
|
59
|
+
* (oldString/newString/content/…) are dropped. Repeated or failed operations
|
|
60
|
+
* on the same target collapse to a recognizable skeleton — the final state
|
|
61
|
+
* lives on disk and in the current-task zone, never in stale payloads.
|
|
62
|
+
*/
|
|
63
|
+
export declare function reduceInput(input: Record<string, unknown> | undefined): Record<string, unknown>;
|
|
64
|
+
//# sourceMappingURL=engine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../../../lib/dtc/engine.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAGvC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AACvC,OAAO,KAAK,EAAE,WAAW,EAAY,IAAI,EAAE,MAAM,SAAS,CAAA;AAE1D;;;;;;;;;;;;GAYG;AAEH,MAAM,WAAW,SAAS;IACtB,gEAAgE;IAChE,SAAS,EAAE,MAAM,CAAA;IACjB,4EAA4E;IAC5E,iBAAiB,EAAE,MAAM,CAAA;IACzB,+DAA+D;IAC/D,WAAW,EAAE,MAAM,CAAA;IACnB,gFAAgF;IAChF,cAAc,EAAE,MAAM,CAAA;IACtB,2EAA2E;IAC3E,mBAAmB,EAAE,MAAM,CAAA;CAC9B;AAED,eAAO,MAAM,YAAY,EAAE,SAM1B,CAAA;AAoBD,MAAM,MAAM,SAAS,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;AAErC,MAAM,WAAW,cAAc;IAC3B,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,SAAS,CAAA;IAChB,eAAe,EAAE,MAAM,CAAA;IACvB,cAAc,EAAE,MAAM,CAAA;IACtB,aAAa,EAAE,MAAM,CAAA;IACrB,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,MAAM,CAAA;IACnB,aAAa,EAAE,MAAM,CAAA;IACrB,YAAY,EAAE,MAAM,CAAA;IACpB,aAAa,EAAE,MAAM,CAAA;IACrB,OAAO,EAAE,OAAO,GAAG,iBAAiB,GAAG,YAAY,GAAG,SAAS,CAAA;CAClE;AAiBD,MAAM,WAAW,aAAa;IAC1B,KAAK,EAAE,QAAQ,CAAA;IACf,MAAM,EAAE,SAAS,CAAA;IACjB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,GAAG,CAAC,EAAE,MAAM,MAAM,CAAA;CACrB;AAED;;0CAE0C;AAC1C,wBAAgB,YAAY,CAAC,QAAQ,EAAE,WAAW,EAAE,GAAG,IAAI,EAAE,CAY5D;AAED,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,WAAW,EAAE,EAAE,IAAI,EAAE,aAAa,GAAG,cAAc,CAmE9F;AA+KD;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAY/F"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-session runtime state for the DTC engine. Everything here is
|
|
3
|
+
* request-scoped or in-memory only — nothing is ever persisted, matching the
|
|
4
|
+
* "no plugin checkpoint persistence" constraint. All maps are LRU-bounded.
|
|
5
|
+
*/
|
|
6
|
+
export declare class DtcState {
|
|
7
|
+
private readonly sessions;
|
|
8
|
+
private readonly digests;
|
|
9
|
+
observeContextLimit(sessionID: string, contextTokens: number | undefined): void;
|
|
10
|
+
contextTokens(sessionID: string): number | undefined;
|
|
11
|
+
/** Called by the compacting hook; consumed by the very next transform. */
|
|
12
|
+
armCompactionSkip(sessionID: string): void;
|
|
13
|
+
consumeCompactionSkip(sessionID: string): boolean;
|
|
14
|
+
/** `dcp_prune` / `/dcp fold`: mark a boundary now and deepen folding. */
|
|
15
|
+
markBoundary(sessionID: string, at: number, minLevel?: number): void;
|
|
16
|
+
boundaryMark(sessionID: string): number | undefined;
|
|
17
|
+
minLevel(sessionID: string): number;
|
|
18
|
+
cachedDigest(key: string): string | undefined;
|
|
19
|
+
storeDigest(key: string, digest: string): void;
|
|
20
|
+
dropSession(sessionID: string): void;
|
|
21
|
+
/** Test/inspection surface. */
|
|
22
|
+
stats(): {
|
|
23
|
+
sessions: number;
|
|
24
|
+
digests: number;
|
|
25
|
+
};
|
|
26
|
+
private session;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../lib/dtc/state.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAmCH,qBAAa,QAAQ;IACjB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAqC;IAC9D,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA4B;IAEpD,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;IAS/E,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAIpD,0EAA0E;IAC1E,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAM1C,qBAAqB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;IAOjD,yEAAyE;IACzE,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,SAAI,GAAG,IAAI;IAO/D,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAInD,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM;IAInC,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAI7C,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAI9C,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAIpC,+BAA+B;IAC/B,KAAK,IAAI;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE;IAI9C,OAAO,CAAC,OAAO;CAGlB"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loose structural types for session messages as delivered by the host's
|
|
3
|
+
* `experimental.chat.messages.transform` hook. Deliberately duck-typed: the
|
|
4
|
+
* engine only reads roles/part types and rewrites string payloads, so it
|
|
5
|
+
* stays compatible across host versions without importing their schemas.
|
|
6
|
+
*/
|
|
7
|
+
export interface MessageInfoLike {
|
|
8
|
+
id?: string;
|
|
9
|
+
role?: string;
|
|
10
|
+
sessionID?: string;
|
|
11
|
+
time?: {
|
|
12
|
+
created?: number;
|
|
13
|
+
};
|
|
14
|
+
summary?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface ToolStateLike {
|
|
17
|
+
status?: string;
|
|
18
|
+
output?: string;
|
|
19
|
+
error?: unknown;
|
|
20
|
+
input?: Record<string, unknown>;
|
|
21
|
+
time?: {
|
|
22
|
+
compacted?: number;
|
|
23
|
+
} & Record<string, unknown>;
|
|
24
|
+
metadata?: Record<string, unknown>;
|
|
25
|
+
}
|
|
26
|
+
export interface PartLike {
|
|
27
|
+
type?: string;
|
|
28
|
+
id?: string;
|
|
29
|
+
text?: string;
|
|
30
|
+
tool?: string;
|
|
31
|
+
state?: ToolStateLike;
|
|
32
|
+
[key: string]: unknown;
|
|
33
|
+
}
|
|
34
|
+
export interface MessageLike {
|
|
35
|
+
info?: MessageInfoLike;
|
|
36
|
+
parts?: PartLike[];
|
|
37
|
+
}
|
|
38
|
+
/** A turn = a user message plus everything up to the next user message. */
|
|
39
|
+
export interface Turn {
|
|
40
|
+
/** Index of the user message that opens the turn. */
|
|
41
|
+
start: number;
|
|
42
|
+
/** Exclusive end index in the message array. */
|
|
43
|
+
end: number;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../lib/dtc/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,WAAW,eAAe;IAC5B,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,IAAI,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;IAC3B,OAAO,CAAC,EAAE,OAAO,CAAA;CACpB;AAED,MAAM,WAAW,aAAa;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC/B,IAAI,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACvD,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACrC;AAED,MAAM,WAAW,QAAQ;IACrB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,aAAa,CAAA;IACrB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACzB;AAED,MAAM,WAAW,WAAW;IACxB,IAAI,CAAC,EAAE,eAAe,CAAA;IACtB,KAAK,CAAC,EAAE,QAAQ,EAAE,CAAA;CACrB;AAED,2EAA2E;AAC3E,MAAM,WAAW,IAAI;IACjB,qDAAqD;IACrD,KAAK,EAAE,MAAM,CAAA;IACb,gDAAgD;IAChD,GAAG,EAAE,MAAM,CAAA;CACd"}
|
package/dist/lib/hooks.d.ts
CHANGED
|
@@ -1,57 +1,86 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PluginConfig } from "./config";
|
|
2
2
|
import type { Logger } from "./logger";
|
|
3
3
|
import type { OpenCodeClient } from "./opencode-client";
|
|
4
|
-
import type {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
interface
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
import type { DtcState } from "./dtc/state";
|
|
5
|
+
/** Host-side tail protection DCP applies unless the user configured it. */
|
|
6
|
+
export declare const DEFAULT_TAIL_TURNS = 4;
|
|
7
|
+
export declare const DEFAULT_PRESERVE_RECENT_TOKENS = 32000;
|
|
8
|
+
export interface SessionCompactingDeps {
|
|
9
|
+
state: DtcState;
|
|
10
|
+
logger: Logger;
|
|
11
11
|
}
|
|
12
|
-
|
|
12
|
+
/**
|
|
13
|
+
* The host fires this hook right before it runs the messages transform over
|
|
14
|
+
* the compaction input (fork session/compaction.ts :373 → :380). DCP does NOT
|
|
15
|
+
* touch the compaction prompt: the host's native anchored-summary template
|
|
16
|
+
* (with its own previous-summary rolling merge) stays fully in charge of
|
|
17
|
+
* `/compact` and the overflow fallback. The hook's single job is arming the
|
|
18
|
+
* one-shot DTC skip so the summarizer always sees full-fidelity input instead
|
|
19
|
+
* of request-time folds.
|
|
20
|
+
*/
|
|
21
|
+
export declare function createSessionCompactingHandler(deps: SessionCompactingDeps): (input: {
|
|
13
22
|
sessionID: string;
|
|
14
|
-
},
|
|
15
|
-
|
|
23
|
+
}, _output?: unknown) => Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* `chat.params` fires on every LLM request with the resolved model. DTC only
|
|
26
|
+
* reads the context-window size from it — the budget tiers are fractions of
|
|
27
|
+
* that window, and until it is known the engine fails open (no folding).
|
|
28
|
+
*/
|
|
29
|
+
export declare function createChatParamsHandler(deps: {
|
|
30
|
+
state: DtcState;
|
|
31
|
+
logger: Logger;
|
|
32
|
+
}): (input: {
|
|
16
33
|
sessionID: string;
|
|
34
|
+
model?: {
|
|
35
|
+
limit?: {
|
|
36
|
+
context?: number;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
17
39
|
}, _output?: unknown) => Promise<void>;
|
|
18
|
-
export interface
|
|
19
|
-
|
|
20
|
-
|
|
40
|
+
export interface TransformHandlerDeps {
|
|
41
|
+
state: DtcState;
|
|
42
|
+
config: PluginConfig["dtc"];
|
|
21
43
|
logger: Logger;
|
|
22
44
|
}
|
|
23
45
|
/**
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* deferred-prune drain and the at-rest auto-prune listener. This handler only
|
|
28
|
-
* keeps the heuristic pruner's own lifecycle state in sync.
|
|
46
|
+
* THE compression surface: runs inside the host's per-request messages
|
|
47
|
+
* transform. Fail-open by contract — any engine error must leave the array
|
|
48
|
+
* untouched rather than break the model call.
|
|
29
49
|
*/
|
|
50
|
+
export declare function createTransformHandler(deps: TransformHandlerDeps): (_input: unknown, output: {
|
|
51
|
+
messages: unknown[];
|
|
52
|
+
}) => Promise<void>;
|
|
53
|
+
export interface EventHandlerDeps {
|
|
54
|
+
state: DtcState;
|
|
55
|
+
logger: Logger;
|
|
56
|
+
}
|
|
57
|
+
/** Slim lifecycle feed: only session deletion needs explicit cleanup; every
|
|
58
|
+
* other DTC structure is LRU-bounded or request-scoped. */
|
|
30
59
|
export declare function createEventHandler(deps: EventHandlerDeps): (input: {
|
|
31
60
|
event: {
|
|
32
61
|
type: string;
|
|
33
62
|
properties?: Record<string, any>;
|
|
34
63
|
};
|
|
35
64
|
}) => Promise<void>;
|
|
36
|
-
export interface
|
|
65
|
+
export interface CommandExecuteDeps {
|
|
37
66
|
client: OpenCodeClient;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
config: AutoPruneConfig;
|
|
67
|
+
state: DtcState;
|
|
68
|
+
config: PluginConfig["dtc"];
|
|
41
69
|
logger: Logger;
|
|
42
70
|
}
|
|
43
|
-
|
|
44
|
-
* At-rest listener #2: the heuristic auto prune. The `enabled` gate stays at
|
|
45
|
-
* this mount point — a tool-only configuration (auto prune disabled) never
|
|
46
|
-
* registers the listener, so it gains no auto-prune behavior.
|
|
47
|
-
*/
|
|
48
|
-
export declare function createAtRestAutoPruneListener(deps: AtRestAutoPruneDeps): (sessionID: string, _reason: RestFireReason) => Promise<void>;
|
|
49
|
-
export declare function createCommandExecuteHandler(client: OpenCodeClient, prune: PruneService, logger: Logger): (input: {
|
|
71
|
+
export declare function createCommandExecuteHandler(deps: CommandExecuteDeps): (input: {
|
|
50
72
|
command: string;
|
|
51
73
|
sessionID: string;
|
|
52
74
|
arguments: string;
|
|
53
75
|
}, _output?: {
|
|
54
76
|
parts: unknown[];
|
|
55
77
|
}) => Promise<void>;
|
|
56
|
-
|
|
78
|
+
/**
|
|
79
|
+
* Mutates the host config at load time: register the `/dcp` command when
|
|
80
|
+
* enabled, and raise the host's compaction tail protection to DCP's tiered
|
|
81
|
+
* defaults (last turns kept verbatim) unless the user already configured
|
|
82
|
+
* them — this shapes the host's own overflow-compaction fallback, which is
|
|
83
|
+
* the only compaction that still writes checkpoints.
|
|
84
|
+
*/
|
|
85
|
+
export declare function createConfigHandler(config: PluginConfig, logger: Logger): (opencodeConfig: Record<string, any>) => Promise<void>;
|
|
57
86
|
//# sourceMappingURL=hooks.d.ts.map
|
package/dist/lib/hooks.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../lib/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../lib/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAC5C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACtC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAEvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAK3C,2EAA2E;AAC3E,eAAO,MAAM,kBAAkB,IAAI,CAAA;AACnC,eAAO,MAAM,8BAA8B,QAAS,CAAA;AAEpD,MAAM,WAAW,qBAAqB;IAClC,KAAK,EAAE,QAAQ,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;CACjB;AAED;;;;;;;;GAQG;AACH,wBAAgB,8BAA8B,CAAC,IAAI,EAAE,qBAAqB,IACxD,OAAO;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,EAAE,UAAU,OAAO,KAAG,OAAO,CAAC,IAAI,CAAC,CAahF;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE;IAAE,KAAK,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,IAEzE,OAAO;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE;YAAE,OAAO,CAAC,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,CAAA;CAAE,EACtE,UAAU,OAAO,KAClB,OAAO,CAAC,IAAI,CAAC,CAYnB;AAED,MAAM,WAAW,oBAAoB;IACjC,KAAK,EAAE,QAAQ,CAAA;IACf,MAAM,EAAE,YAAY,CAAC,KAAK,CAAC,CAAA;IAC3B,MAAM,EAAE,MAAM,CAAA;CACjB;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,oBAAoB,IAC/C,QAAQ,OAAO,EAAE,QAAQ;IAAE,QAAQ,EAAE,OAAO,EAAE,CAAA;CAAE,KAAG,OAAO,CAAC,IAAI,CAAC,CAcjF;AAED,MAAM,WAAW,gBAAgB;IAC7B,KAAK,EAAE,QAAQ,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;CACjB;AAED;2DAC2D;AAC3D,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,gBAAgB,IACvC,OAAO;IAAE,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;KAAE,CAAA;CAAE,mBAYrF;AAeD,MAAM,WAAW,kBAAkB;IAC/B,MAAM,EAAE,cAAc,CAAA;IACtB,KAAK,EAAE,QAAQ,CAAA;IACf,MAAM,EAAE,YAAY,CAAC,KAAK,CAAC,CAAA;IAC3B,MAAM,EAAE,MAAM,CAAA;CACjB;AAED,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,kBAAkB,IAE5D,OAAO;IACH,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;CACpB,EACD,UAAU;IAAE,KAAK,EAAE,OAAO,EAAE,CAAA;CAAE,KAC/B,OAAO,CAAC,IAAI,CAAC,CA6BnB;AAuBD;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,IACtD,gBAAgB,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAG,OAAO,CAAC,IAAI,CAAC,CAoBpE"}
|
package/dist/lib/prune-tool.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { Logger } from "./logger";
|
|
2
|
-
import type {
|
|
2
|
+
import type { DtcState } from "./dtc/state";
|
|
3
3
|
export declare const PRUNE_TOOL_NAME = "dcp_prune";
|
|
4
4
|
export interface PruneToolDeps {
|
|
5
|
-
|
|
5
|
+
state: DtcState;
|
|
6
6
|
logger: Logger;
|
|
7
|
+
now?: () => number;
|
|
7
8
|
}
|
|
8
9
|
export declare function createPruneTool(deps: PruneToolDeps): {
|
|
9
10
|
description: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prune-tool.d.ts","sourceRoot":"","sources":["../../lib/prune-tool.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACtC,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"prune-tool.d.ts","sourceRoot":"","sources":["../../lib/prune-tool.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACtC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAE3C,eAAO,MAAM,eAAe,cAAc,CAAA;AAU1C,MAAM,WAAW,aAAa;IAC1B,KAAK,EAAE,QAAQ,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;IACd,GAAG,CAAC,EAAE,MAAM,MAAM,CAAA;CACrB;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,aAAa;;;;EAclD"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolves the session ID from a host event's properties. Most events carry
|
|
3
|
+
* `sessionID` directly, but some (e.g. `session.deleted`) only carry
|
|
4
|
+
* `info: Session`. Returns `undefined` when neither is a non-empty string.
|
|
5
|
+
*/
|
|
6
|
+
export declare function eventSessionID(properties?: Record<string, any>): string | undefined;
|
|
7
|
+
//# sourceMappingURL=session-events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-events.d.ts","sourceRoot":"","sources":["../../lib/session-events.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,GAAG,SAAS,CAMnF"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared text utilities for the dynamic tiered compression engine and the
|
|
3
|
+
* topic-boundary scanner. Pure functions only — everything here must stay
|
|
4
|
+
* deterministic so folded output and digests are stable across requests.
|
|
5
|
+
*/
|
|
6
|
+
export declare function tokenize(text: string): Set<string>;
|
|
7
|
+
export declare function jaccard(a: Set<string>, b: Set<string>): number;
|
|
8
|
+
/**
|
|
9
|
+
* Cheap deterministic token estimate: CJK characters count ~0.7 tokens each,
|
|
10
|
+
* everything else ~0.25 (the standard chars/4 approximation). Precise enough
|
|
11
|
+
* for budget decisions — the escalation loop re-measures after every level.
|
|
12
|
+
*/
|
|
13
|
+
export declare function estimateTokens(text: string): number;
|
|
14
|
+
/** djb2 string hash — stable digest cache keys without storing content. */
|
|
15
|
+
export declare function hashString(text: string): string;
|
|
16
|
+
export declare function firstLine(text: string, maxChars: number): string;
|
|
17
|
+
export declare function truncateMiddle(text: string, keepChars: number, note: string): string;
|
|
18
|
+
export declare function extractTextParts(parts: unknown[]): string;
|
|
19
|
+
//# sourceMappingURL=text.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../lib/text.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAiBlD;AAED,wBAAgB,OAAO,CAAC,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,MAAM,CAO9D;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CASnD;AAED,2EAA2E;AAC3E,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAM/C;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAGhE;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAKpF;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,MAAM,CAazD"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@lexwdex-org/opencode-dcp",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "5.0.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Semantic pruning for OpenCode native context compaction",
|
|
7
7
|
"main": "./dist/index.js",
|
|
@@ -26,8 +26,7 @@
|
|
|
26
26
|
"typecheck": "tsc --noEmit",
|
|
27
27
|
"test": "node --import tsx --test tests/*.test.ts",
|
|
28
28
|
"format": "prettier --write .",
|
|
29
|
-
"format:check": "prettier --check ."
|
|
30
|
-
"dcp": "tsx scripts/print.ts"
|
|
29
|
+
"format:check": "prettier --check ."
|
|
31
30
|
},
|
|
32
31
|
"keywords": [
|
|
33
32
|
"opencode",
|
package/dist/lib/auto-prune.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { AutoPruneConfig } from "./config";
|
|
2
|
-
export type PruneSignal = "topic-drift" | "volume" | "idle-gap";
|
|
3
|
-
export interface ObserveResult {
|
|
4
|
-
signals: PruneSignal[];
|
|
5
|
-
}
|
|
6
|
-
export declare function tokenize(text: string): Set<string>;
|
|
7
|
-
export declare function jaccard(a: Set<string>, b: Set<string>): number;
|
|
8
|
-
export declare class AutoPruner {
|
|
9
|
-
private readonly config;
|
|
10
|
-
private readonly sessions;
|
|
11
|
-
private readonly now;
|
|
12
|
-
constructor(config: AutoPruneConfig, now?: () => number);
|
|
13
|
-
observeUserMessage(sessionID: string, parts: unknown[], at?: number): ObserveResult;
|
|
14
|
-
consumePending(sessionID: string, at?: number): PruneSignal[] | null;
|
|
15
|
-
markPruned(sessionID: string, at?: number): void;
|
|
16
|
-
dropSession(sessionID: string): void;
|
|
17
|
-
private evaluate;
|
|
18
|
-
private state;
|
|
19
|
-
}
|
|
20
|
-
//# sourceMappingURL=auto-prune.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auto-prune.d.ts","sourceRoot":"","sources":["../../lib/auto-prune.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE/C,MAAM,MAAM,WAAW,GAAG,aAAa,GAAG,QAAQ,GAAG,UAAU,CAAA;AAE/D,MAAM,WAAW,aAAa;IAC1B,OAAO,EAAE,WAAW,EAAE,CAAA;CACzB;AAUD,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAiBlD;AAED,wBAAgB,OAAO,CAAC,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,MAAM,CAO9D;AAwBD,qBAAa,UAAU;IAKf,OAAO,CAAC,QAAQ,CAAC,MAAM;IAJ3B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAkC;IAC3D,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAc;gBAGb,MAAM,EAAE,eAAe,EACxC,GAAG,CAAC,EAAE,MAAM,MAAM;IAKtB,kBAAkB,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,SAAa,GAAG,aAAa;IAoBvF,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,SAAa,GAAG,WAAW,EAAE,GAAG,IAAI;IAUxE,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,SAAa,GAAG,IAAI;IASpD,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAIpC,OAAO,CAAC,QAAQ;IA8BhB,OAAO,CAAC,KAAK;CAYhB"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export declare const COMPACTION = "\u4F60\u6B63\u5728\u751F\u6210\u5F53\u524D\u4F1A\u8BDD\u552F\u4E00\u7684\u6EDA\u52A8\u68C0\u67E5\u70B9\u3002\u8F93\u51FA\u5C06\u66FF\u4EE3\u65E7\u5BF9\u8BDD\u524D\u7F00\uFF0C\u6210\u4E3A\u540E\u7EED\u6A21\u578B\u770B\u5230\u7684\u7B2C\u4E00\u6BB5\u4E0A\u4E0B\u6587\uFF1BOpenCode \u4F1A\u5728\u5B83\u540E\u9762\u4FDD\u7559\u5C1A\u672A\u538B\u7F29\u7684\u8FD1\u671F\u5C3E\u90E8\u3002\u7CFB\u7EDF\u7EA7\u5185\u5BB9\uFF08AGENTS.md\u3001\u9879\u76EE\u89C4\u5219\u7B49\uFF09\u7531 OpenCode \u5728\u6BCF\u6B21\u8BF7\u6C42\u65F6\u72EC\u7ACB\u6CE8\u5165\uFF0C\u4E0D\u5C5E\u4E8E\u538B\u7F29\u8303\u56F4\uFF0C\u4E0D\u8981\u590D\u8FF0\u5B83\u4EEC\u3002\n\n\u8FD9\u4E0D\u662F\u804A\u5929\u8BB0\u5F55\u6458\u8981\uFF0C\u800C\u662F\u53EF\u76F4\u63A5\u7EE7\u7EED\u5DE5\u4F5C\u7684\u8BED\u4E49\u526A\u679D\u7ED3\u679C\u3002\u6309\u4EE5\u4E0B\u89C4\u5219\u538B\u7F29\uFF1A\n\n1. \u5982\u679C\u8F93\u5165\u542B\u6709\u4E0A\u4E00\u4EFD\u68C0\u67E5\u70B9\uFF0C\u628A\u4ECD\u6709\u6548\u7684\u4FE1\u606F\u5408\u5E76\u8FDB\u65B0\u68C0\u67E5\u70B9\uFF1B\u4E0D\u8981\u5D4C\u5957\u3001\u5F15\u7528\u6216\u91CD\u590D\u65E7\u68C0\u67E5\u70B9\u3002\n2. \u5220\u9664\u65E0\u5173\u95F2\u804A\u3001\u5176\u4ED6\u9879\u76EE\u6216\u5176\u4ED6\u4ED3\u5E93\u7684\u5BF9\u8BDD\u3001\u91CD\u590D\u89E3\u91CA\u3001\u5DF2\u7ECF\u63A8\u7FFB\u4E14\u4E0D\u518D\u6709\u8BCA\u65AD\u4EF7\u503C\u7684\u65B9\u6848\u3002\n3. \u591A\u6B21\u5DE5\u5177\u8C03\u7528\u8BD5\u9519\u6216\u5931\u8D25\u540E\u6210\u529F\u65F6\uFF0C\u53EA\u4FDD\u7559\u6700\u7EC8\u6210\u529F\u7ED3\u679C\uFF1B\u4EC5\u5F53\u6839\u56E0\u4F1A\u5F71\u54CD\u540E\u7EED\u5DE5\u4F5C\u65F6\u4FDD\u7559\u4E00\u6B21\u7B80\u77ED\u5931\u8D25\u539F\u56E0\u3002\n4. \u540C\u4E00\u5185\u5BB9\u6216\u6587\u4EF6\u88AB\u91CD\u590D\u7F16\u8F91\u65F6\uFF0C\u53EA\u4FDD\u7559\u6700\u7EC8\u72B6\u6001\u3001\u4ECD\u6709\u6548\u7684\u5173\u952E\u51B3\u7B56\u548C\u5FC5\u8981\u7406\u7531\uFF0C\u4E0D\u590D\u8FF0\u6BCF\u8F6E\u4FEE\u6539\u3002\n5. \u6309\u65F6\u95F4\u5206\u5C42\u51B3\u5B9A\u538B\u7F29\u6DF1\u5EA6\uFF1A\u65E9\u671F\u5386\u53F2\u548C\u4E2D\u90E8\u5386\u53F2\u9AD8\u5EA6\u538B\u7F29\u2014\u2014\u6BCF\u4E2A\u4E3B\u9898\u53EA\u7559\u4E00\u53E5\u8BDD\u7ED3\u8BBA\uFF0C\u4E0D\u7559\u8FC7\u7A0B\uFF1B\u6700\u8FD1\u5386\u53F2\u8F7B\u5EA6\u538B\u7F29\u2014\u2014\u5C24\u5176\u662F\u4E0E\u5F53\u524D\u4EFB\u52A1\u76F8\u5173\u7684\u5185\u5BB9\uFF0C\u4FDD\u7559\u7EE7\u7EED\u5DE5\u4F5C\u6240\u9700\u7684\u5173\u952E\u7EC6\u8282\uFF08\u6587\u4EF6\u8DEF\u5F84\u3001\u63A5\u53E3\u3001\u547D\u4EE4\u3001\u6D4B\u8BD5\u7ED3\u679C\u3001\u9519\u8BEF\u4E8B\u5B9E\u3001\u4ECD\u6709\u6548\u7684\u51B3\u7B56\u53CA\u7406\u7531\uFF09\uFF0C\u53EA\u6298\u53E0\u91CD\u590D\u4E0E\u5DF2\u5931\u6548\u7684\u5185\u5BB9\u3002\u6700\u8FD1\u5386\u53F2\u6307\u81EA\u4E0A\u4E00\u4EFD\u68C0\u67E5\u70B9\u4EE5\u6765\u7684\u65B0\u5185\u5BB9\u3002\n\n\u4F7F\u7528\u4EE5\u4E0B\u56FA\u5B9A\u7ED3\u6784\uFF0C\u7701\u7565\u786E\u5B9E\u4E3A\u7A7A\u7684\u6761\u76EE\uFF1A\n\n## \u5386\u53F2\u6982\u8981\n\u65E9\u671F\u4E0E\u4E2D\u90E8\u5386\u53F2\u7684\u4E3B\u9898\u548C\u80CC\u666F\uFF0C\u6BCF\u9879\u4E00\u53E5\u8BDD\u7ED3\u8BBA\uFF1B\u8FDC\u671F\u5DF2\u5B8C\u6210\u4EFB\u52A1\u5F52\u5165\u6B64\u5904\uFF0C\u4E0D\u542B\u6267\u884C\u8FC7\u7A0B\u3002\n\n## \u5DF2\u5B8C\u6210\u4EFB\u52A1\u7684\u6982\u62EC\n\u6700\u8FD1\u7684\u5DF2\u5B8C\u6210\u4EFB\u52A1\uFF0C\u6BCF\u4E2A\u4EFB\u52A1\u4E00\u53E5\u8BDD\u6982\u62EC\u5176\u7ED3\u679C\u4E0E\u5173\u952E\u4EA7\u51FA\u3002\n\n## \u8FDB\u884C\u4E2D\u4EFB\u52A1\u8BE6\u60C5\n\u5F53\u524D\u6B63\u5728\u8FDB\u884C\u7684\u4EFB\u52A1\u9010\u9879\u5199\u6E05\uFF1A\u76EE\u6807\u3001\u5DF2\u5B8C\u6210\u6B65\u9AA4\u3001\u6D89\u53CA\u6587\u4EF6\u8DEF\u5F84\u4E0E\u63A5\u53E3\u3001\u5173\u952E\u51B3\u7B56\u3001\u9047\u5230\u7684\u963B\u585E\u3001\u4E0B\u4E00\u6B65\u5177\u4F53\u52A8\u4F5C\u3002\u672C\u8282\u5C5E\u4E8E\u8F7B\u5EA6\u538B\u7F29\u533A\uFF0C\u5B81\u53EF\u591A\u4FDD\u7559\u7EC6\u8282\uFF0C\u4E0D\u505A\u4E8C\u6B21\u63A8\u65AD\u3002\n\n## \u672A\u89E3\u51B3\u95EE\u9898\n\u8DE8\u4EFB\u52A1\u7684\u9057\u7559\u98CE\u9669\u548C\u5F85\u786E\u8BA4\u4E8B\u9879\u3002\u53EA\u5199\u672A\u5728\u300C\u8FDB\u884C\u4E2D\u4EFB\u52A1\u8BE6\u60C5\u300D\u4E2D\u51FA\u73B0\u7684\u5185\u5BB9\uFF0C\u907F\u514D\u4E0E\u8BE5\u8282\u91CD\u590D\u3002\n\n\u4FDD\u6301\u5177\u4F53\u3001\u53EF\u9A8C\u8BC1\u548C\u9879\u76EE\u5185\u805A\u3002\u8FDB\u884C\u4E2D\u7684\u4EFB\u52A1\u5FC5\u987B\u80FD\u51ED\u68C0\u67E5\u70B9\u76F4\u63A5\u7EE7\u7EED\uFF0C\u4E0D\u8981\u4F9D\u8D56\u5DF2\u88AB\u538B\u7F29\u6389\u7684\u4E2D\u95F4\u8FC7\u7A0B\u3002\u4FDD\u7559\u6587\u4EF6\u8DEF\u5F84\u3001\u63A5\u53E3\u3001\u547D\u4EE4\u3001\u6D4B\u8BD5\u7ED3\u679C\u548C\u9519\u8BEF\u4E8B\u5B9E\u7B49\u786C\u4E8B\u5B9E\uFF0C\u4F46\u4E0D\u8981\u4FDD\u7559\u6D88\u606F ID\u3001\u5757 ID\u3001\u951A\u70B9\u3001\u5360\u4F4D\u7B26\u3001\u63A7\u5236\u6807\u7B7E\u6216\u8FC7\u7A0B\u6027\u804A\u5929\u3002";
|
|
2
|
-
export declare const COMPACTION_EN = "You are generating the single rolling checkpoint for this session. Your output will replace the old conversation prefix as the first context the model sees afterwards; OpenCode keeps an uncompacted recent tail right after it. System-level content (AGENTS.md, project rules, etc.) is injected independently by OpenCode on every request and is not part of compaction; do not restate it.\n\nThis is not a chat-log summary but a semantic pruning result one can resume working from directly. Compress by these rules:\n\n1. If the input contains a previous checkpoint, merge the still-valid information into the new checkpoint; do not nest, quote, or duplicate the old one.\n2. Remove irrelevant chitchat, conversations about other projects or repositories, repeated explanations, and approaches that were overturned and no longer carry diagnostic value.\n3. When repeated tool trial-and-error ends in success, keep only the final successful outcome; retain one brief failure reason only if the root cause affects future work.\n4. When the same content or file was edited repeatedly, keep only the final state, the still-valid key decisions, and the necessary rationale; do not restate each round of edits.\n5. Choose compression depth by recency tiers: early and middle history are compressed heavily\u2014one concluding sentence per topic, no process detail; recent history is compressed lightly\u2014especially content related to the current task, keeping the key details needed to continue (file paths, interfaces, commands, test results, error facts, still-valid decisions and their rationale), folding only duplicates and invalidated content. Recent history means everything generated since the previous checkpoint.\n\nUse the following fixed structure, omitting sections that are truly empty:\n\n## History Overview\nTopics and background from early and middle history, one concluding sentence each; long-completed tasks belong here, without execution process.\n\n## Completed Task Summaries\nRecently completed tasks, one sentence per task covering its outcome and key outputs.\n\n## In-Progress Task Details\nFor the current task, itemize: goal, completed steps, file paths and interfaces involved, key decisions, blockers encountered, concrete next actions. This is the lightly-compressed zone; prefer keeping more detail and avoid second-order inference.\n\n## Unresolved Issues\nCross-task lingering risks and items awaiting confirmation. Only list items not already covered under In-Progress Task Details, to avoid duplication.\n\nStay specific, verifiable, and project-cohesive. An in-progress task must be resumable straight from this checkpoint, without relying on intermediate process that was pruned away. Keep hard facts such as file paths, interfaces, commands, test results, and error facts, but never message IDs, block IDs, anchors, placeholders, control tags, or procedural chatter.";
|
|
3
|
-
export declare function getCompactionPrompt(language?: string): string;
|
|
4
|
-
//# sourceMappingURL=compaction.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"compaction.d.ts","sourceRoot":"","sources":["../../../lib/prompts/compaction.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU,wwJAwBsF,CAAA;AAE7G,eAAO,MAAM,aAAa,y1FAwBiV,CAAA;AAE3W,wBAAgB,mBAAmB,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAE7D"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { Logger } from "../logger";
|
|
2
|
-
export interface RuntimePrompts {
|
|
3
|
-
compaction: string;
|
|
4
|
-
}
|
|
5
|
-
export declare class PromptStore {
|
|
6
|
-
private readonly logger;
|
|
7
|
-
private readonly customPromptsEnabled;
|
|
8
|
-
private readonly paths;
|
|
9
|
-
private readonly defaultPrompt;
|
|
10
|
-
private runtime;
|
|
11
|
-
private lastReloadAt;
|
|
12
|
-
constructor(logger: Logger, workingDirectory: string, customPromptsEnabled?: boolean, language?: string);
|
|
13
|
-
getRuntimePrompts(): RuntimePrompts;
|
|
14
|
-
reload(): void;
|
|
15
|
-
private ensureDefaults;
|
|
16
|
-
}
|
|
17
|
-
//# sourceMappingURL=store.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../lib/prompts/store.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAGvC,MAAM,WAAW,cAAc;IAC3B,UAAU,EAAE,MAAM,CAAA;CACrB;AA2CD,qBAAa,WAAW;IAOhB,OAAO,CAAC,QAAQ,CAAC,MAAM;IAEvB,OAAO,CAAC,QAAQ,CAAC,oBAAoB;IARzC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAa;IACnC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAQ;IACtC,OAAO,CAAC,OAAO,CAAgB;IAC/B,OAAO,CAAC,YAAY,CAAI;gBAGH,MAAM,EAAE,MAAM,EAC/B,gBAAgB,EAAE,MAAM,EACP,oBAAoB,UAAQ,EAC7C,QAAQ,CAAC,EAAE,MAAM;IASrB,iBAAiB,IAAI,cAAc;IAInC,MAAM,IAAI,IAAI;IAsBd,OAAO,CAAC,cAAc;CAiBzB"}
|