wiki-graph-core 0.3.1

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.
Files changed (576) hide show
  1. package/LICENSE +201 -0
  2. package/data/editor/clue_reviewer.jinja +410 -0
  3. package/data/editor/clue_reviewer_generator.jinja +428 -0
  4. package/data/editor/revision_feedback.jinja +5 -0
  5. package/data/editor/text_compressor.jinja +127 -0
  6. package/data/guaranteed/response_intent_classifier.jinja +8 -0
  7. package/data/help/commands/archive/next.jinja +29 -0
  8. package/data/help/commands/gc.jinja +38 -0
  9. package/data/help/commands/legacy/migrate.jinja +20 -0
  10. package/data/help/commands/legacy.jinja +19 -0
  11. package/data/help/commands/maintenance/chapter/add.jinja +41 -0
  12. package/data/help/commands/maintenance/chapter/list.jinja +33 -0
  13. package/data/help/commands/maintenance/chapter/move.jinja +36 -0
  14. package/data/help/commands/maintenance/chapter/remove.jinja +26 -0
  15. package/data/help/commands/maintenance/chapter/reset.jinja +29 -0
  16. package/data/help/commands/maintenance/chapter/set-source.jinja +34 -0
  17. package/data/help/commands/maintenance/chapter/set-summary.jinja +31 -0
  18. package/data/help/commands/maintenance/chapter/set-title.jinja +29 -0
  19. package/data/help/commands/maintenance/chapter/tree.jinja +58 -0
  20. package/data/help/commands/maintenance/chapter.jinja +59 -0
  21. package/data/help/commands/maintenance/cover.jinja +28 -0
  22. package/data/help/commands/maintenance/meta.jinja +55 -0
  23. package/data/help/commands/predicate.jinja +460 -0
  24. package/data/help/commands/root.jinja +83 -0
  25. package/data/help/commands/transform.jinja +34 -0
  26. package/data/help/commands/uri.jinja +274 -0
  27. package/data/help/topics/config.jinja +88 -0
  28. package/data/help/topics/format.jinja +72 -0
  29. package/data/help/topics/readiness.jinja +99 -0
  30. package/data/help/topics/recipe.jinja +151 -0
  31. package/data/help/topics/runtime.jinja +62 -0
  32. package/data/help/topics/uri.jinja +178 -0
  33. package/data/output/epub/cover.xhtml.jinja +13 -0
  34. package/data/output/epub/nav.xhtml.jinja +12 -0
  35. package/data/output/epub/package.opf.xml.jinja +39 -0
  36. package/data/output/epub/section.xhtml.jinja +12 -0
  37. package/data/topologization/book_coherence_extraction.jinja +223 -0
  38. package/data/topologization/chunk_extraction.jinja +233 -0
  39. package/data/topologization/evidence_choice.jinja +38 -0
  40. package/data/topologization/translate_chunks.jinja +138 -0
  41. package/data/topologization/user_focused_extraction.jinja +378 -0
  42. package/dist/archive/query/archive-view.d.ts +26 -0
  43. package/dist/archive/query/archive-view.js +4540 -0
  44. package/dist/archive/query/archive-view.js.map +1 -0
  45. package/dist/archive/query/continuation-cursor.d.ts +61 -0
  46. package/dist/archive/query/continuation-cursor.js +363 -0
  47. package/dist/archive/query/continuation-cursor.js.map +1 -0
  48. package/dist/archive/query/index.d.ts +29 -0
  49. package/dist/archive/query/index.js +63 -0
  50. package/dist/archive/query/index.js.map +1 -0
  51. package/dist/archive/query/lexical-search.d.ts +22 -0
  52. package/dist/archive/query/lexical-search.js +137 -0
  53. package/dist/archive/query/lexical-search.js.map +1 -0
  54. package/dist/archive/query/search-cache.d.ts +192 -0
  55. package/dist/archive/query/search-cache.js +1248 -0
  56. package/dist/archive/query/search-cache.js.map +1 -0
  57. package/dist/archive/search-index/index.d.ts +26 -0
  58. package/dist/archive/search-index/index.js +29 -0
  59. package/dist/archive/search-index/index.js.map +1 -0
  60. package/dist/archive/search-index/search-index.d.ts +26 -0
  61. package/dist/archive/search-index/search-index.js +555 -0
  62. package/dist/archive/search-index/search-index.js.map +1 -0
  63. package/dist/archive/search-index/search-tokenizer.d.ts +16 -0
  64. package/dist/archive/search-index/search-tokenizer.js +225 -0
  65. package/dist/archive/search-index/search-tokenizer.js.map +1 -0
  66. package/dist/common/cli-command.d.ts +4 -0
  67. package/dist/common/cli-command.js +7 -0
  68. package/dist/common/cli-command.js.map +1 -0
  69. package/dist/common/data-dir.d.ts +3 -0
  70. package/dist/common/data-dir.js +48 -0
  71. package/dist/common/data-dir.js.map +1 -0
  72. package/dist/common/language.d.ts +55 -0
  73. package/dist/common/language.js +208 -0
  74. package/dist/common/language.js.map +1 -0
  75. package/dist/common/llm-scope.d.ts +19 -0
  76. package/dist/common/llm-scope.js +31 -0
  77. package/dist/common/llm-scope.js.map +1 -0
  78. package/dist/common/logging.d.ts +22 -0
  79. package/dist/common/logging.js +141 -0
  80. package/dist/common/logging.js.map +1 -0
  81. package/dist/common/template.d.ts +8 -0
  82. package/dist/common/template.js +54 -0
  83. package/dist/common/template.js.map +1 -0
  84. package/dist/common/tinyld-language.d.ts +6 -0
  85. package/dist/common/tinyld-language.js +34 -0
  86. package/dist/common/tinyld-language.js.map +1 -0
  87. package/dist/common/wiki-graph-dir.d.ts +10 -0
  88. package/dist/common/wiki-graph-dir.js +41 -0
  89. package/dist/common/wiki-graph-dir.js.map +1 -0
  90. package/dist/common/wiki-graph-temp.d.ts +6 -0
  91. package/dist/common/wiki-graph-temp.js +21 -0
  92. package/dist/common/wiki-graph-temp.js.map +1 -0
  93. package/dist/common/wiki-graph-uri.d.ts +28 -0
  94. package/dist/common/wiki-graph-uri.js +171 -0
  95. package/dist/common/wiki-graph-uri.js.map +1 -0
  96. package/dist/context/index.d.ts +1 -0
  97. package/dist/context/index.js +13 -0
  98. package/dist/context/index.js.map +1 -0
  99. package/dist/context/task-context.d.ts +41 -0
  100. package/dist/context/task-context.js +111 -0
  101. package/dist/context/task-context.js.map +1 -0
  102. package/dist/document/database.d.ts +30 -0
  103. package/dist/document/database.js +273 -0
  104. package/dist/document/database.js.map +1 -0
  105. package/dist/document/document.d.ts +153 -0
  106. package/dist/document/document.js +615 -0
  107. package/dist/document/document.js.map +1 -0
  108. package/dist/document/fragments.d.ts +63 -0
  109. package/dist/document/fragments.js +371 -0
  110. package/dist/document/fragments.js.map +1 -0
  111. package/dist/document/index.d.ts +13 -0
  112. package/dist/document/index.js +62 -0
  113. package/dist/document/index.js.map +1 -0
  114. package/dist/document/schema.d.ts +8 -0
  115. package/dist/document/schema.js +472 -0
  116. package/dist/document/schema.js.map +1 -0
  117. package/dist/document/shared-state-database.d.ts +9 -0
  118. package/dist/document/shared-state-database.js +193 -0
  119. package/dist/document/shared-state-database.js.map +1 -0
  120. package/dist/document/stores.d.ts +203 -0
  121. package/dist/document/stores.js +1678 -0
  122. package/dist/document/stores.js.map +1 -0
  123. package/dist/document/text-streams.d.ts +86 -0
  124. package/dist/document/text-streams.js +515 -0
  125. package/dist/document/text-streams.js.map +1 -0
  126. package/dist/document/types.d.ts +148 -0
  127. package/dist/document/types.js +69 -0
  128. package/dist/document/types.js.map +1 -0
  129. package/dist/editor/clue.d.ts +27 -0
  130. package/dist/editor/clue.js +158 -0
  131. package/dist/editor/clue.js.map +1 -0
  132. package/dist/editor/compressor.d.ts +18 -0
  133. package/dist/editor/compressor.js +68 -0
  134. package/dist/editor/compressor.js.map +1 -0
  135. package/dist/editor/editor.d.ts +39 -0
  136. package/dist/editor/editor.js +253 -0
  137. package/dist/editor/editor.js.map +1 -0
  138. package/dist/editor/feedback.d.ts +16 -0
  139. package/dist/editor/feedback.js +104 -0
  140. package/dist/editor/feedback.js.map +1 -0
  141. package/dist/editor/index.d.ts +17 -0
  142. package/dist/editor/index.js +5 -0
  143. package/dist/editor/index.js.map +1 -0
  144. package/dist/editor/language-review.d.ts +14 -0
  145. package/dist/editor/language-review.js +35 -0
  146. package/dist/editor/language-review.js.map +1 -0
  147. package/dist/editor/log.d.ts +37 -0
  148. package/dist/editor/log.js +202 -0
  149. package/dist/editor/log.js.map +1 -0
  150. package/dist/editor/markup.d.ts +20 -0
  151. package/dist/editor/markup.js +294 -0
  152. package/dist/editor/markup.js.map +1 -0
  153. package/dist/editor/prompt-templates.d.ts +6 -0
  154. package/dist/editor/prompt-templates.js +11 -0
  155. package/dist/editor/prompt-templates.js.map +1 -0
  156. package/dist/editor/response.d.ts +5 -0
  157. package/dist/editor/response.js +31 -0
  158. package/dist/editor/response.js.map +1 -0
  159. package/dist/editor/review.d.ts +34 -0
  160. package/dist/editor/review.js +189 -0
  161. package/dist/editor/review.js.map +1 -0
  162. package/dist/editor/types.d.ts +31 -0
  163. package/dist/editor/types.js +21 -0
  164. package/dist/editor/types.js.map +1 -0
  165. package/dist/evidence-selection/anchor-resolver.d.ts +43 -0
  166. package/dist/evidence-selection/anchor-resolver.js +783 -0
  167. package/dist/evidence-selection/anchor-resolver.js.map +1 -0
  168. package/dist/evidence-selection/anchor-types.d.ts +27 -0
  169. package/dist/evidence-selection/anchor-types.js +1 -0
  170. package/dist/evidence-selection/anchor-types.js.map +1 -0
  171. package/dist/evidence-selection/index.d.ts +8 -0
  172. package/dist/evidence-selection/index.js +32 -0
  173. package/dist/evidence-selection/index.js.map +1 -0
  174. package/dist/evidence-selection/prompt.d.ts +18 -0
  175. package/dist/evidence-selection/prompt.js +54 -0
  176. package/dist/evidence-selection/prompt.js.map +1 -0
  177. package/dist/evidence-selection/quote-score.d.ts +29 -0
  178. package/dist/evidence-selection/quote-score.js +331 -0
  179. package/dist/evidence-selection/quote-score.js.map +1 -0
  180. package/dist/evidence-selection/selection-resolver.d.ts +19 -0
  181. package/dist/evidence-selection/selection-resolver.js +303 -0
  182. package/dist/evidence-selection/selection-resolver.js.map +1 -0
  183. package/dist/evidence-selection/text.d.ts +4 -0
  184. package/dist/evidence-selection/text.js +66 -0
  185. package/dist/evidence-selection/text.js.map +1 -0
  186. package/dist/evidence-selection/types.d.ts +36 -0
  187. package/dist/evidence-selection/types.js +1 -0
  188. package/dist/evidence-selection/types.js.map +1 -0
  189. package/dist/facade/app.d.ts +75 -0
  190. package/dist/facade/app.js +141 -0
  191. package/dist/facade/app.js.map +1 -0
  192. package/dist/facade/build-queue.d.ts +181 -0
  193. package/dist/facade/build-queue.js +1442 -0
  194. package/dist/facade/build-queue.js.map +1 -0
  195. package/dist/facade/chapter-build.d.ts +60 -0
  196. package/dist/facade/chapter-build.js +1020 -0
  197. package/dist/facade/chapter-build.js.map +1 -0
  198. package/dist/facade/chapter.d.ts +168 -0
  199. package/dist/facade/chapter.js +944 -0
  200. package/dist/facade/chapter.js.map +1 -0
  201. package/dist/facade/digest.d.ts +55 -0
  202. package/dist/facade/digest.js +168 -0
  203. package/dist/facade/digest.js.map +1 -0
  204. package/dist/facade/graph.d.ts +60 -0
  205. package/dist/facade/graph.js +203 -0
  206. package/dist/facade/graph.js.map +1 -0
  207. package/dist/facade/import.d.ts +49 -0
  208. package/dist/facade/import.js +262 -0
  209. package/dist/facade/import.js.map +1 -0
  210. package/dist/facade/index.d.ts +39 -0
  211. package/dist/facade/index.js +171 -0
  212. package/dist/facade/index.js.map +1 -0
  213. package/dist/facade/knowledge-graph-build.d.ts +75 -0
  214. package/dist/facade/knowledge-graph-build.js +897 -0
  215. package/dist/facade/knowledge-graph-build.js.map +1 -0
  216. package/dist/facade/llm-sampling.d.ts +11 -0
  217. package/dist/facade/llm-sampling.js +58 -0
  218. package/dist/facade/llm-sampling.js.map +1 -0
  219. package/dist/facade/types.d.ts +8 -0
  220. package/dist/facade/types.js +1 -0
  221. package/dist/facade/types.js.map +1 -0
  222. package/dist/facade/wiki-graph-archive.d.ts +41 -0
  223. package/dist/facade/wiki-graph-archive.js +130 -0
  224. package/dist/facade/wiki-graph-archive.js.map +1 -0
  225. package/dist/gc/files.d.ts +15 -0
  226. package/dist/gc/files.js +141 -0
  227. package/dist/gc/files.js.map +1 -0
  228. package/dist/gc/index.d.ts +2 -0
  229. package/dist/gc/index.js +5 -0
  230. package/dist/gc/index.js.map +1 -0
  231. package/dist/gc/lock.d.ts +3 -0
  232. package/dist/gc/lock.js +137 -0
  233. package/dist/gc/lock.js.map +1 -0
  234. package/dist/gc/runner.d.ts +9 -0
  235. package/dist/gc/runner.js +129 -0
  236. package/dist/gc/runner.js.map +1 -0
  237. package/dist/gc/tmp-gc.d.ts +5 -0
  238. package/dist/gc/tmp-gc.js +57 -0
  239. package/dist/gc/tmp-gc.js.map +1 -0
  240. package/dist/gc/types.d.ts +24 -0
  241. package/dist/gc/types.js +1 -0
  242. package/dist/gc/types.js.map +1 -0
  243. package/dist/gc.cjs +10041 -0
  244. package/dist/gc.cjs.map +1 -0
  245. package/dist/gc.d.cts +10 -0
  246. package/dist/gc.d.ts +2 -0
  247. package/dist/gc.js +5 -0
  248. package/dist/gc.js.map +1 -0
  249. package/dist/guaranteed/classifier.d.ts +10 -0
  250. package/dist/guaranteed/classifier.js +88 -0
  251. package/dist/guaranteed/classifier.js.map +1 -0
  252. package/dist/guaranteed/errors.d.ts +38 -0
  253. package/dist/guaranteed/errors.js +73 -0
  254. package/dist/guaranteed/errors.js.map +1 -0
  255. package/dist/guaranteed/index.d.ts +7 -0
  256. package/dist/guaranteed/index.js +21 -0
  257. package/dist/guaranteed/index.js.map +1 -0
  258. package/dist/guaranteed/request.d.ts +8 -0
  259. package/dist/guaranteed/request.js +206 -0
  260. package/dist/guaranteed/request.js.map +1 -0
  261. package/dist/guaranteed/response.d.ts +12 -0
  262. package/dist/guaranteed/response.js +98 -0
  263. package/dist/guaranteed/response.js.map +1 -0
  264. package/dist/guaranteed/types.d.ts +20 -0
  265. package/dist/guaranteed/types.js +1 -0
  266. package/dist/guaranteed/types.js.map +1 -0
  267. package/dist/index-B8NNnQ8P.d.ts +424 -0
  268. package/dist/index.cjs +34774 -0
  269. package/dist/index.cjs.map +1 -0
  270. package/dist/index.d.cts +2462 -0
  271. package/dist/index.d.ts +79 -0
  272. package/dist/index.js +168 -0
  273. package/dist/index.js.map +1 -0
  274. package/dist/legacy-sdpub/upgrade.d.ts +7 -0
  275. package/dist/legacy-sdpub/upgrade.js +795 -0
  276. package/dist/legacy-sdpub/upgrade.js.map +1 -0
  277. package/dist/llm/cache.d.ts +13 -0
  278. package/dist/llm/cache.js +35 -0
  279. package/dist/llm/cache.js.map +1 -0
  280. package/dist/llm/client.d.ts +26 -0
  281. package/dist/llm/client.js +572 -0
  282. package/dist/llm/client.js.map +1 -0
  283. package/dist/llm/context.d.ts +22 -0
  284. package/dist/llm/context.js +78 -0
  285. package/dist/llm/context.js.map +1 -0
  286. package/dist/llm/errors.d.ts +7 -0
  287. package/dist/llm/errors.js +12 -0
  288. package/dist/llm/errors.js.map +1 -0
  289. package/dist/llm/index.d.ts +7 -0
  290. package/dist/llm/index.js +17 -0
  291. package/dist/llm/index.js.map +1 -0
  292. package/dist/llm/request-log.d.ts +9 -0
  293. package/dist/llm/request-log.js +35 -0
  294. package/dist/llm/request-log.js.map +1 -0
  295. package/dist/llm/sampling.d.ts +11 -0
  296. package/dist/llm/sampling.js +67 -0
  297. package/dist/llm/sampling.js.map +1 -0
  298. package/dist/llm/types.d.ts +50 -0
  299. package/dist/llm/types.js +1 -0
  300. package/dist/llm/types.js.map +1 -0
  301. package/dist/output/epub/archive.d.ts +9 -0
  302. package/dist/output/epub/archive.js +81 -0
  303. package/dist/output/epub/archive.js.map +1 -0
  304. package/dist/output/epub/book.d.ts +15 -0
  305. package/dist/output/epub/book.js +76 -0
  306. package/dist/output/epub/book.js.map +1 -0
  307. package/dist/output/epub/content.d.ts +9 -0
  308. package/dist/output/epub/content.js +35 -0
  309. package/dist/output/epub/content.js.map +1 -0
  310. package/dist/output/epub/index.d.ts +20 -0
  311. package/dist/output/epub/index.js +14 -0
  312. package/dist/output/epub/index.js.map +1 -0
  313. package/dist/output/epub/model.d.ts +24 -0
  314. package/dist/output/epub/model.js +1 -0
  315. package/dist/output/epub/model.js.map +1 -0
  316. package/dist/output/epub/navigation.d.ts +10 -0
  317. package/dist/output/epub/navigation.js +39 -0
  318. package/dist/output/epub/navigation.js.map +1 -0
  319. package/dist/output/epub/package.d.ts +17 -0
  320. package/dist/output/epub/package.js +29 -0
  321. package/dist/output/epub/package.js.map +1 -0
  322. package/dist/output/epub/shared.d.ts +4 -0
  323. package/dist/output/epub/shared.js +12 -0
  324. package/dist/output/epub/shared.js.map +1 -0
  325. package/dist/output/epub/templates.d.ts +35 -0
  326. package/dist/output/epub/templates.js +26 -0
  327. package/dist/output/epub/templates.js.map +1 -0
  328. package/dist/output/index.d.ts +14 -0
  329. package/dist/output/index.js +11 -0
  330. package/dist/output/index.js.map +1 -0
  331. package/dist/output/plain-text.d.ts +18 -0
  332. package/dist/output/plain-text.js +56 -0
  333. package/dist/output/plain-text.js.map +1 -0
  334. package/dist/progress/index.d.ts +3 -0
  335. package/dist/progress/index.js +14 -0
  336. package/dist/progress/index.js.map +1 -0
  337. package/dist/progress/reporter.d.ts +10 -0
  338. package/dist/progress/reporter.js +79 -0
  339. package/dist/progress/reporter.js.map +1 -0
  340. package/dist/progress/tracker.d.ts +37 -0
  341. package/dist/progress/tracker.js +119 -0
  342. package/dist/progress/tracker.js.map +1 -0
  343. package/dist/progress/types.d.ts +28 -0
  344. package/dist/progress/types.js +1 -0
  345. package/dist/progress/types.js.map +1 -0
  346. package/dist/reader/attention/attention.d.ts +39 -0
  347. package/dist/reader/attention/attention.js +123 -0
  348. package/dist/reader/attention/attention.js.map +1 -0
  349. package/dist/reader/attention/index.d.ts +9 -0
  350. package/dist/reader/attention/index.js +5 -0
  351. package/dist/reader/attention/index.js.map +1 -0
  352. package/dist/reader/attention/wave-reflection.d.ts +21 -0
  353. package/dist/reader/attention/wave-reflection.js +153 -0
  354. package/dist/reader/attention/wave-reflection.js.map +1 -0
  355. package/dist/reader/attention/working-memory.d.ts +28 -0
  356. package/dist/reader/attention/working-memory.js +62 -0
  357. package/dist/reader/attention/working-memory.js.map +1 -0
  358. package/dist/reader/chunk-batch/extract.d.ts +13 -0
  359. package/dist/reader/chunk-batch/extract.js +14 -0
  360. package/dist/reader/chunk-batch/extract.js.map +1 -0
  361. package/dist/reader/chunk-batch/extractor.d.ts +17 -0
  362. package/dist/reader/chunk-batch/extractor.js +337 -0
  363. package/dist/reader/chunk-batch/extractor.js.map +1 -0
  364. package/dist/reader/chunk-batch/fragment-projection.d.ts +34 -0
  365. package/dist/reader/chunk-batch/fragment-projection.js +94 -0
  366. package/dist/reader/chunk-batch/fragment-projection.js.map +1 -0
  367. package/dist/reader/chunk-batch/index.d.ts +12 -0
  368. package/dist/reader/chunk-batch/index.js +13 -0
  369. package/dist/reader/chunk-batch/index.js.map +1 -0
  370. package/dist/reader/chunk-batch/language.d.ts +9 -0
  371. package/dist/reader/chunk-batch/language.js +23 -0
  372. package/dist/reader/chunk-batch/language.js.map +1 -0
  373. package/dist/reader/chunk-batch/parser.d.ts +94 -0
  374. package/dist/reader/chunk-batch/parser.js +640 -0
  375. package/dist/reader/chunk-batch/parser.js.map +1 -0
  376. package/dist/reader/chunk-batch/prompt-templates.d.ts +6 -0
  377. package/dist/reader/chunk-batch/prompt-templates.js +11 -0
  378. package/dist/reader/chunk-batch/prompt-templates.js.map +1 -0
  379. package/dist/reader/chunk-batch/types.d.ts +85 -0
  380. package/dist/reader/chunk-batch/types.js +1 -0
  381. package/dist/reader/chunk-batch/types.js.map +1 -0
  382. package/dist/reader/index.d.ts +13 -0
  383. package/dist/reader/index.js +7 -0
  384. package/dist/reader/index.js.map +1 -0
  385. package/dist/reader/reader.d.ts +37 -0
  386. package/dist/reader/reader.js +82 -0
  387. package/dist/reader/reader.js.map +1 -0
  388. package/dist/reader/segment/index.d.ts +2 -0
  389. package/dist/reader/segment/index.js +5 -0
  390. package/dist/reader/segment/index.js.map +1 -0
  391. package/dist/reader/segment/intl-segmenter.d.ts +5 -0
  392. package/dist/reader/segment/intl-segmenter.js +102 -0
  393. package/dist/reader/segment/intl-segmenter.js.map +1 -0
  394. package/dist/reader/segment/segment.d.ts +5 -0
  395. package/dist/reader/segment/segment.js +9 -0
  396. package/dist/reader/segment/segment.js.map +1 -0
  397. package/dist/reader/segment/types.d.ts +14 -0
  398. package/dist/reader/segment/types.js +1 -0
  399. package/dist/reader/segment/types.js.map +1 -0
  400. package/dist/reader/types.d.ts +29 -0
  401. package/dist/reader/types.js +1 -0
  402. package/dist/reader/types.js.map +1 -0
  403. package/dist/serial.d.ts +89 -0
  404. package/dist/serial.js +476 -0
  405. package/dist/serial.js.map +1 -0
  406. package/dist/source/adapter.d.ts +15 -0
  407. package/dist/source/adapter.js +1 -0
  408. package/dist/source/adapter.js.map +1 -0
  409. package/dist/source/epub/archive.d.ts +27 -0
  410. package/dist/source/epub/archive.js +189 -0
  411. package/dist/source/epub/archive.js.map +1 -0
  412. package/dist/source/epub/content.d.ts +22 -0
  413. package/dist/source/epub/content.js +183 -0
  414. package/dist/source/epub/content.js.map +1 -0
  415. package/dist/source/epub/document.d.ts +55 -0
  416. package/dist/source/epub/document.js +179 -0
  417. package/dist/source/epub/document.js.map +1 -0
  418. package/dist/source/epub/index.d.ts +10 -0
  419. package/dist/source/epub/index.js +6 -0
  420. package/dist/source/epub/index.js.map +1 -0
  421. package/dist/source/epub/navigation.d.ts +16 -0
  422. package/dist/source/epub/navigation.js +215 -0
  423. package/dist/source/epub/navigation.js.map +1 -0
  424. package/dist/source/epub/package.d.ts +33 -0
  425. package/dist/source/epub/package.js +237 -0
  426. package/dist/source/epub/package.js.map +1 -0
  427. package/dist/source/epub/xml.d.ts +16 -0
  428. package/dist/source/epub/xml.js +111 -0
  429. package/dist/source/epub/xml.js.map +1 -0
  430. package/dist/source/index.d.ts +12 -0
  431. package/dist/source/index.js +32 -0
  432. package/dist/source/index.js.map +1 -0
  433. package/dist/source/meta.d.ts +30 -0
  434. package/dist/source/meta.js +22 -0
  435. package/dist/source/meta.js.map +1 -0
  436. package/dist/source/plain-text.d.ts +16 -0
  437. package/dist/source/plain-text.js +86 -0
  438. package/dist/source/plain-text.js.map +1 -0
  439. package/dist/source/toc.d.ts +16 -0
  440. package/dist/source/toc.js +17 -0
  441. package/dist/source/toc.js.map +1 -0
  442. package/dist/source/types.d.ts +16 -0
  443. package/dist/source/types.js +1 -0
  444. package/dist/source/types.js.map +1 -0
  445. package/dist/topology/grouping.d.ts +15 -0
  446. package/dist/topology/grouping.js +18 -0
  447. package/dist/topology/grouping.js.map +1 -0
  448. package/dist/topology/index.d.ts +21 -0
  449. package/dist/topology/index.js +5 -0
  450. package/dist/topology/index.js.map +1 -0
  451. package/dist/topology/resource-segmentation.d.ts +13 -0
  452. package/dist/topology/resource-segmentation.js +111 -0
  453. package/dist/topology/resource-segmentation.js.map +1 -0
  454. package/dist/topology/segment-incision.d.ts +18 -0
  455. package/dist/topology/segment-incision.js +197 -0
  456. package/dist/topology/segment-incision.js.map +1 -0
  457. package/dist/topology/snake-detector.d.ts +13 -0
  458. package/dist/topology/snake-detector.js +520 -0
  459. package/dist/topology/snake-detector.js.map +1 -0
  460. package/dist/topology/snake-graph-builder.d.ts +14 -0
  461. package/dist/topology/snake-graph-builder.js +76 -0
  462. package/dist/topology/snake-graph-builder.js.map +1 -0
  463. package/dist/topology/topology.d.ts +29 -0
  464. package/dist/topology/topology.js +348 -0
  465. package/dist/topology/topology.js.map +1 -0
  466. package/dist/topology/weights.d.ts +10 -0
  467. package/dist/topology/weights.js +84 -0
  468. package/dist/topology/weights.js.map +1 -0
  469. package/dist/types-FVIqiLC9.d.cts +24 -0
  470. package/dist/utils/async-semaphore.d.ts +7 -0
  471. package/dist/utils/async-semaphore.js +40 -0
  472. package/dist/utils/async-semaphore.js.map +1 -0
  473. package/dist/utils/enum.d.ts +5 -0
  474. package/dist/utils/enum.js +18 -0
  475. package/dist/utils/enum.js.map +1 -0
  476. package/dist/utils/hash.d.ts +3 -0
  477. package/dist/utils/hash.js +132 -0
  478. package/dist/utils/hash.js.map +1 -0
  479. package/dist/utils/node-error.d.ts +4 -0
  480. package/dist/utils/node-error.js +59 -0
  481. package/dist/utils/node-error.js.map +1 -0
  482. package/dist/wikg/archive-uri.d.ts +1 -0
  483. package/dist/wikg/archive-uri.js +37 -0
  484. package/dist/wikg/archive-uri.js.map +1 -0
  485. package/dist/wikg/archive.d.ts +28 -0
  486. package/dist/wikg/archive.js +496 -0
  487. package/dist/wikg/archive.js.map +1 -0
  488. package/dist/wikg/index.d.ts +31 -0
  489. package/dist/wikg/index.js +60 -0
  490. package/dist/wikg/index.js.map +1 -0
  491. package/dist/wikg/wikg-coordinator.d.ts +45 -0
  492. package/dist/wikg/wikg-coordinator.js +1687 -0
  493. package/dist/wikg/wikg-coordinator.js.map +1 -0
  494. package/dist/wikg/wiki-graph-archive-file.d.ts +42 -0
  495. package/dist/wikg/wiki-graph-archive-file.js +78 -0
  496. package/dist/wikg/wiki-graph-archive-file.js.map +1 -0
  497. package/dist/wikilink/index.d.ts +10 -0
  498. package/dist/wikilink/index.js +7 -0
  499. package/dist/wikilink/index.js.map +1 -0
  500. package/dist/wikilink/relation-discovery.d.ts +31 -0
  501. package/dist/wikilink/relation-discovery.js +477 -0
  502. package/dist/wikilink/relation-discovery.js.map +1 -0
  503. package/dist/wikilink/types.d.ts +23 -0
  504. package/dist/wikilink/types.js +1 -0
  505. package/dist/wikilink/types.js.map +1 -0
  506. package/dist/wikilink/window.d.ts +7 -0
  507. package/dist/wikilink/window.js +53 -0
  508. package/dist/wikilink/window.js.map +1 -0
  509. package/dist/wikimatch/enrichment.d.ts +10 -0
  510. package/dist/wikimatch/enrichment.js +55 -0
  511. package/dist/wikimatch/enrichment.js.map +1 -0
  512. package/dist/wikimatch/index.d.ts +16 -0
  513. package/dist/wikimatch/index.js +66 -0
  514. package/dist/wikimatch/index.js.map +1 -0
  515. package/dist/wikimatch/option-narrowing.d.ts +17 -0
  516. package/dist/wikimatch/option-narrowing.js +208 -0
  517. package/dist/wikimatch/option-narrowing.js.map +1 -0
  518. package/dist/wikimatch/options.d.ts +14 -0
  519. package/dist/wikimatch/options.js +155 -0
  520. package/dist/wikimatch/options.js.map +1 -0
  521. package/dist/wikimatch/policy-judge.d.ts +17 -0
  522. package/dist/wikimatch/policy-judge.js +430 -0
  523. package/dist/wikimatch/policy-judge.js.map +1 -0
  524. package/dist/wikimatch/range-suppression.d.ts +9 -0
  525. package/dist/wikimatch/range-suppression.js +27 -0
  526. package/dist/wikimatch/range-suppression.js.map +1 -0
  527. package/dist/wikimatch/surface-screening.d.ts +16 -0
  528. package/dist/wikimatch/surface-screening.js +168 -0
  529. package/dist/wikimatch/surface-screening.js.map +1 -0
  530. package/dist/wikimatch/surface-window.d.ts +6 -0
  531. package/dist/wikimatch/surface-window.js +44 -0
  532. package/dist/wikimatch/surface-window.js.map +1 -0
  533. package/dist/wikimatch/types.d.ts +151 -0
  534. package/dist/wikimatch/types.js +1 -0
  535. package/dist/wikimatch/types.js.map +1 -0
  536. package/dist/wikimatch/wikispine.d.ts +43 -0
  537. package/dist/wikimatch/wikispine.js +399 -0
  538. package/dist/wikimatch/wikispine.js.map +1 -0
  539. package/dist/wikimatch/window.d.ts +6 -0
  540. package/dist/wikimatch/window.js +83 -0
  541. package/dist/wikimatch/window.js.map +1 -0
  542. package/dist/wikimatch/words.d.ts +16 -0
  543. package/dist/wikimatch/words.js +66 -0
  544. package/dist/wikimatch/words.js.map +1 -0
  545. package/dist/wikipage/cache.d.ts +18 -0
  546. package/dist/wikipage/cache.js +404 -0
  547. package/dist/wikipage/cache.js.map +1 -0
  548. package/dist/wikipage/fetch-log.d.ts +17 -0
  549. package/dist/wikipage/fetch-log.js +143 -0
  550. package/dist/wikipage/fetch-log.js.map +1 -0
  551. package/dist/wikipage/index.d.ts +14 -0
  552. package/dist/wikipage/index.js +17 -0
  553. package/dist/wikipage/index.js.map +1 -0
  554. package/dist/wikipage/normalizer.d.ts +14 -0
  555. package/dist/wikipage/normalizer.js +147 -0
  556. package/dist/wikipage/normalizer.js.map +1 -0
  557. package/dist/wikipage/rate-limiter.d.ts +13 -0
  558. package/dist/wikipage/rate-limiter.js +84 -0
  559. package/dist/wikipage/rate-limiter.js.map +1 -0
  560. package/dist/wikipage/resolver.d.ts +26 -0
  561. package/dist/wikipage/resolver.js +325 -0
  562. package/dist/wikipage/resolver.js.map +1 -0
  563. package/dist/wikipage/types.d.ts +96 -0
  564. package/dist/wikipage/types.js +1 -0
  565. package/dist/wikipage/types.js.map +1 -0
  566. package/dist/wikipage/wikimedia-client.d.ts +48 -0
  567. package/dist/wikipage/wikimedia-client.js +397 -0
  568. package/dist/wikipage/wikimedia-client.js.map +1 -0
  569. package/dist/worker-BgQ0Xl8T.d.cts +181 -0
  570. package/dist/worker.cjs +5259 -0
  571. package/dist/worker.cjs.map +1 -0
  572. package/dist/worker.d.cts +2 -0
  573. package/dist/worker.d.ts +2 -0
  574. package/dist/worker.js +5 -0
  575. package/dist/worker.js.map +1 -0
  576. package/package.json +78 -0
