@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,212 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vault Memory Sync
|
|
3
|
+
*
|
|
4
|
+
* Provides bidirectional synchronization between the knowledge graph
|
|
5
|
+
* and claude-flow memory system for persistent agent coordination.
|
|
6
|
+
*
|
|
7
|
+
* @module memory/vault-sync
|
|
8
|
+
*/
|
|
9
|
+
import { type RetryOptions } from '../utils/index.js';
|
|
10
|
+
import { type FileChange } from '../core/cache.js';
|
|
11
|
+
import { KnowledgeGraphDatabase } from '../core/database.js';
|
|
12
|
+
/**
|
|
13
|
+
* Sync direction
|
|
14
|
+
*/
|
|
15
|
+
export type SyncDirection = 'to-memory' | 'from-memory' | 'bidirectional';
|
|
16
|
+
/**
|
|
17
|
+
* Conflict resolution strategy
|
|
18
|
+
*/
|
|
19
|
+
export type ConflictStrategy = 'memory-wins' | 'vault-wins' | 'newest-wins' | 'merge' | 'manual';
|
|
20
|
+
/**
|
|
21
|
+
* Sync status
|
|
22
|
+
*/
|
|
23
|
+
export interface SyncStatus {
|
|
24
|
+
/** Last successful sync timestamp */
|
|
25
|
+
lastSync: Date | null;
|
|
26
|
+
/** Whether sync is currently running */
|
|
27
|
+
isSyncing: boolean;
|
|
28
|
+
/** Number of pending changes in vault */
|
|
29
|
+
pendingVaultChanges: number;
|
|
30
|
+
/** Number of pending changes in memory */
|
|
31
|
+
pendingMemoryChanges: number;
|
|
32
|
+
/** Any sync errors */
|
|
33
|
+
errors: string[];
|
|
34
|
+
/** Sync health status */
|
|
35
|
+
health: 'healthy' | 'warning' | 'error';
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Memory entry format for claude-flow
|
|
39
|
+
*/
|
|
40
|
+
export interface MemoryNode {
|
|
41
|
+
id: string;
|
|
42
|
+
title: string;
|
|
43
|
+
type: string;
|
|
44
|
+
status: string;
|
|
45
|
+
path: string;
|
|
46
|
+
tags: string[];
|
|
47
|
+
outgoingLinks: string[];
|
|
48
|
+
incomingLinks: string[];
|
|
49
|
+
summary: string;
|
|
50
|
+
contentHash: string;
|
|
51
|
+
lastModified: string;
|
|
52
|
+
syncedAt: string;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Conflict record
|
|
56
|
+
*/
|
|
57
|
+
export interface SyncConflict {
|
|
58
|
+
nodeId: string;
|
|
59
|
+
path: string;
|
|
60
|
+
vaultVersion: {
|
|
61
|
+
hash: string;
|
|
62
|
+
modifiedAt: Date;
|
|
63
|
+
content?: string;
|
|
64
|
+
};
|
|
65
|
+
memoryVersion: {
|
|
66
|
+
hash: string;
|
|
67
|
+
modifiedAt: Date;
|
|
68
|
+
content?: string;
|
|
69
|
+
};
|
|
70
|
+
resolvedAs?: 'vault' | 'memory' | 'merged';
|
|
71
|
+
resolvedAt?: Date;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Sync options
|
|
75
|
+
*/
|
|
76
|
+
export interface VaultSyncOptions {
|
|
77
|
+
/** Project root directory */
|
|
78
|
+
projectRoot: string;
|
|
79
|
+
/** Claude-flow memory namespace */
|
|
80
|
+
namespace?: string;
|
|
81
|
+
/** Conflict resolution strategy */
|
|
82
|
+
conflictStrategy?: ConflictStrategy;
|
|
83
|
+
/** Whether to auto-sync on changes */
|
|
84
|
+
autoSync?: boolean;
|
|
85
|
+
/** Auto-sync interval in milliseconds */
|
|
86
|
+
autoSyncInterval?: number;
|
|
87
|
+
/** Retry options for network operations */
|
|
88
|
+
retryOptions?: RetryOptions;
|
|
89
|
+
/** Maximum batch size for sync operations */
|
|
90
|
+
batchSize?: number;
|
|
91
|
+
/** Whether to include content in memory entries */
|
|
92
|
+
includeContent?: boolean;
|
|
93
|
+
/** Maximum content length to store */
|
|
94
|
+
maxContentLength?: number;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Sync result for a single operation
|
|
98
|
+
*/
|
|
99
|
+
export interface SyncOperationResult {
|
|
100
|
+
success: boolean;
|
|
101
|
+
synced: number;
|
|
102
|
+
skipped: number;
|
|
103
|
+
failed: number;
|
|
104
|
+
conflicts: SyncConflict[];
|
|
105
|
+
errors: Array<{
|
|
106
|
+
nodeId: string;
|
|
107
|
+
error: string;
|
|
108
|
+
}>;
|
|
109
|
+
duration: number;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Full sync result
|
|
113
|
+
*/
|
|
114
|
+
export interface FullSyncResult {
|
|
115
|
+
success: boolean;
|
|
116
|
+
toMemory: SyncOperationResult;
|
|
117
|
+
fromMemory: SyncOperationResult;
|
|
118
|
+
totalDuration: number;
|
|
119
|
+
timestamp: Date;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Vault Memory Sync
|
|
123
|
+
*
|
|
124
|
+
* Manages bidirectional synchronization between the knowledge graph vault
|
|
125
|
+
* and claude-flow memory for cross-session persistence and agent coordination.
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* ```typescript
|
|
129
|
+
* const sync = new VaultMemorySync({
|
|
130
|
+
* projectRoot: '/my/project',
|
|
131
|
+
* namespace: 'knowledge-graph',
|
|
132
|
+
* conflictStrategy: 'newest-wins',
|
|
133
|
+
* });
|
|
134
|
+
*
|
|
135
|
+
* // Initialize with database
|
|
136
|
+
* await sync.initialize(db);
|
|
137
|
+
*
|
|
138
|
+
* // Sync to memory
|
|
139
|
+
* const result = await sync.syncToMemory();
|
|
140
|
+
*
|
|
141
|
+
* // Check status
|
|
142
|
+
* const status = sync.getStatus();
|
|
143
|
+
* ```
|
|
144
|
+
*/
|
|
145
|
+
export declare class VaultMemorySync {
|
|
146
|
+
private options;
|
|
147
|
+
private shadowCache;
|
|
148
|
+
private db;
|
|
149
|
+
private memoryCache;
|
|
150
|
+
private conflicts;
|
|
151
|
+
private lastSyncTime;
|
|
152
|
+
private isSyncing;
|
|
153
|
+
private syncErrors;
|
|
154
|
+
private autoSyncTimer;
|
|
155
|
+
constructor(options: VaultSyncOptions);
|
|
156
|
+
/**
|
|
157
|
+
* Initialize the sync system with database
|
|
158
|
+
*/
|
|
159
|
+
initialize(db: KnowledgeGraphDatabase): Promise<void>;
|
|
160
|
+
/**
|
|
161
|
+
* Sync knowledge graph to claude-flow memory
|
|
162
|
+
*/
|
|
163
|
+
syncToMemory(): Promise<SyncOperationResult>;
|
|
164
|
+
/**
|
|
165
|
+
* Sync from claude-flow memory to knowledge graph
|
|
166
|
+
*/
|
|
167
|
+
syncFromMemory(): Promise<SyncOperationResult>;
|
|
168
|
+
/**
|
|
169
|
+
* Perform full bidirectional sync
|
|
170
|
+
*/
|
|
171
|
+
fullSync(): Promise<FullSyncResult>;
|
|
172
|
+
/**
|
|
173
|
+
* Get current sync status
|
|
174
|
+
*/
|
|
175
|
+
getStatus(): SyncStatus;
|
|
176
|
+
/**
|
|
177
|
+
* Get unresolved conflicts
|
|
178
|
+
*/
|
|
179
|
+
getConflicts(): SyncConflict[];
|
|
180
|
+
/**
|
|
181
|
+
* Manually resolve a conflict
|
|
182
|
+
*/
|
|
183
|
+
resolveConflictManually(nodeId: string, resolution: 'vault' | 'memory'): Promise<boolean>;
|
|
184
|
+
/**
|
|
185
|
+
* Detect changes in vault since last sync
|
|
186
|
+
*/
|
|
187
|
+
detectChanges(): Promise<FileChange[]>;
|
|
188
|
+
/**
|
|
189
|
+
* Stop the sync system
|
|
190
|
+
*/
|
|
191
|
+
stop(): void;
|
|
192
|
+
private startAutoSync;
|
|
193
|
+
private nodeToMemoryEntry;
|
|
194
|
+
private extractSummary;
|
|
195
|
+
private computeContentHash;
|
|
196
|
+
private storeToMemory;
|
|
197
|
+
private retrieveFromMemory;
|
|
198
|
+
private syncIndexesToMemory;
|
|
199
|
+
private detectConflict;
|
|
200
|
+
private createConflictRecord;
|
|
201
|
+
private resolveConflict;
|
|
202
|
+
private countPendingVaultChanges;
|
|
203
|
+
private countPendingMemoryChanges;
|
|
204
|
+
private createBatches;
|
|
205
|
+
private loadMemoryCache;
|
|
206
|
+
private saveMemoryCache;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Create a vault memory sync instance
|
|
210
|
+
*/
|
|
211
|
+
export declare function createVaultMemorySync(options: VaultSyncOptions): VaultMemorySync;
|
|
212
|
+
//# sourceMappingURL=vault-sync.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vault-sync.d.ts","sourceRoot":"","sources":["../../src/memory/vault-sync.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,463 @@
|
|
|
1
|
+
import { createHash } from "crypto";
|
|
2
|
+
import { createLogger } from "../utils/logger.js";
|
|
3
|
+
import { ShadowCache } from "../core/cache.js";
|
|
4
|
+
const logger = createLogger("vault-sync");
|
|
5
|
+
class VaultMemorySync {
|
|
6
|
+
options;
|
|
7
|
+
shadowCache;
|
|
8
|
+
db = null;
|
|
9
|
+
memoryCache = /* @__PURE__ */ new Map();
|
|
10
|
+
conflicts = [];
|
|
11
|
+
lastSyncTime = null;
|
|
12
|
+
isSyncing = false;
|
|
13
|
+
syncErrors = [];
|
|
14
|
+
autoSyncTimer = null;
|
|
15
|
+
constructor(options) {
|
|
16
|
+
this.options = {
|
|
17
|
+
projectRoot: options.projectRoot,
|
|
18
|
+
namespace: options.namespace ?? "knowledge-graph",
|
|
19
|
+
conflictStrategy: options.conflictStrategy ?? "newest-wins",
|
|
20
|
+
autoSync: options.autoSync ?? false,
|
|
21
|
+
autoSyncInterval: options.autoSyncInterval ?? 3e5,
|
|
22
|
+
// 5 minutes
|
|
23
|
+
retryOptions: options.retryOptions ?? { maxRetries: 3, initialDelay: 1e3 },
|
|
24
|
+
batchSize: options.batchSize ?? 50,
|
|
25
|
+
includeContent: options.includeContent ?? false,
|
|
26
|
+
maxContentLength: options.maxContentLength ?? 5e3
|
|
27
|
+
};
|
|
28
|
+
this.shadowCache = new ShadowCache({
|
|
29
|
+
projectRoot: options.projectRoot,
|
|
30
|
+
cacheDir: ".kg/sync-cache"
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Initialize the sync system with database
|
|
35
|
+
*/
|
|
36
|
+
async initialize(db) {
|
|
37
|
+
this.db = db;
|
|
38
|
+
await this.shadowCache.load();
|
|
39
|
+
await this.loadMemoryCache();
|
|
40
|
+
if (this.options.autoSync) {
|
|
41
|
+
this.startAutoSync();
|
|
42
|
+
}
|
|
43
|
+
logger.info("Vault sync initialized", {
|
|
44
|
+
namespace: this.options.namespace,
|
|
45
|
+
autoSync: this.options.autoSync
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Sync knowledge graph to claude-flow memory
|
|
50
|
+
*/
|
|
51
|
+
async syncToMemory() {
|
|
52
|
+
if (!this.db) {
|
|
53
|
+
throw new Error("Database not initialized. Call initialize() first.");
|
|
54
|
+
}
|
|
55
|
+
const startTime = Date.now();
|
|
56
|
+
const result = {
|
|
57
|
+
success: true,
|
|
58
|
+
synced: 0,
|
|
59
|
+
skipped: 0,
|
|
60
|
+
failed: 0,
|
|
61
|
+
conflicts: [],
|
|
62
|
+
errors: [],
|
|
63
|
+
duration: 0
|
|
64
|
+
};
|
|
65
|
+
this.isSyncing = true;
|
|
66
|
+
this.syncErrors = [];
|
|
67
|
+
try {
|
|
68
|
+
const nodes = this.db.getAllNodes();
|
|
69
|
+
const batches = this.createBatches(nodes, this.options.batchSize);
|
|
70
|
+
for (const batch of batches) {
|
|
71
|
+
for (const node of batch) {
|
|
72
|
+
try {
|
|
73
|
+
const memoryNode = this.nodeToMemoryEntry(node);
|
|
74
|
+
const cached = this.memoryCache.get(node.id);
|
|
75
|
+
if (cached && cached.contentHash !== memoryNode.contentHash) {
|
|
76
|
+
const conflict = await this.detectConflict(node, cached);
|
|
77
|
+
if (conflict) {
|
|
78
|
+
result.conflicts.push(conflict);
|
|
79
|
+
const resolved = await this.resolveConflict(conflict);
|
|
80
|
+
if (!resolved) {
|
|
81
|
+
result.skipped++;
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
await this.storeToMemory(memoryNode);
|
|
87
|
+
this.memoryCache.set(node.id, memoryNode);
|
|
88
|
+
result.synced++;
|
|
89
|
+
} catch (error) {
|
|
90
|
+
result.failed++;
|
|
91
|
+
result.errors.push({
|
|
92
|
+
nodeId: node.id,
|
|
93
|
+
error: String(error)
|
|
94
|
+
});
|
|
95
|
+
this.syncErrors.push(`Failed to sync ${node.id}: ${error}`);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
await this.syncIndexesToMemory(nodes);
|
|
100
|
+
result.duration = Date.now() - startTime;
|
|
101
|
+
result.success = result.failed === 0;
|
|
102
|
+
this.lastSyncTime = /* @__PURE__ */ new Date();
|
|
103
|
+
logger.info("Sync to memory completed", {
|
|
104
|
+
synced: result.synced,
|
|
105
|
+
failed: result.failed,
|
|
106
|
+
duration: result.duration
|
|
107
|
+
});
|
|
108
|
+
} finally {
|
|
109
|
+
this.isSyncing = false;
|
|
110
|
+
await this.saveMemoryCache();
|
|
111
|
+
}
|
|
112
|
+
return result;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Sync from claude-flow memory to knowledge graph
|
|
116
|
+
*/
|
|
117
|
+
async syncFromMemory() {
|
|
118
|
+
if (!this.db) {
|
|
119
|
+
throw new Error("Database not initialized. Call initialize() first.");
|
|
120
|
+
}
|
|
121
|
+
const startTime = Date.now();
|
|
122
|
+
const result = {
|
|
123
|
+
success: true,
|
|
124
|
+
synced: 0,
|
|
125
|
+
skipped: 0,
|
|
126
|
+
failed: 0,
|
|
127
|
+
conflicts: [],
|
|
128
|
+
errors: [],
|
|
129
|
+
duration: 0
|
|
130
|
+
};
|
|
131
|
+
this.isSyncing = true;
|
|
132
|
+
this.syncErrors = [];
|
|
133
|
+
try {
|
|
134
|
+
const memoryNodes = await this.retrieveFromMemory();
|
|
135
|
+
for (const memoryNode of memoryNodes) {
|
|
136
|
+
try {
|
|
137
|
+
const existingNode = this.db.getNode(memoryNode.id);
|
|
138
|
+
if (existingNode) {
|
|
139
|
+
const currentHash = this.computeContentHash(existingNode.content);
|
|
140
|
+
if (currentHash !== memoryNode.contentHash) {
|
|
141
|
+
const conflict = this.createConflictRecord(existingNode, memoryNode);
|
|
142
|
+
result.conflicts.push(conflict);
|
|
143
|
+
const resolved = await this.resolveConflict(conflict);
|
|
144
|
+
if (!resolved || conflict.resolvedAs === "vault") {
|
|
145
|
+
result.skipped++;
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
result.synced++;
|
|
151
|
+
this.memoryCache.set(memoryNode.id, memoryNode);
|
|
152
|
+
} catch (error) {
|
|
153
|
+
result.failed++;
|
|
154
|
+
result.errors.push({
|
|
155
|
+
nodeId: memoryNode.id,
|
|
156
|
+
error: String(error)
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
result.duration = Date.now() - startTime;
|
|
161
|
+
result.success = result.failed === 0;
|
|
162
|
+
this.lastSyncTime = /* @__PURE__ */ new Date();
|
|
163
|
+
logger.info("Sync from memory completed", {
|
|
164
|
+
synced: result.synced,
|
|
165
|
+
failed: result.failed,
|
|
166
|
+
duration: result.duration
|
|
167
|
+
});
|
|
168
|
+
} finally {
|
|
169
|
+
this.isSyncing = false;
|
|
170
|
+
await this.saveMemoryCache();
|
|
171
|
+
}
|
|
172
|
+
return result;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Perform full bidirectional sync
|
|
176
|
+
*/
|
|
177
|
+
async fullSync() {
|
|
178
|
+
const startTime = Date.now();
|
|
179
|
+
const toMemory = await this.syncToMemory();
|
|
180
|
+
const fromMemory = await this.syncFromMemory();
|
|
181
|
+
return {
|
|
182
|
+
success: toMemory.success && fromMemory.success,
|
|
183
|
+
toMemory,
|
|
184
|
+
fromMemory,
|
|
185
|
+
totalDuration: Date.now() - startTime,
|
|
186
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Get current sync status
|
|
191
|
+
*/
|
|
192
|
+
getStatus() {
|
|
193
|
+
const pendingVaultChanges = this.db ? this.countPendingVaultChanges() : 0;
|
|
194
|
+
const pendingMemoryChanges = this.countPendingMemoryChanges();
|
|
195
|
+
let health = "healthy";
|
|
196
|
+
if (this.syncErrors.length > 0) {
|
|
197
|
+
health = "error";
|
|
198
|
+
} else if (this.conflicts.length > 0 || pendingVaultChanges > 10) {
|
|
199
|
+
health = "warning";
|
|
200
|
+
}
|
|
201
|
+
return {
|
|
202
|
+
lastSync: this.lastSyncTime,
|
|
203
|
+
isSyncing: this.isSyncing,
|
|
204
|
+
pendingVaultChanges,
|
|
205
|
+
pendingMemoryChanges,
|
|
206
|
+
errors: [...this.syncErrors],
|
|
207
|
+
health
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Get unresolved conflicts
|
|
212
|
+
*/
|
|
213
|
+
getConflicts() {
|
|
214
|
+
return this.conflicts.filter((c) => !c.resolvedAt);
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Manually resolve a conflict
|
|
218
|
+
*/
|
|
219
|
+
async resolveConflictManually(nodeId, resolution) {
|
|
220
|
+
const conflict = this.conflicts.find(
|
|
221
|
+
(c) => c.nodeId === nodeId && !c.resolvedAt
|
|
222
|
+
);
|
|
223
|
+
if (!conflict) {
|
|
224
|
+
return false;
|
|
225
|
+
}
|
|
226
|
+
conflict.resolvedAs = resolution;
|
|
227
|
+
conflict.resolvedAt = /* @__PURE__ */ new Date();
|
|
228
|
+
if (resolution === "vault" && this.db) {
|
|
229
|
+
const node = this.db.getNode(nodeId);
|
|
230
|
+
if (node) {
|
|
231
|
+
const memoryNode = this.nodeToMemoryEntry(node);
|
|
232
|
+
await this.storeToMemory(memoryNode);
|
|
233
|
+
this.memoryCache.set(nodeId, memoryNode);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
return true;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Detect changes in vault since last sync
|
|
240
|
+
*/
|
|
241
|
+
async detectChanges() {
|
|
242
|
+
if (!this.db) {
|
|
243
|
+
return [];
|
|
244
|
+
}
|
|
245
|
+
const nodes = this.db.getAllNodes();
|
|
246
|
+
const filePaths = nodes.map((n) => n.path);
|
|
247
|
+
return this.shadowCache.detectChanges(filePaths);
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Stop the sync system
|
|
251
|
+
*/
|
|
252
|
+
stop() {
|
|
253
|
+
if (this.autoSyncTimer) {
|
|
254
|
+
clearInterval(this.autoSyncTimer);
|
|
255
|
+
this.autoSyncTimer = null;
|
|
256
|
+
}
|
|
257
|
+
this.saveMemoryCache().catch(
|
|
258
|
+
(err) => logger.error("Failed to save memory cache on stop", err)
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
// Private methods
|
|
262
|
+
startAutoSync() {
|
|
263
|
+
if (this.autoSyncTimer) {
|
|
264
|
+
clearInterval(this.autoSyncTimer);
|
|
265
|
+
}
|
|
266
|
+
this.autoSyncTimer = setInterval(async () => {
|
|
267
|
+
if (!this.isSyncing) {
|
|
268
|
+
try {
|
|
269
|
+
await this.syncToMemory();
|
|
270
|
+
} catch (error) {
|
|
271
|
+
logger.error("Auto-sync failed", error);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}, this.options.autoSyncInterval);
|
|
275
|
+
}
|
|
276
|
+
nodeToMemoryEntry(node) {
|
|
277
|
+
const summary = this.extractSummary(node.content);
|
|
278
|
+
const contentHash = this.computeContentHash(node.content);
|
|
279
|
+
return {
|
|
280
|
+
id: node.id,
|
|
281
|
+
title: node.title,
|
|
282
|
+
type: node.type,
|
|
283
|
+
status: node.status,
|
|
284
|
+
path: node.path,
|
|
285
|
+
tags: node.tags,
|
|
286
|
+
outgoingLinks: node.outgoingLinks.map((l) => l.target),
|
|
287
|
+
incomingLinks: node.incomingLinks.map((l) => l.target),
|
|
288
|
+
summary,
|
|
289
|
+
contentHash,
|
|
290
|
+
lastModified: node.lastModified.toISOString(),
|
|
291
|
+
syncedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
extractSummary(content, maxLength = 200) {
|
|
295
|
+
const lines = content.split("\n");
|
|
296
|
+
let summary = "";
|
|
297
|
+
for (const line of lines) {
|
|
298
|
+
const trimmed = line.trim();
|
|
299
|
+
if (!trimmed || trimmed.startsWith("#") || trimmed.startsWith("```") || trimmed === "---") {
|
|
300
|
+
continue;
|
|
301
|
+
}
|
|
302
|
+
summary = trimmed;
|
|
303
|
+
break;
|
|
304
|
+
}
|
|
305
|
+
if (summary.length > maxLength) {
|
|
306
|
+
summary = summary.slice(0, maxLength - 3) + "...";
|
|
307
|
+
}
|
|
308
|
+
return summary;
|
|
309
|
+
}
|
|
310
|
+
computeContentHash(content) {
|
|
311
|
+
return createHash("md5").update(content).digest("hex").substring(0, 16);
|
|
312
|
+
}
|
|
313
|
+
async storeToMemory(node) {
|
|
314
|
+
logger.debug("Store to memory", {
|
|
315
|
+
key: `node/${node.id}`,
|
|
316
|
+
namespace: this.options.namespace
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
async retrieveFromMemory() {
|
|
320
|
+
logger.debug("Retrieve from memory", {
|
|
321
|
+
namespace: this.options.namespace
|
|
322
|
+
});
|
|
323
|
+
return Array.from(this.memoryCache.values());
|
|
324
|
+
}
|
|
325
|
+
async syncIndexesToMemory(nodes) {
|
|
326
|
+
const nodeIndex = nodes.map((n) => ({
|
|
327
|
+
id: n.id,
|
|
328
|
+
title: n.title,
|
|
329
|
+
type: n.type,
|
|
330
|
+
path: n.path
|
|
331
|
+
}));
|
|
332
|
+
logger.debug("Sync node index", {
|
|
333
|
+
count: nodeIndex.length,
|
|
334
|
+
namespace: this.options.namespace
|
|
335
|
+
});
|
|
336
|
+
const tagIndex = {};
|
|
337
|
+
for (const node of nodes) {
|
|
338
|
+
for (const tag of node.tags) {
|
|
339
|
+
if (!tagIndex[tag]) {
|
|
340
|
+
tagIndex[tag] = [];
|
|
341
|
+
}
|
|
342
|
+
tagIndex[tag].push(node.id);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
logger.debug("Sync tag index", {
|
|
346
|
+
tags: Object.keys(tagIndex).length,
|
|
347
|
+
namespace: this.options.namespace
|
|
348
|
+
});
|
|
349
|
+
const metadata = {
|
|
350
|
+
lastSync: (/* @__PURE__ */ new Date()).toISOString(),
|
|
351
|
+
nodeCount: nodes.length,
|
|
352
|
+
namespace: this.options.namespace
|
|
353
|
+
};
|
|
354
|
+
logger.debug("Sync metadata", metadata);
|
|
355
|
+
}
|
|
356
|
+
async detectConflict(node, cached) {
|
|
357
|
+
const vaultHash = this.computeContentHash(node.content);
|
|
358
|
+
if (vaultHash === cached.contentHash) {
|
|
359
|
+
return null;
|
|
360
|
+
}
|
|
361
|
+
return {
|
|
362
|
+
nodeId: node.id,
|
|
363
|
+
path: node.path,
|
|
364
|
+
vaultVersion: {
|
|
365
|
+
hash: vaultHash,
|
|
366
|
+
modifiedAt: node.lastModified,
|
|
367
|
+
content: this.options.includeContent ? node.content : void 0
|
|
368
|
+
},
|
|
369
|
+
memoryVersion: {
|
|
370
|
+
hash: cached.contentHash,
|
|
371
|
+
modifiedAt: new Date(cached.lastModified)
|
|
372
|
+
}
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
createConflictRecord(node, memoryNode) {
|
|
376
|
+
return {
|
|
377
|
+
nodeId: node.id,
|
|
378
|
+
path: node.path,
|
|
379
|
+
vaultVersion: {
|
|
380
|
+
hash: this.computeContentHash(node.content),
|
|
381
|
+
modifiedAt: node.lastModified
|
|
382
|
+
},
|
|
383
|
+
memoryVersion: {
|
|
384
|
+
hash: memoryNode.contentHash,
|
|
385
|
+
modifiedAt: new Date(memoryNode.lastModified)
|
|
386
|
+
}
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
async resolveConflict(conflict) {
|
|
390
|
+
switch (this.options.conflictStrategy) {
|
|
391
|
+
case "vault-wins":
|
|
392
|
+
conflict.resolvedAs = "vault";
|
|
393
|
+
conflict.resolvedAt = /* @__PURE__ */ new Date();
|
|
394
|
+
return true;
|
|
395
|
+
case "memory-wins":
|
|
396
|
+
conflict.resolvedAs = "memory";
|
|
397
|
+
conflict.resolvedAt = /* @__PURE__ */ new Date();
|
|
398
|
+
return true;
|
|
399
|
+
case "newest-wins":
|
|
400
|
+
if (conflict.vaultVersion.modifiedAt > conflict.memoryVersion.modifiedAt) {
|
|
401
|
+
conflict.resolvedAs = "vault";
|
|
402
|
+
} else {
|
|
403
|
+
conflict.resolvedAs = "memory";
|
|
404
|
+
}
|
|
405
|
+
conflict.resolvedAt = /* @__PURE__ */ new Date();
|
|
406
|
+
return true;
|
|
407
|
+
case "merge":
|
|
408
|
+
if (conflict.vaultVersion.modifiedAt > conflict.memoryVersion.modifiedAt) {
|
|
409
|
+
conflict.resolvedAs = "vault";
|
|
410
|
+
} else {
|
|
411
|
+
conflict.resolvedAs = "memory";
|
|
412
|
+
}
|
|
413
|
+
conflict.resolvedAt = /* @__PURE__ */ new Date();
|
|
414
|
+
return true;
|
|
415
|
+
case "manual":
|
|
416
|
+
this.conflicts.push(conflict);
|
|
417
|
+
return false;
|
|
418
|
+
default:
|
|
419
|
+
return false;
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
countPendingVaultChanges() {
|
|
423
|
+
const cachedHashes = /* @__PURE__ */ new Map();
|
|
424
|
+
for (const [id, node] of this.memoryCache) {
|
|
425
|
+
cachedHashes.set(id, node.contentHash);
|
|
426
|
+
}
|
|
427
|
+
let pending = 0;
|
|
428
|
+
const nodes = this.db?.getAllNodes() ?? [];
|
|
429
|
+
for (const node of nodes) {
|
|
430
|
+
const cachedHash = cachedHashes.get(node.id);
|
|
431
|
+
const currentHash = this.computeContentHash(node.content);
|
|
432
|
+
if (!cachedHash || cachedHash !== currentHash) {
|
|
433
|
+
pending++;
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
return pending;
|
|
437
|
+
}
|
|
438
|
+
countPendingMemoryChanges() {
|
|
439
|
+
return 0;
|
|
440
|
+
}
|
|
441
|
+
createBatches(items, batchSize) {
|
|
442
|
+
const batches = [];
|
|
443
|
+
for (let i = 0; i < items.length; i += batchSize) {
|
|
444
|
+
batches.push(items.slice(i, i + batchSize));
|
|
445
|
+
}
|
|
446
|
+
return batches;
|
|
447
|
+
}
|
|
448
|
+
async loadMemoryCache() {
|
|
449
|
+
logger.debug("Loading memory cache");
|
|
450
|
+
}
|
|
451
|
+
async saveMemoryCache() {
|
|
452
|
+
await this.shadowCache.save();
|
|
453
|
+
logger.debug("Memory cache saved");
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
function createVaultMemorySync(options) {
|
|
457
|
+
return new VaultMemorySync(options);
|
|
458
|
+
}
|
|
459
|
+
export {
|
|
460
|
+
VaultMemorySync,
|
|
461
|
+
createVaultMemorySync
|
|
462
|
+
};
|
|
463
|
+
//# sourceMappingURL=vault-sync.js.map
|