@stackmemoryai/stackmemory 0.5.57 → 0.5.59
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/bin/codex-smd +6 -0
- package/dist/cli/codex-sm-danger.js +21 -0
- package/dist/cli/codex-sm-danger.js.map +7 -0
- package/dist/cli/commands/handoff.js +33 -3
- package/dist/cli/commands/handoff.js.map +2 -2
- package/dist/cli/commands/search.js +20 -3
- package/dist/cli/commands/search.js.map +2 -2
- package/dist/core/database/sqlite-adapter.js +13 -3
- package/dist/core/database/sqlite-adapter.js.map +2 -2
- package/dist/core/errors/error-utils.js +208 -0
- package/dist/core/errors/error-utils.js.map +7 -0
- package/dist/core/errors/index.js +13 -4
- package/dist/core/errors/index.js.map +2 -2
- package/dist/core/merge/unified-merge-resolver.js +303 -0
- package/dist/core/merge/unified-merge-resolver.js.map +7 -0
- package/dist/core/monitoring/logger.js +61 -9
- package/dist/core/monitoring/logger.js.map +2 -2
- package/dist/core/security/index.js +35 -0
- package/dist/core/security/index.js.map +7 -0
- package/dist/core/security/input-sanitizer.js +321 -0
- package/dist/core/security/input-sanitizer.js.map +7 -0
- package/dist/core/session/enhanced-handoff.js +136 -2
- package/dist/core/session/enhanced-handoff.js.map +3 -3
- package/dist/integrations/linear/client.js +5 -1
- package/dist/integrations/linear/client.js.map +2 -2
- package/dist/integrations/mcp/remote-server.js +27 -36
- package/dist/integrations/mcp/remote-server.js.map +2 -2
- package/dist/integrations/mcp/server.js +44 -29
- package/dist/integrations/mcp/server.js.map +3 -3
- package/dist/scripts/benchmark-performance.js +48 -0
- package/dist/scripts/benchmark-performance.js.map +7 -0
- package/dist/scripts/check-redis.js +42 -0
- package/dist/scripts/check-redis.js.map +7 -0
- package/dist/scripts/initialize.js +116 -0
- package/dist/scripts/initialize.js.map +7 -0
- package/dist/scripts/list-linear-tasks.js +124 -0
- package/dist/scripts/list-linear-tasks.js.map +7 -0
- package/dist/scripts/measure-handoff-impact.js +340 -0
- package/dist/scripts/measure-handoff-impact.js.map +7 -0
- package/dist/scripts/query-chromadb.js +160 -0
- package/dist/scripts/query-chromadb.js.map +7 -0
- package/dist/scripts/show-linear-summary.js +119 -0
- package/dist/scripts/show-linear-summary.js.map +7 -0
- package/dist/scripts/simple-swarm-demo.js +90 -0
- package/dist/scripts/simple-swarm-demo.js.map +7 -0
- package/dist/scripts/status.js +155 -0
- package/dist/scripts/status.js.map +7 -0
- package/dist/scripts/test-chromadb-sync.js +192 -0
- package/dist/scripts/test-chromadb-sync.js.map +7 -0
- package/dist/scripts/test-ralph-iteration-fix.js +86 -0
- package/dist/scripts/test-ralph-iteration-fix.js.map +7 -0
- package/dist/scripts/test-ralph-iterations.js +121 -0
- package/dist/scripts/test-ralph-iterations.js.map +7 -0
- package/dist/scripts/test-redis-storage.js +389 -0
- package/dist/scripts/test-redis-storage.js.map +7 -0
- package/dist/scripts/test-simple-ralph-state-sync.js +115 -0
- package/dist/scripts/test-simple-ralph-state-sync.js.map +7 -0
- package/dist/scripts/test-swarm-fixes.js +125 -0
- package/dist/scripts/test-swarm-fixes.js.map +7 -0
- package/dist/scripts/test-swarm-tui.js +23 -0
- package/dist/scripts/test-swarm-tui.js.map +7 -0
- package/dist/scripts/test-tui-shortcuts.js +52 -0
- package/dist/scripts/test-tui-shortcuts.js.map +7 -0
- package/dist/scripts/validate-tui-shortcuts.js +60 -0
- package/dist/scripts/validate-tui-shortcuts.js.map +7 -0
- package/dist/src/agents/core/agent-task-manager.js +527 -0
- package/dist/src/agents/core/agent-task-manager.js.map +7 -0
- package/dist/src/agents/verifiers/base-verifier.js +133 -0
- package/dist/src/agents/verifiers/base-verifier.js.map +7 -0
- package/dist/src/agents/verifiers/formatter-verifier.js +130 -0
- package/dist/src/agents/verifiers/formatter-verifier.js.map +7 -0
- package/dist/src/agents/verifiers/llm-judge.js +252 -0
- package/dist/src/agents/verifiers/llm-judge.js.map +7 -0
- package/dist/src/cli/auto-detect.js +321 -0
- package/dist/src/cli/auto-detect.js.map +7 -0
- package/dist/src/cli/claude-sm-danger.js +21 -0
- package/dist/src/cli/claude-sm-danger.js.map +7 -0
- package/dist/src/cli/claude-sm.js +1156 -0
- package/dist/src/cli/claude-sm.js.map +7 -0
- package/dist/src/cli/codex-sm-danger.js +21 -0
- package/dist/src/cli/codex-sm-danger.js.map +7 -0
- package/dist/src/cli/codex-sm.js +349 -0
- package/dist/src/cli/codex-sm.js.map +7 -0
- package/dist/src/cli/commands/api.js +232 -0
- package/dist/src/cli/commands/api.js.map +7 -0
- package/dist/src/cli/commands/auto-background.js +180 -0
- package/dist/src/cli/commands/auto-background.js.map +7 -0
- package/dist/src/cli/commands/cleanup-processes.js +68 -0
- package/dist/src/cli/commands/cleanup-processes.js.map +7 -0
- package/dist/src/cli/commands/clear.js +202 -0
- package/dist/src/cli/commands/clear.js.map +7 -0
- package/dist/src/cli/commands/config.js +445 -0
- package/dist/src/cli/commands/config.js.map +7 -0
- package/dist/src/cli/commands/context-rehydrate.js +751 -0
- package/dist/src/cli/commands/context-rehydrate.js.map +7 -0
- package/dist/src/cli/commands/context.js +343 -0
- package/dist/src/cli/commands/context.js.map +7 -0
- package/dist/src/cli/commands/daemon.js +392 -0
- package/dist/src/cli/commands/daemon.js.map +7 -0
- package/dist/src/cli/commands/dashboard.js +210 -0
- package/dist/src/cli/commands/dashboard.js.map +7 -0
- package/dist/src/cli/commands/db.js +147 -0
- package/dist/src/cli/commands/db.js.map +7 -0
- package/dist/src/cli/commands/decision.js +266 -0
- package/dist/src/cli/commands/decision.js.map +7 -0
- package/dist/src/cli/commands/discovery.js +279 -0
- package/dist/src/cli/commands/discovery.js.map +7 -0
- package/dist/src/cli/commands/handoff.js +624 -0
- package/dist/src/cli/commands/handoff.js.map +7 -0
- package/dist/src/cli/commands/hooks.js +298 -0
- package/dist/src/cli/commands/hooks.js.map +7 -0
- package/dist/src/cli/commands/linear.js +529 -0
- package/dist/src/cli/commands/linear.js.map +7 -0
- package/dist/src/cli/commands/log.js +169 -0
- package/dist/src/cli/commands/log.js.map +7 -0
- package/dist/src/cli/commands/login.js +172 -0
- package/dist/src/cli/commands/login.js.map +7 -0
- package/dist/src/cli/commands/migrate.js +240 -0
- package/dist/src/cli/commands/migrate.js.map +7 -0
- package/dist/src/cli/commands/model.js +533 -0
- package/dist/src/cli/commands/model.js.map +7 -0
- package/dist/src/cli/commands/onboard.js +536 -0
- package/dist/src/cli/commands/onboard.js.map +7 -0
- package/dist/src/cli/commands/projects.js +199 -0
- package/dist/src/cli/commands/projects.js.map +7 -0
- package/dist/src/cli/commands/ralph.js +909 -0
- package/dist/src/cli/commands/ralph.js.map +7 -0
- package/dist/src/cli/commands/retrieval.js +248 -0
- package/dist/src/cli/commands/retrieval.js.map +7 -0
- package/dist/src/cli/commands/search.js +173 -0
- package/dist/src/cli/commands/search.js.map +7 -0
- package/dist/src/cli/commands/service.js +749 -0
- package/dist/src/cli/commands/service.js.map +7 -0
- package/dist/src/cli/commands/session.js +200 -0
- package/dist/src/cli/commands/session.js.map +7 -0
- package/dist/src/cli/commands/settings.js +306 -0
- package/dist/src/cli/commands/settings.js.map +7 -0
- package/dist/src/cli/commands/setup.js +701 -0
- package/dist/src/cli/commands/setup.js.map +7 -0
- package/dist/src/cli/commands/shell.js +249 -0
- package/dist/src/cli/commands/shell.js.map +7 -0
- package/dist/src/cli/commands/signup.js +50 -0
- package/dist/src/cli/commands/signup.js.map +7 -0
- package/dist/src/cli/commands/skills.js +470 -0
- package/dist/src/cli/commands/skills.js.map +7 -0
- package/dist/src/cli/commands/sms-notify.js +795 -0
- package/dist/src/cli/commands/sms-notify.js.map +7 -0
- package/dist/src/cli/commands/storage-tier.js +183 -0
- package/dist/src/cli/commands/storage-tier.js.map +7 -0
- package/dist/src/cli/commands/sweep.js +249 -0
- package/dist/src/cli/commands/sweep.js.map +7 -0
- package/dist/src/cli/commands/tasks.js +213 -0
- package/dist/src/cli/commands/tasks.js.map +7 -0
- package/dist/src/cli/commands/worktree.js +319 -0
- package/dist/src/cli/commands/worktree.js.map +7 -0
- package/dist/src/cli/index.js +594 -0
- package/dist/src/cli/index.js.map +7 -0
- package/dist/src/cli/opencode-sm.js +448 -0
- package/dist/src/cli/opencode-sm.js.map +7 -0
- package/dist/src/cli/utils/viewer.js +96 -0
- package/dist/src/cli/utils/viewer.js.map +7 -0
- package/dist/src/core/config/config-manager.js +398 -0
- package/dist/src/core/config/config-manager.js.map +7 -0
- package/dist/src/core/config/feature-flags.js +76 -0
- package/dist/src/core/config/feature-flags.js.map +7 -0
- package/dist/src/core/config/storage-config.js +115 -0
- package/dist/src/core/config/storage-config.js.map +7 -0
- package/dist/src/core/config/types.js +144 -0
- package/dist/src/core/config/types.js.map +7 -0
- package/dist/src/core/context/auto-context.js +80 -0
- package/dist/src/core/context/auto-context.js.map +7 -0
- package/dist/src/core/context/dual-stack-manager.js +870 -0
- package/dist/src/core/context/dual-stack-manager.js.map +7 -0
- package/dist/src/core/context/enhanced-rehydration.js +994 -0
- package/dist/src/core/context/enhanced-rehydration.js.map +7 -0
- package/dist/src/core/context/frame-database.js +479 -0
- package/dist/src/core/context/frame-database.js.map +7 -0
- package/dist/src/core/context/frame-digest.js +250 -0
- package/dist/src/core/context/frame-digest.js.map +7 -0
- package/dist/src/core/context/frame-handoff-manager.js +778 -0
- package/dist/src/core/context/frame-handoff-manager.js.map +7 -0
- package/dist/src/core/context/frame-lifecycle-hooks.js +119 -0
- package/dist/src/core/context/frame-lifecycle-hooks.js.map +7 -0
- package/dist/src/core/context/frame-recovery.js +302 -0
- package/dist/src/core/context/frame-recovery.js.map +7 -0
- package/dist/src/core/context/frame-stack.js +314 -0
- package/dist/src/core/context/frame-stack.js.map +7 -0
- package/dist/src/core/context/frame-types.js +5 -0
- package/dist/src/core/context/frame-types.js.map +7 -0
- package/dist/src/core/context/index.js +25 -0
- package/dist/src/core/context/index.js.map +7 -0
- package/dist/src/core/context/permission-manager.js +185 -0
- package/dist/src/core/context/permission-manager.js.map +7 -0
- package/dist/src/core/context/recursive-context-manager.js +592 -0
- package/dist/src/core/context/recursive-context-manager.js.map +7 -0
- package/dist/src/core/context/refactored-frame-manager.js +754 -0
- package/dist/src/core/context/refactored-frame-manager.js.map +7 -0
- package/dist/src/core/context/shared-context-layer.js +621 -0
- package/dist/src/core/context/shared-context-layer.js.map +7 -0
- package/dist/src/core/context/stack-merge-resolver.js +749 -0
- package/dist/src/core/context/stack-merge-resolver.js.map +7 -0
- package/dist/src/core/context/validation.js +130 -0
- package/dist/src/core/context/validation.js.map +7 -0
- package/dist/src/core/database/batch-operations.js +384 -0
- package/dist/src/core/database/batch-operations.js.map +7 -0
- package/dist/src/core/database/connection-pool.js +330 -0
- package/dist/src/core/database/connection-pool.js.map +7 -0
- package/dist/src/core/database/database-adapter.js +60 -0
- package/dist/src/core/database/database-adapter.js.map +7 -0
- package/dist/src/core/database/migration-manager.js +614 -0
- package/dist/src/core/database/migration-manager.js.map +7 -0
- package/dist/src/core/database/query-cache.js +298 -0
- package/dist/src/core/database/query-cache.js.map +7 -0
- package/dist/src/core/database/query-router.js +430 -0
- package/dist/src/core/database/query-router.js.map +7 -0
- package/dist/src/core/database/sqlite-adapter.js +738 -0
- package/dist/src/core/database/sqlite-adapter.js.map +7 -0
- package/dist/src/core/digest/enhanced-hybrid-digest.js +277 -0
- package/dist/src/core/digest/enhanced-hybrid-digest.js.map +7 -0
- package/dist/src/core/digest/frame-digest-integration.js +176 -0
- package/dist/src/core/digest/frame-digest-integration.js.map +7 -0
- package/dist/src/core/digest/hybrid-digest-generator.js +553 -0
- package/dist/src/core/digest/hybrid-digest-generator.js.map +7 -0
- package/dist/src/core/digest/index.js +9 -0
- package/dist/src/core/digest/index.js.map +7 -0
- package/dist/src/core/digest/types.js +25 -0
- package/dist/src/core/digest/types.js.map +7 -0
- package/dist/src/core/errors/error-utils.js +208 -0
- package/dist/src/core/errors/error-utils.js.map +7 -0
- package/dist/src/core/errors/index.js +521 -0
- package/dist/src/core/errors/index.js.map +7 -0
- package/dist/src/core/errors/recovery.js +269 -0
- package/dist/src/core/errors/recovery.js.map +7 -0
- package/dist/src/core/execution/parallel-executor.js +258 -0
- package/dist/src/core/execution/parallel-executor.js.map +7 -0
- package/dist/src/core/frame/workflow-templates.js +319 -0
- package/dist/src/core/frame/workflow-templates.js.map +7 -0
- package/dist/src/core/merge/conflict-detector.js +431 -0
- package/dist/src/core/merge/conflict-detector.js.map +7 -0
- package/dist/src/core/merge/index.js +9 -0
- package/dist/src/core/merge/index.js.map +7 -0
- package/dist/src/core/merge/resolution-engine.js +558 -0
- package/dist/src/core/merge/resolution-engine.js.map +7 -0
- package/dist/src/core/merge/stack-diff.js +532 -0
- package/dist/src/core/merge/stack-diff.js.map +7 -0
- package/dist/src/core/merge/types.js +5 -0
- package/dist/src/core/merge/types.js.map +7 -0
- package/dist/src/core/merge/unified-merge-resolver.js +303 -0
- package/dist/src/core/merge/unified-merge-resolver.js.map +7 -0
- package/dist/src/core/models/fallback-monitor.js +232 -0
- package/dist/src/core/models/fallback-monitor.js.map +7 -0
- package/dist/src/core/models/model-router.js +340 -0
- package/dist/src/core/models/model-router.js.map +7 -0
- package/dist/src/core/monitoring/error-handler.js +49 -0
- package/dist/src/core/monitoring/error-handler.js.map +7 -0
- package/dist/src/core/monitoring/logger.js +202 -0
- package/dist/src/core/monitoring/logger.js.map +7 -0
- package/dist/src/core/monitoring/metrics.js +172 -0
- package/dist/src/core/monitoring/metrics.js.map +7 -0
- package/dist/src/core/monitoring/progress-tracker.js +189 -0
- package/dist/src/core/monitoring/progress-tracker.js.map +7 -0
- package/dist/src/core/monitoring/session-monitor.js +300 -0
- package/dist/src/core/monitoring/session-monitor.js.map +7 -0
- package/dist/src/core/performance/context-cache.js +273 -0
- package/dist/src/core/performance/context-cache.js.map +7 -0
- package/dist/src/core/performance/index.js +11 -0
- package/dist/src/core/performance/index.js.map +7 -0
- package/dist/src/core/performance/lazy-context-loader.js +327 -0
- package/dist/src/core/performance/lazy-context-loader.js.map +7 -0
- package/dist/src/core/performance/monitor.js +221 -0
- package/dist/src/core/performance/monitor.js.map +7 -0
- package/dist/src/core/performance/optimized-frame-context.js +345 -0
- package/dist/src/core/performance/optimized-frame-context.js.map +7 -0
- package/dist/src/core/performance/performance-benchmark.js +277 -0
- package/dist/src/core/performance/performance-benchmark.js.map +7 -0
- package/dist/src/core/performance/performance-profiler.js +370 -0
- package/dist/src/core/performance/performance-profiler.js.map +7 -0
- package/dist/src/core/performance/streaming-jsonl-parser.js +195 -0
- package/dist/src/core/performance/streaming-jsonl-parser.js.map +7 -0
- package/dist/src/core/persistence/postgres-adapter.js +349 -0
- package/dist/src/core/persistence/postgres-adapter.js.map +7 -0
- package/dist/src/core/projects/project-isolation.js +201 -0
- package/dist/src/core/projects/project-isolation.js.map +7 -0
- package/dist/src/core/projects/project-manager.js +697 -0
- package/dist/src/core/projects/project-manager.js.map +7 -0
- package/dist/src/core/query/query-parser.js +370 -0
- package/dist/src/core/query/query-parser.js.map +7 -0
- package/dist/src/core/query/query-templates.js +321 -0
- package/dist/src/core/query/query-templates.js.map +7 -0
- package/dist/src/core/retrieval/context-retriever.js +479 -0
- package/dist/src/core/retrieval/context-retriever.js.map +7 -0
- package/dist/src/core/retrieval/index.js +8 -0
- package/dist/src/core/retrieval/index.js.map +7 -0
- package/dist/src/core/retrieval/llm-context-retrieval.js +613 -0
- package/dist/src/core/retrieval/llm-context-retrieval.js.map +7 -0
- package/dist/src/core/retrieval/llm-provider.js +151 -0
- package/dist/src/core/retrieval/llm-provider.js.map +7 -0
- package/dist/src/core/retrieval/retrieval-audit.js +236 -0
- package/dist/src/core/retrieval/retrieval-audit.js.map +7 -0
- package/dist/src/core/retrieval/summary-generator.js +589 -0
- package/dist/src/core/retrieval/summary-generator.js.map +7 -0
- package/dist/src/core/retrieval/types.js +21 -0
- package/dist/src/core/retrieval/types.js.map +7 -0
- package/dist/src/core/security/index.js +35 -0
- package/dist/src/core/security/index.js.map +7 -0
- package/dist/src/core/security/input-sanitizer.js +321 -0
- package/dist/src/core/security/input-sanitizer.js.map +7 -0
- package/dist/src/core/session/clear-survival.js +465 -0
- package/dist/src/core/session/clear-survival.js.map +7 -0
- package/dist/src/core/session/enhanced-handoff.js +792 -0
- package/dist/src/core/session/enhanced-handoff.js.map +7 -0
- package/dist/src/core/session/handoff-generator.js +343 -0
- package/dist/src/core/session/handoff-generator.js.map +7 -0
- package/dist/src/core/session/index.js +15 -0
- package/dist/src/core/session/index.js.map +7 -0
- package/dist/src/core/session/session-manager.js +347 -0
- package/dist/src/core/session/session-manager.js.map +7 -0
- package/dist/src/core/skills/index.js +7 -0
- package/dist/src/core/skills/index.js.map +7 -0
- package/dist/src/core/skills/skill-storage.js +764 -0
- package/dist/src/core/skills/skill-storage.js.map +7 -0
- package/dist/src/core/skills/types.js +193 -0
- package/dist/src/core/skills/types.js.map +7 -0
- package/dist/src/core/storage/chromadb-adapter.js +354 -0
- package/dist/src/core/storage/chromadb-adapter.js.map +7 -0
- package/dist/src/core/storage/infinite-storage.js +510 -0
- package/dist/src/core/storage/infinite-storage.js.map +7 -0
- package/dist/src/core/storage/remote-storage.js +489 -0
- package/dist/src/core/storage/remote-storage.js.map +7 -0
- package/dist/src/core/storage/two-tier-storage.js +766 -0
- package/dist/src/core/storage/two-tier-storage.js.map +7 -0
- package/dist/src/core/trace/cli-trace-wrapper.js +132 -0
- package/dist/src/core/trace/cli-trace-wrapper.js.map +7 -0
- package/dist/src/core/trace/db-trace-wrapper.js +247 -0
- package/dist/src/core/trace/db-trace-wrapper.js.map +7 -0
- package/dist/src/core/trace/debug-trace.js +417 -0
- package/dist/src/core/trace/debug-trace.js.map +7 -0
- package/dist/src/core/trace/index.js +109 -0
- package/dist/src/core/trace/index.js.map +7 -0
- package/dist/src/core/trace/linear-api-wrapper.js +178 -0
- package/dist/src/core/trace/linear-api-wrapper.js.map +7 -0
- package/dist/src/core/trace/trace-detector.js +528 -0
- package/dist/src/core/trace/trace-detector.js.map +7 -0
- package/dist/src/core/trace/trace-store.js +345 -0
- package/dist/src/core/trace/trace-store.js.map +7 -0
- package/dist/src/core/trace/types.js +77 -0
- package/dist/src/core/trace/types.js.map +7 -0
- package/dist/src/core/types.js +5 -0
- package/dist/src/core/types.js.map +7 -0
- package/dist/src/core/utils/async-mutex.js +114 -0
- package/dist/src/core/utils/async-mutex.js.map +7 -0
- package/dist/src/core/utils/compression.js +83 -0
- package/dist/src/core/utils/compression.js.map +7 -0
- package/dist/src/core/utils/update-checker.js +218 -0
- package/dist/src/core/utils/update-checker.js.map +7 -0
- package/dist/src/core/worktree/worktree-manager.js +465 -0
- package/dist/src/core/worktree/worktree-manager.js.map +7 -0
- package/dist/src/daemon/daemon-config.js +149 -0
- package/dist/src/daemon/daemon-config.js.map +7 -0
- package/dist/src/daemon/services/context-service.js +122 -0
- package/dist/src/daemon/services/context-service.js.map +7 -0
- package/dist/src/daemon/services/linear-service.js +136 -0
- package/dist/src/daemon/services/linear-service.js.map +7 -0
- package/dist/src/daemon/session-daemon.js +312 -0
- package/dist/src/daemon/session-daemon.js.map +7 -0
- package/dist/src/daemon/unified-daemon.js +276 -0
- package/dist/src/daemon/unified-daemon.js.map +7 -0
- package/dist/src/features/analytics/api/analytics-api.js +287 -0
- package/dist/src/features/analytics/api/analytics-api.js.map +7 -0
- package/dist/src/features/analytics/core/analytics-service.js +282 -0
- package/dist/src/features/analytics/core/analytics-service.js.map +7 -0
- package/dist/src/features/analytics/index.js +18 -0
- package/dist/src/features/analytics/index.js.map +7 -0
- package/dist/src/features/analytics/queries/metrics-queries.js +277 -0
- package/dist/src/features/analytics/queries/metrics-queries.js.map +7 -0
- package/dist/src/features/analytics/types/metrics.js +5 -0
- package/dist/src/features/analytics/types/metrics.js.map +7 -0
- package/dist/src/features/browser/browser-mcp.js +492 -0
- package/dist/src/features/browser/browser-mcp.js.map +7 -0
- package/dist/src/features/sweep/index.js +20 -0
- package/dist/src/features/sweep/index.js.map +7 -0
- package/dist/src/features/sweep/prediction-client.js +155 -0
- package/dist/src/features/sweep/prediction-client.js.map +7 -0
- package/dist/src/features/sweep/prompt-builder.js +85 -0
- package/dist/src/features/sweep/prompt-builder.js.map +7 -0
- package/dist/src/features/sweep/pty-wrapper.js +171 -0
- package/dist/src/features/sweep/pty-wrapper.js.map +7 -0
- package/dist/src/features/sweep/state-watcher.js +87 -0
- package/dist/src/features/sweep/state-watcher.js.map +7 -0
- package/dist/src/features/sweep/status-bar.js +88 -0
- package/dist/src/features/sweep/status-bar.js.map +7 -0
- package/dist/src/features/sweep/sweep-server-manager.js +226 -0
- package/dist/src/features/sweep/sweep-server-manager.js.map +7 -0
- package/dist/src/features/sweep/tab-interceptor.js +38 -0
- package/dist/src/features/sweep/tab-interceptor.js.map +7 -0
- package/dist/src/features/sweep/types.js +18 -0
- package/dist/src/features/sweep/types.js.map +7 -0
- package/dist/src/features/tasks/linear-task-manager.js +487 -0
- package/dist/src/features/tasks/linear-task-manager.js.map +7 -0
- package/dist/src/features/tasks/task-aware-context.js +410 -0
- package/dist/src/features/tasks/task-aware-context.js.map +7 -0
- package/dist/src/features/tui/simple-monitor.js +116 -0
- package/dist/src/features/tui/simple-monitor.js.map +7 -0
- package/dist/src/features/tui/swarm-monitor.js +648 -0
- package/dist/src/features/tui/swarm-monitor.js.map +7 -0
- package/dist/src/features/web/client/stores/task-store.js +26 -0
- package/dist/src/features/web/client/stores/task-store.js.map +7 -0
- package/dist/src/features/web/server/index.js +194 -0
- package/dist/src/features/web/server/index.js.map +7 -0
- package/dist/src/hooks/auto-background.js +151 -0
- package/dist/src/hooks/auto-background.js.map +7 -0
- package/dist/src/hooks/claude-code-whatsapp-hook.js +197 -0
- package/dist/src/hooks/claude-code-whatsapp-hook.js.map +7 -0
- package/dist/src/hooks/config.js +150 -0
- package/dist/src/hooks/config.js.map +7 -0
- package/dist/src/hooks/daemon.js +364 -0
- package/dist/src/hooks/daemon.js.map +7 -0
- package/dist/src/hooks/events.js +58 -0
- package/dist/src/hooks/events.js.map +7 -0
- package/dist/src/hooks/index.js +12 -0
- package/dist/src/hooks/index.js.map +7 -0
- package/dist/src/hooks/linear-task-picker.js +186 -0
- package/dist/src/hooks/linear-task-picker.js.map +7 -0
- package/dist/src/hooks/schemas.js +197 -0
- package/dist/src/hooks/schemas.js.map +7 -0
- package/dist/src/hooks/secure-fs.js +49 -0
- package/dist/src/hooks/secure-fs.js.map +7 -0
- package/dist/src/hooks/security-logger.js +155 -0
- package/dist/src/hooks/security-logger.js.map +7 -0
- package/dist/src/hooks/session-summary.js +222 -0
- package/dist/src/hooks/session-summary.js.map +7 -0
- package/dist/src/hooks/sms-action-runner.js +371 -0
- package/dist/src/hooks/sms-action-runner.js.map +7 -0
- package/dist/src/hooks/sms-notify.js +506 -0
- package/dist/src/hooks/sms-notify.js.map +7 -0
- package/dist/src/hooks/sms-watcher.js +93 -0
- package/dist/src/hooks/sms-watcher.js.map +7 -0
- package/dist/src/hooks/sms-webhook.js +555 -0
- package/dist/src/hooks/sms-webhook.js.map +7 -0
- package/dist/src/hooks/whatsapp-commands.js +479 -0
- package/dist/src/hooks/whatsapp-commands.js.map +7 -0
- package/dist/src/hooks/whatsapp-scheduler.js +317 -0
- package/dist/src/hooks/whatsapp-scheduler.js.map +7 -0
- package/dist/src/hooks/whatsapp-sync.js +409 -0
- package/dist/src/hooks/whatsapp-sync.js.map +7 -0
- package/dist/src/index.js +25 -0
- package/dist/src/index.js.map +7 -0
- package/dist/src/integrations/anthropic/client.js +263 -0
- package/dist/src/integrations/anthropic/client.js.map +7 -0
- package/dist/src/integrations/claude-code/agent-bridge.js +768 -0
- package/dist/src/integrations/claude-code/agent-bridge.js.map +7 -0
- package/dist/src/integrations/claude-code/enhanced-pre-clear-hooks.js +459 -0
- package/dist/src/integrations/claude-code/enhanced-pre-clear-hooks.js.map +7 -0
- package/dist/src/integrations/claude-code/lifecycle-hooks.js +254 -0
- package/dist/src/integrations/claude-code/lifecycle-hooks.js.map +7 -0
- package/dist/src/integrations/claude-code/post-task-hooks.js +545 -0
- package/dist/src/integrations/claude-code/post-task-hooks.js.map +7 -0
- package/dist/src/integrations/claude-code/subagent-client-stub.js +20 -0
- package/dist/src/integrations/claude-code/subagent-client-stub.js.map +7 -0
- package/dist/src/integrations/claude-code/subagent-client.js +511 -0
- package/dist/src/integrations/claude-code/subagent-client.js.map +7 -0
- package/dist/src/integrations/claude-code/task-coordinator.js +360 -0
- package/dist/src/integrations/claude-code/task-coordinator.js.map +7 -0
- package/dist/src/integrations/linear/auth.js +337 -0
- package/dist/src/integrations/linear/auth.js.map +7 -0
- package/dist/src/integrations/linear/auto-sync.js +258 -0
- package/dist/src/integrations/linear/auto-sync.js.map +7 -0
- package/dist/src/integrations/linear/client.js +634 -0
- package/dist/src/integrations/linear/client.js.map +7 -0
- package/dist/src/integrations/linear/config.js +130 -0
- package/dist/src/integrations/linear/config.js.map +7 -0
- package/dist/src/integrations/linear/migration.js +361 -0
- package/dist/src/integrations/linear/migration.js.map +7 -0
- package/dist/src/integrations/linear/oauth-server.js +454 -0
- package/dist/src/integrations/linear/oauth-server.js.map +7 -0
- package/dist/src/integrations/linear/rest-client.js +213 -0
- package/dist/src/integrations/linear/rest-client.js.map +7 -0
- package/dist/src/integrations/linear/sync-manager.js +236 -0
- package/dist/src/integrations/linear/sync-manager.js.map +7 -0
- package/dist/src/integrations/linear/sync-service.js +231 -0
- package/dist/src/integrations/linear/sync-service.js.map +7 -0
- package/dist/src/integrations/linear/sync.js +782 -0
- package/dist/src/integrations/linear/sync.js.map +7 -0
- package/dist/src/integrations/linear/types.js +5 -0
- package/dist/src/integrations/linear/types.js.map +7 -0
- package/dist/src/integrations/linear/unified-sync.js +589 -0
- package/dist/src/integrations/linear/unified-sync.js.map +7 -0
- package/dist/src/integrations/linear/webhook-handler.js +219 -0
- package/dist/src/integrations/linear/webhook-handler.js.map +7 -0
- package/dist/src/integrations/linear/webhook-server.js +218 -0
- package/dist/src/integrations/linear/webhook-server.js.map +7 -0
- package/dist/src/integrations/linear/webhook.js +291 -0
- package/dist/src/integrations/linear/webhook.js.map +7 -0
- package/dist/src/integrations/mcp/handlers/code-execution-handlers.js +266 -0
- package/dist/src/integrations/mcp/handlers/code-execution-handlers.js.map +7 -0
- package/dist/src/integrations/mcp/handlers/context-handlers.js +257 -0
- package/dist/src/integrations/mcp/handlers/context-handlers.js.map +7 -0
- package/dist/src/integrations/mcp/handlers/discovery-handlers.js +497 -0
- package/dist/src/integrations/mcp/handlers/discovery-handlers.js.map +7 -0
- package/dist/src/integrations/mcp/handlers/index.js +166 -0
- package/dist/src/integrations/mcp/handlers/index.js.map +7 -0
- package/dist/src/integrations/mcp/handlers/linear-handlers.js +247 -0
- package/dist/src/integrations/mcp/handlers/linear-handlers.js.map +7 -0
- package/dist/src/integrations/mcp/handlers/skill-handlers.js +529 -0
- package/dist/src/integrations/mcp/handlers/skill-handlers.js.map +7 -0
- package/dist/src/integrations/mcp/handlers/task-handlers.js +239 -0
- package/dist/src/integrations/mcp/handlers/task-handlers.js.map +7 -0
- package/dist/src/integrations/mcp/handlers/trace-handlers.js +308 -0
- package/dist/src/integrations/mcp/handlers/trace-handlers.js.map +7 -0
- package/dist/src/integrations/mcp/index.js +23 -0
- package/dist/src/integrations/mcp/index.js.map +7 -0
- package/dist/src/integrations/mcp/middleware/tool-scoring.js +356 -0
- package/dist/src/integrations/mcp/middleware/tool-scoring.js.map +7 -0
- package/dist/src/integrations/mcp/refactored-server.js +374 -0
- package/dist/src/integrations/mcp/refactored-server.js.map +7 -0
- package/dist/src/integrations/mcp/remote-server.js +682 -0
- package/dist/src/integrations/mcp/remote-server.js.map +7 -0
- package/dist/src/integrations/mcp/schemas.js +147 -0
- package/dist/src/integrations/mcp/schemas.js.map +7 -0
- package/dist/src/integrations/mcp/server.js +1975 -0
- package/dist/src/integrations/mcp/server.js.map +7 -0
- package/dist/src/integrations/mcp/tool-definitions-code.js +125 -0
- package/dist/src/integrations/mcp/tool-definitions-code.js.map +7 -0
- package/dist/src/integrations/mcp/tool-definitions.js +702 -0
- package/dist/src/integrations/mcp/tool-definitions.js.map +7 -0
- package/dist/src/integrations/ralph/bridge/ralph-stackmemory-bridge.js +860 -0
- package/dist/src/integrations/ralph/bridge/ralph-stackmemory-bridge.js.map +7 -0
- package/dist/src/integrations/ralph/context/context-budget-manager.js +301 -0
- package/dist/src/integrations/ralph/context/context-budget-manager.js.map +7 -0
- package/dist/src/integrations/ralph/context/stackmemory-context-loader.js +360 -0
- package/dist/src/integrations/ralph/context/stackmemory-context-loader.js.map +7 -0
- package/dist/src/integrations/ralph/coordination/enhanced-coordination.js +410 -0
- package/dist/src/integrations/ralph/coordination/enhanced-coordination.js.map +7 -0
- package/dist/src/integrations/ralph/index.js +18 -0
- package/dist/src/integrations/ralph/index.js.map +7 -0
- package/dist/src/integrations/ralph/learning/pattern-learner.js +401 -0
- package/dist/src/integrations/ralph/learning/pattern-learner.js.map +7 -0
- package/dist/src/integrations/ralph/lifecycle/iteration-lifecycle.js +448 -0
- package/dist/src/integrations/ralph/lifecycle/iteration-lifecycle.js.map +7 -0
- package/dist/src/integrations/ralph/monitoring/swarm-dashboard.js +294 -0
- package/dist/src/integrations/ralph/monitoring/swarm-dashboard.js.map +7 -0
- package/dist/src/integrations/ralph/monitoring/swarm-registry.js +108 -0
- package/dist/src/integrations/ralph/monitoring/swarm-registry.js.map +7 -0
- package/dist/src/integrations/ralph/orchestration/multi-loop-orchestrator.js +463 -0
- package/dist/src/integrations/ralph/orchestration/multi-loop-orchestrator.js.map +7 -0
- package/dist/src/integrations/ralph/patterns/compounding-engineering-pattern.js +400 -0
- package/dist/src/integrations/ralph/patterns/compounding-engineering-pattern.js.map +7 -0
- package/dist/src/integrations/ralph/patterns/extended-coherence-sessions.js +473 -0
- package/dist/src/integrations/ralph/patterns/extended-coherence-sessions.js.map +7 -0
- package/dist/src/integrations/ralph/patterns/oracle-worker-pattern.js +388 -0
- package/dist/src/integrations/ralph/patterns/oracle-worker-pattern.js.map +7 -0
- package/dist/src/integrations/ralph/performance/performance-optimizer.js +358 -0
- package/dist/src/integrations/ralph/performance/performance-optimizer.js.map +7 -0
- package/dist/src/integrations/ralph/recovery/crash-recovery.js +462 -0
- package/dist/src/integrations/ralph/recovery/crash-recovery.js.map +7 -0
- package/dist/src/integrations/ralph/state/state-reconciler.js +404 -0
- package/dist/src/integrations/ralph/state/state-reconciler.js.map +7 -0
- package/dist/src/integrations/ralph/swarm/git-workflow-manager.js +428 -0
- package/dist/src/integrations/ralph/swarm/git-workflow-manager.js.map +7 -0
- package/dist/src/integrations/ralph/swarm/swarm-coordinator.js +996 -0
- package/dist/src/integrations/ralph/swarm/swarm-coordinator.js.map +7 -0
- package/dist/src/integrations/ralph/types.js +5 -0
- package/dist/src/integrations/ralph/types.js.map +7 -0
- package/dist/src/integrations/ralph/visualization/ralph-debugger.js +585 -0
- package/dist/src/integrations/ralph/visualization/ralph-debugger.js.map +7 -0
- package/dist/src/mcp/stackmemory-mcp-server.js +554 -0
- package/dist/src/mcp/stackmemory-mcp-server.js.map +7 -0
- package/dist/src/middleware/exponential-rate-limiter.js +289 -0
- package/dist/src/middleware/exponential-rate-limiter.js.map +7 -0
- package/dist/src/models/user.model.js +358 -0
- package/dist/src/models/user.model.js.map +7 -0
- package/dist/src/servers/production/auth-middleware.js +528 -0
- package/dist/src/servers/production/auth-middleware.js.map +7 -0
- package/dist/src/services/config-service.js +65 -0
- package/dist/src/services/config-service.js.map +7 -0
- package/dist/src/services/context-service.js +194 -0
- package/dist/src/services/context-service.js.map +7 -0
- package/dist/src/skills/api-discovery.js +354 -0
- package/dist/src/skills/api-discovery.js.map +7 -0
- package/dist/src/skills/api-skill.js +475 -0
- package/dist/src/skills/api-skill.js.map +7 -0
- package/dist/src/skills/claude-skills.js +1061 -0
- package/dist/src/skills/claude-skills.js.map +7 -0
- package/dist/src/skills/dashboard-launcher.js +216 -0
- package/dist/src/skills/dashboard-launcher.js.map +7 -0
- package/dist/src/skills/recursive-agent-orchestrator.js +575 -0
- package/dist/src/skills/recursive-agent-orchestrator.js.map +7 -0
- package/dist/src/skills/repo-ingestion-skill.js +609 -0
- package/dist/src/skills/repo-ingestion-skill.js.map +7 -0
- package/dist/src/skills/unified-rlm-orchestrator.js +404 -0
- package/dist/src/skills/unified-rlm-orchestrator.js.map +7 -0
- package/dist/src/types/task.js +5 -0
- package/dist/src/types/task.js.map +7 -0
- package/dist/src/utils/env.js +50 -0
- package/dist/src/utils/env.js.map +7 -0
- package/dist/src/utils/formatting.js +62 -0
- package/dist/src/utils/formatting.js.map +7 -0
- package/dist/src/utils/process-cleanup.js +136 -0
- package/dist/src/utils/process-cleanup.js.map +7 -0
- package/package.json +4 -3
- package/scripts/create-cleanup-issues.js +302 -0
- package/scripts/demos/browser-test.ts +39 -0
- package/scripts/demos/ralph-integration-demo.ts +244 -0
- package/scripts/demos/trace-demo.ts +214 -0
- package/scripts/demos/trace-detector.demo.ts +171 -0
- package/scripts/demos/trace-test.ts +67 -0
- package/scripts/initialize.ts +16 -7
- package/scripts/install.sh +14 -62
- package/scripts/status.ts +111 -46
- package/scripts/test-claude-config.sh +123 -0
- package/scripts/validate-claude-config.sh +155 -0
|
@@ -0,0 +1,764 @@
|
|
|
1
|
+
import { fileURLToPath as __fileURLToPath } from 'url';
|
|
2
|
+
import { dirname as __pathDirname } from 'path';
|
|
3
|
+
const __filename = __fileURLToPath(import.meta.url);
|
|
4
|
+
const __dirname = __pathDirname(__filename);
|
|
5
|
+
import "dotenv/config";
|
|
6
|
+
import Redis from "ioredis";
|
|
7
|
+
import { v4 as uuidv4 } from "uuid";
|
|
8
|
+
import { logger } from "../monitoring/logger.js";
|
|
9
|
+
function getEnv(key, defaultValue) {
|
|
10
|
+
const value = process.env[key];
|
|
11
|
+
if (value === void 0) {
|
|
12
|
+
if (defaultValue !== void 0) return defaultValue;
|
|
13
|
+
throw new Error(`Environment variable ${key} is required`);
|
|
14
|
+
}
|
|
15
|
+
return value;
|
|
16
|
+
}
|
|
17
|
+
function getOptionalEnv(key) {
|
|
18
|
+
return process.env[key];
|
|
19
|
+
}
|
|
20
|
+
import {
|
|
21
|
+
REDIS_KEYS,
|
|
22
|
+
CACHE_TTL,
|
|
23
|
+
calculateSkillTTL,
|
|
24
|
+
SkillSchema,
|
|
25
|
+
JournalEntrySchema
|
|
26
|
+
} from "./types.js";
|
|
27
|
+
class SkillStorageService {
|
|
28
|
+
redis;
|
|
29
|
+
userId;
|
|
30
|
+
keyPrefix;
|
|
31
|
+
enableMetrics;
|
|
32
|
+
// Metrics tracking
|
|
33
|
+
metrics = {
|
|
34
|
+
cacheHits: 0,
|
|
35
|
+
cacheMisses: 0
|
|
36
|
+
};
|
|
37
|
+
constructor(config) {
|
|
38
|
+
this.redis = new Redis(config.redisUrl);
|
|
39
|
+
this.userId = config.userId;
|
|
40
|
+
this.keyPrefix = config.keyPrefix || "sm:skills";
|
|
41
|
+
this.enableMetrics = config.enableMetrics ?? true;
|
|
42
|
+
this.redis.on("error", (err) => {
|
|
43
|
+
logger.error("Redis connection error in SkillStorage", err);
|
|
44
|
+
});
|
|
45
|
+
this.redis.on("connect", () => {
|
|
46
|
+
logger.info("SkillStorage connected to Redis");
|
|
47
|
+
});
|
|
48
|
+
logger.info("SkillStorageService initialized", {
|
|
49
|
+
userId: this.userId,
|
|
50
|
+
keyPrefix: this.keyPrefix,
|
|
51
|
+
enableMetrics: this.enableMetrics
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
key(pattern) {
|
|
55
|
+
return `${this.keyPrefix}:${pattern}`;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Get the current user ID
|
|
59
|
+
*/
|
|
60
|
+
getUserId() {
|
|
61
|
+
return this.userId;
|
|
62
|
+
}
|
|
63
|
+
// ============================================================
|
|
64
|
+
// SKILL CRUD OPERATIONS
|
|
65
|
+
// ============================================================
|
|
66
|
+
/**
|
|
67
|
+
* Create a new skill
|
|
68
|
+
*/
|
|
69
|
+
async createSkill(input) {
|
|
70
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
71
|
+
const skill = {
|
|
72
|
+
...input,
|
|
73
|
+
id: uuidv4(),
|
|
74
|
+
createdAt: now,
|
|
75
|
+
updatedAt: now,
|
|
76
|
+
validatedCount: 0
|
|
77
|
+
};
|
|
78
|
+
SkillSchema.parse(skill);
|
|
79
|
+
const pipeline = this.redis.pipeline();
|
|
80
|
+
const skillKey = this.key(REDIS_KEYS.skill(this.userId, skill.id));
|
|
81
|
+
pipeline.setex(
|
|
82
|
+
skillKey,
|
|
83
|
+
calculateSkillTTL(skill.validatedCount),
|
|
84
|
+
JSON.stringify(skill)
|
|
85
|
+
);
|
|
86
|
+
if (skill.tool) {
|
|
87
|
+
pipeline.zadd(
|
|
88
|
+
this.key(REDIS_KEYS.skillsByTool(this.userId, skill.tool)),
|
|
89
|
+
Date.now(),
|
|
90
|
+
skill.id
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
pipeline.zadd(
|
|
94
|
+
this.key(REDIS_KEYS.skillsByCategory(this.userId, skill.category)),
|
|
95
|
+
this.priorityScore(skill.priority),
|
|
96
|
+
skill.id
|
|
97
|
+
);
|
|
98
|
+
for (const tag of skill.tags) {
|
|
99
|
+
pipeline.zadd(
|
|
100
|
+
this.key(REDIS_KEYS.skillsByTag(this.userId, tag)),
|
|
101
|
+
Date.now(),
|
|
102
|
+
skill.id
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
pipeline.zadd(
|
|
106
|
+
this.key(REDIS_KEYS.skillsRecent(this.userId)),
|
|
107
|
+
Date.now(),
|
|
108
|
+
skill.id
|
|
109
|
+
);
|
|
110
|
+
pipeline.zremrangebyrank(
|
|
111
|
+
this.key(REDIS_KEYS.skillsRecent(this.userId)),
|
|
112
|
+
0,
|
|
113
|
+
-1001
|
|
114
|
+
);
|
|
115
|
+
await pipeline.exec();
|
|
116
|
+
logger.info("Created skill", {
|
|
117
|
+
userId: this.userId,
|
|
118
|
+
id: skill.id,
|
|
119
|
+
category: skill.category,
|
|
120
|
+
tool: skill.tool
|
|
121
|
+
});
|
|
122
|
+
return skill;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Get skill by ID
|
|
126
|
+
*/
|
|
127
|
+
async getSkill(id) {
|
|
128
|
+
const skillKey = this.key(REDIS_KEYS.skill(this.userId, id));
|
|
129
|
+
const data = await this.redis.get(skillKey);
|
|
130
|
+
if (!data) {
|
|
131
|
+
this.metrics.cacheMisses++;
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
this.metrics.cacheHits++;
|
|
135
|
+
return JSON.parse(data);
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Update an existing skill
|
|
139
|
+
*/
|
|
140
|
+
async updateSkill(input) {
|
|
141
|
+
const existing = await this.getSkill(input.id);
|
|
142
|
+
if (!existing) {
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
145
|
+
const updated = {
|
|
146
|
+
...existing,
|
|
147
|
+
...input,
|
|
148
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
149
|
+
};
|
|
150
|
+
SkillSchema.parse(updated);
|
|
151
|
+
const skillKey = this.key(REDIS_KEYS.skill(this.userId, updated.id));
|
|
152
|
+
await this.redis.setex(
|
|
153
|
+
skillKey,
|
|
154
|
+
calculateSkillTTL(updated.validatedCount),
|
|
155
|
+
JSON.stringify(updated)
|
|
156
|
+
);
|
|
157
|
+
logger.info("Updated skill", { userId: this.userId, id: updated.id });
|
|
158
|
+
return updated;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Validate a skill (increment validation count)
|
|
162
|
+
*/
|
|
163
|
+
async validateSkill(id) {
|
|
164
|
+
const skill = await this.getSkill(id);
|
|
165
|
+
if (!skill) {
|
|
166
|
+
return null;
|
|
167
|
+
}
|
|
168
|
+
skill.validatedCount++;
|
|
169
|
+
skill.lastValidated = (/* @__PURE__ */ new Date()).toISOString();
|
|
170
|
+
skill.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
171
|
+
const skillKey = this.key(REDIS_KEYS.skill(this.userId, id));
|
|
172
|
+
await this.redis.setex(
|
|
173
|
+
skillKey,
|
|
174
|
+
calculateSkillTTL(skill.validatedCount),
|
|
175
|
+
JSON.stringify(skill)
|
|
176
|
+
);
|
|
177
|
+
await this.redis.zadd(
|
|
178
|
+
this.key(REDIS_KEYS.skillsValidated(this.userId)),
|
|
179
|
+
skill.validatedCount,
|
|
180
|
+
id
|
|
181
|
+
);
|
|
182
|
+
if (skill.validatedCount >= 3 && skill.priority !== "critical") {
|
|
183
|
+
await this.redis.sadd(
|
|
184
|
+
this.key(REDIS_KEYS.promotionCandidates(this.userId)),
|
|
185
|
+
id
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
logger.info("Validated skill", {
|
|
189
|
+
userId: this.userId,
|
|
190
|
+
id,
|
|
191
|
+
validatedCount: skill.validatedCount
|
|
192
|
+
});
|
|
193
|
+
return skill;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Delete a skill
|
|
197
|
+
*/
|
|
198
|
+
async deleteSkill(id) {
|
|
199
|
+
const skill = await this.getSkill(id);
|
|
200
|
+
if (!skill) {
|
|
201
|
+
return false;
|
|
202
|
+
}
|
|
203
|
+
const pipeline = this.redis.pipeline();
|
|
204
|
+
const skillKey = this.key(REDIS_KEYS.skill(this.userId, id));
|
|
205
|
+
pipeline.del(skillKey);
|
|
206
|
+
if (skill.tool) {
|
|
207
|
+
pipeline.zrem(
|
|
208
|
+
this.key(REDIS_KEYS.skillsByTool(this.userId, skill.tool)),
|
|
209
|
+
id
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
pipeline.zrem(
|
|
213
|
+
this.key(REDIS_KEYS.skillsByCategory(this.userId, skill.category)),
|
|
214
|
+
id
|
|
215
|
+
);
|
|
216
|
+
for (const tag of skill.tags) {
|
|
217
|
+
pipeline.zrem(this.key(REDIS_KEYS.skillsByTag(this.userId, tag)), id);
|
|
218
|
+
}
|
|
219
|
+
pipeline.zrem(this.key(REDIS_KEYS.skillsRecent(this.userId)), id);
|
|
220
|
+
pipeline.zrem(this.key(REDIS_KEYS.skillsValidated(this.userId)), id);
|
|
221
|
+
pipeline.srem(this.key(REDIS_KEYS.promotionCandidates(this.userId)), id);
|
|
222
|
+
await pipeline.exec();
|
|
223
|
+
logger.info("Deleted skill", { userId: this.userId, id });
|
|
224
|
+
return true;
|
|
225
|
+
}
|
|
226
|
+
// ============================================================
|
|
227
|
+
// SKILL QUERIES
|
|
228
|
+
// ============================================================
|
|
229
|
+
/**
|
|
230
|
+
* Query skills with filters
|
|
231
|
+
*/
|
|
232
|
+
async querySkills(query) {
|
|
233
|
+
let skillIds = [];
|
|
234
|
+
if (query.tool) {
|
|
235
|
+
skillIds = await this.redis.zrevrange(
|
|
236
|
+
this.key(REDIS_KEYS.skillsByTool(this.userId, query.tool)),
|
|
237
|
+
0,
|
|
238
|
+
-1
|
|
239
|
+
);
|
|
240
|
+
} else if (query.categories && query.categories.length === 1) {
|
|
241
|
+
skillIds = await this.redis.zrevrange(
|
|
242
|
+
this.key(REDIS_KEYS.skillsByCategory(this.userId, query.categories[0])),
|
|
243
|
+
0,
|
|
244
|
+
-1
|
|
245
|
+
);
|
|
246
|
+
} else if (query.tags && query.tags.length === 1) {
|
|
247
|
+
skillIds = await this.redis.zrevrange(
|
|
248
|
+
this.key(REDIS_KEYS.skillsByTag(this.userId, query.tags[0])),
|
|
249
|
+
0,
|
|
250
|
+
-1
|
|
251
|
+
);
|
|
252
|
+
} else {
|
|
253
|
+
skillIds = await this.redis.zrevrange(
|
|
254
|
+
this.key(REDIS_KEYS.skillsRecent(this.userId)),
|
|
255
|
+
0,
|
|
256
|
+
query.limit + query.offset
|
|
257
|
+
);
|
|
258
|
+
}
|
|
259
|
+
if (skillIds.length === 0) {
|
|
260
|
+
return [];
|
|
261
|
+
}
|
|
262
|
+
const pipeline = this.redis.pipeline();
|
|
263
|
+
for (const id of skillIds) {
|
|
264
|
+
pipeline.get(this.key(REDIS_KEYS.skill(this.userId, id)));
|
|
265
|
+
}
|
|
266
|
+
const results = await pipeline.exec();
|
|
267
|
+
if (!results) {
|
|
268
|
+
return [];
|
|
269
|
+
}
|
|
270
|
+
let skills = results.map(([err, data]) => {
|
|
271
|
+
if (err || !data) return null;
|
|
272
|
+
try {
|
|
273
|
+
return JSON.parse(data);
|
|
274
|
+
} catch {
|
|
275
|
+
return null;
|
|
276
|
+
}
|
|
277
|
+
}).filter((s) => s !== null);
|
|
278
|
+
if (query.categories && query.categories.length > 0) {
|
|
279
|
+
skills = skills.filter((s) => query.categories.includes(s.category));
|
|
280
|
+
}
|
|
281
|
+
if (query.priorities && query.priorities.length > 0) {
|
|
282
|
+
skills = skills.filter((s) => query.priorities.includes(s.priority));
|
|
283
|
+
}
|
|
284
|
+
if (query.minValidatedCount !== void 0) {
|
|
285
|
+
skills = skills.filter(
|
|
286
|
+
(s) => s.validatedCount >= query.minValidatedCount
|
|
287
|
+
);
|
|
288
|
+
}
|
|
289
|
+
if (query.language) {
|
|
290
|
+
skills = skills.filter((s) => s.language === query.language);
|
|
291
|
+
}
|
|
292
|
+
if (query.framework) {
|
|
293
|
+
skills = skills.filter((s) => s.framework === query.framework);
|
|
294
|
+
}
|
|
295
|
+
skills.sort((a, b) => {
|
|
296
|
+
let aVal, bVal;
|
|
297
|
+
switch (query.sortBy) {
|
|
298
|
+
case "priority":
|
|
299
|
+
aVal = this.priorityScore(a.priority);
|
|
300
|
+
bVal = this.priorityScore(b.priority);
|
|
301
|
+
break;
|
|
302
|
+
case "validatedCount":
|
|
303
|
+
aVal = a.validatedCount;
|
|
304
|
+
bVal = b.validatedCount;
|
|
305
|
+
break;
|
|
306
|
+
case "createdAt":
|
|
307
|
+
aVal = new Date(a.createdAt).getTime();
|
|
308
|
+
bVal = new Date(b.createdAt).getTime();
|
|
309
|
+
break;
|
|
310
|
+
case "updatedAt":
|
|
311
|
+
aVal = new Date(a.updatedAt).getTime();
|
|
312
|
+
bVal = new Date(b.updatedAt).getTime();
|
|
313
|
+
break;
|
|
314
|
+
default:
|
|
315
|
+
aVal = this.priorityScore(a.priority);
|
|
316
|
+
bVal = this.priorityScore(b.priority);
|
|
317
|
+
}
|
|
318
|
+
return query.sortOrder === "desc" ? bVal - aVal : aVal - bVal;
|
|
319
|
+
});
|
|
320
|
+
return skills.slice(query.offset, query.offset + query.limit);
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Get skills relevant to current context
|
|
324
|
+
*/
|
|
325
|
+
async getRelevantSkills(context) {
|
|
326
|
+
const skills = [];
|
|
327
|
+
const seenIds = /* @__PURE__ */ new Set();
|
|
328
|
+
const criticalIds = await this.redis.zrevrange(
|
|
329
|
+
this.key(REDIS_KEYS.skillsByCategory(this.userId, "correction")),
|
|
330
|
+
0,
|
|
331
|
+
-1
|
|
332
|
+
);
|
|
333
|
+
for (const id of criticalIds) {
|
|
334
|
+
const skill = await this.getSkill(id);
|
|
335
|
+
if (skill && skill.priority === "critical" && !seenIds.has(id)) {
|
|
336
|
+
skills.push(skill);
|
|
337
|
+
seenIds.add(id);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
if (context.tool) {
|
|
341
|
+
const toolSkills = await this.querySkills({
|
|
342
|
+
tool: context.tool,
|
|
343
|
+
limit: 20,
|
|
344
|
+
offset: 0,
|
|
345
|
+
sortBy: "priority",
|
|
346
|
+
sortOrder: "desc"
|
|
347
|
+
});
|
|
348
|
+
for (const skill of toolSkills) {
|
|
349
|
+
if (!seenIds.has(skill.id)) {
|
|
350
|
+
skills.push(skill);
|
|
351
|
+
seenIds.add(skill.id);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
const validatedIds = await this.redis.zrevrange(
|
|
356
|
+
this.key(REDIS_KEYS.skillsValidated(this.userId)),
|
|
357
|
+
0,
|
|
358
|
+
10
|
|
359
|
+
);
|
|
360
|
+
for (const id of validatedIds) {
|
|
361
|
+
if (!seenIds.has(id)) {
|
|
362
|
+
const skill = await this.getSkill(id);
|
|
363
|
+
if (skill) {
|
|
364
|
+
skills.push(skill);
|
|
365
|
+
seenIds.add(id);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
return skills.slice(0, 50);
|
|
370
|
+
}
|
|
371
|
+
// ============================================================
|
|
372
|
+
// SESSION JOURNAL
|
|
373
|
+
// ============================================================
|
|
374
|
+
/**
|
|
375
|
+
* Create a journal entry
|
|
376
|
+
*/
|
|
377
|
+
async createJournalEntry(sessionId, type, title, content, context) {
|
|
378
|
+
const entry = {
|
|
379
|
+
id: uuidv4(),
|
|
380
|
+
sessionId,
|
|
381
|
+
type,
|
|
382
|
+
title,
|
|
383
|
+
content,
|
|
384
|
+
context,
|
|
385
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
386
|
+
};
|
|
387
|
+
JournalEntrySchema.parse(entry);
|
|
388
|
+
const pipeline = this.redis.pipeline();
|
|
389
|
+
pipeline.setex(
|
|
390
|
+
this.key(REDIS_KEYS.journalEntry(this.userId, entry.id)),
|
|
391
|
+
CACHE_TTL.journal,
|
|
392
|
+
JSON.stringify(entry)
|
|
393
|
+
);
|
|
394
|
+
pipeline.zadd(
|
|
395
|
+
this.key(REDIS_KEYS.journalSession(this.userId, sessionId)),
|
|
396
|
+
Date.now(),
|
|
397
|
+
entry.id
|
|
398
|
+
);
|
|
399
|
+
pipeline.zadd(
|
|
400
|
+
this.key(REDIS_KEYS.journalRecent(this.userId)),
|
|
401
|
+
Date.now(),
|
|
402
|
+
entry.id
|
|
403
|
+
);
|
|
404
|
+
pipeline.zremrangebyrank(
|
|
405
|
+
this.key(REDIS_KEYS.journalRecent(this.userId)),
|
|
406
|
+
0,
|
|
407
|
+
-501
|
|
408
|
+
);
|
|
409
|
+
await pipeline.exec();
|
|
410
|
+
logger.info("Created journal entry", {
|
|
411
|
+
userId: this.userId,
|
|
412
|
+
id: entry.id,
|
|
413
|
+
sessionId,
|
|
414
|
+
type,
|
|
415
|
+
title
|
|
416
|
+
});
|
|
417
|
+
return entry;
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* Get journal entries for a session
|
|
421
|
+
*/
|
|
422
|
+
async getSessionJournal(sessionId) {
|
|
423
|
+
const entryIds = await this.redis.zrevrange(
|
|
424
|
+
this.key(REDIS_KEYS.journalSession(this.userId, sessionId)),
|
|
425
|
+
0,
|
|
426
|
+
-1
|
|
427
|
+
);
|
|
428
|
+
if (entryIds.length === 0) {
|
|
429
|
+
return [];
|
|
430
|
+
}
|
|
431
|
+
const pipeline = this.redis.pipeline();
|
|
432
|
+
for (const id of entryIds) {
|
|
433
|
+
pipeline.get(this.key(REDIS_KEYS.journalEntry(this.userId, id)));
|
|
434
|
+
}
|
|
435
|
+
const results = await pipeline.exec();
|
|
436
|
+
if (!results) {
|
|
437
|
+
return [];
|
|
438
|
+
}
|
|
439
|
+
return results.map(([err, data]) => {
|
|
440
|
+
if (err || !data) return null;
|
|
441
|
+
try {
|
|
442
|
+
return JSON.parse(data);
|
|
443
|
+
} catch {
|
|
444
|
+
return null;
|
|
445
|
+
}
|
|
446
|
+
}).filter((e) => e !== null);
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* Promote a journal entry to a skill
|
|
450
|
+
*/
|
|
451
|
+
async promoteToSkill(entryId, category, priority = "medium") {
|
|
452
|
+
const entryData = await this.redis.get(
|
|
453
|
+
this.key(REDIS_KEYS.journalEntry(this.userId, entryId))
|
|
454
|
+
);
|
|
455
|
+
if (!entryData) {
|
|
456
|
+
return null;
|
|
457
|
+
}
|
|
458
|
+
const entry = JSON.parse(entryData);
|
|
459
|
+
const skill = await this.createSkill({
|
|
460
|
+
content: entry.content,
|
|
461
|
+
summary: entry.title,
|
|
462
|
+
category,
|
|
463
|
+
priority,
|
|
464
|
+
tags: [],
|
|
465
|
+
tool: entry.context?.tool,
|
|
466
|
+
source: "observation",
|
|
467
|
+
sessionId: entry.sessionId
|
|
468
|
+
});
|
|
469
|
+
entry.promotedToSkillId = skill.id;
|
|
470
|
+
await this.redis.setex(
|
|
471
|
+
this.key(REDIS_KEYS.journalEntry(this.userId, entryId)),
|
|
472
|
+
CACHE_TTL.journal,
|
|
473
|
+
JSON.stringify(entry)
|
|
474
|
+
);
|
|
475
|
+
logger.info("Promoted journal entry to skill", {
|
|
476
|
+
userId: this.userId,
|
|
477
|
+
entryId,
|
|
478
|
+
skillId: skill.id
|
|
479
|
+
});
|
|
480
|
+
return skill;
|
|
481
|
+
}
|
|
482
|
+
// ============================================================
|
|
483
|
+
// SESSION MANAGEMENT
|
|
484
|
+
// ============================================================
|
|
485
|
+
/**
|
|
486
|
+
* Start tracking a new session
|
|
487
|
+
*/
|
|
488
|
+
async startSession(sessionId) {
|
|
489
|
+
const summary = {
|
|
490
|
+
sessionId,
|
|
491
|
+
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
492
|
+
entriesCount: 0,
|
|
493
|
+
correctionsCount: 0,
|
|
494
|
+
decisionsCount: 0,
|
|
495
|
+
keyLearnings: [],
|
|
496
|
+
promotedSkillIds: []
|
|
497
|
+
};
|
|
498
|
+
await this.redis.setex(
|
|
499
|
+
this.key(REDIS_KEYS.sessionSummary(this.userId, sessionId)),
|
|
500
|
+
CACHE_TTL.session,
|
|
501
|
+
JSON.stringify(summary)
|
|
502
|
+
);
|
|
503
|
+
await this.redis.sadd(
|
|
504
|
+
this.key(REDIS_KEYS.sessionsActive(this.userId)),
|
|
505
|
+
sessionId
|
|
506
|
+
);
|
|
507
|
+
logger.info("Started session tracking", { userId: this.userId, sessionId });
|
|
508
|
+
}
|
|
509
|
+
/**
|
|
510
|
+
* End a session and generate summary
|
|
511
|
+
*/
|
|
512
|
+
async endSession(sessionId) {
|
|
513
|
+
const summaryData = await this.redis.get(
|
|
514
|
+
this.key(REDIS_KEYS.sessionSummary(this.userId, sessionId))
|
|
515
|
+
);
|
|
516
|
+
if (!summaryData) {
|
|
517
|
+
return null;
|
|
518
|
+
}
|
|
519
|
+
const summary = JSON.parse(summaryData);
|
|
520
|
+
summary.endedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
521
|
+
const entries = await this.getSessionJournal(sessionId);
|
|
522
|
+
summary.entriesCount = entries.length;
|
|
523
|
+
summary.correctionsCount = entries.filter(
|
|
524
|
+
(e) => e.type === "correction"
|
|
525
|
+
).length;
|
|
526
|
+
summary.decisionsCount = entries.filter(
|
|
527
|
+
(e) => e.type === "decision"
|
|
528
|
+
).length;
|
|
529
|
+
summary.keyLearnings = entries.filter((e) => e.type === "correction" || e.type === "resolution").slice(0, 5).map((e) => e.title);
|
|
530
|
+
summary.promotedSkillIds = entries.filter((e) => e.promotedToSkillId).map((e) => e.promotedToSkillId);
|
|
531
|
+
await this.redis.setex(
|
|
532
|
+
this.key(REDIS_KEYS.sessionSummary(this.userId, sessionId)),
|
|
533
|
+
CACHE_TTL.session,
|
|
534
|
+
JSON.stringify(summary)
|
|
535
|
+
);
|
|
536
|
+
await this.redis.srem(
|
|
537
|
+
this.key(REDIS_KEYS.sessionsActive(this.userId)),
|
|
538
|
+
sessionId
|
|
539
|
+
);
|
|
540
|
+
logger.info("Ended session", {
|
|
541
|
+
userId: this.userId,
|
|
542
|
+
sessionId,
|
|
543
|
+
entriesCount: summary.entriesCount,
|
|
544
|
+
keyLearnings: summary.keyLearnings.length
|
|
545
|
+
});
|
|
546
|
+
return summary;
|
|
547
|
+
}
|
|
548
|
+
/**
|
|
549
|
+
* Get session summary
|
|
550
|
+
*/
|
|
551
|
+
async getSessionSummary(sessionId) {
|
|
552
|
+
const data = await this.redis.get(
|
|
553
|
+
this.key(REDIS_KEYS.sessionSummary(this.userId, sessionId))
|
|
554
|
+
);
|
|
555
|
+
if (!data) {
|
|
556
|
+
return null;
|
|
557
|
+
}
|
|
558
|
+
return JSON.parse(data);
|
|
559
|
+
}
|
|
560
|
+
// ============================================================
|
|
561
|
+
// KNOWLEDGE HYGIENE
|
|
562
|
+
// ============================================================
|
|
563
|
+
/**
|
|
564
|
+
* Get skills eligible for promotion
|
|
565
|
+
*/
|
|
566
|
+
async getPromotionCandidates() {
|
|
567
|
+
const ids = await this.redis.smembers(
|
|
568
|
+
this.key(REDIS_KEYS.promotionCandidates(this.userId))
|
|
569
|
+
);
|
|
570
|
+
const skills = [];
|
|
571
|
+
for (const id of ids) {
|
|
572
|
+
const skill = await this.getSkill(id);
|
|
573
|
+
if (skill && skill.validatedCount >= 3) {
|
|
574
|
+
skills.push(skill);
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
return skills;
|
|
578
|
+
}
|
|
579
|
+
/**
|
|
580
|
+
* Promote a skill (increase priority)
|
|
581
|
+
*/
|
|
582
|
+
async promoteSkill(id) {
|
|
583
|
+
const skill = await this.getSkill(id);
|
|
584
|
+
if (!skill) {
|
|
585
|
+
return null;
|
|
586
|
+
}
|
|
587
|
+
const priorityOrder = [
|
|
588
|
+
"low",
|
|
589
|
+
"medium",
|
|
590
|
+
"high",
|
|
591
|
+
"critical"
|
|
592
|
+
];
|
|
593
|
+
const currentIndex = priorityOrder.indexOf(skill.priority);
|
|
594
|
+
if (currentIndex < priorityOrder.length - 1) {
|
|
595
|
+
skill.priority = priorityOrder[currentIndex + 1];
|
|
596
|
+
skill.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
597
|
+
await this.redis.setex(
|
|
598
|
+
this.key(REDIS_KEYS.skill(this.userId, id)),
|
|
599
|
+
calculateSkillTTL(skill.validatedCount),
|
|
600
|
+
JSON.stringify(skill)
|
|
601
|
+
);
|
|
602
|
+
await this.redis.zadd(
|
|
603
|
+
this.key(REDIS_KEYS.skillsByCategory(this.userId, skill.category)),
|
|
604
|
+
this.priorityScore(skill.priority),
|
|
605
|
+
id
|
|
606
|
+
);
|
|
607
|
+
if (skill.priority === "critical") {
|
|
608
|
+
await this.redis.srem(
|
|
609
|
+
this.key(REDIS_KEYS.promotionCandidates(this.userId)),
|
|
610
|
+
id
|
|
611
|
+
);
|
|
612
|
+
}
|
|
613
|
+
logger.info("Promoted skill", {
|
|
614
|
+
userId: this.userId,
|
|
615
|
+
id,
|
|
616
|
+
newPriority: skill.priority
|
|
617
|
+
});
|
|
618
|
+
}
|
|
619
|
+
return skill;
|
|
620
|
+
}
|
|
621
|
+
/**
|
|
622
|
+
* Archive stale skills (not validated in 90 days)
|
|
623
|
+
*/
|
|
624
|
+
async archiveStaleSkills(daysThreshold = 90) {
|
|
625
|
+
const cutoff = Date.now() - daysThreshold * 24 * 60 * 60 * 1e3;
|
|
626
|
+
let archivedCount = 0;
|
|
627
|
+
const skillIds = await this.redis.zrangebyscore(
|
|
628
|
+
this.key(REDIS_KEYS.skillsRecent(this.userId)),
|
|
629
|
+
0,
|
|
630
|
+
cutoff
|
|
631
|
+
);
|
|
632
|
+
for (const id of skillIds) {
|
|
633
|
+
const skill = await this.getSkill(id);
|
|
634
|
+
if (skill && skill.priority !== "critical") {
|
|
635
|
+
if (!skill.lastValidated || new Date(skill.lastValidated).getTime() < cutoff) {
|
|
636
|
+
if (skill.priority !== "low") {
|
|
637
|
+
skill.priority = "low";
|
|
638
|
+
skill.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
639
|
+
await this.redis.setex(
|
|
640
|
+
this.key(REDIS_KEYS.skill(this.userId, id)),
|
|
641
|
+
calculateSkillTTL(skill.validatedCount),
|
|
642
|
+
JSON.stringify(skill)
|
|
643
|
+
);
|
|
644
|
+
archivedCount++;
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
logger.info("Archived stale skills", {
|
|
650
|
+
userId: this.userId,
|
|
651
|
+
archivedCount,
|
|
652
|
+
daysThreshold
|
|
653
|
+
});
|
|
654
|
+
return archivedCount;
|
|
655
|
+
}
|
|
656
|
+
// ============================================================
|
|
657
|
+
// METRICS & UTILITIES
|
|
658
|
+
// ============================================================
|
|
659
|
+
/**
|
|
660
|
+
* Get storage metrics
|
|
661
|
+
*/
|
|
662
|
+
async getMetrics() {
|
|
663
|
+
const [
|
|
664
|
+
skillsTotal,
|
|
665
|
+
toolSkills,
|
|
666
|
+
workflowSkills,
|
|
667
|
+
correctionSkills,
|
|
668
|
+
patternSkills,
|
|
669
|
+
preferenceSkills,
|
|
670
|
+
pitfallSkills,
|
|
671
|
+
optimizationSkills,
|
|
672
|
+
journalTotal,
|
|
673
|
+
sessionsActive
|
|
674
|
+
] = await Promise.all([
|
|
675
|
+
this.redis.zcard(this.key(REDIS_KEYS.skillsRecent(this.userId))),
|
|
676
|
+
this.redis.zcard(
|
|
677
|
+
this.key(REDIS_KEYS.skillsByCategory(this.userId, "tool"))
|
|
678
|
+
),
|
|
679
|
+
this.redis.zcard(
|
|
680
|
+
this.key(REDIS_KEYS.skillsByCategory(this.userId, "workflow"))
|
|
681
|
+
),
|
|
682
|
+
this.redis.zcard(
|
|
683
|
+
this.key(REDIS_KEYS.skillsByCategory(this.userId, "correction"))
|
|
684
|
+
),
|
|
685
|
+
this.redis.zcard(
|
|
686
|
+
this.key(REDIS_KEYS.skillsByCategory(this.userId, "pattern"))
|
|
687
|
+
),
|
|
688
|
+
this.redis.zcard(
|
|
689
|
+
this.key(REDIS_KEYS.skillsByCategory(this.userId, "preference"))
|
|
690
|
+
),
|
|
691
|
+
this.redis.zcard(
|
|
692
|
+
this.key(REDIS_KEYS.skillsByCategory(this.userId, "pitfall"))
|
|
693
|
+
),
|
|
694
|
+
this.redis.zcard(
|
|
695
|
+
this.key(REDIS_KEYS.skillsByCategory(this.userId, "optimization"))
|
|
696
|
+
),
|
|
697
|
+
this.redis.zcard(this.key(REDIS_KEYS.journalRecent(this.userId))),
|
|
698
|
+
this.redis.scard(this.key(REDIS_KEYS.sessionsActive(this.userId)))
|
|
699
|
+
]);
|
|
700
|
+
return {
|
|
701
|
+
userId: this.userId,
|
|
702
|
+
skillsTotal,
|
|
703
|
+
skillsByCategory: {
|
|
704
|
+
tool: toolSkills,
|
|
705
|
+
workflow: workflowSkills,
|
|
706
|
+
correction: correctionSkills,
|
|
707
|
+
pattern: patternSkills,
|
|
708
|
+
preference: preferenceSkills,
|
|
709
|
+
pitfall: pitfallSkills,
|
|
710
|
+
optimization: optimizationSkills
|
|
711
|
+
},
|
|
712
|
+
journalEntriesTotal: journalTotal,
|
|
713
|
+
sessionsTracked: sessionsActive,
|
|
714
|
+
cacheHits: this.metrics.cacheHits,
|
|
715
|
+
cacheMisses: this.metrics.cacheMisses
|
|
716
|
+
};
|
|
717
|
+
}
|
|
718
|
+
/**
|
|
719
|
+
* Priority to numeric score for sorting
|
|
720
|
+
*/
|
|
721
|
+
priorityScore(priority) {
|
|
722
|
+
const scores = {
|
|
723
|
+
critical: 1e3,
|
|
724
|
+
high: 100,
|
|
725
|
+
medium: 10,
|
|
726
|
+
low: 1
|
|
727
|
+
};
|
|
728
|
+
return scores[priority];
|
|
729
|
+
}
|
|
730
|
+
/**
|
|
731
|
+
* Close Redis connection
|
|
732
|
+
*/
|
|
733
|
+
async close() {
|
|
734
|
+
await this.redis.quit();
|
|
735
|
+
logger.info("SkillStorageService closed");
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
const userStorageInstances = /* @__PURE__ */ new Map();
|
|
739
|
+
function getSkillStorage(config) {
|
|
740
|
+
const existing = userStorageInstances.get(config.userId);
|
|
741
|
+
if (existing) {
|
|
742
|
+
return existing;
|
|
743
|
+
}
|
|
744
|
+
const instance = new SkillStorageService(config);
|
|
745
|
+
userStorageInstances.set(config.userId, instance);
|
|
746
|
+
return instance;
|
|
747
|
+
}
|
|
748
|
+
function initializeSkillStorage(userId, redisUrl) {
|
|
749
|
+
const url = redisUrl || process.env["REDIS_URL"];
|
|
750
|
+
if (!url) {
|
|
751
|
+
throw new Error("REDIS_URL environment variable not set");
|
|
752
|
+
}
|
|
753
|
+
return getSkillStorage({ redisUrl: url, userId });
|
|
754
|
+
}
|
|
755
|
+
function getDefaultUserId() {
|
|
756
|
+
return process.env["STACKMEMORY_USER_ID"] || process.env["USER"] || process.env["USERNAME"] || "default";
|
|
757
|
+
}
|
|
758
|
+
export {
|
|
759
|
+
SkillStorageService,
|
|
760
|
+
getDefaultUserId,
|
|
761
|
+
getSkillStorage,
|
|
762
|
+
initializeSkillStorage
|
|
763
|
+
};
|
|
764
|
+
//# sourceMappingURL=skill-storage.js.map
|