@zinn-dev/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.
- package/LICENSE +9 -0
- package/README.md +24 -2
- package/package.json +62 -3
- package/pkg/commands.ts +89 -0
- package/pkg/components.tsx +221 -0
- package/pkg/data.ts +349 -0
- package/pkg/dialogs.tsx +208 -0
- package/pkg/options.ts +39 -0
- package/pkg/rows.ts +109 -0
- package/pkg/scan.ts +267 -0
- package/pkg/session.ts +175 -0
- package/pkg/sidebar.tsx +543 -0
- package/pkg/theme.ts +51 -0
- package/pkg/tui.tsx +32 -0
- package/pkg/types.ts +66 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright 2026 Zinn
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,25 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Zinn task inspector for OpenCode
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Task inspection in the OpenCode TUI. Read mentioned tasks, open their details, and find tasks with `/zinn`.
|
|
4
|
+
|
|
5
|
+
Requires OpenCode 2.2.0 and Zinn CLI 0.41.0 or newer on `PATH`.
|
|
6
|
+
|
|
7
|
+
Add this entry to the `plugins` array in `~/.config/opencode/cli.json`:
|
|
8
|
+
|
|
9
|
+
```json
|
|
10
|
+
{ "package": "@zinn-dev/opencode@0.1.0", "options": { "rows": 2, "current": "glyph" } }
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Read the [setup, options, compatibility, update and removal guide](https://zinn.sh/integrations/opencode/inspector).
|
|
14
|
+
|
|
15
|
+
## Development
|
|
16
|
+
|
|
17
|
+
From the repository root:
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
bun install --frozen-lockfile
|
|
21
|
+
bun run opencode:typecheck
|
|
22
|
+
bun run opencode:test
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
For a local checkout, use its absolute `integrations/opencode/inspector` directory as the package value in an isolated OpenCode `cli.json`. Replace that directory's source to update it, or remove the config entry to stop loading it.
|
package/package.json
CHANGED
|
@@ -1,6 +1,65 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zinn-dev/opencode",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Experimental Zinn task inspector for the OpenCode TUI.",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"zinn",
|
|
8
|
+
"opencode",
|
|
9
|
+
"opencode-plugin",
|
|
10
|
+
"tui",
|
|
11
|
+
"kanban",
|
|
12
|
+
"task-management",
|
|
13
|
+
"ai-agents",
|
|
14
|
+
"developer-tools"
|
|
15
|
+
],
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/yethranayeh/zinn.git",
|
|
20
|
+
"directory": "integrations/opencode/inspector"
|
|
21
|
+
},
|
|
22
|
+
"bugs": {
|
|
23
|
+
"url": "https://github.com/yethranayeh/zinn/issues"
|
|
24
|
+
},
|
|
25
|
+
"homepage": "https://zinn.sh/integrations/opencode/inspector",
|
|
26
|
+
"exports": {
|
|
27
|
+
"./tui": "./pkg/tui.tsx"
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"pkg/types.ts",
|
|
31
|
+
"pkg/options.ts",
|
|
32
|
+
"pkg/data.ts",
|
|
33
|
+
"pkg/session.ts",
|
|
34
|
+
"pkg/scan.ts",
|
|
35
|
+
"pkg/rows.ts",
|
|
36
|
+
"pkg/theme.ts",
|
|
37
|
+
"pkg/components.tsx",
|
|
38
|
+
"pkg/dialogs.tsx",
|
|
39
|
+
"pkg/commands.ts",
|
|
40
|
+
"pkg/sidebar.tsx",
|
|
41
|
+
"pkg/tui.tsx"
|
|
42
|
+
],
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"@opencode/plugin": "2.2.0"
|
|
45
|
+
},
|
|
46
|
+
"peerDependencies": {
|
|
47
|
+
"@opentui/core": "0.7.0",
|
|
48
|
+
"@opentui/solid": "0.7.0",
|
|
49
|
+
"solid-js": ">=1.9.0"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@opencode/theme": "2.2.0",
|
|
53
|
+
"@opentui/core": "0.7.0",
|
|
54
|
+
"@opentui/solid": "0.7.0",
|
|
55
|
+
"solid-js": "^1.9.0"
|
|
56
|
+
},
|
|
57
|
+
"publishConfig": {
|
|
58
|
+
"access": "public"
|
|
59
|
+
},
|
|
60
|
+
"scripts": {
|
|
61
|
+
"test": "bun test --timeout 120000 pkg tests",
|
|
62
|
+
"typecheck": "bun ../../../scripts/typecheck.ts integrations/opencode/inspector",
|
|
63
|
+
"test:package": "bun test --timeout 120000 tests/package.test.ts"
|
|
64
|
+
}
|
|
6
65
|
}
|
package/pkg/commands.ts
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { Ctx, Mention, TaskSummary } from "./types.ts";
|
|
2
|
+
|
|
3
|
+
import { openPicker } from "./dialogs.tsx";
|
|
4
|
+
import { mentionCounts } from "./scan.ts";
|
|
5
|
+
|
|
6
|
+
export type PanelSnapshot = {
|
|
7
|
+
map: Map<string, TaskSummary> | undefined;
|
|
8
|
+
known: readonly Mention[];
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export let activePanel: PanelSnapshot | undefined;
|
|
12
|
+
export function publishPanel(snapshot: PanelSnapshot): void {
|
|
13
|
+
activePanel = snapshot;
|
|
14
|
+
}
|
|
15
|
+
export function clearPanel(snapshot: PanelSnapshot | undefined): void {
|
|
16
|
+
if (snapshot !== undefined && activePanel === snapshot) {
|
|
17
|
+
activePanel = undefined;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export function registerCommands(ctx: Ctx): void {
|
|
21
|
+
const commands: unknown[] = [
|
|
22
|
+
{
|
|
23
|
+
id: "zinn.chat",
|
|
24
|
+
name: "zinn.chat",
|
|
25
|
+
title: "Zinn: task keys in this chat",
|
|
26
|
+
description: "Pick a task mentioned in this conversation",
|
|
27
|
+
desc: "Pick a task mentioned in this conversation",
|
|
28
|
+
group: "Zinn",
|
|
29
|
+
category: "Zinn",
|
|
30
|
+
palette: true,
|
|
31
|
+
namespace: "palette",
|
|
32
|
+
run() {
|
|
33
|
+
const panel = activePanel;
|
|
34
|
+
if (!panel) {
|
|
35
|
+
ctx.ui.toast.show({
|
|
36
|
+
variant: "warning",
|
|
37
|
+
title: "Zinn",
|
|
38
|
+
message: "no session sidebar mounted",
|
|
39
|
+
});
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const keys = panel.known.map((mention) => mention.key);
|
|
43
|
+
openPicker(
|
|
44
|
+
ctx,
|
|
45
|
+
"Zinn | keys in this chat",
|
|
46
|
+
keys,
|
|
47
|
+
panel.map,
|
|
48
|
+
false,
|
|
49
|
+
mentionCounts(panel.known),
|
|
50
|
+
);
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
id: "zinn.board",
|
|
55
|
+
name: "zinn.board",
|
|
56
|
+
title: "Zinn: pick a task from the board",
|
|
57
|
+
description: "Search every task in the store",
|
|
58
|
+
desc: "Search every task in the store",
|
|
59
|
+
group: "Zinn",
|
|
60
|
+
category: "Zinn",
|
|
61
|
+
palette: true,
|
|
62
|
+
namespace: "palette",
|
|
63
|
+
slash: { name: "zinn" },
|
|
64
|
+
slashName: "zinn",
|
|
65
|
+
run() {
|
|
66
|
+
const panel = activePanel;
|
|
67
|
+
if (!panel?.map) {
|
|
68
|
+
ctx.ui.toast.show({
|
|
69
|
+
variant: "warning",
|
|
70
|
+
title: "Zinn",
|
|
71
|
+
message: "Open a session to load tasks.",
|
|
72
|
+
});
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const map = panel.map;
|
|
76
|
+
openPicker(
|
|
77
|
+
ctx,
|
|
78
|
+
"Zinn | all tasks",
|
|
79
|
+
[...map.keys()],
|
|
80
|
+
map,
|
|
81
|
+
false,
|
|
82
|
+
mentionCounts(panel.known),
|
|
83
|
+
);
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
];
|
|
87
|
+
|
|
88
|
+
ctx.keymap.layer((() => ({ mode: "global", priority: 350, commands })) as () => never);
|
|
89
|
+
}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
/** @jsxImportSource @opentui/solid */
|
|
2
|
+
import type { RGBA } from "@opentui/core";
|
|
3
|
+
import type { JSX } from "@opentui/solid";
|
|
4
|
+
import type { Ctx } from "./types.ts";
|
|
5
|
+
import type { CurrentMark } from "./options.ts";
|
|
6
|
+
import type { DisplayRow } from "./rows.ts";
|
|
7
|
+
|
|
8
|
+
import { For, Show, createMemo, createSignal } from "solid-js";
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
CHIP_PAD,
|
|
12
|
+
CHIP_PRIORITY,
|
|
13
|
+
CONTEXT_SEPARATOR,
|
|
14
|
+
LABEL_SEPARATOR,
|
|
15
|
+
PRIORITY_COLOR,
|
|
16
|
+
labelColors,
|
|
17
|
+
} from "./data.ts";
|
|
18
|
+
import { MARKER_COLUMNS, RAIL_COLUMNS, SESSION_GLYPH, priorityLetter } from "./options.ts";
|
|
19
|
+
import { truncate } from "./rows.ts";
|
|
20
|
+
import { TINT_ALPHA_STRONG, TINT_ALPHA_SUBTLE, inspectorTheme, toneColor } from "./theme.ts";
|
|
21
|
+
|
|
22
|
+
export function Overflow(props: {
|
|
23
|
+
ctx: Ctx;
|
|
24
|
+
count: number;
|
|
25
|
+
label: string;
|
|
26
|
+
onOpen: () => void;
|
|
27
|
+
}): JSX.Element {
|
|
28
|
+
const theme = () => inspectorTheme(props.ctx);
|
|
29
|
+
const [hover, setHover] = createSignal(false);
|
|
30
|
+
const onClick = (event: { stopPropagation: () => void }) => {
|
|
31
|
+
event.stopPropagation();
|
|
32
|
+
|
|
33
|
+
if (hover()) {
|
|
34
|
+
props.onOpen();
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<box
|
|
40
|
+
flexDirection="row"
|
|
41
|
+
backgroundColor={hover() ? theme().backgroundElement : "transparent"}
|
|
42
|
+
onMouseOver={() => setHover(true)}
|
|
43
|
+
onMouseOut={() => setHover(false)}
|
|
44
|
+
onMouseUp={onClick}
|
|
45
|
+
>
|
|
46
|
+
<text flexShrink={0} fg={theme().textMuted}>{`+${props.count} ${props.label}`}</text>
|
|
47
|
+
</box>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
type MetaPart = {
|
|
52
|
+
text: string;
|
|
53
|
+
color: string | null;
|
|
54
|
+
chip: boolean;
|
|
55
|
+
sep: boolean;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export function Row(props: {
|
|
59
|
+
ctx: Ctx;
|
|
60
|
+
row: DisplayRow;
|
|
61
|
+
titleColumns: number;
|
|
62
|
+
metaColumns: number;
|
|
63
|
+
dense: boolean;
|
|
64
|
+
current: CurrentMark;
|
|
65
|
+
markGlyph?: string;
|
|
66
|
+
onOpen: () => void;
|
|
67
|
+
}): JSX.Element {
|
|
68
|
+
const theme = () => inspectorTheme(props.ctx);
|
|
69
|
+
const keyColor = toneColor(props.ctx, () => props.row.tone);
|
|
70
|
+
const metaColor = () => theme().textMuted;
|
|
71
|
+
const glyph = () => props.current === "glyph";
|
|
72
|
+
const markerColumns = () => {
|
|
73
|
+
if (!props.dense) {
|
|
74
|
+
return MARKER_COLUMNS + (glyph() ? RAIL_COLUMNS : 0);
|
|
75
|
+
}
|
|
76
|
+
return (glyph() ? RAIL_COLUMNS : 0) + (props.row.created ? 1 : 0);
|
|
77
|
+
};
|
|
78
|
+
const metaIndent = () => markerColumns() + 1;
|
|
79
|
+
const sessionMark = () => props.markGlyph ?? (props.row.mine ? SESSION_GLYPH : " ");
|
|
80
|
+
const statusGlyph = () => (props.dense ? (props.row.created ? "+" : "") : props.row.glyph);
|
|
81
|
+
const [hover, setHover] = createSignal(false);
|
|
82
|
+
const onEnter = () => setHover(true);
|
|
83
|
+
const onLeave = () => setHover(false);
|
|
84
|
+
const wash = (color: RGBA) => {
|
|
85
|
+
const [r, g, b] = color.toInts();
|
|
86
|
+
const byte = (n: number) => n.toString(16).padStart(2, "0");
|
|
87
|
+
return `#${byte(r)}${byte(g)}${byte(b)}${hover() ? TINT_ALPHA_STRONG : TINT_ALPHA_SUBTLE}`;
|
|
88
|
+
};
|
|
89
|
+
const done = () => props.row.column === "Done";
|
|
90
|
+
const background = () =>
|
|
91
|
+
done() ? wash(theme().success) : hover() ? theme().backgroundElement : "transparent";
|
|
92
|
+
// Every row reserves the left border, coloured only for Done rows so nothing shifts.
|
|
93
|
+
const railColor = () => (done() ? theme().success : "transparent");
|
|
94
|
+
const onClick = (event: { stopPropagation: () => void }) => {
|
|
95
|
+
event.stopPropagation();
|
|
96
|
+
if (hover()) {
|
|
97
|
+
props.onOpen();
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const head = (
|
|
102
|
+
<box flexDirection="row" gap={1}>
|
|
103
|
+
<text width={markerColumns()} flexShrink={0} fg={keyColor()}>
|
|
104
|
+
{glyph() ? <span style={{ fg: theme().accent }}>{sessionMark()}</span> : null}
|
|
105
|
+
{statusGlyph()}
|
|
106
|
+
</text>
|
|
107
|
+
|
|
108
|
+
<text flexShrink={0} fg={keyColor()}>
|
|
109
|
+
{props.row.key}
|
|
110
|
+
</text>
|
|
111
|
+
{!props.dense && (
|
|
112
|
+
<text flexShrink={0} fg={metaColor()}>
|
|
113
|
+
{priorityLetter(props.row.priority)}
|
|
114
|
+
</text>
|
|
115
|
+
)}
|
|
116
|
+
|
|
117
|
+
<text wrapMode="none" flexShrink={1} fg={metaColor()}>
|
|
118
|
+
{truncate(props.row.title, props.titleColumns)}
|
|
119
|
+
</text>
|
|
120
|
+
</box>
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
const metaPlan = createMemo<MetaPart[]>(() => {
|
|
124
|
+
const budget = props.metaColumns;
|
|
125
|
+
const parts: MetaPart[] = [];
|
|
126
|
+
const contexts: MetaPart[] = [];
|
|
127
|
+
if (props.row.column.length > 0) {
|
|
128
|
+
contexts.push({ text: props.row.column, color: null, chip: false, sep: false });
|
|
129
|
+
}
|
|
130
|
+
if (props.row.priority) {
|
|
131
|
+
contexts.push({
|
|
132
|
+
text: props.row.priority,
|
|
133
|
+
color: PRIORITY_COLOR[props.row.priority] ?? null,
|
|
134
|
+
chip: props.row.priority === CHIP_PRIORITY,
|
|
135
|
+
sep: false,
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
let used = contexts.reduce(
|
|
140
|
+
(sum, part) => sum + part.text.length + (part.chip ? CHIP_PAD : 0),
|
|
141
|
+
0,
|
|
142
|
+
);
|
|
143
|
+
used += Math.max(0, contexts.length - 1) * CONTEXT_SEPARATOR.length;
|
|
144
|
+
contexts.forEach((part, index) => {
|
|
145
|
+
if (index > 0) {
|
|
146
|
+
parts.push({ text: CONTEXT_SEPARATOR, color: null, chip: false, sep: true });
|
|
147
|
+
}
|
|
148
|
+
parts.push(part);
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
let shown = 0;
|
|
152
|
+
for (let i = 0; i < props.row.labels.length; i++) {
|
|
153
|
+
const label = props.row.labels[i]!;
|
|
154
|
+
const separator =
|
|
155
|
+
contexts.length > 0 || shown > 0 ? (shown > 0 ? LABEL_SEPARATOR : CONTEXT_SEPARATOR) : "";
|
|
156
|
+
const leftovers = props.row.labels.length - i - 1;
|
|
157
|
+
const reserve = leftovers > 0 ? 2 + String(leftovers).length : 0;
|
|
158
|
+
if (used + separator.length + label.length + reserve > budget) {
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
if (separator.length > 0) {
|
|
162
|
+
parts.push({ text: separator, color: null, chip: false, sep: true });
|
|
163
|
+
}
|
|
164
|
+
parts.push({ text: label, color: labelColors().get(label) ?? null, chip: false, sep: false });
|
|
165
|
+
used += separator.length + label.length;
|
|
166
|
+
shown++;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const hidden = props.row.labels.length - shown;
|
|
170
|
+
if (hidden > 0) {
|
|
171
|
+
const tail = ` +${hidden}`;
|
|
172
|
+
if (used + tail.length <= budget) {
|
|
173
|
+
parts.push({ text: tail, color: null, chip: false, sep: false });
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return parts;
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
const meta = () => (
|
|
180
|
+
<box flexDirection="row">
|
|
181
|
+
<text flexShrink={0}>{` `.repeat(metaIndent())}</text>
|
|
182
|
+
<text wrapMode="none" flexShrink={1} fg={metaColor()}>
|
|
183
|
+
<For each={metaPlan()}>
|
|
184
|
+
{(part) => (
|
|
185
|
+
<Show
|
|
186
|
+
when={!part.chip}
|
|
187
|
+
fallback={
|
|
188
|
+
<>
|
|
189
|
+
<span style={{ fg: metaColor() }}> </span>
|
|
190
|
+
<span style={{ fg: part.color, bg: `${part.color}${TINT_ALPHA_STRONG}` }}>
|
|
191
|
+
{part.text}
|
|
192
|
+
</span>
|
|
193
|
+
<span style={{ fg: metaColor() }}> </span>
|
|
194
|
+
</>
|
|
195
|
+
}
|
|
196
|
+
>
|
|
197
|
+
<span style={{ fg: part.sep ? theme().borderSubtle : (part.color ?? metaColor()) }}>
|
|
198
|
+
{part.text}
|
|
199
|
+
</span>
|
|
200
|
+
</Show>
|
|
201
|
+
)}
|
|
202
|
+
</For>
|
|
203
|
+
</text>
|
|
204
|
+
</box>
|
|
205
|
+
);
|
|
206
|
+
|
|
207
|
+
return (
|
|
208
|
+
<box
|
|
209
|
+
flexDirection={props.dense ? "column" : "row"}
|
|
210
|
+
backgroundColor={background()}
|
|
211
|
+
border={["left"]}
|
|
212
|
+
borderColor={railColor()}
|
|
213
|
+
onMouseOver={onEnter}
|
|
214
|
+
onMouseOut={onLeave}
|
|
215
|
+
onMouseUp={onClick}
|
|
216
|
+
>
|
|
217
|
+
{head}
|
|
218
|
+
<Show when={props.dense}>{meta()}</Show>
|
|
219
|
+
</box>
|
|
220
|
+
);
|
|
221
|
+
}
|