@wanshi-kg/wanshi 0.1.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.
Files changed (443) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +458 -0
  3. package/dist/__tests__/helpers.js +27 -0
  4. package/dist/__tests__/helpers.js.map +1 -0
  5. package/dist/cli/commands/export.command.js +99 -0
  6. package/dist/cli/commands/export.command.js.map +1 -0
  7. package/dist/cli/commands/index.js +22 -0
  8. package/dist/cli/commands/index.js.map +1 -0
  9. package/dist/cli/commands/inspectMerges.command.js +84 -0
  10. package/dist/cli/commands/inspectMerges.command.js.map +1 -0
  11. package/dist/cli/commands/metrics.command.js +196 -0
  12. package/dist/cli/commands/metrics.command.js.map +1 -0
  13. package/dist/cli/commands/process.command.js +82 -0
  14. package/dist/cli/commands/process.command.js.map +1 -0
  15. package/dist/cli/commands/watch.command.js +91 -0
  16. package/dist/cli/commands/watch.command.js.map +1 -0
  17. package/dist/cli/index.js +269 -0
  18. package/dist/cli/index.js.map +1 -0
  19. package/dist/cli/optionsToConfig.js +160 -0
  20. package/dist/cli/optionsToConfig.js.map +1 -0
  21. package/dist/config/index.js +59 -0
  22. package/dist/config/index.js.map +1 -0
  23. package/dist/config/legacyHints.js +113 -0
  24. package/dist/config/legacyHints.js.map +1 -0
  25. package/dist/config/schema.js +803 -0
  26. package/dist/config/schema.js.map +1 -0
  27. package/dist/config/ui.js +221 -0
  28. package/dist/config/ui.js.map +1 -0
  29. package/dist/core/DirectoryProcessor.js +725 -0
  30. package/dist/core/DirectoryProcessor.js.map +1 -0
  31. package/dist/core/adapters/IStructuredAdapter.js +3 -0
  32. package/dist/core/adapters/IStructuredAdapter.js.map +1 -0
  33. package/dist/core/adapters/SqliteAdapter.js +267 -0
  34. package/dist/core/adapters/SqliteAdapter.js.map +1 -0
  35. package/dist/core/adapters/StructuredAdapterRegistry.js +31 -0
  36. package/dist/core/adapters/StructuredAdapterRegistry.js.map +1 -0
  37. package/dist/core/adapters/index.js +20 -0
  38. package/dist/core/adapters/index.js.map +1 -0
  39. package/dist/core/checkpoint/CheckpointService.js +188 -0
  40. package/dist/core/checkpoint/CheckpointService.js.map +1 -0
  41. package/dist/core/checkpoint/index.js +18 -0
  42. package/dist/core/checkpoint/index.js.map +1 -0
  43. package/dist/core/corpus/CorpusAnalyzer.js +266 -0
  44. package/dist/core/corpus/CorpusAnalyzer.js.map +1 -0
  45. package/dist/core/corpus/CorpusProfileStore.js +92 -0
  46. package/dist/core/corpus/CorpusProfileStore.js.map +1 -0
  47. package/dist/core/corpus/index.js +21 -0
  48. package/dist/core/corpus/index.js.map +1 -0
  49. package/dist/core/corpus/normalizeGlossary.js +60 -0
  50. package/dist/core/corpus/normalizeGlossary.js.map +1 -0
  51. package/dist/core/corpus/relPath.js +52 -0
  52. package/dist/core/corpus/relPath.js.map +1 -0
  53. package/dist/core/corpus/termFrequency.js +86 -0
  54. package/dist/core/corpus/termFrequency.js.map +1 -0
  55. package/dist/core/cost/CostMeter.js +235 -0
  56. package/dist/core/cost/CostMeter.js.map +1 -0
  57. package/dist/core/cost/index.js +19 -0
  58. package/dist/core/cost/index.js.map +1 -0
  59. package/dist/core/cost/prices.js +38 -0
  60. package/dist/core/cost/prices.js.map +1 -0
  61. package/dist/core/cv/ObjectDetectionService.js +119 -0
  62. package/dist/core/cv/ObjectDetectionService.js.map +1 -0
  63. package/dist/core/di/ContainerFactory.js +670 -0
  64. package/dist/core/di/ContainerFactory.js.map +1 -0
  65. package/dist/core/di/DIContainer.js +103 -0
  66. package/dist/core/di/DIContainer.js.map +1 -0
  67. package/dist/core/di/index.js +19 -0
  68. package/dist/core/di/index.js.map +1 -0
  69. package/dist/core/errors/CustomErrors.js +342 -0
  70. package/dist/core/errors/CustomErrors.js.map +1 -0
  71. package/dist/core/errors/index.js +18 -0
  72. package/dist/core/errors/index.js.map +1 -0
  73. package/dist/core/export/KnowledgeGraphExportService.js +56 -0
  74. package/dist/core/export/KnowledgeGraphExportService.js.map +1 -0
  75. package/dist/core/export/index.js +19 -0
  76. package/dist/core/export/index.js.map +1 -0
  77. package/dist/core/export/strategies/GraphitiExportStrategy.js +115 -0
  78. package/dist/core/export/strategies/GraphitiExportStrategy.js.map +1 -0
  79. package/dist/core/export/strategies/GraphvizDotExportStrategy.js +331 -0
  80. package/dist/core/export/strategies/GraphvizDotExportStrategy.js.map +1 -0
  81. package/dist/core/export/strategies/IExportStrategy.js +3 -0
  82. package/dist/core/export/strategies/IExportStrategy.js.map +1 -0
  83. package/dist/core/export/strategies/JsonExportStrategy.js +19 -0
  84. package/dist/core/export/strategies/JsonExportStrategy.js.map +1 -0
  85. package/dist/core/export/strategies/JsonlExportStrategy.js +69 -0
  86. package/dist/core/export/strategies/JsonlExportStrategy.js.map +1 -0
  87. package/dist/core/export/strategies/KblamExportStrategy.js +36 -0
  88. package/dist/core/export/strategies/KblamExportStrategy.js.map +1 -0
  89. package/dist/core/export/strategies/LoraExportStrategy.js +46 -0
  90. package/dist/core/export/strategies/LoraExportStrategy.js.map +1 -0
  91. package/dist/core/export/strategies/McpExportStrategy.js +67 -0
  92. package/dist/core/export/strategies/McpExportStrategy.js.map +1 -0
  93. package/dist/core/export/strategies/index.js +25 -0
  94. package/dist/core/export/strategies/index.js.map +1 -0
  95. package/dist/core/export/strategies/kbTriples.js +60 -0
  96. package/dist/core/export/strategies/kbTriples.js.map +1 -0
  97. package/dist/core/index.js +22 -0
  98. package/dist/core/index.js.map +1 -0
  99. package/dist/core/knowledge/KnowledgeGraphBuilder.js +627 -0
  100. package/dist/core/knowledge/KnowledgeGraphBuilder.js.map +1 -0
  101. package/dist/core/knowledge/MergeRecord.js +3 -0
  102. package/dist/core/knowledge/MergeRecord.js.map +1 -0
  103. package/dist/core/knowledge/canon/Canonicalizer.js +414 -0
  104. package/dist/core/knowledge/canon/Canonicalizer.js.map +1 -0
  105. package/dist/core/knowledge/canon/index.js +18 -0
  106. package/dist/core/knowledge/canon/index.js.map +1 -0
  107. package/dist/core/knowledge/contradiction/HeuristicContradictionChecker.js +92 -0
  108. package/dist/core/knowledge/contradiction/HeuristicContradictionChecker.js.map +1 -0
  109. package/dist/core/knowledge/contradiction/LlmContradictionChecker.js +52 -0
  110. package/dist/core/knowledge/contradiction/LlmContradictionChecker.js.map +1 -0
  111. package/dist/core/knowledge/contradiction/index.js +19 -0
  112. package/dist/core/knowledge/contradiction/index.js.map +1 -0
  113. package/dist/core/knowledge/grounding/KeywordGroundingChecker.js +33 -0
  114. package/dist/core/knowledge/grounding/KeywordGroundingChecker.js.map +1 -0
  115. package/dist/core/knowledge/grounding/MiniCheckGroundingChecker.js +82 -0
  116. package/dist/core/knowledge/grounding/MiniCheckGroundingChecker.js.map +1 -0
  117. package/dist/core/knowledge/grounding/index.js +20 -0
  118. package/dist/core/knowledge/grounding/index.js.map +1 -0
  119. package/dist/core/knowledge/grounding/verbalize.js +38 -0
  120. package/dist/core/knowledge/grounding/verbalize.js.map +1 -0
  121. package/dist/core/knowledge/images/imageMetaGraph.js +136 -0
  122. package/dist/core/knowledge/images/imageMetaGraph.js.map +1 -0
  123. package/dist/core/knowledge/index.js +20 -0
  124. package/dist/core/knowledge/index.js.map +1 -0
  125. package/dist/core/knowledge/merging/KnowledgeMerger.js +624 -0
  126. package/dist/core/knowledge/merging/KnowledgeMerger.js.map +1 -0
  127. package/dist/core/knowledge/references/ReferenceResolver.js +184 -0
  128. package/dist/core/knowledge/references/ReferenceResolver.js.map +1 -0
  129. package/dist/core/knowledge/references/citations/CitationEvidenceProcessor.js +401 -0
  130. package/dist/core/knowledge/references/citations/CitationEvidenceProcessor.js.map +1 -0
  131. package/dist/core/knowledge/references/citations/CitationResolver.js +95 -0
  132. package/dist/core/knowledge/references/citations/CitationResolver.js.map +1 -0
  133. package/dist/core/knowledge/references/citations/GrobidClient.js +143 -0
  134. package/dist/core/knowledge/references/citations/GrobidClient.js.map +1 -0
  135. package/dist/core/knowledge/references/citations/TitleIdResolver.js +101 -0
  136. package/dist/core/knowledge/references/citations/TitleIdResolver.js.map +1 -0
  137. package/dist/core/knowledge/references/web/FetchCacheService.js +114 -0
  138. package/dist/core/knowledge/references/web/FetchCacheService.js.map +1 -0
  139. package/dist/core/knowledge/references/web/GatedFetcher.js +228 -0
  140. package/dist/core/knowledge/references/web/GatedFetcher.js.map +1 -0
  141. package/dist/core/knowledge/references/web/WebReferenceProcessor.js +164 -0
  142. package/dist/core/knowledge/references/web/WebReferenceProcessor.js.map +1 -0
  143. package/dist/core/knowledge/search/KnowledgeGraphSearch.js +261 -0
  144. package/dist/core/knowledge/search/KnowledgeGraphSearch.js.map +1 -0
  145. package/dist/core/knowledge/vocabulary.js +162 -0
  146. package/dist/core/knowledge/vocabulary.js.map +1 -0
  147. package/dist/core/llm/EmbeddingService.js +113 -0
  148. package/dist/core/llm/EmbeddingService.js.map +1 -0
  149. package/dist/core/llm/OllamaService.js +146 -0
  150. package/dist/core/llm/OllamaService.js.map +1 -0
  151. package/dist/core/llm/OpenAICompatibleService.js +190 -0
  152. package/dist/core/llm/OpenAICompatibleService.js.map +1 -0
  153. package/dist/core/llm/OpenAIEmbeddingService.js +129 -0
  154. package/dist/core/llm/OpenAIEmbeddingService.js.map +1 -0
  155. package/dist/core/llm/embeddingUtils.js +25 -0
  156. package/dist/core/llm/embeddingUtils.js.map +1 -0
  157. package/dist/core/llm/index.js +23 -0
  158. package/dist/core/llm/index.js.map +1 -0
  159. package/dist/core/llm/prompts/PromptManager.js +388 -0
  160. package/dist/core/llm/prompts/PromptManager.js.map +1 -0
  161. package/dist/core/llm/prompts/PromptTemplateEngine.js +257 -0
  162. package/dist/core/llm/prompts/PromptTemplateEngine.js.map +1 -0
  163. package/dist/core/llm/prompts/templates/partials/examples/EXAMPLE_STYLE_GUIDE.md +84 -0
  164. package/dist/core/llm/prompts/templates/partials/examples/article.md +187 -0
  165. package/dist/core/llm/prompts/templates/partials/examples/code.md +229 -0
  166. package/dist/core/llm/prompts/templates/partials/examples/communication.md +205 -0
  167. package/dist/core/llm/prompts/templates/partials/examples/documentation.md +262 -0
  168. package/dist/core/llm/prompts/templates/partials/examples/financial.md +157 -0
  169. package/dist/core/llm/prompts/templates/partials/examples/legal.md +153 -0
  170. package/dist/core/llm/prompts/templates/partials/examples/logs.md +127 -0
  171. package/dist/core/llm/prompts/templates/partials/examples/medical.md +218 -0
  172. package/dist/core/llm/prompts/templates/partials/examples/notes.md +201 -0
  173. package/dist/core/llm/prompts/templates/partials/examples/research.md +208 -0
  174. package/dist/core/llm/prompts/templates/partials/examples/tabular.md +178 -0
  175. package/dist/core/llm/prompts/templates/partials/examples/transcript.md +204 -0
  176. package/dist/core/llm/prompts/templates/partials/retrieved-context.hbs +18 -0
  177. package/dist/core/llm/prompts/templates/v1/system.hbs +371 -0
  178. package/dist/core/llm/prompts/templates/v1/user.hbs +20 -0
  179. package/dist/core/llm/prompts/templates/v2/system.hbs +573 -0
  180. package/dist/core/llm/prompts/templates/v2/user.hbs +20 -0
  181. package/dist/core/llm/prompts/templates/v3/system.hbs +861 -0
  182. package/dist/core/llm/prompts/templates/v3/user.hbs +16 -0
  183. package/dist/core/llm/prompts/templates/v4/system.hbs +800 -0
  184. package/dist/core/llm/prompts/templates/v4/user.hbs +40 -0
  185. package/dist/core/llm/prompts/templates/v4.5/system.hbs +71 -0
  186. package/dist/core/llm/prompts/templates/v4.5/user.hbs +46 -0
  187. package/dist/core/llm/prompts/templates/v5/glossary/system.hbs +40 -0
  188. package/dist/core/llm/prompts/templates/v5/glossary/user.hbs +11 -0
  189. package/dist/core/llm/prompts/templates/v5/system.hbs +163 -0
  190. package/dist/core/llm/prompts/templates/v5/user.hbs +55 -0
  191. package/dist/core/pipeline/GroundingTransform.js +52 -0
  192. package/dist/core/pipeline/GroundingTransform.js.map +1 -0
  193. package/dist/core/pipeline/PipelineRunner.js +51 -0
  194. package/dist/core/pipeline/PipelineRunner.js.map +1 -0
  195. package/dist/core/pipeline/RelationFilterTransform.js +72 -0
  196. package/dist/core/pipeline/RelationFilterTransform.js.map +1 -0
  197. package/dist/core/pipeline/index.js +20 -0
  198. package/dist/core/pipeline/index.js.map +1 -0
  199. package/dist/core/processor/FileProcessor.js +184 -0
  200. package/dist/core/processor/FileProcessor.js.map +1 -0
  201. package/dist/core/processor/ProcessedRegistry.js +38 -0
  202. package/dist/core/processor/ProcessedRegistry.js.map +1 -0
  203. package/dist/core/processor/ast/AstSeedService.js +0 -0
  204. package/dist/core/processor/ast/AstSeedService.js.map +1 -0
  205. package/dist/core/processor/ast/AstSymbolStore.js +110 -0
  206. package/dist/core/processor/ast/AstSymbolStore.js.map +1 -0
  207. package/dist/core/processor/ast/index.js +19 -0
  208. package/dist/core/processor/ast/index.js.map +1 -0
  209. package/dist/core/processor/chunking/TextChunker.js +98 -0
  210. package/dist/core/processor/chunking/TextChunker.js.map +1 -0
  211. package/dist/core/processor/chunking/index.js +18 -0
  212. package/dist/core/processor/chunking/index.js.map +1 -0
  213. package/dist/core/processor/classifier/CONTENT_CLASSES.js +294 -0
  214. package/dist/core/processor/classifier/CONTENT_CLASSES.js.map +1 -0
  215. package/dist/core/processor/classifier/CascadeContentClassifier.js +107 -0
  216. package/dist/core/processor/classifier/CascadeContentClassifier.js.map +1 -0
  217. package/dist/core/processor/classifier/HeuristicContentClassifier.js +113 -0
  218. package/dist/core/processor/classifier/HeuristicContentClassifier.js.map +1 -0
  219. package/dist/core/processor/classifier/IContentTypeClassifier.js +3 -0
  220. package/dist/core/processor/classifier/IContentTypeClassifier.js.map +1 -0
  221. package/dist/core/processor/classifier/LlmContentClassifier.js +107 -0
  222. package/dist/core/processor/classifier/LlmContentClassifier.js.map +1 -0
  223. package/dist/core/processor/classifier/NER_DOMAIN_EXAMPLES.js +498 -0
  224. package/dist/core/processor/classifier/NER_DOMAIN_EXAMPLES.js.map +1 -0
  225. package/dist/core/processor/classifier/index.js +21 -0
  226. package/dist/core/processor/classifier/index.js.map +1 -0
  227. package/dist/core/processor/classifier/mergeClassifications.js +32 -0
  228. package/dist/core/processor/classifier/mergeClassifications.js.map +1 -0
  229. package/dist/core/processor/index.js +20 -0
  230. package/dist/core/processor/index.js.map +1 -0
  231. package/dist/core/processor/readers/AudioReader.js +462 -0
  232. package/dist/core/processor/readers/AudioReader.js.map +1 -0
  233. package/dist/core/processor/readers/BinaryReader.js +90 -0
  234. package/dist/core/processor/readers/BinaryReader.js.map +1 -0
  235. package/dist/core/processor/readers/ChandraPdfReader.js +187 -0
  236. package/dist/core/processor/readers/ChandraPdfReader.js.map +1 -0
  237. package/dist/core/processor/readers/ChatExportReader.js +365 -0
  238. package/dist/core/processor/readers/ChatExportReader.js.map +1 -0
  239. package/dist/core/processor/readers/DoclingReader.js +445 -0
  240. package/dist/core/processor/readers/DoclingReader.js.map +1 -0
  241. package/dist/core/processor/readers/EmailReader.js +259 -0
  242. package/dist/core/processor/readers/EmailReader.js.map +1 -0
  243. package/dist/core/processor/readers/EpubReader.js +175 -0
  244. package/dist/core/processor/readers/EpubReader.js.map +1 -0
  245. package/dist/core/processor/readers/FileReader.js +90 -0
  246. package/dist/core/processor/readers/FileReader.js.map +1 -0
  247. package/dist/core/processor/readers/FileReaderFactory.js +49 -0
  248. package/dist/core/processor/readers/FileReaderFactory.js.map +1 -0
  249. package/dist/core/processor/readers/HtmlReader.js +371 -0
  250. package/dist/core/processor/readers/HtmlReader.js.map +1 -0
  251. package/dist/core/processor/readers/ImageReader.js +162 -0
  252. package/dist/core/processor/readers/ImageReader.js.map +1 -0
  253. package/dist/core/processor/readers/JsonFileReader.js +232 -0
  254. package/dist/core/processor/readers/JsonFileReader.js.map +1 -0
  255. package/dist/core/processor/readers/JupyterReader.js +178 -0
  256. package/dist/core/processor/readers/JupyterReader.js.map +1 -0
  257. package/dist/core/processor/readers/LatexReader.js +176 -0
  258. package/dist/core/processor/readers/LatexReader.js.map +1 -0
  259. package/dist/core/processor/readers/MarkdownReader.js +289 -0
  260. package/dist/core/processor/readers/MarkdownReader.js.map +1 -0
  261. package/dist/core/processor/readers/MarkerPdfReader.js +193 -0
  262. package/dist/core/processor/readers/MarkerPdfReader.js.map +1 -0
  263. package/dist/core/processor/readers/MistralOcrReader.js +198 -0
  264. package/dist/core/processor/readers/MistralOcrReader.js.map +1 -0
  265. package/dist/core/processor/readers/OfficeReader.js +174 -0
  266. package/dist/core/processor/readers/OfficeReader.js.map +1 -0
  267. package/dist/core/processor/readers/PdfReader.js +116 -0
  268. package/dist/core/processor/readers/PdfReader.js.map +1 -0
  269. package/dist/core/processor/readers/RtfReader.js +107 -0
  270. package/dist/core/processor/readers/RtfReader.js.map +1 -0
  271. package/dist/core/processor/readers/SubtitleReader.js +145 -0
  272. package/dist/core/processor/readers/SubtitleReader.js.map +1 -0
  273. package/dist/core/processor/readers/TesseractPdfReader.js +183 -0
  274. package/dist/core/processor/readers/TesseractPdfReader.js.map +1 -0
  275. package/dist/core/processor/readers/TextReader.js +129 -0
  276. package/dist/core/processor/readers/TextReader.js.map +1 -0
  277. package/dist/core/processor/readers/TranscriptReader.js +234 -0
  278. package/dist/core/processor/readers/TranscriptReader.js.map +1 -0
  279. package/dist/core/processor/readers/image/imageMetadata.js +155 -0
  280. package/dist/core/processor/readers/image/imageMetadata.js.map +1 -0
  281. package/dist/core/processor/readers/index.js +41 -0
  282. package/dist/core/processor/readers/index.js.map +1 -0
  283. package/dist/core/processor/readers/referenceExtraction.js +198 -0
  284. package/dist/core/processor/readers/referenceExtraction.js.map +1 -0
  285. package/dist/core/processor/readers/stripReferences.js +59 -0
  286. package/dist/core/processor/readers/stripReferences.js.map +1 -0
  287. package/dist/core/processor/readers/transcript/turnPacking.js +81 -0
  288. package/dist/core/processor/readers/transcript/turnPacking.js.map +1 -0
  289. package/dist/core/progress/NdjsonProgressEmitter.js +30 -0
  290. package/dist/core/progress/NdjsonProgressEmitter.js.map +1 -0
  291. package/dist/core/progress/NoopProgressEmitter.js +15 -0
  292. package/dist/core/progress/NoopProgressEmitter.js.map +1 -0
  293. package/dist/core/progress/index.js +19 -0
  294. package/dist/core/progress/index.js.map +1 -0
  295. package/dist/core/trace/TraceWriter.js +100 -0
  296. package/dist/core/trace/TraceWriter.js.map +1 -0
  297. package/dist/core/trace/events.js +13 -0
  298. package/dist/core/trace/events.js.map +1 -0
  299. package/dist/core/trace/index.js +20 -0
  300. package/dist/core/trace/index.js.map +1 -0
  301. package/dist/core/trace/lineage.js +97 -0
  302. package/dist/core/trace/lineage.js.map +1 -0
  303. package/dist/evaluation/BenchmarkRunner.js +171 -0
  304. package/dist/evaluation/BenchmarkRunner.js.map +1 -0
  305. package/dist/evaluation/classifier/ClassifierAccuracy.js +185 -0
  306. package/dist/evaluation/classifier/ClassifierAccuracy.js.map +1 -0
  307. package/dist/evaluation/classifier/labeledSamples.js +379 -0
  308. package/dist/evaluation/classifier/labeledSamples.js.map +1 -0
  309. package/dist/evaluation/compare/goldCompare.js +126 -0
  310. package/dist/evaluation/compare/goldCompare.js.map +1 -0
  311. package/dist/evaluation/crossre/compareScoring.js +30 -0
  312. package/dist/evaluation/crossre/compareScoring.js.map +1 -0
  313. package/dist/evaluation/datasets/CrossREDataset.js +170 -0
  314. package/dist/evaluation/datasets/CrossREDataset.js.map +1 -0
  315. package/dist/evaluation/datasets/IDataset.js +3 -0
  316. package/dist/evaluation/datasets/IDataset.js.map +1 -0
  317. package/dist/evaluation/datasets/RebelDataset.js +117 -0
  318. package/dist/evaluation/datasets/RebelDataset.js.map +1 -0
  319. package/dist/evaluation/datasets/RedocredDataset.js +218 -0
  320. package/dist/evaluation/datasets/RedocredDataset.js.map +1 -0
  321. package/dist/evaluation/datasets/SemEval2010Dataset.js +150 -0
  322. package/dist/evaluation/datasets/SemEval2010Dataset.js.map +1 -0
  323. package/dist/evaluation/index.js +33 -0
  324. package/dist/evaluation/index.js.map +1 -0
  325. package/dist/evaluation/matching/ExactMatcher.js +75 -0
  326. package/dist/evaluation/matching/ExactMatcher.js.map +1 -0
  327. package/dist/evaluation/matching/SemanticMatcher.js +143 -0
  328. package/dist/evaluation/matching/SemanticMatcher.js.map +1 -0
  329. package/dist/evaluation/metrics/TripleMetrics.js +64 -0
  330. package/dist/evaluation/metrics/TripleMetrics.js.map +1 -0
  331. package/dist/evaluation/mine/MineCheckpoint.js +114 -0
  332. package/dist/evaluation/mine/MineCheckpoint.js.map +1 -0
  333. package/dist/evaluation/mine/MineDataset.js +208 -0
  334. package/dist/evaluation/mine/MineDataset.js.map +1 -0
  335. package/dist/evaluation/mine/MineReporter.js +98 -0
  336. package/dist/evaluation/mine/MineReporter.js.map +1 -0
  337. package/dist/evaluation/mine/MineRunner.js +148 -0
  338. package/dist/evaluation/mine/MineRunner.js.map +1 -0
  339. package/dist/evaluation/mine/MineScorer.js +127 -0
  340. package/dist/evaluation/mine/MineScorer.js.map +1 -0
  341. package/dist/evaluation/mine/types.js +12 -0
  342. package/dist/evaluation/mine/types.js.map +1 -0
  343. package/dist/evaluation/reporters/ConsoleReporter.js +55 -0
  344. package/dist/evaluation/reporters/ConsoleReporter.js.map +1 -0
  345. package/dist/evaluation/reporters/JsonReporter.js +50 -0
  346. package/dist/evaluation/reporters/JsonReporter.js.map +1 -0
  347. package/dist/index.js +28 -0
  348. package/dist/index.js.map +1 -0
  349. package/dist/quality/CompositeScore.js +61 -0
  350. package/dist/quality/CompositeScore.js.map +1 -0
  351. package/dist/quality/ConsistencyMetrics.js +70 -0
  352. package/dist/quality/ConsistencyMetrics.js.map +1 -0
  353. package/dist/quality/FactualMetrics.js +76 -0
  354. package/dist/quality/FactualMetrics.js.map +1 -0
  355. package/dist/quality/GraphHealthMetrics.js +68 -0
  356. package/dist/quality/GraphHealthMetrics.js.map +1 -0
  357. package/dist/quality/SemanticMetrics.js +102 -0
  358. package/dist/quality/SemanticMetrics.js.map +1 -0
  359. package/dist/quality/StructuralMetrics.js +60 -0
  360. package/dist/quality/StructuralMetrics.js.map +1 -0
  361. package/dist/quality/index.js +23 -0
  362. package/dist/quality/index.js.map +1 -0
  363. package/dist/shared/index.js +20 -0
  364. package/dist/shared/index.js.map +1 -0
  365. package/dist/shared/logger/Logger.js +3 -0
  366. package/dist/shared/logger/Logger.js.map +1 -0
  367. package/dist/shared/logger/LoggerFactory.js +75 -0
  368. package/dist/shared/logger/LoggerFactory.js.map +1 -0
  369. package/dist/shared/logger/index.js +19 -0
  370. package/dist/shared/logger/index.js.map +1 -0
  371. package/dist/shared/shutdown.js +30 -0
  372. package/dist/shared/shutdown.js.map +1 -0
  373. package/dist/shared/utils/agglomerativeCluster.js +269 -0
  374. package/dist/shared/utils/agglomerativeCluster.js.map +1 -0
  375. package/dist/shared/utils/astSymbols.js +69 -0
  376. package/dist/shared/utils/astSymbols.js.map +1 -0
  377. package/dist/shared/utils/cosineSimilarity.js +18 -0
  378. package/dist/shared/utils/cosineSimilarity.js.map +1 -0
  379. package/dist/shared/utils/directoryTree.js +184 -0
  380. package/dist/shared/utils/directoryTree.js.map +1 -0
  381. package/dist/shared/utils/documentOutline.js +74 -0
  382. package/dist/shared/utils/documentOutline.js.map +1 -0
  383. package/dist/shared/utils/index.js +24 -0
  384. package/dist/shared/utils/index.js.map +1 -0
  385. package/dist/shared/utils/jaroWinklerSimilarity.js +60 -0
  386. package/dist/shared/utils/jaroWinklerSimilarity.js.map +1 -0
  387. package/dist/shared/utils/parseJsonLenient.js +27 -0
  388. package/dist/shared/utils/parseJsonLenient.js.map +1 -0
  389. package/dist/shared/utils/readConfig.js +42 -0
  390. package/dist/shared/utils/readConfig.js.map +1 -0
  391. package/dist/shared/utils/readRtf.js +216 -0
  392. package/dist/shared/utils/readRtf.js.map +1 -0
  393. package/dist/shared/utils/softmax.js +26 -0
  394. package/dist/shared/utils/softmax.js.map +1 -0
  395. package/dist/types/ContentClass.js +3 -0
  396. package/dist/types/ContentClass.js.map +1 -0
  397. package/dist/types/CorpusProfile.js +3 -0
  398. package/dist/types/CorpusProfile.js.map +1 -0
  399. package/dist/types/IContradictionChecker.js +3 -0
  400. package/dist/types/IContradictionChecker.js.map +1 -0
  401. package/dist/types/ICorpusAnalyzer.js +3 -0
  402. package/dist/types/ICorpusAnalyzer.js.map +1 -0
  403. package/dist/types/IDirectoryProcessor.js +3 -0
  404. package/dist/types/IDirectoryProcessor.js.map +1 -0
  405. package/dist/types/IEmbeddingProvider.js +3 -0
  406. package/dist/types/IEmbeddingProvider.js.map +1 -0
  407. package/dist/types/IEmbeddingService.js +6 -0
  408. package/dist/types/IEmbeddingService.js.map +1 -0
  409. package/dist/types/IFileProcessor.js +3 -0
  410. package/dist/types/IFileProcessor.js.map +1 -0
  411. package/dist/types/IGroundingChecker.js +3 -0
  412. package/dist/types/IGroundingChecker.js.map +1 -0
  413. package/dist/types/IKnowledgeGraphBuilder.js +3 -0
  414. package/dist/types/IKnowledgeGraphBuilder.js.map +1 -0
  415. package/dist/types/IKnowledgeGraphExporter.js +3 -0
  416. package/dist/types/IKnowledgeGraphExporter.js.map +1 -0
  417. package/dist/types/IKnowledgeGraphMerger.js +3 -0
  418. package/dist/types/IKnowledgeGraphMerger.js.map +1 -0
  419. package/dist/types/IKnowledgeGraphSearch.js +3 -0
  420. package/dist/types/IKnowledgeGraphSearch.js.map +1 -0
  421. package/dist/types/ILLMProvider.js +3 -0
  422. package/dist/types/ILLMProvider.js.map +1 -0
  423. package/dist/types/ILLMService.js +3 -0
  424. package/dist/types/ILLMService.js.map +1 -0
  425. package/dist/types/IObjectDetector.js +3 -0
  426. package/dist/types/IObjectDetector.js.map +1 -0
  427. package/dist/types/IProcessingService.js +3 -0
  428. package/dist/types/IProcessingService.js.map +1 -0
  429. package/dist/types/IProgressEmitter.js +3 -0
  430. package/dist/types/IProgressEmitter.js.map +1 -0
  431. package/dist/types/IPromptManager.js +3 -0
  432. package/dist/types/IPromptManager.js.map +1 -0
  433. package/dist/types/KnowledgeGraph.js +3 -0
  434. package/dist/types/KnowledgeGraph.js.map +1 -0
  435. package/dist/types/MCPKnowledgeGraph.js +3 -0
  436. package/dist/types/MCPKnowledgeGraph.js.map +1 -0
  437. package/dist/types/Observation.js +21 -0
  438. package/dist/types/Observation.js.map +1 -0
  439. package/dist/types/ProcessingOptions.js +3 -0
  440. package/dist/types/ProcessingOptions.js.map +1 -0
  441. package/dist/types/index.js +40 -0
  442. package/dist/types/index.js.map +1 -0
  443. package/package.json +122 -0
