@cardinal4/opencode-fold-diffs 0.3.0 → 0.3.2
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 +9 -2
- package/package.json +2 -2
- package/tui.js +6 -3
package/README.md
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
# opencode-fold-diffs
|
|
2
2
|
|
|
3
|
+
> [!IMPORTANT]
|
|
4
|
+
> **This is a fork, and it exists for one reason: OpenCode V2 support.**
|
|
5
|
+
>
|
|
6
|
+
> The original plugin is **[Tanner Bruhn](https://github.com/tannerbruhn)**'s [`tannerbruhn/opencode-fold-diffs`](https://github.com/tannerbruhn/opencode-fold-diffs) (npm: `opencode-fold-diffs`) — the **OpenCode V1** plugin, whose V1 implementation does not run in V2. This fork — [`cardin/opencode-fold-diffs`](https://github.com/cardin/opencode-fold-diffs), published as [`@cardinal4/opencode-fold-diffs`](https://www.npmjs.com/package/@cardinal4/opencode-fold-diffs) — ports it to **OpenCode V2** (the `@opencode/cli` 2.x line, `opencode v2.0.x`). Install this fork if you are on V2; install upstream if you are on V1.
|
|
7
|
+
>
|
|
8
|
+
> **All credit for the original plugin goes to [Tanner Bruhn](https://github.com/tannerbruhn).** This fork is unofficial and independent: Tanner has not reviewed it, does not maintain it, and does not endorse it. Report bugs in this fork here, not upstream.
|
|
9
|
+
|
|
3
10
|
**Every `write` and `edit` dumps the whole file or the whole diff into your transcript, and stays there.** This plugin folds those blocks down to their header line — `# Wrote 40 lines · click to expand src/app.ts` — and opens them again on click, or with a fold/unfold-all key if you configure one.
|
|
4
11
|
|
|
5
|
-
|
|
12
|
+
The V2 port is not a re-host: it follows V2's new plugin API and render tree, so the V1 code cannot be reused. See [Migrating from V1](#migrating-from-v1) for what changed.
|
|
6
13
|
|
|
7
14
|
## What V2 already folds
|
|
8
15
|
|
|
@@ -121,7 +128,7 @@ Blocks are re-scanned on `message.part.updated` and `message.updated`, plus a 2
|
|
|
121
128
|
|
|
122
129
|
## Migrating from V1
|
|
123
130
|
|
|
124
|
-
V1 plugin implementations do not run in V2.
|
|
131
|
+
V1 plugin implementations do not run in V2. The V2 port made these changes:
|
|
125
132
|
|
|
126
133
|
- Entrypoint is a `{ id, setup(context) }` definition (`Plugin.define()` is an identity helper, so the shape is the same). `setup` returns the cleanup function instead of `api.lifecycle.onDispose`.
|
|
127
134
|
- `api.renderer` → `context.renderer`; `api.route.current.name` → `context.ui.router.current().type`; `api.event.on` → `context.data.on`; `api.ui.toast` → `context.ui.toast.show`; `api.keymap.registerLayer` → `context.keymap.layer`.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cardinal4/opencode-fold-diffs",
|
|
3
|
-
"version": "0.3.
|
|
4
|
-
"description": "OpenCode V2
|
|
3
|
+
"version": "0.3.2",
|
|
4
|
+
"description": "Unofficial OpenCode V2 fork of opencode-fold-diffs: write, edit and apply_patch blocks render folded to their header line, click to expand.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"keywords": [
|
package/tui.js
CHANGED
|
@@ -89,14 +89,17 @@ function plain(node) {
|
|
|
89
89
|
|
|
90
90
|
// Duck-typing, not instanceof: the classes live in the host's bundled
|
|
91
91
|
// @opentui/core and are minified, so their names are not stable. A diff
|
|
92
|
-
// renderable is the only thing in the tree carrying a `diff` string
|
|
93
|
-
// renderable the only thing
|
|
92
|
+
// renderable is the only thing in the tree carrying a `diff` string. A code
|
|
93
|
+
// renderable is the only thing whose `content` is a string -- text renderables
|
|
94
|
+
// carry a styled-text `content` object and expose `plainText` instead. OpenCode
|
|
95
|
+
// 2.0.16 stopped setting `filetype` on a written file's body, so it must not be
|
|
96
|
+
// required (requiring it silently stopped every write block from folding).
|
|
94
97
|
function isDiff(node) {
|
|
95
98
|
return typeof node?.diff === "string";
|
|
96
99
|
}
|
|
97
100
|
|
|
98
101
|
function isCode(node) {
|
|
99
|
-
return typeof node?.content === "string"
|
|
102
|
+
return typeof node?.content === "string";
|
|
100
103
|
}
|
|
101
104
|
|
|
102
105
|
// The command text of a bash block, or nothing. V2 wraps the command and its
|