@andrebuzeli/git-mcp 10.0.8 → 11.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.
Files changed (135) hide show
  1. package/README.md +34 -428
  2. package/bin/git-mcp.js +21 -0
  3. package/docs/TOOLS.md +110 -0
  4. package/mcp.json.template +12 -0
  5. package/package.json +9 -76
  6. package/src/local/git.js +14 -0
  7. package/src/providers/gitea.js +13 -0
  8. package/src/providers/github.js +13 -0
  9. package/src/server.js +63 -0
  10. package/src/tools/git-actions.js +19 -0
  11. package/src/tools/git-activity.js +28 -0
  12. package/src/tools/git-admin.js +20 -0
  13. package/src/tools/git-checks.js +14 -0
  14. package/src/tools/git-commits.js +34 -0
  15. package/src/tools/git-contents.js +30 -0
  16. package/src/tools/git-deployments.js +21 -0
  17. package/src/tools/git-gists.js +15 -0
  18. package/src/tools/git-gitdata.js +19 -0
  19. package/src/tools/git-issues-prs.js +44 -0
  20. package/src/tools/git-issues.js +12 -0
  21. package/src/tools/git-local.js +66 -0
  22. package/src/tools/git-meta.js +19 -0
  23. package/src/tools/git-misc.js +21 -0
  24. package/src/tools/git-orgs.js +26 -0
  25. package/src/tools/git-packages.js +12 -0
  26. package/src/tools/git-raw.js +14 -0
  27. package/src/tools/git-releases.js +17 -0
  28. package/src/tools/git-remote.js +29 -0
  29. package/src/tools/git-repos.js +60 -0
  30. package/src/tools/git-search.js +18 -0
  31. package/src/tools/git-sync.js +40 -0
  32. package/src/tools/git-user.js +26 -0
  33. package/src/tools/schema.js +3 -0
  34. package/src/utils/fs.js +29 -0
  35. package/src/utils/project.js +7 -0
  36. package/tests/errors.js +26 -0
  37. package/tests/full_suite.js +98 -0
  38. package/tests/run.js +50 -0
  39. package/LICENSE +0 -21
  40. package/dist/index.d.ts +0 -2
  41. package/dist/index.js +0 -224
  42. package/dist/prompts/gitPrompts.d.ts +0 -93
  43. package/dist/prompts/gitPrompts.js +0 -177
  44. package/dist/providers/giteaProvider.d.ts +0 -3
  45. package/dist/providers/giteaProvider.js +0 -6
  46. package/dist/providers/githubProvider.d.ts +0 -2
  47. package/dist/providers/githubProvider.js +0 -4
  48. package/dist/providers/providerManager.d.ts +0 -11
  49. package/dist/providers/providerManager.js +0 -49
  50. package/dist/resources/toolsGuide.d.ts +0 -12
  51. package/dist/resources/toolsGuide.js +0 -1713
  52. package/dist/scripts/test_e2e.d.ts +0 -1
  53. package/dist/scripts/test_e2e.js +0 -199
  54. package/dist/scripts/test_exhaustive.d.ts +0 -1
  55. package/dist/scripts/test_exhaustive.js +0 -275
  56. package/dist/scripts/verify_setup.d.ts +0 -1
  57. package/dist/scripts/verify_setup.js +0 -61
  58. package/dist/server.d.ts +0 -9
  59. package/dist/server.js +0 -73
  60. package/dist/tools/gitAnalytics.d.ts +0 -35
  61. package/dist/tools/gitAnalytics.js +0 -220
  62. package/dist/tools/gitArchive.d.ts +0 -119
  63. package/dist/tools/gitArchive.js +0 -150
  64. package/dist/tools/gitBackup.d.ts +0 -116
  65. package/dist/tools/gitBackup.js +0 -156
  66. package/dist/tools/gitBranches.d.ts +0 -54
  67. package/dist/tools/gitBranches.js +0 -282
  68. package/dist/tools/gitChangelog.d.ts +0 -37
  69. package/dist/tools/gitChangelog.js +0 -67
  70. package/dist/tools/gitConfig.d.ts +0 -97
  71. package/dist/tools/gitConfig.js +0 -125
  72. package/dist/tools/gitFiles.d.ts +0 -129
  73. package/dist/tools/gitFiles.js +0 -213
  74. package/dist/tools/gitFix.d.ts +0 -4
  75. package/dist/tools/gitFix.js +0 -159
  76. package/dist/tools/gitFix.tool.d.ts +0 -31
  77. package/dist/tools/gitFix.tool.js +0 -92
  78. package/dist/tools/gitHistory.d.ts +0 -41
  79. package/dist/tools/gitHistory.js +0 -349
  80. package/dist/tools/gitIgnore.d.ts +0 -214
  81. package/dist/tools/gitIgnore.js +0 -338
  82. package/dist/tools/gitIssues.d.ts +0 -80
  83. package/dist/tools/gitIssues.js +0 -363
  84. package/dist/tools/gitLog.d.ts +0 -30
  85. package/dist/tools/gitLog.js +0 -46
  86. package/dist/tools/gitMonitor.d.ts +0 -30
  87. package/dist/tools/gitMonitor.js +0 -284
  88. package/dist/tools/gitPackages.d.ts +0 -180
  89. package/dist/tools/gitPackages.js +0 -214
  90. package/dist/tools/gitPulls.d.ts +0 -66
  91. package/dist/tools/gitPulls.js +0 -347
  92. package/dist/tools/gitPush.d.ts +0 -40
  93. package/dist/tools/gitPush.js +0 -59
  94. package/dist/tools/gitRelease.d.ts +0 -49
  95. package/dist/tools/gitRelease.js +0 -359
  96. package/dist/tools/gitRemote.d.ts +0 -47
  97. package/dist/tools/gitRemote.js +0 -111
  98. package/dist/tools/gitReset.d.ts +0 -57
  99. package/dist/tools/gitReset.js +0 -79
  100. package/dist/tools/gitStash.d.ts +0 -61
  101. package/dist/tools/gitStash.js +0 -80
  102. package/dist/tools/gitSync.d.ts +0 -34
  103. package/dist/tools/gitSync.js +0 -182
  104. package/dist/tools/gitTags.d.ts +0 -45
  105. package/dist/tools/gitTags.js +0 -251
  106. package/dist/tools/gitUpdate.d.ts +0 -60
  107. package/dist/tools/gitUpdate.js +0 -474
  108. package/dist/tools/gitUpload.d.ts +0 -35
  109. package/dist/tools/gitUpload.js +0 -385
  110. package/dist/tools/gitWorkflow.d.ts +0 -117
  111. package/dist/tools/gitWorkflow.js +0 -472
  112. package/dist/types.d.ts +0 -20
  113. package/dist/types.js +0 -1
  114. package/dist/utils/agentHelpers.d.ts +0 -11
  115. package/dist/utils/agentHelpers.js +0 -41
  116. package/dist/utils/apiHelpers.d.ts +0 -29
  117. package/dist/utils/apiHelpers.js +0 -125
  118. package/dist/utils/cache.d.ts +0 -96
  119. package/dist/utils/cache.js +0 -208
  120. package/dist/utils/contextDetector.d.ts +0 -0
  121. package/dist/utils/contextDetector.js +0 -1
  122. package/dist/utils/errors.d.ts +0 -13
  123. package/dist/utils/errors.js +0 -17
  124. package/dist/utils/gitAdapter.d.ts +0 -224
  125. package/dist/utils/gitAdapter.js +0 -1152
  126. package/dist/utils/logger.d.ts +0 -45
  127. package/dist/utils/logger.js +0 -140
  128. package/dist/utils/rateLimiter.d.ts +0 -113
  129. package/dist/utils/rateLimiter.js +0 -257
  130. package/dist/utils/repoHelpers.d.ts +0 -44
  131. package/dist/utils/repoHelpers.js +0 -122
  132. package/dist/utils/safetyController.d.ts +0 -1
  133. package/dist/utils/safetyController.js +0 -12
  134. package/dist/utils/validation.d.ts +0 -115
  135. package/dist/utils/validation.js +0 -270
