contextgit 0.1.4 → 0.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.
Files changed (29) hide show
  1. package/bin/contextgit-mcp.js +7 -0
  2. package/package.json +6 -9
  3. package/node_modules/@contextgit/mcp/dist/auto-snapshot.d.ts +0 -30
  4. package/node_modules/@contextgit/mcp/dist/auto-snapshot.d.ts.map +0 -1
  5. package/node_modules/@contextgit/mcp/dist/auto-snapshot.js +0 -68
  6. package/node_modules/@contextgit/mcp/dist/auto-snapshot.js.map +0 -1
  7. package/node_modules/@contextgit/mcp/dist/config.d.ts +0 -17
  8. package/node_modules/@contextgit/mcp/dist/config.d.ts.map +0 -1
  9. package/node_modules/@contextgit/mcp/dist/config.js +0 -48
  10. package/node_modules/@contextgit/mcp/dist/config.js.map +0 -1
  11. package/node_modules/@contextgit/mcp/dist/git-sync.d.ts +0 -15
  12. package/node_modules/@contextgit/mcp/dist/git-sync.d.ts.map +0 -1
  13. package/node_modules/@contextgit/mcp/dist/git-sync.js +0 -87
  14. package/node_modules/@contextgit/mcp/dist/git-sync.js.map +0 -1
  15. package/node_modules/@contextgit/mcp/dist/index.d.ts +0 -3
  16. package/node_modules/@contextgit/mcp/dist/index.d.ts.map +0 -1
  17. package/node_modules/@contextgit/mcp/dist/index.js +0 -17
  18. package/node_modules/@contextgit/mcp/dist/index.js.map +0 -1
  19. package/node_modules/@contextgit/mcp/dist/server.d.ts +0 -3
  20. package/node_modules/@contextgit/mcp/dist/server.d.ts.map +0 -1
  21. package/node_modules/@contextgit/mcp/dist/server.js +0 -377
  22. package/node_modules/@contextgit/mcp/dist/server.js.map +0 -1
  23. package/node_modules/@contextgit/mcp/package.json +0 -31
  24. package/node_modules/@contextgit/mcp/src/auto-snapshot.ts +0 -83
  25. package/node_modules/@contextgit/mcp/src/config.ts +0 -53
  26. package/node_modules/@contextgit/mcp/src/git-sync.ts +0 -94
  27. package/node_modules/@contextgit/mcp/src/index.ts +0 -19
  28. package/node_modules/@contextgit/mcp/src/server.ts +0 -568
  29. package/node_modules/@contextgit/mcp/tsconfig.json +0 -9
