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,675 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Signature Extractor
|
|
3
|
+
*
|
|
4
|
+
* Extracts function/class signatures and docstrings from source files
|
|
5
|
+
* across multiple languages using regex patterns (no AST required).
|
|
6
|
+
*
|
|
7
|
+
* Used to build a compact semantic index of all project files for Stage 1,
|
|
8
|
+
* replacing the simple file-path list with language-aware summaries.
|
|
9
|
+
*/
|
|
10
|
+
// Max signatures per file to keep output compact
|
|
11
|
+
const MAX_SIGS_PER_FILE = 25;
|
|
12
|
+
// Max chars per Stage 1 chunk (~10k tokens, safe for all providers)
|
|
13
|
+
export const STAGE1_MAX_CHARS = 40_000;
|
|
14
|
+
// ============================================================================
|
|
15
|
+
// LANGUAGE DETECTION
|
|
16
|
+
// ============================================================================
|
|
17
|
+
export function detectLanguage(filePath) {
|
|
18
|
+
const ext = filePath.split('.').pop()?.toLowerCase() ?? '';
|
|
19
|
+
switch (ext) {
|
|
20
|
+
case 'py': return 'Python';
|
|
21
|
+
case 'ts':
|
|
22
|
+
case 'tsx': return 'TypeScript';
|
|
23
|
+
case 'js':
|
|
24
|
+
case 'jsx': return 'JavaScript';
|
|
25
|
+
case 'go': return 'Go';
|
|
26
|
+
case 'rs': return 'Rust';
|
|
27
|
+
case 'rb': return 'Ruby';
|
|
28
|
+
case 'java': return 'Java';
|
|
29
|
+
case 'kt': return 'Kotlin';
|
|
30
|
+
case 'php': return 'PHP';
|
|
31
|
+
case 'cs': return 'C#';
|
|
32
|
+
case 'cpp':
|
|
33
|
+
case 'cc':
|
|
34
|
+
case 'cxx':
|
|
35
|
+
case 'h':
|
|
36
|
+
case 'hpp': return 'C++';
|
|
37
|
+
case 'c': return 'C';
|
|
38
|
+
case 'swift': return 'Swift';
|
|
39
|
+
default: return 'unknown';
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
// ============================================================================
|
|
43
|
+
// PYTHON EXTRACTOR
|
|
44
|
+
// ============================================================================
|
|
45
|
+
function extractPython(content) {
|
|
46
|
+
const entries = [];
|
|
47
|
+
const lines = content.split('\n');
|
|
48
|
+
let pendingDecorator;
|
|
49
|
+
let currentClass;
|
|
50
|
+
let currentClassIndent = -1;
|
|
51
|
+
for (let i = 0; i < lines.length && entries.length < MAX_SIGS_PER_FILE; i++) {
|
|
52
|
+
const line = lines[i];
|
|
53
|
+
const trimmed = line.trimStart();
|
|
54
|
+
const indent = line.length - trimmed.length;
|
|
55
|
+
// Track class context (methods vs module-level functions)
|
|
56
|
+
if (indent === 0 && currentClass && indent <= currentClassIndent) {
|
|
57
|
+
currentClass = undefined;
|
|
58
|
+
currentClassIndent = -1;
|
|
59
|
+
}
|
|
60
|
+
// Decorator lines
|
|
61
|
+
const decoratorMatch = trimmed.match(/^(@(?:[\w.]+)(?:\([^)]*\))?)/);
|
|
62
|
+
if (decoratorMatch) {
|
|
63
|
+
pendingDecorator = decoratorMatch[1];
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
// Class declaration
|
|
67
|
+
const classMatch = trimmed.match(/^class\s+(\w+)(?:\s*\(([^)]*)\))?\s*:/);
|
|
68
|
+
if (classMatch && indent === 0) {
|
|
69
|
+
const name = classMatch[1];
|
|
70
|
+
const bases = classMatch[2] ? `(${classMatch[2]})` : '';
|
|
71
|
+
const docstring = extractPythonDocstring(lines, i + 1);
|
|
72
|
+
entries.push({
|
|
73
|
+
kind: 'class',
|
|
74
|
+
name,
|
|
75
|
+
signature: `class ${name}${bases}:`,
|
|
76
|
+
docstring,
|
|
77
|
+
});
|
|
78
|
+
currentClass = name;
|
|
79
|
+
currentClassIndent = indent;
|
|
80
|
+
pendingDecorator = undefined;
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
// Function / method declaration
|
|
84
|
+
const funcMatch = trimmed.match(/^(async\s+)?def\s+(\w+)\s*\(([^)]*)\)(?:\s*->\s*([^\n:]+))?\s*:/);
|
|
85
|
+
if (funcMatch) {
|
|
86
|
+
const isAsync = !!funcMatch[1];
|
|
87
|
+
const name = funcMatch[2];
|
|
88
|
+
const params = funcMatch[3].trim();
|
|
89
|
+
const ret = funcMatch[4]?.trim() ?? '';
|
|
90
|
+
// Skip private methods (leading underscore) unless very few entries so far
|
|
91
|
+
if (name.startsWith('_') && name !== '__init__' && entries.length > 2) {
|
|
92
|
+
pendingDecorator = undefined;
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
const asyncPrefix = isAsync ? 'async ' : '';
|
|
96
|
+
const returnSuffix = ret ? ` -> ${ret}` : '';
|
|
97
|
+
// Compact params: remove 'self' from display
|
|
98
|
+
const displayParams = params
|
|
99
|
+
.split(',')
|
|
100
|
+
.map(p => p.trim())
|
|
101
|
+
.filter(p => p !== 'self' && p !== 'cls')
|
|
102
|
+
.join(', ');
|
|
103
|
+
const sig = `${asyncPrefix}def ${name}(${displayParams})${returnSuffix}`;
|
|
104
|
+
const docstring = extractPythonDocstring(lines, i + 1);
|
|
105
|
+
const kind = indent > 0 ? 'method' : 'function';
|
|
106
|
+
entries.push({
|
|
107
|
+
kind,
|
|
108
|
+
name,
|
|
109
|
+
signature: (indent > 0 ? ' ' : '') + sig,
|
|
110
|
+
docstring,
|
|
111
|
+
decorator: pendingDecorator,
|
|
112
|
+
});
|
|
113
|
+
pendingDecorator = undefined;
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
// Module-level ALL_CAPS constants (PEP 8 convention), only at indent 0 and outside class
|
|
117
|
+
const constMatch = indent === 0 && !currentClass
|
|
118
|
+
? trimmed.match(/^([A-Z][A-Z0-9_]{1,})\s*(?::\s*[\w[\], |]+)?\s*=/)
|
|
119
|
+
: null;
|
|
120
|
+
if (constMatch) {
|
|
121
|
+
const name = constMatch[1];
|
|
122
|
+
const sig = trimmed.slice(0, 80).replace(/\s+/g, ' ');
|
|
123
|
+
// Use preceding # comment as docstring
|
|
124
|
+
const comment = lines[i - 1]?.trim().startsWith('#')
|
|
125
|
+
? lines[i - 1].trim().slice(1).trim()
|
|
126
|
+
: undefined;
|
|
127
|
+
entries.push({ kind: 'const', name, signature: sig, docstring: comment });
|
|
128
|
+
pendingDecorator = undefined;
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
// Reset decorator if line is neither decorator nor def/class
|
|
132
|
+
if (trimmed && !trimmed.startsWith('#')) {
|
|
133
|
+
pendingDecorator = undefined;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return entries;
|
|
137
|
+
}
|
|
138
|
+
function extractPythonDocstring(lines, startIdx) {
|
|
139
|
+
const next = lines[startIdx]?.trimStart() ?? '';
|
|
140
|
+
if (next.startsWith('"""') || next.startsWith("'''")) {
|
|
141
|
+
const quote = next.startsWith('"""') ? '"""' : "'''";
|
|
142
|
+
const inner = next.slice(3);
|
|
143
|
+
// Single-line docstring: """Text"""
|
|
144
|
+
if (inner.includes(quote)) {
|
|
145
|
+
return inner.slice(0, inner.indexOf(quote)).trim() || undefined;
|
|
146
|
+
}
|
|
147
|
+
// Multi-line: take the first non-empty line
|
|
148
|
+
return inner.trim() || lines[startIdx + 1]?.trim() || undefined;
|
|
149
|
+
}
|
|
150
|
+
return undefined;
|
|
151
|
+
}
|
|
152
|
+
// ============================================================================
|
|
153
|
+
// TYPESCRIPT / JAVASCRIPT EXTRACTOR
|
|
154
|
+
// ============================================================================
|
|
155
|
+
function extractTypeScript(content) {
|
|
156
|
+
const entries = [];
|
|
157
|
+
const lines = content.split('\n');
|
|
158
|
+
for (let i = 0; i < lines.length && entries.length < MAX_SIGS_PER_FILE; i++) {
|
|
159
|
+
const line = lines[i];
|
|
160
|
+
const trimmed = line.trimStart();
|
|
161
|
+
// Collect JSDoc comment above the declaration
|
|
162
|
+
let jsDoc;
|
|
163
|
+
if (i > 0) {
|
|
164
|
+
jsDoc = extractJSDoc(lines, i);
|
|
165
|
+
}
|
|
166
|
+
// export class / export abstract class
|
|
167
|
+
const classMatch = trimmed.match(/^export\s+(?:default\s+)?(?:abstract\s+)?class\s+(\w+)(?:\s+extends\s+([\w<>, .]+?))?(?:\s+implements\s+[\w<>, .]+)?\s*\{?/);
|
|
168
|
+
if (classMatch) {
|
|
169
|
+
const name = classMatch[1];
|
|
170
|
+
const ext = classMatch[2] ? ` extends ${classMatch[2].trim()}` : '';
|
|
171
|
+
entries.push({ kind: 'class', name, signature: `export class ${name}${ext}`, docstring: jsDoc });
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
// export interface
|
|
175
|
+
const ifaceMatch = trimmed.match(/^export\s+(?:default\s+)?interface\s+(\w+)(?:\s+extends\s+[\w<>, .]+)?\s*\{?/);
|
|
176
|
+
if (ifaceMatch) {
|
|
177
|
+
entries.push({ kind: 'interface', name: ifaceMatch[1], signature: `export interface ${ifaceMatch[1]}`, docstring: jsDoc });
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
// export type
|
|
181
|
+
const typeMatch = trimmed.match(/^export\s+type\s+(\w+)\s*(?:<[^>]*>)?\s*=/);
|
|
182
|
+
if (typeMatch) {
|
|
183
|
+
entries.push({ kind: 'type', name: typeMatch[1], signature: `export type ${typeMatch[1]}`, docstring: jsDoc });
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
186
|
+
// export function / export async function / export default function
|
|
187
|
+
const fnMatch = trimmed.match(/^export\s+(?:default\s+)?(?:async\s+)?function\s+(\w+)\s*(?:<[^>]*>)?\s*\(([^)]*)\)(?:\s*:\s*([^{]+))?/);
|
|
188
|
+
if (fnMatch) {
|
|
189
|
+
const name = fnMatch[1];
|
|
190
|
+
const params = compactParams(fnMatch[2]);
|
|
191
|
+
const ret = fnMatch[3]?.trim().replace(/\s+/g, ' ') ?? '';
|
|
192
|
+
const sig = `export function ${name}(${params})${ret ? ': ' + ret : ''}`;
|
|
193
|
+
entries.push({ kind: 'function', name, signature: sig, docstring: jsDoc });
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
196
|
+
// Multi-line export function: `export [async] function name(` with params on following lines
|
|
197
|
+
const fnOpenMatch = trimmed.match(/^export\s+(?:default\s+)?(?:async\s+)?function\s+(\w+)\s*(?:<[^>]*>)?\s*\($/);
|
|
198
|
+
if (fnOpenMatch) {
|
|
199
|
+
const name = fnOpenMatch[1];
|
|
200
|
+
// Scan forward to collect params until closing paren
|
|
201
|
+
let parenDepth = 1;
|
|
202
|
+
const paramLines = [];
|
|
203
|
+
let retType = '';
|
|
204
|
+
let j = i + 1;
|
|
205
|
+
for (; j < lines.length && parenDepth > 0; j++) {
|
|
206
|
+
const jl = lines[j];
|
|
207
|
+
for (const ch of jl) {
|
|
208
|
+
if (ch === '(')
|
|
209
|
+
parenDepth++;
|
|
210
|
+
else if (ch === ')') {
|
|
211
|
+
parenDepth--;
|
|
212
|
+
if (parenDepth === 0)
|
|
213
|
+
break;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
if (parenDepth > 0)
|
|
217
|
+
paramLines.push(jl.trim().replace(/,$/, ''));
|
|
218
|
+
}
|
|
219
|
+
// Try to get return type from the line after closing paren (e.g. `): Promise<T> {`)
|
|
220
|
+
if (j < lines.length) {
|
|
221
|
+
const retMatch = lines[j].match(/\)\s*:\s*([^{]+)/);
|
|
222
|
+
if (retMatch)
|
|
223
|
+
retType = retMatch[1].trim().replace(/\s+/g, ' ');
|
|
224
|
+
}
|
|
225
|
+
const params = paramLines.map(p => p.split(':')[0].trim()).filter(Boolean).join(', ');
|
|
226
|
+
const sig = `export function ${name}(${params})${retType ? ': ' + retType : ''}`;
|
|
227
|
+
entries.push({ kind: 'function', name, signature: sig, docstring: jsDoc });
|
|
228
|
+
continue;
|
|
229
|
+
}
|
|
230
|
+
// export const foo = (...) => / export const foo: Type = (...)
|
|
231
|
+
const arrowMatch = trimmed.match(/^export\s+const\s+(\w+)(?:\s*:\s*[\w<>[\], |&]+)?\s*=\s*(?:async\s+)?\(/);
|
|
232
|
+
if (arrowMatch) {
|
|
233
|
+
entries.push({ kind: 'function', name: arrowMatch[1], signature: `export const ${arrowMatch[1]} = (...)`, docstring: jsDoc });
|
|
234
|
+
continue;
|
|
235
|
+
}
|
|
236
|
+
// export const FOO = { ... } / [...] / primitive — objects, arrays, config constants
|
|
237
|
+
const constMatch = trimmed.match(/^export\s+const\s+(\w+)/);
|
|
238
|
+
if (constMatch) {
|
|
239
|
+
const sig = trimmed.slice(0, 80).replace(/\s+/g, ' ');
|
|
240
|
+
entries.push({ kind: 'const', name: constMatch[1], signature: sig, docstring: jsDoc });
|
|
241
|
+
continue;
|
|
242
|
+
}
|
|
243
|
+
// Public/private class methods (indented, not '#' private fields) — single-line params
|
|
244
|
+
// Private methods with JSDoc are included: they're documented because the impl is worth finding.
|
|
245
|
+
const methodMatch = trimmed.match(/^(?:public\s+|static\s+|override\s+|async\s+|private\s+|protected\s+)*(?:public\s+|private\s+|protected\s+)?(?:static\s+)?(?:async\s+)?(\w+)\s*\(([^)]*)\)(?:\s*:\s*([^{]+))?.*\{/);
|
|
246
|
+
if (methodMatch && line.startsWith(' ') && !trimmed.startsWith('//') && !trimmed.startsWith('*') && !trimmed.startsWith('#')) {
|
|
247
|
+
const name = methodMatch[1];
|
|
248
|
+
if (/^[a-z]/.test(name) && name !== 'if' && name !== 'for' && name !== 'while' && name !== 'switch' && name !== 'return') {
|
|
249
|
+
const params = compactParams(methodMatch[2]);
|
|
250
|
+
const ret = methodMatch[3]?.trim().replace(/\s+/g, ' ') ?? '';
|
|
251
|
+
entries.push({ kind: 'method', name, signature: ` ${name}(${params})${ret ? ': ' + ret : ''}`, docstring: jsDoc });
|
|
252
|
+
continue;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
// Multi-line class method: `[static] [async] methodName(` with no closing paren on same line
|
|
256
|
+
const methodOpenMatch = trimmed.match(/^(?:public\s+|static\s+|override\s+|async\s+|private\s+|protected\s+)*(?:public\s+|private\s+|protected\s+)?(?:static\s+)?(?:async\s+)?(\w+)\s*\($/);
|
|
257
|
+
if (methodOpenMatch && line.startsWith(' ') && !trimmed.startsWith('//') && !trimmed.startsWith('*') && !trimmed.startsWith('#')) {
|
|
258
|
+
const name = methodOpenMatch[1];
|
|
259
|
+
if (/^[a-z]/.test(name) && name !== 'if' && name !== 'for' && name !== 'while' && name !== 'switch' && name !== 'return') {
|
|
260
|
+
let parenDepth = 1;
|
|
261
|
+
const paramLines = [];
|
|
262
|
+
let retType = '';
|
|
263
|
+
let j = i + 1;
|
|
264
|
+
for (; j < lines.length && parenDepth > 0; j++) {
|
|
265
|
+
const jl = lines[j];
|
|
266
|
+
for (const ch of jl) {
|
|
267
|
+
if (ch === '(')
|
|
268
|
+
parenDepth++;
|
|
269
|
+
else if (ch === ')') {
|
|
270
|
+
parenDepth--;
|
|
271
|
+
if (parenDepth === 0)
|
|
272
|
+
break;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
if (parenDepth > 0)
|
|
276
|
+
paramLines.push(jl.trim().replace(/,$/, ''));
|
|
277
|
+
}
|
|
278
|
+
if (j < lines.length) {
|
|
279
|
+
const retMatch = lines[j].match(/\)\s*:\s*([^{]+)/);
|
|
280
|
+
if (retMatch)
|
|
281
|
+
retType = retMatch[1].trim().replace(/\s+/g, ' ');
|
|
282
|
+
}
|
|
283
|
+
const params = paramLines.map(p => p.split(':')[0].trim()).filter(Boolean).join(', ');
|
|
284
|
+
entries.push({ kind: 'method', name, signature: ` ${name}(${params})${retType ? ': ' + retType : ''}`, docstring: jsDoc });
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
return entries;
|
|
289
|
+
}
|
|
290
|
+
function extractJSDoc(lines, declLineIdx) {
|
|
291
|
+
// Walk backwards to find */ then /**
|
|
292
|
+
let endIdx = declLineIdx - 1;
|
|
293
|
+
// Skip blank lines
|
|
294
|
+
while (endIdx >= 0 && lines[endIdx].trim() === '')
|
|
295
|
+
endIdx--;
|
|
296
|
+
if (endIdx < 0 || !lines[endIdx].trim().endsWith('*/'))
|
|
297
|
+
return undefined;
|
|
298
|
+
let startIdx = endIdx;
|
|
299
|
+
while (startIdx >= 0 && !lines[startIdx].trim().startsWith('/**'))
|
|
300
|
+
startIdx--;
|
|
301
|
+
if (startIdx < 0)
|
|
302
|
+
return undefined;
|
|
303
|
+
// Find first meaningful @description or plain text line
|
|
304
|
+
for (let j = startIdx + 1; j <= endIdx; j++) {
|
|
305
|
+
const t = lines[j].replace(/^\s*\*\s?/, '').trim();
|
|
306
|
+
if (t && !t.startsWith('@'))
|
|
307
|
+
return t;
|
|
308
|
+
}
|
|
309
|
+
return undefined;
|
|
310
|
+
}
|
|
311
|
+
function compactParams(params) {
|
|
312
|
+
return params
|
|
313
|
+
.split(',')
|
|
314
|
+
.map(p => p.trim().replace(/\s+/g, ' '))
|
|
315
|
+
.filter(Boolean)
|
|
316
|
+
.join(', ');
|
|
317
|
+
}
|
|
318
|
+
// ============================================================================
|
|
319
|
+
// GO EXTRACTOR
|
|
320
|
+
// ============================================================================
|
|
321
|
+
function extractGo(content) {
|
|
322
|
+
const entries = [];
|
|
323
|
+
const lines = content.split('\n');
|
|
324
|
+
for (let i = 0; i < lines.length && entries.length < MAX_SIGS_PER_FILE; i++) {
|
|
325
|
+
const line = lines[i];
|
|
326
|
+
// func (r *Receiver) Name(args) ret or func Name(args) ret
|
|
327
|
+
const match = line.match(/^func\s+(?:\([^)]+\)\s+)?(\w+)\s*\(([^)]*)\)(?:\s*(?:\([^)]*\)|[\w*[\], ]+))?/);
|
|
328
|
+
if (match) {
|
|
329
|
+
const name = match[1];
|
|
330
|
+
if (name === 'init' || name.startsWith('test') || name.startsWith('Test'))
|
|
331
|
+
continue;
|
|
332
|
+
// Grab comment above
|
|
333
|
+
const comment = lines[i - 1]?.trim().startsWith('//') ? lines[i - 1].trim().slice(2).trim() : undefined;
|
|
334
|
+
entries.push({ kind: 'function', name, signature: line.trim().replace(/\s*\{.*$/, ''), docstring: comment });
|
|
335
|
+
}
|
|
336
|
+
// type Foo struct or type Foo interface
|
|
337
|
+
const typeMatch = line.match(/^type\s+(\w+)\s+(struct|interface)\s*\{?/);
|
|
338
|
+
if (typeMatch) {
|
|
339
|
+
entries.push({ kind: typeMatch[2] === 'interface' ? 'interface' : 'class', name: typeMatch[1], signature: `type ${typeMatch[1]} ${typeMatch[2]}` });
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
return entries;
|
|
343
|
+
}
|
|
344
|
+
// ============================================================================
|
|
345
|
+
// RUST EXTRACTOR
|
|
346
|
+
// ============================================================================
|
|
347
|
+
function extractRust(content) {
|
|
348
|
+
const entries = [];
|
|
349
|
+
const lines = content.split('\n');
|
|
350
|
+
for (let i = 0; i < lines.length && entries.length < MAX_SIGS_PER_FILE; i++) {
|
|
351
|
+
const line = lines[i];
|
|
352
|
+
// pub fn / pub async fn
|
|
353
|
+
const fnMatch = line.match(/^\s*pub(?:\(crate\))?\s+(?:async\s+)?fn\s+(\w+)\s*(?:<[^>]*>)?\s*\(([^)]*)\)(?:\s*->\s*([^{]+))?/);
|
|
354
|
+
if (fnMatch) {
|
|
355
|
+
const name = fnMatch[1];
|
|
356
|
+
const params = compactParams(fnMatch[2]);
|
|
357
|
+
const ret = fnMatch[3]?.trim() ?? '';
|
|
358
|
+
const sig = `pub fn ${name}(${params})${ret ? ' -> ' + ret : ''}`;
|
|
359
|
+
const comment = lines[i - 1]?.trim().startsWith('///') ? lines[i - 1].trim().slice(3).trim() : undefined;
|
|
360
|
+
entries.push({ kind: 'function', name, signature: sig, docstring: comment });
|
|
361
|
+
}
|
|
362
|
+
// pub struct / pub enum
|
|
363
|
+
const typeMatch = line.match(/^\s*pub(?:\(crate\))?\s+(struct|enum)\s+(\w+)/);
|
|
364
|
+
if (typeMatch) {
|
|
365
|
+
entries.push({ kind: 'class', name: typeMatch[2], signature: `pub ${typeMatch[1]} ${typeMatch[2]}` });
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
return entries;
|
|
369
|
+
}
|
|
370
|
+
// ============================================================================
|
|
371
|
+
// RUBY EXTRACTOR
|
|
372
|
+
// ============================================================================
|
|
373
|
+
function extractRuby(content) {
|
|
374
|
+
const entries = [];
|
|
375
|
+
const lines = content.split('\n');
|
|
376
|
+
for (let i = 0; i < lines.length && entries.length < MAX_SIGS_PER_FILE; i++) {
|
|
377
|
+
const line = lines[i].trim();
|
|
378
|
+
const classMatch = line.match(/^class\s+(\w+)(?:\s*<\s*(\w+))?/);
|
|
379
|
+
if (classMatch) {
|
|
380
|
+
const name = classMatch[1];
|
|
381
|
+
const parent = classMatch[2] ? ` < ${classMatch[2]}` : '';
|
|
382
|
+
entries.push({ kind: 'class', name, signature: `class ${name}${parent}` });
|
|
383
|
+
continue;
|
|
384
|
+
}
|
|
385
|
+
const methodMatch = line.match(/^def\s+(\w+)(?:\s*\(([^)]*)\))?/);
|
|
386
|
+
if (methodMatch) {
|
|
387
|
+
const name = methodMatch[1];
|
|
388
|
+
const params = methodMatch[2] ? `(${methodMatch[2]})` : '';
|
|
389
|
+
entries.push({ kind: 'function', name, signature: `def ${name}${params}` });
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
return entries;
|
|
393
|
+
}
|
|
394
|
+
// ============================================================================
|
|
395
|
+
// C++ EXTRACTOR
|
|
396
|
+
// ============================================================================
|
|
397
|
+
/** Keywords that look like function names but are control-flow or declarations */
|
|
398
|
+
const CPP_SKIP_NAMES = new Set([
|
|
399
|
+
'if', 'for', 'while', 'switch', 'catch', 'namespace', 'class', 'struct',
|
|
400
|
+
'return', 'delete', 'do', 'else', 'new', 'sizeof', 'static_assert', 'assert',
|
|
401
|
+
'typedef', 'template', 'decltype', 'alignof', 'typeid',
|
|
402
|
+
]);
|
|
403
|
+
function extractCpp(content) {
|
|
404
|
+
const entries = [];
|
|
405
|
+
const lines = content.split('\n');
|
|
406
|
+
for (let i = 0; i < lines.length && entries.length < MAX_SIGS_PER_FILE; i++) {
|
|
407
|
+
const line = lines[i];
|
|
408
|
+
const trimmed = line.trimStart();
|
|
409
|
+
// Skip preprocessor directives, comments, empty lines
|
|
410
|
+
if (!trimmed || trimmed.startsWith('#') || trimmed.startsWith('//') || trimmed.startsWith('*') || trimmed.startsWith('/*'))
|
|
411
|
+
continue;
|
|
412
|
+
// class / struct declaration (not a forward declaration ending in ;)
|
|
413
|
+
const classMatch = trimmed.match(/^(?:class|struct)\s+(\w+)\b/);
|
|
414
|
+
if (classMatch && !trimmed.endsWith(';')) {
|
|
415
|
+
const keyword = trimmed.startsWith('struct') ? 'struct' : 'class';
|
|
416
|
+
const name = classMatch[1];
|
|
417
|
+
const comment = lines[i - 1]?.trim().startsWith('//') ? lines[i - 1].trim().slice(2).trim() : undefined;
|
|
418
|
+
entries.push({ kind: 'class', name, signature: `${keyword} ${name}`, docstring: comment });
|
|
419
|
+
continue;
|
|
420
|
+
}
|
|
421
|
+
// Function / method: look for Name(params) followed by qualifiers then { or :
|
|
422
|
+
// This regex finds the last word before a ( that has content after closing )
|
|
423
|
+
const fnMatch = trimmed.match(/\b(\w+)\s*\(([^)]*)\)\s*(?:const\s*)?(?:noexcept[^{;]*)?\s*(?:override\s*)?(?:final\s*)?(?:->\s*[\w:*&<>, ]+\s*)?[{:]/);
|
|
424
|
+
if (fnMatch) {
|
|
425
|
+
const name = fnMatch[1];
|
|
426
|
+
if (!CPP_SKIP_NAMES.has(name) && /^[a-zA-Z_]/.test(name)) {
|
|
427
|
+
const params = compactParams(fnMatch[2]);
|
|
428
|
+
const comment = lines[i - 1]?.trim().startsWith('//') ? lines[i - 1].trim().slice(2).trim() : undefined;
|
|
429
|
+
const kind = line.startsWith(' ') || line.startsWith('\t') ? 'method' : 'function';
|
|
430
|
+
entries.push({ kind, name, signature: `${name}(${params})`, docstring: comment });
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
return entries;
|
|
435
|
+
}
|
|
436
|
+
// ============================================================================
|
|
437
|
+
// SWIFT EXTRACTOR
|
|
438
|
+
// ============================================================================
|
|
439
|
+
function extractSwift(content) {
|
|
440
|
+
const entries = [];
|
|
441
|
+
const lines = content.split('\n');
|
|
442
|
+
for (let i = 0; i < lines.length && entries.length < MAX_SIGS_PER_FILE; i++) {
|
|
443
|
+
const line = lines[i];
|
|
444
|
+
const trimmed = line.trimStart();
|
|
445
|
+
// Collect /// doc comment above the declaration
|
|
446
|
+
let docstring;
|
|
447
|
+
if (i > 0) {
|
|
448
|
+
let j = i - 1;
|
|
449
|
+
while (j >= 0 && lines[j].trim() === '')
|
|
450
|
+
j--;
|
|
451
|
+
if (j >= 0 && lines[j].trim().startsWith('///')) {
|
|
452
|
+
docstring = lines[j].trim().slice(3).trim() || undefined;
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
// class / struct / actor / enum declaration
|
|
456
|
+
const typeMatch = trimmed.match(/^(?:public\s+|open\s+|internal\s+|private\s+|fileprivate\s+)*(?:final\s+)?(class|struct|actor|enum)\s+(\w+)/);
|
|
457
|
+
if (typeMatch) {
|
|
458
|
+
const keyword = typeMatch[1];
|
|
459
|
+
const name = typeMatch[2];
|
|
460
|
+
const kind = keyword === 'enum' ? 'type' : 'class';
|
|
461
|
+
entries.push({ kind, name, signature: `${keyword} ${name}`, docstring });
|
|
462
|
+
continue;
|
|
463
|
+
}
|
|
464
|
+
// protocol declaration
|
|
465
|
+
const protocolMatch = trimmed.match(/^(?:public\s+|internal\s+|private\s+|fileprivate\s+)*protocol\s+(\w+)/);
|
|
466
|
+
if (protocolMatch) {
|
|
467
|
+
entries.push({ kind: 'interface', name: protocolMatch[1], signature: `protocol ${protocolMatch[1]}`, docstring });
|
|
468
|
+
continue;
|
|
469
|
+
}
|
|
470
|
+
// func declaration (free or method)
|
|
471
|
+
const funcMatch = trimmed.match(/^(?:public\s+|open\s+|internal\s+|private\s+|fileprivate\s+|static\s+|class\s+|override\s+|mutating\s+)*(?:async\s+)?func\s+(\w+)\s*(?:<[^>]*>)?\s*\(([^)]*)\)(?:\s*(?:async|throws|rethrows))?\s*(?:->\s*([^{]+))?/);
|
|
472
|
+
if (funcMatch) {
|
|
473
|
+
const name = funcMatch[1];
|
|
474
|
+
const params = compactParams(funcMatch[2]);
|
|
475
|
+
const ret = funcMatch[3]?.trim().replace(/\s+/g, ' ') ?? '';
|
|
476
|
+
const isMethod = line.startsWith(' ') || line.startsWith('\t');
|
|
477
|
+
const sig = `func ${name}(${params})${ret ? ' -> ' + ret : ''}`;
|
|
478
|
+
entries.push({ kind: isMethod ? 'method' : 'function', name, signature: isMethod ? ' ' + sig : sig, docstring });
|
|
479
|
+
continue;
|
|
480
|
+
}
|
|
481
|
+
// init declaration
|
|
482
|
+
const initMatch = trimmed.match(/^(?:public\s+|internal\s+|private\s+|fileprivate\s+|convenience\s+|required\s+)*init\s*(?:\?|!)?(?:<[^>]*>)?\s*\(/);
|
|
483
|
+
if (initMatch) {
|
|
484
|
+
const sig = 'init(' + (trimmed.split('(')[1]?.split(')')[0] ?? '') + ')';
|
|
485
|
+
entries.push({ kind: 'method', name: 'init', signature: ' ' + sig.slice(0, 80), docstring });
|
|
486
|
+
continue;
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
return entries;
|
|
490
|
+
}
|
|
491
|
+
// ============================================================================
|
|
492
|
+
// JAVA EXTRACTOR
|
|
493
|
+
// ============================================================================
|
|
494
|
+
/** Java modifier keywords that can precede a type or method declaration. */
|
|
495
|
+
const JAVA_MODIFIER_PREFIX = '(?:public\\s+|private\\s+|protected\\s+|static\\s+|final\\s+|abstract\\s+|synchronized\\s+|default\\s+|native\\s+|sealed\\s+|non-sealed\\s+)*';
|
|
496
|
+
/** Keywords that look like method names but are not. */
|
|
497
|
+
const JAVA_SKIP_NAMES = new Set([
|
|
498
|
+
'if', 'for', 'while', 'switch', 'return', 'do', 'else', 'try', 'catch', 'finally',
|
|
499
|
+
'new', 'throw', 'class', 'interface', 'enum', 'record',
|
|
500
|
+
]);
|
|
501
|
+
function extractJava(content) {
|
|
502
|
+
const entries = [];
|
|
503
|
+
const lines = content.split('\n');
|
|
504
|
+
for (let i = 0; i < lines.length && entries.length < MAX_SIGS_PER_FILE; i++) {
|
|
505
|
+
const line = lines[i];
|
|
506
|
+
const trimmed = line.trimStart();
|
|
507
|
+
// Skip lines that are clearly not declarations
|
|
508
|
+
if (!trimmed || trimmed.startsWith('//') || trimmed.startsWith('*') || trimmed.startsWith('/*'))
|
|
509
|
+
continue;
|
|
510
|
+
if (trimmed.startsWith('@'))
|
|
511
|
+
continue; // annotations
|
|
512
|
+
// Collect Javadoc comment above the declaration (walk back through
|
|
513
|
+
// annotations and blank lines to find the closing `*/`).
|
|
514
|
+
const docstring = extractJavadoc(lines, i);
|
|
515
|
+
// class / interface / enum / record / @interface
|
|
516
|
+
const typeMatch = trimmed.match(new RegExp('^' + JAVA_MODIFIER_PREFIX + '(class|interface|enum|record|@interface)\\s+(\\w+)'));
|
|
517
|
+
if (typeMatch) {
|
|
518
|
+
const keyword = typeMatch[1];
|
|
519
|
+
const name = typeMatch[2];
|
|
520
|
+
const kind = keyword === 'interface' || keyword === '@interface' ? 'interface' : 'class';
|
|
521
|
+
const sig = trimmed.replace(/\s*\{.*$/, '').slice(0, 120);
|
|
522
|
+
entries.push({ kind, name, signature: sig, docstring });
|
|
523
|
+
continue;
|
|
524
|
+
}
|
|
525
|
+
// Method: `[modifiers] [<generics>] ReturnType name(params)` — return type
|
|
526
|
+
// may include generics, arrays, and dotted package-qualified names.
|
|
527
|
+
const methodMatch = trimmed.match(new RegExp('^' + JAVA_MODIFIER_PREFIX + '(?:<[^>]+>\\s+)?([\\w<>\\[\\], ?.]+?)\\s+(\\w+)\\s*\\(([^)]*)\\)'));
|
|
528
|
+
if (methodMatch) {
|
|
529
|
+
const returnType = methodMatch[1].trim();
|
|
530
|
+
const name = methodMatch[2];
|
|
531
|
+
if (JAVA_SKIP_NAMES.has(name))
|
|
532
|
+
continue;
|
|
533
|
+
// Skip obvious field declarations like `private final Foo bar = ...` —
|
|
534
|
+
// fields don't have `(` so the regex wouldn't match. This path is
|
|
535
|
+
// method-only by construction.
|
|
536
|
+
const params = compactParams(methodMatch[3]);
|
|
537
|
+
const isMethod = line.startsWith(' ') || line.startsWith('\t');
|
|
538
|
+
const sig = `${returnType} ${name}(${params})`;
|
|
539
|
+
entries.push({
|
|
540
|
+
kind: isMethod ? 'method' : 'function',
|
|
541
|
+
name,
|
|
542
|
+
signature: (isMethod ? ' ' : '') + sig,
|
|
543
|
+
docstring,
|
|
544
|
+
});
|
|
545
|
+
continue;
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
return entries;
|
|
549
|
+
}
|
|
550
|
+
/**
|
|
551
|
+
* Walk backwards from declLineIdx, skipping annotations and blank lines, to
|
|
552
|
+
* find a preceding Javadoc block (`/** … *\/`). Returns the first meaningful
|
|
553
|
+
* line of the block, or undefined.
|
|
554
|
+
*/
|
|
555
|
+
function extractJavadoc(lines, declLineIdx) {
|
|
556
|
+
let endIdx = declLineIdx - 1;
|
|
557
|
+
// Skip annotation lines and blanks
|
|
558
|
+
while (endIdx >= 0) {
|
|
559
|
+
const t = lines[endIdx].trim();
|
|
560
|
+
if (t === '' || t.startsWith('@')) {
|
|
561
|
+
endIdx--;
|
|
562
|
+
continue;
|
|
563
|
+
}
|
|
564
|
+
break;
|
|
565
|
+
}
|
|
566
|
+
if (endIdx < 0 || !lines[endIdx].trim().endsWith('*/'))
|
|
567
|
+
return undefined;
|
|
568
|
+
let startIdx = endIdx;
|
|
569
|
+
while (startIdx >= 0 && !lines[startIdx].trim().startsWith('/**'))
|
|
570
|
+
startIdx--;
|
|
571
|
+
if (startIdx < 0)
|
|
572
|
+
return undefined;
|
|
573
|
+
for (let j = startIdx + 1; j <= endIdx; j++) {
|
|
574
|
+
const t = lines[j].replace(/^\s*\*\s?/, '').trim();
|
|
575
|
+
if (t && !t.startsWith('@') && !t.startsWith('/'))
|
|
576
|
+
return t;
|
|
577
|
+
}
|
|
578
|
+
return undefined;
|
|
579
|
+
}
|
|
580
|
+
// ============================================================================
|
|
581
|
+
// GENERIC FALLBACK EXTRACTOR
|
|
582
|
+
// ============================================================================
|
|
583
|
+
function extractGeneric(content) {
|
|
584
|
+
const entries = [];
|
|
585
|
+
const lines = content.split('\n');
|
|
586
|
+
for (let i = 0; i < lines.length && entries.length < MAX_SIGS_PER_FILE; i++) {
|
|
587
|
+
const line = lines[i];
|
|
588
|
+
// Generic: lines that look like declarations (function/class/def keywords)
|
|
589
|
+
const match = line.match(/^\s*(?:public|private|protected|export|static|async)?\s*(?:function|class|def|func|fn|sub|procedure)\s+(\w+)/);
|
|
590
|
+
if (match) {
|
|
591
|
+
entries.push({ kind: 'function', name: match[1], signature: line.trim().slice(0, 120) });
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
return entries;
|
|
595
|
+
}
|
|
596
|
+
// ============================================================================
|
|
597
|
+
// MAIN EXTRACTOR
|
|
598
|
+
// ============================================================================
|
|
599
|
+
export function extractSignatures(filePath, content) {
|
|
600
|
+
const language = detectLanguage(filePath);
|
|
601
|
+
let entries;
|
|
602
|
+
switch (language) {
|
|
603
|
+
case 'Python':
|
|
604
|
+
entries = extractPython(content);
|
|
605
|
+
break;
|
|
606
|
+
case 'TypeScript':
|
|
607
|
+
case 'JavaScript':
|
|
608
|
+
entries = extractTypeScript(content);
|
|
609
|
+
break;
|
|
610
|
+
case 'Go':
|
|
611
|
+
entries = extractGo(content);
|
|
612
|
+
break;
|
|
613
|
+
case 'Rust':
|
|
614
|
+
entries = extractRust(content);
|
|
615
|
+
break;
|
|
616
|
+
case 'Ruby':
|
|
617
|
+
entries = extractRuby(content);
|
|
618
|
+
break;
|
|
619
|
+
case 'C++':
|
|
620
|
+
entries = extractCpp(content);
|
|
621
|
+
break;
|
|
622
|
+
case 'Swift':
|
|
623
|
+
entries = extractSwift(content);
|
|
624
|
+
break;
|
|
625
|
+
case 'Java':
|
|
626
|
+
entries = extractJava(content);
|
|
627
|
+
break;
|
|
628
|
+
default:
|
|
629
|
+
entries = extractGeneric(content);
|
|
630
|
+
break;
|
|
631
|
+
}
|
|
632
|
+
return { path: filePath, language, entries };
|
|
633
|
+
}
|
|
634
|
+
// ============================================================================
|
|
635
|
+
// FORMATTER
|
|
636
|
+
// ============================================================================
|
|
637
|
+
/**
|
|
638
|
+
* Format signature maps as compact text blocks for Stage 1 LLM prompt.
|
|
639
|
+
* Returns an array of chunk strings — 1 element if total fits within maxChars,
|
|
640
|
+
* N elements if chunking is needed. Files are never split across chunks.
|
|
641
|
+
*/
|
|
642
|
+
export function formatSignatureMaps(maps, maxChars = STAGE1_MAX_CHARS) {
|
|
643
|
+
// Filter out files with no signatures
|
|
644
|
+
const meaningful = maps.filter(m => m.entries.length > 0);
|
|
645
|
+
const chunks = [];
|
|
646
|
+
let current = '';
|
|
647
|
+
for (const map of meaningful) {
|
|
648
|
+
const block = formatSingleFile(map);
|
|
649
|
+
// If adding this block would exceed the limit, flush current chunk
|
|
650
|
+
if (current.length > 0 && current.length + block.length > maxChars) {
|
|
651
|
+
chunks.push(current.trim());
|
|
652
|
+
current = '';
|
|
653
|
+
}
|
|
654
|
+
current += block + '\n';
|
|
655
|
+
}
|
|
656
|
+
if (current.trim()) {
|
|
657
|
+
chunks.push(current.trim());
|
|
658
|
+
}
|
|
659
|
+
return chunks.length > 0 ? chunks : ['(no signatures extracted)'];
|
|
660
|
+
}
|
|
661
|
+
function formatSingleFile(map) {
|
|
662
|
+
const lines = [`=== ${map.path} [${map.language}] ===`];
|
|
663
|
+
for (const entry of map.entries) {
|
|
664
|
+
if (entry.decorator) {
|
|
665
|
+
lines.push(entry.decorator);
|
|
666
|
+
}
|
|
667
|
+
lines.push(entry.signature);
|
|
668
|
+
if (entry.docstring) {
|
|
669
|
+
const indent = entry.signature.startsWith(' ') ? ' ' : ' ';
|
|
670
|
+
lines.push(`${indent}"""${entry.docstring}"""`);
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
return lines.join('\n') + '\n';
|
|
674
|
+
}
|
|
675
|
+
//# sourceMappingURL=signature-extractor.js.map
|