dsh-session-history 0.0.0-stage → 0.1.0
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/LICENSE +21 -0
- package/README.md +120 -2
- package/bin/session-history.js +198 -0
- package/client.js +179 -0
- package/cordis.patch.yml +3 -0
- package/icon.svg +9 -0
- package/index.js +195 -0
- package/lib/agents.js +28 -0
- package/lib/clock.js +66 -0
- package/lib/config.js +101 -0
- package/lib/files.js +112 -0
- package/lib/links.js +98 -0
- package/lib/markdown.js +109 -0
- package/lib/normalize.js +29 -0
- package/lib/py.js +81 -0
- package/lib/raw.js +120 -0
- package/lib/recall.js +448 -0
- package/lib/refresh.js +173 -0
- package/lib/skill.js +195 -0
- package/lib/sources/antigravity.js +138 -0
- package/lib/sources/claude.js +122 -0
- package/lib/sources/codex.js +115 -0
- package/lib/sources/common.js +71 -0
- package/lib/sources/dsh.js +113 -0
- package/lib/sources/pi.js +96 -0
- package/lib/store.js +226 -0
- package/lib/text.js +80 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +68 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 fujingzhai
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,121 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Session History
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
本机各 agent 的对话记忆。把 Claude Code、Codex、Antigravity、Pi、DSH 的会话**确定性清洗**成每天一份的 Markdown 日志(只留问答原文、无摘要),建离线全文索引,再以**一个技能**提供给所有 agent:谁都能查“之前在别的 agent 里聊过什么”。全程不调用模型、不联网。
|
|
4
|
+
|
|
5
|
+
- DSH 插件页:数据目录与最近整理、各 agent 的会话检测与技能接入状态(一键建软链)、设置、自动生成的 SKILL.md 预览。
|
|
6
|
+
- 技能 `session-history`:按本机实际有的 agent 生成 SKILL.md——没装 Pi 就不提 Pi,免得误导模型。
|
|
7
|
+
- 命令行 `session-history`:search/outline/get/raw/timeline,以及 refresh、status、link 等管理命令。
|
|
8
|
+
|
|
9
|
+
## 安装
|
|
10
|
+
|
|
11
|
+
在 DSH **插件 → 添加插件** 填包名:
|
|
12
|
+
|
|
13
|
+
```text
|
|
14
|
+
dsh-session-history
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
或命令行(Web 版把 `desktop` 换成 `web`):
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
dsh plugin --profile desktop add dsh-session-history
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
装好后打开插件详情:
|
|
24
|
+
|
|
25
|
+
1. 点 **立即整理**。首次会读全部历史会话并建索引,几百 MB 的会话约半分钟到一两分钟;之后只重读变过的会话文件,通常一两秒。
|
|
26
|
+
2. 在 **Agent 与技能** 里点 **一键接入**,或逐个 **创建软链**。
|
|
27
|
+
3. 新开一个对话问“我们之前……”,agent 会自己用上这个技能。
|
|
28
|
+
|
|
29
|
+
不用 DSH 也能用:`npm i -g dsh-session-history`,然后 `session-history setup`、`session-history refresh`、`session-history link all`。需要 Node 22.15 以上(推荐 24,内置 SQLite 与 zstd)。
|
|
30
|
+
|
|
31
|
+
## 技能怎么接入:共用,不拷副本
|
|
32
|
+
|
|
33
|
+
技能文件夹就是数据目录本身(默认 `~/.session-history`,内含 SKILL.md 与入口 `bin/session-history`)。接入某个 agent = 在它读的技能目录里放一条指向数据目录的软链 `session-history`。
|
|
34
|
+
|
|
35
|
+
| Agent | 会话来源 | 读取的技能目录 |
|
|
36
|
+
|---|---|---|
|
|
37
|
+
| Claude Code | `~/.claude/projects/*/*.jsonl`(含 macOS 桌面版 Cowork) | `~/.claude/skills` |
|
|
38
|
+
| Codex | `~/.codex/sessions/**/rollout-*.jsonl(.zst)` | `~/.agents/skills`、`~/.codex/skills` |
|
|
39
|
+
| Antigravity | `~/.gemini/antigravity[-cli]/brain/*/…/transcript_full.jsonl` | `~/.gemini/config/skills` |
|
|
40
|
+
| Pi | `~/.pi/agent/sessions/*/*.jsonl` | `~/.pi/agent/skills`、`~/.agents/skills` |
|
|
41
|
+
| DSH | `~/.dsh/sessions/*/*/session[.vN].jsonl.zstd` | `~/.dsh/skills`、`~/.agents/skills` |
|
|
42
|
+
|
|
43
|
+
`CLAUDE_CONFIG_DIR`、`CODEX_HOME`、`PI_CODING_AGENT_DIR`、`DSH_HOME` 等环境变量照各家规则生效。
|
|
44
|
+
|
|
45
|
+
很多人只维护一个技能文件夹、其余用软链共用(如 `~/.claude/skills → ~/my-skills`、`~/.agents/skills → ~/my-skills`)。插件按**真实路径**判断:几家共用同一个真实目录时只需一条软链,建好后它们一起显示“技能可用”。面板会标出“与 X、Y 共用技能目录”;移除软链时也会提示共用者一起看不到。
|
|
46
|
+
|
|
47
|
+
- 已有同名的独立文件夹(多半是旧版拷贝)时不覆盖,面板显示冲突,请先移走。
|
|
48
|
+
- 数据目录本身就放在某个技能目录里时(例如 `~/my-skills/session-history`),共用它的 agent 直接可见,无需软链。
|
|
49
|
+
- Windows 用目录联接(junction),无需管理员权限。入口有两份:PowerShell/cmd 用 `bin\session-history.cmd`,Git Bash 用 `bin/session-history`,SKILL.md 会按平台写明。
|
|
50
|
+
|
|
51
|
+
## 数据与插件分开
|
|
52
|
+
|
|
53
|
+
| 位置 | 内容 | 卸载/更新/重装插件 |
|
|
54
|
+
|---|---|---|
|
|
55
|
+
| 插件包(DSH profile 的 `node_modules`) | 代码 | 随之替换或删除 |
|
|
56
|
+
| 数据目录 `~/.session-history` | `logs/<Agent>/` 清洗日志(权威数据)、`config.json` 设置、`state/` 索引与缓存、SKILL.md 与入口 | **不动** |
|
|
57
|
+
|
|
58
|
+
- `state/` 可随时删掉,下次检索自动重建;`logs/` 是唯一权威数据,请勿删除。
|
|
59
|
+
- 来源里已经没有的旧会话(应用清理了历史、或停用了某个 agent),日志里的段落原样保留,照常检索。
|
|
60
|
+
- 卸载前可在面板移除软链;不移也无妨:入口会提示引擎不在,日志仍可直接用 `rg` 查。重装后入口自动改写回来。
|
|
61
|
+
- 改数据目录:设环境变量 `SESSION_HISTORY_HOME`,或在 profile 的 `cordis.patch.yml` 给本插件的行加 `config.home`。已有数据请自行整体搬过去。
|
|
62
|
+
|
|
63
|
+
## 设置(插件页,存在数据目录的 config.json)
|
|
64
|
+
|
|
65
|
+
| 项 | 默认 | 说明 |
|
|
66
|
+
|---|---|---|
|
|
67
|
+
| 日志里用户的称呼 | 用户 | 发言标题 `## 10:00 🧑 用户`;只影响之后新整理的内容 |
|
|
68
|
+
| 定时整理 | 每小时整点 | DSH 运行期间在子进程里整理,不卡宿主 |
|
|
69
|
+
| 检索前自动补整理 | 距上次超过 30 分钟 | DSH 没开时,其他 agent 检索也能拿到较新的对话 |
|
|
70
|
+
| 日界 | 4 点 | 这个钟点之前的对话算前一天 |
|
|
71
|
+
| 时区 | 跟随系统 | 也可写 `+08:00` 或 `Asia/Shanghai` |
|
|
72
|
+
| 检索附 Claude Code 记忆 | 开 | search 对题时列至多 2 条 CC 记忆的文件名与描述 |
|
|
73
|
+
| 日志 Git 快照 | 关 | 每次整理后把 `logs/` 提交一次;开启时在数据目录建仓库(只收 logs/) |
|
|
74
|
+
| 不收的工作目录 | 无 | 临时目录(`/tmp` 等)本就不收 |
|
|
75
|
+
|
|
76
|
+
按 agent 关闭整理在面板的开关;更细的(如 Codex 只收某些工作目录 `agents.codex.onlyCwds`)直接编辑 config.json。
|
|
77
|
+
|
|
78
|
+
## 命令行
|
|
79
|
+
|
|
80
|
+
```sh
|
|
81
|
+
session-history search 插件 更新失败 # 主体词+事件词;空格=AND,词内 | 任选
|
|
82
|
+
session-history search "VPN|openconnect" 断线 --agent Codex --since 08-01
|
|
83
|
+
session-history outline 01a06cc6 # 会话提纲:用户每条发言+末轮回复
|
|
84
|
+
session-history get 2ddbae3eed --context 1 # 读块原文
|
|
85
|
+
session-history raw 5f3c92de "base_url|api.example" # 在原始记录里查工具调用与返回
|
|
86
|
+
session-history timeline --since 7d
|
|
87
|
+
session-history refresh | status | setup | link all | unlink claude | config
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
检索排序以会话为单位:题目(各家原生标题,没有才取开场请求)与用户原话权重最高,再看稀有度、饱和词频、共现,乘轻度时间衰减;命中太多时只列题目和“常同现的词”供收窄。繁简、全半角、大小写自动统一(OpenCC);三个字符以内的英文数字词按整词匹配。
|
|
91
|
+
|
|
92
|
+
## 更新
|
|
93
|
+
|
|
94
|
+
### 检查更新
|
|
95
|
+
|
|
96
|
+
适用于从 npm 安装的 DSH 0.2.2-rc.1 及以上:
|
|
97
|
+
|
|
98
|
+
1. 打开 **插件**,点 **刷新**;有新版时卡片标记 **可更新**。也可在插件详情 **版本 → 重新检查**。
|
|
99
|
+
2. 点页头 **更新到 <版本>**,核对版本与安装源后确认。**无需手动卸载重装**;数据目录不受影响。
|
|
100
|
+
3. 更新后插件会自动改写技能入口;如提示需要重启,按提示重启 DSH。
|
|
101
|
+
|
|
102
|
+
这是打开详情或刷新列表时的检查,不是全局推送,也不自动升级。固定 Git 标签、压缩包或 `link:` 安装不显示这套更新入口。
|
|
103
|
+
|
|
104
|
+
### 固定版本
|
|
105
|
+
|
|
106
|
+
Git 子目录地址(不提供原生更新检查):
|
|
107
|
+
|
|
108
|
+
```text
|
|
109
|
+
git+https://github.com/fujingzhai/youxia-dsh-plugins.git#dsh-session-history@0.1.0&path:/dsh-session-history
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## 兼容与限制
|
|
113
|
+
|
|
114
|
+
- 需要 DSH 0.2.2-rc.1 以上;在 macOS、DSH 0.2.2-rc.3 隔离 profile 实测宿主加载、管理接口与子进程整理。
|
|
115
|
+
- Windows:CI(Node 24)上跑全部单元测试,并在含中文与空格的目录里实际调用 `.cmd` 与 Git Bash 入口;`.cmd` 只写 ASCII(路径换成 `%USERPROFILE%` 等变量),避开中文系统代码页。DSH 桌面版 Windows 实机与插件页 GUI **未实测**;Linux 只跑了 CI。
|
|
116
|
+
- 只读各 agent 的会话文件,从不修改它们;日志里的指令是历史数据,SKILL.md 已要求 agent 不得照做。
|
|
117
|
+
- 日志不含思考、工具调用与返回;这些要用 `raw` 回查原始记录(原始记录不在了就查不到)。
|
|
118
|
+
|
|
119
|
+
## 许可
|
|
120
|
+
|
|
121
|
+
MIT
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Session History 命令行:检索各 agent 的历史对话,并管理整理、索引与技能接入。不调用模型。
|
|
3
|
+
const [major, minor] = process.versions.node.split('.').map(Number);
|
|
4
|
+
if (major < 22 || (major === 22 && minor < 15)) {
|
|
5
|
+
console.error(`Session History 需要 Node 22.15 以上(推荐 24,内置 SQLite 与 zstd),当前 ${process.version}。`);
|
|
6
|
+
process.exit(3);
|
|
7
|
+
}
|
|
8
|
+
// node:sqlite 在 Node 22/23 会打一行 ExperimentalWarning,混进输出没用。
|
|
9
|
+
const emit = process.emitWarning;
|
|
10
|
+
process.emitWarning = (warning, ...rest) => {
|
|
11
|
+
const type = typeof rest[0] === 'string' ? rest[0] : rest[0]?.type;
|
|
12
|
+
if (type === 'ExperimentalWarning' && /SQLite/i.test(String(warning))) return;
|
|
13
|
+
return emit.call(process, warning, ...rest);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const { resolveHome, loadConfig, saveConfig, layout, readJson, DEFAULTS } = await import('../lib/config.js');
|
|
17
|
+
const { connect, updateIndex } = await import('../lib/store.js');
|
|
18
|
+
const { search, get, outline, timeline, UsageError } = await import('../lib/recall.js');
|
|
19
|
+
const { raw } = await import('../lib/raw.js');
|
|
20
|
+
const { refresh, refreshIfStale } = await import('../lib/refresh.js');
|
|
21
|
+
const { SOURCES, byId, byFolder, enabled, detected } = await import('../lib/agents.js');
|
|
22
|
+
const { installSkill, logFolders, VERSION } = await import('../lib/skill.js');
|
|
23
|
+
const { skillStatus, link, linkAll, unlink } = await import('../lib/links.js');
|
|
24
|
+
const { tilde } = await import('../lib/files.js');
|
|
25
|
+
|
|
26
|
+
const HELP = `Session History ${VERSION} — 本机 agent 历史对话检索(不调用模型)
|
|
27
|
+
|
|
28
|
+
检索
|
|
29
|
+
search <词…> [--agent A] [--since D] [--until D] [--session ID] [--role user|assistant]
|
|
30
|
+
[--sort relevance|recent] [--limit 6] [--snippet 220] [--snippets] [--budget 3000]
|
|
31
|
+
outline <会话ID|块ID> [--agent A] [--all] [--width 100] [--budget 3000]
|
|
32
|
+
get <块ID> [--context 1] [--budget 4000]
|
|
33
|
+
raw <会话ID|块ID> <词…> [--agent A] [--width 200] [--budget 2000]
|
|
34
|
+
timeline [--since D] [--until D] [--agent A] [--all] [--budget 3000]
|
|
35
|
+
|
|
36
|
+
管理
|
|
37
|
+
refresh [--agent A] 整理会话为日志并更新索引(只重读变过的会话)
|
|
38
|
+
index 只增量更新索引
|
|
39
|
+
status 数据目录、各 agent 与技能接入情况
|
|
40
|
+
setup 生成技能文件(SKILL.md、入口),首次使用先跑
|
|
41
|
+
link <agent|all> 在 agent 的技能目录里建指向数据目录的软链
|
|
42
|
+
unlink <agent> 移除上述软链
|
|
43
|
+
config [键 [值]] 查看或修改设置
|
|
44
|
+
|
|
45
|
+
通用:--home DIR(数据目录,默认 ~/.session-history 或 $SESSION_HISTORY_HOME) --no-refresh(检索前不补整理)
|
|
46
|
+
日期:YYYY-MM-DD、MM-DD、today、7d;--until 含当天。词:空格=AND,词内 | 任选其一。`;
|
|
47
|
+
|
|
48
|
+
const BOOL = new Set(['snippets', 'all', 'no-refresh', 'json', 'help']);
|
|
49
|
+
const NUM = { limit: 6, snippet: 220, budget: null, context: 1, width: null };
|
|
50
|
+
|
|
51
|
+
function parseArgs(argv) {
|
|
52
|
+
const args = { _: [] };
|
|
53
|
+
for (let i = 0; i < argv.length; i++) {
|
|
54
|
+
const a = argv[i];
|
|
55
|
+
if (a === '--') { args._.push(...argv.slice(i + 1)); break; }
|
|
56
|
+
if (a.startsWith('--')) {
|
|
57
|
+
const [key, inline] = a.slice(2).split(/=(.*)/s);
|
|
58
|
+
if (BOOL.has(key)) { args[key] = true; continue; }
|
|
59
|
+
const value = inline ?? argv[++i];
|
|
60
|
+
if (value === undefined) throw new UsageError(`--${key} 需要一个值`);
|
|
61
|
+
args[key] = value;
|
|
62
|
+
} else if (a === '-h') args.help = true;
|
|
63
|
+
else args._.push(a);
|
|
64
|
+
}
|
|
65
|
+
for (const key of Object.keys(NUM)) if (args[key] !== undefined) {
|
|
66
|
+
const n = Number(args[key]);
|
|
67
|
+
if (!Number.isInteger(n)) throw new UsageError(`--${key} 应为整数`);
|
|
68
|
+
args[key] = n;
|
|
69
|
+
}
|
|
70
|
+
return args;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** --agent 收 Claude/claude/Claude Code 等写法,统一成日志文件夹名。 */
|
|
74
|
+
function agentFolder(value, home) {
|
|
75
|
+
if (!value) return null;
|
|
76
|
+
const v = String(value).toLowerCase().replace(/\s+/g, '');
|
|
77
|
+
const folders = [...new Set([...SOURCES.map(s => s.folder), ...logFolders(home)])];
|
|
78
|
+
const hit = SOURCES.find(s => s.id === v || s.folder.toLowerCase() === v || s.name.toLowerCase().replace(/\s+/g, '') === v)?.folder
|
|
79
|
+
|| folders.find(f => f.toLowerCase() === v);
|
|
80
|
+
if (!hit) throw new UsageError(`--agent 可选:${folders.join('、')}`);
|
|
81
|
+
return hit;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function withIndex(home, config, fn) {
|
|
85
|
+
const db = connect(home);
|
|
86
|
+
try { updateIndex(home, config, db); return fn(db); } finally { db.close(); }
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function statusText(home) {
|
|
90
|
+
const config = loadConfig(home);
|
|
91
|
+
const last = readJson(layout(home).status, null);
|
|
92
|
+
const agents = skillStatus(home, config);
|
|
93
|
+
const lines = [`Session History ${VERSION}|数据目录 ${tilde(home)}`];
|
|
94
|
+
lines.push(last ? `最近整理 ${last.run}(${(last.ms / 1000).toFixed(1)} 秒)|索引 ${last.index?.sessions ?? '?'} 个会话、${last.index?.files ?? '?'} 份日志` : '尚未整理过:先跑 refresh');
|
|
95
|
+
for (const a of agents) {
|
|
96
|
+
const run = last?.agents?.[a.folder];
|
|
97
|
+
const src = !a.installed ? '未检测到' : enabled(byId(a.id), config) ? (run ? (run.ok ? `已整理 ${run.files} 个会话文件` : `整理出错:${run.error}`) : '已启用,待整理') : '已检测到,未启用整理';
|
|
98
|
+
const skill = a.visible ? `技能可用(经 ${a.via})` : a.conflict ? `技能冲突:${a.conflict.path}` : `技能未接入(link ${a.id})`;
|
|
99
|
+
lines.push(` ${a.name.padEnd(12)} ${src}|${skill}`);
|
|
100
|
+
}
|
|
101
|
+
const legacy = logFolders(home).filter(f => !byFolder(f));
|
|
102
|
+
if (legacy.length) lines.push(` 已停用来源的旧日志:${legacy.join('、')}`);
|
|
103
|
+
return lines.join('\n');
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
async function main() {
|
|
107
|
+
const argv = process.argv.slice(2);
|
|
108
|
+
const args = parseArgs(argv);
|
|
109
|
+
const [cmd, ...rest] = args._;
|
|
110
|
+
if (!cmd || args.help || cmd === 'help') { console.log(HELP); return; }
|
|
111
|
+
const home = resolveHome(args.home);
|
|
112
|
+
const config = loadConfig(home);
|
|
113
|
+
const log = message => console.error(message);
|
|
114
|
+
const ctx = { config, cmd: 'session-history' };
|
|
115
|
+
const agent = agentFolder(args.agent, home);
|
|
116
|
+
const ensure = () => { if (!args['no-refresh']) refreshIfStale({ home }); };
|
|
117
|
+
const budget = d => args.budget ?? d;
|
|
118
|
+
if (args.budget !== undefined && args.budget < 100) throw new UsageError('budget 至少 100');
|
|
119
|
+
if (args.limit !== undefined && args.limit < 1) throw new UsageError('limit 为正数');
|
|
120
|
+
if (args.snippet !== undefined && args.snippet < 20) throw new UsageError('snippet 至少 20');
|
|
121
|
+
switch (cmd) {
|
|
122
|
+
case 'search':
|
|
123
|
+
ensure();
|
|
124
|
+
return console.log(withIndex(home, config, db => search(db, { query: rest, agent, since: args.since, until: args.until, session: args.session,
|
|
125
|
+
role: args.role, sort: args.sort || 'relevance', limit: args.limit ?? 6, snippet: args.snippet ?? 220, snippets: !!args.snippets, budget: budget(3000) }, ctx)));
|
|
126
|
+
case 'get':
|
|
127
|
+
if (!rest[0]) throw new UsageError('用法:get <块ID>');
|
|
128
|
+
ensure();
|
|
129
|
+
return console.log(withIndex(home, config, db => get(db, { id: rest[0], context: args.context ?? 1, budget: budget(4000) }, ctx)));
|
|
130
|
+
case 'outline':
|
|
131
|
+
if (!rest[0]) throw new UsageError('用法:outline <会话ID|块ID>');
|
|
132
|
+
ensure();
|
|
133
|
+
return console.log(withIndex(home, config, db => outline(db, { target: rest[0], agent, all: !!args.all, width: args.width ?? 100, budget: budget(3000) }, ctx)));
|
|
134
|
+
case 'raw':
|
|
135
|
+
if (rest.length < 2) throw new UsageError('用法:raw <会话ID|块ID> <词…>');
|
|
136
|
+
ensure();
|
|
137
|
+
return console.log(withIndex(home, config, db => raw(db, { target: rest[0], query: rest.slice(1), agent, width: args.width ?? 200, budget: budget(2000) }, ctx)));
|
|
138
|
+
case 'timeline':
|
|
139
|
+
ensure();
|
|
140
|
+
return console.log(withIndex(home, config, db => timeline(db, { since: args.since, until: args.until, agent, all: !!args.all, budget: budget(3000) }, ctx)));
|
|
141
|
+
case 'index':
|
|
142
|
+
return console.log(JSON.stringify(updateIndex(home, config)));
|
|
143
|
+
case 'refresh': {
|
|
144
|
+
const only = agent ? [byFolder(agent)?.id].filter(Boolean) : null;
|
|
145
|
+
const status = refresh({ home, only, log });
|
|
146
|
+
if (args.json) return console.log(JSON.stringify(status, null, 2));
|
|
147
|
+
if (status.skipped) return console.log(status.reason);
|
|
148
|
+
for (const [name, r] of Object.entries(status.agents)) console.log(`${name}: ${r.ok ? `OK 会话文件 ${r.files}(重读 ${r.parsed})· 日志 ${r.days} 天 · 变更 ${r.changed} 天` : 'ERROR ' + r.error}`);
|
|
149
|
+
console.log(`索引: ${status.index.ok ? `${status.index.sessions} 个会话 · 更新 ${status.index.updated} 份` : 'ERROR ' + status.index.error}|${(status.ms / 1000).toFixed(1)} 秒`);
|
|
150
|
+
const warnings = Object.values(status.agents).flatMap(r => r.warnings || []);
|
|
151
|
+
if (warnings.length) console.error(warnings.slice(0, 20).join('\n') + (warnings.length > 20 ? `\n……另有 ${warnings.length - 20} 条` : ''));
|
|
152
|
+
if (Object.values(status.agents).some(r => !r.ok) || !status.index.ok) process.exitCode = 1;
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
case 'status':
|
|
156
|
+
return console.log(args.json ? JSON.stringify({ home, config, last: readJson(layout(home).status, null), agents: skillStatus(home, config) }, null, 2) : statusText(home));
|
|
157
|
+
case 'setup': {
|
|
158
|
+
const r = installSkill(home);
|
|
159
|
+
console.log(`技能文件已${r.changed.length ? '更新:' + r.changed.join('、') : '是最新'}|${tilde(layout(home).skill)}`);
|
|
160
|
+
console.log(statusText(home));
|
|
161
|
+
if (!readJson(layout(home).status)) console.log('\n下一步:session-history refresh(首次整理全部历史,可能要一两分钟)');
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
case 'link': {
|
|
165
|
+
if (!rest[0]) throw new UsageError('用法:link <agent|all>');
|
|
166
|
+
installSkill(home);
|
|
167
|
+
const results = rest[0] === 'all' ? linkAll(home, config) : [{ id: rest[0], ...link(home, (SOURCES.find(s => s.id === rest[0].toLowerCase() || s.folder.toLowerCase() === rest[0].toLowerCase()) || {}).id || rest[0], config) }];
|
|
168
|
+
for (const r of results) console.log(`${r.id}: ${r.error ? '失败:' + r.error : r.changed ? `已建软链 ${r.entry}` : `已可用(经 ${r.via})`}`);
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
case 'unlink': {
|
|
172
|
+
if (!rest[0]) throw new UsageError('用法:unlink <agent>');
|
|
173
|
+
const id = (SOURCES.find(s => s.id === rest[0].toLowerCase() || s.folder.toLowerCase() === rest[0].toLowerCase()) || {}).id || rest[0];
|
|
174
|
+
const r = unlink(home, id, config);
|
|
175
|
+
return console.log(`已移除 ${r.removed.join('、')}${r.affects.length ? `;共用该目录的 ${r.affects.join('、')} 也随之看不到` : ''}`);
|
|
176
|
+
}
|
|
177
|
+
case 'config': {
|
|
178
|
+
if (!rest.length) return console.log(JSON.stringify(config, null, 2));
|
|
179
|
+
const [key, ...value] = rest;
|
|
180
|
+
if (!(key in DEFAULTS) || key === 'agents') throw new UsageError(`可改的键:${Object.keys(DEFAULTS).filter(k => k !== 'agents').join('、')}(agents 请直接编辑 config.json)`);
|
|
181
|
+
if (!value.length) return console.log(JSON.stringify(config[key]));
|
|
182
|
+
let parsed = value.join(' ');
|
|
183
|
+
try { parsed = JSON.parse(parsed); } catch { /* 当字符串 */ }
|
|
184
|
+
const next = saveConfig(home, { [key]: parsed });
|
|
185
|
+
installSkill(home);
|
|
186
|
+
return console.log(`${key} = ${JSON.stringify(next[key])}`);
|
|
187
|
+
}
|
|
188
|
+
default:
|
|
189
|
+
throw new UsageError(`未知命令 ${cmd};session-history help 查看用法`);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
try { await main(); }
|
|
194
|
+
catch (error) {
|
|
195
|
+
if (error instanceof UsageError) { console.error(error.message); process.exit(2); }
|
|
196
|
+
console.error(`Session History 出错:${error.stack || error.message}`);
|
|
197
|
+
process.exit(1);
|
|
198
|
+
}
|
package/client.js
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({
|
|
2
|
+
id: 'dsh-session-history',
|
|
3
|
+
factory(require) {
|
|
4
|
+
const React = require('react');
|
|
5
|
+
const h = React.createElement;
|
|
6
|
+
const PACKAGE = 'dsh-session-history';
|
|
7
|
+
const API = './youxia-session-history/api';
|
|
8
|
+
|
|
9
|
+
const css = `
|
|
10
|
+
.yxsh{font-size:13px;line-height:1.5;color:var(--dsw-alias-label-primary,inherit);display:flex;flex-direction:column;gap:22px;max-width:820px}
|
|
11
|
+
.yxsh *{box-sizing:border-box}.yxsh button,.yxsh input,.yxsh select,.yxsh textarea{font:inherit;color:inherit}
|
|
12
|
+
.yxsh h3{margin:0 0 6px;font-size:13px;font-weight:600}.yxsh-muted{color:var(--dsw-alias-label-tertiary,#888);font-size:12px}
|
|
13
|
+
.yxsh-row{display:flex;align-items:center;gap:10px;min-width:0;flex-wrap:wrap}.yxsh-grow{flex:1;min-width:0}
|
|
14
|
+
.yxsh-btn{appearance:none;cursor:pointer;border:0.5px solid var(--dsw-alias-border-l4,#8884);background:var(--dsw-alias-bg-layer-3,transparent);border-radius:var(--dsw-radius-md,8px);padding:3px 10px;font-size:12px;line-height:1.6;white-space:nowrap}
|
|
15
|
+
.yxsh-btn:disabled{opacity:.5;cursor:default}.yxsh-btn.primary{background:var(--dsw-alias-interactive-bg-primary,#0A84FF);color:#fff;border-color:transparent}
|
|
16
|
+
@media (hover:hover){.yxsh-btn:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover,#8882)}.yxsh-btn.primary:hover:not(:disabled){filter:brightness(1.08);background:var(--dsw-alias-interactive-bg-primary,#0A84FF)}}
|
|
17
|
+
.yxsh-card{border:0.5px solid var(--dsw-alias-border-l2,#8883);border-radius:10px;overflow:hidden}
|
|
18
|
+
.yxsh-agent{display:grid;grid-template-columns:minmax(120px,1.1fr) minmax(150px,1.4fr) minmax(170px,2fr) auto;gap:10px;align-items:center;padding:10px 12px;border-top:0.5px solid var(--dsw-alias-border-l2,#8883)}
|
|
19
|
+
.yxsh-agent:first-child{border-top:0}.yxsh-agent b{font-weight:500}
|
|
20
|
+
.yxsh-chip{display:inline-flex;align-items:center;gap:5px;border-radius:5px;padding:1px 7px;font-size:12px;background:var(--dsw-alias-bg-layer-4,#8881);color:var(--dsw-alias-label-secondary,#666);max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
21
|
+
.yxsh-chip.ok{background:color-mix(in srgb,#34C759 15%,transparent);color:var(--dsw-alias-label-primary,inherit)}
|
|
22
|
+
.yxsh-chip.bad{background:color-mix(in srgb,#FF3B30 14%,transparent);color:var(--dsw-alias-label-error,#e44848)}
|
|
23
|
+
.yxsh-dot{width:7px;height:7px;border-radius:50%;background:currentColor;flex:none}.yxsh-chip.ok .yxsh-dot{background:#34C759}
|
|
24
|
+
.yxsh-switch{display:inline-flex;align-items:center;gap:6px;cursor:pointer}.yxsh-switch input{margin:0}
|
|
25
|
+
.yxsh-field{display:grid;grid-template-columns:200px 1fr;gap:12px;align-items:start;padding:9px 0;border-bottom:0.5px solid var(--dsw-alias-border-l2,#8883)}
|
|
26
|
+
.yxsh-field:last-of-type{border-bottom:0}.yxsh-field label{padding-top:4px}
|
|
27
|
+
.yxsh-input{height:30px;border:0.5px solid var(--dsw-alias-border-l4,#8884);background:var(--dsw-alias-bg-layer-3,transparent);border-radius:var(--dsw-radius-md,8px);padding:0 10px;min-width:0;width:100%;max-width:320px}
|
|
28
|
+
.yxsh textarea.yxsh-input{height:64px;padding:6px 10px;resize:vertical;max-width:420px;font-family:var(--dsw-font-mono,ui-monospace,monospace);font-size:12px}
|
|
29
|
+
.yxsh-error{color:var(--dsw-alias-label-error,#e44848);font-size:12px;white-space:pre-wrap}
|
|
30
|
+
.yxsh-pre{margin:8px 0 0;padding:10px 12px;max-height:320px;overflow:auto;border-radius:8px;background:var(--dsw-alias-bg-layer-4,#8881);font-family:var(--dsw-font-mono,ui-monospace,monospace);font-size:11.5px;line-height:1.55;white-space:pre-wrap}
|
|
31
|
+
.yxsh summary{cursor:pointer;font-weight:600}.yxsh code{font-family:var(--dsw-font-mono,ui-monospace,monospace);font-size:12px}
|
|
32
|
+
@media (max-width:720px){.yxsh-agent{grid-template-columns:1fr 1fr}.yxsh-field{grid-template-columns:1fr}}
|
|
33
|
+
`;
|
|
34
|
+
|
|
35
|
+
function source(initial) {
|
|
36
|
+
let value = initial;
|
|
37
|
+
const listeners = new Set();
|
|
38
|
+
return { getSnapshot: () => value, subscribe(fn) { listeners.add(fn); return () => listeners.delete(fn); },
|
|
39
|
+
set(next) { value = { ...value, ...next }; for (const fn of listeners) fn(); } };
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function fmtRun(last) {
|
|
43
|
+
if (!last) return '尚未整理过';
|
|
44
|
+
const when = String(last.run || '').replace('T', ' ').slice(0, 16);
|
|
45
|
+
const bad = Object.entries(last.agents || {}).filter(([, r]) => !r.ok).map(([k]) => k);
|
|
46
|
+
return `${when} · ${(Number(last.ms || 0) / 1000).toFixed(1)} 秒 · ${last.index?.sessions ?? '?'} 个会话` + (bad.length ? ` · 出错:${bad.join('、')}` : '');
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function skillChip(agent) {
|
|
50
|
+
if (agent.visible) return h('span', { className: 'yxsh-chip ok', title: agent.via }, h('span', { className: 'yxsh-dot' }), `技能可用 · 经 ${agent.via}`);
|
|
51
|
+
if (agent.conflict) return h('span', { className: 'yxsh-chip bad', title: agent.conflict.path }, `冲突:${agent.conflict.path}`);
|
|
52
|
+
return h('span', { className: 'yxsh-chip' }, '技能未接入');
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function sourceText(agent, last) {
|
|
56
|
+
if (!agent.installed) return h('span', { className: 'yxsh-muted' }, '本机未检测到');
|
|
57
|
+
const run = last?.agents?.[agent.folder];
|
|
58
|
+
if (!agent.enabled) return h('span', { className: 'yxsh-muted' }, '已检测到,未整理');
|
|
59
|
+
if (!run) return h('span', { className: 'yxsh-muted' }, '已检测到,待整理');
|
|
60
|
+
return run.ok ? h('span', null, `${run.files} 个会话文件 · ${run.days} 天日志`) : h('span', { className: 'yxsh-error' }, `出错:${run.error}`);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return {
|
|
64
|
+
inject: ['slots'],
|
|
65
|
+
apply(ctx) {
|
|
66
|
+
let alive = true;
|
|
67
|
+
const state = source({ data: null, loading: true, error: '', pending: '' });
|
|
68
|
+
const useState = () => React.useSyncExternalStore(state.subscribe, state.getSnapshot, state.getSnapshot);
|
|
69
|
+
|
|
70
|
+
async function api(command) {
|
|
71
|
+
const response = await fetch(API, { credentials: 'same-origin', cache: 'no-store',
|
|
72
|
+
...(command ? { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(command) } : {}) });
|
|
73
|
+
const value = await response.json().catch(() => ({ error: `HTTP ${response.status}` }));
|
|
74
|
+
if (!response.ok) throw new Error(value.error || `HTTP ${response.status}`);
|
|
75
|
+
return value;
|
|
76
|
+
}
|
|
77
|
+
async function load() {
|
|
78
|
+
try { const data = await api(); if (alive) state.set({ data, loading: false, error: '' }); }
|
|
79
|
+
catch (error) { if (alive) state.set({ loading: false, error: error.message }); }
|
|
80
|
+
}
|
|
81
|
+
async function run(command, label) {
|
|
82
|
+
if (state.getSnapshot().pending) return false;
|
|
83
|
+
state.set({ pending: label, error: '' });
|
|
84
|
+
try { const data = await api(command); if (alive) state.set({ data }); return true; }
|
|
85
|
+
catch (error) { if (alive) state.set({ error: error.message }); load(); return false; }
|
|
86
|
+
finally { if (alive) state.set({ pending: '' }); }
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function Agents({ data, pending }) {
|
|
90
|
+
const missing = data.agents.filter(a => a.installed && !a.visible && !a.conflict);
|
|
91
|
+
return h('section', null,
|
|
92
|
+
h('div', { className: 'yxsh-row' },
|
|
93
|
+
h('h3', { className: 'yxsh-grow' }, 'Agent 与技能'),
|
|
94
|
+
missing.length ? h('button', { className: 'yxsh-btn primary', disabled: !!pending, onClick: () => run({ op: 'linkAll' }, 'link') },
|
|
95
|
+
pending === 'link' ? '接入中…' : `一键接入(${missing.map(a => a.name).join('、')})`) : null),
|
|
96
|
+
h('p', { className: 'yxsh-muted', style: { margin: '0 0 8px' } },
|
|
97
|
+
'技能不拷副本:在各 agent 读取的技能目录里放一个指向数据目录的软链 ', h('code', null, 'session-history'), '。按真实路径识别共用目录——几家共用的目录只需一条软链。'),
|
|
98
|
+
h('div', { className: 'yxsh-card' }, ...data.agents.map(a => {
|
|
99
|
+
const shared = [...new Set(a.dirs.flatMap(d => d.sharedWith || []))];
|
|
100
|
+
const own = a.dirs.some(d => d.state === 'link');
|
|
101
|
+
return h('div', { className: 'yxsh-agent', key: a.id },
|
|
102
|
+
h('div', null, h('b', null, a.name), shared.length ? h('div', { className: 'yxsh-muted' }, `与 ${shared.join('、')} 共用技能目录`) : null),
|
|
103
|
+
h('div', null, sourceText(a, data.last),
|
|
104
|
+
a.installed ? h('div', null, h('label', { className: 'yxsh-switch yxsh-muted' },
|
|
105
|
+
h('input', { type: 'checkbox', checked: a.enabled, disabled: !!pending, onChange: e => run({ op: 'enable', agent: a.id, enabled: e.target.checked }, 'enable') }), '整理此 agent 的会话')) : null),
|
|
106
|
+
h('div', { style: { minWidth: 0 } }, skillChip(a),
|
|
107
|
+
h('div', { className: 'yxsh-muted', title: a.dirs.map(d => d.display).join('\n') }, '读取 ', a.dirs.map(d => d.display).join('、'))),
|
|
108
|
+
h('div', null,
|
|
109
|
+
a.visible ? (own ? h('button', { className: 'yxsh-btn', disabled: !!pending, title: shared.length ? `共用该目录的 ${shared.join('、')} 也会一起看不到` : '',
|
|
110
|
+
onClick: () => run({ op: 'unlink', agent: a.id }, 'unlink') }, '移除软链') : null)
|
|
111
|
+
: a.conflict ? null
|
|
112
|
+
: h('button', { className: 'yxsh-btn', disabled: !!pending, onClick: () => run({ op: 'link', agent: a.id }, 'link') }, '创建软链')));
|
|
113
|
+
})),
|
|
114
|
+
data.legacy.length ? h('p', { className: 'yxsh-muted', style: { margin: '6px 0 0' } }, `已停用来源的旧日志:${data.legacy.join('、')}(照常检索)`) : null);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function Settings({ data, pending }) {
|
|
118
|
+
const c = data.config;
|
|
119
|
+
const [draft, setDraft] = React.useState(null);
|
|
120
|
+
const d = draft || { userLabel: c.userLabel, timezone: c.timezone, dayStartHour: c.dayStartHour, refreshMinutes: c.refreshMinutes,
|
|
121
|
+
staleMinutes: c.staleMinutes, memoryHints: c.memoryHints, gitSnapshots: c.gitSnapshots, excludeCwds: (c.excludeCwds || []).join('\n') };
|
|
122
|
+
const set = patch => setDraft({ ...d, ...patch });
|
|
123
|
+
const field = (label, control, hint) => h('div', { className: 'yxsh-field' }, h('label', null, label), h('div', null, control, hint ? h('div', { className: 'yxsh-muted' }, hint) : null));
|
|
124
|
+
const select = (value, options, onChange) => h('select', { className: 'yxsh-input', value, onChange: e => onChange(Number(e.target.value)) },
|
|
125
|
+
...options.map(([v, text]) => h('option', { key: v, value: v }, text)));
|
|
126
|
+
const save = async () => {
|
|
127
|
+
const ok = await run({ op: 'config', patch: { ...d, excludeCwds: d.excludeCwds.split('\n').map(s => s.trim()).filter(Boolean) } }, 'config');
|
|
128
|
+
if (ok) setDraft(null);
|
|
129
|
+
};
|
|
130
|
+
return h('section', null,
|
|
131
|
+
h('h3', null, '设置'),
|
|
132
|
+
field('日志里用户的称呼', h('input', { className: 'yxsh-input', value: d.userLabel, maxLength: 12, onChange: e => set({ userLabel: e.target.value }) }),
|
|
133
|
+
'只影响此后新整理的发言标题;旧日志不改。'),
|
|
134
|
+
field('定时整理(DSH 运行时)', select(d.refreshMinutes, [[0, '关闭'], [30, '每 30 分钟'], [60, '每小时整点'], [120, '每 2 小时'], [360, '每 6 小时']], v => set({ refreshMinutes: v })),
|
|
135
|
+
'整理在子进程里跑,只重读变过的会话文件。'),
|
|
136
|
+
field('检索前自动补整理', select(d.staleMinutes, [[0, '关闭'], [10, '距上次超过 10 分钟'], [30, '距上次超过 30 分钟'], [60, '距上次超过 1 小时']], v => set({ staleMinutes: v })),
|
|
137
|
+
'DSH 没开时,别的 agent 检索也能拿到较新的对话。'),
|
|
138
|
+
field('日界', select(d.dayStartHour, Array.from({ length: 24 }, (_, i) => [i, `${i} 点`]), v => set({ dayStartHour: v })), '这个钟点之前的对话算前一天。'),
|
|
139
|
+
field('时区', h('input', { className: 'yxsh-input', value: d.timezone, placeholder: '留空跟随系统;或 +08:00、Asia/Shanghai', onChange: e => set({ timezone: e.target.value }) })),
|
|
140
|
+
field('检索附 Claude Code 记忆', h('label', { className: 'yxsh-switch' }, h('input', { type: 'checkbox', checked: d.memoryHints, onChange: e => set({ memoryHints: e.target.checked }) }), '对题时列至多 2 条记忆的文件名与描述')),
|
|
141
|
+
field('日志 Git 快照', h('label', { className: 'yxsh-switch' }, h('input', { type: 'checkbox', checked: d.gitSnapshots, onChange: e => set({ gitSnapshots: e.target.checked }) }), '每次整理后把 logs/ 提交一次'),
|
|
142
|
+
data.git ? '数据目录已是 Git 仓库。' : '开启时在数据目录建 Git 仓库(只收 logs/)。'),
|
|
143
|
+
field('不收的工作目录', h('textarea', { className: 'yxsh-input', value: d.excludeCwds, placeholder: '每行一个,如 ~/scratch', onChange: e => set({ excludeCwds: e.target.value }) }),
|
|
144
|
+
'临时目录(/tmp 等)本就不收。'),
|
|
145
|
+
h('div', { className: 'yxsh-row', style: { paddingTop: '10px' } },
|
|
146
|
+
h('button', { className: 'yxsh-btn primary', disabled: !draft || !!pending, onClick: save }, pending === 'config' ? '保存中…' : '保存'),
|
|
147
|
+
draft ? h('button', { className: 'yxsh-btn', disabled: !!pending, onClick: () => setDraft(null) }, '还原') : null));
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function Panel({ view }) {
|
|
151
|
+
const s = useState();
|
|
152
|
+
React.useEffect(() => { load(); }, []);
|
|
153
|
+
if (view && view !== 'page') return null;
|
|
154
|
+
if (s.loading && !s.data) return h('div', { className: 'yxsh yxsh-muted' }, h('style', null, css), '读取中…');
|
|
155
|
+
if (!s.data) return h('div', { className: 'yxsh' }, h('style', null, css), h('p', { className: 'yxsh-error' }, s.error || '读取失败'),
|
|
156
|
+
h('button', { className: 'yxsh-btn', onClick: load }, '重试'));
|
|
157
|
+
const data = s.data;
|
|
158
|
+
return h('div', { className: 'yxsh' }, h('style', null, css),
|
|
159
|
+
h('section', null,
|
|
160
|
+
h('div', { className: 'yxsh-row' },
|
|
161
|
+
h('div', { className: 'yxsh-grow' },
|
|
162
|
+
h('div', null, '数据目录 ', h('code', null, data.home), h('span', { className: 'yxsh-muted' }, '(日志、索引、设置都在这里,与插件分开存放:卸载、更新、重装都不动它)')),
|
|
163
|
+
h('div', { className: 'yxsh-muted' }, '最近整理:', fmtRun(data.last))),
|
|
164
|
+
h('button', { className: 'yxsh-btn', onClick: () => run({ op: 'open' }, 'open'), disabled: !!s.pending }, '打开目录'),
|
|
165
|
+
h('button', { className: 'yxsh-btn primary', onClick: () => run({ op: 'refresh' }, 'refresh'), disabled: !!s.pending || data.running },
|
|
166
|
+
s.pending === 'refresh' || data.running ? '整理中…' : '立即整理')),
|
|
167
|
+
s.error ? h('p', { className: 'yxsh-error', role: 'alert' }, s.error) : null),
|
|
168
|
+
h(Agents, { data, pending: s.pending }),
|
|
169
|
+
h(Settings, { data, pending: s.pending, key: JSON.stringify(data.config) }),
|
|
170
|
+
h('section', null, h('details', null, h('summary', null, 'SKILL.md(按本机 agent 自动生成)'),
|
|
171
|
+
h('pre', { className: 'yxsh-pre' }, data.skill))));
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
ctx.effect(() => () => { alive = false; });
|
|
175
|
+
ctx.slots.inject('plugins.bundle.config', () => ctx.slots.register({ name: 'plugins.bundle.config', key: PACKAGE }, Panel));
|
|
176
|
+
},
|
|
177
|
+
};
|
|
178
|
+
},
|
|
179
|
+
});
|
package/cordis.patch.yml
ADDED
package/icon.svg
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" fill="none">
|
|
2
|
+
<circle cx="32" cy="32" r="28" fill="#4F46E5"/>
|
|
3
|
+
<path d="M19.5 17H44.5A4.5 4.5 0 0 1 49 21.5V37A4.5 4.5 0 0 1 44.5 41.5H31.5L24 47.5V41.5H19.5A4.5 4.5 0 0 1 15 37V21.5A4.5 4.5 0 0 1 19.5 17Z" stroke="#FFFFFF" stroke-width="2.8" stroke-linejoin="round"/>
|
|
4
|
+
<g transform="translate(23.6 20.85) scale(0.7)" stroke="#FFFFFF" stroke-width="3.6" stroke-linecap="round" stroke-linejoin="round">
|
|
5
|
+
<path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"/>
|
|
6
|
+
<path d="M3 3v5h5"/>
|
|
7
|
+
<path d="M12 7v5l4 2"/>
|
|
8
|
+
</g>
|
|
9
|
+
</svg>
|