synapsexcoder 6.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/.opencode/opencode.jsonc +102 -0
- package/README.md +353 -0
- package/dist/agents/agent-config-manager.d.ts +58 -0
- package/dist/agents/agent-config-manager.d.ts.map +1 -0
- package/dist/agents/agent-config-manager.js +313 -0
- package/dist/agents/agent-config-manager.js.map +1 -0
- package/dist/agents/base-agents.d.ts +352 -0
- package/dist/agents/base-agents.d.ts.map +1 -0
- package/dist/agents/base-agents.js +3961 -0
- package/dist/agents/base-agents.js.map +1 -0
- package/dist/agents/gated-subagent.d.ts +126 -0
- package/dist/agents/gated-subagent.d.ts.map +1 -0
- package/dist/agents/gated-subagent.js +591 -0
- package/dist/agents/gated-subagent.js.map +1 -0
- package/dist/agents/gated-subagents.d.ts +130 -0
- package/dist/agents/gated-subagents.d.ts.map +1 -0
- package/dist/agents/gated-subagents.js +2014 -0
- package/dist/agents/gated-subagents.js.map +1 -0
- package/dist/agents/internal-gatekeeper.d.ts +167 -0
- package/dist/agents/internal-gatekeeper.d.ts.map +1 -0
- package/dist/agents/internal-gatekeeper.js +1130 -0
- package/dist/agents/internal-gatekeeper.js.map +1 -0
- package/dist/agents/verification-agent.d.ts +86 -0
- package/dist/agents/verification-agent.d.ts.map +1 -0
- package/dist/agents/verification-agent.js +211 -0
- package/dist/agents/verification-agent.js.map +1 -0
- package/dist/analytics/analytics-types.d.ts +113 -0
- package/dist/analytics/analytics-types.d.ts.map +1 -0
- package/dist/analytics/analytics-types.js +8 -0
- package/dist/analytics/analytics-types.js.map +1 -0
- package/dist/analytics/dashboard-generator.d.ts +35 -0
- package/dist/analytics/dashboard-generator.d.ts.map +1 -0
- package/dist/analytics/dashboard-generator.js +365 -0
- package/dist/analytics/dashboard-generator.js.map +1 -0
- package/dist/analytics/index.d.ts +12 -0
- package/dist/analytics/index.d.ts.map +1 -0
- package/dist/analytics/index.js +12 -0
- package/dist/analytics/index.js.map +1 -0
- package/dist/analytics/metrics-aggregator.d.ts +88 -0
- package/dist/analytics/metrics-aggregator.d.ts.map +1 -0
- package/dist/analytics/metrics-aggregator.js +280 -0
- package/dist/analytics/metrics-aggregator.js.map +1 -0
- package/dist/cli/index.d.ts +36 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +2677 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/normalize_patch.d.ts +3 -0
- package/dist/cli/normalize_patch.d.ts.map +1 -0
- package/dist/cli/normalize_patch.js +34 -0
- package/dist/cli/normalize_patch.js.map +1 -0
- package/dist/commands/command-processor.d.ts +58 -0
- package/dist/commands/command-processor.d.ts.map +1 -0
- package/dist/commands/command-processor.js +796 -0
- package/dist/commands/command-processor.js.map +1 -0
- package/dist/config/compliance-checker.d.ts +93 -0
- package/dist/config/compliance-checker.d.ts.map +1 -0
- package/dist/config/compliance-checker.js +424 -0
- package/dist/config/compliance-checker.js.map +1 -0
- package/dist/config/enterprise-config.d.ts +173 -0
- package/dist/config/enterprise-config.d.ts.map +1 -0
- package/dist/config/enterprise-config.js +190 -0
- package/dist/config/enterprise-config.js.map +1 -0
- package/dist/config/index.d.ts +13 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +11 -0
- package/dist/config/index.js.map +1 -0
- package/dist/context/context-system.d.ts +97 -0
- package/dist/context/context-system.d.ts.map +1 -0
- package/dist/context/context-system.js +880 -0
- package/dist/context/context-system.js.map +1 -0
- package/dist/context/store.d.ts +123 -0
- package/dist/context/store.d.ts.map +1 -0
- package/dist/context/store.js +281 -0
- package/dist/context/store.js.map +1 -0
- package/dist/dasp/dasp-controller.d.ts +83 -0
- package/dist/dasp/dasp-controller.d.ts.map +1 -0
- package/dist/dasp/dasp-controller.js +190 -0
- package/dist/dasp/dasp-controller.js.map +1 -0
- package/dist/dasp/feedback-adapter.d.ts +56 -0
- package/dist/dasp/feedback-adapter.d.ts.map +1 -0
- package/dist/dasp/feedback-adapter.js +158 -0
- package/dist/dasp/feedback-adapter.js.map +1 -0
- package/dist/dasp/index.d.ts +14 -0
- package/dist/dasp/index.d.ts.map +1 -0
- package/dist/dasp/index.js +10 -0
- package/dist/dasp/index.js.map +1 -0
- package/dist/dasp/prompt-templates.d.ts +38 -0
- package/dist/dasp/prompt-templates.d.ts.map +1 -0
- package/dist/dasp/prompt-templates.js +406 -0
- package/dist/dasp/prompt-templates.js.map +1 -0
- package/dist/dasp/vault-rag-provider.d.ts +51 -0
- package/dist/dasp/vault-rag-provider.d.ts.map +1 -0
- package/dist/dasp/vault-rag-provider.js +125 -0
- package/dist/dasp/vault-rag-provider.js.map +1 -0
- package/dist/distribution/cli-distribution.d.ts +68 -0
- package/dist/distribution/cli-distribution.d.ts.map +1 -0
- package/dist/distribution/cli-distribution.js +941 -0
- package/dist/distribution/cli-distribution.js.map +1 -0
- package/dist/docs/doc-generator.d.ts +78 -0
- package/dist/docs/doc-generator.d.ts.map +1 -0
- package/dist/docs/doc-generator.js +297 -0
- package/dist/docs/doc-generator.js.map +1 -0
- package/dist/docs/index.d.ts +13 -0
- package/dist/docs/index.d.ts.map +1 -0
- package/dist/docs/index.js +11 -0
- package/dist/docs/index.js.map +1 -0
- package/dist/docs/site-builder.d.ts +58 -0
- package/dist/docs/site-builder.d.ts.map +1 -0
- package/dist/docs/site-builder.js +229 -0
- package/dist/docs/site-builder.js.map +1 -0
- package/dist/ecosystem/adapters/claude-adapter.d.ts +29 -0
- package/dist/ecosystem/adapters/claude-adapter.d.ts.map +1 -0
- package/dist/ecosystem/adapters/claude-adapter.js +116 -0
- package/dist/ecosystem/adapters/claude-adapter.js.map +1 -0
- package/dist/ecosystem/adapters/cursor-adapter.d.ts +27 -0
- package/dist/ecosystem/adapters/cursor-adapter.d.ts.map +1 -0
- package/dist/ecosystem/adapters/cursor-adapter.js +93 -0
- package/dist/ecosystem/adapters/cursor-adapter.js.map +1 -0
- package/dist/ecosystem/adapters/v0-adapter.d.ts +30 -0
- package/dist/ecosystem/adapters/v0-adapter.d.ts.map +1 -0
- package/dist/ecosystem/adapters/v0-adapter.js +112 -0
- package/dist/ecosystem/adapters/v0-adapter.js.map +1 -0
- package/dist/ecosystem/ecosystem-router.d.ts +80 -0
- package/dist/ecosystem/ecosystem-router.d.ts.map +1 -0
- package/dist/ecosystem/ecosystem-router.js +241 -0
- package/dist/ecosystem/ecosystem-router.js.map +1 -0
- package/dist/ecosystem/ecosystem-types.d.ts +94 -0
- package/dist/ecosystem/ecosystem-types.d.ts.map +1 -0
- package/dist/ecosystem/ecosystem-types.js +27 -0
- package/dist/ecosystem/ecosystem-types.js.map +1 -0
- package/dist/ecosystem/index.d.ts +10 -0
- package/dist/ecosystem/index.d.ts.map +1 -0
- package/dist/ecosystem/index.js +9 -0
- package/dist/ecosystem/index.js.map +1 -0
- package/dist/integration/agentic-integration.d.ts +73 -0
- package/dist/integration/agentic-integration.d.ts.map +1 -0
- package/dist/integration/agentic-integration.js +253 -0
- package/dist/integration/agentic-integration.js.map +1 -0
- package/dist/integration/background-agents-integration.d.ts +54 -0
- package/dist/integration/background-agents-integration.d.ts.map +1 -0
- package/dist/integration/background-agents-integration.js +225 -0
- package/dist/integration/background-agents-integration.js.map +1 -0
- package/dist/integration/dcp-integration.d.ts +81 -0
- package/dist/integration/dcp-integration.d.ts.map +1 -0
- package/dist/integration/dcp-integration.js +189 -0
- package/dist/integration/dcp-integration.js.map +1 -0
- package/dist/integration/firecrawl-integration.d.ts +61 -0
- package/dist/integration/firecrawl-integration.d.ts.map +1 -0
- package/dist/integration/firecrawl-integration.js +246 -0
- package/dist/integration/firecrawl-integration.js.map +1 -0
- package/dist/integration/index.d.ts +40 -0
- package/dist/integration/index.d.ts.map +1 -0
- package/dist/integration/index.js +43 -0
- package/dist/integration/index.js.map +1 -0
- package/dist/integration/integration-hub.d.ts +43 -0
- package/dist/integration/integration-hub.d.ts.map +1 -0
- package/dist/integration/integration-hub.js +507 -0
- package/dist/integration/integration-hub.js.map +1 -0
- package/dist/integration/integration-loader.d.ts +42 -0
- package/dist/integration/integration-loader.d.ts.map +1 -0
- package/dist/integration/integration-loader.js +240 -0
- package/dist/integration/integration-loader.js.map +1 -0
- package/dist/integration/md-table-formatter-integration.d.ts +41 -0
- package/dist/integration/md-table-formatter-integration.d.ts.map +1 -0
- package/dist/integration/md-table-formatter-integration.js +183 -0
- package/dist/integration/md-table-formatter-integration.js.map +1 -0
- package/dist/integration/native/agentic/agentic-engine.d.ts +52 -0
- package/dist/integration/native/agentic/agentic-engine.d.ts.map +1 -0
- package/dist/integration/native/agentic/agentic-engine.js +267 -0
- package/dist/integration/native/agentic/agentic-engine.js.map +1 -0
- package/dist/integration/native/background/background-engine.d.ts +62 -0
- package/dist/integration/native/background/background-engine.d.ts.map +1 -0
- package/dist/integration/native/background/background-engine.js +167 -0
- package/dist/integration/native/background/background-engine.js.map +1 -0
- package/dist/integration/native/dcp/dcp-engine.d.ts +55 -0
- package/dist/integration/native/dcp/dcp-engine.d.ts.map +1 -0
- package/dist/integration/native/dcp/dcp-engine.js +168 -0
- package/dist/integration/native/dcp/dcp-engine.js.map +1 -0
- package/dist/integration/native/firecrawl/firecrawl-engine.d.ts +66 -0
- package/dist/integration/native/firecrawl/firecrawl-engine.d.ts.map +1 -0
- package/dist/integration/native/firecrawl/firecrawl-engine.js +221 -0
- package/dist/integration/native/firecrawl/firecrawl-engine.js.map +1 -0
- package/dist/integration/native/formatter/formatter-engine.d.ts +47 -0
- package/dist/integration/native/formatter/formatter-engine.d.ts.map +1 -0
- package/dist/integration/native/formatter/formatter-engine.js +130 -0
- package/dist/integration/native/formatter/formatter-engine.js.map +1 -0
- package/dist/integration/native/index.d.ts +41 -0
- package/dist/integration/native/index.d.ts.map +1 -0
- package/dist/integration/native/index.js +80 -0
- package/dist/integration/native/index.js.map +1 -0
- package/dist/integration/native/orchestration/orchestration-engine.d.ts +62 -0
- package/dist/integration/native/orchestration/orchestration-engine.d.ts.map +1 -0
- package/dist/integration/native/orchestration/orchestration-engine.js +177 -0
- package/dist/integration/native/orchestration/orchestration-engine.js.map +1 -0
- package/dist/integration/native/pty/pty-engine.d.ts +45 -0
- package/dist/integration/native/pty/pty-engine.d.ts.map +1 -0
- package/dist/integration/native/pty/pty-engine.js +103 -0
- package/dist/integration/native/pty/pty-engine.js.map +1 -0
- package/dist/integration/native/shell-strategy.d.ts +60 -0
- package/dist/integration/native/shell-strategy.d.ts.map +1 -0
- package/dist/integration/native/shell-strategy.js +131 -0
- package/dist/integration/native/shell-strategy.js.map +1 -0
- package/dist/integration/native/skillful/skillful-engine.d.ts +53 -0
- package/dist/integration/native/skillful/skillful-engine.d.ts.map +1 -0
- package/dist/integration/native/skillful/skillful-engine.js +127 -0
- package/dist/integration/native/skillful/skillful-engine.js.map +1 -0
- package/dist/integration/native/subtask2/subtask2-engine.d.ts +50 -0
- package/dist/integration/native/subtask2/subtask2-engine.d.ts.map +1 -0
- package/dist/integration/native/subtask2/subtask2-engine.js +158 -0
- package/dist/integration/native/subtask2/subtask2-engine.js.map +1 -0
- package/dist/integration/native/supermemory/supermemory-engine.d.ts +63 -0
- package/dist/integration/native/supermemory/supermemory-engine.d.ts.map +1 -0
- package/dist/integration/native/supermemory/supermemory-engine.js +127 -0
- package/dist/integration/native/supermemory/supermemory-engine.js.map +1 -0
- package/dist/integration/native/workspace/workspace-engine.d.ts +75 -0
- package/dist/integration/native/workspace/workspace-engine.d.ts.map +1 -0
- package/dist/integration/native/workspace/workspace-engine.js +216 -0
- package/dist/integration/native/workspace/workspace-engine.js.map +1 -0
- package/dist/integration/oh-my-opencode-integration.d.ts +59 -0
- package/dist/integration/oh-my-opencode-integration.d.ts.map +1 -0
- package/dist/integration/oh-my-opencode-integration.js +180 -0
- package/dist/integration/oh-my-opencode-integration.js.map +1 -0
- package/dist/integration/openagents-control-integration.d.ts +81 -0
- package/dist/integration/openagents-control-integration.d.ts.map +1 -0
- package/dist/integration/openagents-control-integration.js +273 -0
- package/dist/integration/openagents-control-integration.js.map +1 -0
- package/dist/integration/pty-integration.d.ts +64 -0
- package/dist/integration/pty-integration.d.ts.map +1 -0
- package/dist/integration/pty-integration.js +180 -0
- package/dist/integration/pty-integration.js.map +1 -0
- package/dist/integration/shell-strategy-integration.d.ts +26 -0
- package/dist/integration/shell-strategy-integration.d.ts.map +1 -0
- package/dist/integration/shell-strategy-integration.js +110 -0
- package/dist/integration/shell-strategy-integration.js.map +1 -0
- package/dist/integration/skillful-integration.d.ts +74 -0
- package/dist/integration/skillful-integration.d.ts.map +1 -0
- package/dist/integration/skillful-integration.js +317 -0
- package/dist/integration/skillful-integration.js.map +1 -0
- package/dist/integration/subtask2-integration.d.ts +71 -0
- package/dist/integration/subtask2-integration.d.ts.map +1 -0
- package/dist/integration/subtask2-integration.js +240 -0
- package/dist/integration/subtask2-integration.js.map +1 -0
- package/dist/integration/supermemory-integration.d.ts +82 -0
- package/dist/integration/supermemory-integration.d.ts.map +1 -0
- package/dist/integration/supermemory-integration.js +252 -0
- package/dist/integration/supermemory-integration.js.map +1 -0
- package/dist/integration/types.d.ts +218 -0
- package/dist/integration/types.d.ts.map +1 -0
- package/dist/integration/types.js +5 -0
- package/dist/integration/types.js.map +1 -0
- package/dist/integration/workspace-integration.d.ts +46 -0
- package/dist/integration/workspace-integration.d.ts.map +1 -0
- package/dist/integration/workspace-integration.js +181 -0
- package/dist/integration/workspace-integration.js.map +1 -0
- package/dist/knowledge-vault/deepwiki-sync.d.ts +99 -0
- package/dist/knowledge-vault/deepwiki-sync.d.ts.map +1 -0
- package/dist/knowledge-vault/deepwiki-sync.js +381 -0
- package/dist/knowledge-vault/deepwiki-sync.js.map +1 -0
- package/dist/knowledge-vault/index.d.ts +11 -0
- package/dist/knowledge-vault/index.d.ts.map +1 -0
- package/dist/knowledge-vault/index.js +8 -0
- package/dist/knowledge-vault/index.js.map +1 -0
- package/dist/knowledge-vault/knowledge-vault.d.ts +38 -0
- package/dist/knowledge-vault/knowledge-vault.d.ts.map +1 -0
- package/dist/knowledge-vault/knowledge-vault.js +284 -0
- package/dist/knowledge-vault/knowledge-vault.js.map +1 -0
- package/dist/knowledge-vault/opencode-doc-ingest.d.ts +23 -0
- package/dist/knowledge-vault/opencode-doc-ingest.d.ts.map +1 -0
- package/dist/knowledge-vault/opencode-doc-ingest.js +48 -0
- package/dist/knowledge-vault/opencode-doc-ingest.js.map +1 -0
- package/dist/knowledge-vault/types.d.ts +61 -0
- package/dist/knowledge-vault/types.d.ts.map +1 -0
- package/dist/knowledge-vault/types.js +5 -0
- package/dist/knowledge-vault/types.js.map +1 -0
- package/dist/knowledge-vault/vault-config.d.ts +12 -0
- package/dist/knowledge-vault/vault-config.d.ts.map +1 -0
- package/dist/knowledge-vault/vault-config.js +24 -0
- package/dist/knowledge-vault/vault-config.js.map +1 -0
- package/dist/mcp/index.d.ts +28 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +29 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/mcp-manager.d.ts +181 -0
- package/dist/mcp/mcp-manager.d.ts.map +1 -0
- package/dist/mcp/mcp-manager.js +621 -0
- package/dist/mcp/mcp-manager.js.map +1 -0
- package/dist/mcp/mcp-types.d.ts +199 -0
- package/dist/mcp/mcp-types.d.ts.map +1 -0
- package/dist/mcp/mcp-types.js +152 -0
- package/dist/mcp/mcp-types.js.map +1 -0
- package/dist/mcp/servers/mcp-server-bridge.d.ts +64 -0
- package/dist/mcp/servers/mcp-server-bridge.d.ts.map +1 -0
- package/dist/mcp/servers/mcp-server-bridge.js +189 -0
- package/dist/mcp/servers/mcp-server-bridge.js.map +1 -0
- package/dist/messages/message-bus.d.ts +148 -0
- package/dist/messages/message-bus.d.ts.map +1 -0
- package/dist/messages/message-bus.js +432 -0
- package/dist/messages/message-bus.js.map +1 -0
- package/dist/modes/custom-mode-registry.d.ts +121 -0
- package/dist/modes/custom-mode-registry.d.ts.map +1 -0
- package/dist/modes/custom-mode-registry.js +306 -0
- package/dist/modes/custom-mode-registry.js.map +1 -0
- package/dist/modes/index.d.ts +10 -0
- package/dist/modes/index.d.ts.map +1 -0
- package/dist/modes/index.js +8 -0
- package/dist/modes/index.js.map +1 -0
- package/dist/modes/mode-designer.d.ts +89 -0
- package/dist/modes/mode-designer.d.ts.map +1 -0
- package/dist/modes/mode-designer.js +485 -0
- package/dist/modes/mode-designer.js.map +1 -0
- package/dist/modes/mode-manager.d.ts +27 -0
- package/dist/modes/mode-manager.d.ts.map +1 -0
- package/dist/modes/mode-manager.js +68 -0
- package/dist/modes/mode-manager.js.map +1 -0
- package/dist/modes/synapse-modes.d.ts +26 -0
- package/dist/modes/synapse-modes.d.ts.map +1 -0
- package/dist/modes/synapse-modes.js +69 -0
- package/dist/modes/synapse-modes.js.map +1 -0
- package/dist/opencode/agent-delegate.d.ts +3 -0
- package/dist/opencode/agent-delegate.d.ts.map +1 -0
- package/dist/opencode/agent-delegate.js +3 -0
- package/dist/opencode/agent-delegate.js.map +1 -0
- package/dist/opencode/tool-bridge.d.ts +3 -0
- package/dist/opencode/tool-bridge.d.ts.map +1 -0
- package/dist/opencode/tool-bridge.js +3 -0
- package/dist/opencode/tool-bridge.js.map +1 -0
- package/dist/optimization/token-optimizer-v2.d.ts +18 -0
- package/dist/optimization/token-optimizer-v2.d.ts.map +1 -0
- package/dist/optimization/token-optimizer-v2.js +23 -0
- package/dist/optimization/token-optimizer-v2.js.map +1 -0
- package/dist/optimization/token-optimizer.d.ts +90 -0
- package/dist/optimization/token-optimizer.d.ts.map +1 -0
- package/dist/optimization/token-optimizer.js +399 -0
- package/dist/optimization/token-optimizer.js.map +1 -0
- package/dist/parallel/agent-farm.d.ts +123 -0
- package/dist/parallel/agent-farm.d.ts.map +1 -0
- package/dist/parallel/agent-farm.js +501 -0
- package/dist/parallel/agent-farm.js.map +1 -0
- package/dist/parallel/farm-scheduler.d.ts +115 -0
- package/dist/parallel/farm-scheduler.d.ts.map +1 -0
- package/dist/parallel/farm-scheduler.js +356 -0
- package/dist/parallel/farm-scheduler.js.map +1 -0
- package/dist/parallel/farm-types.d.ts +104 -0
- package/dist/parallel/farm-types.d.ts.map +1 -0
- package/dist/parallel/farm-types.js +9 -0
- package/dist/parallel/farm-types.js.map +1 -0
- package/dist/parallel/farm-worker.d.ts +62 -0
- package/dist/parallel/farm-worker.d.ts.map +1 -0
- package/dist/parallel/farm-worker.js +268 -0
- package/dist/parallel/farm-worker.js.map +1 -0
- package/dist/parallel/index.d.ts +14 -0
- package/dist/parallel/index.d.ts.map +1 -0
- package/dist/parallel/index.js +14 -0
- package/dist/parallel/index.js.map +1 -0
- package/dist/plugin/native-tools.d.ts +8 -0
- package/dist/plugin/native-tools.d.ts.map +1 -0
- package/dist/plugin/native-tools.js +147 -0
- package/dist/plugin/native-tools.js.map +1 -0
- package/dist/plugin/opencode-plugin.d.ts +32 -0
- package/dist/plugin/opencode-plugin.d.ts.map +1 -0
- package/dist/plugin/opencode-plugin.js +119 -0
- package/dist/plugin/opencode-plugin.js.map +1 -0
- package/dist/plugins/plugin-system.d.ts +108 -0
- package/dist/plugins/plugin-system.d.ts.map +1 -0
- package/dist/plugins/plugin-system.js +707 -0
- package/dist/plugins/plugin-system.js.map +1 -0
- package/dist/profiler/cpu-profiler.d.ts +53 -0
- package/dist/profiler/cpu-profiler.d.ts.map +1 -0
- package/dist/profiler/cpu-profiler.js +233 -0
- package/dist/profiler/cpu-profiler.js.map +1 -0
- package/dist/profiler/index.d.ts +36 -0
- package/dist/profiler/index.d.ts.map +1 -0
- package/dist/profiler/index.js +122 -0
- package/dist/profiler/index.js.map +1 -0
- package/dist/profiler/memory-profiler.d.ts +45 -0
- package/dist/profiler/memory-profiler.d.ts.map +1 -0
- package/dist/profiler/memory-profiler.js +211 -0
- package/dist/profiler/memory-profiler.js.map +1 -0
- package/dist/profiler/profiler-types.d.ts +234 -0
- package/dist/profiler/profiler-types.d.ts.map +1 -0
- package/dist/profiler/profiler-types.js +89 -0
- package/dist/profiler/profiler-types.js.map +1 -0
- package/dist/profiler/query-profiler.d.ts +48 -0
- package/dist/profiler/query-profiler.d.ts.map +1 -0
- package/dist/profiler/query-profiler.js +210 -0
- package/dist/profiler/query-profiler.js.map +1 -0
- package/dist/profiler/report-generator.d.ts +17 -0
- package/dist/profiler/report-generator.d.ts.map +1 -0
- package/dist/profiler/report-generator.js +329 -0
- package/dist/profiler/report-generator.js.map +1 -0
- package/dist/sdk/api.d.ts +85 -0
- package/dist/sdk/api.d.ts.map +1 -0
- package/dist/sdk/api.js +155 -0
- package/dist/sdk/api.js.map +1 -0
- package/dist/sdk/hooks.d.ts +58 -0
- package/dist/sdk/hooks.d.ts.map +1 -0
- package/dist/sdk/hooks.js +115 -0
- package/dist/sdk/hooks.js.map +1 -0
- package/dist/sdk/index.d.ts +17 -0
- package/dist/sdk/index.d.ts.map +1 -0
- package/dist/sdk/index.js +14 -0
- package/dist/sdk/index.js.map +1 -0
- package/dist/sdk/plugin-base.d.ts +198 -0
- package/dist/sdk/plugin-base.d.ts.map +1 -0
- package/dist/sdk/plugin-base.js +227 -0
- package/dist/sdk/plugin-base.js.map +1 -0
- package/dist/security/audit-rules.d.ts +12 -0
- package/dist/security/audit-rules.d.ts.map +1 -0
- package/dist/security/audit-rules.js +214 -0
- package/dist/security/audit-rules.js.map +1 -0
- package/dist/security/index.d.ts +13 -0
- package/dist/security/index.d.ts.map +1 -0
- package/dist/security/index.js +13 -0
- package/dist/security/index.js.map +1 -0
- package/dist/security/sarif-exporter.d.ts +36 -0
- package/dist/security/sarif-exporter.d.ts.map +1 -0
- package/dist/security/sarif-exporter.js +216 -0
- package/dist/security/sarif-exporter.js.map +1 -0
- package/dist/security/security-auditor.d.ts +30 -0
- package/dist/security/security-auditor.d.ts.map +1 -0
- package/dist/security/security-auditor.js +295 -0
- package/dist/security/security-auditor.js.map +1 -0
- package/dist/security/security-types.d.ts +132 -0
- package/dist/security/security-types.d.ts.map +1 -0
- package/dist/security/security-types.js +7 -0
- package/dist/security/security-types.js.map +1 -0
- package/dist/synapsexcoder/agent-delegate.d.ts +128 -0
- package/dist/synapsexcoder/agent-delegate.d.ts.map +1 -0
- package/dist/synapsexcoder/agent-delegate.js +837 -0
- package/dist/synapsexcoder/agent-delegate.js.map +1 -0
- package/dist/synapsexcoder/agent-mailbox.d.ts +26 -0
- package/dist/synapsexcoder/agent-mailbox.d.ts.map +1 -0
- package/dist/synapsexcoder/agent-mailbox.js +64 -0
- package/dist/synapsexcoder/agent-mailbox.js.map +1 -0
- package/dist/synapsexcoder/ast-grep/ast-grep-api.d.ts +62 -0
- package/dist/synapsexcoder/ast-grep/ast-grep-api.d.ts.map +1 -0
- package/dist/synapsexcoder/ast-grep/ast-grep-api.js +223 -0
- package/dist/synapsexcoder/ast-grep/ast-grep-api.js.map +1 -0
- package/dist/synapsexcoder/cited-search.d.ts +32 -0
- package/dist/synapsexcoder/cited-search.d.ts.map +1 -0
- package/dist/synapsexcoder/cited-search.js +141 -0
- package/dist/synapsexcoder/cited-search.js.map +1 -0
- package/dist/synapsexcoder/credential-store.d.ts +42 -0
- package/dist/synapsexcoder/credential-store.d.ts.map +1 -0
- package/dist/synapsexcoder/credential-store.js +165 -0
- package/dist/synapsexcoder/credential-store.js.map +1 -0
- package/dist/synapsexcoder/devcontainer-awareness.d.ts +35 -0
- package/dist/synapsexcoder/devcontainer-awareness.d.ts.map +1 -0
- package/dist/synapsexcoder/devcontainer-awareness.js +133 -0
- package/dist/synapsexcoder/devcontainer-awareness.js.map +1 -0
- package/dist/synapsexcoder/execution-loops/helix-loop.d.ts +31 -0
- package/dist/synapsexcoder/execution-loops/helix-loop.d.ts.map +1 -0
- package/dist/synapsexcoder/execution-loops/helix-loop.js +93 -0
- package/dist/synapsexcoder/execution-loops/helix-loop.js.map +1 -0
- package/dist/synapsexcoder/execution-loops/ralp-loop.d.ts +28 -0
- package/dist/synapsexcoder/execution-loops/ralp-loop.d.ts.map +1 -0
- package/dist/synapsexcoder/execution-loops/ralp-loop.js +77 -0
- package/dist/synapsexcoder/execution-loops/ralp-loop.js.map +1 -0
- package/dist/synapsexcoder/feature-names.d.ts +27 -0
- package/dist/synapsexcoder/feature-names.d.ts.map +1 -0
- package/dist/synapsexcoder/feature-names.js +40 -0
- package/dist/synapsexcoder/feature-names.js.map +1 -0
- package/dist/synapsexcoder/index.d.ts +39 -0
- package/dist/synapsexcoder/index.d.ts.map +1 -0
- package/dist/synapsexcoder/index.js +23 -0
- package/dist/synapsexcoder/index.js.map +1 -0
- package/dist/synapsexcoder/knowledge-provider.d.ts +44 -0
- package/dist/synapsexcoder/knowledge-provider.d.ts.map +1 -0
- package/dist/synapsexcoder/knowledge-provider.js +107 -0
- package/dist/synapsexcoder/knowledge-provider.js.map +1 -0
- package/dist/synapsexcoder/lsp/lsp-layer.d.ts +51 -0
- package/dist/synapsexcoder/lsp/lsp-layer.d.ts.map +1 -0
- package/dist/synapsexcoder/lsp/lsp-layer.js +302 -0
- package/dist/synapsexcoder/lsp/lsp-layer.js.map +1 -0
- package/dist/synapsexcoder/migration/opencode-config-migrator.d.ts +37 -0
- package/dist/synapsexcoder/migration/opencode-config-migrator.d.ts.map +1 -0
- package/dist/synapsexcoder/migration/opencode-config-migrator.js +100 -0
- package/dist/synapsexcoder/migration/opencode-config-migrator.js.map +1 -0
- package/dist/synapsexcoder/runtime-environment.d.ts +35 -0
- package/dist/synapsexcoder/runtime-environment.d.ts.map +1 -0
- package/dist/synapsexcoder/runtime-environment.js +108 -0
- package/dist/synapsexcoder/runtime-environment.js.map +1 -0
- package/dist/synapsexcoder/secret-guard.d.ts +18 -0
- package/dist/synapsexcoder/secret-guard.d.ts.map +1 -0
- package/dist/synapsexcoder/secret-guard.js +69 -0
- package/dist/synapsexcoder/secret-guard.js.map +1 -0
- package/dist/synapsexcoder/self-prompt-engine.d.ts +15 -0
- package/dist/synapsexcoder/self-prompt-engine.d.ts.map +1 -0
- package/dist/synapsexcoder/self-prompt-engine.js +11 -0
- package/dist/synapsexcoder/self-prompt-engine.js.map +1 -0
- package/dist/synapsexcoder/session-observability.d.ts +44 -0
- package/dist/synapsexcoder/session-observability.d.ts.map +1 -0
- package/dist/synapsexcoder/session-observability.js +115 -0
- package/dist/synapsexcoder/session-observability.js.map +1 -0
- package/dist/synapsexcoder/specialist-agents.d.ts +38 -0
- package/dist/synapsexcoder/specialist-agents.d.ts.map +1 -0
- package/dist/synapsexcoder/specialist-agents.js +192 -0
- package/dist/synapsexcoder/specialist-agents.js.map +1 -0
- package/dist/synapsexcoder/swarm/kanban-board.d.ts +34 -0
- package/dist/synapsexcoder/swarm/kanban-board.d.ts.map +1 -0
- package/dist/synapsexcoder/swarm/kanban-board.js +85 -0
- package/dist/synapsexcoder/swarm/kanban-board.js.map +1 -0
- package/dist/synapsexcoder/swarm/swarm-mailbox.d.ts +38 -0
- package/dist/synapsexcoder/swarm/swarm-mailbox.d.ts.map +1 -0
- package/dist/synapsexcoder/swarm/swarm-mailbox.js +93 -0
- package/dist/synapsexcoder/swarm/swarm-mailbox.js.map +1 -0
- package/dist/synapsexcoder/tool-bridge.d.ts +277 -0
- package/dist/synapsexcoder/tool-bridge.d.ts.map +1 -0
- package/dist/synapsexcoder/tool-bridge.js +1356 -0
- package/dist/synapsexcoder/tool-bridge.js.map +1 -0
- package/dist/synapsexcoder/tool-routing.d.ts +28 -0
- package/dist/synapsexcoder/tool-routing.d.ts.map +1 -0
- package/dist/synapsexcoder/tool-routing.js +79 -0
- package/dist/synapsexcoder/tool-routing.js.map +1 -0
- package/dist/synapsexcoder/type-injector.d.ts +26 -0
- package/dist/synapsexcoder/type-injector.d.ts.map +1 -0
- package/dist/synapsexcoder/type-injector.js +124 -0
- package/dist/synapsexcoder/type-injector.js.map +1 -0
- package/dist/synapsexcoder/utils/fuzzy-match.d.ts +25 -0
- package/dist/synapsexcoder/utils/fuzzy-match.d.ts.map +1 -0
- package/dist/synapsexcoder/utils/fuzzy-match.js +83 -0
- package/dist/synapsexcoder/utils/fuzzy-match.js.map +1 -0
- package/dist/synapsexcoder/vault-crawl.d.ts +29 -0
- package/dist/synapsexcoder/vault-crawl.d.ts.map +1 -0
- package/dist/synapsexcoder/vault-crawl.js +103 -0
- package/dist/synapsexcoder/vault-crawl.js.map +1 -0
- package/dist/synapsexcoder/verified-apply.d.ts +39 -0
- package/dist/synapsexcoder/verified-apply.d.ts.map +1 -0
- package/dist/synapsexcoder/verified-apply.js +81 -0
- package/dist/synapsexcoder/verified-apply.js.map +1 -0
- package/dist/synapsexcoder/verified-context-editing.d.ts +34 -0
- package/dist/synapsexcoder/verified-context-editing.d.ts.map +1 -0
- package/dist/synapsexcoder/verified-context-editing.js +80 -0
- package/dist/synapsexcoder/verified-context-editing.js.map +1 -0
- package/dist/synapsexcoder/worker-pool.d.ts +47 -0
- package/dist/synapsexcoder/worker-pool.d.ts.map +1 -0
- package/dist/synapsexcoder/worker-pool.js +120 -0
- package/dist/synapsexcoder/worker-pool.js.map +1 -0
- package/dist/synapsexcoder/workspace-intelligence.d.ts +35 -0
- package/dist/synapsexcoder/workspace-intelligence.d.ts.map +1 -0
- package/dist/synapsexcoder/workspace-intelligence.js +126 -0
- package/dist/synapsexcoder/workspace-intelligence.js.map +1 -0
- package/dist/synapsexcoder/worktree-manager.d.ts +31 -0
- package/dist/synapsexcoder/worktree-manager.d.ts.map +1 -0
- package/dist/synapsexcoder/worktree-manager.js +100 -0
- package/dist/synapsexcoder/worktree-manager.js.map +1 -0
- package/dist/team/index.d.ts +17 -0
- package/dist/team/index.d.ts.map +1 -0
- package/dist/team/index.js +13 -0
- package/dist/team/index.js.map +1 -0
- package/dist/team/team-audit.d.ts +120 -0
- package/dist/team/team-audit.d.ts.map +1 -0
- package/dist/team/team-audit.js +357 -0
- package/dist/team/team-audit.js.map +1 -0
- package/dist/team/team-collaboration.d.ts +150 -0
- package/dist/team/team-collaboration.d.ts.map +1 -0
- package/dist/team/team-collaboration.js +495 -0
- package/dist/team/team-collaboration.js.map +1 -0
- package/dist/team/team-rbac.d.ts +84 -0
- package/dist/team/team-rbac.d.ts.map +1 -0
- package/dist/team/team-rbac.js +259 -0
- package/dist/team/team-rbac.js.map +1 -0
- package/dist/team/team-session-manager.d.ts +100 -0
- package/dist/team/team-session-manager.d.ts.map +1 -0
- package/dist/team/team-session-manager.js +255 -0
- package/dist/team/team-session-manager.js.map +1 -0
- package/dist/thoughts/thoughts-manager.d.ts +52 -0
- package/dist/thoughts/thoughts-manager.d.ts.map +1 -0
- package/dist/thoughts/thoughts-manager.js +271 -0
- package/dist/thoughts/thoughts-manager.js.map +1 -0
- package/dist/tools/api-validator/index.d.ts +97 -0
- package/dist/tools/api-validator/index.d.ts.map +1 -0
- package/dist/tools/api-validator/index.js +312 -0
- package/dist/tools/api-validator/index.js.map +1 -0
- package/dist/tools/code-archaeology/index.d.ts +193 -0
- package/dist/tools/code-archaeology/index.d.ts.map +1 -0
- package/dist/tools/code-archaeology/index.js +468 -0
- package/dist/tools/code-archaeology/index.js.map +1 -0
- package/dist/tools/codebase-search/index.d.ts +126 -0
- package/dist/tools/codebase-search/index.d.ts.map +1 -0
- package/dist/tools/codebase-search/index.js +437 -0
- package/dist/tools/codebase-search/index.js.map +1 -0
- package/dist/tools/context/index.d.ts +162 -0
- package/dist/tools/context/index.d.ts.map +1 -0
- package/dist/tools/context/index.js +332 -0
- package/dist/tools/context/index.js.map +1 -0
- package/dist/tools/deepwiki/analyzer.d.ts +167 -0
- package/dist/tools/deepwiki/analyzer.d.ts.map +1 -0
- package/dist/tools/deepwiki/analyzer.js +925 -0
- package/dist/tools/deepwiki/analyzer.js.map +1 -0
- package/dist/tools/deepwiki/extractor.d.ts +151 -0
- package/dist/tools/deepwiki/extractor.d.ts.map +1 -0
- package/dist/tools/deepwiki/extractor.js +923 -0
- package/dist/tools/deepwiki/extractor.js.map +1 -0
- package/dist/tools/deepwiki/generator.d.ts +89 -0
- package/dist/tools/deepwiki/generator.d.ts.map +1 -0
- package/dist/tools/deepwiki/generator.js +638 -0
- package/dist/tools/deepwiki/generator.js.map +1 -0
- package/dist/tools/deepwiki/index.d.ts +96 -0
- package/dist/tools/deepwiki/index.d.ts.map +1 -0
- package/dist/tools/deepwiki/index.js +282 -0
- package/dist/tools/deepwiki/index.js.map +1 -0
- package/dist/tools/deepwiki/types.d.ts +370 -0
- package/dist/tools/deepwiki/types.d.ts.map +1 -0
- package/dist/tools/deepwiki/types.js +21 -0
- package/dist/tools/deepwiki/types.js.map +1 -0
- package/dist/tools/dependency-mapper/index.d.ts +212 -0
- package/dist/tools/dependency-mapper/index.d.ts.map +1 -0
- package/dist/tools/dependency-mapper/index.js +592 -0
- package/dist/tools/dependency-mapper/index.js.map +1 -0
- package/dist/tools/memory/index.d.ts +120 -0
- package/dist/tools/memory/index.d.ts.map +1 -0
- package/dist/tools/memory/index.js +275 -0
- package/dist/tools/memory/index.js.map +1 -0
- package/dist/tools/normalize_patch.d.ts +3 -0
- package/dist/tools/normalize_patch.d.ts.map +1 -0
- package/dist/tools/normalize_patch.js +22 -0
- package/dist/tools/normalize_patch.js.map +1 -0
- package/dist/tools/pattern-detector/index.d.ts +105 -0
- package/dist/tools/pattern-detector/index.d.ts.map +1 -0
- package/dist/tools/pattern-detector/index.js +526 -0
- package/dist/tools/pattern-detector/index.js.map +1 -0
- package/dist/tools/performance-profiler/index.d.ts +50 -0
- package/dist/tools/performance-profiler/index.d.ts.map +1 -0
- package/dist/tools/performance-profiler/index.js +164 -0
- package/dist/tools/performance-profiler/index.js.map +1 -0
- package/dist/tools/refactoring-engine/index.d.ts +63 -0
- package/dist/tools/refactoring-engine/index.d.ts.map +1 -0
- package/dist/tools/refactoring-engine/index.js +270 -0
- package/dist/tools/refactoring-engine/index.js.map +1 -0
- package/dist/tools/registry.d.ts +36 -0
- package/dist/tools/registry.d.ts.map +1 -0
- package/dist/tools/registry.js +499 -0
- package/dist/tools/registry.js.map +1 -0
- package/dist/tools/test-generator/index.d.ts +152 -0
- package/dist/tools/test-generator/index.d.ts.map +1 -0
- package/dist/tools/test-generator/index.js +448 -0
- package/dist/tools/test-generator/index.js.map +1 -0
- package/dist/types/index.d.ts +565 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +7 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/path-validator.d.ts +94 -0
- package/dist/utils/path-validator.d.ts.map +1 -0
- package/dist/utils/path-validator.js +192 -0
- package/dist/utils/path-validator.js.map +1 -0
- package/dist/utils/secure-exec.d.ts +92 -0
- package/dist/utils/secure-exec.d.ts.map +1 -0
- package/dist/utils/secure-exec.js +230 -0
- package/dist/utils/secure-exec.js.map +1 -0
- package/dist/verification/claim-parser.d.ts +37 -0
- package/dist/verification/claim-parser.d.ts.map +1 -0
- package/dist/verification/claim-parser.js +231 -0
- package/dist/verification/claim-parser.js.map +1 -0
- package/dist/verification/cross-reference-engine.d.ts +55 -0
- package/dist/verification/cross-reference-engine.d.ts.map +1 -0
- package/dist/verification/cross-reference-engine.js +149 -0
- package/dist/verification/cross-reference-engine.js.map +1 -0
- package/dist/verification/discrepancy-tracker.d.ts +73 -0
- package/dist/verification/discrepancy-tracker.d.ts.map +1 -0
- package/dist/verification/discrepancy-tracker.js +196 -0
- package/dist/verification/discrepancy-tracker.js.map +1 -0
- package/dist/verification/feature-reconciler.d.ts +90 -0
- package/dist/verification/feature-reconciler.d.ts.map +1 -0
- package/dist/verification/feature-reconciler.js +264 -0
- package/dist/verification/feature-reconciler.js.map +1 -0
- package/dist/verification/index.d.ts +16 -0
- package/dist/verification/index.d.ts.map +1 -0
- package/dist/verification/index.js +19 -0
- package/dist/verification/index.js.map +1 -0
- package/dist/verification/integration-verifier.d.ts +66 -0
- package/dist/verification/integration-verifier.d.ts.map +1 -0
- package/dist/verification/integration-verifier.js +210 -0
- package/dist/verification/integration-verifier.js.map +1 -0
- package/dist/verification/recursive-audit-loop.d.ts +56 -0
- package/dist/verification/recursive-audit-loop.d.ts.map +1 -0
- package/dist/verification/recursive-audit-loop.js +136 -0
- package/dist/verification/recursive-audit-loop.js.map +1 -0
- package/dist/verification/runtime-verifier.d.ts +37 -0
- package/dist/verification/runtime-verifier.d.ts.map +1 -0
- package/dist/verification/runtime-verifier.js +221 -0
- package/dist/verification/runtime-verifier.js.map +1 -0
- package/dist/verification/types.d.ts +88 -0
- package/dist/verification/types.d.ts.map +1 -0
- package/dist/verification/types.js +5 -0
- package/dist/verification/types.js.map +1 -0
- package/dist/verification/verification-engine.d.ts +48 -0
- package/dist/verification/verification-engine.d.ts.map +1 -0
- package/dist/verification/verification-engine.js +203 -0
- package/dist/verification/verification-engine.js.map +1 -0
- package/opencode-agents/synapse-analyzer.md +64 -0
- package/opencode-agents/synapse-debugger.md +43 -0
- package/opencode-agents/synapse-diff-validator.md +42 -0
- package/opencode-agents/synapse-gatekeeper.md +273 -0
- package/opencode-agents/synapse-master.md +167 -0
- package/opencode-agents/synapse-planner.md +55 -0
- package/opencode-agents/synapse-researcher.md +61 -0
- package/opencode-agents/synapse-reviewer.md +64 -0
- package/opencode-agents/synapse-rewriter.md +62 -0
- package/opencode-agents/synapse-strategist.md +50 -0
- package/opencode-agents/synapse-test-runner.md +43 -0
- package/opencode-agents/synapse-ui-designer.md +61 -0
- package/opencode-agents/synapse-verifier.md +544 -0
- package/package.json +108 -0
- package/src/plugin/opencode-plugin.ts +141 -0
|
@@ -0,0 +1,925 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DeepWiki Tool - Code Analyzer
|
|
3
|
+
*
|
|
4
|
+
* Analyzes codebase structure and extracts information for documentation.
|
|
5
|
+
*/
|
|
6
|
+
import { readFileSync, existsSync, readdirSync } from "fs";
|
|
7
|
+
import { extname, basename, relative, join } from "path";
|
|
8
|
+
// ============================================================================
|
|
9
|
+
// Constants
|
|
10
|
+
// ============================================================================
|
|
11
|
+
const SUPPORTED_EXTENSIONS = [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"];
|
|
12
|
+
// ============================================================================
|
|
13
|
+
// Analyzer Class
|
|
14
|
+
// ============================================================================
|
|
15
|
+
export class DeepWikiAnalyzer {
|
|
16
|
+
config;
|
|
17
|
+
files = [];
|
|
18
|
+
cache = new Map();
|
|
19
|
+
constructor(config) {
|
|
20
|
+
this.config = config;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Analyze the entire codebase
|
|
24
|
+
*/
|
|
25
|
+
async analyze() {
|
|
26
|
+
// Discover files
|
|
27
|
+
this.files = this.discoverFiles(this.config.rootPath);
|
|
28
|
+
// Analyze project
|
|
29
|
+
const project = this.analyzeProject();
|
|
30
|
+
// Analyze modules
|
|
31
|
+
const modules = this.analyzeModules();
|
|
32
|
+
// Analyze classes
|
|
33
|
+
const classes = this.analyzeClasses();
|
|
34
|
+
// Analyze functions
|
|
35
|
+
const functions = this.analyzeFunctions();
|
|
36
|
+
// Analyze interfaces
|
|
37
|
+
const interfaces = this.analyzeInterfaces();
|
|
38
|
+
// Analyze dependencies
|
|
39
|
+
const dependencies = this.analyzeDependencies();
|
|
40
|
+
// Detect patterns
|
|
41
|
+
const patterns = this.detectPatterns();
|
|
42
|
+
// Calculate metrics
|
|
43
|
+
const metrics = this.calculateMetrics(modules, classes, functions, interfaces);
|
|
44
|
+
return {
|
|
45
|
+
project,
|
|
46
|
+
modules,
|
|
47
|
+
classes,
|
|
48
|
+
functions,
|
|
49
|
+
interfaces,
|
|
50
|
+
dependencies,
|
|
51
|
+
patterns,
|
|
52
|
+
metrics,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Discover all relevant files in the project
|
|
57
|
+
*/
|
|
58
|
+
discoverFiles(dirPath, depth = 0) {
|
|
59
|
+
if (depth > this.config.maxDepth)
|
|
60
|
+
return [];
|
|
61
|
+
const files = [];
|
|
62
|
+
try {
|
|
63
|
+
const entries = readdirSync(dirPath, { withFileTypes: true });
|
|
64
|
+
for (const entry of entries) {
|
|
65
|
+
const fullPath = join(dirPath, entry.name);
|
|
66
|
+
const relativePath = relative(this.config.rootPath, fullPath);
|
|
67
|
+
// Check exclusions
|
|
68
|
+
if (this.shouldExclude(relativePath))
|
|
69
|
+
continue;
|
|
70
|
+
if (entry.isDirectory()) {
|
|
71
|
+
files.push(...this.discoverFiles(fullPath, depth + 1));
|
|
72
|
+
}
|
|
73
|
+
else if (entry.isFile() && this.isSupportedFile(fullPath)) {
|
|
74
|
+
files.push(fullPath);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
// Skip directories we can't read
|
|
80
|
+
}
|
|
81
|
+
return files;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Check if a file should be excluded
|
|
85
|
+
*/
|
|
86
|
+
shouldExclude(path) {
|
|
87
|
+
for (const pattern of this.config.exclude) {
|
|
88
|
+
if (this.matchGlob(path, pattern))
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Check if a file is supported
|
|
95
|
+
*/
|
|
96
|
+
isSupportedFile(path) {
|
|
97
|
+
const ext = extname(path);
|
|
98
|
+
return SUPPORTED_EXTENSIONS.includes(ext);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Simple glob matching
|
|
102
|
+
*/
|
|
103
|
+
matchGlob(path, pattern) {
|
|
104
|
+
const regex = pattern
|
|
105
|
+
.replace(/\*\*/g, ".*")
|
|
106
|
+
.replace(/\*/g, "[^/]*")
|
|
107
|
+
.replace(/\?/g, ".");
|
|
108
|
+
return new RegExp(`^${regex}$`).test(path);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Read file content with caching
|
|
112
|
+
*/
|
|
113
|
+
readFile(filePath) {
|
|
114
|
+
if (this.cache.has(filePath)) {
|
|
115
|
+
return this.cache.get(filePath);
|
|
116
|
+
}
|
|
117
|
+
try {
|
|
118
|
+
const content = readFileSync(filePath, "utf-8");
|
|
119
|
+
this.cache.set(filePath, content);
|
|
120
|
+
return content;
|
|
121
|
+
}
|
|
122
|
+
catch {
|
|
123
|
+
return "";
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Analyze project information
|
|
128
|
+
*/
|
|
129
|
+
analyzeProject() {
|
|
130
|
+
const packageJsonPath = join(this.config.rootPath, "package.json");
|
|
131
|
+
let name = basename(this.config.rootPath);
|
|
132
|
+
let version = "0.0.0";
|
|
133
|
+
let description = "";
|
|
134
|
+
if (existsSync(packageJsonPath)) {
|
|
135
|
+
try {
|
|
136
|
+
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
|
|
137
|
+
name = packageJson.name || name;
|
|
138
|
+
version = packageJson.version || version;
|
|
139
|
+
description = packageJson.description || description;
|
|
140
|
+
}
|
|
141
|
+
catch {
|
|
142
|
+
// Use defaults
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
// Detect languages
|
|
146
|
+
const languages = new Set();
|
|
147
|
+
for (const file of this.files) {
|
|
148
|
+
const ext = extname(file);
|
|
149
|
+
switch (ext) {
|
|
150
|
+
case ".ts":
|
|
151
|
+
case ".tsx":
|
|
152
|
+
languages.add("TypeScript");
|
|
153
|
+
break;
|
|
154
|
+
case ".js":
|
|
155
|
+
case ".jsx":
|
|
156
|
+
case ".mjs":
|
|
157
|
+
case ".cjs":
|
|
158
|
+
languages.add("JavaScript");
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
// Detect frameworks
|
|
163
|
+
const frameworks = this.detectFrameworks();
|
|
164
|
+
// Find entry points
|
|
165
|
+
const entryPoints = this.findEntryPoints();
|
|
166
|
+
return {
|
|
167
|
+
name,
|
|
168
|
+
version,
|
|
169
|
+
description,
|
|
170
|
+
rootPath: this.config.rootPath,
|
|
171
|
+
languages: Array.from(languages),
|
|
172
|
+
frameworks,
|
|
173
|
+
entryPoints,
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Detect frameworks used in the project
|
|
178
|
+
*/
|
|
179
|
+
detectFrameworks() {
|
|
180
|
+
const frameworks = [];
|
|
181
|
+
const packageJsonPath = join(this.config.rootPath, "package.json");
|
|
182
|
+
if (existsSync(packageJsonPath)) {
|
|
183
|
+
try {
|
|
184
|
+
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
|
|
185
|
+
const allDeps = {
|
|
186
|
+
...packageJson.dependencies,
|
|
187
|
+
...packageJson.devDependencies,
|
|
188
|
+
};
|
|
189
|
+
const frameworkPatterns = {
|
|
190
|
+
react: "React",
|
|
191
|
+
vue: "Vue.js",
|
|
192
|
+
angular: "Angular",
|
|
193
|
+
svelte: "Svelte",
|
|
194
|
+
next: "Next.js",
|
|
195
|
+
nuxt: "Nuxt.js",
|
|
196
|
+
express: "Express.js",
|
|
197
|
+
fastify: "Fastify",
|
|
198
|
+
nest: "NestJS",
|
|
199
|
+
koa: "Koa.js",
|
|
200
|
+
vitest: "Vitest",
|
|
201
|
+
jest: "Jest",
|
|
202
|
+
mocha: "Mocha",
|
|
203
|
+
typescript: "TypeScript",
|
|
204
|
+
};
|
|
205
|
+
for (const [pkg, framework] of Object.entries(frameworkPatterns)) {
|
|
206
|
+
if (allDeps[pkg]) {
|
|
207
|
+
frameworks.push(framework);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
catch {
|
|
212
|
+
// Ignore errors
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
return frameworks;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Find entry points
|
|
219
|
+
*/
|
|
220
|
+
findEntryPoints() {
|
|
221
|
+
const entryPoints = [];
|
|
222
|
+
const candidates = [
|
|
223
|
+
"index.ts",
|
|
224
|
+
"index.js",
|
|
225
|
+
"src/index.ts",
|
|
226
|
+
"src/index.js",
|
|
227
|
+
"main.ts",
|
|
228
|
+
"main.js",
|
|
229
|
+
"src/main.ts",
|
|
230
|
+
"src/main.js",
|
|
231
|
+
"app.ts",
|
|
232
|
+
"app.js",
|
|
233
|
+
"src/app.ts",
|
|
234
|
+
"src/app.js",
|
|
235
|
+
];
|
|
236
|
+
for (const candidate of candidates) {
|
|
237
|
+
const fullPath = join(this.config.rootPath, candidate);
|
|
238
|
+
if (existsSync(fullPath)) {
|
|
239
|
+
entryPoints.push(candidate);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
return entryPoints;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Analyze all modules
|
|
246
|
+
*/
|
|
247
|
+
analyzeModules() {
|
|
248
|
+
const modules = [];
|
|
249
|
+
for (const file of this.files) {
|
|
250
|
+
const content = this.readFile(file);
|
|
251
|
+
if (!content)
|
|
252
|
+
continue;
|
|
253
|
+
const moduleInfo = this.analyzeModule(file, content);
|
|
254
|
+
modules.push(moduleInfo);
|
|
255
|
+
}
|
|
256
|
+
return modules;
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Analyze a single module
|
|
260
|
+
*/
|
|
261
|
+
analyzeModule(filePath, content) {
|
|
262
|
+
const relativePath = relative(this.config.rootPath, filePath);
|
|
263
|
+
const name = basename(filePath, extname(filePath));
|
|
264
|
+
// Extract imports
|
|
265
|
+
const imports = this.extractImports(content);
|
|
266
|
+
// Extract exports
|
|
267
|
+
const exports = this.extractExports(content);
|
|
268
|
+
// Extract classes
|
|
269
|
+
const classes = this.extractClassNames(content);
|
|
270
|
+
// Extract functions
|
|
271
|
+
const functions = this.extractFunctionNames(content);
|
|
272
|
+
// Extract interfaces
|
|
273
|
+
const interfaces = this.extractInterfaceNames(content);
|
|
274
|
+
// Extract types
|
|
275
|
+
const types = this.extractTypeNames(content);
|
|
276
|
+
// Calculate complexity
|
|
277
|
+
const complexity = this.calculateFileComplexity(content);
|
|
278
|
+
// Count lines
|
|
279
|
+
const linesOfCode = content.split("\n").length;
|
|
280
|
+
// Extract description from first JSDoc comment
|
|
281
|
+
const description = this.extractFileDescription(content);
|
|
282
|
+
return {
|
|
283
|
+
path: relativePath,
|
|
284
|
+
name,
|
|
285
|
+
description,
|
|
286
|
+
exports,
|
|
287
|
+
imports,
|
|
288
|
+
classes,
|
|
289
|
+
functions,
|
|
290
|
+
interfaces,
|
|
291
|
+
types,
|
|
292
|
+
complexity,
|
|
293
|
+
linesOfCode,
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Extract imports from content
|
|
298
|
+
*/
|
|
299
|
+
extractImports(content) {
|
|
300
|
+
const imports = [];
|
|
301
|
+
let match;
|
|
302
|
+
const importRegex = /import\s+(?:{([^}]+)}|(\w+)|\*\s+as\s+(\w+))\s+from\s+['"]([^'"]+)['"]/g;
|
|
303
|
+
while ((match = importRegex.exec(content)) !== null) {
|
|
304
|
+
const modulePath = match[4];
|
|
305
|
+
if (modulePath && !modulePath.startsWith(".")) {
|
|
306
|
+
imports.push(modulePath);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
return [...new Set(imports)];
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Extract exports from content
|
|
313
|
+
*/
|
|
314
|
+
extractExports(content) {
|
|
315
|
+
const exports = [];
|
|
316
|
+
let match;
|
|
317
|
+
const exportRegex = /export\s+(?:default\s+)?(?:class|interface|function|const|let|var|type|enum)\s+(\w+)/g;
|
|
318
|
+
while ((match = exportRegex.exec(content)) !== null) {
|
|
319
|
+
if (match[1]) {
|
|
320
|
+
exports.push(match[1]);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
return [...new Set(exports)];
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Extract class names from content
|
|
327
|
+
*/
|
|
328
|
+
extractClassNames(content) {
|
|
329
|
+
const classes = [];
|
|
330
|
+
let match;
|
|
331
|
+
const classRegex = /class\s+(\w+)/g;
|
|
332
|
+
while ((match = classRegex.exec(content)) !== null) {
|
|
333
|
+
if (match[1]) {
|
|
334
|
+
classes.push(match[1]);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
return classes;
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Extract function names from content
|
|
341
|
+
*/
|
|
342
|
+
extractFunctionNames(content) {
|
|
343
|
+
const functions = [];
|
|
344
|
+
let match;
|
|
345
|
+
// Named functions
|
|
346
|
+
const funcRegex = /(?:export\s+)?(?:async\s+)?function\s+(\w+)/g;
|
|
347
|
+
while ((match = funcRegex.exec(content)) !== null) {
|
|
348
|
+
if (match[1]) {
|
|
349
|
+
functions.push(match[1]);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
// Arrow functions
|
|
353
|
+
const arrowRegex = /(?:export\s+)?(?:const|let)\s+(\w+)\s*=\s*(?:async\s+)?\(/g;
|
|
354
|
+
while ((match = arrowRegex.exec(content)) !== null) {
|
|
355
|
+
if (match[1] && !functions.includes(match[1])) {
|
|
356
|
+
functions.push(match[1]);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
return functions;
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* Extract interface names from content
|
|
363
|
+
*/
|
|
364
|
+
extractInterfaceNames(content) {
|
|
365
|
+
const interfaces = [];
|
|
366
|
+
let match;
|
|
367
|
+
const interfaceRegex = /interface\s+(\w+)/g;
|
|
368
|
+
while ((match = interfaceRegex.exec(content)) !== null) {
|
|
369
|
+
if (match[1]) {
|
|
370
|
+
interfaces.push(match[1]);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
return interfaces;
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* Extract type names from content
|
|
377
|
+
*/
|
|
378
|
+
extractTypeNames(content) {
|
|
379
|
+
const types = [];
|
|
380
|
+
let match;
|
|
381
|
+
const typeRegex = /type\s+(\w+)/g;
|
|
382
|
+
while ((match = typeRegex.exec(content)) !== null) {
|
|
383
|
+
if (match[1]) {
|
|
384
|
+
types.push(match[1]);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
return types;
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* Calculate file complexity
|
|
391
|
+
*/
|
|
392
|
+
calculateFileComplexity(content) {
|
|
393
|
+
let complexity = 1;
|
|
394
|
+
// Count decision points
|
|
395
|
+
const decisionPatterns = [
|
|
396
|
+
/\bif\s*\(/g,
|
|
397
|
+
/\belse\s+if\s*\(/g,
|
|
398
|
+
/\bfor\s*\(/g,
|
|
399
|
+
/\bwhile\s*\(/g,
|
|
400
|
+
/\bcase\s+/g,
|
|
401
|
+
/\bcatch\s*\(/g,
|
|
402
|
+
/\?\s*[^:]/g, // Ternary operators
|
|
403
|
+
/&&/g,
|
|
404
|
+
/\|\|/g,
|
|
405
|
+
];
|
|
406
|
+
for (const pattern of decisionPatterns) {
|
|
407
|
+
const matches = content.match(pattern);
|
|
408
|
+
if (matches) {
|
|
409
|
+
complexity += matches.length;
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
return complexity;
|
|
413
|
+
}
|
|
414
|
+
/**
|
|
415
|
+
* Extract file description from first JSDoc comment
|
|
416
|
+
*/
|
|
417
|
+
extractFileDescription(content) {
|
|
418
|
+
const jsdocRegex = /\/\*\*([\s\S]*?)\*\//;
|
|
419
|
+
const match = content.match(jsdocRegex);
|
|
420
|
+
if (match) {
|
|
421
|
+
const jsdoc = match[1].replace(/^\s*\*\s?/gm, "").trim();
|
|
422
|
+
return jsdoc.split("\n")[0] || "";
|
|
423
|
+
}
|
|
424
|
+
return "";
|
|
425
|
+
}
|
|
426
|
+
/**
|
|
427
|
+
* Analyze all classes
|
|
428
|
+
*/
|
|
429
|
+
analyzeClasses() {
|
|
430
|
+
const classes = [];
|
|
431
|
+
for (const file of this.files) {
|
|
432
|
+
const content = this.readFile(file);
|
|
433
|
+
if (!content)
|
|
434
|
+
continue;
|
|
435
|
+
const fileClasses = this.extractClasses(file, content);
|
|
436
|
+
classes.push(...fileClasses);
|
|
437
|
+
}
|
|
438
|
+
return classes;
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* Extract classes from file content
|
|
442
|
+
*/
|
|
443
|
+
extractClasses(filePath, content) {
|
|
444
|
+
const classes = [];
|
|
445
|
+
const lines = content.split("\n");
|
|
446
|
+
const relativePath = relative(this.config.rootPath, filePath);
|
|
447
|
+
let currentClass = null;
|
|
448
|
+
let braceCount = 0;
|
|
449
|
+
for (let i = 0; i < lines.length; i++) {
|
|
450
|
+
const line = lines[i];
|
|
451
|
+
// Check for class declaration
|
|
452
|
+
const classMatch = line.match(/(?:export\s+)?(?:abstract\s+)?class\s+(\w+)(?:\s+extends\s+(\w+))?(?:\s+implements\s+([\w,\s]+))?\s*\{/);
|
|
453
|
+
if (classMatch) {
|
|
454
|
+
currentClass = {
|
|
455
|
+
name: classMatch[1],
|
|
456
|
+
module: relativePath,
|
|
457
|
+
description: this.extractJsDocAbove(lines, i),
|
|
458
|
+
methods: [],
|
|
459
|
+
properties: [],
|
|
460
|
+
extends: classMatch[2],
|
|
461
|
+
implements: classMatch[3]?.split(",").map((s) => s.trim()) || [],
|
|
462
|
+
isAbstract: line.includes("abstract"),
|
|
463
|
+
isExported: line.includes("export"),
|
|
464
|
+
lineStart: i + 1,
|
|
465
|
+
lineEnd: 0,
|
|
466
|
+
};
|
|
467
|
+
braceCount = 1;
|
|
468
|
+
continue;
|
|
469
|
+
}
|
|
470
|
+
if (currentClass) {
|
|
471
|
+
// Count braces
|
|
472
|
+
braceCount += (line.match(/\{/g) || []).length;
|
|
473
|
+
braceCount -= (line.match(/\}/g) || []).length;
|
|
474
|
+
// Check for method
|
|
475
|
+
const methodMatch = line.match(/^\s+(public|private|protected)?\s*(static)?\s*(async)?\s*(\w+)\s*\(([^)]*)\)\s*(?::\s*(\w+))?\s*\{/);
|
|
476
|
+
if (methodMatch && currentClass.methods) {
|
|
477
|
+
currentClass.methods.push({
|
|
478
|
+
name: methodMatch[4],
|
|
479
|
+
description: "",
|
|
480
|
+
parameters: this.parseParameters(methodMatch[5]),
|
|
481
|
+
returnType: methodMatch[6] || "void",
|
|
482
|
+
visibility: methodMatch[1] ||
|
|
483
|
+
"public",
|
|
484
|
+
isStatic: !!methodMatch[2],
|
|
485
|
+
isAsync: !!methodMatch[3],
|
|
486
|
+
lineStart: i + 1,
|
|
487
|
+
lineEnd: 0,
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
|
+
// Check for property
|
|
491
|
+
const propertyMatch = line.match(/^\s+(public|private|protected)?\s*(static)?\s*(readonly)?\s*(\w+)\s*:\s*([^;=]+)/);
|
|
492
|
+
if (propertyMatch && currentClass.properties) {
|
|
493
|
+
currentClass.properties.push({
|
|
494
|
+
name: propertyMatch[4],
|
|
495
|
+
description: "",
|
|
496
|
+
type: propertyMatch[5].trim(),
|
|
497
|
+
visibility: propertyMatch[1] ||
|
|
498
|
+
"public",
|
|
499
|
+
isStatic: !!propertyMatch[2],
|
|
500
|
+
isReadonly: !!propertyMatch[3],
|
|
501
|
+
});
|
|
502
|
+
}
|
|
503
|
+
// Check if class ended
|
|
504
|
+
if (braceCount === 0) {
|
|
505
|
+
currentClass.lineEnd = i + 1;
|
|
506
|
+
classes.push(currentClass);
|
|
507
|
+
currentClass = null;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
return classes;
|
|
512
|
+
}
|
|
513
|
+
/**
|
|
514
|
+
* Extract JSDoc comment above a line
|
|
515
|
+
*/
|
|
516
|
+
extractJsDocAbove(lines, lineIndex) {
|
|
517
|
+
let jsdoc = "";
|
|
518
|
+
let i = lineIndex - 1;
|
|
519
|
+
// Skip empty lines
|
|
520
|
+
while (i >= 0 && lines[i].trim() === "")
|
|
521
|
+
i--;
|
|
522
|
+
// Check for JSDoc end
|
|
523
|
+
if (i >= 0 && lines[i].includes("*/")) {
|
|
524
|
+
const jsdocLines = [];
|
|
525
|
+
while (i >= 0) {
|
|
526
|
+
jsdocLines.unshift(lines[i]);
|
|
527
|
+
if (lines[i].includes("/**"))
|
|
528
|
+
break;
|
|
529
|
+
i--;
|
|
530
|
+
}
|
|
531
|
+
jsdoc = jsdocLines
|
|
532
|
+
.join("\n")
|
|
533
|
+
.replace(/\/\*\*|\*\//g, "")
|
|
534
|
+
.replace(/^\s*\*\s?/gm, "")
|
|
535
|
+
.trim();
|
|
536
|
+
}
|
|
537
|
+
return jsdoc;
|
|
538
|
+
}
|
|
539
|
+
/**
|
|
540
|
+
* Parse function parameters
|
|
541
|
+
*/
|
|
542
|
+
parseParameters(params) {
|
|
543
|
+
if (!params.trim())
|
|
544
|
+
return [];
|
|
545
|
+
return params.split(",").map((param) => {
|
|
546
|
+
const parts = param.trim().split(":");
|
|
547
|
+
const name = parts[0]?.replace(/\??$/, "").trim() || "";
|
|
548
|
+
const type = parts[1]?.trim() || "any";
|
|
549
|
+
const isOptional = param.includes("?") || param.includes("=");
|
|
550
|
+
return {
|
|
551
|
+
name,
|
|
552
|
+
type,
|
|
553
|
+
description: "",
|
|
554
|
+
isOptional,
|
|
555
|
+
};
|
|
556
|
+
});
|
|
557
|
+
}
|
|
558
|
+
/**
|
|
559
|
+
* Analyze all functions
|
|
560
|
+
*/
|
|
561
|
+
analyzeFunctions() {
|
|
562
|
+
const functions = [];
|
|
563
|
+
for (const file of this.files) {
|
|
564
|
+
const content = this.readFile(file);
|
|
565
|
+
if (!content)
|
|
566
|
+
continue;
|
|
567
|
+
const fileFunctions = this.extractFunctions(file, content);
|
|
568
|
+
functions.push(...fileFunctions);
|
|
569
|
+
}
|
|
570
|
+
return functions;
|
|
571
|
+
}
|
|
572
|
+
/**
|
|
573
|
+
* Extract functions from file content
|
|
574
|
+
*/
|
|
575
|
+
extractFunctions(filePath, content) {
|
|
576
|
+
const functions = [];
|
|
577
|
+
const relativePath = relative(this.config.rootPath, filePath);
|
|
578
|
+
const lines = content.split("\n");
|
|
579
|
+
// Named functions
|
|
580
|
+
const funcRegex = /(?:export\s+)?(?:async\s+)?function\s+(\w+)\s*\(([^)]*)\)\s*(?::\s*(\w+))?\s*\{/g;
|
|
581
|
+
let match;
|
|
582
|
+
while ((match = funcRegex.exec(content)) !== null) {
|
|
583
|
+
const lineNumber = content.substring(0, match.index).split("\n").length;
|
|
584
|
+
functions.push({
|
|
585
|
+
name: match[1],
|
|
586
|
+
module: relativePath,
|
|
587
|
+
description: this.extractJsDocAbove(lines, lineNumber - 1),
|
|
588
|
+
parameters: this.parseParameters(match[2]),
|
|
589
|
+
returnType: match[3] || "void",
|
|
590
|
+
isExported: match[0].includes("export"),
|
|
591
|
+
isAsync: match[0].includes("async"),
|
|
592
|
+
lineStart: lineNumber,
|
|
593
|
+
lineEnd: 0,
|
|
594
|
+
});
|
|
595
|
+
}
|
|
596
|
+
return functions;
|
|
597
|
+
}
|
|
598
|
+
/**
|
|
599
|
+
* Analyze all interfaces
|
|
600
|
+
*/
|
|
601
|
+
analyzeInterfaces() {
|
|
602
|
+
const interfaces = [];
|
|
603
|
+
for (const file of this.files) {
|
|
604
|
+
const content = this.readFile(file);
|
|
605
|
+
if (!content)
|
|
606
|
+
continue;
|
|
607
|
+
const fileInterfaces = this.extractInterfaces(file, content);
|
|
608
|
+
interfaces.push(...fileInterfaces);
|
|
609
|
+
}
|
|
610
|
+
return interfaces;
|
|
611
|
+
}
|
|
612
|
+
/**
|
|
613
|
+
* Extract interfaces from file content
|
|
614
|
+
*/
|
|
615
|
+
extractInterfaces(filePath, content) {
|
|
616
|
+
const interfaces = [];
|
|
617
|
+
const relativePath = relative(this.config.rootPath, filePath);
|
|
618
|
+
const lines = content.split("\n");
|
|
619
|
+
const interfaceRegex = /(?:export\s+)?interface\s+(\w+)(?:\s+extends\s+([\w,\s]+))?\s*\{/g;
|
|
620
|
+
let match;
|
|
621
|
+
while ((match = interfaceRegex.exec(content)) !== null) {
|
|
622
|
+
const lineNumber = content.substring(0, match.index).split("\n").length;
|
|
623
|
+
// Find interface body
|
|
624
|
+
let braceCount = 1;
|
|
625
|
+
let endIndex = lineNumber;
|
|
626
|
+
for (let i = lineNumber; i < lines.length; i++) {
|
|
627
|
+
braceCount += (lines[i].match(/\{/g) || []).length;
|
|
628
|
+
braceCount -= (lines[i].match(/\}/g) || []).length;
|
|
629
|
+
if (braceCount === 0) {
|
|
630
|
+
endIndex = i + 1;
|
|
631
|
+
break;
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
// Extract properties and methods from interface body
|
|
635
|
+
const interfaceBody = lines.slice(lineNumber - 1, endIndex).join("\n");
|
|
636
|
+
const properties = this.extractInterfaceProperties(interfaceBody);
|
|
637
|
+
const methods = this.extractInterfaceMethods(interfaceBody);
|
|
638
|
+
interfaces.push({
|
|
639
|
+
name: match[1],
|
|
640
|
+
module: relativePath,
|
|
641
|
+
description: this.extractJsDocAbove(lines, lineNumber - 1),
|
|
642
|
+
properties,
|
|
643
|
+
methods,
|
|
644
|
+
extends: match[2]?.split(",").map((s) => s.trim()) || [],
|
|
645
|
+
isExported: match[0].includes("export"),
|
|
646
|
+
lineStart: lineNumber,
|
|
647
|
+
lineEnd: endIndex,
|
|
648
|
+
});
|
|
649
|
+
}
|
|
650
|
+
return interfaces;
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* Extract properties from interface body
|
|
654
|
+
*/
|
|
655
|
+
extractInterfaceProperties(body) {
|
|
656
|
+
const properties = [];
|
|
657
|
+
const propRegex = /^\s+(\w+)\??\s*:\s*([^;]+)/gm;
|
|
658
|
+
let match;
|
|
659
|
+
while ((match = propRegex.exec(body)) !== null) {
|
|
660
|
+
properties.push({
|
|
661
|
+
name: match[1],
|
|
662
|
+
description: "",
|
|
663
|
+
type: match[2].trim(),
|
|
664
|
+
visibility: "public",
|
|
665
|
+
isStatic: false,
|
|
666
|
+
isReadonly: body.includes(`readonly ${match[1]}`),
|
|
667
|
+
});
|
|
668
|
+
}
|
|
669
|
+
return properties;
|
|
670
|
+
}
|
|
671
|
+
/**
|
|
672
|
+
* Extract methods from interface body
|
|
673
|
+
*/
|
|
674
|
+
extractInterfaceMethods(body) {
|
|
675
|
+
const methods = [];
|
|
676
|
+
const methodRegex = /^\s+(\w+)\s*\(([^)]*)\)\s*:\s*([^;]+)/gm;
|
|
677
|
+
let match;
|
|
678
|
+
while ((match = methodRegex.exec(body)) !== null) {
|
|
679
|
+
methods.push({
|
|
680
|
+
name: match[1],
|
|
681
|
+
description: "",
|
|
682
|
+
parameters: this.parseParameters(match[2]),
|
|
683
|
+
returnType: match[3].trim(),
|
|
684
|
+
visibility: "public",
|
|
685
|
+
isStatic: false,
|
|
686
|
+
isAsync: false,
|
|
687
|
+
lineStart: 0,
|
|
688
|
+
lineEnd: 0,
|
|
689
|
+
});
|
|
690
|
+
}
|
|
691
|
+
return methods;
|
|
692
|
+
}
|
|
693
|
+
/**
|
|
694
|
+
* Analyze dependencies
|
|
695
|
+
*/
|
|
696
|
+
analyzeDependencies() {
|
|
697
|
+
const dependencies = [];
|
|
698
|
+
const packageJsonPath = join(this.config.rootPath, "package.json");
|
|
699
|
+
if (!existsSync(packageJsonPath)) {
|
|
700
|
+
return dependencies;
|
|
701
|
+
}
|
|
702
|
+
try {
|
|
703
|
+
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
|
|
704
|
+
// Production dependencies
|
|
705
|
+
if (packageJson.dependencies) {
|
|
706
|
+
for (const [name, version] of Object.entries(packageJson.dependencies)) {
|
|
707
|
+
dependencies.push({
|
|
708
|
+
name,
|
|
709
|
+
version: version,
|
|
710
|
+
type: "production",
|
|
711
|
+
description: "",
|
|
712
|
+
usedBy: this.findDependencyUsage(name),
|
|
713
|
+
});
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
// Development dependencies
|
|
717
|
+
if (packageJson.devDependencies) {
|
|
718
|
+
for (const [name, version] of Object.entries(packageJson.devDependencies)) {
|
|
719
|
+
dependencies.push({
|
|
720
|
+
name,
|
|
721
|
+
version: version,
|
|
722
|
+
type: "development",
|
|
723
|
+
description: "",
|
|
724
|
+
usedBy: this.findDependencyUsage(name),
|
|
725
|
+
});
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
catch {
|
|
730
|
+
// Ignore errors
|
|
731
|
+
}
|
|
732
|
+
return dependencies;
|
|
733
|
+
}
|
|
734
|
+
/**
|
|
735
|
+
* Find which files use a dependency
|
|
736
|
+
*/
|
|
737
|
+
findDependencyUsage(depName) {
|
|
738
|
+
const usedBy = [];
|
|
739
|
+
for (const file of this.files) {
|
|
740
|
+
const content = this.readFile(file);
|
|
741
|
+
if ((content && content.includes(`from "${depName}"`)) ||
|
|
742
|
+
content.includes(`from '${depName}'`)) {
|
|
743
|
+
usedBy.push(relative(this.config.rootPath, file));
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
return usedBy;
|
|
747
|
+
}
|
|
748
|
+
/**
|
|
749
|
+
* Detect patterns in the codebase
|
|
750
|
+
*/
|
|
751
|
+
detectPatterns() {
|
|
752
|
+
const patterns = [];
|
|
753
|
+
// Detect singleton pattern
|
|
754
|
+
const singletonPattern = this.detectSingletonPattern();
|
|
755
|
+
if (singletonPattern)
|
|
756
|
+
patterns.push(singletonPattern);
|
|
757
|
+
// Detect factory pattern
|
|
758
|
+
const factoryPattern = this.detectFactoryPattern();
|
|
759
|
+
if (factoryPattern)
|
|
760
|
+
patterns.push(factoryPattern);
|
|
761
|
+
// Detect observer pattern
|
|
762
|
+
const observerPattern = this.detectObserverPattern();
|
|
763
|
+
if (observerPattern)
|
|
764
|
+
patterns.push(observerPattern);
|
|
765
|
+
// Detect middleware pattern
|
|
766
|
+
const middlewarePattern = this.detectMiddlewarePattern();
|
|
767
|
+
if (middlewarePattern)
|
|
768
|
+
patterns.push(middlewarePattern);
|
|
769
|
+
return patterns;
|
|
770
|
+
}
|
|
771
|
+
/**
|
|
772
|
+
* Detect singleton pattern
|
|
773
|
+
*/
|
|
774
|
+
detectSingletonPattern() {
|
|
775
|
+
const occurrences = [];
|
|
776
|
+
for (const file of this.files) {
|
|
777
|
+
const content = this.readFile(file);
|
|
778
|
+
if (!content)
|
|
779
|
+
continue;
|
|
780
|
+
// Look for singleton indicators
|
|
781
|
+
if (content.includes("private static instance") ||
|
|
782
|
+
content.includes("static getInstance") ||
|
|
783
|
+
content.includes("private constructor")) {
|
|
784
|
+
occurrences.push({
|
|
785
|
+
file: relative(this.config.rootPath, file),
|
|
786
|
+
lineStart: 1,
|
|
787
|
+
lineEnd: content.split("\n").length,
|
|
788
|
+
description: "Singleton pattern detected",
|
|
789
|
+
});
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
if (occurrences.length === 0)
|
|
793
|
+
return null;
|
|
794
|
+
return {
|
|
795
|
+
name: "Singleton",
|
|
796
|
+
type: "singleton",
|
|
797
|
+
description: "Ensures a class has only one instance and provides a global point of access to it",
|
|
798
|
+
occurrences,
|
|
799
|
+
confidence: 0.8,
|
|
800
|
+
};
|
|
801
|
+
}
|
|
802
|
+
/**
|
|
803
|
+
* Detect factory pattern
|
|
804
|
+
*/
|
|
805
|
+
detectFactoryPattern() {
|
|
806
|
+
const occurrences = [];
|
|
807
|
+
for (const file of this.files) {
|
|
808
|
+
const content = this.readFile(file);
|
|
809
|
+
if (!content)
|
|
810
|
+
continue;
|
|
811
|
+
// Look for factory indicators
|
|
812
|
+
if (content.includes("create") &&
|
|
813
|
+
(content.includes("Factory") || content.includes("factory"))) {
|
|
814
|
+
occurrences.push({
|
|
815
|
+
file: relative(this.config.rootPath, file),
|
|
816
|
+
lineStart: 1,
|
|
817
|
+
lineEnd: content.split("\n").length,
|
|
818
|
+
description: "Factory pattern detected",
|
|
819
|
+
});
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
if (occurrences.length === 0)
|
|
823
|
+
return null;
|
|
824
|
+
return {
|
|
825
|
+
name: "Factory",
|
|
826
|
+
type: "factory",
|
|
827
|
+
description: "Provides an interface for creating objects without specifying their concrete classes",
|
|
828
|
+
occurrences,
|
|
829
|
+
confidence: 0.7,
|
|
830
|
+
};
|
|
831
|
+
}
|
|
832
|
+
/**
|
|
833
|
+
* Detect observer pattern
|
|
834
|
+
*/
|
|
835
|
+
detectObserverPattern() {
|
|
836
|
+
const occurrences = [];
|
|
837
|
+
for (const file of this.files) {
|
|
838
|
+
const content = this.readFile(file);
|
|
839
|
+
if (!content)
|
|
840
|
+
continue;
|
|
841
|
+
// Look for observer indicators
|
|
842
|
+
if ((content.includes("subscribe") || content.includes("on(")) &&
|
|
843
|
+
(content.includes("emit") || content.includes("publish"))) {
|
|
844
|
+
occurrences.push({
|
|
845
|
+
file: relative(this.config.rootPath, file),
|
|
846
|
+
lineStart: 1,
|
|
847
|
+
lineEnd: content.split("\n").length,
|
|
848
|
+
description: "Observer pattern detected",
|
|
849
|
+
});
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
if (occurrences.length === 0)
|
|
853
|
+
return null;
|
|
854
|
+
return {
|
|
855
|
+
name: "Observer",
|
|
856
|
+
type: "observer",
|
|
857
|
+
description: "Defines a one-to-many dependency between objects so that when one object changes state, all its dependents are notified",
|
|
858
|
+
occurrences,
|
|
859
|
+
confidence: 0.75,
|
|
860
|
+
};
|
|
861
|
+
}
|
|
862
|
+
/**
|
|
863
|
+
* Detect middleware pattern
|
|
864
|
+
*/
|
|
865
|
+
detectMiddlewarePattern() {
|
|
866
|
+
const occurrences = [];
|
|
867
|
+
for (const file of this.files) {
|
|
868
|
+
const content = this.readFile(file);
|
|
869
|
+
if (!content)
|
|
870
|
+
continue;
|
|
871
|
+
// Look for middleware indicators
|
|
872
|
+
if (content.includes("middleware") ||
|
|
873
|
+
content.includes("use(") ||
|
|
874
|
+
content.includes("next()")) {
|
|
875
|
+
occurrences.push({
|
|
876
|
+
file: relative(this.config.rootPath, file),
|
|
877
|
+
lineStart: 1,
|
|
878
|
+
lineEnd: content.split("\n").length,
|
|
879
|
+
description: "Middleware pattern detected",
|
|
880
|
+
});
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
if (occurrences.length === 0)
|
|
884
|
+
return null;
|
|
885
|
+
return {
|
|
886
|
+
name: "Middleware",
|
|
887
|
+
type: "middleware",
|
|
888
|
+
description: "Allows behavior to be added to an object dynamically without affecting other objects",
|
|
889
|
+
occurrences,
|
|
890
|
+
confidence: 0.8,
|
|
891
|
+
};
|
|
892
|
+
}
|
|
893
|
+
/**
|
|
894
|
+
* Calculate codebase metrics
|
|
895
|
+
*/
|
|
896
|
+
calculateMetrics(modules, classes, functions, interfaces) {
|
|
897
|
+
const totalLines = modules.reduce((sum, m) => sum + m.linesOfCode, 0);
|
|
898
|
+
const totalComplexity = modules.reduce((sum, m) => sum + m.complexity, 0);
|
|
899
|
+
return {
|
|
900
|
+
totalFiles: this.files.length,
|
|
901
|
+
totalLines,
|
|
902
|
+
totalModules: modules.length,
|
|
903
|
+
totalClasses: classes.length,
|
|
904
|
+
totalFunctions: functions.length,
|
|
905
|
+
totalInterfaces: interfaces.length,
|
|
906
|
+
averageComplexity: modules.length > 0 ? totalComplexity / modules.length : 0,
|
|
907
|
+
documentationCoverage: this.calculateDocumentationCoverage(modules),
|
|
908
|
+
};
|
|
909
|
+
}
|
|
910
|
+
/**
|
|
911
|
+
* Calculate documentation coverage
|
|
912
|
+
*/
|
|
913
|
+
calculateDocumentationCoverage(modules) {
|
|
914
|
+
const documented = modules.filter((m) => m.description.length > 0).length;
|
|
915
|
+
return modules.length > 0 ? (documented / modules.length) * 100 : 0;
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
// ============================================================================
|
|
919
|
+
// Factory Function
|
|
920
|
+
// ============================================================================
|
|
921
|
+
export function createDeepWikiAnalyzer(config) {
|
|
922
|
+
return new DeepWikiAnalyzer(config);
|
|
923
|
+
}
|
|
924
|
+
export default DeepWikiAnalyzer;
|
|
925
|
+
//# sourceMappingURL=analyzer.js.map
|