@@ -0,0 +1,223 @@
1
+ You are reading a long text and need to extract essential connective tissue for maintaining the book's narrative coherence.
2
+
3
+ ---
4
+
5
+ {% if user_language %}
6
+ **Language Configuration:**
7
+
8
+ **User interface language:** {{ user_language }}
9
+
10
+ **Output Requirements:**
11
+ - **label** and **content** fields: Must be in **{{ user_language }}** (translate from source text if needed)
12
+ - **evidence**: Use the evidence selection protocol below in the **original language(s)** (NEVER translate)
13
+ - Use **evidence** to identify the supporting source sentence.
14
+
15
+ **Important Notes:**
16
+ - The source text may be in any language or mix of languages
17
+ - Your job is to:
18
+ 1. Understand the text in whatever language(s) it uses
19
+ 2. Translate only **label** and **content** to {{ user_language }} for user understanding
20
+ 3. Keep **evidence** quotes in exact original language(s) - never translate them
21
+
22
+ Example output structure:
23
+ ```json
24
+ {
25
+ "importance_annotations": [
26
+ {"chunk_id": 19, "importance": "critical"}
27
+ ],
28
+ "chunks": [
29
+ {
30
+ "temp_id": "D",
31
+ "label": "{{ user_language }} translated label",
32
+ "content": "{{ user_language }} translated description",
33
+ "evidence": [
34
+ {
35
+ "sentence_id": "S1",
36
+ "quote": "Exact short original-language quote"
37
+ }
38
+ ],
39
+ "importance": "critical"
40
+ }
41
+ ]
42
+ }
43
+ ```
44
+
45
+ {% else %}
46
+ **Language Note:** No user language specified. Keep all output fields in the **SAME LANGUAGE(S) as the source text**. Do not translate anything.
47
+
48
+ **Output Requirements:**
49
+ - **label**, **content**, and **evidence**: All in the source text's original language(s)
50
+ - Use **evidence** to identify the supporting source sentence.
51
+ - If the source text contains multiple languages, preserve them as they appear
52
+ {% endif %}
53
+
54
+ ---
55
+
56
+ ## CONTEXT
57
+
58
+ These user-focused chunks were already extracted from this text segment:
59
+
60
+ {% if user_focused_chunks %}
61
+ {% for chunk in user_focused_chunks %}
62
+ {{ chunk.id }}. [{{ chunk.label }}] {{ chunk.content }}
63
+ {% endfor %}
64
+ {% else %}
65
+ (No user-focused chunks were extracted from this segment)
66
+ {% endif %}
67
+
68
+ **Current Working Memory:**
69
+ {{ working_memory }}
70
+
71
+ ---
72
+
73
+ ## TASK
74
+
75
+ Your task has two parts:
76
+
77
+ 1. **Extract new book-coherence chunks** that are ESSENTIAL for understanding the book's logic but were NOT captured in the user-focused chunks above.
78
+
79
+ 2. **Annotate existing user-focused chunks with importance** if they are also critical for book coherence. Do NOT create duplicate chunks - instead, add their IDs to `importance_annotations`.
80
+
81
+ **Be conservative**: Extract 1-3 new chunks ONLY if they meet the strict criteria below. Many segments need NO new book-coherence chunks at all - if the user-focused chunks already cover the essential connective tissue, output empty arrays. Don't extract just for the sake of extracting.
82
+
83
+ ---
84
+
85
+ ## EXTRACTION CRITERIA
86
+
87
+ ### What to extract (book-coherence chunks):
88
+
89
+ Extract information essential for understanding the book's logic and narrative flow, REGARDLESS of the reader's personal interests. This includes:
90
+
91
+ - **First introductions** of key concepts, characters, or settings that will be referenced later
92
+ - **Causal relationships** that drive the plot or argument forward
93
+ - **Context and background** that makes later content comprehensible
94
+ - **Turning points or transitions** in the narrative structure
95
+ - **Definitions, rules, or constraints** established by the author that affect subsequent content
96
+
97
+ ### What to avoid:
98
+
99
+ - Information **already captured** in the user-focused chunks above (use `importance_annotations` instead)
100
+ - Details that **won't affect comprehension** of later content
101
+ - Generic filler, repetition, or tangential information
102
+ - Content that's interesting but not structurally necessary
103
+
104
+ ### When to use importance_annotations:
105
+
106
+ If a user-focused chunk represents a **major turning point, causal link, or structural necessity** for the book's narrative flow, add it to `importance_annotations` with an appropriate importance level. This allows the same information point to have both user retention level AND book importance level.
107
+
108
+ ### Link criteria:
109
+
110
+ Connect book-coherence chunks when there are clear **logical dependencies**, **cause-and-effect relationships**, or **narrative continuity** between them.
111
+
112
+ Also link to user-focused chunks if they provide essential context for each other (e.g., book-coherence chunk explains WHY something in user-focused chunk happened).
113
+
114
+ ---
115
+
116
+ ## IMPORTANCE LEVEL GUIDELINES
117
+
118
+ Rate each book-coherence chunk (being extracted means it's already important, so use only 3 levels):
119
+
120
+ - **critical**: Essential setup, major turning points, or causal links that cannot be skipped
121
+ - Use sparingly - only for structural necessities
122
+ - **important**: Key context, definitions, or transitions that significantly aid understanding
123
+ - This should be the majority of book-coherence chunks
124
+ - **helpful**: Supplementary background or minor connective tissue
125
+ - Use for nice-to-have context
126
+
127
+ **Remember**: Book-coherence extraction should be conservative. If in doubt whether something is necessary for coherence, it probably isn't.
128
+
129
+ ---
130
+
131
+ ## LINK STRENGTH GUIDELINES
132
+
133
+ Rate each link's dependency strength:
134
+
135
+ - **critical**: Must understand FROM to understand TO (cannot skip FROM)
136
+ - **important**: FROM provides essential context for TO (should not skip FROM)
137
+ - **helpful**: FROM and TO are related but both can stand alone (optional connection)
138
+
139
+ ---
140
+
141
+ **Output Format (JSON only, no other text):**
142
+
143
+ The user will provide the same text segment in their message. Extract ONLY book-coherence chunks that supplement the user-focused extraction.
144
+
145
+ CRITICAL: You MUST output in this EXACT structure with "importance_annotations" FIRST, "chunks" SECOND, then "links" THIRD:
146
+
147
+ {
148
+ "importance_annotations": [
149
+ {"chunk_id": 19, "importance": "critical"},
150
+ {"chunk_id": 23, "importance": "important"}
151
+ ],
152
+ "chunks": [
153
+ {
154
+ "temp_id": "D",
155
+ "label": "brief topic label (5-15 chars)",
156
+ "content": "full description of the connective information",
157
+ "evidence": [
158
+ {
159
+ "sentence_id": "S1",
160
+ "quote": "exact short original-language quote"
161
+ }
162
+ ],
163
+ "importance": "critical"
164
+ }
165
+ ],
166
+ "links": [
167
+ {"from": "D", "to": 1, "strength": "important"},
168
+ {"from": 5, "to": "D", "strength": "helpful"}
169
+ ]
170
+ }
171
+
172
+ **If no book-coherence work is needed, output:**
173
+ {
174
+ "importance_annotations": [],
175
+ "chunks": [],
176
+ "links": []
177
+ }
178
+
179
+ This is a VALID successful result.
180
+ - Do NOT apologize
181
+ - Do NOT say you cannot answer
182
+ - Do NOT say no result was found
183
+ - Do NOT output explanatory text outside the JSON
184
+ - When nothing new is needed for coherence, return the empty JSON object above directly
185
+
186
+ **Field Explanations:**
187
+ - "importance_annotations": Array of importance labels for EXISTING user-focused chunks (0-5 annotations)
188
+ - Use this when a user-focused chunk is ALSO important for book coherence
189
+ - "chunk_id": The numeric ID of the user-focused chunk (from the list above)
190
+ - "importance": One of "critical", "important", or "helpful"
191
+ - This avoids duplicate extraction - the same information point gets both retention and importance labels
192
+ - **Process this FIRST**: Identify which user-focused chunks are also book-critical, then extract only what's missing
193
+
194
+ - "chunks": Array of NEW book-coherence chunks (0-3 chunks, only if essential and NOT already in user-focused)
195
+ - "temp_id": Use letters continuing from user-focused chunks (if user had A,B,C then start with D,E,F)
196
+ - "type": MUST be "book_coherence"
197
+ - "label": 5-15 character summary
198
+ - "content": Full one-sentence description
199
+ - "evidence": Evidence selection for this chunk
200
+ {{ evidence_selection_prompt | safe }}
201
+ - Keep quote in the original source language(s)
202
+ - Do NOT translate quote
203
+ - "importance": One of "critical", "important", or "helpful"
204
+ - **Process this SECOND**: After annotating existing chunks, extract only missing book-critical information
205
+
206
+ - "links": Array of relationships between chunks
207
+ - "from" can be: working memory ID (number) OR temp_id (string from user-focused OR book-coherence chunks)
208
+ - "to" can be: working memory ID (number) OR temp_id (string from user-focused OR book-coherence chunks)
209
+ - "strength": One of "critical", "important", or "helpful"
210
+ - Can link book-coherence chunks to user-focused chunks (e.g., "D" to 1)
211
+ - Use empty array [] if no relationships exist
212
+
213
+ **IMPORTANT:**
214
+ 1. The order matters! Output "importance_annotations" FIRST, "chunks" SECOND, then "links" THIRD.
215
+ 2. Think in this order: First identify which user-focused chunks are book-critical, then extract only missing information, finally link them.
216
+ 3. Every chunk MUST have a "type" field set to "book_coherence".
217
+ 4. Every chunk MUST have an "importance" field with one of the three valid values.
218
+ 5. Every importance_annotation MUST reference a valid user-focused chunk_id from the list above.
219
+ 6. Every link MUST have a "strength" field with one of the three valid values.
220
+ 7. Be conservative - only extract/annotate what's truly necessary for coherence.
221
+ 8. Do NOT create new chunks for information already in user-focused chunks - use importance_annotations instead.
222
+ 9. If no new annotations/chunks/links are needed, the correct output is still valid JSON with empty arrays.
223
+ 10. A "nothing to add" case is NOT a failure. Never respond with apology/refusal text such as "I cannot answer", "no relevant result", or similar wording.
@@ -0,0 +1,233 @@
1
+ You are a reading intention analyzer. Your task is to convert a user's reading intention into a **precise extraction ruleset**.
2
+
3
+ **CRITICAL: Use hybrid language approach:**
4
+ - **Structure keywords**: Keep in English (Rule, Semantic pattern, Information type, Recognition criteria, Specificity, Retention level, Do NOT extract if, verbatim, detailed, focused, relevant)
5
+ - **User intent descriptions**: Write in the user's language (Chinese if user writes in Chinese, English if user writes in English)
6
+ - This ensures AI recognizes the structure while preserving semantic precision of user intent
7
+
8
+ The user will tell you their reading intention in their message. Based on that intention, generate an extraction ruleset that defines:
9
+ 1. WHAT information patterns should be extracted
10
+ 2. WHAT retention level each pattern should have
11
+ 3. WHAT should be explicitly excluded
12
+
13
+ ---
14
+
15
+ **Design Philosophy:**
16
+
17
+ This framework is **genre-agnostic** - it works for narratives, academic papers, philosophy books, industry reports, and any other text type. Do NOT assume:
18
+ - The text has "scenes" or "characters"
19
+ - The text has a "protagonist"
20
+ - The text distinguishes "narrator" from "author"
21
+ - The text is a story
22
+
23
+ Instead, focus on **semantic patterns** - what types of information does the user care about, regardless of text structure.
24
+
25
+ ---
26
+
27
+ **Output Format (Structured rules, will be embedded in downstream prompts):**
28
+
29
+ Generate a numbered list of extraction rules. **Keep all structure keywords in English, but write content descriptions in the user's language.** Each rule must follow this EXACT structure:
30
+
31
+ ## Extraction Rules
32
+
33
+ ### Rule [N]: [Brief rule name in user's language]
34
+
35
+ **Semantic pattern (extract content matching this description):**
36
+ - Information type: [What kind of information does user want? Use user's own words and concepts]
37
+ - Recognition criteria: [How to identify this information? Describe semantic features, not structural positions]
38
+ - Specificity: [Any constraints? e.g., "首次出现", "针对特定对象X", "包含具体数据", "direct quotations"]
39
+
40
+ **Retention level:** [verbatim / detailed / focused / relevant] ← Keep these 4 terms in English
41
+
42
+ **Do NOT extract if:**
43
+ - [Exclusion conditions in user's language, based on user's "可以压缩/删节" hints]
44
+ - [Use semantic descriptions, not structural rules]
45
+
46
+ ---
47
+
48
+ **After all extraction rules, add a default rule:**
49
+
50
+ ### Default Rule
51
+
52
+ **IF:** Content does NOT match any of the above rules
53
+
54
+ **THEN:** Do NOT extract (leave for book-coherence phase only)
55
+
56
+ ---
57
+
58
+ ## Link Criteria
59
+
60
+ [1-2 sentences explaining when two chunks should be connected. What relationships matter? Focus on semantic connections, not structural ones.]
61
+
62
+ ---
63
+
64
+ **Important Guidelines:**
65
+
66
+ **Understanding trigger phrases for retention levels:**
67
+ - **Verbatim triggers** (entire passages): "一字不漏", "一字不改", "原文照抄", "原样引用", "verbatim", "word-for-word"
68
+ - **Detailed triggers**: "必须保留", "完整保留", "保留术语", "精确定义", "must preserve", "keep complete"
69
+ - **Focused**: User's PRIMARY interest (未明确强调但核心关注)
70
+ - **Relevant**: User's SECONDARY interest (可有可无的辅助信息)
71
+
72
+ **How to write "Information type":**
73
+ - Use the EXACT concepts and terminology from user's intention
74
+ - Examples:
75
+ - If user says "别人对朱元璋的看法" → write "他人对朱元璋的评价、态度或行为"
76
+ - If user says "model architecture" → write "模型的结构、层次或参数设计"
77
+ - If user says "核心论证" → write "作者的主要论证步骤或逻辑推理"
78
+ - If user says "market data" → write "市场规模、增长率或份额数据"
79
+
80
+ **How to write "Recognition criteria":**
81
+ - Describe SEMANTIC features, not structural positions
82
+ - Focus on "what does this information look like" rather than "where is it located"
83
+ - Examples:
84
+ - ✅ GOOD: "描述具体人物针对朱元璋的言语、动作或态度表现"
85
+ - ❌ BAD: "出现在与朱元璋互动的场景中"
86
+ - ✅ GOOD: "包含具体的数值、百分比或统计结果"
87
+ - ❌ BAD: "出现在数据章节"
88
+ - ✅ GOOD: "作者明确陈述的推理步骤或概念定义"
89
+ - ❌ BAD: "论证部分的内容"
90
+
91
+ **How to write "Specificity" (optional, use when user has special requirements):**
92
+ - Temporal constraints: "首次出现"、"最后一次"、"贯穿全文的"
93
+ - Targeting constraints: "针对主角X"、"关于概念Y"、"涉及公司Z"
94
+ - Format constraints: "直接引语"、"包含数据"、"带有作者评价"
95
+ - Completeness constraints: "完整语句"、"上下文完整"
96
+
97
+ **How to write "Do NOT extract if":**
98
+ - Based on user's explicit exclusion hints: "社会背景可以压缩" → "内容主要描述社会背景、历史事件或环境"
99
+ - Based on common distinctions:
100
+ - For narratives: External actions vs internal thoughts (外在行为 vs 内心活动)
101
+ - For academic texts: Core claims vs background review (核心观点 vs 背景综述)
102
+ - For reports: Primary data vs contextual description (关键数据 vs 背景描述)
103
+ - Use SEMANTIC criteria: "内容是概括性陈述而非具体事例" NOT "内容是作者而非角色所说"
104
+
105
+ **CRITICAL: Avoid narrative-specific assumptions:**
106
+ - ❌ DO NOT write: "Speaker/Actor: 故事中的人物(非叙述者/作者)"
107
+ - Problem: Assumes narrator/character separation, which doesn't exist in many texts
108
+ - ✅ WRITE INSTEAD: Recognition criteria: "描述具体人物的行为或言语(而非概括性评论)"
109
+ - Semantic distinction: Specific instance vs. general commentary
110
+
111
+ - ❌ DO NOT write: "Scene/Context: 第一次见面"
112
+ - Problem: Assumes text has "scenes"
113
+ - ✅ WRITE INSTEAD: Specificity: "文本明确标识为'首次'、'初次'或'第一次'的相关描述"
114
+ - Semantic distinction: First occurrence vs. subsequent occurrences
115
+
116
+ **Examples of good rule structures:**
117
+
118
+ **Example 1: Narrative text (Chinese user intention)**
119
+
120
+ User says: "压缩此书,重点关注别人对朱元璋的看法和对待方式,第一次见面的评价必须一字不漏。社会背景可以压缩。"
121
+
122
+ ✅ GOOD:
123
+ ```
124
+ ### Rule 1: 他人对朱元璋的首次评价
125
+
126
+ **Semantic pattern (extract content matching this description):**
127
+ - Information type: 他人对朱元璋的评价、态度或反应
128
+ - Recognition criteria: 描述具体人物针对朱元璋的言语、表情、动作或判断(而非概括性的历史评论)
129
+ - Specificity: 文本明确标识为"第一次见面"、"初次相识"、"初见"或类似表述的场合
130
+
131
+ **Retention level:** verbatim
132
+
133
+ **Do NOT extract if:**
134
+ - 内容描述朱元璋自己的内心想法或感受
135
+ - 内容是作者对历史的概括性评论(如"元末地主普遍如此")
136
+
137
+ ### Rule 2: 他人对待朱元璋的行为和态度
138
+
139
+ **Semantic pattern (extract content matching this description):**
140
+ - Information type: 他人对朱元璋的行为、态度或处置方式
141
+ - Recognition criteria: 描述具体人物针对朱元璋的具体行动或态度表现(而非对群体的泛泛描述)
142
+ - Specificity: 任何时间,但非"第一次见面"(已被Rule 1覆盖)
143
+
144
+ **Retention level:** detailed
145
+
146
+ **Do NOT extract if:**
147
+ - 内容主要描述社会背景、历史事件或环境,而非具体人物的行为
148
+ - 内容描述朱元璋自己的内心想法、决策过程或心理变化
149
+ ```
150
+
151
+ **Example 2: Academic paper (English user intention)**
152
+
153
+ User says: "Compress this ML paper, focus on model architecture and experimental results. Background can be compressed."
154
+
155
+ ✅ GOOD:
156
+ ```
157
+ ### Rule 1: Model architecture description
158
+
159
+ **Semantic pattern (extract content matching this description):**
160
+ - Information type: Model structure, layers, parameters, or computational flow
161
+ - Recognition criteria: Technical descriptions of how the model is constructed or operates, including specific layer types, dimensions, or architectural innovations
162
+ - Specificity: Core architectural components (not historical background of similar models)
163
+
164
+ **Retention level:** detailed
165
+
166
+ **Do NOT extract if:**
167
+ - Content is background review of related work
168
+ - Content is general motivation without technical specifics
169
+
170
+ ### Rule 2: Experimental results and comparisons
171
+
172
+ **Semantic pattern (extract content matching this description):**
173
+ - Information type: Performance metrics, comparison with baselines, or ablation study results
174
+ - Recognition criteria: Specific numerical results, tables, or quantitative comparisons showing model performance
175
+ - Specificity: Primary results (not auxiliary experiments unless directly compared to baselines)
176
+
177
+ **Retention level:** detailed
178
+
179
+ **Do NOT extract if:**
180
+ - Content is experimental setup description without results
181
+ - Content is background discussion of evaluation methods
182
+ ```
183
+
184
+ **Example 3: Philosophy book (Chinese user intention)**
185
+
186
+ User says: "压缩康德《纯粹理性批判》,重点保留先验感性论和先验逻辑的核心论证,'时空是先天直观形式'的论述一字不漏。历史背景可删。"
187
+
188
+ ✅ GOOD:
189
+ ```
190
+ ### Rule 1: 时空先天性论述
191
+
192
+ **Semantic pattern (extract content matching this description):**
193
+ - Information type: 关于时空作为先天直观形式的论证或陈述
194
+ - Recognition criteria: 康德关于时空的先天性、直观性或形式性的直接论述或论证步骤
195
+ - Specificity: 包含"先天"、"直观"、"形式"等核心概念,且专门论述时空的段落
196
+
197
+ **Retention level:** verbatim
198
+
199
+ **Do NOT extract if:**
200
+ - 内容是对其他哲学家观点的引述或批判(非康德自己的论证)
201
+
202
+ ### Rule 2: 先验感性论和先验逻辑的核心论证
203
+
204
+ **Semantic pattern (extract content matching this description):**
205
+ - Information type: 先验感性论或先验逻辑中的主要论证步骤、概念定义或推理链条
206
+ - Recognition criteria: 康德阐述核心观点、定义关键概念、或进行逻辑推导的段落(而非举例说明或历史回顾)
207
+ - Specificity: 排除时空论述(已被Rule 1覆盖)
208
+
209
+ **Retention level:** detailed
210
+
211
+ **Do NOT extract if:**
212
+ - 内容是历史背景介绍或对前人观点的综述
213
+ - 内容是辅助性的例子说明(非核心论证)
214
+ ```
215
+
216
+ ❌ BAD (uses narrative-specific structure):
217
+ ```
218
+ ### Rule 1: 核心论证
219
+
220
+ **IF (Content matches ALL of these conditions):**
221
+ - Content type: 论证步骤
222
+ - Scene/Context: 先验感性论章节 ← 这是结构位置,不是语义特征
223
+ - Speaker/Actor: 康德(非叙述者/作者) ← 康德就是作者!矛盾!
224
+
225
+ **THEN:**
226
+ - Retention level: detailed
227
+ ```
228
+
229
+ **Number of rules:**
230
+ - Typically 3-6 rules depending on complexity
231
+ - Each rule should be mutually exclusive where possible
232
+ - Rules are checked in order - first match wins
233
+ - More specific rules should come before more general rules
@@ -0,0 +1,38 @@
1
+ You previously extracted a chunk from the source text.
2
+ That chunk is already written and should not be changed.
3
+
4
+ One evidence field in that chunk is ambiguous, so you need to identify which candidate occurrence in the source text
5
+ best matches what the chunk was referring to.
6
+
7
+ This chunk originally came from the following extraction context:
8
+
9
+ {% if metadata_field == "retention" %}
10
+ User-focused extraction rules:
11
+ {{ extraction_guidance }}
12
+ {% else %}
13
+ Book-coherence extraction rules:
14
+ - Extract only information essential for understanding the text's logic and flow.
15
+ - Prefer first introductions, causal links, critical context, turning points, and definitions.
16
+ - Do not duplicate information already covered by user-focused chunks.
17
+ - Use this stage for connective tissue that is structurally necessary for comprehension.
18
+ {% endif %}
19
+
20
+ Your job:
21
+ 1. Read the previously generated chunk
22
+ 2. Read the candidate occurrences from the source text
23
+ 3. Use the extraction context above to infer why this chunk was selected
24
+ 4. Choose exactly one occurrence ID for the requested evidence field
25
+
26
+ Output format:
27
+ ```json
28
+ {"choice": "S2"}
29
+ ```
30
+
31
+ Rules:
32
+ - Choose exactly one candidate occurrence ID from the provided list
33
+ - Do not output any other fields
34
+ - Do not explain your reasoning
35
+ - Do not rewrite the chunk
36
+ - Use the extraction context above as part of your judgment
37
+ - Use the candidate context (`prev`, `text`, `next`) to disambiguate duplicates
38
+ - If several candidates look similar, still choose the single best match from the provided list
@@ -0,0 +1,138 @@
1
+ You are a professional translator specialized in translating extracted information chunks.
2
+
3
+ ---
4
+
5
+ **Target Language:** {{ user_language }}
6
+
7
+ ---
8
+
9
+ ## TRANSLATION STRATEGY
10
+
11
+ **Understand the hierarchical structure:**
12
+ - Each chunk has three fields with a clear hierarchical relationship:
13
+ 1. **sourceSentences**: Original text excerpts (the source)
14
+ 2. **content**: A summary/distillation of the sourceSentences
15
+ 3. **label**: A condensed summary of the content (5-15 characters)
16
+ - When translating, maintain this hierarchy:
17
+ - Translate **content** based on the meaning in sourceSentences
18
+ - Translate **label** as a concise summary of the translated content
19
+
20
+ **Use sourceSentences as translation reference:**
21
+ - sourceSentences provides the full context and original meaning
22
+ - This is crucial for understanding proper nouns, technical terms, and ambiguous phrases
23
+ - Especially important for short labels which may be unclear without context
24
+
25
+ **Handle already-translated content:**
26
+ - Some chunks may already be partially or fully in the target language
27
+ - **Check each field (label, content) individually** before translating
28
+ - **If a field is already in {{ user_language }}, keep it unchanged** - do not rephrase or rewrite
29
+ - Only translate fields that are NOT in {{ user_language }}
30
+
31
+ **Output format:**
32
+ - **Do NOT include sourceSentences in your output** - it's for reference only
33
+ - Only output: id, label, and content
34
+
35
+ ---
36
+
37
+ ## OUTPUT REQUIREMENTS
38
+
39
+ **Format:** Return a JSON array with the exact same structure as the input.
40
+
41
+ **Example:**
42
+
43
+ Input:
44
+ ```json
45
+ [
46
+ {
47
+ "id": 1,
48
+ "label": "新材料发现",
49
+ "content": "研究团队在实验室中偶然发现了一种具有超导特性的新型合金材料。",
50
+ "sourceSentences": ["在一次常规的材料测试中,科学家们意外地观察到一种金属混合物在室温下表现出零电阻现象。"]
51
+ },
52
+ {
53
+ "id": 2,
54
+ "label": "应用前景",
55
+ "content": "这种材料有望在能源传输和量子计算领域带来革命性变化。",
56
+ "sourceSentences": ["专家们认为,如果能够实现大规模生产,这项发现将彻底改变电力传输效率,并为下一代计算机技术铺平道路。"]
57
+ }
58
+ ]
59
+ ```
60
+
61
+ Output (if target language is English):
62
+ ```json
63
+ [
64
+ {
65
+ "id": 1,
66
+ "label": "New Material Found",
67
+ "content": "Research team accidentally discovered a new alloy with superconducting properties in the lab."
68
+ },
69
+ {
70
+ "id": 2,
71
+ "label": "Future Applications",
72
+ "content": "This material promises revolutionary changes in energy transmission and quantum computing."
73
+ }
74
+ ]
75
+ ```
76
+
77
+ **Notice:**
78
+ - Labels are concise translations informed by the source context
79
+ - Content accurately reflects the meaning from sourceSentences
80
+ - sourceSentences are NOT included in the output (they were only for translation reference)
81
+
82
+ ---
83
+
84
+ **Example 2 - Mixed language input (some already translated):**
85
+
86
+ Input:
87
+ ```json
88
+ [
89
+ {
90
+ "id": 3,
91
+ "label": "New Discovery",
92
+ "content": "科学家发现了一种新的治疗方法。",
93
+ "sourceSentences": ["在最新的临床试验中,研究人员成功验证了一种创新的基因疗法。"]
94
+ },
95
+ {
96
+ "id": 4,
97
+ "label": "临床试验",
98
+ "content": "Clinical trials showed 85% success rate.",
99
+ "sourceSentences": ["临床试验结果显示,在参与的200名患者中,有170人出现了显著改善。"]
100
+ }
101
+ ]
102
+ ```
103
+
104
+ Output (if target language is English):
105
+ ```json
106
+ [
107
+ {
108
+ "id": 3,
109
+ "label": "New Discovery",
110
+ "content": "Scientists discovered a new treatment method."
111
+ },
112
+ {
113
+ "id": 4,
114
+ "label": "Clinical Trials",
115
+ "content": "Clinical trials showed 85% success rate."
116
+ }
117
+ ]
118
+ ```
119
+
120
+ **Notice:**
121
+ - Chunk 3: label was already in English (kept unchanged), only content was translated
122
+ - Chunk 4: content was already in English (kept unchanged), only label was translated
123
+ - No unnecessary rewording or rephrasing of already-translated text
124
+
125
+ ---
126
+
127
+ ## CRITICAL RULES
128
+
129
+ 1. **Output ONLY the JSON array** - no explanations, no markdown code blocks, no extra text
130
+ 2. **Every chunk** in the input MUST appear in the output with the same id
131
+ 3. **Preserve array order** - output chunks in the same order as input
132
+ 4. **Never modify id values** - copy them exactly as provided
133
+ 5. **Check each field's language individually**:
134
+ - If label is already in {{ user_language }}, output it unchanged
135
+ - If content is already in {{ user_language }}, output it unchanged
136
+ - Only translate fields that are NOT in {{ user_language }}
137
+ 6. **Never rephrase or rewrite** content that's already in the target language
138
+ 7. **Do NOT output sourceSentences** - they are for reference only, not part of the output