project-node-memory 1.3.0 → 1.3.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 +5 -20
- package/README_EN.md +3 -24
- package/lib/host/prompt.js +5 -6
- package/lib/host/tools.js +13 -16
- package/package.json +1 -1
- package/skills/project-node-memory-guide/SKILL.md +4 -6
package/README.md
CHANGED
|
@@ -2,15 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
> 简体中文 · [English](README_EN.md)
|
|
4
4
|
|
|
5
|
-
把 **Markdown 目录当成知识库** 的 DSH 插件:为 Agent 提供
|
|
5
|
+
把 **Markdown 目录当成知识库** 的 DSH 插件:为 Agent 提供 9 个 `kb_*` 工具,为人类提供知识节点面板(侧栏入口名「项目节点知识库」)。
|
|
6
6
|
|
|
7
7
|
没有索引数据库、没有向量、没有后台进程。完整知识库位于项目下的 `.nodekb/` 目录——一堆 md 文件,删掉插件之后它仍然是普通 md。
|
|
8
8
|
|
|
9
|
+
本 README 只描述**当前版本**的行为;每个版本的变更记录在 [Releases](https://github.com/levodoubt/project-node-memory/releases)。
|
|
10
|
+
|
|
9
11
|
```
|
|
10
12
|
项目/
|
|
11
13
|
└── .nodekb/
|
|
12
14
|
├── index/entry.md ## 3.1 编译契约
|
|
13
|
-
├── doc/03-build.md <
|
|
15
|
+
├── doc/03-build.md <tscl id="fact:abi">…</tscl>
|
|
14
16
|
├── lessons/001.md
|
|
15
17
|
└── diag_ignore.json 可选:豁免样板块
|
|
16
18
|
```
|
|
@@ -92,7 +94,7 @@ config:
|
|
|
92
94
|
面板只读,数据走宿主侧注册的 `/nodekb/api/*`。写库就是写 md——用 `write` / `edit` 工具,或者 `kb_write`。
|
|
93
95
|
右栏正文单次最多渲染 10000 字符(超出显示截断提示);宽表格横向滚动,长文本纵向滚动。
|
|
94
96
|
|
|
95
|
-
##
|
|
97
|
+
## 9 个工具
|
|
96
98
|
|
|
97
99
|
| 工具 | 干什么 |
|
|
98
100
|
| --------------- | ---------------------------------------------------------------------------------------------- |
|
|
@@ -197,23 +199,6 @@ ABI 校验见 [[tscl="fact:ver"]]。
|
|
|
197
199
|
|
|
198
200
|
旧写法 `[[TID]]` 仍兼容(有定义时当宏、否则当链接),`kb_diag` 会 warning,2.0 移除。
|
|
199
201
|
|
|
200
|
-
## 从 1.0 升到 1.1
|
|
201
|
-
|
|
202
|
-
数据格式没变——md 还是 md,TID 还是那些 TID,插件卸了照样能读。变化只有两条:
|
|
203
|
-
|
|
204
|
-
1. **`[[x]]` 现在只出链接**,不再把被引用节点的正文复制进来(要复制原文请显式写 `<tscl>`)。
|
|
205
|
-
好处是引用不再撑大渲染结果,位置型小节 `## 3.1` 也能点了。
|
|
206
|
-
2. **`kb_init` 不再建 `facts/`**。已有的 `facts/` 不会被动,`kb_read`/`kb_search` 照常;只是新库默认只有
|
|
207
|
-
`doc/ lessons/ todo/ index/`,事实改写成 `<tscl>` 定义放进它所属的 `doc/` 里。
|
|
208
|
-
|
|
209
|
-
老库要不要迁?**不迁也能用**,只是 `kb_diag` 会给每条裸引用一条 warning。要迁就让 Agent 按
|
|
210
|
-
`kb_diag` 的清单逐条改成 `[[node="…"]]` / `[[tscl="…"]]`(只改写法,不动 TID 与文件):
|
|
211
|
-
|
|
212
|
-
```text
|
|
213
|
-
kb_diag # 列出每条 `旧语法引用`
|
|
214
|
-
kb_write mode=node target=<TID> content=… # 逐条改,或直接改 md 再 kb_diag 复验
|
|
215
|
-
```
|
|
216
|
-
|
|
217
202
|
## 自检(不装 DSH 也能跑)
|
|
218
203
|
|
|
219
204
|
```bash
|
package/README_EN.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
A DSH plugin that treats **a directory of Markdown as a database**: nine `kb_*` tools for the agent, and a center-column panel for humans (sidebar entry: 「项目节点知识库」).
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
This README describes **the current version only**; per-version changes live in [Releases](https://github.com/levodoubt/project-node-memory/releases).
|
|
8
8
|
|
|
9
9
|
No index database, no embeddings, no background process. The library *is* the `.nodekb/` directory in your project — a pile of Markdown files that stay ordinary Markdown if you uninstall the plugin.
|
|
10
10
|
|
|
@@ -12,7 +12,7 @@ No index database, no embeddings, no background process. The library *is* the `.
|
|
|
12
12
|
project/
|
|
13
13
|
└── .nodekb/
|
|
14
14
|
├── index/entry.md ## 3.1 Compile contract
|
|
15
|
-
├── doc/03-build.md <
|
|
15
|
+
├── doc/03-build.md <tscl id="fact:abi">…</tscl>
|
|
16
16
|
├── lessons/001.md
|
|
17
17
|
└── diag_ignore.json optional: whitelist boilerplate blocks
|
|
18
18
|
```
|
|
@@ -89,7 +89,7 @@ The Markdown renderer is a small home-grown one (headings, lists, code, tables,
|
|
|
89
89
|
The panel is read-only; data flows through host routes under `/nodekb/api/*`. Writing a library means writing Markdown — via `write` / `edit`, or `kb_write`.
|
|
90
90
|
The right column renders at most 10,000 characters per view (with a truncation notice); wide tables scroll horizontally and long text scrolls vertically.
|
|
91
91
|
|
|
92
|
-
## The
|
|
92
|
+
## The nine tools
|
|
93
93
|
|
|
94
94
|
| Tool | What it does |
|
|
95
95
|
|---|---|
|
|
@@ -179,27 +179,6 @@ and who references it.
|
|
|
179
179
|
The old `[[TID]]` form still works (macro when a definition exists, link otherwise) with a
|
|
180
180
|
`kb_diag` warning, and goes away in 2.0.
|
|
181
181
|
|
|
182
|
-
## Upgrading from 1.0
|
|
183
|
-
|
|
184
|
-
The data format is unchanged — Markdown stays Markdown, TIDs stay the same, and the library remains
|
|
185
|
-
readable after the plugin is removed. Only two things changed:
|
|
186
|
-
|
|
187
|
-
1. **`[[x]]` now renders a link only**; it no longer copies the referenced node's body into the
|
|
188
|
-
output (use an explicit `<tscl>` for that). References stop inflating rendered size, and
|
|
189
|
-
positional sections (`## 3.1`) become clickable.
|
|
190
|
-
2. **`kb_init` no longer creates `facts/`.** Existing `facts/` folders are untouched and still
|
|
191
|
-
readable/searchable; new libraries get `doc/ lessons/ todo/ index/` only, and facts become
|
|
192
|
-
`<tscl>` definitions inside the `doc/` file they belong to.
|
|
193
|
-
|
|
194
|
-
Do old libraries need migrating? **No** — they keep working, `kb_diag` just emits one warning per
|
|
195
|
-
bare reference. To migrate, have the agent walk the `kb_diag` list and fix each one (syntax only, no
|
|
196
|
-
TID or file changes):
|
|
197
|
-
|
|
198
|
-
```text
|
|
199
|
-
kb_diag # lists every `旧语法引用` (legacy bare ref)
|
|
200
|
-
kb_write mode=node target=<TID> content=… # fix one at a time, or edit the md and re-run kb_diag
|
|
201
|
-
```
|
|
202
|
-
|
|
203
182
|
## Self-check (no DSH required)
|
|
204
183
|
|
|
205
184
|
```bash
|
package/lib/host/prompt.js
CHANGED
|
@@ -14,14 +14,13 @@ export const PROMPT_SECTION_ORDER = 100
|
|
|
14
14
|
export const DEFAULT_PROMPT = [
|
|
15
15
|
'## 项目知识库(project-node-memory)',
|
|
16
16
|
'',
|
|
17
|
-
'
|
|
17
|
+
'当本项目需要沉淀长期知识(设计决策、踩坑、事实常量、待办、交接)时,可用 `.nodekb/` + `kb_*` 工具。',
|
|
18
18
|
'',
|
|
19
|
-
'- 建库:`kb_init`
|
|
20
|
-
'- 写库:`kb_write`(append/replace/create,或对显式节点用 mode=node)。写前校验 TID
|
|
21
|
-
'- 读库:先 `kb_read mode=toc`
|
|
19
|
+
'- 建库:`kb_init` 一次铺出骨架 `doc/ lessons/ todo/ index/entry.md` + 落位约定。已有 `.nodekb/` 就别重建;目录与节点类型都可按项目实际增删。',
|
|
20
|
+
'- 写库:`kb_write`(append/replace/create,或对显式节点用 mode=node)。写前校验 TID 与标签独占一行,写后 `kb_diag` 报悬空引用/重复定义。',
|
|
21
|
+
'- 读库:先 `kb_read mode=toc` 看结构,再按 TID 读一支;找不到就 `kb_search`。别一次性把整库读进上下文。',
|
|
22
22
|
'- 改名前先 `kb_backlinks`,改名用 `kb_rename`(会重写全库引用并跳过被并发改过的文件)。',
|
|
23
|
-
'-
|
|
24
|
-
'- 旧写法 `[[TID]]` 仍能用但 `kb_diag` 会 warning,2.0 移除(老库按 diag 清单逐处改成 `[[node=…]]` / `[[tscl=…]]`)。',
|
|
23
|
+
'- 引用分两种:结构用 `[[node="xxx"]]`(只出一个链接,不复制正文);值只写一处——定义 `<tscl id="xxx:xxx">…</tscl>`,嵌入处写 `[[tscl="xxx:xxx"]]`,同一 id 全库只能定义一次。定义可就近写在正文句子里(单行、别写进表格)。读一个值用 `kb_read target=<定义 id>`。',
|
|
25
24
|
].join('\n')
|
|
26
25
|
|
|
27
26
|
function textOf(config) {
|
package/lib/host/tools.js
CHANGED
|
@@ -73,8 +73,7 @@ export function buildTools(ctx, config) {
|
|
|
73
73
|
tools.push({
|
|
74
74
|
name: 'kb_list',
|
|
75
75
|
description:
|
|
76
|
-
'列出当前可用的 nodekb
|
|
77
|
-
'不确定该传什么 kb 参数时先调它。只读、极轻量。',
|
|
76
|
+
'列出当前可用的 nodekb 知识库以及本次调用实际会命中的默认库。不确定该传什么 kb 参数时先用它。',
|
|
78
77
|
parameters: { type: 'object', properties: {} },
|
|
79
78
|
output: {
|
|
80
79
|
schema: {},
|
|
@@ -97,13 +96,15 @@ export function buildTools(ctx, config) {
|
|
|
97
96
|
tools.push({
|
|
98
97
|
name: 'kb_read',
|
|
99
98
|
description:
|
|
100
|
-
'读知识库的一个节点。target = TID 或其唯一前缀(空/"." = 库根),也可以是 <tscl id>
|
|
101
|
-
'mode: subtree(默认,整支投影)| toc
|
|
102
|
-
'先定位再读)| node(只本节点)| raw(元信息+原文)。比 read 好在 TID 不随行号漂移;超 maxlen 会报错并提示换 toc/node。',
|
|
99
|
+
'读知识库的一个节点。target = TID 或其唯一前缀(空/"." = 库根),也可以是 <tscl id> 定义的名字。' +
|
|
100
|
+
'mode: subtree(默认,整支投影)| toc(只看结构,先定位再读)| node(只本节点)| raw(元信息+原文)。',
|
|
103
101
|
parameters: {
|
|
104
102
|
type: 'object',
|
|
105
103
|
properties: {
|
|
106
|
-
target: {
|
|
104
|
+
target: {
|
|
105
|
+
type: 'string',
|
|
106
|
+
description: '节点 TID 或其唯一前缀;也可以是 <tscl id> 定义的名字(回定义体、定义处、被谁引用)。空字符串或 "." 表示库根。',
|
|
107
|
+
},
|
|
107
108
|
kb: KB_PARAM,
|
|
108
109
|
mode: {
|
|
109
110
|
type: 'string',
|
|
@@ -185,8 +186,7 @@ export function buildTools(ctx, config) {
|
|
|
185
186
|
tools.push({
|
|
186
187
|
name: 'kb_search',
|
|
187
188
|
description:
|
|
188
|
-
'检索知识库(中文 2-gram + 多词加权 +
|
|
189
|
-
'先 kb_search 拿 tid 再 kb_read,比 grep 后逐个 read 省往返。',
|
|
189
|
+
'检索知识库(中文 2-gram + 多词加权 + 子串兜底)。建议先 kb_search 拿 tid 再 kb_read。',
|
|
190
190
|
parameters: {
|
|
191
191
|
type: 'object',
|
|
192
192
|
properties: {
|
|
@@ -224,8 +224,7 @@ export function buildTools(ctx, config) {
|
|
|
224
224
|
tools.push({
|
|
225
225
|
name: 'kb_diag',
|
|
226
226
|
description:
|
|
227
|
-
'结构自检。errors =
|
|
228
|
-
'warnings = 疑似漂移(同一段文字出现在多处),默认不算失败。写完 md 就跑一次。',
|
|
227
|
+
'结构自检。errors = 真损坏;warnings = 疑似漂移,默认不算失败。建议写完 md 就跑一次。',
|
|
229
228
|
parameters: {
|
|
230
229
|
type: 'object',
|
|
231
230
|
properties: {
|
|
@@ -254,8 +253,7 @@ export function buildTools(ctx, config) {
|
|
|
254
253
|
tools.push({
|
|
255
254
|
name: 'kb_backlinks',
|
|
256
255
|
description:
|
|
257
|
-
'反查:谁引用了这个 id
|
|
258
|
-
'比全库 grep 准——只认真实引用语法。',
|
|
256
|
+
'反查:谁引用了这个 id。建议改 TID 或删节点前先跑。',
|
|
259
257
|
parameters: {
|
|
260
258
|
type: 'object',
|
|
261
259
|
properties: {
|
|
@@ -289,8 +287,7 @@ export function buildTools(ctx, config) {
|
|
|
289
287
|
tools.push({
|
|
290
288
|
name: 'kb_rename',
|
|
291
289
|
description:
|
|
292
|
-
'重命名 md
|
|
293
|
-
'写前重读校验,别人刚改过的文件跳过不覆盖。',
|
|
290
|
+
'重命名 md 文件并改写全库指向它的引用。写前重读校验,别人刚改过的文件跳过不覆盖。',
|
|
294
291
|
parameters: {
|
|
295
292
|
type: 'object',
|
|
296
293
|
properties: {
|
|
@@ -403,8 +400,8 @@ export function buildTools(ctx, config) {
|
|
|
403
400
|
tools.push({
|
|
404
401
|
name: 'kb_write',
|
|
405
402
|
description:
|
|
406
|
-
'
|
|
407
|
-
'
|
|
403
|
+
'写库并立刻自检。写前会校验 TID 与 <node> 规范。' +
|
|
404
|
+
'mode=append(追加,不存在则建)| replace(整篇)| create(只新建)| node(就地改一个 <node> 块)。',
|
|
408
405
|
parameters: {
|
|
409
406
|
type: 'object',
|
|
410
407
|
properties: {
|
package/package.json
CHANGED
|
@@ -36,10 +36,10 @@ kb_search query=... # toc 里找不到再搜
|
|
|
36
36
|
|
|
37
37
|
## 两种引用方法
|
|
38
38
|
|
|
39
|
-
| 写法 | 渲染成 |
|
|
40
|
-
| ----------------------------- | ---------------------------------------------- |
|
|
41
|
-
| `[[node="doc:03-build:3.1"]]` | 一个链接,**不复制正文** |
|
|
42
|
-
| `[[tscl="fact:abi"]]` | 把 `<tscl id="fact:abi">` 的定义体**替换进来** |
|
|
39
|
+
| 写法 | 渲染成 |
|
|
40
|
+
| ----------------------------- | ---------------------------------------------- |
|
|
41
|
+
| `[[node="doc:03-build:3.1"]]` | 一个链接,**不复制正文** |
|
|
42
|
+
| `[[tscl="fact:abi"]]` | 把 `<tscl id="fact:abi">` 的定义体**替换进来** |
|
|
43
43
|
|
|
44
44
|
```md
|
|
45
45
|
<tscl id="fact:sample">
|
|
@@ -81,5 +81,3 @@ kb_write target=doc/03-...md mode=append content=...
|
|
|
81
81
|
|
|
82
82
|
1. 不要把整段对话贴进 `doc/` —— 记的是过程,不是结论。
|
|
83
83
|
2. 不要把同一件事在 `doc/` 和 `lessons/` 各写一份 —— 抽成 `<tscl>` 定义,两处都引用它。
|
|
84
|
-
|
|
85
|
-
|