@@ -1,377 +0,0 @@
1
- // server.ts — ContextGit MCP Server
2
- //
3
- // Exposes tools to Claude and other MCP clients:
4
- // project_memory_load — return a formatted project snapshot
5
- // project_memory_save — persist a context commit
6
- // context_search — full-text search over past commits
7
- // project_memory_branch — create a context branch
8
- // project_task_claim — claim a task
9
- // project_task_unclaim — release a claimed task
10
- // project_memory_merge — merge a context branch
11
- //
12
- // Transport: stdio (launched by the MCP host, e.g. Claude Desktop / Claude Code)
13
- //
14
- // Initialization (per server process):
15
- // 1. Load .contextgit/config.json (search from CWD upward)
16
- // 2. Open LocalStore for projectId
17
- // 3. Detect current git branch via simple-git
18
- // 4. Resolve (or create) the context branch for that git branch
19
- // 5. Build ContextEngine, call engine.init()
20
- import os from 'os';
21
- import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
22
- import { z } from 'zod';
23
- import { simpleGit } from 'simple-git';
24
- import { ContextEngine, EmbeddingService, SnapshotFormatter } from '@contextgit/core';
25
- import { LocalStore, RemoteStore, SupabaseStore, resolveDbPath } from '@contextgit/store';
26
- import { loadConfig } from './config.js';
27
- import { captureGitMetadata } from './git-sync.js';
28
- import { AutoSnapshotManager } from './auto-snapshot.js';
29
- // ─── Helpers ──────────────────────────────────────────────────────────────────
30
- async function detectGitBranch() {
31
- try {
32
- const git = simpleGit(process.cwd());
33
- const result = await git.revparse(['--abbrev-ref', 'HEAD']);
34
- return result.trim();
35
- }
36
- catch {
37
- return 'main';
38
- }
39
- }
40
- /**
41
- * Resolve the ContextGit branch that tracks `gitBranch`.
42
- * Creates one if it doesn't exist yet.
43
- */
44
- async function resolveContextBranch(store, projectId, gitBranch) {
45
- const existing = await store.getBranchByGitName(projectId, gitBranch);
46
- if (existing)
47
- return existing.id;
48
- const created = await store.createBranch({
49
- projectId,
50
- name: `Context: ${gitBranch}`,
51
- gitBranch,
52
- });
53
- return created.id;
54
- }
55
- async function bootstrap() {
56
- const config = loadConfig();
57
- const { projectId, configDir } = config;
58
- const store = config.store && config.store !== 'local'
59
- ? new RemoteStore(config.store)
60
- : new LocalStore(projectId, resolveDbPath(projectId, configDir));
61
- // Ensure the project row exists before creating branches (FK constraint)
62
- const existing = await store.getProject(projectId);
63
- if (!existing) {
64
- await store.createProject({ id: projectId, name: config.project });
65
- }
66
- const gitBranch = await detectGitBranch();
67
- const branchId = await resolveContextBranch(store, projectId, gitBranch);
68
- const hostname = os.hostname();
69
- const agentId = process.env['CONTEXTGIT_AGENT_ID'] ?? `${hostname}-mcp-claude-code-interactive`;
70
- const engine = new ContextEngine(store, agentId, config.agentRole ?? 'solo', 'claude-code', config.workflowType ?? 'interactive', { embeddingService: new EmbeddingService() });
71
- await engine.init(projectId, branchId);
72
- let claimsStore = store; // default: same as primary store
73
- if (config.supabaseUrl) {
74
- // Env var is preferred; fall back to config file for VS Code extension
75
- // env injection bug (https://github.com/anthropics/claude-code/issues/28090)
76
- const key = process.env['SUPABASE_SERVICE_KEY'] ?? config.supabaseServiceKey;
77
- if (key) {
78
- claimsStore = new SupabaseStore(config.supabaseUrl, key);
79
- }
80
- }
81
- return { engine, store, claimsStore, projectId, branchId, config, agentId };
82
- }
83
- // ─── Tool definitions ─────────────────────────────────────────────────────────
84
- export async function createServer() {
85
- const ctx = await bootstrap();
86
- const autoSnapshot = new AutoSnapshotManager(ctx.engine, {
87
- interval: ctx.config.snapshotInterval ?? 10,
88
- });
89
- const server = new McpServer({
90
- name: 'contextgit',
91
- version: '0.0.1',
92
- });
93
- // ── project_memory_load (was: context_get) ──────────────────────────────────
94
- const handleProjectMemoryLoad = async ({ format, agent_role, since, }) => {
95
- await autoSnapshot.onToolCall('context_get');
96
- try {
97
- if (since !== undefined) {
98
- const delta = await ctx.store.getContextDelta(ctx.projectId, ctx.branchId, since);
99
- return {
100
- content: [{ type: 'text', text: JSON.stringify(delta, null, 2) }],
101
- };
102
- }
103
- const snapshot = await ctx.store.getSessionSnapshot(ctx.projectId, ctx.branchId, agent_role ? { agentRole: agent_role } : undefined);
104
- // If claimsStore is different (Supabase configured), replace claims with live data
105
- if (ctx.claimsStore !== ctx.store) {
106
- snapshot.activeClaims = await ctx.claimsStore.listActiveClaims(ctx.projectId);
107
- }
108
- const text = new SnapshotFormatter().format(snapshot, format ?? 'agents-md');
109
- return {
110
- content: [{ type: 'text', text }],
111
- };
112
- }
113
- catch (err) {
114
- const message = err instanceof Error ? err.message : String(err);
115
- return {
116
- content: [{ type: 'text', text: `Error retrieving snapshot: ${message}` }],
117
- isError: true,
118
- };
119
- }
120
- };
121
- const projectMemoryLoadSchema = {
122
- scope: z.enum(['global', 'branch']).default('global').describe("'global' returns the full project summary + branch state. 'branch' scopes to the current branch."),
123
- format: z.enum(['agents-md', 'json', 'text']).default('agents-md').describe('Output format. agents-md is optimized for agent consumption.'),
124
- agent_role: z.enum(['orchestrator', 'dev', 'test', 'review', 'background', 'ci', 'solo']).optional().describe('Filter recentCommits to this agent role only. Omit to return commits from all roles.'),
125
- since: z.number().optional().describe('Unix timestamp ms. When provided, returns only commits and thread changes after this time. Use for orchestrator polling loops.'),
126
- };
127
- server.tool('project_memory_load', `Load persistent project memory and context.
128
-
129
- IMPORTANT: Call this tool at the START of every session — before reading files, before asking questions, before doing any work. This tool returns the project's current state including: what was built, what was decided, active tasks, claimed work, recent decisions, and open questions.
130
-
131
- Skipping this call means you will duplicate work that was already done, re-explore approaches that already failed, and contradict decisions that were already made.
132
-
133
- If you are a subagent working on a specific task, call this tool first to understand the full project context before starting your assigned work.`, projectMemoryLoadSchema, handleProjectMemoryLoad);
134
- // Backward-compat alias — remove in 0.0.6
135
- server.tool('context_get', 'DEPRECATED: Use project_memory_load instead. Retrieve the current project snapshot.', projectMemoryLoadSchema, async (params) => {
136
- console.warn('[contextgit] context_get is deprecated. Use project_memory_load.');
137
- return handleProjectMemoryLoad(params);
138
- });
139
- // ── project_memory_save (was: context_commit) ───────────────────────────────
140
- const handleProjectMemorySave = async ({ message, content, open_threads, close_thread_ids, }) => {
141
- await autoSnapshot.onToolCall('context_commit');
142
- try {
143
- const threads = {};
144
- if (open_threads?.length)
145
- threads.open = open_threads;
146
- if (close_thread_ids?.length) {
147
- threads.close = close_thread_ids.map(id => ({ id, note: 'Closed via context_commit' }));
148
- }
149
- const git = await captureGitMetadata(process.cwd());
150
- const commit = await ctx.engine.commit({
151
- message,
152
- content,
153
- gitCommitSha: git?.sha,
154
- ...(Object.keys(threads).length > 0 ? { threads } : {}),
155
- });
156
- return {
157
- content: [
158
- {
159
- type: 'text',
160
- text: `Commit recorded.\nID: ${commit.id}\nMessage: ${commit.message}`,
161
- },
162
- ],
163
- };
164
- }
165
- catch (err) {
166
- const message = err instanceof Error ? err.message : String(err);
167
- return {
168
- content: [{ type: 'text', text: `Error recording commit: ${message}` }],
169
- isError: true,
170
- };
171
- }
172
- };
173
- const projectMemorySaveSchema = {
174
- message: z.string().min(1).describe('Short summary of what was accomplished (1–2 sentences).'),
175
- content: z.string().min(1).describe('Detailed description of the work done, decisions made, and current state.'),
176
- open_threads: z.array(z.string()).optional().describe('New open questions or blockers to track (each max 200 chars).'),
177
- close_thread_ids: z.array(z.string()).optional().describe('IDs of threads to close.'),
178
- };
179
- server.tool('project_memory_save', `Save project memory after completing work.
180
-
181
- IMPORTANT: Call this tool BEFORE ending your session or moving to the next task. This saves what you did, what you decided, and what questions remain — so the next session (or the next agent) can pick up where you left off.
182
-
183
- If you skip this call, the next session starts blind. Your work will be invisible to future agents. They will re-do what you already did.
184
-
185
- Call after: completing a feature, making an architectural decision, resolving a bug, closing a thread, or finishing any meaningful unit of work. Small decisions compound — save them.`, projectMemorySaveSchema, handleProjectMemorySave);
186
- // Backward-compat alias — remove in 0.0.6
187
- server.tool('context_commit', 'DEPRECATED: Use project_memory_save instead. Persist a context commit recording significant work.', projectMemorySaveSchema, async (params) => {
188
- console.warn('[contextgit] context_commit is deprecated. Use project_memory_save.');
189
- return handleProjectMemorySave(params);
190
- });
191
- // ── context_search (unchanged) ──────────────────────────────────────────────
192
- server.tool('context_search', 'Search past context commits. Uses semantic + full-text search and merges results.', {
193
- query: z.string().min(1).describe('Search query — natural language or keywords.'),
194
- limit: z.number().int().min(1).max(20).default(5).describe('Maximum results to return.'),
195
- }, async ({ query, limit }) => {
196
- await autoSnapshot.onToolCall('context_search');
197
- try {
198
- const [semantic, fts] = await Promise.all([
199
- ctx.engine.semanticSearch(query, ctx.projectId, limit),
200
- ctx.store.fullTextSearch(query, ctx.projectId),
201
- ]);
202
- const seen = new Set();
203
- const merged = [...semantic, ...fts].filter(r => {
204
- if (seen.has(r.commit.id))
205
- return false;
206
- seen.add(r.commit.id);
207
- return true;
208
- });
209
- const trimmed = merged.slice(0, limit);
210
- if (trimmed.length === 0) {
211
- return {
212
- content: [{ type: 'text', text: 'No results found.' }],
213
- };
214
- }
215
- const formatted = trimmed
216
- .map((r, i) => `[${i + 1}] ${r.commit.message}\n` +
217
- ` ID: ${r.commit.id} Score: ${r.score.toFixed(3)}\n` +
218
- ` ${r.commit.content.slice(0, 200)}${r.commit.content.length > 200 ? '…' : ''}`)
219
- .join('\n\n');
220
- return {
221
- content: [{ type: 'text', text: formatted }],
222
- };
223
- }
224
- catch (err) {
225
- const message = err instanceof Error ? err.message : String(err);
226
- return {
227
- content: [{ type: 'text', text: `Error searching commits: ${message}` }],
228
- isError: true,
229
- };
230
- }
231
- });
232
- // ── project_memory_branch (was: context_branch) ─────────────────────────────
233
- const handleProjectMemoryBranch = async ({ git_branch, name, }) => {
234
- await autoSnapshot.onToolCall('context_branch');
235
- try {
236
- const branch = await ctx.engine.branch(git_branch, name);
237
- return {
238
- content: [
239
- {
240
- type: 'text',
241
- text: `Branch created.\nID: ${branch.id}\nName: ${branch.name}`,
242
- },
243
- ],
244
- };
245
- }
246
- catch (err) {
247
- const message = err instanceof Error ? err.message : String(err);
248
- return {
249
- content: [{ type: 'text', text: `Error creating branch: ${message}` }],
250
- isError: true,
251
- };
252
- }
253
- };
254
- const projectMemoryBranchSchema = {
255
- git_branch: z.string().min(1).describe('The git branch name to track.'),
256
- name: z.string().optional().describe('Optional display name for the context branch.'),
257
- };
258
- server.tool('project_memory_branch', `Create an isolated context branch before risky or experimental work.
259
-
260
- Call before: trying an approach you're not sure will work, refactoring across many files, or exploring an architectural alternative. If the exploration fails, the main context is untouched.
261
-
262
- The cost of not branching is re-explaining to the next session why you abandoned an approach you spent an hour on.`, projectMemoryBranchSchema, handleProjectMemoryBranch);
263
- // Backward-compat alias — remove in 0.0.6
264
- server.tool('context_branch', 'DEPRECATED: Use project_memory_branch instead. Create a new context branch tracking a git branch.', projectMemoryBranchSchema, async (params) => {
265
- console.warn('[contextgit] context_branch is deprecated. Use project_memory_branch.');
266
- return handleProjectMemoryBranch(params);
267
- });
268
- // ── project_task_claim (was: context_claim) ─────────────────────────────────
269
- const handleProjectTaskClaim = async ({ task, ttl_hours, status, for_agent_id, thread_id, }) => {
270
- await autoSnapshot.onToolCall('context_claim');
271
- try {
272
- const claim = await ctx.claimsStore.claimTask(ctx.projectId, ctx.branchId, {
273
- task,
274
- agentId: for_agent_id ?? ctx.agentId,
275
- role: ctx.config.agentRole ?? 'solo',
276
- status: status ?? 'proposed',
277
- ttl: Math.round((ttl_hours ?? 2) * 3_600_000),
278
- threadId: thread_id,
279
- });
280
- return {
281
- content: [
282
- {
283
- type: 'text',
284
- text: `Claim recorded.\nID: ${claim.id}\nTask: ${claim.task}\nStatus: ${claim.status}\nTTL: ${ttl_hours ?? 2}h`,
285
- },
286
- ],
287
- };
288
- }
289
- catch (err) {
290
- const message = err instanceof Error ? err.message : String(err);
291
- return {
292
- content: [{ type: 'text', text: `Error creating claim: ${message}` }],
293
- isError: true,
294
- };
295
- }
296
- };
297
- const projectTaskClaimSchema = {
298
- task: z.string().min(1).describe('Short description of the task being claimed (e.g. "build auth module").'),
299
- ttl_hours: z.number().positive().default(2).describe('Time-to-live in hours before the claim auto-expires. Default: 2.'),
300
- status: z.enum(['proposed', 'active']).default('proposed').describe("'proposed' for plan-mode claims; 'active' once approved and work begins."),
301
- for_agent_id: z.string().optional().describe('Claim on behalf of this agent ID (pre-claiming by orchestrator).'),
302
- thread_id: z.string().optional().describe('Direct thread ID link for this claim.'),
303
- };
304
- server.tool('project_task_claim', `Claim a task to prevent other agents from working on it simultaneously.
305
-
306
- Call before starting work on any task visible in the project memory. Other agents will see your claim and skip this task. Claims auto-expire after 2 hours.
307
-
308
- If you skip claiming, another agent may start the same task, producing duplicate and conflicting work.`, projectTaskClaimSchema, handleProjectTaskClaim);
309
- // Backward-compat alias — remove in 0.0.6
310
- server.tool('context_claim', 'DEPRECATED: Use project_task_claim instead. Claim a task to prevent other agents from picking it up simultaneously.', projectTaskClaimSchema, async (params) => {
311
- console.warn('[contextgit] context_claim is deprecated. Use project_task_claim.');
312
- return handleProjectTaskClaim(params);
313
- });
314
- // ── project_task_unclaim (was: context_unclaim) ──────────────────────────────
315
- const handleProjectTaskUnclaim = async ({ claim_id }) => {
316
- await autoSnapshot.onToolCall('context_unclaim');
317
- try {
318
- await ctx.claimsStore.unclaimTask(claim_id);
319
- return {
320
- content: [{ type: 'text', text: `Claim released.\nID: ${claim_id}` }],
321
- };
322
- }
323
- catch (err) {
324
- const message = err instanceof Error ? err.message : String(err);
325
- return {
326
- content: [{ type: 'text', text: `Error releasing claim: ${message}` }],
327
- isError: true,
328
- };
329
- }
330
- };
331
- const projectTaskUnclaimSchema = {
332
- claim_id: z.string().min(1).describe('ID of the claim to release.'),
333
- };
334
- server.tool('project_task_unclaim', `Release a previously claimed task so other agents can work on it.
335
-
336
- Call when: abandoning a task you claimed (won't be completing it), or when re-assigning work. If you claimed a task and won't complete it, release it — otherwise it blocks other agents until the 2-hour TTL expires.`, projectTaskUnclaimSchema, handleProjectTaskUnclaim);
337
- // Backward-compat alias — remove in 0.0.6
338
- server.tool('context_unclaim', 'DEPRECATED: Use project_task_unclaim instead. Release a previously claimed task.', projectTaskUnclaimSchema, async (params) => {
339
- console.warn('[contextgit] context_unclaim is deprecated. Use project_task_unclaim.');
340
- return handleProjectTaskUnclaim(params);
341
- });
342
- // ── project_memory_merge (was: context_merge) ───────────────────────────────
343
- const handleProjectMemoryMerge = async ({ source_branch_id }) => {
344
- await autoSnapshot.onToolCall('context_merge');
345
- try {
346
- const commit = await ctx.engine.merge(source_branch_id);
347
- return {
348
- content: [
349
- {
350
- type: 'text',
351
- text: `Merge commit recorded.\nID: ${commit.id}`,
352
- },
353
- ],
354
- };
355
- }
356
- catch (err) {
357
- const message = err instanceof Error ? err.message : String(err);
358
- return {
359
- content: [{ type: 'text', text: `Error merging branch: ${message}` }],
360
- isError: true,
361
- };
362
- }
363
- };
364
- const projectMemoryMergeSchema = {
365
- source_branch_id: z.string().min(1).describe('ID of the context branch to merge in.'),
366
- };
367
- server.tool('project_memory_merge', `Merge a context branch back into the parent branch after successful exploration.
368
-
369
- Call after a context branch experiment succeeds and you want to preserve the findings in the main project memory.`, projectMemoryMergeSchema, handleProjectMemoryMerge);
370
- // Backward-compat alias — remove in 0.0.6
371
- server.tool('context_merge', 'DEPRECATED: Use project_memory_merge instead. Merge a source context branch into the current branch.', projectMemoryMergeSchema, async (params) => {
372
- console.warn('[contextgit] context_merge is deprecated. Use project_memory_merge.');
373
- return handleProjectMemoryMerge(params);
374
- });
375
- return server;
376
- }
377
- //# sourceMappingURL=server.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,EAAE;AACF,iDAAiD;AACjD,gEAAgE;AAChE,qDAAqD;AACrD,+DAA+D;AAC/D,oDAAoD;AACpD,yCAAyC;AACzC,mDAAmD;AACnD,mDAAmD;AACnD,EAAE;AACF,iFAAiF;AACjF,EAAE;AACF,uCAAuC;AACvC,6DAA6D;AAC7D,qCAAqC;AACrC,gDAAgD;AAChD,kEAAkE;AAClE,+CAA+C;AAE/C,OAAO,EAAE,MAAM,IAAI,CAAA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F,CAAA;IAED,OAAO,MAAM,CAAA;AACf,CAAC"}
@@ -1,31 +0,0 @@
1
- {
2
- "name": "@contextgit/mcp",
3
- "version": "0.1.4",
4
- "type": "module",
5
- "main": "./dist/index.js",
6
- "types": "./dist/index.d.ts",
7
- "exports": {
8
- ".": {
9
- "import": "./dist/index.js",
10
- "types": "./dist/index.d.ts"
11
- }
12
- },
13
- "bin": {
14
- "contextgit-mcp": "./dist/index.js"
15
- },
16
- "scripts": {
17
- "build": "tsc",
18
- "typecheck": "tsc --noEmit"
19
- },
20
- "dependencies": {
21
- "@contextgit/core": "0.1.4",
22
- "@contextgit/store": "0.1.4",
23
- "@modelcontextprotocol/sdk": "^1.0.0",
24
- "simple-git": "^3.27.0",
25
- "zod": "^3.23.0"
26
- },
27
- "devDependencies": {
28
- "@types/node": "^20.0.0",
29
- "typescript": "^5.4.0"
30
- }
31
- }
@@ -1,83 +0,0 @@
1
- // auto-snapshot.ts — AutoSnapshotManager
2
- //
3
- // Tracks tool calls made to the MCP server and fires an automatic context_commit
4
- // after every N=10 non-commit calls. This ensures context is preserved even when
5
- // the agent forgets to call context_commit manually.
6
- //
7
- // Context tool semantics:
8
- // context_commit → resets the counter (manual commit = checkpoint reached)
9
- // context_get → counted (each session-start snapshot counts toward the interval)
10
- // context_search → counted
11
- // any other tool → counted (future tools)
12
-
13
- import type { ContextEngine } from '@contextgit/core'
14
-
15
- export interface AutoSnapshotOptions {
16
- /** Number of non-commit tool calls before an auto-commit fires. Default: 10. */
17
- interval?: number
18
- }
19
-
20
- export class AutoSnapshotManager {
21
- private count = 0
22
- private readonly interval: number
23
- private readonly engine: ContextEngine
24
-
25
- constructor(engine: ContextEngine, options: AutoSnapshotOptions = {}) {
26
- this.engine = engine
27
- this.interval = options.interval ?? 10
28
- }
29
-
30
- /**
31
- * Record a tool call by name.
32
- *
33
- * - `context_commit` resets the counter (manual commit; no auto-commit fired).
34
- * - All other tool names increment the counter.
35
- * - When the counter reaches `interval`, an auto-commit is fired and the
36
- * counter resets to 0.
37
- *
38
- * Auto-commit failures are swallowed — the tool call is never blocked.
39
- *
40
- * @returns The new commit ID if an auto-commit was fired, otherwise undefined.
41
- */
42
- async onToolCall(toolName: string): Promise<string | undefined> {
43
- if (toolName === 'context_commit') {
44
- this.count = 0
45
- return undefined
46
- }
47
-
48
- this.count++
49
-
50
- if (this.count >= this.interval) {
51
- this.count = 0
52
- return this.fireAutoCommit()
53
- }
54
-
55
- return undefined
56
- }
57
-
58
- /** Current tool-call count since the last commit (manual or auto). */
59
- get toolCallCount(): number {
60
- return this.count
61
- }
62
-
63
- /** Manually reset the counter (e.g. after an out-of-band commit). */
64
- reset(): void {
65
- this.count = 0
66
- }
67
-
68
- // ─── Private ──────────────────────────────────────────────────────────────
69
-
70
- private async fireAutoCommit(): Promise<string | undefined> {
71
- try {
72
- const commit = await this.engine.commit({
73
- message: `Auto-snapshot after ${this.interval} tool calls`,
74
- content: `Automatic context checkpoint triggered after ${this.interval} tool calls without a manual context_commit.`,
75
- commitType: 'auto',
76
- })
77
- return commit.id
78
- } catch {
79
- // Never block a tool call due to auto-snapshot failure.
80
- return undefined
81
- }
82
- }
83
- }
@@ -1,53 +0,0 @@
1
- // config.ts — load and validate .contextgit/config.json
2
- // Searches from CWD upwards until it finds the config file.
3
-
4
- import { readFileSync } from 'fs'
5
- import { join, dirname } from 'path'
6
- import type { ContextGitConfig } from '@contextgit/core'
7
-
8
- export class ConfigNotFoundError extends Error {
9
- constructor(startDir: string) {
10
- super(`No .contextgit/config.json found searching upward from: ${startDir}`)
11
- this.name = 'ConfigNotFoundError'
12
- }
13
- }
14
-
15
- /**
16
- * Search upward from `startDir` for `.contextgit/config.json`.
17
- * Returns the first match found, or throws ConfigNotFoundError.
18
- */
19
- export function findConfigPath(startDir: string = process.cwd()): string {
20
- let current = startDir
21
- while (true) {
22
- const candidate = join(current, '.contextgit', 'config.json')
23
- try {
24
- readFileSync(candidate)
25
- return candidate
26
- } catch {
27
- const parent = dirname(current)
28
- if (parent === current) {
29
- throw new ConfigNotFoundError(startDir)
30
- }
31
- current = parent
32
- }
33
- }
34
- }
35
-
36
- /**
37
- * Load and parse `.contextgit/config.json`.
38
- * Throws ConfigNotFoundError if not found, or Error if JSON is invalid.
39
- */
40
- export function loadConfig(startDir?: string): ContextGitConfig & { configDir: string } {
41
- const configPath = findConfigPath(startDir)
42
- const raw = readFileSync(configPath, 'utf-8')
43
- const config = JSON.parse(raw) as ContextGitConfig
44
-
45
- if (!config.projectId) {
46
- throw new Error(`Invalid config at ${configPath}: missing required field 'projectId'`)
47
- }
48
- if (!config.project) {
49
- throw new Error(`Invalid config at ${configPath}: missing required field 'project'`)
50
- }
51
-
52
- return { ...config, configDir: dirname(configPath) }
53
- }
@@ -1,94 +0,0 @@
1
- // git-sync.ts — git metadata capture and hook installation.
2
- //
3
- // captureGitMetadata: used by context_commit (MCP) and commit CLI command to
4
- // auto-populate gitCommitSha on every context commit.
5
- //
6
- // installGitHooks: idempotent hook installer — writes post-commit,
7
- // post-checkout, post-merge scripts into .git/hooks/.
8
-
9
- import { writeFileSync, readFileSync, mkdirSync, existsSync, appendFileSync } from 'fs'
10
- import { join, resolve } from 'path'
11
- import { homedir } from 'os'
12
- import { simpleGit } from 'simple-git'
13
-
14
- const SENTINEL = '# contextgit'
15
- const HOOKS_LOG = join(homedir(), '.contextgit', 'hooks.log')
16
-
17
- // ─── captureGitMetadata ────────────────────────────────────────────────────────
18
-
19
- /**
20
- * Capture the current git commit SHA and branch name.
21
- * Returns null on any error — must never block a context commit.
22
- */
23
- export async function captureGitMetadata(
24
- cwd: string,
25
- ): Promise<{ sha: string; branch: string } | null> {
26
- try {
27
- const git = simpleGit(cwd)
28
- const [sha, branch] = await Promise.all([
29
- git.revparse(['HEAD']),
30
- git.revparse(['--abbrev-ref', 'HEAD']),
31
- ])
32
- return { sha: sha.trim(), branch: branch.trim() }
33
- } catch {
34
- return null
35
- }
36
- }
37
-
38
- // ─── installGitHooks ──────────────────────────────────────────────────────────
39
-
40
- const HOOK_SCRIPTS: Record<string, string> = {
41
- 'post-commit': `#!/bin/sh
42
- ${SENTINEL}
43
- contextgit commit -m "git: $(git log -1 --pretty=%s)" 2>>"${HOOKS_LOG}" || true
44
- `,
45
- 'post-checkout': `#!/bin/sh
46
- ${SENTINEL}
47
- contextgit context --quiet 2>>"${HOOKS_LOG}" || true
48
- `,
49
- 'post-merge': `#!/bin/sh
50
- ${SENTINEL}
51
- contextgit commit -m "Merged into $(git rev-parse --abbrev-ref HEAD)" 2>>"${HOOKS_LOG}" || true
52
- `,
53
- }
54
-
55
- /**
56
- * Install contextgit git hooks into <projectRoot>/.git/hooks/.
57
- * Idempotent: checks for the sentinel comment before appending.
58
- * Hook failures are logged to ~/.contextgit/hooks.log — never to stderr.
59
- */
60
- export async function installGitHooks(projectRoot: string): Promise<void> {
61
- const hooksDir = join(resolve(projectRoot), '.git', 'hooks')
62
- mkdirSync(hooksDir, { recursive: true })
63
-
64
- for (const [hookName, script] of Object.entries(HOOK_SCRIPTS)) {
65
- const hookPath = join(hooksDir, hookName)
66
-
67
- if (existsSync(hookPath)) {
68
- const existing = readFileSync(hookPath, 'utf-8')
69
- if (existing.includes(SENTINEL)) continue // already installed
70
- // Append to existing hook
71
- writeFileSync(hookPath, existing.trimEnd() + '\n\n' + script)
72
- } else {
73
- writeFileSync(hookPath, script)
74
- }
75
-
76
- // Make executable (chmod +x)
77
- try {
78
- const { chmodSync } = await import('fs')
79
- chmodSync(hookPath, 0o755)
80
- } catch {
81
- logHookError(`chmod failed for ${hookPath}`)
82
- }
83
- }
84
- }
85
-
86
- function logHookError(msg: string): void {
87
- try {
88
- const dir = join(homedir(), '.contextgit')
89
- mkdirSync(dir, { recursive: true })
90
- appendFileSync(HOOKS_LOG, `[${new Date().toISOString()}] ${msg}\n`)
91
- } catch {
92
- // truly silent
93
- }
94
- }