gitmem-mcp 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +47 -0
- package/CLAUDE.md.template +65 -0
- package/LICENSE +21 -0
- package/README.md +221 -0
- package/bin/gitmem.js +383 -0
- package/dist/commands/check.d.ts +33 -0
- package/dist/commands/check.d.ts.map +1 -0
- package/dist/commands/check.js +492 -0
- package/dist/commands/check.js.map +1 -0
- package/dist/constants/closing-questions.d.ts +40 -0
- package/dist/constants/closing-questions.d.ts.map +1 -0
- package/dist/constants/closing-questions.js +107 -0
- package/dist/constants/closing-questions.js.map +1 -0
- package/dist/diagnostics/anonymizer.d.ts +55 -0
- package/dist/diagnostics/anonymizer.d.ts.map +1 -0
- package/dist/diagnostics/anonymizer.js +191 -0
- package/dist/diagnostics/anonymizer.js.map +1 -0
- package/dist/diagnostics/channels.d.ts +132 -0
- package/dist/diagnostics/channels.d.ts.map +1 -0
- package/dist/diagnostics/channels.js +150 -0
- package/dist/diagnostics/channels.js.map +1 -0
- package/dist/diagnostics/collector.d.ts +183 -0
- package/dist/diagnostics/collector.d.ts.map +1 -0
- package/dist/diagnostics/collector.js +227 -0
- package/dist/diagnostics/collector.js.map +1 -0
- package/dist/diagnostics/index.d.ts +28 -0
- package/dist/diagnostics/index.d.ts.map +1 -0
- package/dist/diagnostics/index.js +31 -0
- package/dist/diagnostics/index.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/schemas/absorb-observations.d.ts +63 -0
- package/dist/schemas/absorb-observations.d.ts.map +1 -0
- package/dist/schemas/absorb-observations.js +25 -0
- package/dist/schemas/absorb-observations.js.map +1 -0
- package/dist/schemas/active-sessions.d.ts +71 -0
- package/dist/schemas/active-sessions.d.ts.map +1 -0
- package/dist/schemas/active-sessions.js +19 -0
- package/dist/schemas/active-sessions.js.map +1 -0
- package/dist/schemas/analyze.d.ts +38 -0
- package/dist/schemas/analyze.d.ts.map +1 -0
- package/dist/schemas/analyze.js +30 -0
- package/dist/schemas/analyze.js.map +1 -0
- package/dist/schemas/common.d.ts +55 -0
- package/dist/schemas/common.d.ts.map +1 -0
- package/dist/schemas/common.js +65 -0
- package/dist/schemas/common.js.map +1 -0
- package/dist/schemas/create-decision.d.ts +48 -0
- package/dist/schemas/create-decision.d.ts.map +1 -0
- package/dist/schemas/create-decision.js +31 -0
- package/dist/schemas/create-decision.js.map +1 -0
- package/dist/schemas/create-learning.d.ts +107 -0
- package/dist/schemas/create-learning.d.ts.map +1 -0
- package/dist/schemas/create-learning.js +64 -0
- package/dist/schemas/create-learning.js.map +1 -0
- package/dist/schemas/get-transcript.d.ts +24 -0
- package/dist/schemas/get-transcript.d.ts.map +1 -0
- package/dist/schemas/get-transcript.js +22 -0
- package/dist/schemas/get-transcript.js.map +1 -0
- package/dist/schemas/index.d.ts +23 -0
- package/dist/schemas/index.d.ts.map +1 -0
- package/dist/schemas/index.js +23 -0
- package/dist/schemas/index.js.map +1 -0
- package/dist/schemas/log.d.ts +36 -0
- package/dist/schemas/log.d.ts.map +1 -0
- package/dist/schemas/log.js +27 -0
- package/dist/schemas/log.js.map +1 -0
- package/dist/schemas/prepare-context.d.ts +41 -0
- package/dist/schemas/prepare-context.d.ts.map +1 -0
- package/dist/schemas/prepare-context.js +31 -0
- package/dist/schemas/prepare-context.js.map +1 -0
- package/dist/schemas/recall.d.ts +41 -0
- package/dist/schemas/recall.d.ts.map +1 -0
- package/dist/schemas/recall.js +47 -0
- package/dist/schemas/recall.js.map +1 -0
- package/dist/schemas/record-scar-usage-batch.d.ts +82 -0
- package/dist/schemas/record-scar-usage-batch.d.ts.map +1 -0
- package/dist/schemas/record-scar-usage-batch.js +25 -0
- package/dist/schemas/record-scar-usage-batch.js.map +1 -0
- package/dist/schemas/record-scar-usage.d.ts +51 -0
- package/dist/schemas/record-scar-usage.d.ts.map +1 -0
- package/dist/schemas/record-scar-usage.js +32 -0
- package/dist/schemas/record-scar-usage.js.map +1 -0
- package/dist/schemas/save-transcript.d.ts +38 -0
- package/dist/schemas/save-transcript.d.ts.map +1 -0
- package/dist/schemas/save-transcript.js +30 -0
- package/dist/schemas/save-transcript.js.map +1 -0
- package/dist/schemas/search.d.ts +36 -0
- package/dist/schemas/search.d.ts.map +1 -0
- package/dist/schemas/search.js +27 -0
- package/dist/schemas/search.js.map +1 -0
- package/dist/schemas/session-close.d.ts +371 -0
- package/dist/schemas/session-close.d.ts.map +1 -0
- package/dist/schemas/session-close.js +95 -0
- package/dist/schemas/session-close.js.map +1 -0
- package/dist/schemas/session-start.d.ts +46 -0
- package/dist/schemas/session-start.d.ts.map +1 -0
- package/dist/schemas/session-start.js +33 -0
- package/dist/schemas/session-start.js.map +1 -0
- package/dist/schemas/thread.d.ts +72 -0
- package/dist/schemas/thread.d.ts.map +1 -0
- package/dist/schemas/thread.js +39 -0
- package/dist/schemas/thread.js.map +1 -0
- package/dist/server.d.ts +22 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +313 -0
- package/dist/server.js.map +1 -0
- package/dist/services/active-sessions.d.ts +66 -0
- package/dist/services/active-sessions.d.ts.map +1 -0
- package/dist/services/active-sessions.js +311 -0
- package/dist/services/active-sessions.js.map +1 -0
- package/dist/services/agent-detection.d.ts +25 -0
- package/dist/services/agent-detection.d.ts.map +1 -0
- package/dist/services/agent-detection.js +93 -0
- package/dist/services/agent-detection.js.map +1 -0
- package/dist/services/analytics.d.ts +201 -0
- package/dist/services/analytics.d.ts.map +1 -0
- package/dist/services/analytics.js +483 -0
- package/dist/services/analytics.js.map +1 -0
- package/dist/services/cache.d.ts +148 -0
- package/dist/services/cache.d.ts.map +1 -0
- package/dist/services/cache.js +384 -0
- package/dist/services/cache.js.map +1 -0
- package/dist/services/cache.test.d.ts +8 -0
- package/dist/services/cache.test.d.ts.map +1 -0
- package/dist/services/cache.test.js +267 -0
- package/dist/services/cache.test.js.map +1 -0
- package/dist/services/compliance-validator.d.ts +30 -0
- package/dist/services/compliance-validator.d.ts.map +1 -0
- package/dist/services/compliance-validator.js +257 -0
- package/dist/services/compliance-validator.js.map +1 -0
- package/dist/services/config.d.ts +48 -0
- package/dist/services/config.d.ts.map +1 -0
- package/dist/services/config.js +128 -0
- package/dist/services/config.js.map +1 -0
- package/dist/services/embedding.d.ts +58 -0
- package/dist/services/embedding.d.ts.map +1 -0
- package/dist/services/embedding.js +243 -0
- package/dist/services/embedding.js.map +1 -0
- package/dist/services/gitmem-dir.d.ts +38 -0
- package/dist/services/gitmem-dir.d.ts.map +1 -0
- package/dist/services/gitmem-dir.js +84 -0
- package/dist/services/gitmem-dir.js.map +1 -0
- package/dist/services/local-file-storage.d.ts +56 -0
- package/dist/services/local-file-storage.d.ts.map +1 -0
- package/dist/services/local-file-storage.js +213 -0
- package/dist/services/local-file-storage.js.map +1 -0
- package/dist/services/local-vector-search.d.ts +137 -0
- package/dist/services/local-vector-search.d.ts.map +1 -0
- package/dist/services/local-vector-search.js +311 -0
- package/dist/services/local-vector-search.js.map +1 -0
- package/dist/services/metrics.d.ts +104 -0
- package/dist/services/metrics.d.ts.map +1 -0
- package/dist/services/metrics.js +264 -0
- package/dist/services/metrics.js.map +1 -0
- package/dist/services/session-state.d.ts +113 -0
- package/dist/services/session-state.d.ts.map +1 -0
- package/dist/services/session-state.js +203 -0
- package/dist/services/session-state.js.map +1 -0
- package/dist/services/startup.d.ts +112 -0
- package/dist/services/startup.d.ts.map +1 -0
- package/dist/services/startup.js +436 -0
- package/dist/services/startup.js.map +1 -0
- package/dist/services/storage.d.ts +43 -0
- package/dist/services/storage.d.ts.map +1 -0
- package/dist/services/storage.js +92 -0
- package/dist/services/storage.js.map +1 -0
- package/dist/services/supabase-client.d.ts +163 -0
- package/dist/services/supabase-client.d.ts.map +1 -0
- package/dist/services/supabase-client.js +510 -0
- package/dist/services/supabase-client.js.map +1 -0
- package/dist/services/thread-dedup.d.ts +44 -0
- package/dist/services/thread-dedup.d.ts.map +1 -0
- package/dist/services/thread-dedup.js +113 -0
- package/dist/services/thread-dedup.js.map +1 -0
- package/dist/services/thread-manager.d.ts +77 -0
- package/dist/services/thread-manager.d.ts.map +1 -0
- package/dist/services/thread-manager.js +250 -0
- package/dist/services/thread-manager.js.map +1 -0
- package/dist/services/thread-suggestions.d.ts +66 -0
- package/dist/services/thread-suggestions.d.ts.map +1 -0
- package/dist/services/thread-suggestions.js +243 -0
- package/dist/services/thread-suggestions.js.map +1 -0
- package/dist/services/thread-supabase.d.ts +111 -0
- package/dist/services/thread-supabase.d.ts.map +1 -0
- package/dist/services/thread-supabase.js +459 -0
- package/dist/services/thread-supabase.js.map +1 -0
- package/dist/services/thread-vitality.d.ts +65 -0
- package/dist/services/thread-vitality.d.ts.map +1 -0
- package/dist/services/thread-vitality.js +143 -0
- package/dist/services/thread-vitality.js.map +1 -0
- package/dist/services/tier.d.ts +52 -0
- package/dist/services/tier.d.ts.map +1 -0
- package/dist/services/tier.js +109 -0
- package/dist/services/tier.js.map +1 -0
- package/dist/services/timezone.d.ts +37 -0
- package/dist/services/timezone.d.ts.map +1 -0
- package/dist/services/timezone.js +147 -0
- package/dist/services/timezone.js.map +1 -0
- package/dist/services/transcript-chunker.d.ts +18 -0
- package/dist/services/transcript-chunker.d.ts.map +1 -0
- package/dist/services/transcript-chunker.js +237 -0
- package/dist/services/transcript-chunker.js.map +1 -0
- package/dist/services/triple-writer.d.ts +128 -0
- package/dist/services/triple-writer.d.ts.map +1 -0
- package/dist/services/triple-writer.js +338 -0
- package/dist/services/triple-writer.js.map +1 -0
- package/dist/services/variant-assignment.d.ts +92 -0
- package/dist/services/variant-assignment.d.ts.map +1 -0
- package/dist/services/variant-assignment.js +196 -0
- package/dist/services/variant-assignment.js.map +1 -0
- package/dist/tools/absorb-observations.d.ts +16 -0
- package/dist/tools/absorb-observations.d.ts.map +1 -0
- package/dist/tools/absorb-observations.js +82 -0
- package/dist/tools/absorb-observations.js.map +1 -0
- package/dist/tools/analyze.d.ts +55 -0
- package/dist/tools/analyze.d.ts.map +1 -0
- package/dist/tools/analyze.js +139 -0
- package/dist/tools/analyze.js.map +1 -0
- package/dist/tools/cleanup-threads.d.ts +47 -0
- package/dist/tools/cleanup-threads.d.ts.map +1 -0
- package/dist/tools/cleanup-threads.js +127 -0
- package/dist/tools/cleanup-threads.js.map +1 -0
- package/dist/tools/confirm-scars.d.ts +23 -0
- package/dist/tools/confirm-scars.d.ts.map +1 -0
- package/dist/tools/confirm-scars.js +209 -0
- package/dist/tools/confirm-scars.js.map +1 -0
- package/dist/tools/create-decision.d.ts +15 -0
- package/dist/tools/create-decision.d.ts.map +1 -0
- package/dist/tools/create-decision.js +138 -0
- package/dist/tools/create-decision.js.map +1 -0
- package/dist/tools/create-learning.d.ts +15 -0
- package/dist/tools/create-learning.d.ts.map +1 -0
- package/dist/tools/create-learning.js +226 -0
- package/dist/tools/create-learning.js.map +1 -0
- package/dist/tools/create-thread.d.ts +42 -0
- package/dist/tools/create-thread.d.ts.map +1 -0
- package/dist/tools/create-thread.js +180 -0
- package/dist/tools/create-thread.js.map +1 -0
- package/dist/tools/definitions.d.ts +5013 -0
- package/dist/tools/definitions.d.ts.map +1 -0
- package/dist/tools/definitions.js +2017 -0
- package/dist/tools/definitions.js.map +1 -0
- package/dist/tools/dismiss-suggestion.d.ts +20 -0
- package/dist/tools/dismiss-suggestion.d.ts.map +1 -0
- package/dist/tools/dismiss-suggestion.js +40 -0
- package/dist/tools/dismiss-suggestion.js.map +1 -0
- package/dist/tools/get-transcript.d.ts +24 -0
- package/dist/tools/get-transcript.d.ts.map +1 -0
- package/dist/tools/get-transcript.js +52 -0
- package/dist/tools/get-transcript.js.map +1 -0
- package/dist/tools/graph-traverse.d.ts +83 -0
- package/dist/tools/graph-traverse.d.ts.map +1 -0
- package/dist/tools/graph-traverse.js +394 -0
- package/dist/tools/graph-traverse.js.map +1 -0
- package/dist/tools/list-threads.d.ts +15 -0
- package/dist/tools/list-threads.d.ts.map +1 -0
- package/dist/tools/list-threads.js +114 -0
- package/dist/tools/list-threads.js.map +1 -0
- package/dist/tools/log.d.ts +43 -0
- package/dist/tools/log.d.ts.map +1 -0
- package/dist/tools/log.js +157 -0
- package/dist/tools/log.js.map +1 -0
- package/dist/tools/prepare-context.d.ts +36 -0
- package/dist/tools/prepare-context.d.ts.map +1 -0
- package/dist/tools/prepare-context.js +353 -0
- package/dist/tools/prepare-context.js.map +1 -0
- package/dist/tools/promote-suggestion.d.ts +25 -0
- package/dist/tools/promote-suggestion.d.ts.map +1 -0
- package/dist/tools/promote-suggestion.js +60 -0
- package/dist/tools/promote-suggestion.js.map +1 -0
- package/dist/tools/recall.d.ts +77 -0
- package/dist/tools/recall.d.ts.map +1 -0
- package/dist/tools/recall.js +423 -0
- package/dist/tools/recall.js.map +1 -0
- package/dist/tools/recall.test.d.ts +5 -0
- package/dist/tools/recall.test.d.ts.map +1 -0
- package/dist/tools/recall.test.js +155 -0
- package/dist/tools/recall.test.js.map +1 -0
- package/dist/tools/record-scar-usage-batch.d.ts +10 -0
- package/dist/tools/record-scar-usage-batch.d.ts.map +1 -0
- package/dist/tools/record-scar-usage-batch.js +153 -0
- package/dist/tools/record-scar-usage-batch.js.map +1 -0
- package/dist/tools/record-scar-usage.d.ts +14 -0
- package/dist/tools/record-scar-usage.d.ts.map +1 -0
- package/dist/tools/record-scar-usage.js +94 -0
- package/dist/tools/record-scar-usage.js.map +1 -0
- package/dist/tools/resolve-thread.d.ts +16 -0
- package/dist/tools/resolve-thread.d.ts.map +1 -0
- package/dist/tools/resolve-thread.js +102 -0
- package/dist/tools/resolve-thread.js.map +1 -0
- package/dist/tools/save-transcript.d.ts +29 -0
- package/dist/tools/save-transcript.d.ts.map +1 -0
- package/dist/tools/save-transcript.js +97 -0
- package/dist/tools/save-transcript.js.map +1 -0
- package/dist/tools/search.d.ts +46 -0
- package/dist/tools/search.d.ts.map +1 -0
- package/dist/tools/search.js +186 -0
- package/dist/tools/search.js.map +1 -0
- package/dist/tools/session-close.d.ts +14 -0
- package/dist/tools/session-close.d.ts.map +1 -0
- package/dist/tools/session-close.js +881 -0
- package/dist/tools/session-close.js.map +1 -0
- package/dist/tools/session-start.d.ts +38 -0
- package/dist/tools/session-start.d.ts.map +1 -0
- package/dist/tools/session-start.js +1104 -0
- package/dist/tools/session-start.js.map +1 -0
- package/dist/types/index.d.ts +456 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +5 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +76 -0
- package/schema/setup.sql +193 -0
- package/schema/starter-scars.json +206 -0
package/schema/setup.sql
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
-- GitMem Schema Setup
|
|
2
|
+
-- Run this SQL in your Supabase SQL Editor to create the required tables.
|
|
3
|
+
-- Dashboard → SQL Editor → New query → Paste → Run
|
|
4
|
+
|
|
5
|
+
-- Enable pgvector extension for semantic search
|
|
6
|
+
CREATE EXTENSION IF NOT EXISTS vector;
|
|
7
|
+
|
|
8
|
+
-- ============================================================================
|
|
9
|
+
-- Learnings table (scars, wins, patterns)
|
|
10
|
+
-- ============================================================================
|
|
11
|
+
CREATE TABLE IF NOT EXISTS gitmem_learnings (
|
|
12
|
+
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
13
|
+
learning_type TEXT NOT NULL CHECK (learning_type IN ('scar', 'win', 'pattern')),
|
|
14
|
+
title TEXT NOT NULL,
|
|
15
|
+
description TEXT NOT NULL,
|
|
16
|
+
severity TEXT CHECK (severity IN ('critical', 'high', 'medium', 'low')),
|
|
17
|
+
scar_type TEXT DEFAULT 'operational',
|
|
18
|
+
counter_arguments TEXT[] DEFAULT '{}',
|
|
19
|
+
problem_context TEXT DEFAULT '',
|
|
20
|
+
solution_approach TEXT DEFAULT '',
|
|
21
|
+
applies_when TEXT[] DEFAULT '{}',
|
|
22
|
+
keywords TEXT[] DEFAULT '{}',
|
|
23
|
+
domain TEXT[] DEFAULT '{}',
|
|
24
|
+
embedding vector(1536),
|
|
25
|
+
project TEXT DEFAULT 'default',
|
|
26
|
+
source_date DATE DEFAULT CURRENT_DATE,
|
|
27
|
+
created_at TIMESTAMPTZ DEFAULT NOW(),
|
|
28
|
+
updated_at TIMESTAMPTZ DEFAULT NOW()
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
-- Index for faster vector search
|
|
32
|
+
CREATE INDEX IF NOT EXISTS idx_gitmem_learnings_embedding
|
|
33
|
+
ON gitmem_learnings USING ivfflat (embedding vector_cosine_ops)
|
|
34
|
+
WITH (lists = 10);
|
|
35
|
+
|
|
36
|
+
CREATE INDEX IF NOT EXISTS idx_gitmem_learnings_type
|
|
37
|
+
ON gitmem_learnings (learning_type);
|
|
38
|
+
|
|
39
|
+
CREATE INDEX IF NOT EXISTS idx_gitmem_learnings_project
|
|
40
|
+
ON gitmem_learnings (project);
|
|
41
|
+
|
|
42
|
+
-- ============================================================================
|
|
43
|
+
-- Sessions table
|
|
44
|
+
-- ============================================================================
|
|
45
|
+
CREATE TABLE IF NOT EXISTS gitmem_sessions (
|
|
46
|
+
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
47
|
+
session_title TEXT DEFAULT 'Interactive Session',
|
|
48
|
+
session_date DATE DEFAULT CURRENT_DATE,
|
|
49
|
+
agent TEXT DEFAULT 'Unknown',
|
|
50
|
+
project TEXT DEFAULT 'default',
|
|
51
|
+
decisions TEXT[] DEFAULT '{}',
|
|
52
|
+
open_threads TEXT[] DEFAULT '{}',
|
|
53
|
+
closing_reflection JSONB,
|
|
54
|
+
embedding vector(1536),
|
|
55
|
+
created_at TIMESTAMPTZ DEFAULT NOW(),
|
|
56
|
+
updated_at TIMESTAMPTZ DEFAULT NOW()
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
CREATE INDEX IF NOT EXISTS idx_gitmem_sessions_agent
|
|
60
|
+
ON gitmem_sessions (agent);
|
|
61
|
+
|
|
62
|
+
CREATE INDEX IF NOT EXISTS idx_gitmem_sessions_created
|
|
63
|
+
ON gitmem_sessions (created_at DESC);
|
|
64
|
+
|
|
65
|
+
-- ============================================================================
|
|
66
|
+
-- Decisions table
|
|
67
|
+
-- ============================================================================
|
|
68
|
+
CREATE TABLE IF NOT EXISTS gitmem_decisions (
|
|
69
|
+
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
70
|
+
decision_date DATE DEFAULT CURRENT_DATE,
|
|
71
|
+
title TEXT NOT NULL,
|
|
72
|
+
decision TEXT NOT NULL,
|
|
73
|
+
rationale TEXT NOT NULL,
|
|
74
|
+
alternatives_considered TEXT[] DEFAULT '{}',
|
|
75
|
+
session_id UUID REFERENCES gitmem_sessions(id),
|
|
76
|
+
project TEXT DEFAULT 'default',
|
|
77
|
+
embedding vector(1536),
|
|
78
|
+
created_at TIMESTAMPTZ DEFAULT NOW()
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
CREATE INDEX IF NOT EXISTS idx_gitmem_decisions_session
|
|
82
|
+
ON gitmem_decisions (session_id);
|
|
83
|
+
|
|
84
|
+
-- ============================================================================
|
|
85
|
+
-- Scar usage tracking
|
|
86
|
+
-- ============================================================================
|
|
87
|
+
CREATE TABLE IF NOT EXISTS gitmem_scar_usage (
|
|
88
|
+
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
89
|
+
scar_id UUID REFERENCES gitmem_learnings(id),
|
|
90
|
+
session_id UUID REFERENCES gitmem_sessions(id),
|
|
91
|
+
agent TEXT DEFAULT 'Unknown',
|
|
92
|
+
reference_type TEXT CHECK (reference_type IN ('explicit', 'implicit', 'acknowledged', 'refuted', 'none')),
|
|
93
|
+
reference_context TEXT,
|
|
94
|
+
surfaced_at TIMESTAMPTZ,
|
|
95
|
+
execution_successful BOOLEAN,
|
|
96
|
+
created_at TIMESTAMPTZ DEFAULT NOW()
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
CREATE INDEX IF NOT EXISTS idx_gitmem_scar_usage_scar
|
|
100
|
+
ON gitmem_scar_usage (scar_id);
|
|
101
|
+
|
|
102
|
+
CREATE INDEX IF NOT EXISTS idx_gitmem_scar_usage_session
|
|
103
|
+
ON gitmem_scar_usage (session_id);
|
|
104
|
+
|
|
105
|
+
-- ============================================================================
|
|
106
|
+
-- Semantic search RPC function
|
|
107
|
+
-- ============================================================================
|
|
108
|
+
CREATE OR REPLACE FUNCTION gitmem_semantic_search(
|
|
109
|
+
query_embedding vector(1536),
|
|
110
|
+
match_count INT DEFAULT 5,
|
|
111
|
+
similarity_threshold FLOAT DEFAULT 0.0
|
|
112
|
+
)
|
|
113
|
+
RETURNS TABLE (
|
|
114
|
+
id UUID,
|
|
115
|
+
title TEXT,
|
|
116
|
+
description TEXT,
|
|
117
|
+
severity TEXT,
|
|
118
|
+
counter_arguments TEXT[],
|
|
119
|
+
similarity FLOAT
|
|
120
|
+
)
|
|
121
|
+
LANGUAGE plpgsql
|
|
122
|
+
AS $$
|
|
123
|
+
BEGIN
|
|
124
|
+
RETURN QUERY
|
|
125
|
+
SELECT
|
|
126
|
+
l.id,
|
|
127
|
+
l.title,
|
|
128
|
+
l.description,
|
|
129
|
+
l.severity,
|
|
130
|
+
l.counter_arguments,
|
|
131
|
+
1 - (l.embedding <=> query_embedding) AS similarity
|
|
132
|
+
FROM gitmem_learnings l
|
|
133
|
+
WHERE l.embedding IS NOT NULL
|
|
134
|
+
AND 1 - (l.embedding <=> query_embedding) > similarity_threshold
|
|
135
|
+
ORDER BY l.embedding <=> query_embedding
|
|
136
|
+
LIMIT match_count;
|
|
137
|
+
END;
|
|
138
|
+
$$;
|
|
139
|
+
|
|
140
|
+
-- ============================================================================
|
|
141
|
+
-- Row Level Security
|
|
142
|
+
-- ============================================================================
|
|
143
|
+
|
|
144
|
+
-- Enable RLS on all tables
|
|
145
|
+
ALTER TABLE gitmem_learnings ENABLE ROW LEVEL SECURITY;
|
|
146
|
+
ALTER TABLE gitmem_sessions ENABLE ROW LEVEL SECURITY;
|
|
147
|
+
ALTER TABLE gitmem_decisions ENABLE ROW LEVEL SECURITY;
|
|
148
|
+
ALTER TABLE gitmem_scar_usage ENABLE ROW LEVEL SECURITY;
|
|
149
|
+
|
|
150
|
+
-- Service role has full access (used by the MCP server)
|
|
151
|
+
CREATE POLICY "Service role full access" ON gitmem_learnings
|
|
152
|
+
FOR ALL USING (auth.role() = 'service_role');
|
|
153
|
+
|
|
154
|
+
CREATE POLICY "Service role full access" ON gitmem_sessions
|
|
155
|
+
FOR ALL USING (auth.role() = 'service_role');
|
|
156
|
+
|
|
157
|
+
CREATE POLICY "Service role full access" ON gitmem_decisions
|
|
158
|
+
FOR ALL USING (auth.role() = 'service_role');
|
|
159
|
+
|
|
160
|
+
CREATE POLICY "Service role full access" ON gitmem_scar_usage
|
|
161
|
+
FOR ALL USING (auth.role() = 'service_role');
|
|
162
|
+
|
|
163
|
+
-- Block anonymous access
|
|
164
|
+
CREATE POLICY "Block anonymous access" ON gitmem_learnings
|
|
165
|
+
FOR ALL USING (auth.role() != 'anon');
|
|
166
|
+
|
|
167
|
+
CREATE POLICY "Block anonymous access" ON gitmem_sessions
|
|
168
|
+
FOR ALL USING (auth.role() != 'anon');
|
|
169
|
+
|
|
170
|
+
CREATE POLICY "Block anonymous access" ON gitmem_decisions
|
|
171
|
+
FOR ALL USING (auth.role() != 'anon');
|
|
172
|
+
|
|
173
|
+
CREATE POLICY "Block anonymous access" ON gitmem_scar_usage
|
|
174
|
+
FOR ALL USING (auth.role() != 'anon');
|
|
175
|
+
|
|
176
|
+
-- ============================================================================
|
|
177
|
+
-- Auto-update timestamps
|
|
178
|
+
-- ============================================================================
|
|
179
|
+
CREATE OR REPLACE FUNCTION gitmem_update_timestamp()
|
|
180
|
+
RETURNS TRIGGER AS $$
|
|
181
|
+
BEGIN
|
|
182
|
+
NEW.updated_at = NOW();
|
|
183
|
+
RETURN NEW;
|
|
184
|
+
END;
|
|
185
|
+
$$ LANGUAGE plpgsql;
|
|
186
|
+
|
|
187
|
+
CREATE TRIGGER gitmem_learnings_updated
|
|
188
|
+
BEFORE UPDATE ON gitmem_learnings
|
|
189
|
+
FOR EACH ROW EXECUTE FUNCTION gitmem_update_timestamp();
|
|
190
|
+
|
|
191
|
+
CREATE TRIGGER gitmem_sessions_updated
|
|
192
|
+
BEFORE UPDATE ON gitmem_sessions
|
|
193
|
+
FOR EACH ROW EXECUTE FUNCTION gitmem_update_timestamp();
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "00000000-0000-0000-0000-000000000001",
|
|
4
|
+
"learning_type": "scar",
|
|
5
|
+
"title": "Tests Pass Locally But Fail in CI",
|
|
6
|
+
"description": "Local test environments often differ from CI (different OS, Node version, env vars, timing). Code that passes locally may fail in CI due to missing environment variables, hardcoded paths, race conditions, or dependency version differences. Always verify in CI before declaring 'it works'.",
|
|
7
|
+
"severity": "high",
|
|
8
|
+
"scar_type": "verification",
|
|
9
|
+
"counter_arguments": [
|
|
10
|
+
"Our CI config matches local exactly — but environment variables, caching, and timing can still differ",
|
|
11
|
+
"We have good test coverage so local passing is enough — but coverage doesn't catch environment-specific issues"
|
|
12
|
+
],
|
|
13
|
+
"keywords": ["tests", "ci", "local", "environment", "flaky"],
|
|
14
|
+
"domain": ["testing", "ci-cd"],
|
|
15
|
+
"project": "default",
|
|
16
|
+
"source_date": "2026-01-01",
|
|
17
|
+
"created_at": "2026-01-01T00:00:00Z"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"id": "00000000-0000-0000-0000-000000000002",
|
|
21
|
+
"learning_type": "scar",
|
|
22
|
+
"title": "Done != Deployed != Verified Working",
|
|
23
|
+
"description": "Code being 'done' (merged) doesn't mean it's deployed, and being deployed doesn't mean it's working correctly in production. The full loop is: merge → deploy → verify the feature works end-to-end in the target environment. Skipping verification leads to silent failures.",
|
|
24
|
+
"severity": "critical",
|
|
25
|
+
"scar_type": "verification",
|
|
26
|
+
"counter_arguments": [
|
|
27
|
+
"Our deployment pipeline is automated so merge = deploy — but automated doesn't mean verified working",
|
|
28
|
+
"We have monitoring that would catch issues — but monitoring has blind spots and alert fatigue is real"
|
|
29
|
+
],
|
|
30
|
+
"keywords": ["deployment", "verification", "production", "done"],
|
|
31
|
+
"domain": ["deployment", "operations"],
|
|
32
|
+
"project": "default",
|
|
33
|
+
"source_date": "2026-01-01",
|
|
34
|
+
"created_at": "2026-01-01T00:00:00Z"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"id": "00000000-0000-0000-0000-000000000003",
|
|
38
|
+
"learning_type": "scar",
|
|
39
|
+
"title": "Environment Variables Missing in Production",
|
|
40
|
+
"description": "New features that rely on environment variables frequently fail in production because the variables were set locally but never added to the production environment. Always document required env vars and verify they exist in all target environments before deploying.",
|
|
41
|
+
"severity": "high",
|
|
42
|
+
"scar_type": "deployment",
|
|
43
|
+
"counter_arguments": [
|
|
44
|
+
"We have a .env.example that tracks all variables — but .env.example and actual production config drift apart",
|
|
45
|
+
"Our deployment checklist covers env vars — but checklists get skipped under time pressure"
|
|
46
|
+
],
|
|
47
|
+
"keywords": ["environment", "variables", "production", "config", "missing"],
|
|
48
|
+
"domain": ["deployment", "configuration"],
|
|
49
|
+
"project": "default",
|
|
50
|
+
"source_date": "2026-01-01",
|
|
51
|
+
"created_at": "2026-01-01T00:00:00Z"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"id": "00000000-0000-0000-0000-000000000004",
|
|
55
|
+
"learning_type": "scar",
|
|
56
|
+
"title": "Database Migration Without Rollback Plan",
|
|
57
|
+
"description": "Running database migrations without a tested rollback plan risks data loss or extended downtime. Destructive migrations (dropping columns, changing types) are especially dangerous. Always write and test the down migration before running the up migration in production.",
|
|
58
|
+
"severity": "critical",
|
|
59
|
+
"scar_type": "architectural",
|
|
60
|
+
"counter_arguments": [
|
|
61
|
+
"This migration is additive so it's safe — but even additive migrations can fail and leave the schema in a partial state",
|
|
62
|
+
"We can always restore from backup — but backup restoration takes time and may lose recent data"
|
|
63
|
+
],
|
|
64
|
+
"keywords": ["database", "migration", "rollback", "schema", "data-loss"],
|
|
65
|
+
"domain": ["database", "operations"],
|
|
66
|
+
"project": "default",
|
|
67
|
+
"source_date": "2026-01-01",
|
|
68
|
+
"created_at": "2026-01-01T00:00:00Z"
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"id": "00000000-0000-0000-0000-000000000005",
|
|
72
|
+
"learning_type": "scar",
|
|
73
|
+
"title": "Hardcoded Secrets in Source Code",
|
|
74
|
+
"description": "API keys, database passwords, and other secrets hardcoded in source code inevitably leak — through git history, logs, error messages, or public repos. Always use environment variables or a secrets manager. If a secret was ever committed, rotate it immediately.",
|
|
75
|
+
"severity": "critical",
|
|
76
|
+
"scar_type": "security",
|
|
77
|
+
"counter_arguments": [
|
|
78
|
+
"This is a private repo so it's fine — but private repos get forked, team members change, and git history is forever",
|
|
79
|
+
"It's just a dev/test key — but dev keys often have more permissions than expected and habits carry to production"
|
|
80
|
+
],
|
|
81
|
+
"keywords": ["secrets", "api-keys", "security", "hardcoded", "credentials"],
|
|
82
|
+
"domain": ["security", "configuration"],
|
|
83
|
+
"project": "default",
|
|
84
|
+
"source_date": "2026-01-01",
|
|
85
|
+
"created_at": "2026-01-01T00:00:00Z"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"id": "00000000-0000-0000-0000-000000000006",
|
|
89
|
+
"learning_type": "scar",
|
|
90
|
+
"title": "API Breaking Change Without Versioning",
|
|
91
|
+
"description": "Changing API response shapes, removing fields, or modifying behavior without versioning breaks downstream consumers silently. Even 'internal' APIs often have more consumers than expected. Use API versioning and deprecation periods for any breaking change.",
|
|
92
|
+
"severity": "high",
|
|
93
|
+
"scar_type": "architectural",
|
|
94
|
+
"counter_arguments": [
|
|
95
|
+
"Only our own frontend uses this API — but other teams, scripts, and integrations may depend on it too",
|
|
96
|
+
"We can coordinate the change with all consumers — but coordinated deploys are fragile and someone always gets missed"
|
|
97
|
+
],
|
|
98
|
+
"keywords": ["api", "breaking-change", "versioning", "backwards-compatibility"],
|
|
99
|
+
"domain": ["api", "architecture"],
|
|
100
|
+
"project": "default",
|
|
101
|
+
"source_date": "2026-01-01",
|
|
102
|
+
"created_at": "2026-01-01T00:00:00Z"
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"id": "00000000-0000-0000-0000-000000000007",
|
|
106
|
+
"learning_type": "scar",
|
|
107
|
+
"title": "Cache Invalidation After Data Update",
|
|
108
|
+
"description": "When data is updated but cached values aren't invalidated, users see stale data. This is especially insidious because it works 'sometimes' (when the cache expires naturally). Always identify all caches that need invalidation when changing underlying data.",
|
|
109
|
+
"severity": "medium",
|
|
110
|
+
"scar_type": "operational",
|
|
111
|
+
"counter_arguments": [
|
|
112
|
+
"Our cache TTL is short enough that staleness is acceptable — but even short TTLs cause confusion during testing and demos",
|
|
113
|
+
"We don't use caching in this part of the system — but CDNs, browser caches, and ORM-level caches are often invisible"
|
|
114
|
+
],
|
|
115
|
+
"keywords": ["cache", "invalidation", "stale-data", "ttl"],
|
|
116
|
+
"domain": ["caching", "data"],
|
|
117
|
+
"project": "default",
|
|
118
|
+
"source_date": "2026-01-01",
|
|
119
|
+
"created_at": "2026-01-01T00:00:00Z"
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"id": "00000000-0000-0000-0000-000000000008",
|
|
123
|
+
"learning_type": "scar",
|
|
124
|
+
"title": "Off-by-One Errors in Pagination",
|
|
125
|
+
"description": "Pagination logic is a common source of off-by-one errors: skipping the first item, duplicating items at page boundaries, or returning empty last pages. Always test pagination with 0 items, 1 item, exactly page-size items, and page-size + 1 items.",
|
|
126
|
+
"severity": "medium",
|
|
127
|
+
"scar_type": "verification",
|
|
128
|
+
"counter_arguments": [
|
|
129
|
+
"Our pagination uses a well-tested library — but the integration between your offset/cursor logic and the library is where bugs hide",
|
|
130
|
+
"We tested with a few pages and it works — but edge cases at boundaries and with concurrent modifications are where pagination breaks"
|
|
131
|
+
],
|
|
132
|
+
"keywords": ["pagination", "off-by-one", "cursor", "offset", "boundary"],
|
|
133
|
+
"domain": ["api", "data"],
|
|
134
|
+
"project": "default",
|
|
135
|
+
"source_date": "2026-01-01",
|
|
136
|
+
"created_at": "2026-01-01T00:00:00Z"
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
"id": "00000000-0000-0000-0000-000000000009",
|
|
140
|
+
"learning_type": "scar",
|
|
141
|
+
"title": "Timezone Bugs Between Server and Client",
|
|
142
|
+
"description": "Timezone handling between server (usually UTC) and client (user's local timezone) is a frequent source of bugs. Dates that 'look right' in development (same timezone) break for users in different timezones. Always store dates as UTC and convert only at the display layer.",
|
|
143
|
+
"severity": "medium",
|
|
144
|
+
"scar_type": "operational",
|
|
145
|
+
"counter_arguments": [
|
|
146
|
+
"We already use UTC everywhere — but date libraries and database functions sometimes apply local timezone implicitly",
|
|
147
|
+
"Our users are all in one timezone — but that assumption breaks when the product grows or developers travel"
|
|
148
|
+
],
|
|
149
|
+
"keywords": ["timezone", "utc", "date", "time", "client-server"],
|
|
150
|
+
"domain": ["frontend", "backend", "data"],
|
|
151
|
+
"project": "default",
|
|
152
|
+
"source_date": "2026-01-01",
|
|
153
|
+
"created_at": "2026-01-01T00:00:00Z"
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
"id": "00000000-0000-0000-0000-000000000010",
|
|
157
|
+
"learning_type": "scar",
|
|
158
|
+
"title": "Silent Error Swallowing Hides Real Failures",
|
|
159
|
+
"description": "Empty catch blocks and generic error handlers that log but don't surface errors lead to silent failures. The system appears to work while data is lost or corrupted. At minimum, log errors with enough context to diagnose the issue. Better: fail visibly so problems are caught early.",
|
|
160
|
+
"severity": "high",
|
|
161
|
+
"scar_type": "operational",
|
|
162
|
+
"counter_arguments": [
|
|
163
|
+
"We catch errors to prevent crashes — but catching without handling is worse than crashing because the problem is hidden",
|
|
164
|
+
"The error is non-critical so swallowing it is fine — but 'non-critical' errors compound and mask the root cause of critical issues"
|
|
165
|
+
],
|
|
166
|
+
"keywords": ["error-handling", "catch", "silent-failure", "logging"],
|
|
167
|
+
"domain": ["error-handling", "debugging"],
|
|
168
|
+
"project": "default",
|
|
169
|
+
"source_date": "2026-01-01",
|
|
170
|
+
"created_at": "2026-01-01T00:00:00Z"
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
"id": "00000000-0000-0000-0000-000000000011",
|
|
174
|
+
"learning_type": "scar",
|
|
175
|
+
"title": "Long-Lived Feature Branches Create Merge Hell",
|
|
176
|
+
"description": "Feature branches that diverge from main for more than a few days accumulate merge conflicts and integration issues. The longer a branch lives, the harder and riskier the merge. Break large features into small, mergeable increments behind feature flags if needed.",
|
|
177
|
+
"severity": "medium",
|
|
178
|
+
"scar_type": "process",
|
|
179
|
+
"counter_arguments": [
|
|
180
|
+
"This feature is too big to merge incrementally — but that means the feature should be broken into smaller deliverables",
|
|
181
|
+
"We'll merge when it's fully done to avoid shipping incomplete features — but feature flags solve this without the merge risk"
|
|
182
|
+
],
|
|
183
|
+
"keywords": ["git", "branch", "merge", "conflict", "feature-flag"],
|
|
184
|
+
"domain": ["git", "process"],
|
|
185
|
+
"project": "default",
|
|
186
|
+
"source_date": "2026-01-01",
|
|
187
|
+
"created_at": "2026-01-01T00:00:00Z"
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
"id": "00000000-0000-0000-0000-000000000012",
|
|
191
|
+
"learning_type": "scar",
|
|
192
|
+
"title": "Premature Abstraction Increases Complexity",
|
|
193
|
+
"description": "Creating abstractions, helpers, and shared utilities before you have at least 3 concrete use cases leads to wrong abstractions that are harder to change than duplicated code. Wait until patterns emerge naturally. Three similar implementations reveal the right abstraction; one guess rarely does.",
|
|
194
|
+
"severity": "medium",
|
|
195
|
+
"scar_type": "architectural",
|
|
196
|
+
"counter_arguments": [
|
|
197
|
+
"DRY principle says we should never duplicate code — but WET (Write Everything Twice) is better than wrong abstractions",
|
|
198
|
+
"Good architecture means planning ahead — but over-engineering for hypothetical futures wastes time and adds complexity"
|
|
199
|
+
],
|
|
200
|
+
"keywords": ["abstraction", "dry", "complexity", "over-engineering", "refactoring"],
|
|
201
|
+
"domain": ["architecture", "design"],
|
|
202
|
+
"project": "default",
|
|
203
|
+
"source_date": "2026-01-01",
|
|
204
|
+
"created_at": "2026-01-01T00:00:00Z"
|
|
205
|
+
}
|
|
206
|
+
]
|