0
365
近 7 天 365
35.7
生态多维模型
4 小时前
2026-10-21
快速安装与配置
opencode.json写入当前项目的 opencode.json,只对这个仓库生效。
opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-session-diff@0.1.1"]
}写入 ~/.config/opencode/opencode.json,对所有项目生效。
~/.config/opencode/opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-session-diff@0.1.1"]
}若你要在本地改造这个插件,先装到项目里再从本地路径引用。
shell
pnpm add -D opencode-session-diffOpenCode 启动时会通过内嵌运行时自动加载 npm 依赖并缓存至本地目录,无需手动在全局环境执行安装。
Not an official OpenCode / SST product. This is a community plugin, not affiliated with or endorsed by OpenCode.
English | 简体中文
Changes sidebar panel for OpenCode — see every file the current session touched, at a glance.
A TUI plugin for OpenCode that adds a Changes section to the session sidebar. It lists every file the current session modified, added, or deleted, with ± line counts, highlights the file being edited right now, and click-through to the built-in diff viewer.
▼ Changes (4) +154 −18
• src/agent/loop.ts +28 −9
• src/tools/fs.ts +110 −3
• test/loop.test.ts +13
• src/legacy/runner.ts −6
Features
- Session-scoped: exactly what this conversation changed — powered by the server's
session.diffsnapshot, not a client-side guess. - Added / modified / deleted with per-file
+additions −deletionscounters, right-aligned. - Live-edit highlight: the file being edited turns warning-colored for a few seconds (
session.tool.*events; filesystem watcher as fallback). - Click to review: opens the official diff viewer, already scoped to this session's changes.
- Events, not polling: refreshes on round completion and
/undo; no timers in the background. - Theme-aware: all colors come from the host theme (dark/light/custom).
- Zero config.
Install
opencode plugin add opencode-session-diff@latest
Recommended host setting so the diff viewer opens on the session's own changes rather than the git branch:
// ~/.config/opencode/cli.json
{
"diffs": { "source": "turn" }
}
The sidebar shows when space allows (session.sidebar: "auto"). Toggle it with Ctrl+X then B.
Usage
| Action | Result |
|---|---|
| Click the Changes title | Collapse / expand the section |
| Click a file row | Open the diff viewer (session source) |
Ctrl+P → Toggle collapse (Changes group) |
Same collapse, keyboard-only |
Collapse state is persisted per TUI instance.
Requirements
- OpenCode ≥ 2.0.x (V2 plugin API,
@opencode/plugin/tui) - A git repository is not required; the panel is driven by the session snapshot
How it works
- The plugin registers a
sidebar.content-anchored claim (afterthe content boundary, below other sections, above the footer) with@opencode/plugin'sui.slot. - It fetches
client.session.diff({ sessionID })and classifies eachFileDiff.Infoby its authoritativestatus(added/deleted/modified), falling back to ± counts ifstatusis absent. - Refreshes are debounced 500 ms and triggered by
session.execution.succeeded,session.idle, andsession.revert.*events. - The host paints only the synchronous snapshot returned by the slot render, so any state change re-registers the claim (documented in
docs/DEVELOPMENT.md).
Limitations
- The official diff viewer cannot focus a single file from the API; clicking opens the whole session diff (navigate files with
n/pinside it). - The plugin is TUI-only (V2). It ships a no-op server stub because the host loader requires one.
Development
bun install
bun run build # dist/index.js + dist/tui.js (host deps stay external)
bun test # 34 unit tests
bun run typecheck
Deeper notes, verified API contracts, and edge cases live in docs/DEVELOPMENT.md.
License
同类生态推荐
Fold Diffs
opencode-fold-diffs
OpenCode TUI plugin: write, edit, apply_patch and long bash commands render folded to their title line, click or ctrl+o to open them.
Review
@opencode-cockpit/review
A pull request in the terminal: read the diff, hold your notes, send one review
Fork Lane
@bojackduy/opencode-fork-lane
Fork-lane for OpenCode — lane-inspired copy-on-write git worktrees + session fork. /fork-lane (/lane) creates a new branch + worktree (reflink for ignored files) and forks the session into it. Agent-callable via fork_lane tool (alias lane).