@dibs.ai/opencode 0.0.0-stage → 0.1.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.
Files changed (3) hide show
  1. package/README.md +40 -2
  2. package/package.json +31 -3
  3. package/plugin/tui.tsx +89 -0
package/README.md CHANGED
@@ -1,3 +1,41 @@
1
- # Temporary Holding Version
1
+ # dibs for opencode
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ opencode loads skills from `skills/<id>/SKILL.md`, so it uses the shared `dibs` skill unchanged. The skill calls the CLI, so `dibs` must be on your PATH.
4
+
5
+ ## Install
6
+
7
+ ```sh
8
+ bun run build:agent opencode # writes dist/opencode/skills/dibs/SKILL.md
9
+
10
+ # project-local
11
+ mkdir -p .opencode/skills && cp -R dist/opencode/skills/dibs .opencode/skills/
12
+
13
+ # or global
14
+ mkdir -p ~/.config/opencode/skills && cp -R dist/opencode/skills/dibs ~/.config/opencode/skills/
15
+ ```
16
+
17
+ Use `ln -s "$PWD/dist/opencode/skills/dibs" <target>/dibs` instead of `cp -R` to follow rebuilds.
18
+
19
+ To check, start opencode in the project and ask it to load the `dibs` skill, or type `@dibs`. The command `opencode debug skill` does not exist in v2.3.0.
20
+
21
+ Docs: https://opencode.ai/docs/skills/ (opencode also scans `.claude/skills` and `.agents/skills`).
22
+
23
+ ## Tools (MCP)
24
+
25
+ Requires `dibs` on your PATH (for example, after `bun link`). Add this to `opencode.json`:
26
+
27
+ ```json
28
+ {"mcp":{"dibs":{"type":"local","command":["dibs","mcp"]}}}
29
+ ```
30
+
31
+ ## Task panel
32
+
33
+ A live task panel (views `current`/`project`/`completed`, like the Pi panel) shown above the prompt. Needs `dibs` on your PATH. It is a TUI-only plugin, so add it to `cli.json` (docs: https://opencode.ai/docs/cli/plugins):
34
+
35
+ ```json
36
+ { "plugins": ["/absolute/path/to/dibs/agents/opencode/plugin/tui.tsx"] }
37
+ ```
38
+
39
+ Local plugin entries are documented as directories or package names; if the file path is rejected, point at `/absolute/path/to/dibs/agents/opencode` (its `package.json` exports `./tui`). Install peers there first: `cd agents/opencode && bun add @opencode/plugin @opentui/core @opentui/solid solid-js`.
40
+
41
+ Keys: `ctrl+shift+v` cycles the view, `ctrl+shift+t` collapses (also `/tasks-view`, `/tasks-toggle`, and the command palette). The panel refreshes every 3 s and after any event mentioning a `todo_*` tool. Not verified against a running opencode.
package/package.json CHANGED
@@ -1,6 +1,34 @@
1
1
  {
2
2
  "name": "@dibs.ai/opencode",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0",
4
+ "description": "opencode TUI plugin for dibs: task panel.",
5
+ "type": "module",
6
+ "keywords": [
7
+ "opencode",
8
+ "opencode-plugin",
9
+ "dibs",
10
+ "coding-agent",
11
+ "task-manager"
12
+ ],
13
+ "exports": {
14
+ "./tui": "./plugin/tui.tsx"
15
+ },
16
+ "files": [
17
+ "plugin/"
18
+ ],
19
+ "peerDependencies": {
20
+ "@opencode/plugin": "latest",
21
+ "@opentui/core": ">=0.6.6",
22
+ "@opentui/solid": ">=0.6.6",
23
+ "solid-js": ">=1.9.0"
24
+ },
25
+ "publishConfig": {
26
+ "access": "public"
27
+ },
28
+ "license": "MIT",
29
+ "repository": {
30
+ "type": "git",
31
+ "url": "git+https://github.com/arobida/dibs.git",
32
+ "directory": "agents/opencode"
33
+ }
6
34
  }
package/plugin/tui.tsx ADDED
@@ -0,0 +1,89 @@
1
+ /** @jsxImportSource @opentui/solid */
2
+ // Live dibs task panel for opencode. API per https://opencode.ai/docs/build/plugins/cli
3
+ import { Plugin } from "@opencode/plugin/tui"
4
+ import { createSignal, For, Show, onCleanup } from "solid-js"
5
+ import { execFile } from "node:child_process"
6
+
7
+ type Row = { id: string; name: string; state: "done" | "started" | "open" }
8
+ type P = { title: string; rows: Row[]; more: number; empty: string | null }
9
+ const views = ["current", "project", "completed"] as const
10
+ const GLYPH = { done: "✓", started: "◐", open: "○" }
11
+ // U: theme token names beyond text.base are undocumented, so plain hex colours.
12
+ const COLOR = { done: "#5faf5f", started: "#d7af00", open: "#808080" }
13
+
14
+ export default Plugin.define({
15
+ id: "dibs.panel",
16
+ setup(context) {
17
+ const [view, setView] = createSignal<(typeof views)[number]>("current")
18
+ const [collapsed, setCollapsed] = createSignal(false)
19
+ const [panel, setPanel] = createSignal<P | null>(null)
20
+ const mine = new Set<string>()
21
+ // U: `location` shape is undocumented; fall back to the process cwd.
22
+ const cwd = (context.location as any)?.directory ?? process.cwd()
23
+
24
+ const refresh = () => {
25
+ const args = ["panel", view(), "--json", ...(mine.size ? ["--mine", [...mine].join(",")] : [])]
26
+ execFile("dibs", args, { cwd }, (err, out) => {
27
+ if (err) return setPanel(null) // fail silently
28
+ try { setPanel(JSON.parse(out)) } catch { setPanel(null) }
29
+ })
30
+ }
31
+
32
+ // U: server-event payload shape is not documented. Look for any {tool, input} object whose tool
33
+ // name contains "todo_" anywhere in the event, and treat that as a task tool call.
34
+ const scan = (o: any, depth = 0): any => {
35
+ if (!o || typeof o !== "object" || depth > 5) return
36
+ if (typeof o.tool === "string" && o.tool.includes("todo_")) return o
37
+ for (const v of Object.values(o)) { const r = scan(v, depth + 1); if (r) return r }
38
+ }
39
+ let timer: any
40
+ const stop = context.data.listen(({ details }: any) => {
41
+ const hit = scan(details)
42
+ if (!hit) return
43
+ const input = hit.input ?? hit.state?.input
44
+ if (input?.id && /todo_(create|edit|status)$/.test(hit.tool)) mine.add(String(input.id))
45
+ const out = JSON.stringify(hit.output ?? hit.result ?? hit.state?.output ?? "")
46
+ const m = /Created task (\S+)/.exec(out)
47
+ if (m && input?.parent && mine.has(String(input.parent))) mine.add(m[1].replace(/\W+$/, ""))
48
+ clearTimeout(timer)
49
+ timer = setTimeout(refresh, 200)
50
+ })
51
+
52
+ const cycle = () => { setView(views[(views.indexOf(view()) + 1) % views.length]); refresh() }
53
+ const toggle = () => setCollapsed(!collapsed())
54
+ // Same keys as the Pi panel; also in the command palette and as slash commands.
55
+ // U: ctrl+shift+* may not reach the app in terminals without kitty keyboard protocol.
56
+ context.keymap.layer(() => ({
57
+ mode: "global", priority: 10,
58
+ commands: [
59
+ { id: "dibs.view", title: "Cycle task view", bind: "ctrl+shift+v", palette: true, slash: { name: "tasks-view" }, run: cycle },
60
+ { id: "dibs.toggle", title: "Toggle task panel", bind: "ctrl+shift+t", palette: true, slash: { name: "tasks-toggle" }, run: toggle },
61
+ ],
62
+ bindings: ["dibs.view", "dibs.toggle"],
63
+ }))
64
+
65
+ context.ui.slot({
66
+ append: "session.composer.top",
67
+ render: () => {
68
+ refresh()
69
+ const poll = setInterval(refresh, 3000)
70
+ onCleanup(() => clearInterval(poll))
71
+ return (
72
+ <Show when={panel()}>
73
+ {(p) => (
74
+ <box flexDirection="column">
75
+ <text fg="#5fafd7">{`● ${p().title} ctrl+shift+v: view`}</text>
76
+ <Show when={!collapsed()} fallback={<text fg="#808080"> ctrl+shift+t to expand</text>}>
77
+ <For each={p().rows}>{(r) => <text fg={COLOR[r.state]}>{` ${GLYPH[r.state]} #${r.id} ${r.name}`}</text>}</For>
78
+ <Show when={p().more > 0}><text fg="#808080">{` +${p().more} more`}</text></Show>
79
+ <Show when={p().empty}><text fg="#808080">{` ${p().empty}`}</text></Show>
80
+ </Show>
81
+ </box>
82
+ )}
83
+ </Show>
84
+ )
85
+ },
86
+ })
87
+ return () => { stop(); clearTimeout(timer) }
88
+ },
89
+ })