@tarquinen/opencode-dcp 0.3.16 → 0.3.18
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 +16 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -43
- package/dist/index.js.map +1 -1
- package/dist/lib/config.d.ts +1 -15
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +22 -95
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/deduplicator.d.ts +0 -34
- package/dist/lib/deduplicator.d.ts.map +1 -1
- package/dist/lib/deduplicator.js +1 -127
- package/dist/lib/deduplicator.js.map +1 -1
- package/dist/lib/display-utils.d.ts +9 -0
- package/dist/lib/display-utils.d.ts.map +1 -0
- package/dist/lib/display-utils.js +71 -0
- package/dist/lib/display-utils.js.map +1 -0
- package/dist/lib/janitor.d.ts +2 -61
- package/dist/lib/janitor.d.ts.map +1 -1
- package/dist/lib/janitor.js +53 -195
- package/dist/lib/janitor.js.map +1 -1
- package/dist/lib/logger.d.ts +0 -24
- package/dist/lib/logger.d.ts.map +1 -1
- package/dist/lib/logger.js +3 -58
- package/dist/lib/logger.js.map +1 -1
- package/dist/lib/model-selector.d.ts +0 -31
- package/dist/lib/model-selector.d.ts.map +1 -1
- package/dist/lib/model-selector.js +0 -55
- package/dist/lib/model-selector.js.map +1 -1
- package/dist/lib/prompt.d.ts.map +1 -1
- package/dist/lib/prompt.js +3 -29
- package/dist/lib/prompt.js.map +1 -1
- package/dist/lib/tokenizer.d.ts +0 -23
- package/dist/lib/tokenizer.d.ts.map +1 -1
- package/dist/lib/tokenizer.js +0 -25
- package/dist/lib/tokenizer.js.map +1 -1
- package/dist/lib/version-checker.d.ts +0 -15
- package/dist/lib/version-checker.d.ts.map +1 -1
- package/dist/lib/version-checker.js +1 -19
- package/dist/lib/version-checker.js.map +1 -1
- package/package.json +1 -1
package/dist/lib/prompt.js
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Minimize message structure for AI analysis - keep only what's needed
|
|
3
|
-
* to determine if tool calls are obsolete
|
|
4
|
-
* Also replaces callIDs of already-pruned tools with "<already-pruned>"
|
|
5
|
-
* and protected tools with "<protected>"
|
|
6
|
-
*/
|
|
7
1
|
function minimizeMessages(messages, alreadyPrunedIds, protectedToolCallIds) {
|
|
8
2
|
const prunedIdsSet = alreadyPrunedIds ? new Set(alreadyPrunedIds.map(id => id.toLowerCase())) : new Set();
|
|
9
3
|
const protectedIdsSet = protectedToolCallIds ? new Set(protectedToolCallIds.map(id => id.toLowerCase())) : new Set();
|
|
@@ -11,20 +5,16 @@ function minimizeMessages(messages, alreadyPrunedIds, protectedToolCallIds) {
|
|
|
11
5
|
const minimized = {
|
|
12
6
|
role: msg.info?.role
|
|
13
7
|
};
|
|
14
|
-
// Keep essential parts only
|
|
15
8
|
if (msg.parts) {
|
|
16
9
|
minimized.parts = msg.parts
|
|
17
10
|
.filter((part) => {
|
|
18
|
-
// Completely remove step markers - they add no value for janitor
|
|
19
11
|
if (part.type === 'step-start' || part.type === 'step-finish') {
|
|
20
12
|
return false;
|
|
21
13
|
}
|
|
22
14
|
return true;
|
|
23
15
|
})
|
|
24
16
|
.map((part) => {
|
|
25
|
-
// For text parts, keep the text content (needed for user intent & retention requests)
|
|
26
17
|
if (part.type === 'text') {
|
|
27
|
-
// Filter out ignored messages (e.g., DCP summary UI messages)
|
|
28
18
|
if (part.ignored) {
|
|
29
19
|
return null;
|
|
30
20
|
}
|
|
@@ -33,7 +23,6 @@ function minimizeMessages(messages, alreadyPrunedIds, protectedToolCallIds) {
|
|
|
33
23
|
text: part.text
|
|
34
24
|
};
|
|
35
25
|
}
|
|
36
|
-
// For tool parts, keep what's needed for pruning decisions
|
|
37
26
|
if (part.type === 'tool') {
|
|
38
27
|
const callIDLower = part.callID?.toLowerCase();
|
|
39
28
|
const isAlreadyPruned = prunedIdsSet.has(callIDLower);
|
|
@@ -50,56 +39,41 @@ function minimizeMessages(messages, alreadyPrunedIds, protectedToolCallIds) {
|
|
|
50
39
|
toolCallID: displayCallID,
|
|
51
40
|
tool: part.tool
|
|
52
41
|
};
|
|
53
|
-
// Keep the actual output - janitor needs to see what was returned
|
|
54
42
|
if (part.state?.output) {
|
|
55
43
|
toolPart.output = part.state.output;
|
|
56
44
|
}
|
|
57
|
-
// Include minimal input for deduplication context
|
|
58
|
-
// Only keep resource identifiers, not full nested structures
|
|
59
45
|
if (part.state?.input) {
|
|
60
46
|
const input = part.state.input;
|
|
61
|
-
// For write/edit tools, keep file path AND content (what was changed matters)
|
|
62
|
-
// These tools: write, edit, multiedit, patch
|
|
63
47
|
if (input.filePath && (part.tool === 'write' || part.tool === 'edit' || part.tool === 'multiedit' || part.tool === 'patch')) {
|
|
64
|
-
toolPart.input = input;
|
|
48
|
+
toolPart.input = input;
|
|
65
49
|
}
|
|
66
|
-
// For read-only file operations, just keep the file path
|
|
67
50
|
else if (input.filePath) {
|
|
68
51
|
toolPart.input = { filePath: input.filePath };
|
|
69
52
|
}
|
|
70
|
-
// For batch operations, summarize instead of full array
|
|
71
53
|
else if (input.tool_calls && Array.isArray(input.tool_calls)) {
|
|
72
54
|
toolPart.input = {
|
|
73
55
|
batch_summary: `${input.tool_calls.length} tool calls`,
|
|
74
56
|
tools: input.tool_calls.map((tc) => tc.tool)
|
|
75
57
|
};
|
|
76
58
|
}
|
|
77
|
-
// For other operations, keep minimal input
|
|
78
59
|
else {
|
|
79
60
|
toolPart.input = input;
|
|
80
61
|
}
|
|
81
62
|
}
|
|
82
63
|
return toolPart;
|
|
83
64
|
}
|
|
84
|
-
// Skip all other part types (they're not relevant to pruning)
|
|
85
65
|
return null;
|
|
86
66
|
})
|
|
87
|
-
.filter(Boolean);
|
|
67
|
+
.filter(Boolean);
|
|
88
68
|
}
|
|
89
69
|
return minimized;
|
|
90
70
|
}).filter(msg => {
|
|
91
|
-
// Filter out messages that have no parts (e.g., only contained ignored messages)
|
|
92
71
|
return msg.parts && msg.parts.length > 0;
|
|
93
72
|
});
|
|
94
73
|
}
|
|
95
|
-
export function buildAnalysisPrompt(unprunedToolCallIds, messages, alreadyPrunedIds, protectedToolCallIds, reason
|
|
96
|
-
) {
|
|
97
|
-
// Minimize messages to reduce token usage, passing already-pruned and protected IDs for replacement
|
|
74
|
+
export function buildAnalysisPrompt(unprunedToolCallIds, messages, alreadyPrunedIds, protectedToolCallIds, reason) {
|
|
98
75
|
const minimizedMessages = minimizeMessages(messages, alreadyPrunedIds, protectedToolCallIds);
|
|
99
|
-
// Stringify with pretty-printing, then replace escaped newlines with actual newlines
|
|
100
|
-
// This makes the logged prompts much more readable
|
|
101
76
|
const messagesJson = JSON.stringify(minimizedMessages, null, 2).replace(/\\n/g, '\n');
|
|
102
|
-
// Build optional context section if reason provided
|
|
103
77
|
const reasonContext = reason
|
|
104
78
|
? `\nContext: The AI has requested pruning with the following reason: "${reason}"\nUse this context to inform your decisions about what is most relevant to keep.`
|
|
105
79
|
: '';
|
package/dist/lib/prompt.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../lib/prompt.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../lib/prompt.ts"],"names":[],"mappings":"AAAA,SAAS,gBAAgB,CAAC,QAAe,EAAE,gBAA2B,EAAE,oBAA+B;IACnG,MAAM,YAAY,GAAG,gBAAgB,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,gBAAgB,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,EAAE,CAAA;IACzG,MAAM,eAAe,GAAG,oBAAoB,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,oBAAoB,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC,CAA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I,CAAA;YACf,CAAC,CAAC;iBACD,MAAM,CAAC,OAAO,CAAC,CAAA;QACxB,CAAC;QAED,OAAO,SAAS,CAAA;IACpB,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE;QACZ,OAAO,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAA;IAC5C,CAAC,CAAC,CAAA;AACN,CAAC;AAED,MAAM,UAAU,mBAAmB,CAC/B,mBAA6B,EAC7B,QAAe,EACf,gBAA2B,EAC3B,oBAA+B,EAC/B,MAAe;IAEf,MAAM,iBAAiB,GAAG,gBAAgB,CAAC,QAAQ,EAAE,gBAAgB,EAAE,oBAAoB,CAAC,CAAA;IAE5F,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,CAAC,iBAAiB,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IAErF,MAAM,aAAa,GAAG,MAAM;QACxB,CAAC,CAAC,uEAAuE,MAAM,mFAAmF;QAClK,CAAC,CAAC,EAAE,CAAA;IAER,OAAO;EACT,aAAa;;;;;;;;;;;;;mDAaoC,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC;;;;;;;;;EAS/E,YAAY;;;;;;EAMZ,CAAA;AACF,CAAC"}
|
package/dist/lib/tokenizer.d.ts
CHANGED
|
@@ -1,26 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Token counting utilities using gpt-tokenizer
|
|
3
|
-
*
|
|
4
|
-
* Uses gpt-tokenizer to provide token counts for text content.
|
|
5
|
-
* Works with any LLM provider - provides accurate counts for OpenAI models
|
|
6
|
-
* and reasonable approximations for other providers.
|
|
7
|
-
*
|
|
8
|
-
* NOTE: gpt-tokenizer is lazily imported to avoid loading the 53MB package
|
|
9
|
-
* during plugin initialization. The package is only loaded when tokenization
|
|
10
|
-
* is actually needed.
|
|
11
|
-
*/
|
|
12
|
-
/**
|
|
13
|
-
* Batch estimates tokens for multiple text samples
|
|
14
|
-
*
|
|
15
|
-
* @param texts - Array of text strings to tokenize
|
|
16
|
-
* @returns Array of token counts
|
|
17
|
-
*/
|
|
18
1
|
export declare function estimateTokensBatch(texts: string[]): Promise<number[]>;
|
|
19
|
-
/**
|
|
20
|
-
* Formats token count for display (e.g., 1500 -> "1.5K", 50 -> "50")
|
|
21
|
-
*
|
|
22
|
-
* @param tokens - Number of tokens
|
|
23
|
-
* @returns Formatted string
|
|
24
|
-
*/
|
|
25
2
|
export declare function formatTokenCount(tokens: number): string;
|
|
26
3
|
//# sourceMappingURL=tokenizer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokenizer.d.ts","sourceRoot":"","sources":["../../lib/tokenizer.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"tokenizer.d.ts","sourceRoot":"","sources":["../../lib/tokenizer.ts"],"names":[],"mappings":"AAAA,wBAAsB,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAO5E;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAKvD"}
|
package/dist/lib/tokenizer.js
CHANGED
|
@@ -1,37 +1,12 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Token counting utilities using gpt-tokenizer
|
|
3
|
-
*
|
|
4
|
-
* Uses gpt-tokenizer to provide token counts for text content.
|
|
5
|
-
* Works with any LLM provider - provides accurate counts for OpenAI models
|
|
6
|
-
* and reasonable approximations for other providers.
|
|
7
|
-
*
|
|
8
|
-
* NOTE: gpt-tokenizer is lazily imported to avoid loading the 53MB package
|
|
9
|
-
* during plugin initialization. The package is only loaded when tokenization
|
|
10
|
-
* is actually needed.
|
|
11
|
-
*/
|
|
12
|
-
/**
|
|
13
|
-
* Batch estimates tokens for multiple text samples
|
|
14
|
-
*
|
|
15
|
-
* @param texts - Array of text strings to tokenize
|
|
16
|
-
* @returns Array of token counts
|
|
17
|
-
*/
|
|
18
1
|
export async function estimateTokensBatch(texts) {
|
|
19
2
|
try {
|
|
20
|
-
// Lazy import - only load the 53MB gpt-tokenizer package when actually needed
|
|
21
3
|
const { encode } = await import('gpt-tokenizer');
|
|
22
4
|
return texts.map(text => encode(text).length);
|
|
23
5
|
}
|
|
24
6
|
catch {
|
|
25
|
-
// Fallback to character-based estimation if tokenizer fails
|
|
26
7
|
return texts.map(text => Math.round(text.length / 4));
|
|
27
8
|
}
|
|
28
9
|
}
|
|
29
|
-
/**
|
|
30
|
-
* Formats token count for display (e.g., 1500 -> "1.5K", 50 -> "50")
|
|
31
|
-
*
|
|
32
|
-
* @param tokens - Number of tokens
|
|
33
|
-
* @returns Formatted string
|
|
34
|
-
*/
|
|
35
10
|
export function formatTokenCount(tokens) {
|
|
36
11
|
if (tokens >= 1000) {
|
|
37
12
|
return `${(tokens / 1000).toFixed(1)}K`.replace('.0K', 'K');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokenizer.js","sourceRoot":"","sources":["../../lib/tokenizer.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"tokenizer.js","sourceRoot":"","sources":["../../lib/tokenizer.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,KAAe;IACrD,IAAI,CAAC;QACD,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,MAAM,CAAC,eAAe,CAAC,CAAA;QAChD,OAAO,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAA;IACjD,CAAC;IAAC,MAAM,CAAC;QACL,OAAO,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAA;IACzD,CAAC;AACL,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,MAAc;IAC3C,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;QACjB,OAAO,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;IAC/D,CAAC;IACD,OAAO,MAAM,CAAC,QAAQ,EAAE,CAAA;AAC5B,CAAC"}
|
|
@@ -1,23 +1,8 @@
|
|
|
1
1
|
export declare const PACKAGE_NAME = "@tarquinen/opencode-dcp";
|
|
2
2
|
export declare const NPM_REGISTRY_URL = "https://registry.npmjs.org/@tarquinen/opencode-dcp/latest";
|
|
3
|
-
/**
|
|
4
|
-
* Gets the local package version from package.json
|
|
5
|
-
* Note: In compiled output, this file is at dist/lib/version-checker.js
|
|
6
|
-
* so we need to go up two levels to reach package.json
|
|
7
|
-
*/
|
|
8
3
|
export declare function getLocalVersion(): string;
|
|
9
|
-
/**
|
|
10
|
-
* Fetches the latest version from npm registry
|
|
11
|
-
*/
|
|
12
4
|
export declare function getNpmVersion(): Promise<string | null>;
|
|
13
|
-
/**
|
|
14
|
-
* Compares semver versions. Returns true if remote > local
|
|
15
|
-
*/
|
|
16
5
|
export declare function isOutdated(local: string, remote: string): boolean;
|
|
17
|
-
/**
|
|
18
|
-
* Checks for updates and shows a toast if outdated.
|
|
19
|
-
* Fire-and-forget: does not throw, logs errors silently.
|
|
20
|
-
*/
|
|
21
6
|
export declare function checkForUpdates(client: any, logger?: {
|
|
22
7
|
info: (component: string, message: string, data?: any) => void;
|
|
23
8
|
}): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version-checker.d.ts","sourceRoot":"","sources":["../../lib/version-checker.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"version-checker.d.ts","sourceRoot":"","sources":["../../lib/version-checker.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,YAAY,4BAA4B,CAAA;AACrD,eAAO,MAAM,gBAAgB,8DAAsD,CAAA;AAKnF,wBAAgB,eAAe,IAAI,MAAM,CAQxC;AAED,wBAAsB,aAAa,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAiB5D;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAWjE;AAED,wBAAsB,eAAe,CAAC,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,EAAE;IAAE,IAAI,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,KAAK,IAAI,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CA2B7I"}
|
|
@@ -1,17 +1,10 @@
|
|
|
1
|
-
// version-checker.ts - Checks for DCP updates on npm and shows toast notification
|
|
2
1
|
import { readFileSync } from 'fs';
|
|
3
2
|
import { join, dirname } from 'path';
|
|
4
3
|
import { fileURLToPath } from 'url';
|
|
5
4
|
export const PACKAGE_NAME = '@tarquinen/opencode-dcp';
|
|
6
5
|
export const NPM_REGISTRY_URL = `https://registry.npmjs.org/${PACKAGE_NAME}/latest`;
|
|
7
|
-
// ESM-compatible __dirname
|
|
8
6
|
const __filename = fileURLToPath(import.meta.url);
|
|
9
7
|
const __dirname = dirname(__filename);
|
|
10
|
-
/**
|
|
11
|
-
* Gets the local package version from package.json
|
|
12
|
-
* Note: In compiled output, this file is at dist/lib/version-checker.js
|
|
13
|
-
* so we need to go up two levels to reach package.json
|
|
14
|
-
*/
|
|
15
8
|
export function getLocalVersion() {
|
|
16
9
|
try {
|
|
17
10
|
const pkgPath = join(__dirname, '../../package.json');
|
|
@@ -22,13 +15,10 @@ export function getLocalVersion() {
|
|
|
22
15
|
return '0.0.0';
|
|
23
16
|
}
|
|
24
17
|
}
|
|
25
|
-
/**
|
|
26
|
-
* Fetches the latest version from npm registry
|
|
27
|
-
*/
|
|
28
18
|
export async function getNpmVersion() {
|
|
29
19
|
try {
|
|
30
20
|
const controller = new AbortController();
|
|
31
|
-
const timeout = setTimeout(() => controller.abort(), 5000);
|
|
21
|
+
const timeout = setTimeout(() => controller.abort(), 5000);
|
|
32
22
|
const res = await fetch(NPM_REGISTRY_URL, {
|
|
33
23
|
signal: controller.signal,
|
|
34
24
|
headers: { 'Accept': 'application/json' }
|
|
@@ -43,9 +33,6 @@ export async function getNpmVersion() {
|
|
|
43
33
|
return null;
|
|
44
34
|
}
|
|
45
35
|
}
|
|
46
|
-
/**
|
|
47
|
-
* Compares semver versions. Returns true if remote > local
|
|
48
|
-
*/
|
|
49
36
|
export function isOutdated(local, remote) {
|
|
50
37
|
const parseVersion = (v) => v.split('.').map(n => parseInt(n, 10) || 0);
|
|
51
38
|
const [localParts, remoteParts] = [parseVersion(local), parseVersion(remote)];
|
|
@@ -59,10 +46,6 @@ export function isOutdated(local, remote) {
|
|
|
59
46
|
}
|
|
60
47
|
return false;
|
|
61
48
|
}
|
|
62
|
-
/**
|
|
63
|
-
* Checks for updates and shows a toast if outdated.
|
|
64
|
-
* Fire-and-forget: does not throw, logs errors silently.
|
|
65
|
-
*/
|
|
66
49
|
export async function checkForUpdates(client, logger) {
|
|
67
50
|
try {
|
|
68
51
|
const local = getLocalVersion();
|
|
@@ -86,7 +69,6 @@ export async function checkForUpdates(client, logger) {
|
|
|
86
69
|
});
|
|
87
70
|
}
|
|
88
71
|
catch {
|
|
89
|
-
// Silently fail - version check is non-critical
|
|
90
72
|
}
|
|
91
73
|
}
|
|
92
74
|
//# sourceMappingURL=version-checker.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version-checker.js","sourceRoot":"","sources":["../../lib/version-checker.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"version-checker.js","sourceRoot":"","sources":["../../lib/version-checker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAA;AACjC,OAAO,EAAE,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,UAAU,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,CAAC;YAC1B,MAAM,EAAE,IAAI,CAAC,SAAS,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAA;YACrD,OAAM;QACV,CAAC;QAED,MAAM,EAAE,IAAI,CAAC,SAAS,EAAE,kBAAkB,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAA;QAE3D,MAAM,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC;YACvB,IAAI,EAAE;gBACF,KAAK,EAAE,uBAAuB;gBAC9B,OAAO,EAAE,IAAI,KAAK,OAAO,GAAG,4BAA4B,YAAY,IAAI,GAAG,EAAE;gBAC7E,OAAO,EAAE,MAAM;gBACf,QAAQ,EAAE,IAAI;aACjB;SACJ,CAAC,CAAA;IACN,CAAC;IAAC,MAAM,CAAC;IACT,CAAC;AACL,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@tarquinen/opencode-dcp",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.18",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "OpenCode plugin that optimizes token usage by pruning obsolete tool outputs from conversation context",
|
|
7
7
|
"main": "./dist/index.js",
|