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,211 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Memory Profiler — Memory usage tracking and leak detection
|
|
3
|
+
*
|
|
4
|
+
* Phase 12: Performance Profiling — Collects memory snapshots, detects
|
|
5
|
+
* growth patterns, identifies leak suspects, and tracks allocation hotspots.
|
|
6
|
+
*/
|
|
7
|
+
import { performance } from "node:perf_hooks";
|
|
8
|
+
// Use v8 for heap statistics
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
10
|
+
const v8 = null; // Disabled binding for compatibility
|
|
11
|
+
let v8Module = null;
|
|
12
|
+
try {
|
|
13
|
+
// Dynamic import to avoid crash in non-Node environments
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
15
|
+
v8Module = require("node:v8");
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
// Not in Node.js environment
|
|
19
|
+
}
|
|
20
|
+
import { calculateRiskLevel } from "./profiler-types.js";
|
|
21
|
+
// ============================================================================
|
|
22
|
+
// MemoryProfiler
|
|
23
|
+
// ============================================================================
|
|
24
|
+
export class MemoryProfiler {
|
|
25
|
+
snapshots = [];
|
|
26
|
+
leakSuspects = [];
|
|
27
|
+
allocationHotspots = [];
|
|
28
|
+
options;
|
|
29
|
+
startTime = 0;
|
|
30
|
+
isRunning = false;
|
|
31
|
+
sampleIntervalId = null;
|
|
32
|
+
previousSnapshot = null;
|
|
33
|
+
growthRate = 0;
|
|
34
|
+
gcEvents = 0;
|
|
35
|
+
constructor(options) {
|
|
36
|
+
this.options = {
|
|
37
|
+
sampleIntervalMs: 500,
|
|
38
|
+
maxSnapshots: 200,
|
|
39
|
+
growthThresholdMbPerSec: 2,
|
|
40
|
+
leakDetectionWindowMs: 10000,
|
|
41
|
+
...options,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
// ========================================================================
|
|
45
|
+
// Lifecycle
|
|
46
|
+
// ========================================================================
|
|
47
|
+
start() {
|
|
48
|
+
this.startTime = performance.now();
|
|
49
|
+
this.isRunning = true;
|
|
50
|
+
this.snapshots.length = 0;
|
|
51
|
+
this.leakSuspects.length = 0;
|
|
52
|
+
this.allocationHotspots.length = 0;
|
|
53
|
+
this.previousSnapshot = null;
|
|
54
|
+
this.growthRate = 0;
|
|
55
|
+
this.gcEvents = 0;
|
|
56
|
+
// Take initial snapshot
|
|
57
|
+
this.takeSnapshot();
|
|
58
|
+
// Start periodic sampling
|
|
59
|
+
this.sampleIntervalId = setInterval(() => {
|
|
60
|
+
this.takeSnapshot();
|
|
61
|
+
}, this.options.sampleIntervalMs);
|
|
62
|
+
}
|
|
63
|
+
stop() {
|
|
64
|
+
this.isRunning = false;
|
|
65
|
+
if (this.sampleIntervalId) {
|
|
66
|
+
clearInterval(this.sampleIntervalId);
|
|
67
|
+
this.sampleIntervalId = null;
|
|
68
|
+
}
|
|
69
|
+
// Take final snapshot
|
|
70
|
+
this.takeSnapshot();
|
|
71
|
+
this.detectLeaks();
|
|
72
|
+
return this.getResult();
|
|
73
|
+
}
|
|
74
|
+
get isActive() {
|
|
75
|
+
return this.isRunning;
|
|
76
|
+
}
|
|
77
|
+
// ========================================================================
|
|
78
|
+
// Snapshot Collection
|
|
79
|
+
// ========================================================================
|
|
80
|
+
takeSnapshot() {
|
|
81
|
+
const usage = process.memoryUsage();
|
|
82
|
+
const snapshot = {
|
|
83
|
+
timestamp: performance.now(),
|
|
84
|
+
heapUsed: usage.heapUsed,
|
|
85
|
+
heapTotal: usage.heapTotal,
|
|
86
|
+
external: usage.external,
|
|
87
|
+
arrayBuffers: usage.arrayBuffers,
|
|
88
|
+
rss: usage.rss,
|
|
89
|
+
};
|
|
90
|
+
this.snapshots.push(snapshot);
|
|
91
|
+
// Enforce max snapshots
|
|
92
|
+
if (this.snapshots.length > this.options.maxSnapshots) {
|
|
93
|
+
this.snapshots.splice(0, this.snapshots.length - this.options.maxSnapshots);
|
|
94
|
+
}
|
|
95
|
+
// Detect GC events (heapUsed drops significantly)
|
|
96
|
+
if (this.previousSnapshot) {
|
|
97
|
+
const dropBytes = this.previousSnapshot.heapUsed - snapshot.heapUsed;
|
|
98
|
+
if (dropBytes > 5 * 1024 * 1024) {
|
|
99
|
+
// Drop > 5MB = likely GC
|
|
100
|
+
this.gcEvents++;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
this.previousSnapshot = snapshot;
|
|
104
|
+
return snapshot;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Record an allocation hotspot detected by external analysis.
|
|
108
|
+
*/
|
|
109
|
+
recordAllocationHotspot(fn, location, percentAllocations, allocationCount, suggestion) {
|
|
110
|
+
this.allocationHotspots.push({
|
|
111
|
+
function: fn,
|
|
112
|
+
location,
|
|
113
|
+
percentAllocations: Math.min(100, percentAllocations),
|
|
114
|
+
allocationCount,
|
|
115
|
+
suggestion,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Add a memory leak suspect.
|
|
120
|
+
*/
|
|
121
|
+
addLeakSuspect(pattern, description, confidence, location, suggestion) {
|
|
122
|
+
this.leakSuspects.push({
|
|
123
|
+
pattern,
|
|
124
|
+
description,
|
|
125
|
+
confidence: Math.min(1, Math.max(0, confidence)),
|
|
126
|
+
location,
|
|
127
|
+
suggestion: suggestion ?? `Investigate "${pattern}" pattern for proper cleanup`,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
// ========================================================================
|
|
131
|
+
// Leak Detection
|
|
132
|
+
// ========================================================================
|
|
133
|
+
detectLeaks() {
|
|
134
|
+
if (this.snapshots.length < 3)
|
|
135
|
+
return;
|
|
136
|
+
// Analyze growth over time
|
|
137
|
+
const midIndex = Math.floor(this.snapshots.length / 2);
|
|
138
|
+
const firstHalf = this.snapshots.slice(0, midIndex);
|
|
139
|
+
const secondHalf = this.snapshots.slice(midIndex);
|
|
140
|
+
const firstAvg = firstHalf.reduce((s, n) => s + n.heapUsed, 0) / firstHalf.length;
|
|
141
|
+
const secondAvg = secondHalf.reduce((s, n) => s + n.heapUsed, 0) / secondHalf.length;
|
|
142
|
+
const growthBytes = secondAvg - firstAvg;
|
|
143
|
+
const durationSec = (this.snapshots[this.snapshots.length - 1].timestamp -
|
|
144
|
+
this.snapshots[0].timestamp) / 1000;
|
|
145
|
+
this.growthRate = durationSec > 0 ? (growthBytes / (1024 * 1024)) / durationSec : 0;
|
|
146
|
+
// Monotonically increasing heap = leak suspect
|
|
147
|
+
let increasingCount = 0;
|
|
148
|
+
for (let i = 1; i < this.snapshots.length; i++) {
|
|
149
|
+
if (this.snapshots[i].heapUsed > this.snapshots[i - 1].heapUsed) {
|
|
150
|
+
increasingCount++;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
const increaseRatio = increasingCount / this.snapshots.length;
|
|
154
|
+
if (increaseRatio > 0.8 && this.growthRate > this.options.growthThresholdMbPerSec) {
|
|
155
|
+
this.leakSuspects.push({
|
|
156
|
+
pattern: "monotonically_increasing_heap",
|
|
157
|
+
description: `Heap grew continuously (${increaseRatio * 100}% of samples increasing) at ${this.growthRate.toFixed(2)} MB/s`,
|
|
158
|
+
confidence: Math.min(0.9, 0.5 + (this.growthRate / 10)),
|
|
159
|
+
suggestion: "Use heap snapshots to identify retained objects. Check for event listeners, timers, closures, and cache without eviction.",
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
// High RSS relative to heap = external leak
|
|
163
|
+
const rssSnapshots = this.snapshots.filter((s) => s.rss !== undefined);
|
|
164
|
+
if (rssSnapshots.length > 2) {
|
|
165
|
+
const avgRssMb = rssSnapshots.reduce((s, n) => s + (n.rss || 0), 0) / rssSnapshots.length / (1024 * 1024);
|
|
166
|
+
const avgHeapMb = rssSnapshots.reduce((s, n) => s + n.heapUsed, 0) / rssSnapshots.length / (1024 * 1024);
|
|
167
|
+
if (avgRssMb > avgHeapMb * 3) {
|
|
168
|
+
this.leakSuspects.push({
|
|
169
|
+
pattern: "high_rss_to_heap_ratio",
|
|
170
|
+
description: `RSS (${avgRssMb.toFixed(1)}MB) is ${(avgRssMb / avgHeapMb).toFixed(1)}x heap used (${avgHeapMb.toFixed(1)}MB)`,
|
|
171
|
+
confidence: 0.6,
|
|
172
|
+
suggestion: "Check for native bindings, large Buffers, or child processes leaking memory outside V8 heap.",
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
// Large array buffers
|
|
177
|
+
const avgArrayBuffers = this.snapshots.reduce((s, n) => s + n.arrayBuffers, 0) / this.snapshots.length;
|
|
178
|
+
if (avgArrayBuffers > 100 * 1024 * 1024) {
|
|
179
|
+
this.leakSuspects.push({
|
|
180
|
+
pattern: "large_array_buffers",
|
|
181
|
+
description: `Average ArrayBuffer size: ${(avgArrayBuffers / (1024 * 1024)).toFixed(1)}MB`,
|
|
182
|
+
confidence: 0.5,
|
|
183
|
+
suggestion: "Ensure ArrayBuffers are recycled or freed. Use pool allocation for frequent buffer operations.",
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
// ========================================================================
|
|
188
|
+
// Result
|
|
189
|
+
// ========================================================================
|
|
190
|
+
getResult() {
|
|
191
|
+
const heapUsages = this.snapshots.map((s) => s.heapUsed);
|
|
192
|
+
const heapUsedMb = (b) => Math.round((b / (1024 * 1024)) * 100) / 100;
|
|
193
|
+
const peakHeap = heapUsages.length > 0 ? Math.max(...heapUsages) : 0;
|
|
194
|
+
const minHeap = heapUsages.length > 0 ? Math.min(...heapUsages) : 0;
|
|
195
|
+
const avgHeap = heapUsages.length > 0
|
|
196
|
+
? heapUsages.reduce((s, n) => s + n, 0) / heapUsages.length
|
|
197
|
+
: 0;
|
|
198
|
+
return {
|
|
199
|
+
snapshots: [...this.snapshots],
|
|
200
|
+
leakSuspects: [...this.leakSuspects],
|
|
201
|
+
peakHeapUsedMb: heapUsedMb(peakHeap),
|
|
202
|
+
averageHeapUsedMb: heapUsedMb(avgHeap),
|
|
203
|
+
minHeapUsedMb: heapUsedMb(minHeap),
|
|
204
|
+
growthRateMbPerSec: Math.round(this.growthRate * 100) / 100,
|
|
205
|
+
totalGcEvents: this.gcEvents,
|
|
206
|
+
allocationHotspots: [...this.allocationHotspots],
|
|
207
|
+
riskLevel: calculateRiskLevel(heapUsedMb(peakHeap), this.growthRate, this.leakSuspects.length),
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
//# sourceMappingURL=memory-profiler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory-profiler.js","sourceRoot":"","sources":["../../src/profiler/memory-profiler.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,6BAA6B;AAC7B,iEAAiE;AACjE,MAAM,E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SAAS,EAAE,kBAAkB,CAC3B,UAAU,CAAC,QAAQ,CAAC,EACpB,IAAI,CAAC,UAAU,EACf,IAAI,CAAC,YAAY,CAAC,MAAM,CACzB;SACF,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Profiler Types — Core type definitions for performance profiling
|
|
3
|
+
*
|
|
4
|
+
* Phase 12: Performance Profiling — Integrated profiler for measuring
|
|
5
|
+
* CPU, memory, query, and rendering performance across the system.
|
|
6
|
+
*/
|
|
7
|
+
export interface ProfilerConfig {
|
|
8
|
+
/** Sample interval in ms (default: 100) */
|
|
9
|
+
sampleIntervalMs?: number;
|
|
10
|
+
/** Maximum profiling duration in ms (default: 30000) */
|
|
11
|
+
maxDurationMs?: number;
|
|
12
|
+
/** Maximum number of samples to collect (default: 1000) */
|
|
13
|
+
maxSamples?: number;
|
|
14
|
+
/** Include memory tracking (default: true) */
|
|
15
|
+
trackMemory?: boolean;
|
|
16
|
+
/** Include async operations tracking (default: true) */
|
|
17
|
+
trackAsync?: boolean;
|
|
18
|
+
/** Paths to include (glob patterns) */
|
|
19
|
+
includePaths?: string[];
|
|
20
|
+
/** Paths to exclude (glob patterns) */
|
|
21
|
+
excludePaths?: string[];
|
|
22
|
+
}
|
|
23
|
+
export interface ProfileResult {
|
|
24
|
+
/** Unique profile session ID */
|
|
25
|
+
sessionId: string;
|
|
26
|
+
/** When profiling started */
|
|
27
|
+
startTime: number;
|
|
28
|
+
/** When profiling ended */
|
|
29
|
+
endTime: number;
|
|
30
|
+
/** Duration in ms */
|
|
31
|
+
duration: number;
|
|
32
|
+
/** Configuration used */
|
|
33
|
+
config: Required<ProfilerConfig>;
|
|
34
|
+
/** CPU profile data */
|
|
35
|
+
cpu: CpuProfileResult;
|
|
36
|
+
/** Memory profile data */
|
|
37
|
+
memory: MemoryProfileResult;
|
|
38
|
+
/** Query profile data */
|
|
39
|
+
queries: QueryProfileResult;
|
|
40
|
+
/** Timeline of events */
|
|
41
|
+
timeline: TimelineEntry[];
|
|
42
|
+
/** Summary recommendations */
|
|
43
|
+
recommendations: string[];
|
|
44
|
+
}
|
|
45
|
+
export interface CpuProfileResult {
|
|
46
|
+
/** Total functions profiled */
|
|
47
|
+
totalFunctions: number;
|
|
48
|
+
/** Total async operations tracked */
|
|
49
|
+
totalAsyncOps: number;
|
|
50
|
+
/** Total sync operations tracked */
|
|
51
|
+
totalSyncOps: number;
|
|
52
|
+
/** Slowest functions (sorted) */
|
|
53
|
+
slowestFunctions: ProfiledFunction[];
|
|
54
|
+
/** Functions with most calls */
|
|
55
|
+
mostCalled: ProfiledFunction[];
|
|
56
|
+
/** Async waterfall entries */
|
|
57
|
+
asyncWaterfall: AsyncProfileEntry[];
|
|
58
|
+
/** Blocking operations detected */
|
|
59
|
+
blockingOps: BlockingOperation[];
|
|
60
|
+
/** Average execution time in ms */
|
|
61
|
+
averageTimeMs: number;
|
|
62
|
+
/** Peak execution time in ms */
|
|
63
|
+
peakTimeMs: number;
|
|
64
|
+
}
|
|
65
|
+
export interface ProfiledFunction {
|
|
66
|
+
name: string;
|
|
67
|
+
/** File location */
|
|
68
|
+
location?: string;
|
|
69
|
+
/** Number of times called */
|
|
70
|
+
callCount: number;
|
|
71
|
+
/** Total execution time in ms */
|
|
72
|
+
totalTimeMs: number;
|
|
73
|
+
/** Average execution time in ms */
|
|
74
|
+
averageTimeMs: number;
|
|
75
|
+
/** Minimum execution time in ms */
|
|
76
|
+
minTimeMs: number;
|
|
77
|
+
/** Maximum execution time in ms */
|
|
78
|
+
maxTimeMs: number;
|
|
79
|
+
/** Whether the function is async */
|
|
80
|
+
isAsync: boolean;
|
|
81
|
+
/** Stack trace samples */
|
|
82
|
+
samples?: number;
|
|
83
|
+
}
|
|
84
|
+
export interface AsyncProfileEntry {
|
|
85
|
+
operation: string;
|
|
86
|
+
/** Start time epoch ms */
|
|
87
|
+
startTime: number;
|
|
88
|
+
/** Duration in ms */
|
|
89
|
+
duration: number;
|
|
90
|
+
/** Status */
|
|
91
|
+
status: "pending" | "resolved" | "rejected";
|
|
92
|
+
/** Parent async operation if any */
|
|
93
|
+
parentOperation?: string;
|
|
94
|
+
/** Line/file location */
|
|
95
|
+
location?: string;
|
|
96
|
+
}
|
|
97
|
+
export interface BlockingOperation {
|
|
98
|
+
type: "sync_io" | "long_loop" | "heavy_compute" | "blocking_wait";
|
|
99
|
+
/** Description of the operation */
|
|
100
|
+
description: string;
|
|
101
|
+
/** Duration in ms */
|
|
102
|
+
durationMs: number;
|
|
103
|
+
/** Threshold exceeded */
|
|
104
|
+
thresholdMs: number;
|
|
105
|
+
/** Location */
|
|
106
|
+
location?: string;
|
|
107
|
+
/** Suggestion for improvement */
|
|
108
|
+
suggestion: string;
|
|
109
|
+
}
|
|
110
|
+
export interface MemoryProfileResult {
|
|
111
|
+
/** Memory snapshot timeline */
|
|
112
|
+
snapshots: MemorySnapshot[];
|
|
113
|
+
/** Memory leak suspects */
|
|
114
|
+
leakSuspects: MemoryLeakSuspect[];
|
|
115
|
+
/** Peak memory usage in MB */
|
|
116
|
+
peakHeapUsedMb: number;
|
|
117
|
+
/** Average memory usage in MB */
|
|
118
|
+
averageHeapUsedMb: number;
|
|
119
|
+
/** Min memory usage in MB */
|
|
120
|
+
minHeapUsedMb: number;
|
|
121
|
+
/** Memory growth rate (MB/s) */
|
|
122
|
+
growthRateMbPerSec: number;
|
|
123
|
+
/** Total garbage collections observed */
|
|
124
|
+
totalGcEvents: number;
|
|
125
|
+
/** Detected allocation hotspots */
|
|
126
|
+
allocationHotspots: AllocationHotspot[];
|
|
127
|
+
/** Risk level */
|
|
128
|
+
riskLevel: "low" | "medium" | "high" | "critical";
|
|
129
|
+
}
|
|
130
|
+
export interface MemorySnapshot {
|
|
131
|
+
timestamp: number;
|
|
132
|
+
/** Heap used in bytes */
|
|
133
|
+
heapUsed: number;
|
|
134
|
+
/** Heap total in bytes */
|
|
135
|
+
heapTotal: number;
|
|
136
|
+
/** External memory in bytes */
|
|
137
|
+
external: number;
|
|
138
|
+
/** Array buffers in bytes */
|
|
139
|
+
arrayBuffers: number;
|
|
140
|
+
/** RSS in bytes */
|
|
141
|
+
rss?: number;
|
|
142
|
+
}
|
|
143
|
+
export interface MemoryLeakSuspect {
|
|
144
|
+
/** Pattern that suggests a leak */
|
|
145
|
+
pattern: string;
|
|
146
|
+
/** Description of the suspected leak */
|
|
147
|
+
description: string;
|
|
148
|
+
/** Confidence level 0-1 */
|
|
149
|
+
confidence: number;
|
|
150
|
+
/** Affected area */
|
|
151
|
+
location?: string;
|
|
152
|
+
/** Suggestion */
|
|
153
|
+
suggestion: string;
|
|
154
|
+
}
|
|
155
|
+
export interface AllocationHotspot {
|
|
156
|
+
function: string;
|
|
157
|
+
location: string;
|
|
158
|
+
/** Percentage of total allocations */
|
|
159
|
+
percentAllocations: number;
|
|
160
|
+
/** Number of allocation events */
|
|
161
|
+
allocationCount: number;
|
|
162
|
+
/** Suggested optimization */
|
|
163
|
+
suggestion: string;
|
|
164
|
+
}
|
|
165
|
+
export interface QueryProfileResult {
|
|
166
|
+
totalQueries: number;
|
|
167
|
+
slowestQueries: SlowQuery[];
|
|
168
|
+
nPlusOneDetections: NPlusOneDetection[];
|
|
169
|
+
duplicateDetections: DuplicateQuery[];
|
|
170
|
+
cacheMisses: number;
|
|
171
|
+
averageQueryTimeMs: number;
|
|
172
|
+
totalQueryTimeMs: number;
|
|
173
|
+
recommendations: string[];
|
|
174
|
+
}
|
|
175
|
+
export interface SlowQuery {
|
|
176
|
+
/** Query fingerprint (normalized form) */
|
|
177
|
+
fingerprint: string;
|
|
178
|
+
/** Raw query text */
|
|
179
|
+
query: string;
|
|
180
|
+
/** Execution time in ms */
|
|
181
|
+
executionTimeMs: number;
|
|
182
|
+
/** Number of times executed */
|
|
183
|
+
executionCount: number;
|
|
184
|
+
/** Source file location */
|
|
185
|
+
location?: string;
|
|
186
|
+
/** Suggested index or optimization */
|
|
187
|
+
suggestion: string;
|
|
188
|
+
/** Whether a covering index would help */
|
|
189
|
+
needsIndex: boolean;
|
|
190
|
+
}
|
|
191
|
+
export interface NPlusOneDetection {
|
|
192
|
+
/** The parent query */
|
|
193
|
+
parentQuery: string;
|
|
194
|
+
/** The repeated child query */
|
|
195
|
+
childQuery: string;
|
|
196
|
+
/** Number of repeated executions */
|
|
197
|
+
repeatCount: number;
|
|
198
|
+
/** Total time wasted in ms */
|
|
199
|
+
wastedTimeMs: number;
|
|
200
|
+
/** Location */
|
|
201
|
+
location?: string;
|
|
202
|
+
/** Suggestion (batch/join/eager load) */
|
|
203
|
+
suggestion: string;
|
|
204
|
+
}
|
|
205
|
+
export interface DuplicateQuery {
|
|
206
|
+
/** Query fingerprint */
|
|
207
|
+
fingerprint: string;
|
|
208
|
+
/** Number of identical executions */
|
|
209
|
+
executionCount: number;
|
|
210
|
+
/** Total wasted time (all but first) */
|
|
211
|
+
wastedTimeMs: number;
|
|
212
|
+
/** Location */
|
|
213
|
+
location?: string;
|
|
214
|
+
}
|
|
215
|
+
export interface TimelineEntry {
|
|
216
|
+
timestamp: number;
|
|
217
|
+
type: "cpu_sample" | "memory_sample" | "async_start" | "async_end" | "gc_event" | "query" | "allocation" | "custom";
|
|
218
|
+
label: string;
|
|
219
|
+
duration?: number;
|
|
220
|
+
data?: Record<string, unknown>;
|
|
221
|
+
}
|
|
222
|
+
export type ReportFormat = "json" | "markdown" | "html";
|
|
223
|
+
export interface ExportOptions {
|
|
224
|
+
format: ReportFormat;
|
|
225
|
+
includeTimeline?: boolean;
|
|
226
|
+
includeAllFunctions?: boolean;
|
|
227
|
+
maxFunctions?: number;
|
|
228
|
+
title?: string;
|
|
229
|
+
colorScheme?: "light" | "dark";
|
|
230
|
+
}
|
|
231
|
+
export declare function createDefaultProfilerConfig(): Required<ProfilerConfig>;
|
|
232
|
+
export declare function calculateRiskLevel(peakMb: number, growthRate: number, leakSuspects: number): MemoryProfileResult["riskLevel"];
|
|
233
|
+
export declare function createEmptyProfileResult(config?: ProfilerConfig): ProfileResult;
|
|
234
|
+
//# sourceMappingURL=profiler-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profiler-types.d.ts","sourceRoot":"","sources":["../../src/profiler/profiler-types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,MAAM,WAAW,cAAc;IAC7B,2CAA2C;IAC3C,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,wDAAwD;IACxD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,2DAA2D;IAC3D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,8CAA8C;IAC9C,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,wDAAwD;IACxD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,uCAAuC;IACvC,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,uCAAuC;IACvC,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB;AAMD,MAAM,WAAW,aAAa;IAC5B,gCAAgC;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,6BAA6B;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,2BAA2B;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,qBAAqB;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,yBAAyB;IACzB,MAAM,EAAE,QAAQ,CAAC,cAAc,CAAC,CAAC;IACjC,uBAAuB;IACvB,GAAG,EAAE,gBAAgB,CAAC;IACtB,0BAA0B;IAC1B,MAAM,EAAE,mBAAmB,CAAC;IAC5B,yBAAyB;IACzB,OAAO,EAAE,kBAAkB,CAAC;IAC5B,yBAAyB;IACzB,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B,8BAA8B;IAC9B,eAAe,EAAE,MAAM,EAAE,CAAC;CAC3B;AAMD,MAAM,WAAW,gBAAgB;IAC/B,+BAA+B;IAC/B,cAAc,EAAE,MAAM,CAAC;IACvB,qCAAqC;IACrC,aAAa,EAAE,MAAM,CAAC;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Integrated profiler for measuring
|
|
5
|
+
* CPU, memory, query, and rendering performance across the system.
|
|
6
|
+
*/
|
|
7
|
+
// ============================================================================
|
|
8
|
+
// Helpers
|
|
9
|
+
// ============================================================================
|
|
10
|
+
export function createDefaultProfilerConfig() {
|
|
11
|
+
return {
|
|
12
|
+
sampleIntervalMs: 100,
|
|
13
|
+
maxDurationMs: 30000,
|
|
14
|
+
maxSamples: 1000,
|
|
15
|
+
trackMemory: true,
|
|
16
|
+
trackAsync: true,
|
|
17
|
+
includePaths: ["src/**/*.ts"],
|
|
18
|
+
excludePaths: ["node_modules/**", "dist/**", ".git/**"],
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export function calculateRiskLevel(peakMb, growthRate, leakSuspects) {
|
|
22
|
+
let score = 0;
|
|
23
|
+
if (peakMb > 500)
|
|
24
|
+
score += 2;
|
|
25
|
+
else if (peakMb > 200)
|
|
26
|
+
score += 1;
|
|
27
|
+
if (growthRate > 10)
|
|
28
|
+
score += 3;
|
|
29
|
+
else if (growthRate > 5)
|
|
30
|
+
score += 2;
|
|
31
|
+
else if (growthRate > 1)
|
|
32
|
+
score += 1;
|
|
33
|
+
if (leakSuspects > 3)
|
|
34
|
+
score += 3;
|
|
35
|
+
else if (leakSuspects > 1)
|
|
36
|
+
score += 1;
|
|
37
|
+
if (score >= 6)
|
|
38
|
+
return "critical";
|
|
39
|
+
if (score >= 4)
|
|
40
|
+
return "high";
|
|
41
|
+
if (score >= 2)
|
|
42
|
+
return "medium";
|
|
43
|
+
return "low";
|
|
44
|
+
}
|
|
45
|
+
export function createEmptyProfileResult(config) {
|
|
46
|
+
const cfg = config ? { ...createDefaultProfilerConfig(), ...config } : createDefaultProfilerConfig();
|
|
47
|
+
return {
|
|
48
|
+
sessionId: `profile_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`,
|
|
49
|
+
startTime: 0,
|
|
50
|
+
endTime: 0,
|
|
51
|
+
duration: 0,
|
|
52
|
+
config: cfg,
|
|
53
|
+
cpu: {
|
|
54
|
+
totalFunctions: 0,
|
|
55
|
+
totalAsyncOps: 0,
|
|
56
|
+
totalSyncOps: 0,
|
|
57
|
+
slowestFunctions: [],
|
|
58
|
+
mostCalled: [],
|
|
59
|
+
asyncWaterfall: [],
|
|
60
|
+
blockingOps: [],
|
|
61
|
+
averageTimeMs: 0,
|
|
62
|
+
peakTimeMs: 0,
|
|
63
|
+
},
|
|
64
|
+
memory: {
|
|
65
|
+
snapshots: [],
|
|
66
|
+
leakSuspects: [],
|
|
67
|
+
peakHeapUsedMb: 0,
|
|
68
|
+
averageHeapUsedMb: 0,
|
|
69
|
+
minHeapUsedMb: 0,
|
|
70
|
+
growthRateMbPerSec: 0,
|
|
71
|
+
totalGcEvents: 0,
|
|
72
|
+
allocationHotspots: [],
|
|
73
|
+
riskLevel: "low",
|
|
74
|
+
},
|
|
75
|
+
queries: {
|
|
76
|
+
totalQueries: 0,
|
|
77
|
+
slowestQueries: [],
|
|
78
|
+
nPlusOneDetections: [],
|
|
79
|
+
duplicateDetections: [],
|
|
80
|
+
cacheMisses: 0,
|
|
81
|
+
averageQueryTimeMs: 0,
|
|
82
|
+
totalQueryTimeMs: 0,
|
|
83
|
+
recommendations: [],
|
|
84
|
+
},
|
|
85
|
+
timeline: [],
|
|
86
|
+
recommendations: [],
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=profiler-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profiler-types.js","sourceRoot":"","sources":["../../src/profiler/profiler-types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAuRH,+EAA+E;AAC/E,UAAU;AACV,+EAA+E;AAE/E,MAAM,UAAU,2BAA2B;IACzC,OAAO;QACL,gBAAgB,EAAE,GAAG;QACrB,aAAa,EAAE,KAAK;QACpB,UAAU,EAAE,IAAI;QAChB,WAAW,EAAE,IAAI;QACjB,UAAU,EAAE,IAAI;QAChB,YAAY,EAAE,CAAC,aAAa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AAC;QACX,MAAM,EAAE,GAAG;QACX,GAAG,EAAE;YACH,cAAc,EAAE,CAAC;YACjB,aAAa,EAAE,CAAC;YAChB,YAAY,EAAE,CAAC;YACf,gBAAgB,EAAE,EAAE;YACpB,UAAU,EAAE,EAAE;YACd,cAAc,EAAE,EAAE;YAClB,WAAW,EAAE,EAAE;YACf,aAAa,EAAE,CAAC;YAChB,UAAU,EAAE,CAAC;SACd;QACD,MAAM,EAAE;YACN,SAAS,EAAE,EAAE;YACb,YAAY,EAAE,EAAE;YAChB,cAAc,EAAE,CAAC;YACjB,iBAAiB,EAAE,CAAC;YACpB,aAAa,EAAE,CAAC;YAChB,kBAAkB,EAAE,CAAC;YACrB,aAAa,EAAE,CAAC;YAChB,kBAAkB,EAAE,EAAE;YACtB,SAAS,EAAE,KAAK;SACjB;QACD,OAAO,EAAE;YACP,YAAY,EAAE,CAAC;YACf,cAAc,EAAE,EAAE;YAClB,kBAAkB,EAAE,EAAE;YACtB,mBAAmB,EAAE,EAAE;YACvB,WAAW,EAAE,CAAC;YACd,kBAAkB,EAAE,CAAC;YACrB,gBAAgB,EAAE,CAAC;YACnB,eAAe,EAAE,EAAE;SACpB;QACD,QAAQ,EAAE,EAAE;QACZ,eAAe,EAAE,EAAE;KACpB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Query Profiler — Database query analysis and optimization detection
|
|
3
|
+
*
|
|
4
|
+
* Phase 12: Performance Profiling — Detects slow queries, N+1 patterns,
|
|
5
|
+
* duplicate queries, and provides optimization recommendations.
|
|
6
|
+
*/
|
|
7
|
+
import type { QueryProfileResult } from "./profiler-types.js";
|
|
8
|
+
export interface QueryProfilerOptions {
|
|
9
|
+
/** Threshold in ms for slow query detection (default: 100) */
|
|
10
|
+
slowQueryThresholdMs?: number;
|
|
11
|
+
/** Threshold for N+1 detection (minimum repeats) (default: 5) */
|
|
12
|
+
nPlusOneMinRepeats?: number;
|
|
13
|
+
/** Maximum queries to track (default: 1000) */
|
|
14
|
+
maxQueries?: number;
|
|
15
|
+
/** Whether to normalize SQL for fingerprinting (default: true) */
|
|
16
|
+
normalizeSql?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export declare class QueryProfiler {
|
|
19
|
+
private readonly queries;
|
|
20
|
+
private options;
|
|
21
|
+
private isRunning;
|
|
22
|
+
constructor(options?: QueryProfilerOptions);
|
|
23
|
+
start(): void;
|
|
24
|
+
stop(): QueryProfileResult;
|
|
25
|
+
get isActive(): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Record a database query execution.
|
|
28
|
+
*/
|
|
29
|
+
recordQuery(query: string, executionTimeMs: number, location?: string): void;
|
|
30
|
+
/**
|
|
31
|
+
* Record multiple queries at once (batch recording).
|
|
32
|
+
*/
|
|
33
|
+
recordQueries(records: Array<{
|
|
34
|
+
query: string;
|
|
35
|
+
executionTimeMs: number;
|
|
36
|
+
location?: string;
|
|
37
|
+
}>): void;
|
|
38
|
+
/**
|
|
39
|
+
* Normalize a SQL query by replacing literals with placeholders.
|
|
40
|
+
*/
|
|
41
|
+
private fingerprint;
|
|
42
|
+
private getResult;
|
|
43
|
+
private detectSlowQueries;
|
|
44
|
+
private detectNPlusOne;
|
|
45
|
+
private detectDuplicates;
|
|
46
|
+
private groupByFingerprint;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=query-profiler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-profiler.d.ts","sourceRoot":"","sources":["../../src/profiler/query-profiler.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAIV,kBAAkB,EACnB,MAAM,qBAAqB,CAAC;AAM7B,MAAM,WAAW,oBAAoB;IACnC,8DAA8D;IAC9D,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,iEAAiE;IACjE,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,+CAA+C;IAC/C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kEAAkE;IAClE,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAMD,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAMhB;IAER,OAAO,CAAC,OAAO,CAAiC;IAChD,OAAO,CAAC,SAAS,CAAkB;gBAEvB,OAAO,CAAC,EAAE,oBAAoB;IAc1C,KAAK,IAAI,IAAI;IAKb,IAAI,IAAI,kBAAkB;IAK1B,IAAI,QAAQ,IAAI,OAAO,CAEtB;IAMD;;OAEG;IACH,WAAW,CACT,KAAK,EAAE,MAAM,EACb,eAAe,EAAE,MAAM,EACvB,QAAQ,CAAC,EAAE,MAAM,GAChB,IAAI;IAgBP;;OAEG;IACH,aAAa,CACX,OAAO,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,eAAe,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,GAC5E,IAAI;IAUP;;OAEG;IACH,OAAO,CAAC,WAAW;IAcnB,OAAO,CAAC,SAAS;IAsCjB,OAAO,CAAC,iBAAiB;IA0BzB,OAAO,CAAC,cAAc;IAyCtB,OAAO,CAAC,gBAAgB;IAkBxB,OAAO,CAAC,kBAAkB;CA8B3B"}
|