Skip to content

v0.8.9:技能根指向账号真实的 ~/.agents(自动迁移旧版私有根)/ Skill Root Moves to the Account's Real ~/.agents

Choose a tag to compare

@btsd321 btsd321 released this 28 Oct 01:47
· 14 commits to master since this release

中文

新功能

  • 🟢 技能与全局指令改指账号真实的 ~/.agents:DSH_AGENTS_HOME 从本工具私有的 btsd321/.agents 改为远端账号的 ~/.agents(dsh 的默认值)。用户在同一台机器上早已维护的技能与 ~/.agents/AGENTS.md 全局指令,现在在远端会话里直接生效;远端窗口里装的技能,原生 dsh 也共享同一份。同一远端账号下换工作目录开会话,技能依然在。
  • 旧版私有根自动迁移:首次连接把 btsd321/.agents 里的技能与 AGENTS.md 并入 ~/.agents——同名冲突项不迁移(保留新版,旧副本原地留下),第三方安装器元数据 .skill-lock.json 不搬运(dsh 的技能发现只扫目录,本工具不伪造来源/hash)。迁移幂等、失败只跳过该阶段、不影响会话;写入经 base/tmp/agents.lock 的 flock 串行化,多个会话同时连接不会互相踩。
  • 迁移后旧版空目录与本工具旧 .lock 自动收尾(rmdir 只删空目录,有冲突项或第三方元数据时保留)。

修复

  • 代码审查发现:迁移「无可迁项」分支的旧根收尾(rm .lock / rmdir)此前绕过 flock,与「所有写 ~/.agents 的动作共用同一把锁」不一致;现在收尾与搬运走同一临界区。
  • AGENTS.md 的搬运结果不再复用技能名输出通道(技能根里若存在同名平铺技能 AGENTS.md 会被误记成全局指令),改用独立标签区分。
  • 预建 ~/.agents/skills 改为失败容忍:该根现在归用户(可能是只读目录、软链或普通文件),预建只是 watcher 优化,失败交由 dsh 自带的轮询兜底,不该连会话启动一起挂掉。
  • clean 不再删除任何 agent 目录:~/.agents(技能与全局 AGENTS.md)属于用户数据,与 plugin store 同一纪律;旧 btsd321/.agents 也保留,避免丢掉未迁移的同名冲突项。
  • 锁文件从 .agents/.lock 迁到 base/tmp/agents.lock,不再往用户目录写本工具的内部文件。

文档

  • README(中/英)、usage(中/英)更新:技能根位置、本工具对 ~/.agents 的两处写操作(预建空 skills/ + 迁移)、clean 语义、迁移规则,以及「被复用的旧远端进程仍带旧 DSH_AGENTS_HOME,需重启远端会话才读到新根」。
  • lessons 第 11/22 条重写:记录技能根从「会话级 → 工具机器级 → 账号级」三代演进与判据(dsh 的 agent-instructions 与 skill-filesystem 只认这个根)。
  • 单测同步:remote-paths/agents-lock 断言新归属;新增迁移计划用例(冲突不迁移、平铺 .md、AGENTS.md 冲突);删除 clean-agents 旧用例。

验证

  • pnpm run typecheck 零错误;scripts/check-plugin.ts 全通过;单元测试 664 个用例 661 通过 / 3 skipped(既有 POSIX-only)/ 0 失败。
  • 依赖真实 POSIX shell 的 WSL 冒烟:在 /tmp 沙箱跑完整迁移——非冲突技能迁走、同名冲突保留、AGENTS.md 首次迁移且二次冲突跳过、旧 .lock 清理、空旧根移除、二次调用幂等,全部符合预期;锁文件落在 base/tmp/agents.lock。
  • build:plugin 重建后 lib/ 可复现(工作区干净),产物内联版本 0.8.9。

English

Features

  • 🟢 Skills and global instructions now use the account's real ~/.agents: DSH_AGENTS_HOME moves from this tool's private btsd321/.agents to the remote account's ~/.agents (dsh's default). Skills and the ~/.agents/AGENTS.md global instructions you already maintain on that machine now apply directly in remote sessions, and skills installed from the remote window are shared with native dsh. Opening a session in a different working directory on the same account keeps your skills.
  • Automatic migration of the old private root: on first connect, skills and AGENTS.md under btsd321/.agents are merged into ~/.agents — same-name entries are not migrated (the new copy wins and the old one stays in place), and external installer metadata (.skill-lock.json) is not carried over (dsh's skill discovery only scans directories; this tool does not fabricate source/hash records). The migration is idempotent, a failure only skips the stage and never blocks the session, and writes are serialized by a flock at base/tmp/agents.lock so concurrent sessions cannot step on each other.
  • Empty legacy directories and the tool's old .lock are cleaned up afterwards (rmdir only removes empty directories; conflicts or third-party metadata are kept).

Fixes

  • Found in code review: the no-op branch's legacy cleanup (rm .lock / rmdir) bypassed the flock, contradicting the rule that every write to ~/.agents shares one lock; cleanup and moves now run in the same critical section.
  • The AGENTS.md move result no longer reuses the skill-name output channel (a flat skill named AGENTS.md would have been misreported as the global instruction file); it now uses its own tags.
  • Pre-creating ~/.agents/skills is now failure-tolerant: the root belongs to the user (it may be read-only, a symlink, or a regular file), pre-creation is only a watcher optimization, and dsh's own polling is the fallback — it must not take session startup down with it.
  • clean no longer deletes any agent directory: ~/.agents (skills and global AGENTS.md) is user data, the same discipline as the plugin store; the old btsd321/.agents is kept too so unmigrated same-name conflicts are not lost.
  • The lock file moves from .agents/.lock to base/tmp/agents.lock, so this tool no longer writes its internal lock into the user's home.

Documentation

  • README (zh/en) and usage (zh/en): skill root location, the two places this tool writes into ~/.agents (empty skills/ pre-create + migration), clean semantics, migration rules, and the note that a reused remote process still carries the old DSH_AGENTS_HOME and needs a restart to read the migrated skills.
  • lessons #11/#22 rewritten: the three-generation evolution of the skill root (session-level → tool machine-level → account-level) and the evidence behind it (dsh's agent-instructions and skill-filesystem only read that root).
  • Tests updated: remote-paths/agents-lock assert the new ownership; new migration-plan cases (conflict skip, flat .md, AGENTS.md conflict); the obsolete clean-agents cases are removed.

Verification

  • pnpm run typecheck clean; scripts/check-plugin.ts fully passing; 664 unit tests — 661 passed / 3 skipped (pre-existing POSIX-only) / 0 failed.
  • WSL smoke test driven by a real POSIX shell: a complete migration in a /tmp sandbox — non-conflicting skills moved, same-name conflicts kept, AGENTS.md migrated once and skipped on the second run, old .lock removed, empty legacy root removed, second call idempotent; all as expected, with the lock at base/tmp/agents.lock.
  • build:plugin reproduces lib/ exactly (clean working tree); the bundle inlines version 0.8.9.

Full Changelog: v0.8.8...v0.8.9