@daoninc/opencode-changed-files 0.0.0-stage → 0.1.1
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 +21 -0
- package/README.md +67 -2
- package/dist/status.js +62 -0
- package/dist/tree.js +48 -0
- package/dist/tui.js +322 -0
- package/dist/worktree.js +30 -0
- package/package.json +13 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Daon Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,68 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Changed files sidebar (OpenCode V2)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## Install
|
|
4
|
+
|
|
5
|
+
Add the fixed `0.1.1` npm release to the existing `plugins`
|
|
6
|
+
array in `~/.config/opencode/cli.json`:
|
|
7
|
+
|
|
8
|
+
```json
|
|
9
|
+
{ "plugins": ["@daoninc/opencode-changed-files@0.1.1"] }
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Requires OpenCode V2. This is a TUI-only package; remove the equivalent local
|
|
13
|
+
entry when switching to npm. MIT licensed; see `LICENSE`.
|
|
14
|
+
|
|
15
|
+
**Do not use `0.1.0` with OpenCode 2.3.1:** its raw TSX bypasses the host's Solid
|
|
16
|
+
transform inside `node_modules` and can cause runaway CPU/memory consumption.
|
|
17
|
+
Version `0.1.1` exports precompiled JavaScript and uses `daoninc.changed-files`.
|
|
18
|
+
|
|
19
|
+
## Features
|
|
20
|
+
|
|
21
|
+
TUI-only plugin showing the active session's uncommitted changes in a compact file tree,
|
|
22
|
+
added/modified/deleted indicators, per-file additions/deletions, and totals.
|
|
23
|
+
Uses the connected server's `vcs.status` API (including its staged, unstaged,
|
|
24
|
+
untracked and binary-file counting semantics), so remote sessions work too.
|
|
25
|
+
This is the working-tree view, not a list limited to files edited by the agent.
|
|
26
|
+
|
|
27
|
+
Directories appear once, with filenames indented underneath. Single-folder chains
|
|
28
|
+
are compacted (for example `assets/thoth/config`), while branching directories stay
|
|
29
|
+
nested. Root files remain at the top level; full paths and counts are retained
|
|
30
|
+
internally.
|
|
31
|
+
|
|
32
|
+
Click the **▼ Changed files** heading to collapse the section, or **▶ Changed
|
|
33
|
+
files** to expand it. The triangle uses the theme's muted color. File counts,
|
|
34
|
+
totals, and the worktree badge remain visible, and background updates continue.
|
|
35
|
+
The collapsed/expanded preference survives closing/reopening the sidebar and
|
|
36
|
+
plugin reloads for the lifetime of the TUI.
|
|
37
|
+
|
|
38
|
+
A blue `WT` (worktree) badge appears beside the heading in a linked Git worktree (including
|
|
39
|
+
sessions in its subdirectories), but not in the main checkout. Detection uses
|
|
40
|
+
the connected server's location and worktree metadata, so it also works remotely.
|
|
41
|
+
The badge follows session switches and refreshes with the list; metadata errors
|
|
42
|
+
hide it rather than interrupting the file list.
|
|
43
|
+
|
|
44
|
+
Click a file row to open OpenCode's **built-in diff viewer**, using the public
|
|
45
|
+
`context.keymap.dispatch("diff.open")` command. There is no custom diff panel or
|
|
46
|
+
popup. Hover highlights the row; dragging to select/copy a path does not open it.
|
|
47
|
+
|
|
48
|
+
The built-in viewer controls scope, selected file and all shortcuts. The documented
|
|
49
|
+
command does not expose a file-selection argument, so clicking a row opens the
|
|
50
|
+
viewer without automatically selecting that file. Select it in the viewer's tree;
|
|
51
|
+
if needed, press d and choose **Uncommitted** to match the sidebar's working-tree
|
|
52
|
+
scope. Use Escape/q to close, f for fullscreen and v for split/unified view.
|
|
53
|
+
|
|
54
|
+
The section appends to the shared sidebar slot; hot reload can affect its order
|
|
55
|
+
relative to other contributions. Updates
|
|
56
|
+
are debounced after filesystem, shell, tool, session and branch events, with a
|
|
57
|
+
five-second polling fallback for changes made outside OpenCode. Switching session
|
|
58
|
+
directories clears the old list immediately. Clean, loading and unavailable states
|
|
59
|
+
are explicit; failures retry automatically. Timers/listeners are removed on unmount.
|
|
60
|
+
|
|
61
|
+
If the plugin is not picked up immediately, run `/reload`. No service restart is
|
|
62
|
+
needed. Disable it by removing its entry from `cli.json`.
|
|
63
|
+
|
|
64
|
+
Run the lifecycle/count tests:
|
|
65
|
+
|
|
66
|
+
```sh
|
|
67
|
+
bun test
|
|
68
|
+
```
|
package/dist/status.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export function totals(files) {
|
|
2
|
+
return files.reduce((sum, file) => ({
|
|
3
|
+
additions: sum.additions + file.additions,
|
|
4
|
+
deletions: sum.deletions + file.deletions
|
|
5
|
+
}), {
|
|
6
|
+
additions: 0,
|
|
7
|
+
deletions: 0
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
export function createStatusTracker(fetchFiles, publish) {
|
|
11
|
+
let directory = "";
|
|
12
|
+
let disposed = false;
|
|
13
|
+
let running;
|
|
14
|
+
const refresh = async () => {
|
|
15
|
+
if (disposed || !directory) return;
|
|
16
|
+
if (running) {
|
|
17
|
+
running.queued = true;
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const request = {
|
|
21
|
+
queued: false
|
|
22
|
+
};
|
|
23
|
+
running = request;
|
|
24
|
+
try {
|
|
25
|
+
const files = await fetchFiles(directory);
|
|
26
|
+
if (!disposed && running === request) publish({
|
|
27
|
+
files: [...files].sort((a, b) => a.file.localeCompare(b.file)),
|
|
28
|
+
loading: false,
|
|
29
|
+
error: false
|
|
30
|
+
});
|
|
31
|
+
} catch {
|
|
32
|
+
if (!disposed && running === request) publish({
|
|
33
|
+
files: [],
|
|
34
|
+
loading: false,
|
|
35
|
+
error: true
|
|
36
|
+
});
|
|
37
|
+
} finally {
|
|
38
|
+
if (running === request) {
|
|
39
|
+
running = undefined;
|
|
40
|
+
if (request.queued && !disposed) void refresh();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
return {
|
|
45
|
+
refresh,
|
|
46
|
+
setDirectory(next) {
|
|
47
|
+
if (disposed || next === directory) return;
|
|
48
|
+
directory = next;
|
|
49
|
+
running = undefined;
|
|
50
|
+
publish({
|
|
51
|
+
files: [],
|
|
52
|
+
loading: Boolean(next),
|
|
53
|
+
error: false
|
|
54
|
+
});
|
|
55
|
+
void refresh();
|
|
56
|
+
},
|
|
57
|
+
dispose() {
|
|
58
|
+
disposed = true;
|
|
59
|
+
running = undefined;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
}
|
package/dist/tree.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
const directory = () => ({
|
|
2
|
+
directories: new Map(),
|
|
3
|
+
files: []
|
|
4
|
+
});
|
|
5
|
+
const basename = path => path.slice(path.lastIndexOf("/") + 1);
|
|
6
|
+
export function fileTree(files) {
|
|
7
|
+
const root = directory();
|
|
8
|
+
for (const file of files) {
|
|
9
|
+
let node = root;
|
|
10
|
+
const parts = file.file.split("/");
|
|
11
|
+
for (const part of parts.slice(0, -1)) {
|
|
12
|
+
if (!node.directories.has(part)) node.directories.set(part, directory());
|
|
13
|
+
node = node.directories.get(part);
|
|
14
|
+
}
|
|
15
|
+
node.files.push(file);
|
|
16
|
+
}
|
|
17
|
+
const entries = [];
|
|
18
|
+
const visit = (node, parent, depth) => {
|
|
19
|
+
for (const [segment, child] of [...node.directories].sort(([a], [b]) => a.localeCompare(b))) {
|
|
20
|
+
let name = segment;
|
|
21
|
+
let current = child;
|
|
22
|
+
while (current.files.length === 0 && current.directories.size === 1) {
|
|
23
|
+
const [next, nested] = current.directories.entries().next().value;
|
|
24
|
+
name += `/${next}`;
|
|
25
|
+
current = nested;
|
|
26
|
+
}
|
|
27
|
+
const path = parent ? `${parent}/${name}` : name;
|
|
28
|
+
entries.push({
|
|
29
|
+
kind: "directory",
|
|
30
|
+
name,
|
|
31
|
+
path,
|
|
32
|
+
depth
|
|
33
|
+
});
|
|
34
|
+
visit(current, path, depth + 1);
|
|
35
|
+
}
|
|
36
|
+
for (const file of [...node.files].sort((a, b) => basename(a.file).localeCompare(basename(b.file)))) {
|
|
37
|
+
entries.push({
|
|
38
|
+
kind: "file",
|
|
39
|
+
name: basename(file.file),
|
|
40
|
+
path: file.file,
|
|
41
|
+
depth,
|
|
42
|
+
file
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
visit(root, "", 0);
|
|
47
|
+
return entries;
|
|
48
|
+
}
|
package/dist/tui.js
ADDED
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
import { createComponent as _$createComponent } from "@opentui/solid";
|
|
2
|
+
import { effect as _$effect } from "@opentui/solid";
|
|
3
|
+
import { createTextNode as _$createTextNode } from "@opentui/solid";
|
|
4
|
+
import { insertNode as _$insertNode } from "@opentui/solid";
|
|
5
|
+
import { insert as _$insert } from "@opentui/solid";
|
|
6
|
+
import { memo as _$memo } from "@opentui/solid";
|
|
7
|
+
import { setProp as _$setProp } from "@opentui/solid";
|
|
8
|
+
import { createElement as _$createElement } from "@opentui/solid";
|
|
9
|
+
import { Plugin } from "@opencode/plugin/tui";
|
|
10
|
+
import { createEffect, createMemo, createResource, createSignal, For, onCleanup, Show, untrack } from "solid-js";
|
|
11
|
+
import { createStatusTracker, totals } from "./status.js";
|
|
12
|
+
import { fileTree } from "./tree.js";
|
|
13
|
+
import { loadWorktreeBadge } from "./worktree.js";
|
|
14
|
+
const POLL_MS = 5_000;
|
|
15
|
+
const DEBOUNCE_MS = 200;
|
|
16
|
+
export default Plugin.define({
|
|
17
|
+
id: "daoninc.changed-files",
|
|
18
|
+
setup(context) {
|
|
19
|
+
const fallback = context.location ?? context.data.location.default();
|
|
20
|
+
const [section, updateSection] = context.storage.memory("changed-files-section", {
|
|
21
|
+
initial: {
|
|
22
|
+
expanded: true
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
return context.ui.slot({
|
|
26
|
+
append: "sidebar.content",
|
|
27
|
+
render: props => {
|
|
28
|
+
const directory = () => context.data.session.get(props.sessionID)?.location.directory ?? fallback.directory;
|
|
29
|
+
const [worktree, {
|
|
30
|
+
refetch: refreshWorktree
|
|
31
|
+
}] = createResource(directory, directory => loadWorktreeBadge(context.client, directory));
|
|
32
|
+
const showWorktree = () => worktree()?.directory === directory() && worktree()?.isWorktree;
|
|
33
|
+
const [status, setStatus] = createSignal({
|
|
34
|
+
files: [],
|
|
35
|
+
loading: true,
|
|
36
|
+
error: false
|
|
37
|
+
});
|
|
38
|
+
const expanded = () => section.expanded;
|
|
39
|
+
const sum = createMemo(() => totals(status().files));
|
|
40
|
+
const tree = createMemo(() => fileTree(status().files));
|
|
41
|
+
const tracker = createStatusTracker(async directory => {
|
|
42
|
+
const response = await context.client.vcs.status({
|
|
43
|
+
location: {
|
|
44
|
+
directory
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
return response.data;
|
|
48
|
+
}, setStatus);
|
|
49
|
+
let debounce;
|
|
50
|
+
const schedule = () => {
|
|
51
|
+
clearTimeout(debounce);
|
|
52
|
+
debounce = setTimeout(() => void tracker.refresh(), DEBOUNCE_MS);
|
|
53
|
+
};
|
|
54
|
+
const stopEvents = context.data.listen(({
|
|
55
|
+
details
|
|
56
|
+
}) => {
|
|
57
|
+
if (details.type === "worktree.updated" || details.type === "worktree.resolved") {
|
|
58
|
+
void refreshWorktree();
|
|
59
|
+
schedule();
|
|
60
|
+
}
|
|
61
|
+
if (details.location && details.location.directory !== directory()) return;
|
|
62
|
+
if (["filesystem.changed", "shell.exited", "session.shell.ended", "session.tool.success", "session.execution.succeeded", "session.execution.failed", "vcs.branch.updated"].includes(details.type)) schedule();
|
|
63
|
+
});
|
|
64
|
+
const poll = setInterval(() => {
|
|
65
|
+
void tracker.refresh();
|
|
66
|
+
void refreshWorktree();
|
|
67
|
+
}, POLL_MS);
|
|
68
|
+
createEffect(() => {
|
|
69
|
+
const next = directory();
|
|
70
|
+
untrack(() => tracker.setDirectory(next));
|
|
71
|
+
});
|
|
72
|
+
onCleanup(() => {
|
|
73
|
+
tracker.dispose();
|
|
74
|
+
stopEvents();
|
|
75
|
+
clearInterval(poll);
|
|
76
|
+
clearTimeout(debounce);
|
|
77
|
+
});
|
|
78
|
+
const addedColor = () => context.themeMode === "light" ? "#18703b" : "#8bd49c";
|
|
79
|
+
const deletedColor = () => context.themeMode === "light" ? "#b42318" : "#f38ba8";
|
|
80
|
+
const worktreeColor = () => context.themeMode === "light" ? "#175cd3" : "#89b4fa";
|
|
81
|
+
return (() => {
|
|
82
|
+
var _el$ = _$createElement("box"),
|
|
83
|
+
_el$2 = _$createElement("box"),
|
|
84
|
+
_el$3 = _$createElement("text"),
|
|
85
|
+
_el$4 = _$createElement("span"),
|
|
86
|
+
_el$5 = _$createElement("b"),
|
|
87
|
+
_el$6 = _$createTextNode(`Changed files (`),
|
|
88
|
+
_el$7 = _$createTextNode(`)`),
|
|
89
|
+
_el$14 = _$createElement("box");
|
|
90
|
+
_$insertNode(_el$, _el$2);
|
|
91
|
+
_$insertNode(_el$, _el$14);
|
|
92
|
+
_$setProp(_el$, "flexDirection", "column");
|
|
93
|
+
_$setProp(_el$, "gap", 1);
|
|
94
|
+
_$insertNode(_el$2, _el$3);
|
|
95
|
+
_$setProp(_el$2, "flexDirection", "row");
|
|
96
|
+
_$setProp(_el$2, "justifyContent", "space-between");
|
|
97
|
+
_$setProp(_el$2, "gap", 1);
|
|
98
|
+
_$insertNode(_el$3, _el$4);
|
|
99
|
+
_$insertNode(_el$3, _el$5);
|
|
100
|
+
_$setProp(_el$3, "wrapMode", "word");
|
|
101
|
+
_$setProp(_el$3, "selectable", false);
|
|
102
|
+
_$setProp(_el$3, "onMouseUp", event => {
|
|
103
|
+
if (event.button !== 0) return;
|
|
104
|
+
event.stopPropagation();
|
|
105
|
+
updateSection(value => {
|
|
106
|
+
value.expanded = !value.expanded;
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
_$insert(_el$4, () => expanded() ? "▼ " : "▶ ");
|
|
110
|
+
_$insertNode(_el$5, _el$6);
|
|
111
|
+
_$insertNode(_el$5, _el$7);
|
|
112
|
+
_$insert(_el$5, () => status().files.length, _el$7);
|
|
113
|
+
_$insert(_el$3, _$createComponent(Show, {
|
|
114
|
+
get when() {
|
|
115
|
+
return showWorktree();
|
|
116
|
+
},
|
|
117
|
+
get children() {
|
|
118
|
+
return [" ", (() => {
|
|
119
|
+
var _el$8 = _$createElement("span");
|
|
120
|
+
_$insertNode(_el$8, _$createTextNode(` WT `));
|
|
121
|
+
_$effect(_$p => _$setProp(_el$8, "style", {
|
|
122
|
+
fg: worktreeColor(),
|
|
123
|
+
bg: context.theme.background.action.primary.hovered
|
|
124
|
+
}, _$p));
|
|
125
|
+
return _el$8;
|
|
126
|
+
})()];
|
|
127
|
+
}
|
|
128
|
+
}), null);
|
|
129
|
+
_$insert(_el$2, _$createComponent(Show, {
|
|
130
|
+
get when() {
|
|
131
|
+
return status().files.length > 0;
|
|
132
|
+
},
|
|
133
|
+
get children() {
|
|
134
|
+
var _el$0 = _$createElement("text"),
|
|
135
|
+
_el$1 = _$createElement("span"),
|
|
136
|
+
_el$10 = _$createTextNode(`+`),
|
|
137
|
+
_el$11 = _$createTextNode(` `),
|
|
138
|
+
_el$12 = _$createElement("span"),
|
|
139
|
+
_el$13 = _$createTextNode(`−`);
|
|
140
|
+
_$insertNode(_el$0, _el$1);
|
|
141
|
+
_$insertNode(_el$0, _el$11);
|
|
142
|
+
_$insertNode(_el$0, _el$12);
|
|
143
|
+
_$setProp(_el$0, "flexShrink", 0);
|
|
144
|
+
_$insertNode(_el$1, _el$10);
|
|
145
|
+
_$insert(_el$1, () => sum().additions, null);
|
|
146
|
+
_$insertNode(_el$12, _el$13);
|
|
147
|
+
_$insert(_el$12, () => sum().deletions, null);
|
|
148
|
+
_$effect(_p$ => {
|
|
149
|
+
var _v$ = {
|
|
150
|
+
fg: addedColor()
|
|
151
|
+
},
|
|
152
|
+
_v$2 = {
|
|
153
|
+
fg: deletedColor()
|
|
154
|
+
};
|
|
155
|
+
_v$ !== _p$.e && (_p$.e = _$setProp(_el$1, "style", _v$, _p$.e));
|
|
156
|
+
_v$2 !== _p$.t && (_p$.t = _$setProp(_el$12, "style", _v$2, _p$.t));
|
|
157
|
+
return _p$;
|
|
158
|
+
}, {
|
|
159
|
+
e: undefined,
|
|
160
|
+
t: undefined
|
|
161
|
+
});
|
|
162
|
+
return _el$0;
|
|
163
|
+
}
|
|
164
|
+
}), null);
|
|
165
|
+
_$setProp(_el$14, "flexDirection", "column");
|
|
166
|
+
_$insert(_el$14, _$createComponent(Show, {
|
|
167
|
+
get when() {
|
|
168
|
+
return !status().loading;
|
|
169
|
+
},
|
|
170
|
+
get fallback() {
|
|
171
|
+
return (() => {
|
|
172
|
+
var _el$16 = _$createElement("text");
|
|
173
|
+
_$insertNode(_el$16, _$createTextNode(`Loading changes…`));
|
|
174
|
+
_$effect(_$p => _$setProp(_el$16, "fg", context.theme.text.muted, _$p));
|
|
175
|
+
return _el$16;
|
|
176
|
+
})();
|
|
177
|
+
},
|
|
178
|
+
get children() {
|
|
179
|
+
return _$createComponent(Show, {
|
|
180
|
+
get when() {
|
|
181
|
+
return !status().error;
|
|
182
|
+
},
|
|
183
|
+
get fallback() {
|
|
184
|
+
return (() => {
|
|
185
|
+
var _el$18 = _$createElement("text");
|
|
186
|
+
_$insertNode(_el$18, _$createTextNode(`Changes unavailable; retrying…`));
|
|
187
|
+
_$effect(_$p => _$setProp(_el$18, "fg", context.theme.text.muted, _$p));
|
|
188
|
+
return _el$18;
|
|
189
|
+
})();
|
|
190
|
+
},
|
|
191
|
+
get children() {
|
|
192
|
+
return _$createComponent(Show, {
|
|
193
|
+
get when() {
|
|
194
|
+
return status().files.length > 0;
|
|
195
|
+
},
|
|
196
|
+
get fallback() {
|
|
197
|
+
return (() => {
|
|
198
|
+
var _el$20 = _$createElement("text");
|
|
199
|
+
_$insertNode(_el$20, _$createTextNode(`Working tree clean`));
|
|
200
|
+
_$effect(_$p => _$setProp(_el$20, "fg", context.theme.text.muted, _$p));
|
|
201
|
+
return _el$20;
|
|
202
|
+
})();
|
|
203
|
+
},
|
|
204
|
+
get children() {
|
|
205
|
+
var _el$15 = _$createElement("box");
|
|
206
|
+
_$setProp(_el$15, "flexDirection", "column");
|
|
207
|
+
_$insert(_el$15, _$createComponent(For, {
|
|
208
|
+
get each() {
|
|
209
|
+
return tree();
|
|
210
|
+
},
|
|
211
|
+
children: entry => {
|
|
212
|
+
if (entry.kind === "directory") return (() => {
|
|
213
|
+
var _el$22 = _$createElement("text");
|
|
214
|
+
_$setProp(_el$22, "wrapMode", "char");
|
|
215
|
+
_$insert(_el$22, () => entry.name);
|
|
216
|
+
_$effect(_p$ => {
|
|
217
|
+
var _v$6 = context.theme.text.muted,
|
|
218
|
+
_v$7 = entry.depth * 2;
|
|
219
|
+
_v$6 !== _p$.e && (_p$.e = _$setProp(_el$22, "fg", _v$6, _p$.e));
|
|
220
|
+
_v$7 !== _p$.t && (_p$.t = _$setProp(_el$22, "paddingLeft", _v$7, _p$.t));
|
|
221
|
+
return _p$;
|
|
222
|
+
}, {
|
|
223
|
+
e: undefined,
|
|
224
|
+
t: undefined
|
|
225
|
+
});
|
|
226
|
+
return _el$22;
|
|
227
|
+
})();
|
|
228
|
+
const file = entry.file;
|
|
229
|
+
const [hovered, setHovered] = createSignal(false);
|
|
230
|
+
return (() => {
|
|
231
|
+
var _el$23 = _$createElement("box"),
|
|
232
|
+
_el$24 = _$createElement("text"),
|
|
233
|
+
_el$25 = _$createElement("text"),
|
|
234
|
+
_el$26 = _$createTextNode(` `),
|
|
235
|
+
_el$27 = _$createElement("span"),
|
|
236
|
+
_el$28 = _$createTextNode(`+`),
|
|
237
|
+
_el$29 = _$createTextNode(` `),
|
|
238
|
+
_el$30 = _$createElement("span"),
|
|
239
|
+
_el$31 = _$createTextNode(`−`);
|
|
240
|
+
_$insertNode(_el$23, _el$24);
|
|
241
|
+
_$insertNode(_el$23, _el$25);
|
|
242
|
+
_$setProp(_el$23, "flexDirection", "column");
|
|
243
|
+
_$setProp(_el$23, "marginBottom", 1);
|
|
244
|
+
_$setProp(_el$23, "onMouseOver", () => setHovered(true));
|
|
245
|
+
_$setProp(_el$23, "onMouseOut", () => setHovered(false));
|
|
246
|
+
_$setProp(_el$23, "onMouseUp", event => {
|
|
247
|
+
if (event.button !== 0 || context.renderer.getSelection()?.getSelectedText()) return;
|
|
248
|
+
event.stopPropagation();
|
|
249
|
+
context.keymap.dispatch("diff.open");
|
|
250
|
+
});
|
|
251
|
+
_$setProp(_el$24, "wrapMode", "char");
|
|
252
|
+
_$insert(_el$24, () => entry.name);
|
|
253
|
+
_$insertNode(_el$25, _el$26);
|
|
254
|
+
_$insertNode(_el$25, _el$27);
|
|
255
|
+
_$insertNode(_el$25, _el$29);
|
|
256
|
+
_$insertNode(_el$25, _el$30);
|
|
257
|
+
_$insert(_el$25, (() => {
|
|
258
|
+
var _c$ = _$memo(() => file.status === "added");
|
|
259
|
+
return () => _c$() ? "A" : file.status === "deleted" ? "D" : "M";
|
|
260
|
+
})(), _el$26);
|
|
261
|
+
_$insertNode(_el$27, _el$28);
|
|
262
|
+
_$insert(_el$27, () => file.additions, null);
|
|
263
|
+
_$insertNode(_el$30, _el$31);
|
|
264
|
+
_$insert(_el$30, () => file.deletions, null);
|
|
265
|
+
_$effect(_p$ => {
|
|
266
|
+
var _v$8 = entry.depth * 2,
|
|
267
|
+
_v$9 = hovered() ? context.theme.background.action.primary.hovered : undefined,
|
|
268
|
+
_v$0 = context.theme.text.base,
|
|
269
|
+
_v$1 = context.theme.text.muted,
|
|
270
|
+
_v$10 = {
|
|
271
|
+
fg: addedColor()
|
|
272
|
+
},
|
|
273
|
+
_v$11 = {
|
|
274
|
+
fg: deletedColor()
|
|
275
|
+
};
|
|
276
|
+
_v$8 !== _p$.e && (_p$.e = _$setProp(_el$23, "paddingLeft", _v$8, _p$.e));
|
|
277
|
+
_v$9 !== _p$.t && (_p$.t = _$setProp(_el$23, "backgroundColor", _v$9, _p$.t));
|
|
278
|
+
_v$0 !== _p$.a && (_p$.a = _$setProp(_el$24, "fg", _v$0, _p$.a));
|
|
279
|
+
_v$1 !== _p$.o && (_p$.o = _$setProp(_el$25, "fg", _v$1, _p$.o));
|
|
280
|
+
_v$10 !== _p$.i && (_p$.i = _$setProp(_el$27, "style", _v$10, _p$.i));
|
|
281
|
+
_v$11 !== _p$.n && (_p$.n = _$setProp(_el$30, "style", _v$11, _p$.n));
|
|
282
|
+
return _p$;
|
|
283
|
+
}, {
|
|
284
|
+
e: undefined,
|
|
285
|
+
t: undefined,
|
|
286
|
+
a: undefined,
|
|
287
|
+
o: undefined,
|
|
288
|
+
i: undefined,
|
|
289
|
+
n: undefined
|
|
290
|
+
});
|
|
291
|
+
return _el$23;
|
|
292
|
+
})();
|
|
293
|
+
}
|
|
294
|
+
}));
|
|
295
|
+
return _el$15;
|
|
296
|
+
}
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
}));
|
|
302
|
+
_$effect(_p$ => {
|
|
303
|
+
var _v$3 = context.theme.text.base,
|
|
304
|
+
_v$4 = {
|
|
305
|
+
fg: context.theme.text.muted
|
|
306
|
+
},
|
|
307
|
+
_v$5 = expanded();
|
|
308
|
+
_v$3 !== _p$.e && (_p$.e = _$setProp(_el$3, "fg", _v$3, _p$.e));
|
|
309
|
+
_v$4 !== _p$.t && (_p$.t = _$setProp(_el$4, "style", _v$4, _p$.t));
|
|
310
|
+
_v$5 !== _p$.a && (_p$.a = _$setProp(_el$14, "visible", _v$5, _p$.a));
|
|
311
|
+
return _p$;
|
|
312
|
+
}, {
|
|
313
|
+
e: undefined,
|
|
314
|
+
t: undefined,
|
|
315
|
+
a: undefined
|
|
316
|
+
});
|
|
317
|
+
return _el$;
|
|
318
|
+
})();
|
|
319
|
+
}
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
});
|
package/dist/worktree.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export function isGitWorktree(project, trees) {
|
|
2
|
+
return project.directory !== project.canonical && trees.some(tree => tree.directory === project.directory && tree.strategy === "git");
|
|
3
|
+
}
|
|
4
|
+
export async function loadWorktreeBadge(client, directory) {
|
|
5
|
+
try {
|
|
6
|
+
const {
|
|
7
|
+
project
|
|
8
|
+
} = await client.location.get({
|
|
9
|
+
location: {
|
|
10
|
+
directory
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
if (project.directory === project.canonical) return {
|
|
14
|
+
directory,
|
|
15
|
+
isWorktree: false
|
|
16
|
+
};
|
|
17
|
+
const trees = await client.worktree.list({
|
|
18
|
+
projectID: project.id
|
|
19
|
+
});
|
|
20
|
+
return {
|
|
21
|
+
directory,
|
|
22
|
+
isWorktree: isGitWorktree(project, trees)
|
|
23
|
+
};
|
|
24
|
+
} catch {
|
|
25
|
+
return {
|
|
26
|
+
directory,
|
|
27
|
+
isWorktree: false
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@daoninc/opencode-changed-files",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Working-tree changes, diff totals, and worktree indicators in the OpenCode sidebar",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"exports": { "./tui": "./dist/tui.js" },
|
|
8
|
+
"files": ["dist", "README.md", "LICENSE"],
|
|
9
|
+
"scripts": { "test": "bun test", "prepack": "bun run ../../scripts/build.ts .", "prepublishOnly": "bun run ../../scripts/build.ts . && bun run ../../scripts/check-release.ts ." },
|
|
10
|
+
"dependencies": { "@opencode/plugin": "^2.3.1" },
|
|
11
|
+
"peerDependencies": { "@opentui/core": ">=0.8.4 <0.9", "@opentui/solid": ">=0.8.4 <0.9", "solid-js": "^1.9.0" },
|
|
12
|
+
"publishConfig": { "access": "public", "registry": "https://registry.npmjs.org/" },
|
|
13
|
+
"keywords": ["opencode", "opencode-plugin", "tui", "git", "sidebar"],
|
|
14
|
+
"repository": { "type": "git", "url": "git+https://github.com/daon-private/sdk-tools.git", "directory": "AI/opencode/plugins/changed-files" }
|
|
15
|
+
}
|