@serkanalgur/opencode-slim 1.3.0 → 1.4.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 CHANGED
@@ -24,14 +24,26 @@ Smart context management plugin for OpenCode. Optimizes token usage through sema
24
24
  opencode plugin @serkanalgur/opencode-slim@latest --global
25
25
  ```
26
26
 
27
+ This installs the plugin globally. The TUI features (panel, slash commands) are automatically loaded when OpenCode starts.
28
+
29
+ ### Manual Installation
30
+
31
+ If the CLI command doesn't work, add to your `~/.config/opencode/opencode.json`:
32
+
33
+ ```json
34
+ {
35
+ "plugins": ["@serkanalgur/opencode-slim"]
36
+ }
37
+ ```
38
+
27
39
  ## Usage
28
40
 
29
41
  ### Slash Commands
30
42
 
31
- Slim provides slash commands for easy access:
43
+ After installation, these slash commands are available in the TUI:
32
44
 
33
45
  - `/panel` — Opens the rich TUI panel with context usage, stats, and help
34
- - `/compress [focus]` — Manually trigger compression with focus description
46
+ - `/compress` — Shows instructions for using the compress tool
35
47
 
36
48
  ### TUI Panel
37
49
 
@@ -133,7 +145,9 @@ State is saved to disk, so compression history and learning persist across resta
133
145
  | Command | Description |
134
146
  |---------|-------------|
135
147
  | `/panel` | Open the Slim TUI panel with context usage, stats, and help |
136
- | `/compress [focus]` | Manually trigger compression with focus description |
148
+ | `/compress` | Show instructions for using the compress tool |
149
+
150
+ Note: Compression is performed by the AI assistant using the `compress` tool. The slash command provides guidance on usage.
137
151
 
138
152
  ## Comparison with DCP
139
153
 
package/dist/tui.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"tui.d.ts","sourceRoot":"","sources":["../tui.tsx"],"names":[],"mappings":"AAAA,sCAAsC;;;;;AAsBtC,wBAG2B"}
1
+ {"version":3,"file":"tui.d.ts","sourceRoot":"","sources":["../tui.tsx"],"names":[],"mappings":"AAAA,sCAAsC;;;;;AAsFtC,wBAG2B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@serkanalgur/opencode-slim",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "description": "Smart context management plugin for OpenCode - semantic compression, cost-aware pruning, adaptive thresholds",
5
5
  "keywords": [
6
6
  "opencode",
package/tui.tsx CHANGED
@@ -1,23 +1,87 @@
1
1
  /** @jsxImportSource @opentui/solid */
2
2
 
3
- import type { TuiPluginModule } from "@opencode-ai/plugin/tui"
4
- import { registerCommands } from "./lib/tui/commands"
3
+ import type { TuiPluginModule, TuiPluginApi } from "@opencode-ai/plugin/tui"
4
+ import type { SlimConfig } from "./lib/types"
5
5
  import { loadConfig } from "./lib/tui/data"
6
6
  import { openPanelModal } from "./lib/tui/modals"
7
7
 
8
+ /**
9
+ * Register slash commands using the appropriate API version.
10
+ * - v2 (1.18.29+): keymap.registerLayer
11
+ * - v1 (legacy): api.command.register
12
+ */
13
+ function registerSlashCommands(api: TuiPluginApi, config: SlimConfig): void {
14
+ // v2 way: keymap.registerLayer
15
+ if (api.keymap && typeof api.keymap.registerLayer === "function") {
16
+ api.keymap.registerLayer({
17
+ mode: "global",
18
+ priority: 10,
19
+ commands: [
20
+ {
21
+ name: "slim.panel",
22
+ title: "Open Slim Panel",
23
+ group: "Slim",
24
+ slash: { name: "panel" },
25
+ enabled: () => true,
26
+ suggested: true,
27
+ run: () => {
28
+ openPanelModal(api, config)
29
+ },
30
+ },
31
+ {
32
+ name: "slim.compress",
33
+ title: "Compress Context",
34
+ group: "Slim",
35
+ slash: { name: "compress" },
36
+ enabled: () => true,
37
+ suggested: true,
38
+ run: () => {
39
+ api.ui.toast({
40
+ title: "Slim",
41
+ message: "Use the compress tool: compress({ focus: 'your focus' })",
42
+ variant: "info",
43
+ })
44
+ },
45
+ },
46
+ ],
47
+ })
48
+ return
49
+ }
50
+
51
+ // v1 fallback: api.command.register
52
+ if (api.command && typeof api.command.register === "function") {
53
+ api.command.register(() => [
54
+ {
55
+ title: "Slim",
56
+ value: "slim.panel",
57
+ description: "Open Slim context panel",
58
+ category: "Slim",
59
+ slash: { name: "panel" },
60
+ onSelect: () => openPanelModal(api, config),
61
+ },
62
+ {
63
+ title: "Compress",
64
+ value: "slim.compress",
65
+ description: "Compress context (use compress tool)",
66
+ category: "Slim",
67
+ slash: { name: "compress" },
68
+ onSelect: () => {
69
+ api.ui.toast({
70
+ title: "Slim",
71
+ message: "Use the compress tool: compress({ focus: 'your focus' })",
72
+ variant: "info",
73
+ })
74
+ },
75
+ },
76
+ ])
77
+ }
78
+ }
79
+
8
80
  const tui: TuiPluginModule["tui"] = async (api) => {
9
81
  const config = loadConfig(api)
10
82
  if (!config.enabled) return
11
83
 
12
- registerCommands(api, [
13
- {
14
- title: "Slim",
15
- name: "slim.panel",
16
- description: "Open Slim context panel",
17
- slashName: "panel",
18
- run: () => openPanelModal(api, config),
19
- },
20
- ])
84
+ registerSlashCommands(api, config)
21
85
  }
22
86
 
23
87
  export default {
@@ -1,14 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,30 +0,0 @@
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
- }