@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.
- package/LICENSE +21 -0
- package/README.md +458 -0
- package/dist/__tests__/helpers.js +27 -0
- package/dist/__tests__/helpers.js.map +1 -0
- package/dist/cli/commands/export.command.js +99 -0
- package/dist/cli/commands/export.command.js.map +1 -0
- package/dist/cli/commands/index.js +22 -0
- package/dist/cli/commands/index.js.map +1 -0
- package/dist/cli/commands/inspectMerges.command.js +84 -0
- package/dist/cli/commands/inspectMerges.command.js.map +1 -0
- package/dist/cli/commands/metrics.command.js +196 -0
- package/dist/cli/commands/metrics.command.js.map +1 -0
- package/dist/cli/commands/process.command.js +82 -0
- package/dist/cli/commands/process.command.js.map +1 -0
- package/dist/cli/commands/watch.command.js +91 -0
- package/dist/cli/commands/watch.command.js.map +1 -0
- package/dist/cli/index.js +269 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/optionsToConfig.js +160 -0
- package/dist/cli/optionsToConfig.js.map +1 -0
- package/dist/config/index.js +59 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/legacyHints.js +113 -0
- package/dist/config/legacyHints.js.map +1 -0
- package/dist/config/schema.js +803 -0
- package/dist/config/schema.js.map +1 -0
- package/dist/config/ui.js +221 -0
- package/dist/config/ui.js.map +1 -0
- package/dist/core/DirectoryProcessor.js +725 -0
- package/dist/core/DirectoryProcessor.js.map +1 -0
- package/dist/core/adapters/IStructuredAdapter.js +3 -0
- package/dist/core/adapters/IStructuredAdapter.js.map +1 -0
- package/dist/core/adapters/SqliteAdapter.js +267 -0
- package/dist/core/adapters/SqliteAdapter.js.map +1 -0
- package/dist/core/adapters/StructuredAdapterRegistry.js +31 -0
- package/dist/core/adapters/StructuredAdapterRegistry.js.map +1 -0
- package/dist/core/adapters/index.js +20 -0
- package/dist/core/adapters/index.js.map +1 -0
- package/dist/core/checkpoint/CheckpointService.js +188 -0
- package/dist/core/checkpoint/CheckpointService.js.map +1 -0
- package/dist/core/checkpoint/index.js +18 -0
- package/dist/core/checkpoint/index.js.map +1 -0
- package/dist/core/corpus/CorpusAnalyzer.js +266 -0
- package/dist/core/corpus/CorpusAnalyzer.js.map +1 -0
- package/dist/core/corpus/CorpusProfileStore.js +92 -0
- package/dist/core/corpus/CorpusProfileStore.js.map +1 -0
- package/dist/core/corpus/index.js +21 -0
- package/dist/core/corpus/index.js.map +1 -0
- package/dist/core/corpus/normalizeGlossary.js +60 -0
- package/dist/core/corpus/normalizeGlossary.js.map +1 -0
- package/dist/core/corpus/relPath.js +52 -0
- package/dist/core/corpus/relPath.js.map +1 -0
- package/dist/core/corpus/termFrequency.js +86 -0
- package/dist/core/corpus/termFrequency.js.map +1 -0
- package/dist/core/cost/CostMeter.js +235 -0
- package/dist/core/cost/CostMeter.js.map +1 -0
- package/dist/core/cost/index.js +19 -0
- package/dist/core/cost/index.js.map +1 -0
- package/dist/core/cost/prices.js +38 -0
- package/dist/core/cost/prices.js.map +1 -0
- package/dist/core/cv/ObjectDetectionService.js +119 -0
- package/dist/core/cv/ObjectDetectionService.js.map +1 -0
- package/dist/core/di/ContainerFactory.js +670 -0
- package/dist/core/di/ContainerFactory.js.map +1 -0
- package/dist/core/di/DIContainer.js +103 -0
- package/dist/core/di/DIContainer.js.map +1 -0
- package/dist/core/di/index.js +19 -0
- package/dist/core/di/index.js.map +1 -0
- package/dist/core/errors/CustomErrors.js +342 -0
- package/dist/core/errors/CustomErrors.js.map +1 -0
- package/dist/core/errors/index.js +18 -0
- package/dist/core/errors/index.js.map +1 -0
- package/dist/core/export/KnowledgeGraphExportService.js +56 -0
- package/dist/core/export/KnowledgeGraphExportService.js.map +1 -0
- package/dist/core/export/index.js +19 -0
- package/dist/core/export/index.js.map +1 -0
- package/dist/core/export/strategies/GraphitiExportStrategy.js +115 -0
- package/dist/core/export/strategies/GraphitiExportStrategy.js.map +1 -0
- package/dist/core/export/strategies/GraphvizDotExportStrategy.js +331 -0
- package/dist/core/export/strategies/GraphvizDotExportStrategy.js.map +1 -0
- package/dist/core/export/strategies/IExportStrategy.js +3 -0
- package/dist/core/export/strategies/IExportStrategy.js.map +1 -0
- package/dist/core/export/strategies/JsonExportStrategy.js +19 -0
- package/dist/core/export/strategies/JsonExportStrategy.js.map +1 -0
- package/dist/core/export/strategies/JsonlExportStrategy.js +69 -0
- package/dist/core/export/strategies/JsonlExportStrategy.js.map +1 -0
- package/dist/core/export/strategies/KblamExportStrategy.js +36 -0
- package/dist/core/export/strategies/KblamExportStrategy.js.map +1 -0
- package/dist/core/export/strategies/LoraExportStrategy.js +46 -0
- package/dist/core/export/strategies/LoraExportStrategy.js.map +1 -0
- package/dist/core/export/strategies/McpExportStrategy.js +67 -0
- package/dist/core/export/strategies/McpExportStrategy.js.map +1 -0
- package/dist/core/export/strategies/index.js +25 -0
- package/dist/core/export/strategies/index.js.map +1 -0
- package/dist/core/export/strategies/kbTriples.js +60 -0
- package/dist/core/export/strategies/kbTriples.js.map +1 -0
- package/dist/core/index.js +22 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/knowledge/KnowledgeGraphBuilder.js +627 -0
- package/dist/core/knowledge/KnowledgeGraphBuilder.js.map +1 -0
- package/dist/core/knowledge/MergeRecord.js +3 -0
- package/dist/core/knowledge/MergeRecord.js.map +1 -0
- package/dist/core/knowledge/canon/Canonicalizer.js +414 -0
- package/dist/core/knowledge/canon/Canonicalizer.js.map +1 -0
- package/dist/core/knowledge/canon/index.js +18 -0
- package/dist/core/knowledge/canon/index.js.map +1 -0
- package/dist/core/knowledge/contradiction/HeuristicContradictionChecker.js +92 -0
- package/dist/core/knowledge/contradiction/HeuristicContradictionChecker.js.map +1 -0
- package/dist/core/knowledge/contradiction/LlmContradictionChecker.js +52 -0
- package/dist/core/knowledge/contradiction/LlmContradictionChecker.js.map +1 -0
- package/dist/core/knowledge/contradiction/index.js +19 -0
- package/dist/core/knowledge/contradiction/index.js.map +1 -0
- package/dist/core/knowledge/grounding/KeywordGroundingChecker.js +33 -0
- package/dist/core/knowledge/grounding/KeywordGroundingChecker.js.map +1 -0
- package/dist/core/knowledge/grounding/MiniCheckGroundingChecker.js +82 -0
- package/dist/core/knowledge/grounding/MiniCheckGroundingChecker.js.map +1 -0
- package/dist/core/knowledge/grounding/index.js +20 -0
- package/dist/core/knowledge/grounding/index.js.map +1 -0
- package/dist/core/knowledge/grounding/verbalize.js +38 -0
- package/dist/core/knowledge/grounding/verbalize.js.map +1 -0
- package/dist/core/knowledge/images/imageMetaGraph.js +136 -0
- package/dist/core/knowledge/images/imageMetaGraph.js.map +1 -0
- package/dist/core/knowledge/index.js +20 -0
- package/dist/core/knowledge/index.js.map +1 -0
- package/dist/core/knowledge/merging/KnowledgeMerger.js +624 -0
- package/dist/core/knowledge/merging/KnowledgeMerger.js.map +1 -0
- package/dist/core/knowledge/references/ReferenceResolver.js +184 -0
- package/dist/core/knowledge/references/ReferenceResolver.js.map +1 -0
- package/dist/core/knowledge/references/citations/CitationEvidenceProcessor.js +401 -0
- package/dist/core/knowledge/references/citations/CitationEvidenceProcessor.js.map +1 -0
- package/dist/core/knowledge/references/citations/CitationResolver.js +95 -0
- package/dist/core/knowledge/references/citations/CitationResolver.js.map +1 -0
- package/dist/core/knowledge/references/citations/GrobidClient.js +143 -0
- package/dist/core/knowledge/references/citations/GrobidClient.js.map +1 -0
- package/dist/core/knowledge/references/citations/TitleIdResolver.js +101 -0
- package/dist/core/knowledge/references/citations/TitleIdResolver.js.map +1 -0
- package/dist/core/knowledge/references/web/FetchCacheService.js +114 -0
- package/dist/core/knowledge/references/web/FetchCacheService.js.map +1 -0
- package/dist/core/knowledge/references/web/GatedFetcher.js +228 -0
- package/dist/core/knowledge/references/web/GatedFetcher.js.map +1 -0
- package/dist/core/knowledge/references/web/WebReferenceProcessor.js +164 -0
- package/dist/core/knowledge/references/web/WebReferenceProcessor.js.map +1 -0
- package/dist/core/knowledge/search/KnowledgeGraphSearch.js +261 -0
- package/dist/core/knowledge/search/KnowledgeGraphSearch.js.map +1 -0
- package/dist/core/knowledge/vocabulary.js +162 -0
- package/dist/core/knowledge/vocabulary.js.map +1 -0
- package/dist/core/llm/EmbeddingService.js +113 -0
- package/dist/core/llm/EmbeddingService.js.map +1 -0
- package/dist/core/llm/OllamaService.js +146 -0
- package/dist/core/llm/OllamaService.js.map +1 -0
- package/dist/core/llm/OpenAICompatibleService.js +190 -0
- package/dist/core/llm/OpenAICompatibleService.js.map +1 -0
- package/dist/core/llm/OpenAIEmbeddingService.js +129 -0
- package/dist/core/llm/OpenAIEmbeddingService.js.map +1 -0
- package/dist/core/llm/embeddingUtils.js +25 -0
- package/dist/core/llm/embeddingUtils.js.map +1 -0
- package/dist/core/llm/index.js +23 -0
- package/dist/core/llm/index.js.map +1 -0
- package/dist/core/llm/prompts/PromptManager.js +388 -0
- package/dist/core/llm/prompts/PromptManager.js.map +1 -0
- package/dist/core/llm/prompts/PromptTemplateEngine.js +257 -0
- package/dist/core/llm/prompts/PromptTemplateEngine.js.map +1 -0
- package/dist/core/llm/prompts/templates/partials/examples/EXAMPLE_STYLE_GUIDE.md +84 -0
- package/dist/core/llm/prompts/templates/partials/examples/article.md +187 -0
- package/dist/core/llm/prompts/templates/partials/examples/code.md +229 -0
- package/dist/core/llm/prompts/templates/partials/examples/communication.md +205 -0
- package/dist/core/llm/prompts/templates/partials/examples/documentation.md +262 -0
- package/dist/core/llm/prompts/templates/partials/examples/financial.md +157 -0
- package/dist/core/llm/prompts/templates/partials/examples/legal.md +153 -0
- package/dist/core/llm/prompts/templates/partials/examples/logs.md +127 -0
- package/dist/core/llm/prompts/templates/partials/examples/medical.md +218 -0
- package/dist/core/llm/prompts/templates/partials/examples/notes.md +201 -0
- package/dist/core/llm/prompts/templates/partials/examples/research.md +208 -0
- package/dist/core/llm/prompts/templates/partials/examples/tabular.md +178 -0
- package/dist/core/llm/prompts/templates/partials/examples/transcript.md +204 -0
- package/dist/core/llm/prompts/templates/partials/retrieved-context.hbs +18 -0
- package/dist/core/llm/prompts/templates/v1/system.hbs +371 -0
- package/dist/core/llm/prompts/templates/v1/user.hbs +20 -0
- package/dist/core/llm/prompts/templates/v2/system.hbs +573 -0
- package/dist/core/llm/prompts/templates/v2/user.hbs +20 -0
- package/dist/core/llm/prompts/templates/v3/system.hbs +861 -0
- package/dist/core/llm/prompts/templates/v3/user.hbs +16 -0
- package/dist/core/llm/prompts/templates/v4/system.hbs +800 -0
- package/dist/core/llm/prompts/templates/v4/user.hbs +40 -0
- package/dist/core/llm/prompts/templates/v4.5/system.hbs +71 -0
- package/dist/core/llm/prompts/templates/v4.5/user.hbs +46 -0
- package/dist/core/llm/prompts/templates/v5/glossary/system.hbs +40 -0
- package/dist/core/llm/prompts/templates/v5/glossary/user.hbs +11 -0
- package/dist/core/llm/prompts/templates/v5/system.hbs +163 -0
- package/dist/core/llm/prompts/templates/v5/user.hbs +55 -0
- package/dist/core/pipeline/GroundingTransform.js +52 -0
- package/dist/core/pipeline/GroundingTransform.js.map +1 -0
- package/dist/core/pipeline/PipelineRunner.js +51 -0
- package/dist/core/pipeline/PipelineRunner.js.map +1 -0
- package/dist/core/pipeline/RelationFilterTransform.js +72 -0
- package/dist/core/pipeline/RelationFilterTransform.js.map +1 -0
- package/dist/core/pipeline/index.js +20 -0
- package/dist/core/pipeline/index.js.map +1 -0
- package/dist/core/processor/FileProcessor.js +184 -0
- package/dist/core/processor/FileProcessor.js.map +1 -0
- package/dist/core/processor/ProcessedRegistry.js +38 -0
- package/dist/core/processor/ProcessedRegistry.js.map +1 -0
- package/dist/core/processor/ast/AstSeedService.js +0 -0
- package/dist/core/processor/ast/AstSeedService.js.map +1 -0
- package/dist/core/processor/ast/AstSymbolStore.js +110 -0
- package/dist/core/processor/ast/AstSymbolStore.js.map +1 -0
- package/dist/core/processor/ast/index.js +19 -0
- package/dist/core/processor/ast/index.js.map +1 -0
- package/dist/core/processor/chunking/TextChunker.js +98 -0
- package/dist/core/processor/chunking/TextChunker.js.map +1 -0
- package/dist/core/processor/chunking/index.js +18 -0
- package/dist/core/processor/chunking/index.js.map +1 -0
- package/dist/core/processor/classifier/CONTENT_CLASSES.js +294 -0
- package/dist/core/processor/classifier/CONTENT_CLASSES.js.map +1 -0
- package/dist/core/processor/classifier/CascadeContentClassifier.js +107 -0
- package/dist/core/processor/classifier/CascadeContentClassifier.js.map +1 -0
- package/dist/core/processor/classifier/HeuristicContentClassifier.js +113 -0
- package/dist/core/processor/classifier/HeuristicContentClassifier.js.map +1 -0
- package/dist/core/processor/classifier/IContentTypeClassifier.js +3 -0
- package/dist/core/processor/classifier/IContentTypeClassifier.js.map +1 -0
- package/dist/core/processor/classifier/LlmContentClassifier.js +107 -0
- package/dist/core/processor/classifier/LlmContentClassifier.js.map +1 -0
- package/dist/core/processor/classifier/NER_DOMAIN_EXAMPLES.js +498 -0
- package/dist/core/processor/classifier/NER_DOMAIN_EXAMPLES.js.map +1 -0
- package/dist/core/processor/classifier/index.js +21 -0
- package/dist/core/processor/classifier/index.js.map +1 -0
- package/dist/core/processor/classifier/mergeClassifications.js +32 -0
- package/dist/core/processor/classifier/mergeClassifications.js.map +1 -0
- package/dist/core/processor/index.js +20 -0
- package/dist/core/processor/index.js.map +1 -0
- package/dist/core/processor/readers/AudioReader.js +462 -0
- package/dist/core/processor/readers/AudioReader.js.map +1 -0
- package/dist/core/processor/readers/BinaryReader.js +90 -0
- package/dist/core/processor/readers/BinaryReader.js.map +1 -0
- package/dist/core/processor/readers/ChandraPdfReader.js +187 -0
- package/dist/core/processor/readers/ChandraPdfReader.js.map +1 -0
- package/dist/core/processor/readers/ChatExportReader.js +365 -0
- package/dist/core/processor/readers/ChatExportReader.js.map +1 -0
- package/dist/core/processor/readers/DoclingReader.js +445 -0
- package/dist/core/processor/readers/DoclingReader.js.map +1 -0
- package/dist/core/processor/readers/EmailReader.js +259 -0
- package/dist/core/processor/readers/EmailReader.js.map +1 -0
- package/dist/core/processor/readers/EpubReader.js +175 -0
- package/dist/core/processor/readers/EpubReader.js.map +1 -0
- package/dist/core/processor/readers/FileReader.js +90 -0
- package/dist/core/processor/readers/FileReader.js.map +1 -0
- package/dist/core/processor/readers/FileReaderFactory.js +49 -0
- package/dist/core/processor/readers/FileReaderFactory.js.map +1 -0
- package/dist/core/processor/readers/HtmlReader.js +371 -0
- package/dist/core/processor/readers/HtmlReader.js.map +1 -0
- package/dist/core/processor/readers/ImageReader.js +162 -0
- package/dist/core/processor/readers/ImageReader.js.map +1 -0
- package/dist/core/processor/readers/JsonFileReader.js +232 -0
- package/dist/core/processor/readers/JsonFileReader.js.map +1 -0
- package/dist/core/processor/readers/JupyterReader.js +178 -0
- package/dist/core/processor/readers/JupyterReader.js.map +1 -0
- package/dist/core/processor/readers/LatexReader.js +176 -0
- package/dist/core/processor/readers/LatexReader.js.map +1 -0
- package/dist/core/processor/readers/MarkdownReader.js +289 -0
- package/dist/core/processor/readers/MarkdownReader.js.map +1 -0
- package/dist/core/processor/readers/MarkerPdfReader.js +193 -0
- package/dist/core/processor/readers/MarkerPdfReader.js.map +1 -0
- package/dist/core/processor/readers/MistralOcrReader.js +198 -0
- package/dist/core/processor/readers/MistralOcrReader.js.map +1 -0
- package/dist/core/processor/readers/OfficeReader.js +174 -0
- package/dist/core/processor/readers/OfficeReader.js.map +1 -0
- package/dist/core/processor/readers/PdfReader.js +116 -0
- package/dist/core/processor/readers/PdfReader.js.map +1 -0
- package/dist/core/processor/readers/RtfReader.js +107 -0
- package/dist/core/processor/readers/RtfReader.js.map +1 -0
- package/dist/core/processor/readers/SubtitleReader.js +145 -0
- package/dist/core/processor/readers/SubtitleReader.js.map +1 -0
- package/dist/core/processor/readers/TesseractPdfReader.js +183 -0
- package/dist/core/processor/readers/TesseractPdfReader.js.map +1 -0
- package/dist/core/processor/readers/TextReader.js +129 -0
- package/dist/core/processor/readers/TextReader.js.map +1 -0
- package/dist/core/processor/readers/TranscriptReader.js +234 -0
- package/dist/core/processor/readers/TranscriptReader.js.map +1 -0
- package/dist/core/processor/readers/image/imageMetadata.js +155 -0
- package/dist/core/processor/readers/image/imageMetadata.js.map +1 -0
- package/dist/core/processor/readers/index.js +41 -0
- package/dist/core/processor/readers/index.js.map +1 -0
- package/dist/core/processor/readers/referenceExtraction.js +198 -0
- package/dist/core/processor/readers/referenceExtraction.js.map +1 -0
- package/dist/core/processor/readers/stripReferences.js +59 -0
- package/dist/core/processor/readers/stripReferences.js.map +1 -0
- package/dist/core/processor/readers/transcript/turnPacking.js +81 -0
- package/dist/core/processor/readers/transcript/turnPacking.js.map +1 -0
- package/dist/core/progress/NdjsonProgressEmitter.js +30 -0
- package/dist/core/progress/NdjsonProgressEmitter.js.map +1 -0
- package/dist/core/progress/NoopProgressEmitter.js +15 -0
- package/dist/core/progress/NoopProgressEmitter.js.map +1 -0
- package/dist/core/progress/index.js +19 -0
- package/dist/core/progress/index.js.map +1 -0
- package/dist/core/trace/TraceWriter.js +100 -0
- package/dist/core/trace/TraceWriter.js.map +1 -0
- package/dist/core/trace/events.js +13 -0
- package/dist/core/trace/events.js.map +1 -0
- package/dist/core/trace/index.js +20 -0
- package/dist/core/trace/index.js.map +1 -0
- package/dist/core/trace/lineage.js +97 -0
- package/dist/core/trace/lineage.js.map +1 -0
- package/dist/evaluation/BenchmarkRunner.js +171 -0
- package/dist/evaluation/BenchmarkRunner.js.map +1 -0
- package/dist/evaluation/classifier/ClassifierAccuracy.js +185 -0
- package/dist/evaluation/classifier/ClassifierAccuracy.js.map +1 -0
- package/dist/evaluation/classifier/labeledSamples.js +379 -0
- package/dist/evaluation/classifier/labeledSamples.js.map +1 -0
- package/dist/evaluation/compare/goldCompare.js +126 -0
- package/dist/evaluation/compare/goldCompare.js.map +1 -0
- package/dist/evaluation/crossre/compareScoring.js +30 -0
- package/dist/evaluation/crossre/compareScoring.js.map +1 -0
- package/dist/evaluation/datasets/CrossREDataset.js +170 -0
- package/dist/evaluation/datasets/CrossREDataset.js.map +1 -0
- package/dist/evaluation/datasets/IDataset.js +3 -0
- package/dist/evaluation/datasets/IDataset.js.map +1 -0
- package/dist/evaluation/datasets/RebelDataset.js +117 -0
- package/dist/evaluation/datasets/RebelDataset.js.map +1 -0
- package/dist/evaluation/datasets/RedocredDataset.js +218 -0
- package/dist/evaluation/datasets/RedocredDataset.js.map +1 -0
- package/dist/evaluation/datasets/SemEval2010Dataset.js +150 -0
- package/dist/evaluation/datasets/SemEval2010Dataset.js.map +1 -0
- package/dist/evaluation/index.js +33 -0
- package/dist/evaluation/index.js.map +1 -0
- package/dist/evaluation/matching/ExactMatcher.js +75 -0
- package/dist/evaluation/matching/ExactMatcher.js.map +1 -0
- package/dist/evaluation/matching/SemanticMatcher.js +143 -0
- package/dist/evaluation/matching/SemanticMatcher.js.map +1 -0
- package/dist/evaluation/metrics/TripleMetrics.js +64 -0
- package/dist/evaluation/metrics/TripleMetrics.js.map +1 -0
- package/dist/evaluation/mine/MineCheckpoint.js +114 -0
- package/dist/evaluation/mine/MineCheckpoint.js.map +1 -0
- package/dist/evaluation/mine/MineDataset.js +208 -0
- package/dist/evaluation/mine/MineDataset.js.map +1 -0
- package/dist/evaluation/mine/MineReporter.js +98 -0
- package/dist/evaluation/mine/MineReporter.js.map +1 -0
- package/dist/evaluation/mine/MineRunner.js +148 -0
- package/dist/evaluation/mine/MineRunner.js.map +1 -0
- package/dist/evaluation/mine/MineScorer.js +127 -0
- package/dist/evaluation/mine/MineScorer.js.map +1 -0
- package/dist/evaluation/mine/types.js +12 -0
- package/dist/evaluation/mine/types.js.map +1 -0
- package/dist/evaluation/reporters/ConsoleReporter.js +55 -0
- package/dist/evaluation/reporters/ConsoleReporter.js.map +1 -0
- package/dist/evaluation/reporters/JsonReporter.js +50 -0
- package/dist/evaluation/reporters/JsonReporter.js.map +1 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -0
- package/dist/quality/CompositeScore.js +61 -0
- package/dist/quality/CompositeScore.js.map +1 -0
- package/dist/quality/ConsistencyMetrics.js +70 -0
- package/dist/quality/ConsistencyMetrics.js.map +1 -0
- package/dist/quality/FactualMetrics.js +76 -0
- package/dist/quality/FactualMetrics.js.map +1 -0
- package/dist/quality/GraphHealthMetrics.js +68 -0
- package/dist/quality/GraphHealthMetrics.js.map +1 -0
- package/dist/quality/SemanticMetrics.js +102 -0
- package/dist/quality/SemanticMetrics.js.map +1 -0
- package/dist/quality/StructuralMetrics.js +60 -0
- package/dist/quality/StructuralMetrics.js.map +1 -0
- package/dist/quality/index.js +23 -0
- package/dist/quality/index.js.map +1 -0
- package/dist/shared/index.js +20 -0
- package/dist/shared/index.js.map +1 -0
- package/dist/shared/logger/Logger.js +3 -0
- package/dist/shared/logger/Logger.js.map +1 -0
- package/dist/shared/logger/LoggerFactory.js +75 -0
- package/dist/shared/logger/LoggerFactory.js.map +1 -0
- package/dist/shared/logger/index.js +19 -0
- package/dist/shared/logger/index.js.map +1 -0
- package/dist/shared/shutdown.js +30 -0
- package/dist/shared/shutdown.js.map +1 -0
- package/dist/shared/utils/agglomerativeCluster.js +269 -0
- package/dist/shared/utils/agglomerativeCluster.js.map +1 -0
- package/dist/shared/utils/astSymbols.js +69 -0
- package/dist/shared/utils/astSymbols.js.map +1 -0
- package/dist/shared/utils/cosineSimilarity.js +18 -0
- package/dist/shared/utils/cosineSimilarity.js.map +1 -0
- package/dist/shared/utils/directoryTree.js +184 -0
- package/dist/shared/utils/directoryTree.js.map +1 -0
- package/dist/shared/utils/documentOutline.js +74 -0
- package/dist/shared/utils/documentOutline.js.map +1 -0
- package/dist/shared/utils/index.js +24 -0
- package/dist/shared/utils/index.js.map +1 -0
- package/dist/shared/utils/jaroWinklerSimilarity.js +60 -0
- package/dist/shared/utils/jaroWinklerSimilarity.js.map +1 -0
- package/dist/shared/utils/parseJsonLenient.js +27 -0
- package/dist/shared/utils/parseJsonLenient.js.map +1 -0
- package/dist/shared/utils/readConfig.js +42 -0
- package/dist/shared/utils/readConfig.js.map +1 -0
- package/dist/shared/utils/readRtf.js +216 -0
- package/dist/shared/utils/readRtf.js.map +1 -0
- package/dist/shared/utils/softmax.js +26 -0
- package/dist/shared/utils/softmax.js.map +1 -0
- package/dist/types/ContentClass.js +3 -0
- package/dist/types/ContentClass.js.map +1 -0
- package/dist/types/CorpusProfile.js +3 -0
- package/dist/types/CorpusProfile.js.map +1 -0
- package/dist/types/IContradictionChecker.js +3 -0
- package/dist/types/IContradictionChecker.js.map +1 -0
- package/dist/types/ICorpusAnalyzer.js +3 -0
- package/dist/types/ICorpusAnalyzer.js.map +1 -0
- package/dist/types/IDirectoryProcessor.js +3 -0
- package/dist/types/IDirectoryProcessor.js.map +1 -0
- package/dist/types/IEmbeddingProvider.js +3 -0
- package/dist/types/IEmbeddingProvider.js.map +1 -0
- package/dist/types/IEmbeddingService.js +6 -0
- package/dist/types/IEmbeddingService.js.map +1 -0
- package/dist/types/IFileProcessor.js +3 -0
- package/dist/types/IFileProcessor.js.map +1 -0
- package/dist/types/IGroundingChecker.js +3 -0
- package/dist/types/IGroundingChecker.js.map +1 -0
- package/dist/types/IKnowledgeGraphBuilder.js +3 -0
- package/dist/types/IKnowledgeGraphBuilder.js.map +1 -0
- package/dist/types/IKnowledgeGraphExporter.js +3 -0
- package/dist/types/IKnowledgeGraphExporter.js.map +1 -0
- package/dist/types/IKnowledgeGraphMerger.js +3 -0
- package/dist/types/IKnowledgeGraphMerger.js.map +1 -0
- package/dist/types/IKnowledgeGraphSearch.js +3 -0
- package/dist/types/IKnowledgeGraphSearch.js.map +1 -0
- package/dist/types/ILLMProvider.js +3 -0
- package/dist/types/ILLMProvider.js.map +1 -0
- package/dist/types/ILLMService.js +3 -0
- package/dist/types/ILLMService.js.map +1 -0
- package/dist/types/IObjectDetector.js +3 -0
- package/dist/types/IObjectDetector.js.map +1 -0
- package/dist/types/IProcessingService.js +3 -0
- package/dist/types/IProcessingService.js.map +1 -0
- package/dist/types/IProgressEmitter.js +3 -0
- package/dist/types/IProgressEmitter.js.map +1 -0
- package/dist/types/IPromptManager.js +3 -0
- package/dist/types/IPromptManager.js.map +1 -0
- package/dist/types/KnowledgeGraph.js +3 -0
- package/dist/types/KnowledgeGraph.js.map +1 -0
- package/dist/types/MCPKnowledgeGraph.js +3 -0
- package/dist/types/MCPKnowledgeGraph.js.map +1 -0
- package/dist/types/Observation.js +21 -0
- package/dist/types/Observation.js.map +1 -0
- package/dist/types/ProcessingOptions.js +3 -0
- package/dist/types/ProcessingOptions.js.map +1 -0
- package/dist/types/index.js +40 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +122 -0
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
+
exports.DirectoryTreeGenerator = void 0;
|
|
46
|
+
const fs = __importStar(require("fs"));
|
|
47
|
+
const path = __importStar(require("path"));
|
|
48
|
+
const minimatch_1 = require("minimatch");
|
|
49
|
+
/**
|
|
50
|
+
* Generate a directory tree structure with filtering support
|
|
51
|
+
*/
|
|
52
|
+
class DirectoryTreeGenerator {
|
|
53
|
+
/**
|
|
54
|
+
* Generate a tree structure for a directory
|
|
55
|
+
*/
|
|
56
|
+
static generateTree(dirPath_1) {
|
|
57
|
+
return __awaiter(this, arguments, void 0, function* (dirPath, options = {}, logger) {
|
|
58
|
+
const { filter = '**/*', maxDepth = 10, excludePatterns = [], includeHidden = false } = options;
|
|
59
|
+
return this.buildTree(dirPath, filter, excludePatterns, includeHidden, 0, maxDepth, logger);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Generate a text representation of the directory tree
|
|
64
|
+
*/
|
|
65
|
+
static generateTextTree(dirPath_1) {
|
|
66
|
+
return __awaiter(this, arguments, void 0, function* (dirPath, options = {}, logger) {
|
|
67
|
+
const tree = yield this.generateTree(dirPath, options, logger);
|
|
68
|
+
return this.treeToText(tree, '', true);
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Recursively build the tree structure
|
|
73
|
+
*/
|
|
74
|
+
static buildTree(dirPath, filter, excludePatterns, includeHidden, currentDepth, maxDepth, logger) {
|
|
75
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
76
|
+
if (currentDepth >= maxDepth) {
|
|
77
|
+
return [];
|
|
78
|
+
}
|
|
79
|
+
try {
|
|
80
|
+
const entries = yield fs.promises.readdir(dirPath, { withFileTypes: true });
|
|
81
|
+
const nodes = [];
|
|
82
|
+
for (const entry of entries) {
|
|
83
|
+
// Skip hidden files if not included
|
|
84
|
+
if (!includeHidden && entry.name.startsWith('.')) {
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
// Skip excluded patterns
|
|
88
|
+
const fullPath = path.join(dirPath, entry.name);
|
|
89
|
+
const relativePath = path.relative(process.cwd(), fullPath);
|
|
90
|
+
if (excludePatterns.some(pattern => (0, minimatch_1.minimatch)(relativePath, pattern))) {
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
if (entry.isDirectory()) {
|
|
94
|
+
// For directories, check if any child would match the filter
|
|
95
|
+
const children = yield this.buildTree(fullPath, filter, excludePatterns, includeHidden, currentDepth + 1, maxDepth, logger);
|
|
96
|
+
// Only include directory if it has matching children or matches filter itself
|
|
97
|
+
if (children.length > 0 || (0, minimatch_1.minimatch)(relativePath, filter)) {
|
|
98
|
+
nodes.push({
|
|
99
|
+
name: entry.name,
|
|
100
|
+
type: 'directory',
|
|
101
|
+
children
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
else if (entry.isFile()) {
|
|
106
|
+
// Check if file matches the filter
|
|
107
|
+
if ((0, minimatch_1.minimatch)(relativePath, filter) || (0, minimatch_1.minimatch)(entry.name, filter)) {
|
|
108
|
+
nodes.push({
|
|
109
|
+
name: entry.name,
|
|
110
|
+
type: 'file'
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
// Sort: directories first, then files, alphabetically
|
|
116
|
+
return nodes.sort((a, b) => {
|
|
117
|
+
if (a.type !== b.type) {
|
|
118
|
+
return a.type === 'directory' ? -1 : 1;
|
|
119
|
+
}
|
|
120
|
+
return a.name.localeCompare(b.name);
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
logger === null || logger === void 0 ? void 0 : logger.error(`Failed to read directory ${dirPath}: ${error}`);
|
|
125
|
+
return [];
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Convert tree structure to text representation
|
|
131
|
+
*/
|
|
132
|
+
static treeToText(nodes, prefix = '', isRoot = false) {
|
|
133
|
+
let result = '';
|
|
134
|
+
nodes.forEach((node, index) => {
|
|
135
|
+
const isLast = index === nodes.length - 1;
|
|
136
|
+
const connector = isLast ? '└── ' : '├── ';
|
|
137
|
+
const extension = isLast ? ' ' : '│ ';
|
|
138
|
+
if (!isRoot) {
|
|
139
|
+
result += prefix + connector + node.name + '\n';
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
result += node.name + '\n';
|
|
143
|
+
}
|
|
144
|
+
if (node.children && node.children.length > 0) {
|
|
145
|
+
const childPrefix = isRoot ? '' : prefix + extension;
|
|
146
|
+
result += this.treeToText(node.children, childPrefix, false);
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
return result;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Get a filtered list of files (flat, not tree)
|
|
153
|
+
*/
|
|
154
|
+
static getFilteredFiles(dirPath_1, filter_1) {
|
|
155
|
+
return __awaiter(this, arguments, void 0, function* (dirPath, filter, excludePatterns = []) {
|
|
156
|
+
const files = [];
|
|
157
|
+
function walk(dir) {
|
|
158
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
159
|
+
const entries = yield fs.promises.readdir(dir, { withFileTypes: true });
|
|
160
|
+
for (const entry of entries) {
|
|
161
|
+
const fullPath = path.join(dir, entry.name);
|
|
162
|
+
const relativePath = path.relative(dirPath, fullPath);
|
|
163
|
+
// Skip excluded patterns
|
|
164
|
+
if (excludePatterns.some(pattern => (0, minimatch_1.minimatch)(relativePath, pattern))) {
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
if (entry.isDirectory()) {
|
|
168
|
+
yield walk(fullPath);
|
|
169
|
+
}
|
|
170
|
+
else if (entry.isFile()) {
|
|
171
|
+
if ((0, minimatch_1.minimatch)(relativePath, filter) || (0, minimatch_1.minimatch)(entry.name, filter)) {
|
|
172
|
+
files.push(fullPath);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
yield walk(dirPath);
|
|
179
|
+
return files;
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
exports.DirectoryTreeGenerator = DirectoryTreeGenerator;
|
|
184
|
+
//# sourceMappingURL=directoryTree.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"directoryTree.js","sourceRoot":"","sources":["../../../src/shared/utils/directoryTree.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAC7B,yCAAsC;AAgBtC;;GAEG;AACH,MAAa,sBAAsB;IACjC;;OAEG;IACH,MAAM,CAAO,YAAY;6DACvB,OAAe,EACf,UAAgC,EAAE,EAClC,MAAc;YAEd,MAAM,EACJ,MAAM,GAAG,MAAM,EACf,QAAQ,GAAG,EAAE,EACb,eAAe,GAAG,EAAE,EACpB,aAAa,GAAG,KAAK,EACtB,GAAG,OAAO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}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
45
|
+
var t = {};
|
|
46
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
47
|
+
t[p] = s[p];
|
|
48
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
49
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
50
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
51
|
+
t[p[i]] = s[p[i]];
|
|
52
|
+
}
|
|
53
|
+
return t;
|
|
54
|
+
};
|
|
55
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
56
|
+
exports.DocumentOutlineGenerator = void 0;
|
|
57
|
+
const outlion_1 = __importStar(require("@wanshi-kg/outlion"));
|
|
58
|
+
class DocumentOutlineGenerator {
|
|
59
|
+
static generateOutlineFromContent(content, extension, options) {
|
|
60
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
+
const _a = options !== null && options !== void 0 ? options : {}, { compact } = _a, genOptions = __rest(_a, ["compact"]);
|
|
62
|
+
const generator = new outlion_1.default();
|
|
63
|
+
// The Safe variant returns [] for unknown extensions / parse failures instead
|
|
64
|
+
// of throwing — exactly what a heterogeneous corpus wants (no per-chunk
|
|
65
|
+
// "No generator found" warning, KG-17). Rendering goes through upstream's
|
|
66
|
+
// canonical ascii-tree formatter so wanshi no longer carries its own copy;
|
|
67
|
+
// `compact` drops line numbers + metadata for token-lean prompts.
|
|
68
|
+
const outline = yield generator.generateFromContentSafe(content, extension, genOptions);
|
|
69
|
+
return (0, outlion_1.formatOutline)(outline, "ascii-tree", { compact: compact === true });
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
exports.DocumentOutlineGenerator = DocumentOutlineGenerator;
|
|
74
|
+
//# sourceMappingURL=documentOutline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"documentOutline.js","sourceRoot":"","sources":["../../../src/shared/utils/documentOutline.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8DAA+E;AAe/E,MAAa,wBAAwB;IACnC,MAAM,CAAO,0BAA0B,CACrC,OAAe,EACf,SAAiB,EACjB,OAAiC;;YAEjC,MAAM,KAA6B,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,EAAE,EAA1C,EAAE,OAAO,OAAiC,EAA5B,UAAU,cAAxB,WAA0B,CAAgB,CAAC;YACjD,MAAM,SAAS,GAAG,IAAI,iBAAe,EAAE,CAAC;YACxC,8EAA8E;YAC9E,wEAAwE;YACxE,0EAA0E;YAC1E,2EAA2E;YAC3E,kEAAkE;YAClE,MAAM,OAAO,GAAG,MAAM,SAAS,CAAC,uBAAuB,CAAC,OAAO,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;YACxF,OAAO,IAAA,uBAAa,EAAC,OAAO,EAAE,YAAY,EAAE,EAAE,OAAO,EAAE,OAAO,KAAK,IAAI,EAAE,CAAC,CAAC;QAC7E,CAAC;KAAA;CACF;AAhBD,4DAgBC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./cosineSimilarity"), exports);
|
|
18
|
+
__exportStar(require("./softmax"), exports);
|
|
19
|
+
__exportStar(require("./agglomerativeCluster"), exports);
|
|
20
|
+
__exportStar(require("./jaroWinklerSimilarity"), exports);
|
|
21
|
+
__exportStar(require("./parseJsonLenient"), exports);
|
|
22
|
+
__exportStar(require("./readConfig"), exports);
|
|
23
|
+
__exportStar(require("./readRtf"), exports);
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/shared/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmC;AACnC,4CAA0B;AAC1B,yDAAuC;AACvC,0DAAwC;AACxC,qDAAmC;AACnC,+CAA6B;AAC7B,4CAA0B"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Calculate string similarity using Jaro-Winkler algorithm
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.jaroWinklerSimilarity = jaroWinklerSimilarity;
|
|
5
|
+
function jaroWinklerSimilarity(s1, s2) {
|
|
6
|
+
const s1Lower = s1.toLowerCase();
|
|
7
|
+
const s2Lower = s2.toLowerCase();
|
|
8
|
+
if (s1Lower === s2Lower)
|
|
9
|
+
return 1.0;
|
|
10
|
+
const len1 = s1Lower.length;
|
|
11
|
+
const len2 = s2Lower.length;
|
|
12
|
+
if (len1 === 0 || len2 === 0)
|
|
13
|
+
return 0.0;
|
|
14
|
+
const matchWindow = Math.floor(Math.max(len1, len2) / 2) - 1;
|
|
15
|
+
if (matchWindow < 0)
|
|
16
|
+
return 0.0;
|
|
17
|
+
const s1Matches = new Array(len1).fill(false);
|
|
18
|
+
const s2Matches = new Array(len2).fill(false);
|
|
19
|
+
let matches = 0;
|
|
20
|
+
let transpositions = 0;
|
|
21
|
+
// Find matches
|
|
22
|
+
for (let i = 0; i < len1; i++) {
|
|
23
|
+
const start = Math.max(0, i - matchWindow);
|
|
24
|
+
const end = Math.min(i + matchWindow + 1, len2);
|
|
25
|
+
for (let j = start; j < end; j++) {
|
|
26
|
+
if (s2Matches[j] || s1Lower[i] !== s2Lower[j])
|
|
27
|
+
continue;
|
|
28
|
+
s1Matches[i] = s2Matches[j] = true;
|
|
29
|
+
matches++;
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (matches === 0)
|
|
34
|
+
return 0.0;
|
|
35
|
+
// Find transpositions
|
|
36
|
+
let k = 0;
|
|
37
|
+
for (let i = 0; i < len1; i++) {
|
|
38
|
+
if (!s1Matches[i])
|
|
39
|
+
continue;
|
|
40
|
+
while (!s2Matches[k])
|
|
41
|
+
k++;
|
|
42
|
+
if (s1Lower[i] !== s2Lower[k])
|
|
43
|
+
transpositions++;
|
|
44
|
+
k++;
|
|
45
|
+
}
|
|
46
|
+
const jaro = (matches / len1 +
|
|
47
|
+
matches / len2 +
|
|
48
|
+
(matches - transpositions / 2) / matches) /
|
|
49
|
+
3;
|
|
50
|
+
// Winkler prefix bonus
|
|
51
|
+
let prefix = 0;
|
|
52
|
+
for (let i = 0; i < Math.min(len1, len2, 4); i++) {
|
|
53
|
+
if (s1Lower[i] === s2Lower[i])
|
|
54
|
+
prefix++;
|
|
55
|
+
else
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
return jaro + 0.1 * prefix * (1 - jaro);
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=jaroWinklerSimilarity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jaroWinklerSimilarity.js","sourceRoot":"","sources":["../../../src/shared/utils/jaroWinklerSimilarity.ts"],"names":[],"mappings":";AAAA,2DAA2D;;AAE3D,sDAyDC;AAzDD,SAAgB,qBAAqB,CAAC,EAAU,EAAE,EAAU;IAC1D,MAAM,OAAO,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC;IACjC,MAAM,OAAO,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC;IAEjC,IAAI,OAAO,KAAK,OAAO;QAAE,OAAO,GAAG,CAAC;IAEpC,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC;IAC5B,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC;IAE5B,IAAI,IAAI,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC;QAAE,OAAO,GAAG,CAAC;IAEzC,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;IAC7D,IAAI,WAAW,GAAG,CAAC;QAAE,OAAO,GAAG,CAAC;IAEhC,MAAM,SAAS,GAAG,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC9C,MAAM,SAAS,GAAG,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAE9C,IAAI,OAAO,GAAG,CAAC,CAAC;IAChB,IAAI,cAAc,GAAG,CAAC,CAAC;IAEvB,eAAe;IACf,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,CA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AAC,EAAE,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QACjD,IAAI,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC;YAAE,MAAM,EAAE,CAAC;;YACnC,MAAM;IACb,CAAC;IAED,OAAO,IAAI,GAAG,GAAG,GAAG,MAAM,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;AAC1C,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseJsonLenient = parseJsonLenient;
|
|
4
|
+
const jsonrepair_1 = require("jsonrepair");
|
|
5
|
+
/**
|
|
6
|
+
* Parse JSON, repairing malformed output before giving up.
|
|
7
|
+
*
|
|
8
|
+
* Structured-generation responses occasionally arrive broken — most commonly an
|
|
9
|
+
* unterminated string when the model hits its output-token budget mid-emit (the
|
|
10
|
+
* `SyntaxError: Unterminated string in JSON` class seen on large chunks). A plain
|
|
11
|
+
* `JSON.parse` throws and the whole attempt is wasted; `jsonrepair` closes dangling
|
|
12
|
+
* strings/brackets so a truncated-but-mostly-complete object still parses.
|
|
13
|
+
*
|
|
14
|
+
* Fast path first: a well-formed response never touches `jsonrepair`. On repair,
|
|
15
|
+
* `onRepair` is invoked (for a warn log) so the recovery isn't silent.
|
|
16
|
+
*/
|
|
17
|
+
function parseJsonLenient(content, onRepair) {
|
|
18
|
+
try {
|
|
19
|
+
return JSON.parse(content);
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
const repaired = (0, jsonrepair_1.jsonrepair)(content); // throws if unrepairable — propagate
|
|
23
|
+
onRepair === null || onRepair === void 0 ? void 0 : onRepair();
|
|
24
|
+
return JSON.parse(repaired);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=parseJsonLenient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseJsonLenient.js","sourceRoot":"","sources":["../../../src/shared/utils/parseJsonLenient.ts"],"names":[],"mappings":";;AAcA,4CAQC;AAtBD,2CAAwC;AAExC;;;;;;;;;;;GAWG;AACH,SAAgB,gBAAgB,CAAC,OAAe,EAAE,QAAqB;IACrE,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC7B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,QAAQ,GAAG,IAAA,uBAAU,EAAC,OAAO,CAAC,CAAC,CAAC,qCAAqC;QAC3E,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,EAAI,CAAC;QACb,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC9B,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.readConfigurationFile = readConfigurationFile;
|
|
16
|
+
const js_yaml_1 = __importDefault(require("js-yaml"));
|
|
17
|
+
const path_1 = __importDefault(require("path"));
|
|
18
|
+
const fs_1 = __importDefault(require("fs"));
|
|
19
|
+
/**
|
|
20
|
+
* Read a YAML/JSON config file into a raw object. No validation or shaping here
|
|
21
|
+
* — the caller merges this with CLI flags + env and validates the result via
|
|
22
|
+
* `parseConfig` (src/config), the single source of truth.
|
|
23
|
+
*/
|
|
24
|
+
function readConfigurationFile(file) {
|
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
var _a;
|
|
27
|
+
const ext = path_1.default.extname(file);
|
|
28
|
+
const content = fs_1.default.readFileSync(file, "utf-8");
|
|
29
|
+
switch (ext.toLowerCase()) {
|
|
30
|
+
case ".json":
|
|
31
|
+
return JSON.parse(content);
|
|
32
|
+
case ".yaml":
|
|
33
|
+
case ".yml":
|
|
34
|
+
return (_a = js_yaml_1.default.load(content)) !== null && _a !== void 0 ? _a : {};
|
|
35
|
+
default:
|
|
36
|
+
// Fail loud: returning {} silently ran the whole pipeline on pure
|
|
37
|
+
// defaults (ignoring the user's config entirely) — KG-18.
|
|
38
|
+
throw new Error(`Unsupported config file extension "${ext}" for ${file}; use .json, .yaml, or .yml`);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=readConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readConfig.js","sourceRoot":"","sources":["../../../src/shared/utils/readConfig.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AASA,sDAoBC;AA7BD,sDAA2B;AAC3B,gDAAwB;AACxB,4CAAoB;AAEpB;;;;GAIG;AACH,SAAsB,qBAAqB,CACzC,IAAY;;;QAEZ,MAAM,GAAG,GAAG,cAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAC/B,MAAM,OAAO,GAAG,YAAE,CAAC,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAC/C,QAAQ,GAAG,CAAC,WAAW,EAAE,EAAE,CAAC;YAC1B,KAAK,OAAO;gBACV,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAA4B,CAAC;YAExD,KAAK,OAAO,CAAC;YACb,KAAK,MAAM;gBACT,OAAO,MAAC,iBAAI,CAAC,IAAI,CAAC,OAAO,CAA6B,mCAAI,EAAE,CAAC;YAE/D;gBACE,kEAAkE;gBAClE,0DAA0D;gBAC1D,MAAM,IAAI,KAAK,CACb,sCAAsC,GAAG,SAAS,IAAI,6BAA6B,CACpF,CAAC;QACN,CAAC;IACH,CAAC;CAAA"}
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
+
exports.RtfReadError = void 0;
|
|
46
|
+
exports.readRtf = readRtf;
|
|
47
|
+
const fs = __importStar(require("fs"));
|
|
48
|
+
/**
|
|
49
|
+
* Extract plain text content from parsed RTF document
|
|
50
|
+
* RTF documents have a complex structure with formatting commands,
|
|
51
|
+
* we need to traverse the content and extract just the text
|
|
52
|
+
*/
|
|
53
|
+
function extractPlainText(document) {
|
|
54
|
+
if (!document || !document.content) {
|
|
55
|
+
return "";
|
|
56
|
+
}
|
|
57
|
+
let plainText = "";
|
|
58
|
+
const extractTextFromContent = (content) => {
|
|
59
|
+
let text = "";
|
|
60
|
+
for (const item of content) {
|
|
61
|
+
if (typeof item === "string") {
|
|
62
|
+
text += item;
|
|
63
|
+
}
|
|
64
|
+
else if (item && typeof item === "object") {
|
|
65
|
+
// Handle different RTF content types
|
|
66
|
+
if (item.type === "text" && item.value) {
|
|
67
|
+
text += item.value;
|
|
68
|
+
}
|
|
69
|
+
else if (item.type === "paragraph") {
|
|
70
|
+
if (item.content) {
|
|
71
|
+
text += extractTextFromContent(item.content);
|
|
72
|
+
}
|
|
73
|
+
text += "\n"; // Add paragraph break
|
|
74
|
+
}
|
|
75
|
+
else if (item.type === "span") {
|
|
76
|
+
if (item.content) {
|
|
77
|
+
text += extractTextFromContent(item.content);
|
|
78
|
+
}
|
|
79
|
+
text += "\n"; // Add paragraph break
|
|
80
|
+
}
|
|
81
|
+
else if (item.content && Array.isArray(item.content)) {
|
|
82
|
+
// Recursively extract from nested content
|
|
83
|
+
text += extractTextFromContent(item.content);
|
|
84
|
+
text += "\n"; // Add paragraph break
|
|
85
|
+
}
|
|
86
|
+
else if (typeof item.value === "string") {
|
|
87
|
+
text += item.value;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return text;
|
|
92
|
+
};
|
|
93
|
+
if (Array.isArray(document.content)) {
|
|
94
|
+
plainText = extractTextFromContent(document.content);
|
|
95
|
+
}
|
|
96
|
+
else if (typeof document.content === "string") {
|
|
97
|
+
plainText = document.content;
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
// Fallback: try to extract any text-like properties
|
|
101
|
+
const stringifyAndExtract = (obj) => {
|
|
102
|
+
if (typeof obj === "string")
|
|
103
|
+
return obj;
|
|
104
|
+
if (Array.isArray(obj)) {
|
|
105
|
+
return obj.map(stringifyAndExtract).join("");
|
|
106
|
+
}
|
|
107
|
+
if (obj && typeof obj === "object") {
|
|
108
|
+
let result = "";
|
|
109
|
+
if (obj.value && typeof obj.value === "string") {
|
|
110
|
+
result += obj.value;
|
|
111
|
+
}
|
|
112
|
+
if (obj.content) {
|
|
113
|
+
result += stringifyAndExtract(obj.content);
|
|
114
|
+
}
|
|
115
|
+
return result;
|
|
116
|
+
}
|
|
117
|
+
return "";
|
|
118
|
+
};
|
|
119
|
+
plainText = stringifyAndExtract(document.content);
|
|
120
|
+
}
|
|
121
|
+
// Clean up the extracted text
|
|
122
|
+
return cleanExtractedText(plainText);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Clean up extracted text by removing excessive whitespace and control characters
|
|
126
|
+
*/
|
|
127
|
+
function cleanExtractedText(text) {
|
|
128
|
+
return (text
|
|
129
|
+
// Remove control characters but keep newlines and tabs
|
|
130
|
+
.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]/g, "")
|
|
131
|
+
// Normalize line endings
|
|
132
|
+
.replace(/\r\n/g, "\n")
|
|
133
|
+
.replace(/\r/g, "\n")
|
|
134
|
+
// Remove excessive whitespace but preserve paragraph structure
|
|
135
|
+
.replace(/[ \t]+/g, " ")
|
|
136
|
+
.replace(/\n\s*\n\s*\n/g, "\n\n")
|
|
137
|
+
// Trim leading/trailing whitespace
|
|
138
|
+
.trim());
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Extract document information from parsed RTF document
|
|
142
|
+
*/
|
|
143
|
+
function extractDocumentInfo(document) {
|
|
144
|
+
const info = {};
|
|
145
|
+
// Extract document metadata if available
|
|
146
|
+
if (document.metadata) {
|
|
147
|
+
info.metadata = document.metadata;
|
|
148
|
+
}
|
|
149
|
+
// Extract document properties if available
|
|
150
|
+
if (document.props) {
|
|
151
|
+
info.properties = document.props;
|
|
152
|
+
}
|
|
153
|
+
// Extract font table information
|
|
154
|
+
if (document.fonts && Object.keys(document.fonts).length > 0) {
|
|
155
|
+
info.fontCount = Object.keys(document.fonts).length;
|
|
156
|
+
info.fonts = Object.keys(document.fonts).slice(0, 5); // Limit to first 5 fonts
|
|
157
|
+
}
|
|
158
|
+
// Extract color table information
|
|
159
|
+
if (document.colors &&
|
|
160
|
+
Array.isArray(document.colors) &&
|
|
161
|
+
document.colors.length > 0) {
|
|
162
|
+
info.colorCount = document.colors.length;
|
|
163
|
+
}
|
|
164
|
+
// Extract style information
|
|
165
|
+
if (document.styles && Object.keys(document.styles).length > 0) {
|
|
166
|
+
info.styleCount = Object.keys(document.styles).length;
|
|
167
|
+
}
|
|
168
|
+
// Extract any document-level properties
|
|
169
|
+
const docProps = [
|
|
170
|
+
"title",
|
|
171
|
+
"subject",
|
|
172
|
+
"author",
|
|
173
|
+
"manager",
|
|
174
|
+
"company",
|
|
175
|
+
"operator",
|
|
176
|
+
"category",
|
|
177
|
+
"keywords",
|
|
178
|
+
"comment",
|
|
179
|
+
];
|
|
180
|
+
for (const prop of docProps) {
|
|
181
|
+
if (document[prop]) {
|
|
182
|
+
info[prop] = document[prop];
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
return info;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Custom error for RTF reading failures
|
|
189
|
+
*/
|
|
190
|
+
class RtfReadError extends Error {
|
|
191
|
+
constructor(message, options) {
|
|
192
|
+
super(message);
|
|
193
|
+
this.name = "RtfReadError";
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
exports.RtfReadError = RtfReadError;
|
|
197
|
+
function readRtf(path) {
|
|
198
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
199
|
+
// @ts-ignore
|
|
200
|
+
const rtfParser = yield Promise.resolve().then(() => __importStar(require("rtf-parser")));
|
|
201
|
+
const rtf = yield fs.promises.readFile(path, "utf8");
|
|
202
|
+
return new Promise((resolve, reject) => {
|
|
203
|
+
rtfParser.string(rtf, (err, doc) => {
|
|
204
|
+
if (err) {
|
|
205
|
+
reject(new RtfReadError(err));
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
const text = extractPlainText(doc);
|
|
209
|
+
const info = extractDocumentInfo(doc);
|
|
210
|
+
resolve({ text, info });
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
});
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
//# sourceMappingURL=readRtf.js.map
|