squish-memory 1.0.2 → 1.1.5
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 +130 -0
- package/CHANGELOG.md +55 -0
- package/README.md +150 -287
- package/config/hooks/claude-code-hooks.json +39 -0
- package/config/hooks/cursor-hooks.json +30 -0
- package/config/hooks/opencode-hooks.json +30 -0
- package/config/hooks/windsurf-hooks.json +30 -0
- package/config/mcp-mode-semantics.json +23 -21
- package/config/plugin-manifest.json +101 -152
- package/{plugin.json → config/plugin.json} +2 -2
- package/config/settings.json +52 -51
- package/{commands → core/commands}/init.md +39 -39
- package/dist/config.d.ts +28 -4
- package/dist/config.js +97 -29
- 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 +157 -0
- package/dist/core/adapters/types.js +50 -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 +1 -1
- 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 +133 -0
- package/dist/core/algorithms/types.js +5 -0
- package/dist/core/associations.d.ts +1 -2
- package/dist/core/associations.js +1 -2
- package/dist/core/autosave.d.ts +19 -0
- package/dist/core/autosave.js +16 -0
- package/dist/{commands → core/commands}/managed-sync.js +5 -5
- package/dist/core/commands/mcp-server.js +739 -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.d.ts +1 -1
- package/dist/core/embeddings.js +54 -2
- package/dist/core/error-handling.d.ts +63 -0
- package/dist/core/error-handling.js +173 -0
- package/dist/core/external-folder/index.d.ts +102 -0
- package/dist/core/external-folder/index.js +294 -0
- package/dist/core/hooks/agent-hooks.d.ts +74 -0
- package/dist/core/hooks/agent-hooks.js +244 -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/index.d.ts +6 -6
- package/dist/core/index.js +6 -6
- package/dist/core/{agent-memory.js → ingestion/agent-memory.js} +5 -7
- package/dist/core/{core-memory.js → ingestion/core-memory.js} +4 -4
- package/dist/core/ingestion/learnings.d.ts +57 -0
- package/dist/core/ingestion/learnings.js +202 -0
- package/dist/core/lib/db-client.d.ts +114 -0
- package/dist/core/lib/db-client.js +130 -0
- package/dist/core/lib/schemas.d.ts +129 -0
- package/dist/core/lib/schemas.js +87 -0
- package/dist/core/{utils.d.ts → lib/utils.d.ts} +1 -0
- package/dist/core/{utils.js → lib/utils.js} +31 -15
- package/dist/core/lib/validation.d.ts +38 -0
- package/dist/core/lib/validation.js +151 -0
- package/dist/core/lifecycle.d.ts +7 -0
- package/dist/core/lifecycle.js +140 -20
- package/dist/core/local-embeddings.d.ts +6 -1
- package/dist/core/local-embeddings.js +6 -15
- package/dist/core/logger.js +7 -1
- package/dist/core/mcp/tools.js +35 -3
- package/dist/core/memory/categorizer.js +1 -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 +2 -11
- package/dist/core/memory/context-collector.js +1 -1
- package/dist/core/memory/edit-workflow.js +1 -1
- package/dist/core/memory/entity-resolver.js +7 -7
- 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.js +2 -2
- package/dist/core/memory/hybrid-search.d.ts +1 -6
- package/dist/core/memory/hybrid-search.js +70 -84
- package/dist/core/memory/importance.d.ts +8 -13
- package/dist/core/memory/importance.js +47 -74
- 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 +12 -4
- package/dist/core/memory/memories.js +192 -180
- package/dist/core/memory/memory-lifecycle.d.ts +8 -0
- package/dist/core/memory/memory-lifecycle.js +55 -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 +22 -0
- package/dist/core/memory/normalization.js +26 -0
- package/dist/core/memory/progressive-disclosure.js +1 -1
- package/dist/core/memory/query-rewriter.js +9 -9
- package/dist/core/memory/serialization.d.ts +4 -0
- package/dist/core/memory/serialization.js +49 -0
- package/dist/core/memory/stats.d.ts +5 -0
- package/dist/core/memory/stats.js +63 -12
- package/dist/core/memory/temporal-facts.js +21 -0
- package/dist/core/memory/write-gate.js +1 -1
- package/dist/core/obsidian-vault.d.ts +30 -0
- package/dist/core/obsidian-vault.js +94 -0
- 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 +39 -18
- package/dist/core/responses.d.ts +96 -0
- package/dist/core/responses.js +122 -0
- package/dist/core/scheduler/cron-scheduler.js +29 -7
- package/dist/core/scheduler/index.d.ts +1 -1
- package/dist/core/scheduler/index.js +1 -1
- package/dist/core/scheduler/job-runner.js +1 -1
- 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-search.js +4 -4
- 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 +6 -6
- package/dist/core/session/index.d.ts +1 -1
- package/dist/core/session/index.js +1 -1
- package/dist/core/session/self-iteration-job.d.ts +20 -0
- package/dist/core/session/self-iteration-job.js +282 -0
- package/dist/core/session/session-hooks.d.ts +18 -0
- package/dist/core/session/session-hooks.js +58 -0
- package/dist/core/session-hooks/self-iteration-job.js +35 -35
- package/dist/core/{cache.js → storage/cache.js} +2 -2
- package/dist/core/sync/qmd-sync.d.ts +1 -13
- package/dist/core/sync/qmd-sync.js +1 -13
- package/dist/core/toon.d.ts +43 -0
- package/dist/core/toon.js +160 -0
- package/dist/core/utils/memory-operations.js +1 -1
- 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.js +820 -522
- package/dist/{drizzle → db/drizzle}/schema-sqlite.d.ts +74 -25
- package/dist/{drizzle → db/drizzle}/schema-sqlite.js +91 -24
- package/dist/{drizzle → db/drizzle}/schema.d.ts +79 -32
- package/dist/{drizzle → db/drizzle}/schema.js +106 -35
- 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/neon.d.ts +8 -0
- package/dist/db/neon.js +20 -0
- package/dist/db/schema/index.d.ts +40 -0
- package/dist/db/schema/index.js +105 -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/index.d.ts +2 -14
- package/dist/index.js +1320 -640
- package/dist/vendor/sql.js/sql-wasm.wasm +0 -0
- package/dist/webui/server.d.ts +5 -0
- package/dist/{api/web/web.js → webui/server.js} +511 -508
- package/generated/mcp/manifest.json +1 -1
- package/{.mcp.json → mcp.json.example} +1 -1
- package/package.json +159 -181
- package/scripts/README.md +60 -0
- package/scripts/copy-runtime-assets.mjs +26 -0
- package/scripts/generate-mcp.mjs +264 -264
- package/scripts/github-release.sh +4 -4
- package/scripts/install-claude-code.sh +85 -0
- package/scripts/install-cursor.sh +56 -0
- package/scripts/install-hooks.sh +73 -0
- package/scripts/install-interactive.mjs +357 -677
- package/scripts/install-opencode.sh +75 -0
- package/scripts/install-windsurf.sh +67 -0
- package/skills/squish-memory/SKILL.md +104 -114
- package/skills/squish-memory/{install.mjs → scripts/install.mjs} +2 -2
- package/skills/squish-memory/{install.sh → scripts/install.sh} +2 -2
- package/skills/squish-memory/write_skill.js +2 -0
- package/.claude-plugin/marketplace.json +0 -20
- package/.claude-plugin/plugin.json +0 -32
- package/.env.mcp.example +0 -60
- package/QUICK-START.md +0 -71
- package/bin/squish-add.mjs +0 -32
- package/bin/squish-rm.mjs +0 -21
- package/commands/observe.md +0 -5
- 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/commands/mcp-server.js +0 -393
- package/dist/core/context.js +0 -24
- package/dist/core/governance.js +0 -64
- 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/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/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/install-mcp.mjs +0 -116
- 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/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/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/claude-desktop.json +0 -12
- package/skills/squish-memory/openclaw.json +0 -13
- package/skills/squish-memory/opencode.json +0 -14
- package/skills/squish-memory/skill.json +0 -32
- /package/{commands → core/commands}/context-paging.md +0 -0
- /package/{commands → core/commands}/context-status.md +0 -0
- /package/{commands → core/commands}/context.md +0 -0
- /package/{commands → core/commands}/core-memory.md +0 -0
- /package/{commands → core/commands}/health.md +0 -0
- /package/{commands → core/commands}/merge.md +0 -0
- /package/{commands → core/commands}/recall.md +0 -0
- /package/{commands → core/commands}/remember.md +0 -0
- /package/{commands → core/commands}/search.md +0 -0
- /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/{commands → core/commands}/managed-sync.d.ts +0 -0
- /package/dist/{commands → core/commands}/mcp-server.d.ts +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/{core-memory.d.ts → ingestion/core-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/{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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type MemoryType = 'observation' | 'fact' | 'decision' | 'context' | 'preference';
|
|
1
|
+
export type MemoryType = 'observation' | 'fact' | 'decision' | 'context' | 'preference' | 'reflection' | 'note';
|
|
2
2
|
/**
|
|
3
3
|
* Users - represents Claude Code users
|
|
4
4
|
*/
|
|
@@ -914,15 +914,15 @@ export declare const messages: import("drizzle-orm/pg-core").PgTableWithColumns<
|
|
|
914
914
|
dialect: "pg";
|
|
915
915
|
}>;
|
|
916
916
|
/**
|
|
917
|
-
*
|
|
917
|
+
* Learnings - agent learnings: success, failure, fix, insight
|
|
918
918
|
*/
|
|
919
|
-
export declare const
|
|
920
|
-
name: "
|
|
919
|
+
export declare const learnings: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
920
|
+
name: "learnings";
|
|
921
921
|
schema: undefined;
|
|
922
922
|
columns: {
|
|
923
923
|
id: import("drizzle-orm/pg-core").PgColumn<{
|
|
924
924
|
name: "id";
|
|
925
|
-
tableName: "
|
|
925
|
+
tableName: "learnings";
|
|
926
926
|
dataType: "string";
|
|
927
927
|
columnType: "PgUUID";
|
|
928
928
|
data: string;
|
|
@@ -939,7 +939,7 @@ export declare const observations: import("drizzle-orm/pg-core").PgTableWithColu
|
|
|
939
939
|
}, {}, {}>;
|
|
940
940
|
projectId: import("drizzle-orm/pg-core").PgColumn<{
|
|
941
941
|
name: "project_id";
|
|
942
|
-
tableName: "
|
|
942
|
+
tableName: "learnings";
|
|
943
943
|
dataType: "string";
|
|
944
944
|
columnType: "PgUUID";
|
|
945
945
|
data: string;
|
|
@@ -956,7 +956,7 @@ export declare const observations: import("drizzle-orm/pg-core").PgTableWithColu
|
|
|
956
956
|
}, {}, {}>;
|
|
957
957
|
conversationId: import("drizzle-orm/pg-core").PgColumn<{
|
|
958
958
|
name: "conversation_id";
|
|
959
|
-
tableName: "
|
|
959
|
+
tableName: "learnings";
|
|
960
960
|
dataType: "string";
|
|
961
961
|
columnType: "PgUUID";
|
|
962
962
|
data: string;
|
|
@@ -973,10 +973,10 @@ export declare const observations: import("drizzle-orm/pg-core").PgTableWithColu
|
|
|
973
973
|
}, {}, {}>;
|
|
974
974
|
type: import("drizzle-orm/pg-core").PgColumn<{
|
|
975
975
|
name: "type";
|
|
976
|
-
tableName: "
|
|
976
|
+
tableName: "learnings";
|
|
977
977
|
dataType: "string";
|
|
978
978
|
columnType: "PgText";
|
|
979
|
-
data: "
|
|
979
|
+
data: "success" | "failure" | "fix" | "insight";
|
|
980
980
|
driverParam: string;
|
|
981
981
|
notNull: true;
|
|
982
982
|
hasDefault: false;
|
|
@@ -988,11 +988,11 @@ export declare const observations: import("drizzle-orm/pg-core").PgTableWithColu
|
|
|
988
988
|
identity: undefined;
|
|
989
989
|
generated: undefined;
|
|
990
990
|
}, {}, {
|
|
991
|
-
$type: "
|
|
991
|
+
$type: "success" | "failure" | "fix" | "insight";
|
|
992
992
|
}>;
|
|
993
993
|
action: import("drizzle-orm/pg-core").PgColumn<{
|
|
994
994
|
name: "action";
|
|
995
|
-
tableName: "
|
|
995
|
+
tableName: "learnings";
|
|
996
996
|
dataType: "string";
|
|
997
997
|
columnType: "PgText";
|
|
998
998
|
data: string;
|
|
@@ -1009,7 +1009,7 @@ export declare const observations: import("drizzle-orm/pg-core").PgTableWithColu
|
|
|
1009
1009
|
}, {}, {}>;
|
|
1010
1010
|
target: import("drizzle-orm/pg-core").PgColumn<{
|
|
1011
1011
|
name: "target";
|
|
1012
|
-
tableName: "
|
|
1012
|
+
tableName: "learnings";
|
|
1013
1013
|
dataType: "string";
|
|
1014
1014
|
columnType: "PgText";
|
|
1015
1015
|
data: string;
|
|
@@ -1026,7 +1026,7 @@ export declare const observations: import("drizzle-orm/pg-core").PgTableWithColu
|
|
|
1026
1026
|
}, {}, {}>;
|
|
1027
1027
|
summary: import("drizzle-orm/pg-core").PgColumn<{
|
|
1028
1028
|
name: "summary";
|
|
1029
|
-
tableName: "
|
|
1029
|
+
tableName: "learnings";
|
|
1030
1030
|
dataType: "string";
|
|
1031
1031
|
columnType: "PgText";
|
|
1032
1032
|
data: string;
|
|
@@ -1043,7 +1043,7 @@ export declare const observations: import("drizzle-orm/pg-core").PgTableWithColu
|
|
|
1043
1043
|
}, {}, {}>;
|
|
1044
1044
|
details: import("drizzle-orm/pg-core").PgColumn<{
|
|
1045
1045
|
name: "details";
|
|
1046
|
-
tableName: "
|
|
1046
|
+
tableName: "learnings";
|
|
1047
1047
|
dataType: "json";
|
|
1048
1048
|
columnType: "PgJsonb";
|
|
1049
1049
|
data: Record<string, unknown>;
|
|
@@ -1062,7 +1062,7 @@ export declare const observations: import("drizzle-orm/pg-core").PgTableWithColu
|
|
|
1062
1062
|
}>;
|
|
1063
1063
|
embedding: import("drizzle-orm/pg-core").PgColumn<{
|
|
1064
1064
|
name: "embedding";
|
|
1065
|
-
tableName: "
|
|
1065
|
+
tableName: "learnings";
|
|
1066
1066
|
dataType: "array";
|
|
1067
1067
|
columnType: "PgVector";
|
|
1068
1068
|
data: number[];
|
|
@@ -1079,9 +1079,26 @@ export declare const observations: import("drizzle-orm/pg-core").PgTableWithColu
|
|
|
1079
1079
|
}, {}, {
|
|
1080
1080
|
dimensions: 1536;
|
|
1081
1081
|
}>;
|
|
1082
|
+
memoryId: import("drizzle-orm/pg-core").PgColumn<{
|
|
1083
|
+
name: "memory_id";
|
|
1084
|
+
tableName: "learnings";
|
|
1085
|
+
dataType: "string";
|
|
1086
|
+
columnType: "PgUUID";
|
|
1087
|
+
data: string;
|
|
1088
|
+
driverParam: string;
|
|
1089
|
+
notNull: false;
|
|
1090
|
+
hasDefault: false;
|
|
1091
|
+
isPrimaryKey: false;
|
|
1092
|
+
isAutoincrement: false;
|
|
1093
|
+
hasRuntimeDefault: false;
|
|
1094
|
+
enumValues: undefined;
|
|
1095
|
+
baseColumn: never;
|
|
1096
|
+
identity: undefined;
|
|
1097
|
+
generated: undefined;
|
|
1098
|
+
}, {}, {}>;
|
|
1082
1099
|
folderPath: import("drizzle-orm/pg-core").PgColumn<{
|
|
1083
1100
|
name: "folder_path";
|
|
1084
|
-
tableName: "
|
|
1101
|
+
tableName: "learnings";
|
|
1085
1102
|
dataType: "string";
|
|
1086
1103
|
columnType: "PgText";
|
|
1087
1104
|
data: string;
|
|
@@ -1098,7 +1115,7 @@ export declare const observations: import("drizzle-orm/pg-core").PgTableWithColu
|
|
|
1098
1115
|
}, {}, {}>;
|
|
1099
1116
|
projectPath: import("drizzle-orm/pg-core").PgColumn<{
|
|
1100
1117
|
name: "project_path";
|
|
1101
|
-
tableName: "
|
|
1118
|
+
tableName: "learnings";
|
|
1102
1119
|
dataType: "string";
|
|
1103
1120
|
columnType: "PgText";
|
|
1104
1121
|
data: string;
|
|
@@ -1115,7 +1132,7 @@ export declare const observations: import("drizzle-orm/pg-core").PgTableWithColu
|
|
|
1115
1132
|
}, {}, {}>;
|
|
1116
1133
|
isPrivate: import("drizzle-orm/pg-core").PgColumn<{
|
|
1117
1134
|
name: "is_private";
|
|
1118
|
-
tableName: "
|
|
1135
|
+
tableName: "learnings";
|
|
1119
1136
|
dataType: "boolean";
|
|
1120
1137
|
columnType: "PgBoolean";
|
|
1121
1138
|
data: boolean;
|
|
@@ -1132,7 +1149,7 @@ export declare const observations: import("drizzle-orm/pg-core").PgTableWithColu
|
|
|
1132
1149
|
}, {}, {}>;
|
|
1133
1150
|
hasSecrets: import("drizzle-orm/pg-core").PgColumn<{
|
|
1134
1151
|
name: "has_secrets";
|
|
1135
|
-
tableName: "
|
|
1152
|
+
tableName: "learnings";
|
|
1136
1153
|
dataType: "boolean";
|
|
1137
1154
|
columnType: "PgBoolean";
|
|
1138
1155
|
data: boolean;
|
|
@@ -1149,7 +1166,7 @@ export declare const observations: import("drizzle-orm/pg-core").PgTableWithColu
|
|
|
1149
1166
|
}, {}, {}>;
|
|
1150
1167
|
relevanceScore: import("drizzle-orm/pg-core").PgColumn<{
|
|
1151
1168
|
name: "relevance_score";
|
|
1152
|
-
tableName: "
|
|
1169
|
+
tableName: "learnings";
|
|
1153
1170
|
dataType: "number";
|
|
1154
1171
|
columnType: "PgInteger";
|
|
1155
1172
|
data: number;
|
|
@@ -1166,7 +1183,7 @@ export declare const observations: import("drizzle-orm/pg-core").PgTableWithColu
|
|
|
1166
1183
|
}, {}, {}>;
|
|
1167
1184
|
category: import("drizzle-orm/pg-core").PgColumn<{
|
|
1168
1185
|
name: "category";
|
|
1169
|
-
tableName: "
|
|
1186
|
+
tableName: "learnings";
|
|
1170
1187
|
dataType: "string";
|
|
1171
1188
|
columnType: "PgText";
|
|
1172
1189
|
data: string;
|
|
@@ -1183,7 +1200,7 @@ export declare const observations: import("drizzle-orm/pg-core").PgTableWithColu
|
|
|
1183
1200
|
}, {}, {}>;
|
|
1184
1201
|
importance: import("drizzle-orm/pg-core").PgColumn<{
|
|
1185
1202
|
name: "importance";
|
|
1186
|
-
tableName: "
|
|
1203
|
+
tableName: "learnings";
|
|
1187
1204
|
dataType: "number";
|
|
1188
1205
|
columnType: "PgInteger";
|
|
1189
1206
|
data: number;
|
|
@@ -1200,7 +1217,7 @@ export declare const observations: import("drizzle-orm/pg-core").PgTableWithColu
|
|
|
1200
1217
|
}, {}, {}>;
|
|
1201
1218
|
metadata: import("drizzle-orm/pg-core").PgColumn<{
|
|
1202
1219
|
name: "metadata";
|
|
1203
|
-
tableName: "
|
|
1220
|
+
tableName: "learnings";
|
|
1204
1221
|
dataType: "json";
|
|
1205
1222
|
columnType: "PgJsonb";
|
|
1206
1223
|
data: Record<string, unknown>;
|
|
@@ -1217,9 +1234,26 @@ export declare const observations: import("drizzle-orm/pg-core").PgTableWithColu
|
|
|
1217
1234
|
}, {}, {
|
|
1218
1235
|
$type: Record<string, unknown>;
|
|
1219
1236
|
}>;
|
|
1237
|
+
isImported: import("drizzle-orm/pg-core").PgColumn<{
|
|
1238
|
+
name: "is_imported";
|
|
1239
|
+
tableName: "learnings";
|
|
1240
|
+
dataType: "boolean";
|
|
1241
|
+
columnType: "PgBoolean";
|
|
1242
|
+
data: boolean;
|
|
1243
|
+
driverParam: boolean;
|
|
1244
|
+
notNull: false;
|
|
1245
|
+
hasDefault: true;
|
|
1246
|
+
isPrimaryKey: false;
|
|
1247
|
+
isAutoincrement: false;
|
|
1248
|
+
hasRuntimeDefault: false;
|
|
1249
|
+
enumValues: undefined;
|
|
1250
|
+
baseColumn: never;
|
|
1251
|
+
identity: undefined;
|
|
1252
|
+
generated: undefined;
|
|
1253
|
+
}, {}, {}>;
|
|
1220
1254
|
createdAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
1221
1255
|
name: "created_at";
|
|
1222
|
-
tableName: "
|
|
1256
|
+
tableName: "learnings";
|
|
1223
1257
|
dataType: "date";
|
|
1224
1258
|
columnType: "PgTimestamp";
|
|
1225
1259
|
data: Date;
|
|
@@ -1410,6 +1444,18 @@ export declare const entities: import("drizzle-orm/pg-core").PgTableWithColumns<
|
|
|
1410
1444
|
* Namespaces - Hierarchical folder-like namespaces for memory organization
|
|
1411
1445
|
*/
|
|
1412
1446
|
export declare const namespaces: any;
|
|
1447
|
+
/**
|
|
1448
|
+
* Places - Spatial memory organization (Method of Loci)
|
|
1449
|
+
*/
|
|
1450
|
+
export declare const places: any;
|
|
1451
|
+
/**
|
|
1452
|
+
* Memory-Place assignments
|
|
1453
|
+
*/
|
|
1454
|
+
export declare const memoryPlaces: any;
|
|
1455
|
+
/**
|
|
1456
|
+
* Place auto-assignment rules
|
|
1457
|
+
*/
|
|
1458
|
+
export declare const placeRules: any;
|
|
1413
1459
|
/**
|
|
1414
1460
|
* Memory Layers - Tiered L0/L1/L2 summaries for token-efficient retrieval
|
|
1415
1461
|
*/
|
|
@@ -3943,7 +3989,7 @@ export declare const usersRelations: import("drizzle-orm").Relations<"users", {
|
|
|
3943
3989
|
export declare const projectsRelations: import("drizzle-orm").Relations<"projects", {
|
|
3944
3990
|
memories: import("drizzle-orm").Many<any>;
|
|
3945
3991
|
conversations: import("drizzle-orm").Many<"conversations">;
|
|
3946
|
-
|
|
3992
|
+
learnings: import("drizzle-orm").Many<"learnings">;
|
|
3947
3993
|
entities: import("drizzle-orm").Many<"entities">;
|
|
3948
3994
|
}>;
|
|
3949
3995
|
export declare const memoriesRelations: import("drizzle-orm").Relations<string, {
|
|
@@ -3954,14 +4000,15 @@ export declare const conversationsRelations: import("drizzle-orm").Relations<"co
|
|
|
3954
4000
|
project: import("drizzle-orm").One<"projects", false>;
|
|
3955
4001
|
user: import("drizzle-orm").One<"users", false>;
|
|
3956
4002
|
messages: import("drizzle-orm").Many<"messages">;
|
|
3957
|
-
|
|
3958
|
-
}>;
|
|
3959
|
-
export declare const messagesRelations: import("drizzle-orm").Relations<"messages", {
|
|
3960
|
-
conversation: import("drizzle-orm").One<"conversations", true>;
|
|
4003
|
+
learnings: import("drizzle-orm").Many<"learnings">;
|
|
3961
4004
|
}>;
|
|
3962
|
-
export declare const
|
|
4005
|
+
export declare const learningsRelations: import("drizzle-orm").Relations<"learnings", {
|
|
3963
4006
|
project: import("drizzle-orm").One<"projects", false>;
|
|
3964
4007
|
conversation: import("drizzle-orm").One<"conversations", false>;
|
|
4008
|
+
memory: import("drizzle-orm").One<any, false>;
|
|
4009
|
+
}>;
|
|
4010
|
+
export declare const messagesRelations: import("drizzle-orm").Relations<"messages", {
|
|
4011
|
+
conversation: import("drizzle-orm").One<"conversations", true>;
|
|
3965
4012
|
}>;
|
|
3966
4013
|
export declare const entitiesRelations: import("drizzle-orm").Relations<"entities", {
|
|
3967
4014
|
project: import("drizzle-orm").One<"projects", false>;
|
|
@@ -4007,8 +4054,8 @@ export type Conversation = typeof conversations.$inferSelect;
|
|
|
4007
4054
|
export type NewConversation = typeof conversations.$inferInsert;
|
|
4008
4055
|
export type Message = typeof messages.$inferSelect;
|
|
4009
4056
|
export type NewMessage = typeof messages.$inferInsert;
|
|
4010
|
-
export type
|
|
4011
|
-
export type
|
|
4057
|
+
export type Learning = typeof learnings.$inferSelect;
|
|
4058
|
+
export type NewLearning = typeof learnings.$inferInsert;
|
|
4012
4059
|
export type Entity = typeof entities.$inferSelect;
|
|
4013
4060
|
export type NewEntity = typeof entities.$inferInsert;
|
|
4014
4061
|
export type EntityRelation = typeof entityRelations.$inferSelect;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { pgTable, text, timestamp, uuid, integer, boolean, jsonb, index, vector, numeric } from 'drizzle-orm/pg-core';
|
|
2
2
|
import { relations } from 'drizzle-orm';
|
|
3
|
-
// ============================================================================
|
|
4
3
|
// Core Tables
|
|
5
4
|
// ============================================================================
|
|
6
5
|
/**
|
|
@@ -15,7 +14,6 @@ export const users = pgTable('users', {
|
|
|
15
14
|
createdAt: timestamp('created_at').defaultNow().notNull(),
|
|
16
15
|
updatedAt: timestamp('updated_at').defaultNow().notNull(),
|
|
17
16
|
});
|
|
18
|
-
// ============================================================================
|
|
19
17
|
// Memory Editing Tables
|
|
20
18
|
// ============================================================================
|
|
21
19
|
/**
|
|
@@ -74,7 +72,8 @@ export const memories = pgTable('memories', {
|
|
|
74
72
|
embedding: vector('embedding', { dimensions: 1536 }), // OpenAI ada-002 compatible
|
|
75
73
|
// Metadata
|
|
76
74
|
source: text('source'), // Where this memory came from (tool, hook, user)
|
|
77
|
-
confidence: integer('confidence').default(
|
|
75
|
+
confidence: integer('confidence').default(50), // 0-100 confidence score (default: speculative)
|
|
76
|
+
confidenceLevel: text('confidence_level').default('speculative').$type(), // Iteration 3: Confidence flags (default: speculative)
|
|
78
77
|
tags: text('tags').array(),
|
|
79
78
|
metadata: jsonb('metadata').$type(),
|
|
80
79
|
// v0.2.0: Privacy and relevance
|
|
@@ -84,7 +83,12 @@ export const memories = pgTable('memories', {
|
|
|
84
83
|
// v0.3.0: Lifecycle Management
|
|
85
84
|
sector: text('sector').default('episodic').$type(),
|
|
86
85
|
tier: text('tier').default('hot').$type(),
|
|
87
|
-
|
|
86
|
+
status: text('status').notNull().default('active'),
|
|
87
|
+
encrypted_content: text('encrypted_content'),
|
|
88
|
+
encryption_nonce: text('encryption_nonce'),
|
|
89
|
+
is_encrypted: boolean('is_encrypted').default(false),
|
|
90
|
+
// Per-memory decay rate (integer percentage, e.g., 30 = 30% decay per cycle)
|
|
91
|
+
decayRate: integer('decay_rate').default(30),
|
|
88
92
|
coactivationScore: integer('coactivation_score').default(0), // 0-100
|
|
89
93
|
lastDecayAt: timestamp('last_decay_at').defaultNow(),
|
|
90
94
|
// v0.3.0: Agent-Aware
|
|
@@ -124,10 +128,15 @@ export const memories = pgTable('memories', {
|
|
|
124
128
|
// v0.4.2: Namespace support
|
|
125
129
|
namespaceId: uuid('namespace_id').references(() => namespaces.id, { onDelete: 'set null' }),
|
|
126
130
|
namespacePath: text('namespace_path'),
|
|
131
|
+
// v1.1.5: Places support (spatial memory organization)
|
|
132
|
+
placeId: uuid('place_id').references(() => places.id, { onDelete: 'set null' }),
|
|
133
|
+
placeLociIndex: integer('place_loci_index'),
|
|
127
134
|
// v0.4.3: Layer support
|
|
128
135
|
hasL0Abstract: boolean('has_l0_abstract').default(false),
|
|
129
136
|
hasL1Overview: boolean('has_l1_overview').default(false),
|
|
130
137
|
lastLayerUpdate: timestamp('last_layer_update'),
|
|
138
|
+
// v1.0.x: Token tracking
|
|
139
|
+
tokensEstimate: integer('tokens_estimate').default(0).notNull(),
|
|
131
140
|
createdAt: timestamp('created_at').defaultNow().notNull(),
|
|
132
141
|
updatedAt: timestamp('updated_at').defaultNow().notNull(),
|
|
133
142
|
}, (table) => [
|
|
@@ -205,41 +214,46 @@ export const messages = pgTable('messages', {
|
|
|
205
214
|
index('messages_created_idx').on(table.createdAt),
|
|
206
215
|
]);
|
|
207
216
|
/**
|
|
208
|
-
*
|
|
217
|
+
* Learnings - agent learnings: success, failure, fix, insight
|
|
209
218
|
*/
|
|
210
|
-
export const
|
|
219
|
+
export const learnings = pgTable('learnings', {
|
|
211
220
|
id: uuid('id').primaryKey().defaultRandom(),
|
|
212
221
|
projectId: uuid('project_id').references(() => projects.id, { onDelete: 'cascade' }),
|
|
213
222
|
conversationId: uuid('conversation_id').references(() => conversations.id, { onDelete: 'set null' }),
|
|
214
|
-
//
|
|
223
|
+
// Learning type: success, failure, fix, insight
|
|
215
224
|
type: text('type').notNull().$type(),
|
|
216
|
-
action: text('action').notNull(),
|
|
217
|
-
target: text('target'),
|
|
225
|
+
action: text('action').notNull(),
|
|
226
|
+
target: text('target'),
|
|
218
227
|
// Details
|
|
219
228
|
summary: text('summary').notNull(),
|
|
220
229
|
details: jsonb('details').$type(),
|
|
221
230
|
// Semantic search
|
|
222
231
|
embedding: vector('embedding', { dimensions: 1536 }),
|
|
223
|
-
//
|
|
232
|
+
// Optional link to a memory
|
|
233
|
+
memoryId: uuid('memory_id').references(() => memories.id, { onDelete: 'set null' }),
|
|
234
|
+
// Folder-scoped
|
|
224
235
|
folderPath: text('folder_path'),
|
|
225
236
|
projectPath: text('project_path'),
|
|
226
|
-
//
|
|
237
|
+
// Privacy and relevance
|
|
227
238
|
isPrivate: boolean('is_private').default(false),
|
|
228
239
|
hasSecrets: boolean('has_secrets').default(false),
|
|
229
|
-
relevanceScore: integer('relevance_score').default(50),
|
|
240
|
+
relevanceScore: integer('relevance_score').default(50),
|
|
230
241
|
// Classification
|
|
231
|
-
category: text('category'),
|
|
232
|
-
importance: integer('importance').default(50),
|
|
242
|
+
category: text('category'),
|
|
243
|
+
importance: integer('importance').default(50),
|
|
233
244
|
metadata: jsonb('metadata').$type(),
|
|
245
|
+
// Migration tracking
|
|
246
|
+
isImported: boolean('is_imported').default(false),
|
|
234
247
|
createdAt: timestamp('created_at').defaultNow().notNull(),
|
|
235
248
|
}, (table) => [
|
|
236
|
-
index('
|
|
237
|
-
index('
|
|
238
|
-
index('
|
|
239
|
-
index('
|
|
240
|
-
index('
|
|
241
|
-
index('
|
|
242
|
-
index('
|
|
249
|
+
index('learnings_project_idx').on(table.projectId),
|
|
250
|
+
index('learnings_type_idx').on(table.type),
|
|
251
|
+
index('learnings_action_idx').on(table.action),
|
|
252
|
+
index('learnings_created_idx').on(table.createdAt),
|
|
253
|
+
index('learnings_folder_idx').on(table.folderPath),
|
|
254
|
+
index('learnings_relevance_idx').on(table.relevanceScore),
|
|
255
|
+
index('learnings_private_idx').on(table.isPrivate),
|
|
256
|
+
index('learnings_memory_idx').on(table.memoryId),
|
|
243
257
|
]);
|
|
244
258
|
/**
|
|
245
259
|
* Entities - knowledge graph nodes
|
|
@@ -277,6 +291,63 @@ export const namespaces = pgTable('namespaces', {
|
|
|
277
291
|
index('namespaces_project_idx').on(table.projectId),
|
|
278
292
|
index('namespaces_parent_idx').on(table.parentId),
|
|
279
293
|
]);
|
|
294
|
+
/**
|
|
295
|
+
* Places - Spatial memory organization (Method of Loci)
|
|
296
|
+
*/
|
|
297
|
+
export const places = pgTable('places', {
|
|
298
|
+
id: uuid('id').primaryKey().defaultRandom(),
|
|
299
|
+
projectId: uuid('project_id').references(() => projects.id, { onDelete: 'cascade' }).notNull(),
|
|
300
|
+
name: text('name').notNull(),
|
|
301
|
+
placeType: text('place_type').notNull(),
|
|
302
|
+
parentId: uuid('parent_id').references(() => places.id, { onDelete: 'set null' }),
|
|
303
|
+
lociIndex: integer('loci_index').default(0),
|
|
304
|
+
positionX: integer('position_x').default(0),
|
|
305
|
+
positionY: integer('position_y').default(0),
|
|
306
|
+
description: text('description'),
|
|
307
|
+
purpose: text('purpose'),
|
|
308
|
+
memoryCount: integer('memory_count').default(0),
|
|
309
|
+
createdAt: timestamp('created_at').defaultNow().notNull(),
|
|
310
|
+
updatedAt: timestamp('updated_at').defaultNow().notNull(),
|
|
311
|
+
}, (table) => [
|
|
312
|
+
index('places_project_idx').on(table.projectId),
|
|
313
|
+
index('places_type_idx').on(table.placeType),
|
|
314
|
+
index('places_parent_idx').on(table.parentId),
|
|
315
|
+
index('places_loci_idx').on(table.projectId, table.lociIndex),
|
|
316
|
+
]);
|
|
317
|
+
/**
|
|
318
|
+
* Memory-Place assignments
|
|
319
|
+
*/
|
|
320
|
+
export const memoryPlaces = pgTable('memory_places', {
|
|
321
|
+
id: uuid('id').primaryKey().defaultRandom(),
|
|
322
|
+
memoryId: uuid('memory_id').references(() => memories.id, { onDelete: 'cascade' }).notNull(),
|
|
323
|
+
placeId: uuid('place_id').references(() => places.id, { onDelete: 'cascade' }).notNull(),
|
|
324
|
+
isManual: boolean('is_manual').default(false),
|
|
325
|
+
ruleId: uuid('rule_id'),
|
|
326
|
+
createdAt: timestamp('created_at').defaultNow().notNull(),
|
|
327
|
+
}, (table) => [
|
|
328
|
+
index('memory_places_memory_idx').on(table.memoryId),
|
|
329
|
+
index('memory_places_place_idx').on(table.placeId),
|
|
330
|
+
]);
|
|
331
|
+
/**
|
|
332
|
+
* Place auto-assignment rules
|
|
333
|
+
*/
|
|
334
|
+
export const placeRules = pgTable('place_rules', {
|
|
335
|
+
id: uuid('id').primaryKey().defaultRandom(),
|
|
336
|
+
projectId: uuid('project_id').references(() => projects.id, { onDelete: 'cascade' }).notNull(),
|
|
337
|
+
name: text('name').notNull(),
|
|
338
|
+
placeType: text('place_type').notNull(),
|
|
339
|
+
matchTool: text('match_tool'),
|
|
340
|
+
matchKeyword: text('match_keyword'),
|
|
341
|
+
matchTag: text('match_tag'),
|
|
342
|
+
matchMemoryType: text('match_memory_type'),
|
|
343
|
+
priority: integer('priority').default(0),
|
|
344
|
+
enabled: boolean('enabled').default(true),
|
|
345
|
+
createdAt: timestamp('created_at').defaultNow().notNull(),
|
|
346
|
+
updatedAt: timestamp('updated_at').defaultNow().notNull(),
|
|
347
|
+
}, (table) => [
|
|
348
|
+
index('place_rules_project_idx').on(table.projectId),
|
|
349
|
+
index('place_rules_type_idx').on(table.placeType),
|
|
350
|
+
]);
|
|
280
351
|
/**
|
|
281
352
|
* Memory Layers - Tiered L0/L1/L2 summaries for token-efficient retrieval
|
|
282
353
|
*/
|
|
@@ -308,7 +379,6 @@ export const entityRelations = pgTable('entity_relations', {
|
|
|
308
379
|
index('relations_to_idx').on(table.toEntityId),
|
|
309
380
|
index('relations_type_idx').on(table.type),
|
|
310
381
|
]);
|
|
311
|
-
// ============================================================================
|
|
312
382
|
// v0.3.0: Lifecycle & Governance Tables
|
|
313
383
|
// ============================================================================
|
|
314
384
|
/**
|
|
@@ -366,7 +436,6 @@ export const memorySnapshots = pgTable('memory_snapshots', {
|
|
|
366
436
|
index('snapshots_type_idx').on(table.snapshotType),
|
|
367
437
|
index('snapshots_created_idx').on(table.createdAt),
|
|
368
438
|
]);
|
|
369
|
-
// ============================================================================
|
|
370
439
|
// Progressive Disclosure & Context Paging Tables
|
|
371
440
|
// ============================================================================
|
|
372
441
|
/**
|
|
@@ -415,7 +484,6 @@ export const contextPagingSessions = pgTable('context_paging_sessions', {
|
|
|
415
484
|
index('context_paging_project_idx').on(table.projectId),
|
|
416
485
|
index('context_paging_created_idx').on(table.createdAt),
|
|
417
486
|
]);
|
|
418
|
-
// ============================================================================
|
|
419
487
|
// Memory Merging Tables
|
|
420
488
|
// ============================================================================
|
|
421
489
|
/**
|
|
@@ -559,7 +627,6 @@ export const contextSessions = pgTable('context_sessions', {
|
|
|
559
627
|
index('context_sessions_project_idx').on(table.projectId),
|
|
560
628
|
index('context_sessions_created_idx').on(table.createdAt),
|
|
561
629
|
]);
|
|
562
|
-
// ============================================================================
|
|
563
630
|
// Relations (Drizzle ORM)
|
|
564
631
|
// ============================================================================
|
|
565
632
|
export const usersRelations = relations(users, ({ many }) => ({
|
|
@@ -569,7 +636,7 @@ export const usersRelations = relations(users, ({ many }) => ({
|
|
|
569
636
|
export const projectsRelations = relations(projects, ({ many }) => ({
|
|
570
637
|
memories: many(memories),
|
|
571
638
|
conversations: many(conversations),
|
|
572
|
-
|
|
639
|
+
learnings: many(learnings),
|
|
573
640
|
entities: many(entities),
|
|
574
641
|
}));
|
|
575
642
|
export const memoriesRelations = relations(memories, ({ one }) => ({
|
|
@@ -592,21 +659,25 @@ export const conversationsRelations = relations(conversations, ({ one, many }) =
|
|
|
592
659
|
references: [users.id],
|
|
593
660
|
}),
|
|
594
661
|
messages: many(messages),
|
|
595
|
-
|
|
662
|
+
learnings: many(learnings),
|
|
596
663
|
}));
|
|
597
|
-
export const
|
|
664
|
+
export const learningsRelations = relations(learnings, ({ one }) => ({
|
|
665
|
+
project: one(projects, {
|
|
666
|
+
fields: [learnings.projectId],
|
|
667
|
+
references: [projects.id],
|
|
668
|
+
}),
|
|
598
669
|
conversation: one(conversations, {
|
|
599
|
-
fields: [
|
|
670
|
+
fields: [learnings.conversationId],
|
|
600
671
|
references: [conversations.id],
|
|
601
672
|
}),
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
fields: [observations.projectId],
|
|
606
|
-
references: [projects.id],
|
|
673
|
+
memory: one(memories, {
|
|
674
|
+
fields: [learnings.memoryId],
|
|
675
|
+
references: [memories.id],
|
|
607
676
|
}),
|
|
677
|
+
}));
|
|
678
|
+
export const messagesRelations = relations(messages, ({ one }) => ({
|
|
608
679
|
conversation: one(conversations, {
|
|
609
|
-
fields: [
|
|
680
|
+
fields: [messages.conversationId],
|
|
610
681
|
references: [conversations.id],
|
|
611
682
|
}),
|
|
612
683
|
}));
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { defineConfig } from 'drizzle-kit';
|
|
2
|
+
export default defineConfig({
|
|
3
|
+
schema: './drizzle/schema.ts',
|
|
4
|
+
out: './drizzle/migrations',
|
|
5
|
+
dialect: 'postgresql',
|
|
6
|
+
dbCredentials: {
|
|
7
|
+
url: process.env.DATABASE_URL || 'postgres://squish:squish_dev@localhost:5432/squish',
|
|
8
|
+
},
|
|
9
|
+
verbose: true,
|
|
10
|
+
strict: true,
|
|
11
|
+
});
|
|
12
|
+
//# sourceMappingURL=drizzle.config.js.map
|
package/dist/db/index.d.ts
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import { createDb } from './adapter.js';
|
|
2
2
|
import { config } from '../config.js';
|
|
3
|
-
export declare function getDb(): Promise<
|
|
4
|
-
$client: import("pg").Pool;
|
|
5
|
-
}) | (import("drizzle-orm/better-sqlite3").BetterSQLite3Database<typeof import("../drizzle/schema-sqlite.js")> & {
|
|
6
|
-
$client: import("better-sqlite3").Database;
|
|
7
|
-
}) | import("drizzle-orm/sql-js").SQLJsDatabase<typeof import("../drizzle/schema-sqlite.js")>>;
|
|
3
|
+
export declare function getDb(): Promise<any>;
|
|
8
4
|
export declare function checkDatabaseHealth(): Promise<boolean>;
|
|
9
5
|
export { config };
|
|
10
6
|
export { createDb };
|
package/dist/db/index.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { createDb } from './adapter.js';
|
|
2
2
|
import { config } from '../config.js';
|
|
3
3
|
import { logger } from '../core/logger.js';
|
|
4
|
+
import { isDatabaseUnavailableError } from '../core/lib/utils.js';
|
|
5
|
+
// Use any for db to avoid type conflicts between different drivers
|
|
6
|
+
// The actual type will be determined at runtime based on mode
|
|
4
7
|
let db = null;
|
|
5
8
|
let dbError = null;
|
|
6
9
|
export async function getDb() {
|
|
@@ -9,7 +12,38 @@ export async function getDb() {
|
|
|
9
12
|
}
|
|
10
13
|
if (!db) {
|
|
11
14
|
try {
|
|
12
|
-
|
|
15
|
+
// Priority: remote (user's Supabase/Neon) > team (PostgreSQL) > local (SQLite)
|
|
16
|
+
if (config.isRemoteMode) {
|
|
17
|
+
if (config.remoteBackend === 'neon' && config.neonProjectId && config.neonServiceKey) {
|
|
18
|
+
const { createNeonClient } = await import('./neon.js');
|
|
19
|
+
db = await createNeonClient();
|
|
20
|
+
}
|
|
21
|
+
else if (config.supabaseUrl && config.supabaseKey) {
|
|
22
|
+
const { createSupabaseClient } = await import('./supabase.js');
|
|
23
|
+
db = await createSupabaseClient();
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
throw new Error('Remote backend not configured (need SUPABASE_URL or NEON_PROJECT_ID)');
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
else if (config.isTeamMode) {
|
|
30
|
+
// Team mode: PostgreSQL (or Supabase/Neon if explicitly configured)
|
|
31
|
+
if (config.teamBackend === 'supabase' && config.supabaseUrl && config.supabaseKey) {
|
|
32
|
+
const { createSupabaseClient } = await import('./supabase.js');
|
|
33
|
+
db = await createSupabaseClient();
|
|
34
|
+
}
|
|
35
|
+
else if (config.teamBackend === 'neon' && config.neonProjectId && config.neonServiceKey) {
|
|
36
|
+
const { createNeonClient } = await import('./neon.js');
|
|
37
|
+
db = await createNeonClient();
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
db = await createDb();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
// Local mode: SQLite
|
|
45
|
+
db = await createDb();
|
|
46
|
+
}
|
|
13
47
|
}
|
|
14
48
|
catch (error) {
|
|
15
49
|
dbError = error instanceof Error ? error.message : 'Database initialization failed';
|
|
@@ -21,21 +55,30 @@ export async function getDb() {
|
|
|
21
55
|
export async function checkDatabaseHealth() {
|
|
22
56
|
try {
|
|
23
57
|
const database = await getDb();
|
|
24
|
-
|
|
25
|
-
const dbClient = database.$client;
|
|
58
|
+
const dbClient = database.$client ?? database;
|
|
26
59
|
if (dbClient && typeof dbClient.query === 'function') {
|
|
27
60
|
await dbClient.query('SELECT 1');
|
|
28
61
|
}
|
|
62
|
+
else if (dbClient && typeof dbClient.exec === 'function') {
|
|
63
|
+
dbClient.exec('SELECT 1');
|
|
64
|
+
}
|
|
29
65
|
else if (dbClient && typeof dbClient.prepare === 'function') {
|
|
30
|
-
dbClient.prepare('SELECT 1')
|
|
66
|
+
const statement = dbClient.prepare('SELECT 1');
|
|
67
|
+
if (typeof statement.get === 'function') {
|
|
68
|
+
statement.get();
|
|
69
|
+
}
|
|
70
|
+
else if (typeof statement.step === 'function') {
|
|
71
|
+
statement.step();
|
|
72
|
+
}
|
|
73
|
+
if (typeof statement.free === 'function') {
|
|
74
|
+
statement.free();
|
|
75
|
+
}
|
|
31
76
|
}
|
|
32
77
|
return true;
|
|
33
78
|
}
|
|
34
79
|
catch (error) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
error.message?.includes('Database unavailable')) {
|
|
38
|
-
return false; // Graceful degradation - database unavailable but not an error
|
|
80
|
+
if (isDatabaseUnavailableError(error)) {
|
|
81
|
+
return false;
|
|
39
82
|
}
|
|
40
83
|
logger.error('Database health check failed', error);
|
|
41
84
|
return false;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Neon client wrapper that returns a Drizzle HTTP client.
|
|
3
|
+
* Neon HTTP driver is faster for single non-interactive transactions.
|
|
4
|
+
*/
|
|
5
|
+
export declare function createNeonClient(): Promise<import("drizzle-orm/neon-http").NeonHttpDatabase<Record<string, never>> & {
|
|
6
|
+
$client: import("@neondatabase/serverless").NeonQueryFunction<false, false>;
|
|
7
|
+
}>;
|
|
8
|
+
//# sourceMappingURL=neon.d.ts.map
|