@cardinal4/opencode-fold-diffs 0.3.3 → 0.3.4
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 +1 -0
- package/package.json +1 -1
- package/tui.js +25 -6
package/README.md
CHANGED
|
@@ -132,6 +132,7 @@ V1 plugin implementations do not run in V2. The V2 port made these changes:
|
|
|
132
132
|
|
|
133
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`.
|
|
134
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`.
|
|
135
|
+
- `context.keymap.layer` is called directly from `setup` on 2.0.23+; earlier V2 builds read Solid context there, so the plugin still registers from a component mounted in the `app` slot for them.
|
|
135
136
|
- Event names are V2's: `message.updated` / `message.part.updated` are legacy schemas in V2 and are never emitted. The plugin listens to `session.message.content.updated`, `session.tool.success` / `session.tool.failed`, `session.step.ended` and `session.execution.succeeded` (plus `session.shell.ended` when bash folding is on). These names exist from 2.0.10 on, so older V2 installs get the same fix without upgrading.
|
|
136
137
|
- Tool headers are no longer one string. V1 rendered `"← Edit src/app.ts"`; V2 renders a label node plus a path node, so detection and the stats suffix target the label.
|
|
137
138
|
- `bash` defaults to `false`, because V2 now trims long commands to two lines itself.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cardinal4/opencode-fold-diffs",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4",
|
|
4
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",
|
package/tui.js
CHANGED
|
@@ -241,6 +241,16 @@ function dumpNode(node, depth, lines, limit) {
|
|
|
241
241
|
for (const kid of kids) dumpNode(kid, depth + 1, lines, limit);
|
|
242
242
|
}
|
|
243
243
|
|
|
244
|
+
// 2.0.23 was the first V2 release whose `keymap.layer` may be called from
|
|
245
|
+
// setup; before that it reads Solid context and needs a mounted component.
|
|
246
|
+
// An unparseable version takes the fallback, which works on every V2 build.
|
|
247
|
+
function supportsSetupKeymap(version) {
|
|
248
|
+
const match = /(\d+)\.(\d+)\.(\d+)/.exec(String(version ?? ""));
|
|
249
|
+
if (!match) return false;
|
|
250
|
+
const [major, minor, patch] = match.slice(1).map(Number);
|
|
251
|
+
return major > 2 || (major === 2 && (minor > 0 || patch >= 23));
|
|
252
|
+
}
|
|
253
|
+
|
|
244
254
|
export const PLUGIN_ID = "opencode-fold-diffs";
|
|
245
255
|
|
|
246
256
|
export default {
|
|
@@ -435,10 +445,11 @@ export default {
|
|
|
435
445
|
const timer = setInterval(sweep, SWEEP_MS);
|
|
436
446
|
schedule();
|
|
437
447
|
|
|
438
|
-
//
|
|
439
|
-
//
|
|
440
|
-
//
|
|
441
|
-
|
|
448
|
+
// The command layer itself is identical everywhere; only who registers it
|
|
449
|
+
// differs. 2.0.23+ runs `keymap.layer` from setup and owns its teardown.
|
|
450
|
+
// Older V2 reads Solid context when registering, so there the layer has to
|
|
451
|
+
// be created by a mounted component. The `app` slot supplies one.
|
|
452
|
+
function registerCommands() {
|
|
442
453
|
context.keymap.layer(() => ({
|
|
443
454
|
mode: "global",
|
|
444
455
|
priority: 100,
|
|
@@ -516,9 +527,17 @@ export default {
|
|
|
516
527
|
],
|
|
517
528
|
bindings: opts.key ? ["opencode-fold-diffs.toggle"] : [],
|
|
518
529
|
}));
|
|
519
|
-
return null;
|
|
520
530
|
}
|
|
521
|
-
|
|
531
|
+
let stopCommands = () => {};
|
|
532
|
+
if (supportsSetupKeymap(context.app?.version)) {
|
|
533
|
+
registerCommands();
|
|
534
|
+
} else {
|
|
535
|
+
function FoldCommands() {
|
|
536
|
+
registerCommands();
|
|
537
|
+
return null;
|
|
538
|
+
}
|
|
539
|
+
stopCommands = context.ui.slot({ append: "app", render: () => FoldCommands() });
|
|
540
|
+
}
|
|
522
541
|
|
|
523
542
|
return () => {
|
|
524
543
|
stopCommands();
|