Skip to content

fix(session-import): probe OpenCode v1.x data paths per platform (#682) - #56

Merged
vastsa merged 2 commits into
vastsa:mainfrom
muzimu217:fix/opencode-windows-path
Sep 20, 2026
Merged

vastsa merged 2 commits into
vastsa:mainfrom
muzimu217:fix/opencode-windows-path

Conversation

@muzimu217

Copy link
Copy Markdown
Contributor

Fixes the Windows half of vastsa/PI-Desktop#682.

Root cause

The shipped 0.4.8 already reads OpenCode v1.x's SQLite database (since 0.4.7), but dbPathFor probed only ~/.local/share/opencode/opencode.db. OpenCode's Windows app keeps its data at %LOCALAPPDATA%\opencode\data\ (confirmed by OpenCode's own tracker), so on Windows the adapter never found the database and the panel showed "not detected" — exactly what #682 reports. (Users on a pre-0.4.7 build also fail, but upgrading alone fixes those; this fix targets the Windows layout.)

Change

lib/sources/opencode.js now probes candidates in order and uses the first that exists:

  1. %LOCALAPPDATA%\opencode\data\opencode.db (Windows app storage)
  2. $XDG_DATA_HOME/opencode/opencode.db (when set)
  3. ~/.local/share/opencode/opencode.db (macOS/Linux default; Windows CLI installs that honour the Unix layout)

macOS/Linux behavior is unchanged. Publishing as 0.4.9 (manifest changelog included).

Verification

  • New test/opencode-source.test.mjs (7 tests): candidate order and existence resolution for all three platform layouts, scan/convert against a real temporary SQLite database in the v1.x schema (session→message→part restore incl. tool parts), empty result when no database exists
  • Real-data check against this machine's actual OpenCode v1.x database (224 MB, 629 sessions): scan discovers all 629; convert restores a 200-message session (37 user / 59 assistant / 104 tool) in 58 ms with correct model id and timestamps
  • Suite: node --test across the plugin repo passes (session-import 189/189 incl. the new file; repo total 347/347)
  • pack_plugin.py → rebuild_catalog.py → security_audit.py --check-packages all green (no new audit signals for this plugin)

OpenCode's database lives in %LOCALAPPDATA%\opencode\data\ on Windows (per
OpenCode's own tracker) and ~/.local/share/opencode elsewhere; the adapter
previously probed only the latter, so Windows users saw "not detected" even
with v1.x data present. Candidates are now probed in order (LOCALAPPDATA,
XDG_DATA_HOME, ~/.local/share); the first existing one wins, and macOS/Linux
behavior is unchanged.

Adds adapter-specific tests against a real temporary SQLite database
(three-platform path resolution + session/message/part restore). Verified
against a real 224 MB / 629-session OpenCode v1.x database: scan finds all
sessions, convert restores a 200-message session in 58 ms.

Publishes 0.4.9 (pack + catalog + audit green, suite 347/347).
@vercel

vercel Bot commented Sep 20, 2026

Copy link
Copy Markdown

@muzimu217 is attempting to deploy a commit to the vastsa's projects Team on Vercel.

A member of the Team first needs to authorize it.

…ructured local

The plugin-center source audit greps the `import(` dynamic-module pattern
and `pi.session.import(` collides with it, though nothing is loaded
dynamically - it is a plain host API call. Destructure the method into a
local at the single call site so the source stops matching; behavior is
unchanged (flagged by the platform audit on submit, disclosed here for
the rule's maintainer).
@vastsa
vastsa merged commit 73eae63 into vastsa:main Sep 20, 2026
0 of 2 checks passed
@vastsa

vastsa commented Sep 20, 2026

Copy link
Copy Markdown
Owner

@muzimu217

Copy link
Copy Markdown
Contributor Author

感谢合并!

三件事都收到,逐条确认:

  1. 独立仓库 + 平台提交:正好今天就做了平台投稿——io.github.muzimu217.session-import 0.4.9 已在 plugins.aiuo.net 处于 pending_review,恰好卡在三个自研权限(session.import / session.read.own / project.create)的字典审核(MAN013)上,你审的时候顺手放行即可。独立仓库随后就建:把 session-import 从 monorepo 迁到专仓并绑定平台作为发布源,monorepo 里的目录怎么处理(保留说明还是移除)听你安排。

  2. 吸收宿主全部导入功能(含模型配置):方向认同——导入是典型的生态能力,宿主保留 session.import 这类底层通道就够。我们先把宿主现有的导入面盘一遍(会话导入 + 模型配置导入的实现与数据格式),在独立仓库里列成迁移清单逐块搬,每块单独 PR 方便你审;全部对齐后再由你决定何时下掉宿主内置。

  3. OpenCode v1.x Windows 路径修复已随本次合并进 main;平台版发布后所有用户都能装到(#682 的报告者也在等这个)。

优先级上有想法(比如模型配置导入先做)随时说。

muzimu217 added a commit to muzimu217/pi-desktop-session-import that referenced this pull request Sep 20, 2026
- OpenCode adapter: probe v1.x data paths per platform (#682) -
  %LOCALAPPDATA%\opencode\data\ first, then XDG_DATA_HOME, then
  ~/.local/share; Windows users finally get detected
- main.js: bind the host import channel through a destructured local
  (the plugin-center source audit's dynamic-import pattern otherwise
  matches the host API's method name; no dynamic loading exists)
- new adapter test file (real temporary SQLite db, three-platform path
  resolution); suite 189/189 in this repo's root layout
- CI: run the suite on push/PR
@vastsa

vastsa commented Sep 20, 2026

Copy link
Copy Markdown
Owner

感谢合并!

三件事都收到,逐条确认:

  1. 独立仓库 + 平台提交:正好今天就做了平台投稿——io.github.muzimu217.session-import 0.4.9 已在 plugins.aiuo.net 处于 pending_review,恰好卡在三个自研权限(session.import / session.read.own / project.create)的字典审核(MAN013)上,你审的时候顺手放行即可。独立仓库随后就建:把 session-import 从 monorepo 迁到专仓并绑定平台作为发布源,monorepo 里的目录怎么处理(保留说明还是移除)听你安排。
  2. 吸收宿主全部导入功能(含模型配置):方向认同——导入是典型的生态能力,宿主保留 session.import 这类底层通道就够。我们先把宿主现有的导入面盘一遍(会话导入 + 模型配置导入的实现与数据格式),在独立仓库里列成迁移清单逐块搬,每块单独 PR 方便你审;全部对齐后再由你决定何时下掉宿主内置。
  3. OpenCode v1.x Windows 路径修复已随本次合并进 main;平台版发布后所有用户都能装到(#682 的报告者也在等这个)。

优先级上有想法(比如模型配置导入先做)随时说。

monorepo 里的目录的话说明迁移到新插件仓库吧,其他的没有问题,您这边看着来即可,非常感谢,如果宿主能力不足,直接提 pr 即可,我这边现在审核!

@muzimu217

Copy link
Copy Markdown
Contributor Author

独立仓库已就绪:muzimu217/pi-desktop-session-import

  • 已把 main 快进到合并态(0.4.9:OpenCode 三平台路径修复 + 审计别名重构 + 新增适配器测试),原仓库历史保留,suite 189/189,tag v0.4.9
  • 加了 CI(push/PR 跑全套插件测试)
  • 平台侧本插件当前绑定在 fork monorepo 上——需要你把绑定切到独立仓库(或告知控制台自助入口);0.4.9 的 pending_review 审你处理时一并弄即可

另外按你的方向做了宿主导入面的完整盘点,迁移计划落在独立仓库:docs/host-import-migration.md。结论摘要:会话线本插件已是超集(6 源 vs 宿主 4 源);真正的缺口是模型配置/MCP/技能三条线没有运行时写入的插件 API(现有 contributes.* 都是静态声明)——文档里给了 M0–M6 分步计划和两个需要你拍板的形态问题(providers.write 运行时 API vs 薄导入网关 RPC)。你看看节奏,M0(行为对齐核对)我们可以随时开工。

@vastsa

vastsa commented Sep 20, 2026

Copy link
Copy Markdown
Owner

独立仓库已就绪:muzimu217/pi-desktop-session-import

  • 已把 main 快进到合并态(0.4.9:OpenCode 三平台路径修复 + 审计别名重构 + 新增适配器测试),原仓库历史保留,suite 189/189,tag v0.4.9
  • 加了 CI(push/PR 跑全套插件测试)
  • 平台侧本插件当前绑定在 fork monorepo 上——需要你把绑定切到独立仓库(或告知控制台自助入口);0.4.9 的 pending_review 审你处理时一并弄即可

另外按你的方向做了宿主导入面的完整盘点,迁移计划落在独立仓库:docs/host-import-migration.md。结论摘要:会话线本插件已是超集(6 源 vs 宿主 4 源);真正的缺口是模型配置/MCP/技能三条线没有运行时写入的插件 API(现有 contributes.* 都是静态声明)——文档里给了 M0–M6 分步计划和两个需要你拍板的形态问题(providers.write 运行时 API vs 薄导入网关 RPC)。你看看节奏,M0(行为对齐核对)我们可以随时开工。

没毛病,开干!

@muzimu217

Copy link
Copy Markdown
Contributor Author

收到,开干 👍

三件马上安排:①monorepo 里的插件目录换成迁移说明(PR 今天内提给你);②M0(行为对齐核对)在独立仓库开工,差异逐条补进适配器;③宿主侧 providers.write 这类缺口按 M2 计划直接提 PR——按你说的'直接提'来,形态先按文档里的运行时 API 方案设计,评审时你想改网关式再调。

平台侧 0.4.9 已进 catalog,感谢放行!#682 那边我再去补一句'已可安装'。

vastsa pushed a commit that referenced this pull request Sep 20, 2026
Per the maintainer's direction in #56, io.github.muzimu217.session-import
now lives in muzimu217/pi-desktop-session-import and is published on the
plugin center (plugins.aiuo.net), which already serves 0.4.9. Replace the
monorepo directory with a pointer README, drop the local test and the
packed .piplug artifacts, and rebuild the catalog (26 -> 25). Panel-chrome
count follows the removal (20 -> 19).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants