@andrebuzeli/git-mcp 13.6.0 → 13.7.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/package.json +1 -1
- package/src/index.js +11 -0
- package/src/providers/providerManager.js +24 -0
- package/src/utils/gitAdapter.js +11 -0
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -19,6 +19,10 @@ import { createGitSyncTool } from "./tools/git-sync.js";
|
|
|
19
19
|
import { createGitIssuesTool } from "./tools/git-issues.js";
|
|
20
20
|
import { createGitPullsTool } from "./tools/git-pulls.js";
|
|
21
21
|
|
|
22
|
+
// #region agent log
|
|
23
|
+
const debugLog = (loc, msg, data) => { fetch('http://127.0.0.1:8242/ingest/e5799a4a-1a0d-4201-a6ce-42835e6f6fc7',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:loc,message:msg,data,timestamp:Date.now(),sessionId:'debug-session'})}).catch(()=>{}); };
|
|
24
|
+
// #endregion
|
|
25
|
+
|
|
22
26
|
const transport = new StdioServerTransport();
|
|
23
27
|
const server = new Server({ name: "git-mcpv2", version: "0.0.0" });
|
|
24
28
|
server.connect(transport);
|
|
@@ -66,6 +70,10 @@ server.setRequestHandler(
|
|
|
66
70
|
const tool = tools.find(t => t.name === name);
|
|
67
71
|
if (!tool) return { content: [{ type: "text", text: `Tool não encontrada: ${name}` }], isError: true };
|
|
68
72
|
try {
|
|
73
|
+
// #region agent log
|
|
74
|
+
const startTime = Date.now();
|
|
75
|
+
debugLog('index.js:call', `START ${name}`, { action: args.action, projectPath: args.projectPath, hypothesisId: 'A' });
|
|
76
|
+
// #endregion
|
|
69
77
|
if (progressToken) {
|
|
70
78
|
await server.notification({ method: "notifications/progress", params: { progressToken, progress: 0 } });
|
|
71
79
|
}
|
|
@@ -73,6 +81,9 @@ server.setRequestHandler(
|
|
|
73
81
|
if (progressToken) {
|
|
74
82
|
await server.notification({ method: "notifications/progress", params: { progressToken, progress: 100 } });
|
|
75
83
|
}
|
|
84
|
+
// #region agent log
|
|
85
|
+
debugLog('index.js:call', `END ${name}`, { duration: Date.now() - startTime, hypothesisId: 'A' });
|
|
86
|
+
// #endregion
|
|
76
87
|
return result;
|
|
77
88
|
} catch (e) {
|
|
78
89
|
return asToolError(e.code || "ERROR", e.message || String(e));
|
|
@@ -2,6 +2,10 @@ import { Octokit } from "@octokit/rest";
|
|
|
2
2
|
import axios from "axios";
|
|
3
3
|
import { getProvidersEnv } from "../utils/repoHelpers.js";
|
|
4
4
|
|
|
5
|
+
// #region agent log
|
|
6
|
+
const debugLog = (loc, msg, data) => { fetch('http://127.0.0.1:8242/ingest/e5799a4a-1a0d-4201-a6ce-42835e6f6fc7',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:loc,message:msg,data,timestamp:Date.now(),sessionId:'debug-session'})}).catch(()=>{}); };
|
|
7
|
+
// #endregion
|
|
8
|
+
|
|
5
9
|
export class ProviderManager {
|
|
6
10
|
constructor() {
|
|
7
11
|
const { githubToken, giteaUrl, giteaToken } = getProvidersEnv();
|
|
@@ -18,12 +22,22 @@ export class ProviderManager {
|
|
|
18
22
|
if (!this.github) return "";
|
|
19
23
|
const now = Date.now();
|
|
20
24
|
if (this._githubOwner && now - this._ownerFetchedAt < 5 * 60 * 1000) return this._githubOwner;
|
|
25
|
+
// #region agent log
|
|
26
|
+
const t0 = Date.now();
|
|
27
|
+
debugLog('providerManager.js:getGitHubOwner', 'START API call', { hypothesisId: 'B' });
|
|
28
|
+
// #endregion
|
|
21
29
|
try {
|
|
22
30
|
const me = await this.github.rest.users.getAuthenticated();
|
|
23
31
|
this._githubOwner = me.data.login || "";
|
|
24
32
|
this._ownerFetchedAt = now;
|
|
33
|
+
// #region agent log
|
|
34
|
+
debugLog('providerManager.js:getGitHubOwner', 'END API call', { duration: Date.now() - t0, owner: this._githubOwner, hypothesisId: 'B' });
|
|
35
|
+
// #endregion
|
|
25
36
|
return this._githubOwner;
|
|
26
37
|
} catch {
|
|
38
|
+
// #region agent log
|
|
39
|
+
debugLog('providerManager.js:getGitHubOwner', 'FAILED API call', { duration: Date.now() - t0, hypothesisId: 'B' });
|
|
40
|
+
// #endregion
|
|
27
41
|
return "";
|
|
28
42
|
}
|
|
29
43
|
}
|
|
@@ -32,6 +46,10 @@ export class ProviderManager {
|
|
|
32
46
|
if (!this.giteaUrl || !this.giteaToken) return "";
|
|
33
47
|
const now = Date.now();
|
|
34
48
|
if (this._giteaOwner && now - this._ownerFetchedAt < 5 * 60 * 1000) return this._giteaOwner;
|
|
49
|
+
// #region agent log
|
|
50
|
+
const t0 = Date.now();
|
|
51
|
+
debugLog('providerManager.js:getGiteaOwner', 'START API call', { hypothesisId: 'B' });
|
|
52
|
+
// #endregion
|
|
35
53
|
try {
|
|
36
54
|
const r = await axios.get(`${this.giteaUrl}/api/v1/user`, {
|
|
37
55
|
headers: { Authorization: `token ${this.giteaToken}` },
|
|
@@ -40,8 +58,14 @@ export class ProviderManager {
|
|
|
40
58
|
const d = r.data || {};
|
|
41
59
|
this._giteaOwner = d.login || d.username || "";
|
|
42
60
|
this._ownerFetchedAt = now;
|
|
61
|
+
// #region agent log
|
|
62
|
+
debugLog('providerManager.js:getGiteaOwner', 'END API call', { duration: Date.now() - t0, owner: this._giteaOwner, hypothesisId: 'B' });
|
|
63
|
+
// #endregion
|
|
43
64
|
return this._giteaOwner;
|
|
44
65
|
} catch {
|
|
66
|
+
// #region agent log
|
|
67
|
+
debugLog('providerManager.js:getGiteaOwner', 'FAILED API call', { duration: Date.now() - t0, hypothesisId: 'B' });
|
|
68
|
+
// #endregion
|
|
45
69
|
return "";
|
|
46
70
|
}
|
|
47
71
|
}
|
package/src/utils/gitAdapter.js
CHANGED
|
@@ -6,6 +6,10 @@ import { MCPError, createError, mapExternalError } from "./errors.js";
|
|
|
6
6
|
import { getProvidersEnv } from "./repoHelpers.js";
|
|
7
7
|
import { withRetry } from "./retry.js";
|
|
8
8
|
|
|
9
|
+
// #region agent log
|
|
10
|
+
const debugLog = (loc, msg, data) => { fetch('http://127.0.0.1:8242/ingest/e5799a4a-1a0d-4201-a6ce-42835e6f6fc7',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:loc,message:msg,data,timestamp:Date.now(),sessionId:'debug-session'})}).catch(()=>{}); };
|
|
11
|
+
// #endregion
|
|
12
|
+
|
|
9
13
|
export class GitAdapter {
|
|
10
14
|
constructor(providerManager) {
|
|
11
15
|
this.pm = providerManager;
|
|
@@ -16,7 +20,14 @@ export class GitAdapter {
|
|
|
16
20
|
}
|
|
17
21
|
|
|
18
22
|
async status(dir) {
|
|
23
|
+
// #region agent log
|
|
24
|
+
const t0 = Date.now();
|
|
25
|
+
debugLog('gitAdapter.js:status', 'START statusMatrix', { dir, hypothesisId: 'A' });
|
|
26
|
+
// #endregion
|
|
19
27
|
const matrix = await git.statusMatrix({ fs, dir });
|
|
28
|
+
// #region agent log
|
|
29
|
+
debugLog('gitAdapter.js:status', 'END statusMatrix', { duration: Date.now() - t0, fileCount: matrix.length, hypothesisId: 'A' });
|
|
30
|
+
// #endregion
|
|
20
31
|
const FILE = 0, HEAD = 1, WORKDIR = 2, STAGE = 3;
|
|
21
32
|
const modified = [], created = [], deleted = [], not_added = [], files = [];
|
|
22
33
|
for (const row of matrix) {
|