@@ -0,0 +1,205 @@
1
+ ### Example 1: Email with cc + attachment
2
+
3
+ Input:
4
+
5
+ ## File information
6
+
7
+ Path: `mail/q4-budget.eml`
8
+
9
+ ## Content to analyze
10
+ ```
11
+ From: John Park <john@acme.com>
12
+ To: Sarah Lee <sarah@acme.com>
13
+ Cc: Mike Ross <mike@acme.com>
14
+ Subject: Q4 budget draft — Apollo
15
+ Date: 2022-11-03
16
+
17
+ Hi Sarah, attached is the Q4 budget draft for the Apollo project. I'll finalize the
18
+ headcount numbers by Friday — can you review the travel section before then?
19
+ Thanks, John
20
+
21
+ [attachment: q4-budget.xlsx]
22
+ ```
23
+
24
+ Output:
25
+
26
+ ```json
27
+ {
28
+ "entities": [
29
+ {
30
+ "name": "John Park",
31
+ "entityType": "person",
32
+ "observations": [
33
+ "Sent the Q4 budget draft email on 2022-11-03",
34
+ "Committed to finalize the headcount numbers by Friday"
35
+ ]
36
+ },
37
+ {
38
+ "name": "Sarah Lee",
39
+ "entityType": "person",
40
+ "observations": ["Asked to review the travel section before Friday"]
41
+ },
42
+ {
43
+ "name": "Mike Ross",
44
+ "entityType": "person",
45
+ "observations": ["Cc'd on the Q4 budget draft email"]
46
+ },
47
+ {
48
+ "name": "Q4 budget draft — Apollo",
49
+ "entityType": "thread",
50
+ "observations": ["Email about the Apollo project budget, dated 2022-11-03"]
51
+ },
52
+ {
53
+ "name": "Apollo project",
54
+ "entityType": "project",
55
+ "observations": ["Initiative the Q4 budget covers"]
56
+ },
57
+ {
58
+ "name": "q4-budget.xlsx",
59
+ "entityType": "attachment",
60
+ "observations": ["Spreadsheet holding the Q4 budget draft"]
61
+ }
62
+ ],
63
+ "relations": [
64
+ { "from": "John Park", "to": "Sarah Lee", "relationType": ["sends_to"] },
65
+ { "from": "John Park", "to": "Mike Ross", "relationType": ["cc"] },
66
+ { "from": "Q4 budget draft — Apollo", "to": "Apollo project", "relationType": ["references"] },
67
+ { "from": "q4-budget.xlsx", "to": "Q4 budget draft — Apollo", "relationType": ["part_of"] }
68
+ ]
69
+ }
70
+ ```
71
+
72
+ Note: the deadline ("by Friday") and the review request are observations on the
73
+ people, not nodes. `sends_to` is sender → recipient; `cc` is its own predicate, not
74
+ stacked onto `sends_to`. The attachment is `part_of` the thread that carried it.
75
+
76
+ ---
77
+
78
+ ### Example 2: Reply in the thread (with prior context — extend)
79
+
80
+ Input:
81
+
82
+ ## File information
83
+
84
+ Path: `mail/q4-budget.eml`
85
+ Chunk 2 of 3
86
+
87
+ ## Already extracted (do not re-emit)
88
+
89
+ - **John Park** (person): Sent the Q4 budget draft email on 2022-11-03
90
+ - **Sarah Lee** (person): Asked to review the travel section before Friday
91
+
92
+ ## Content to analyze
93
+ ```
94
+ From: Sarah Lee <sarah@acme.com>
95
+ To: John Park <john@acme.com>
96
+ Subject: Re: Q4 budget draft — Apollo
97
+ Date: 2022-11-04
98
+
99
+ Reviewed — travel looks fine. Looping in my manager, Dana, who owns the Apollo
100
+ budget sign-off.
101
+ ```
102
+
103
+ Output:
104
+
105
+ ```json
106
+ {
107
+ "entities": [
108
+ {
109
+ "name": "Sarah Lee",
110
+ "entityType": "person",
111
+ "observations": ["Reviewed the travel section and approved it (2022-11-04)"]
112
+ },
113
+ {
114
+ "name": "Dana",
115
+ "entityType": "person",
116
+ "observations": ["Sarah Lee's manager; owns the Apollo budget sign-off"]
117
+ }
118
+ ],
119
+ "relations": [
120
+ { "from": "Sarah Lee", "to": "John Park", "relationType": ["replies_to"] },
121
+ { "from": "Sarah Lee", "to": "Dana", "relationType": ["reports_to"] }
122
+ ]
123
+ }
124
+ ```
125
+
126
+ Note: the reply is `replies_to`, not another `sends_to`; `reports_to` captures the
127
+ org hierarchy. `Sarah Lee` is re-emitted under her exact name carrying a *new*
128
+ observation (the approval), which extends the existing node on merge.
129
+
130
+ ---
131
+
132
+ ### Example 3: Group chat (hand-off + scheduling)
133
+
134
+ Input:
135
+
136
+ ## File information
137
+
138
+ Path: `chat/apollo-standup.txt`
139
+
140
+ ## Content to analyze
141
+ ```
142
+ [09:02] Mike Ross: I'll forward the vendor quote to Sarah for the budget.
143
+ [09:03] Sarah Lee: thanks. Let's set up a sync Thursday to close the numbers.
144
+ [09:03] John Park: works for me, I'll book the room.
145
+ ```
146
+
147
+ Output:
148
+
149
+ ```json
150
+ {
151
+ "entities": [
152
+ {
153
+ "name": "Mike Ross",
154
+ "entityType": "person",
155
+ "observations": ["Forwarded the vendor quote to Sarah for the Apollo budget"]
156
+ },
157
+ {
158
+ "name": "Sarah Lee",
159
+ "entityType": "person",
160
+ "observations": ["Proposed a Thursday sync to finalize the numbers"]
161
+ },
162
+ {
163
+ "name": "John Park",
164
+ "entityType": "person",
165
+ "observations": ["Agreed to book a room for the Thursday sync"]
166
+ }
167
+ ],
168
+ "relations": [
169
+ { "from": "Mike Ross", "to": "Sarah Lee", "relationType": ["forwards_to"] },
170
+ { "from": "Sarah Lee", "to": "John Park", "relationType": ["schedules_with"] },
171
+ { "from": "John Park", "to": "Mike Ross", "relationType": ["collaborates_with"] }
172
+ ]
173
+ }
174
+ ```
175
+
176
+ Note: each predicate names the one real interaction — `forwards_to` for the hand-off,
177
+ `schedules_with` for the proposed sync, `collaborates_with` for joint work. No
178
+ `["sends_to", "forwards_to"]` synonym stacking; the timestamps stay out of the graph.
179
+
180
+ ---
181
+
182
+ ### Example 4: Encrypted body → empty graph
183
+
184
+ Input:
185
+
186
+ ## File information
187
+
188
+ Path: `mail/secure-thread.eml`
189
+ Chunk 2 of 2
190
+
191
+ ## Content to analyze
192
+ ```
193
+ -----BEGIN PGP MESSAGE-----
194
+ hQEMA4l3xK2vQp9rAQf/Wd7yK0c1nT8mLpQ2... (encrypted body) ...=Xy7Q
195
+ -----END PGP MESSAGE-----
196
+ ```
197
+
198
+ Output:
199
+
200
+ ```json
201
+ { "entities": [], "relations": [] }
202
+ ```
203
+
204
+ Note: an encrypted or otherwise undecodable body carries no extractable facts —
205
+ empty graph, not a node minted from the armor headers.
@@ -0,0 +1,262 @@
1
+ ### Example 1: README install + usage
2
+
3
+ Input:
4
+
5
+ ## File information
6
+
7
+ Path: `README.md`
8
+
9
+ ## Content to analyze
10
+ ```
11
+ # Wanshi
12
+ Wanshi turns files into knowledge graphs. Requires Node.js 18+.
13
+
14
+ ## Install
15
+ npm install -g wanshi
16
+
17
+ ## Usage
18
+ Run `wanshi --config config.yaml`. Set `output` to choose the destination file.
19
+ ```
20
+
21
+ Output:
22
+
23
+ ```json
24
+ {
25
+ "entities": [
26
+ {
27
+ "name": "Wanshi README",
28
+ "entityType": "guide",
29
+ "observations": ["Install and usage documentation for the Wanshi CLI"]
30
+ },
31
+ {
32
+ "name": "Wanshi",
33
+ "entityType": "product",
34
+ "observations": ["CLI that turns files into knowledge graphs"]
35
+ },
36
+ {
37
+ "name": "Node.js 18+",
38
+ "entityType": "requirement",
39
+ "observations": ["Minimum runtime needed to install Wanshi"]
40
+ },
41
+ {
42
+ "name": "install wanshi",
43
+ "entityType": "procedure",
44
+ "observations": ["Run `npm install -g wanshi`"]
45
+ },
46
+ {
47
+ "name": "output",
48
+ "entityType": "configuration_option",
49
+ "observations": ["Sets the destination file for the generated graph; configured in config.yaml"]
50
+ }
51
+ ],
52
+ "relations": [
53
+ { "from": "Wanshi README", "to": "Wanshi", "relationType": ["documents"] },
54
+ { "from": "Wanshi README", "to": "install wanshi","relationType": ["guides_through"] },
55
+ { "from": "install wanshi", "to": "Node.js 18+", "relationType": ["requires"] },
56
+ { "from": "output", "to": "Wanshi", "relationType": ["configures"] }
57
+ ]
58
+ }
59
+ ```
60
+
61
+ Note: the named option `output` is a `configuration_option` node, but its concrete
62
+ value lives in the observation — a raw value like `graph.jsonl` would not be its own
63
+ node. The install command is the procedure's observation, not a separate entity.
64
+
65
+ ---
66
+
67
+ ### Example 2: API reference (method + parameters)
68
+
69
+ Input:
70
+
71
+ ## File information
72
+
73
+ Path: `docs/api.md`
74
+
75
+ ## Content to analyze
76
+ ```
77
+ ### `createGraph(files, options)`
78
+ Builds a knowledge graph from the given files.
79
+ - `files` (string[]) — paths to ingest. Required.
80
+ - `options.format` — output format, one of json|jsonl. Defaults to json.
81
+ Returns a `KnowledgeGraph`.
82
+ ```
83
+
84
+ Output:
85
+
86
+ ```json
87
+ {
88
+ "entities": [
89
+ {
90
+ "name": "createGraph",
91
+ "entityType": "api_method",
92
+ "observations": [
93
+ "Builds a knowledge graph from the given files",
94
+ "Returns a KnowledgeGraph"
95
+ ]
96
+ },
97
+ {
98
+ "name": "files",
99
+ "entityType": "parameter",
100
+ "observations": ["string[] of paths to ingest; required"]
101
+ },
102
+ {
103
+ "name": "options.format",
104
+ "entityType": "parameter",
105
+ "observations": ["Output format, one of json|jsonl; defaults to json"]
106
+ }
107
+ ],
108
+ "relations": [
109
+ { "from": "files", "to": "createGraph", "relationType": ["part_of"] },
110
+ { "from": "options.format", "to": "createGraph", "relationType": ["part_of"] }
111
+ ]
112
+ }
113
+ ```
114
+
115
+ Note: `Required` and the default value are observations on the parameter, not nodes.
116
+ Parameters are `part_of` their method; the return type stays an observation rather
117
+ than becoming a dangling `KnowledgeGraph` node with no facts of its own here.
118
+
119
+ ---
120
+
121
+ ### Example 3: Tutorial with ordered steps
122
+
123
+ Input:
124
+
125
+ ## File information
126
+
127
+ Path: `docs/tutorial.md`
128
+
129
+ ## Content to analyze
130
+ ```
131
+ ## Your first graph
132
+ 1. Create a `config.yaml` pointing `input` at your project.
133
+ 2. Run `wanshi --config config.yaml`.
134
+ 3. Open the generated `graph.jsonl`.
135
+
136
+ Example: the snippet below ingests a TypeScript repo and writes JSONL.
137
+ ```
138
+
139
+ Output:
140
+
141
+ ```json
142
+ {
143
+ "entities": [
144
+ {
145
+ "name": "first graph tutorial",
146
+ "entityType": "guide",
147
+ "observations": ["Walks a new user through producing their first knowledge graph"]
148
+ },
149
+ {
150
+ "name": "create config.yaml",
151
+ "entityType": "tutorial_step",
152
+ "observations": ["Point `input` at the project to ingest"]
153
+ },
154
+ {
155
+ "name": "run wanshi",
156
+ "entityType": "tutorial_step",
157
+ "observations": ["Run `wanshi --config config.yaml`"]
158
+ },
159
+ {
160
+ "name": "open the output graph",
161
+ "entityType": "tutorial_step",
162
+ "observations": ["Inspect the generated `graph.jsonl`"]
163
+ },
164
+ {
165
+ "name": "TypeScript repo walkthrough",
166
+ "entityType": "example",
167
+ "observations": ["Ingests a TypeScript repo and writes JSONL"]
168
+ }
169
+ ],
170
+ "relations": [
171
+ { "from": "first graph tutorial", "to": "create config.yaml", "relationType": ["guides_through"] },
172
+ { "from": "first graph tutorial", "to": "run wanshi", "relationType": ["guides_through"] },
173
+ { "from": "first graph tutorial", "to": "open the output graph", "relationType": ["guides_through"] },
174
+ { "from": "first graph tutorial", "to": "TypeScript repo walkthrough", "relationType": ["demonstrates"] },
175
+ { "from": "create config.yaml", "to": "run wanshi", "relationType": ["precedes"] },
176
+ { "from": "run wanshi", "to": "open the output graph", "relationType": ["precedes"] }
177
+ ]
178
+ }
179
+ ```
180
+
181
+ Note: `guides_through` links the tutorial to each step; `precedes` records step order
182
+ without restating it as a synonym; `demonstrates` links the tutorial to the worked
183
+ example. Direction stays consistent (guide → step, earlier step → later step).
184
+
185
+ ---
186
+
187
+ ### Example 4: Feature explanation
188
+
189
+ Input:
190
+
191
+ ## File information
192
+
193
+ Path: `docs/features.md`
194
+
195
+ ## Content to analyze
196
+ ```
197
+ ## Resume
198
+ The `--resume` flag checkpoints every chunk so an interrupted run can continue
199
+ without re-billing. It requires a writable output directory.
200
+ ```
201
+
202
+ Output:
203
+
204
+ ```json
205
+ {
206
+ "entities": [
207
+ {
208
+ "name": "Resume documentation",
209
+ "entityType": "guide",
210
+ "observations": ["Explains how the resume feature works"]
211
+ },
212
+ {
213
+ "name": "Resume",
214
+ "entityType": "feature",
215
+ "observations": [
216
+ "Checkpoints every chunk so an interrupted run can continue without re-billing",
217
+ "Enabled with the `--resume` flag"
218
+ ]
219
+ },
220
+ {
221
+ "name": "writable output directory",
222
+ "entityType": "requirement",
223
+ "observations": ["Needed so resume can persist checkpoints"]
224
+ }
225
+ ],
226
+ "relations": [
227
+ { "from": "Resume documentation", "to": "Resume", "relationType": ["explains"] },
228
+ { "from": "Resume", "to": "writable output directory", "relationType": ["requires"] }
229
+ ]
230
+ }
231
+ ```
232
+
233
+ Note: `explains` links the doc section to the feature it describes; `requires`
234
+ captures the precondition. The `--resume` flag is an observation on the feature, not
235
+ a separate node.
236
+
237
+ ---
238
+
239
+ ### Example 5: Badges / scaffolding → empty graph
240
+
241
+ Input:
242
+
243
+ ## File information
244
+
245
+ Path: `README.md`
246
+ Chunk 1 of 4
247
+
248
+ ## Content to analyze
249
+ ```
250
+ ![build](https://img.shields.io/badge/build-passing-green)
251
+ ![npm](https://img.shields.io/npm/v/wanshi)
252
+ <!-- TOC generated, do not edit -->
253
+ ```
254
+
255
+ Output:
256
+
257
+ ```json
258
+ { "entities": [], "relations": [] }
259
+ ```
260
+
261
+ Note: status badges and generated table-of-contents markup carry no durable facts —
262
+ empty graph, not a node scraped from a shields.io URL.
@@ -0,0 +1,157 @@
1
+ ### Example 1: Service contract
2
+
3
+ Input:
4
+
5
+ ## File information
6
+
7
+ Path: `contracts/abc-xyz-services.pdf`
8
+
9
+ ## Content to analyze
10
+ ```
11
+ This contract is made between ABC Corporation ("the Company") and XYZ Inc.
12
+ ("the Contractor") on January 10, 2022. The Company agrees to pay the Contractor
13
+ a total amount of $100,000 for the services rendered.
14
+ ```
15
+
16
+ Output:
17
+
18
+ ```json
19
+ {
20
+ "entities": [
21
+ {
22
+ "name": "ABC Corporation",
23
+ "entityType": "organization",
24
+ "observations": ["Client in the services contract", "Pays $100,000 for services rendered"]
25
+ },
26
+ {
27
+ "name": "XYZ Inc.",
28
+ "entityType": "organization",
29
+ "observations": ["Contractor in the services contract", "Receives $100,000 for services rendered"]
30
+ }
31
+ ],
32
+ "relations": [
33
+ { "from": "ABC Corporation", "to": "XYZ Inc.", "relationType": ["pays"] }
34
+ ]
35
+ }
36
+ ```
37
+
38
+ Note: `$100,000` is a value, not an entity. It lives in the observations of the
39
+ parties it concerns. The two companies are the real nodes; the payment is the edge.
40
+
41
+ ---
42
+
43
+ ### Example 2: Invoice
44
+
45
+ Input:
46
+
47
+ ## File information
48
+
49
+ Path: `invoices/inv-1234.pdf`
50
+
51
+ ## Content to analyze
52
+ ```
53
+ Invoice #1234
54
+ Date: January 20, 2022
55
+ Bill To: ABC Corporation
56
+ Amount: $2,000
57
+ ```
58
+
59
+ Output:
60
+
61
+ ```json
62
+ {
63
+ "entities": [
64
+ {
65
+ "name": "Invoice #1234",
66
+ "entityType": "document",
67
+ "observations": ["Issued 2022-01-20", "Billed amount $2,000"]
68
+ },
69
+ {
70
+ "name": "ABC Corporation",
71
+ "entityType": "organization",
72
+ "observations": ["Billed party on Invoice #1234"]
73
+ }
74
+ ],
75
+ "relations": [
76
+ { "from": "Invoice #1234", "to": "ABC Corporation", "relationType": ["targets"] }
77
+ ]
78
+ }
79
+ ```
80
+
81
+ ---
82
+
83
+ ### Example 3: Loan agreement
84
+
85
+ Input:
86
+
87
+ ## File information
88
+
89
+ Path: `loans/abc-term-loan.docx`
90
+
91
+ ## Content to analyze
92
+ ```
93
+ Loan Agreement between ABC Corporation (Borrower) and XYZ Bank (Lender) with a
94
+ loan amount of $500,000 and an interest rate of 5%.
95
+ ```
96
+
97
+ Output:
98
+
99
+ ```json
100
+ {
101
+ "entities": [
102
+ {
103
+ "name": "ABC Corporation",
104
+ "entityType": "organization",
105
+ "observations": ["Borrower under the loan agreement", "Principal $500,000 at 5% interest"]
106
+ },
107
+ {
108
+ "name": "XYZ Bank",
109
+ "entityType": "organization",
110
+ "observations": ["Lender under the loan agreement"]
111
+ }
112
+ ],
113
+ "relations": [
114
+ { "from": "ABC Corporation", "to": "XYZ Bank", "relationType": ["owes"] }
115
+ ]
116
+ }
117
+ ```
118
+
119
+ ---
120
+
121
+ ### Example 4: Financial statement
122
+
123
+ Input:
124
+
125
+ ## File information
126
+
127
+ Path: `reports/fy2022-revenue.docx`
128
+
129
+ ## Content to analyze
130
+ ```
131
+ The company's total revenue for the year 2022 is $1,000,000, comprised of
132
+ sales ($800,000) and interest income ($200,000).
133
+ ```
134
+
135
+ Output:
136
+
137
+ ```json
138
+ {
139
+ "entities": [
140
+ {
141
+ "name": "FY2022 revenue",
142
+ "entityType": "metric",
143
+ "observations": [
144
+ "Total revenue of $1,000,000 for fiscal year 2022",
145
+ "Composed of $800,000 sales and $200,000 interest income"
146
+ ]
147
+ }
148
+ ],
149
+ "relations": []
150
+ }
151
+ ```
152
+
153
+ Note: a single reported figure with its breakdown is one `metric` entity, not four
154
+ dollar-amount nodes wired together. Splitting `$1,000,000`, `$800,000`, and
155
+ `$200,000` into separate entities produces meaningless value-nodes and a fan of
156
+ edges that say nothing. When there is only one real entity, an empty `relations`
157
+ array is correct.