squish-memory 1.0.2 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +146 -0
- package/CHANGELOG.md +202 -0
- package/README.md +192 -287
- package/{scripts → bin}/dependency-manager.mjs +217 -217
- package/{scripts → bin}/detect-clients.mjs +78 -78
- package/bin/install-interactive.mjs +321 -0
- package/bin/squish-mcp.mjs +46 -0
- package/bin/squish.mjs +33 -0
- package/config/mcp-migration-map.json +1 -6
- package/config/mcp-mode-semantics.json +10 -12
- package/config/mcp-remote-auth.json +3 -26
- package/config/mcp-universal.schema.json +5 -35
- package/config/settings.json +78 -22
- package/config.js +5 -0
- package/config.ts +218 -0
- package/core/adapters/config/claude-code.ts +133 -0
- package/core/adapters/config/cursor.ts +90 -0
- package/core/adapters/config/opencode.ts +89 -0
- package/core/adapters/config/windsurf.ts +90 -0
- package/core/adapters/index.ts +102 -0
- package/core/adapters/timeline.ts +116 -0
- package/core/adapters/types.ts +166 -0
- package/core/agent-preferences.ts +140 -0
- package/core/algorithms/analytics/token-estimator.ts +216 -0
- package/core/algorithms/detection/hash-filters.ts +260 -0
- package/core/algorithms/detection/semantic-ranker.ts +194 -0
- package/core/algorithms/detection/two-stage-detector.ts +421 -0
- package/core/algorithms/handlers/approve-merge.ts +215 -0
- package/core/algorithms/handlers/detect-duplicates.ts +192 -0
- package/core/algorithms/handlers/get-stats.ts +132 -0
- package/core/algorithms/handlers/list-proposals.ts +130 -0
- package/core/algorithms/handlers/preview-merge.ts +139 -0
- package/core/algorithms/handlers/reject-merge.ts +93 -0
- package/core/algorithms/handlers/reverse-merge.ts +155 -0
- package/core/algorithms/index.ts +39 -0
- package/core/algorithms/operations/cache-maintenance.ts +182 -0
- package/core/algorithms/safety/safety-checks.ts +256 -0
- package/core/algorithms/strategies/merge-strategies.ts +381 -0
- package/core/algorithms/types.ts +140 -0
- package/core/algorithms/utils/response-builder.ts +61 -0
- package/core/associations.ts +363 -0
- package/core/beliefs/decay.ts +289 -0
- package/core/beliefs/extractor.ts +131 -0
- package/core/beliefs/store.ts +557 -0
- package/core/beliefs/types.ts +38 -0
- package/core/commands/mcp-server.ts +5 -0
- package/core/compression.ts +177 -0
- package/core/config.js +2 -0
- package/core/consolidation.ts +330 -0
- package/core/context/agent-context.ts +388 -0
- package/core/context/context-paging.ts +449 -0
- package/core/context/context-window.ts +234 -0
- package/core/context/context.ts +35 -0
- package/core/embeddings/embeddings.ts +616 -0
- package/core/embeddings/google-multimodal.ts +200 -0
- package/core/embeddings/local-embeddings.ts +12 -0
- package/core/embeddings/qmd-client.ts +495 -0
- package/core/embeddings/transformers-local.ts +261 -0
- package/core/embeddings.js +4 -0
- package/core/error-handling.ts +206 -0
- package/core/external +219 -0
- package/core/graph/entity-deduplicator.ts +232 -0
- package/core/graph/graph-builder.ts +257 -0
- package/core/graph/graph-traversal.ts +490 -0
- package/core/graph/index.ts +24 -0
- package/core/graph/llm-entity-extractor.ts +402 -0
- package/core/graph/multi-hop-retrieval.ts +317 -0
- package/core/graph/relationship-extractor.ts +465 -0
- package/core/hooks/agent-hooks.ts +653 -0
- package/core/hooks/auto-tagger.ts +149 -0
- package/core/hooks/capture-filter.ts +169 -0
- package/core/hot-cache.ts +388 -0
- package/core/index.ts +10 -0
- package/core/ingestion/agent-memory.ts +167 -0
- package/core/ingestion/core-memory.ts +326 -0
- package/core/ingestion/learnings.ts +260 -0
- package/core/ingestion/signal-engine.ts +266 -0
- package/core/integrations/obsidian-vault.ts +197 -0
- package/core/layers/generator.ts +115 -0
- package/core/lib/db-client.ts +168 -0
- package/core/lib/parse-embedding.ts +59 -0
- package/core/lib/schemas.ts +102 -0
- package/core/lib/types.ts +49 -0
- package/core/lib/utils.ts +151 -0
- package/core/lib/validation.ts +180 -0
- package/core/lifecycle.ts +353 -0
- package/core/logger.ts +59 -0
- package/core/memory/bridge-discovery.ts +395 -0
- package/core/memory/categorizer.ts +390 -0
- package/core/memory/conflict-detector.ts +62 -0
- package/core/memory/consolidation.ts +372 -0
- package/core/memory/context-collector.ts +75 -0
- package/core/memory/contradiction-resolver.ts +494 -0
- package/core/memory/edit-workflow.ts +174 -0
- package/core/memory/entity-extractor.ts +426 -0
- package/core/memory/entity-resolver.ts +89 -0
- package/core/memory/explain.ts +112 -0
- package/core/memory/fact-deriver.ts +300 -0
- package/core/memory/fact-extractor.ts +120 -0
- package/core/memory/feedback-tracker.ts +200 -0
- package/core/memory/hooks.ts +230 -0
- package/core/memory/hybrid-retrieval.ts +65 -0
- package/core/memory/hybrid-scorer.ts +325 -0
- package/core/memory/hybrid-search.ts +748 -0
- package/core/memory/importance.ts +319 -0
- package/core/memory/index.ts +11 -0
- package/core/memory/loader.ts +178 -0
- package/core/memory/markdown/markdown-storage.ts +318 -0
- package/core/memory/memories.ts +565 -0
- package/core/memory/memory-lifecycle.ts +51 -0
- package/core/memory/memory-manager.ts +53 -0
- package/core/memory/migrate.ts +173 -0
- package/core/memory/normalization.ts +30 -0
- package/core/memory/path-strengthener.ts +211 -0
- package/core/memory/progressive-disclosure.ts +392 -0
- package/core/memory/query-processor.ts +130 -0
- package/core/memory/query-rewriter.ts +153 -0
- package/core/memory/response-analyzer.ts +81 -0
- package/core/memory/retrieval-feedback.ts +276 -0
- package/core/memory/serialization.ts +83 -0
- package/core/memory/stale-cleaner.ts +147 -0
- package/core/memory/stats.ts +181 -0
- package/core/memory/telemetry.ts +392 -0
- package/core/memory/temporal-facts.ts +356 -0
- package/core/memory/temporal-parser.ts +477 -0
- package/core/memory/trigger-detector.ts +104 -0
- package/core/memory/write-gate.ts +288 -0
- package/core/places/index.ts +14 -0
- package/core/places/memory-places.ts +339 -0
- package/core/places/places.ts +406 -0
- package/core/places/rules.ts +308 -0
- package/core/places/walking.ts +192 -0
- package/core/projects +89 -0
- package/core/projects.ts +131 -0
- package/core/redis.ts +82 -0
- package/core/responses.ts +187 -0
- package/core/runtime/trust-report.ts +195 -0
- package/core/runtime/trust-state.ts +360 -0
- package/core/scheduler/cron-scheduler.ts +581 -0
- package/core/scheduler/heartbeat.ts +91 -0
- package/core/scheduler/index.ts +8 -0
- package/core/scheduler/job-runner.ts +197 -0
- package/core/search/conversations.ts +166 -0
- package/core/search/entities.ts +46 -0
- package/core/search/folder-context.ts +154 -0
- package/core/search/graph-boost.ts +22 -0
- package/core/search/index.ts +4 -0
- package/core/search/qmd-wrapper.ts +84 -0
- package/core/security/encrypt.ts +51 -0
- package/core/security/governance.ts +102 -0
- package/core/security/privacy.ts +108 -0
- package/core/security/secret-detector.ts +122 -0
- package/core/session/auto-load.ts +160 -0
- package/core/session/entity-tracker.ts +363 -0
- package/core/session/index.ts +7 -0
- package/core/session/reference-resolver.ts +158 -0
- package/core/session/self-iteration-job.ts +478 -0
- package/core/session/session-hooks.ts +69 -0
- package/core/session/types.ts +36 -0
- package/core/session/working-set.ts +275 -0
- package/core/snapshots/cleanup.ts +13 -0
- package/core/snapshots/comparison.ts +59 -0
- package/core/snapshots/creation.ts +139 -0
- package/core/snapshots/retrieval.ts +44 -0
- package/core/snapshots/stats.ts +63 -0
- package/core/storage/cache.ts +241 -0
- package/core/storage/database.ts +23 -0
- package/core/summarization/cleanup.ts +13 -0
- package/core/summarization/queries.ts +32 -0
- package/core/summarization/stats.ts +64 -0
- package/core/summarization/strategies.ts +52 -0
- package/core/summarization.ts +248 -0
- package/core/temporal-facts.ts +244 -0
- package/core/tracing/collector.ts +470 -0
- package/core/tracing/visualizer.ts +195 -0
- package/core/utils/cleanup-operations.ts +50 -0
- package/core/utils/content-extraction.ts +95 -0
- package/core/utils/filter-builder.ts +56 -0
- package/core/utils/history-traversal.ts +63 -0
- package/core/utils/memory-operations.ts +56 -0
- package/core/utils/query-operations.ts +83 -0
- package/core/utils/summarization-helpers.ts +45 -0
- package/core/utils/temporal-queries.ts +39 -0
- package/core/utils/vector-operations.ts +135 -0
- package/core/utils/version-management.ts +74 -0
- package/core/worker.ts +324 -0
- package/db/adapter.ts +215 -0
- package/db/bootstrap.ts +1055 -0
- package/db/drizzle/migrations/0000_needy_cerebro.sql +402 -0
- package/db/drizzle/migrations/meta/0000_snapshot.json +3451 -0
- package/db/drizzle/migrations/meta/_journal.json +13 -0
- package/db/drizzle/schema-sqlite.ts +1032 -0
- package/db/drizzle/schema.ts +1128 -0
- package/db/drizzle.config.ts +12 -0
- package/db/index.ts +83 -0
- package/db/init.sql +5 -0
- package/db/migrations/associations.ts +35 -0
- package/db/migrations/beliefs.ts +89 -0
- package/db/migrations/core-memory.ts +35 -0
- package/db/migrations/fts.ts +59 -0
- package/db/migrations/index.ts +54 -0
- package/db/migrations/indexes.ts +36 -0
- package/db/migrations/learnings.ts +34 -0
- package/db/migrations/maintenance.ts +68 -0
- package/db/migrations/memories.ts +22 -0
- package/db/migrations/memory-places.ts +35 -0
- package/db/migrations/places.ts +49 -0
- package/db/migrations/projects.ts +21 -0
- package/db/migrations/tier-conversion.ts +24 -0
- package/db/neon.ts +22 -0
- package/db/schema/beliefs.ts +50 -0
- package/db/schema/generator.ts +159 -0
- package/db/schema/index.ts +58 -0
- package/db/schema/learnings.ts +32 -0
- package/db/schema/memories.ts +83 -0
- package/db/schema/projects.ts +33 -0
- package/db/schema.ts +13 -0
- package/db/supabase.ts +27 -0
- package/dist/config.d.ts +61 -14
- package/dist/config.js +159 -139
- package/dist/core/adapters/config/claude-code.d.ts +45 -0
- package/dist/core/adapters/config/claude-code.js +113 -0
- package/dist/core/adapters/config/cursor.d.ts +26 -0
- package/dist/core/adapters/config/cursor.js +74 -0
- package/dist/core/adapters/config/opencode.d.ts +23 -0
- package/dist/core/adapters/config/opencode.js +73 -0
- package/dist/core/adapters/config/windsurf.d.ts +26 -0
- package/dist/core/adapters/config/windsurf.js +74 -0
- package/dist/core/adapters/index.d.ts +45 -0
- package/dist/core/adapters/index.js +84 -0
- package/dist/core/adapters/scripts/install-adapter.d.ts +19 -0
- package/dist/core/adapters/scripts/install-adapter.js +149 -0
- package/dist/core/adapters/timeline.d.ts +23 -0
- package/dist/core/adapters/timeline.js +88 -0
- package/dist/core/adapters/types.d.ts +137 -0
- package/dist/core/adapters/types.js +50 -0
- package/dist/core/agent-preferences.d.ts +16 -0
- package/dist/core/agent-preferences.js +124 -0
- package/dist/{algorithms → core/algorithms}/analytics/token-estimator.d.ts +1 -1
- package/dist/{algorithms → core/algorithms}/analytics/token-estimator.js +3 -3
- package/dist/{algorithms → core/algorithms}/detection/semantic-ranker.d.ts +1 -1
- package/dist/{algorithms → core/algorithms}/detection/semantic-ranker.js +1 -1
- package/dist/{algorithms → core/algorithms}/detection/two-stage-detector.d.ts +1 -1
- package/dist/{algorithms → core/algorithms}/detection/two-stage-detector.js +7 -10
- package/dist/{algorithms → core/algorithms}/handlers/approve-merge.js +4 -4
- package/dist/{algorithms → core/algorithms}/handlers/detect-duplicates.js +3 -3
- package/dist/{algorithms → core/algorithms}/handlers/get-stats.js +3 -3
- package/dist/{algorithms → core/algorithms}/handlers/list-proposals.js +3 -3
- package/dist/{algorithms → core/algorithms}/handlers/preview-merge.js +3 -3
- package/dist/{algorithms → core/algorithms}/handlers/reject-merge.js +3 -3
- package/dist/{algorithms → core/algorithms}/handlers/reverse-merge.js +3 -3
- package/dist/core/algorithms/index.d.ts +21 -0
- package/dist/core/algorithms/index.js +26 -0
- package/dist/core/algorithms/operations/cache-maintenance.d.ts +12 -0
- package/dist/core/algorithms/operations/cache-maintenance.js +157 -0
- package/dist/{algorithms → core/algorithms}/safety/safety-checks.d.ts +2 -6
- package/dist/{algorithms → core/algorithms}/strategies/merge-strategies.d.ts +19 -1
- package/dist/{algorithms → core/algorithms}/strategies/merge-strategies.js +74 -123
- package/dist/core/algorithms/types.d.ts +125 -0
- package/dist/core/algorithms/types.js +5 -0
- package/dist/core/associations.d.ts +3 -2
- package/dist/core/associations.js +37 -2
- package/dist/core/autosave.d.ts +19 -0
- package/dist/core/autosave.js +16 -0
- package/dist/core/beliefs/decay.d.ts +27 -0
- package/dist/core/beliefs/decay.js +217 -0
- package/dist/core/beliefs/extractor.d.ts +9 -0
- package/dist/core/beliefs/extractor.js +113 -0
- package/dist/core/beliefs/store.d.ts +46 -0
- package/dist/core/beliefs/store.js +466 -0
- package/dist/core/beliefs/types.d.ts +28 -0
- package/dist/core/beliefs/types.js +2 -0
- package/dist/core/commands/mcp-server.d.ts +2 -0
- package/dist/core/commands/mcp-server.js +6 -0
- package/dist/core/commands/remember.d.ts +24 -0
- package/dist/core/commands/remember.js +144 -0
- package/dist/core/compression.d.ts +45 -0
- package/dist/core/compression.js +160 -0
- package/dist/core/context/agent-context.d.ts +106 -0
- package/dist/core/context/agent-context.js +274 -0
- package/dist/core/{context-paging.d.ts → context/context-paging.d.ts} +2 -12
- package/dist/core/{context-paging.js → context/context-paging.js} +19 -39
- package/dist/core/context/context-window.d.ts +40 -0
- package/dist/core/context/context-window.js +177 -0
- package/dist/core/context/context.js +22 -0
- package/dist/core/embeddings/embeddings.d.ts +29 -0
- package/dist/core/embeddings/embeddings.js +546 -0
- package/dist/core/embeddings/google-multimodal.js +6 -2
- package/dist/core/embeddings/local-embeddings.d.ts +11 -0
- package/dist/core/embeddings/local-embeddings.js +11 -0
- package/dist/core/embeddings/qmd-client.js +1 -1
- package/dist/core/embeddings/transformers-local.d.ts +64 -0
- package/dist/core/embeddings/transformers-local.js +213 -0
- package/dist/core/embeddings.d.ts +1 -28
- package/dist/core/embeddings.js +2 -401
- package/dist/core/error-handling.d.ts +63 -0
- package/dist/core/error-handling.js +173 -0
- package/dist/core/graph/entity-deduplicator.d.ts +24 -0
- package/dist/core/graph/entity-deduplicator.js +183 -0
- package/dist/core/graph/graph-builder.d.ts +46 -0
- package/dist/core/graph/graph-builder.js +174 -0
- package/dist/core/graph/graph-traversal.d.ts +80 -0
- package/dist/core/graph/graph-traversal.js +315 -0
- package/dist/core/graph/index.d.ts +19 -0
- package/dist/core/graph/index.js +13 -0
- package/dist/core/graph/llm-entity-extractor.d.ts +49 -0
- package/dist/core/graph/llm-entity-extractor.js +313 -0
- package/dist/core/graph/multi-hop-retrieval.d.ts +48 -0
- package/dist/core/graph/multi-hop-retrieval.js +215 -0
- package/dist/core/graph/relationship-extractor.d.ts +48 -0
- package/dist/core/graph/relationship-extractor.js +351 -0
- package/dist/core/hooks/agent-hooks.d.ts +83 -0
- package/dist/core/hooks/agent-hooks.js +521 -0
- package/dist/core/hooks/auto-tagger.d.ts +19 -0
- package/dist/core/hooks/auto-tagger.js +155 -0
- package/dist/core/hooks/capture-filter.d.ts +41 -0
- package/dist/core/hooks/capture-filter.js +128 -0
- package/dist/core/hot-cache.d.ts +86 -0
- package/dist/core/hot-cache.js +285 -0
- package/dist/core/index.d.ts +9 -9
- package/dist/core/index.js +9 -12
- package/dist/core/{agent-memory.js → ingestion/agent-memory.js} +5 -7
- package/dist/core/{core-memory.d.ts → ingestion/core-memory.d.ts} +2 -2
- package/dist/core/{core-memory.js → ingestion/core-memory.js} +7 -7
- package/dist/core/ingestion/learnings.d.ts +57 -0
- package/dist/core/ingestion/learnings.js +205 -0
- package/dist/core/ingestion/signal-engine.d.ts +41 -0
- package/dist/core/ingestion/signal-engine.js +201 -0
- package/dist/core/integrations/obsidian-vault.d.ts +31 -0
- package/dist/core/integrations/obsidian-vault.js +156 -0
- package/dist/core/lib/db-client.d.ts +114 -0
- package/dist/core/lib/db-client.js +130 -0
- package/dist/core/lib/parse-embedding.d.ts +9 -0
- package/dist/core/lib/parse-embedding.js +58 -0
- package/dist/core/lib/schemas.d.ts +132 -0
- package/dist/core/lib/schemas.js +87 -0
- package/dist/core/lib/types.d.ts +45 -0
- package/dist/core/lib/types.js +6 -0
- package/dist/core/{utils.d.ts → lib/utils.d.ts} +5 -0
- package/dist/core/lib/utils.js +145 -0
- package/dist/core/lib/validation.d.ts +38 -0
- package/dist/core/lib/validation.js +151 -0
- package/dist/core/lifecycle.d.ts +7 -1
- package/dist/core/lifecycle.js +152 -42
- package/dist/core/logger.d.ts +1 -0
- package/dist/core/logger.js +13 -1
- package/dist/core/mcp/tools.d.ts +0 -2
- package/dist/core/mcp/tools.js +35 -90
- package/dist/core/mcp/types.d.ts +25 -253
- package/dist/core/mcp/types.js +2 -2
- package/dist/core/memory/categorizer.js +2 -0
- package/dist/core/memory/conflict-detector.js +1 -1
- package/dist/core/memory/consolidation.d.ts +1 -10
- package/dist/core/memory/consolidation.js +4 -39
- package/dist/core/memory/context-collector.js +1 -1
- package/dist/core/memory/edit-workflow.js +1 -1
- package/dist/core/memory/entity-extractor.d.ts +4 -0
- package/dist/core/memory/entity-extractor.js +30 -16
- package/dist/core/memory/entity-resolver.js +7 -7
- package/dist/core/memory/explain.d.ts +18 -0
- package/dist/core/memory/explain.js +92 -0
- package/dist/core/memory/fact-deriver.d.ts +31 -0
- package/dist/core/memory/fact-deriver.js +236 -0
- package/dist/core/memory/fact-extractor.js +12 -12
- package/dist/core/memory/feedback-tracker.js +1 -1
- package/dist/core/memory/hooks.d.ts +88 -0
- package/dist/core/memory/hooks.js +174 -0
- package/dist/core/memory/hybrid-retrieval.d.ts +14 -16
- package/dist/core/memory/hybrid-retrieval.js +25 -127
- package/dist/core/memory/hybrid-scorer.js +6 -23
- package/dist/core/memory/hybrid-search.d.ts +9 -11
- package/dist/core/memory/hybrid-search.js +496 -273
- package/dist/core/memory/importance.d.ts +2 -24
- package/dist/core/memory/importance.js +7 -91
- package/dist/core/memory/index.d.ts +1 -0
- package/dist/core/memory/index.js +1 -0
- package/dist/core/memory/loader.d.ts +31 -0
- package/dist/core/memory/loader.js +141 -0
- package/dist/core/memory/markdown/markdown-storage.d.ts +72 -0
- package/dist/core/memory/markdown/markdown-storage.js +243 -0
- package/dist/core/memory/memories.d.ts +23 -19
- package/dist/core/memory/memories.js +243 -228
- package/dist/core/memory/memory-lifecycle.d.ts +8 -0
- package/dist/core/memory/memory-lifecycle.js +47 -0
- package/dist/core/memory/migrate.d.ts +21 -0
- package/dist/core/memory/migrate.js +134 -0
- package/dist/core/memory/normalization.d.ts +7 -0
- package/dist/core/memory/normalization.js +26 -0
- package/dist/core/memory/path-strengthener.d.ts +39 -0
- package/dist/core/memory/path-strengthener.js +150 -0
- package/dist/core/memory/progressive-disclosure.js +1 -1
- package/dist/core/memory/query-processor.js +37 -3
- package/dist/core/memory/query-rewriter.js +9 -9
- package/dist/core/memory/retrieval-feedback.d.ts +70 -0
- package/dist/core/memory/retrieval-feedback.js +213 -0
- package/dist/core/memory/serialization.d.ts +4 -0
- package/dist/core/memory/serialization.js +49 -0
- package/dist/core/memory/stale-cleaner.d.ts +26 -0
- package/dist/core/memory/stale-cleaner.js +97 -0
- package/dist/core/memory/stats.d.ts +15 -0
- package/dist/core/memory/stats.js +69 -13
- package/dist/core/memory/temporal-facts.js +21 -0
- package/dist/core/memory/trigger-detector.d.ts +8 -1
- package/dist/core/memory/trigger-detector.js +42 -5
- package/dist/core/memory/write-gate.js +1 -1
- package/dist/core/places/index.d.ts +14 -0
- package/dist/core/places/index.js +14 -0
- package/dist/core/places/memory-places.d.ts +68 -0
- package/dist/core/places/memory-places.js +261 -0
- package/dist/core/places/places.d.ts +88 -0
- package/dist/core/places/places.js +314 -0
- package/dist/core/places/rules.d.ts +74 -0
- package/dist/core/places/rules.js +240 -0
- package/dist/core/places/walking.d.ts +56 -0
- package/dist/core/places/walking.js +121 -0
- package/dist/core/projects.d.ts +5 -0
- package/dist/core/projects.js +47 -18
- package/dist/core/responses.d.ts +96 -0
- package/dist/core/responses.js +122 -0
- package/dist/core/runtime/trust-report.d.ts +102 -0
- package/dist/core/runtime/trust-report.js +107 -0
- package/dist/core/runtime/trust-state.d.ts +12 -0
- package/dist/core/runtime/trust-state.js +309 -0
- package/dist/core/scheduler/cron-scheduler.d.ts +1 -1
- package/dist/core/scheduler/cron-scheduler.js +193 -10
- package/dist/core/scheduler/index.d.ts +1 -1
- package/dist/core/scheduler/index.js +1 -1
- package/dist/core/scheduler/job-runner.js +2 -2
- package/dist/core/search/conversations.js +40 -42
- package/dist/core/search/entities.js +6 -9
- package/dist/core/search/graph-boost.d.ts +7 -0
- package/dist/core/search/graph-boost.js +23 -0
- package/dist/core/search/qmd-wrapper.d.ts +36 -0
- package/dist/core/search/qmd-wrapper.js +58 -0
- package/dist/core/security/encrypt.d.ts +6 -0
- package/dist/core/security/encrypt.js +47 -0
- package/dist/core/{governance.d.ts → security/governance.d.ts} +6 -1
- package/dist/core/security/governance.js +79 -0
- package/dist/core/session/auto-load.js +34 -9
- package/dist/core/session/entity-tracker.d.ts +62 -0
- package/dist/core/session/entity-tracker.js +287 -0
- package/dist/core/session/index.d.ts +1 -1
- package/dist/core/session/index.js +1 -1
- package/dist/core/session/reference-resolver.d.ts +26 -0
- package/dist/core/session/reference-resolver.js +121 -0
- package/dist/core/{session-hooks → session}/self-iteration-job.d.ts +15 -0
- package/dist/core/{session-hooks → session}/self-iteration-job.js +195 -90
- package/dist/core/session/working-set.d.ts +50 -0
- package/dist/core/session/working-set.js +212 -0
- package/dist/core/snapshots/creation.d.ts +2 -8
- package/dist/core/snapshots/creation.js +3 -12
- package/dist/core/{cache.js → storage/cache.js} +2 -2
- package/dist/core/utils/memory-operations.js +1 -1
- package/dist/core/utils/summarization-helpers.d.ts +0 -4
- package/dist/core/utils/summarization-helpers.js +1 -6
- package/dist/core/utils/vector-operations.d.ts +71 -0
- package/dist/core/utils/vector-operations.js +129 -0
- package/dist/db/adapter.d.ts +3 -3
- package/dist/db/adapter.js +99 -88
- package/dist/db/bootstrap.d.ts +2 -0
- package/dist/db/bootstrap.js +921 -674
- package/dist/{drizzle → db/drizzle}/schema-sqlite.d.ts +775 -25
- package/dist/{drizzle → db/drizzle}/schema-sqlite.js +170 -24
- package/dist/{drizzle → db/drizzle}/schema.d.ts +731 -32
- package/dist/{drizzle → db/drizzle}/schema.js +192 -32
- package/dist/db/drizzle.config.d.ts +3 -0
- package/dist/db/drizzle.config.js +12 -0
- package/dist/db/index.d.ts +1 -5
- package/dist/db/index.js +51 -8
- package/dist/db/migrations/associations.d.ts +6 -0
- package/dist/db/migrations/associations.js +29 -0
- package/dist/db/migrations/beliefs.d.ts +10 -0
- package/dist/db/migrations/beliefs.js +76 -0
- package/dist/db/migrations/core-memory.d.ts +6 -0
- package/dist/db/migrations/core-memory.js +29 -0
- package/dist/db/migrations/fts.d.ts +6 -0
- package/dist/db/migrations/fts.js +52 -0
- package/dist/db/migrations/index.d.ts +25 -0
- package/dist/db/migrations/index.js +51 -0
- package/dist/db/migrations/indexes.d.ts +6 -0
- package/dist/db/migrations/indexes.js +30 -0
- package/dist/db/migrations/learnings.d.ts +7 -0
- package/dist/db/migrations/learnings.js +26 -0
- package/dist/db/migrations/maintenance.d.ts +6 -0
- package/dist/db/migrations/maintenance.js +61 -0
- package/dist/db/migrations/memories.d.ts +7 -0
- package/dist/db/migrations/memories.js +16 -0
- package/dist/db/migrations/memory-places.d.ts +6 -0
- package/dist/db/migrations/memory-places.js +29 -0
- package/dist/db/migrations/places.d.ts +6 -0
- package/dist/db/migrations/places.js +43 -0
- package/dist/db/migrations/projects.d.ts +3 -0
- package/dist/db/migrations/projects.js +13 -0
- package/dist/db/migrations/tier-conversion.d.ts +7 -0
- package/dist/db/migrations/tier-conversion.js +20 -0
- package/dist/db/neon.d.ts +8 -0
- package/dist/db/neon.js +20 -0
- package/dist/db/schema/beliefs.d.ts +9 -0
- package/dist/db/schema/beliefs.js +46 -0
- package/dist/db/schema/generator.d.ts +38 -0
- package/dist/db/schema/generator.js +108 -0
- package/dist/db/schema/index.d.ts +39 -0
- package/dist/db/schema/index.js +51 -0
- package/dist/db/schema/learnings.d.ts +7 -0
- package/dist/db/schema/learnings.js +30 -0
- package/dist/db/schema/memories.d.ts +7 -0
- package/dist/db/schema/memories.js +81 -0
- package/dist/db/schema/projects.d.ts +4 -0
- package/dist/db/schema/projects.js +31 -0
- package/dist/db/schema/tables/context-sessions.d.ts +9 -0
- package/dist/db/schema/tables/context-sessions.js +37 -0
- package/dist/db/schema/tables/conversations.d.ts +9 -0
- package/dist/db/schema/tables/conversations.js +47 -0
- package/dist/db/schema/tables/core-memory.d.ts +9 -0
- package/dist/db/schema/tables/core-memory.js +41 -0
- package/dist/db/schema/tables/entities.d.ts +9 -0
- package/dist/db/schema/tables/entities.js +39 -0
- package/dist/db/schema/tables/entity-relations.d.ts +9 -0
- package/dist/db/schema/tables/entity-relations.js +31 -0
- package/dist/db/schema/tables/learnings.d.ts +9 -0
- package/dist/db/schema/tables/learnings.js +66 -0
- package/dist/db/schema/tables/memories.d.ts +9 -0
- package/dist/db/schema/tables/memories.js +161 -0
- package/dist/db/schema/tables/memory-associations.d.ts +9 -0
- package/dist/db/schema/tables/memory-associations.js +39 -0
- package/dist/db/schema/tables/memory-hash-cache.d.ts +9 -0
- package/dist/db/schema/tables/memory-hash-cache.js +29 -0
- package/dist/db/schema/tables/memory-merge-history.d.ts +9 -0
- package/dist/db/schema/tables/memory-merge-history.js +33 -0
- package/dist/db/schema/tables/memory-merge-proposals.d.ts +9 -0
- package/dist/db/schema/tables/memory-merge-proposals.js +39 -0
- package/dist/db/schema/tables/messages.d.ts +9 -0
- package/dist/db/schema/tables/messages.js +41 -0
- package/dist/db/schema/tables/namespaces.d.ts +9 -0
- package/dist/db/schema/tables/namespaces.js +37 -0
- package/dist/db/schema/tables/projects.d.ts +9 -0
- package/dist/db/schema/tables/projects.js +31 -0
- package/dist/db/schema/tables/users.d.ts +9 -0
- package/dist/db/schema/tables/users.js +27 -0
- package/dist/db/schema.d.ts +1 -1
- package/dist/db/schema.js +2 -2
- package/dist/db/supabase.d.ts +9 -0
- package/dist/db/supabase.js +24 -0
- package/dist/packages/mcp/src/index.d.ts +3 -0
- package/dist/packages/mcp/src/index.js +733 -0
- package/mcp.json.example +8 -0
- package/package.json +132 -173
- package/packages/cli/package.json +22 -0
- package/packages/cli/src/commands/clean.ts +68 -0
- package/packages/cli/src/commands/context.ts +79 -0
- package/packages/cli/src/commands/doctor.ts +357 -0
- package/packages/cli/src/commands/forget.ts +72 -0
- package/packages/cli/src/commands/health.ts +36 -0
- package/packages/cli/src/commands/inspect.ts +41 -0
- package/packages/cli/src/commands/link.ts +50 -0
- package/packages/cli/src/commands/migrate.ts +93 -0
- package/packages/cli/src/commands/recall.ts +99 -0
- package/packages/cli/src/commands/recent.ts +57 -0
- package/packages/cli/src/commands/remember.ts +139 -0
- package/packages/cli/src/commands/run.ts +58 -0
- package/packages/cli/src/commands/stale.ts +43 -0
- package/packages/cli/src/commands/stats.ts +42 -0
- package/packages/cli/src/index.ts +57 -0
- package/packages/cli/tsconfig.json +24 -0
- package/packages/mcp/package.json +26 -0
- package/packages/mcp/src/index.ts +877 -0
- package/packages/mcp/tsconfig.json +20 -0
- package/skills/squish-memory/SKILL.md +107 -114
- package/skills/squish-memory/install.sh +3 -3
- package/skills/squish-memory/{claude-desktop.json → references/claude-desktop.json} +12 -12
- package/skills/squish-memory/{openclaw.json → references/openclaw.json} +13 -13
- package/skills/squish-memory/{opencode.json → references/opencode.json} +14 -14
- package/.claude-plugin/marketplace.json +0 -20
- package/.claude-plugin/plugin.json +0 -32
- package/.env.mcp.example +0 -60
- package/.mcp.json +0 -11
- package/QUICK-START.md +0 -71
- package/bin/squish-add.mjs +0 -32
- package/bin/squish-rm.mjs +0 -21
- package/commands/context-paging.md +0 -51
- package/commands/context-status.md +0 -22
- package/commands/context.md +0 -5
- package/commands/core-memory.md +0 -56
- package/commands/health.md +0 -5
- package/commands/init.md +0 -39
- package/commands/merge.md +0 -113
- package/commands/observe.md +0 -5
- package/commands/recall.md +0 -5
- package/commands/remember.md +0 -11
- package/commands/search.md +0 -10
- package/config/mcp-cli-fallback-policy.json +0 -22
- package/config/mcp.json +0 -38
- package/config/plugin-manifest.json +0 -152
- package/config/plugin-manifest.schema.json +0 -244
- package/config/remote-memory-policy.json +0 -32
- package/dist/api/web/index.d.ts +0 -3
- package/dist/api/web/index.js +0 -4
- package/dist/api/web/web-server.d.ts +0 -3
- package/dist/api/web/web-server.js +0 -6
- package/dist/api/web/web.d.ts +0 -4
- package/dist/api/web/web.js +0 -639
- package/dist/commands/managed-sync.d.ts +0 -10
- package/dist/commands/managed-sync.js +0 -64
- package/dist/commands/mcp-server.d.ts +0 -3
- package/dist/commands/mcp-server.js +0 -393
- package/dist/core/context.js +0 -24
- package/dist/core/governance.js +0 -64
- package/dist/core/local-embeddings.d.ts +0 -6
- package/dist/core/local-embeddings.js +0 -20
- package/dist/core/namespaces/index.d.ts +0 -71
- package/dist/core/namespaces/index.js +0 -305
- package/dist/core/namespaces/uri-parser.d.ts +0 -31
- package/dist/core/namespaces/uri-parser.js +0 -74
- package/dist/core/observations.d.ts +0 -26
- package/dist/core/observations.js +0 -110
- package/dist/core/requirements.d.ts +0 -20
- package/dist/core/requirements.js +0 -35
- package/dist/core/search/qmd-search.d.ts +0 -61
- package/dist/core/search/qmd-search.js +0 -178
- package/dist/core/snapshots.d.ts +0 -29
- package/dist/core/snapshots.js +0 -220
- package/dist/core/sync/qmd-sync.d.ts +0 -106
- package/dist/core/sync/qmd-sync.js +0 -213
- package/dist/core/utils.js +0 -74
- package/dist/index.d.ts +0 -19
- package/dist/index.js +0 -997
- package/generated/mcp/manifest.json +0 -23
- package/generated/mcp/mcp-servers.json +0 -25
- package/generated/mcp/mcporter.json +0 -34
- package/generated/mcp/openclaw-memory-qmd.json +0 -17
- package/generated/mcp/runtime.json +0 -12
- package/hooks/hooks.json +0 -52
- package/hooks/post-tool-use.js +0 -26
- package/hooks/session-end.js +0 -28
- package/hooks/session-start.js +0 -33
- package/hooks/user-prompt-submit.js +0 -26
- package/hooks/utils.js +0 -153
- package/npx-installer.js +0 -208
- package/packages/plugin-claude-code/README.md +0 -73
- package/packages/plugin-claude-code/dist/plugin-wrapper.d.ts +0 -35
- package/packages/plugin-claude-code/dist/plugin-wrapper.js +0 -191
- package/packages/plugin-claude-code/package.json +0 -31
- package/packages/plugin-openclaw/README.md +0 -70
- package/packages/plugin-openclaw/dist/index.d.ts +0 -49
- package/packages/plugin-openclaw/dist/index.js +0 -262
- package/packages/plugin-openclaw/openclaw.plugin.json +0 -94
- package/packages/plugin-openclaw/package.json +0 -31
- package/packages/plugin-opencode/install.mjs +0 -217
- package/packages/plugin-opencode/package.json +0 -21
- package/plugin.json +0 -32
- package/scripts/build-release.sh +0 -36
- package/scripts/check-secrets.js +0 -132
- package/scripts/db/check-db.mjs +0 -88
- package/scripts/db/fix-all-columns.mjs +0 -52
- package/scripts/db/fix-schema-all.mjs +0 -55
- package/scripts/db/fix-schema-full.mjs +0 -46
- package/scripts/db/fix-schema.mjs +0 -38
- package/scripts/db/init-db.mjs +0 -13
- package/scripts/db/recreate-db.mjs +0 -14
- package/scripts/generate-mcp.mjs +0 -264
- package/scripts/github-release.sh +0 -77
- package/scripts/init-dirs.mjs +0 -13
- package/scripts/install-interactive.mjs +0 -677
- package/scripts/install-mcp.mjs +0 -116
- package/scripts/install-plugin.mjs +0 -415
- package/scripts/install-web.sh +0 -120
- package/scripts/install.mjs +0 -340
- package/scripts/openclaw-bootstrap.mjs +0 -127
- package/scripts/package-release.sh +0 -71
- package/scripts/remote-preflight.mjs +0 -62
- package/scripts/squish-fallback.mjs +0 -132
- package/scripts/test/test-all-systems.mjs +0 -139
- package/scripts/test/test-memory-system.mjs +0 -139
- package/scripts/test/test-v0.5.0.mjs +0 -210
- package/scripts/test-interactive.mjs +0 -131
- package/scripts/verify-mcp.mjs +0 -214
- package/skills/memory-guide/SKILL.md +0 -332
- package/skills/squish-cli/SKILL.md +0 -240
- package/skills/squish-mcp/SKILL.md +0 -355
- package/skills/squish-memory/install.mjs +0 -335
- package/skills/squish-memory/skill.json +0 -32
- /package/dist/{algorithms → core/algorithms}/detection/hash-filters.d.ts +0 -0
- /package/dist/{algorithms → core/algorithms}/detection/hash-filters.js +0 -0
- /package/dist/{algorithms → core/algorithms}/handlers/approve-merge.d.ts +0 -0
- /package/dist/{algorithms → core/algorithms}/handlers/detect-duplicates.d.ts +0 -0
- /package/dist/{algorithms → core/algorithms}/handlers/get-stats.d.ts +0 -0
- /package/dist/{algorithms → core/algorithms}/handlers/list-proposals.d.ts +0 -0
- /package/dist/{algorithms → core/algorithms}/handlers/preview-merge.d.ts +0 -0
- /package/dist/{algorithms → core/algorithms}/handlers/reject-merge.d.ts +0 -0
- /package/dist/{algorithms → core/algorithms}/handlers/reverse-merge.d.ts +0 -0
- /package/dist/{algorithms → core/algorithms}/safety/safety-checks.js +0 -0
- /package/dist/{algorithms → core/algorithms}/utils/response-builder.d.ts +0 -0
- /package/dist/{algorithms → core/algorithms}/utils/response-builder.js +0 -0
- /package/dist/core/{context.d.ts → context/context.d.ts} +0 -0
- /package/dist/core/{agent-memory.d.ts → ingestion/agent-memory.d.ts} +0 -0
- /package/dist/core/{privacy.d.ts → security/privacy.d.ts} +0 -0
- /package/dist/core/{privacy.js → security/privacy.js} +0 -0
- /package/dist/core/{secret-detector.d.ts → security/secret-detector.d.ts} +0 -0
- /package/dist/core/{secret-detector.js → security/secret-detector.js} +0 -0
- /package/dist/core/{session-hooks → session}/session-hooks.d.ts +0 -0
- /package/dist/core/{session-hooks → session}/session-hooks.js +0 -0
- /package/dist/core/{cache.d.ts → storage/cache.d.ts} +0 -0
- /package/dist/core/{database.d.ts → storage/database.d.ts} +0 -0
- /package/dist/core/{database.js → storage/database.js} +0 -0
package/dist/index.js
DELETED
|
@@ -1,997 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* Squish v1.0.2 - Universal Memory Plugin System
|
|
4
|
-
*
|
|
5
|
-
* Modes:
|
|
6
|
-
* - CLI Mode: For any MCP client bash execution (e.g., `squish remember "text"`)
|
|
7
|
-
* - MCP Mode: For AI assistants (Claude Code, OpenClaw, OpenCode, Codex, etc.)
|
|
8
|
-
*
|
|
9
|
-
* Features:
|
|
10
|
-
* - Hybrid Search: BM25 + vector search with RRF
|
|
11
|
-
* - Importance Scoring: Auto-score memories with temporal decay
|
|
12
|
-
* - Consolidation: Summarize old, low-importance memory clusters
|
|
13
|
-
* - 16 MCP tools
|
|
14
|
-
* - Local mode: SQLite with FTS5
|
|
15
|
-
* - Team mode: PostgreSQL + pgvector
|
|
16
|
-
* - Universal Plugin: Works with 7+ AI assistants
|
|
17
|
-
*/
|
|
18
|
-
import 'dotenv/config';
|
|
19
|
-
import fs from 'node:fs';
|
|
20
|
-
import { existsSync } from 'node:fs';
|
|
21
|
-
import os from 'node:os';
|
|
22
|
-
import path from 'node:path';
|
|
23
|
-
import { fileURLToPath } from 'node:url';
|
|
24
|
-
import { spawnSync } from 'node:child_process';
|
|
25
|
-
import { Command } from 'commander';
|
|
26
|
-
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
27
|
-
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
28
|
-
import { CallToolRequestSchema, ErrorCode, ListToolsRequestSchema, McpError, } from '@modelcontextprotocol/sdk/types.js';
|
|
29
|
-
import { logger } from './core/logger.js';
|
|
30
|
-
import { checkDatabaseHealth, config } from './db/index.js';
|
|
31
|
-
import { checkRedisHealth, closeCache } from './core/cache.js';
|
|
32
|
-
import { rememberMemory, getMemoryById, searchMemories } from './core/memory/memories.js';
|
|
33
|
-
import { createObservation } from './core/observations.js';
|
|
34
|
-
import { getProjectContext } from './core/context.js';
|
|
35
|
-
import { setImportanceScore } from './core/memory/importance.js';
|
|
36
|
-
import { getMemoryStats } from './core/memory/stats.js';
|
|
37
|
-
import { ensureProject } from './core/projects.js';
|
|
38
|
-
import { consolidateMemories as consolidateMemoriesImpl, getConsolidationStats } from './core/memory/consolidation.js';
|
|
39
|
-
import { startWebServer } from './api/web/web.js';
|
|
40
|
-
import { handleDetectDuplicates } from './algorithms/handlers/detect-duplicates.js';
|
|
41
|
-
import { handleListProposals } from './algorithms/handlers/list-proposals.js';
|
|
42
|
-
import { handlePreviewMerge } from './algorithms/handlers/preview-merge.js';
|
|
43
|
-
import { handleApproveMerge } from './algorithms/handlers/approve-merge.js';
|
|
44
|
-
import { handleRejectMerge } from './algorithms/handlers/reject-merge.js';
|
|
45
|
-
import { handleReverseMerge } from './algorithms/handlers/reverse-merge.js';
|
|
46
|
-
import { handleGetMergeStats } from './algorithms/handlers/get-stats.js';
|
|
47
|
-
import { pinMemory, unpinMemory } from './core/governance.js';
|
|
48
|
-
import { searchWithQMD, isQMDAvailable } from './core/search/qmd-search.js';
|
|
49
|
-
import { initializeCoreMemory, getCoreMemory, editCoreMemorySection, appendCoreMemorySection, getCoreMemoryStats, } from './core/core-memory.js';
|
|
50
|
-
import { loadMemoryToContext, evictMemoryFromContext, viewLoadedMemories, getContextStatus, } from './core/context-paging.js';
|
|
51
|
-
import { ensureDataDirectory } from './db/bootstrap.js';
|
|
52
|
-
import { getDataDir } from './config.js';
|
|
53
|
-
import { performAutoLoad, shouldAutoLoad, getAutoLoadConfig } from './core/session/auto-load.js';
|
|
54
|
-
import { initializeScheduler, registerJobHandler } from './core/scheduler/cron-scheduler.js';
|
|
55
|
-
import { startHeartbeatChecking, heartbeat } from './core/scheduler/heartbeat.js';
|
|
56
|
-
import { runNightlyJob, runWeeklyJob } from './core/scheduler/job-runner.js';
|
|
57
|
-
const VERSION = '1.0.2';
|
|
58
|
-
// Load plugin manifest for self-verification
|
|
59
|
-
function loadPluginManifest() {
|
|
60
|
-
try {
|
|
61
|
-
const manifestPath = path.join(process.cwd(), 'config', 'plugin-manifest.json');
|
|
62
|
-
if (fs.existsSync(manifestPath)) {
|
|
63
|
-
return JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
catch (error) {
|
|
67
|
-
logger.warn('Could not load plugin manifest:', error?.message || error);
|
|
68
|
-
}
|
|
69
|
-
return null;
|
|
70
|
-
}
|
|
71
|
-
function verifyManifest(manifest) {
|
|
72
|
-
if (!manifest) {
|
|
73
|
-
return { ok: false, errors: ['Manifest not found'] };
|
|
74
|
-
}
|
|
75
|
-
const errors = [];
|
|
76
|
-
const required = ['id', 'name', 'version', 'capabilities', 'targets', 'dependencies'];
|
|
77
|
-
required.forEach((field) => {
|
|
78
|
-
if (!manifest[field]) {
|
|
79
|
-
errors.push(`Missing required field: ${field}`);
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
if (manifest.version !== VERSION) {
|
|
83
|
-
errors.push(`Version mismatch: manifest=${manifest.version}, binary=${VERSION}`);
|
|
84
|
-
}
|
|
85
|
-
const expectedTargets = ['claude-code', 'openclaw', 'opencode', 'codex', 'cursor', 'vscode', 'windsurf'];
|
|
86
|
-
expectedTargets.forEach((target) => {
|
|
87
|
-
if (!manifest.targets[target]) {
|
|
88
|
-
errors.push(`Missing target: ${target}`);
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
return { ok: errors.length === 0, errors };
|
|
92
|
-
}
|
|
93
|
-
// ============================================================================
|
|
94
|
-
// HELPER FUNCTIONS
|
|
95
|
-
// ============================================================================
|
|
96
|
-
function showHelp() {
|
|
97
|
-
console.log(`
|
|
98
|
-
Squish Memory v${VERSION} - Universal Memory Plugin System
|
|
99
|
-
|
|
100
|
-
Usage:
|
|
101
|
-
squish Start interactive wizard
|
|
102
|
-
squish run mcp Start MCP server
|
|
103
|
-
squish run web Start Web UI only
|
|
104
|
-
squish <command> [options] Run CLI commands for agents
|
|
105
|
-
|
|
106
|
-
CLI Commands (for agents):
|
|
107
|
-
squish remember <content> Store a memory
|
|
108
|
-
squish search <query> Search memories
|
|
109
|
-
squish health Check system health
|
|
110
|
-
squish stats View statistics
|
|
111
|
-
squish core_memory Manage core memory
|
|
112
|
-
|
|
113
|
-
Examples:
|
|
114
|
-
squish run mcp # Start MCP server (for Claude Code)
|
|
115
|
-
squish run web # Start Web UI only
|
|
116
|
-
squish remember "Hello" # Store memory via CLI
|
|
117
|
-
squish search "query" # Search memories via CLI
|
|
118
|
-
|
|
119
|
-
For more info: https://github.com/michielhdoteth/squish
|
|
120
|
-
`);
|
|
121
|
-
}
|
|
122
|
-
async function runInteractiveInstaller() {
|
|
123
|
-
const { select } = await import('@clack/prompts');
|
|
124
|
-
const { isCancel } = await import('@clack/prompts');
|
|
125
|
-
const { log } = await import('@clack/prompts');
|
|
126
|
-
const { intro, outro } = await import('@clack/prompts');
|
|
127
|
-
intro(`Squish Memory v${VERSION}`);
|
|
128
|
-
const options = [
|
|
129
|
-
{ value: 'mcp', label: 'Start MCP Server (for AI Assistants: Claude Code, OpenCode, etc.)' },
|
|
130
|
-
{ value: 'web', label: 'Start Web UI Only' },
|
|
131
|
-
{ value: 'health', label: 'Health & Stats' },
|
|
132
|
-
{ value: 'help', label: 'Show Help' },
|
|
133
|
-
{ value: 'exit', label: 'Exit' }
|
|
134
|
-
];
|
|
135
|
-
const selected = await select({
|
|
136
|
-
message: 'What would you like to do?',
|
|
137
|
-
options: options,
|
|
138
|
-
});
|
|
139
|
-
if (isCancel(selected)) {
|
|
140
|
-
outro('Cancelled');
|
|
141
|
-
process.exit(0);
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
switch (selected) {
|
|
145
|
-
case 'mcp':
|
|
146
|
-
log.step('Starting MCP server...');
|
|
147
|
-
await runMcpMode();
|
|
148
|
-
break;
|
|
149
|
-
case 'web':
|
|
150
|
-
log.step('Starting Web UI...');
|
|
151
|
-
await runWebOnly();
|
|
152
|
-
break;
|
|
153
|
-
case 'health':
|
|
154
|
-
log.step('Checking health...');
|
|
155
|
-
await runCliCommand('health');
|
|
156
|
-
await runCliCommand('stats');
|
|
157
|
-
break;
|
|
158
|
-
case 'help':
|
|
159
|
-
showHelp();
|
|
160
|
-
process.exit(0);
|
|
161
|
-
break;
|
|
162
|
-
case 'exit':
|
|
163
|
-
outro('Goodbye! 👋');
|
|
164
|
-
process.exit(0);
|
|
165
|
-
break;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
async function runCliCommand(command) {
|
|
169
|
-
// Run CLI command programmatically
|
|
170
|
-
const program = new Command();
|
|
171
|
-
program.hook('preAction', async () => {
|
|
172
|
-
await ensureDataDirectory();
|
|
173
|
-
});
|
|
174
|
-
if (command === 'health') {
|
|
175
|
-
const dbHealth = await checkDatabaseHealth();
|
|
176
|
-
const redisHealth = await checkRedisHealth();
|
|
177
|
-
const dataDir = process.env.SQUISH_DATA_DIR || path.join(os.homedir(), '.squish');
|
|
178
|
-
const dirExists = fs.existsSync(dataDir);
|
|
179
|
-
console.log(`\n Squish Memory v${VERSION}`);
|
|
180
|
-
console.log(` ====================`);
|
|
181
|
-
console.log(` Mode: ${config.isTeamMode ? 'team' : 'local'}`);
|
|
182
|
-
console.log(` Database: ${dbHealth ? 'ok' : 'error'}`);
|
|
183
|
-
console.log(` Cache: ${redisHealth ? 'ok' : 'unavailable'}`);
|
|
184
|
-
console.log(` Data Dir: ${dataDir}`);
|
|
185
|
-
console.log(` Status: ${dbHealth ? 'HEALTHY' : 'UNHEALTHY'}\n`);
|
|
186
|
-
}
|
|
187
|
-
else if (command === 'stats') {
|
|
188
|
-
const stats = await getMemoryStats(process.cwd());
|
|
189
|
-
console.log(JSON.stringify({ ok: true, ...stats }, null, 2));
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
async function spawnInstallerWizard() {
|
|
193
|
-
const distDir = path.dirname(fileURLToPath(import.meta.url));
|
|
194
|
-
const packageDir = path.dirname(distDir);
|
|
195
|
-
const installScript = path.join(packageDir, 'scripts', 'install-interactive.mjs');
|
|
196
|
-
if (!fs.existsSync(installScript)) {
|
|
197
|
-
console.error('Installer not found at:', installScript);
|
|
198
|
-
process.exit(1);
|
|
199
|
-
}
|
|
200
|
-
console.log('\nLaunching full installer wizard...\n');
|
|
201
|
-
const result = spawnSync('node', [`"${installScript}"`], {
|
|
202
|
-
stdio: 'inherit',
|
|
203
|
-
shell: true,
|
|
204
|
-
cwd: packageDir
|
|
205
|
-
});
|
|
206
|
-
process.exit(result.status || 0);
|
|
207
|
-
}
|
|
208
|
-
function isDatabaseInitialized() {
|
|
209
|
-
try {
|
|
210
|
-
const dataDir = getDataDir();
|
|
211
|
-
const dbPath = path.join(dataDir, 'squish.db');
|
|
212
|
-
return existsSync(dataDir) && existsSync(dbPath);
|
|
213
|
-
}
|
|
214
|
-
catch (error) {
|
|
215
|
-
return false;
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
async function runWebOnly() {
|
|
219
|
-
console.log(`[squish] Starting Web UI only...`);
|
|
220
|
-
await ensureDataDirectory();
|
|
221
|
-
startWebServer();
|
|
222
|
-
}
|
|
223
|
-
// ============================================================================
|
|
224
|
-
// CLI MODE DETECTION
|
|
225
|
-
// ============================================================================
|
|
226
|
-
const args = process.argv.slice(2);
|
|
227
|
-
const firstArg = args[0];
|
|
228
|
-
// Detect command type
|
|
229
|
-
const isNoArgs = args.length === 0;
|
|
230
|
-
const isRunCommand = firstArg === 'run';
|
|
231
|
-
const isHelpCommand = firstArg === '--help' || firstArg === '-h' || firstArg === 'help';
|
|
232
|
-
if (isNoArgs) {
|
|
233
|
-
// Check if database exists - if not, run installer automatically
|
|
234
|
-
if (!isDatabaseInitialized()) {
|
|
235
|
-
console.log(`[squish] No existing database found. Launching installer wizard...\n`);
|
|
236
|
-
await spawnInstallerWizard();
|
|
237
|
-
}
|
|
238
|
-
else {
|
|
239
|
-
// === INTERACTIVE WIZARD (default when no args) ===
|
|
240
|
-
runInteractiveInstaller().catch((e) => {
|
|
241
|
-
console.error('Installer error:', e.message);
|
|
242
|
-
process.exit(1);
|
|
243
|
-
});
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
else if (isRunCommand) {
|
|
247
|
-
// === RUN SUBCOMMAND ===
|
|
248
|
-
const subcommand = args[1];
|
|
249
|
-
if (subcommand === 'mcp') {
|
|
250
|
-
runMcpMode().catch((e) => {
|
|
251
|
-
logger.error('Fatal error', e);
|
|
252
|
-
process.exit(1);
|
|
253
|
-
});
|
|
254
|
-
}
|
|
255
|
-
else if (subcommand === 'web') {
|
|
256
|
-
runWebOnly().catch((e) => {
|
|
257
|
-
logger.error('Web server error', e);
|
|
258
|
-
process.exit(1);
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
|
-
else {
|
|
262
|
-
console.log(`
|
|
263
|
-
Usage: squish run <command>
|
|
264
|
-
|
|
265
|
-
Commands:
|
|
266
|
-
mcp Start MCP server
|
|
267
|
-
web Start Web UI only
|
|
268
|
-
|
|
269
|
-
Examples:
|
|
270
|
-
squish run mcp # Start MCP server with web UI
|
|
271
|
-
squish run web # Start Web UI only
|
|
272
|
-
`);
|
|
273
|
-
process.exit(subcommand ? 1 : 0);
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
else if (isHelpCommand) {
|
|
277
|
-
// === SHOW HELP ===
|
|
278
|
-
showHelp();
|
|
279
|
-
process.exit(0);
|
|
280
|
-
}
|
|
281
|
-
else {
|
|
282
|
-
// === CLI MODE (for agents/OpenClaw) ===
|
|
283
|
-
runCliMode().catch((e) => {
|
|
284
|
-
console.error(JSON.stringify({ error: e.message }, null, 2));
|
|
285
|
-
process.exit(1);
|
|
286
|
-
});
|
|
287
|
-
}
|
|
288
|
-
// ============================================================================
|
|
289
|
-
// CLI MODE (for OpenClaw bash execution)
|
|
290
|
-
// ============================================================================
|
|
291
|
-
async function runCliMode() {
|
|
292
|
-
const program = new Command();
|
|
293
|
-
program
|
|
294
|
-
.name('squish')
|
|
295
|
-
.description('Squish - Persistent memory for AI assistants')
|
|
296
|
-
.version(VERSION);
|
|
297
|
-
// Initialize data directory before any command
|
|
298
|
-
program.hook('preAction', async () => {
|
|
299
|
-
await ensureDataDirectory();
|
|
300
|
-
});
|
|
301
|
-
// squish remember "content" --type fact --tags tag1,tag2
|
|
302
|
-
program
|
|
303
|
-
.command('remember <content>')
|
|
304
|
-
.description('Store a memory')
|
|
305
|
-
.option('-t, --type <type>', 'Memory type (observation, fact, decision, context, preference)', 'observation')
|
|
306
|
-
.option('-T, --tags <tags>', 'Comma-separated tags', '')
|
|
307
|
-
.option('-p, --project <project>', 'Project path', process.cwd())
|
|
308
|
-
.action(async (content, options) => {
|
|
309
|
-
try {
|
|
310
|
-
const result = await rememberMemory({
|
|
311
|
-
content,
|
|
312
|
-
type: options.type,
|
|
313
|
-
tags: options.tags ? options.tags.split(',').map((t) => t.trim()) : [],
|
|
314
|
-
project: options.project,
|
|
315
|
-
});
|
|
316
|
-
console.log(JSON.stringify({ ok: true, ...result }, null, 2));
|
|
317
|
-
}
|
|
318
|
-
catch (error) {
|
|
319
|
-
console.log(JSON.stringify({ ok: false, error: error.message }, null, 2));
|
|
320
|
-
process.exit(1);
|
|
321
|
-
}
|
|
322
|
-
});
|
|
323
|
-
// squish search "query" --type fact --limit 10
|
|
324
|
-
program
|
|
325
|
-
.command('search <query>')
|
|
326
|
-
.description('Search memories')
|
|
327
|
-
.option('-t, --type <type>', 'Filter by memory type')
|
|
328
|
-
.option('-l, --limit <number>', 'Max results', '10')
|
|
329
|
-
.option('-p, --project <project>', 'Project path', process.cwd())
|
|
330
|
-
.action(async (query, options) => {
|
|
331
|
-
try {
|
|
332
|
-
const results = await searchMemories({
|
|
333
|
-
query,
|
|
334
|
-
type: options.type,
|
|
335
|
-
limit: parseInt(options.limit, 10),
|
|
336
|
-
project: options.project,
|
|
337
|
-
});
|
|
338
|
-
console.log(JSON.stringify({ ok: true, query, count: results?.length || 0, results }, null, 2));
|
|
339
|
-
}
|
|
340
|
-
catch (error) {
|
|
341
|
-
console.log(JSON.stringify({ ok: false, error: error.message }, null, 2));
|
|
342
|
-
process.exit(1);
|
|
343
|
-
}
|
|
344
|
-
});
|
|
345
|
-
// squish recall <memoryId>
|
|
346
|
-
program
|
|
347
|
-
.command('recall <memoryId>')
|
|
348
|
-
.description('Retrieve a memory by ID')
|
|
349
|
-
.action(async (memoryId) => {
|
|
350
|
-
try {
|
|
351
|
-
const memory = await getMemoryById(String(memoryId));
|
|
352
|
-
console.log(JSON.stringify({ ok: true, found: !!memory, memory }, null, 2));
|
|
353
|
-
}
|
|
354
|
-
catch (error) {
|
|
355
|
-
console.log(JSON.stringify({ ok: false, error: error.message }, null, 2));
|
|
356
|
-
process.exit(1);
|
|
357
|
-
}
|
|
358
|
-
});
|
|
359
|
-
// squish core_memory view
|
|
360
|
-
// squish core_memory edit persona --content "I am helpful"
|
|
361
|
-
// squish core_memory append user_info --text "Prefers TypeScript"
|
|
362
|
-
program
|
|
363
|
-
.command('core_memory')
|
|
364
|
-
.description('Manage core memory (always-visible context)')
|
|
365
|
-
.argument('[action]', 'view, edit, append', 'view')
|
|
366
|
-
.option('-s, --section <section>', 'Section: persona, user_info, project_context, working_notes')
|
|
367
|
-
.option('-c, --content <content>', 'New content (for edit)')
|
|
368
|
-
.option('-t, --text <text>', 'Text to append (for append)')
|
|
369
|
-
.option('-p, --project <project>', 'Project path', process.cwd())
|
|
370
|
-
.action(async (action, options) => {
|
|
371
|
-
try {
|
|
372
|
-
const projectPath = options.project;
|
|
373
|
-
const projectRecord = await ensureProject(projectPath);
|
|
374
|
-
if (!projectRecord) {
|
|
375
|
-
console.log(JSON.stringify({ ok: false, error: 'Project not found and could not be created' }, null, 2));
|
|
376
|
-
process.exit(1);
|
|
377
|
-
}
|
|
378
|
-
const projectId = projectRecord.id;
|
|
379
|
-
switch (action) {
|
|
380
|
-
case 'view':
|
|
381
|
-
await initializeCoreMemory(projectId);
|
|
382
|
-
const core = await getCoreMemory(projectId);
|
|
383
|
-
const stats = await getCoreMemoryStats(projectId);
|
|
384
|
-
console.log(JSON.stringify({ ok: true, action, content: core, stats }, null, 2));
|
|
385
|
-
break;
|
|
386
|
-
case 'edit':
|
|
387
|
-
if (!options.section || !options.content) {
|
|
388
|
-
console.log(JSON.stringify({ ok: false, error: '--section and --content required for edit' }, null, 2));
|
|
389
|
-
process.exit(1);
|
|
390
|
-
}
|
|
391
|
-
await initializeCoreMemory(projectId);
|
|
392
|
-
const editResult = await editCoreMemorySection(projectId, options.section, String(options.content));
|
|
393
|
-
console.log(JSON.stringify({ ok: editResult.success, action: 'edit', section: options.section, ...editResult }, null, 2));
|
|
394
|
-
break;
|
|
395
|
-
case 'append':
|
|
396
|
-
if (!options.section || !options.text) {
|
|
397
|
-
console.log(JSON.stringify({ ok: false, error: '--section and --text required for append' }, null, 2));
|
|
398
|
-
process.exit(1);
|
|
399
|
-
}
|
|
400
|
-
await initializeCoreMemory(projectId);
|
|
401
|
-
const appendResult = await appendCoreMemorySection(projectId, options.section, String(options.text));
|
|
402
|
-
console.log(JSON.stringify({ ok: appendResult.success, action: 'append', section: options.section, ...appendResult }, null, 2));
|
|
403
|
-
break;
|
|
404
|
-
default:
|
|
405
|
-
console.log(JSON.stringify({ ok: false, error: `Unknown action: ${action}` }, null, 2));
|
|
406
|
-
process.exit(1);
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
catch (error) {
|
|
410
|
-
console.log(JSON.stringify({ ok: false, error: error.message }, null, 2));
|
|
411
|
-
process.exit(1);
|
|
412
|
-
}
|
|
413
|
-
});
|
|
414
|
-
// squish set-importance <memoryId> --importance 80
|
|
415
|
-
program
|
|
416
|
-
.command('set-importance <memoryId>')
|
|
417
|
-
.description('Manually set importance score for a memory (0-100)')
|
|
418
|
-
.option('-i, --importance <number>', 'Importance score (0-100)', '50')
|
|
419
|
-
.action(async (memoryId, options) => {
|
|
420
|
-
try {
|
|
421
|
-
const score = parseInt(options.importance, 10);
|
|
422
|
-
if (isNaN(score) || score < 0 || score > 100) {
|
|
423
|
-
console.log(JSON.stringify({ ok: false, error: 'Importance must be between 0 and 100' }, null, 2));
|
|
424
|
-
process.exit(1);
|
|
425
|
-
}
|
|
426
|
-
await setImportanceScore(String(memoryId), score);
|
|
427
|
-
console.log(JSON.stringify({ ok: true, memoryId, importanceScore: score }, null, 2));
|
|
428
|
-
}
|
|
429
|
-
catch (error) {
|
|
430
|
-
console.log(JSON.stringify({ ok: false, error: error.message }, null, 2));
|
|
431
|
-
process.exit(1);
|
|
432
|
-
}
|
|
433
|
-
});
|
|
434
|
-
// squish pin <memoryId>
|
|
435
|
-
program
|
|
436
|
-
.command('pin <memoryId>')
|
|
437
|
-
.description('Pin a memory to prevent pruning/consolidation')
|
|
438
|
-
.action(async (memoryId) => {
|
|
439
|
-
try {
|
|
440
|
-
await pinMemory(String(memoryId));
|
|
441
|
-
console.log(JSON.stringify({ ok: true, memoryId, pinned: true }, null, 2));
|
|
442
|
-
}
|
|
443
|
-
catch (error) {
|
|
444
|
-
console.log(JSON.stringify({ ok: false, error: error.message }, null, 2));
|
|
445
|
-
process.exit(1);
|
|
446
|
-
}
|
|
447
|
-
});
|
|
448
|
-
// squish unpin <memoryId>
|
|
449
|
-
program
|
|
450
|
-
.command('unpin <memoryId>')
|
|
451
|
-
.description('Unpin a memory')
|
|
452
|
-
.action(async (memoryId) => {
|
|
453
|
-
try {
|
|
454
|
-
await unpinMemory(String(memoryId));
|
|
455
|
-
console.log(JSON.stringify({ ok: true, memoryId, pinned: false }, null, 2));
|
|
456
|
-
}
|
|
457
|
-
catch (error) {
|
|
458
|
-
console.log(JSON.stringify({ ok: false, error: error.message }, null, 2));
|
|
459
|
-
process.exit(1);
|
|
460
|
-
}
|
|
461
|
-
});
|
|
462
|
-
// squish consolidate --project-id <id> --min-age 90
|
|
463
|
-
program
|
|
464
|
-
.command('consolidate')
|
|
465
|
-
.description('Trigger manual memory consolidation')
|
|
466
|
-
.option('-p, --project-id <id>', 'Project ID', process.cwd())
|
|
467
|
-
.option('-a, --min-age <number>', 'Minimum age in days', '90')
|
|
468
|
-
.option('-i, --max-importance <number>', 'Maximum importance to consolidate', '30')
|
|
469
|
-
.option('-t, --threshold <number>', 'Similarity threshold (0-1)', '0.7')
|
|
470
|
-
.option('-l, --limit <number>', 'Max memories to process', '100')
|
|
471
|
-
.action(async (options) => {
|
|
472
|
-
try {
|
|
473
|
-
const results = await consolidateMemoriesImpl({
|
|
474
|
-
projectId: String(options.projectId),
|
|
475
|
-
minAge: parseInt(options.minAge, 10),
|
|
476
|
-
maxImportance: parseInt(options.maxImportance, 10),
|
|
477
|
-
similarityThreshold: parseFloat(options.threshold),
|
|
478
|
-
limit: parseInt(options.limit, 10),
|
|
479
|
-
});
|
|
480
|
-
console.log(JSON.stringify({ ok: true, consolidated: results.length, results }, null, 2));
|
|
481
|
-
}
|
|
482
|
-
catch (error) {
|
|
483
|
-
console.log(JSON.stringify({ ok: false, error: error.message }, null, 2));
|
|
484
|
-
process.exit(1);
|
|
485
|
-
}
|
|
486
|
-
});
|
|
487
|
-
// squish consolidation-stats --project-id <id>
|
|
488
|
-
program
|
|
489
|
-
.command('consolidation-stats')
|
|
490
|
-
.description('Get consolidation statistics for a project')
|
|
491
|
-
.option('-p, --project-id <id>', 'Project ID', process.cwd())
|
|
492
|
-
.action(async (options) => {
|
|
493
|
-
try {
|
|
494
|
-
const stats = await getConsolidationStats(String(options.projectId));
|
|
495
|
-
console.log(JSON.stringify({ ok: true, ...stats }, null, 2));
|
|
496
|
-
}
|
|
497
|
-
catch (error) {
|
|
498
|
-
console.log(JSON.stringify({ ok: false, error: error.message }, null, 2));
|
|
499
|
-
process.exit(1);
|
|
500
|
-
}
|
|
501
|
-
});
|
|
502
|
-
// squish health
|
|
503
|
-
program
|
|
504
|
-
.command('health')
|
|
505
|
-
.description('Check service health and configuration')
|
|
506
|
-
.option('-j, --json', 'Output as JSON', false)
|
|
507
|
-
.action(async (options) => {
|
|
508
|
-
try {
|
|
509
|
-
const dbHealth = await checkDatabaseHealth();
|
|
510
|
-
const redisHealth = await checkRedisHealth();
|
|
511
|
-
const dataDir = process.env.SQUISH_DATA_DIR || path.join(os.homedir(), '.squish');
|
|
512
|
-
const dirExists = fs.existsSync(dataDir);
|
|
513
|
-
const status = {
|
|
514
|
-
version: VERSION,
|
|
515
|
-
mode: config.isTeamMode ? 'team' : 'local',
|
|
516
|
-
database: dbHealth ? 'ok' : 'error',
|
|
517
|
-
cache: redisHealth ? 'ok' : 'unavailable',
|
|
518
|
-
dataDirectory: dataDir,
|
|
519
|
-
dataDirectoryExists: dirExists,
|
|
520
|
-
timestamp: new Date().toISOString()
|
|
521
|
-
};
|
|
522
|
-
if (options.json) {
|
|
523
|
-
console.log(JSON.stringify({ ok: true, ...status }, null, 2));
|
|
524
|
-
}
|
|
525
|
-
else {
|
|
526
|
-
console.log(`\n Squish Memory v${VERSION}`);
|
|
527
|
-
console.log(` ====================`);
|
|
528
|
-
console.log(` Mode: ${status.mode}`);
|
|
529
|
-
console.log(` Database: ${status.database}`);
|
|
530
|
-
console.log(` Cache: ${status.cache}`);
|
|
531
|
-
console.log(` Data Dir: ${status.dataDirectory}`);
|
|
532
|
-
console.log(` Status: ${dbHealth ? 'HEALTHY' : 'UNHEALTHY'}\n`);
|
|
533
|
-
}
|
|
534
|
-
if (!dbHealth) {
|
|
535
|
-
process.exit(1);
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
|
-
catch (error) {
|
|
539
|
-
console.log(JSON.stringify({ ok: false, error: error.message }, null, 2));
|
|
540
|
-
process.exit(1);
|
|
541
|
-
}
|
|
542
|
-
});
|
|
543
|
-
// squish stats
|
|
544
|
-
program
|
|
545
|
-
.command('stats')
|
|
546
|
-
.description('View statistics')
|
|
547
|
-
.option('-p, --project <project>', 'Project path', process.cwd())
|
|
548
|
-
.action(async (options) => {
|
|
549
|
-
try {
|
|
550
|
-
const stats = await getMemoryStats(options.project);
|
|
551
|
-
console.log(JSON.stringify({ ok: true, ...stats }, null, 2));
|
|
552
|
-
}
|
|
553
|
-
catch (error) {
|
|
554
|
-
console.log(JSON.stringify({ ok: false, error: error.message }, null, 2));
|
|
555
|
-
process.exit(1);
|
|
556
|
-
}
|
|
557
|
-
});
|
|
558
|
-
// squish install
|
|
559
|
-
program
|
|
560
|
-
.command('install')
|
|
561
|
-
.description('Run the interactive installer wizard')
|
|
562
|
-
.action(async () => {
|
|
563
|
-
await spawnInstallerWizard();
|
|
564
|
-
});
|
|
565
|
-
await program.parseAsync(process.argv);
|
|
566
|
-
}
|
|
567
|
-
// ============================================================================
|
|
568
|
-
// MCP MODE (for Claude Code) - DEFAULT
|
|
569
|
-
// ============================================================================
|
|
570
|
-
async function runMcpMode() {
|
|
571
|
-
const TOOLS = [
|
|
572
|
-
// Core Memory Tool
|
|
573
|
-
{
|
|
574
|
-
name: 'core_memory',
|
|
575
|
-
description: 'View or edit your core memory (always-visible). Use this to see your persona, user info, project context, and working notes.',
|
|
576
|
-
inputSchema: {
|
|
577
|
-
type: 'object',
|
|
578
|
-
properties: {
|
|
579
|
-
action: { type: 'string', enum: ['view', 'edit', 'append'] },
|
|
580
|
-
projectId: { type: 'string' },
|
|
581
|
-
section: { type: 'string', enum: ['persona', 'user_info', 'project_context', 'working_notes'] },
|
|
582
|
-
content: { type: 'string' },
|
|
583
|
-
text: { type: 'string' },
|
|
584
|
-
},
|
|
585
|
-
required: ['action', 'projectId']
|
|
586
|
-
}
|
|
587
|
-
},
|
|
588
|
-
// Context Paging
|
|
589
|
-
{
|
|
590
|
-
name: 'context_paging',
|
|
591
|
-
description: 'Manage your working memory set. Load, evict, or view loaded memories.',
|
|
592
|
-
inputSchema: {
|
|
593
|
-
type: 'object',
|
|
594
|
-
properties: {
|
|
595
|
-
action: { type: 'string', enum: ['load', 'evict', 'view'] },
|
|
596
|
-
sessionId: { type: 'string' },
|
|
597
|
-
memoryId: { type: 'string' },
|
|
598
|
-
},
|
|
599
|
-
required: ['action', 'sessionId']
|
|
600
|
-
}
|
|
601
|
-
},
|
|
602
|
-
{
|
|
603
|
-
name: 'context_status',
|
|
604
|
-
description: 'View comprehensive context window status and token usage',
|
|
605
|
-
inputSchema: {
|
|
606
|
-
type: 'object',
|
|
607
|
-
properties: {
|
|
608
|
-
sessionId: { type: 'string' },
|
|
609
|
-
projectId: { type: 'string' },
|
|
610
|
-
},
|
|
611
|
-
required: ['sessionId', 'projectId']
|
|
612
|
-
}
|
|
613
|
-
},
|
|
614
|
-
// Memory Tools
|
|
615
|
-
{
|
|
616
|
-
name: 'remember',
|
|
617
|
-
description: 'Store information for future use. Perfect for facts, decisions, code snippets, configuration details, or user preferences.',
|
|
618
|
-
inputSchema: {
|
|
619
|
-
type: 'object',
|
|
620
|
-
properties: {
|
|
621
|
-
content: { type: 'string' },
|
|
622
|
-
type: { type: 'string', enum: ['observation', 'fact', 'decision', 'context', 'preference'] },
|
|
623
|
-
tags: { type: 'array', items: { type: 'string' } },
|
|
624
|
-
project: { type: 'string' },
|
|
625
|
-
metadata: { type: 'object' },
|
|
626
|
-
},
|
|
627
|
-
required: ['content']
|
|
628
|
-
}
|
|
629
|
-
},
|
|
630
|
-
{
|
|
631
|
-
name: 'recall',
|
|
632
|
-
description: 'Retrieve a specific stored memory by ID',
|
|
633
|
-
inputSchema: {
|
|
634
|
-
type: 'object',
|
|
635
|
-
properties: { id: { type: 'string' } },
|
|
636
|
-
required: ['id']
|
|
637
|
-
}
|
|
638
|
-
},
|
|
639
|
-
{
|
|
640
|
-
name: 'search',
|
|
641
|
-
description: 'Search your stored memories. Leave query empty to list recent memories.',
|
|
642
|
-
inputSchema: {
|
|
643
|
-
type: 'object',
|
|
644
|
-
properties: {
|
|
645
|
-
query: { type: 'string' },
|
|
646
|
-
scope: { type: 'string', enum: ['memories', 'conversations', 'recent'], default: 'memories' },
|
|
647
|
-
type: { type: 'string', enum: ['observation', 'fact', 'decision', 'context', 'preference'] },
|
|
648
|
-
tags: { type: 'array', items: { type: 'string' } },
|
|
649
|
-
limit: { type: 'number', default: 10 },
|
|
650
|
-
project: { type: 'string' },
|
|
651
|
-
}
|
|
652
|
-
}
|
|
653
|
-
},
|
|
654
|
-
{
|
|
655
|
-
name: 'observe',
|
|
656
|
-
description: 'Record an observation about your work (tool usage, patterns, errors)',
|
|
657
|
-
inputSchema: {
|
|
658
|
-
type: 'object',
|
|
659
|
-
properties: {
|
|
660
|
-
type: { type: 'string', enum: ['tool_use', 'file_change', 'error', 'pattern', 'insight'] },
|
|
661
|
-
action: { type: 'string' },
|
|
662
|
-
target: { type: 'string' },
|
|
663
|
-
summary: { type: 'string' },
|
|
664
|
-
details: { type: 'object' },
|
|
665
|
-
},
|
|
666
|
-
required: ['type', 'action', 'summary']
|
|
667
|
-
}
|
|
668
|
-
},
|
|
669
|
-
{
|
|
670
|
-
name: 'context',
|
|
671
|
-
description: 'Get project context',
|
|
672
|
-
inputSchema: {
|
|
673
|
-
type: 'object',
|
|
674
|
-
properties: {
|
|
675
|
-
project: { type: 'string' },
|
|
676
|
-
include: { type: 'array', items: { type: 'string' }, default: ['memories', 'observations'] },
|
|
677
|
-
limit: { type: 'number', default: 10 }
|
|
678
|
-
},
|
|
679
|
-
required: ['project']
|
|
680
|
-
}
|
|
681
|
-
},
|
|
682
|
-
{
|
|
683
|
-
name: 'init',
|
|
684
|
-
description: 'Initialize Squish memory system for the current project',
|
|
685
|
-
inputSchema: {
|
|
686
|
-
type: 'object',
|
|
687
|
-
properties: { projectPath: { type: 'string' } }
|
|
688
|
-
}
|
|
689
|
-
},
|
|
690
|
-
{
|
|
691
|
-
name: 'health',
|
|
692
|
-
description: 'Check service status',
|
|
693
|
-
inputSchema: { type: 'object', properties: {} }
|
|
694
|
-
},
|
|
695
|
-
{
|
|
696
|
-
name: 'merge',
|
|
697
|
-
description: 'Manage memory merges: detect, list, preview, approve, reject, reverse',
|
|
698
|
-
inputSchema: {
|
|
699
|
-
type: 'object',
|
|
700
|
-
properties: {
|
|
701
|
-
action: { type: 'string', enum: ['detect', 'list', 'preview', 'stats', 'approve', 'reject', 'reverse'] },
|
|
702
|
-
projectId: { type: 'string' },
|
|
703
|
-
proposalId: { type: 'string' },
|
|
704
|
-
threshold: { type: 'number' },
|
|
705
|
-
},
|
|
706
|
-
required: ['action']
|
|
707
|
-
}
|
|
708
|
-
},
|
|
709
|
-
{
|
|
710
|
-
name: 'qmd_search',
|
|
711
|
-
description: 'Search memories using QMD hybrid search (BM25 + vector + rerank)',
|
|
712
|
-
inputSchema: {
|
|
713
|
-
type: 'object',
|
|
714
|
-
properties: {
|
|
715
|
-
query: { type: 'string' },
|
|
716
|
-
type: { type: 'string', enum: ['observation', 'fact', 'decision', 'context', 'preference'] },
|
|
717
|
-
limit: { type: 'number', default: 10 },
|
|
718
|
-
},
|
|
719
|
-
required: ['query']
|
|
720
|
-
}
|
|
721
|
-
},
|
|
722
|
-
// v0.8.0: Importance Scoring Tools
|
|
723
|
-
{
|
|
724
|
-
name: 'set_importance',
|
|
725
|
-
description: 'Manually set importance score for a memory (0-100)',
|
|
726
|
-
inputSchema: {
|
|
727
|
-
type: 'object',
|
|
728
|
-
properties: {
|
|
729
|
-
memoryId: { type: 'string' },
|
|
730
|
-
importance: { type: 'number', minimum: 0, maximum: 100 },
|
|
731
|
-
},
|
|
732
|
-
required: ['memoryId', 'importance']
|
|
733
|
-
}
|
|
734
|
-
},
|
|
735
|
-
{
|
|
736
|
-
name: 'pin_memory',
|
|
737
|
-
description: 'Pin a memory to prevent pruning/consolidation (or unpin it)',
|
|
738
|
-
inputSchema: {
|
|
739
|
-
type: 'object',
|
|
740
|
-
properties: {
|
|
741
|
-
memoryId: { type: 'string' },
|
|
742
|
-
pinned: { type: 'boolean', default: true },
|
|
743
|
-
},
|
|
744
|
-
required: ['memoryId']
|
|
745
|
-
}
|
|
746
|
-
},
|
|
747
|
-
// v0.8.0: Consolidation Tool
|
|
748
|
-
{
|
|
749
|
-
name: 'consolidate',
|
|
750
|
-
description: 'Trigger manual memory consolidation - summarizes old, low-importance memories',
|
|
751
|
-
inputSchema: {
|
|
752
|
-
type: 'object',
|
|
753
|
-
properties: {
|
|
754
|
-
projectId: { type: 'string' },
|
|
755
|
-
threshold: { type: 'number', default: 0.7 },
|
|
756
|
-
minAge: { type: 'number', default: 90 },
|
|
757
|
-
limit: { type: 'number', default: 100 },
|
|
758
|
-
},
|
|
759
|
-
required: ['projectId']
|
|
760
|
-
}
|
|
761
|
-
},
|
|
762
|
-
{
|
|
763
|
-
name: 'consolidation_stats',
|
|
764
|
-
description: 'Get consolidation statistics for a project',
|
|
765
|
-
inputSchema: {
|
|
766
|
-
type: 'object',
|
|
767
|
-
properties: {
|
|
768
|
-
projectId: { type: 'string' },
|
|
769
|
-
},
|
|
770
|
-
required: ['projectId']
|
|
771
|
-
}
|
|
772
|
-
}
|
|
773
|
-
];
|
|
774
|
-
class Squish {
|
|
775
|
-
server;
|
|
776
|
-
projectPath;
|
|
777
|
-
constructor() {
|
|
778
|
-
this.projectPath = process.env.CLAUDE_WORKING_DIRECTORY || process.cwd();
|
|
779
|
-
this.server = new Server({ name: 'squish', version: VERSION }, {
|
|
780
|
-
capabilities: { tools: {} },
|
|
781
|
-
});
|
|
782
|
-
this.setup();
|
|
783
|
-
}
|
|
784
|
-
async onSessionInitialized() {
|
|
785
|
-
if (!shouldAutoLoad()) {
|
|
786
|
-
logger.info('[Session] Auto-load disabled');
|
|
787
|
-
return;
|
|
788
|
-
}
|
|
789
|
-
try {
|
|
790
|
-
logger.info('[Session] Performing auto-load...');
|
|
791
|
-
const result = await performAutoLoad(this.projectPath, getAutoLoadConfig());
|
|
792
|
-
if (result.warnings.length > 0) {
|
|
793
|
-
logger.warn('[Session] Auto-load warnings:', result.warnings);
|
|
794
|
-
}
|
|
795
|
-
logger.info(`[Session] Auto-load complete: ${result.memoriesLoaded} memories, ~${result.tokensUsed} tokens`);
|
|
796
|
-
}
|
|
797
|
-
catch (error) {
|
|
798
|
-
logger.error('[Session] Auto-load failed:', error);
|
|
799
|
-
}
|
|
800
|
-
}
|
|
801
|
-
setup() {
|
|
802
|
-
this.server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
803
|
-
tools: TOOLS
|
|
804
|
-
}));
|
|
805
|
-
this.server.setRequestHandler(CallToolRequestSchema, async (req) => {
|
|
806
|
-
const { name } = req.params;
|
|
807
|
-
const args = (req.params.arguments ?? {});
|
|
808
|
-
try {
|
|
809
|
-
switch (name) {
|
|
810
|
-
case 'core_memory':
|
|
811
|
-
return await this.handleCoreMemory(args);
|
|
812
|
-
case 'context_paging':
|
|
813
|
-
return await this.handleContextPaging(args);
|
|
814
|
-
case 'context_status': {
|
|
815
|
-
const result = await getContextStatus(String(args.sessionId), String(args.projectId));
|
|
816
|
-
return this.jsonResponse({ ok: true, ...result });
|
|
817
|
-
}
|
|
818
|
-
case 'remember': {
|
|
819
|
-
return this.jsonResponse({ ok: true, data: await rememberMemory(args) });
|
|
820
|
-
}
|
|
821
|
-
case 'recall': {
|
|
822
|
-
const memory = await getMemoryById(String(args.id));
|
|
823
|
-
return this.jsonResponse({ ok: true, found: !!memory, data: memory });
|
|
824
|
-
}
|
|
825
|
-
case 'search': {
|
|
826
|
-
return this.jsonResponse({ ok: true, data: await searchMemories(args) });
|
|
827
|
-
}
|
|
828
|
-
case 'observe':
|
|
829
|
-
return this.jsonResponse({ ok: true, data: await createObservation(args) });
|
|
830
|
-
case 'context':
|
|
831
|
-
return this.jsonResponse({ ok: true, data: await getProjectContext(args) });
|
|
832
|
-
case 'init': {
|
|
833
|
-
await ensureDataDirectory();
|
|
834
|
-
const project = await ensureProject(args.projectPath || process.cwd());
|
|
835
|
-
return this.jsonResponse({ success: true, project });
|
|
836
|
-
}
|
|
837
|
-
case 'health':
|
|
838
|
-
return this.health();
|
|
839
|
-
case 'merge':
|
|
840
|
-
return await this.handleMerge(args);
|
|
841
|
-
case 'qmd_search': {
|
|
842
|
-
const available = await isQMDAvailable();
|
|
843
|
-
if (!available) {
|
|
844
|
-
return this.jsonResponse({ ok: true, qmdAvailable: false, data: await searchMemories(args) });
|
|
845
|
-
}
|
|
846
|
-
return this.jsonResponse({ ok: true, qmdAvailable: true, data: await searchWithQMD(args) });
|
|
847
|
-
}
|
|
848
|
-
// v0.8.0: Importance scoring tools
|
|
849
|
-
case 'set_importance': {
|
|
850
|
-
await setImportanceScore(String(args.memoryId), Number(args.importance));
|
|
851
|
-
return this.jsonResponse({
|
|
852
|
-
ok: true,
|
|
853
|
-
message: `Importance score set to ${args.importance} for memory ${args.memoryId}`
|
|
854
|
-
});
|
|
855
|
-
}
|
|
856
|
-
case 'pin_memory': {
|
|
857
|
-
const pinned = args.pinned !== undefined ? Boolean(args.pinned) : true;
|
|
858
|
-
if (pinned) {
|
|
859
|
-
await pinMemory(String(args.memoryId));
|
|
860
|
-
}
|
|
861
|
-
else {
|
|
862
|
-
await unpinMemory(String(args.memoryId));
|
|
863
|
-
}
|
|
864
|
-
return this.jsonResponse({
|
|
865
|
-
ok: true,
|
|
866
|
-
message: `Memory ${args.memoryId} ${pinned ? 'pinned' : 'unpinned'}`
|
|
867
|
-
});
|
|
868
|
-
}
|
|
869
|
-
// v0.8.0: Consolidation tools
|
|
870
|
-
case 'consolidate': {
|
|
871
|
-
const results = await consolidateMemoriesImpl({
|
|
872
|
-
projectId: String(args.projectId),
|
|
873
|
-
minAge: args.minAge ? Number(args.minAge) : 90,
|
|
874
|
-
maxImportance: 30,
|
|
875
|
-
similarityThreshold: args.threshold ? Number(args.threshold) : 0.7,
|
|
876
|
-
limit: args.limit ? Number(args.limit) : 100,
|
|
877
|
-
});
|
|
878
|
-
return this.jsonResponse({
|
|
879
|
-
ok: true,
|
|
880
|
-
consolidated: results.length,
|
|
881
|
-
results
|
|
882
|
-
});
|
|
883
|
-
}
|
|
884
|
-
case 'consolidation_stats': {
|
|
885
|
-
const stats = await getConsolidationStats(String(args.projectId));
|
|
886
|
-
return this.jsonResponse({ ok: true, ...stats });
|
|
887
|
-
}
|
|
888
|
-
default:
|
|
889
|
-
throw new McpError(ErrorCode.MethodNotFound, `Unknown tool: ${name}`);
|
|
890
|
-
}
|
|
891
|
-
}
|
|
892
|
-
catch (error) {
|
|
893
|
-
if (error instanceof McpError)
|
|
894
|
-
throw error;
|
|
895
|
-
throw new McpError(ErrorCode.InternalError, `Tool '${name}' failed`);
|
|
896
|
-
}
|
|
897
|
-
});
|
|
898
|
-
this.server.onerror = (e) => logger.error('MCP Server error', e);
|
|
899
|
-
process.on('SIGINT', () => this.shutdown());
|
|
900
|
-
process.on('SIGTERM', () => this.shutdown());
|
|
901
|
-
}
|
|
902
|
-
jsonResponse(payload) {
|
|
903
|
-
return {
|
|
904
|
-
content: [{ type: 'text', text: JSON.stringify(payload, null, 2) }]
|
|
905
|
-
};
|
|
906
|
-
}
|
|
907
|
-
async handleCoreMemory(args) {
|
|
908
|
-
const action = args.action;
|
|
909
|
-
const projectId = String(args.projectId);
|
|
910
|
-
await initializeCoreMemory(projectId);
|
|
911
|
-
const actions = {
|
|
912
|
-
view: async () => {
|
|
913
|
-
const content = await getCoreMemory(projectId);
|
|
914
|
-
const stats = await getCoreMemoryStats(projectId);
|
|
915
|
-
return this.jsonResponse({ ok: true, action: 'view', content, stats });
|
|
916
|
-
},
|
|
917
|
-
edit: async () => {
|
|
918
|
-
const result = await editCoreMemorySection(projectId, args.section, String(args.content));
|
|
919
|
-
return this.jsonResponse({ ok: true, action: 'edit', ...result });
|
|
920
|
-
},
|
|
921
|
-
append: async () => {
|
|
922
|
-
const result = await appendCoreMemorySection(projectId, args.section, String(args.text));
|
|
923
|
-
return this.jsonResponse({ ok: true, action: 'append', ...result });
|
|
924
|
-
},
|
|
925
|
-
};
|
|
926
|
-
const handler = actions[action];
|
|
927
|
-
if (!handler)
|
|
928
|
-
throw new McpError(ErrorCode.InvalidParams, `Unknown action: ${action}`);
|
|
929
|
-
return handler();
|
|
930
|
-
}
|
|
931
|
-
async handleContextPaging(args) {
|
|
932
|
-
const action = args.action;
|
|
933
|
-
const sessionId = String(args.sessionId);
|
|
934
|
-
const actions = {
|
|
935
|
-
load: () => loadMemoryToContext(sessionId, String(args.memoryId)),
|
|
936
|
-
evict: () => evictMemoryFromContext(sessionId, String(args.memoryId)),
|
|
937
|
-
view: () => viewLoadedMemories(sessionId),
|
|
938
|
-
};
|
|
939
|
-
const handler = actions[action];
|
|
940
|
-
if (!handler)
|
|
941
|
-
throw new McpError(ErrorCode.InvalidParams, `Unknown action: ${action}`);
|
|
942
|
-
return this.jsonResponse(await handler());
|
|
943
|
-
}
|
|
944
|
-
async handleMerge(args) {
|
|
945
|
-
const action = args.action;
|
|
946
|
-
const handlers = {
|
|
947
|
-
detect: () => handleDetectDuplicates(args),
|
|
948
|
-
list: () => handleListProposals(args),
|
|
949
|
-
preview: () => handlePreviewMerge(args),
|
|
950
|
-
stats: () => handleGetMergeStats(args),
|
|
951
|
-
approve: () => handleApproveMerge(args),
|
|
952
|
-
reject: () => handleRejectMerge(args),
|
|
953
|
-
reverse: () => handleReverseMerge(args),
|
|
954
|
-
};
|
|
955
|
-
const handler = handlers[action];
|
|
956
|
-
if (!handler)
|
|
957
|
-
throw new McpError(ErrorCode.InvalidParams, `Unknown action: ${action}`);
|
|
958
|
-
return this.jsonResponse(await handler());
|
|
959
|
-
}
|
|
960
|
-
async shutdown() {
|
|
961
|
-
await closeCache();
|
|
962
|
-
process.exit(0);
|
|
963
|
-
}
|
|
964
|
-
async health() {
|
|
965
|
-
const dbOk = await checkDatabaseHealth();
|
|
966
|
-
const redisOk = await checkRedisHealth();
|
|
967
|
-
return this.jsonResponse({
|
|
968
|
-
version: VERSION,
|
|
969
|
-
mode: config.isTeamMode ? 'team' : 'local',
|
|
970
|
-
status: dbOk ? 'ok' : 'error',
|
|
971
|
-
});
|
|
972
|
-
}
|
|
973
|
-
async run() {
|
|
974
|
-
// Verify plugin manifest (universal plugin self-check)
|
|
975
|
-
const manifest = loadPluginManifest();
|
|
976
|
-
const verification = verifyManifest(manifest);
|
|
977
|
-
if (!verification.ok) {
|
|
978
|
-
logger.warn('Plugin manifest verification failed:', verification.errors);
|
|
979
|
-
}
|
|
980
|
-
else {
|
|
981
|
-
logger.info(`Squish v${VERSION} - Plugin manifest verified`);
|
|
982
|
-
}
|
|
983
|
-
const transport = new StdioServerTransport();
|
|
984
|
-
await this.server.connect(transport);
|
|
985
|
-
logger.info(`v${VERSION}`);
|
|
986
|
-
registerJobHandler('nightly_maintenance', runNightlyJob);
|
|
987
|
-
registerJobHandler('weekly_maintenance', runWeeklyJob);
|
|
988
|
-
await initializeScheduler();
|
|
989
|
-
startHeartbeatChecking();
|
|
990
|
-
await this.onSessionInitialized();
|
|
991
|
-
await heartbeat();
|
|
992
|
-
startWebServer();
|
|
993
|
-
}
|
|
994
|
-
}
|
|
995
|
-
new Squish().run();
|
|
996
|
-
}
|
|
997
|
-
//# sourceMappingURL=index.js.map
|