project-node-memory 1.3.0 → 1.3.2
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/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
|
-
|