dsh-solution-ledger 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 +139 -2
- package/cordis.patch.yml +16 -0
- package/icon.svg +11 -0
- package/lib/client.js +617 -0
- package/lib/index.js +700 -0
- package/lib/search.js +206 -0
- package/lib/store.js +222 -0
- package/locale/en.json +7 -0
- package/locale/zh.json +7 -0
- package/package.json +37 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 qiyao
|
|
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,140 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Solution ledger
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
一个全局的问题解决账本:记下踩过的坑和做过的取舍,调试前先检索,工具报错时自动带出已确认的相关条目。
|
|
4
|
+
|
|
5
|
+
## 它解决什么
|
|
6
|
+
|
|
7
|
+
会话是独立的,坑却反复踩。这个插件把「症状 → 根因 → 解法 → 怎么验证」沉淀成跨会话可检索的条目,并且**不靠模型自觉去查**:只要一个工具调用失败,插件会拿报错原文去匹配账本,命中已确认条目时直接把摘要附在这次失败结果里,模型在同一个 step 就看到了。
|
|
8
|
+
|
|
9
|
+
## 安装
|
|
10
|
+
|
|
11
|
+
### 从 GitHub 安装
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
dsh plugin --profile <profile 名> add github:Catwb/dsh-solution-ledger
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
也可以打开 Web 的 **Plugins** 页面,点 Add,填 `github:Catwb/dsh-solution-ledger`。
|
|
18
|
+
|
|
19
|
+
安装后侧边栏顶部图标排会多出一个账本图标。修改插件代码后,在 Plugins 页面关掉再打开以重新加载 Host 半;浏览器端还需要刷新页面。
|
|
20
|
+
|
|
21
|
+
### 本地开发
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
git clone https://github.com/Catwb/dsh-solution-ledger.git
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
在你的 profile 的 `package.json` 里加两条,然后在该目录执行 `pnpm install`:
|
|
28
|
+
|
|
29
|
+
```json
|
|
30
|
+
{
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"dsh-solution-ledger": "link:<你 clone 的绝对路径>"
|
|
33
|
+
},
|
|
34
|
+
"dsh": {
|
|
35
|
+
"profile": {
|
|
36
|
+
"bundles": ["dsh-solution-ledger"]
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
这个插件不依赖任何第三方包,`node_modules` 里只有它自己,所以上面两条就够了。
|
|
43
|
+
|
|
44
|
+
## 两个工具
|
|
45
|
+
|
|
46
|
+
### `solution_log`
|
|
47
|
+
|
|
48
|
+
写入一条记录。新条目默认 `draft`(草稿),**草稿不参与自动推送**,只有被确认为 `confirmed` 之后才会被自动带出。
|
|
49
|
+
|
|
50
|
+
它只收两类东西:**根因不明显的问题**,和**真正否决过可行方案的取舍**。下面这些不该记——
|
|
51
|
+
|
|
52
|
+
- 实现说明(「我们用 X 做 Y」「某文件里写了什么」)
|
|
53
|
+
- 没有否决任何方案的设计决定
|
|
54
|
+
- 一眼看代码或文档就能得到的信息
|
|
55
|
+
|
|
56
|
+
判据是三个问题,任一为否就别记:
|
|
57
|
+
|
|
58
|
+
1. 未来的会话会不会再撞上同一情况?
|
|
59
|
+
2. 答案能不能看一眼代码或文档就得到?
|
|
60
|
+
3. 不记的话,那个会话会不会真的浪费时间?
|
|
61
|
+
|
|
62
|
+
换句话说:**如果一条记录永远不会出现在报错里、也不会改变任何人下一步的决定,那它是日志,不是账本条目。**
|
|
63
|
+
|
|
64
|
+
| 参数 | 必填 | 说明 |
|
|
65
|
+
|---|---|---|
|
|
66
|
+
| `kind` | 是 | `troubleshoot`(修好的故障)或 `decision`(选定/否决的路线) |
|
|
67
|
+
| `domain` | 是 | `environment` / `tooling` / `code` / `config` / `process` / `other`,检索第一维 |
|
|
68
|
+
| `title` | 是 | 一句话结论,不是话题标签 |
|
|
69
|
+
| `problem` | 是 | 出现时的症状,或面临的抉择 |
|
|
70
|
+
| `resolution` | 是 | 有效的解法,或最终选择 |
|
|
71
|
+
| `rejected` | decision 必填 | 否决掉的方案和原因 |
|
|
72
|
+
| `verify` | 否 | 怎么确认修好了:跑什么命令、应该看到什么 |
|
|
73
|
+
| `signals` | 否 | 错误码、命令名、文件名等**能被未来报错原文原样命中**的字符串,自动匹配靠它 |
|
|
74
|
+
| `tags` | 否 | 2–6 个小写复用词 |
|
|
75
|
+
| `scope` | 否 | `machine`(本机路径/权限/已装工具)/ `project`(单个仓库约定)/ `general` |
|
|
76
|
+
| `platform` | 否 | 仅当条目与平台强相关时填 |
|
|
77
|
+
| `status` | 否 | `draft`(默认)/ `confirmed` / `deprecated` |
|
|
78
|
+
| `replaces` | 否 | 已有条目 id,原地更新而不是新增 |
|
|
79
|
+
|
|
80
|
+
写入前会做一次近似探测,若有高度相似的条目会在结果里列出 id,提示用 `replaces` 合并。
|
|
81
|
+
|
|
82
|
+
### `solution_search`
|
|
83
|
+
|
|
84
|
+
检索账本。`query` 可以是报错原文,也可以是你正在权衡的选项。
|
|
85
|
+
|
|
86
|
+
打分权重(高到低):`signals` 命中 → `tags` → `domain` → 标题词元 → 正文词元;平台不符扣分,跨目录的 `machine` 条目扣分,`deprecated` 大幅降权。
|
|
87
|
+
|
|
88
|
+
## 自动推送
|
|
89
|
+
|
|
90
|
+
`tools/post-execute` 钩子:工具失败时取报错文本(`error.message` / `error.info.code` / 结果里的文本块)去匹配,命中 `confirmed` 且分数 ≥ `pushMinScore` 的条目时,在结果尾部追加一段摘要。
|
|
91
|
+
|
|
92
|
+
约束:
|
|
93
|
+
- 只推 `confirmed`,草稿和被推翻的永远不推
|
|
94
|
+
- 同一个失败形态只推一次(按工具名 + 报错前缀去重,保留最近 20 条)
|
|
95
|
+
- 单条摘要 ≤ 200 字
|
|
96
|
+
- 查找自身出错时静默返回,绝不把原来的报错变成更糟的报错
|
|
97
|
+
|
|
98
|
+
## 存储
|
|
99
|
+
|
|
100
|
+
`$DSH_HOME/solution-ledger.json`(可用 `statePath` 覆盖)。写入用「临时文件 + rename」保证原子性,读取失败或 JSON 损坏时以空库启动而不是让插件挂掉。
|
|
101
|
+
|
|
102
|
+
```json
|
|
103
|
+
{ "version": 1, "entries": { "<id>": { "id": "...", "title": "..." } } }
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
检索命中的计数只在内存累加,每 30 秒批量落盘一次——否则每次查询都要写磁盘。
|
|
107
|
+
|
|
108
|
+
## 界面
|
|
109
|
+
|
|
110
|
+
侧边栏图标排里多出一个账本图标(`order: 30`,在 `dsh-context` 与 `dsh-ppt.workbench` 之间;`sidebar.panellist` 的每一项都对应 `main` 里同 key 的面板)。点开即中央区域的账本面板:
|
|
111
|
+
|
|
112
|
+
- 搜索框 + 类型 / 状态筛选
|
|
113
|
+
- 每条点开可展开:标题、问题、解法、否决方案、验证方式、标签,全部可直接编辑,失焦即保存
|
|
114
|
+
- 状态操作:**确认**(草稿 → 已确认,只有确认过的才会参与自动推送)、退回草稿、弃用、归档、删除
|
|
115
|
+
- 顶部显示总数与各状态计数,底部显示存储文件的实际路径
|
|
116
|
+
|
|
117
|
+
Host 半为此注册了三条路由:`GET /solution-ledger/list`、`POST /solution-ledger/update`、`POST /solution-ledger/delete`。
|
|
118
|
+
|
|
119
|
+
## 配置
|
|
120
|
+
|
|
121
|
+
在 `cordis.patch.yml` 的本行 `config` 里改:
|
|
122
|
+
|
|
123
|
+
| 键 | 默认 | 说明 |
|
|
124
|
+
|---|---|---|
|
|
125
|
+
| `pushOnToolError` | `true` | 工具失败时是否自动推送匹配条目 |
|
|
126
|
+
| `pushMinScore` | `12` | 自动推送的最低相关度。低于它的匹配不打扰模型 |
|
|
127
|
+
| `maxEntries` | `2000` | 硬上限;超出后按更新时间删除最旧的**已归档**条目 |
|
|
128
|
+
| `archiveAfterDays` | `90` | 超过这么多天未被命中的条目移出检索(不删除) |
|
|
129
|
+
| `statePath` | `''` | 空则用 `$DSH_HOME/solution-ledger.json` |
|
|
130
|
+
|
|
131
|
+
## 限制
|
|
132
|
+
|
|
133
|
+
- **没有语义检索。** 匹配基于词元与子串,靠的是 `signals` 写得准。写得越像真实报错,命中率越高。
|
|
134
|
+
- **没有 UI。** 确认草稿需要让模型调 `solution_log` 带上 `status: "confirmed"`,或直接改 JSON 文件。
|
|
135
|
+
- **单进程。** 存储是本地文件,两个 DSH 进程同时写会互相覆盖。
|
|
136
|
+
- **`decision` 类不做自动推送。** 选技术路线不产生错误事件,这类条目只能靠 `solution_search` 主动查。
|
|
137
|
+
|
|
138
|
+
## 许可证
|
|
139
|
+
|
|
140
|
+
MIT,见 [LICENSE](LICENSE)。
|
package/cordis.patch.yml
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Every value below is a tunable default: edit this row (or override it in the
|
|
2
|
+
# profile's own cordis.patch.yml) instead of the plugin source.
|
|
3
|
+
- insert:
|
|
4
|
+
- id: solution-ledger
|
|
5
|
+
name: 'dsh-solution-ledger'
|
|
6
|
+
config:
|
|
7
|
+
# Surface a matching confirmed entry when a tool call fails.
|
|
8
|
+
pushOnToolError: true
|
|
9
|
+
# Minimum relevance score before an automatic note is attached.
|
|
10
|
+
pushMinScore: 12
|
|
11
|
+
# Hard ceiling; the oldest archived entries are dropped past this.
|
|
12
|
+
maxEntries: 2000
|
|
13
|
+
# Entries untouched for this many days are archived out of search.
|
|
14
|
+
archiveAfterDays: 90
|
|
15
|
+
# Absolute path for the JSON store. Empty uses $DSH_HOME/solution-ledger.json.
|
|
16
|
+
statePath: ''
|
package/icon.svg
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" width="64" height="64" role="img" aria-label="Solution ledger">
|
|
2
|
+
<rect width="64" height="64" rx="14" fill="#2563eb"/>
|
|
3
|
+
<rect x="14" y="12" width="32" height="40" rx="6" fill="#ffffff" opacity="0.96"/>
|
|
4
|
+
<g fill="#2563eb">
|
|
5
|
+
<rect x="20" y="20" width="20" height="3" rx="1.5"/>
|
|
6
|
+
<rect x="20" y="27" width="14" height="3" rx="1.5"/>
|
|
7
|
+
<rect x="20" y="34" width="17" height="3" rx="1.5"/>
|
|
8
|
+
</g>
|
|
9
|
+
<circle cx="46" cy="46" r="12" fill="#16a34a"/>
|
|
10
|
+
<path d="M40.6 46.3l3.9 3.9 7.5-7.8" fill="none" stroke="#ffffff" stroke-width="2.6" stroke-linecap="round" stroke-linejoin="round"/>
|
|
11
|
+
</svg>
|