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,13 +1,17 @@
|
|
|
1
1
|
import express from 'express';
|
|
2
2
|
import cors from 'cors';
|
|
3
3
|
import rateLimit from 'express-rate-limit';
|
|
4
|
-
import { logger } from '
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { getAllProjects,
|
|
8
|
-
import {
|
|
4
|
+
import { logger } from '../core/logger.js';
|
|
5
|
+
import { getRecent } from '../core/memory/memories.js';
|
|
6
|
+
import { getObservations } from '../core/ingestion/learnings.js';
|
|
7
|
+
import { getAllProjects, requireProject } from '../core/projects.js';
|
|
8
|
+
import { checkDatabaseHealth } from '../db/index.js';
|
|
9
|
+
import { config } from '../config.js';
|
|
10
|
+
import { isDatabaseUnavailableError } from '../core/lib/utils.js';
|
|
11
|
+
import { validateLimit } from '../core/lib/validation.js';
|
|
9
12
|
const app = express();
|
|
10
|
-
const PORT = process.env.SQUISH_WEB_PORT || 37777;
|
|
13
|
+
const PORT = Number(process.env.SQUISH_WEB_PORT || 37777);
|
|
14
|
+
const VERSION = '1.1.5';
|
|
11
15
|
const allowedOrigins = process.env.SQUISH_CORS_ORIGINS?.split(',').map(s => s.trim()) || ['http://localhost:*', 'http://127.0.0.1:*'];
|
|
12
16
|
const appCors = cors({
|
|
13
17
|
origin: (origin, callback) => {
|
|
@@ -37,32 +41,36 @@ app.use(limiter);
|
|
|
37
41
|
app.use(express.json());
|
|
38
42
|
// Health check endpoint
|
|
39
43
|
app.get('/api/health', async (req, res) => {
|
|
40
|
-
let dbStatus = '
|
|
44
|
+
let dbStatus = 'error';
|
|
41
45
|
let projectInfo = null;
|
|
42
46
|
let allProjects = [];
|
|
47
|
+
let errorMessage = null;
|
|
43
48
|
try {
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
if (
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
// If there are projects, use the first one as default (most recent)
|
|
52
|
-
if (allProjects.length > 0) {
|
|
53
|
-
projectInfo = { id: allProjects[0].id, name: allProjects[0].name, path: allProjects[0].path };
|
|
49
|
+
const healthy = await checkDatabaseHealth();
|
|
50
|
+
dbStatus = healthy ? 'ok' : 'error';
|
|
51
|
+
if (healthy) {
|
|
52
|
+
allProjects = await getAllProjects();
|
|
53
|
+
if (allProjects.length > 0) {
|
|
54
|
+
projectInfo = { id: allProjects[0].id, name: allProjects[0].name, path: allProjects[0].path };
|
|
55
|
+
}
|
|
54
56
|
}
|
|
55
57
|
}
|
|
56
58
|
catch (error) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
+
errorMessage = error.message;
|
|
60
|
+
if (!isDatabaseUnavailableError(error)) {
|
|
61
|
+
logger.error('Health check failed:', error.message);
|
|
62
|
+
}
|
|
59
63
|
}
|
|
60
64
|
res.json({
|
|
61
|
-
|
|
62
|
-
|
|
65
|
+
ok: dbStatus === 'ok',
|
|
66
|
+
status: dbStatus,
|
|
67
|
+
version: VERSION,
|
|
63
68
|
database: dbStatus,
|
|
69
|
+
cache: config.redisEnabled ? 'configured' : 'unavailable',
|
|
70
|
+
dataDirectory: config.dataDir,
|
|
64
71
|
project: projectInfo || { id: 'unknown', name: 'No Project', path: '' },
|
|
65
72
|
projects: allProjects,
|
|
73
|
+
error: errorMessage,
|
|
66
74
|
timestamp: new Date().toISOString()
|
|
67
75
|
});
|
|
68
76
|
});
|
|
@@ -70,12 +78,9 @@ app.get('/api/health', async (req, res) => {
|
|
|
70
78
|
app.get('/api/memories', async (req, res) => {
|
|
71
79
|
try {
|
|
72
80
|
const projectPath = req.query.projectPath || process.cwd();
|
|
73
|
-
const limit =
|
|
74
|
-
const project = await
|
|
75
|
-
|
|
76
|
-
return res.json({ status: 'ok', data: [], count: 0, message: 'Project not found' });
|
|
77
|
-
}
|
|
78
|
-
const memories = await getRecentMemories(projectPath, limit);
|
|
81
|
+
const limit = validateLimit(req.query.limit, 20, 1, 100);
|
|
82
|
+
const project = await requireProject(projectPath);
|
|
83
|
+
const memories = await getRecent(projectPath, limit);
|
|
79
84
|
res.json({
|
|
80
85
|
status: 'ok',
|
|
81
86
|
data: memories,
|
|
@@ -84,20 +89,19 @@ app.get('/api/memories', async (req, res) => {
|
|
|
84
89
|
});
|
|
85
90
|
}
|
|
86
91
|
catch (error) {
|
|
87
|
-
|
|
88
|
-
|
|
92
|
+
if (!isDatabaseUnavailableError(error)) {
|
|
93
|
+
logger.error('Failed to get memories:', error.message);
|
|
94
|
+
}
|
|
95
|
+
res.status(isDatabaseUnavailableError(error) ? 503 : 500).json({ status: 'error', message: error.message });
|
|
89
96
|
}
|
|
90
97
|
});
|
|
91
98
|
// Get observations for project
|
|
92
99
|
app.get('/api/observations', async (req, res) => {
|
|
93
100
|
try {
|
|
94
101
|
const projectPath = req.query.projectPath || process.cwd();
|
|
95
|
-
const limit =
|
|
96
|
-
const project = await
|
|
97
|
-
|
|
98
|
-
return res.json({ status: 'ok', data: [], count: 0, message: 'Project not found' });
|
|
99
|
-
}
|
|
100
|
-
const observations = await getObservationsForProject(projectPath, limit);
|
|
102
|
+
const limit = validateLimit(req.query.limit, 20, 1, 100);
|
|
103
|
+
const project = await requireProject(projectPath);
|
|
104
|
+
const observations = await getObservations(projectPath, limit);
|
|
101
105
|
res.json({
|
|
102
106
|
status: 'ok',
|
|
103
107
|
data: observations,
|
|
@@ -106,8 +110,10 @@ app.get('/api/observations', async (req, res) => {
|
|
|
106
110
|
});
|
|
107
111
|
}
|
|
108
112
|
catch (error) {
|
|
109
|
-
|
|
110
|
-
|
|
113
|
+
if (!isDatabaseUnavailableError(error)) {
|
|
114
|
+
logger.error('Failed to get observations:', error.message);
|
|
115
|
+
}
|
|
116
|
+
res.status(isDatabaseUnavailableError(error) ? 503 : 500).json({ status: 'error', message: error.message });
|
|
111
117
|
}
|
|
112
118
|
});
|
|
113
119
|
// Get project context
|
|
@@ -131,20 +137,9 @@ app.get('/api/context', async (req, res) => {
|
|
|
131
137
|
message: 'No projects found in database'
|
|
132
138
|
});
|
|
133
139
|
}
|
|
134
|
-
const project = await
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
status: 'ok',
|
|
138
|
-
project: { id: 'unknown', name: 'Project Not Found', path: projectPath },
|
|
139
|
-
projects: allProjects,
|
|
140
|
-
memories: [],
|
|
141
|
-
observations: [],
|
|
142
|
-
totalCount: 0,
|
|
143
|
-
message: 'Project not found in database'
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
const memories = await getRecentMemories(projectPath, 20);
|
|
147
|
-
const observations = await getObservationsForProject(projectPath, 20);
|
|
140
|
+
const project = await requireProject(projectPath);
|
|
141
|
+
const memories = await getRecent(projectPath, 20);
|
|
142
|
+
const observations = await getObservations(projectPath, 20);
|
|
148
143
|
res.json({
|
|
149
144
|
status: 'ok',
|
|
150
145
|
project: { id: project.id, name: project.name, path: project.path },
|
|
@@ -155,8 +150,10 @@ app.get('/api/context', async (req, res) => {
|
|
|
155
150
|
});
|
|
156
151
|
}
|
|
157
152
|
catch (error) {
|
|
158
|
-
|
|
159
|
-
|
|
153
|
+
if (!isDatabaseUnavailableError(error)) {
|
|
154
|
+
logger.error('Failed to get context:', error.message);
|
|
155
|
+
}
|
|
156
|
+
res.status(isDatabaseUnavailableError(error) ? 503 : 500).json({ status: 'error', message: error.message });
|
|
160
157
|
}
|
|
161
158
|
});
|
|
162
159
|
// Get all projects
|
|
@@ -170,470 +167,476 @@ app.get('/api/projects', async (req, res) => {
|
|
|
170
167
|
});
|
|
171
168
|
}
|
|
172
169
|
catch (error) {
|
|
173
|
-
|
|
174
|
-
|
|
170
|
+
if (!isDatabaseUnavailableError(error)) {
|
|
171
|
+
logger.error('Failed to get projects:', error.message);
|
|
172
|
+
}
|
|
173
|
+
res.status(isDatabaseUnavailableError(error) ? 503 : 500).json({ status: 'error', message: error.message });
|
|
175
174
|
}
|
|
176
175
|
});
|
|
177
176
|
// Web UI
|
|
178
177
|
app.get('/', (req, res) => {
|
|
179
|
-
const html = `<!DOCTYPE html>
|
|
180
|
-
<html class="dark" lang="en"><head>
|
|
181
|
-
<meta charset="utf-8"/>
|
|
182
|
-
<meta content="width=device-width, initial-scale=1.0" name="viewport"/>
|
|
183
|
-
<title>Squish Memory Viewer - Playful Dashboard</title>
|
|
184
|
-
<link href="https://fonts.googleapis.com" rel="preconnect"/>
|
|
185
|
-
<link crossorigin="" href="https://fonts.gstatic.com" rel="preconnect"/>
|
|
186
|
-
<link href="https://fonts.googleapis.com/css2?family=Spline+Sans:wght@300;400;500;600;700;800&display=swap" rel="stylesheet"/>
|
|
187
|
-
<link href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:wght,FILL@100..700,0..1&display=swap" rel="stylesheet"/>
|
|
188
|
-
<script src="https://cdn.tailwindcss.com?plugins=forms,container-queries"></script>
|
|
189
|
-
<script id="tailwind-config">
|
|
190
|
-
tailwind.config = {
|
|
191
|
-
darkMode: "class",
|
|
192
|
-
theme: {
|
|
193
|
-
extend: {
|
|
194
|
-
colors: {
|
|
195
|
-
"primary": "#00ffbf",
|
|
196
|
-
"secondary": "#ff6392",
|
|
197
|
-
"accent": "#ffcd26",
|
|
198
|
-
"background-dark": "#0f172a",
|
|
199
|
-
"card-bg": "#1e293b",
|
|
200
|
-
"text-main": "#f8fafc",
|
|
201
|
-
"text-muted": "#94a3b8",
|
|
202
|
-
"alert-orange": "rgba(251, 146, 60, 0.1)"
|
|
203
|
-
},
|
|
204
|
-
fontFamily: {
|
|
205
|
-
"display": ["Spline Sans", "sans-serif"]
|
|
206
|
-
},
|
|
207
|
-
borderRadius: {
|
|
208
|
-
"pill": "2.5rem",
|
|
209
|
-
"blob": "30% 70% 70% 30% / 30% 30% 70% 70%"
|
|
210
|
-
}
|
|
211
|
-
},
|
|
212
|
-
},
|
|
213
|
-
}
|
|
214
|
-
</script>
|
|
215
|
-
<style type="text/tailwindcss">
|
|
216
|
-
@layer base {
|
|
217
|
-
body { @apply font-display text-text-main bg-background-dark antialiased; }
|
|
218
|
-
}
|
|
219
|
-
.squish-pill {
|
|
220
|
-
border-radius: 3rem;
|
|
221
|
-
}
|
|
222
|
-
.blob-alert {
|
|
223
|
-
border-radius: 40% 60% 70% 30% / 40% 50% 60% 50%;
|
|
224
|
-
}
|
|
225
|
-
.squishy-hover {
|
|
226
|
-
transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
|
|
227
|
-
}
|
|
228
|
-
.squishy-hover:hover {
|
|
229
|
-
transform: scale(1.02) translateY(-4px);
|
|
230
|
-
}
|
|
231
|
-
.pulse-red {
|
|
232
|
-
animation: pulse 2s infinite;
|
|
233
|
-
}
|
|
234
|
-
@keyframes pulse {
|
|
235
|
-
0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
|
|
236
|
-
70% { transform: scale(1); box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
|
|
237
|
-
100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
|
|
238
|
-
}
|
|
239
|
-
</style>
|
|
240
|
-
</head>
|
|
241
|
-
<body class="min-h-screen selection:bg-primary/30 pb-20">
|
|
242
|
-
<header class="w-full px-6 py-8">
|
|
243
|
-
<div class="max-w-6xl mx-auto flex items-center justify-between">
|
|
244
|
-
<div class="flex items-center gap-4">
|
|
245
|
-
<div class="relative size-12 flex items-center justify-center">
|
|
246
|
-
<div class="absolute inset-0 bg-secondary/20 blur-xl rounded-full"></div>
|
|
247
|
-
<span class="material-symbols-outlined text-secondary text-5xl relative z-10">psychology</span>
|
|
248
|
-
</div>
|
|
249
|
-
<h1 class="text-3xl font-black tracking-tight flex items-center gap-2">
|
|
250
|
-
Squish <span class="text-primary italic">Memory Viewer</span>
|
|
251
|
-
</h1>
|
|
252
|
-
</div>
|
|
253
|
-
<div class="flex items-center gap-4">
|
|
254
|
-
<select id="project-select" onchange="changeProject(this.value)" class="bg-card-bg px-4 py-2 rounded-full border-2 border-slate-700/50 text-text-main text-sm font-medium focus:outline-none focus:border-primary">
|
|
255
|
-
<option value="">Loading projects...</option>
|
|
256
|
-
</select>
|
|
257
|
-
<div class="bg-card-bg px-4 py-2 rounded-full border-2 border-slate-700/50 flex items-center gap-2">
|
|
258
|
-
<div class="size-2 rounded-full bg-primary animate-pulse"></div>
|
|
259
|
-
<span class="text-xs font-bold uppercase tracking-widest text-text-muted">Local Server: Online</span>
|
|
260
|
-
</div>
|
|
261
|
-
</div>
|
|
262
|
-
</div>
|
|
263
|
-
</header>
|
|
264
|
-
<main class="max-w-6xl mx-auto px-6 space-y-12">
|
|
265
|
-
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-6">
|
|
266
|
-
<div class="bg-card-bg p-8 squish-pill border-2 border-slate-700/30 text-center squishy-hover shadow-xl">
|
|
267
|
-
<p class="text-4xl font-black mb-1" id="memories-count">-</p>
|
|
268
|
-
<p class="text-sm font-bold uppercase tracking-widest text-text-muted italic">Memories</p>
|
|
269
|
-
</div>
|
|
270
|
-
<div class="bg-card-bg p-8 squish-pill border-2 border-slate-700/30 text-center squishy-hover shadow-xl">
|
|
271
|
-
<p class="text-4xl font-black mb-1" id="observations-count">-</p>
|
|
272
|
-
<p class="text-sm font-bold uppercase tracking-widest text-text-muted italic">Observations</p>
|
|
273
|
-
</div>
|
|
274
|
-
<div class="bg-card-bg p-8 squish-pill border-2 border-slate-700/30 text-center squishy-hover shadow-xl">
|
|
275
|
-
<p class="text-4xl font-black mb-1" id="total-count">-</p>
|
|
276
|
-
<p class="text-sm font-bold uppercase tracking-widest text-text-muted italic">Total Items</p>
|
|
277
|
-
</div>
|
|
278
|
-
<div class="bg-card-bg p-8 squish-pill border-2 border-slate-700/30 flex flex-col items-center justify-center squishy-hover shadow-xl">
|
|
279
|
-
<div class="flex items-center gap-3">
|
|
280
|
-
<div class="size-4 bg-red-500 rounded-full pulse-red"></div>
|
|
281
|
-
<p class="text-2xl font-black text-red-400 italic">Error</p>
|
|
282
|
-
</div>
|
|
283
|
-
<p class="text-sm font-bold uppercase tracking-widest text-text-muted italic mt-1">Status</p>
|
|
284
|
-
</div>
|
|
285
|
-
</div>
|
|
286
|
-
<div class="relative py-6 px-10 bg-orange-500/10 border-2 border-orange-500/20 blob-alert flex items-center gap-6 overflow-hidden">
|
|
287
|
-
<div class="absolute top-0 left-0 w-full h-full bg-orange-500/5 -z-10"></div>
|
|
288
|
-
<span class="material-symbols-outlined text-orange-400 text-3xl">warning</span>
|
|
289
|
-
<div>
|
|
290
|
-
<h4 class="font-black text-orange-400 italic uppercase text-sm tracking-wider">Communication Breakdown</h4>
|
|
291
|
-
<p class="text-orange-200/80 font-medium">Failed to load data: Unknown error. Is the blob server running?</p>
|
|
292
|
-
</div>
|
|
293
|
-
</div>
|
|
294
|
-
<div class="grid grid-cols-1 lg:grid-cols-2 gap-12">
|
|
295
|
-
<section class="space-y-6">
|
|
296
|
-
<div class="flex items-center gap-4 border-b-4 border-primary/20 pb-4">
|
|
297
|
-
<div class="size-10 bg-primary/20 rounded-full flex items-center justify-center border-2 border-primary">
|
|
298
|
-
<span class="material-symbols-outlined text-primary font-bold">neurology</span>
|
|
299
|
-
</div>
|
|
300
|
-
<h2 class="text-2xl font-black italic text-primary uppercase">Recent Memories</h2>
|
|
301
|
-
</div>
|
|
302
|
-
<div class="space-y-4" id="memories">
|
|
303
|
-
<div class="bg-card-bg/50 p-6 rounded-3xl border-2 border-slate-700/20 flex flex-col items-center justify-center py-16 opacity-60">
|
|
304
|
-
<div class="size-12 border-4 border-primary border-t-transparent rounded-full animate-spin mb-4"></div>
|
|
305
|
-
<p class="font-black italic text-text-muted">Loading memories...</p>
|
|
306
|
-
</div>
|
|
307
|
-
</div>
|
|
308
|
-
</section>
|
|
309
|
-
<section class="space-y-6">
|
|
310
|
-
<div class="flex items-center gap-4 border-b-4 border-primary/20 pb-4">
|
|
311
|
-
<div class="size-10 bg-primary/20 rounded-full flex items-center justify-center border-2 border-primary">
|
|
312
|
-
<span class="material-symbols-outlined text-primary font-bold">visibility</span>
|
|
313
|
-
</div>
|
|
314
|
-
<h2 class="text-2xl font-black italic text-primary uppercase">Recent Observations</h2>
|
|
315
|
-
</div>
|
|
316
|
-
<div class="space-y-4" id="observations">
|
|
317
|
-
<div class="bg-card-bg/50 p-6 rounded-3xl border-2 border-slate-700/20 flex flex-col items-center justify-center py-16 opacity-60">
|
|
318
|
-
<div class="size-12 border-4 border-primary border-t-transparent rounded-full animate-spin mb-4"></div>
|
|
319
|
-
<p class="font-black italic text-text-muted">Loading observations...</p>
|
|
320
|
-
</div>
|
|
321
|
-
</div>
|
|
322
|
-
</section>
|
|
323
|
-
</div>
|
|
324
|
-
<div class="pt-12 flex justify-center">
|
|
325
|
-
<div class="bg-card-bg border-4 border-slate-700/50 p-2 rounded-full flex gap-2">
|
|
326
|
-
<button class="bg-primary text-black px-8 py-3 rounded-full font-black text-sm uppercase hover:scale-105 transition-transform flex items-center gap-2">
|
|
327
|
-
<span class="material-symbols-outlined text-sm">refresh</span>
|
|
328
|
-
Reconnect
|
|
329
|
-
</button>
|
|
330
|
-
<button class="text-text-main px-8 py-3 rounded-full font-black text-sm uppercase hover:bg-slate-700/50 transition-colors" onclick="openDocs()">
|
|
331
|
-
Docs
|
|
332
|
-
</button>
|
|
333
|
-
<button class="text-text-main px-8 py-3 rounded-full font-black text-sm uppercase hover:bg-slate-700/50 transition-colors" onclick="openSettings()">
|
|
334
|
-
Settings
|
|
335
|
-
</button>
|
|
336
|
-
</div>
|
|
337
|
-
</div>
|
|
338
|
-
</main>
|
|
339
|
-
<footer class="mt-20 px-6 opacity-30">
|
|
340
|
-
<div class="max-w-6xl mx-auto flex justify-between items-center py-8 border-t border-slate-700">
|
|
341
|
-
<p class="text-xs font-black uppercase">© 2026 Squish-Memory Dashboard</p>
|
|
342
|
-
<div class="flex gap-4">
|
|
343
|
-
<span class="material-symbols-outlined text-sm">database</span>
|
|
344
|
-
<span class="text-xs font-black uppercase italic">Local-First Engine v1.0</span>
|
|
345
|
-
</div>
|
|
346
|
-
</div>
|
|
347
|
-
</footer>
|
|
348
|
-
<script>
|
|
349
|
-
let currentProjectPath = null;
|
|
350
|
-
|
|
351
|
-
async function loadProjects() {
|
|
352
|
-
try {
|
|
353
|
-
const response = await fetch('/api/projects');
|
|
354
|
-
const data = await response.json();
|
|
355
|
-
|
|
356
|
-
if (data.status === 'ok' && data.data && data.data.length > 0) {
|
|
357
|
-
const select = document.getElementById('project-select');
|
|
358
|
-
if (select) {
|
|
359
|
-
select.innerHTML = data.data.map(function(p) {
|
|
360
|
-
return '<option value="' + escapeHtml(p.path) + '">' + escapeHtml(p.name || p.path) + '</option>';
|
|
361
|
-
}).join('');
|
|
362
|
-
|
|
363
|
-
// Try to select current directory
|
|
364
|
-
const cwd = window.location.pathname === '/' ? '' : window.location.pathname;
|
|
365
|
-
const defaultProject = data.data.find(function(p) { return p.path === cwd; }) || data.data[0];
|
|
366
|
-
if (defaultProject) {
|
|
367
|
-
currentProjectPath = defaultProject.path;
|
|
368
|
-
select.value = defaultProject.path;
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
} else {
|
|
372
|
-
// No projects yet, use current directory
|
|
373
|
-
currentProjectPath = window.location.pathname === '/' ? '' : window.location.pathname;
|
|
374
|
-
}
|
|
375
|
-
} catch (error) {
|
|
376
|
-
console.error('Failed to load projects:', error);
|
|
377
|
-
currentProjectPath = '';
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
async function loadData() {
|
|
382
|
-
try {
|
|
383
|
-
const url = currentProjectPath ? '/api/context?projectPath=' + encodeURIComponent(currentProjectPath) : '/api/context';
|
|
384
|
-
const response = await fetch(url);
|
|
385
|
-
const data = await response.json();
|
|
386
|
-
|
|
387
|
-
if (data.status === 'ok') {
|
|
388
|
-
document.getElementById('memories-count').textContent = data.memories ? data.memories.length : 0;
|
|
389
|
-
document.getElementById('observations-count').textContent = data.observations ? data.observations.length : 0;
|
|
390
|
-
document.getElementById('total-count').textContent = data.totalCount || 0;
|
|
391
|
-
updateStatus(data.memories && data.observations ? 'ok' : 'error');
|
|
392
|
-
|
|
393
|
-
renderMemories(data.memories || []);
|
|
394
|
-
renderObservations(data.observations || []);
|
|
395
|
-
|
|
396
|
-
// Update project info
|
|
397
|
-
if (data.project) {
|
|
398
|
-
const projectInfo = document.getElementById('project-info');
|
|
399
|
-
if (projectInfo) {
|
|
400
|
-
projectInfo.textContent = data.project.name || data.project.path || 'Unknown';
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
// Hide error alert if data loaded
|
|
405
|
-
const errorAlert = document.querySelector('.blob-alert');
|
|
406
|
-
if (errorAlert && (data.memories && data.memories.length > 0 || data.observations && data.observations.length > 0)) {
|
|
407
|
-
errorAlert.style.display = 'none';
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
// Show error alert if message present
|
|
411
|
-
if (data.message) {
|
|
412
|
-
const errorAlert = document.querySelector('.blob-alert');
|
|
413
|
-
if (errorAlert) {
|
|
414
|
-
errorAlert.querySelector('p').textContent = data.message;
|
|
415
|
-
errorAlert.style.display = 'flex';
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
} else {
|
|
419
|
-
throw new Error('API returned error status');
|
|
420
|
-
}
|
|
421
|
-
} catch (error) {
|
|
422
|
-
updateStatus('error');
|
|
423
|
-
|
|
424
|
-
// Show error alert
|
|
425
|
-
const errorAlert = document.querySelector('.blob-alert');
|
|
426
|
-
if (errorAlert) errorAlert.style.display = 'flex';
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
function renderMemories(memories) {
|
|
431
|
-
const container = document.getElementById('memories');
|
|
432
|
-
if (!memories || memories.length === 0) {
|
|
433
|
-
container.innerHTML = '<div class="bg-card-bg/50 p-6 rounded-3xl border-2 border-slate-700/20 flex flex-col items-center justify-center py-16 opacity-60"><p class="font-black italic text-text-muted">No memories found</p></div>';
|
|
434
|
-
return;
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
container.innerHTML = memories.map(function(memory) {
|
|
438
|
-
return '<div class="bg-card-bg p-6 rounded-3xl border-2 border-slate-700/20 squishy-hover">' +
|
|
439
|
-
'<div class="flex items-start justify-between mb-4">' +
|
|
440
|
-
'<span class="bg-primary text-black px-3 py-1 rounded-full text-xs font-bold uppercase">' + (memory.type || 'memory') + '</span>' +
|
|
441
|
-
'<span class="text-text-muted text-sm">' + formatTime(memory.createdAt) + '</span>' +
|
|
442
|
-
'</div>' +
|
|
443
|
-
'<div class="text-text-main mb-4">' + escapeHtml(memory.content || memory.text || '') + '</div>' +
|
|
444
|
-
'<div class="text-text-muted text-sm">' +
|
|
445
|
-
'Tags: ' + (memory.tags ? memory.tags.join(', ') : 'none') +
|
|
446
|
-
'</div>' +
|
|
447
|
-
'</div>';
|
|
448
|
-
}).join('');
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
function renderObservations(observations) {
|
|
452
|
-
const container = document.getElementById('observations');
|
|
453
|
-
if (!observations || observations.length === 0) {
|
|
454
|
-
container.innerHTML = '<div class="bg-card-bg/50 p-6 rounded-3xl border-2 border-slate-700/20 flex flex-col items-center justify-center py-16 opacity-60"><p class="font-black italic text-text-muted">No observations found</p></div>';
|
|
455
|
-
return;
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
container.innerHTML = observations.map(function(obs) {
|
|
459
|
-
return '<div class="bg-card-bg p-6 rounded-3xl border-2 border-slate-700/20 squishy-hover">' +
|
|
460
|
-
'<div class="flex items-start justify-between mb-4">' +
|
|
461
|
-
'<span class="bg-secondary text-black px-3 py-1 rounded-full text-xs font-bold uppercase">' + (obs.type || 'observation') + '</span>' +
|
|
462
|
-
'<span class="text-text-muted text-sm">' + formatTime(obs.createdAt) + '</span>' +
|
|
463
|
-
'</div>' +
|
|
464
|
-
'<div class="text-text-main mb-4">' + escapeHtml(obs.summary || obs.content || '') + '</div>' +
|
|
465
|
-
'<div class="text-text-muted text-sm">' +
|
|
466
|
-
'Action: ' + (obs.action || 'none') + ' | ' +
|
|
467
|
-
'Target: ' + (obs.target || 'none') +
|
|
468
|
-
'</div>' +
|
|
469
|
-
'</div>';
|
|
470
|
-
}).join('');
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
function updateStatus(status) {
|
|
474
|
-
const statusCard = document.querySelector('.squishy-hover.flex-col');
|
|
475
|
-
if (!statusCard) return;
|
|
476
|
-
|
|
477
|
-
if (status === 'ok') {
|
|
478
|
-
statusCard.innerHTML = '<div class="flex items-center gap-3">' +
|
|
479
|
-
'<div class="size-4 bg-primary rounded-full animate-pulse"></div>' +
|
|
480
|
-
'<p class="text-2xl font-black text-primary italic">OK</p>' +
|
|
481
|
-
'</div>' +
|
|
482
|
-
'<p class="text-sm font-bold uppercase tracking-widest text-text-muted italic mt-1">Status</p>';
|
|
483
|
-
} else {
|
|
484
|
-
statusCard.innerHTML = '<div class="flex items-center gap-3">' +
|
|
485
|
-
'<div class="size-4 bg-red-500 rounded-full pulse-red"></div>' +
|
|
486
|
-
'<p class="text-2xl font-black text-red-400 italic">Error</p>' +
|
|
487
|
-
'</div>' +
|
|
488
|
-
'<p class="text-sm font-bold uppercase tracking-widest text-text-muted italic mt-1">Status</p>';
|
|
489
|
-
}
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
function formatTime(timestamp) {
|
|
493
|
-
if (!timestamp) return 'Unknown';
|
|
494
|
-
const date = new Date(timestamp);
|
|
495
|
-
return date.toLocaleString();
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
function escapeHtml(text) {
|
|
499
|
-
const div = document.createElement('div');
|
|
500
|
-
div.textContent = text;
|
|
501
|
-
return div.innerHTML;
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
function openDocs() {
|
|
505
|
-
// Create and show documentation modal
|
|
506
|
-
const modal = document.createElement('div');
|
|
507
|
-
modal.className = 'fixed inset-0 bg-black/50 flex items-center justify-center z-50';
|
|
508
|
-
modal.innerHTML = '<div class="bg-card-bg p-8 rounded-3xl border-2 border-slate-700/50 max-w-2xl w-full mx-4 max-h-[80vh] overflow-y-auto">' +
|
|
509
|
-
'<div class="flex justify-between items-center mb-6">' +
|
|
510
|
-
'<h2 class="text-2xl font-black text-primary italic">Documentation</h2>' +
|
|
511
|
-
'<button onclick="closeModal(this)" class="text-text-muted hover:text-text-main text-2xl">×</button>' +
|
|
512
|
-
'</div>' +
|
|
513
|
-
'<div class="space-y-4 text-text-main">' +
|
|
514
|
-
'<div class="bg-card-bg/50 p-4 rounded-xl border border-slate-700/30">' +
|
|
515
|
-
'<h3 class="font-bold text-primary mb-2">🧠 Memory System</h3>' +
|
|
516
|
-
'<p class="text-sm">The Squish Memory Plugin captures and stores conversations, tool usage, and project insights across sessions.</p>' +
|
|
517
|
-
'</div>' +
|
|
518
|
-
'<div class="bg-card-bg/50 p-4 rounded-xl border border-slate-700/30">' +
|
|
519
|
-
'<h3 class="font-bold text-primary mb-2">📊 API Endpoints</h3>' +
|
|
520
|
-
'<ul class="text-sm space-y-1">' +
|
|
521
|
-
'<li><code class="bg-slate-700/50 px-2 py-1 rounded">GET /api/health</code> - Service health status</li>' +
|
|
522
|
-
'<li><code class="bg-slate-700/50 px-2 py-1 rounded">GET /api/memories</code> - Recent memories</li>' +
|
|
523
|
-
'<li><code class="bg-slate-700/50 px-2 py-1 rounded">GET /api/observations</code> - Tool usage observations</li>' +
|
|
524
|
-
'<li><code class="bg-slate-700/50 px-2 py-1 rounded">GET /api/context</code> - Combined data</li>' +
|
|
525
|
-
'</ul>' +
|
|
526
|
-
'</div>' +
|
|
527
|
-
'<div class="bg-card-bg/50 p-4 rounded-xl border border-slate-700/30">' +
|
|
528
|
-
'<h3 class="font-bold text-primary mb-2">⚙️ Configuration</h3>' +
|
|
529
|
-
'<p class="text-sm">Configure via environment variables: <code class="bg-slate-700/50 px-2 py-1 rounded">SQUISH_WEB_PORT</code>, <code class="bg-slate-700/50 px-2 py-1 rounded">DATABASE_URL</code>, etc.</p>' +
|
|
530
|
-
'</div>' +
|
|
531
|
-
'<div class="bg-card-bg/50 p-4 rounded-xl border border-slate-700/30">' +
|
|
532
|
-
'<h3 class="font-bold text-primary mb-2">🚀 Getting Started</h3>' +
|
|
533
|
-
'<p class="text-sm">1. Install the plugin<br>2. Configure your database<br>3. Start the web UI<br>4. Access at http://localhost:37777</p>' +
|
|
534
|
-
'</div>' +
|
|
535
|
-
'</div>' +
|
|
536
|
-
'</div>';
|
|
537
|
-
document.body.appendChild(modal);
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
function openSettings() {
|
|
541
|
-
// Create and show settings modal
|
|
542
|
-
const modal = document.createElement('div');
|
|
543
|
-
modal.className = 'fixed inset-0 bg-black/50 flex items-center justify-center z-50';
|
|
544
|
-
modal.innerHTML = '<div class="bg-card-bg p-8 rounded-3xl border-2 border-slate-700/50 max-w-md w-full mx-4">' +
|
|
545
|
-
'<div class="flex justify-between items-center mb-6">' +
|
|
546
|
-
'<h2 class="text-2xl font-black text-primary italic">Settings</h2>' +
|
|
547
|
-
'<button onclick="closeModal(this)" class="text-text-muted hover:text-text-main text-2xl">×</button>' +
|
|
548
|
-
'</div>' +
|
|
549
|
-
'<div class="space-y-4">' +
|
|
550
|
-
'<div class="bg-card-bg/50 p-4 rounded-xl border border-slate-700/30">' +
|
|
551
|
-
'<label class="block text-sm font-bold text-text-main mb-2">Refresh Interval</label>' +
|
|
552
|
-
'<select class="w-full bg-slate-700/50 border border-slate-600 rounded-lg px-3 py-2 text-text-main" onchange="changeRefreshInterval(this.value)">' +
|
|
553
|
-
'<option value="10000">10 seconds</option>' +
|
|
554
|
-
'<option value="30000" selected>30 seconds</option>' +
|
|
555
|
-
'<option value="60000">1 minute</option>' +
|
|
556
|
-
'<option value="300000">5 minutes</option>' +
|
|
557
|
-
'</select>' +
|
|
558
|
-
'</div>' +
|
|
559
|
-
'<div class="bg-card-bg/50 p-4 rounded-xl border border-slate-700/30">' +
|
|
560
|
-
'<label class="block text-sm font-bold text-text-main mb-2">Theme</label>' +
|
|
561
|
-
'<select class="w-full bg-slate-700/50 border border-slate-600 rounded-lg px-3 py-2 text-text-main" onchange="changeTheme(this.value)">' +
|
|
562
|
-
'<option value="dark" selected>Dark</option>' +
|
|
563
|
-
'<option value="light">Light</option>' +
|
|
564
|
-
'</select>' +
|
|
565
|
-
'</div>' +
|
|
566
|
-
'<div class="bg-card-bg/50 p-4 rounded-xl border border-slate-700/30">' +
|
|
567
|
-
'<label class="block text-sm font-bold text-text-main mb-2">Items per Page</label>' +
|
|
568
|
-
'<select class="w-full bg-slate-700/50 border border-slate-600 rounded-lg px-3 py-2 text-text-main" onchange="changeItemsPerPage(this.value)">' +
|
|
569
|
-
'<option value="10">10</option>' +
|
|
570
|
-
'<option value="25" selected>25</option>' +
|
|
571
|
-
'<option value="50">50</option>' +
|
|
572
|
-
'<option value="100">100</option>' +
|
|
573
|
-
'</select>' +
|
|
574
|
-
'</div>' +
|
|
575
|
-
'<div class="flex justify-end space-x-3 mt-6">' +
|
|
576
|
-
'<button onclick="closeModal(this)" class="px-4 py-2 bg-slate-700/50 hover:bg-slate-600/50 rounded-lg text-text-main transition-colors">Cancel</button>' +
|
|
577
|
-
'<button onclick="saveSettings()" class="px-4 py-2 bg-primary text-black rounded-lg hover:bg-primary/80 transition-colors">Save</button>' +
|
|
578
|
-
'</div>' +
|
|
579
|
-
'</div>' +
|
|
580
|
-
'</div>';
|
|
581
|
-
document.body.appendChild(modal);
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
function closeModal(button) {
|
|
585
|
-
const modal = button.closest('.fixed');
|
|
586
|
-
if (modal) {
|
|
587
|
-
modal.remove();
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
function changeRefreshInterval(interval) {
|
|
592
|
-
clearInterval(window.refreshInterval);
|
|
593
|
-
window.refreshInterval = setInterval(loadData, parseInt(interval));
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
function changeTheme(theme) {
|
|
597
|
-
if (theme === 'light') {
|
|
598
|
-
document.documentElement.classList.remove('dark');
|
|
599
|
-
} else {
|
|
600
|
-
document.documentElement.classList.add('dark');
|
|
601
|
-
}
|
|
602
|
-
}
|
|
603
|
-
|
|
604
|
-
function changeItemsPerPage(count) {
|
|
605
|
-
// This would require updating the API calls, for now just store in localStorage
|
|
606
|
-
localStorage.setItem('itemsPerPage', count);
|
|
607
|
-
}
|
|
608
|
-
|
|
609
|
-
function saveSettings() {
|
|
610
|
-
// Close the modal and show success message
|
|
611
|
-
const modal = document.querySelector('.fixed');
|
|
612
|
-
if (modal) {
|
|
613
|
-
// Could show a toast notification here
|
|
614
|
-
modal.remove();
|
|
615
|
-
}
|
|
616
|
-
}
|
|
617
|
-
|
|
618
|
-
function changeProject(path) {
|
|
619
|
-
currentProjectPath = path;
|
|
620
|
-
loadData();
|
|
621
|
-
}
|
|
622
|
-
|
|
623
|
-
// Initialize: load projects first, then data
|
|
624
|
-
loadProjects().then(function() {
|
|
625
|
-
loadData();
|
|
626
|
-
window.refreshInterval = setInterval(loadData, 30000);
|
|
627
|
-
});
|
|
628
|
-
</script>
|
|
178
|
+
const html = `<!DOCTYPE html>
|
|
179
|
+
<html class="dark" lang="en"><head>
|
|
180
|
+
<meta charset="utf-8"/>
|
|
181
|
+
<meta content="width=device-width, initial-scale=1.0" name="viewport"/>
|
|
182
|
+
<title>Squish Memory Viewer - Playful Dashboard</title>
|
|
183
|
+
<link href="https://fonts.googleapis.com" rel="preconnect"/>
|
|
184
|
+
<link crossorigin="" href="https://fonts.gstatic.com" rel="preconnect"/>
|
|
185
|
+
<link href="https://fonts.googleapis.com/css2?family=Spline+Sans:wght@300;400;500;600;700;800&display=swap" rel="stylesheet"/>
|
|
186
|
+
<link href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:wght,FILL@100..700,0..1&display=swap" rel="stylesheet"/>
|
|
187
|
+
<script src="https://cdn.tailwindcss.com?plugins=forms,container-queries"></script>
|
|
188
|
+
<script id="tailwind-config">
|
|
189
|
+
tailwind.config = {
|
|
190
|
+
darkMode: "class",
|
|
191
|
+
theme: {
|
|
192
|
+
extend: {
|
|
193
|
+
colors: {
|
|
194
|
+
"primary": "#00ffbf",
|
|
195
|
+
"secondary": "#ff6392",
|
|
196
|
+
"accent": "#ffcd26",
|
|
197
|
+
"background-dark": "#0f172a",
|
|
198
|
+
"card-bg": "#1e293b",
|
|
199
|
+
"text-main": "#f8fafc",
|
|
200
|
+
"text-muted": "#94a3b8",
|
|
201
|
+
"alert-orange": "rgba(251, 146, 60, 0.1)"
|
|
202
|
+
},
|
|
203
|
+
fontFamily: {
|
|
204
|
+
"display": ["Spline Sans", "sans-serif"]
|
|
205
|
+
},
|
|
206
|
+
borderRadius: {
|
|
207
|
+
"pill": "2.5rem",
|
|
208
|
+
"blob": "30% 70% 70% 30% / 30% 30% 70% 70%"
|
|
209
|
+
}
|
|
210
|
+
},
|
|
211
|
+
},
|
|
212
|
+
}
|
|
213
|
+
</script>
|
|
214
|
+
<style type="text/tailwindcss">
|
|
215
|
+
@layer base {
|
|
216
|
+
body { @apply font-display text-text-main bg-background-dark antialiased; }
|
|
217
|
+
}
|
|
218
|
+
.squish-pill {
|
|
219
|
+
border-radius: 3rem;
|
|
220
|
+
}
|
|
221
|
+
.blob-alert {
|
|
222
|
+
border-radius: 40% 60% 70% 30% / 40% 50% 60% 50%;
|
|
223
|
+
}
|
|
224
|
+
.squishy-hover {
|
|
225
|
+
transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
|
|
226
|
+
}
|
|
227
|
+
.squishy-hover:hover {
|
|
228
|
+
transform: scale(1.02) translateY(-4px);
|
|
229
|
+
}
|
|
230
|
+
.pulse-red {
|
|
231
|
+
animation: pulse 2s infinite;
|
|
232
|
+
}
|
|
233
|
+
@keyframes pulse {
|
|
234
|
+
0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
|
|
235
|
+
70% { transform: scale(1); box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
|
|
236
|
+
100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
|
|
237
|
+
}
|
|
238
|
+
</style>
|
|
239
|
+
</head>
|
|
240
|
+
<body class="min-h-screen selection:bg-primary/30 pb-20">
|
|
241
|
+
<header class="w-full px-6 py-8">
|
|
242
|
+
<div class="max-w-6xl mx-auto flex items-center justify-between">
|
|
243
|
+
<div class="flex items-center gap-4">
|
|
244
|
+
<div class="relative size-12 flex items-center justify-center">
|
|
245
|
+
<div class="absolute inset-0 bg-secondary/20 blur-xl rounded-full"></div>
|
|
246
|
+
<span class="material-symbols-outlined text-secondary text-5xl relative z-10">psychology</span>
|
|
247
|
+
</div>
|
|
248
|
+
<h1 class="text-3xl font-black tracking-tight flex items-center gap-2">
|
|
249
|
+
Squish <span class="text-primary italic">Memory Viewer</span>
|
|
250
|
+
</h1>
|
|
251
|
+
</div>
|
|
252
|
+
<div class="flex items-center gap-4">
|
|
253
|
+
<select id="project-select" onchange="changeProject(this.value)" class="bg-card-bg px-4 py-2 rounded-full border-2 border-slate-700/50 text-text-main text-sm font-medium focus:outline-none focus:border-primary">
|
|
254
|
+
<option value="">Loading projects...</option>
|
|
255
|
+
</select>
|
|
256
|
+
<div class="bg-card-bg px-4 py-2 rounded-full border-2 border-slate-700/50 flex items-center gap-2">
|
|
257
|
+
<div class="size-2 rounded-full bg-primary animate-pulse"></div>
|
|
258
|
+
<span class="text-xs font-bold uppercase tracking-widest text-text-muted">Local Server: Online</span>
|
|
259
|
+
</div>
|
|
260
|
+
</div>
|
|
261
|
+
</div>
|
|
262
|
+
</header>
|
|
263
|
+
<main class="max-w-6xl mx-auto px-6 space-y-12">
|
|
264
|
+
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-6">
|
|
265
|
+
<div class="bg-card-bg p-8 squish-pill border-2 border-slate-700/30 text-center squishy-hover shadow-xl">
|
|
266
|
+
<p class="text-4xl font-black mb-1" id="memories-count">-</p>
|
|
267
|
+
<p class="text-sm font-bold uppercase tracking-widest text-text-muted italic">Memories</p>
|
|
268
|
+
</div>
|
|
269
|
+
<div class="bg-card-bg p-8 squish-pill border-2 border-slate-700/30 text-center squishy-hover shadow-xl">
|
|
270
|
+
<p class="text-4xl font-black mb-1" id="observations-count">-</p>
|
|
271
|
+
<p class="text-sm font-bold uppercase tracking-widest text-text-muted italic">Observations</p>
|
|
272
|
+
</div>
|
|
273
|
+
<div class="bg-card-bg p-8 squish-pill border-2 border-slate-700/30 text-center squishy-hover shadow-xl">
|
|
274
|
+
<p class="text-4xl font-black mb-1" id="total-count">-</p>
|
|
275
|
+
<p class="text-sm font-bold uppercase tracking-widest text-text-muted italic">Total Items</p>
|
|
276
|
+
</div>
|
|
277
|
+
<div class="bg-card-bg p-8 squish-pill border-2 border-slate-700/30 flex flex-col items-center justify-center squishy-hover shadow-xl">
|
|
278
|
+
<div class="flex items-center gap-3">
|
|
279
|
+
<div class="size-4 bg-red-500 rounded-full pulse-red"></div>
|
|
280
|
+
<p class="text-2xl font-black text-red-400 italic">Error</p>
|
|
281
|
+
</div>
|
|
282
|
+
<p class="text-sm font-bold uppercase tracking-widest text-text-muted italic mt-1">Status</p>
|
|
283
|
+
</div>
|
|
284
|
+
</div>
|
|
285
|
+
<div class="relative py-6 px-10 bg-orange-500/10 border-2 border-orange-500/20 blob-alert flex items-center gap-6 overflow-hidden">
|
|
286
|
+
<div class="absolute top-0 left-0 w-full h-full bg-orange-500/5 -z-10"></div>
|
|
287
|
+
<span class="material-symbols-outlined text-orange-400 text-3xl">warning</span>
|
|
288
|
+
<div>
|
|
289
|
+
<h4 class="font-black text-orange-400 italic uppercase text-sm tracking-wider">Communication Breakdown</h4>
|
|
290
|
+
<p class="text-orange-200/80 font-medium">Failed to load data: Unknown error. Is the blob server running?</p>
|
|
291
|
+
</div>
|
|
292
|
+
</div>
|
|
293
|
+
<div class="grid grid-cols-1 lg:grid-cols-2 gap-12">
|
|
294
|
+
<section class="space-y-6">
|
|
295
|
+
<div class="flex items-center gap-4 border-b-4 border-primary/20 pb-4">
|
|
296
|
+
<div class="size-10 bg-primary/20 rounded-full flex items-center justify-center border-2 border-primary">
|
|
297
|
+
<span class="material-symbols-outlined text-primary font-bold">neurology</span>
|
|
298
|
+
</div>
|
|
299
|
+
<h2 class="text-2xl font-black italic text-primary uppercase">Recent Memories</h2>
|
|
300
|
+
</div>
|
|
301
|
+
<div class="space-y-4" id="memories">
|
|
302
|
+
<div class="bg-card-bg/50 p-6 rounded-3xl border-2 border-slate-700/20 flex flex-col items-center justify-center py-16 opacity-60">
|
|
303
|
+
<div class="size-12 border-4 border-primary border-t-transparent rounded-full animate-spin mb-4"></div>
|
|
304
|
+
<p class="font-black italic text-text-muted">Loading memories...</p>
|
|
305
|
+
</div>
|
|
306
|
+
</div>
|
|
307
|
+
</section>
|
|
308
|
+
<section class="space-y-6">
|
|
309
|
+
<div class="flex items-center gap-4 border-b-4 border-primary/20 pb-4">
|
|
310
|
+
<div class="size-10 bg-primary/20 rounded-full flex items-center justify-center border-2 border-primary">
|
|
311
|
+
<span class="material-symbols-outlined text-primary font-bold">visibility</span>
|
|
312
|
+
</div>
|
|
313
|
+
<h2 class="text-2xl font-black italic text-primary uppercase">Recent Observations</h2>
|
|
314
|
+
</div>
|
|
315
|
+
<div class="space-y-4" id="observations">
|
|
316
|
+
<div class="bg-card-bg/50 p-6 rounded-3xl border-2 border-slate-700/20 flex flex-col items-center justify-center py-16 opacity-60">
|
|
317
|
+
<div class="size-12 border-4 border-primary border-t-transparent rounded-full animate-spin mb-4"></div>
|
|
318
|
+
<p class="font-black italic text-text-muted">Loading observations...</p>
|
|
319
|
+
</div>
|
|
320
|
+
</div>
|
|
321
|
+
</section>
|
|
322
|
+
</div>
|
|
323
|
+
<div class="pt-12 flex justify-center">
|
|
324
|
+
<div class="bg-card-bg border-4 border-slate-700/50 p-2 rounded-full flex gap-2">
|
|
325
|
+
<button class="bg-primary text-black px-8 py-3 rounded-full font-black text-sm uppercase hover:scale-105 transition-transform flex items-center gap-2">
|
|
326
|
+
<span class="material-symbols-outlined text-sm">refresh</span>
|
|
327
|
+
Reconnect
|
|
328
|
+
</button>
|
|
329
|
+
<button class="text-text-main px-8 py-3 rounded-full font-black text-sm uppercase hover:bg-slate-700/50 transition-colors" onclick="openDocs()">
|
|
330
|
+
Docs
|
|
331
|
+
</button>
|
|
332
|
+
<button class="text-text-main px-8 py-3 rounded-full font-black text-sm uppercase hover:bg-slate-700/50 transition-colors" onclick="openSettings()">
|
|
333
|
+
Settings
|
|
334
|
+
</button>
|
|
335
|
+
</div>
|
|
336
|
+
</div>
|
|
337
|
+
</main>
|
|
338
|
+
<footer class="mt-20 px-6 opacity-30">
|
|
339
|
+
<div class="max-w-6xl mx-auto flex justify-between items-center py-8 border-t border-slate-700">
|
|
340
|
+
<p class="text-xs font-black uppercase">© 2026 Squish-Memory Dashboard</p>
|
|
341
|
+
<div class="flex gap-4">
|
|
342
|
+
<span class="material-symbols-outlined text-sm">database</span>
|
|
343
|
+
<span class="text-xs font-black uppercase italic">Local-First Engine v1.0</span>
|
|
344
|
+
</div>
|
|
345
|
+
</div>
|
|
346
|
+
</footer>
|
|
347
|
+
<script>
|
|
348
|
+
let currentProjectPath = null;
|
|
349
|
+
|
|
350
|
+
async function loadProjects() {
|
|
351
|
+
try {
|
|
352
|
+
const response = await fetch('/api/projects');
|
|
353
|
+
const data = await response.json();
|
|
354
|
+
|
|
355
|
+
if (data.status === 'ok' && data.data && data.data.length > 0) {
|
|
356
|
+
const select = document.getElementById('project-select');
|
|
357
|
+
if (select) {
|
|
358
|
+
select.innerHTML = data.data.map(function(p) {
|
|
359
|
+
return '<option value="' + escapeHtml(p.path) + '">' + escapeHtml(p.name || p.path) + '</option>';
|
|
360
|
+
}).join('');
|
|
361
|
+
|
|
362
|
+
// Try to select current directory
|
|
363
|
+
const cwd = window.location.pathname === '/' ? '' : window.location.pathname;
|
|
364
|
+
const defaultProject = data.data.find(function(p) { return p.path === cwd; }) || data.data[0];
|
|
365
|
+
if (defaultProject) {
|
|
366
|
+
currentProjectPath = defaultProject.path;
|
|
367
|
+
select.value = defaultProject.path;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
} else {
|
|
371
|
+
// No projects yet, use current directory
|
|
372
|
+
currentProjectPath = window.location.pathname === '/' ? '' : window.location.pathname;
|
|
373
|
+
}
|
|
374
|
+
} catch (error) {
|
|
375
|
+
console.error('Failed to load projects:', error);
|
|
376
|
+
currentProjectPath = '';
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
async function loadData() {
|
|
381
|
+
try {
|
|
382
|
+
const url = currentProjectPath ? '/api/context?projectPath=' + encodeURIComponent(currentProjectPath) : '/api/context';
|
|
383
|
+
const response = await fetch(url);
|
|
384
|
+
const data = await response.json();
|
|
385
|
+
|
|
386
|
+
if (data.status === 'ok') {
|
|
387
|
+
document.getElementById('memories-count').textContent = data.memories ? data.memories.length : 0;
|
|
388
|
+
document.getElementById('observations-count').textContent = data.observations ? data.observations.length : 0;
|
|
389
|
+
document.getElementById('total-count').textContent = data.totalCount || 0;
|
|
390
|
+
updateStatus(data.memories && data.observations ? 'ok' : 'error');
|
|
391
|
+
|
|
392
|
+
renderMemories(data.memories || []);
|
|
393
|
+
renderObservations(data.observations || []);
|
|
394
|
+
|
|
395
|
+
// Update project info
|
|
396
|
+
if (data.project) {
|
|
397
|
+
const projectInfo = document.getElementById('project-info');
|
|
398
|
+
if (projectInfo) {
|
|
399
|
+
projectInfo.textContent = data.project.name || data.project.path || 'Unknown';
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
// Hide error alert if data loaded
|
|
404
|
+
const errorAlert = document.querySelector('.blob-alert');
|
|
405
|
+
if (errorAlert && (data.memories && data.memories.length > 0 || data.observations && data.observations.length > 0)) {
|
|
406
|
+
errorAlert.style.display = 'none';
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
// Show error alert if message present
|
|
410
|
+
if (data.message) {
|
|
411
|
+
const errorAlert = document.querySelector('.blob-alert');
|
|
412
|
+
if (errorAlert) {
|
|
413
|
+
errorAlert.querySelector('p').textContent = data.message;
|
|
414
|
+
errorAlert.style.display = 'flex';
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
} else {
|
|
418
|
+
throw new Error('API returned error status');
|
|
419
|
+
}
|
|
420
|
+
} catch (error) {
|
|
421
|
+
updateStatus('error');
|
|
422
|
+
|
|
423
|
+
// Show error alert
|
|
424
|
+
const errorAlert = document.querySelector('.blob-alert');
|
|
425
|
+
if (errorAlert) errorAlert.style.display = 'flex';
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
function renderMemories(memories) {
|
|
430
|
+
const container = document.getElementById('memories');
|
|
431
|
+
if (!memories || memories.length === 0) {
|
|
432
|
+
container.innerHTML = '<div class="bg-card-bg/50 p-6 rounded-3xl border-2 border-slate-700/20 flex flex-col items-center justify-center py-16 opacity-60"><p class="font-black italic text-text-muted">No memories found</p></div>';
|
|
433
|
+
return;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
container.innerHTML = memories.map(function(memory) {
|
|
437
|
+
return '<div class="bg-card-bg p-6 rounded-3xl border-2 border-slate-700/20 squishy-hover">' +
|
|
438
|
+
'<div class="flex items-start justify-between mb-4">' +
|
|
439
|
+
'<span class="bg-primary text-black px-3 py-1 rounded-full text-xs font-bold uppercase">' + (memory.type || 'memory') + '</span>' +
|
|
440
|
+
'<span class="text-text-muted text-sm">' + formatTime(memory.createdAt) + '</span>' +
|
|
441
|
+
'</div>' +
|
|
442
|
+
'<div class="text-text-main mb-4">' + escapeHtml(memory.content || memory.text || '') + '</div>' +
|
|
443
|
+
'<div class="text-text-muted text-sm">' +
|
|
444
|
+
'Tags: ' + (memory.tags ? memory.tags.join(', ') : 'none') +
|
|
445
|
+
'</div>' +
|
|
446
|
+
'</div>';
|
|
447
|
+
}).join('');
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
function renderObservations(observations) {
|
|
451
|
+
const container = document.getElementById('observations');
|
|
452
|
+
if (!observations || observations.length === 0) {
|
|
453
|
+
container.innerHTML = '<div class="bg-card-bg/50 p-6 rounded-3xl border-2 border-slate-700/20 flex flex-col items-center justify-center py-16 opacity-60"><p class="font-black italic text-text-muted">No observations found</p></div>';
|
|
454
|
+
return;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
container.innerHTML = observations.map(function(obs) {
|
|
458
|
+
return '<div class="bg-card-bg p-6 rounded-3xl border-2 border-slate-700/20 squishy-hover">' +
|
|
459
|
+
'<div class="flex items-start justify-between mb-4">' +
|
|
460
|
+
'<span class="bg-secondary text-black px-3 py-1 rounded-full text-xs font-bold uppercase">' + (obs.type || 'observation') + '</span>' +
|
|
461
|
+
'<span class="text-text-muted text-sm">' + formatTime(obs.createdAt) + '</span>' +
|
|
462
|
+
'</div>' +
|
|
463
|
+
'<div class="text-text-main mb-4">' + escapeHtml(obs.summary || obs.content || '') + '</div>' +
|
|
464
|
+
'<div class="text-text-muted text-sm">' +
|
|
465
|
+
'Action: ' + (obs.action || 'none') + ' | ' +
|
|
466
|
+
'Target: ' + (obs.target || 'none') +
|
|
467
|
+
'</div>' +
|
|
468
|
+
'</div>';
|
|
469
|
+
}).join('');
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
function updateStatus(status) {
|
|
473
|
+
const statusCard = document.querySelector('.squishy-hover.flex-col');
|
|
474
|
+
if (!statusCard) return;
|
|
475
|
+
|
|
476
|
+
if (status === 'ok') {
|
|
477
|
+
statusCard.innerHTML = '<div class="flex items-center gap-3">' +
|
|
478
|
+
'<div class="size-4 bg-primary rounded-full animate-pulse"></div>' +
|
|
479
|
+
'<p class="text-2xl font-black text-primary italic">OK</p>' +
|
|
480
|
+
'</div>' +
|
|
481
|
+
'<p class="text-sm font-bold uppercase tracking-widest text-text-muted italic mt-1">Status</p>';
|
|
482
|
+
} else {
|
|
483
|
+
statusCard.innerHTML = '<div class="flex items-center gap-3">' +
|
|
484
|
+
'<div class="size-4 bg-red-500 rounded-full pulse-red"></div>' +
|
|
485
|
+
'<p class="text-2xl font-black text-red-400 italic">Error</p>' +
|
|
486
|
+
'</div>' +
|
|
487
|
+
'<p class="text-sm font-bold uppercase tracking-widest text-text-muted italic mt-1">Status</p>';
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
function formatTime(timestamp) {
|
|
492
|
+
if (!timestamp) return 'Unknown';
|
|
493
|
+
const date = new Date(timestamp);
|
|
494
|
+
return date.toLocaleString();
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
function escapeHtml(text) {
|
|
498
|
+
const div = document.createElement('div');
|
|
499
|
+
div.textContent = text;
|
|
500
|
+
return div.innerHTML;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
function openDocs() {
|
|
504
|
+
// Create and show documentation modal
|
|
505
|
+
const modal = document.createElement('div');
|
|
506
|
+
modal.className = 'fixed inset-0 bg-black/50 flex items-center justify-center z-50';
|
|
507
|
+
modal.innerHTML = '<div class="bg-card-bg p-8 rounded-3xl border-2 border-slate-700/50 max-w-2xl w-full mx-4 max-h-[80vh] overflow-y-auto">' +
|
|
508
|
+
'<div class="flex justify-between items-center mb-6">' +
|
|
509
|
+
'<h2 class="text-2xl font-black text-primary italic">Documentation</h2>' +
|
|
510
|
+
'<button onclick="closeModal(this)" class="text-text-muted hover:text-text-main text-2xl">×</button>' +
|
|
511
|
+
'</div>' +
|
|
512
|
+
'<div class="space-y-4 text-text-main">' +
|
|
513
|
+
'<div class="bg-card-bg/50 p-4 rounded-xl border border-slate-700/30">' +
|
|
514
|
+
'<h3 class="font-bold text-primary mb-2">🧠 Memory System</h3>' +
|
|
515
|
+
'<p class="text-sm">The Squish Memory Plugin captures and stores conversations, tool usage, and project insights across sessions.</p>' +
|
|
516
|
+
'</div>' +
|
|
517
|
+
'<div class="bg-card-bg/50 p-4 rounded-xl border border-slate-700/30">' +
|
|
518
|
+
'<h3 class="font-bold text-primary mb-2">📊 API Endpoints</h3>' +
|
|
519
|
+
'<ul class="text-sm space-y-1">' +
|
|
520
|
+
'<li><code class="bg-slate-700/50 px-2 py-1 rounded">GET /api/health</code> - Service health status</li>' +
|
|
521
|
+
'<li><code class="bg-slate-700/50 px-2 py-1 rounded">GET /api/memories</code> - Recent memories</li>' +
|
|
522
|
+
'<li><code class="bg-slate-700/50 px-2 py-1 rounded">GET /api/observations</code> - Tool usage observations</li>' +
|
|
523
|
+
'<li><code class="bg-slate-700/50 px-2 py-1 rounded">GET /api/context</code> - Combined data</li>' +
|
|
524
|
+
'</ul>' +
|
|
525
|
+
'</div>' +
|
|
526
|
+
'<div class="bg-card-bg/50 p-4 rounded-xl border border-slate-700/30">' +
|
|
527
|
+
'<h3 class="font-bold text-primary mb-2">⚙️ Configuration</h3>' +
|
|
528
|
+
'<p class="text-sm">Configure via environment variables: <code class="bg-slate-700/50 px-2 py-1 rounded">SQUISH_WEB_PORT</code>, <code class="bg-slate-700/50 px-2 py-1 rounded">DATABASE_URL</code>, etc.</p>' +
|
|
529
|
+
'</div>' +
|
|
530
|
+
'<div class="bg-card-bg/50 p-4 rounded-xl border border-slate-700/30">' +
|
|
531
|
+
'<h3 class="font-bold text-primary mb-2">🚀 Getting Started</h3>' +
|
|
532
|
+
'<p class="text-sm">1. Install the plugin<br>2. Configure your database<br>3. Start the web UI<br>4. Access at http://localhost:37777</p>' +
|
|
533
|
+
'</div>' +
|
|
534
|
+
'</div>' +
|
|
535
|
+
'</div>';
|
|
536
|
+
document.body.appendChild(modal);
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
function openSettings() {
|
|
540
|
+
// Create and show settings modal
|
|
541
|
+
const modal = document.createElement('div');
|
|
542
|
+
modal.className = 'fixed inset-0 bg-black/50 flex items-center justify-center z-50';
|
|
543
|
+
modal.innerHTML = '<div class="bg-card-bg p-8 rounded-3xl border-2 border-slate-700/50 max-w-md w-full mx-4">' +
|
|
544
|
+
'<div class="flex justify-between items-center mb-6">' +
|
|
545
|
+
'<h2 class="text-2xl font-black text-primary italic">Settings</h2>' +
|
|
546
|
+
'<button onclick="closeModal(this)" class="text-text-muted hover:text-text-main text-2xl">×</button>' +
|
|
547
|
+
'</div>' +
|
|
548
|
+
'<div class="space-y-4">' +
|
|
549
|
+
'<div class="bg-card-bg/50 p-4 rounded-xl border border-slate-700/30">' +
|
|
550
|
+
'<label class="block text-sm font-bold text-text-main mb-2">Refresh Interval</label>' +
|
|
551
|
+
'<select class="w-full bg-slate-700/50 border border-slate-600 rounded-lg px-3 py-2 text-text-main" onchange="changeRefreshInterval(this.value)">' +
|
|
552
|
+
'<option value="10000">10 seconds</option>' +
|
|
553
|
+
'<option value="30000" selected>30 seconds</option>' +
|
|
554
|
+
'<option value="60000">1 minute</option>' +
|
|
555
|
+
'<option value="300000">5 minutes</option>' +
|
|
556
|
+
'</select>' +
|
|
557
|
+
'</div>' +
|
|
558
|
+
'<div class="bg-card-bg/50 p-4 rounded-xl border border-slate-700/30">' +
|
|
559
|
+
'<label class="block text-sm font-bold text-text-main mb-2">Theme</label>' +
|
|
560
|
+
'<select class="w-full bg-slate-700/50 border border-slate-600 rounded-lg px-3 py-2 text-text-main" onchange="changeTheme(this.value)">' +
|
|
561
|
+
'<option value="dark" selected>Dark</option>' +
|
|
562
|
+
'<option value="light">Light</option>' +
|
|
563
|
+
'</select>' +
|
|
564
|
+
'</div>' +
|
|
565
|
+
'<div class="bg-card-bg/50 p-4 rounded-xl border border-slate-700/30">' +
|
|
566
|
+
'<label class="block text-sm font-bold text-text-main mb-2">Items per Page</label>' +
|
|
567
|
+
'<select class="w-full bg-slate-700/50 border border-slate-600 rounded-lg px-3 py-2 text-text-main" onchange="changeItemsPerPage(this.value)">' +
|
|
568
|
+
'<option value="10">10</option>' +
|
|
569
|
+
'<option value="25" selected>25</option>' +
|
|
570
|
+
'<option value="50">50</option>' +
|
|
571
|
+
'<option value="100">100</option>' +
|
|
572
|
+
'</select>' +
|
|
573
|
+
'</div>' +
|
|
574
|
+
'<div class="flex justify-end space-x-3 mt-6">' +
|
|
575
|
+
'<button onclick="closeModal(this)" class="px-4 py-2 bg-slate-700/50 hover:bg-slate-600/50 rounded-lg text-text-main transition-colors">Cancel</button>' +
|
|
576
|
+
'<button onclick="saveSettings()" class="px-4 py-2 bg-primary text-black rounded-lg hover:bg-primary/80 transition-colors">Save</button>' +
|
|
577
|
+
'</div>' +
|
|
578
|
+
'</div>' +
|
|
579
|
+
'</div>';
|
|
580
|
+
document.body.appendChild(modal);
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
function closeModal(button) {
|
|
584
|
+
const modal = button.closest('.fixed');
|
|
585
|
+
if (modal) {
|
|
586
|
+
modal.remove();
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
function changeRefreshInterval(interval) {
|
|
591
|
+
clearInterval(window.refreshInterval);
|
|
592
|
+
window.refreshInterval = setInterval(loadData, parseInt(interval));
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
function changeTheme(theme) {
|
|
596
|
+
if (theme === 'light') {
|
|
597
|
+
document.documentElement.classList.remove('dark');
|
|
598
|
+
} else {
|
|
599
|
+
document.documentElement.classList.add('dark');
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
function changeItemsPerPage(count) {
|
|
604
|
+
// This would require updating the API calls, for now just store in localStorage
|
|
605
|
+
localStorage.setItem('itemsPerPage', count);
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
function saveSettings() {
|
|
609
|
+
// Close the modal and show success message
|
|
610
|
+
const modal = document.querySelector('.fixed');
|
|
611
|
+
if (modal) {
|
|
612
|
+
// Could show a toast notification here
|
|
613
|
+
modal.remove();
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
function changeProject(path) {
|
|
618
|
+
currentProjectPath = path;
|
|
619
|
+
loadData();
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
// Initialize: load projects first, then data
|
|
623
|
+
loadProjects().then(function() {
|
|
624
|
+
loadData();
|
|
625
|
+
window.refreshInterval = setInterval(loadData, 30000);
|
|
626
|
+
});
|
|
627
|
+
</script>
|
|
629
628
|
</body></html>`;
|
|
630
629
|
res.send(html);
|
|
631
630
|
});
|
|
632
631
|
// Start server
|
|
633
632
|
export function startWebServer() {
|
|
634
|
-
|
|
635
|
-
|
|
633
|
+
return new Promise((resolve, reject) => {
|
|
634
|
+
const server = app.listen(PORT, () => {
|
|
635
|
+
logger.info('Web UI available at http://localhost:' + PORT);
|
|
636
|
+
resolve(server);
|
|
637
|
+
});
|
|
638
|
+
server.on('error', reject);
|
|
636
639
|
});
|
|
637
640
|
}
|
|
638
641
|
export default app;
|
|
639
|
-
//# sourceMappingURL=
|
|
642
|
+
//# sourceMappingURL=server.js.map
|