@cloud411716/fancy-webnovel 4.14.0 → 4.15.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.
|
@@ -348,13 +348,13 @@ DEFINE ANALYZER material_zh
|
|
|
348
348
|
/fancy-material load <文件> 导入 JSONL
|
|
349
349
|
/fancy-material dump 导出 <工作区>/素材库.md
|
|
350
350
|
/fancy-material export [文件] 导出 SurrealDB 原生 SurrealQL 备份(默认 素材库.surql)
|
|
351
|
-
/fancy-material import [文件]
|
|
351
|
+
/fancy-material import [文件] 追加导入 SurrealQL 备份;已存在 ID 跳过
|
|
352
352
|
/fancy-material init 创建/补齐 schema、索引和查询脚本
|
|
353
353
|
/fancy-material remove 删除整个素材库(需确认)
|
|
354
354
|
/fancy-material prompt 展示全类型提示词
|
|
355
355
|
```
|
|
356
356
|
|
|
357
|
-
`dump` / `load` 面向 Markdown 清单和 JSONL 素材;`export` / `import` 面向 SurrealDB 原生 SurrealQL
|
|
357
|
+
`dump` / `load` 面向 Markdown 清单和 JSONL 素材;`export` / `import` 面向 SurrealDB 原生 SurrealQL 备份。原生备份包含表结构和记录;`import` 会补齐 schema、追加尚不存在的记录,并跳过已经存在的记录 ID,不会覆盖现有素材。
|
|
358
358
|
|
|
359
359
|
素材题材只认用户选题链路:
|
|
360
360
|
|
package/docs/workspace-mcp.md
CHANGED
|
@@ -101,7 +101,7 @@ namespace: fancy
|
|
|
101
101
|
/fancy-material load <文件> # 先校验 JSONL,再追加导入
|
|
102
102
|
/fancy-material dump # 导出 A/素材库.md
|
|
103
103
|
/fancy-material export [文件] # 导出 SurrealDB 原生 SurrealQL 备份(默认 素材库.surql)
|
|
104
|
-
/fancy-material import [文件] #
|
|
104
|
+
/fancy-material import [文件] # 追加导入 SurrealQL 备份;已存在 ID 跳过
|
|
105
105
|
/fancy-material init # 创建/补齐素材库 schema、索引、查询脚本
|
|
106
106
|
/fancy-material remove # 删除整个素材库(二次确认)
|
|
107
107
|
/fancy-material prompt # 展示全类型提示词,不发给 LLM
|
package/package.json
CHANGED
|
@@ -24,10 +24,15 @@ const NATIVE_TIMEOUT_MS = 15 * 60 * 1000;
|
|
|
24
24
|
// second definition fail with "field already exists". Rewriting definitions to
|
|
25
25
|
// OVERWRITE avoids that conflict and lets a restore replace existing schema.
|
|
26
26
|
const DEFINITION_RE = /^(\s*)DEFINE\s+(TABLE|FIELD|INDEX|FUNCTION|ANALYZER|PARAM|EVENT)\s+(?!OVERWRITE\b|IF\s+NOT\s+EXISTS\b)(.*)$/i;
|
|
27
|
+
const INSERT_RE = /^(\s*)INSERT\s+(\[.*)$/i;
|
|
27
28
|
|
|
28
29
|
function rewriteDefinition(line) {
|
|
29
|
-
return line
|
|
30
|
-
|
|
30
|
+
return line
|
|
31
|
+
.replace(DEFINITION_RE, (_match, indent, keyword, rest) =>
|
|
32
|
+
`${indent}DEFINE ${keyword.toUpperCase()} OVERWRITE ${rest}`)
|
|
33
|
+
// 原生备份默认用 INSERT,遇到已有记录 ID 会整批失败。IGNORE 让它
|
|
34
|
+
// 只追加缺失记录,已存在的记录原样保留。
|
|
35
|
+
.replace(INSERT_RE, (_match, indent, rest) => `${indent}INSERT IGNORE ${rest}`);
|
|
31
36
|
}
|
|
32
37
|
|
|
33
38
|
async function rewriteForImport(file) {
|
|
@@ -118,8 +123,9 @@ export async function exportMaterialDatabase(root, options = {}) {
|
|
|
118
123
|
* Import a SurrealQL backup into the material database.
|
|
119
124
|
*
|
|
120
125
|
* The backup contains its own `DEFINE TABLE` statements, so this command does
|
|
121
|
-
* not initialize the schema first
|
|
122
|
-
*
|
|
126
|
+
* not initialize the schema first. Existing schema definitions are overwritten,
|
|
127
|
+
* while records use INSERT IGNORE: missing records are appended and records
|
|
128
|
+
* whose IDs already exist are left untouched.
|
|
123
129
|
*
|
|
124
130
|
* @param {string} root workspace directory
|
|
125
131
|
* @param {string} file SurrealQL backup path
|
|
@@ -31,7 +31,7 @@ export function helpText() {
|
|
|
31
31
|
/fancy-material prompt 展示全类型提示词,不发送给 LLM
|
|
32
32
|
/fancy-material dump 把素材库导出为 <工作区>/素材库.md
|
|
33
33
|
/fancy-material export [文件.surql] 导出 SurrealDB 原生备份,默认 <工作区>/素材库.surql
|
|
34
|
-
/fancy-material import [文件.surql]
|
|
34
|
+
/fancy-material import [文件.surql] 追加导入 SurrealDB 原生备份;已存在 ID 跳过
|
|
35
35
|
/fancy-material help 显示本帮助
|
|
36
36
|
|
|
37
37
|
说明:
|
|
@@ -50,7 +50,7 @@ export function helpText() {
|
|
|
50
50
|
- 中断后重跑会开始新一轮 50 条配额,已经导入的素材不会撤销。
|
|
51
51
|
- 只追加,不覆盖;同 kind 同 name 的素材会被跳过。
|
|
52
52
|
- dump / load 面向 Markdown 清单和 JSONL 素材;export / import 面向 SurrealDB 原生 SurrealQL 备份。
|
|
53
|
-
- 原生 import
|
|
53
|
+
- 原生 import 会补齐 schema,并追加备份中尚不存在的记录;相同记录 ID 已存在时自动跳过,不会覆盖。
|
|
54
54
|
- 全文索引:name(中文 ngram);tags / genres 精确过滤。
|
|
55
55
|
- 查询脚本:<工作区>/.fancy-tools/fancy-material/query.js
|
|
56
56
|
- 校验脚本:<工作区>/.fancy-tools/fancy-material/validate.js
|