@weavelogic/knowledge-graph-agent 0.2.0 → 0.3.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/README.md +686 -304
- package/dist/_virtual/_commonjsHelpers.js +7 -0
- package/dist/_virtual/_commonjsHelpers.js.map +1 -0
- package/dist/_virtual/additionalItems.js +5 -0
- package/dist/_virtual/additionalItems.js.map +1 -0
- package/dist/_virtual/additionalProperties.js +5 -0
- package/dist/_virtual/additionalProperties.js.map +1 -0
- package/dist/_virtual/ajv.js +6 -0
- package/dist/_virtual/ajv.js.map +1 -0
- package/dist/_virtual/ajv2.js +5 -0
- package/dist/_virtual/ajv2.js.map +1 -0
- package/dist/_virtual/allOf.js +5 -0
- package/dist/_virtual/allOf.js.map +1 -0
- package/dist/_virtual/anyOf.js +5 -0
- package/dist/_virtual/anyOf.js.map +1 -0
- package/dist/_virtual/applicability.js +5 -0
- package/dist/_virtual/applicability.js.map +1 -0
- package/dist/_virtual/boolSchema.js +5 -0
- package/dist/_virtual/boolSchema.js.map +1 -0
- package/dist/_virtual/code.js +5 -0
- package/dist/_virtual/code.js.map +1 -0
- package/dist/_virtual/code2.js +5 -0
- package/dist/_virtual/code2.js.map +1 -0
- package/dist/_virtual/const.js +5 -0
- package/dist/_virtual/const.js.map +1 -0
- package/dist/_virtual/contains.js +5 -0
- package/dist/_virtual/contains.js.map +1 -0
- package/dist/_virtual/core.js +5 -0
- package/dist/_virtual/core.js.map +1 -0
- package/dist/_virtual/dataType.js +5 -0
- package/dist/_virtual/dataType.js.map +1 -0
- package/dist/_virtual/defaults.js +5 -0
- package/dist/_virtual/defaults.js.map +1 -0
- package/dist/_virtual/dependencies.js +5 -0
- package/dist/_virtual/dependencies.js.map +1 -0
- package/dist/_virtual/draft7.js +5 -0
- package/dist/_virtual/draft7.js.map +1 -0
- package/dist/_virtual/enum.js +5 -0
- package/dist/_virtual/enum.js.map +1 -0
- package/dist/_virtual/equal.js +5 -0
- package/dist/_virtual/equal.js.map +1 -0
- package/dist/_virtual/errors.js +5 -0
- package/dist/_virtual/errors.js.map +1 -0
- package/dist/_virtual/format.js +5 -0
- package/dist/_virtual/format.js.map +1 -0
- package/dist/_virtual/formats.js +5 -0
- package/dist/_virtual/formats.js.map +1 -0
- package/dist/_virtual/id.js +5 -0
- package/dist/_virtual/id.js.map +1 -0
- package/dist/_virtual/if.js +5 -0
- package/dist/_virtual/if.js.map +1 -0
- package/dist/_virtual/index.js +8 -0
- package/dist/_virtual/index.js.map +1 -0
- package/dist/_virtual/index10.js +5 -0
- package/dist/_virtual/index10.js.map +1 -0
- package/dist/_virtual/index11.js +5 -0
- package/dist/_virtual/index11.js.map +1 -0
- package/dist/_virtual/index12.js +5 -0
- package/dist/_virtual/index12.js.map +1 -0
- package/dist/_virtual/index2.js +5 -0
- package/dist/_virtual/index2.js.map +1 -0
- package/dist/_virtual/index3.js +5 -0
- package/dist/_virtual/index3.js.map +1 -0
- package/dist/_virtual/index4.js +5 -0
- package/dist/_virtual/index4.js.map +1 -0
- package/dist/_virtual/index5.js +5 -0
- package/dist/_virtual/index5.js.map +1 -0
- package/dist/_virtual/index6.js +5 -0
- package/dist/_virtual/index6.js.map +1 -0
- package/dist/_virtual/index7.js +5 -0
- package/dist/_virtual/index7.js.map +1 -0
- package/dist/_virtual/index8.js +5 -0
- package/dist/_virtual/index8.js.map +1 -0
- package/dist/_virtual/index9.js +5 -0
- package/dist/_virtual/index9.js.map +1 -0
- package/dist/_virtual/items.js +5 -0
- package/dist/_virtual/items.js.map +1 -0
- package/dist/_virtual/items2020.js +5 -0
- package/dist/_virtual/items2020.js.map +1 -0
- package/dist/_virtual/keyword.js +5 -0
- package/dist/_virtual/keyword.js.map +1 -0
- package/dist/_virtual/limit.js +5 -0
- package/dist/_virtual/limit.js.map +1 -0
- package/dist/_virtual/limitItems.js +5 -0
- package/dist/_virtual/limitItems.js.map +1 -0
- package/dist/_virtual/limitLength.js +5 -0
- package/dist/_virtual/limitLength.js.map +1 -0
- package/dist/_virtual/limitNumber.js +5 -0
- package/dist/_virtual/limitNumber.js.map +1 -0
- package/dist/_virtual/limitProperties.js +5 -0
- package/dist/_virtual/limitProperties.js.map +1 -0
- package/dist/_virtual/metadata.js +5 -0
- package/dist/_virtual/metadata.js.map +1 -0
- package/dist/_virtual/multipleOf.js +5 -0
- package/dist/_virtual/multipleOf.js.map +1 -0
- package/dist/_virtual/names.js +5 -0
- package/dist/_virtual/names.js.map +1 -0
- package/dist/_virtual/not.js +5 -0
- package/dist/_virtual/not.js.map +1 -0
- package/dist/_virtual/oneOf.js +5 -0
- package/dist/_virtual/oneOf.js.map +1 -0
- package/dist/_virtual/pattern.js +5 -0
- package/dist/_virtual/pattern.js.map +1 -0
- package/dist/_virtual/patternProperties.js +5 -0
- package/dist/_virtual/patternProperties.js.map +1 -0
- package/dist/_virtual/prefixItems.js +5 -0
- package/dist/_virtual/prefixItems.js.map +1 -0
- package/dist/_virtual/properties.js +5 -0
- package/dist/_virtual/properties.js.map +1 -0
- package/dist/_virtual/propertyNames.js +5 -0
- package/dist/_virtual/propertyNames.js.map +1 -0
- package/dist/_virtual/ref.js +5 -0
- package/dist/_virtual/ref.js.map +1 -0
- package/dist/_virtual/ref_error.js +5 -0
- package/dist/_virtual/ref_error.js.map +1 -0
- package/dist/_virtual/required.js +5 -0
- package/dist/_virtual/required.js.map +1 -0
- package/dist/_virtual/resolve.js +5 -0
- package/dist/_virtual/resolve.js.map +1 -0
- package/dist/_virtual/rules.js +5 -0
- package/dist/_virtual/rules.js.map +1 -0
- package/dist/_virtual/scope.js +5 -0
- package/dist/_virtual/scope.js.map +1 -0
- package/dist/_virtual/subschema.js +5 -0
- package/dist/_virtual/subschema.js.map +1 -0
- package/dist/_virtual/thenElse.js +5 -0
- package/dist/_virtual/thenElse.js.map +1 -0
- package/dist/_virtual/types.js +5 -0
- package/dist/_virtual/types.js.map +1 -0
- package/dist/_virtual/ucs2length.js +5 -0
- package/dist/_virtual/ucs2length.js.map +1 -0
- package/dist/_virtual/uniqueItems.js +5 -0
- package/dist/_virtual/uniqueItems.js.map +1 -0
- package/dist/_virtual/uri.js +5 -0
- package/dist/_virtual/uri.js.map +1 -0
- package/dist/_virtual/util.js +5 -0
- package/dist/_virtual/util.js.map +1 -0
- package/dist/_virtual/validation_error.js +5 -0
- package/dist/_virtual/validation_error.js.map +1 -0
- package/dist/agents/analyst-agent.d.ts +230 -0
- package/dist/agents/analyst-agent.d.ts.map +1 -0
- package/dist/agents/analyst-agent.js +793 -0
- package/dist/agents/analyst-agent.js.map +1 -0
- package/dist/agents/architect-agent.d.ts +248 -0
- package/dist/agents/architect-agent.d.ts.map +1 -0
- package/dist/agents/architect-agent.js +685 -0
- package/dist/agents/architect-agent.js.map +1 -0
- package/dist/agents/base-agent.d.ts +169 -0
- package/dist/agents/base-agent.d.ts.map +1 -0
- package/dist/agents/base-agent.js +441 -0
- package/dist/agents/base-agent.js.map +1 -0
- package/dist/agents/coder-agent.d.ts +191 -0
- package/dist/agents/coder-agent.d.ts.map +1 -0
- package/dist/agents/coder-agent.js +1008 -0
- package/dist/agents/coder-agent.js.map +1 -0
- package/dist/agents/index.d.ts +18 -0
- package/dist/agents/index.d.ts.map +1 -0
- package/dist/agents/index.js +40 -0
- package/dist/agents/index.js.map +1 -0
- package/dist/agents/registry.d.ts +213 -0
- package/dist/agents/registry.d.ts.map +1 -0
- package/dist/agents/registry.js +419 -0
- package/dist/agents/registry.js.map +1 -0
- package/dist/agents/researcher-agent.d.ts +226 -0
- package/dist/agents/researcher-agent.d.ts.map +1 -0
- package/dist/agents/researcher-agent.js +572 -0
- package/dist/agents/researcher-agent.js.map +1 -0
- package/dist/agents/rules-engine.d.ts +320 -0
- package/dist/agents/rules-engine.d.ts.map +1 -0
- package/dist/agents/rules-engine.js +552 -0
- package/dist/agents/rules-engine.js.map +1 -0
- package/dist/agents/tester-agent.d.ts +219 -0
- package/dist/agents/tester-agent.d.ts.map +1 -0
- package/dist/agents/tester-agent.js +683 -0
- package/dist/agents/tester-agent.js.map +1 -0
- package/dist/agents/types.d.ts +425 -0
- package/dist/agents/types.d.ts.map +1 -0
- package/dist/agents/types.js +57 -0
- package/dist/agents/types.js.map +1 -0
- package/dist/caching/index.d.ts +55 -0
- package/dist/caching/index.d.ts.map +1 -0
- package/dist/caching/index.js +206 -0
- package/dist/caching/index.js.map +1 -0
- package/dist/caching/lru-cache.d.ts +254 -0
- package/dist/caching/lru-cache.d.ts.map +1 -0
- package/dist/caching/types.d.ts +95 -0
- package/dist/caching/types.d.ts.map +1 -0
- package/dist/chunking/chunker.d.ts +94 -0
- package/dist/chunking/chunker.d.ts.map +1 -0
- package/dist/chunking/index.d.ts +125 -0
- package/dist/chunking/index.d.ts.map +1 -0
- package/dist/chunking/index.js +283 -0
- package/dist/chunking/index.js.map +1 -0
- package/dist/chunking/types.d.ts +92 -0
- package/dist/chunking/types.d.ts.map +1 -0
- package/dist/cli/commands/commit.d.ts +11 -0
- package/dist/cli/commands/commit.d.ts.map +1 -0
- package/dist/cli/commands/commit.js +379 -0
- package/dist/cli/commands/commit.js.map +1 -0
- package/dist/cli/commands/config.d.ts +8 -0
- package/dist/cli/commands/config.d.ts.map +1 -0
- package/dist/cli/commands/config.js +107 -0
- package/dist/cli/commands/config.js.map +1 -0
- package/dist/cli/commands/cultivate.d.ts +16 -0
- package/dist/cli/commands/cultivate.d.ts.map +1 -0
- package/dist/cli/commands/cultivate.js +254 -0
- package/dist/cli/commands/cultivate.js.map +1 -0
- package/dist/cli/commands/diagnostics.d.ts +8 -0
- package/dist/cli/commands/diagnostics.d.ts.map +1 -0
- package/dist/cli/commands/diagnostics.js +140 -0
- package/dist/cli/commands/diagnostics.js.map +1 -0
- package/dist/cli/commands/generate.d.ts +13 -0
- package/dist/cli/commands/generate.d.ts.map +1 -0
- package/dist/cli/commands/init-primitives.d.ts +19 -0
- package/dist/cli/commands/init-primitives.d.ts.map +1 -0
- package/dist/cli/commands/init-primitives.js +208 -0
- package/dist/cli/commands/init-primitives.js.map +1 -0
- package/dist/cli/commands/sop.d.ts +14 -0
- package/dist/cli/commands/sop.d.ts.map +1 -0
- package/dist/cli/commands/sop.js +598 -0
- package/dist/cli/commands/sop.js.map +1 -0
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +40 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/config/index.d.ts +153 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +141 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/manager.d.ts +136 -0
- package/dist/config/manager.d.ts.map +1 -0
- package/dist/config/types.d.ts +127 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/core/cache.d.ts +185 -0
- package/dist/core/cache.d.ts.map +1 -0
- package/dist/core/cache.js +435 -0
- package/dist/core/cache.js.map +1 -0
- package/dist/cultivation/deep-analyzer.d.ts +129 -0
- package/dist/cultivation/deep-analyzer.d.ts.map +1 -0
- package/dist/cultivation/deep-analyzer.js +322 -0
- package/dist/cultivation/deep-analyzer.js.map +1 -0
- package/dist/cultivation/index.d.ts +13 -0
- package/dist/cultivation/index.d.ts.map +1 -0
- package/dist/cultivation/seed-generator.d.ts +92 -0
- package/dist/cultivation/seed-generator.d.ts.map +1 -0
- package/dist/cultivation/seed-generator.js +1033 -0
- package/dist/cultivation/seed-generator.js.map +1 -0
- package/dist/cultivation/types.d.ts +230 -0
- package/dist/cultivation/types.d.ts.map +1 -0
- package/dist/generators/claude-md.d.ts +7 -0
- package/dist/generators/claude-md.d.ts.map +1 -1
- package/dist/generators/claude-md.js.map +1 -1
- package/dist/generators/docs-init.d.ts +6 -0
- package/dist/generators/docs-init.d.ts.map +1 -1
- package/dist/generators/docs-init.js.map +1 -1
- package/dist/health/checks.d.ts +135 -0
- package/dist/health/checks.d.ts.map +1 -0
- package/dist/health/index.d.ts +119 -0
- package/dist/health/index.d.ts.map +1 -0
- package/dist/health/index.js +191 -0
- package/dist/health/index.js.map +1 -0
- package/dist/health/monitor.d.ts +146 -0
- package/dist/health/monitor.d.ts.map +1 -0
- package/dist/health/types.d.ts +135 -0
- package/dist/health/types.d.ts.map +1 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +173 -1
- package/dist/index.js.map +1 -1
- package/dist/integrations/auto-commit.d.ts +175 -0
- package/dist/integrations/auto-commit.d.ts.map +1 -0
- package/dist/integrations/auto-commit.js +399 -0
- package/dist/integrations/auto-commit.js.map +1 -0
- package/dist/integrations/git.d.ts +299 -0
- package/dist/integrations/git.d.ts.map +1 -0
- package/dist/integrations/git.js +465 -0
- package/dist/integrations/git.js.map +1 -0
- package/dist/mcp-server/bin.d.ts +11 -0
- package/dist/mcp-server/bin.d.ts.map +1 -0
- package/dist/mcp-server/handlers/index.d.ts +57 -0
- package/dist/mcp-server/handlers/index.d.ts.map +1 -0
- package/dist/mcp-server/handlers/index.js +235 -0
- package/dist/mcp-server/handlers/index.js.map +1 -0
- package/dist/mcp-server/index.d.ts +28 -0
- package/dist/mcp-server/index.d.ts.map +1 -0
- package/dist/mcp-server/server.d.ts +133 -0
- package/dist/mcp-server/server.d.ts.map +1 -0
- package/dist/mcp-server/server.js +280 -0
- package/dist/mcp-server/server.js.map +1 -0
- package/dist/mcp-server/tools/agents/index.d.ts +10 -0
- package/dist/mcp-server/tools/agents/index.d.ts.map +1 -0
- package/dist/mcp-server/tools/agents/list.d.ts +19 -0
- package/dist/mcp-server/tools/agents/list.d.ts.map +1 -0
- package/dist/mcp-server/tools/agents/spawn.d.ts +19 -0
- package/dist/mcp-server/tools/agents/spawn.d.ts.map +1 -0
- package/dist/mcp-server/tools/graph/generate.d.ts +21 -0
- package/dist/mcp-server/tools/graph/generate.d.ts.map +1 -0
- package/dist/mcp-server/tools/graph/index.d.ts +11 -0
- package/dist/mcp-server/tools/graph/index.d.ts.map +1 -0
- package/dist/mcp-server/tools/graph/query.d.ts +22 -0
- package/dist/mcp-server/tools/graph/query.d.ts.map +1 -0
- package/dist/mcp-server/tools/graph/stats.d.ts +22 -0
- package/dist/mcp-server/tools/graph/stats.d.ts.map +1 -0
- package/dist/mcp-server/tools/health.d.ts +21 -0
- package/dist/mcp-server/tools/health.d.ts.map +1 -0
- package/dist/mcp-server/tools/index.d.ts +13 -0
- package/dist/mcp-server/tools/index.d.ts.map +1 -0
- package/dist/mcp-server/tools/registry.d.ts +90 -0
- package/dist/mcp-server/tools/registry.d.ts.map +1 -0
- package/dist/mcp-server/tools/registry.js +663 -0
- package/dist/mcp-server/tools/registry.js.map +1 -0
- package/dist/mcp-server/tools/search/index.d.ts +10 -0
- package/dist/mcp-server/tools/search/index.d.ts.map +1 -0
- package/dist/mcp-server/tools/search/nodes.d.ts +22 -0
- package/dist/mcp-server/tools/search/nodes.d.ts.map +1 -0
- package/dist/mcp-server/tools/search/tags.d.ts +22 -0
- package/dist/mcp-server/tools/search/tags.d.ts.map +1 -0
- package/dist/mcp-server/types/index.d.ts +286 -0
- package/dist/mcp-server/types/index.d.ts.map +1 -0
- package/dist/memory/index.d.ts +10 -0
- package/dist/memory/index.d.ts.map +1 -0
- package/dist/memory/vault-sync.d.ts +212 -0
- package/dist/memory/vault-sync.d.ts.map +1 -0
- package/dist/memory/vault-sync.js +463 -0
- package/dist/memory/vault-sync.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js +296 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js +71 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-json-schema-compat.js +26 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-json-schema-compat.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js +407 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js +1332 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/validation/ajv-provider.js +71 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/validation/ajv-provider.js.map +1 -0
- package/dist/node_modules/ajv/dist/ajv.js +84 -0
- package/dist/node_modules/ajv/dist/ajv.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/codegen/code.js +160 -0
- package/dist/node_modules/ajv/dist/compile/codegen/code.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/codegen/index.js +728 -0
- package/dist/node_modules/ajv/dist/compile/codegen/index.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/codegen/scope.js +152 -0
- package/dist/node_modules/ajv/dist/compile/codegen/scope.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/errors.js +131 -0
- package/dist/node_modules/ajv/dist/compile/errors.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/index.js +234 -0
- package/dist/node_modules/ajv/dist/compile/index.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/names.js +44 -0
- package/dist/node_modules/ajv/dist/compile/names.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/ref_error.js +22 -0
- package/dist/node_modules/ajv/dist/compile/ref_error.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/resolve.js +163 -0
- package/dist/node_modules/ajv/dist/compile/resolve.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/rules.js +35 -0
- package/dist/node_modules/ajv/dist/compile/rules.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/util.js +173 -0
- package/dist/node_modules/ajv/dist/compile/util.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/validate/applicability.js +27 -0
- package/dist/node_modules/ajv/dist/compile/validate/applicability.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/validate/boolSchema.js +58 -0
- package/dist/node_modules/ajv/dist/compile/validate/boolSchema.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/validate/dataType.js +193 -0
- package/dist/node_modules/ajv/dist/compile/validate/dataType.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/validate/defaults.js +43 -0
- package/dist/node_modules/ajv/dist/compile/validate/defaults.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/validate/index.js +522 -0
- package/dist/node_modules/ajv/dist/compile/validate/index.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/validate/keyword.js +126 -0
- package/dist/node_modules/ajv/dist/compile/validate/keyword.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/validate/subschema.js +89 -0
- package/dist/node_modules/ajv/dist/compile/validate/subschema.js.map +1 -0
- package/dist/node_modules/ajv/dist/core.js +628 -0
- package/dist/node_modules/ajv/dist/core.js.map +1 -0
- package/dist/node_modules/ajv/dist/refs/data.json.js +24 -0
- package/dist/node_modules/ajv/dist/refs/data.json.js.map +1 -0
- package/dist/node_modules/ajv/dist/refs/json-schema-draft-07.json.js +25 -0
- package/dist/node_modules/ajv/dist/refs/json-schema-draft-07.json.js.map +1 -0
- package/dist/node_modules/ajv/dist/runtime/equal.js +16 -0
- package/dist/node_modules/ajv/dist/runtime/equal.js.map +1 -0
- package/dist/node_modules/ajv/dist/runtime/ucs2length.js +30 -0
- package/dist/node_modules/ajv/dist/runtime/ucs2length.js.map +1 -0
- package/dist/node_modules/ajv/dist/runtime/uri.js +16 -0
- package/dist/node_modules/ajv/dist/runtime/uri.js.map +1 -0
- package/dist/node_modules/ajv/dist/runtime/validation_error.js +20 -0
- package/dist/node_modules/ajv/dist/runtime/validation_error.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js +59 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js +114 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/allOf.js +32 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/allOf.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/anyOf.js +22 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/anyOf.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/contains.js +100 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/contains.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/dependencies.js +103 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/dependencies.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/if.js +75 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/if.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/index.js +68 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/index.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/items.js +64 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/items.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/items2020.js +43 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/items2020.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/not.js +36 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/not.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/oneOf.js +64 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/oneOf.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js +81 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js +22 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/properties.js +66 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/properties.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js +49 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/thenElse.js +23 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/thenElse.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/code.js +140 -0
- package/dist/node_modules/ajv/dist/vocabularies/code.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/core/id.js +19 -0
- package/dist/node_modules/ajv/dist/vocabularies/core/id.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/core/index.js +27 -0
- package/dist/node_modules/ajv/dist/vocabularies/core/index.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/core/ref.js +132 -0
- package/dist/node_modules/ajv/dist/vocabularies/core/ref.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/discriminator/index.js +114 -0
- package/dist/node_modules/ajv/dist/vocabularies/discriminator/index.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/discriminator/types.js +18 -0
- package/dist/node_modules/ajv/dist/vocabularies/discriminator/types.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/draft7.js +31 -0
- package/dist/node_modules/ajv/dist/vocabularies/draft7.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/format/format.js +95 -0
- package/dist/node_modules/ajv/dist/vocabularies/format/format.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/format/index.js +16 -0
- package/dist/node_modules/ajv/dist/vocabularies/format/index.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/metadata.js +27 -0
- package/dist/node_modules/ajv/dist/vocabularies/metadata.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/const.js +36 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/const.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/enum.js +56 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/enum.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/index.js +52 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/index.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/limitItems.js +34 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/limitItems.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/limitLength.js +39 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/limitLength.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/limitNumber.js +37 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/limitNumber.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/limitProperties.js +34 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/limitProperties.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/multipleOf.js +33 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/multipleOf.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/pattern.js +34 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/pattern.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/required.js +89 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/required.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js +75 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js.map +1 -0
- package/dist/node_modules/ajv-formats/dist/formats.js +209 -0
- package/dist/node_modules/ajv-formats/dist/formats.js.map +1 -0
- package/dist/node_modules/ajv-formats/dist/index.js +51 -0
- package/dist/node_modules/ajv-formats/dist/index.js.map +1 -0
- package/dist/node_modules/ajv-formats/dist/limit.js +80 -0
- package/dist/node_modules/ajv-formats/dist/limit.js.map +1 -0
- package/dist/node_modules/fast-deep-equal/index.js +39 -0
- package/dist/node_modules/fast-deep-equal/index.js.map +1 -0
- package/dist/node_modules/fast-uri/index.js +261 -0
- package/dist/node_modules/fast-uri/index.js.map +1 -0
- package/dist/node_modules/fast-uri/lib/schemes.js +215 -0
- package/dist/node_modules/fast-uri/lib/schemes.js.map +1 -0
- package/dist/node_modules/fast-uri/lib/utils.js +261 -0
- package/dist/node_modules/fast-uri/lib/utils.js.map +1 -0
- package/dist/node_modules/json-schema-traverse/index.js +92 -0
- package/dist/node_modules/json-schema-traverse/index.js.map +1 -0
- package/dist/node_modules/zod/v4/classic/errors.js +37 -0
- package/dist/node_modules/zod/v4/classic/errors.js.map +1 -0
- package/dist/node_modules/zod/v4/classic/iso.js +43 -0
- package/dist/node_modules/zod/v4/classic/iso.js.map +1 -0
- package/dist/node_modules/zod/v4/classic/parse.js +13 -0
- package/dist/node_modules/zod/v4/classic/parse.js.map +1 -0
- package/dist/node_modules/zod/v4/classic/schemas.js +688 -0
- package/dist/node_modules/zod/v4/classic/schemas.js.map +1 -0
- package/dist/node_modules/zod/v4/core/api.js +492 -0
- package/dist/node_modules/zod/v4/core/api.js.map +1 -0
- package/dist/node_modules/zod/v4/core/checks.js +405 -0
- package/dist/node_modules/zod/v4/core/checks.js.map +1 -0
- package/dist/node_modules/zod/v4/core/core.js +58 -0
- package/dist/node_modules/zod/v4/core/core.js.map +1 -0
- package/dist/node_modules/zod/v4/core/doc.js +38 -0
- package/dist/node_modules/zod/v4/core/doc.js.map +1 -0
- package/dist/node_modules/zod/v4/core/errors.js +82 -0
- package/dist/node_modules/zod/v4/core/errors.js.map +1 -0
- package/dist/node_modules/zod/v4/core/parse.js +60 -0
- package/dist/node_modules/zod/v4/core/parse.js.map +1 -0
- package/dist/node_modules/zod/v4/core/regexes.js +87 -0
- package/dist/node_modules/zod/v4/core/regexes.js.map +1 -0
- package/dist/node_modules/zod/v4/core/registries.js +52 -0
- package/dist/node_modules/zod/v4/core/registries.js.map +1 -0
- package/dist/node_modules/zod/v4/core/schemas.js +1283 -0
- package/dist/node_modules/zod/v4/core/schemas.js.map +1 -0
- package/dist/node_modules/zod/v4/core/util.js +341 -0
- package/dist/node_modules/zod/v4/core/util.js.map +1 -0
- package/dist/node_modules/zod/v4/core/versions.js +9 -0
- package/dist/node_modules/zod/v4/core/versions.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/string.js +2 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/string.js.map +1 -0
- package/dist/reasoning/index.d.ts +74 -0
- package/dist/reasoning/index.d.ts.map +1 -0
- package/dist/reasoning/index.js +124 -0
- package/dist/reasoning/index.js.map +1 -0
- package/dist/reasoning/tracker.d.ts +210 -0
- package/dist/reasoning/tracker.d.ts.map +1 -0
- package/dist/reasoning/types.d.ts +146 -0
- package/dist/reasoning/types.d.ts.map +1 -0
- package/dist/recovery/backup.d.ts +110 -0
- package/dist/recovery/backup.d.ts.map +1 -0
- package/dist/recovery/index.d.ts +70 -0
- package/dist/recovery/index.d.ts.map +1 -0
- package/dist/recovery/index.js +186 -0
- package/dist/recovery/index.js.map +1 -0
- package/dist/recovery/integrity.d.ts +74 -0
- package/dist/recovery/integrity.d.ts.map +1 -0
- package/dist/recovery/types.d.ts +94 -0
- package/dist/recovery/types.d.ts.map +1 -0
- package/dist/services/index.d.ts +130 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +134 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/manager.d.ts +140 -0
- package/dist/services/manager.d.ts.map +1 -0
- package/dist/services/types.d.ts +106 -0
- package/dist/services/types.d.ts.map +1 -0
- package/dist/services/watchers.d.ts +95 -0
- package/dist/services/watchers.d.ts.map +1 -0
- package/dist/sops/compliance-checker.d.ts +83 -0
- package/dist/sops/compliance-checker.d.ts.map +1 -0
- package/dist/sops/compliance-checker.js +399 -0
- package/dist/sops/compliance-checker.js.map +1 -0
- package/dist/sops/gap-analyzer.d.ts +124 -0
- package/dist/sops/gap-analyzer.d.ts.map +1 -0
- package/dist/sops/gap-analyzer.js +313 -0
- package/dist/sops/gap-analyzer.js.map +1 -0
- package/dist/sops/index.d.ts +14 -0
- package/dist/sops/index.d.ts.map +1 -0
- package/dist/sops/overlay-manager.d.ts +115 -0
- package/dist/sops/overlay-manager.d.ts.map +1 -0
- package/dist/sops/overlay-manager.js +394 -0
- package/dist/sops/overlay-manager.js.map +1 -0
- package/dist/sops/registry.d.ts +73 -0
- package/dist/sops/registry.d.ts.map +1 -0
- package/dist/sops/registry.js +919 -0
- package/dist/sops/registry.js.map +1 -0
- package/dist/sops/types.d.ts +377 -0
- package/dist/sops/types.d.ts.map +1 -0
- package/dist/sops/types.js +46 -0
- package/dist/sops/types.js.map +1 -0
- package/dist/utils/error-recovery.d.ts +230 -0
- package/dist/utils/error-recovery.d.ts.map +1 -0
- package/dist/utils/error-recovery.js +228 -0
- package/dist/utils/error-recovery.js.map +1 -0
- package/dist/utils/error-taxonomy.d.ts +149 -0
- package/dist/utils/error-taxonomy.d.ts.map +1 -0
- package/dist/utils/error-taxonomy.js +260 -0
- package/dist/utils/error-taxonomy.js.map +1 -0
- package/dist/utils/index.d.ts +11 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/logger.d.ts +139 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +311 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/workflows/index.d.ts +11 -0
- package/dist/workflows/index.d.ts.map +1 -0
- package/dist/workflows/registry.d.ts +118 -0
- package/dist/workflows/registry.d.ts.map +1 -0
- package/dist/workflows/registry.js +575 -0
- package/dist/workflows/registry.js.map +1 -0
- package/dist/workflows/types.d.ts +322 -0
- package/dist/workflows/types.d.ts.map +1 -0
- package/dist/workflows/types.js +16 -0
- package/dist/workflows/types.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,685 @@
|
|
|
1
|
+
import * as fs from "fs/promises";
|
|
2
|
+
import * as path from "path";
|
|
3
|
+
import { BaseAgent } from "./base-agent.js";
|
|
4
|
+
import { AgentType } from "./types.js";
|
|
5
|
+
class ArchitectAgent extends BaseAgent {
|
|
6
|
+
/** File patterns to analyze */
|
|
7
|
+
codePatterns = [".ts", ".tsx", ".js", ".jsx", ".mts", ".mjs"];
|
|
8
|
+
/** Knowledge graph reference */
|
|
9
|
+
knowledgeGraph = null;
|
|
10
|
+
/** Layer definitions for common architectures */
|
|
11
|
+
layerDefinitions = {
|
|
12
|
+
presentation: ["components", "views", "pages", "ui"],
|
|
13
|
+
application: ["services", "usecases", "handlers", "controllers"],
|
|
14
|
+
domain: ["models", "entities", "domain", "core"],
|
|
15
|
+
infrastructure: ["repositories", "adapters", "database", "api"],
|
|
16
|
+
shared: ["utils", "helpers", "common", "shared", "lib"]
|
|
17
|
+
};
|
|
18
|
+
constructor(config) {
|
|
19
|
+
super({
|
|
20
|
+
type: AgentType.ARCHITECT,
|
|
21
|
+
taskTimeout: 3e5,
|
|
22
|
+
// 5 minutes for large projects
|
|
23
|
+
capabilities: ["architecture-analysis", "design", "dependency-analysis"],
|
|
24
|
+
...config
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
// ==========================================================================
|
|
28
|
+
// Knowledge Graph Integration
|
|
29
|
+
// ==========================================================================
|
|
30
|
+
/**
|
|
31
|
+
* Set knowledge graph for context-aware analysis
|
|
32
|
+
*/
|
|
33
|
+
setKnowledgeGraph(graph) {
|
|
34
|
+
this.knowledgeGraph = graph;
|
|
35
|
+
this.logger.debug("Knowledge graph attached", {
|
|
36
|
+
nodeCount: graph.getMetadata().nodeCount
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
// ==========================================================================
|
|
40
|
+
// Task Execution
|
|
41
|
+
// ==========================================================================
|
|
42
|
+
/**
|
|
43
|
+
* Execute architect task
|
|
44
|
+
*/
|
|
45
|
+
async executeTask(task) {
|
|
46
|
+
const startTime = /* @__PURE__ */ new Date();
|
|
47
|
+
const taskType = task.input?.parameters?.taskType || "analyze";
|
|
48
|
+
switch (taskType) {
|
|
49
|
+
case "analyze":
|
|
50
|
+
return this.handleAnalyzeTask(task, startTime);
|
|
51
|
+
case "design":
|
|
52
|
+
return this.handleDesignTask(task, startTime);
|
|
53
|
+
case "dependencies":
|
|
54
|
+
return this.handleDependenciesTask(task, startTime);
|
|
55
|
+
case "suggest":
|
|
56
|
+
return this.handleSuggestTask(task, startTime);
|
|
57
|
+
default:
|
|
58
|
+
return this.createErrorResult(
|
|
59
|
+
"INVALID_TASK_TYPE",
|
|
60
|
+
`Unknown task type: ${taskType}`,
|
|
61
|
+
startTime
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
// ==========================================================================
|
|
66
|
+
// Public Methods
|
|
67
|
+
// ==========================================================================
|
|
68
|
+
/**
|
|
69
|
+
* Analyze project architecture
|
|
70
|
+
*/
|
|
71
|
+
async analyzeArchitecture(projectRoot) {
|
|
72
|
+
this.logger.info("Analyzing architecture", { root: projectRoot });
|
|
73
|
+
const components = await this.discoverComponents(projectRoot);
|
|
74
|
+
const patterns = this.detectPatterns(components, projectRoot);
|
|
75
|
+
const layers = this.identifyLayers(components);
|
|
76
|
+
const dependencies = this.analyzeDependencies(components);
|
|
77
|
+
const decisions = this.generateDesignDecisions(components, layers, dependencies);
|
|
78
|
+
const healthScore = this.calculateHealthScore(components, layers, dependencies);
|
|
79
|
+
return {
|
|
80
|
+
projectName: path.basename(projectRoot),
|
|
81
|
+
patterns,
|
|
82
|
+
layers,
|
|
83
|
+
components,
|
|
84
|
+
dependencies,
|
|
85
|
+
decisions,
|
|
86
|
+
healthScore,
|
|
87
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Suggest design improvements
|
|
92
|
+
*/
|
|
93
|
+
async suggestDesign(projectRoot) {
|
|
94
|
+
this.logger.info("Generating design suggestions", { root: projectRoot });
|
|
95
|
+
const analysis = await this.analyzeArchitecture(projectRoot);
|
|
96
|
+
const suggestions = [];
|
|
97
|
+
for (const cycle of analysis.dependencies.cycles) {
|
|
98
|
+
suggestions.push({
|
|
99
|
+
type: "refactor",
|
|
100
|
+
target: cycle.join(" -> "),
|
|
101
|
+
description: "Break circular dependency",
|
|
102
|
+
priority: "high",
|
|
103
|
+
benefit: "Improves testability and maintainability",
|
|
104
|
+
effort: "medium"
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
for (const hub of analysis.dependencies.hubs) {
|
|
108
|
+
if (hub.connections > 10) {
|
|
109
|
+
suggestions.push({
|
|
110
|
+
type: "extract",
|
|
111
|
+
target: hub.module,
|
|
112
|
+
description: `Split ${hub.module} - too many connections (${hub.connections})`,
|
|
113
|
+
priority: hub.connections > 20 ? "high" : "medium",
|
|
114
|
+
benefit: "Reduces coupling and improves modularity",
|
|
115
|
+
effort: "high"
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
for (const layer of analysis.layers) {
|
|
120
|
+
if (layer.violations.length > 0) {
|
|
121
|
+
suggestions.push({
|
|
122
|
+
type: "refactor",
|
|
123
|
+
target: layer.name,
|
|
124
|
+
description: `Fix ${layer.violations.length} layer violation(s) in ${layer.name}`,
|
|
125
|
+
priority: "high",
|
|
126
|
+
benefit: "Enforces clean architecture boundaries",
|
|
127
|
+
effort: "medium"
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
for (const orphan of analysis.dependencies.orphans) {
|
|
132
|
+
suggestions.push({
|
|
133
|
+
type: "remove",
|
|
134
|
+
target: orphan,
|
|
135
|
+
description: `Consider removing unused module: ${orphan}`,
|
|
136
|
+
priority: "low",
|
|
137
|
+
benefit: "Reduces codebase size and maintenance burden",
|
|
138
|
+
effort: "low"
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
for (const component of analysis.components) {
|
|
142
|
+
if (component.complexity > 30) {
|
|
143
|
+
suggestions.push({
|
|
144
|
+
type: "extract",
|
|
145
|
+
target: component.name,
|
|
146
|
+
description: `Reduce complexity of ${component.name} (${component.complexity})`,
|
|
147
|
+
priority: component.complexity > 50 ? "high" : "medium",
|
|
148
|
+
benefit: "Improves readability and testability",
|
|
149
|
+
effort: "medium"
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return suggestions.sort((a, b) => {
|
|
154
|
+
const priorityOrder = { high: 0, medium: 1, low: 2 };
|
|
155
|
+
return priorityOrder[a.priority] - priorityOrder[b.priority];
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Map dependencies between modules
|
|
160
|
+
*/
|
|
161
|
+
async mapDependencies(projectRoot) {
|
|
162
|
+
this.logger.info("Mapping dependencies", { root: projectRoot });
|
|
163
|
+
const components = await this.discoverComponents(projectRoot);
|
|
164
|
+
return this.analyzeDependencies(components);
|
|
165
|
+
}
|
|
166
|
+
// ==========================================================================
|
|
167
|
+
// Private Task Handlers
|
|
168
|
+
// ==========================================================================
|
|
169
|
+
async handleAnalyzeTask(task, startTime) {
|
|
170
|
+
const input = task.input?.data;
|
|
171
|
+
if (!input?.projectRoot) {
|
|
172
|
+
return this.createErrorResult(
|
|
173
|
+
"VALIDATION_ERROR",
|
|
174
|
+
"Project root is required for architecture analysis",
|
|
175
|
+
startTime
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
try {
|
|
179
|
+
const analysis = await this.analyzeArchitecture(input.projectRoot);
|
|
180
|
+
const artifacts = [{
|
|
181
|
+
type: "report",
|
|
182
|
+
name: "architecture-analysis",
|
|
183
|
+
content: JSON.stringify(analysis, null, 2),
|
|
184
|
+
mimeType: "application/json"
|
|
185
|
+
}];
|
|
186
|
+
return this.createSuccessResult(analysis, startTime, artifacts);
|
|
187
|
+
} catch (error) {
|
|
188
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
189
|
+
return this.createErrorResult("ANALYSIS_ERROR", `Architecture analysis failed: ${message}`, startTime);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
async handleDesignTask(task, startTime) {
|
|
193
|
+
const input = task.input?.data;
|
|
194
|
+
if (!input?.projectRoot) {
|
|
195
|
+
return this.createErrorResult(
|
|
196
|
+
"VALIDATION_ERROR",
|
|
197
|
+
"Project root is required for design analysis",
|
|
198
|
+
startTime
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
try {
|
|
202
|
+
const analysis = await this.analyzeArchitecture(input.projectRoot);
|
|
203
|
+
return this.createSuccessResult(analysis.decisions, startTime);
|
|
204
|
+
} catch (error) {
|
|
205
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
206
|
+
return this.createErrorResult("DESIGN_ERROR", `Design analysis failed: ${message}`, startTime);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
async handleDependenciesTask(task, startTime) {
|
|
210
|
+
const input = task.input?.data;
|
|
211
|
+
if (!input?.projectRoot) {
|
|
212
|
+
return this.createErrorResult(
|
|
213
|
+
"VALIDATION_ERROR",
|
|
214
|
+
"Project root is required for dependency analysis",
|
|
215
|
+
startTime
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
try {
|
|
219
|
+
const analysis = await this.mapDependencies(input.projectRoot);
|
|
220
|
+
return this.createSuccessResult(analysis, startTime);
|
|
221
|
+
} catch (error) {
|
|
222
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
223
|
+
return this.createErrorResult("DEPENDENCY_ERROR", `Dependency analysis failed: ${message}`, startTime);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
async handleSuggestTask(task, startTime) {
|
|
227
|
+
const input = task.input?.data;
|
|
228
|
+
if (!input?.projectRoot) {
|
|
229
|
+
return this.createErrorResult(
|
|
230
|
+
"VALIDATION_ERROR",
|
|
231
|
+
"Project root is required for design suggestions",
|
|
232
|
+
startTime
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
try {
|
|
236
|
+
const suggestions = await this.suggestDesign(input.projectRoot);
|
|
237
|
+
return this.createSuccessResult(suggestions, startTime);
|
|
238
|
+
} catch (error) {
|
|
239
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
240
|
+
return this.createErrorResult("SUGGEST_ERROR", `Design suggestion failed: ${message}`, startTime);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
// ==========================================================================
|
|
244
|
+
// Component Discovery
|
|
245
|
+
// ==========================================================================
|
|
246
|
+
async discoverComponents(projectRoot) {
|
|
247
|
+
const components = [];
|
|
248
|
+
const files = await this.findFiles(projectRoot);
|
|
249
|
+
for (const file of files) {
|
|
250
|
+
try {
|
|
251
|
+
const content = await fs.readFile(file, "utf-8");
|
|
252
|
+
const relativePath = path.relative(projectRoot, file);
|
|
253
|
+
const component = this.analyzeComponent(content, relativePath);
|
|
254
|
+
components.push(component);
|
|
255
|
+
} catch (error) {
|
|
256
|
+
this.logger.warn(`Failed to analyze ${file}`, { error });
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
this.resolveDependencies(components);
|
|
260
|
+
return components;
|
|
261
|
+
}
|
|
262
|
+
analyzeComponent(content, filePath) {
|
|
263
|
+
const name = path.basename(filePath, path.extname(filePath));
|
|
264
|
+
const type = this.inferComponentType(filePath, content);
|
|
265
|
+
const dependencies = this.extractDependencies(content);
|
|
266
|
+
const exports$1 = this.extractExports(content);
|
|
267
|
+
const linesOfCode = content.split("\n").filter((l) => l.trim().length > 0).length;
|
|
268
|
+
const complexity = this.calculateComplexity(content);
|
|
269
|
+
return {
|
|
270
|
+
name,
|
|
271
|
+
type,
|
|
272
|
+
path: filePath,
|
|
273
|
+
dependencies,
|
|
274
|
+
dependents: [],
|
|
275
|
+
// Filled later
|
|
276
|
+
exports: exports$1,
|
|
277
|
+
linesOfCode,
|
|
278
|
+
complexity
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
inferComponentType(filePath, content) {
|
|
282
|
+
const lowerPath = filePath.toLowerCase();
|
|
283
|
+
const lowerContent = content.toLowerCase();
|
|
284
|
+
if (lowerPath.includes("service") || lowerPath.includes("services")) return "service";
|
|
285
|
+
if (lowerPath.includes("controller") || lowerPath.includes("controllers")) return "controller";
|
|
286
|
+
if (lowerPath.includes("repository") || lowerPath.includes("repositories")) return "repository";
|
|
287
|
+
if (lowerPath.includes("model") || lowerPath.includes("models")) return "model";
|
|
288
|
+
if (lowerPath.includes("view") || lowerPath.includes("component")) return "view";
|
|
289
|
+
if (lowerPath.includes("util") || lowerPath.includes("helper")) return "utility";
|
|
290
|
+
if (lowerPath.includes("middleware")) return "middleware";
|
|
291
|
+
if (lowerPath.includes("handler")) return "handler";
|
|
292
|
+
if (lowerPath.includes("factory")) return "factory";
|
|
293
|
+
if (lowerPath.includes("adapter")) return "adapter";
|
|
294
|
+
if (lowerContent.includes("class") && lowerContent.includes("service")) return "service";
|
|
295
|
+
if (lowerContent.includes("@controller") || lowerContent.includes("router")) return "controller";
|
|
296
|
+
if (lowerContent.includes("repository") || lowerContent.includes("findby")) return "repository";
|
|
297
|
+
if (lowerContent.includes("interface") && lowerContent.includes("model")) return "model";
|
|
298
|
+
return "utility";
|
|
299
|
+
}
|
|
300
|
+
resolveDependencies(components) {
|
|
301
|
+
const componentMap = new Map(components.map((c) => [c.path, c]));
|
|
302
|
+
const nameMap = new Map(components.map((c) => [c.name, c]));
|
|
303
|
+
for (const component of components) {
|
|
304
|
+
for (const dep of component.dependencies) {
|
|
305
|
+
const depPath = this.resolveDependencyPath(component.path, dep);
|
|
306
|
+
const depComponent = componentMap.get(depPath) || nameMap.get(dep);
|
|
307
|
+
if (depComponent && depComponent !== component) {
|
|
308
|
+
if (!depComponent.dependents.includes(component.name)) {
|
|
309
|
+
depComponent.dependents.push(component.name);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
resolveDependencyPath(fromPath, dep) {
|
|
316
|
+
if (dep.startsWith(".")) {
|
|
317
|
+
const dir = path.dirname(fromPath);
|
|
318
|
+
const resolved = path.normalize(path.join(dir, dep));
|
|
319
|
+
for (const ext of this.codePatterns) {
|
|
320
|
+
if (resolved.endsWith(ext)) return resolved;
|
|
321
|
+
}
|
|
322
|
+
return resolved + ".ts";
|
|
323
|
+
}
|
|
324
|
+
return dep;
|
|
325
|
+
}
|
|
326
|
+
// ==========================================================================
|
|
327
|
+
// Pattern Detection
|
|
328
|
+
// ==========================================================================
|
|
329
|
+
detectPatterns(components, projectRoot) {
|
|
330
|
+
const patterns = [];
|
|
331
|
+
const hasControllers = components.some((c) => c.type === "controller");
|
|
332
|
+
const hasModels = components.some((c) => c.type === "model");
|
|
333
|
+
const hasViews = components.some((c) => c.type === "view");
|
|
334
|
+
if (hasControllers && hasModels && hasViews) {
|
|
335
|
+
patterns.push("mvc");
|
|
336
|
+
}
|
|
337
|
+
const layers = this.identifyLayers(components);
|
|
338
|
+
if (layers.length >= 3) {
|
|
339
|
+
patterns.push("layered");
|
|
340
|
+
}
|
|
341
|
+
const hasAdapters = components.some((c) => c.type === "adapter");
|
|
342
|
+
const hasRepositories = components.some((c) => c.type === "repository");
|
|
343
|
+
if (hasAdapters && hasRepositories && layers.length >= 3) {
|
|
344
|
+
patterns.push("clean-architecture");
|
|
345
|
+
}
|
|
346
|
+
const directories = new Set(components.map((c) => path.dirname(c.path)));
|
|
347
|
+
if (directories.size > 5) {
|
|
348
|
+
patterns.push("modular");
|
|
349
|
+
}
|
|
350
|
+
const hasEvents = components.some(
|
|
351
|
+
(c) => c.exports.some((e) => e.toLowerCase().includes("event") || e.toLowerCase().includes("emit"))
|
|
352
|
+
);
|
|
353
|
+
if (hasEvents) {
|
|
354
|
+
patterns.push("event-driven");
|
|
355
|
+
}
|
|
356
|
+
return patterns.length > 0 ? patterns : ["monolith"];
|
|
357
|
+
}
|
|
358
|
+
// ==========================================================================
|
|
359
|
+
// Layer Analysis
|
|
360
|
+
// ==========================================================================
|
|
361
|
+
identifyLayers(components) {
|
|
362
|
+
const layers = [];
|
|
363
|
+
const layerComponents = {};
|
|
364
|
+
for (const component of components) {
|
|
365
|
+
const layer = this.inferLayer(component.path);
|
|
366
|
+
if (!layerComponents[layer]) {
|
|
367
|
+
layerComponents[layer] = [];
|
|
368
|
+
}
|
|
369
|
+
layerComponents[layer].push(component.name);
|
|
370
|
+
}
|
|
371
|
+
const layerOrder = ["presentation", "application", "domain", "infrastructure", "shared"];
|
|
372
|
+
for (let i = 0; i < layerOrder.length; i++) {
|
|
373
|
+
const layerName = layerOrder[i];
|
|
374
|
+
if (layerComponents[layerName] && layerComponents[layerName].length > 0) {
|
|
375
|
+
const allowedDeps = layerOrder.slice(i + 1);
|
|
376
|
+
const actualDeps = this.findLayerDependencies(
|
|
377
|
+
components,
|
|
378
|
+
layerComponents[layerName],
|
|
379
|
+
layerComponents
|
|
380
|
+
);
|
|
381
|
+
const violations = actualDeps.filter(
|
|
382
|
+
(d) => !allowedDeps.includes(d) && d !== layerName
|
|
383
|
+
);
|
|
384
|
+
layers.push({
|
|
385
|
+
name: layerName,
|
|
386
|
+
level: i,
|
|
387
|
+
components: layerComponents[layerName],
|
|
388
|
+
allowedDependencies: allowedDeps,
|
|
389
|
+
actualDependencies: actualDeps,
|
|
390
|
+
violations
|
|
391
|
+
});
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
return layers;
|
|
395
|
+
}
|
|
396
|
+
inferLayer(filePath) {
|
|
397
|
+
const lowerPath = filePath.toLowerCase();
|
|
398
|
+
for (const [layer, patterns] of Object.entries(this.layerDefinitions)) {
|
|
399
|
+
for (const pattern of patterns) {
|
|
400
|
+
if (lowerPath.includes(pattern)) {
|
|
401
|
+
return layer;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
return "shared";
|
|
406
|
+
}
|
|
407
|
+
findLayerDependencies(components, layerComponentNames, allLayerComponents) {
|
|
408
|
+
const dependencies = /* @__PURE__ */ new Set();
|
|
409
|
+
for (const componentName of layerComponentNames) {
|
|
410
|
+
const component = components.find((c) => c.name === componentName);
|
|
411
|
+
if (!component) continue;
|
|
412
|
+
for (const dep of component.dependencies) {
|
|
413
|
+
for (const [layer, componentNames] of Object.entries(allLayerComponents)) {
|
|
414
|
+
if (componentNames.includes(dep)) {
|
|
415
|
+
dependencies.add(layer);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
return [...dependencies];
|
|
421
|
+
}
|
|
422
|
+
// ==========================================================================
|
|
423
|
+
// Dependency Analysis
|
|
424
|
+
// ==========================================================================
|
|
425
|
+
analyzeDependencies(components) {
|
|
426
|
+
const graph = this.buildDependencyGraph(components);
|
|
427
|
+
const cycles = this.findCycles(components);
|
|
428
|
+
const orphans = this.findOrphans(components);
|
|
429
|
+
const hubs = this.findHubs(components);
|
|
430
|
+
const recommendations = this.generateDependencyRecommendations(cycles, orphans, hubs);
|
|
431
|
+
return {
|
|
432
|
+
graph,
|
|
433
|
+
cycles,
|
|
434
|
+
orphans,
|
|
435
|
+
hubs,
|
|
436
|
+
recommendations
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
buildDependencyGraph(components) {
|
|
440
|
+
return components.map((c) => {
|
|
441
|
+
const fanIn = c.dependents.length;
|
|
442
|
+
const fanOut = c.dependencies.length;
|
|
443
|
+
const instability = fanOut / (fanIn + fanOut) || 0;
|
|
444
|
+
return {
|
|
445
|
+
id: c.name,
|
|
446
|
+
label: c.name,
|
|
447
|
+
type: c.type,
|
|
448
|
+
outgoing: c.dependencies,
|
|
449
|
+
incoming: c.dependents,
|
|
450
|
+
metrics: {
|
|
451
|
+
fanIn,
|
|
452
|
+
fanOut,
|
|
453
|
+
instability: Math.round(instability * 100) / 100,
|
|
454
|
+
abstractness: 0
|
|
455
|
+
// Would require interface detection
|
|
456
|
+
}
|
|
457
|
+
};
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
findCycles(components) {
|
|
461
|
+
const cycles = [];
|
|
462
|
+
const visited = /* @__PURE__ */ new Set();
|
|
463
|
+
const recursionStack = /* @__PURE__ */ new Set();
|
|
464
|
+
const path2 = [];
|
|
465
|
+
const dfs = (componentName) => {
|
|
466
|
+
visited.add(componentName);
|
|
467
|
+
recursionStack.add(componentName);
|
|
468
|
+
path2.push(componentName);
|
|
469
|
+
const component = components.find((c) => c.name === componentName);
|
|
470
|
+
if (component) {
|
|
471
|
+
for (const dep of component.dependencies) {
|
|
472
|
+
const depComponent = components.find((c) => c.name === dep);
|
|
473
|
+
if (!depComponent) continue;
|
|
474
|
+
if (!visited.has(dep)) {
|
|
475
|
+
dfs(dep);
|
|
476
|
+
} else if (recursionStack.has(dep)) {
|
|
477
|
+
const cycleStart = path2.indexOf(dep);
|
|
478
|
+
if (cycleStart !== -1) {
|
|
479
|
+
cycles.push([...path2.slice(cycleStart), dep]);
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
path2.pop();
|
|
485
|
+
recursionStack.delete(componentName);
|
|
486
|
+
};
|
|
487
|
+
for (const component of components) {
|
|
488
|
+
if (!visited.has(component.name)) {
|
|
489
|
+
dfs(component.name);
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
return cycles;
|
|
493
|
+
}
|
|
494
|
+
findOrphans(components) {
|
|
495
|
+
return components.filter((c) => c.dependencies.length === 0 && c.dependents.length === 0).map((c) => c.name);
|
|
496
|
+
}
|
|
497
|
+
findHubs(components) {
|
|
498
|
+
return components.map((c) => ({
|
|
499
|
+
module: c.name,
|
|
500
|
+
connections: c.dependencies.length + c.dependents.length
|
|
501
|
+
})).filter((h) => h.connections > 5).sort((a, b) => b.connections - a.connections);
|
|
502
|
+
}
|
|
503
|
+
generateDependencyRecommendations(cycles, orphans, hubs) {
|
|
504
|
+
const recommendations = [];
|
|
505
|
+
if (cycles.length > 0) {
|
|
506
|
+
recommendations.push(
|
|
507
|
+
`Found ${cycles.length} circular dependency(s) - consider using dependency inversion`
|
|
508
|
+
);
|
|
509
|
+
}
|
|
510
|
+
if (orphans.length > 0) {
|
|
511
|
+
recommendations.push(
|
|
512
|
+
`${orphans.length} orphan module(s) detected - consider removing or integrating`
|
|
513
|
+
);
|
|
514
|
+
}
|
|
515
|
+
const majorHubs = hubs.filter((h) => h.connections > 10);
|
|
516
|
+
if (majorHubs.length > 0) {
|
|
517
|
+
recommendations.push(
|
|
518
|
+
`${majorHubs.length} highly-connected module(s) - consider splitting into smaller modules`
|
|
519
|
+
);
|
|
520
|
+
}
|
|
521
|
+
if (recommendations.length === 0) {
|
|
522
|
+
recommendations.push("Dependency structure looks healthy");
|
|
523
|
+
}
|
|
524
|
+
return recommendations;
|
|
525
|
+
}
|
|
526
|
+
// ==========================================================================
|
|
527
|
+
// Design Decisions
|
|
528
|
+
// ==========================================================================
|
|
529
|
+
generateDesignDecisions(components, layers, dependencies) {
|
|
530
|
+
const decisions = [];
|
|
531
|
+
const violatingLayers = layers.filter((l) => l.violations.length > 0);
|
|
532
|
+
if (violatingLayers.length > 0) {
|
|
533
|
+
decisions.push({
|
|
534
|
+
title: "Enforce Layer Boundaries",
|
|
535
|
+
category: "structure",
|
|
536
|
+
description: "Some layers have dependencies that violate the intended architecture",
|
|
537
|
+
rationale: "Clean separation of concerns improves maintainability and testability",
|
|
538
|
+
pros: ["Better modularity", "Easier testing", "Clearer responsibilities"],
|
|
539
|
+
cons: ["Initial refactoring effort", "May require interface introduction"],
|
|
540
|
+
priority: "high"
|
|
541
|
+
});
|
|
542
|
+
}
|
|
543
|
+
if (dependencies.cycles.length > 0) {
|
|
544
|
+
decisions.push({
|
|
545
|
+
title: "Break Circular Dependencies",
|
|
546
|
+
category: "structure",
|
|
547
|
+
description: `Found ${dependencies.cycles.length} circular dependency chain(s)`,
|
|
548
|
+
rationale: "Circular dependencies make code harder to understand and test",
|
|
549
|
+
pros: ["Improved testability", "Clearer module boundaries", "Easier refactoring"],
|
|
550
|
+
cons: ["May require interface extraction", "Some restructuring needed"],
|
|
551
|
+
alternatives: ["Dependency injection", "Event-driven communication"],
|
|
552
|
+
priority: "high"
|
|
553
|
+
});
|
|
554
|
+
}
|
|
555
|
+
const complexComponents = components.filter((c) => c.complexity > 30);
|
|
556
|
+
if (complexComponents.length > 0) {
|
|
557
|
+
decisions.push({
|
|
558
|
+
title: "Reduce Component Complexity",
|
|
559
|
+
category: "pattern",
|
|
560
|
+
description: `${complexComponents.length} component(s) have high complexity`,
|
|
561
|
+
rationale: "Lower complexity improves readability and reduces bug risk",
|
|
562
|
+
pros: ["Better maintainability", "Easier testing", "Reduced cognitive load"],
|
|
563
|
+
cons: ["May increase number of files", "Refactoring effort"],
|
|
564
|
+
alternatives: ["Extract methods", "Apply design patterns", "Split responsibilities"],
|
|
565
|
+
priority: "medium"
|
|
566
|
+
});
|
|
567
|
+
}
|
|
568
|
+
const services = components.filter((c) => c.type === "service");
|
|
569
|
+
if (services.length === 0 && components.length > 10) {
|
|
570
|
+
decisions.push({
|
|
571
|
+
title: "Introduce Service Layer",
|
|
572
|
+
category: "pattern",
|
|
573
|
+
description: "Consider introducing a service layer for business logic",
|
|
574
|
+
rationale: "Service layer provides clean separation between UI and business logic",
|
|
575
|
+
pros: ["Reusable business logic", "Better testability", "Cleaner controllers"],
|
|
576
|
+
cons: ["Additional abstraction layer", "More files to manage"],
|
|
577
|
+
priority: "medium"
|
|
578
|
+
});
|
|
579
|
+
}
|
|
580
|
+
return decisions;
|
|
581
|
+
}
|
|
582
|
+
// ==========================================================================
|
|
583
|
+
// Health Score
|
|
584
|
+
// ==========================================================================
|
|
585
|
+
calculateHealthScore(components, layers, dependencies) {
|
|
586
|
+
let score = 100;
|
|
587
|
+
score -= dependencies.cycles.length * 10;
|
|
588
|
+
const totalViolations = layers.reduce((sum, l) => sum + l.violations.length, 0);
|
|
589
|
+
score -= totalViolations * 5;
|
|
590
|
+
const complexComponents = components.filter((c) => c.complexity > 30);
|
|
591
|
+
score -= complexComponents.length * 3;
|
|
592
|
+
if (dependencies.orphans.length > 5) {
|
|
593
|
+
score -= (dependencies.orphans.length - 5) * 2;
|
|
594
|
+
}
|
|
595
|
+
const majorHubs = dependencies.hubs.filter((h) => h.connections > 15);
|
|
596
|
+
score -= majorHubs.length * 5;
|
|
597
|
+
return Math.max(0, Math.min(100, Math.round(score)));
|
|
598
|
+
}
|
|
599
|
+
// ==========================================================================
|
|
600
|
+
// Helper Methods
|
|
601
|
+
// ==========================================================================
|
|
602
|
+
extractDependencies(content) {
|
|
603
|
+
const dependencies = [];
|
|
604
|
+
const importRegex = /import\s+(?:.*?\s+from\s+)?['"]([^'"]+)['"]/g;
|
|
605
|
+
let match;
|
|
606
|
+
while ((match = importRegex.exec(content)) !== null) {
|
|
607
|
+
const dep = match[1];
|
|
608
|
+
if (dep.startsWith(".")) {
|
|
609
|
+
const name = path.basename(dep, path.extname(dep));
|
|
610
|
+
dependencies.push(name);
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
const requireRegex = /require\s*\(['"]([^'"]+)['"]\)/g;
|
|
614
|
+
while ((match = requireRegex.exec(content)) !== null) {
|
|
615
|
+
const dep = match[1];
|
|
616
|
+
if (dep.startsWith(".")) {
|
|
617
|
+
const name = path.basename(dep, path.extname(dep));
|
|
618
|
+
dependencies.push(name);
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
return [...new Set(dependencies)];
|
|
622
|
+
}
|
|
623
|
+
extractExports(content) {
|
|
624
|
+
const exports$1 = [];
|
|
625
|
+
const namedExportRegex = /export\s+(?:const|let|var|function|class)\s+(\w+)/g;
|
|
626
|
+
let match;
|
|
627
|
+
while ((match = namedExportRegex.exec(content)) !== null) {
|
|
628
|
+
exports$1.push(match[1]);
|
|
629
|
+
}
|
|
630
|
+
const exportDeclRegex = /export\s*\{([^}]+)\}/g;
|
|
631
|
+
while ((match = exportDeclRegex.exec(content)) !== null) {
|
|
632
|
+
const names = match[1].split(",").map((n) => n.trim().split(/\s+as\s+/)[0]);
|
|
633
|
+
exports$1.push(...names);
|
|
634
|
+
}
|
|
635
|
+
return [...new Set(exports$1.filter((e) => e))];
|
|
636
|
+
}
|
|
637
|
+
calculateComplexity(content) {
|
|
638
|
+
let complexity = 1;
|
|
639
|
+
const patterns = [
|
|
640
|
+
/\bif\s*\(/g,
|
|
641
|
+
/\belse\s+if\s*\(/g,
|
|
642
|
+
/\bfor\s*\(/g,
|
|
643
|
+
/\bwhile\s*\(/g,
|
|
644
|
+
/\bcase\s+/g,
|
|
645
|
+
/\bcatch\s*\(/g,
|
|
646
|
+
/\?\s*[^:]+\s*:/g,
|
|
647
|
+
/&&/g,
|
|
648
|
+
/\|\|/g
|
|
649
|
+
];
|
|
650
|
+
for (const pattern of patterns) {
|
|
651
|
+
const matches = content.match(pattern);
|
|
652
|
+
if (matches) {
|
|
653
|
+
complexity += matches.length;
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
return complexity;
|
|
657
|
+
}
|
|
658
|
+
async findFiles(dir) {
|
|
659
|
+
const files = [];
|
|
660
|
+
try {
|
|
661
|
+
const entries = await fs.readdir(dir, { withFileTypes: true });
|
|
662
|
+
for (const entry of entries) {
|
|
663
|
+
const fullPath = path.join(dir, entry.name);
|
|
664
|
+
if (entry.name === "node_modules" || entry.name === ".git" || entry.name === "dist" || entry.name === "build" || entry.name.startsWith(".")) {
|
|
665
|
+
continue;
|
|
666
|
+
}
|
|
667
|
+
if (entry.isDirectory()) {
|
|
668
|
+
const subFiles = await this.findFiles(fullPath);
|
|
669
|
+
files.push(...subFiles);
|
|
670
|
+
} else if (entry.isFile()) {
|
|
671
|
+
const ext = path.extname(entry.name);
|
|
672
|
+
if (this.codePatterns.includes(ext)) {
|
|
673
|
+
files.push(fullPath);
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
} catch {
|
|
678
|
+
}
|
|
679
|
+
return files;
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
export {
|
|
683
|
+
ArchitectAgent
|
|
684
|
+
};
|
|
685
|
+
//# sourceMappingURL=architect-agent.js.map
|