Files
oc_session/README.md
T

79 lines
3.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# oc-session-all
OpenCode TUI 插件:弹出全项目会话选择器,跨所有项目浏览和切换会话。
## 功能
- `Ctrl+o` 或 `/sessions-all` 打开可搜索的会话选择面板
- 按项目分组、按更新时间倒序排列
- 过滤掉已归档和子代理会话
- 对调2份`opencode.json`实现拦截mcp报错的toast
- 热更新skill,新的skill丢入目录,插件自动发现并更新
- **MCP 推送兜底(v10)**:`config.get` 取 shell(GET→活文件→null 三级兜底)→
`config.update({config})` → `({body})` → `experimental.config.update` 三跳推进
运行中的 OC,配合 reload 双保险;`/mcpon` `/mcpoff` 可用
## 安装
在 `~/.config/opencode/tui.json` 中添加(现役源码是 `.js`,部署副本放 `tui-plugins/` 下):
```json
{
"$schema": "https://opencode.ai/tui.json",
"plugin": [
"file:///C:/Users/<你>/.config/opencode/tui-plugins/oc-session-all.js"
]
}
```
WSL 侧同理:`file:///root/.config/opencode/tui-plugins/oc-session-all.js`。
源码改动后需同步部署副本(本机 + WSL 两处,MD5 应与源码一致),重启 OpenCode 生效。
## 快捷键
| 快捷键 | 命令 | 说明 |
|--------|------|------|
| `Ctrl+o` | — | 打开会话选择器 |
| `/sessions-all` | `resume-all`, `continue-all` | 斜杠命令 |
| — | `/mcpon` `/mcpoff` | MCP 开关(对调 + 推送兜底 + 热重载) |
| — | 任意位置 `/home` 等 | CLI 菜单(`wsl-round-mcp/oc.py`)跳回顶层,见下节 |
## skill 推拉(wsl-round-mcp)
菜单入口 `oc.py`(任意位置 `/home` 回顶层),skill 管理简化为三动作,**输出路径用户不可选**:
- **推送 push**:只输入源路径(带引号自动剥离成对引号,单侧引号不动)→ 输出固定为 WSL OC skill 目录;
先只读探查同名文件夹:**不存在直接放,存在才询问是否覆盖**(`--force` 跳过确认)。
- **拉取 pull**:只输入 skill 名 → 输出固定为本机 `~/.config/opencode/skills`,同样探查式覆盖。
- **删除 delete**:`--local` 删本机 / 缺省删 WSL,`--yes` 跳过确认;不存在时报错退出码非 0。
- 覆盖与删除统一先移入 `<skills根>/.trash/<时间戳>/` 备份(点前缀目录,OC 不会当技能加载)。
- 推送前过标准 skill 校验(SKILL.md 结构等),不合规拒推。
## 项目结构
```
oc_session/
├── tui-plugins/
│ ├── oc-session-all.js ← 现役插件源码(OC 加载入口,v10)
│ ├── oc-session-all.ts ← 旧版留档
│ ├── oc-session-all-debug.js
│ └── readmcpcfg.test.mjs ← mcpcfg 解析 16 项单测(node readmcpcfg.test.mjs)
├── ai-mcp/ ← 独立 git 仓库(分支 ai-mcp),server 插件
│ ⚠ 双导出配方(default+占位命名导出,body 禁改)见 ai-mcp.ts 头注释:
│ 2026-09-23 三态写盘实验证实,缺失/返回对象/直返 undefined 均触发
│ OC 2.0.15 批量 reload 崩溃(Ae is not a function)
├── wsl-round-mcp/ ← 独立 git 仓库(分支 wsl-round-mcp),Python CLI
├── package.json
├── node_modules/
├── .gitignore
└── README.md
```
## 分支结构
| 分支 | 内容 |
| :---: | :---: |
| main | 主插件,会话切换、skill热加载、用户端mcp配置对调等 |
| ai-mcp | 大模型操作mcp配置对调的插件 |
| wsl-round-mcp | wsl和win之间的skill互推、mcp配置互推等 |