dsh-session-history 0.2.1 → 0.2.3
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 +38 -5
- package/index.js +2 -0
- package/lib/links.js +11 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -52,14 +52,45 @@ dsh-session-history
|
|
|
52
52
|
dsh plugin --profile desktop add dsh-session-history
|
|
53
53
|
```
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
### 你要做的只有两件事
|
|
56
56
|
|
|
57
|
-
1.
|
|
58
|
-
2.
|
|
59
|
-
|
|
57
|
+
1. **装好插件。** 约 20 秒后会自动做第一次整理(也可以在插件详情点 **立即整理**)。
|
|
58
|
+
2. **在插件详情的「技能接入」里点「建软链」**(或「全部接入」)。几家共用一个技能文件夹时只需点一次。
|
|
59
|
+
|
|
60
|
+
然后在各个 agent 里**新开一个对话**——多数 agent 只在会话开始时读取技能清单,已经开着的对话看不到新技能(DSH 会自动刷新)。之后你提到“之前”“上次”,agent 会自己去查。
|
|
60
61
|
|
|
61
62
|
不用 DSH 也能用:`npm i -g dsh-session-history`,再运行 `session-history setup`、`session-history refresh`、`session-history link all`。需要 Node 22.15 以上(推荐 24)。
|
|
62
63
|
|
|
64
|
+
### 第一次使用会发生什么
|
|
65
|
+
|
|
66
|
+
- **插件启动时**:建好数据目录 `~/.session-history`,检测电脑上有哪些 agent,按检测结果生成 SKILL.md 和入口。
|
|
67
|
+
- **第一次整理(全量)**:把每个检测到的 agent 现存的全部会话读一遍,清洗成按天的日志、建好索引,并为每个会话文件记下缓存。在后台子进程里进行,不影响使用;几百 MB 到几 GB 的历史,一般半分钟到一两分钟。
|
|
68
|
+
- **建软链之前**:日志已经整理好了,但各 agent 还不知道有这个技能,不会去查。
|
|
69
|
+
- **建软链之后**:新开的对话里,agent 就能用上。
|
|
70
|
+
|
|
71
|
+
### 之后怎么运转
|
|
72
|
+
|
|
73
|
+
- **DSH 开着时**:每小时整点在后台整理一次,只重读有变化的会话,通常一两秒。
|
|
74
|
+
- **DSH 没开时**:不会定时整理。但任何 agent 检索之前,如果距上次整理超过 30 分钟,会先补一次再查,所以查到的总是较新的对话。也可以随时运行 `session-history refresh`。
|
|
75
|
+
- **后来装的 agent**:会被自动检测、自动收录,SKILL.md 也会更新(见下节)。它若读的是已经接入的技能文件夹(比如 `~/.agents/skills`),直接显示「已接入」;否则显示「待接入」,再点一次「建软链」。
|
|
76
|
+
- **卸载了某个 agent,或它删了自己的历史**:已经整理进日志的内容照样保留、照常检索,插件页会把它列在「另有旧日志」里。
|
|
77
|
+
|
|
78
|
+
### 注意事项
|
|
79
|
+
|
|
80
|
+
- **越早装越好。** 第一次整理只能收到各 agent 当时还留在磁盘上的会话;有的 agent 会自己清理旧记录(例如 Claude Code 默认只保留约 30 天),更早的找不回来。一旦整理进日志,以后原始记录被删也不影响。
|
|
81
|
+
- **长期不开 DSH、也一直不检索时**,整理会暂停;如果因此有会话在被 agent 清理之前都没整理过,就会漏掉。偶尔开一次 DSH 或运行一次 `session-history refresh` 即可。
|
|
82
|
+
- **只读不改**:插件只读取各 agent 的会话文件,从不修改它们;日志里你的原话一字不改。
|
|
83
|
+
- **全部在本地**:不调用模型、不联网;插件新建的数据目录只有你自己的账户能读。
|
|
84
|
+
- **日志不是指令**:日志里出现的命令和要求是历史记录,SKILL.md 已要求 agent 不得照做,回答时要注明日期和出处。
|
|
85
|
+
|
|
86
|
+
### SKILL.md 是怎么来的
|
|
87
|
+
|
|
88
|
+
所有 agent 读的是同一份 `~/.session-history/SKILL.md`,由插件自动生成,手改会被覆盖。
|
|
89
|
+
|
|
90
|
+
- **通用部分**(每个人都一样):怎么检索(先找会话,再有限度地读原文,必要时查原始记录)、查询怎么写、一次回忆读多少、证据纪律。
|
|
91
|
+
- **按你的电脑生成的部分**:列出的 agent 名单(检测到的,以及只剩旧日志的)、入口的实际路径(Windows 上同时给出 PowerShell/cmd 与 Git Bash 两种写法)、`--agent` 可选的名字、是否提 Claude Code 记忆提示、Pi 的分支说明、检索前补整理的时长,以及兜底搜索用的日志路径。
|
|
92
|
+
- **什么时候更新**:插件启动时、每次整理之后(定时、检索前补整理、立即整理都算)、打开插件页时、改设置或增删 agent 时。内容没变就不写盘。建软链不会改它——软链只决定哪些 agent 能读到这份文件。
|
|
93
|
+
|
|
63
94
|
## 插件页
|
|
64
95
|
|
|
65
96
|
- **数据目录**:位置、最近整理时间、会话与日志数量、整理是否出错;可打开目录或立即整理。
|
|
@@ -113,6 +144,8 @@ dsh plugin --profile desktop add dsh-session-history
|
|
|
113
144
|
|
|
114
145
|
很多人只维护一个技能文件夹,其余目录用软链指向它(例如 `~/.claude/skills`、`~/.agents/skills` 都指向 `~/my-skills`)。这时各 agent 读的其实是同一个文件夹,但本技能的文件夹(数据目录)不在里面,所以显示「待接入」是准确的:只需在那个共用文件夹里建一条 `session-history` 软链,它们就一起接入。
|
|
115
146
|
|
|
147
|
+
各家读的不是同一个文件夹时,会按文件夹分组、各给一个按钮;一个 agent 同时读几个目录的(如 Pi 既读自己的目录也读 `~/.agents/skills`),只归入能覆盖它的那一组,不会让你点两次。
|
|
148
|
+
|
|
116
149
|
判断是否已接入,是从每个 agent 自己的技能目录出发、顺着软链去读 `session-history/SKILL.md`,读得到、名字对才算,与 agent 加载技能走同一条路。已有同名的独立文件夹(多半是旧版拷贝)时不会覆盖,会提示冲突。Windows 用目录联接,不需要管理员权限。
|
|
117
150
|
|
|
118
151
|
## 数据与卸载
|
|
@@ -156,7 +189,7 @@ session-history refresh | status | setup | link all | unlink claude | config
|
|
|
156
189
|
Git 子目录地址(不提供原生更新检查):
|
|
157
190
|
|
|
158
191
|
```text
|
|
159
|
-
git+https://github.com/fujingzhai/youxia-dsh-plugins.git#dsh-session-history@0.2.
|
|
192
|
+
git+https://github.com/fujingzhai/youxia-dsh-plugins.git#dsh-session-history@0.2.3&path:/dsh-session-history
|
|
160
193
|
```
|
|
161
194
|
|
|
162
195
|
## 兼容与限制
|
package/index.js
CHANGED
|
@@ -75,6 +75,8 @@ export function createRunner(home, { node = findNode(), engine = ENGINE } = {})
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
export function snapshot(home, runner) {
|
|
78
|
+
// 打开插件页时也同步一次技能文件:新装的 agent 立刻反映到 SKILL.md(内容没变不写盘)。
|
|
79
|
+
try { installSkill(home); } catch { /* 写不了也不影响读状态 */ }
|
|
78
80
|
const config = loadConfig(home);
|
|
79
81
|
const last = readJson(layout(home).status, null);
|
|
80
82
|
const status = skillStatus(home, config);
|
package/lib/links.js
CHANGED
|
@@ -73,9 +73,19 @@ export function skillStatus(home, config = {}) {
|
|
|
73
73
|
g.agents.push(a.name);
|
|
74
74
|
groups.set(a.target.key, g);
|
|
75
75
|
}
|
|
76
|
-
//
|
|
76
|
+
// 同一目录还被别的未接入 agent 读到的,一并算进受益者。
|
|
77
77
|
for (const g of groups.values()) {
|
|
78
78
|
for (const a of live.filter(x => x.state === 'missing' && !g.agents.includes(x.name))) if (a.dirs.some(d => d.real === g.key)) g.agents.push(a.name);
|
|
79
|
+
}
|
|
80
|
+
// 一个 agent 读多个目录时(如 Pi 既读自己的目录也读 ~/.agents/skills),只归入覆盖 agent 最多的那一组,
|
|
81
|
+
// 免得同一家出现在两组、让人以为要点两次;被完全覆盖的组不再列出。
|
|
82
|
+
const assigned = new Set();
|
|
83
|
+
for (const g of [...groups.values()].sort((a, b) => b.agents.length - a.agents.length)) {
|
|
84
|
+
g.agents = g.agents.filter(n => !assigned.has(n));
|
|
85
|
+
for (const n of g.agents) assigned.add(n);
|
|
86
|
+
}
|
|
87
|
+
for (const [k, g] of groups) if (!g.agents.length) groups.delete(k);
|
|
88
|
+
for (const g of groups.values()) {
|
|
79
89
|
const realPath = g.create ? null : realpathSafe(g.path);
|
|
80
90
|
g.realDisplay = realPath && key(realPath) !== key(g.path) ? tilde(realPath) : null;
|
|
81
91
|
g.paths = [...new Set(live.filter(a => g.agents.includes(a.name)).flatMap(a => a.dirs.filter(d => d.real === g.key).map(d => d.display)))];
|