@stackmemoryai/stackmemory 0.5.58 → 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/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/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 +3 -3
- package/scripts/initialize.ts +16 -7
- package/scripts/install.sh +14 -62
- package/scripts/status.ts +111 -46
|
@@ -0,0 +1,1156 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { fileURLToPath as __fileURLToPath } from 'url';
|
|
3
|
+
import { dirname as __pathDirname } from 'path';
|
|
4
|
+
const __filename = __fileURLToPath(import.meta.url);
|
|
5
|
+
const __dirname = __pathDirname(__filename);
|
|
6
|
+
import { config as loadDotenv } from "dotenv";
|
|
7
|
+
loadDotenv({ override: true, debug: false });
|
|
8
|
+
import { spawn, execSync, execFileSync } from "child_process";
|
|
9
|
+
import * as fs from "fs";
|
|
10
|
+
import * as path from "path";
|
|
11
|
+
import * as os from "os";
|
|
12
|
+
import { program } from "commander";
|
|
13
|
+
import { v4 as uuidv4 } from "uuid";
|
|
14
|
+
import chalk from "chalk";
|
|
15
|
+
import { initializeTracing, trace } from "../core/trace/index.js";
|
|
16
|
+
import {
|
|
17
|
+
generateSessionSummary,
|
|
18
|
+
formatSummaryMessage
|
|
19
|
+
} from "../hooks/session-summary.js";
|
|
20
|
+
import { sendNotification, loadSMSConfig } from "../hooks/sms-notify.js";
|
|
21
|
+
import { enableAutoSync } from "../hooks/whatsapp-sync.js";
|
|
22
|
+
import { enableCommands } from "../hooks/whatsapp-commands.js";
|
|
23
|
+
import { startScheduler, listSchedules } from "../hooks/whatsapp-scheduler.js";
|
|
24
|
+
import {
|
|
25
|
+
getModelRouter,
|
|
26
|
+
loadModelRouterConfig
|
|
27
|
+
} from "../core/models/model-router.js";
|
|
28
|
+
import { launchWrapper } from "../features/sweep/pty-wrapper.js";
|
|
29
|
+
import { FallbackMonitor } from "../core/models/fallback-monitor.js";
|
|
30
|
+
const DEFAULT_SM_CONFIG = {
|
|
31
|
+
defaultWorktree: false,
|
|
32
|
+
defaultSandbox: false,
|
|
33
|
+
defaultChrome: false,
|
|
34
|
+
defaultTracing: true,
|
|
35
|
+
defaultRemote: false,
|
|
36
|
+
defaultNotifyOnDone: true,
|
|
37
|
+
defaultWhatsApp: false,
|
|
38
|
+
defaultModelRouting: false,
|
|
39
|
+
defaultSweep: true,
|
|
40
|
+
defaultGreptile: true
|
|
41
|
+
};
|
|
42
|
+
function getConfigPath() {
|
|
43
|
+
return path.join(os.homedir(), ".stackmemory", "claude-sm.json");
|
|
44
|
+
}
|
|
45
|
+
function loadSMConfig() {
|
|
46
|
+
try {
|
|
47
|
+
const configPath = getConfigPath();
|
|
48
|
+
if (fs.existsSync(configPath)) {
|
|
49
|
+
const content = fs.readFileSync(configPath, "utf8");
|
|
50
|
+
return { ...DEFAULT_SM_CONFIG, ...JSON.parse(content) };
|
|
51
|
+
}
|
|
52
|
+
} catch {
|
|
53
|
+
}
|
|
54
|
+
return { ...DEFAULT_SM_CONFIG };
|
|
55
|
+
}
|
|
56
|
+
function saveSMConfig(config) {
|
|
57
|
+
const configPath = getConfigPath();
|
|
58
|
+
const dir = path.dirname(configPath);
|
|
59
|
+
if (!fs.existsSync(dir)) {
|
|
60
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
61
|
+
}
|
|
62
|
+
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
|
|
63
|
+
}
|
|
64
|
+
class ClaudeSM {
|
|
65
|
+
config;
|
|
66
|
+
stackmemoryPath;
|
|
67
|
+
worktreeScriptPath;
|
|
68
|
+
claudeConfigDir;
|
|
69
|
+
smConfig;
|
|
70
|
+
constructor() {
|
|
71
|
+
this.smConfig = loadSMConfig();
|
|
72
|
+
this.config = {
|
|
73
|
+
instanceId: this.generateInstanceId(),
|
|
74
|
+
useSandbox: this.smConfig.defaultSandbox,
|
|
75
|
+
useChrome: this.smConfig.defaultChrome,
|
|
76
|
+
useWorktree: this.smConfig.defaultWorktree,
|
|
77
|
+
useRemote: this.smConfig.defaultRemote,
|
|
78
|
+
notifyOnDone: this.smConfig.defaultNotifyOnDone,
|
|
79
|
+
useWhatsApp: this.smConfig.defaultWhatsApp,
|
|
80
|
+
contextEnabled: true,
|
|
81
|
+
tracingEnabled: this.smConfig.defaultTracing,
|
|
82
|
+
verboseTracing: false,
|
|
83
|
+
sessionStartTime: Date.now(),
|
|
84
|
+
useModelRouting: this.smConfig.defaultModelRouting,
|
|
85
|
+
useThinkingMode: false,
|
|
86
|
+
useSweep: this.smConfig.defaultSweep,
|
|
87
|
+
useGreptile: this.smConfig.defaultGreptile
|
|
88
|
+
};
|
|
89
|
+
this.stackmemoryPath = this.findStackMemory();
|
|
90
|
+
this.worktreeScriptPath = path.join(
|
|
91
|
+
__dirname,
|
|
92
|
+
"../../scripts/claude-worktree-manager.sh"
|
|
93
|
+
);
|
|
94
|
+
this.claudeConfigDir = path.join(os.homedir(), ".claude");
|
|
95
|
+
if (!fs.existsSync(this.claudeConfigDir)) {
|
|
96
|
+
fs.mkdirSync(this.claudeConfigDir, { recursive: true });
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
generateInstanceId() {
|
|
100
|
+
return uuidv4().substring(0, 8);
|
|
101
|
+
}
|
|
102
|
+
findStackMemory() {
|
|
103
|
+
const possiblePaths = [
|
|
104
|
+
path.join(os.homedir(), ".stackmemory", "bin", "stackmemory"),
|
|
105
|
+
"/usr/local/bin/stackmemory",
|
|
106
|
+
"/opt/homebrew/bin/stackmemory",
|
|
107
|
+
"stackmemory"
|
|
108
|
+
// Rely on PATH
|
|
109
|
+
];
|
|
110
|
+
for (const smPath of possiblePaths) {
|
|
111
|
+
try {
|
|
112
|
+
execFileSync("which", [smPath], { stdio: "ignore" });
|
|
113
|
+
return smPath;
|
|
114
|
+
} catch {
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return "stackmemory";
|
|
118
|
+
}
|
|
119
|
+
isGitRepo() {
|
|
120
|
+
try {
|
|
121
|
+
execSync("git rev-parse --git-dir", { stdio: "ignore" });
|
|
122
|
+
return true;
|
|
123
|
+
} catch {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
getCurrentBranch() {
|
|
128
|
+
try {
|
|
129
|
+
return execSync("git rev-parse --abbrev-ref HEAD", {
|
|
130
|
+
encoding: "utf8"
|
|
131
|
+
}).trim();
|
|
132
|
+
} catch {
|
|
133
|
+
return "main";
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
hasUncommittedChanges() {
|
|
137
|
+
try {
|
|
138
|
+
const status = execSync("git status --porcelain", { encoding: "utf8" });
|
|
139
|
+
return status.length > 0;
|
|
140
|
+
} catch {
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
resolveClaudeBin() {
|
|
145
|
+
if (this.config.claudeBin && this.config.claudeBin.trim()) {
|
|
146
|
+
return this.config.claudeBin.trim();
|
|
147
|
+
}
|
|
148
|
+
const envBin = process.env["CLAUDE_BIN"];
|
|
149
|
+
if (envBin && envBin.trim()) return envBin.trim();
|
|
150
|
+
try {
|
|
151
|
+
execSync("which claude", { stdio: "ignore" });
|
|
152
|
+
return "claude";
|
|
153
|
+
} catch {
|
|
154
|
+
}
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
ensureGreptileMcp() {
|
|
158
|
+
const apiKey = process.env["GREPTILE_API_KEY"];
|
|
159
|
+
const ghToken = process.env["GITHUB_TOKEN"];
|
|
160
|
+
if (!apiKey) {
|
|
161
|
+
console.log(
|
|
162
|
+
chalk.gray(" Greptile: disabled (set GREPTILE_API_KEY in .env)")
|
|
163
|
+
);
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
try {
|
|
167
|
+
const result = execSync("claude mcp list 2>/dev/null", {
|
|
168
|
+
encoding: "utf-8"
|
|
169
|
+
});
|
|
170
|
+
if (result.includes("greptile")) {
|
|
171
|
+
console.log(chalk.gray(" Greptile: MCP server registered"));
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
} catch {
|
|
175
|
+
}
|
|
176
|
+
try {
|
|
177
|
+
const cmd = [
|
|
178
|
+
"claude mcp add",
|
|
179
|
+
"--transport http",
|
|
180
|
+
"greptile",
|
|
181
|
+
"https://api.greptile.com/mcp",
|
|
182
|
+
`--header "Authorization: Bearer ${apiKey}"`
|
|
183
|
+
];
|
|
184
|
+
if (ghToken) {
|
|
185
|
+
cmd.push(`--header "X-GitHub-Token: ${ghToken}"`);
|
|
186
|
+
}
|
|
187
|
+
execSync(cmd.join(" "), { stdio: "ignore" });
|
|
188
|
+
console.log(chalk.cyan(" Greptile: MCP server registered"));
|
|
189
|
+
} catch {
|
|
190
|
+
try {
|
|
191
|
+
const envArgs = [`GREPTILE_API_KEY=${apiKey}`];
|
|
192
|
+
if (ghToken) envArgs.push(`GITHUB_TOKEN=${ghToken}`);
|
|
193
|
+
execSync(
|
|
194
|
+
`claude mcp add greptile -- env ${envArgs.join(" ")} npx greptile-mcp-server`,
|
|
195
|
+
{ stdio: "ignore" }
|
|
196
|
+
);
|
|
197
|
+
console.log(chalk.cyan(" Greptile: MCP server registered (stdio)"));
|
|
198
|
+
} catch {
|
|
199
|
+
console.log(chalk.gray(" Greptile: failed to register MCP server"));
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
setupWorktree() {
|
|
204
|
+
if (!this.config.useWorktree || !this.isGitRepo()) {
|
|
205
|
+
return null;
|
|
206
|
+
}
|
|
207
|
+
console.log(chalk.blue("\u{1F333} Setting up isolated worktree..."));
|
|
208
|
+
const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-").substring(0, 19);
|
|
209
|
+
const branch = this.config.branch || `claude-${this.config.task || "work"}-${timestamp}-${this.config.instanceId}`;
|
|
210
|
+
const repoName = path.basename(process.cwd());
|
|
211
|
+
const worktreePath = path.join(
|
|
212
|
+
path.dirname(process.cwd()),
|
|
213
|
+
`${repoName}--${branch}`
|
|
214
|
+
);
|
|
215
|
+
try {
|
|
216
|
+
const flags = [];
|
|
217
|
+
if (this.config.useSandbox) flags.push("--sandbox");
|
|
218
|
+
if (this.config.useChrome) flags.push("--chrome");
|
|
219
|
+
const cmd = `git worktree add -b "${branch}" "${worktreePath}"`;
|
|
220
|
+
execSync(cmd, { stdio: "inherit" });
|
|
221
|
+
console.log(chalk.green(`\u2705 Worktree created: ${worktreePath}`));
|
|
222
|
+
console.log(chalk.gray(` Branch: ${branch}`));
|
|
223
|
+
const configPath = path.join(worktreePath, ".claude-instance.json");
|
|
224
|
+
const configData = {
|
|
225
|
+
instanceId: this.config.instanceId,
|
|
226
|
+
worktreePath,
|
|
227
|
+
branch,
|
|
228
|
+
task: this.config.task,
|
|
229
|
+
sandboxEnabled: this.config.useSandbox,
|
|
230
|
+
chromeEnabled: this.config.useChrome,
|
|
231
|
+
created: (/* @__PURE__ */ new Date()).toISOString(),
|
|
232
|
+
parentRepo: process.cwd()
|
|
233
|
+
};
|
|
234
|
+
fs.writeFileSync(configPath, JSON.stringify(configData, null, 2));
|
|
235
|
+
const envFiles = [".env", ".env.local", ".mise.toml", ".tool-versions"];
|
|
236
|
+
for (const file of envFiles) {
|
|
237
|
+
const srcPath = path.join(process.cwd(), file);
|
|
238
|
+
if (fs.existsSync(srcPath)) {
|
|
239
|
+
fs.copyFileSync(srcPath, path.join(worktreePath, file));
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
return worktreePath;
|
|
243
|
+
} catch (err) {
|
|
244
|
+
console.error(chalk.red("\u274C Failed to create worktree:"), err);
|
|
245
|
+
return null;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
saveContext(message, metadata = {}) {
|
|
249
|
+
if (!this.config.contextEnabled) return;
|
|
250
|
+
try {
|
|
251
|
+
const contextData = {
|
|
252
|
+
message,
|
|
253
|
+
metadata: {
|
|
254
|
+
...metadata,
|
|
255
|
+
instanceId: this.config.instanceId,
|
|
256
|
+
worktree: this.config.worktreePath,
|
|
257
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
const cmd = `${this.stackmemoryPath} context save --json '${JSON.stringify(contextData)}'`;
|
|
261
|
+
execSync(cmd, { stdio: "ignore" });
|
|
262
|
+
} catch {
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
loadContext() {
|
|
266
|
+
if (!this.config.contextEnabled) return;
|
|
267
|
+
try {
|
|
268
|
+
console.log(chalk.blue("\u{1F4DA} Loading previous context..."));
|
|
269
|
+
const cmd = `${this.stackmemoryPath} context show`;
|
|
270
|
+
const output = execSync(cmd, {
|
|
271
|
+
encoding: "utf8",
|
|
272
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
273
|
+
// Capture stderr to suppress errors
|
|
274
|
+
});
|
|
275
|
+
const lines = output.trim().split("\n").filter((l) => l.trim());
|
|
276
|
+
if (lines.length > 3) {
|
|
277
|
+
console.log(chalk.gray("Context stack loaded"));
|
|
278
|
+
}
|
|
279
|
+
} catch {
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
detectMultipleInstances() {
|
|
283
|
+
try {
|
|
284
|
+
const lockDir = path.join(process.cwd(), ".claude-worktree-locks");
|
|
285
|
+
if (!fs.existsSync(lockDir)) return false;
|
|
286
|
+
const locks = fs.readdirSync(lockDir).filter((f) => f.endsWith(".lock"));
|
|
287
|
+
const activeLocks = locks.filter((lockFile) => {
|
|
288
|
+
const lockPath = path.join(lockDir, lockFile);
|
|
289
|
+
const lockData = JSON.parse(fs.readFileSync(lockPath, "utf8"));
|
|
290
|
+
const lockAge = Date.now() - new Date(lockData.created).getTime();
|
|
291
|
+
return lockAge < 24 * 60 * 60 * 1e3;
|
|
292
|
+
});
|
|
293
|
+
return activeLocks.length > 0;
|
|
294
|
+
} catch {
|
|
295
|
+
return false;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
suggestWorktreeMode() {
|
|
299
|
+
if (this.hasUncommittedChanges()) {
|
|
300
|
+
console.log(chalk.yellow("\u26A0\uFE0F Uncommitted changes detected"));
|
|
301
|
+
console.log(
|
|
302
|
+
chalk.gray(" Consider using --worktree to work in isolation")
|
|
303
|
+
);
|
|
304
|
+
}
|
|
305
|
+
if (this.detectMultipleInstances()) {
|
|
306
|
+
console.log(chalk.yellow("\u26A0\uFE0F Other Claude instances detected"));
|
|
307
|
+
console.log(
|
|
308
|
+
chalk.gray(" Using --worktree is recommended to avoid conflicts")
|
|
309
|
+
);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
async startWhatsAppServices() {
|
|
313
|
+
const WEBHOOK_PORT = 3456;
|
|
314
|
+
console.log(chalk.cyan("\n\u{1F4F1} WhatsApp Mode - Full Integration"));
|
|
315
|
+
console.log(chalk.gray("\u2500".repeat(42)));
|
|
316
|
+
const smsConfig = loadSMSConfig();
|
|
317
|
+
if (!smsConfig.enabled) {
|
|
318
|
+
console.log(
|
|
319
|
+
chalk.yellow(" Notifications disabled. Run: stackmemory notify enable")
|
|
320
|
+
);
|
|
321
|
+
}
|
|
322
|
+
try {
|
|
323
|
+
enableAutoSync();
|
|
324
|
+
console.log(
|
|
325
|
+
chalk.green(" \u2713 Auto-sync enabled (digests on frame close)")
|
|
326
|
+
);
|
|
327
|
+
} catch {
|
|
328
|
+
console.log(chalk.gray(" Auto-sync: skipped"));
|
|
329
|
+
}
|
|
330
|
+
try {
|
|
331
|
+
enableCommands();
|
|
332
|
+
console.log(chalk.green(" \u2713 Command processing enabled"));
|
|
333
|
+
console.log(
|
|
334
|
+
chalk.gray(" Reply: status, tasks, context, help, build, test, lint")
|
|
335
|
+
);
|
|
336
|
+
} catch {
|
|
337
|
+
console.log(chalk.gray(" Command processing: skipped"));
|
|
338
|
+
}
|
|
339
|
+
try {
|
|
340
|
+
const schedules = listSchedules();
|
|
341
|
+
if (schedules.length > 0) {
|
|
342
|
+
startScheduler();
|
|
343
|
+
console.log(
|
|
344
|
+
chalk.green(` \u2713 Scheduler started (${schedules.length} schedules)`)
|
|
345
|
+
);
|
|
346
|
+
}
|
|
347
|
+
} catch {
|
|
348
|
+
}
|
|
349
|
+
const webhookRunning = await fetch(
|
|
350
|
+
`http://localhost:${WEBHOOK_PORT}/health`
|
|
351
|
+
).then((r) => r.ok).catch(() => false);
|
|
352
|
+
if (!webhookRunning) {
|
|
353
|
+
const webhookPath = path.join(__dirname, "../hooks/sms-webhook.js");
|
|
354
|
+
const webhookProcess = spawn("node", [webhookPath], {
|
|
355
|
+
detached: true,
|
|
356
|
+
stdio: "ignore",
|
|
357
|
+
env: { ...process.env, SMS_WEBHOOK_PORT: String(WEBHOOK_PORT) }
|
|
358
|
+
});
|
|
359
|
+
webhookProcess.unref();
|
|
360
|
+
console.log(
|
|
361
|
+
chalk.green(` \u2713 Webhook server started (port ${WEBHOOK_PORT})`)
|
|
362
|
+
);
|
|
363
|
+
} else {
|
|
364
|
+
console.log(
|
|
365
|
+
chalk.green(` \u2713 Webhook already running (port ${WEBHOOK_PORT})`)
|
|
366
|
+
);
|
|
367
|
+
}
|
|
368
|
+
const ngrokRunning = await fetch("http://localhost:4040/api/tunnels").then((r) => r.ok).catch(() => false);
|
|
369
|
+
if (!ngrokRunning) {
|
|
370
|
+
const ngrokProcess = spawn("ngrok", ["http", String(WEBHOOK_PORT)], {
|
|
371
|
+
detached: true,
|
|
372
|
+
stdio: "ignore"
|
|
373
|
+
});
|
|
374
|
+
ngrokProcess.unref();
|
|
375
|
+
console.log(chalk.gray(" Starting ngrok tunnel..."));
|
|
376
|
+
await new Promise((resolve) => setTimeout(resolve, 3e3));
|
|
377
|
+
}
|
|
378
|
+
try {
|
|
379
|
+
const tunnels = await fetch("http://localhost:4040/api/tunnels").then(
|
|
380
|
+
(r) => r.json()
|
|
381
|
+
);
|
|
382
|
+
const publicUrl = tunnels?.tunnels?.[0]?.public_url;
|
|
383
|
+
if (publicUrl) {
|
|
384
|
+
const configDir = path.join(os.homedir(), ".stackmemory");
|
|
385
|
+
const configPath = path.join(configDir, "ngrok-url.txt");
|
|
386
|
+
if (!fs.existsSync(configDir)) {
|
|
387
|
+
fs.mkdirSync(configDir, { recursive: true });
|
|
388
|
+
}
|
|
389
|
+
fs.writeFileSync(configPath, publicUrl);
|
|
390
|
+
console.log(chalk.green(` \u2713 ngrok tunnel: ${publicUrl}/sms/incoming`));
|
|
391
|
+
}
|
|
392
|
+
} catch {
|
|
393
|
+
console.log(chalk.yellow(" ngrok: waiting for tunnel..."));
|
|
394
|
+
}
|
|
395
|
+
if (smsConfig.pendingPrompts.length > 0) {
|
|
396
|
+
console.log();
|
|
397
|
+
console.log(
|
|
398
|
+
chalk.yellow(
|
|
399
|
+
` \u23F3 ${smsConfig.pendingPrompts.length} pending prompt(s) awaiting response:`
|
|
400
|
+
)
|
|
401
|
+
);
|
|
402
|
+
smsConfig.pendingPrompts.slice(0, 3).forEach((p, i) => {
|
|
403
|
+
const msg = p.message.length > 40 ? p.message.slice(0, 40) + "..." : p.message;
|
|
404
|
+
console.log(chalk.gray(` ${i + 1}. [${p.id}] ${msg}`));
|
|
405
|
+
});
|
|
406
|
+
if (smsConfig.pendingPrompts.length > 3) {
|
|
407
|
+
console.log(
|
|
408
|
+
chalk.gray(` ... and ${smsConfig.pendingPrompts.length - 3} more`)
|
|
409
|
+
);
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
console.log();
|
|
413
|
+
console.log(chalk.gray(" Quick actions from WhatsApp:"));
|
|
414
|
+
console.log(chalk.gray(' "status" - session status'));
|
|
415
|
+
console.log(chalk.gray(' "context" - current frame digest'));
|
|
416
|
+
console.log(chalk.gray(' "1", "2" - respond to prompts'));
|
|
417
|
+
console.log(chalk.gray("\u2500".repeat(42)));
|
|
418
|
+
}
|
|
419
|
+
async sendDoneNotification(exitCode) {
|
|
420
|
+
try {
|
|
421
|
+
const context = {
|
|
422
|
+
instanceId: this.config.instanceId,
|
|
423
|
+
exitCode,
|
|
424
|
+
sessionStartTime: this.config.sessionStartTime,
|
|
425
|
+
worktreePath: this.config.worktreePath,
|
|
426
|
+
branch: this.config.branch,
|
|
427
|
+
task: this.config.task
|
|
428
|
+
};
|
|
429
|
+
const summary = await generateSessionSummary(context);
|
|
430
|
+
const message = formatSummaryMessage(summary, this.config.instanceId);
|
|
431
|
+
console.log(chalk.cyan("\nSending session summary via WhatsApp..."));
|
|
432
|
+
let options = summary.suggestions.slice(0, 4).map((s) => ({
|
|
433
|
+
key: s.key,
|
|
434
|
+
label: s.label,
|
|
435
|
+
action: s.action
|
|
436
|
+
}));
|
|
437
|
+
if (options.length < 2) {
|
|
438
|
+
const defaults = [
|
|
439
|
+
{ key: "1", label: "Start new session", action: "claude-sm" },
|
|
440
|
+
{
|
|
441
|
+
key: "2",
|
|
442
|
+
label: "View logs",
|
|
443
|
+
action: "tail -30 ~/.claude/logs/*.log"
|
|
444
|
+
}
|
|
445
|
+
];
|
|
446
|
+
options = defaults.slice(0, 2 - options.length).concat(options);
|
|
447
|
+
options.forEach((o, i) => o.key = String(i + 1));
|
|
448
|
+
}
|
|
449
|
+
const result = await sendNotification({
|
|
450
|
+
type: "task_complete",
|
|
451
|
+
title: `Claude Session ${this.config.instanceId}`,
|
|
452
|
+
message,
|
|
453
|
+
prompt: {
|
|
454
|
+
type: "options",
|
|
455
|
+
options
|
|
456
|
+
}
|
|
457
|
+
});
|
|
458
|
+
if (result.success) {
|
|
459
|
+
console.log(chalk.green("Notification sent successfully"));
|
|
460
|
+
} else {
|
|
461
|
+
console.log(
|
|
462
|
+
chalk.yellow(`Notification not sent: ${result.error || "unknown"}`)
|
|
463
|
+
);
|
|
464
|
+
}
|
|
465
|
+
} catch (error) {
|
|
466
|
+
console.log(
|
|
467
|
+
chalk.yellow(
|
|
468
|
+
`Could not send notification: ${error instanceof Error ? error.message : "unknown"}`
|
|
469
|
+
)
|
|
470
|
+
);
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
async run(args) {
|
|
474
|
+
const claudeArgs = [];
|
|
475
|
+
let i = 0;
|
|
476
|
+
while (i < args.length) {
|
|
477
|
+
const arg = args[i];
|
|
478
|
+
switch (arg) {
|
|
479
|
+
case "--worktree":
|
|
480
|
+
case "-w":
|
|
481
|
+
this.config.useWorktree = true;
|
|
482
|
+
break;
|
|
483
|
+
case "--no-worktree":
|
|
484
|
+
case "-W":
|
|
485
|
+
this.config.useWorktree = false;
|
|
486
|
+
break;
|
|
487
|
+
case "--remote":
|
|
488
|
+
case "-r":
|
|
489
|
+
this.config.useRemote = true;
|
|
490
|
+
break;
|
|
491
|
+
case "--no-remote":
|
|
492
|
+
this.config.useRemote = false;
|
|
493
|
+
break;
|
|
494
|
+
case "--notify-done":
|
|
495
|
+
case "-n":
|
|
496
|
+
this.config.notifyOnDone = true;
|
|
497
|
+
break;
|
|
498
|
+
case "--no-notify-done":
|
|
499
|
+
this.config.notifyOnDone = false;
|
|
500
|
+
break;
|
|
501
|
+
case "--whatsapp":
|
|
502
|
+
this.config.useWhatsApp = true;
|
|
503
|
+
this.config.notifyOnDone = true;
|
|
504
|
+
break;
|
|
505
|
+
case "--no-whatsapp":
|
|
506
|
+
this.config.useWhatsApp = false;
|
|
507
|
+
break;
|
|
508
|
+
case "--sandbox":
|
|
509
|
+
case "-s":
|
|
510
|
+
this.config.useSandbox = true;
|
|
511
|
+
claudeArgs.push("--sandbox");
|
|
512
|
+
break;
|
|
513
|
+
case "--chrome":
|
|
514
|
+
case "-c":
|
|
515
|
+
this.config.useChrome = true;
|
|
516
|
+
claudeArgs.push("--chrome");
|
|
517
|
+
break;
|
|
518
|
+
case "--no-context":
|
|
519
|
+
this.config.contextEnabled = false;
|
|
520
|
+
break;
|
|
521
|
+
case "--no-trace":
|
|
522
|
+
this.config.tracingEnabled = false;
|
|
523
|
+
break;
|
|
524
|
+
case "--verbose-trace":
|
|
525
|
+
this.config.verboseTracing = true;
|
|
526
|
+
break;
|
|
527
|
+
case "--branch":
|
|
528
|
+
case "-b":
|
|
529
|
+
i++;
|
|
530
|
+
this.config.branch = args[i];
|
|
531
|
+
break;
|
|
532
|
+
case "--task":
|
|
533
|
+
case "-t":
|
|
534
|
+
i++;
|
|
535
|
+
this.config.task = args[i];
|
|
536
|
+
break;
|
|
537
|
+
case "--claude-bin":
|
|
538
|
+
i++;
|
|
539
|
+
this.config.claudeBin = args[i];
|
|
540
|
+
process.env["CLAUDE_BIN"] = this.config.claudeBin;
|
|
541
|
+
break;
|
|
542
|
+
case "--auto":
|
|
543
|
+
case "-a":
|
|
544
|
+
if (this.isGitRepo()) {
|
|
545
|
+
this.config.useWorktree = this.hasUncommittedChanges() || this.detectMultipleInstances();
|
|
546
|
+
}
|
|
547
|
+
break;
|
|
548
|
+
case "--think":
|
|
549
|
+
case "--think-hard":
|
|
550
|
+
case "--ultrathink":
|
|
551
|
+
this.config.useThinkingMode = true;
|
|
552
|
+
this.config.useModelRouting = true;
|
|
553
|
+
this.config.forceProvider = "qwen";
|
|
554
|
+
break;
|
|
555
|
+
case "--qwen":
|
|
556
|
+
this.config.useModelRouting = true;
|
|
557
|
+
this.config.forceProvider = "qwen";
|
|
558
|
+
break;
|
|
559
|
+
case "--openai":
|
|
560
|
+
this.config.useModelRouting = true;
|
|
561
|
+
this.config.forceProvider = "openai";
|
|
562
|
+
break;
|
|
563
|
+
case "--ollama":
|
|
564
|
+
this.config.useModelRouting = true;
|
|
565
|
+
this.config.forceProvider = "ollama";
|
|
566
|
+
break;
|
|
567
|
+
case "--model-routing":
|
|
568
|
+
this.config.useModelRouting = true;
|
|
569
|
+
break;
|
|
570
|
+
case "--no-model-routing":
|
|
571
|
+
this.config.useModelRouting = false;
|
|
572
|
+
break;
|
|
573
|
+
case "--sweep":
|
|
574
|
+
this.config.useSweep = true;
|
|
575
|
+
break;
|
|
576
|
+
case "--no-sweep":
|
|
577
|
+
this.config.useSweep = false;
|
|
578
|
+
break;
|
|
579
|
+
case "--greptile":
|
|
580
|
+
this.config.useGreptile = true;
|
|
581
|
+
break;
|
|
582
|
+
case "--no-greptile":
|
|
583
|
+
this.config.useGreptile = false;
|
|
584
|
+
break;
|
|
585
|
+
default:
|
|
586
|
+
claudeArgs.push(arg);
|
|
587
|
+
}
|
|
588
|
+
i++;
|
|
589
|
+
}
|
|
590
|
+
const printIndex = claudeArgs.findIndex(
|
|
591
|
+
(a) => a === "-p" || a === "--print"
|
|
592
|
+
);
|
|
593
|
+
if (printIndex !== -1) {
|
|
594
|
+
const nextArg = claudeArgs[printIndex + 1];
|
|
595
|
+
const hasStdin = !process.stdin.isTTY;
|
|
596
|
+
const hasPromptArg = nextArg && !nextArg.startsWith("-");
|
|
597
|
+
if (!hasStdin && !hasPromptArg) {
|
|
598
|
+
console.error(
|
|
599
|
+
chalk.red("Error: --print/-p requires a prompt argument.")
|
|
600
|
+
);
|
|
601
|
+
console.log(chalk.gray('Usage: claude-smd -p "your prompt here"'));
|
|
602
|
+
console.log(chalk.gray(' echo "prompt" | claude-smd -p'));
|
|
603
|
+
process.exit(1);
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
if (this.config.tracingEnabled) {
|
|
607
|
+
process.env["DEBUG_TRACE"] = "true";
|
|
608
|
+
process.env["STACKMEMORY_DEBUG"] = "true";
|
|
609
|
+
process.env["TRACE_OUTPUT"] = "file";
|
|
610
|
+
process.env["TRACE_MASK_SENSITIVE"] = "true";
|
|
611
|
+
if (this.config.verboseTracing) {
|
|
612
|
+
process.env["TRACE_VERBOSITY"] = "full";
|
|
613
|
+
process.env["TRACE_PARAMS"] = "true";
|
|
614
|
+
process.env["TRACE_RESULTS"] = "true";
|
|
615
|
+
process.env["TRACE_MEMORY"] = "true";
|
|
616
|
+
} else {
|
|
617
|
+
process.env["TRACE_VERBOSITY"] = "summary";
|
|
618
|
+
process.env["TRACE_PARAMS"] = "true";
|
|
619
|
+
process.env["TRACE_RESULTS"] = "false";
|
|
620
|
+
}
|
|
621
|
+
initializeTracing();
|
|
622
|
+
trace.command(
|
|
623
|
+
"claude-sm",
|
|
624
|
+
{
|
|
625
|
+
instanceId: this.config.instanceId,
|
|
626
|
+
worktree: this.config.useWorktree,
|
|
627
|
+
sandbox: this.config.useSandbox,
|
|
628
|
+
task: this.config.task
|
|
629
|
+
},
|
|
630
|
+
async () => {
|
|
631
|
+
}
|
|
632
|
+
);
|
|
633
|
+
}
|
|
634
|
+
console.log(chalk.blue("\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557"));
|
|
635
|
+
console.log(chalk.blue("\u2551 Claude + StackMemory + Worktree \u2551"));
|
|
636
|
+
console.log(chalk.blue("\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D"));
|
|
637
|
+
console.log();
|
|
638
|
+
if (this.isGitRepo()) {
|
|
639
|
+
const branch = this.getCurrentBranch();
|
|
640
|
+
console.log(chalk.gray(`\u{1F4CD} Current branch: ${branch}`));
|
|
641
|
+
if (!this.config.useWorktree) {
|
|
642
|
+
this.suggestWorktreeMode();
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
if (this.config.useWorktree) {
|
|
646
|
+
const worktreePath = this.setupWorktree();
|
|
647
|
+
if (worktreePath) {
|
|
648
|
+
this.config.worktreePath = worktreePath;
|
|
649
|
+
process.chdir(worktreePath);
|
|
650
|
+
this.saveContext("Created worktree for Claude instance", {
|
|
651
|
+
action: "worktree_created",
|
|
652
|
+
path: worktreePath,
|
|
653
|
+
branch: this.config.branch
|
|
654
|
+
});
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
this.loadContext();
|
|
658
|
+
process.env["CLAUDE_INSTANCE_ID"] = this.config.instanceId;
|
|
659
|
+
if (this.config.worktreePath) {
|
|
660
|
+
process.env["CLAUDE_WORKTREE_PATH"] = this.config.worktreePath;
|
|
661
|
+
}
|
|
662
|
+
if (this.config.useRemote) {
|
|
663
|
+
process.env["CLAUDE_REMOTE"] = "1";
|
|
664
|
+
}
|
|
665
|
+
console.log(chalk.gray(`\u{1F916} Instance ID: ${this.config.instanceId}`));
|
|
666
|
+
console.log(chalk.gray(`\u{1F4C1} Working in: ${process.cwd()}`));
|
|
667
|
+
if (this.config.useSandbox) {
|
|
668
|
+
console.log(chalk.yellow("\u{1F512} Sandbox mode enabled"));
|
|
669
|
+
}
|
|
670
|
+
if (this.config.useRemote) {
|
|
671
|
+
console.log(
|
|
672
|
+
chalk.cyan("\u{1F4F1} Remote mode: WhatsApp notifications for all questions")
|
|
673
|
+
);
|
|
674
|
+
}
|
|
675
|
+
if (this.config.useChrome) {
|
|
676
|
+
console.log(chalk.yellow("\u{1F310} Chrome automation enabled"));
|
|
677
|
+
}
|
|
678
|
+
if (this.config.tracingEnabled) {
|
|
679
|
+
console.log(
|
|
680
|
+
chalk.gray(`\u{1F50D} Debug tracing enabled (logs to ~/.stackmemory/traces/)`)
|
|
681
|
+
);
|
|
682
|
+
if (this.config.verboseTracing) {
|
|
683
|
+
console.log(
|
|
684
|
+
chalk.gray(` Verbose mode: capturing all execution details`)
|
|
685
|
+
);
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
if (this.config.useModelRouting) {
|
|
689
|
+
const routerConfig = loadModelRouterConfig();
|
|
690
|
+
if (routerConfig.enabled || this.config.forceProvider) {
|
|
691
|
+
const router = getModelRouter();
|
|
692
|
+
let routeResult;
|
|
693
|
+
if (this.config.forceProvider) {
|
|
694
|
+
const env = router.switchTo(this.config.forceProvider);
|
|
695
|
+
Object.assign(process.env, env);
|
|
696
|
+
console.log(
|
|
697
|
+
chalk.magenta(`\u{1F500} Model: ${this.config.forceProvider} (forced)`)
|
|
698
|
+
);
|
|
699
|
+
if (this.config.forceProvider === "qwen" && this.config.useThinkingMode) {
|
|
700
|
+
const qwenConfig = routerConfig.providers.qwen;
|
|
701
|
+
if (qwenConfig?.params?.enable_thinking) {
|
|
702
|
+
console.log(
|
|
703
|
+
chalk.gray(
|
|
704
|
+
` Thinking mode: budget ${qwenConfig.params.thinking_budget || 1e4} tokens`
|
|
705
|
+
)
|
|
706
|
+
);
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
} else {
|
|
710
|
+
const taskType = this.config.useThinkingMode ? "think" : "default";
|
|
711
|
+
routeResult = router.route(taskType, this.config.task);
|
|
712
|
+
Object.assign(process.env, routeResult.env);
|
|
713
|
+
if (routeResult.switched) {
|
|
714
|
+
console.log(
|
|
715
|
+
chalk.magenta(`\u{1F500} Model routed to: ${routeResult.provider}`)
|
|
716
|
+
);
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
} else {
|
|
720
|
+
console.log(
|
|
721
|
+
chalk.gray(
|
|
722
|
+
" Model routing: disabled (run: stackmemory model enable)"
|
|
723
|
+
)
|
|
724
|
+
);
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
if (this.config.useGreptile) {
|
|
728
|
+
this.ensureGreptileMcp();
|
|
729
|
+
}
|
|
730
|
+
if (this.config.useWhatsApp) {
|
|
731
|
+
console.log(
|
|
732
|
+
chalk.cyan("\u{1F4F1} WhatsApp mode: notifications + webhook enabled")
|
|
733
|
+
);
|
|
734
|
+
await this.startWhatsAppServices();
|
|
735
|
+
}
|
|
736
|
+
console.log();
|
|
737
|
+
if (this.config.useSweep) {
|
|
738
|
+
const claudeBin2 = this.resolveClaudeBin();
|
|
739
|
+
if (!claudeBin2) {
|
|
740
|
+
console.error(chalk.red("Claude CLI not found."));
|
|
741
|
+
process.exit(1);
|
|
742
|
+
return;
|
|
743
|
+
}
|
|
744
|
+
console.log(
|
|
745
|
+
chalk.cyan("[Sweep] Launching Claude with prediction bar...")
|
|
746
|
+
);
|
|
747
|
+
console.log(chalk.gray("\u2500".repeat(42)));
|
|
748
|
+
try {
|
|
749
|
+
await launchWrapper({
|
|
750
|
+
claudeBin: claudeBin2,
|
|
751
|
+
claudeArgs
|
|
752
|
+
});
|
|
753
|
+
} catch (error) {
|
|
754
|
+
console.error(chalk.red(error.message));
|
|
755
|
+
process.exit(1);
|
|
756
|
+
}
|
|
757
|
+
return;
|
|
758
|
+
}
|
|
759
|
+
console.log(chalk.gray("Starting Claude..."));
|
|
760
|
+
console.log(chalk.gray("\u2500".repeat(42)));
|
|
761
|
+
const claudeBin = this.resolveClaudeBin();
|
|
762
|
+
if (!claudeBin) {
|
|
763
|
+
console.error(chalk.red("\u274C Claude CLI not found."));
|
|
764
|
+
console.log(
|
|
765
|
+
chalk.gray(
|
|
766
|
+
" Install Claude CLI or set an override:\n export CLAUDE_BIN=/path/to/claude\n claude-sm --help\n\n Ensure PATH includes npm global bin (npm bin -g)."
|
|
767
|
+
)
|
|
768
|
+
);
|
|
769
|
+
process.exit(1);
|
|
770
|
+
return;
|
|
771
|
+
}
|
|
772
|
+
const fallbackMonitor = new FallbackMonitor({
|
|
773
|
+
enabled: true,
|
|
774
|
+
maxRestarts: 2,
|
|
775
|
+
restartDelayMs: 1500,
|
|
776
|
+
onFallback: (provider, reason) => {
|
|
777
|
+
console.log(chalk.yellow(`
|
|
778
|
+
[auto-fallback] Switching to ${provider}`));
|
|
779
|
+
console.log(chalk.gray(` Reason: ${reason}`));
|
|
780
|
+
console.log(chalk.gray(` Session will continue on ${provider}...`));
|
|
781
|
+
if (this.config.notifyOnDone || this.config.useWhatsApp) {
|
|
782
|
+
sendNotification({
|
|
783
|
+
type: "custom",
|
|
784
|
+
title: "Model Fallback",
|
|
785
|
+
message: `Claude unavailable (${reason}). Switched to ${provider}.`
|
|
786
|
+
}).catch(() => {
|
|
787
|
+
});
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
});
|
|
791
|
+
const fallbackAvailable = fallbackMonitor.isFallbackAvailable();
|
|
792
|
+
if (fallbackAvailable) {
|
|
793
|
+
console.log(
|
|
794
|
+
chalk.gray(` Auto-fallback: Qwen ready (on rate limit/error)`)
|
|
795
|
+
);
|
|
796
|
+
}
|
|
797
|
+
const wrapper = fallbackMonitor.wrapProcess(claudeBin, claudeArgs, {
|
|
798
|
+
env: process.env,
|
|
799
|
+
cwd: process.cwd()
|
|
800
|
+
});
|
|
801
|
+
const claude = wrapper.start();
|
|
802
|
+
claude.on("error", (err) => {
|
|
803
|
+
console.error(chalk.red("\u274C Failed to launch Claude CLI."));
|
|
804
|
+
if (err.code === "ENOENT") {
|
|
805
|
+
console.error(
|
|
806
|
+
chalk.gray(" Not found. Set CLAUDE_BIN or install claude on PATH.")
|
|
807
|
+
);
|
|
808
|
+
} else if (err.code === "EPERM" || err.code === "EACCES") {
|
|
809
|
+
console.error(
|
|
810
|
+
chalk.gray(
|
|
811
|
+
" Permission/sandbox issue. Try outside a sandbox or set CLAUDE_BIN."
|
|
812
|
+
)
|
|
813
|
+
);
|
|
814
|
+
} else {
|
|
815
|
+
console.error(chalk.gray(` ${err.message}`));
|
|
816
|
+
}
|
|
817
|
+
process.exit(1);
|
|
818
|
+
});
|
|
819
|
+
claude.on("exit", async (code) => {
|
|
820
|
+
const status = fallbackMonitor.getStatus();
|
|
821
|
+
if (status.inFallback) {
|
|
822
|
+
console.log(
|
|
823
|
+
chalk.yellow(
|
|
824
|
+
`
|
|
825
|
+
Session completed on fallback provider: ${status.currentProvider}`
|
|
826
|
+
)
|
|
827
|
+
);
|
|
828
|
+
}
|
|
829
|
+
this.saveContext("Claude session ended", {
|
|
830
|
+
action: "session_end",
|
|
831
|
+
exitCode: code
|
|
832
|
+
});
|
|
833
|
+
if (this.config.tracingEnabled) {
|
|
834
|
+
const summary = trace.getExecutionSummary();
|
|
835
|
+
console.log();
|
|
836
|
+
console.log(chalk.gray("\u2500".repeat(42)));
|
|
837
|
+
console.log(chalk.blue("Debug Trace Summary:"));
|
|
838
|
+
console.log(chalk.gray(summary));
|
|
839
|
+
}
|
|
840
|
+
if (this.config.notifyOnDone || this.config.useRemote) {
|
|
841
|
+
await this.sendDoneNotification(code);
|
|
842
|
+
}
|
|
843
|
+
if (this.config.worktreePath) {
|
|
844
|
+
console.log();
|
|
845
|
+
console.log(chalk.gray("\u2500".repeat(42)));
|
|
846
|
+
console.log(chalk.blue("Session ended in worktree:"));
|
|
847
|
+
console.log(chalk.gray(` ${this.config.worktreePath}`));
|
|
848
|
+
console.log();
|
|
849
|
+
console.log(chalk.gray("To remove worktree: gd_claude"));
|
|
850
|
+
console.log(chalk.gray("To merge to main: cwm"));
|
|
851
|
+
}
|
|
852
|
+
process.exit(code || 0);
|
|
853
|
+
});
|
|
854
|
+
process.on("SIGINT", () => {
|
|
855
|
+
this.saveContext("Claude session interrupted", {
|
|
856
|
+
action: "session_interrupt"
|
|
857
|
+
});
|
|
858
|
+
claude.kill("SIGINT");
|
|
859
|
+
});
|
|
860
|
+
process.on("SIGTERM", () => {
|
|
861
|
+
this.saveContext("Claude session terminated", {
|
|
862
|
+
action: "session_terminate"
|
|
863
|
+
});
|
|
864
|
+
claude.kill("SIGTERM");
|
|
865
|
+
});
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
program.name("claude-sm").description("Claude with StackMemory context and worktree isolation").version("1.0.0");
|
|
869
|
+
const configCmd = program.command("config").description("Manage claude-sm defaults");
|
|
870
|
+
configCmd.command("show").description("Show current default settings").action(() => {
|
|
871
|
+
const config = loadSMConfig();
|
|
872
|
+
console.log(chalk.blue("claude-sm defaults:"));
|
|
873
|
+
console.log(
|
|
874
|
+
` defaultWorktree: ${config.defaultWorktree ? chalk.green("true") : chalk.gray("false")}`
|
|
875
|
+
);
|
|
876
|
+
console.log(
|
|
877
|
+
` defaultSandbox: ${config.defaultSandbox ? chalk.green("true") : chalk.gray("false")}`
|
|
878
|
+
);
|
|
879
|
+
console.log(
|
|
880
|
+
` defaultChrome: ${config.defaultChrome ? chalk.green("true") : chalk.gray("false")}`
|
|
881
|
+
);
|
|
882
|
+
console.log(
|
|
883
|
+
` defaultTracing: ${config.defaultTracing ? chalk.green("true") : chalk.gray("false")}`
|
|
884
|
+
);
|
|
885
|
+
console.log(
|
|
886
|
+
` defaultRemote: ${config.defaultRemote ? chalk.green("true") : chalk.gray("false")}`
|
|
887
|
+
);
|
|
888
|
+
console.log(
|
|
889
|
+
` defaultNotifyOnDone: ${config.defaultNotifyOnDone ? chalk.green("true") : chalk.gray("false")}`
|
|
890
|
+
);
|
|
891
|
+
console.log(
|
|
892
|
+
` defaultWhatsApp: ${config.defaultWhatsApp ? chalk.green("true") : chalk.gray("false")}`
|
|
893
|
+
);
|
|
894
|
+
console.log(
|
|
895
|
+
` defaultModelRouting: ${config.defaultModelRouting ? chalk.green("true") : chalk.gray("false")}`
|
|
896
|
+
);
|
|
897
|
+
console.log(
|
|
898
|
+
` defaultSweep: ${config.defaultSweep ? chalk.green("true") : chalk.gray("false")}`
|
|
899
|
+
);
|
|
900
|
+
console.log(
|
|
901
|
+
` defaultGreptile: ${config.defaultGreptile ? chalk.green("true") : chalk.gray("false")}`
|
|
902
|
+
);
|
|
903
|
+
console.log(chalk.gray(`
|
|
904
|
+
Config: ${getConfigPath()}`));
|
|
905
|
+
});
|
|
906
|
+
configCmd.command("set <key> <value>").description("Set a default (e.g., set worktree true)").action((key, value) => {
|
|
907
|
+
const config = loadSMConfig();
|
|
908
|
+
const boolValue = value === "true" || value === "1" || value === "on";
|
|
909
|
+
const keyMap = {
|
|
910
|
+
worktree: "defaultWorktree",
|
|
911
|
+
sandbox: "defaultSandbox",
|
|
912
|
+
chrome: "defaultChrome",
|
|
913
|
+
tracing: "defaultTracing",
|
|
914
|
+
remote: "defaultRemote",
|
|
915
|
+
"notify-done": "defaultNotifyOnDone",
|
|
916
|
+
notifyondone: "defaultNotifyOnDone",
|
|
917
|
+
whatsapp: "defaultWhatsApp",
|
|
918
|
+
"model-routing": "defaultModelRouting",
|
|
919
|
+
modelrouting: "defaultModelRouting",
|
|
920
|
+
sweep: "defaultSweep",
|
|
921
|
+
greptile: "defaultGreptile"
|
|
922
|
+
};
|
|
923
|
+
const configKey = keyMap[key];
|
|
924
|
+
if (!configKey) {
|
|
925
|
+
console.log(chalk.red(`Unknown key: ${key}`));
|
|
926
|
+
console.log(
|
|
927
|
+
chalk.gray(
|
|
928
|
+
"Valid keys: worktree, sandbox, chrome, tracing, remote, notify-done, whatsapp, sweep, greptile"
|
|
929
|
+
)
|
|
930
|
+
);
|
|
931
|
+
process.exit(1);
|
|
932
|
+
}
|
|
933
|
+
config[configKey] = boolValue;
|
|
934
|
+
saveSMConfig(config);
|
|
935
|
+
console.log(chalk.green(`Set ${key} = ${boolValue}`));
|
|
936
|
+
});
|
|
937
|
+
configCmd.command("worktree-on").description("Enable worktree mode by default").action(() => {
|
|
938
|
+
const config = loadSMConfig();
|
|
939
|
+
config.defaultWorktree = true;
|
|
940
|
+
saveSMConfig(config);
|
|
941
|
+
console.log(chalk.green("Worktree mode enabled by default"));
|
|
942
|
+
});
|
|
943
|
+
configCmd.command("worktree-off").description("Disable worktree mode by default").action(() => {
|
|
944
|
+
const config = loadSMConfig();
|
|
945
|
+
config.defaultWorktree = false;
|
|
946
|
+
saveSMConfig(config);
|
|
947
|
+
console.log(chalk.green("Worktree mode disabled by default"));
|
|
948
|
+
});
|
|
949
|
+
configCmd.command("remote-on").description("Enable remote mode by default (WhatsApp for all questions)").action(() => {
|
|
950
|
+
const config = loadSMConfig();
|
|
951
|
+
config.defaultRemote = true;
|
|
952
|
+
saveSMConfig(config);
|
|
953
|
+
console.log(chalk.green("Remote mode enabled by default"));
|
|
954
|
+
});
|
|
955
|
+
configCmd.command("remote-off").description("Disable remote mode by default").action(() => {
|
|
956
|
+
const config = loadSMConfig();
|
|
957
|
+
config.defaultRemote = false;
|
|
958
|
+
saveSMConfig(config);
|
|
959
|
+
console.log(chalk.green("Remote mode disabled by default"));
|
|
960
|
+
});
|
|
961
|
+
configCmd.command("notify-done-on").description("Enable WhatsApp notification when session ends (default)").action(() => {
|
|
962
|
+
const config = loadSMConfig();
|
|
963
|
+
config.defaultNotifyOnDone = true;
|
|
964
|
+
saveSMConfig(config);
|
|
965
|
+
console.log(chalk.green("Notify-on-done enabled by default"));
|
|
966
|
+
});
|
|
967
|
+
configCmd.command("notify-done-off").description("Disable notification when session ends").action(() => {
|
|
968
|
+
const config = loadSMConfig();
|
|
969
|
+
config.defaultNotifyOnDone = false;
|
|
970
|
+
saveSMConfig(config);
|
|
971
|
+
console.log(chalk.green("Notify-on-done disabled by default"));
|
|
972
|
+
});
|
|
973
|
+
configCmd.command("whatsapp-on").description("Enable WhatsApp mode by default (auto-starts webhook + ngrok)").action(() => {
|
|
974
|
+
const config = loadSMConfig();
|
|
975
|
+
config.defaultWhatsApp = true;
|
|
976
|
+
config.defaultNotifyOnDone = true;
|
|
977
|
+
saveSMConfig(config);
|
|
978
|
+
console.log(chalk.green("WhatsApp mode enabled by default"));
|
|
979
|
+
console.log(chalk.gray("Sessions will auto-start webhook and ngrok"));
|
|
980
|
+
});
|
|
981
|
+
configCmd.command("whatsapp-off").description("Disable WhatsApp mode by default").action(() => {
|
|
982
|
+
const config = loadSMConfig();
|
|
983
|
+
config.defaultWhatsApp = false;
|
|
984
|
+
saveSMConfig(config);
|
|
985
|
+
console.log(chalk.green("WhatsApp mode disabled by default"));
|
|
986
|
+
});
|
|
987
|
+
configCmd.command("model-routing-on").description(
|
|
988
|
+
"Enable model routing by default (route tasks to Qwen/other models)"
|
|
989
|
+
).action(() => {
|
|
990
|
+
const config = loadSMConfig();
|
|
991
|
+
config.defaultModelRouting = true;
|
|
992
|
+
saveSMConfig(config);
|
|
993
|
+
console.log(chalk.green("Model routing enabled by default"));
|
|
994
|
+
console.log(chalk.gray("Configure with: stackmemory model setup-qwen"));
|
|
995
|
+
});
|
|
996
|
+
configCmd.command("model-routing-off").description("Disable model routing by default (use Claude only)").action(() => {
|
|
997
|
+
const config = loadSMConfig();
|
|
998
|
+
config.defaultModelRouting = false;
|
|
999
|
+
saveSMConfig(config);
|
|
1000
|
+
console.log(chalk.green("Model routing disabled by default"));
|
|
1001
|
+
});
|
|
1002
|
+
configCmd.command("greptile-on").description(
|
|
1003
|
+
"Enable Greptile AI code review by default (requires GREPTILE_API_KEY)"
|
|
1004
|
+
).action(() => {
|
|
1005
|
+
const config = loadSMConfig();
|
|
1006
|
+
config.defaultGreptile = true;
|
|
1007
|
+
saveSMConfig(config);
|
|
1008
|
+
console.log(chalk.green("Greptile enabled by default"));
|
|
1009
|
+
if (!process.env["GREPTILE_API_KEY"]) {
|
|
1010
|
+
console.log(chalk.gray("Set GREPTILE_API_KEY in .env to activate"));
|
|
1011
|
+
}
|
|
1012
|
+
});
|
|
1013
|
+
configCmd.command("greptile-off").description("Disable Greptile AI code review by default").action(() => {
|
|
1014
|
+
const config = loadSMConfig();
|
|
1015
|
+
config.defaultGreptile = false;
|
|
1016
|
+
saveSMConfig(config);
|
|
1017
|
+
console.log(chalk.green("Greptile disabled by default"));
|
|
1018
|
+
});
|
|
1019
|
+
configCmd.command("setup").description("Interactive feature setup wizard").action(async () => {
|
|
1020
|
+
const inquirer = await import("inquirer");
|
|
1021
|
+
const ora = (await import("ora")).default;
|
|
1022
|
+
const config = loadSMConfig();
|
|
1023
|
+
console.log(chalk.cyan("\nClaude-SM Feature Setup\n"));
|
|
1024
|
+
const features = [
|
|
1025
|
+
{
|
|
1026
|
+
key: "defaultSweep",
|
|
1027
|
+
name: "Sweep",
|
|
1028
|
+
desc: "Next-edit predictions via PTY wrapper (installs node-pty)"
|
|
1029
|
+
},
|
|
1030
|
+
{
|
|
1031
|
+
key: "defaultGreptile",
|
|
1032
|
+
name: "Greptile",
|
|
1033
|
+
desc: "AI code review MCP server (requires GREPTILE_API_KEY)"
|
|
1034
|
+
},
|
|
1035
|
+
{
|
|
1036
|
+
key: "defaultModelRouting",
|
|
1037
|
+
name: "Model Routing",
|
|
1038
|
+
desc: "Route tasks to Qwen/other providers"
|
|
1039
|
+
},
|
|
1040
|
+
{
|
|
1041
|
+
key: "defaultWorktree",
|
|
1042
|
+
name: "Worktree",
|
|
1043
|
+
desc: "Git worktree isolation per instance"
|
|
1044
|
+
},
|
|
1045
|
+
{
|
|
1046
|
+
key: "defaultWhatsApp",
|
|
1047
|
+
name: "WhatsApp",
|
|
1048
|
+
desc: "Notifications and remote control"
|
|
1049
|
+
},
|
|
1050
|
+
{
|
|
1051
|
+
key: "defaultTracing",
|
|
1052
|
+
name: "Tracing",
|
|
1053
|
+
desc: "Debug trace logging"
|
|
1054
|
+
},
|
|
1055
|
+
{
|
|
1056
|
+
key: "defaultNotifyOnDone",
|
|
1057
|
+
name: "Notify on Done",
|
|
1058
|
+
desc: "Notification when session ends"
|
|
1059
|
+
}
|
|
1060
|
+
];
|
|
1061
|
+
const choices = features.map((f) => ({
|
|
1062
|
+
name: `${f.name} - ${f.desc}`,
|
|
1063
|
+
value: f.key,
|
|
1064
|
+
checked: config[f.key]
|
|
1065
|
+
}));
|
|
1066
|
+
const { selected } = await inquirer.default.prompt([
|
|
1067
|
+
{
|
|
1068
|
+
type: "checkbox",
|
|
1069
|
+
name: "selected",
|
|
1070
|
+
message: "Select features to enable:",
|
|
1071
|
+
choices
|
|
1072
|
+
}
|
|
1073
|
+
]);
|
|
1074
|
+
const selectedKeys = selected;
|
|
1075
|
+
for (const f of features) {
|
|
1076
|
+
config[f.key] = selectedKeys.includes(f.key);
|
|
1077
|
+
}
|
|
1078
|
+
saveSMConfig(config);
|
|
1079
|
+
if (config.defaultSweep) {
|
|
1080
|
+
let hasPty = false;
|
|
1081
|
+
try {
|
|
1082
|
+
await import("node-pty");
|
|
1083
|
+
hasPty = true;
|
|
1084
|
+
} catch {
|
|
1085
|
+
}
|
|
1086
|
+
if (!hasPty) {
|
|
1087
|
+
const spinner = ora("Installing node-pty...").start();
|
|
1088
|
+
try {
|
|
1089
|
+
execSync("npm install node-pty", {
|
|
1090
|
+
stdio: "ignore",
|
|
1091
|
+
cwd: process.cwd()
|
|
1092
|
+
});
|
|
1093
|
+
spinner.succeed("node-pty installed");
|
|
1094
|
+
} catch {
|
|
1095
|
+
spinner.fail("Failed to install node-pty");
|
|
1096
|
+
console.log(chalk.gray(" Install manually: npm install node-pty"));
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
1100
|
+
if (config.defaultGreptile) {
|
|
1101
|
+
const apiKey = process.env["GREPTILE_API_KEY"];
|
|
1102
|
+
if (!apiKey) {
|
|
1103
|
+
const { key } = await inquirer.default.prompt([
|
|
1104
|
+
{
|
|
1105
|
+
type: "password",
|
|
1106
|
+
name: "key",
|
|
1107
|
+
message: "Enter your Greptile API key (from app.greptile.com):",
|
|
1108
|
+
mask: "*"
|
|
1109
|
+
}
|
|
1110
|
+
]);
|
|
1111
|
+
if (key && key.trim()) {
|
|
1112
|
+
const envPath = path.join(process.cwd(), ".env");
|
|
1113
|
+
const line = `
|
|
1114
|
+
GREPTILE_API_KEY=${key.trim()}
|
|
1115
|
+
`;
|
|
1116
|
+
fs.appendFileSync(envPath, line);
|
|
1117
|
+
process.env["GREPTILE_API_KEY"] = key.trim();
|
|
1118
|
+
console.log(chalk.green(" API key saved to .env"));
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
const currentKey = process.env["GREPTILE_API_KEY"];
|
|
1122
|
+
if (currentKey) {
|
|
1123
|
+
try {
|
|
1124
|
+
const result = execSync("claude mcp list 2>/dev/null", {
|
|
1125
|
+
encoding: "utf-8"
|
|
1126
|
+
});
|
|
1127
|
+
if (!result.includes("greptile")) {
|
|
1128
|
+
execSync(
|
|
1129
|
+
`claude mcp add --transport http greptile https://api.greptile.com/mcp --header "Authorization: Bearer ${currentKey}"`,
|
|
1130
|
+
{ stdio: "ignore" }
|
|
1131
|
+
);
|
|
1132
|
+
console.log(chalk.green(" Greptile MCP server registered"));
|
|
1133
|
+
}
|
|
1134
|
+
} catch {
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
console.log(chalk.cyan("\nFeature summary:"));
|
|
1139
|
+
for (const f of features) {
|
|
1140
|
+
const on = config[f.key];
|
|
1141
|
+
const mark = on ? chalk.green("ON") : chalk.gray("OFF");
|
|
1142
|
+
console.log(` ${mark} ${f.name}`);
|
|
1143
|
+
}
|
|
1144
|
+
console.log(chalk.gray(`
|
|
1145
|
+
Saved to ${getConfigPath()}`));
|
|
1146
|
+
});
|
|
1147
|
+
program.option("-w, --worktree", "Create isolated worktree for this instance").option("-W, --no-worktree", "Disable worktree (override default)").option("-r, --remote", "Enable remote mode (WhatsApp for all questions)").option("--no-remote", "Disable remote mode (override default)").option("-n, --notify-done", "Send WhatsApp notification when session ends").option("--no-notify-done", "Disable notification when session ends").option(
|
|
1148
|
+
"--whatsapp",
|
|
1149
|
+
"Enable WhatsApp mode (auto-start webhook + ngrok + notifications)"
|
|
1150
|
+
).option("--no-whatsapp", "Disable WhatsApp mode (override default)").option("-s, --sandbox", "Enable sandbox mode (file/network restrictions)").option("-c, --chrome", "Enable Chrome automation").option("-a, --auto", "Automatically detect and apply best settings").option("-b, --branch <name>", "Specify branch name for worktree").option("-t, --task <desc>", "Task description for context").option("--claude-bin <path>", "Path to claude CLI (or use CLAUDE_BIN)").option("--no-context", "Disable StackMemory context integration").option("--no-trace", "Disable debug tracing (enabled by default)").option("--verbose-trace", "Enable verbose debug tracing with full details").option("--think", "Enable thinking mode with Qwen (deep reasoning)").option("--think-hard", "Alias for --think").option("--ultrathink", "Alias for --think").option("--qwen", "Force Qwen provider for this session").option("--openai", "Force OpenAI provider for this session").option("--ollama", "Force Ollama provider for this session").option("--model-routing", "Enable model routing").option("--no-model-routing", "Disable model routing").option("--sweep", "Enable Sweep next-edit predictions (PTY wrapper)").option("--no-sweep", "Disable Sweep predictions").option("--greptile", "Enable Greptile AI code review (MCP server)").option("--no-greptile", "Disable Greptile integration").helpOption("-h, --help", "Display help").allowUnknownOption(true).action(async (_options) => {
|
|
1151
|
+
const claudeSM = new ClaudeSM();
|
|
1152
|
+
const args = process.argv.slice(2);
|
|
1153
|
+
await claudeSM.run(args);
|
|
1154
|
+
});
|
|
1155
|
+
program.parse(process.argv);
|
|
1156
|
+
//# sourceMappingURL=claude-sm.js.map
|