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,880 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Context System - Pattern Learning and Knowledge Management
|
|
3
|
+
*
|
|
4
|
+
* Inspired by OpenAgentsControl's context system for learning user patterns
|
|
5
|
+
* and providing context-aware code generation.
|
|
6
|
+
*/
|
|
7
|
+
import { v4 as uuidv4 } from "uuid";
|
|
8
|
+
import { writeFileSync, readFileSync, existsSync, mkdirSync, readdirSync, } from "fs";
|
|
9
|
+
import { join, extname } from "path";
|
|
10
|
+
import { homedir } from "os";
|
|
11
|
+
export class ContextSystem {
|
|
12
|
+
contextDir;
|
|
13
|
+
projectRoot;
|
|
14
|
+
projectContext;
|
|
15
|
+
globalPatterns = [];
|
|
16
|
+
constructor(projectRoot) {
|
|
17
|
+
this.projectRoot = projectRoot ?? null;
|
|
18
|
+
this.contextDir = projectRoot
|
|
19
|
+
? join(projectRoot, ".synapsexcoder", "context")
|
|
20
|
+
: join(homedir(), ".synapsexcoder", "context");
|
|
21
|
+
// Ensure directories exist
|
|
22
|
+
if (!existsSync(this.contextDir)) {
|
|
23
|
+
mkdirSync(this.contextDir, { recursive: true });
|
|
24
|
+
}
|
|
25
|
+
this.projectContext = this.loadProjectContext();
|
|
26
|
+
this.loadGlobalPatterns();
|
|
27
|
+
}
|
|
28
|
+
// ========================================================================
|
|
29
|
+
// Project Context Management
|
|
30
|
+
// ========================================================================
|
|
31
|
+
loadProjectContext() {
|
|
32
|
+
const contextPath = join(this.contextDir, "project.json");
|
|
33
|
+
if (existsSync(contextPath)) {
|
|
34
|
+
try {
|
|
35
|
+
const content = readFileSync(contextPath, "utf-8");
|
|
36
|
+
return JSON.parse(content);
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
console.warn("Failed to load project context:", error);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
// Create default context
|
|
43
|
+
return {
|
|
44
|
+
id: uuidv4(),
|
|
45
|
+
name: "Unnamed Project",
|
|
46
|
+
techStack: [],
|
|
47
|
+
patterns: [],
|
|
48
|
+
standards: {
|
|
49
|
+
naming: {},
|
|
50
|
+
security: [],
|
|
51
|
+
performance: [],
|
|
52
|
+
codeQuality: [],
|
|
53
|
+
},
|
|
54
|
+
integrations: [],
|
|
55
|
+
createdAt: Date.now(),
|
|
56
|
+
updatedAt: Date.now(),
|
|
57
|
+
version: 1,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
saveProjectContext() {
|
|
61
|
+
const contextPath = join(this.contextDir, "project.json");
|
|
62
|
+
writeFileSync(contextPath, JSON.stringify(this.projectContext, null, 2));
|
|
63
|
+
}
|
|
64
|
+
loadGlobalPatterns() {
|
|
65
|
+
const globalDir = join(homedir(), ".synapsexcoder", "context", "global");
|
|
66
|
+
if (!existsSync(globalDir)) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
// Load global patterns (universal standards)
|
|
70
|
+
const patternsPath = join(globalDir, "patterns.json");
|
|
71
|
+
if (existsSync(patternsPath)) {
|
|
72
|
+
try {
|
|
73
|
+
const content = readFileSync(patternsPath, "utf-8");
|
|
74
|
+
this.globalPatterns = JSON.parse(content);
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
console.warn("Failed to load global patterns:", error);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
// ========================================================================
|
|
82
|
+
// Pattern Learning
|
|
83
|
+
// ========================================================================
|
|
84
|
+
addPattern(pattern) {
|
|
85
|
+
const newPattern = {
|
|
86
|
+
...pattern,
|
|
87
|
+
id: uuidv4(),
|
|
88
|
+
createdAt: Date.now(),
|
|
89
|
+
updatedAt: Date.now(),
|
|
90
|
+
version: 1,
|
|
91
|
+
};
|
|
92
|
+
this.projectContext.patterns.push(newPattern);
|
|
93
|
+
this.projectContext.updatedAt = Date.now();
|
|
94
|
+
this.projectContext.version++;
|
|
95
|
+
this.saveProjectContext();
|
|
96
|
+
return newPattern.id;
|
|
97
|
+
}
|
|
98
|
+
updatePattern(id, updates) {
|
|
99
|
+
const pattern = this.projectContext.patterns.find((p) => p.id === id);
|
|
100
|
+
if (!pattern)
|
|
101
|
+
return false;
|
|
102
|
+
Object.assign(pattern, updates, {
|
|
103
|
+
updatedAt: Date.now(),
|
|
104
|
+
version: pattern.version + 1,
|
|
105
|
+
});
|
|
106
|
+
this.projectContext.updatedAt = Date.now();
|
|
107
|
+
this.projectContext.version++;
|
|
108
|
+
this.saveProjectContext();
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
111
|
+
removePattern(id) {
|
|
112
|
+
const index = this.projectContext.patterns.findIndex((p) => p.id === id);
|
|
113
|
+
if (index === -1)
|
|
114
|
+
return false;
|
|
115
|
+
this.projectContext.patterns.splice(index, 1);
|
|
116
|
+
this.projectContext.updatedAt = Date.now();
|
|
117
|
+
this.projectContext.version++;
|
|
118
|
+
this.saveProjectContext();
|
|
119
|
+
return true;
|
|
120
|
+
}
|
|
121
|
+
// ========================================================================
|
|
122
|
+
// Context Discovery
|
|
123
|
+
// ========================================================================
|
|
124
|
+
findRelevantPatterns(query) {
|
|
125
|
+
const allPatterns = [
|
|
126
|
+
...this.projectContext.patterns,
|
|
127
|
+
...this.globalPatterns,
|
|
128
|
+
];
|
|
129
|
+
let filtered = allPatterns;
|
|
130
|
+
// Filter by type
|
|
131
|
+
if (query.type) {
|
|
132
|
+
filtered = filtered.filter((p) => p.type === query.type);
|
|
133
|
+
}
|
|
134
|
+
// Filter by tags
|
|
135
|
+
if (query.tags && query.tags.length > 0) {
|
|
136
|
+
filtered = filtered.filter((p) => query.tags.some((tag) => p.tags.includes(tag)));
|
|
137
|
+
}
|
|
138
|
+
// Filter by keywords
|
|
139
|
+
if (query.keywords && query.keywords.length > 0) {
|
|
140
|
+
filtered = filtered.filter((p) => {
|
|
141
|
+
const searchText = `${p.name} ${p.description} ${p.tags.join(" ")}`.toLowerCase();
|
|
142
|
+
return query.keywords.some((keyword) => searchText.includes(keyword.toLowerCase()));
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
// Sort by relevance (simple scoring)
|
|
146
|
+
filtered.sort((a, b) => {
|
|
147
|
+
let scoreA = 0;
|
|
148
|
+
let scoreB = 0;
|
|
149
|
+
// Prefer project patterns over global
|
|
150
|
+
if (this.projectContext.patterns.includes(a))
|
|
151
|
+
scoreA += 10;
|
|
152
|
+
if (this.projectContext.patterns.includes(b))
|
|
153
|
+
scoreB += 10;
|
|
154
|
+
// Prefer recently updated
|
|
155
|
+
scoreA += (a.updatedAt - Date.now()) / (1000 * 60 * 60 * 24); // days ago
|
|
156
|
+
scoreB += (b.updatedAt - Date.now()) / (1000 * 60 * 60 * 24);
|
|
157
|
+
return scoreB - scoreA;
|
|
158
|
+
});
|
|
159
|
+
return query.limit ? filtered.slice(0, query.limit) : filtered;
|
|
160
|
+
}
|
|
161
|
+
// ========================================================================
|
|
162
|
+
// Project Configuration
|
|
163
|
+
// ========================================================================
|
|
164
|
+
updateProjectInfo(updates) {
|
|
165
|
+
Object.assign(this.projectContext, updates, {
|
|
166
|
+
updatedAt: Date.now(),
|
|
167
|
+
version: this.projectContext.version + 1,
|
|
168
|
+
});
|
|
169
|
+
this.saveProjectContext();
|
|
170
|
+
}
|
|
171
|
+
getProjectContext() {
|
|
172
|
+
return { ...this.projectContext };
|
|
173
|
+
}
|
|
174
|
+
// ========================================================================
|
|
175
|
+
// Context Generation for AI
|
|
176
|
+
// ========================================================================
|
|
177
|
+
generateContextPrompt(taskDescription, codeContext) {
|
|
178
|
+
const relevantPatterns = this.findRelevantPatterns({
|
|
179
|
+
keywords: this.extractKeywords(taskDescription),
|
|
180
|
+
limit: 5,
|
|
181
|
+
});
|
|
182
|
+
let context = "";
|
|
183
|
+
// Add project info
|
|
184
|
+
context += `## Project Context\n`;
|
|
185
|
+
context += `Tech Stack: ${this.projectContext.techStack.join(", ") || "Not specified"}\n\n`;
|
|
186
|
+
// Add relevant patterns
|
|
187
|
+
if (relevantPatterns.length > 0) {
|
|
188
|
+
context += `## Relevant Patterns\n`;
|
|
189
|
+
for (const pattern of relevantPatterns) {
|
|
190
|
+
context += `### ${pattern.name}\n`;
|
|
191
|
+
context += `${pattern.description}\n\n`;
|
|
192
|
+
if (pattern.examples.length > 0) {
|
|
193
|
+
context += `Example:\n${pattern.examples[0].input}\n\n`;
|
|
194
|
+
context += `Result: ${pattern.examples[0].output}\n\n`;
|
|
195
|
+
}
|
|
196
|
+
context += `Tags: ${pattern.tags.join(", ")}\n\n`;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
// Add standards
|
|
200
|
+
const standards = this.projectContext.standards;
|
|
201
|
+
if (Object.keys(standards.naming).length > 0 ||
|
|
202
|
+
standards.security.length > 0 ||
|
|
203
|
+
standards.performance.length > 0 ||
|
|
204
|
+
standards.codeQuality.length > 0) {
|
|
205
|
+
context += `## Project Standards\n`;
|
|
206
|
+
if (Object.keys(standards.naming).length > 0) {
|
|
207
|
+
context += `Naming: ${Object.entries(standards.naming)
|
|
208
|
+
.map(([k, v]) => `${k}: ${v}`)
|
|
209
|
+
.join(", ")}\n`;
|
|
210
|
+
}
|
|
211
|
+
if (standards.security.length > 0) {
|
|
212
|
+
context += `Security: ${standards.security.join(", ")}\n`;
|
|
213
|
+
}
|
|
214
|
+
if (standards.performance.length > 0) {
|
|
215
|
+
context += `Performance: ${standards.performance.join(", ")}\n`;
|
|
216
|
+
}
|
|
217
|
+
if (standards.codeQuality.length > 0) {
|
|
218
|
+
context += `Code Quality: ${standards.codeQuality.join(", ")}\n`;
|
|
219
|
+
}
|
|
220
|
+
context += "\n";
|
|
221
|
+
}
|
|
222
|
+
// Add code context if provided
|
|
223
|
+
if (codeContext && codeContext.length > 0) {
|
|
224
|
+
context += `## Current Code Context\n`;
|
|
225
|
+
context += codeContext.join("\n\n");
|
|
226
|
+
context += "\n\n";
|
|
227
|
+
}
|
|
228
|
+
return context;
|
|
229
|
+
}
|
|
230
|
+
extractKeywords(text) {
|
|
231
|
+
// Simple keyword extraction - split by spaces and filter common words
|
|
232
|
+
const words = text.toLowerCase().split(/\W+/);
|
|
233
|
+
const stopWords = new Set([
|
|
234
|
+
"the",
|
|
235
|
+
"a",
|
|
236
|
+
"an",
|
|
237
|
+
"and",
|
|
238
|
+
"or",
|
|
239
|
+
"but",
|
|
240
|
+
"in",
|
|
241
|
+
"on",
|
|
242
|
+
"at",
|
|
243
|
+
"to",
|
|
244
|
+
"for",
|
|
245
|
+
"of",
|
|
246
|
+
"with",
|
|
247
|
+
"by",
|
|
248
|
+
"is",
|
|
249
|
+
"are",
|
|
250
|
+
"was",
|
|
251
|
+
"were",
|
|
252
|
+
"be",
|
|
253
|
+
"been",
|
|
254
|
+
"being",
|
|
255
|
+
"have",
|
|
256
|
+
"has",
|
|
257
|
+
"had",
|
|
258
|
+
"do",
|
|
259
|
+
"does",
|
|
260
|
+
"did",
|
|
261
|
+
"will",
|
|
262
|
+
"would",
|
|
263
|
+
"could",
|
|
264
|
+
"should",
|
|
265
|
+
"may",
|
|
266
|
+
"might",
|
|
267
|
+
"must",
|
|
268
|
+
"can",
|
|
269
|
+
"this",
|
|
270
|
+
"that",
|
|
271
|
+
"these",
|
|
272
|
+
"those",
|
|
273
|
+
]);
|
|
274
|
+
return words.filter((word) => word.length > 2 && !stopWords.has(word));
|
|
275
|
+
}
|
|
276
|
+
// ========================================================================
|
|
277
|
+
// Interactive Context Building
|
|
278
|
+
// ========================================================================
|
|
279
|
+
/**
|
|
280
|
+
* Collect shallow directory entries (files and dirs) for a given path.
|
|
281
|
+
* Returns empty array on any error (permission denied, missing dir, etc.).
|
|
282
|
+
*/
|
|
283
|
+
safeReadDir(dirPath) {
|
|
284
|
+
try {
|
|
285
|
+
return readdirSync(dirPath, { withFileTypes: true }).map((e) => ({
|
|
286
|
+
name: e.name,
|
|
287
|
+
isDir: e.isDirectory(),
|
|
288
|
+
}));
|
|
289
|
+
}
|
|
290
|
+
catch {
|
|
291
|
+
return [];
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Safely read a text file. Returns null on any error.
|
|
296
|
+
*/
|
|
297
|
+
safeReadFile(filePath) {
|
|
298
|
+
try {
|
|
299
|
+
return readFileSync(filePath, "utf-8");
|
|
300
|
+
}
|
|
301
|
+
catch {
|
|
302
|
+
return null;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Walk source directories up to `maxDepth` and collect file paths.
|
|
307
|
+
* Skips common non-source directories for speed.
|
|
308
|
+
*/
|
|
309
|
+
collectSourceFiles(root, maxDepth = 3) {
|
|
310
|
+
const skipDirs = new Set([
|
|
311
|
+
"node_modules",
|
|
312
|
+
".git",
|
|
313
|
+
"dist",
|
|
314
|
+
"build",
|
|
315
|
+
".next",
|
|
316
|
+
".nuxt",
|
|
317
|
+
".svelte-kit",
|
|
318
|
+
"coverage",
|
|
319
|
+
"__pycache__",
|
|
320
|
+
".venv",
|
|
321
|
+
"venv",
|
|
322
|
+
"target",
|
|
323
|
+
"vendor",
|
|
324
|
+
"bin",
|
|
325
|
+
"obj",
|
|
326
|
+
".synapsexcoder",
|
|
327
|
+
]);
|
|
328
|
+
const results = [];
|
|
329
|
+
const maxFiles = 500; // cap to keep detection fast
|
|
330
|
+
const walk = (dir, depth) => {
|
|
331
|
+
if (depth > maxDepth || results.length >= maxFiles)
|
|
332
|
+
return;
|
|
333
|
+
for (const entry of this.safeReadDir(dir)) {
|
|
334
|
+
if (results.length >= maxFiles)
|
|
335
|
+
return;
|
|
336
|
+
const full = join(dir, entry.name);
|
|
337
|
+
if (entry.isDir) {
|
|
338
|
+
if (!skipDirs.has(entry.name) && !entry.name.startsWith(".")) {
|
|
339
|
+
walk(full, depth + 1);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
else {
|
|
343
|
+
results.push(full);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
};
|
|
347
|
+
walk(root, 0);
|
|
348
|
+
return results;
|
|
349
|
+
}
|
|
350
|
+
// ── Tech-Stack Detection ───────────────────────────────────────────────
|
|
351
|
+
/**
|
|
352
|
+
* Auto-detect the project's technology stack by inspecting config files
|
|
353
|
+
* and, as a fallback, file-extension frequency analysis.
|
|
354
|
+
*/
|
|
355
|
+
detectTechStack(root) {
|
|
356
|
+
const stack = new Set();
|
|
357
|
+
// --- 1. package.json (Node / JS ecosystem) ---
|
|
358
|
+
const pkgRaw = this.safeReadFile(join(root, "package.json"));
|
|
359
|
+
if (pkgRaw) {
|
|
360
|
+
try {
|
|
361
|
+
const pkg = JSON.parse(pkgRaw);
|
|
362
|
+
const allDeps = {
|
|
363
|
+
...pkg.dependencies,
|
|
364
|
+
...pkg.devDependencies,
|
|
365
|
+
};
|
|
366
|
+
// Core runtimes
|
|
367
|
+
stack.add("Node.js");
|
|
368
|
+
if (allDeps["typescript"] || existsSync(join(root, "tsconfig.json"))) {
|
|
369
|
+
stack.add("TypeScript");
|
|
370
|
+
}
|
|
371
|
+
else {
|
|
372
|
+
stack.add("JavaScript");
|
|
373
|
+
}
|
|
374
|
+
// Frameworks / major libs (order matters — check specific first)
|
|
375
|
+
const depMap = {
|
|
376
|
+
next: "Next.js",
|
|
377
|
+
nuxt: "Nuxt",
|
|
378
|
+
nuxt3: "Nuxt",
|
|
379
|
+
"@angular/core": "Angular",
|
|
380
|
+
vue: "Vue",
|
|
381
|
+
svelte: "Svelte",
|
|
382
|
+
"@sveltejs/kit": "SvelteKit",
|
|
383
|
+
react: "React",
|
|
384
|
+
"react-native": "React Native",
|
|
385
|
+
express: "Express",
|
|
386
|
+
fastify: "Fastify",
|
|
387
|
+
hono: "Hono",
|
|
388
|
+
koa: "Koa",
|
|
389
|
+
"nestjs/core": "NestJS",
|
|
390
|
+
"@nestjs/core": "NestJS",
|
|
391
|
+
electron: "Electron",
|
|
392
|
+
"apollo-server": "Apollo GraphQL",
|
|
393
|
+
"@apollo/server": "Apollo GraphQL",
|
|
394
|
+
graphql: "GraphQL",
|
|
395
|
+
prisma: "Prisma",
|
|
396
|
+
"@prisma/client": "Prisma",
|
|
397
|
+
drizzle: "Drizzle ORM",
|
|
398
|
+
"drizzle-orm": "Drizzle ORM",
|
|
399
|
+
mongoose: "Mongoose",
|
|
400
|
+
sequelize: "Sequelize",
|
|
401
|
+
tailwindcss: "Tailwind CSS",
|
|
402
|
+
"styled-components": "styled-components",
|
|
403
|
+
"@emotion/react": "Emotion",
|
|
404
|
+
redux: "Redux",
|
|
405
|
+
"@reduxjs/toolkit": "Redux Toolkit",
|
|
406
|
+
zustand: "Zustand",
|
|
407
|
+
mobx: "MobX",
|
|
408
|
+
zod: "Zod",
|
|
409
|
+
vitest: "Vitest",
|
|
410
|
+
jest: "Jest",
|
|
411
|
+
mocha: "Mocha",
|
|
412
|
+
playwright: "Playwright",
|
|
413
|
+
cypress: "Cypress",
|
|
414
|
+
storybook: "Storybook",
|
|
415
|
+
"@storybook/react": "Storybook",
|
|
416
|
+
webpack: "Webpack",
|
|
417
|
+
vite: "Vite",
|
|
418
|
+
esbuild: "esbuild",
|
|
419
|
+
turbo: "Turborepo",
|
|
420
|
+
};
|
|
421
|
+
for (const [dep, label] of Object.entries(depMap)) {
|
|
422
|
+
if (dep in allDeps)
|
|
423
|
+
stack.add(label);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
catch {
|
|
427
|
+
// malformed package.json — continue
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
// --- 2. tsconfig.json ---
|
|
431
|
+
if (existsSync(join(root, "tsconfig.json"))) {
|
|
432
|
+
stack.add("TypeScript");
|
|
433
|
+
}
|
|
434
|
+
// --- 3. Cargo.toml → Rust ---
|
|
435
|
+
if (existsSync(join(root, "Cargo.toml")))
|
|
436
|
+
stack.add("Rust");
|
|
437
|
+
// --- 4. go.mod → Go ---
|
|
438
|
+
if (existsSync(join(root, "go.mod")))
|
|
439
|
+
stack.add("Go");
|
|
440
|
+
// --- 5. Python indicators ---
|
|
441
|
+
if (existsSync(join(root, "requirements.txt")) ||
|
|
442
|
+
existsSync(join(root, "pyproject.toml")) ||
|
|
443
|
+
existsSync(join(root, "setup.py")) ||
|
|
444
|
+
existsSync(join(root, "Pipfile"))) {
|
|
445
|
+
stack.add("Python");
|
|
446
|
+
// Check for common Python frameworks
|
|
447
|
+
const reqRaw = this.safeReadFile(join(root, "requirements.txt")) ??
|
|
448
|
+
this.safeReadFile(join(root, "pyproject.toml")) ??
|
|
449
|
+
"";
|
|
450
|
+
if (/django/i.test(reqRaw))
|
|
451
|
+
stack.add("Django");
|
|
452
|
+
if (/flask/i.test(reqRaw))
|
|
453
|
+
stack.add("Flask");
|
|
454
|
+
if (/fastapi/i.test(reqRaw))
|
|
455
|
+
stack.add("FastAPI");
|
|
456
|
+
if (/pytorch|torch/i.test(reqRaw))
|
|
457
|
+
stack.add("PyTorch");
|
|
458
|
+
if (/tensorflow/i.test(reqRaw))
|
|
459
|
+
stack.add("TensorFlow");
|
|
460
|
+
}
|
|
461
|
+
// --- 6. Ruby ---
|
|
462
|
+
if (existsSync(join(root, "Gemfile"))) {
|
|
463
|
+
stack.add("Ruby");
|
|
464
|
+
const gemRaw = this.safeReadFile(join(root, "Gemfile")) ?? "";
|
|
465
|
+
if (/rails/i.test(gemRaw))
|
|
466
|
+
stack.add("Ruby on Rails");
|
|
467
|
+
}
|
|
468
|
+
// --- 7. C# / .NET ---
|
|
469
|
+
const rootEntries = this.safeReadDir(root);
|
|
470
|
+
if (rootEntries.some((e) => !e.isDir &&
|
|
471
|
+
(e.name.endsWith(".sln") ||
|
|
472
|
+
e.name.endsWith(".csproj") ||
|
|
473
|
+
e.name.endsWith(".fsproj")))) {
|
|
474
|
+
stack.add("C#/.NET");
|
|
475
|
+
}
|
|
476
|
+
// --- 8. Java ---
|
|
477
|
+
if (existsSync(join(root, "pom.xml")) ||
|
|
478
|
+
existsSync(join(root, "build.gradle")) ||
|
|
479
|
+
existsSync(join(root, "build.gradle.kts"))) {
|
|
480
|
+
stack.add("Java");
|
|
481
|
+
}
|
|
482
|
+
// --- 9. Docker ---
|
|
483
|
+
if (existsSync(join(root, "Dockerfile")) ||
|
|
484
|
+
existsSync(join(root, "docker-compose.yml")) ||
|
|
485
|
+
existsSync(join(root, "docker-compose.yaml"))) {
|
|
486
|
+
stack.add("Docker");
|
|
487
|
+
}
|
|
488
|
+
// --- 10. File-extension frequency fallback (only if nothing detected yet) ---
|
|
489
|
+
if (stack.size === 0) {
|
|
490
|
+
const extCounts = new Map();
|
|
491
|
+
const files = this.collectSourceFiles(root, 2);
|
|
492
|
+
for (const f of files) {
|
|
493
|
+
const ext = extname(f).toLowerCase();
|
|
494
|
+
if (ext)
|
|
495
|
+
extCounts.set(ext, (extCounts.get(ext) ?? 0) + 1);
|
|
496
|
+
}
|
|
497
|
+
const extToLang = {
|
|
498
|
+
".ts": "TypeScript",
|
|
499
|
+
".tsx": "TypeScript",
|
|
500
|
+
".js": "JavaScript",
|
|
501
|
+
".jsx": "JavaScript",
|
|
502
|
+
".py": "Python",
|
|
503
|
+
".rs": "Rust",
|
|
504
|
+
".go": "Go",
|
|
505
|
+
".rb": "Ruby",
|
|
506
|
+
".java": "Java",
|
|
507
|
+
".cs": "C#",
|
|
508
|
+
".cpp": "C++",
|
|
509
|
+
".c": "C",
|
|
510
|
+
".swift": "Swift",
|
|
511
|
+
".kt": "Kotlin",
|
|
512
|
+
".php": "PHP",
|
|
513
|
+
".dart": "Dart",
|
|
514
|
+
};
|
|
515
|
+
// Pick the top 3 extensions by count
|
|
516
|
+
const sorted = [...extCounts.entries()]
|
|
517
|
+
.sort((a, b) => b[1] - a[1])
|
|
518
|
+
.slice(0, 3);
|
|
519
|
+
for (const [ext] of sorted) {
|
|
520
|
+
if (extToLang[ext])
|
|
521
|
+
stack.add(extToLang[ext]);
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
return [...stack];
|
|
525
|
+
}
|
|
526
|
+
// ── API-Pattern Detection ──────────────────────────────────────────────
|
|
527
|
+
/**
|
|
528
|
+
* Auto-detect API patterns by sampling source files for common
|
|
529
|
+
* route/handler/schema definitions.
|
|
530
|
+
*/
|
|
531
|
+
detectApiPatterns(root) {
|
|
532
|
+
const signals = [];
|
|
533
|
+
const files = this.collectSourceFiles(root, 3);
|
|
534
|
+
let hasExpressRoutes = false;
|
|
535
|
+
let hasFastifyRoutes = false;
|
|
536
|
+
let hasNextApiRoutes = false;
|
|
537
|
+
let hasGraphQL = false;
|
|
538
|
+
let hasGrpc = false;
|
|
539
|
+
let hasTrpc = false;
|
|
540
|
+
let hasMiddleware = false;
|
|
541
|
+
let hasValidation = false;
|
|
542
|
+
let hasOpenApi = false;
|
|
543
|
+
for (const filePath of files) {
|
|
544
|
+
const name = filePath.toLowerCase();
|
|
545
|
+
// Next.js API routes (app dir: route.ts, pages dir: /api/)
|
|
546
|
+
if (name.includes("/api/") &&
|
|
547
|
+
(name.endsWith("route.ts") ||
|
|
548
|
+
name.endsWith("route.js") ||
|
|
549
|
+
name.endsWith("/api/") === false)) {
|
|
550
|
+
hasNextApiRoutes = true;
|
|
551
|
+
}
|
|
552
|
+
// GraphQL schema files
|
|
553
|
+
if (name.endsWith(".graphql") || name.endsWith(".gql")) {
|
|
554
|
+
hasGraphQL = true;
|
|
555
|
+
}
|
|
556
|
+
// gRPC proto files
|
|
557
|
+
if (name.endsWith(".proto")) {
|
|
558
|
+
hasGrpc = true;
|
|
559
|
+
}
|
|
560
|
+
// Only read a subset of source files to keep it fast
|
|
561
|
+
const ext = extname(filePath).toLowerCase();
|
|
562
|
+
if (![".ts", ".js", ".tsx", ".jsx", ".py", ".rb", ".go"].includes(ext)) {
|
|
563
|
+
continue;
|
|
564
|
+
}
|
|
565
|
+
const content = this.safeReadFile(filePath);
|
|
566
|
+
if (!content)
|
|
567
|
+
continue;
|
|
568
|
+
// Sample only first 3000 chars for speed
|
|
569
|
+
const sample = content.slice(0, 3000);
|
|
570
|
+
// Express / Koa / Hono route patterns
|
|
571
|
+
if (/\b(app|router)\.(get|post|put|patch|delete|use)\s*\(/.test(sample)) {
|
|
572
|
+
hasExpressRoutes = true;
|
|
573
|
+
}
|
|
574
|
+
// Fastify routes
|
|
575
|
+
if (/\bfastify\.(get|post|put|delete|register)\s*\(/.test(sample)) {
|
|
576
|
+
hasFastifyRoutes = true;
|
|
577
|
+
}
|
|
578
|
+
// GraphQL resolvers / typeDefs
|
|
579
|
+
if (/\b(typeDefs|resolvers|gql`|makeExecutableSchema)\b/.test(sample)) {
|
|
580
|
+
hasGraphQL = true;
|
|
581
|
+
}
|
|
582
|
+
// tRPC
|
|
583
|
+
if (/\b(trpc|createTRPCRouter|publicProcedure|protectedProcedure)\b/.test(sample)) {
|
|
584
|
+
hasTrpc = true;
|
|
585
|
+
}
|
|
586
|
+
// Middleware patterns
|
|
587
|
+
if (/\b(middleware|use\(|next\(\))\b/.test(sample) &&
|
|
588
|
+
/\b(req|request|ctx|context)\b/.test(sample)) {
|
|
589
|
+
hasMiddleware = true;
|
|
590
|
+
}
|
|
591
|
+
// Validation (Zod, Joi, Yup, class-validator)
|
|
592
|
+
if (/\b(z\.|Joi\.|yup\.|@IsString|@IsNumber|@Validate)\b/.test(sample)) {
|
|
593
|
+
hasValidation = true;
|
|
594
|
+
}
|
|
595
|
+
// OpenAPI / Swagger
|
|
596
|
+
if (/\b(swagger|openapi|@ApiProperty|@ApiOperation)\b/i.test(sample)) {
|
|
597
|
+
hasOpenApi = true;
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
// Build human-readable description
|
|
601
|
+
if (hasNextApiRoutes)
|
|
602
|
+
signals.push("Next.js API routes (App Router)");
|
|
603
|
+
if (hasExpressRoutes)
|
|
604
|
+
signals.push("Express-style route handlers");
|
|
605
|
+
if (hasFastifyRoutes)
|
|
606
|
+
signals.push("Fastify route handlers");
|
|
607
|
+
if (hasTrpc)
|
|
608
|
+
signals.push("tRPC procedures");
|
|
609
|
+
if (hasGraphQL)
|
|
610
|
+
signals.push("GraphQL schema + resolvers");
|
|
611
|
+
if (hasGrpc)
|
|
612
|
+
signals.push("gRPC services");
|
|
613
|
+
if (hasOpenApi)
|
|
614
|
+
signals.push("OpenAPI/Swagger documentation");
|
|
615
|
+
if (hasMiddleware)
|
|
616
|
+
signals.push("middleware pipeline");
|
|
617
|
+
if (hasValidation)
|
|
618
|
+
signals.push("request validation");
|
|
619
|
+
if (signals.length === 0) {
|
|
620
|
+
// Fallback: check if there are any API-like directories
|
|
621
|
+
const entries = this.safeReadDir(root);
|
|
622
|
+
const hasApiDir = entries.some((e) => e.isDir &&
|
|
623
|
+
["api", "routes", "controllers", "handlers"].includes(e.name.toLowerCase()));
|
|
624
|
+
if (hasApiDir) {
|
|
625
|
+
return "RESTful endpoints (detected API directory structure)";
|
|
626
|
+
}
|
|
627
|
+
return "No specific API pattern detected";
|
|
628
|
+
}
|
|
629
|
+
return signals.join(", ");
|
|
630
|
+
}
|
|
631
|
+
// ── UI-Pattern Detection ───────────────────────────────────────────────
|
|
632
|
+
/**
|
|
633
|
+
* Auto-detect UI/component patterns by scanning source files for
|
|
634
|
+
* framework idioms, styling approaches, and state management.
|
|
635
|
+
*/
|
|
636
|
+
detectUiPatterns(root) {
|
|
637
|
+
const signals = [];
|
|
638
|
+
const files = this.collectSourceFiles(root, 3);
|
|
639
|
+
let hasClassComponents = false;
|
|
640
|
+
let hasFunctionalComponents = false;
|
|
641
|
+
let hasVueSfc = false;
|
|
642
|
+
let hasVueCompositionApi = false;
|
|
643
|
+
let hasSvelte = false;
|
|
644
|
+
let hasCssModules = false;
|
|
645
|
+
let hasCssInJs = false;
|
|
646
|
+
let hasTailwind = false;
|
|
647
|
+
let hasRedux = false;
|
|
648
|
+
let hasZustand = false;
|
|
649
|
+
let hasMobx = false;
|
|
650
|
+
let hasContextApi = false;
|
|
651
|
+
let hasJotai = false;
|
|
652
|
+
let hasRecoil = false;
|
|
653
|
+
// Quick check for Tailwind config at root
|
|
654
|
+
if (existsSync(join(root, "tailwind.config.js")) ||
|
|
655
|
+
existsSync(join(root, "tailwind.config.ts")) ||
|
|
656
|
+
existsSync(join(root, "tailwind.config.mjs")) ||
|
|
657
|
+
existsSync(join(root, "tailwind.config.cjs"))) {
|
|
658
|
+
hasTailwind = true;
|
|
659
|
+
}
|
|
660
|
+
for (const filePath of files) {
|
|
661
|
+
const name = filePath.toLowerCase();
|
|
662
|
+
const ext = extname(filePath).toLowerCase();
|
|
663
|
+
// Vue SFCs
|
|
664
|
+
if (ext === ".vue") {
|
|
665
|
+
hasVueSfc = true;
|
|
666
|
+
const content = this.safeReadFile(filePath);
|
|
667
|
+
if (content &&
|
|
668
|
+
/\bsetup\s*\(|<script\s+setup/i.test(content.slice(0, 2000))) {
|
|
669
|
+
hasVueCompositionApi = true;
|
|
670
|
+
}
|
|
671
|
+
continue;
|
|
672
|
+
}
|
|
673
|
+
// Svelte components
|
|
674
|
+
if (ext === ".svelte") {
|
|
675
|
+
hasSvelte = true;
|
|
676
|
+
continue;
|
|
677
|
+
}
|
|
678
|
+
// CSS modules
|
|
679
|
+
if (name.endsWith(".module.css") || name.endsWith(".module.scss")) {
|
|
680
|
+
hasCssModules = true;
|
|
681
|
+
continue;
|
|
682
|
+
}
|
|
683
|
+
// Only parse JS/TS for deeper analysis
|
|
684
|
+
if (![".ts", ".tsx", ".js", ".jsx"].includes(ext))
|
|
685
|
+
continue;
|
|
686
|
+
const content = this.safeReadFile(filePath);
|
|
687
|
+
if (!content)
|
|
688
|
+
continue;
|
|
689
|
+
const sample = content.slice(0, 3000);
|
|
690
|
+
// React class components
|
|
691
|
+
if (/\bclass\s+\w+\s+extends\s+(React\.)?Component\b/.test(sample) ||
|
|
692
|
+
/\bclass\s+\w+\s+extends\s+(React\.)?PureComponent\b/.test(sample)) {
|
|
693
|
+
hasClassComponents = true;
|
|
694
|
+
}
|
|
695
|
+
// React functional components (hooks usage is a strong signal)
|
|
696
|
+
if (/\b(useState|useEffect|useCallback|useMemo|useRef|useContext)\b/.test(sample)) {
|
|
697
|
+
hasFunctionalComponents = true;
|
|
698
|
+
}
|
|
699
|
+
// styled-components / Emotion
|
|
700
|
+
if (/\b(styled\.|css`|styled\(|@emotion)\b/.test(sample)) {
|
|
701
|
+
hasCssInJs = true;
|
|
702
|
+
}
|
|
703
|
+
// Tailwind class names in JSX
|
|
704
|
+
if (!hasTailwind &&
|
|
705
|
+
/className=["'`][^"'`]*\b(flex|grid|p-|m-|text-|bg-|rounded)\b/.test(sample)) {
|
|
706
|
+
hasTailwind = true;
|
|
707
|
+
}
|
|
708
|
+
// State management
|
|
709
|
+
if (/\b(useSelector|useDispatch|createSlice|configureStore)\b/.test(sample)) {
|
|
710
|
+
hasRedux = true;
|
|
711
|
+
}
|
|
712
|
+
if (/\bcreate\s*\(\s*\(set\b|\buseStore\b/.test(sample) ||
|
|
713
|
+
/\bfrom\s+['"]zustand['"]/.test(sample)) {
|
|
714
|
+
hasZustand = true;
|
|
715
|
+
}
|
|
716
|
+
if (/\b(observable|makeObservable|makeAutoObservable|observer\()\b/.test(sample)) {
|
|
717
|
+
hasMobx = true;
|
|
718
|
+
}
|
|
719
|
+
if (/\b(createContext|useContext)\b/.test(sample) &&
|
|
720
|
+
/\bProvider\b/.test(sample)) {
|
|
721
|
+
hasContextApi = true;
|
|
722
|
+
}
|
|
723
|
+
if (/\b(atom|useAtom)\b/.test(sample) && /jotai/i.test(sample)) {
|
|
724
|
+
hasJotai = true;
|
|
725
|
+
}
|
|
726
|
+
if (/\b(atom|selector|useRecoilState|useRecoilValue)\b/.test(sample) &&
|
|
727
|
+
/recoil/i.test(sample)) {
|
|
728
|
+
hasRecoil = true;
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
// Build description
|
|
732
|
+
// Component style
|
|
733
|
+
if (hasFunctionalComponents && hasClassComponents) {
|
|
734
|
+
signals.push("React (mixed class + functional components)");
|
|
735
|
+
}
|
|
736
|
+
else if (hasFunctionalComponents) {
|
|
737
|
+
signals.push("Functional React components with hooks");
|
|
738
|
+
}
|
|
739
|
+
else if (hasClassComponents) {
|
|
740
|
+
signals.push("React class components");
|
|
741
|
+
}
|
|
742
|
+
if (hasVueSfc) {
|
|
743
|
+
signals.push(hasVueCompositionApi
|
|
744
|
+
? "Vue SFCs with Composition API"
|
|
745
|
+
: "Vue Single-File Components");
|
|
746
|
+
}
|
|
747
|
+
if (hasSvelte)
|
|
748
|
+
signals.push("Svelte components");
|
|
749
|
+
// Styling
|
|
750
|
+
const stylingSignals = [];
|
|
751
|
+
if (hasTailwind)
|
|
752
|
+
stylingSignals.push("Tailwind CSS");
|
|
753
|
+
if (hasCssInJs)
|
|
754
|
+
stylingSignals.push("CSS-in-JS");
|
|
755
|
+
if (hasCssModules)
|
|
756
|
+
stylingSignals.push("CSS Modules");
|
|
757
|
+
if (stylingSignals.length > 0) {
|
|
758
|
+
signals.push(`Styling: ${stylingSignals.join(", ")}`);
|
|
759
|
+
}
|
|
760
|
+
// State management
|
|
761
|
+
const stateSignals = [];
|
|
762
|
+
if (hasRedux)
|
|
763
|
+
stateSignals.push("Redux");
|
|
764
|
+
if (hasZustand)
|
|
765
|
+
stateSignals.push("Zustand");
|
|
766
|
+
if (hasMobx)
|
|
767
|
+
stateSignals.push("MobX");
|
|
768
|
+
if (hasContextApi)
|
|
769
|
+
stateSignals.push("Context API");
|
|
770
|
+
if (hasJotai)
|
|
771
|
+
stateSignals.push("Jotai");
|
|
772
|
+
if (hasRecoil)
|
|
773
|
+
stateSignals.push("Recoil");
|
|
774
|
+
if (stateSignals.length > 0) {
|
|
775
|
+
signals.push(`State: ${stateSignals.join(", ")}`);
|
|
776
|
+
}
|
|
777
|
+
if (signals.length === 0) {
|
|
778
|
+
return "No specific UI framework pattern detected";
|
|
779
|
+
}
|
|
780
|
+
return signals.join("; ");
|
|
781
|
+
}
|
|
782
|
+
// ── Build Context ──────────────────────────────────────────────────────
|
|
783
|
+
async buildContextInteractively() {
|
|
784
|
+
console.log("🧠 Building project context...\n");
|
|
785
|
+
// Resolve the project root for auto-detection.
|
|
786
|
+
// If no projectRoot was provided at construction time, fall back to cwd.
|
|
787
|
+
const root = this.projectRoot ?? process.cwd();
|
|
788
|
+
// ── Auto-detect tech stack ───────────────────────────────────────────
|
|
789
|
+
console.log("🔍 Auto-detecting tech stack...");
|
|
790
|
+
const techStack = this.detectTechStack(root);
|
|
791
|
+
if (techStack.length > 0) {
|
|
792
|
+
console.log(` Detected: ${techStack.join(", ")}`);
|
|
793
|
+
}
|
|
794
|
+
else {
|
|
795
|
+
console.log(" No specific tech stack detected — using defaults");
|
|
796
|
+
}
|
|
797
|
+
// ── Auto-detect API patterns ─────────────────────────────────────────
|
|
798
|
+
console.log("🔍 Auto-detecting API patterns...");
|
|
799
|
+
const apiPattern = this.detectApiPatterns(root);
|
|
800
|
+
console.log(` Detected: ${apiPattern}`);
|
|
801
|
+
// ── Auto-detect UI patterns ──────────────────────────────────────────
|
|
802
|
+
console.log("🔍 Auto-detecting UI/component patterns...");
|
|
803
|
+
const uiPattern = this.detectUiPatterns(root);
|
|
804
|
+
console.log(` Detected: ${uiPattern}`);
|
|
805
|
+
// ── Detect code-quality tooling ──────────────────────────────────────
|
|
806
|
+
const codeQuality = [];
|
|
807
|
+
if (techStack.includes("TypeScript"))
|
|
808
|
+
codeQuality.push("TypeScript strict mode");
|
|
809
|
+
if (existsSync(join(root, ".eslintrc.js")) ||
|
|
810
|
+
existsSync(join(root, ".eslintrc.json")) ||
|
|
811
|
+
existsSync(join(root, ".eslintrc.cjs")) ||
|
|
812
|
+
existsSync(join(root, "eslint.config.js")) ||
|
|
813
|
+
existsSync(join(root, "eslint.config.mjs"))) {
|
|
814
|
+
codeQuality.push("ESLint");
|
|
815
|
+
}
|
|
816
|
+
if (existsSync(join(root, ".prettierrc")) ||
|
|
817
|
+
existsSync(join(root, ".prettierrc.json")) ||
|
|
818
|
+
existsSync(join(root, ".prettierrc.js"))) {
|
|
819
|
+
codeQuality.push("Prettier");
|
|
820
|
+
}
|
|
821
|
+
if (existsSync(join(root, "biome.json")) ||
|
|
822
|
+
existsSync(join(root, "biome.jsonc"))) {
|
|
823
|
+
codeQuality.push("Biome");
|
|
824
|
+
}
|
|
825
|
+
// ── Persist to project context ───────────────────────────────────────
|
|
826
|
+
this.updateProjectInfo({
|
|
827
|
+
techStack,
|
|
828
|
+
standards: {
|
|
829
|
+
...this.projectContext.standards,
|
|
830
|
+
codeQuality: codeQuality.length > 0
|
|
831
|
+
? codeQuality
|
|
832
|
+
: this.projectContext.standards.codeQuality,
|
|
833
|
+
},
|
|
834
|
+
});
|
|
835
|
+
// Add API pattern
|
|
836
|
+
this.addPattern({
|
|
837
|
+
type: "api",
|
|
838
|
+
name: "API Endpoint Pattern",
|
|
839
|
+
description: apiPattern,
|
|
840
|
+
examples: [
|
|
841
|
+
{
|
|
842
|
+
input: "Create user endpoint",
|
|
843
|
+
output: "app/api/users/route.ts with POST handler",
|
|
844
|
+
explanation: "Standard RESTful endpoint structure",
|
|
845
|
+
},
|
|
846
|
+
],
|
|
847
|
+
tags: ["api", "backend", "rest"],
|
|
848
|
+
});
|
|
849
|
+
// Add UI pattern only if a UI framework was detected
|
|
850
|
+
if (uiPattern !== "No specific UI framework pattern detected" &&
|
|
851
|
+
techStack.some((t) => /react|vue|svelte|angular/i.test(t))) {
|
|
852
|
+
this.addPattern({
|
|
853
|
+
type: "ui",
|
|
854
|
+
name: "Component Pattern",
|
|
855
|
+
description: uiPattern,
|
|
856
|
+
examples: [
|
|
857
|
+
{
|
|
858
|
+
input: "Create user profile component",
|
|
859
|
+
output: "components/UserProfile.tsx with TypeScript interfaces",
|
|
860
|
+
explanation: "Standard component structure with props interface",
|
|
861
|
+
},
|
|
862
|
+
],
|
|
863
|
+
tags: ["ui", "frontend", "components"],
|
|
864
|
+
});
|
|
865
|
+
}
|
|
866
|
+
console.log("\n✅ Context built successfully!");
|
|
867
|
+
console.log(` Tech stack: ${techStack.join(", ") || "(none)"}`);
|
|
868
|
+
console.log(` API patterns: ${apiPattern}`);
|
|
869
|
+
console.log(` UI patterns: ${uiPattern}`);
|
|
870
|
+
console.log(` Code quality: ${codeQuality.join(", ") || "(none)"}`);
|
|
871
|
+
console.log(` Patterns added: ${this.projectContext.patterns.length}`);
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
// ========================================================================
|
|
875
|
+
// Factory Function
|
|
876
|
+
// ========================================================================
|
|
877
|
+
export function createContextSystem(projectRoot) {
|
|
878
|
+
return new ContextSystem(projectRoot);
|
|
879
|
+
}
|
|
880
|
+
//# sourceMappingURL=context-system.js.map
|