@serkanalgur/opencode-slim 1.1.0 → 1.3.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.md +59 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +338 -11
- package/dist/index.js.map +1 -1
- package/dist/lib/prompts.d.ts +1 -0
- package/dist/lib/prompts.d.ts.map +1 -1
- package/dist/lib/tui/commands.d.ts +14 -0
- package/dist/lib/tui/commands.d.ts.map +1 -0
- package/dist/lib/tui/data.d.ts +4 -0
- package/dist/lib/tui/data.d.ts.map +1 -0
- package/dist/lib/tui/dialogs.d.ts +8 -0
- package/dist/lib/tui/dialogs.d.ts.map +1 -0
- package/dist/lib/tui/modals.d.ts +5 -0
- package/dist/lib/tui/modals.d.ts.map +1 -0
- package/dist/lib/tui.d.ts +36 -0
- package/dist/lib/tui.d.ts.map +1 -0
- package/dist/tui.d.ts +7 -0
- package/dist/tui.d.ts.map +1 -0
- package/lib/tui/commands.ts +30 -0
- package/lib/tui/data.ts +90 -0
- package/lib/tui/dialogs.tsx +467 -0
- package/lib/tui/modals.tsx +12 -0
- package/package.json +34 -3
- package/tui.tsx +26 -0
package/dist/lib/prompts.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare function getSystemPrompt(isCompact?: boolean): string;
|
|
2
2
|
export declare function getCompressToolDescription(): string;
|
|
3
|
+
export declare function getPanelToolDescription(): string;
|
|
3
4
|
export declare function getNudgeMessage(reason: string, tokenCount: number, maxTokens: number): string;
|
|
4
5
|
//# sourceMappingURL=prompts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../lib/prompts.ts"],"names":[],"mappings":"AAiCA,wBAAgB,eAAe,CAAC,SAAS,GAAE,OAAe,GAAG,MAAM,CAElE;AAED,wBAAgB,0BAA0B,IAAI,MAAM,CAcnD;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAa7F"}
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../lib/prompts.ts"],"names":[],"mappings":"AAiCA,wBAAgB,eAAe,CAAC,SAAS,GAAE,OAAe,GAAG,MAAM,CAElE;AAED,wBAAgB,0BAA0B,IAAI,MAAM,CAcnD;AAED,wBAAgB,uBAAuB,IAAI,MAAM,CAWhD;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAa7F"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { TuiPluginApi } from "@opencode-ai/plugin/tui";
|
|
2
|
+
export interface SlimCommand {
|
|
3
|
+
title: string;
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
slashName: string;
|
|
7
|
+
run: () => void | Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Register slash commands with the OpenCode TUI.
|
|
11
|
+
* Uses the legacy api.command API for V1 compatibility.
|
|
12
|
+
*/
|
|
13
|
+
export declare function registerCommands(api: TuiPluginApi, commands: SlimCommand[]): void;
|
|
14
|
+
//# sourceMappingURL=commands.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../../lib/tui/commands.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAE3D,MAAM,WAAW,WAAW;IACxB,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,SAAS,EAAE,MAAM,CAAA;IACjB,GAAG,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CAClC;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE,GAAG,IAAI,CAejF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../lib/tui/data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AA2D1C,wBAAgB,UAAU,CAAC,IAAI,EAAE,YAAY,GAAG,UAAU,CA6BzD"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** @jsxImportSource @opentui/solid */
|
|
2
|
+
import type { TuiPluginApi } from "@opencode-ai/plugin/tui";
|
|
3
|
+
import type { SlimConfig } from "../types";
|
|
4
|
+
export declare function PanelDialog(props: {
|
|
5
|
+
api: TuiPluginApi;
|
|
6
|
+
config: SlimConfig;
|
|
7
|
+
}): any;
|
|
8
|
+
//# sourceMappingURL=dialogs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dialogs.d.ts","sourceRoot":"","sources":["../../../lib/tui/dialogs.tsx"],"names":[],"mappings":"AAAA,sCAAsC;AAGtC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AA0I1C,wBAAgB,WAAW,CAAC,KAAK,EAAE;IAAE,GAAG,EAAE,YAAY,CAAC;IAAC,MAAM,EAAE,UAAU,CAAA;CAAE,OA2E3E"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** @jsxImportSource @opentui/solid */
|
|
2
|
+
import type { TuiPluginApi } from "@opencode-ai/plugin/tui";
|
|
3
|
+
import type { SlimConfig } from "../types";
|
|
4
|
+
export declare function openPanelModal(api: TuiPluginApi, config: SlimConfig): void;
|
|
5
|
+
//# sourceMappingURL=modals.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modals.d.ts","sourceRoot":"","sources":["../../../lib/tui/modals.tsx"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAG1C,wBAAgB,cAAc,CAAC,GAAG,EAAE,YAAY,EAAE,MAAM,EAAE,UAAU,GAAG,IAAI,CAK1E"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { MessageWithParts, SessionState, SlimConfig, CompressionRecord } from "./types";
|
|
2
|
+
export interface PanelData {
|
|
3
|
+
sessionId: string;
|
|
4
|
+
timestamp: number;
|
|
5
|
+
currentTokens: number;
|
|
6
|
+
maxTokens: number;
|
|
7
|
+
usagePercent: number;
|
|
8
|
+
status: "healthy" | "warning" | "critical";
|
|
9
|
+
messageCount: number;
|
|
10
|
+
userMessages: number;
|
|
11
|
+
assistantMessages: number;
|
|
12
|
+
toolCalls: number;
|
|
13
|
+
toolResults: number;
|
|
14
|
+
tokensByRole: {
|
|
15
|
+
user: number;
|
|
16
|
+
assistant: number;
|
|
17
|
+
tools: number;
|
|
18
|
+
system: number;
|
|
19
|
+
};
|
|
20
|
+
compressionCount: number;
|
|
21
|
+
averageRatio: number;
|
|
22
|
+
totalTokensSaved: number;
|
|
23
|
+
lastCompression: CompressionRecord | null;
|
|
24
|
+
estimatedCost: number;
|
|
25
|
+
costSaved: number;
|
|
26
|
+
model: string;
|
|
27
|
+
topics: {
|
|
28
|
+
topic: string;
|
|
29
|
+
count: number;
|
|
30
|
+
tokens: number;
|
|
31
|
+
}[];
|
|
32
|
+
recommendations: string[];
|
|
33
|
+
}
|
|
34
|
+
export declare function buildPanelData(sessionId: string, messages: MessageWithParts[], state: SessionState, config: SlimConfig, modelId?: string): Promise<PanelData>;
|
|
35
|
+
export declare function renderPanel(data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AQ,EAAE,gBAAgB,EAAE,EAC5B,KAAK,EAAE,YAAY,EACnB,MAAM,EAAE,UAAU,EAClB,OAAO,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,SAAS,CAAC,CAoHpB;AAsED,wBAAgB,WAAW,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM,CAsEnD"}
|
package/dist/tui.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tui.d.ts","sourceRoot":"","sources":["../tui.tsx"],"names":[],"mappings":"AAAA,sCAAsC;;;;;AAsBtC,wBAG2B"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { TuiPluginApi } from "@opencode-ai/plugin/tui"
|
|
2
|
+
|
|
3
|
+
export interface SlimCommand {
|
|
4
|
+
title: string
|
|
5
|
+
name: string
|
|
6
|
+
description: string
|
|
7
|
+
slashName: string
|
|
8
|
+
run: () => void | Promise<void>
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Register slash commands with the OpenCode TUI.
|
|
13
|
+
* Uses the legacy api.command API for V1 compatibility.
|
|
14
|
+
*/
|
|
15
|
+
export function registerCommands(api: TuiPluginApi, commands: SlimCommand[]): void {
|
|
16
|
+
if (!api.command) return
|
|
17
|
+
|
|
18
|
+
api.command.register(() =>
|
|
19
|
+
commands.map((cmd) => ({
|
|
20
|
+
title: cmd.title,
|
|
21
|
+
value: cmd.name,
|
|
22
|
+
description: cmd.description,
|
|
23
|
+
category: "Slim",
|
|
24
|
+
slash: {
|
|
25
|
+
name: cmd.slashName,
|
|
26
|
+
},
|
|
27
|
+
onSelect: () => cmd.run(),
|
|
28
|
+
})),
|
|
29
|
+
)
|
|
30
|
+
}
|
package/lib/tui/data.ts
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { TuiPluginApi } from "@opencode-ai/plugin/tui"
|
|
2
|
+
import type { SlimConfig } from "../types"
|
|
3
|
+
import { readFileSync, existsSync } from "fs"
|
|
4
|
+
import { join } from "path"
|
|
5
|
+
import { homedir } from "os"
|
|
6
|
+
import { parse } from "jsonc-parser/lib/esm/main.js"
|
|
7
|
+
|
|
8
|
+
const DEFAULT_CONFIG: SlimConfig = {
|
|
9
|
+
enabled: true,
|
|
10
|
+
debug: false,
|
|
11
|
+
compress: {
|
|
12
|
+
enabled: true,
|
|
13
|
+
permission: "allow",
|
|
14
|
+
maxContextLimit: "80%",
|
|
15
|
+
minContextLimit: "40%",
|
|
16
|
+
nudgeFrequency: 5,
|
|
17
|
+
protectUserMessages: false,
|
|
18
|
+
protectedTools: ["task", "skill", "todowrite", "todoread"],
|
|
19
|
+
},
|
|
20
|
+
strategies: {
|
|
21
|
+
deduplication: {
|
|
22
|
+
enabled: true,
|
|
23
|
+
protectedTools: [],
|
|
24
|
+
},
|
|
25
|
+
purgeErrors: {
|
|
26
|
+
enabled: true,
|
|
27
|
+
turns: 4,
|
|
28
|
+
protectedTools: [],
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
adaptive: {
|
|
32
|
+
enabled: true,
|
|
33
|
+
learningRate: 0.1,
|
|
34
|
+
minCompressionRatio: 0.3,
|
|
35
|
+
},
|
|
36
|
+
costAware: {
|
|
37
|
+
enabled: true,
|
|
38
|
+
cacheBoostFactor: 0.5,
|
|
39
|
+
},
|
|
40
|
+
persistence: {
|
|
41
|
+
enabled: true,
|
|
42
|
+
directory: join(homedir(), ".config", "opencode", "slim"),
|
|
43
|
+
},
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function deepMerge(base: SlimConfig, override: Partial<SlimConfig>): SlimConfig {
|
|
47
|
+
return {
|
|
48
|
+
...base,
|
|
49
|
+
...override,
|
|
50
|
+
compress: { ...base.compress, ...override.compress },
|
|
51
|
+
strategies: {
|
|
52
|
+
deduplication: { ...base.strategies.deduplication, ...override.strategies?.deduplication },
|
|
53
|
+
purgeErrors: { ...base.strategies.purgeErrors, ...override.strategies?.purgeErrors },
|
|
54
|
+
},
|
|
55
|
+
adaptive: { ...base.adaptive, ...override.adaptive },
|
|
56
|
+
costAware: { ...base.costAware, ...override.costAware },
|
|
57
|
+
persistence: { ...base.persistence, ...override.persistence },
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function loadConfig(_api: TuiPluginApi): SlimConfig {
|
|
62
|
+
let config = { ...DEFAULT_CONFIG }
|
|
63
|
+
|
|
64
|
+
const globalDir = process.env.XDG_CONFIG_HOME
|
|
65
|
+
? join(process.env.XDG_CONFIG_HOME, "opencode")
|
|
66
|
+
: join(homedir(), ".config", "opencode")
|
|
67
|
+
|
|
68
|
+
const globalPath = join(globalDir, "slim.jsonc")
|
|
69
|
+
const globalPathJson = join(globalDir, "slim.json")
|
|
70
|
+
|
|
71
|
+
const configPath = existsSync(globalPath)
|
|
72
|
+
? globalPath
|
|
73
|
+
: existsSync(globalPathJson)
|
|
74
|
+
? globalPathJson
|
|
75
|
+
: null
|
|
76
|
+
|
|
77
|
+
if (configPath) {
|
|
78
|
+
try {
|
|
79
|
+
const content = readFileSync(configPath, "utf-8")
|
|
80
|
+
const parsed = parse(content)
|
|
81
|
+
if (parsed) {
|
|
82
|
+
config = deepMerge(config, parsed)
|
|
83
|
+
}
|
|
84
|
+
} catch {
|
|
85
|
+
// Use defaults
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return config
|
|
90
|
+
}
|