git-memory 0.1.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/LICENSE +661 -0
- package/config/mcp_config_example.json +16 -0
- package/dist/chroma-index.d.ts +63 -0
- package/dist/chroma-index.d.ts.map +1 -0
- package/dist/chroma-index.js +166 -0
- package/dist/chroma-index.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +311 -0
- package/dist/cli.js.map +1 -0
- package/dist/context-store.d.ts +54 -0
- package/dist/context-store.d.ts.map +1 -0
- package/dist/context-store.js +187 -0
- package/dist/context-store.js.map +1 -0
- package/dist/embeddings.d.ts +10 -0
- package/dist/embeddings.d.ts.map +1 -0
- package/dist/embeddings.js +42 -0
- package/dist/embeddings.js.map +1 -0
- package/dist/filters.d.ts +70 -0
- package/dist/filters.d.ts.map +1 -0
- package/dist/filters.js +131 -0
- package/dist/filters.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/indexer.d.ts +45 -0
- package/dist/indexer.d.ts.map +1 -0
- package/dist/indexer.js +242 -0
- package/dist/indexer.js.map +1 -0
- package/dist/mcp-server.d.ts +8 -0
- package/dist/mcp-server.d.ts.map +1 -0
- package/dist/mcp-server.js +373 -0
- package/dist/mcp-server.js.map +1 -0
- package/dist/store.d.ts +17 -0
- package/dist/store.d.ts.map +1 -0
- package/dist/store.js +47 -0
- package/dist/store.js.map +1 -0
- package/dist/types.d.ts +59 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +25 -0
- package/dist/types.js.map +1 -0
- package/dist/vector-store.d.ts +65 -0
- package/dist/vector-store.d.ts.map +1 -0
- package/dist/vector-store.js +152 -0
- package/dist/vector-store.js.map +1 -0
- package/package.json +52 -0
- package/skills/git-memory-debug/SKILL.md +99 -0
- package/skills/git-memory-index/SKILL.md +88 -0
- package/skills/git-memory-search/SKILL.md +92 -0
- package/skills/git-memory-status/SKILL.md +69 -0
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { join } from 'path';
|
|
2
|
+
import { VectorCollection } from './vector-store.js';
|
|
3
|
+
const DB_FILENAME = 'git_commit_context.db';
|
|
4
|
+
export class ContextStore {
|
|
5
|
+
col;
|
|
6
|
+
llm;
|
|
7
|
+
llmModel;
|
|
8
|
+
constructor(col, llm, llmModel) {
|
|
9
|
+
this.col = col;
|
|
10
|
+
this.llm = llm;
|
|
11
|
+
this.llmModel = llmModel;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Async factory — opens (or creates) the local SQLite context store and detects LLM availability.
|
|
15
|
+
* LLM detection order (matches Python _default_mem0_config() priority):
|
|
16
|
+
* 1. OPENAI_API_KEY set → use OpenAI gpt-4o-mini
|
|
17
|
+
* 2. otherwise → attempt Ollama at OLLAMA_URL
|
|
18
|
+
* 3. Ollama fails → llm = null (graceful degradation)
|
|
19
|
+
*/
|
|
20
|
+
static async create(config, embedFn) {
|
|
21
|
+
const dbPath = join(config.contextDir, DB_FILENAME);
|
|
22
|
+
const col = VectorCollection.open(dbPath, 'git_commit_context', embedFn);
|
|
23
|
+
let llm = null;
|
|
24
|
+
if (config.openaiApiKey) {
|
|
25
|
+
try {
|
|
26
|
+
const { default: OpenAI } = await import('openai');
|
|
27
|
+
const openaiClient = new OpenAI({ apiKey: config.openaiApiKey });
|
|
28
|
+
llm = { type: 'openai', client: openaiClient };
|
|
29
|
+
}
|
|
30
|
+
catch (e) {
|
|
31
|
+
process.stderr.write(`ContextStore: OpenAI init failed — Layer 2 disabled: ${e}\n`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
try {
|
|
36
|
+
const { Ollama } = await import('ollama');
|
|
37
|
+
const ollamaClient = new Ollama({ host: config.ollamaUrl });
|
|
38
|
+
// Quick connectivity test
|
|
39
|
+
await ollamaClient.list();
|
|
40
|
+
llm = { type: 'ollama', client: ollamaClient };
|
|
41
|
+
}
|
|
42
|
+
catch (e) {
|
|
43
|
+
process.stderr.write(`ContextStore: Ollama unavailable — Layer 2 (LLM context) disabled: ${e}\n`);
|
|
44
|
+
process.stderr.write(` To enable: install and start Ollama (https://ollama.com) or set OPENAI_API_KEY\n`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return new ContextStore(col, llm, config.llmModel);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Extract LLM interpretation and store it.
|
|
51
|
+
* Mirrors Python: memory.add(messages=[{"role":"user","content":summary}], metadata)
|
|
52
|
+
*
|
|
53
|
+
* Flow:
|
|
54
|
+
* 1. If llm is null → no-op (graceful degradation)
|
|
55
|
+
* 2. Dedup check — skip if hash already stored
|
|
56
|
+
* 3. Extract 1–2 sentence interpretation via LLM
|
|
57
|
+
* 4. Store extracted text + metadata in collection
|
|
58
|
+
*/
|
|
59
|
+
async addCommit(params) {
|
|
60
|
+
if (this.llm === null)
|
|
61
|
+
return;
|
|
62
|
+
try {
|
|
63
|
+
if (this.col.has(params.hash))
|
|
64
|
+
return;
|
|
65
|
+
const interpretation = await this.extractContext(params.summary);
|
|
66
|
+
await this.col.add({
|
|
67
|
+
id: params.hash,
|
|
68
|
+
document: interpretation,
|
|
69
|
+
metadata: {
|
|
70
|
+
commit_hash: params.hash,
|
|
71
|
+
short_hash: params.metadata.short_hash,
|
|
72
|
+
author_name: params.metadata.author_name,
|
|
73
|
+
author_email: params.metadata.author_email,
|
|
74
|
+
committed_date: params.metadata.committed_date,
|
|
75
|
+
category: params.metadata.category,
|
|
76
|
+
repo: params.metadata.repo,
|
|
77
|
+
files_str: params.metadata.files_str,
|
|
78
|
+
date_str: params.metadata.date_str,
|
|
79
|
+
user_id: params.userId,
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
catch (e) {
|
|
84
|
+
process.stderr.write(`ContextStore.addCommit failed for ${params.hash.slice(0, 8)}: ${e}\n`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Semantic search on extracted context collection.
|
|
89
|
+
* Returns CommitRecord[] with the LLM interpretation as the summary field.
|
|
90
|
+
*/
|
|
91
|
+
async search(params) {
|
|
92
|
+
try {
|
|
93
|
+
const count = this.col.count();
|
|
94
|
+
if (count === 0)
|
|
95
|
+
return [];
|
|
96
|
+
const nResults = Math.min(params.limit, Math.max(1, count));
|
|
97
|
+
const raw = await this.col.query({
|
|
98
|
+
queryTexts: [params.query],
|
|
99
|
+
nResults,
|
|
100
|
+
});
|
|
101
|
+
return formatQueryResults(raw);
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
return [];
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Get all stored context entries (for latest_commits enrichment map).
|
|
109
|
+
* Matches Python: mem.get_all(user_id=USER_ID)
|
|
110
|
+
*/
|
|
111
|
+
async getAll(_userId) {
|
|
112
|
+
try {
|
|
113
|
+
const raw = this.col.get({});
|
|
114
|
+
return formatGetResults(raw);
|
|
115
|
+
}
|
|
116
|
+
catch {
|
|
117
|
+
return [];
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
/** Whether LLM context extraction is available. */
|
|
121
|
+
get isActive() {
|
|
122
|
+
return this.llm !== null;
|
|
123
|
+
}
|
|
124
|
+
// ── Private ──────────────────────────────────────────────────────────────────
|
|
125
|
+
/**
|
|
126
|
+
* Call LLM to extract a concise interpretation of a commit.
|
|
127
|
+
* Prompt matches spirit of mem0's extraction: brief, why-focused.
|
|
128
|
+
*/
|
|
129
|
+
async extractContext(summary) {
|
|
130
|
+
const prompt = `Summarize in 1-2 sentences what this commit achieves and why it matters:\n\n${summary}`;
|
|
131
|
+
if (this.llm?.type === 'openai') {
|
|
132
|
+
const response = await this.llm.client.chat.completions.create({
|
|
133
|
+
model: 'gpt-4o-mini',
|
|
134
|
+
messages: [
|
|
135
|
+
{ role: 'system', content: 'You extract concise commit interpretations for a code search index.' },
|
|
136
|
+
{ role: 'user', content: prompt },
|
|
137
|
+
],
|
|
138
|
+
max_tokens: 120,
|
|
139
|
+
temperature: 0,
|
|
140
|
+
});
|
|
141
|
+
return response.choices[0]?.message?.content?.trim() ?? summary;
|
|
142
|
+
}
|
|
143
|
+
if (this.llm?.type === 'ollama') {
|
|
144
|
+
const response = await this.llm.client.chat({
|
|
145
|
+
model: this.llmModel,
|
|
146
|
+
messages: [
|
|
147
|
+
{ role: 'system', content: 'You extract concise commit interpretations for a code search index.' },
|
|
148
|
+
{ role: 'user', content: prompt },
|
|
149
|
+
],
|
|
150
|
+
});
|
|
151
|
+
return response.message?.content?.trim() ?? summary;
|
|
152
|
+
}
|
|
153
|
+
return summary;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
// ── Helpers ───────────────────────────────────────────────────────────────────
|
|
157
|
+
function formatQueryResults(raw) {
|
|
158
|
+
const ids = raw.ids?.[0] ?? [];
|
|
159
|
+
const docs = raw.documents?.[0] ?? [];
|
|
160
|
+
const metas = raw.metadatas?.[0] ?? [];
|
|
161
|
+
const dists = raw.distances?.[0] ?? [];
|
|
162
|
+
return ids.map((hash, i) => ({
|
|
163
|
+
commit_hash: String(metas[i]?.commit_hash ?? hash),
|
|
164
|
+
short_hash: String(metas[i]?.short_hash ?? hash.slice(0, 8)),
|
|
165
|
+
author: String(metas[i]?.author_name ?? 'unknown'),
|
|
166
|
+
date: String(metas[i]?.committed_date ?? ''),
|
|
167
|
+
category: String(metas[i]?.category ?? 'general'),
|
|
168
|
+
files_changed: String(metas[i]?.files_str ?? '').split('|').filter(Boolean),
|
|
169
|
+
summary: docs[i] ?? '',
|
|
170
|
+
relevance_score: Math.round((1.0 - (dists[i] ?? 1.0)) * 10000) / 10000,
|
|
171
|
+
source: 'context',
|
|
172
|
+
}));
|
|
173
|
+
}
|
|
174
|
+
function formatGetResults(raw) {
|
|
175
|
+
return raw.ids.map((hash, i) => ({
|
|
176
|
+
commit_hash: String(raw.metadatas[i]?.commit_hash ?? hash),
|
|
177
|
+
short_hash: String(raw.metadatas[i]?.short_hash ?? ''),
|
|
178
|
+
author: String(raw.metadatas[i]?.author_name ?? ''),
|
|
179
|
+
date: String(raw.metadatas[i]?.committed_date ?? ''),
|
|
180
|
+
category: String(raw.metadatas[i]?.category ?? 'general'),
|
|
181
|
+
files_changed: String(raw.metadatas[i]?.files_str ?? '').split('|').filter(Boolean),
|
|
182
|
+
summary: raw.documents[i] ?? '',
|
|
183
|
+
relevance_score: 0,
|
|
184
|
+
source: 'context',
|
|
185
|
+
}));
|
|
186
|
+
}
|
|
187
|
+
//# sourceMappingURL=context-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-store.js","sourceRoot":"","sources":["../src/context-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAIrD,MAAM,WAAW,GAAG,uBAAuB,CAAC;AAM5C,MAAM,OAAO,YAAY;IACf,GAAG,CAAmB;IACtB,GAAG,CAAmB;IACtB,QAAQ,CAAS;IAEzB,YAAoB,GAAqB,EAAE,GAAqB,EAAE,QAAgB;QAChF,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAuB,EAAE,OAA2B;QACtE,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;QACpD,MAAM,GAAG,GAAG,gBAAgB,CAAC,IAAI,CAAC,MAAM,EAAE,oBAAoB,EAAE,OAAO,CAAC,CAAC;QAEzE,IAAI,GAAG,GAAqB,IAAI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AAS,CAAC,CAAC,CAAC,EAAE,cAAc,IAAI,EAAE,CAAC;QAC/D,QAAQ,EAAS,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,IAAU,SAAS,CAAmB;QACxF,aAAa,EAAI,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,IAAS,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC;QAC1F,OAAO,EAAU,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,EAAE;QACvC,eAAe,EAAE,CAAC;QAClB,MAAM,EAAW,SAAS;KAC3B,CAAC,CAAC,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { EmbedProvider } from './types.js';
|
|
2
|
+
export interface IEmbeddingFunction {
|
|
3
|
+
generate(texts: string[]): Promise<number[][]>;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Factory — returns a ChromaDB-compatible embedding function.
|
|
7
|
+
* Provider priority mirrors Python chroma_index.py _build_embedding_function().
|
|
8
|
+
*/
|
|
9
|
+
export declare function createEmbeddingFunction(provider: EmbedProvider, model: string, ollamaUrl: string, openaiApiKey?: string): Promise<IEmbeddingFunction>;
|
|
10
|
+
//# sourceMappingURL=embeddings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"embeddings.d.ts","sourceRoot":"","sources":["../src/embeddings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;CAChD;AAED;;;GAGG;AACH,wBAAsB,uBAAuB,CAC3C,QAAQ,EAAE,aAAa,EACvB,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,EACjB,YAAY,CAAC,EAAE,MAAM,GACpB,OAAO,CAAC,kBAAkB,CAAC,CAqC7B"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Factory — returns a ChromaDB-compatible embedding function.
|
|
3
|
+
* Provider priority mirrors Python chroma_index.py _build_embedding_function().
|
|
4
|
+
*/
|
|
5
|
+
export async function createEmbeddingFunction(provider, model, ollamaUrl, openaiApiKey) {
|
|
6
|
+
if (provider === 'openai') {
|
|
7
|
+
const { OpenAIEmbeddingFunction } = await import('chromadb');
|
|
8
|
+
if (!openaiApiKey)
|
|
9
|
+
throw new Error('OPENAI_API_KEY is required for openai embed provider');
|
|
10
|
+
return new OpenAIEmbeddingFunction({
|
|
11
|
+
openai_api_key: openaiApiKey,
|
|
12
|
+
openai_model: model || 'text-embedding-3-small',
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
if (provider === 'fastembed') {
|
|
16
|
+
const { FlagEmbedding, EmbeddingModel } = await import('fastembed');
|
|
17
|
+
// Use BGESmallENV15 as default; caller can pass any EmbeddingModel key
|
|
18
|
+
const modelKey = (model in EmbeddingModel)
|
|
19
|
+
? EmbeddingModel[model]
|
|
20
|
+
: EmbeddingModel.BGESmallENV15;
|
|
21
|
+
const embedder = await FlagEmbedding.init({ model: modelKey });
|
|
22
|
+
return {
|
|
23
|
+
generate: async (texts) => {
|
|
24
|
+
const result = [];
|
|
25
|
+
for await (const batch of embedder.embed(texts)) {
|
|
26
|
+
// batch is Float32Array[] or number[][] depending on version
|
|
27
|
+
for (const vec of batch) {
|
|
28
|
+
result.push(Array.from(vec));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return result;
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
// Default: ollama
|
|
36
|
+
const { OllamaEmbeddingFunction } = await import('chromadb');
|
|
37
|
+
return new OllamaEmbeddingFunction({
|
|
38
|
+
url: `${ollamaUrl}/api/embeddings`,
|
|
39
|
+
model: model || 'nomic-embed-text',
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=embeddings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"embeddings.js","sourceRoot":"","sources":["../src/embeddings.ts"],"names":[],"mappings":"AAMA;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,QAAuB,EACvB,KAAa,EACb,SAAiB,EACjB,YAAqB;IAErB,IAAI,QAAQ,KAAK,QAAQ,EAAE,CAAC;QAC1B,MAAM,EAAE,uBAAuB,EAAE,GAAG,MAAM,MAAM,CAAC,UAAU,CAAC,CAAC;QAC7D,IAAI,CAAC,YAAY;YAAE,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;QAC3F,OAAO,IAAI,uBAAuB,CAAC;YACjC,cAAc,EAAE,YAAY;YAC5B,YAAY,EAAE,KAAK,IAAI,wBAAwB;SAChD,CAAkC,CAAC;IACtC,CAAC;IAED,IAAI,QAAQ,KAAK,WAAW,EAAE,CAAC;QAC7B,MAAM,EAAE,aAAa,EAAE,cAAc,EAAE,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC,CAAC;QACpE,uEAAuE;QACvE,MAAM,QAAQ,GAAG,CAAC,KAAK,IAAI,cAAc,CAAC;YACxC,CAAC,CAAC,cAAc,CAAC,KAAoC,CAAC;YACtD,CAAC,CAAC,cAAc,CAAC,aAAa,CAAC;QACjC,MAAM,QAAQ,GAAG,MAAM,aAAa,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;QAC/D,OAAO;YACL,QAAQ,EAAE,KAAK,EAAE,KAAe,EAAuB,EAAE;gBACvD,MAAM,MAAM,GAAe,EAAE,CAAC;gBAC9B,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;oBAChD,6DAA6D;oBAC7D,KAAK,MAAM,GAAG,IAAI,KAA+C,EAAE,CAAC;wBAClE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;oBAC/B,CAAC;gBACH,CAAC;gBACD,OAAO,MAAM,CAAC;YAChB,CAAC;SACF,CAAC;IACJ,CAAC;IAED,kBAAkB;IAClB,MAAM,EAAE,uBAAuB,EAAE,GAAG,MAAM,MAAM,CAAC,UAAU,CAAC,CAAC;IAC7D,OAAO,IAAI,uBAAuB,CAAC;QACjC,GAAG,EAAE,GAAG,SAAS,iBAAiB;QAClC,KAAK,EAAE,KAAK,IAAI,kBAAkB;KACnC,CAAkC,CAAC;AACtC,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { CommitCategory, IndexMetadata } from './types.js';
|
|
2
|
+
export declare const MAX_FILES_PER_COMMIT = 20;
|
|
3
|
+
/**
|
|
4
|
+
* Signal keywords that make a commit worth indexing.
|
|
5
|
+
* Exact set from Python filters.py RELEVANT_KEYWORDS.
|
|
6
|
+
*/
|
|
7
|
+
export declare const RELEVANT_KEYWORDS: Set<string>;
|
|
8
|
+
/**
|
|
9
|
+
* True if commit message contains at least one signal keyword.
|
|
10
|
+
* Exact port of Python is_relevant().
|
|
11
|
+
*/
|
|
12
|
+
export declare function isRelevant(message: string): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* First keyword match → category. Falls back to 'general'.
|
|
15
|
+
* Exact port of Python build_metadata() category logic.
|
|
16
|
+
*/
|
|
17
|
+
export declare function categorize(message: string): CommitCategory;
|
|
18
|
+
/**
|
|
19
|
+
* Build the searchable document text stored in ChromaDB.
|
|
20
|
+
* Exact format from Python _build_document():
|
|
21
|
+
*
|
|
22
|
+
* {message}
|
|
23
|
+
* Author: {name} <{email}>
|
|
24
|
+
* Date: {YYYY-MM-DD}
|
|
25
|
+
* Stats: {stats_str}
|
|
26
|
+
* Files: {comma-separated or "none"}
|
|
27
|
+
*/
|
|
28
|
+
export declare function buildDocument(message: string, authorName: string, authorEmail: string, dateStr: string, statsStr: string, files: string[]): string;
|
|
29
|
+
/**
|
|
30
|
+
* Build the 6-line LLM-readable summary for ContextStore (Layer 2).
|
|
31
|
+
* Exact format from Python summarize_commit():
|
|
32
|
+
*
|
|
33
|
+
* Commit: {hash}
|
|
34
|
+
* Author: {name} <{email}>
|
|
35
|
+
* Date: {YYYY-MM-DD HH:MM UTC}
|
|
36
|
+
* Message: {message}
|
|
37
|
+
* Stats: +{ins}/-{del} lines across {n} file(s)
|
|
38
|
+
* Files changed: {comma-separated or "none"}
|
|
39
|
+
*/
|
|
40
|
+
export declare function summarizeCommit(params: {
|
|
41
|
+
hash: string;
|
|
42
|
+
authorName: string;
|
|
43
|
+
authorEmail: string;
|
|
44
|
+
date: Date;
|
|
45
|
+
message: string;
|
|
46
|
+
insertions: number;
|
|
47
|
+
deletions: number;
|
|
48
|
+
fileCount: number;
|
|
49
|
+
files: string[];
|
|
50
|
+
}): string;
|
|
51
|
+
/**
|
|
52
|
+
* Build structured metadata dict stored alongside the commit.
|
|
53
|
+
* Exact port of Python build_metadata().
|
|
54
|
+
* Returns IndexMetadata (superset of CommitMetadata).
|
|
55
|
+
*/
|
|
56
|
+
export declare function buildMetadata(params: {
|
|
57
|
+
hash: string;
|
|
58
|
+
authorName: string;
|
|
59
|
+
authorEmail: string;
|
|
60
|
+
date: Date;
|
|
61
|
+
message: string;
|
|
62
|
+
files: string[];
|
|
63
|
+
repoName: string;
|
|
64
|
+
}): IndexMetadata;
|
|
65
|
+
/**
|
|
66
|
+
* Build stats string from insertions/deletions.
|
|
67
|
+
* Format: "+100/-50 lines" — used in buildDocument().
|
|
68
|
+
*/
|
|
69
|
+
export declare function buildStatsStr(insertions: number, deletions: number): string;
|
|
70
|
+
//# sourceMappingURL=filters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filters.d.ts","sourceRoot":"","sources":["../src/filters.ts"],"names":[],"mappings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E,SAAS,EAAE,MAAM,GAAG,MAAM,CAE3E"}
|
package/dist/filters.js
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
export const MAX_FILES_PER_COMMIT = 20;
|
|
2
|
+
/**
|
|
3
|
+
* Signal keywords that make a commit worth indexing.
|
|
4
|
+
* Exact set from Python filters.py RELEVANT_KEYWORDS.
|
|
5
|
+
*/
|
|
6
|
+
export const RELEVANT_KEYWORDS = new Set([
|
|
7
|
+
'fix', 'bug', 'refactor', 'security', 'arch', 'architecture',
|
|
8
|
+
'perf', 'performance', 'breaking', 'migrate', 'migration',
|
|
9
|
+
'deprecat', 'revert', 'feat', 'feature', 'design', 'restructure',
|
|
10
|
+
'upgrade', 'downgrade', 'critical', 'hotfix', 'patch', 'chore',
|
|
11
|
+
]);
|
|
12
|
+
/**
|
|
13
|
+
* Ordered pairs for category detection.
|
|
14
|
+
* IMPORTANT: order matches Python tuple exactly — first match wins.
|
|
15
|
+
* ("fix", "bug", "security", "refactor", "perf", "performance",
|
|
16
|
+
* "arch", "feature", "feat", "migration", "revert")
|
|
17
|
+
*/
|
|
18
|
+
const CATEGORY_ORDER = [
|
|
19
|
+
['fix', 'fix'],
|
|
20
|
+
['bug', 'fix'],
|
|
21
|
+
['security', 'security'],
|
|
22
|
+
['refactor', 'refactor'],
|
|
23
|
+
['perf', 'perf'],
|
|
24
|
+
['performance', 'perf'],
|
|
25
|
+
['arch', 'arch'],
|
|
26
|
+
['feature', 'feat'],
|
|
27
|
+
['feat', 'feat'],
|
|
28
|
+
['migration', 'migration'],
|
|
29
|
+
['revert', 'fix'],
|
|
30
|
+
];
|
|
31
|
+
/**
|
|
32
|
+
* True if commit message contains at least one signal keyword.
|
|
33
|
+
* Exact port of Python is_relevant().
|
|
34
|
+
*/
|
|
35
|
+
export function isRelevant(message) {
|
|
36
|
+
const lowered = message.toLowerCase();
|
|
37
|
+
for (const kw of RELEVANT_KEYWORDS) {
|
|
38
|
+
if (lowered.includes(kw))
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* First keyword match → category. Falls back to 'general'.
|
|
45
|
+
* Exact port of Python build_metadata() category logic.
|
|
46
|
+
*/
|
|
47
|
+
export function categorize(message) {
|
|
48
|
+
const lowered = message.toLowerCase();
|
|
49
|
+
for (const [kw, cat] of CATEGORY_ORDER) {
|
|
50
|
+
if (lowered.includes(kw))
|
|
51
|
+
return cat;
|
|
52
|
+
}
|
|
53
|
+
return 'general';
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Build the searchable document text stored in ChromaDB.
|
|
57
|
+
* Exact format from Python _build_document():
|
|
58
|
+
*
|
|
59
|
+
* {message}
|
|
60
|
+
* Author: {name} <{email}>
|
|
61
|
+
* Date: {YYYY-MM-DD}
|
|
62
|
+
* Stats: {stats_str}
|
|
63
|
+
* Files: {comma-separated or "none"}
|
|
64
|
+
*/
|
|
65
|
+
export function buildDocument(message, authorName, authorEmail, dateStr, statsStr, files) {
|
|
66
|
+
const filesDisplay = files.length > 0 ? files.join(', ') : 'none';
|
|
67
|
+
return [
|
|
68
|
+
message.trim(),
|
|
69
|
+
`Author: ${authorName} <${authorEmail}>`,
|
|
70
|
+
`Date: ${dateStr}`,
|
|
71
|
+
`Stats: ${statsStr}`,
|
|
72
|
+
`Files: ${filesDisplay}`,
|
|
73
|
+
].join('\n');
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Build the 6-line LLM-readable summary for ContextStore (Layer 2).
|
|
77
|
+
* Exact format from Python summarize_commit():
|
|
78
|
+
*
|
|
79
|
+
* Commit: {hash}
|
|
80
|
+
* Author: {name} <{email}>
|
|
81
|
+
* Date: {YYYY-MM-DD HH:MM UTC}
|
|
82
|
+
* Message: {message}
|
|
83
|
+
* Stats: +{ins}/-{del} lines across {n} file(s)
|
|
84
|
+
* Files changed: {comma-separated or "none"}
|
|
85
|
+
*/
|
|
86
|
+
export function summarizeCommit(params) {
|
|
87
|
+
const dateStr = params.date
|
|
88
|
+
.toISOString()
|
|
89
|
+
.replace('T', ' ')
|
|
90
|
+
.replace(/\.\d+Z$/, ' UTC');
|
|
91
|
+
const filesDisplay = params.files.length > 0 ? params.files.join(', ') : 'none';
|
|
92
|
+
const statsStr = `+${params.insertions}/-${params.deletions} lines across ${params.fileCount} file(s)`;
|
|
93
|
+
return [
|
|
94
|
+
`Commit: ${params.hash}`,
|
|
95
|
+
`Author: ${params.authorName} <${params.authorEmail}>`,
|
|
96
|
+
`Date: ${dateStr}`,
|
|
97
|
+
`Message: ${params.message.trim()}`,
|
|
98
|
+
`Stats: ${statsStr}`,
|
|
99
|
+
`Files changed: ${filesDisplay}`,
|
|
100
|
+
].join('\n');
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Build structured metadata dict stored alongside the commit.
|
|
104
|
+
* Exact port of Python build_metadata().
|
|
105
|
+
* Returns IndexMetadata (superset of CommitMetadata).
|
|
106
|
+
*/
|
|
107
|
+
export function buildMetadata(params) {
|
|
108
|
+
const dateIso = params.date.toISOString();
|
|
109
|
+
const files = params.files.slice(0, MAX_FILES_PER_COMMIT);
|
|
110
|
+
return {
|
|
111
|
+
type: 'git_commit',
|
|
112
|
+
repo: params.repoName,
|
|
113
|
+
commit_hash: params.hash,
|
|
114
|
+
short_hash: params.hash.slice(0, 8),
|
|
115
|
+
author_name: params.authorName,
|
|
116
|
+
author_email: params.authorEmail,
|
|
117
|
+
committed_date: dateIso,
|
|
118
|
+
category: categorize(params.message),
|
|
119
|
+
files_changed: files,
|
|
120
|
+
files_str: files.join('|'),
|
|
121
|
+
date_str: dateIso.slice(0, 10),
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Build stats string from insertions/deletions.
|
|
126
|
+
* Format: "+100/-50 lines" — used in buildDocument().
|
|
127
|
+
*/
|
|
128
|
+
export function buildStatsStr(insertions, deletions) {
|
|
129
|
+
return `+${insertions}/-${delet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
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* git-memory — Semantic Git history index for Claude Code
|
|
3
|
+
* Node.js port of claude-memory (Python)
|
|
4
|
+
*
|
|
5
|
+
* Public API matches Python __init__.py exports.
|
|
6
|
+
*/
|
|
7
|
+
export { ChromaCommitIndex } from './chroma-index.js';
|
|
8
|
+
export { GitMemoryIndexer } from './indexer.js';
|
|
9
|
+
export { ContextStore } from './context-store.js';
|
|
10
|
+
export { storeCommit } from './store.js';
|
|
11
|
+
export { isRelevant, categorize, buildMetadata, buildDocument, summarizeCommit, buildStatsStr, RELEVANT_KEYWORDS, MAX_FILES_PER_COMMIT, } from './filters.js';
|
|
12
|
+
export { createEmbeddingFunction, type IEmbeddingFunction, } from './embeddings.js';
|
|
13
|
+
export { configFromEnv, type CommitRecord, type CommitMetadata, type IndexMetadata, type CommitCategory, type IndexStats, type EmbedProvider, type GitMemoryConfig, } from './types.js';
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC,OAAO,EACL,UAAU,EACV,UAAU,EACV,aAAa,EACb,aAAa,EACb,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,uBAAuB,EACvB,KAAK,kBAAkB,GACxB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,aAAa,EACb,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,KAAK,eAAe,GACrB,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* git-memory — Semantic Git history index for Claude Code
|
|
3
|
+
* Node.js port of claude-memory (Python)
|
|
4
|
+
*
|
|
5
|
+
* Public API matches Python __init__.py exports.
|
|
6
|
+
*/
|
|
7
|
+
export { ChromaCommitIndex } from './chroma-index.js';
|
|
8
|
+
export { GitMemoryIndexer } from './indexer.js';
|
|
9
|
+
export { ContextStore } from './context-store.js';
|
|
10
|
+
export { storeCommit } from './store.js';
|
|
11
|
+
export { isRelevant, categorize, buildMetadata, buildDocument, summarizeCommit, buildStatsStr, RELEVANT_KEYWORDS, MAX_FILES_PER_COMMIT, } from './filters.js';
|
|
12
|
+
export { createEmbeddingFunction, } from './embeddings.js';
|
|
13
|
+
export { configFromEnv, } from './types.js';
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC,OAAO,EACL,UAAU,EACV,UAAU,EACV,aAAa,EACb,aAAa,EACb,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,uBAAuB,GAExB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,aAAa,GAQd,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ChromaCommitIndex } from './chroma-index.js';
|
|
2
|
+
import { type GitMemoryConfig, type IndexStats } from './types.js';
|
|
3
|
+
export declare class GitMemoryIndexer {
|
|
4
|
+
private git;
|
|
5
|
+
private repoName;
|
|
6
|
+
private chromaIndex;
|
|
7
|
+
private contextStore;
|
|
8
|
+
private userId;
|
|
9
|
+
private constructor();
|
|
10
|
+
/** Async factory — initialises git, ChromaDB (Layer 1), and ContextStore (Layer 2). */
|
|
11
|
+
static create(config: GitMemoryConfig): Promise<GitMemoryIndexer>;
|
|
12
|
+
/** Convenience factory using environment variables. */
|
|
13
|
+
static fromEnv(): Promise<GitMemoryIndexer>;
|
|
14
|
+
/**
|
|
15
|
+
* Index a single commit by hash.
|
|
16
|
+
* Matches Python index_commit() exactly:
|
|
17
|
+
* 1. Get commit details
|
|
18
|
+
* 2. isRelevant() check — skip if false (unless force)
|
|
19
|
+
* 3. Build metadata + document
|
|
20
|
+
* 4. Layer 1: chromaIndex.upsertCommit() — returns false if duplicate
|
|
21
|
+
* 5. If Layer 1 returned false and !force → return false
|
|
22
|
+
* 6. Layer 2: contextStore.addCommit() — no-throw
|
|
23
|
+
* 7. Return true
|
|
24
|
+
*/
|
|
25
|
+
indexCommit(hash: string, force?: boolean): Promise<boolean>;
|
|
26
|
+
/**
|
|
27
|
+
* Index all commits on a branch.
|
|
28
|
+
* Matches Python index_all() exactly:
|
|
29
|
+
* - Iterates commits, skips irrelevant, logs progress every 100
|
|
30
|
+
* - Returns IndexStats
|
|
31
|
+
*/
|
|
32
|
+
indexAll(params?: {
|
|
33
|
+
branch?: string;
|
|
34
|
+
limit?: number;
|
|
35
|
+
dryRun?: boolean;
|
|
36
|
+
}): Promise<IndexStats>;
|
|
37
|
+
/**
|
|
38
|
+
* Get full commit details via git show + diff-tree.
|
|
39
|
+
* Uses git show for author/date/message, diff-tree for exact file list.
|
|
40
|
+
*/
|
|
41
|
+
private getCommitDetails;
|
|
42
|
+
get name(): string;
|
|
43
|
+
get chroma(): ChromaCommitIndex;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=indexer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"indexer.d.ts","sourceRoot":"","sources":["../src/indexer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAItD,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,UAAU,EAAiB,MAAM,YAAY,CAAC;AAclF,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,GAAG,CAAY;IACvB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,WAAW,CAAoB;IACvC,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,MAAM,CAAS;IAEvB,OAAO;IAcP,uFAAuF;WAC1E,MAAM,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAwBvE,uDAAuD;WAC1C,OAAO,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAIjD;;;;;;;;;;OAUG;IACG,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,UAAQ,GAAG,OAAO,CAAC,OAAO,CAAC;IAoEhE;;;;;OAKG;IACG,QAAQ,CAAC,MAAM,GAAE;QACrB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,OAAO,CAAC;KACb,GAAG,OAAO,CAAC,UAAU,CAAC;IA+D5B;;;OAGG;YACW,gBAAgB;IAuD9B,IAAI,IAAI,IAAI,MAAM,CAA0B;IAC5C,IAAI,MAAM,IAAI,iBAAiB,CAA6B;CAC7D"}
|