@imayuur/contexthub-git-integration 1.0.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/dist/index.d.ts +45 -0
- package/dist/index.js +93 -0
- package/package.json +54 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ContextHubCore } from '@imayuur/contexthub-core';
|
|
2
|
+
export declare class GitIntegration {
|
|
3
|
+
private core;
|
|
4
|
+
private git;
|
|
5
|
+
private repoPath;
|
|
6
|
+
constructor(core: ContextHubCore, repoPath: string);
|
|
7
|
+
/**
|
|
8
|
+
* Save a commit to memory.
|
|
9
|
+
*/
|
|
10
|
+
saveCommit(commit: {
|
|
11
|
+
hash: string;
|
|
12
|
+
message: string;
|
|
13
|
+
author: string;
|
|
14
|
+
date: string;
|
|
15
|
+
filesChanged: string[];
|
|
16
|
+
}): Promise<string>;
|
|
17
|
+
/**
|
|
18
|
+
* Get recent commits and save them to memory.
|
|
19
|
+
*/
|
|
20
|
+
processRecentCommits(limit?: number): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Get a summary of the git repository for context.
|
|
23
|
+
*/
|
|
24
|
+
getGitSummary(): Promise<{
|
|
25
|
+
currentBranch: string;
|
|
26
|
+
recentCommits: Array<{
|
|
27
|
+
hash: string;
|
|
28
|
+
message: string;
|
|
29
|
+
author: string;
|
|
30
|
+
date: string;
|
|
31
|
+
}>;
|
|
32
|
+
status: {
|
|
33
|
+
files: {
|
|
34
|
+
added: string[];
|
|
35
|
+
modified: string[];
|
|
36
|
+
deleted: string[];
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
}>;
|
|
40
|
+
/**
|
|
41
|
+
* Track changes in the working directory.
|
|
42
|
+
* Placeholder for future file watcher implementation.
|
|
43
|
+
*/
|
|
44
|
+
trackChanges(): Promise<void>;
|
|
45
|
+
}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.GitIntegration = void 0;
|
|
7
|
+
const simple_git_1 = __importDefault(require("simple-git"));
|
|
8
|
+
class GitIntegration {
|
|
9
|
+
constructor(core, repoPath) {
|
|
10
|
+
this.core = core;
|
|
11
|
+
this.repoPath = repoPath;
|
|
12
|
+
this.git = (0, simple_git_1.default)(repoPath);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Save a commit to memory.
|
|
16
|
+
*/
|
|
17
|
+
async saveCommit(commit) {
|
|
18
|
+
const memoryId = await this.core.saveMemory({
|
|
19
|
+
sessionId: 'git-integration', // We'll use a fixed session for git events
|
|
20
|
+
type: 'commit',
|
|
21
|
+
content: `Commit ${commit.hash}: ${commit.message}`,
|
|
22
|
+
timestamp: new Date(commit.date).getTime(),
|
|
23
|
+
tags: ['git', 'commit', ...commit.filesChanged.map((f) => `file:${f}`)]
|
|
24
|
+
});
|
|
25
|
+
return memoryId;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Get recent commits and save them to memory.
|
|
29
|
+
*/
|
|
30
|
+
async processRecentCommits(limit = 10) {
|
|
31
|
+
try {
|
|
32
|
+
const log = await this.git.log({ maxCount: limit });
|
|
33
|
+
for (const commit of log.all) {
|
|
34
|
+
await this.saveCommit({
|
|
35
|
+
hash: commit.hash,
|
|
36
|
+
message: commit.message,
|
|
37
|
+
author: commit.author_name,
|
|
38
|
+
date: commit.date,
|
|
39
|
+
filesChanged: []
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
console.error('Failed to process recent commits:', error?.message || 'unknown error');
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Get a summary of the git repository for context.
|
|
49
|
+
*/
|
|
50
|
+
async getGitSummary() {
|
|
51
|
+
try {
|
|
52
|
+
const [branchResult, logResult, statusResult] = await Promise.all([
|
|
53
|
+
this.git.branch(),
|
|
54
|
+
this.git.log({ maxCount: 10 }),
|
|
55
|
+
this.git.status()
|
|
56
|
+
]);
|
|
57
|
+
return {
|
|
58
|
+
currentBranch: branchResult.current,
|
|
59
|
+
recentCommits: logResult.all.map((commit) => ({
|
|
60
|
+
hash: commit.hash,
|
|
61
|
+
message: commit.message,
|
|
62
|
+
author: commit.author_name,
|
|
63
|
+
date: commit.date
|
|
64
|
+
})),
|
|
65
|
+
status: {
|
|
66
|
+
files: {
|
|
67
|
+
added: statusResult.files
|
|
68
|
+
.filter((file) => file.working_dir === '?' || file.index === 'A')
|
|
69
|
+
.map((file) => file.path),
|
|
70
|
+
modified: statusResult.files
|
|
71
|
+
.filter((file) => file.working_dir === 'M' || file.index === 'M')
|
|
72
|
+
.map((file) => file.path),
|
|
73
|
+
deleted: statusResult.files
|
|
74
|
+
.filter((file) => file.working_dir === 'D' || file.index === 'D')
|
|
75
|
+
.map((file) => file.path)
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
console.error('Failed to get git summary:', error?.message || 'unknown error');
|
|
82
|
+
throw error;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Track changes in the working directory.
|
|
87
|
+
* Placeholder for future file watcher implementation.
|
|
88
|
+
*/
|
|
89
|
+
async trackChanges() {
|
|
90
|
+
console.error('Tracking changes is not yet implemented.');
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
exports.GitIntegration = GitIntegration;
|
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@imayuur/contexthub-git-integration",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Git integration for ContextHub",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/iMayuuR/contexthub.git",
|
|
9
|
+
"directory": "packages/git-integration"
|
|
10
|
+
},
|
|
11
|
+
"publishConfig": {
|
|
12
|
+
"access": "public"
|
|
13
|
+
},
|
|
14
|
+
"engines": {
|
|
15
|
+
"node": ">=18"
|
|
16
|
+
},
|
|
17
|
+
"main": "dist/index.js",
|
|
18
|
+
"types": "dist/index.d.ts",
|
|
19
|
+
"files": [
|
|
20
|
+
"dist"
|
|
21
|
+
],
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "tsc",
|
|
24
|
+
"dev": "tsc --watch",
|
|
25
|
+
"prepublishOnly": "npm run build"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"simple-git": "^3.0.0",
|
|
29
|
+
"@imayuur/contexthub-core": "^1.0.0",
|
|
30
|
+
"@imayuur/contexthub-shared-types": "^1.0.0"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@types/node": "^18.0.0",
|
|
34
|
+
"typescript": "^5.0.0"
|
|
35
|
+
},
|
|
36
|
+
"author": "Mayur Dattatray Patil",
|
|
37
|
+
"bugs": {
|
|
38
|
+
"url": "https://github.com/iMayuuR/contexthub/issues"
|
|
39
|
+
},
|
|
40
|
+
"homepage": "https://github.com/iMayuuR/contexthub#readme",
|
|
41
|
+
"keywords": [
|
|
42
|
+
"contexthub",
|
|
43
|
+
"mcp",
|
|
44
|
+
"ai-memory",
|
|
45
|
+
"cursor",
|
|
46
|
+
"claude"
|
|
47
|
+
],
|
|
48
|
+
"exports": {
|
|
49
|
+
".": {
|
|
50
|
+
"types": "./dist/index.d.ts",
|
|
51
|
+
"default": "./dist/index.js"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|