@stackmemoryai/stackmemory 0.5.59 → 0.5.61
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 +105 -1
- package/dist/src/cli/claude-sm.js +130 -50
- package/dist/src/cli/claude-sm.js.map +2 -2
- package/dist/src/cli/index.js +18 -3
- package/dist/src/cli/index.js.map +3 -3
- package/dist/src/core/extensions/custom-tools.js +567 -0
- package/dist/src/core/extensions/custom-tools.js.map +7 -0
- package/dist/src/core/extensions/index.js +55 -0
- package/dist/src/core/extensions/index.js.map +7 -0
- package/dist/src/core/extensions/loader.js +709 -0
- package/dist/src/core/extensions/loader.js.map +7 -0
- package/dist/src/core/extensions/plugin-system.js +506 -0
- package/dist/src/core/extensions/plugin-system.js.map +7 -0
- package/dist/src/core/extensions/provider-adapter.js +617 -0
- package/dist/src/core/extensions/provider-adapter.js.map +7 -0
- package/dist/src/core/extensions/sandbox-runtime.js +664 -0
- package/dist/src/core/extensions/sandbox-runtime.js.map +7 -0
- package/dist/src/core/storage/chromadb-adapter.js +32 -6
- package/dist/src/core/storage/chromadb-adapter.js.map +2 -2
- package/dist/src/skills/repo-ingestion-skill.js +35 -12
- package/dist/src/skills/repo-ingestion-skill.js.map +2 -2
- package/package.json +11 -7
- package/scripts/background-sync-manager.js +145 -83
- package/scripts/claude-sm-autostart.js +17 -12
- package/scripts/gepa/README.md +275 -0
- package/scripts/gepa/config.json +53 -0
- package/scripts/gepa/evals/coding-tasks.jsonl +5 -0
- package/scripts/gepa/evals/fixtures/buggy-loop.js +18 -0
- package/scripts/gepa/evals/fixtures/callback-hell.js +53 -0
- package/scripts/gepa/generations/gen-000/baseline.md +124 -0
- package/scripts/gepa/hooks/auto-optimize.js +494 -0
- package/scripts/gepa/hooks/eval-tracker.js +203 -0
- package/scripts/gepa/hooks/reflect.js +311 -0
- package/scripts/gepa/optimize.js +611 -0
- package/scripts/gepa/state.json +14 -0
- package/scripts/test-pre-publish-quick.sh +1 -1
- package/dist/agents/core/agent-task-manager.js +0 -527
- package/dist/agents/core/agent-task-manager.js.map +0 -7
- package/dist/agents/testing-agent.js +0 -614
- package/dist/agents/testing-agent.js.map +0 -7
- package/dist/agents/verifiers/base-verifier.js +0 -133
- package/dist/agents/verifiers/base-verifier.js.map +0 -7
- package/dist/agents/verifiers/formatter-verifier.js +0 -130
- package/dist/agents/verifiers/formatter-verifier.js.map +0 -7
- package/dist/agents/verifiers/llm-judge.js +0 -252
- package/dist/agents/verifiers/llm-judge.js.map +0 -7
- package/dist/cli/auto-detect.js +0 -321
- package/dist/cli/auto-detect.js.map +0 -7
- package/dist/cli/browser-test.js +0 -33
- package/dist/cli/browser-test.js.map +0 -7
- package/dist/cli/claude-sm-danger.js +0 -21
- package/dist/cli/claude-sm-danger.js.map +0 -7
- package/dist/cli/claude-sm.js +0 -1156
- package/dist/cli/claude-sm.js.map +0 -7
- package/dist/cli/codex-sm-danger.js +0 -21
- package/dist/cli/codex-sm-danger.js.map +0 -7
- package/dist/cli/codex-sm.js +0 -349
- package/dist/cli/codex-sm.js.map +0 -7
- package/dist/cli/commands/api.js +0 -232
- package/dist/cli/commands/api.js.map +0 -7
- package/dist/cli/commands/auto-background.js +0 -180
- package/dist/cli/commands/auto-background.js.map +0 -7
- package/dist/cli/commands/cleanup-processes.js +0 -68
- package/dist/cli/commands/cleanup-processes.js.map +0 -7
- package/dist/cli/commands/clear.js +0 -202
- package/dist/cli/commands/clear.js.map +0 -7
- package/dist/cli/commands/config.js +0 -445
- package/dist/cli/commands/config.js.map +0 -7
- package/dist/cli/commands/context-rehydrate.js +0 -751
- package/dist/cli/commands/context-rehydrate.js.map +0 -7
- package/dist/cli/commands/context.js +0 -343
- package/dist/cli/commands/context.js.map +0 -7
- package/dist/cli/commands/daemon.js +0 -392
- package/dist/cli/commands/daemon.js.map +0 -7
- package/dist/cli/commands/dashboard.js +0 -210
- package/dist/cli/commands/dashboard.js.map +0 -7
- package/dist/cli/commands/db.js +0 -147
- package/dist/cli/commands/db.js.map +0 -7
- package/dist/cli/commands/decision.js +0 -266
- package/dist/cli/commands/decision.js.map +0 -7
- package/dist/cli/commands/discovery.js +0 -279
- package/dist/cli/commands/discovery.js.map +0 -7
- package/dist/cli/commands/handoff.js +0 -624
- package/dist/cli/commands/handoff.js.map +0 -7
- package/dist/cli/commands/hooks.js +0 -298
- package/dist/cli/commands/hooks.js.map +0 -7
- package/dist/cli/commands/linear-unified.js +0 -353
- package/dist/cli/commands/linear-unified.js.map +0 -7
- package/dist/cli/commands/linear.js +0 -529
- package/dist/cli/commands/linear.js.map +0 -7
- package/dist/cli/commands/log.js +0 -169
- package/dist/cli/commands/log.js.map +0 -7
- package/dist/cli/commands/login.js +0 -172
- package/dist/cli/commands/login.js.map +0 -7
- package/dist/cli/commands/migrate.js +0 -240
- package/dist/cli/commands/migrate.js.map +0 -7
- package/dist/cli/commands/model.js +0 -533
- package/dist/cli/commands/model.js.map +0 -7
- package/dist/cli/commands/monitor.js +0 -313
- package/dist/cli/commands/monitor.js.map +0 -7
- package/dist/cli/commands/onboard.js +0 -536
- package/dist/cli/commands/onboard.js.map +0 -7
- package/dist/cli/commands/projects.js +0 -199
- package/dist/cli/commands/projects.js.map +0 -7
- package/dist/cli/commands/quality.js +0 -413
- package/dist/cli/commands/quality.js.map +0 -7
- package/dist/cli/commands/ralph.js +0 -909
- package/dist/cli/commands/ralph.js.map +0 -7
- package/dist/cli/commands/retrieval.js +0 -248
- package/dist/cli/commands/retrieval.js.map +0 -7
- package/dist/cli/commands/search.js +0 -173
- package/dist/cli/commands/search.js.map +0 -7
- package/dist/cli/commands/service.js +0 -749
- package/dist/cli/commands/service.js.map +0 -7
- package/dist/cli/commands/session.js +0 -200
- package/dist/cli/commands/session.js.map +0 -7
- package/dist/cli/commands/settings.js +0 -306
- package/dist/cli/commands/settings.js.map +0 -7
- package/dist/cli/commands/setup.js +0 -701
- package/dist/cli/commands/setup.js.map +0 -7
- package/dist/cli/commands/shell.js +0 -249
- package/dist/cli/commands/shell.js.map +0 -7
- package/dist/cli/commands/signup.js +0 -50
- package/dist/cli/commands/signup.js.map +0 -7
- package/dist/cli/commands/skills.js +0 -470
- package/dist/cli/commands/skills.js.map +0 -7
- package/dist/cli/commands/sms-notify.js +0 -795
- package/dist/cli/commands/sms-notify.js.map +0 -7
- package/dist/cli/commands/storage-tier.js +0 -183
- package/dist/cli/commands/storage-tier.js.map +0 -7
- package/dist/cli/commands/storage.js +0 -360
- package/dist/cli/commands/storage.js.map +0 -7
- package/dist/cli/commands/sweep.js +0 -249
- package/dist/cli/commands/sweep.js.map +0 -7
- package/dist/cli/commands/tasks.js +0 -213
- package/dist/cli/commands/tasks.js.map +0 -7
- package/dist/cli/commands/test.js +0 -286
- package/dist/cli/commands/test.js.map +0 -7
- package/dist/cli/commands/workflow.js +0 -142
- package/dist/cli/commands/workflow.js.map +0 -7
- package/dist/cli/commands/worktree.js +0 -319
- package/dist/cli/commands/worktree.js.map +0 -7
- package/dist/cli/index.js +0 -594
- package/dist/cli/index.js.map +0 -7
- package/dist/cli/opencode-sm.js +0 -448
- package/dist/cli/opencode-sm.js.map +0 -7
- package/dist/cli/utils/viewer.js +0 -96
- package/dist/cli/utils/viewer.js.map +0 -7
- package/dist/core/analytics/team-analytics.js +0 -378
- package/dist/core/analytics/team-analytics.js.map +0 -7
- package/dist/core/config/config-manager.js +0 -398
- package/dist/core/config/config-manager.js.map +0 -7
- package/dist/core/config/feature-flags.js +0 -76
- package/dist/core/config/feature-flags.js.map +0 -7
- package/dist/core/config/storage-config.js +0 -115
- package/dist/core/config/storage-config.js.map +0 -7
- package/dist/core/config/types.js +0 -144
- package/dist/core/config/types.js.map +0 -7
- package/dist/core/context/auto-context.js +0 -80
- package/dist/core/context/auto-context.js.map +0 -7
- package/dist/core/context/dual-stack-manager.js +0 -870
- package/dist/core/context/dual-stack-manager.js.map +0 -7
- package/dist/core/context/enhanced-rehydration.js +0 -994
- package/dist/core/context/enhanced-rehydration.js.map +0 -7
- package/dist/core/context/frame-database.js +0 -479
- package/dist/core/context/frame-database.js.map +0 -7
- package/dist/core/context/frame-digest.js +0 -250
- package/dist/core/context/frame-digest.js.map +0 -7
- package/dist/core/context/frame-handoff-manager.js +0 -778
- package/dist/core/context/frame-handoff-manager.js.map +0 -7
- package/dist/core/context/frame-lifecycle-hooks.js +0 -119
- package/dist/core/context/frame-lifecycle-hooks.js.map +0 -7
- package/dist/core/context/frame-manager.js +0 -1069
- package/dist/core/context/frame-manager.js.map +0 -7
- package/dist/core/context/frame-recovery.js +0 -302
- package/dist/core/context/frame-recovery.js.map +0 -7
- package/dist/core/context/frame-stack.js +0 -314
- package/dist/core/context/frame-stack.js.map +0 -7
- package/dist/core/context/frame-types.js +0 -5
- package/dist/core/context/frame-types.js.map +0 -7
- package/dist/core/context/incremental-gc.js +0 -290
- package/dist/core/context/incremental-gc.js.map +0 -7
- package/dist/core/context/index.js +0 -25
- package/dist/core/context/index.js.map +0 -7
- package/dist/core/context/model-aware-compaction.js +0 -623
- package/dist/core/context/model-aware-compaction.js.map +0 -7
- package/dist/core/context/permission-manager.js +0 -185
- package/dist/core/context/permission-manager.js.map +0 -7
- package/dist/core/context/recursive-context-manager.js +0 -592
- package/dist/core/context/recursive-context-manager.js.map +0 -7
- package/dist/core/context/refactored-frame-manager.js +0 -754
- package/dist/core/context/refactored-frame-manager.js.map +0 -7
- package/dist/core/context/shared-context-layer.js +0 -621
- package/dist/core/context/shared-context-layer.js.map +0 -7
- package/dist/core/context/stack-merge-resolver.js +0 -749
- package/dist/core/context/stack-merge-resolver.js.map +0 -7
- package/dist/core/context/validation.js +0 -130
- package/dist/core/context/validation.js.map +0 -7
- package/dist/core/database/batch-operations.js +0 -384
- package/dist/core/database/batch-operations.js.map +0 -7
- package/dist/core/database/connection-pool.js +0 -330
- package/dist/core/database/connection-pool.js.map +0 -7
- package/dist/core/database/database-adapter.js +0 -60
- package/dist/core/database/database-adapter.js.map +0 -7
- package/dist/core/database/migration-manager.js +0 -614
- package/dist/core/database/migration-manager.js.map +0 -7
- package/dist/core/database/paradedb-adapter.js +0 -990
- package/dist/core/database/paradedb-adapter.js.map +0 -7
- package/dist/core/database/query-cache.js +0 -298
- package/dist/core/database/query-cache.js.map +0 -7
- package/dist/core/database/query-router.js +0 -430
- package/dist/core/database/query-router.js.map +0 -7
- package/dist/core/database/sqlite-adapter.js +0 -738
- package/dist/core/database/sqlite-adapter.js.map +0 -7
- package/dist/core/digest/enhanced-hybrid-digest.js +0 -277
- package/dist/core/digest/enhanced-hybrid-digest.js.map +0 -7
- package/dist/core/digest/frame-digest-integration.js +0 -176
- package/dist/core/digest/frame-digest-integration.js.map +0 -7
- package/dist/core/digest/hybrid-digest-generator.js +0 -553
- package/dist/core/digest/hybrid-digest-generator.js.map +0 -7
- package/dist/core/digest/index.js +0 -9
- package/dist/core/digest/index.js.map +0 -7
- package/dist/core/digest/types.js +0 -25
- package/dist/core/digest/types.js.map +0 -7
- package/dist/core/errors/error-utils.js +0 -208
- package/dist/core/errors/error-utils.js.map +0 -7
- package/dist/core/errors/index.js +0 -521
- package/dist/core/errors/index.js.map +0 -7
- package/dist/core/errors/recovery.js +0 -269
- package/dist/core/errors/recovery.js.map +0 -7
- package/dist/core/execution/parallel-executor.js +0 -258
- package/dist/core/execution/parallel-executor.js.map +0 -7
- package/dist/core/frame/workflow-templates.js +0 -319
- package/dist/core/frame/workflow-templates.js.map +0 -7
- package/dist/core/merge/conflict-detector.js +0 -431
- package/dist/core/merge/conflict-detector.js.map +0 -7
- package/dist/core/merge/index.js +0 -9
- package/dist/core/merge/index.js.map +0 -7
- package/dist/core/merge/resolution-engine.js +0 -558
- package/dist/core/merge/resolution-engine.js.map +0 -7
- package/dist/core/merge/stack-diff.js +0 -532
- package/dist/core/merge/stack-diff.js.map +0 -7
- package/dist/core/merge/unified-merge-resolver.js +0 -303
- package/dist/core/merge/unified-merge-resolver.js.map +0 -7
- package/dist/core/models/fallback-monitor.js +0 -232
- package/dist/core/models/fallback-monitor.js.map +0 -7
- package/dist/core/models/model-router.js +0 -340
- package/dist/core/models/model-router.js.map +0 -7
- package/dist/core/monitoring/error-handler.js +0 -49
- package/dist/core/monitoring/error-handler.js.map +0 -7
- package/dist/core/monitoring/logger.js +0 -202
- package/dist/core/monitoring/logger.js.map +0 -7
- package/dist/core/monitoring/metrics.js +0 -172
- package/dist/core/monitoring/metrics.js.map +0 -7
- package/dist/core/monitoring/progress-tracker.js +0 -189
- package/dist/core/monitoring/progress-tracker.js.map +0 -7
- package/dist/core/monitoring/session-monitor.js +0 -300
- package/dist/core/monitoring/session-monitor.js.map +0 -7
- package/dist/core/performance/context-cache.js +0 -273
- package/dist/core/performance/context-cache.js.map +0 -7
- package/dist/core/performance/index.js +0 -11
- package/dist/core/performance/index.js.map +0 -7
- package/dist/core/performance/lazy-context-loader.js +0 -327
- package/dist/core/performance/lazy-context-loader.js.map +0 -7
- package/dist/core/performance/monitor.js +0 -221
- package/dist/core/performance/monitor.js.map +0 -7
- package/dist/core/performance/optimized-frame-context.js +0 -345
- package/dist/core/performance/optimized-frame-context.js.map +0 -7
- package/dist/core/performance/performance-benchmark.js +0 -277
- package/dist/core/performance/performance-benchmark.js.map +0 -7
- package/dist/core/performance/performance-profiler.js +0 -370
- package/dist/core/performance/performance-profiler.js.map +0 -7
- package/dist/core/performance/streaming-jsonl-parser.js +0 -195
- package/dist/core/performance/streaming-jsonl-parser.js.map +0 -7
- package/dist/core/persistence/postgres-adapter.js +0 -349
- package/dist/core/persistence/postgres-adapter.js.map +0 -7
- package/dist/core/projects/project-isolation.js +0 -201
- package/dist/core/projects/project-isolation.js.map +0 -7
- package/dist/core/projects/project-manager.js +0 -697
- package/dist/core/projects/project-manager.js.map +0 -7
- package/dist/core/query/query-parser.js +0 -370
- package/dist/core/query/query-parser.js.map +0 -7
- package/dist/core/query/query-templates.js +0 -321
- package/dist/core/query/query-templates.js.map +0 -7
- package/dist/core/retrieval/context-retriever.js +0 -479
- package/dist/core/retrieval/context-retriever.js.map +0 -7
- package/dist/core/retrieval/graph-retrieval.js +0 -662
- package/dist/core/retrieval/graph-retrieval.js.map +0 -7
- package/dist/core/retrieval/hierarchical-retrieval.js +0 -656
- package/dist/core/retrieval/hierarchical-retrieval.js.map +0 -7
- package/dist/core/retrieval/index.js +0 -8
- package/dist/core/retrieval/index.js.map +0 -7
- package/dist/core/retrieval/llm-context-retrieval.js +0 -613
- package/dist/core/retrieval/llm-context-retrieval.js.map +0 -7
- package/dist/core/retrieval/llm-provider.js +0 -151
- package/dist/core/retrieval/llm-provider.js.map +0 -7
- package/dist/core/retrieval/retrieval-audit.js +0 -236
- package/dist/core/retrieval/retrieval-audit.js.map +0 -7
- package/dist/core/retrieval/retrieval-benchmarks.js +0 -521
- package/dist/core/retrieval/retrieval-benchmarks.js.map +0 -7
- package/dist/core/retrieval/summary-generator.js +0 -589
- package/dist/core/retrieval/summary-generator.js.map +0 -7
- package/dist/core/retrieval/types.js +0 -21
- package/dist/core/retrieval/types.js.map +0 -7
- package/dist/core/security/index.js +0 -35
- package/dist/core/security/index.js.map +0 -7
- package/dist/core/security/input-sanitizer.js +0 -321
- package/dist/core/security/input-sanitizer.js.map +0 -7
- package/dist/core/session/clear-survival.js +0 -465
- package/dist/core/session/clear-survival.js.map +0 -7
- package/dist/core/session/enhanced-handoff.js +0 -792
- package/dist/core/session/enhanced-handoff.js.map +0 -7
- package/dist/core/session/handoff-generator.js +0 -343
- package/dist/core/session/handoff-generator.js.map +0 -7
- package/dist/core/session/index.js +0 -15
- package/dist/core/session/index.js.map +0 -7
- package/dist/core/session/session-manager.js +0 -347
- package/dist/core/session/session-manager.js.map +0 -7
- package/dist/core/skills/index.js +0 -7
- package/dist/core/skills/index.js.map +0 -7
- package/dist/core/skills/skill-storage.js +0 -764
- package/dist/core/skills/skill-storage.js.map +0 -7
- package/dist/core/skills/types.js +0 -193
- package/dist/core/skills/types.js.map +0 -7
- package/dist/core/storage/chromadb-adapter.js +0 -354
- package/dist/core/storage/chromadb-adapter.js.map +0 -7
- package/dist/core/storage/infinite-storage.js +0 -510
- package/dist/core/storage/infinite-storage.js.map +0 -7
- package/dist/core/storage/railway-optimized-storage.js +0 -591
- package/dist/core/storage/railway-optimized-storage.js.map +0 -7
- package/dist/core/storage/remote-storage.js +0 -489
- package/dist/core/storage/remote-storage.js.map +0 -7
- package/dist/core/storage/two-tier-storage.js +0 -766
- package/dist/core/storage/two-tier-storage.js.map +0 -7
- package/dist/core/trace/cli-trace-wrapper.js +0 -132
- package/dist/core/trace/cli-trace-wrapper.js.map +0 -7
- package/dist/core/trace/db-trace-wrapper.js +0 -247
- package/dist/core/trace/db-trace-wrapper.js.map +0 -7
- package/dist/core/trace/debug-trace.js +0 -417
- package/dist/core/trace/debug-trace.js.map +0 -7
- package/dist/core/trace/index.js +0 -109
- package/dist/core/trace/index.js.map +0 -7
- package/dist/core/trace/linear-api-wrapper.js +0 -178
- package/dist/core/trace/linear-api-wrapper.js.map +0 -7
- package/dist/core/trace/trace-demo.js +0 -154
- package/dist/core/trace/trace-demo.js.map +0 -7
- package/dist/core/trace/trace-detector.demo.js +0 -142
- package/dist/core/trace/trace-detector.demo.js.map +0 -7
- package/dist/core/trace/trace-detector.js +0 -528
- package/dist/core/trace/trace-detector.js.map +0 -7
- package/dist/core/trace/trace-store.js +0 -345
- package/dist/core/trace/trace-store.js.map +0 -7
- package/dist/core/trace/types.js +0 -77
- package/dist/core/trace/types.js.map +0 -7
- package/dist/core/types.js +0 -5
- package/dist/core/types.js.map +0 -7
- package/dist/core/utils/async-mutex.js +0 -114
- package/dist/core/utils/async-mutex.js.map +0 -7
- package/dist/core/utils/compression.js +0 -83
- package/dist/core/utils/compression.js.map +0 -7
- package/dist/core/utils/update-checker.js +0 -218
- package/dist/core/utils/update-checker.js.map +0 -7
- package/dist/core/worktree/worktree-manager.js +0 -465
- package/dist/core/worktree/worktree-manager.js.map +0 -7
- package/dist/daemon/daemon-config.js +0 -149
- package/dist/daemon/daemon-config.js.map +0 -7
- package/dist/daemon/services/context-service.js +0 -122
- package/dist/daemon/services/context-service.js.map +0 -7
- package/dist/daemon/services/linear-service.js +0 -136
- package/dist/daemon/services/linear-service.js.map +0 -7
- package/dist/daemon/session-daemon.js +0 -312
- package/dist/daemon/session-daemon.js.map +0 -7
- package/dist/daemon/unified-daemon.js +0 -276
- package/dist/daemon/unified-daemon.js.map +0 -7
- package/dist/features/analytics/api/analytics-api.js +0 -287
- package/dist/features/analytics/api/analytics-api.js.map +0 -7
- package/dist/features/analytics/core/analytics-service.js +0 -282
- package/dist/features/analytics/core/analytics-service.js.map +0 -7
- package/dist/features/analytics/index.js +0 -18
- package/dist/features/analytics/index.js.map +0 -7
- package/dist/features/analytics/queries/metrics-queries.js +0 -277
- package/dist/features/analytics/queries/metrics-queries.js.map +0 -7
- package/dist/features/analytics/types/metrics.js +0 -5
- package/dist/features/analytics/types/metrics.js.map +0 -7
- package/dist/features/browser/browser-mcp.js +0 -492
- package/dist/features/browser/browser-mcp.js.map +0 -7
- package/dist/features/sweep/index.js +0 -20
- package/dist/features/sweep/index.js.map +0 -7
- package/dist/features/sweep/prediction-client.js +0 -155
- package/dist/features/sweep/prediction-client.js.map +0 -7
- package/dist/features/sweep/prompt-builder.js +0 -85
- package/dist/features/sweep/prompt-builder.js.map +0 -7
- package/dist/features/sweep/pty-wrapper.js +0 -171
- package/dist/features/sweep/pty-wrapper.js.map +0 -7
- package/dist/features/sweep/state-watcher.js +0 -87
- package/dist/features/sweep/state-watcher.js.map +0 -7
- package/dist/features/sweep/status-bar.js +0 -88
- package/dist/features/sweep/status-bar.js.map +0 -7
- package/dist/features/sweep/sweep-server-manager.js +0 -226
- package/dist/features/sweep/sweep-server-manager.js.map +0 -7
- package/dist/features/sweep/tab-interceptor.js +0 -38
- package/dist/features/sweep/tab-interceptor.js.map +0 -7
- package/dist/features/sweep/types.js +0 -18
- package/dist/features/sweep/types.js.map +0 -7
- package/dist/features/tasks/linear-task-manager.js +0 -487
- package/dist/features/tasks/linear-task-manager.js.map +0 -7
- package/dist/features/tasks/task-aware-context.js +0 -410
- package/dist/features/tasks/task-aware-context.js.map +0 -7
- package/dist/features/tui/simple-monitor.js +0 -116
- package/dist/features/tui/simple-monitor.js.map +0 -7
- package/dist/features/tui/swarm-monitor.js +0 -648
- package/dist/features/tui/swarm-monitor.js.map +0 -7
- package/dist/features/web/client/stores/task-store.js +0 -26
- package/dist/features/web/client/stores/task-store.js.map +0 -7
- package/dist/features/web/server/index.js +0 -194
- package/dist/features/web/server/index.js.map +0 -7
- package/dist/hooks/auto-background.js +0 -151
- package/dist/hooks/auto-background.js.map +0 -7
- package/dist/hooks/claude-code-whatsapp-hook.js +0 -197
- package/dist/hooks/claude-code-whatsapp-hook.js.map +0 -7
- package/dist/hooks/config.js +0 -150
- package/dist/hooks/config.js.map +0 -7
- package/dist/hooks/daemon.js +0 -364
- package/dist/hooks/daemon.js.map +0 -7
- package/dist/hooks/events.js +0 -58
- package/dist/hooks/events.js.map +0 -7
- package/dist/hooks/index.js +0 -12
- package/dist/hooks/index.js.map +0 -7
- package/dist/hooks/linear-task-picker.js +0 -186
- package/dist/hooks/linear-task-picker.js.map +0 -7
- package/dist/hooks/schemas.js +0 -197
- package/dist/hooks/schemas.js.map +0 -7
- package/dist/hooks/secure-fs.js +0 -49
- package/dist/hooks/secure-fs.js.map +0 -7
- package/dist/hooks/security-logger.js +0 -155
- package/dist/hooks/security-logger.js.map +0 -7
- package/dist/hooks/session-summary.js +0 -222
- package/dist/hooks/session-summary.js.map +0 -7
- package/dist/hooks/sms-action-runner.js +0 -371
- package/dist/hooks/sms-action-runner.js.map +0 -7
- package/dist/hooks/sms-notify.js +0 -506
- package/dist/hooks/sms-notify.js.map +0 -7
- package/dist/hooks/sms-watcher.js +0 -93
- package/dist/hooks/sms-watcher.js.map +0 -7
- package/dist/hooks/sms-webhook.js +0 -555
- package/dist/hooks/sms-webhook.js.map +0 -7
- package/dist/hooks/whatsapp-commands.js +0 -479
- package/dist/hooks/whatsapp-commands.js.map +0 -7
- package/dist/hooks/whatsapp-scheduler.js +0 -317
- package/dist/hooks/whatsapp-scheduler.js.map +0 -7
- package/dist/hooks/whatsapp-sync.js +0 -409
- package/dist/hooks/whatsapp-sync.js.map +0 -7
- package/dist/index.js +0 -25
- package/dist/index.js.map +0 -7
- package/dist/integrations/anthropic/client.js +0 -263
- package/dist/integrations/anthropic/client.js.map +0 -7
- package/dist/integrations/claude-code/agent-bridge.js +0 -768
- package/dist/integrations/claude-code/agent-bridge.js.map +0 -7
- package/dist/integrations/claude-code/enhanced-pre-clear-hooks.js +0 -459
- package/dist/integrations/claude-code/enhanced-pre-clear-hooks.js.map +0 -7
- package/dist/integrations/claude-code/lifecycle-hooks.js +0 -254
- package/dist/integrations/claude-code/lifecycle-hooks.js.map +0 -7
- package/dist/integrations/claude-code/post-task-hooks.js +0 -545
- package/dist/integrations/claude-code/post-task-hooks.js.map +0 -7
- package/dist/integrations/claude-code/subagent-client-stub.js +0 -20
- package/dist/integrations/claude-code/subagent-client-stub.js.map +0 -7
- package/dist/integrations/claude-code/subagent-client.js +0 -511
- package/dist/integrations/claude-code/subagent-client.js.map +0 -7
- package/dist/integrations/claude-code/task-coordinator.js +0 -360
- package/dist/integrations/claude-code/task-coordinator.js.map +0 -7
- package/dist/integrations/linear/auth.js +0 -337
- package/dist/integrations/linear/auth.js.map +0 -7
- package/dist/integrations/linear/auto-sync.js +0 -258
- package/dist/integrations/linear/auto-sync.js.map +0 -7
- package/dist/integrations/linear/client.js +0 -634
- package/dist/integrations/linear/client.js.map +0 -7
- package/dist/integrations/linear/config.js +0 -130
- package/dist/integrations/linear/config.js.map +0 -7
- package/dist/integrations/linear/migration.js +0 -361
- package/dist/integrations/linear/migration.js.map +0 -7
- package/dist/integrations/linear/oauth-server.js +0 -454
- package/dist/integrations/linear/oauth-server.js.map +0 -7
- package/dist/integrations/linear/rest-client.js +0 -213
- package/dist/integrations/linear/rest-client.js.map +0 -7
- package/dist/integrations/linear/sync-manager.js +0 -236
- package/dist/integrations/linear/sync-manager.js.map +0 -7
- package/dist/integrations/linear/sync-service.js +0 -231
- package/dist/integrations/linear/sync-service.js.map +0 -7
- package/dist/integrations/linear/sync.js +0 -782
- package/dist/integrations/linear/sync.js.map +0 -7
- package/dist/integrations/linear/types.js +0 -5
- package/dist/integrations/linear/types.js.map +0 -7
- package/dist/integrations/linear/unified-sync.js +0 -589
- package/dist/integrations/linear/unified-sync.js.map +0 -7
- package/dist/integrations/linear/webhook-handler.js +0 -219
- package/dist/integrations/linear/webhook-handler.js.map +0 -7
- package/dist/integrations/linear/webhook-server.js +0 -218
- package/dist/integrations/linear/webhook-server.js.map +0 -7
- package/dist/integrations/linear/webhook.js +0 -291
- package/dist/integrations/linear/webhook.js.map +0 -7
- package/dist/integrations/mcp/handlers/code-execution-handlers.js +0 -266
- package/dist/integrations/mcp/handlers/code-execution-handlers.js.map +0 -7
- package/dist/integrations/mcp/handlers/context-handlers.js +0 -257
- package/dist/integrations/mcp/handlers/context-handlers.js.map +0 -7
- package/dist/integrations/mcp/handlers/discovery-handlers.js +0 -497
- package/dist/integrations/mcp/handlers/discovery-handlers.js.map +0 -7
- package/dist/integrations/mcp/handlers/index.js +0 -166
- package/dist/integrations/mcp/handlers/index.js.map +0 -7
- package/dist/integrations/mcp/handlers/linear-handlers.js +0 -247
- package/dist/integrations/mcp/handlers/linear-handlers.js.map +0 -7
- package/dist/integrations/mcp/handlers/skill-handlers.js +0 -529
- package/dist/integrations/mcp/handlers/skill-handlers.js.map +0 -7
- package/dist/integrations/mcp/handlers/task-handlers.js +0 -239
- package/dist/integrations/mcp/handlers/task-handlers.js.map +0 -7
- package/dist/integrations/mcp/handlers/trace-handlers.js +0 -308
- package/dist/integrations/mcp/handlers/trace-handlers.js.map +0 -7
- package/dist/integrations/mcp/index.js +0 -23
- package/dist/integrations/mcp/index.js.map +0 -7
- package/dist/integrations/mcp/middleware/tool-scoring.js +0 -356
- package/dist/integrations/mcp/middleware/tool-scoring.js.map +0 -7
- package/dist/integrations/mcp/refactored-server.js +0 -374
- package/dist/integrations/mcp/refactored-server.js.map +0 -7
- package/dist/integrations/mcp/remote-server.js +0 -682
- package/dist/integrations/mcp/remote-server.js.map +0 -7
- package/dist/integrations/mcp/schemas.js +0 -147
- package/dist/integrations/mcp/schemas.js.map +0 -7
- package/dist/integrations/mcp/server.js +0 -1975
- package/dist/integrations/mcp/server.js.map +0 -7
- package/dist/integrations/mcp/tool-definitions-code.js +0 -125
- package/dist/integrations/mcp/tool-definitions-code.js.map +0 -7
- package/dist/integrations/mcp/tool-definitions.js +0 -702
- package/dist/integrations/mcp/tool-definitions.js.map +0 -7
- package/dist/integrations/mcp/trace-test.js +0 -48
- package/dist/integrations/mcp/trace-test.js.map +0 -7
- package/dist/integrations/pg-aiguide/embedding-provider.js +0 -189
- package/dist/integrations/pg-aiguide/embedding-provider.js.map +0 -7
- package/dist/integrations/pg-aiguide/semantic-search.js +0 -187
- package/dist/integrations/pg-aiguide/semantic-search.js.map +0 -7
- package/dist/integrations/pg-aiguide/timescale-analytics.js +0 -224
- package/dist/integrations/pg-aiguide/timescale-analytics.js.map +0 -7
- package/dist/integrations/ralph/bridge/ralph-stackmemory-bridge.js +0 -860
- package/dist/integrations/ralph/bridge/ralph-stackmemory-bridge.js.map +0 -7
- package/dist/integrations/ralph/context/context-budget-manager.js +0 -301
- package/dist/integrations/ralph/context/context-budget-manager.js.map +0 -7
- package/dist/integrations/ralph/context/stackmemory-context-loader.js +0 -360
- package/dist/integrations/ralph/context/stackmemory-context-loader.js.map +0 -7
- package/dist/integrations/ralph/coordination/enhanced-coordination.js +0 -410
- package/dist/integrations/ralph/coordination/enhanced-coordination.js.map +0 -7
- package/dist/integrations/ralph/index.js +0 -18
- package/dist/integrations/ralph/index.js.map +0 -7
- package/dist/integrations/ralph/learning/pattern-learner.js +0 -401
- package/dist/integrations/ralph/learning/pattern-learner.js.map +0 -7
- package/dist/integrations/ralph/lifecycle/iteration-lifecycle.js +0 -448
- package/dist/integrations/ralph/lifecycle/iteration-lifecycle.js.map +0 -7
- package/dist/integrations/ralph/monitoring/swarm-dashboard.js +0 -294
- package/dist/integrations/ralph/monitoring/swarm-dashboard.js.map +0 -7
- package/dist/integrations/ralph/monitoring/swarm-registry.js +0 -108
- package/dist/integrations/ralph/monitoring/swarm-registry.js.map +0 -7
- package/dist/integrations/ralph/orchestration/multi-loop-orchestrator.js +0 -463
- package/dist/integrations/ralph/orchestration/multi-loop-orchestrator.js.map +0 -7
- package/dist/integrations/ralph/patterns/compounding-engineering-pattern.js +0 -400
- package/dist/integrations/ralph/patterns/compounding-engineering-pattern.js.map +0 -7
- package/dist/integrations/ralph/patterns/extended-coherence-sessions.js +0 -473
- package/dist/integrations/ralph/patterns/extended-coherence-sessions.js.map +0 -7
- package/dist/integrations/ralph/patterns/oracle-worker-pattern.js +0 -388
- package/dist/integrations/ralph/patterns/oracle-worker-pattern.js.map +0 -7
- package/dist/integrations/ralph/performance/performance-optimizer.js +0 -358
- package/dist/integrations/ralph/performance/performance-optimizer.js.map +0 -7
- package/dist/integrations/ralph/ralph-integration-demo.js +0 -182
- package/dist/integrations/ralph/ralph-integration-demo.js.map +0 -7
- package/dist/integrations/ralph/recovery/crash-recovery.js +0 -462
- package/dist/integrations/ralph/recovery/crash-recovery.js.map +0 -7
- package/dist/integrations/ralph/state/state-reconciler.js +0 -404
- package/dist/integrations/ralph/state/state-reconciler.js.map +0 -7
- package/dist/integrations/ralph/swarm/git-workflow-manager.js +0 -428
- package/dist/integrations/ralph/swarm/git-workflow-manager.js.map +0 -7
- package/dist/integrations/ralph/swarm/swarm-coordinator.js +0 -996
- package/dist/integrations/ralph/swarm/swarm-coordinator.js.map +0 -7
- package/dist/integrations/ralph/types.js +0 -5
- package/dist/integrations/ralph/types.js.map +0 -7
- package/dist/integrations/ralph/visualization/ralph-debugger.js +0 -585
- package/dist/integrations/ralph/visualization/ralph-debugger.js.map +0 -7
- package/dist/mcp/stackmemory-mcp-server.js +0 -554
- package/dist/mcp/stackmemory-mcp-server.js.map +0 -7
- package/dist/middleware/exponential-rate-limiter.js +0 -289
- package/dist/middleware/exponential-rate-limiter.js.map +0 -7
- package/dist/models/user.model.js +0 -358
- package/dist/models/user.model.js.map +0 -7
- package/dist/servers/production/auth-middleware.js +0 -528
- package/dist/servers/production/auth-middleware.js.map +0 -7
- package/dist/servers/railway/config.js +0 -55
- package/dist/servers/railway/config.js.map +0 -7
- package/dist/servers/railway/index-enhanced.js +0 -160
- package/dist/servers/railway/index-enhanced.js.map +0 -7
- package/dist/servers/railway/index.js +0 -1349
- package/dist/servers/railway/index.js.map +0 -7
- package/dist/servers/railway/simple.js +0 -64
- package/dist/servers/railway/simple.js.map +0 -7
- package/dist/servers/railway/storage-test.js +0 -459
- package/dist/servers/railway/storage-test.js.map +0 -7
- package/dist/services/config-service.js +0 -65
- package/dist/services/config-service.js.map +0 -7
- package/dist/services/context-service.js +0 -194
- package/dist/services/context-service.js.map +0 -7
- package/dist/skills/api-discovery.js +0 -354
- package/dist/skills/api-discovery.js.map +0 -7
- package/dist/skills/api-skill.js +0 -475
- package/dist/skills/api-skill.js.map +0 -7
- package/dist/skills/claude-skills.js +0 -1061
- package/dist/skills/claude-skills.js.map +0 -7
- package/dist/skills/dashboard-launcher.js +0 -216
- package/dist/skills/dashboard-launcher.js.map +0 -7
- package/dist/skills/recursive-agent-orchestrator.js +0 -575
- package/dist/skills/recursive-agent-orchestrator.js.map +0 -7
- package/dist/skills/repo-ingestion-skill.js +0 -609
- package/dist/skills/repo-ingestion-skill.js.map +0 -7
- package/dist/skills/security-secrets-scanner.js +0 -284
- package/dist/skills/security-secrets-scanner.js.map +0 -7
- package/dist/skills/unified-rlm-orchestrator.js +0 -404
- package/dist/skills/unified-rlm-orchestrator.js.map +0 -7
- package/dist/types/task.js +0 -5
- package/dist/types/task.js.map +0 -7
- package/dist/utils/env.js +0 -50
- package/dist/utils/env.js.map +0 -7
- package/dist/utils/formatting.js +0 -62
- package/dist/utils/formatting.js.map +0 -7
- package/dist/utils/process-cleanup.js +0 -136
- package/dist/utils/process-cleanup.js.map +0 -7
- package/dist/validation/schemas.js +0 -222
- package/dist/validation/schemas.js.map +0 -7
- /package/dist/{core/merge → src/core/extensions}/types.js +0 -0
- /package/dist/{core/merge → src/core/extensions}/types.js.map +0 -0
|
@@ -1,621 +0,0 @@
|
|
|
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 { v4 as uuidv4 } from "uuid";
|
|
6
|
-
import * as fs from "fs/promises";
|
|
7
|
-
import * as path from "path";
|
|
8
|
-
import { sessionManager } from "../session/session-manager.js";
|
|
9
|
-
import { logger } from "../monitoring/logger.js";
|
|
10
|
-
class SharedContextLayer {
|
|
11
|
-
static instance;
|
|
12
|
-
contextDir;
|
|
13
|
-
cache = /* @__PURE__ */ new Map();
|
|
14
|
-
MAX_CACHE_SIZE = 100;
|
|
15
|
-
CACHE_TTL = 5 * 60 * 1e3;
|
|
16
|
-
// 5 minutes
|
|
17
|
-
lastCacheClean = Date.now();
|
|
18
|
-
constructor() {
|
|
19
|
-
const homeDir = process.env["HOME"] || process.env["USERPROFILE"] || "";
|
|
20
|
-
this.contextDir = path.join(homeDir, ".stackmemory", "shared-context");
|
|
21
|
-
}
|
|
22
|
-
static getInstance() {
|
|
23
|
-
if (!SharedContextLayer.instance) {
|
|
24
|
-
SharedContextLayer.instance = new SharedContextLayer();
|
|
25
|
-
}
|
|
26
|
-
return SharedContextLayer.instance;
|
|
27
|
-
}
|
|
28
|
-
async initialize() {
|
|
29
|
-
await fs.mkdir(this.contextDir, { recursive: true });
|
|
30
|
-
await fs.mkdir(path.join(this.contextDir, "projects"), { recursive: true });
|
|
31
|
-
await fs.mkdir(path.join(this.contextDir, "patterns"), { recursive: true });
|
|
32
|
-
await fs.mkdir(path.join(this.contextDir, "decisions"), {
|
|
33
|
-
recursive: true
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Get or create shared context for current project/branch
|
|
38
|
-
*/
|
|
39
|
-
async getSharedContext(options) {
|
|
40
|
-
const session = sessionManager.getCurrentSession();
|
|
41
|
-
const projectId = options?.projectId || session?.projectId || "global";
|
|
42
|
-
const branch = options?.branch || session?.branch;
|
|
43
|
-
const cacheKey = `${projectId}:${branch || "main"}`;
|
|
44
|
-
if (this.cache.has(cacheKey)) {
|
|
45
|
-
const cached = this.cache.get(cacheKey);
|
|
46
|
-
if (Date.now() - cached.lastUpdated < this.CACHE_TTL) {
|
|
47
|
-
return cached;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
const context = await this.loadProjectContext(projectId, branch);
|
|
51
|
-
if (options?.includeOtherBranches) {
|
|
52
|
-
const otherBranches = await this.loadOtherBranchContexts(
|
|
53
|
-
projectId,
|
|
54
|
-
branch
|
|
55
|
-
);
|
|
56
|
-
context.sessions.push(...otherBranches);
|
|
57
|
-
}
|
|
58
|
-
this.cache.set(cacheKey, context);
|
|
59
|
-
this.cleanCache();
|
|
60
|
-
return context;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Add current session's important frames to shared context
|
|
64
|
-
*/
|
|
65
|
-
async addToSharedContext(frames, options) {
|
|
66
|
-
const session = sessionManager.getCurrentSession();
|
|
67
|
-
if (!session) return;
|
|
68
|
-
const context = await this.getSharedContext();
|
|
69
|
-
const minScore = options?.minScore || 0.7;
|
|
70
|
-
const importantFrames = frames.filter((f) => {
|
|
71
|
-
const score = this.calculateFrameScore(f);
|
|
72
|
-
return score >= minScore;
|
|
73
|
-
});
|
|
74
|
-
const sessionContext = {
|
|
75
|
-
sessionId: session.sessionId,
|
|
76
|
-
runId: session.runId,
|
|
77
|
-
summary: this.generateSessionSummary(importantFrames),
|
|
78
|
-
keyFrames: importantFrames.map((f) => this.summarizeFrame(f)),
|
|
79
|
-
createdAt: session.startedAt,
|
|
80
|
-
lastActiveAt: Date.now(),
|
|
81
|
-
metadata: session.metadata
|
|
82
|
-
};
|
|
83
|
-
const existingIndex = context.sessions.findIndex(
|
|
84
|
-
(s) => s.sessionId === session.sessionId
|
|
85
|
-
);
|
|
86
|
-
if (existingIndex >= 0) {
|
|
87
|
-
context.sessions[existingIndex] = sessionContext;
|
|
88
|
-
} else {
|
|
89
|
-
context.sessions.push(sessionContext);
|
|
90
|
-
}
|
|
91
|
-
this.updatePatterns(context, importantFrames);
|
|
92
|
-
this.updateReferenceIndex(context, importantFrames);
|
|
93
|
-
await this.saveProjectContext(context);
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Query shared context for relevant frames
|
|
97
|
-
*/
|
|
98
|
-
async querySharedContext(query) {
|
|
99
|
-
const context = await this.getSharedContext({ includeOtherBranches: true });
|
|
100
|
-
let results = [];
|
|
101
|
-
for (const session of context.sessions) {
|
|
102
|
-
if (query.sessionId && session.sessionId !== query.sessionId) continue;
|
|
103
|
-
if (!session.keyFrames || !Array.isArray(session.keyFrames)) continue;
|
|
104
|
-
const filtered = session.keyFrames.filter((f) => {
|
|
105
|
-
if (query.tags && !query.tags.some((tag) => f.tags.includes(tag)))
|
|
106
|
-
return false;
|
|
107
|
-
if (query.type && f.type !== query.type) return false;
|
|
108
|
-
if (query.minScore && f.score < query.minScore) return false;
|
|
109
|
-
return true;
|
|
110
|
-
});
|
|
111
|
-
results.push(...filtered);
|
|
112
|
-
}
|
|
113
|
-
results.sort((a, b) => {
|
|
114
|
-
const scoreWeight = 0.7;
|
|
115
|
-
const recencyWeight = 0.3;
|
|
116
|
-
const aScore = a.score * scoreWeight + (1 - (Date.now() - a.createdAt) / (30 * 24 * 60 * 60 * 1e3)) * recencyWeight;
|
|
117
|
-
const bScore = b.score * scoreWeight + (1 - (Date.now() - b.createdAt) / (30 * 24 * 60 * 60 * 1e3)) * recencyWeight;
|
|
118
|
-
return bScore - aScore;
|
|
119
|
-
});
|
|
120
|
-
if (query.limit) {
|
|
121
|
-
results = results.slice(0, query.limit);
|
|
122
|
-
}
|
|
123
|
-
const index = context.referenceIndex;
|
|
124
|
-
if (!index.recentlyAccessed) {
|
|
125
|
-
index.recentlyAccessed = [];
|
|
126
|
-
}
|
|
127
|
-
if (results.length > 0) {
|
|
128
|
-
const frameIds = results.map((r) => r.frameId);
|
|
129
|
-
index.recentlyAccessed = [
|
|
130
|
-
...frameIds,
|
|
131
|
-
...index.recentlyAccessed.filter((id) => !frameIds.includes(id))
|
|
132
|
-
].slice(0, 100);
|
|
133
|
-
await this.saveProjectContext(context);
|
|
134
|
-
}
|
|
135
|
-
return results;
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Get relevant patterns from shared context
|
|
139
|
-
*/
|
|
140
|
-
async getPatterns(type) {
|
|
141
|
-
const context = await this.getSharedContext();
|
|
142
|
-
if (type) {
|
|
143
|
-
return context.globalPatterns.filter((p) => p.type === type);
|
|
144
|
-
}
|
|
145
|
-
return context.globalPatterns;
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* Add a decision to the shared context
|
|
149
|
-
*/
|
|
150
|
-
async addDecision(decision) {
|
|
151
|
-
const session = sessionManager.getCurrentSession();
|
|
152
|
-
if (!session) return;
|
|
153
|
-
const context = await this.getSharedContext();
|
|
154
|
-
const newDecision = {
|
|
155
|
-
id: uuidv4(),
|
|
156
|
-
timestamp: Date.now(),
|
|
157
|
-
sessionId: session.sessionId,
|
|
158
|
-
outcome: "pending",
|
|
159
|
-
...decision
|
|
160
|
-
};
|
|
161
|
-
context.decisionLog.push(newDecision);
|
|
162
|
-
if (context.decisionLog.length > 100) {
|
|
163
|
-
context.decisionLog = context.decisionLog.slice(-100);
|
|
164
|
-
}
|
|
165
|
-
await this.saveProjectContext(context);
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* Get recent decisions from shared context
|
|
169
|
-
*/
|
|
170
|
-
async getDecisions(limit = 10) {
|
|
171
|
-
const context = await this.getSharedContext();
|
|
172
|
-
return context.decisionLog.slice(-limit);
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* Automatic context discovery on CLI startup
|
|
176
|
-
*/
|
|
177
|
-
async autoDiscoverContext() {
|
|
178
|
-
const context = await this.getSharedContext({
|
|
179
|
-
includeOtherBranches: false
|
|
180
|
-
});
|
|
181
|
-
const recentPatterns = context.globalPatterns.filter((p) => Date.now() - p.lastSeen < 7 * 24 * 60 * 60 * 1e3).sort((a, b) => b.frequency - a.frequency).slice(0, 5);
|
|
182
|
-
const lastDecisions = context.decisionLog.slice(-5);
|
|
183
|
-
const suggestedFrames = await this.querySharedContext({
|
|
184
|
-
minScore: 0.8,
|
|
185
|
-
limit: 5
|
|
186
|
-
});
|
|
187
|
-
return {
|
|
188
|
-
hasSharedContext: context.sessions.length > 0,
|
|
189
|
-
sessionCount: context.sessions.length,
|
|
190
|
-
recentPatterns,
|
|
191
|
-
lastDecisions,
|
|
192
|
-
suggestedFrames
|
|
193
|
-
};
|
|
194
|
-
}
|
|
195
|
-
async loadProjectContext(projectId, branch) {
|
|
196
|
-
const contextFile = path.join(
|
|
197
|
-
this.contextDir,
|
|
198
|
-
"projects",
|
|
199
|
-
`${projectId}_${branch || "main"}.json`
|
|
200
|
-
);
|
|
201
|
-
try {
|
|
202
|
-
const data = await fs.readFile(contextFile, "utf-8");
|
|
203
|
-
const context = JSON.parse(data);
|
|
204
|
-
context.referenceIndex.byTag = new Map(
|
|
205
|
-
Object.entries(context.referenceIndex.byTag || {})
|
|
206
|
-
);
|
|
207
|
-
context.referenceIndex.byType = new Map(
|
|
208
|
-
Object.entries(context.referenceIndex.byType || {})
|
|
209
|
-
);
|
|
210
|
-
return context;
|
|
211
|
-
} catch {
|
|
212
|
-
return {
|
|
213
|
-
projectId,
|
|
214
|
-
branch,
|
|
215
|
-
lastUpdated: Date.now(),
|
|
216
|
-
sessions: [],
|
|
217
|
-
globalPatterns: [],
|
|
218
|
-
decisionLog: [],
|
|
219
|
-
referenceIndex: {
|
|
220
|
-
byTag: /* @__PURE__ */ new Map(),
|
|
221
|
-
byType: /* @__PURE__ */ new Map(),
|
|
222
|
-
byScore: [],
|
|
223
|
-
recentlyAccessed: []
|
|
224
|
-
}
|
|
225
|
-
};
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
async saveProjectContext(context) {
|
|
229
|
-
const contextFile = path.join(
|
|
230
|
-
this.contextDir,
|
|
231
|
-
"projects",
|
|
232
|
-
`${context.projectId}_${context.branch || "main"}.json`
|
|
233
|
-
);
|
|
234
|
-
const serializable = {
|
|
235
|
-
...context,
|
|
236
|
-
lastUpdated: Date.now(),
|
|
237
|
-
referenceIndex: {
|
|
238
|
-
...context.referenceIndex,
|
|
239
|
-
byTag: Object.fromEntries(context.referenceIndex.byTag),
|
|
240
|
-
byType: Object.fromEntries(context.referenceIndex.byType)
|
|
241
|
-
}
|
|
242
|
-
};
|
|
243
|
-
await fs.writeFile(contextFile, JSON.stringify(serializable, null, 2));
|
|
244
|
-
}
|
|
245
|
-
async loadOtherBranchContexts(projectId, currentBranch) {
|
|
246
|
-
const projectsDir = path.join(this.contextDir, "projects");
|
|
247
|
-
const files = await fs.readdir(projectsDir);
|
|
248
|
-
const sessions = [];
|
|
249
|
-
for (const file of files) {
|
|
250
|
-
if (file.startsWith(`${projectId}_`) && !file.includes(currentBranch || "main")) {
|
|
251
|
-
try {
|
|
252
|
-
const data = await fs.readFile(path.join(projectsDir, file), "utf-8");
|
|
253
|
-
const context = JSON.parse(data);
|
|
254
|
-
sessions.push(...context.sessions);
|
|
255
|
-
} catch {
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
return sessions;
|
|
260
|
-
}
|
|
261
|
-
calculateFrameScore(frame) {
|
|
262
|
-
let score = 0.5;
|
|
263
|
-
if (frame.type === "task" || frame.type === "review") score += 0.2;
|
|
264
|
-
if (frame.type === "debug" || frame.type === "write") score += 0.15;
|
|
265
|
-
if (frame.type === "error") score += 0.15;
|
|
266
|
-
const frameWithData = frame;
|
|
267
|
-
if (frameWithData.data) score += 0.2;
|
|
268
|
-
if (frame.outputs && Object.keys(frame.outputs).length > 0) score += 0.2;
|
|
269
|
-
if (frame.digest_text || frame.digest_json && Object.keys(frame.digest_json).length > 0)
|
|
270
|
-
score += 0.1;
|
|
271
|
-
if (frame.created_at) {
|
|
272
|
-
const age = Date.now() - frame.created_at;
|
|
273
|
-
const daysSinceCreation = age / (24 * 60 * 60 * 1e3);
|
|
274
|
-
score *= Math.max(0.3, 1 - daysSinceCreation / 30);
|
|
275
|
-
}
|
|
276
|
-
return Math.min(1, score);
|
|
277
|
-
}
|
|
278
|
-
summarizeFrame(frame) {
|
|
279
|
-
return {
|
|
280
|
-
frameId: frame.frame_id,
|
|
281
|
-
title: frame.name,
|
|
282
|
-
type: frame.type,
|
|
283
|
-
score: this.calculateFrameScore(frame),
|
|
284
|
-
tags: [],
|
|
285
|
-
summary: this.generateFrameSummary(frame),
|
|
286
|
-
createdAt: frame.created_at
|
|
287
|
-
};
|
|
288
|
-
}
|
|
289
|
-
generateFrameSummary(frame) {
|
|
290
|
-
const parts = [];
|
|
291
|
-
const frameWithData = frame;
|
|
292
|
-
if (frame.type) parts.push(`[${frame.type}]`);
|
|
293
|
-
if (frame.name) parts.push(frame.name);
|
|
294
|
-
if (frameWithData.title) parts.push(frameWithData.title);
|
|
295
|
-
if (frameWithData.data?.error)
|
|
296
|
-
parts.push(`Error: ${frameWithData.data.error}`);
|
|
297
|
-
if (frameWithData.data?.resolution)
|
|
298
|
-
parts.push(`Resolution: ${frameWithData.data.resolution}`);
|
|
299
|
-
return parts.join(" - ").slice(0, 200);
|
|
300
|
-
}
|
|
301
|
-
generateSessionSummary(frames) {
|
|
302
|
-
const types = [...new Set(frames.map((f) => f.type))];
|
|
303
|
-
return `Session with ${frames.length} key frames: ${types.join(", ")}`;
|
|
304
|
-
}
|
|
305
|
-
updatePatterns(context, frames) {
|
|
306
|
-
for (const frame of frames) {
|
|
307
|
-
const frameWithData = frame;
|
|
308
|
-
if (frameWithData.data?.error) {
|
|
309
|
-
this.addPattern(
|
|
310
|
-
context,
|
|
311
|
-
frameWithData.data.error,
|
|
312
|
-
"error",
|
|
313
|
-
frameWithData.data?.resolution
|
|
314
|
-
);
|
|
315
|
-
} else if (frame.type === "error" && frame.name) {
|
|
316
|
-
const errorText = frame.outputs?.error || frame.name;
|
|
317
|
-
const resolution = frame.outputs?.resolution;
|
|
318
|
-
if (errorText) {
|
|
319
|
-
this.addPattern(context, errorText, "error", resolution);
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
if (frame.type === "decision" && frameWithData.data?.decision) {
|
|
323
|
-
this.addPattern(context, frameWithData.data.decision, "decision");
|
|
324
|
-
} else if (frame.digest_json?.decision) {
|
|
325
|
-
this.addPattern(context, frame.digest_json.decision, "decision");
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
addPattern(context, pattern, type, resolution) {
|
|
330
|
-
const existing = context.globalPatterns.find(
|
|
331
|
-
(p) => p.pattern === pattern && p.type === type
|
|
332
|
-
);
|
|
333
|
-
if (existing) {
|
|
334
|
-
existing.frequency++;
|
|
335
|
-
existing.lastSeen = Date.now();
|
|
336
|
-
if (resolution) existing.resolution = resolution;
|
|
337
|
-
} else {
|
|
338
|
-
context.globalPatterns.push({
|
|
339
|
-
pattern,
|
|
340
|
-
type,
|
|
341
|
-
frequency: 1,
|
|
342
|
-
lastSeen: Date.now(),
|
|
343
|
-
resolution
|
|
344
|
-
});
|
|
345
|
-
}
|
|
346
|
-
if (context.globalPatterns.length > 100) {
|
|
347
|
-
context.globalPatterns.sort((a, b) => b.frequency - a.frequency);
|
|
348
|
-
context.globalPatterns = context.globalPatterns.slice(0, 100);
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
updateReferenceIndex(context, frames) {
|
|
352
|
-
for (const frame of frames) {
|
|
353
|
-
const summary = this.summarizeFrame(frame);
|
|
354
|
-
for (const tag of summary.tags) {
|
|
355
|
-
if (!context.referenceIndex.byTag.has(tag)) {
|
|
356
|
-
context.referenceIndex.byTag.set(tag, []);
|
|
357
|
-
}
|
|
358
|
-
context.referenceIndex.byTag.get(tag).push(frame.frameId);
|
|
359
|
-
}
|
|
360
|
-
if (!context.referenceIndex.byType.has(frame.type)) {
|
|
361
|
-
context.referenceIndex.byType.set(frame.type, []);
|
|
362
|
-
}
|
|
363
|
-
context.referenceIndex.byType.get(frame.type).push(frame.frameId);
|
|
364
|
-
const scoreIndex = context.referenceIndex.byScore;
|
|
365
|
-
const insertIndex = scoreIndex.findIndex((id) => {
|
|
366
|
-
const otherFrame = context.sessions.flatMap((s) => s.keyFrames).find((f) => f.frameId === id);
|
|
367
|
-
return otherFrame && otherFrame.score < summary.score;
|
|
368
|
-
});
|
|
369
|
-
if (insertIndex >= 0) {
|
|
370
|
-
scoreIndex.splice(insertIndex, 0, frame.frameId);
|
|
371
|
-
} else {
|
|
372
|
-
scoreIndex.push(frame.frameId);
|
|
373
|
-
}
|
|
374
|
-
context.referenceIndex.byScore = scoreIndex.slice(0, 1e3);
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
cleanCache() {
|
|
378
|
-
if (Date.now() - this.lastCacheClean < 6e4) return;
|
|
379
|
-
if (this.cache.size > this.MAX_CACHE_SIZE) {
|
|
380
|
-
const entries = Array.from(this.cache.entries()).sort(
|
|
381
|
-
(a, b) => b[1].lastUpdated - a[1].lastUpdated
|
|
382
|
-
);
|
|
383
|
-
this.cache = new Map(entries.slice(0, this.MAX_CACHE_SIZE / 2));
|
|
384
|
-
}
|
|
385
|
-
this.lastCacheClean = Date.now();
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
const sharedContextLayer = SharedContextLayer.getInstance();
|
|
389
|
-
class ContextBridge {
|
|
390
|
-
static instance;
|
|
391
|
-
frameManager = null;
|
|
392
|
-
syncTimer = null;
|
|
393
|
-
lastSyncTime = 0;
|
|
394
|
-
options = {
|
|
395
|
-
autoSync: true,
|
|
396
|
-
syncInterval: 6e4,
|
|
397
|
-
// 1 minute
|
|
398
|
-
minFrameScore: 0.5,
|
|
399
|
-
// Include frames with score above 0.5
|
|
400
|
-
importantTags: ["decision", "error", "milestone", "learning"]
|
|
401
|
-
};
|
|
402
|
-
constructor() {
|
|
403
|
-
}
|
|
404
|
-
static getInstance() {
|
|
405
|
-
if (!ContextBridge.instance) {
|
|
406
|
-
ContextBridge.instance = new ContextBridge();
|
|
407
|
-
}
|
|
408
|
-
return ContextBridge.instance;
|
|
409
|
-
}
|
|
410
|
-
/**
|
|
411
|
-
* Initialize the bridge with a frame manager
|
|
412
|
-
*/
|
|
413
|
-
async initialize(frameManager, options) {
|
|
414
|
-
this.frameManager = frameManager;
|
|
415
|
-
this.options = { ...this.options, ...options };
|
|
416
|
-
await this.loadSharedContext();
|
|
417
|
-
if (this.options.autoSync) {
|
|
418
|
-
this.startAutoSync();
|
|
419
|
-
}
|
|
420
|
-
logger.info("Context bridge initialized", {
|
|
421
|
-
autoSync: this.options.autoSync,
|
|
422
|
-
syncInterval: this.options.syncInterval
|
|
423
|
-
});
|
|
424
|
-
}
|
|
425
|
-
/**
|
|
426
|
-
* Load relevant shared context into current session
|
|
427
|
-
*/
|
|
428
|
-
async loadSharedContext() {
|
|
429
|
-
try {
|
|
430
|
-
const session = sessionManager.getCurrentSession();
|
|
431
|
-
if (!session) return;
|
|
432
|
-
const discovery = await sharedContextLayer.autoDiscoverContext();
|
|
433
|
-
if (!discovery.hasSharedContext) {
|
|
434
|
-
logger.info("No shared context available to load");
|
|
435
|
-
return;
|
|
436
|
-
}
|
|
437
|
-
if (discovery.recentPatterns.length > 0) {
|
|
438
|
-
logger.info("Loaded recent patterns from shared context", {
|
|
439
|
-
patternCount: discovery.recentPatterns.length
|
|
440
|
-
});
|
|
441
|
-
}
|
|
442
|
-
if (discovery.lastDecisions.length > 0) {
|
|
443
|
-
logger.info("Loaded recent decisions from shared context", {
|
|
444
|
-
decisionCount: discovery.lastDecisions.length
|
|
445
|
-
});
|
|
446
|
-
}
|
|
447
|
-
if (discovery.suggestedFrames.length > 0) {
|
|
448
|
-
const metadata = {
|
|
449
|
-
suggestedFrames: discovery.suggestedFrames,
|
|
450
|
-
loadedAt: Date.now()
|
|
451
|
-
};
|
|
452
|
-
if (this.frameManager) {
|
|
453
|
-
await this.frameManager.addContext(
|
|
454
|
-
"shared-context-suggestions",
|
|
455
|
-
metadata
|
|
456
|
-
);
|
|
457
|
-
}
|
|
458
|
-
logger.info("Loaded suggested frames from shared context", {
|
|
459
|
-
frameCount: discovery.suggestedFrames.length
|
|
460
|
-
});
|
|
461
|
-
}
|
|
462
|
-
} catch (error) {
|
|
463
|
-
logger.error("Failed to load shared context", error);
|
|
464
|
-
}
|
|
465
|
-
}
|
|
466
|
-
/**
|
|
467
|
-
* Sync current session's important frames to shared context
|
|
468
|
-
*/
|
|
469
|
-
async syncToSharedContext() {
|
|
470
|
-
try {
|
|
471
|
-
if (!this.frameManager) return;
|
|
472
|
-
const session = sessionManager.getCurrentSession();
|
|
473
|
-
if (!session) return;
|
|
474
|
-
const activeFrames = this.frameManager.getActiveFramePath().filter(Boolean);
|
|
475
|
-
const recentFrames = await this.frameManager.getRecentFrames(100);
|
|
476
|
-
const allFrames = [...activeFrames, ...recentFrames].filter(Boolean);
|
|
477
|
-
const importantFrames = this.filterImportantFrames(allFrames);
|
|
478
|
-
if (importantFrames.length === 0) {
|
|
479
|
-
logger.debug("No important frames to sync");
|
|
480
|
-
return;
|
|
481
|
-
}
|
|
482
|
-
await sharedContextLayer.addToSharedContext(importantFrames, {
|
|
483
|
-
minScore: this.options.minFrameScore,
|
|
484
|
-
tags: this.options.importantTags
|
|
485
|
-
});
|
|
486
|
-
this.lastSyncTime = Date.now();
|
|
487
|
-
logger.info("Synced frames to shared context", {
|
|
488
|
-
frameCount: importantFrames.length,
|
|
489
|
-
sessionId: session.sessionId
|
|
490
|
-
});
|
|
491
|
-
} catch (error) {
|
|
492
|
-
logger.error("Failed to sync to shared context", error);
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
/**
|
|
496
|
-
* Query shared context for relevant frames
|
|
497
|
-
*/
|
|
498
|
-
async querySharedFrames(query) {
|
|
499
|
-
try {
|
|
500
|
-
const results = await sharedContextLayer.querySharedContext({
|
|
501
|
-
...query,
|
|
502
|
-
minScore: this.options.minFrameScore
|
|
503
|
-
});
|
|
504
|
-
logger.info("Queried shared context", {
|
|
505
|
-
query,
|
|
506
|
-
resultCount: results.length
|
|
507
|
-
});
|
|
508
|
-
return results;
|
|
509
|
-
} catch (error) {
|
|
510
|
-
logger.error("Failed to query shared context", error);
|
|
511
|
-
return [];
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
/**
|
|
515
|
-
* Add a decision to shared context
|
|
516
|
-
*/
|
|
517
|
-
async addDecision(decision, reasoning) {
|
|
518
|
-
try {
|
|
519
|
-
await sharedContextLayer.addDecision({
|
|
520
|
-
decision,
|
|
521
|
-
reasoning,
|
|
522
|
-
outcome: "pending"
|
|
523
|
-
});
|
|
524
|
-
logger.info("Added decision to shared context", { decision });
|
|
525
|
-
} catch (error) {
|
|
526
|
-
logger.error("Failed to add decision", error);
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
/**
|
|
530
|
-
* Start automatic synchronization
|
|
531
|
-
*/
|
|
532
|
-
startAutoSync() {
|
|
533
|
-
if (this.syncTimer) {
|
|
534
|
-
clearInterval(this.syncTimer);
|
|
535
|
-
}
|
|
536
|
-
this.syncTimer = setInterval(() => {
|
|
537
|
-
this.syncToSharedContext().catch((error) => {
|
|
538
|
-
logger.error("Auto-sync failed", error);
|
|
539
|
-
});
|
|
540
|
-
}, this.options.syncInterval);
|
|
541
|
-
this.setupEventListeners();
|
|
542
|
-
}
|
|
543
|
-
/**
|
|
544
|
-
* Stop automatic synchronization
|
|
545
|
-
*/
|
|
546
|
-
stopAutoSync() {
|
|
547
|
-
if (this.syncTimer) {
|
|
548
|
-
clearInterval(this.syncTimer);
|
|
549
|
-
this.syncTimer = null;
|
|
550
|
-
}
|
|
551
|
-
}
|
|
552
|
-
/**
|
|
553
|
-
* Filter frames that are important enough to share
|
|
554
|
-
*/
|
|
555
|
-
filterImportantFrames(frames) {
|
|
556
|
-
return frames.filter((frame) => {
|
|
557
|
-
const hasImportantTag = this.options.importantTags.some(
|
|
558
|
-
(tag) => frame.metadata?.tags?.includes(tag)
|
|
559
|
-
);
|
|
560
|
-
const isImportantType = [
|
|
561
|
-
"task",
|
|
562
|
-
"milestone",
|
|
563
|
-
"error",
|
|
564
|
-
"resolution",
|
|
565
|
-
"decision"
|
|
566
|
-
].includes(frame.type);
|
|
567
|
-
const markedImportant = frame.metadata?.importance === "high";
|
|
568
|
-
return hasImportantTag || isImportantType || markedImportant;
|
|
569
|
-
});
|
|
570
|
-
}
|
|
571
|
-
/**
|
|
572
|
-
* Setup event listeners for automatic syncing
|
|
573
|
-
*/
|
|
574
|
-
setupEventListeners() {
|
|
575
|
-
if (!this.frameManager) return;
|
|
576
|
-
const originalClose = this.frameManager.closeFrame.bind(this.frameManager);
|
|
577
|
-
this.frameManager.closeFrame = async (frameId, metadata) => {
|
|
578
|
-
const result = await originalClose(frameId, metadata);
|
|
579
|
-
const frame = await this.frameManager.getFrame(frameId);
|
|
580
|
-
if (frame && this.filterImportantFrames([frame]).length > 0) {
|
|
581
|
-
await this.syncToSharedContext();
|
|
582
|
-
}
|
|
583
|
-
return result;
|
|
584
|
-
};
|
|
585
|
-
const originalMilestone = this.frameManager.createFrame.bind(
|
|
586
|
-
this.frameManager
|
|
587
|
-
);
|
|
588
|
-
this.frameManager.createFrame = async (params) => {
|
|
589
|
-
const result = await originalMilestone(params);
|
|
590
|
-
if (params.type === "milestone") {
|
|
591
|
-
await this.syncToSharedContext();
|
|
592
|
-
}
|
|
593
|
-
return result;
|
|
594
|
-
};
|
|
595
|
-
}
|
|
596
|
-
/**
|
|
597
|
-
* Get sync statistics
|
|
598
|
-
*/
|
|
599
|
-
getSyncStats() {
|
|
600
|
-
return {
|
|
601
|
-
lastSyncTime: this.lastSyncTime,
|
|
602
|
-
autoSyncEnabled: this.options.autoSync,
|
|
603
|
-
syncInterval: this.options.syncInterval
|
|
604
|
-
};
|
|
605
|
-
}
|
|
606
|
-
/**
|
|
607
|
-
* Manual trigger for immediate sync
|
|
608
|
-
*/
|
|
609
|
-
async forceSyncNow() {
|
|
610
|
-
logger.info("Force sync triggered");
|
|
611
|
-
await this.syncToSharedContext();
|
|
612
|
-
}
|
|
613
|
-
}
|
|
614
|
-
const contextBridge = ContextBridge.getInstance();
|
|
615
|
-
export {
|
|
616
|
-
ContextBridge,
|
|
617
|
-
SharedContextLayer,
|
|
618
|
-
contextBridge,
|
|
619
|
-
sharedContextLayer
|
|
620
|
-
};
|
|
621
|
-
//# sourceMappingURL=shared-context-layer.js.map
|