@@ -1,125 +0,0 @@
1
- // ============================================================================
2
- // API HELPER UTILITIES
3
- // Retry logic, validation, and eventual consistency handling
4
- // ============================================================================
5
- const DEFAULT_RETRY_CONFIG = {
6
- maxRetries: 5,
7
- initialDelay: 500,
8
- maxDelay: 5000,
9
- backoffFactor: 2
10
- };
11
- async function exponentialBackoff(attemptNumber, config) {
12
- const delay = Math.min(config.initialDelay * Math.pow(config.backoffFactor, attemptNumber), config.maxDelay);
13
- await new Promise(resolve => setTimeout(resolve, delay));
14
- }
15
- /**
16
- * Retry wrapper for operations that may have eventual consistency issues.
17
- * Used for GitHub API list operations after create/update.
18
- */
19
- export async function retryUntilFound(operation, validateFn, config = {}) {
20
- const finalConfig = { ...DEFAULT_RETRY_CONFIG, ...config };
21
- let lastResult = [];
22
- for (let attempt = 0; attempt < finalConfig.maxRetries; attempt++) {
23
- lastResult = await operation();
24
- // Validate result
25
- if (validateFn(lastResult)) {
26
- return lastResult;
27
- }
28
- // If not last attempt, wait with exponential backoff
29
- if (attempt < finalConfig.maxRetries - 1) {
30
- console.log(`Retry ${attempt + 1}/${finalConfig.maxRetries}: ` +
31
- `Waiting for consistency...`);
32
- await exponentialBackoff(attempt, finalConfig);
33
- }
34
- }
35
- // Return last result even if validation fails
36
- console.warn(`Max retries (${finalConfig.maxRetries}) exceeded. ` +
37
- `Returning last result with ${lastResult.length} items.`);
38
- return lastResult;
39
- }
40
- /**
41
- * Retry a single operation with exponential backoff.
42
- */
43
- export async function retryOperation(operation, shouldRetry, config = {}) {
44
- const finalConfig = { ...DEFAULT_RETRY_CONFIG, ...config };
45
- let lastError = null;
46
- for (let attempt = 0; attempt < finalConfig.maxRetries; attempt++) {
47
- try {
48
- return await operation();
49
- }
50
- catch (error) {
51
- lastError = error;
52
- // Check if we should retry
53
- if (!shouldRetry(error)) {
54
- throw error;
55
- }
56
- // If not last attempt, wait
57
- if (attempt < finalConfig.maxRetries - 1) {
58
- console.log(`Retry ${attempt + 1}/${finalConfig.maxRetries}: ` +
59
- `${error.message}`);
60
- await exponentialBackoff(attempt, finalConfig);
61
- }
62
- }
63
- }
64
- throw lastError || new Error('Max retries exceeded');
65
- }
66
- export function validateResponse(data, rules) {
67
- for (const rule of rules) {
68
- if (!rule.validate(data)) {
69
- throw new Error(rule.errorMessage);
70
- }
71
- }
72
- }
73
- /**
74
- * Validate GitHub/Gitea stats response has required fields.
75
- */
76
- export function validateStatsResponse(response) {
77
- const data = response.data;
78
- // List of required fields
79
- const requiredFields = [
80
- { field: 'stargazers_count', type: 'number' },
81
- { field: 'watchers_count', type: 'number' },
82
- { field: 'forks_count', type: 'number' },
83
- { field: 'open_issues_count', type: 'number' },
84
- { field: 'size', type: 'number' }
85
- ];
86
- // Check for Gitea field naming (stars_count vs stargazers_count)
87
- const giteaFields = [
88
- { field: 'stars_count', type: 'number' },
89
- { field: 'watchers_count', type: 'number' },
90
- { field: 'forks_count', type: 'number' },
91
- { field: 'open_issues_count', type: 'number' },
92
- { field: 'size', type: 'number' }
93
- ];
94
- // Validate field by field
95
- const missingFields = [];
96
- const invalidFields = [];
97
- const fieldsToCheck = data.stargazers_count !== undefined ? requiredFields : giteaFields;
98
- for (const { field, type } of fieldsToCheck) {
99
- if (!(field in data)) {
100
- missingFields.push(field);
101
- }
102
- else if (typeof data[field] !== type) {
103
- invalidFields.push(`${field} (expected ${type}, got ${typeof data[field]})`);
104
- }
105
- }
106
- if (missingFields.length > 0) {
107
- throw new Error(`Stats validation failed: Missing fields: ${missingFields.join(', ')}`);
108
- }
109
- if (invalidFields.length > 0) {
110
- throw new Error(`Stats validation failed: Invalid fields: ${invalidFields.join(', ')}`);
111
- }
112
- return data;
113
- }
114
- /**
115
- * Validate contributors response.
116
- */
117
- export function validateContributorsResponse(response) {
118
- if (!Array.isArray(response.data)) {
119
- throw new Error('Contributors validation failed: Expected array');
120
- }
121
- if (response.data.length === 0) {
122
- console.warn('No contributors found (repository may be empty or new)');
123
- }
124
- return response.data;
125
- }
@@ -1,96 +0,0 @@
1
- /**
2
- * Sistema de cache inteligente para Git-MCP
3
- * Otimiza operações frequentes com TTL e invalidação automática
4
- */
5
- export interface CacheEntry {
6
- data: any;
7
- timestamp: number;
8
- ttl: number;
9
- key: string;
10
- }
11
- export declare class SimpleCache {
12
- private static instance;
13
- private cache;
14
- private defaultTTL;
15
- private maxEntries;
16
- private constructor();
17
- static getInstance(): SimpleCache;
18
- /**
19
- * Gera chave única para cache baseada em parâmetros
20
- */
21
- private generateKey;
22
- /**
23
- * Verifica se entrada está expirada
24
- */
25
- private isExpired;
26
- /**
27
- * Remove entradas expiradas
28
- */
29
- private cleanup;
30
- /**
31
- * Obtém valor do cache
32
- */
33
- get(key: string): any | null;
34
- /**
35
- * Define valor no cache
36
- */
37
- set(key: string, data: any, ttl?: number): void;
38
- /**
39
- * Remove entrada do cache
40
- */
41
- delete(key: string): boolean;
42
- /**
43
- * Limpa todo o cache
44
- */
45
- clear(): void;
46
- /**
47
- * Obtém estatísticas do cache
48
- */
49
- getStats(): {
50
- size: number;
51
- maxEntries: number;
52
- defaultTTL: number;
53
- expiredEntries: number;
54
- };
55
- /**
56
- * Cache com função de busca - pattern de memoização
57
- */
58
- memoize<T>(key: string, fn: () => Promise<T>, ttl?: number): Promise<T>;
59
- /**
60
- * Cache específico para operações Git
61
- */
62
- memoizeGitOperation<T>(operation: string, projectPath: string, fn: () => Promise<T>, ttl?: number): Promise<T>;
63
- }
64
- /**
65
- * Decorator para cache automático de métodos
66
- */
67
- export declare function Cacheable(ttl?: number, prefix?: string): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
68
- /**
69
- * Helper functions para cache de operações comuns
70
- */
71
- export declare const cacheHelpers: {
72
- /**
73
- * Cache para informações de repositório
74
- */
75
- getRepoInfo(projectPath: string, fn: () => Promise<any>): Promise<any>;
76
- /**
77
- * Cache para branches
78
- */
79
- getBranches(projectPath: string, fn: () => Promise<any>): Promise<any>;
80
- /**
81
- * Cache para commits/histórico
82
- */
83
- getCommits(projectPath: string, limit: number, fn: () => Promise<any>): Promise<any>;
84
- /**
85
- * Cache para status do repositório
86
- */
87
- getStatus(projectPath: string, fn: () => Promise<any>): Promise<any>;
88
- /**
89
- * Invalida cache específico do repositório
90
- */
91
- invalidateRepoCache(projectPath: string): void;
92
- /**
93
- * Limpa todo cache de operações Git
94
- */
95
- clearGitCache(): void;
96
- };
@@ -1,208 +0,0 @@
1
- /**
2
- * Sistema de cache inteligente para Git-MCP
3
- * Otimiza operações frequentes com TTL e invalidação automática
4
- */
5
- export class SimpleCache {
6
- constructor(defaultTTL = 300000, maxEntries = 1000) {
7
- this.cache = new Map();
8
- this.defaultTTL = defaultTTL;
9
- this.maxEntries = maxEntries;
10
- }
11
- static getInstance() {
12
- if (!SimpleCache.instance) {
13
- SimpleCache.instance = new SimpleCache();
14
- }
15
- return SimpleCache.instance;
16
- }
17
- /**
18
- * Gera chave única para cache baseada em parâmetros
19
- */
20
- generateKey(prefix, params) {
21
- const sortedParams = Object.keys(params)
22
- .sort()
23
- .reduce((acc, key) => {
24
- acc[key] = params[key];
25
- return acc;
26
- }, {});
27
- return `${prefix}:${JSON.stringify(sortedParams)}`;
28
- }
29
- /**
30
- * Verifica se entrada está expirada
31
- */
32
- isExpired(entry) {
33
- return Date.now() - entry.timestamp > entry.ttl;
34
- }
35
- /**
36
- * Remove entradas expiradas
37
- */
38
- cleanup() {
39
- const now = Date.now();
40
- for (const [key, entry] of this.cache.entries()) {
41
- if (now - entry.timestamp > entry.ttl) {
42
- this.cache.delete(key);
43
- }
44
- }
45
- // Remove entradas antigas se exceder limite
46
- if (this.cache.size > this.maxEntries) {
47
- const entries = Array.from(this.cache.entries());
48
- entries.sort((a, b) => a[1].timestamp - b[1].timestamp);
49
- const toRemove = entries.slice(0, this.cache.size - this.maxEntries);
50
- toRemove.forEach(([key]) => this.cache.delete(key));
51
- }
52
- }
53
- /**
54
- * Obtém valor do cache
55
- */
56
- get(key) {
57
- const entry = this.cache.get(key);
58
- if (!entry) {
59
- return null;
60
- }
61
- if (this.isExpired(entry)) {
62
- this.cache.delete(key);
63
- return null;
64
- }
65
- return entry.data;
66
- }
67
- /**
68
- * Define valor no cache
69
- */
70
- set(key, data, ttl) {
71
- const entry = {
72
- data,
73
- timestamp: Date.now(),
74
- ttl: ttl || this.defaultTTL,
75
- key,
76
- };
77
- this.cache.set(key, entry);
78
- // Limpeza periódica
79
- if (Math.random() < 0.01) { // 1% de chance
80
- this.cleanup();
81
- }
82
- }
83
- /**
84
- * Remove entrada do cache
85
- */
86
- delete(key) {
87
- return this.cache.delete(key);
88
- }
89
- /**
90
- * Limpa todo o cache
91
- */
92
- clear() {
93
- this.cache.clear();
94
- }
95
- /**
96
- * Obtém estatísticas do cache
97
- */
98
- getStats() {
99
- const now = Date.now();
100
- let expiredCount = 0;
101
- for (const entry of this.cache.values()) {
102
- if (now - entry.timestamp > entry.ttl) {
103
- expiredCount++;
104
- }
105
- }
106
- return {
107
- size: this.cache.size,
108
- maxEntries: this.maxEntries,
109
- defaultTTL: this.defaultTTL,
110
- expiredEntries: expiredCount,
111
- };
112
- }
113
- /**
114
- * Cache com função de busca - pattern de memoização
115
- */
116
- async memoize(key, fn, ttl) {
117
- const cached = this.get(key);
118
- if (cached !== null) {
119
- return cached;
120
- }
121
- const result = await fn();
122
- this.set(key, result, ttl);
123
- return result;
124
- }
125
- /**
126
- * Cache específico para operações Git
127
- */
128
- async memoizeGitOperation(operation, projectPath, fn, ttl = 60000 // 1 minuto para operações Git
129
- ) {
130
- const key = this.generateKey(`git:${operation}`, { projectPath });
131
- return this.memoize(key, fn, ttl);
132
- }
133
- }
134
- /**
135
- * Decorator para cache automático de métodos
136
- */
137
- export function Cacheable(ttl, prefix) {
138
- return function (target, propertyKey, descriptor) {
139
- const originalMethod = descriptor.value;
140
- descriptor.value = async function (...args) {
141
- const cache = SimpleCache.getInstance();
142
- const keyPrefix = prefix || `${target.constructor.name}:${propertyKey}`;
143
- const cacheKey = `${keyPrefix}:${JSON.stringify(args)}`;
144
- return cache.memoize(cacheKey, () => originalMethod.apply(this, args), ttl);
145
- };
146
- return descriptor;
147
- };
148
- }
149
- /**
150
- * Helper functions para cache de operações comuns
151
- */
152
- export const cacheHelpers = {
153
- /**
154
- * Cache para informações de repositório
155
- */
156
- async getRepoInfo(projectPath, fn) {
157
- const cache = SimpleCache.getInstance();
158
- return cache.memoizeGitOperation('repo_info', projectPath, fn, 300000); // 5 minutos
159
- },
160
- /**
161
- * Cache para branches
162
- */
163
- async getBranches(projectPath, fn) {
164
- const cache = SimpleCache.getInstance();
165
- return cache.memoizeGitOperation('branches', projectPath, fn, 120000); // 2 minutos
166
- },
167
- /**
168
- * Cache para commits/histórico
169
- */
170
- async getCommits(projectPath, limit, fn) {
171
- const cache = SimpleCache.getInstance();
172
- return cache.memoizeGitOperation('commits', `${projectPath}:${limit}`, fn, 60000); // 1 minuto
173
- },
174
- /**
175
- * Cache para status do repositório
176
- */
177
- async getStatus(projectPath, fn) {
178
- const cache = SimpleCache.getInstance();
179
- return cache.memoizeGitOperation('status', projectPath, fn, 30000); // 30 segundos
180
- },
181
- /**
182
- * Invalida cache específico do repositório
183
- */
184
- invalidateRepoCache(projectPath) {
185
- const cache = SimpleCache.getInstance();
186
- const operations = ['repo_info', 'branches', 'commits', 'status'];
187
- operations.forEach(operation => {
188
- const keyPattern = `git:${operation}:${projectPath}`;
189
- // Remove todas as entradas que começam com este padrão
190
- for (const [key] of cache['cache'].entries()) {
191
- if (key.startsWith(keyPattern)) {
192
- cache.delete(key);
193
- }
194
- }
195
- });
196
- },
197
- /**
198
- * Limpa todo cache de operações Git
199
- */
200
- clearGitCache() {
201
- const cache = SimpleCache.getInstance();
202
- for (const [key] of cache['cache'].entries()) {
203
- if (key.startsWith('git:')) {
204
- cache.delete(key);
205
- }
206
- }
207
- },
208
- };
File without changes
@@ -1 +0,0 @@
1
- "use strict";
@@ -1,13 +0,0 @@
1
- export declare function createErrorResponse(code: string, message: string, suggestions?: string[]): {
2
- success: boolean;
3
- error: {
4
- code: string;
5
- message: string;
6
- suggestions: string[];
7
- };
8
- };
9
- export declare class MCPError extends Error {
10
- code: string;
11
- suggestions?: string[];
12
- constructor(code: string, message: string, suggestions?: string[]);
13
- }
@@ -1,17 +0,0 @@
1
- export function createErrorResponse(code, message, suggestions) {
2
- return {
3
- success: false,
4
- error: {
5
- code,
6
- message,
7
- suggestions: suggestions ?? [],
8
- },
9
- };
10
- }
11
- export class MCPError extends Error {
12
- constructor(code, message, suggestions) {
13
- super(message);
14
- this.code = code;
15
- this.suggestions = suggestions;
16
- }
17
- }
@@ -1,224 +0,0 @@
1
- import { ProviderManager } from '../providers/providerManager.js';
2
- export interface Author {
3
- name: string;
4
- email: string;
5
- timestamp?: number;
6
- timezoneOffset?: number;
7
- }
8
- export interface StatusResult {
9
- modified: string[];
10
- created: string[];
11
- deleted: string[];
12
- renamed: string[];
13
- not_added: string[];
14
- staged: string[];
15
- conflicted: string[];
16
- current: string;
17
- tracking: string | null;
18
- ahead: number;
19
- behind: number;
20
- isClean: boolean;
21
- files: Array<{
22
- path: string;
23
- index?: string;
24
- working_dir: string;
25
- }>;
26
- }
27
- export interface CommitResult {
28
- commit: string;
29
- summary: {
30
- changes: number;
31
- insertions: number;
32
- deletions: number;
33
- };
34
- author: Author;
35
- branch: string;
36
- }
37
- export interface BranchInfo {
38
- name: string;
39
- current: boolean;
40
- commit: string;
41
- label?: string;
42
- }
43
- export interface RemoteInfo {
44
- name: string;
45
- remote: string;
46
- url: string;
47
- fetch?: string;
48
- }
49
- export interface TagInfo {
50
- name: string;
51
- commit: string;
52
- date?: Date;
53
- message?: string;
54
- taggerName?: string;
55
- taggerEmail?: string;
56
- }
57
- export interface LogEntry {
58
- hash: string;
59
- date: string;
60
- message: string;
61
- author_name: string;
62
- author_email: string;
63
- refs?: string;
64
- }
65
- export interface MergeResult {
66
- success: boolean;
67
- conflicts?: string[];
68
- message?: string;
69
- }
70
- export interface DiffResult {
71
- files: Array<{
72
- path: string;
73
- additions: number;
74
- deletions: number;
75
- changes: number;
76
- }>;
77
- summary: {
78
- additions: number;
79
- deletions: number;
80
- changes: number;
81
- };
82
- }
83
- export interface StashEntry {
84
- index: number;
85
- message: string;
86
- date: Date;
87
- ref: string;
88
- }
89
- export interface GitAdapter {
90
- init(dir: string, defaultBranch?: string): Promise<void>;
91
- status(dir: string): Promise<StatusResult>;
92
- add(dir: string, files: string[]): Promise<void>;
93
- remove(dir: string, files: string[]): Promise<void>;
94
- commit(dir: string, message: string, author?: Author): Promise<string>;
95
- listBranches(dir: string, remote?: boolean): Promise<string[]>;
96
- createBranch(dir: string, branchName: string, startPoint?: string): Promise<void>;
97
- deleteBranch(dir: string, branchName: string, force?: boolean): Promise<void>;
98
- checkout(dir: string, ref: string): Promise<void>;
99
- getCurrentBranch(dir: string): Promise<string>;
100
- addRemote(dir: string, name: string, url: string): Promise<void>;
101
- removeRemote(dir: string, name: string): Promise<void>;
102
- listRemotes(dir: string): Promise<RemoteInfo[]>;
103
- fetch(dir: string, remote: string, ref?: string): Promise<void>;
104
- pull(dir: string, remote: string, branch: string): Promise<void>;
105
- push(dir: string, remote: string, branch: string, force?: boolean, setUpstream?: boolean): Promise<void>;
106
- merge(dir: string, theirBranch: string, author?: Author): Promise<MergeResult>;
107
- listTags(dir: string): Promise<string[]>;
108
- createTag(dir: string, tagName: string, ref?: string, message?: string): Promise<void>;
109
- deleteTag(dir: string, tagName: string): Promise<void>;
110
- pushTag(dir: string, remote: string, tagName: string): Promise<void>;
111
- log(dir: string, options?: {
112
- maxCount?: number;
113
- ref?: string;
114
- }): Promise<LogEntry[]>;
115
- diff(dir: string, ref1?: string, ref2?: string): Promise<DiffResult>;
116
- reset(dir: string, ref: string, mode: 'soft' | 'mixed' | 'hard'): Promise<void>;
117
- saveStash(dir: string, message?: string, includeUntracked?: boolean): Promise<void>;
118
- listStash(dir: string): Promise<StashEntry[]>;
119
- applyStash(dir: string, stashRef?: string): Promise<void>;
120
- popStash(dir: string, stashRef?: string): Promise<void>;
121
- dropStash(dir: string, stashRef?: string): Promise<void>;
122
- clearStash(dir: string): Promise<void>;
123
- getConfig(dir: string, key: string, scope?: 'local' | 'global' | 'system'): Promise<string | undefined>;
124
- setConfig(dir: string, key: string, value: string, scope?: 'local' | 'global' | 'system'): Promise<void>;
125
- listConfig(dir: string, scope?: 'local' | 'global' | 'system'): Promise<Record<string, string>>;
126
- unsetConfig(dir: string, key: string, scope?: 'local' | 'global' | 'system'): Promise<void>;
127
- }
128
- export declare class IsomorphicGitAdapter implements GitAdapter {
129
- private providerManager;
130
- constructor(providerManager: ProviderManager);
131
- /**
132
- * Get authentication callback for HTTP operations
133
- */
134
- private getAuthCallback;
135
- /**
136
- * Get author information from provider or fallback to config/default
137
- * Auto-configures local git config if provider returns user info but config is missing
138
- */
139
- private getAuthor;
140
- /**
141
- * Convert isomorphic-git status matrix to StatusResult format
142
- */
143
- private convertStatusMatrix;
144
- init(dir: string, defaultBranch?: string): Promise<void>;
145
- status(dir: string): Promise<StatusResult>;
146
- add(dir: string, files: string[]): Promise<void>;
147
- remove(dir: string, files: string[]): Promise<void>;
148
- commit(dir: string, message: string, providedAuthor?: Author): Promise<string>;
149
- listBranches(dir: string, remote?: boolean): Promise<string[]>;
150
- createBranch(dir: string, branchName: string, startPoint?: string): Promise<void>;
151
- deleteBranch(dir: string, branchName: string, force?: boolean): Promise<void>;
152
- renameBranch(dir: string, oldName: string, newName: string): Promise<void>;
153
- checkout(dir: string, ref: string): Promise<void>;
154
- getCurrentBranch(dir: string): Promise<string>;
155
- addRemote(dir: string, name: string, url: string): Promise<void>;
156
- removeRemote(dir: string, name: string): Promise<void>;
157
- listRemotes(dir: string): Promise<RemoteInfo[]>;
158
- fetch(dir: string, remote: string, ref?: string): Promise<void>;
159
- pull(dir: string, remote: string, branch: string): Promise<void>;
160
- push(dir: string, remote: string, branch: string, force?: boolean, setUpstream?: boolean): Promise<void>;
161
- merge(dir: string, theirBranch: string, author?: Author): Promise<MergeResult>;
162
- listTags(dir: string): Promise<string[]>;
163
- createTag(dir: string, tagName: string, ref?: string, message?: string): Promise<void>;
164
- deleteTag(dir: string, tagName: string): Promise<void>;
165
- pushTag(dir: string, remote: string, tagName: string): Promise<void>;
166
- log(dir: string, options?: {
167
- maxCount?: number;
168
- ref?: string;
169
- }): Promise<LogEntry[]>;
170
- diff(dir: string, ref1?: string, ref2?: string): Promise<DiffResult>;
171
- reset(dir: string, ref: string, mode: 'soft' | 'mixed' | 'hard'): Promise<void>;
172
- /**
173
- * Get stash reflog path
174
- */
175
- private getStashReflogPath;
176
- /**
177
- * Get stash ref path
178
- */
179
- private getStashRefPath;
180
- /**
181
- * Read stash reflog entries
182
- */
183
- private readStashReflog;
184
- /**
185
- * Write stash reflog entry
186
- */
187
- private writeStashReflogEntry;
188
- saveStash(dir: string, message?: string, includeUntracked?: boolean): Promise<void>;
189
- listStash(dir: string): Promise<StashEntry[]>;
190
- applyStash(dir: string, stashRef?: string): Promise<void>;
191
- popStash(dir: string, stashRef?: string): Promise<void>;
192
- dropStash(dir: string, stashRef?: string): Promise<void>;
193
- clearStash(dir: string): Promise<void>;
194
- /**
195
- * Get global Git config path (~/.gitconfig)
196
- */
197
- private getGlobalConfigPath;
198
- /**
199
- * Get system Git config path
200
- */
201
- private getSystemConfigPath;
202
- /**
203
- * Parse INI-style Git config file
204
- */
205
- private parseGitConfig;
206
- /**
207
- * Write INI-style Git config file
208
- */
209
- private writeGitConfig;
210
- getConfig(dir: string, key: string, scope?: 'local' | 'global' | 'system'): Promise<string | undefined>;
211
- setConfig(dir: string, key: string, value: string, scope?: 'local' | 'global' | 'system'): Promise<void>;
212
- listConfig(dir: string, scope?: 'local' | 'global' | 'system'): Promise<Record<string, string>>;
213
- getAllConfig(dir: string, scope?: 'local' | 'global' | 'system'): Promise<Record<string, string>>;
214
- unsetConfig(dir: string, key: string, scope?: 'local' | 'global' | 'system'): Promise<void>;
215
- resetSoft(dir: string, ref: string): Promise<void>;
216
- resetMixed(dir: string, ref: string): Promise<void>;
217
- resetHard(dir: string, ref: string): Promise<void>;
218
- createGitignore(dir: string, patterns: string[]): Promise<void>;
219
- addToGitignore(dir: string, patterns: string[]): Promise<void>;
220
- removeFromGitignore(dir: string, patterns: string[]): Promise<void>;
221
- listGitignore(dir: string): Promise<string[]>;
222
- readFile(dir: string, filepath: string, ref?: string): Promise<string>;
223
- listFiles(dir: string, ref?: string): Promise<string[]>;
224
- }