openlore 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +268 -0
- package/dist/api/analyze.d.ts +17 -0
- package/dist/api/analyze.d.ts.map +1 -0
- package/dist/api/analyze.js +143 -0
- package/dist/api/analyze.js.map +1 -0
- package/dist/api/audit.d.ts +10 -0
- package/dist/api/audit.d.ts.map +1 -0
- package/dist/api/audit.js +117 -0
- package/dist/api/audit.js.map +1 -0
- package/dist/api/decisions.d.ts +55 -0
- package/dist/api/decisions.d.ts.map +1 -0
- package/dist/api/decisions.js +157 -0
- package/dist/api/decisions.js.map +1 -0
- package/dist/api/drift.d.ts +21 -0
- package/dist/api/drift.d.ts.map +1 -0
- package/dist/api/drift.js +152 -0
- package/dist/api/drift.js.map +1 -0
- package/dist/api/generate.d.ts +18 -0
- package/dist/api/generate.d.ts.map +1 -0
- package/dist/api/generate.js +259 -0
- package/dist/api/generate.js.map +1 -0
- package/dist/api/index.d.ts +41 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +34 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/init.d.ts +18 -0
- package/dist/api/init.d.ts.map +1 -0
- package/dist/api/init.js +83 -0
- package/dist/api/init.js.map +1 -0
- package/dist/api/run.d.ts +19 -0
- package/dist/api/run.d.ts.map +1 -0
- package/dist/api/run.js +312 -0
- package/dist/api/run.js.map +1 -0
- package/dist/api/specs.d.ts +49 -0
- package/dist/api/specs.d.ts.map +1 -0
- package/dist/api/specs.js +137 -0
- package/dist/api/specs.js.map +1 -0
- package/dist/api/types.d.ts +201 -0
- package/dist/api/types.d.ts.map +1 -0
- package/dist/api/types.js +9 -0
- package/dist/api/types.js.map +1 -0
- package/dist/api/verify.d.ts +20 -0
- package/dist/api/verify.d.ts.map +1 -0
- package/dist/api/verify.js +117 -0
- package/dist/api/verify.js.map +1 -0
- package/dist/cli/commands/analyze.d.ts +30 -0
- package/dist/cli/commands/analyze.d.ts.map +1 -0
- package/dist/cli/commands/analyze.js +683 -0
- package/dist/cli/commands/analyze.js.map +1 -0
- package/dist/cli/commands/audit.d.ts +9 -0
- package/dist/cli/commands/audit.d.ts.map +1 -0
- package/dist/cli/commands/audit.js +98 -0
- package/dist/cli/commands/audit.js.map +1 -0
- package/dist/cli/commands/decisions.d.ts +16 -0
- package/dist/cli/commands/decisions.d.ts.map +1 -0
- package/dist/cli/commands/decisions.js +864 -0
- package/dist/cli/commands/decisions.js.map +1 -0
- package/dist/cli/commands/digest.d.ts +9 -0
- package/dist/cli/commands/digest.d.ts.map +1 -0
- package/dist/cli/commands/digest.js +61 -0
- package/dist/cli/commands/digest.js.map +1 -0
- package/dist/cli/commands/doctor.d.ts +9 -0
- package/dist/cli/commands/doctor.d.ts.map +1 -0
- package/dist/cli/commands/doctor.js +398 -0
- package/dist/cli/commands/doctor.js.map +1 -0
- package/dist/cli/commands/drift.d.ts +9 -0
- package/dist/cli/commands/drift.d.ts.map +1 -0
- package/dist/cli/commands/drift.js +550 -0
- package/dist/cli/commands/drift.js.map +1 -0
- package/dist/cli/commands/generate.d.ts +9 -0
- package/dist/cli/commands/generate.d.ts.map +1 -0
- package/dist/cli/commands/generate.js +565 -0
- package/dist/cli/commands/generate.js.map +1 -0
- package/dist/cli/commands/init.d.ts +9 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/init.js +173 -0
- package/dist/cli/commands/init.js.map +1 -0
- package/dist/cli/commands/mcp.d.ts +2235 -0
- package/dist/cli/commands/mcp.d.ts.map +1 -0
- package/dist/cli/commands/mcp.js +1384 -0
- package/dist/cli/commands/mcp.js.map +1 -0
- package/dist/cli/commands/refresh-stories.d.ts +10 -0
- package/dist/cli/commands/refresh-stories.d.ts.map +1 -0
- package/dist/cli/commands/refresh-stories.js +314 -0
- package/dist/cli/commands/refresh-stories.js.map +1 -0
- package/dist/cli/commands/run.d.ts +9 -0
- package/dist/cli/commands/run.d.ts.map +1 -0
- package/dist/cli/commands/run.js +459 -0
- package/dist/cli/commands/run.js.map +1 -0
- package/dist/cli/commands/setup.d.ts +19 -0
- package/dist/cli/commands/setup.d.ts.map +1 -0
- package/dist/cli/commands/setup.js +355 -0
- package/dist/cli/commands/setup.js.map +1 -0
- package/dist/cli/commands/test.d.ts +22 -0
- package/dist/cli/commands/test.d.ts.map +1 -0
- package/dist/cli/commands/test.js +180 -0
- package/dist/cli/commands/test.js.map +1 -0
- package/dist/cli/commands/verify.d.ts +9 -0
- package/dist/cli/commands/verify.d.ts.map +1 -0
- package/dist/cli/commands/verify.js +383 -0
- package/dist/cli/commands/verify.js.map +1 -0
- package/dist/cli/commands/view.d.ts +13 -0
- package/dist/cli/commands/view.d.ts.map +1 -0
- package/dist/cli/commands/view.js +547 -0
- package/dist/cli/commands/view.js.map +1 -0
- package/dist/cli/index.d.ts +9 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +118 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/tui-approval.d.ts +11 -0
- package/dist/cli/tui-approval.d.ts.map +1 -0
- package/dist/cli/tui-approval.js +129 -0
- package/dist/cli/tui-approval.js.map +1 -0
- package/dist/constants.d.ts +314 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +382 -0
- package/dist/constants.js.map +1 -0
- package/dist/core/analyzer/ai-config-generator.d.ts +54 -0
- package/dist/core/analyzer/ai-config-generator.d.ts.map +1 -0
- package/dist/core/analyzer/ai-config-generator.js +98 -0
- package/dist/core/analyzer/ai-config-generator.js.map +1 -0
- package/dist/core/analyzer/architecture-writer.d.ts +67 -0
- package/dist/core/analyzer/architecture-writer.d.ts.map +1 -0
- package/dist/core/analyzer/architecture-writer.js +209 -0
- package/dist/core/analyzer/architecture-writer.js.map +1 -0
- package/dist/core/analyzer/artifact-generator.d.ts +261 -0
- package/dist/core/analyzer/artifact-generator.d.ts.map +1 -0
- package/dist/core/analyzer/artifact-generator.js +909 -0
- package/dist/core/analyzer/artifact-generator.js.map +1 -0
- package/dist/core/analyzer/ast-chunker.d.ts +24 -0
- package/dist/core/analyzer/ast-chunker.d.ts.map +1 -0
- package/dist/core/analyzer/ast-chunker.js +198 -0
- package/dist/core/analyzer/ast-chunker.js.map +1 -0
- package/dist/core/analyzer/call-graph.d.ts +162 -0
- package/dist/core/analyzer/call-graph.d.ts.map +1 -0
- package/dist/core/analyzer/call-graph.js +2040 -0
- package/dist/core/analyzer/call-graph.js.map +1 -0
- package/dist/core/analyzer/code-shaper.d.ts +33 -0
- package/dist/core/analyzer/code-shaper.d.ts.map +1 -0
- package/dist/core/analyzer/code-shaper.js +154 -0
- package/dist/core/analyzer/code-shaper.js.map +1 -0
- package/dist/core/analyzer/codebase-digest.d.ts +40 -0
- package/dist/core/analyzer/codebase-digest.d.ts.map +1 -0
- package/dist/core/analyzer/codebase-digest.js +195 -0
- package/dist/core/analyzer/codebase-digest.js.map +1 -0
- package/dist/core/analyzer/cpp-header-resolver.d.ts +30 -0
- package/dist/core/analyzer/cpp-header-resolver.d.ts.map +1 -0
- package/dist/core/analyzer/cpp-header-resolver.js +71 -0
- package/dist/core/analyzer/cpp-header-resolver.js.map +1 -0
- package/dist/core/analyzer/dependency-graph.d.ts +230 -0
- package/dist/core/analyzer/dependency-graph.d.ts.map +1 -0
- package/dist/core/analyzer/dependency-graph.js +752 -0
- package/dist/core/analyzer/dependency-graph.js.map +1 -0
- package/dist/core/analyzer/duplicate-detector.d.ts +52 -0
- package/dist/core/analyzer/duplicate-detector.d.ts.map +1 -0
- package/dist/core/analyzer/duplicate-detector.js +289 -0
- package/dist/core/analyzer/duplicate-detector.js.map +1 -0
- package/dist/core/analyzer/embedding-service.d.ts +56 -0
- package/dist/core/analyzer/embedding-service.d.ts.map +1 -0
- package/dist/core/analyzer/embedding-service.js +118 -0
- package/dist/core/analyzer/embedding-service.js.map +1 -0
- package/dist/core/analyzer/env-extractor.d.ts +33 -0
- package/dist/core/analyzer/env-extractor.d.ts.map +1 -0
- package/dist/core/analyzer/env-extractor.js +196 -0
- package/dist/core/analyzer/env-extractor.js.map +1 -0
- package/dist/core/analyzer/external-packages.d.ts +20 -0
- package/dist/core/analyzer/external-packages.d.ts.map +1 -0
- package/dist/core/analyzer/external-packages.js +175 -0
- package/dist/core/analyzer/external-packages.js.map +1 -0
- package/dist/core/analyzer/file-walker.d.ts +78 -0
- package/dist/core/analyzer/file-walker.d.ts.map +1 -0
- package/dist/core/analyzer/file-walker.js +532 -0
- package/dist/core/analyzer/file-walker.js.map +1 -0
- package/dist/core/analyzer/function-registry-trie.d.ts +21 -0
- package/dist/core/analyzer/function-registry-trie.d.ts.map +1 -0
- package/dist/core/analyzer/function-registry-trie.js +39 -0
- package/dist/core/analyzer/function-registry-trie.js.map +1 -0
- package/dist/core/analyzer/http-route-parser.d.ts +152 -0
- package/dist/core/analyzer/http-route-parser.d.ts.map +1 -0
- package/dist/core/analyzer/http-route-parser.js +971 -0
- package/dist/core/analyzer/http-route-parser.js.map +1 -0
- package/dist/core/analyzer/import-parser.d.ts +100 -0
- package/dist/core/analyzer/import-parser.d.ts.map +1 -0
- package/dist/core/analyzer/import-parser.js +952 -0
- package/dist/core/analyzer/import-parser.js.map +1 -0
- package/dist/core/analyzer/import-resolver-bridge.d.ts +25 -0
- package/dist/core/analyzer/import-resolver-bridge.d.ts.map +1 -0
- package/dist/core/analyzer/import-resolver-bridge.js +99 -0
- package/dist/core/analyzer/import-resolver-bridge.js.map +1 -0
- package/dist/core/analyzer/index.d.ts +10 -0
- package/dist/core/analyzer/index.d.ts.map +1 -0
- package/dist/core/analyzer/index.js +10 -0
- package/dist/core/analyzer/index.js.map +1 -0
- package/dist/core/analyzer/middleware-extractor.d.ts +29 -0
- package/dist/core/analyzer/middleware-extractor.d.ts.map +1 -0
- package/dist/core/analyzer/middleware-extractor.js +195 -0
- package/dist/core/analyzer/middleware-extractor.js.map +1 -0
- package/dist/core/analyzer/refactor-analyzer.d.ts +83 -0
- package/dist/core/analyzer/refactor-analyzer.d.ts.map +1 -0
- package/dist/core/analyzer/refactor-analyzer.js +351 -0
- package/dist/core/analyzer/refactor-analyzer.js.map +1 -0
- package/dist/core/analyzer/repository-mapper.d.ts +150 -0
- package/dist/core/analyzer/repository-mapper.d.ts.map +1 -0
- package/dist/core/analyzer/repository-mapper.js +740 -0
- package/dist/core/analyzer/repository-mapper.js.map +1 -0
- package/dist/core/analyzer/schema-extractor.d.ts +41 -0
- package/dist/core/analyzer/schema-extractor.d.ts.map +1 -0
- package/dist/core/analyzer/schema-extractor.js +229 -0
- package/dist/core/analyzer/schema-extractor.js.map +1 -0
- package/dist/core/analyzer/signature-extractor.d.ts +31 -0
- package/dist/core/analyzer/signature-extractor.d.ts.map +1 -0
- package/dist/core/analyzer/signature-extractor.js +675 -0
- package/dist/core/analyzer/signature-extractor.js.map +1 -0
- package/dist/core/analyzer/significance-scorer.d.ts +79 -0
- package/dist/core/analyzer/significance-scorer.d.ts.map +1 -0
- package/dist/core/analyzer/significance-scorer.js +407 -0
- package/dist/core/analyzer/significance-scorer.js.map +1 -0
- package/dist/core/analyzer/spec-snapshot-generator.d.ts +17 -0
- package/dist/core/analyzer/spec-snapshot-generator.d.ts.map +1 -0
- package/dist/core/analyzer/spec-snapshot-generator.js +201 -0
- package/dist/core/analyzer/spec-snapshot-generator.js.map +1 -0
- package/dist/core/analyzer/spec-vector-index.d.ts +68 -0
- package/dist/core/analyzer/spec-vector-index.d.ts.map +1 -0
- package/dist/core/analyzer/spec-vector-index.js +340 -0
- package/dist/core/analyzer/spec-vector-index.js.map +1 -0
- package/dist/core/analyzer/subgraph-extractor.d.ts +51 -0
- package/dist/core/analyzer/subgraph-extractor.d.ts.map +1 -0
- package/dist/core/analyzer/subgraph-extractor.js +147 -0
- package/dist/core/analyzer/subgraph-extractor.js.map +1 -0
- package/dist/core/analyzer/type-inference-engine.d.ts +23 -0
- package/dist/core/analyzer/type-inference-engine.d.ts.map +1 -0
- package/dist/core/analyzer/type-inference-engine.js +130 -0
- package/dist/core/analyzer/type-inference-engine.js.map +1 -0
- package/dist/core/analyzer/ui-component-extractor.d.ts +43 -0
- package/dist/core/analyzer/ui-component-extractor.d.ts.map +1 -0
- package/dist/core/analyzer/ui-component-extractor.js +245 -0
- package/dist/core/analyzer/ui-component-extractor.js.map +1 -0
- package/dist/core/analyzer/unified-search.d.ts +116 -0
- package/dist/core/analyzer/unified-search.d.ts.map +1 -0
- package/dist/core/analyzer/unified-search.js +231 -0
- package/dist/core/analyzer/unified-search.js.map +1 -0
- package/dist/core/analyzer/vector-index.d.ts +92 -0
- package/dist/core/analyzer/vector-index.d.ts.map +1 -0
- package/dist/core/analyzer/vector-index.js +451 -0
- package/dist/core/analyzer/vector-index.js.map +1 -0
- package/dist/core/decisions/consolidator.d.ts +14 -0
- package/dist/core/decisions/consolidator.d.ts.map +1 -0
- package/dist/core/decisions/consolidator.js +169 -0
- package/dist/core/decisions/consolidator.js.map +1 -0
- package/dist/core/decisions/extractor.d.ts +26 -0
- package/dist/core/decisions/extractor.d.ts.map +1 -0
- package/dist/core/decisions/extractor.js +156 -0
- package/dist/core/decisions/extractor.js.map +1 -0
- package/dist/core/decisions/index.d.ts +19 -0
- package/dist/core/decisions/index.d.ts.map +1 -0
- package/dist/core/decisions/index.js +16 -0
- package/dist/core/decisions/index.js.map +1 -0
- package/dist/core/decisions/store.d.ts +36 -0
- package/dist/core/decisions/store.d.ts.map +1 -0
- package/dist/core/decisions/store.js +109 -0
- package/dist/core/decisions/store.js.map +1 -0
- package/dist/core/decisions/syncer.d.ts +27 -0
- package/dist/core/decisions/syncer.d.ts.map +1 -0
- package/dist/core/decisions/syncer.js +214 -0
- package/dist/core/decisions/syncer.js.map +1 -0
- package/dist/core/decisions/verifier.d.ts +20 -0
- package/dist/core/decisions/verifier.d.ts.map +1 -0
- package/dist/core/decisions/verifier.js +115 -0
- package/dist/core/decisions/verifier.js.map +1 -0
- package/dist/core/digest/digest-generator.d.ts +29 -0
- package/dist/core/digest/digest-generator.d.ts.map +1 -0
- package/dist/core/digest/digest-generator.js +181 -0
- package/dist/core/digest/digest-generator.js.map +1 -0
- package/dist/core/drift/drift-detector.d.ts +102 -0
- package/dist/core/drift/drift-detector.d.ts.map +1 -0
- package/dist/core/drift/drift-detector.js +598 -0
- package/dist/core/drift/drift-detector.js.map +1 -0
- package/dist/core/drift/git-diff.d.ts +60 -0
- package/dist/core/drift/git-diff.d.ts.map +1 -0
- package/dist/core/drift/git-diff.js +383 -0
- package/dist/core/drift/git-diff.js.map +1 -0
- package/dist/core/drift/index.d.ts +12 -0
- package/dist/core/drift/index.d.ts.map +1 -0
- package/dist/core/drift/index.js +9 -0
- package/dist/core/drift/index.js.map +1 -0
- package/dist/core/drift/spec-mapper.d.ts +73 -0
- package/dist/core/drift/spec-mapper.d.ts.map +1 -0
- package/dist/core/drift/spec-mapper.js +353 -0
- package/dist/core/drift/spec-mapper.js.map +1 -0
- package/dist/core/drift/test-suggester.d.ts +18 -0
- package/dist/core/drift/test-suggester.d.ts.map +1 -0
- package/dist/core/drift/test-suggester.js +107 -0
- package/dist/core/drift/test-suggester.js.map +1 -0
- package/dist/core/generator/adr-generator.d.ts +32 -0
- package/dist/core/generator/adr-generator.d.ts.map +1 -0
- package/dist/core/generator/adr-generator.js +192 -0
- package/dist/core/generator/adr-generator.js.map +1 -0
- package/dist/core/generator/index.d.ts +9 -0
- package/dist/core/generator/index.d.ts.map +1 -0
- package/dist/core/generator/index.js +12 -0
- package/dist/core/generator/index.js.map +1 -0
- package/dist/core/generator/mapping-generator.d.ts +54 -0
- package/dist/core/generator/mapping-generator.d.ts.map +1 -0
- package/dist/core/generator/mapping-generator.js +240 -0
- package/dist/core/generator/mapping-generator.js.map +1 -0
- package/dist/core/generator/openspec-compat.d.ts +160 -0
- package/dist/core/generator/openspec-compat.d.ts.map +1 -0
- package/dist/core/generator/openspec-compat.js +524 -0
- package/dist/core/generator/openspec-compat.js.map +1 -0
- package/dist/core/generator/openspec-format-generator.d.ts +131 -0
- package/dist/core/generator/openspec-format-generator.d.ts.map +1 -0
- package/dist/core/generator/openspec-format-generator.js +963 -0
- package/dist/core/generator/openspec-format-generator.js.map +1 -0
- package/dist/core/generator/openspec-writer.d.ts +130 -0
- package/dist/core/generator/openspec-writer.d.ts.map +1 -0
- package/dist/core/generator/openspec-writer.js +404 -0
- package/dist/core/generator/openspec-writer.js.map +1 -0
- package/dist/core/generator/prompts.d.ts +35 -0
- package/dist/core/generator/prompts.d.ts.map +1 -0
- package/dist/core/generator/prompts.js +212 -0
- package/dist/core/generator/prompts.js.map +1 -0
- package/dist/core/generator/rag-manifest-generator.d.ts +37 -0
- package/dist/core/generator/rag-manifest-generator.d.ts.map +1 -0
- package/dist/core/generator/rag-manifest-generator.js +134 -0
- package/dist/core/generator/rag-manifest-generator.js.map +1 -0
- package/dist/core/generator/schemas.d.ts +365 -0
- package/dist/core/generator/schemas.d.ts.map +1 -0
- package/dist/core/generator/schemas.js +190 -0
- package/dist/core/generator/schemas.js.map +1 -0
- package/dist/core/generator/spec-pipeline.d.ts +123 -0
- package/dist/core/generator/spec-pipeline.d.ts.map +1 -0
- package/dist/core/generator/spec-pipeline.js +699 -0
- package/dist/core/generator/spec-pipeline.js.map +1 -0
- package/dist/core/generator/stages/stage1-survey.d.ts +19 -0
- package/dist/core/generator/stages/stage1-survey.d.ts.map +1 -0
- package/dist/core/generator/stages/stage1-survey.js +171 -0
- package/dist/core/generator/stages/stage1-survey.js.map +1 -0
- package/dist/core/generator/stages/stage2-entities.d.ts +11 -0
- package/dist/core/generator/stages/stage2-entities.d.ts.map +1 -0
- package/dist/core/generator/stages/stage2-entities.js +74 -0
- package/dist/core/generator/stages/stage2-entities.js.map +1 -0
- package/dist/core/generator/stages/stage3-services.d.ts +11 -0
- package/dist/core/generator/stages/stage3-services.d.ts.map +1 -0
- package/dist/core/generator/stages/stage3-services.js +85 -0
- package/dist/core/generator/stages/stage3-services.js.map +1 -0
- package/dist/core/generator/stages/stage4-api.d.ts +11 -0
- package/dist/core/generator/stages/stage4-api.d.ts.map +1 -0
- package/dist/core/generator/stages/stage4-api.js +72 -0
- package/dist/core/generator/stages/stage4-api.js.map +1 -0
- package/dist/core/generator/stages/stage5-architecture.d.ts +11 -0
- package/dist/core/generator/stages/stage5-architecture.d.ts.map +1 -0
- package/dist/core/generator/stages/stage5-architecture.js +75 -0
- package/dist/core/generator/stages/stage5-architecture.js.map +1 -0
- package/dist/core/generator/stages/stage6-adr.d.ts +8 -0
- package/dist/core/generator/stages/stage6-adr.d.ts.map +1 -0
- package/dist/core/generator/stages/stage6-adr.js +47 -0
- package/dist/core/generator/stages/stage6-adr.js.map +1 -0
- package/dist/core/services/chat-agent.d.ts +50 -0
- package/dist/core/services/chat-agent.d.ts.map +1 -0
- package/dist/core/services/chat-agent.js +369 -0
- package/dist/core/services/chat-agent.js.map +1 -0
- package/dist/core/services/chat-tools.d.ts +32 -0
- package/dist/core/services/chat-tools.d.ts.map +1 -0
- package/dist/core/services/chat-tools.js +494 -0
- package/dist/core/services/chat-tools.js.map +1 -0
- package/dist/core/services/config-manager.d.ts +61 -0
- package/dist/core/services/config-manager.d.ts.map +1 -0
- package/dist/core/services/config-manager.js +149 -0
- package/dist/core/services/config-manager.js.map +1 -0
- package/dist/core/services/edge-store.d.ts +57 -0
- package/dist/core/services/edge-store.d.ts.map +1 -0
- package/dist/core/services/edge-store.js +419 -0
- package/dist/core/services/edge-store.js.map +1 -0
- package/dist/core/services/gitignore-manager.d.ts +29 -0
- package/dist/core/services/gitignore-manager.d.ts.map +1 -0
- package/dist/core/services/gitignore-manager.js +95 -0
- package/dist/core/services/gitignore-manager.js.map +1 -0
- package/dist/core/services/index.d.ts +8 -0
- package/dist/core/services/index.d.ts.map +1 -0
- package/dist/core/services/index.js +8 -0
- package/dist/core/services/index.js.map +1 -0
- package/dist/core/services/llm-service.d.ts +379 -0
- package/dist/core/services/llm-service.d.ts.map +1 -0
- package/dist/core/services/llm-service.js +1553 -0
- package/dist/core/services/llm-service.js.map +1 -0
- package/dist/core/services/mcp-handlers/analysis.d.ts +127 -0
- package/dist/core/services/mcp-handlers/analysis.d.ts.map +1 -0
- package/dist/core/services/mcp-handlers/analysis.js +1185 -0
- package/dist/core/services/mcp-handlers/analysis.js.map +1 -0
- package/dist/core/services/mcp-handlers/change.d.ts +14 -0
- package/dist/core/services/mcp-handlers/change.d.ts.map +1 -0
- package/dist/core/services/mcp-handlers/change.js +416 -0
- package/dist/core/services/mcp-handlers/change.js.map +1 -0
- package/dist/core/services/mcp-handlers/decisions.d.ts +16 -0
- package/dist/core/services/mcp-handlers/decisions.d.ts.map +1 -0
- package/dist/core/services/mcp-handlers/decisions.js +239 -0
- package/dist/core/services/mcp-handlers/decisions.js.map +1 -0
- package/dist/core/services/mcp-handlers/graph.d.ts +94 -0
- package/dist/core/services/mcp-handlers/graph.d.ts.map +1 -0
- package/dist/core/services/mcp-handlers/graph.js +693 -0
- package/dist/core/services/mcp-handlers/graph.js.map +1 -0
- package/dist/core/services/mcp-handlers/orient.d.ts +17 -0
- package/dist/core/services/mcp-handlers/orient.d.ts.map +1 -0
- package/dist/core/services/mcp-handlers/orient.js +357 -0
- package/dist/core/services/mcp-handlers/orient.js.map +1 -0
- package/dist/core/services/mcp-handlers/semantic.d.ts +66 -0
- package/dist/core/services/mcp-handlers/semantic.d.ts.map +1 -0
- package/dist/core/services/mcp-handlers/semantic.js +432 -0
- package/dist/core/services/mcp-handlers/semantic.js.map +1 -0
- package/dist/core/services/mcp-handlers/utils.d.ts +85 -0
- package/dist/core/services/mcp-handlers/utils.d.ts.map +1 -0
- package/dist/core/services/mcp-handlers/utils.js +262 -0
- package/dist/core/services/mcp-handlers/utils.js.map +1 -0
- package/dist/core/services/mcp-watcher.d.ts +41 -0
- package/dist/core/services/mcp-watcher.d.ts.map +1 -0
- package/dist/core/services/mcp-watcher.js +254 -0
- package/dist/core/services/mcp-watcher.js.map +1 -0
- package/dist/core/services/project-detector.d.ts +32 -0
- package/dist/core/services/project-detector.d.ts.map +1 -0
- package/dist/core/services/project-detector.js +100 -0
- package/dist/core/services/project-detector.js.map +1 -0
- package/dist/core/test-generator/coverage-analyzer.d.ts +27 -0
- package/dist/core/test-generator/coverage-analyzer.d.ts.map +1 -0
- package/dist/core/test-generator/coverage-analyzer.js +285 -0
- package/dist/core/test-generator/coverage-analyzer.js.map +1 -0
- package/dist/core/test-generator/framework-detector.d.ts +17 -0
- package/dist/core/test-generator/framework-detector.d.ts.map +1 -0
- package/dist/core/test-generator/framework-detector.js +65 -0
- package/dist/core/test-generator/framework-detector.js.map +1 -0
- package/dist/core/test-generator/index.d.ts +14 -0
- package/dist/core/test-generator/index.d.ts.map +1 -0
- package/dist/core/test-generator/index.js +11 -0
- package/dist/core/test-generator/index.js.map +1 -0
- package/dist/core/test-generator/renderers/catch2.d.ts +8 -0
- package/dist/core/test-generator/renderers/catch2.d.ts.map +1 -0
- package/dist/core/test-generator/renderers/catch2.js +47 -0
- package/dist/core/test-generator/renderers/catch2.js.map +1 -0
- package/dist/core/test-generator/renderers/gtest.d.ts +8 -0
- package/dist/core/test-generator/renderers/gtest.d.ts.map +1 -0
- package/dist/core/test-generator/renderers/gtest.js +45 -0
- package/dist/core/test-generator/renderers/gtest.js.map +1 -0
- package/dist/core/test-generator/renderers/index.d.ts +20 -0
- package/dist/core/test-generator/renderers/index.d.ts.map +1 -0
- package/dist/core/test-generator/renderers/index.js +35 -0
- package/dist/core/test-generator/renderers/index.js.map +1 -0
- package/dist/core/test-generator/renderers/playwright.d.ts +8 -0
- package/dist/core/test-generator/renderers/playwright.d.ts.map +1 -0
- package/dist/core/test-generator/renderers/playwright.js +44 -0
- package/dist/core/test-generator/renderers/playwright.js.map +1 -0
- package/dist/core/test-generator/renderers/pytest.d.ts +8 -0
- package/dist/core/test-generator/renderers/pytest.d.ts.map +1 -0
- package/dist/core/test-generator/renderers/pytest.js +44 -0
- package/dist/core/test-generator/renderers/pytest.js.map +1 -0
- package/dist/core/test-generator/renderers/shared.d.ts +21 -0
- package/dist/core/test-generator/renderers/shared.d.ts.map +1 -0
- package/dist/core/test-generator/renderers/shared.js +56 -0
- package/dist/core/test-generator/renderers/shared.js.map +1 -0
- package/dist/core/test-generator/renderers/vitest.d.ts +8 -0
- package/dist/core/test-generator/renderers/vitest.d.ts.map +1 -0
- package/dist/core/test-generator/renderers/vitest.js +52 -0
- package/dist/core/test-generator/renderers/vitest.js.map +1 -0
- package/dist/core/test-generator/scenario-parser.d.ts +33 -0
- package/dist/core/test-generator/scenario-parser.d.ts.map +1 -0
- package/dist/core/test-generator/scenario-parser.js +244 -0
- package/dist/core/test-generator/scenario-parser.js.map +1 -0
- package/dist/core/test-generator/test-generator.d.ts +30 -0
- package/dist/core/test-generator/test-generator.d.ts.map +1 -0
- package/dist/core/test-generator/test-generator.js +174 -0
- package/dist/core/test-generator/test-generator.js.map +1 -0
- package/dist/core/test-generator/test-writer.d.ts +25 -0
- package/dist/core/test-generator/test-writer.d.ts.map +1 -0
- package/dist/core/test-generator/test-writer.js +128 -0
- package/dist/core/test-generator/test-writer.js.map +1 -0
- package/dist/core/test-generator/then-matchers.d.ts +35 -0
- package/dist/core/test-generator/then-matchers.d.ts.map +1 -0
- package/dist/core/test-generator/then-matchers.js +211 -0
- package/dist/core/test-generator/then-matchers.js.map +1 -0
- package/dist/core/verifier/index.d.ts +5 -0
- package/dist/core/verifier/index.d.ts.map +1 -0
- package/dist/core/verifier/index.js +5 -0
- package/dist/core/verifier/index.js.map +1 -0
- package/dist/core/verifier/verification-engine.d.ts +293 -0
- package/dist/core/verifier/verification-engine.d.ts.map +1 -0
- package/dist/core/verifier/verification-engine.js +919 -0
- package/dist/core/verifier/verification-engine.js.map +1 -0
- package/dist/types/index.d.ts +368 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +5 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/pipeline.d.ts +167 -0
- package/dist/types/pipeline.d.ts.map +1 -0
- package/dist/types/pipeline.js +5 -0
- package/dist/types/pipeline.js.map +1 -0
- package/dist/types/test-generator.d.ts +103 -0
- package/dist/types/test-generator.d.ts.map +1 -0
- package/dist/types/test-generator.js +17 -0
- package/dist/types/test-generator.js.map +1 -0
- package/dist/utils/command-helpers.d.ts +68 -0
- package/dist/utils/command-helpers.d.ts.map +1 -0
- package/dist/utils/command-helpers.js +150 -0
- package/dist/utils/command-helpers.js.map +1 -0
- package/dist/utils/errors.d.ts +51 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +129 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/logger.d.ts +149 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +342 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/misc.d.ts +10 -0
- package/dist/utils/misc.d.ts.map +1 -0
- package/dist/utils/misc.js +21 -0
- package/dist/utils/misc.js.map +1 -0
- package/dist/utils/progress.d.ts +142 -0
- package/dist/utils/progress.d.ts.map +1 -0
- package/dist/utils/progress.js +283 -0
- package/dist/utils/progress.js.map +1 -0
- package/dist/utils/prompts.d.ts +53 -0
- package/dist/utils/prompts.d.ts.map +1 -0
- package/dist/utils/prompts.js +199 -0
- package/dist/utils/prompts.js.map +1 -0
- package/dist/utils/shutdown.d.ts +89 -0
- package/dist/utils/shutdown.d.ts.map +1 -0
- package/dist/utils/shutdown.js +238 -0
- package/dist/utils/shutdown.js.map +1 -0
- package/examples/bmad/README.md +113 -0
- package/examples/bmad/agents/architect.md +226 -0
- package/examples/bmad/agents/dev-brownfield.md +69 -0
- package/examples/bmad/setup/architect.customize.yaml +14 -0
- package/examples/bmad/tasks/implement-story.md +254 -0
- package/examples/bmad/tasks/onboarding.md +169 -0
- package/examples/bmad/tasks/refactor.md +178 -0
- package/examples/bmad/tasks/sprint-planning.md +168 -0
- package/examples/bmad/templates/story.md +108 -0
- package/examples/cline-workflows/openlore-analyze-codebase.md +101 -0
- package/examples/cline-workflows/openlore-check-spec-drift.md +102 -0
- package/examples/cline-workflows/openlore-execute-refactor.md +212 -0
- package/examples/cline-workflows/openlore-implement-feature.md +266 -0
- package/examples/cline-workflows/openlore-plan-refactor.md +279 -0
- package/examples/cline-workflows/openlore-refactor-codebase.md +16 -0
- package/examples/cline-workflows/openlore-write-tests.md +177 -0
- package/examples/drift-demo/openspec/config.yaml +14 -0
- package/examples/drift-demo/openspec/specs/architecture/spec.md +30 -0
- package/examples/drift-demo/openspec/specs/auth/spec.md +71 -0
- package/examples/drift-demo/openspec/specs/database/spec.md +33 -0
- package/examples/drift-demo/openspec/specs/overview/spec.md +20 -0
- package/examples/drift-demo/openspec/specs/projects/spec.md +55 -0
- package/examples/drift-demo/openspec/specs/tasks/spec.md +78 -0
- package/examples/drift-demo/package.json +21 -0
- package/examples/drift-demo/src/auth/auth-middleware.ts +30 -0
- package/examples/drift-demo/src/auth/auth-routes.ts +29 -0
- package/examples/drift-demo/src/auth/auth-service.ts +45 -0
- package/examples/drift-demo/src/database/connection.ts +27 -0
- package/examples/drift-demo/src/index.ts +16 -0
- package/examples/drift-demo/src/projects/project-model.ts +15 -0
- package/examples/drift-demo/src/projects/project-service.ts +34 -0
- package/examples/drift-demo/src/tasks/task-model.ts +37 -0
- package/examples/drift-demo/src/tasks/task-routes.ts +53 -0
- package/examples/drift-demo/src/tasks/task-service.ts +60 -0
- package/examples/drift-demo/src/utils/validation.ts +11 -0
- package/examples/drift-demo/tests/auth.test.ts +4 -0
- package/examples/drift-demo/tests/tasks.test.ts +4 -0
- package/examples/drift-demo/tsconfig.json +10 -0
- package/examples/drift-test/run-drift-test.sh +1087 -0
- package/examples/gsd/README.md +119 -0
- package/examples/gsd/commands/gsd/openlore-drift.md +111 -0
- package/examples/gsd/commands/gsd/openlore-orient.md +191 -0
- package/examples/mistral-vibe/README.md +101 -0
- package/examples/mistral-vibe/antipatterns-template.md +18 -0
- package/examples/mistral-vibe/skills/openlore-analyze-codebase/SKILL.md +124 -0
- package/examples/mistral-vibe/skills/openlore-brainstorm/SKILL.md +379 -0
- package/examples/mistral-vibe/skills/openlore-debug/SKILL.md +330 -0
- package/examples/mistral-vibe/skills/openlore-execute-refactor/SKILL.md +291 -0
- package/examples/mistral-vibe/skills/openlore-generate/SKILL.md +245 -0
- package/examples/mistral-vibe/skills/openlore-implement-story/SKILL.md +326 -0
- package/examples/mistral-vibe/skills/openlore-plan-refactor/SKILL.md +365 -0
- package/examples/mistral-vibe/skills/openlore-review-changes/SKILL.md +128 -0
- package/examples/mistral-vibe/skills/openlore-write-tests/SKILL.md +261 -0
- package/examples/opencode/agent-guard.ts +170 -0
- package/examples/opencode/plugins/anti-laziness.ts +202 -0
- package/examples/opencode/plugins/lib/openlore-context-injector-helpers.ts +116 -0
- package/examples/opencode/plugins/lib/openlore-decision-extractor-helpers.ts +65 -0
- package/examples/opencode/plugins/openlore-context-injector.test.ts +211 -0
- package/examples/opencode/plugins/openlore-context-injector.ts +165 -0
- package/examples/opencode/plugins/openlore-decision-extractor.test.ts +131 -0
- package/examples/opencode/plugins/openlore-decision-extractor.ts +322 -0
- package/examples/opencode/plugins/openlore-enforcer.ts +227 -0
- package/examples/opencode/prompts/sisyphus-sdd.md +150 -0
- package/examples/opencode-skills/openlore-analyze-codebase/SKILL.md +101 -0
- package/examples/opencode-skills/openlore-brainstorm/SKILL.md +354 -0
- package/examples/opencode-skills/openlore-debug/SKILL.md +291 -0
- package/examples/opencode-skills/openlore-execute-refactor/SKILL.md +241 -0
- package/examples/opencode-skills/openlore-generate/SKILL.md +236 -0
- package/examples/opencode-skills/openlore-implement-story/SKILL.md +251 -0
- package/examples/opencode-skills/openlore-plan-refactor/SKILL.md +298 -0
- package/examples/opencode-skills/openlore-review-changes/SKILL.md +134 -0
- package/examples/opencode-skills/openlore-write-tests/SKILL.md +230 -0
- package/examples/openspec-analysis/README.md +59 -0
- package/examples/openspec-analysis/SUMMARY.md +72 -0
- package/examples/openspec-analysis/config.json +16 -0
- package/examples/openspec-analysis/dependencies.mermaid +35 -0
- package/examples/openspec-analysis/dependency-graph.json +12116 -0
- package/examples/openspec-analysis/llm-context.json +119 -0
- package/examples/openspec-analysis/repo-structure.json +871 -0
- package/examples/openspec-cli/README.md +67 -0
- package/examples/openspec-cli/openspec/config.yaml +26 -0
- package/examples/openspec-cli/openspec/specs/architecture/spec.md +178 -0
- package/examples/openspec-cli/openspec/specs/artifact-graph/spec.md +143 -0
- package/examples/openspec-cli/openspec/specs/cli/spec.md +138 -0
- package/examples/openspec-cli/openspec/specs/overview/spec.md +60 -0
- package/examples/openspec-cli/openspec/specs/parsing/spec.md +123 -0
- package/examples/openspec-cli/openspec/specs/validation/spec.md +108 -0
- package/examples/spec-kit/README.md +104 -0
- package/examples/spec-kit/commands/drift.md +87 -0
- package/examples/spec-kit/commands/orient.md +138 -0
- package/examples/spec-kit/extension.yml +54 -0
- package/package.json +125 -0
- package/src/viewer/InteractiveGraphViewer.jsx +1600 -0
- package/src/viewer/app/index.html +17 -0
- package/src/viewer/app/main.jsx +13 -0
- package/src/viewer/components/ArchitectureView.jsx +177 -0
- package/src/viewer/components/ChatPanel.jsx +450 -0
- package/src/viewer/components/ClassGraph.jsx +782 -0
- package/src/viewer/components/ClusterGraph.jsx +469 -0
- package/src/viewer/components/FilterBar.jsx +179 -0
- package/src/viewer/components/FlatGraph.jsx +282 -0
- package/src/viewer/components/MicroComponents.jsx +85 -0
- package/src/viewer/hooks/usePanZoom.js +79 -0
- package/src/viewer/utils/constants.js +64 -0
- package/src/viewer/utils/graph-helpers.js +303 -0
- package/src/viewer/utils/graph-helpers.test.ts +39 -0
- package/src/viewer/utils/themes.js +206 -0
- package/stubs/tree-sitter-cli-stub/package.json +6 -0
|
@@ -0,0 +1,952 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Import/Export Parser
|
|
3
|
+
*
|
|
4
|
+
* Parses source files to extract imports and exports.
|
|
5
|
+
* Uses regex-based parsing for speed and simplicity.
|
|
6
|
+
* Supports JavaScript/TypeScript, Python, and Java.
|
|
7
|
+
*/
|
|
8
|
+
import { readFile } from 'node:fs/promises';
|
|
9
|
+
import { dirname, join, resolve, extname } from 'node:path';
|
|
10
|
+
// ============================================================================
|
|
11
|
+
// NODE.JS BUILTINS
|
|
12
|
+
// ============================================================================
|
|
13
|
+
const NODE_BUILTINS = new Set([
|
|
14
|
+
'assert', 'async_hooks', 'buffer', 'child_process', 'cluster', 'console',
|
|
15
|
+
'constants', 'crypto', 'dgram', 'diagnostics_channel', 'dns', 'domain',
|
|
16
|
+
'events', 'fs', 'http', 'http2', 'https', 'inspector', 'module', 'net',
|
|
17
|
+
'os', 'path', 'perf_hooks', 'process', 'punycode', 'querystring', 'readline',
|
|
18
|
+
'repl', 'stream', 'string_decoder', 'timers', 'tls', 'trace_events', 'tty',
|
|
19
|
+
'url', 'util', 'v8', 'vm', 'wasi', 'worker_threads', 'zlib',
|
|
20
|
+
// Node.js prefixed versions
|
|
21
|
+
'node:assert', 'node:async_hooks', 'node:buffer', 'node:child_process',
|
|
22
|
+
'node:cluster', 'node:console', 'node:constants', 'node:crypto', 'node:dgram',
|
|
23
|
+
'node:diagnostics_channel', 'node:dns', 'node:domain', 'node:events',
|
|
24
|
+
'node:fs', 'node:http', 'node:http2', 'node:https', 'node:inspector',
|
|
25
|
+
'node:module', 'node:net', 'node:os', 'node:path', 'node:perf_hooks',
|
|
26
|
+
'node:process', 'node:punycode', 'node:querystring', 'node:readline',
|
|
27
|
+
'node:repl', 'node:stream', 'node:string_decoder', 'node:timers', 'node:tls',
|
|
28
|
+
'node:trace_events', 'node:tty', 'node:url', 'node:util', 'node:v8',
|
|
29
|
+
'node:vm', 'node:wasi', 'node:worker_threads', 'node:zlib',
|
|
30
|
+
// fs/promises and other submodules
|
|
31
|
+
'fs/promises', 'node:fs/promises', 'stream/promises', 'node:stream/promises',
|
|
32
|
+
'timers/promises', 'node:timers/promises', 'util/types', 'node:util/types',
|
|
33
|
+
]);
|
|
34
|
+
// ============================================================================
|
|
35
|
+
// HELPER FUNCTIONS
|
|
36
|
+
// ============================================================================
|
|
37
|
+
/**
|
|
38
|
+
* Check if a module path is a relative import
|
|
39
|
+
*/
|
|
40
|
+
function isRelativeImport(source) {
|
|
41
|
+
return source.startsWith('.') || source.startsWith('/');
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Check if a module is a Node.js builtin
|
|
45
|
+
*/
|
|
46
|
+
function isBuiltinModule(source) {
|
|
47
|
+
return NODE_BUILTINS.has(source) || NODE_BUILTINS.has(source.split('/')[0]);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Get line number for a match position in content
|
|
51
|
+
*/
|
|
52
|
+
function getLineNumber(content, position) {
|
|
53
|
+
return content.substring(0, position).split('\n').length;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Parse named imports from a string like "X, Y as Z, W"
|
|
57
|
+
*/
|
|
58
|
+
function parseNamedImports(namesStr) {
|
|
59
|
+
return namesStr
|
|
60
|
+
.split(',')
|
|
61
|
+
.map(name => {
|
|
62
|
+
const trimmed = name.trim();
|
|
63
|
+
// Handle "X as Y" - we want the local name Y
|
|
64
|
+
const asMatch = trimmed.match(/(\w+)\s+as\s+(\w+)/);
|
|
65
|
+
if (asMatch) {
|
|
66
|
+
return asMatch[2];
|
|
67
|
+
}
|
|
68
|
+
// Handle type imports like "type X"
|
|
69
|
+
if (trimmed.startsWith('type ')) {
|
|
70
|
+
return trimmed.slice(5).trim();
|
|
71
|
+
}
|
|
72
|
+
return trimmed;
|
|
73
|
+
})
|
|
74
|
+
.filter(name => name && !name.includes(' '));
|
|
75
|
+
}
|
|
76
|
+
// ============================================================================
|
|
77
|
+
// JAVASCRIPT/TYPESCRIPT PARSER
|
|
78
|
+
// ============================================================================
|
|
79
|
+
/**
|
|
80
|
+
* Parse imports from JavaScript/TypeScript content
|
|
81
|
+
*/
|
|
82
|
+
function parseJSImports(content) {
|
|
83
|
+
const imports = [];
|
|
84
|
+
// Remove comments to avoid false matches
|
|
85
|
+
const cleanContent = content
|
|
86
|
+
.replace(/\/\*[\s\S]*?\*\//g, '') // Block comments
|
|
87
|
+
.replace(/\/\/.*$/gm, ''); // Line comments
|
|
88
|
+
// ES Module: import X from 'module'
|
|
89
|
+
let match;
|
|
90
|
+
const defaultImportRegex = /import\s+(\w+)\s+from\s+['"]([^'"]+)['"]/g;
|
|
91
|
+
while ((match = defaultImportRegex.exec(cleanContent)) !== null) {
|
|
92
|
+
const source = match[2];
|
|
93
|
+
imports.push({
|
|
94
|
+
source,
|
|
95
|
+
isRelative: isRelativeImport(source),
|
|
96
|
+
isPackage: !isRelativeImport(source) && !isBuiltinModule(source),
|
|
97
|
+
isBuiltin: isBuiltinModule(source),
|
|
98
|
+
importedNames: [match[1]],
|
|
99
|
+
hasDefault: true,
|
|
100
|
+
hasNamespace: false,
|
|
101
|
+
isTypeOnly: false,
|
|
102
|
+
isDynamic: false,
|
|
103
|
+
line: getLineNumber(content, match.index),
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
// ES Module: import X, { Y, Z } from 'module' (mixed import - default + named)
|
|
107
|
+
const mixedImportRegex = /import\s+(\w+)\s*,\s*\{([^}]+)\}\s+from\s+['"]([^'"]+)['"]/g;
|
|
108
|
+
while ((match = mixedImportRegex.exec(cleanContent)) !== null) {
|
|
109
|
+
const source = match[3];
|
|
110
|
+
const names = [match[1], ...parseNamedImports(match[2])];
|
|
111
|
+
imports.push({
|
|
112
|
+
source,
|
|
113
|
+
isRelative: isRelativeImport(source),
|
|
114
|
+
isPackage: !isRelativeImport(source) && !isBuiltinModule(source),
|
|
115
|
+
isBuiltin: isBuiltinModule(source),
|
|
116
|
+
importedNames: names,
|
|
117
|
+
hasDefault: true,
|
|
118
|
+
hasNamespace: false,
|
|
119
|
+
isTypeOnly: false,
|
|
120
|
+
isDynamic: false,
|
|
121
|
+
line: getLineNumber(content, match.index),
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
// ES Module: import { X, Y } from 'module'
|
|
125
|
+
const namedImportRegex = /import\s+\{([^}]+)\}\s+from\s+['"]([^'"]+)['"]/g;
|
|
126
|
+
while ((match = namedImportRegex.exec(cleanContent)) !== null) {
|
|
127
|
+
const source = match[2];
|
|
128
|
+
const names = parseNamedImports(match[1]);
|
|
129
|
+
imports.push({
|
|
130
|
+
source,
|
|
131
|
+
isRelative: isRelativeImport(source),
|
|
132
|
+
isPackage: !isRelativeImport(source) && !isBuiltinModule(source),
|
|
133
|
+
isBuiltin: isBuiltinModule(source),
|
|
134
|
+
importedNames: names,
|
|
135
|
+
hasDefault: false,
|
|
136
|
+
hasNamespace: false,
|
|
137
|
+
isTypeOnly: false,
|
|
138
|
+
isDynamic: false,
|
|
139
|
+
line: getLineNumber(content, match.index),
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
// ES Module: import * as X from 'module'
|
|
143
|
+
const namespaceImportRegex = /import\s+\*\s+as\s+(\w+)\s+from\s+['"]([^'"]+)['"]/g;
|
|
144
|
+
while ((match = namespaceImportRegex.exec(cleanContent)) !== null) {
|
|
145
|
+
const source = match[2];
|
|
146
|
+
imports.push({
|
|
147
|
+
source,
|
|
148
|
+
isRelative: isRelativeImport(source),
|
|
149
|
+
isPackage: !isRelativeImport(source) && !isBuiltinModule(source),
|
|
150
|
+
isBuiltin: isBuiltinModule(source),
|
|
151
|
+
importedNames: [match[1]],
|
|
152
|
+
hasDefault: false,
|
|
153
|
+
hasNamespace: true,
|
|
154
|
+
isTypeOnly: false,
|
|
155
|
+
isDynamic: false,
|
|
156
|
+
line: getLineNumber(content, match.index),
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
// ES Module: import 'module' (side effect)
|
|
160
|
+
const sideEffectRegex = /import\s+['"]([^'"]+)['"](?!\s*from)/g;
|
|
161
|
+
while ((match = sideEffectRegex.exec(cleanContent)) !== null) {
|
|
162
|
+
const source = match[1];
|
|
163
|
+
imports.push({
|
|
164
|
+
source,
|
|
165
|
+
isRelative: isRelativeImport(source),
|
|
166
|
+
isPackage: !isRelativeImport(source) && !isBuiltinModule(source),
|
|
167
|
+
isBuiltin: isBuiltinModule(source),
|
|
168
|
+
importedNames: [],
|
|
169
|
+
hasDefault: false,
|
|
170
|
+
hasNamespace: false,
|
|
171
|
+
isTypeOnly: false,
|
|
172
|
+
isDynamic: false,
|
|
173
|
+
line: getLineNumber(content, match.index),
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
// Type-only imports: import type { X } from 'module'
|
|
177
|
+
const typeImportRegex = /import\s+type\s+(?:\{([^}]+)\}|(\w+))\s+from\s+['"]([^'"]+)['"]/g;
|
|
178
|
+
while ((match = typeImportRegex.exec(cleanContent)) !== null) {
|
|
179
|
+
const source = match[3];
|
|
180
|
+
const names = match[1] ? parseNamedImports(match[1]) : [match[2]];
|
|
181
|
+
imports.push({
|
|
182
|
+
source,
|
|
183
|
+
isRelative: isRelativeImport(source),
|
|
184
|
+
isPackage: !isRelativeImport(source) && !isBuiltinModule(source),
|
|
185
|
+
isBuiltin: isBuiltinModule(source),
|
|
186
|
+
importedNames: names,
|
|
187
|
+
hasDefault: !!match[2],
|
|
188
|
+
hasNamespace: false,
|
|
189
|
+
isTypeOnly: true,
|
|
190
|
+
isDynamic: false,
|
|
191
|
+
line: getLineNumber(content, match.index),
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
// CommonJS: require('module')
|
|
195
|
+
const requireRegex = /(?:const|let|var)\s+(?:(\w+)|\{([^}]+)\})\s*=\s*require\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
|
|
196
|
+
while ((match = requireRegex.exec(cleanContent)) !== null) {
|
|
197
|
+
const source = match[3];
|
|
198
|
+
const names = match[1] ? [match[1]] : parseNamedImports(match[2]);
|
|
199
|
+
imports.push({
|
|
200
|
+
source,
|
|
201
|
+
isRelative: isRelativeImport(source),
|
|
202
|
+
isPackage: !isRelativeImport(source) && !isBuiltinModule(source),
|
|
203
|
+
isBuiltin: isBuiltinModule(source),
|
|
204
|
+
importedNames: names,
|
|
205
|
+
hasDefault: !!match[1],
|
|
206
|
+
hasNamespace: false,
|
|
207
|
+
isTypeOnly: false,
|
|
208
|
+
isDynamic: false,
|
|
209
|
+
line: getLineNumber(content, match.index),
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
// Dynamic import: import('module')
|
|
213
|
+
const dynamicImportRegex = /(?:await\s+)?import\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
|
|
214
|
+
while ((match = dynamicImportRegex.exec(cleanContent)) !== null) {
|
|
215
|
+
const source = match[1];
|
|
216
|
+
imports.push({
|
|
217
|
+
source,
|
|
218
|
+
isRelative: isRelativeImport(source),
|
|
219
|
+
isPackage: !isRelativeImport(source) && !isBuiltinModule(source),
|
|
220
|
+
isBuiltin: isBuiltinModule(source),
|
|
221
|
+
importedNames: [],
|
|
222
|
+
hasDefault: false,
|
|
223
|
+
hasNamespace: false,
|
|
224
|
+
isTypeOnly: false,
|
|
225
|
+
isDynamic: true,
|
|
226
|
+
line: getLineNumber(content, match.index),
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
return imports;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Parse exports from JavaScript/TypeScript content
|
|
233
|
+
*/
|
|
234
|
+
function parseJSExports(content) {
|
|
235
|
+
const exports = [];
|
|
236
|
+
// Remove comments
|
|
237
|
+
const cleanContent = content
|
|
238
|
+
.replace(/\/\*[\s\S]*?\*\//g, '')
|
|
239
|
+
.replace(/\/\/.*$/gm, '');
|
|
240
|
+
let match;
|
|
241
|
+
// export default
|
|
242
|
+
const defaultExportRegex = /export\s+default\s+(?:(class|function)\s+(\w+)|(\w+))/g;
|
|
243
|
+
while ((match = defaultExportRegex.exec(cleanContent)) !== null) {
|
|
244
|
+
const kind = match[1];
|
|
245
|
+
const name = match[2] || match[3] || 'default';
|
|
246
|
+
exports.push({
|
|
247
|
+
name,
|
|
248
|
+
isDefault: true,
|
|
249
|
+
isType: false,
|
|
250
|
+
isReExport: false,
|
|
251
|
+
kind: kind || 'unknown',
|
|
252
|
+
line: getLineNumber(content, match.index),
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
// export { X, Y } or export { X } from 'module'
|
|
256
|
+
const namedExportRegex = /export\s+\{([^}]+)\}(?:\s+from\s+['"]([^'"]+)['"])?/g;
|
|
257
|
+
while ((match = namedExportRegex.exec(cleanContent)) !== null) {
|
|
258
|
+
const names = parseNamedImports(match[1]);
|
|
259
|
+
const reExportSource = match[2];
|
|
260
|
+
for (const name of names) {
|
|
261
|
+
exports.push({
|
|
262
|
+
name,
|
|
263
|
+
isDefault: false,
|
|
264
|
+
isType: false,
|
|
265
|
+
isReExport: !!reExportSource,
|
|
266
|
+
reExportSource,
|
|
267
|
+
kind: 'unknown',
|
|
268
|
+
line: getLineNumber(content, match.index),
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
// export const/let/var
|
|
273
|
+
const varExportRegex = /export\s+(?:const|let|var)\s+(\w+)/g;
|
|
274
|
+
while ((match = varExportRegex.exec(cleanContent)) !== null) {
|
|
275
|
+
exports.push({
|
|
276
|
+
name: match[1],
|
|
277
|
+
isDefault: false,
|
|
278
|
+
isType: false,
|
|
279
|
+
isReExport: false,
|
|
280
|
+
kind: 'variable',
|
|
281
|
+
line: getLineNumber(content, match.index),
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
// export function
|
|
285
|
+
const funcExportRegex = /export\s+function\s+(\w+)/g;
|
|
286
|
+
while ((match = funcExportRegex.exec(cleanContent)) !== null) {
|
|
287
|
+
exports.push({
|
|
288
|
+
name: match[1],
|
|
289
|
+
isDefault: false,
|
|
290
|
+
isType: false,
|
|
291
|
+
isReExport: false,
|
|
292
|
+
kind: 'function',
|
|
293
|
+
line: getLineNumber(content, match.index),
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
// export class
|
|
297
|
+
const classExportRegex = /export\s+class\s+(\w+)/g;
|
|
298
|
+
while ((match = classExportRegex.exec(cleanContent)) !== null) {
|
|
299
|
+
exports.push({
|
|
300
|
+
name: match[1],
|
|
301
|
+
isDefault: false,
|
|
302
|
+
isType: false,
|
|
303
|
+
isReExport: false,
|
|
304
|
+
kind: 'class',
|
|
305
|
+
line: getLineNumber(content, match.index),
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
// export type
|
|
309
|
+
const typeExportRegex = /export\s+type\s+(\w+)/g;
|
|
310
|
+
while ((match = typeExportRegex.exec(cleanContent)) !== null) {
|
|
311
|
+
exports.push({
|
|
312
|
+
name: match[1],
|
|
313
|
+
isDefault: false,
|
|
314
|
+
isType: true,
|
|
315
|
+
isReExport: false,
|
|
316
|
+
kind: 'type',
|
|
317
|
+
line: getLineNumber(content, match.index),
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
// export interface
|
|
321
|
+
const interfaceExportRegex = /export\s+interface\s+(\w+)/g;
|
|
322
|
+
while ((match = interfaceExportRegex.exec(cleanContent)) !== null) {
|
|
323
|
+
exports.push({
|
|
324
|
+
name: match[1],
|
|
325
|
+
isDefault: false,
|
|
326
|
+
isType: true,
|
|
327
|
+
isReExport: false,
|
|
328
|
+
kind: 'interface',
|
|
329
|
+
line: getLineNumber(content, match.index),
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
// export enum
|
|
333
|
+
const enumExportRegex = /export\s+enum\s+(\w+)/g;
|
|
334
|
+
while ((match = enumExportRegex.exec(cleanContent)) !== null) {
|
|
335
|
+
exports.push({
|
|
336
|
+
name: match[1],
|
|
337
|
+
isDefault: false,
|
|
338
|
+
isType: false,
|
|
339
|
+
isReExport: false,
|
|
340
|
+
kind: 'enum',
|
|
341
|
+
line: getLineNumber(content, match.index),
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
// export * from 'module'
|
|
345
|
+
const reExportAllRegex = /export\s+\*\s+(?:as\s+(\w+)\s+)?from\s+['"]([^'"]+)['"]/g;
|
|
346
|
+
while ((match = reExportAllRegex.exec(cleanContent)) !== null) {
|
|
347
|
+
exports.push({
|
|
348
|
+
name: match[1] || '*',
|
|
349
|
+
isDefault: false,
|
|
350
|
+
isType: false,
|
|
351
|
+
isReExport: true,
|
|
352
|
+
reExportSource: match[2],
|
|
353
|
+
kind: 'unknown',
|
|
354
|
+
line: getLineNumber(content, match.index),
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
// module.exports
|
|
358
|
+
const moduleExportsRegex = /module\.exports\s*=\s*(\w+)/g;
|
|
359
|
+
while ((match = moduleExportsRegex.exec(cleanContent)) !== null) {
|
|
360
|
+
exports.push({
|
|
361
|
+
name: match[1],
|
|
362
|
+
isDefault: true,
|
|
363
|
+
isType: false,
|
|
364
|
+
isReExport: false,
|
|
365
|
+
kind: 'unknown',
|
|
366
|
+
line: getLineNumber(content, match.index),
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
// exports.X
|
|
370
|
+
const exportsRegex = /exports\.(\w+)\s*=/g;
|
|
371
|
+
while ((match = exportsRegex.exec(cleanContent)) !== null) {
|
|
372
|
+
exports.push({
|
|
373
|
+
name: match[1],
|
|
374
|
+
isDefault: false,
|
|
375
|
+
isType: false,
|
|
376
|
+
isReExport: false,
|
|
377
|
+
kind: 'unknown',
|
|
378
|
+
line: getLineNumber(content, match.index),
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
return exports;
|
|
382
|
+
}
|
|
383
|
+
// ============================================================================
|
|
384
|
+
// PYTHON PARSER
|
|
385
|
+
// ============================================================================
|
|
386
|
+
const PYTHON_BUILTINS = new Set([
|
|
387
|
+
// stdlib modules (Python 3)
|
|
388
|
+
'abc', 'argparse', 'ast', 'asyncio', 'base64', 'builtins', 'cgi', 'cmath',
|
|
389
|
+
'cmd', 'code', 'codecs', 'collections', 'concurrent', 'configparser',
|
|
390
|
+
'contextlib', 'copy', 'csv', 'dataclasses', 'datetime', 'decimal',
|
|
391
|
+
'difflib', 'dis', 'email', 'enum', 'errno', 'fileinput', 'fnmatch',
|
|
392
|
+
'fractions', 'ftplib', 'functools', 'gc', 'getpass', 'gettext', 'glob',
|
|
393
|
+
'gzip', 'hashlib', 'heapq', 'hmac', 'html', 'http', 'imaplib', 'importlib',
|
|
394
|
+
'inspect', 'io', 'ipaddress', 'itertools', 'json', 'keyword', 'linecache',
|
|
395
|
+
'locale', 'logging', 'lzma', 'math', 'mimetypes', 'multiprocessing',
|
|
396
|
+
'numbers', 'operator', 'os', 'pathlib', 'pickle', 'platform', 'pprint',
|
|
397
|
+
'queue', 'random', 're', 'shlex', 'shutil', 'signal', 'smtplib', 'socket',
|
|
398
|
+
'socketserver', 'sqlite3', 'ssl', 'stat', 'statistics', 'string',
|
|
399
|
+
'struct', 'subprocess', 'sys', 'tarfile', 'tempfile', 'textwrap',
|
|
400
|
+
'threading', 'time', 'timeit', 'tkinter', 'token', 'tokenize', 'traceback',
|
|
401
|
+
'types', 'typing', 'unicodedata', 'unittest', 'urllib', 'uuid', 'warnings',
|
|
402
|
+
'weakref', 'xml', 'xmlrpc', 'zipfile', 'zipimport', 'zlib',
|
|
403
|
+
'__future__',
|
|
404
|
+
]);
|
|
405
|
+
/**
|
|
406
|
+
* Parse imports from Python content
|
|
407
|
+
*/
|
|
408
|
+
function parsePythonImports(content) {
|
|
409
|
+
const imports = [];
|
|
410
|
+
// Remove comments and collapse multi-line parenthesized imports onto one line
|
|
411
|
+
// e.g. "from x import (\n A,\n B\n)" → "from x import A, B"
|
|
412
|
+
const cleanContent = content
|
|
413
|
+
.replace(/#.*$/gm, '')
|
|
414
|
+
.replace(/\(\s*([\s\S]*?)\s*\)/g, (_, inner) => inner.replace(/\s*\n\s*/g, ', '));
|
|
415
|
+
let match;
|
|
416
|
+
// import X or import X, Y or import X.Y.Z
|
|
417
|
+
const importRegex = /^import[ \t]+([^\n\r]+)$/gm;
|
|
418
|
+
while ((match = importRegex.exec(cleanContent)) !== null) {
|
|
419
|
+
const modules = match[1].split(',').map(m => m.trim()).filter(Boolean);
|
|
420
|
+
for (const mod of modules) {
|
|
421
|
+
const source = mod.split(/\s+as\s+/)[0].trim();
|
|
422
|
+
imports.push({
|
|
423
|
+
source,
|
|
424
|
+
isRelative: source.startsWith('.'),
|
|
425
|
+
isPackage: !source.startsWith('.'),
|
|
426
|
+
isBuiltin: PYTHON_BUILTINS.has(source.split('.')[0]),
|
|
427
|
+
importedNames: [mod.includes(' as ') ? mod.split(/\s+as\s+/)[1].trim() : source.split('.').pop()],
|
|
428
|
+
hasDefault: false,
|
|
429
|
+
hasNamespace: true,
|
|
430
|
+
isTypeOnly: false,
|
|
431
|
+
isDynamic: false,
|
|
432
|
+
line: getLineNumber(content, match.index),
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
// from X import Y or from X import Y, Z (including multi-line after collapsing)
|
|
437
|
+
const fromImportRegex = /^from\s+([\w.]+)\s+import\s+(.+)$/gm;
|
|
438
|
+
while ((match = fromImportRegex.exec(cleanContent)) !== null) {
|
|
439
|
+
const source = match[1];
|
|
440
|
+
const importsPart = match[2].trim().replace(/[()]/g, '');
|
|
441
|
+
if (importsPart === '*') {
|
|
442
|
+
imports.push({
|
|
443
|
+
source,
|
|
444
|
+
isRelative: source.startsWith('.'),
|
|
445
|
+
isPackage: !source.startsWith('.'),
|
|
446
|
+
isBuiltin: PYTHON_BUILTINS.has(source.split('.')[0]),
|
|
447
|
+
importedNames: ['*'],
|
|
448
|
+
hasDefault: false,
|
|
449
|
+
hasNamespace: true,
|
|
450
|
+
isTypeOnly: false,
|
|
451
|
+
isDynamic: false,
|
|
452
|
+
line: getLineNumber(content, match.index),
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
else {
|
|
456
|
+
const names = importsPart.split(',').map(n => {
|
|
457
|
+
const trimmed = n.trim();
|
|
458
|
+
return trimmed.includes(' as ') ? trimmed.split(/\s+as\s+/)[1].trim() : trimmed;
|
|
459
|
+
}).filter(Boolean);
|
|
460
|
+
imports.push({
|
|
461
|
+
source,
|
|
462
|
+
isRelative: source.startsWith('.'),
|
|
463
|
+
isPackage: !source.startsWith('.'),
|
|
464
|
+
isBuiltin: PYTHON_BUILTINS.has(source.split('.')[0]),
|
|
465
|
+
importedNames: names,
|
|
466
|
+
hasDefault: false,
|
|
467
|
+
hasNamespace: false,
|
|
468
|
+
isTypeOnly: false,
|
|
469
|
+
isDynamic: false,
|
|
470
|
+
line: getLineNumber(content, match.index),
|
|
471
|
+
});
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
return imports;
|
|
475
|
+
}
|
|
476
|
+
/**
|
|
477
|
+
* Parse exports from Python content (module-level definitions)
|
|
478
|
+
*/
|
|
479
|
+
function parsePythonExports(content) {
|
|
480
|
+
const exports = [];
|
|
481
|
+
// Remove comments
|
|
482
|
+
const cleanContent = content.replace(/#.*$/gm, '');
|
|
483
|
+
let match;
|
|
484
|
+
// Check for __all__ definition
|
|
485
|
+
const allMatch = cleanContent.match(/__all__\s*=\s*\[([^\]]+)\]/);
|
|
486
|
+
if (allMatch) {
|
|
487
|
+
const names = allMatch[1].match(/['"](\w+)['"]/g);
|
|
488
|
+
if (names) {
|
|
489
|
+
for (const name of names) {
|
|
490
|
+
const cleanName = name.replace(/['"]/g, '');
|
|
491
|
+
exports.push({
|
|
492
|
+
name: cleanName,
|
|
493
|
+
isDefault: false,
|
|
494
|
+
isType: false,
|
|
495
|
+
isReExport: false,
|
|
496
|
+
kind: 'unknown',
|
|
497
|
+
line: getLineNumber(content, allMatch.index ?? 0),
|
|
498
|
+
});
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
// Class definitions at module level (no indentation)
|
|
503
|
+
const classRegex = /^class\s+(\w+)/gm;
|
|
504
|
+
while ((match = classRegex.exec(cleanContent)) !== null) {
|
|
505
|
+
exports.push({
|
|
506
|
+
name: match[1],
|
|
507
|
+
isDefault: false,
|
|
508
|
+
isType: false,
|
|
509
|
+
isReExport: false,
|
|
510
|
+
kind: 'class',
|
|
511
|
+
line: getLineNumber(content, match.index),
|
|
512
|
+
});
|
|
513
|
+
}
|
|
514
|
+
// Function definitions at module level (no indentation)
|
|
515
|
+
const funcRegex = /^def\s+(\w+)/gm;
|
|
516
|
+
while ((match = funcRegex.exec(cleanContent)) !== null) {
|
|
517
|
+
// Skip private functions
|
|
518
|
+
if (!match[1].startsWith('_')) {
|
|
519
|
+
exports.push({
|
|
520
|
+
name: match[1],
|
|
521
|
+
isDefault: false,
|
|
522
|
+
isType: false,
|
|
523
|
+
isReExport: false,
|
|
524
|
+
kind: 'function',
|
|
525
|
+
line: getLineNumber(content, match.index),
|
|
526
|
+
});
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
// Module-level variables (UPPER_CASE constants)
|
|
530
|
+
const constRegex = /^([A-Z][A-Z0-9_]*)\s*=/gm;
|
|
531
|
+
while ((match = constRegex.exec(cleanContent)) !== null) {
|
|
532
|
+
exports.push({
|
|
533
|
+
name: match[1],
|
|
534
|
+
isDefault: false,
|
|
535
|
+
isType: false,
|
|
536
|
+
isReExport: false,
|
|
537
|
+
kind: 'variable',
|
|
538
|
+
line: getLineNumber(content, match.index),
|
|
539
|
+
});
|
|
540
|
+
}
|
|
541
|
+
return exports;
|
|
542
|
+
}
|
|
543
|
+
// ============================================================================
|
|
544
|
+
// JAVA PARSER
|
|
545
|
+
// ============================================================================
|
|
546
|
+
/** Package prefixes considered JDK/standard-library imports (not project code) */
|
|
547
|
+
const JAVA_BUILTIN_PREFIXES = [
|
|
548
|
+
'java.',
|
|
549
|
+
'javax.',
|
|
550
|
+
'jakarta.',
|
|
551
|
+
'sun.',
|
|
552
|
+
'com.sun.',
|
|
553
|
+
'jdk.',
|
|
554
|
+
'org.w3c.',
|
|
555
|
+
'org.xml.',
|
|
556
|
+
];
|
|
557
|
+
function isJavaBuiltin(source) {
|
|
558
|
+
return JAVA_BUILTIN_PREFIXES.some(p => source.startsWith(p));
|
|
559
|
+
}
|
|
560
|
+
/**
|
|
561
|
+
* Extract the package declaration from Java source content.
|
|
562
|
+
* Returns undefined for files without a package declaration (default package).
|
|
563
|
+
*/
|
|
564
|
+
export function parseJavaPackage(content) {
|
|
565
|
+
// Strip block comments so we don't match inside them.
|
|
566
|
+
const clean = content.replace(/\/\*[\s\S]*?\*\//g, '');
|
|
567
|
+
const match = clean.match(/^\s*package\s+([\w.]+)\s*;/m);
|
|
568
|
+
return match ? match[1] : undefined;
|
|
569
|
+
}
|
|
570
|
+
/**
|
|
571
|
+
* Parse imports from Java source content.
|
|
572
|
+
*
|
|
573
|
+
* Handles:
|
|
574
|
+
* import com.foo.Bar;
|
|
575
|
+
* import com.foo.*; (wildcard — hasNamespace=true)
|
|
576
|
+
* import static com.foo.Bar.baz; (static member import — class is com.foo.Bar)
|
|
577
|
+
* import static com.foo.Bar.*; (static wildcard — class is com.foo.Bar)
|
|
578
|
+
*/
|
|
579
|
+
function parseJavaImports(content) {
|
|
580
|
+
const imports = [];
|
|
581
|
+
// Strip comments to avoid false matches
|
|
582
|
+
const clean = content
|
|
583
|
+
.replace(/\/\*[\s\S]*?\*\//g, '')
|
|
584
|
+
.replace(/\/\/.*$/gm, '');
|
|
585
|
+
const importRegex = /^\s*import\s+(static\s+)?([\w.]+(?:\.\*)?)\s*;/gm;
|
|
586
|
+
let match;
|
|
587
|
+
while ((match = importRegex.exec(clean)) !== null) {
|
|
588
|
+
const isStatic = !!match[1];
|
|
589
|
+
let source = match[2];
|
|
590
|
+
const isWildcard = source.endsWith('.*');
|
|
591
|
+
// For `import static com.foo.Bar.baz;` the member `baz` is not a class —
|
|
592
|
+
// the class we want to link to is `com.foo.Bar`. Strip the trailing
|
|
593
|
+
// lowercase identifier (Java convention: classes start uppercase).
|
|
594
|
+
if (isStatic && !isWildcard) {
|
|
595
|
+
const lastDot = source.lastIndexOf('.');
|
|
596
|
+
if (lastDot > 0) {
|
|
597
|
+
const last = source.slice(lastDot + 1);
|
|
598
|
+
if (/^[a-z_$]/.test(last)) {
|
|
599
|
+
source = source.slice(0, lastDot);
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
// For `import static com.foo.Bar.*;` strip the `.*` — we still want to
|
|
604
|
+
// resolve `com.foo.Bar` (the class), not `com.foo` (the package).
|
|
605
|
+
if (isStatic && isWildcard) {
|
|
606
|
+
source = source.slice(0, -2);
|
|
607
|
+
}
|
|
608
|
+
const cleanSource = isWildcard && !isStatic ? source.slice(0, -2) : source;
|
|
609
|
+
const isBuiltin = isJavaBuiltin(cleanSource);
|
|
610
|
+
const displayName = isWildcard && !isStatic
|
|
611
|
+
? '*'
|
|
612
|
+
: cleanSource.slice(cleanSource.lastIndexOf('.') + 1);
|
|
613
|
+
imports.push({
|
|
614
|
+
source,
|
|
615
|
+
isRelative: false,
|
|
616
|
+
isPackage: !isBuiltin,
|
|
617
|
+
isBuiltin,
|
|
618
|
+
importedNames: [displayName],
|
|
619
|
+
hasDefault: false,
|
|
620
|
+
hasNamespace: isWildcard && !isStatic,
|
|
621
|
+
isTypeOnly: false,
|
|
622
|
+
isDynamic: false,
|
|
623
|
+
line: getLineNumber(content, match.index),
|
|
624
|
+
});
|
|
625
|
+
}
|
|
626
|
+
return imports;
|
|
627
|
+
}
|
|
628
|
+
/**
|
|
629
|
+
* Parse exports from Java source content.
|
|
630
|
+
*
|
|
631
|
+
* "Exports" in Java are public top-level types: classes, interfaces,
|
|
632
|
+
* enums, records, and annotations. Also includes public static methods
|
|
633
|
+
* and public fields on those types since downstream mapping uses
|
|
634
|
+
* function-level exports to connect requirements to code.
|
|
635
|
+
*/
|
|
636
|
+
function parseJavaExports(content) {
|
|
637
|
+
const exports = [];
|
|
638
|
+
const clean = content
|
|
639
|
+
.replace(/\/\*[\s\S]*?\*\//g, '')
|
|
640
|
+
.replace(/\/\/.*$/gm, '');
|
|
641
|
+
let match;
|
|
642
|
+
// public class|interface|enum|record|@interface Name
|
|
643
|
+
const typeRegex = /\bpublic\s+(?:static\s+|final\s+|abstract\s+|sealed\s+|non-sealed\s+)*(class|interface|enum|record|@interface)\s+(\w+)/g;
|
|
644
|
+
while ((match = typeRegex.exec(clean)) !== null) {
|
|
645
|
+
const keyword = match[1];
|
|
646
|
+
const name = match[2];
|
|
647
|
+
const kind = keyword === 'interface' || keyword === '@interface' ? 'interface'
|
|
648
|
+
: keyword === 'enum' ? 'enum'
|
|
649
|
+
: 'class';
|
|
650
|
+
exports.push({
|
|
651
|
+
name,
|
|
652
|
+
isDefault: false,
|
|
653
|
+
isType: false,
|
|
654
|
+
isReExport: false,
|
|
655
|
+
kind,
|
|
656
|
+
line: getLineNumber(content, match.index),
|
|
657
|
+
});
|
|
658
|
+
}
|
|
659
|
+
// Public methods: `public [static] [final] ReturnType name(`
|
|
660
|
+
// We keep this conservative: only methods with an explicit `public` modifier.
|
|
661
|
+
// The return-type capture is non-greedy and excludes keywords that start
|
|
662
|
+
// type declarations (class/interface/enum/record) to avoid false matches.
|
|
663
|
+
const methodRegex = /\bpublic\s+(?:static\s+|final\s+|abstract\s+|synchronized\s+|default\s+|native\s+)*(?!class\b|interface\b|enum\b|record\b|@interface\b)(?:<[^>]+>\s+)?[\w<>[\], ?.]+?\s+(\w+)\s*\(/g;
|
|
664
|
+
while ((match = methodRegex.exec(clean)) !== null) {
|
|
665
|
+
const name = match[1];
|
|
666
|
+
// Filter obvious non-methods (the regex can match some constructors or
|
|
667
|
+
// edge cases; keep common false-positives out).
|
|
668
|
+
if (['class', 'interface', 'enum', 'record', 'new', 'return', 'if', 'for', 'while'].includes(name))
|
|
669
|
+
continue;
|
|
670
|
+
exports.push({
|
|
671
|
+
name,
|
|
672
|
+
isDefault: false,
|
|
673
|
+
isType: false,
|
|
674
|
+
isReExport: false,
|
|
675
|
+
kind: 'function',
|
|
676
|
+
line: getLineNumber(content, match.index),
|
|
677
|
+
});
|
|
678
|
+
}
|
|
679
|
+
return exports;
|
|
680
|
+
}
|
|
681
|
+
// ============================================================================
|
|
682
|
+
// IMPORT RESOLUTION
|
|
683
|
+
// ============================================================================
|
|
684
|
+
/**
|
|
685
|
+
* Resolve a relative import to an absolute file path
|
|
686
|
+
*/
|
|
687
|
+
export async function resolveImport(importSource, fromFile, options) {
|
|
688
|
+
const fromExt = extname(fromFile).toLowerCase();
|
|
689
|
+
const isPython = fromExt === '.py' || fromExt === '.pyw';
|
|
690
|
+
const isJava = fromExt === '.java';
|
|
691
|
+
// Java imports are always absolute class FQNs (com.foo.Bar), never relative.
|
|
692
|
+
// Resolve them against the computed source root (dir minus packagePath).
|
|
693
|
+
if (isJava) {
|
|
694
|
+
return resolveJavaImport(importSource, fromFile, options);
|
|
695
|
+
}
|
|
696
|
+
// For non-Python files, external packages can never resolve to a local file.
|
|
697
|
+
// For Python files we must NOT bail out here: `from services.retriever import X`
|
|
698
|
+
// looks like a package import but may well be a local module under rootDir.
|
|
699
|
+
if (!isRelativeImport(importSource) && !isPython) {
|
|
700
|
+
return null;
|
|
701
|
+
}
|
|
702
|
+
const fromDir = dirname(fromFile);
|
|
703
|
+
// Default extensions depend on the source file type
|
|
704
|
+
const extensions = options.extensions ?? (isPython
|
|
705
|
+
? ['.py', '.pyw']
|
|
706
|
+
: ['.ts', '.tsx', '.js', '.jsx', '.mjs', '.cjs']);
|
|
707
|
+
// Python relative imports use dot-prefix notation:
|
|
708
|
+
// from .utils import foo → source = ".utils" → resolve as "./utils"
|
|
709
|
+
// from ..models import X → source = "..models" → resolve as "../models"
|
|
710
|
+
// from ...pkg import Y → source = "...pkg" → resolve as "../../pkg"
|
|
711
|
+
// N dots = (N-1) levels up from fromDir. Also handles dotted paths: .db.models → ./db/models
|
|
712
|
+
let normalizedSource = importSource;
|
|
713
|
+
if (isPython && importSource.startsWith('.')) {
|
|
714
|
+
let dots = 0;
|
|
715
|
+
while (dots < importSource.length && importSource[dots] === '.')
|
|
716
|
+
dots++;
|
|
717
|
+
const rest = importSource.slice(dots).replace(/\./g, '/');
|
|
718
|
+
// dots=1 → './', dots=2 → '../', dots=3 → '../../', etc.
|
|
719
|
+
const prefix = dots === 1 ? './' : '../'.repeat(dots - 1);
|
|
720
|
+
normalizedSource = rest ? prefix + rest : prefix.replace(/\/$/, '') || '.';
|
|
721
|
+
}
|
|
722
|
+
else if (isPython && !importSource.startsWith('.')) {
|
|
723
|
+
// Absolute-style intra-project import: "services.retriever" or "services.retriever.utils"
|
|
724
|
+
// Convert dotted module path to a filesystem path relative to rootDir.
|
|
725
|
+
// e.g. "services.retriever" → "<rootDir>/services/retriever.py"
|
|
726
|
+
normalizedSource = './' + importSource.replace(/\./g, '/');
|
|
727
|
+
}
|
|
728
|
+
// For Python absolute imports resolve from rootDir, not fromDir,
|
|
729
|
+
// because Python's module system uses sys.path (typically the project root).
|
|
730
|
+
// Fall back to fromDir if baseDir is empty to avoid resolving against cwd.
|
|
731
|
+
const resolveBase = (isPython && !importSource.startsWith('.'))
|
|
732
|
+
? (options.baseDir || fromDir)
|
|
733
|
+
: fromDir;
|
|
734
|
+
const basePath = resolve(resolveBase, normalizedSource);
|
|
735
|
+
// Strip any existing extension from the import source.
|
|
736
|
+
// This handles the TypeScript NodeNext convention where imports are written
|
|
737
|
+
// as `./foo.js` but the actual file on disk is `./foo.ts`.
|
|
738
|
+
// Without this, we'd try `foo.js.ts`, `foo.js.tsx`, etc. and find nothing.
|
|
739
|
+
const existingExt = extname(basePath); // e.g. ".js", ".ts", ""
|
|
740
|
+
const baseWithoutExt = existingExt
|
|
741
|
+
? basePath.slice(0, -existingExt.length)
|
|
742
|
+
: basePath;
|
|
743
|
+
// Build candidate list (order matters: most specific first):
|
|
744
|
+
// 1. Exact path as-is (the import may already point to the real file)
|
|
745
|
+
// 2. Strip the extension, try every known extension (handles .js -> .ts)
|
|
746
|
+
// 3. Directory index files (handles `./components` -> `./components/index.ts`)
|
|
747
|
+
// 4. Python packages: module/__init__.py
|
|
748
|
+
const candidates = [
|
|
749
|
+
basePath,
|
|
750
|
+
...extensions.map(ext => baseWithoutExt + ext),
|
|
751
|
+
...extensions.map(ext => join(basePath, `index${ext}`)),
|
|
752
|
+
...extensions.map(ext => join(baseWithoutExt, `index${ext}`)),
|
|
753
|
+
...(isPython ? extensions.map(ext => join(basePath, `__init__${ext}`)) : []),
|
|
754
|
+
];
|
|
755
|
+
// Deduplicate while preserving order
|
|
756
|
+
const seen = new Set();
|
|
757
|
+
for (const candidate of candidates) {
|
|
758
|
+
if (seen.has(candidate))
|
|
759
|
+
continue;
|
|
760
|
+
seen.add(candidate);
|
|
761
|
+
try {
|
|
762
|
+
await readFile(candidate);
|
|
763
|
+
return candidate;
|
|
764
|
+
}
|
|
765
|
+
catch {
|
|
766
|
+
// Not found, try next
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
return null;
|
|
770
|
+
}
|
|
771
|
+
/**
|
|
772
|
+
* Resolve a Java import (fully-qualified class name) to an absolute file path.
|
|
773
|
+
*
|
|
774
|
+
* Java imports are always absolute: `import com.example.foo.Bar;`
|
|
775
|
+
* To find `com/example/foo/Bar.java`, we compute the "source root" by
|
|
776
|
+
* stripping the file's package path from its directory. E.g. for
|
|
777
|
+
* /repo/src/main/java/com/example/service/UserService.java
|
|
778
|
+
* package com.example.service;
|
|
779
|
+
* the source root is /repo/src/main/java.
|
|
780
|
+
*
|
|
781
|
+
* If the package declaration is missing or doesn't match the directory
|
|
782
|
+
* structure, fall back to walking the file's ancestors looking for a
|
|
783
|
+
* conventional source root (src/main/java, src/test/java, src, app).
|
|
784
|
+
*/
|
|
785
|
+
async function resolveJavaImport(importSource, fromFile, options) {
|
|
786
|
+
if (isJavaBuiltin(importSource))
|
|
787
|
+
return null;
|
|
788
|
+
// Wildcard non-static import (`import com.foo.*;`) cannot be resolved to a
|
|
789
|
+
// specific file.
|
|
790
|
+
if (importSource.endsWith('.*'))
|
|
791
|
+
return null;
|
|
792
|
+
const fromDir = dirname(fromFile);
|
|
793
|
+
const candidateRoots = [];
|
|
794
|
+
// Primary strategy: strip the package path from fromDir.
|
|
795
|
+
if (options.sourcePackage) {
|
|
796
|
+
const pkgPath = options.sourcePackage.replace(/\./g, '/');
|
|
797
|
+
// Normalize separators for comparison (Windows may have backslashes).
|
|
798
|
+
const normalizedDir = fromDir.replace(/\\/g, '/');
|
|
799
|
+
if (normalizedDir.endsWith('/' + pkgPath)) {
|
|
800
|
+
candidateRoots.push(fromDir.slice(0, fromDir.length - pkgPath.length - 1));
|
|
801
|
+
}
|
|
802
|
+
else if (normalizedDir === pkgPath || normalizedDir.endsWith(pkgPath)) {
|
|
803
|
+
candidateRoots.push(fromDir.slice(0, fromDir.length - pkgPath.length));
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
// Fallback: walk up the directory tree looking for conventional Java source
|
|
807
|
+
// roots. Covers default-package files and inconsistent package declarations.
|
|
808
|
+
const conventional = ['src/main/java', 'src/test/java', 'src/main/kotlin', 'src/test/kotlin', 'src', 'app'];
|
|
809
|
+
for (const marker of conventional) {
|
|
810
|
+
const normalizedFrom = fromFile.replace(/\\/g, '/');
|
|
811
|
+
const idx = normalizedFrom.lastIndexOf('/' + marker + '/');
|
|
812
|
+
if (idx >= 0) {
|
|
813
|
+
candidateRoots.push(fromFile.slice(0, idx + 1 + marker.length));
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
// Last resort: baseDir (project root).
|
|
817
|
+
if (options.baseDir) {
|
|
818
|
+
candidateRoots.push(options.baseDir);
|
|
819
|
+
}
|
|
820
|
+
// Deduplicate while preserving order.
|
|
821
|
+
const seen = new Set();
|
|
822
|
+
const relPath = importSource.replace(/\./g, '/') + '.java';
|
|
823
|
+
for (const root of candidateRoots) {
|
|
824
|
+
if (!root || seen.has(root))
|
|
825
|
+
continue;
|
|
826
|
+
seen.add(root);
|
|
827
|
+
const candidate = join(root, relPath);
|
|
828
|
+
try {
|
|
829
|
+
await readFile(candidate);
|
|
830
|
+
return candidate;
|
|
831
|
+
}
|
|
832
|
+
catch {
|
|
833
|
+
// try next root
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
return null;
|
|
837
|
+
}
|
|
838
|
+
// ============================================================================
|
|
839
|
+
// MAIN PARSER CLASS
|
|
840
|
+
// ============================================================================
|
|
841
|
+
/**
|
|
842
|
+
* Import/Export Parser
|
|
843
|
+
*/
|
|
844
|
+
export class ImportExportParser {
|
|
845
|
+
cache = new Map();
|
|
846
|
+
/**
|
|
847
|
+
* Clear the parse cache
|
|
848
|
+
*/
|
|
849
|
+
clearCache() {
|
|
850
|
+
this.cache.clear();
|
|
851
|
+
}
|
|
852
|
+
/**
|
|
853
|
+
* Get file extension type
|
|
854
|
+
*/
|
|
855
|
+
getFileType(filePath) {
|
|
856
|
+
const ext = extname(filePath).toLowerCase();
|
|
857
|
+
if (['.ts', '.tsx', '.mts', '.cts'].includes(ext))
|
|
858
|
+
return 'ts';
|
|
859
|
+
if (['.js', '.jsx', '.mjs', '.cjs'].includes(ext))
|
|
860
|
+
return 'js';
|
|
861
|
+
if (['.py', '.pyw'].includes(ext))
|
|
862
|
+
return 'python';
|
|
863
|
+
if (ext === '.java')
|
|
864
|
+
return 'java';
|
|
865
|
+
return 'unknown';
|
|
866
|
+
}
|
|
867
|
+
/**
|
|
868
|
+
* Parse a file and extract imports/exports
|
|
869
|
+
*/
|
|
870
|
+
async parseFile(filePath) {
|
|
871
|
+
// Check cache
|
|
872
|
+
const cached = this.cache.get(filePath);
|
|
873
|
+
if (cached) {
|
|
874
|
+
return cached;
|
|
875
|
+
}
|
|
876
|
+
const analysis = {
|
|
877
|
+
filePath,
|
|
878
|
+
imports: [],
|
|
879
|
+
exports: [],
|
|
880
|
+
localImports: [],
|
|
881
|
+
externalImports: [],
|
|
882
|
+
parseErrors: [],
|
|
883
|
+
};
|
|
884
|
+
try {
|
|
885
|
+
const content = await readFile(filePath, 'utf-8');
|
|
886
|
+
const fileType = this.getFileType(filePath);
|
|
887
|
+
if (fileType === 'js' || fileType === 'ts') {
|
|
888
|
+
analysis.imports = parseJSImports(content);
|
|
889
|
+
analysis.exports = parseJSExports(content);
|
|
890
|
+
}
|
|
891
|
+
else if (fileType === 'python') {
|
|
892
|
+
analysis.imports = parsePythonImports(content);
|
|
893
|
+
analysis.exports = parsePythonExports(content);
|
|
894
|
+
}
|
|
895
|
+
else if (fileType === 'java') {
|
|
896
|
+
analysis.imports = parseJavaImports(content);
|
|
897
|
+
analysis.exports = parseJavaExports(content);
|
|
898
|
+
analysis.javaPackage = parseJavaPackage(content);
|
|
899
|
+
}
|
|
900
|
+
else {
|
|
901
|
+
analysis.parseErrors.push(`Unsupported file type: ${extname(filePath)}`);
|
|
902
|
+
}
|
|
903
|
+
// Categorize imports
|
|
904
|
+
for (const imp of analysis.imports) {
|
|
905
|
+
if (imp.isRelative) {
|
|
906
|
+
analysis.localImports.push(imp.source);
|
|
907
|
+
}
|
|
908
|
+
else if (imp.isPackage) {
|
|
909
|
+
// Extract package name (first part of path)
|
|
910
|
+
const pkgName = imp.source.startsWith('@')
|
|
911
|
+
? imp.source.split('/').slice(0, 2).join('/')
|
|
912
|
+
: imp.source.split('/')[0];
|
|
913
|
+
if (!analysis.externalImports.includes(pkgName)) {
|
|
914
|
+
analysis.externalImports.push(pkgName);
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
catch (error) {
|
|
920
|
+
analysis.parseErrors.push(`Failed to read file: ${error.message}`);
|
|
921
|
+
}
|
|
922
|
+
// Cache the result
|
|
923
|
+
this.cache.set(filePath, analysis);
|
|
924
|
+
return analysis;
|
|
925
|
+
}
|
|
926
|
+
/**
|
|
927
|
+
* Parse multiple files
|
|
928
|
+
*/
|
|
929
|
+
async parseFiles(filePaths) {
|
|
930
|
+
const results = new Map();
|
|
931
|
+
for (const filePath of filePaths) {
|
|
932
|
+
const analysis = await this.parseFile(filePath);
|
|
933
|
+
results.set(filePath, analysis);
|
|
934
|
+
}
|
|
935
|
+
return results;
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
/**
|
|
939
|
+
* Convenience function to parse a single file
|
|
940
|
+
*/
|
|
941
|
+
export async function parseFile(filePath) {
|
|
942
|
+
const parser = new ImportExportParser();
|
|
943
|
+
return parser.parseFile(filePath);
|
|
944
|
+
}
|
|
945
|
+
/**
|
|
946
|
+
* Convenience function to parse multiple files
|
|
947
|
+
*/
|
|
948
|
+
export async function parseFiles(filePaths) {
|
|
949
|
+
const parser = new ImportExportParser();
|
|
950
|
+
return parser.parseFiles(filePaths);
|
|
951
|
+
}
|
|
952
|
+
//# sourceMappingURL=import-parser.js.map
|