inkbone 0.0.0-stage → 2.0.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.en.md +318 -0
- package/README.md +333 -2
- package/bin/inkbone.mjs +941 -0
- package/configs/genres.json +570 -0
- package/configs/messages.json +302 -0
- package/configs/platforms.json +62 -0
- package/configs/presets.json +265 -0
- package/configs/severity.json +52 -0
- package/configs/zh-linguistics.json +986 -0
- package/configs/zh-traditional.json +97 -0
- package/examples/claude-code-hooks.json +15 -0
- package/examples/mcp-config.json +12 -0
- package/package.json +61 -4
- package/prompts/00-style-architect.md +42 -0
- package/prompts/01-beat-planner.md +54 -0
- package/prompts/02-paratactic-renderer.md +60 -0
- package/prompts/03-targeted-rewriter.md +39 -0
- package/prompts/04-evidence-reviewer.md +39 -0
- package/prompts/05-reader-simulator.md +54 -0
- package/prompts/06-ledger-importer.md +41 -0
- package/prompts/07-chapter-settler.md +66 -0
- package/resources/bad_vs_good_cases.md +98 -0
- package/resources/eval/blind-read-instructions.md +18 -0
- package/resources/genre_playbooks/classical-xianxia.md +22 -0
- package/resources/genre_playbooks/general-clean.md +19 -0
- package/resources/genre_playbooks/historical-court.md +21 -0
- package/resources/genre_playbooks/light-fantasy.md +21 -0
- package/resources/genre_playbooks/mystery-thriller.md +22 -0
- package/resources/genre_playbooks/romance-emotional.md +20 -0
- package/resources/genre_playbooks/scifi-wasteland.md +21 -0
- package/resources/genre_playbooks/urban-realism.md +22 -0
- package/resources/genre_playbooks/wuxia-jianghu.md +21 -0
- package/resources/micro_techniques.md +77 -0
- package/skills/inkbone/LICENSE +21 -0
- package/skills/inkbone/README.md +334 -0
- package/skills/inkbone/SKILL.md +155 -0
- package/skills/inkbone/benchmarks/eval-set/README.md +49 -0
- package/skills/inkbone/benchmarks/eval-set/public-pairs.json +42 -0
- package/skills/inkbone/benchmarks/eval-set/seeds.json +42 -0
- package/skills/inkbone/bin/inkbone.mjs +941 -0
- package/skills/inkbone/configs/genres.json +570 -0
- package/skills/inkbone/configs/messages.json +302 -0
- package/skills/inkbone/configs/platforms.json +62 -0
- package/skills/inkbone/configs/presets.json +265 -0
- package/skills/inkbone/configs/severity.json +52 -0
- package/skills/inkbone/configs/zh-linguistics.json +986 -0
- package/skills/inkbone/configs/zh-traditional.json +97 -0
- package/skills/inkbone/package.json +63 -0
- package/skills/inkbone/prompts/00-style-architect.md +42 -0
- package/skills/inkbone/prompts/01-beat-planner.md +54 -0
- package/skills/inkbone/prompts/02-paratactic-renderer.md +60 -0
- package/skills/inkbone/prompts/03-targeted-rewriter.md +39 -0
- package/skills/inkbone/prompts/04-evidence-reviewer.md +39 -0
- package/skills/inkbone/prompts/05-reader-simulator.md +54 -0
- package/skills/inkbone/prompts/06-ledger-importer.md +41 -0
- package/skills/inkbone/prompts/07-chapter-settler.md +66 -0
- package/skills/inkbone/resources/bad_vs_good_cases.md +98 -0
- package/skills/inkbone/resources/eval/blind-read-instructions.md +18 -0
- package/skills/inkbone/resources/genre_playbooks/classical-xianxia.md +22 -0
- package/skills/inkbone/resources/genre_playbooks/general-clean.md +19 -0
- package/skills/inkbone/resources/genre_playbooks/historical-court.md +21 -0
- package/skills/inkbone/resources/genre_playbooks/light-fantasy.md +21 -0
- package/skills/inkbone/resources/genre_playbooks/mystery-thriller.md +22 -0
- package/skills/inkbone/resources/genre_playbooks/romance-emotional.md +20 -0
- package/skills/inkbone/resources/genre_playbooks/scifi-wasteland.md +21 -0
- package/skills/inkbone/resources/genre_playbooks/urban-realism.md +22 -0
- package/skills/inkbone/resources/genre_playbooks/wuxia-jianghu.md +21 -0
- package/skills/inkbone/resources/micro_techniques.md +77 -0
- package/skills/inkbone/src/auditor.mjs +24 -0
- package/skills/inkbone/src/benchmark-runner.mjs +71 -0
- package/skills/inkbone/src/boundary-compiler.mjs +54 -0
- package/skills/inkbone/src/browser-doctor.mjs +30 -0
- package/skills/inkbone/src/calibrator.mjs +175 -0
- package/skills/inkbone/src/config-loader.mjs +233 -0
- package/skills/inkbone/src/continuity.mjs +5 -0
- package/skills/inkbone/src/core/auditor.mjs +914 -0
- package/skills/inkbone/src/core/boundary-compiler.mjs +423 -0
- package/skills/inkbone/src/core/browser-doctor.mjs +318 -0
- package/skills/inkbone/src/core/config-compiler.mjs +434 -0
- package/skills/inkbone/src/core/continuity.mjs +158 -0
- package/skills/inkbone/src/core/evidence-validator.mjs +77 -0
- package/skills/inkbone/src/core/exporter.mjs +128 -0
- package/skills/inkbone/src/core/formatter.mjs +241 -0
- package/skills/inkbone/src/core/ledger-manager.mjs +576 -0
- package/skills/inkbone/src/core/normalizer.mjs +517 -0
- package/skills/inkbone/src/core/profiler.mjs +686 -0
- package/skills/inkbone/src/core/rule-engine.mjs +1536 -0
- package/skills/inkbone/src/core/style-profiler.mjs +229 -0
- package/skills/inkbone/src/detector.mjs +270 -0
- package/skills/inkbone/src/doctor.mjs +428 -0
- package/skills/inkbone/src/evaluation.mjs +311 -0
- package/skills/inkbone/src/evidence-validator.mjs +15 -0
- package/skills/inkbone/src/exporter.mjs +106 -0
- package/skills/inkbone/src/formatter.mjs +34 -0
- package/skills/inkbone/src/importer.mjs +230 -0
- package/skills/inkbone/src/index.mjs +116 -0
- package/skills/inkbone/src/ledger-manager.mjs +15 -0
- package/skills/inkbone/src/mcp-server.mjs +861 -0
- package/skills/inkbone/src/normalizer.mjs +73 -0
- package/skills/inkbone/src/profiler.mjs +17 -0
- package/skills/inkbone/src/rule-engine.mjs +73 -0
- package/skills/inkbone/src/rule-stats.mjs +142 -0
- package/skills/inkbone/src/style-profiler.mjs +25 -0
- package/src/auditor.mjs +24 -0
- package/src/benchmark-runner.mjs +71 -0
- package/src/boundary-compiler.mjs +54 -0
- package/src/browser-doctor.mjs +30 -0
- package/src/calibrator.mjs +175 -0
- package/src/config-loader.mjs +233 -0
- package/src/continuity.mjs +5 -0
- package/src/core/auditor.mjs +914 -0
- package/src/core/boundary-compiler.mjs +423 -0
- package/src/core/browser-doctor.mjs +318 -0
- package/src/core/config-compiler.mjs +434 -0
- package/src/core/continuity.mjs +158 -0
- package/src/core/evidence-validator.mjs +77 -0
- package/src/core/exporter.mjs +128 -0
- package/src/core/formatter.mjs +241 -0
- package/src/core/ledger-manager.mjs +576 -0
- package/src/core/normalizer.mjs +517 -0
- package/src/core/profiler.mjs +686 -0
- package/src/core/rule-engine.mjs +1536 -0
- package/src/core/style-profiler.mjs +229 -0
- package/src/detector.mjs +270 -0
- package/src/doctor.mjs +428 -0
- package/src/evaluation.mjs +311 -0
- package/src/evidence-validator.mjs +15 -0
- package/src/exporter.mjs +106 -0
- package/src/formatter.mjs +34 -0
- package/src/importer.mjs +230 -0
- package/src/index.mjs +116 -0
- package/src/ledger-manager.mjs +15 -0
- package/src/mcp-server.mjs +861 -0
- package/src/normalizer.mjs +73 -0
- package/src/profiler.mjs +17 -0
- package/src/rule-engine.mjs +73 -0
- package/src/rule-stats.mjs +142 -0
- package/src/style-profiler.mjs +25 -0
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import {
|
|
5
|
+
compileGenresConfig,
|
|
6
|
+
compileLinguisticsConfig,
|
|
7
|
+
compileProjectRules,
|
|
8
|
+
compileSeverityConfig,
|
|
9
|
+
compileTraditionalConfig,
|
|
10
|
+
resolveGenreFromConfig,
|
|
11
|
+
resolvePresetFromConfig,
|
|
12
|
+
} from "./core/config-compiler.mjs";
|
|
13
|
+
|
|
14
|
+
export { compileProjectRules };
|
|
15
|
+
|
|
16
|
+
// 解析内置配置文件所在目录路径
|
|
17
|
+
const currentFile = fileURLToPath(import.meta.url);
|
|
18
|
+
const srcDir = path.dirname(currentFile);
|
|
19
|
+
const rootDir = path.resolve(srcDir, "..");
|
|
20
|
+
const defaultLingPath = path.resolve(rootDir, "configs/zh-linguistics.json");
|
|
21
|
+
const defaultPresetsPath = path.resolve(rootDir, "configs/presets.json");
|
|
22
|
+
const defaultGenresPath = path.resolve(rootDir, "configs/genres.json");
|
|
23
|
+
const defaultMessagesPath = path.resolve(rootDir, "configs/messages.json");
|
|
24
|
+
const defaultTraditionalPath = path.resolve(rootDir, "configs/zh-traditional.json");
|
|
25
|
+
const defaultPlatformsPath = path.resolve(rootDir, "configs/platforms.json");
|
|
26
|
+
|
|
27
|
+
let cachedLinguistics = null;
|
|
28
|
+
let cachedPresets = null;
|
|
29
|
+
let cachedGenres = null;
|
|
30
|
+
let cachedSeverity = null;
|
|
31
|
+
let cachedMessages = null;
|
|
32
|
+
let cachedTraditional = null;
|
|
33
|
+
let cachedPlatforms = null;
|
|
34
|
+
|
|
35
|
+
// 加载并缓存中文计算语言学配置与预编译正则表达式
|
|
36
|
+
export function loadLinguisticsConfig(customPath = null) {
|
|
37
|
+
if (!customPath && cachedLinguistics) {
|
|
38
|
+
return cachedLinguistics;
|
|
39
|
+
}
|
|
40
|
+
const targetPath = customPath ? path.resolve(customPath) : defaultLingPath;
|
|
41
|
+
const raw = JSON.parse(fs.readFileSync(targetPath, "utf8"));
|
|
42
|
+
const compiled = compileLinguisticsConfig(raw);
|
|
43
|
+
if (!customPath) {
|
|
44
|
+
cachedLinguistics = compiled;
|
|
45
|
+
}
|
|
46
|
+
return compiled;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// 加载并缓存多题材语域防火墙与通用减法规则配置
|
|
50
|
+
export function loadGenresConfig(customPath = null) {
|
|
51
|
+
if (!customPath && cachedGenres) {
|
|
52
|
+
return cachedGenres;
|
|
53
|
+
}
|
|
54
|
+
const targetPath = customPath ? path.resolve(customPath) : defaultGenresPath;
|
|
55
|
+
const raw = JSON.parse(fs.readFileSync(targetPath, "utf8"));
|
|
56
|
+
const compiled = compileGenresConfig(raw);
|
|
57
|
+
if (!customPath) {
|
|
58
|
+
cachedGenres = compiled;
|
|
59
|
+
}
|
|
60
|
+
return compiled;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// 根据题材标识解析对应的语域防火墙数据包
|
|
64
|
+
export function resolveGenre(genreName, customPath = null) {
|
|
65
|
+
return resolveGenreFromConfig(loadGenresConfig(customPath), genreName);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// 加载并缓存大师声口预设门禁参数配置
|
|
69
|
+
export function loadPresetsConfig(customPath = null) {
|
|
70
|
+
if (!customPath && cachedPresets) {
|
|
71
|
+
return cachedPresets;
|
|
72
|
+
}
|
|
73
|
+
const targetPath = customPath ? path.resolve(customPath) : defaultPresetsPath;
|
|
74
|
+
const parsed = JSON.parse(fs.readFileSync(targetPath, "utf8"));
|
|
75
|
+
if (!customPath) {
|
|
76
|
+
cachedPresets = parsed;
|
|
77
|
+
}
|
|
78
|
+
return parsed;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// 加载违规码分级配置,返回 code -> level 映射
|
|
82
|
+
export function loadSeverityConfig(customPath = null) {
|
|
83
|
+
if (!customPath && cachedSeverity) {
|
|
84
|
+
return cachedSeverity;
|
|
85
|
+
}
|
|
86
|
+
const targetPath = customPath
|
|
87
|
+
? path.resolve(customPath)
|
|
88
|
+
: path.resolve(rootDir, "configs/severity.json");
|
|
89
|
+
const raw = JSON.parse(fs.readFileSync(targetPath, "utf8"));
|
|
90
|
+
const compiled = compileSeverityConfig(raw);
|
|
91
|
+
if (!customPath) {
|
|
92
|
+
cachedSeverity = compiled;
|
|
93
|
+
}
|
|
94
|
+
return compiled;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// 加载中英双语展示文案与精准改稿提示词模板配置
|
|
98
|
+
export function loadMessagesConfig(customPath = null) {
|
|
99
|
+
if (!customPath && cachedMessages) {
|
|
100
|
+
return cachedMessages;
|
|
101
|
+
}
|
|
102
|
+
const targetPath = customPath ? path.resolve(customPath) : defaultMessagesPath;
|
|
103
|
+
const parsed = JSON.parse(fs.readFileSync(targetPath, "utf8"));
|
|
104
|
+
if (!customPath) {
|
|
105
|
+
cachedMessages = parsed;
|
|
106
|
+
}
|
|
107
|
+
return parsed;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// 加载并编译繁体中文 / 港台网文规则层配置
|
|
111
|
+
export function loadTraditionalConfig(customPath = null) {
|
|
112
|
+
if (!customPath && cachedTraditional) {
|
|
113
|
+
return cachedTraditional;
|
|
114
|
+
}
|
|
115
|
+
const targetPath = customPath ? path.resolve(customPath) : defaultTraditionalPath;
|
|
116
|
+
const raw = JSON.parse(fs.readFileSync(targetPath, "utf8"));
|
|
117
|
+
const compiled = compileTraditionalConfig(raw);
|
|
118
|
+
if (!customPath) {
|
|
119
|
+
cachedTraditional = compiled;
|
|
120
|
+
}
|
|
121
|
+
return compiled;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// 加载网文平台投稿导出清洗预设配置
|
|
125
|
+
export function loadPlatformsConfig(customPath = null) {
|
|
126
|
+
if (!customPath && cachedPlatforms) {
|
|
127
|
+
return cachedPlatforms;
|
|
128
|
+
}
|
|
129
|
+
const targetPath = customPath ? path.resolve(customPath) : defaultPlatformsPath;
|
|
130
|
+
const parsed = JSON.parse(fs.readFileSync(targetPath, "utf8"));
|
|
131
|
+
if (!customPath) {
|
|
132
|
+
cachedPlatforms = parsed;
|
|
133
|
+
}
|
|
134
|
+
return parsed;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// 根据预设名称解析对应的阈值配置对象
|
|
138
|
+
export function resolvePreset(presetName, customPath = null) {
|
|
139
|
+
return resolvePresetFromConfig(loadPresetsConfig(customPath), presetName);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const PROJECT_CONFIG_NAME = "novel.json";
|
|
143
|
+
const PROJECT_SEARCH_DEPTH = 6;
|
|
144
|
+
|
|
145
|
+
// 从章节所在目录逐级向上查找书目录里的 novel.json
|
|
146
|
+
export function findProjectConfig(startDir) {
|
|
147
|
+
let curDir = path.resolve(startDir || process.cwd());
|
|
148
|
+
for (let depth = 0; depth < PROJECT_SEARCH_DEPTH; depth += 1) {
|
|
149
|
+
const candidate = path.join(curDir, PROJECT_CONFIG_NAME);
|
|
150
|
+
if (fs.existsSync(candidate)) return candidate;
|
|
151
|
+
const parent = path.dirname(curDir);
|
|
152
|
+
if (parent === curDir) break;
|
|
153
|
+
curDir = parent;
|
|
154
|
+
}
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const DEFAULT_WHITELIST_FILE = ".inkbone-whitelist";
|
|
159
|
+
|
|
160
|
+
// 读取纯字面量书级白名单文件(忽略空行与井号注释,不支持正则与跨目录继承)
|
|
161
|
+
export function loadWhitelistFile(filePath) {
|
|
162
|
+
const absPath = path.resolve(filePath);
|
|
163
|
+
if (!fs.existsSync(absPath)) return [];
|
|
164
|
+
return fs
|
|
165
|
+
.readFileSync(absPath, "utf8")
|
|
166
|
+
.split(/\r?\n/u)
|
|
167
|
+
.map((line) => line.trim())
|
|
168
|
+
.filter((line) => line.length > 0 && !line.startsWith("#"));
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// 加载书目录的 novel.json(或直接给出的规则文件),合并内联 projectRules、rulesFile 与书级白名单
|
|
172
|
+
export function loadProjectConfig(configPath) {
|
|
173
|
+
const absPath = path.resolve(configPath);
|
|
174
|
+
const raw = JSON.parse(fs.readFileSync(absPath, "utf8"));
|
|
175
|
+
const baseDir = path.dirname(absPath);
|
|
176
|
+
const isBareRulesFile =
|
|
177
|
+
!raw.projectRules &&
|
|
178
|
+
!raw.rulesFile &&
|
|
179
|
+
!raw.genre &&
|
|
180
|
+
!raw.projectTitle &&
|
|
181
|
+
!raw.whitelistFile;
|
|
182
|
+
const layers = [];
|
|
183
|
+
if (isBareRulesFile) layers.push(raw);
|
|
184
|
+
if (raw.rulesFile) {
|
|
185
|
+
layers.push(
|
|
186
|
+
JSON.parse(fs.readFileSync(path.resolve(baseDir, raw.rulesFile), "utf8"))
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
if (raw.projectRules) layers.push(raw.projectRules);
|
|
190
|
+
|
|
191
|
+
const merged = {
|
|
192
|
+
clicheRules: [],
|
|
193
|
+
fillerRules: [],
|
|
194
|
+
registerRules: [],
|
|
195
|
+
symmetricSkeletons: [],
|
|
196
|
+
rhetoricalRules: [],
|
|
197
|
+
disabledRuleIds: [],
|
|
198
|
+
whitelistLiterals: [],
|
|
199
|
+
};
|
|
200
|
+
for (const layer of layers) {
|
|
201
|
+
for (const key of Object.keys(merged)) {
|
|
202
|
+
merged[key].push(...(layer[key] || []));
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// 读取书级字面量白名单(显式 whitelistFile 或同目录下的 .inkbone-whitelist)
|
|
207
|
+
const explicitWhitelist = raw.whitelistFile
|
|
208
|
+
? path.resolve(baseDir, raw.whitelistFile)
|
|
209
|
+
: null;
|
|
210
|
+
const defaultWhitelist = path.join(baseDir, DEFAULT_WHITELIST_FILE);
|
|
211
|
+
if (explicitWhitelist) {
|
|
212
|
+
merged.whitelistLiterals.push(...loadWhitelistFile(explicitWhitelist));
|
|
213
|
+
} else if (fs.existsSync(defaultWhitelist)) {
|
|
214
|
+
merged.whitelistLiterals.push(...loadWhitelistFile(defaultWhitelist));
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
return {
|
|
218
|
+
path: absPath,
|
|
219
|
+
projectTitle: raw.projectTitle || null,
|
|
220
|
+
genre: raw.genre || null,
|
|
221
|
+
preset: raw.preset || null,
|
|
222
|
+
variant: raw.variant || null,
|
|
223
|
+
customGates:
|
|
224
|
+
raw.customGates && typeof raw.customGates === "object" && !Array.isArray(raw.customGates)
|
|
225
|
+
? raw.customGates
|
|
226
|
+
: null,
|
|
227
|
+
ledgerFile: raw.ledgerFile ? path.resolve(baseDir, raw.ledgerFile) : null,
|
|
228
|
+
whitelistFile:
|
|
229
|
+
explicitWhitelist ||
|
|
230
|
+
(fs.existsSync(defaultWhitelist) ? defaultWhitelist : null),
|
|
231
|
+
rules: compileProjectRules(merged),
|
|
232
|
+
};
|
|
233
|
+
}
|