@andrebuzeli/git-mcp 2.48.0 → 3.0.1
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/README.md +356 -329
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +82 -83
- package/dist/server.js.map +1 -1
- package/dist/tools/git-branches.d.ts +125 -359
- package/dist/tools/git-branches.d.ts.map +1 -1
- package/dist/tools/git-branches.js +179 -530
- package/dist/tools/git-branches.js.map +1 -1
- package/dist/tools/git-commits.d.ts +2 -2
- package/dist/tools/git-config.d.ts +2 -2
- package/dist/tools/git-files.d.ts +246 -406
- package/dist/tools/git-files.d.ts.map +1 -1
- package/dist/tools/git-files.js +556 -499
- package/dist/tools/git-files.js.map +1 -1
- package/dist/tools/git-issues.d.ts +10 -10
- package/dist/tools/git-packages.d.ts +2 -2
- package/dist/tools/git-projects.d.ts +142 -57
- package/dist/tools/git-projects.d.ts.map +1 -1
- package/dist/tools/git-projects.js +281 -283
- package/dist/tools/git-projects.js.map +1 -1
- package/dist/tools/git-pulls.d.ts +16 -16
- package/dist/tools/git-releases.d.ts +131 -401
- package/dist/tools/git-releases.d.ts.map +1 -1
- package/dist/tools/git-releases.js +374 -469
- package/dist/tools/git-releases.js.map +1 -1
- package/dist/tools/git-remote.d.ts +4 -4
- package/dist/tools/git-repositories.d.ts +8 -8
- package/dist/tools/git-reset.d.ts +106 -65
- package/dist/tools/git-reset.d.ts.map +1 -1
- package/dist/tools/git-reset.js +265 -149
- package/dist/tools/git-reset.js.map +1 -1
- package/dist/tools/git-stash.d.ts +110 -68
- package/dist/tools/git-stash.d.ts.map +1 -1
- package/dist/tools/git-stash.js +311 -186
- package/dist/tools/git-stash.js.map +1 -1
- package/dist/tools/git-sync.d.ts +149 -80
- package/dist/tools/git-sync.d.ts.map +1 -1
- package/dist/tools/git-sync.js +346 -246
- package/dist/tools/git-sync.js.map +1 -1
- package/dist/tools/git-tags.d.ts +2 -2
- package/dist/tools/git-undo.d.ts +268 -0
- package/dist/tools/git-undo.d.ts.map +1 -0
- package/dist/tools/git-undo.js +516 -0
- package/dist/tools/git-undo.js.map +1 -0
- package/dist/tools/git-update-project.d.ts +4 -159
- package/dist/tools/git-update-project.d.ts.map +1 -1
- package/dist/tools/git-update-project.js +7 -349
- package/dist/tools/git-update-project.js.map +1 -1
- package/dist/tools/git-versioning.d.ts +286 -0
- package/dist/tools/git-versioning.d.ts.map +1 -0
- package/dist/tools/git-versioning.js +483 -0
- package/dist/tools/git-versioning.js.map +1 -0
- package/dist/tools/git-workflow.d.ts +200 -259
- package/dist/tools/git-workflow.d.ts.map +1 -1
- package/dist/tools/git-workflow.js +424 -498
- package/dist/tools/git-workflow.js.map +1 -1
- package/package.json +5 -14
- package/dist/tools/git-publish.d.ts +0 -327
- package/dist/tools/git-publish.d.ts.map +0 -1
- package/dist/tools/git-publish.js +0 -632
- package/dist/tools/git-publish.js.map +0 -1
|
@@ -2,86 +2,96 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.gitWorkflowTool = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
|
+
const index_js_1 = require("../providers/index.js");
|
|
6
|
+
const user_detection_js_1 = require("../utils/user-detection.js");
|
|
7
|
+
const git_operations_js_1 = require("../utils/git-operations.js");
|
|
5
8
|
/**
|
|
6
9
|
* Tool: git-workflow
|
|
7
10
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
11
|
+
* FERRAMENTA UNIFICADA PARA WORKFLOW PRINCIPAL
|
|
12
|
+
* Combina as funcionalidades essenciais de:
|
|
13
|
+
* - git-update-project (init, update, sync)
|
|
14
|
+
* - git-commits (create, push, pull)
|
|
15
|
+
* - git-repositories (create, clone)
|
|
10
16
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* - Workflows diários de desenvolvimento
|
|
14
|
-
* - Gerenciamento de features automatizado
|
|
15
|
-
* - Processos de release completos
|
|
16
|
-
* - Limpeza automática de repositórios
|
|
17
|
-
* - Templates para diferentes tipos de projeto
|
|
18
|
-
*
|
|
19
|
-
* USO:
|
|
20
|
-
* - Automação de todo o ciclo de desenvolvimento
|
|
21
|
-
* - Setup consistente de novos projetos
|
|
22
|
-
* - Workflows padronizados
|
|
23
|
-
* - Eliminação de tarefas manuais repetitivas
|
|
24
|
-
*
|
|
25
|
-
* OTIMIZADO PARA AI AGENTS:
|
|
26
|
-
* - Interface simples e intuitiva
|
|
27
|
-
* - Auto-detecção de contexto
|
|
28
|
-
* - Validação automática
|
|
29
|
-
* - Error handling robusto
|
|
30
|
-
* - Workflows em uma única chamada
|
|
17
|
+
* DESIGNED FOR: Programador individual autônomo
|
|
18
|
+
* PHILOSOPHY: Workflow principal completo em uma única ferramenta
|
|
31
19
|
*/
|
|
32
20
|
const GitWorkflowInputSchema = zod_1.z.discriminatedUnion('action', [
|
|
33
|
-
//
|
|
21
|
+
// WORKFLOW PRINCIPAL - Substitui git-update-project
|
|
22
|
+
zod_1.z.object({
|
|
23
|
+
action: zod_1.z.literal('init'),
|
|
24
|
+
repo: zod_1.z.string(),
|
|
25
|
+
projectPath: zod_1.z.string(),
|
|
26
|
+
provider: zod_1.z.enum(['gitea', 'github']),
|
|
27
|
+
message: zod_1.z.string().min(1, 'Commit message is required'),
|
|
28
|
+
createRemote: zod_1.z.boolean().optional().default(false),
|
|
29
|
+
branch: zod_1.z.string().optional().default('main')
|
|
30
|
+
}),
|
|
31
|
+
zod_1.z.object({
|
|
32
|
+
action: zod_1.z.literal('commit'),
|
|
33
|
+
projectPath: zod_1.z.string(),
|
|
34
|
+
message: zod_1.z.string().min(1, 'Commit message is required'),
|
|
35
|
+
addAll: zod_1.z.boolean().optional().default(true),
|
|
36
|
+
push: zod_1.z.boolean().optional().default(false),
|
|
37
|
+
branch: zod_1.z.string().optional().default('main'),
|
|
38
|
+
provider: zod_1.z.enum(['gitea', 'github']).optional()
|
|
39
|
+
}),
|
|
34
40
|
zod_1.z.object({
|
|
35
|
-
action: zod_1.z.literal('
|
|
41
|
+
action: zod_1.z.literal('sync'),
|
|
36
42
|
repo: zod_1.z.string(),
|
|
43
|
+
projectPath: zod_1.z.string(),
|
|
37
44
|
provider: zod_1.z.enum(['gitea', 'github']),
|
|
45
|
+
message: zod_1.z.string().min(1, 'Commit message is required'),
|
|
46
|
+
branch: zod_1.z.string().optional().default('main'),
|
|
47
|
+
forcePush: zod_1.z.boolean().optional().default(false)
|
|
48
|
+
}),
|
|
49
|
+
// STATUS E MONITORAMENTO
|
|
50
|
+
zod_1.z.object({
|
|
51
|
+
action: zod_1.z.literal('status'),
|
|
52
|
+
projectPath: zod_1.z.string(),
|
|
53
|
+
detailed: zod_1.z.boolean().optional().default(false)
|
|
54
|
+
}),
|
|
55
|
+
zod_1.z.object({
|
|
56
|
+
action: zod_1.z.literal('diff'),
|
|
38
57
|
projectPath: zod_1.z.string(),
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
autoConfigure: zod_1.z.boolean().optional().default(true),
|
|
42
|
-
createRemote: zod_1.z.boolean().optional().default(true),
|
|
43
|
-
initGit: zod_1.z.boolean().optional().default(true)
|
|
58
|
+
staged: zod_1.z.boolean().optional().default(false),
|
|
59
|
+
file: zod_1.z.string().optional()
|
|
44
60
|
}),
|
|
45
|
-
// Action: daily-dev - Workflow diário completo
|
|
46
61
|
zod_1.z.object({
|
|
47
|
-
action: zod_1.z.literal('
|
|
62
|
+
action: zod_1.z.literal('log'),
|
|
48
63
|
projectPath: zod_1.z.string(),
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
64
|
+
limit: zod_1.z.number().optional().default(10),
|
|
65
|
+
oneline: zod_1.z.boolean().optional().default(true)
|
|
66
|
+
}),
|
|
67
|
+
// REPOSITORIES - Substitui parte do git-repositories
|
|
68
|
+
zod_1.z.object({
|
|
69
|
+
action: zod_1.z.literal('create-repo'),
|
|
70
|
+
name: zod_1.z.string(),
|
|
71
|
+
description: zod_1.z.string().optional(),
|
|
72
|
+
private: zod_1.z.boolean().optional().default(false),
|
|
73
|
+
provider: zod_1.z.enum(['gitea', 'github'])
|
|
54
74
|
}),
|
|
55
|
-
// Action: feature-dev - Desenvolvimento de features
|
|
56
75
|
zod_1.z.object({
|
|
57
|
-
action: zod_1.z.literal('
|
|
76
|
+
action: zod_1.z.literal('clone-repo'),
|
|
77
|
+
name: zod_1.z.string(),
|
|
78
|
+
provider: zod_1.z.enum(['gitea', 'github']),
|
|
58
79
|
projectPath: zod_1.z.string(),
|
|
59
|
-
|
|
60
|
-
createBranch: zod_1.z.boolean().optional().default(true),
|
|
61
|
-
baseBranch: zod_1.z.string().optional().default('main'),
|
|
62
|
-
mergeWhenReady: zod_1.z.boolean().optional().default(true),
|
|
63
|
-
runTests: zod_1.z.boolean().optional().default(true),
|
|
64
|
-
createPR: zod_1.z.boolean().optional().default(false)
|
|
80
|
+
branch: zod_1.z.string().optional().default('main')
|
|
65
81
|
}),
|
|
66
|
-
//
|
|
82
|
+
// QUICK ACTIONS
|
|
67
83
|
zod_1.z.object({
|
|
68
|
-
action: zod_1.z.literal('
|
|
84
|
+
action: zod_1.z.literal('pull'),
|
|
69
85
|
projectPath: zod_1.z.string(),
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
createTag: zod_1.z.boolean().optional().default(true),
|
|
73
|
-
createRelease: zod_1.z.boolean().optional().default(true),
|
|
74
|
-
updateChangelog: zod_1.z.boolean().optional().default(true),
|
|
75
|
-
runTests: zod_1.z.boolean().optional().default(true)
|
|
86
|
+
branch: zod_1.z.string().optional().default('main'),
|
|
87
|
+
provider: zod_1.z.enum(['gitea', 'github']).optional()
|
|
76
88
|
}),
|
|
77
|
-
// Action: cleanup-workflow - Limpeza de repositório
|
|
78
89
|
zod_1.z.object({
|
|
79
|
-
action: zod_1.z.literal('
|
|
90
|
+
action: zod_1.z.literal('push'),
|
|
80
91
|
projectPath: zod_1.z.string(),
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
daysOld: zod_1.z.number().optional().default(30)
|
|
92
|
+
branch: zod_1.z.string().optional().default('main'),
|
|
93
|
+
provider: zod_1.z.enum(['gitea', 'github']).optional(),
|
|
94
|
+
force: zod_1.z.boolean().optional().default(false)
|
|
85
95
|
})
|
|
86
96
|
]);
|
|
87
97
|
const GitWorkflowResultSchema = zod_1.z.object({
|
|
@@ -89,555 +99,471 @@ const GitWorkflowResultSchema = zod_1.z.object({
|
|
|
89
99
|
action: zod_1.z.string(),
|
|
90
100
|
message: zod_1.z.string(),
|
|
91
101
|
data: zod_1.z.any().optional(),
|
|
92
|
-
error: zod_1.z.string().optional()
|
|
102
|
+
error: zod_1.z.string().optional(),
|
|
103
|
+
recoverable: zod_1.z.boolean().optional(),
|
|
104
|
+
suggestion: zod_1.z.string().optional()
|
|
93
105
|
});
|
|
106
|
+
/**
|
|
107
|
+
* Enhanced Error Handler with Recovery Suggestions
|
|
108
|
+
*/
|
|
109
|
+
class WorkflowErrorHandler {
|
|
110
|
+
static handleError(error, context) {
|
|
111
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
112
|
+
// Error patterns and recovery suggestions
|
|
113
|
+
const errorPatterns = [
|
|
114
|
+
{
|
|
115
|
+
pattern: /not a git repository/i,
|
|
116
|
+
suggestion: "Run 'git init' first or check the project path",
|
|
117
|
+
recoverable: true
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
pattern: /no commits/i,
|
|
121
|
+
suggestion: "Make initial commit first",
|
|
122
|
+
recoverable: true
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
pattern: /repository.*already exists/i,
|
|
126
|
+
suggestion: "Choose a different repository name",
|
|
127
|
+
recoverable: true
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
pattern: /authentication failed/i,
|
|
131
|
+
suggestion: "Check your token configuration",
|
|
132
|
+
recoverable: true
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
pattern: /permission denied/i,
|
|
136
|
+
suggestion: "Check repository permissions and token scope",
|
|
137
|
+
recoverable: true
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
pattern: /network error/i,
|
|
141
|
+
suggestion: "Check internet connection and try again",
|
|
142
|
+
recoverable: true
|
|
143
|
+
}
|
|
144
|
+
];
|
|
145
|
+
const matchedPattern = errorPatterns.find(p => p.pattern.test(errorMessage));
|
|
146
|
+
return {
|
|
147
|
+
success: false,
|
|
148
|
+
action: context,
|
|
149
|
+
message: `Error in ${context}: ${errorMessage}`,
|
|
150
|
+
error: errorMessage,
|
|
151
|
+
recoverable: matchedPattern?.recoverable || false,
|
|
152
|
+
suggestion: matchedPattern?.suggestion
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
}
|
|
94
156
|
exports.gitWorkflowTool = {
|
|
95
157
|
name: 'git-workflow',
|
|
96
|
-
description:
|
|
158
|
+
description: `🛠️ WORKFLOW PRINCIPAL - Tudo que você precisa para trabalhar
|
|
159
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
160
|
+
🎯 WORKFLOW PRINCIPAL:
|
|
161
|
+
• init: Inicializar projeto completo
|
|
162
|
+
• commit: Commit + push automático
|
|
163
|
+
• sync: Pull + commit + push completo
|
|
164
|
+
|
|
165
|
+
📊 STATUS & MONITORAMENTO:
|
|
166
|
+
• status: Status detalhado do projeto
|
|
167
|
+
• diff: Ver diferenças nos arquivos
|
|
168
|
+
• log: Histórico de commits
|
|
169
|
+
|
|
170
|
+
🏗️ REPOSITÓRIOS:
|
|
171
|
+
• create-repo: Criar repositório remoto
|
|
172
|
+
• clone-repo: Clonar repositório localmente
|
|
173
|
+
|
|
174
|
+
⚡ QUICK ACTIONS:
|
|
175
|
+
• pull: Baixar mudanças
|
|
176
|
+
• push: Enviar mudanças
|
|
177
|
+
|
|
178
|
+
✨ DIFERENCIAIS:
|
|
179
|
+
• Error handling inteligente com sugestões
|
|
180
|
+
• Workflow completo em uma ferramenta
|
|
181
|
+
• Auto-detecção de providers
|
|
182
|
+
• Operações seguras com validação`,
|
|
97
183
|
inputSchema: {
|
|
98
184
|
type: 'object',
|
|
99
185
|
properties: {
|
|
100
186
|
action: {
|
|
101
187
|
type: 'string',
|
|
102
|
-
enum: ['
|
|
188
|
+
enum: ['init', 'commit', 'sync', 'status', 'diff', 'log', 'create-repo', 'clone-repo', 'pull', 'push'],
|
|
103
189
|
description: 'Workflow action to perform'
|
|
104
190
|
},
|
|
105
191
|
repo: { type: 'string', description: 'Repository name' },
|
|
106
|
-
provider: { type: 'string', enum: ['gitea', 'github'], description: 'Provider to use' },
|
|
107
192
|
projectPath: { type: 'string', description: 'Local project path' },
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
},
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
},
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
autoPush: { type: 'boolean', description: 'Auto-push after commit', default: true },
|
|
125
|
-
createBackup: { type: 'boolean', description: 'Create backup before operations', default: true },
|
|
126
|
-
runTests: { type: 'boolean', description: 'Run tests before operations', default: true },
|
|
127
|
-
checkLint: { type: 'boolean', description: 'Check linting', default: false },
|
|
128
|
-
featureName: { type: 'string', description: 'Name of the feature to develop' },
|
|
129
|
-
createBranch: { type: 'boolean', description: 'Create feature branch', default: true },
|
|
130
|
-
baseBranch: { type: 'string', description: 'Base branch for feature', default: 'main' },
|
|
131
|
-
mergeWhenReady: { type: 'boolean', description: 'Merge when feature is ready', default: true },
|
|
132
|
-
createPR: { type: 'boolean', description: 'Create pull request', default: false },
|
|
133
|
-
version: { type: 'string', description: 'Release version' },
|
|
134
|
-
createTag: { type: 'boolean', description: 'Create release tag', default: true },
|
|
135
|
-
createRelease: { type: 'boolean', description: 'Create GitHub release', default: true },
|
|
136
|
-
updateChangelog: { type: 'boolean', description: 'Update changelog', default: true },
|
|
137
|
-
removeMergedBranches: { type: 'boolean', description: 'Remove merged branches', default: true },
|
|
138
|
-
removeOldBackups: { type: 'boolean', description: 'Remove old backup stashes', default: true },
|
|
139
|
-
optimizeRepository: { type: 'boolean', description: 'Optimize repository', default: true },
|
|
140
|
-
daysOld: { type: 'number', description: 'Days threshold for cleanup', default: 30 }
|
|
193
|
+
provider: { type: 'string', enum: ['gitea', 'github'], description: 'Git provider' },
|
|
194
|
+
message: { type: 'string', description: 'Commit message' },
|
|
195
|
+
createRemote: { type: 'boolean', description: 'Create remote repository', default: false },
|
|
196
|
+
branch: { type: 'string', description: 'Branch name', default: 'main' },
|
|
197
|
+
addAll: { type: 'boolean', description: 'Add all files before commit', default: true },
|
|
198
|
+
push: { type: 'boolean', description: 'Push after commit', default: false },
|
|
199
|
+
forcePush: { type: 'boolean', description: 'Force push', default: false },
|
|
200
|
+
detailed: { type: 'boolean', description: 'Detailed output', default: false },
|
|
201
|
+
staged: { type: 'boolean', description: 'Show staged changes', default: false },
|
|
202
|
+
file: { type: 'string', description: 'Specific file for diff' },
|
|
203
|
+
limit: { type: 'number', description: 'Limit for log', default: 10 },
|
|
204
|
+
oneline: { type: 'boolean', description: 'One line log format', default: true },
|
|
205
|
+
name: { type: 'string', description: 'Repository name' },
|
|
206
|
+
description: { type: 'string', description: 'Repository description' },
|
|
207
|
+
private: { type: 'boolean', description: 'Private repository', default: false },
|
|
208
|
+
force: { type: 'boolean', description: 'Force push', default: false }
|
|
141
209
|
},
|
|
142
|
-
required: ['action'
|
|
210
|
+
required: ['action']
|
|
143
211
|
},
|
|
144
212
|
async handler(input) {
|
|
145
213
|
try {
|
|
146
214
|
const validatedInput = GitWorkflowInputSchema.parse(input);
|
|
147
215
|
switch (validatedInput.action) {
|
|
148
|
-
case '
|
|
149
|
-
return await this.
|
|
150
|
-
case '
|
|
151
|
-
return await this.
|
|
152
|
-
case '
|
|
153
|
-
return await this.
|
|
154
|
-
case '
|
|
155
|
-
return await this.
|
|
156
|
-
case '
|
|
157
|
-
return await this.
|
|
216
|
+
case 'init':
|
|
217
|
+
return await this.handleInit(validatedInput);
|
|
218
|
+
case 'commit':
|
|
219
|
+
return await this.handleCommit(validatedInput);
|
|
220
|
+
case 'sync':
|
|
221
|
+
return await this.handleSync(validatedInput);
|
|
222
|
+
case 'status':
|
|
223
|
+
return await this.handleStatus(validatedInput);
|
|
224
|
+
case 'diff':
|
|
225
|
+
return await this.handleDiff(validatedInput);
|
|
226
|
+
case 'log':
|
|
227
|
+
return await this.handleLog(validatedInput);
|
|
228
|
+
case 'create-repo':
|
|
229
|
+
return await this.handleCreateRepo(validatedInput);
|
|
230
|
+
case 'clone-repo':
|
|
231
|
+
return await this.handleCloneRepo(validatedInput);
|
|
232
|
+
case 'pull':
|
|
233
|
+
return await this.handlePull(validatedInput);
|
|
234
|
+
case 'push':
|
|
235
|
+
return await this.handlePush(validatedInput);
|
|
158
236
|
default:
|
|
159
|
-
throw new Error(`Action '${validatedInput.action}'
|
|
237
|
+
throw new Error(`Action '${validatedInput.action}' not supported`);
|
|
160
238
|
}
|
|
161
239
|
}
|
|
162
240
|
catch (error) {
|
|
163
|
-
return {
|
|
164
|
-
success: false,
|
|
165
|
-
action: input.action,
|
|
166
|
-
message: `Erro na operação ${input.action}`,
|
|
167
|
-
error: error instanceof Error ? error.message : String(error)
|
|
168
|
-
};
|
|
241
|
+
return WorkflowErrorHandler.handleError(error, `workflow.${input.action}`);
|
|
169
242
|
}
|
|
170
243
|
},
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
remoteCreated: false,
|
|
178
|
-
templateApplied: false,
|
|
179
|
-
configured: false
|
|
180
|
-
};
|
|
181
|
-
// 1. Initialize Git if requested
|
|
182
|
-
if (initGit) {
|
|
183
|
-
const initResult = await this.initializeGit(projectPath);
|
|
184
|
-
results.gitInit = initResult.success;
|
|
185
|
-
}
|
|
186
|
-
// 2. Create remote repository if requested
|
|
187
|
-
if (createRemote) {
|
|
188
|
-
const remoteResult = await this.createRemoteRepository(repo, provider, projectPath);
|
|
189
|
-
results.remoteCreated = remoteResult.success;
|
|
190
|
-
}
|
|
191
|
-
// 3. Apply template
|
|
192
|
-
const templateResult = await this.applyTemplate(projectPath, template);
|
|
193
|
-
results.templateApplied = templateResult.success;
|
|
194
|
-
// 4. Auto-configure if requested
|
|
195
|
-
if (autoConfigure) {
|
|
196
|
-
const configResult = await this.autoConfigureProject(projectPath, template, platforms);
|
|
197
|
-
results.configured = configResult.success;
|
|
198
|
-
}
|
|
199
|
-
const allSuccessful = Object.values(results).every(r => r);
|
|
200
|
-
return {
|
|
201
|
-
success: allSuccessful,
|
|
202
|
-
action: 'setup-project',
|
|
203
|
-
message: `Setup de projeto ${allSuccessful ? 'concluído' : 'com problemas'}`,
|
|
204
|
-
data: {
|
|
205
|
-
repo,
|
|
206
|
-
template,
|
|
207
|
-
platforms,
|
|
208
|
-
results,
|
|
209
|
-
implementation: 'SETUP_PROJECT_v2.39.0'
|
|
210
|
-
}
|
|
211
|
-
};
|
|
212
|
-
}
|
|
213
|
-
catch (error) {
|
|
244
|
+
async handleInit(params) {
|
|
245
|
+
const { repo, projectPath, message, createRemote, branch, provider } = params;
|
|
246
|
+
const gitOps = new git_operations_js_1.GitOperations(projectPath);
|
|
247
|
+
// Check if already a git repo
|
|
248
|
+
const isGit = await gitOps.isGitRepository();
|
|
249
|
+
if (isGit) {
|
|
214
250
|
return {
|
|
215
251
|
success: false,
|
|
216
|
-
action: '
|
|
217
|
-
message: '
|
|
218
|
-
|
|
252
|
+
action: 'init',
|
|
253
|
+
message: 'Project is already a Git repository',
|
|
254
|
+
suggestion: 'Use commit or sync instead'
|
|
219
255
|
};
|
|
220
256
|
}
|
|
221
|
-
},
|
|
222
|
-
// Handler para daily-dev
|
|
223
|
-
async handleDailyDev(params) {
|
|
224
257
|
try {
|
|
225
|
-
|
|
226
|
-
const
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
lint: false,
|
|
230
|
-
commit: false,
|
|
231
|
-
push: false
|
|
232
|
-
};
|
|
233
|
-
// 1. Create backup if requested
|
|
234
|
-
if (createBackup) {
|
|
235
|
-
const backupResult = await this.createBackup(projectPath);
|
|
236
|
-
results.backup = backupResult.success;
|
|
258
|
+
// Initialize git repo
|
|
259
|
+
const initResult = await gitOps.initRepository();
|
|
260
|
+
if (!initResult.success) {
|
|
261
|
+
throw new Error(`Failed to initialize Git repository: ${initResult.error}`);
|
|
237
262
|
}
|
|
238
|
-
//
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
263
|
+
// Add all files
|
|
264
|
+
const addResult = await gitOps.addFiles();
|
|
265
|
+
if (!addResult.success) {
|
|
266
|
+
throw new Error(`Failed to add files: ${addResult.error}`);
|
|
242
267
|
}
|
|
243
|
-
//
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
268
|
+
// Create initial commit
|
|
269
|
+
const commitResult = await gitOps.commit(message);
|
|
270
|
+
if (!commitResult.success) {
|
|
271
|
+
throw new Error(`Failed to create initial commit: ${commitResult.error}`);
|
|
247
272
|
}
|
|
248
|
-
//
|
|
249
|
-
if (
|
|
250
|
-
const
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
273
|
+
// Create remote if requested
|
|
274
|
+
if (createRemote) {
|
|
275
|
+
const processedInput = await (0, user_detection_js_1.applyAutoUserDetection)({ provider }, provider);
|
|
276
|
+
if (processedInput.owner) {
|
|
277
|
+
const providerInstance = index_js_1.globalProviderFactory.getProvider(provider);
|
|
278
|
+
if (providerInstance) {
|
|
279
|
+
try {
|
|
280
|
+
const remoteResult = await providerInstance.createRepository(repo, `Project initialized via MCP`, false);
|
|
281
|
+
const remoteUrl = await providerInstance.getRepositoryUrl(processedInput.owner, repo);
|
|
282
|
+
// Add remote
|
|
283
|
+
const remoteAddResult = await gitOps.remote('add', 'origin', remoteUrl);
|
|
284
|
+
if (remoteAddResult.success) {
|
|
285
|
+
// Push to remote
|
|
286
|
+
const pushResult = await gitOps.push('origin', branch);
|
|
287
|
+
if (pushResult.success) {
|
|
288
|
+
return {
|
|
289
|
+
success: true,
|
|
290
|
+
action: 'init',
|
|
291
|
+
message: `Project initialized with remote repository`,
|
|
292
|
+
data: { remoteUrl, branch, commit: commitResult.output }
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
catch (remoteError) {
|
|
298
|
+
// Remote creation failed, but local repo is ready
|
|
299
|
+
console.warn('Remote creation failed:', remoteError);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}
|
|
257
303
|
}
|
|
258
|
-
const allSuccessful = Object.values(results).filter(r => r !== false).every(r => r);
|
|
259
304
|
return {
|
|
260
|
-
success:
|
|
261
|
-
action: '
|
|
262
|
-
message:
|
|
263
|
-
data: {
|
|
264
|
-
results,
|
|
265
|
-
implementation: 'DAILY_DEV_v2.39.0'
|
|
266
|
-
}
|
|
305
|
+
success: true,
|
|
306
|
+
action: 'init',
|
|
307
|
+
message: 'Project initialized successfully',
|
|
308
|
+
data: { branch, commit: commitResult.output }
|
|
267
309
|
};
|
|
268
310
|
}
|
|
269
311
|
catch (error) {
|
|
270
|
-
return
|
|
271
|
-
success: false,
|
|
272
|
-
action: 'daily-dev',
|
|
273
|
-
message: 'Erro no workflow diário',
|
|
274
|
-
error: error instanceof Error ? error.message : String(error)
|
|
275
|
-
};
|
|
312
|
+
return WorkflowErrorHandler.handleError(error, 'init');
|
|
276
313
|
}
|
|
277
314
|
},
|
|
278
|
-
|
|
279
|
-
|
|
315
|
+
async handleCommit(params) {
|
|
316
|
+
const { projectPath, message, addAll, push, branch, provider } = params;
|
|
317
|
+
const gitOps = new git_operations_js_1.GitOperations(projectPath);
|
|
318
|
+
// Verify git repo
|
|
319
|
+
if (!(await gitOps.isGitRepository())) {
|
|
320
|
+
return WorkflowErrorHandler.handleError(new Error('Not a Git repository'), 'commit');
|
|
321
|
+
}
|
|
280
322
|
try {
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
};
|
|
288
|
-
// 1. Create feature branch if requested
|
|
289
|
-
if (createBranch) {
|
|
290
|
-
const branchResult = await this.createFeatureBranch(projectPath, featureName, baseBranch);
|
|
291
|
-
results.branch = branchResult.success;
|
|
323
|
+
// Add files if requested
|
|
324
|
+
if (addAll) {
|
|
325
|
+
const addResult = await gitOps.addFiles();
|
|
326
|
+
if (!addResult.success) {
|
|
327
|
+
throw new Error(`Failed to add files: ${addResult.error}`);
|
|
328
|
+
}
|
|
292
329
|
}
|
|
293
|
-
//
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
330
|
+
// Check if there are changes to commit
|
|
331
|
+
const statusResult = await gitOps.status({ porcelain: true });
|
|
332
|
+
if (!statusResult.output.trim()) {
|
|
333
|
+
return {
|
|
334
|
+
success: false,
|
|
335
|
+
action: 'commit',
|
|
336
|
+
message: 'No changes to commit',
|
|
337
|
+
suggestion: 'Make some changes first'
|
|
338
|
+
};
|
|
297
339
|
}
|
|
298
|
-
//
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
340
|
+
// Commit
|
|
341
|
+
const commitResult = await gitOps.commit(message);
|
|
342
|
+
if (!commitResult.success) {
|
|
343
|
+
throw new Error(`Commit failed: ${commitResult.error}`);
|
|
302
344
|
}
|
|
303
|
-
//
|
|
304
|
-
if (
|
|
305
|
-
const
|
|
306
|
-
|
|
345
|
+
// Push if requested
|
|
346
|
+
if (push && provider) {
|
|
347
|
+
const pushResult = await gitOps.push('origin', branch);
|
|
348
|
+
if (!pushResult.success) {
|
|
349
|
+
return {
|
|
350
|
+
success: true,
|
|
351
|
+
action: 'commit',
|
|
352
|
+
message: 'Commit successful, but push failed',
|
|
353
|
+
data: { commit: commitResult.output },
|
|
354
|
+
error: pushResult.error,
|
|
355
|
+
suggestion: 'Check remote configuration or network connection'
|
|
356
|
+
};
|
|
357
|
+
}
|
|
307
358
|
}
|
|
308
|
-
const allSuccessful = Object.values(results).filter(r => r !== false).every(r => r);
|
|
309
359
|
return {
|
|
310
|
-
success:
|
|
311
|
-
action: '
|
|
312
|
-
message:
|
|
313
|
-
data: {
|
|
314
|
-
featureName,
|
|
315
|
-
results,
|
|
316
|
-
implementation: 'FEATURE_DEV_v2.39.0'
|
|
317
|
-
}
|
|
360
|
+
success: true,
|
|
361
|
+
action: 'commit',
|
|
362
|
+
message: push ? 'Commit and push successful' : 'Commit successful',
|
|
363
|
+
data: { commit: commitResult.output, pushed: push || false }
|
|
318
364
|
};
|
|
319
365
|
}
|
|
320
366
|
catch (error) {
|
|
321
|
-
return
|
|
322
|
-
success: false,
|
|
323
|
-
action: 'feature-dev',
|
|
324
|
-
message: 'Erro no desenvolvimento de feature',
|
|
325
|
-
error: error instanceof Error ? error.message : String(error)
|
|
326
|
-
};
|
|
367
|
+
return WorkflowErrorHandler.handleError(error, 'commit');
|
|
327
368
|
}
|
|
328
369
|
},
|
|
329
|
-
|
|
330
|
-
|
|
370
|
+
async handleSync(params) {
|
|
371
|
+
const { repo, projectPath, message, branch, forcePush, provider } = params;
|
|
372
|
+
const gitOps = new git_operations_js_1.GitOperations(projectPath);
|
|
331
373
|
try {
|
|
332
|
-
|
|
333
|
-
const
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
tag: false,
|
|
337
|
-
release: false
|
|
338
|
-
};
|
|
339
|
-
// 1. Run tests if requested
|
|
340
|
-
if (runTests) {
|
|
341
|
-
const testResult = await this.runTests(projectPath);
|
|
342
|
-
results.tests = testResult.success;
|
|
374
|
+
// Pull first
|
|
375
|
+
const pullResult = await gitOps.pull('origin', branch);
|
|
376
|
+
if (!pullResult.success && !pullResult.error?.includes('up-to-date')) {
|
|
377
|
+
console.warn('Pull failed:', pullResult.error);
|
|
343
378
|
}
|
|
344
|
-
//
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
379
|
+
// Add and commit
|
|
380
|
+
const addResult = await gitOps.addFiles();
|
|
381
|
+
if (!addResult.success) {
|
|
382
|
+
throw new Error(`Failed to add files: ${addResult.error}`);
|
|
348
383
|
}
|
|
349
|
-
|
|
350
|
-
if (
|
|
351
|
-
const
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
// 4. Create release if requested
|
|
355
|
-
if (createRelease && results.tag) {
|
|
356
|
-
const releaseResult = await this.createRelease(projectPath, version || '1.0.0', platforms);
|
|
357
|
-
results.release = releaseResult.success;
|
|
358
|
-
}
|
|
359
|
-
const allSuccessful = Object.values(results).filter(r => r !== false).every(r => r);
|
|
360
|
-
return {
|
|
361
|
-
success: allSuccessful,
|
|
362
|
-
action: 'release-workflow',
|
|
363
|
-
message: `Workflow de release ${allSuccessful ? 'concluído' : 'com problemas'}`,
|
|
364
|
-
data: {
|
|
365
|
-
version,
|
|
366
|
-
platforms,
|
|
367
|
-
results,
|
|
368
|
-
implementation: 'RELEASE_WORKFLOW_v2.39.0'
|
|
384
|
+
const statusResult = await gitOps.status({ porcelain: true });
|
|
385
|
+
if (statusResult.output.trim()) {
|
|
386
|
+
const commitResult = await gitOps.commit(message);
|
|
387
|
+
if (!commitResult.success) {
|
|
388
|
+
throw new Error(`Commit failed: ${commitResult.error}`);
|
|
369
389
|
}
|
|
370
|
-
};
|
|
371
|
-
}
|
|
372
|
-
catch (error) {
|
|
373
|
-
return {
|
|
374
|
-
success: false,
|
|
375
|
-
action: 'release-workflow',
|
|
376
|
-
message: 'Erro no workflow de release',
|
|
377
|
-
error: error instanceof Error ? error.message : String(error)
|
|
378
|
-
};
|
|
379
|
-
}
|
|
380
|
-
},
|
|
381
|
-
// Handler para cleanup-workflow
|
|
382
|
-
async handleCleanupWorkflow(params) {
|
|
383
|
-
try {
|
|
384
|
-
const { projectPath, removeMergedBranches = true, removeOldBackups = true, optimizeRepository = true, daysOld = 30 } = params;
|
|
385
|
-
const results = {
|
|
386
|
-
mergedBranches: false,
|
|
387
|
-
oldBackups: false,
|
|
388
|
-
optimization: false
|
|
389
|
-
};
|
|
390
|
-
// 1. Remove merged branches if requested
|
|
391
|
-
if (removeMergedBranches) {
|
|
392
|
-
const branchResult = await this.removeMergedBranches(projectPath);
|
|
393
|
-
results.mergedBranches = branchResult.success;
|
|
394
|
-
}
|
|
395
|
-
// 2. Remove old backup stashes if requested
|
|
396
|
-
if (removeOldBackups) {
|
|
397
|
-
const backupResult = await this.removeOldBackups(projectPath, daysOld);
|
|
398
|
-
results.oldBackups = backupResult.success;
|
|
399
390
|
}
|
|
400
|
-
//
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
391
|
+
// Push
|
|
392
|
+
const pushOptions = {};
|
|
393
|
+
if (forcePush)
|
|
394
|
+
pushOptions.force = true;
|
|
395
|
+
const pushResult = await gitOps.push('origin', branch, pushOptions);
|
|
396
|
+
if (!pushResult.success) {
|
|
397
|
+
throw new Error(`Push failed: ${pushResult.error}`);
|
|
404
398
|
}
|
|
405
|
-
const allSuccessful = Object.values(results).filter(r => r !== false).every(r => r);
|
|
406
|
-
return {
|
|
407
|
-
success: allSuccessful,
|
|
408
|
-
action: 'cleanup-workflow',
|
|
409
|
-
message: `Limpeza de repositório ${allSuccessful ? 'concluída' : 'com problemas'}`,
|
|
410
|
-
data: {
|
|
411
|
-
results,
|
|
412
|
-
daysOld,
|
|
413
|
-
implementation: 'CLEANUP_WORKFLOW_v2.39.0'
|
|
414
|
-
}
|
|
415
|
-
};
|
|
416
|
-
}
|
|
417
|
-
catch (error) {
|
|
418
|
-
return {
|
|
419
|
-
success: false,
|
|
420
|
-
action: 'cleanup-workflow',
|
|
421
|
-
message: 'Erro na limpeza de repositório',
|
|
422
|
-
error: error instanceof Error ? error.message : String(error)
|
|
423
|
-
};
|
|
424
|
-
}
|
|
425
|
-
},
|
|
426
|
-
// Helper methods
|
|
427
|
-
async initializeGit(projectPath) {
|
|
428
|
-
try {
|
|
429
|
-
// TODO: Initialize Git repository
|
|
430
|
-
return { success: true };
|
|
431
|
-
}
|
|
432
|
-
catch (error) {
|
|
433
|
-
return {
|
|
434
|
-
success: false,
|
|
435
|
-
error: error instanceof Error ? error.message : String(error)
|
|
436
|
-
};
|
|
437
|
-
}
|
|
438
|
-
},
|
|
439
|
-
async createRemoteRepository(repo, provider, projectPath) {
|
|
440
|
-
try {
|
|
441
|
-
// TODO: Create remote repository
|
|
442
|
-
return { success: true };
|
|
443
|
-
}
|
|
444
|
-
catch (error) {
|
|
445
|
-
return {
|
|
446
|
-
success: false,
|
|
447
|
-
error: error instanceof Error ? error.message : String(error)
|
|
448
|
-
};
|
|
449
|
-
}
|
|
450
|
-
},
|
|
451
|
-
async applyTemplate(projectPath, template) {
|
|
452
|
-
try {
|
|
453
|
-
// TODO: Apply project template
|
|
454
|
-
return { success: true };
|
|
455
|
-
}
|
|
456
|
-
catch (error) {
|
|
457
399
|
return {
|
|
458
|
-
success:
|
|
459
|
-
|
|
400
|
+
success: true,
|
|
401
|
+
action: 'sync',
|
|
402
|
+
message: 'Sync completed successfully',
|
|
403
|
+
data: { pulled: pullResult.success, pushed: true, branch }
|
|
460
404
|
};
|
|
461
405
|
}
|
|
462
|
-
},
|
|
463
|
-
async autoConfigureProject(projectPath, template, platforms) {
|
|
464
|
-
try {
|
|
465
|
-
// TODO: Auto-configure project
|
|
466
|
-
return { success: true };
|
|
467
|
-
}
|
|
468
406
|
catch (error) {
|
|
469
|
-
return
|
|
470
|
-
success: false,
|
|
471
|
-
error: error instanceof Error ? error.message : String(error)
|
|
472
|
-
};
|
|
407
|
+
return WorkflowErrorHandler.handleError(error, 'sync');
|
|
473
408
|
}
|
|
474
409
|
},
|
|
475
|
-
async
|
|
410
|
+
async handleStatus(params) {
|
|
411
|
+
const { projectPath, detailed } = params;
|
|
412
|
+
const gitOps = new git_operations_js_1.GitOperations(projectPath);
|
|
476
413
|
try {
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
414
|
+
const statusResult = await gitOps.status(detailed ? {} : { short: true });
|
|
415
|
+
if (!statusResult.success) {
|
|
416
|
+
throw new Error(`Status check failed: ${statusResult.error}`);
|
|
417
|
+
}
|
|
481
418
|
return {
|
|
482
|
-
success:
|
|
483
|
-
|
|
419
|
+
success: true,
|
|
420
|
+
action: 'status',
|
|
421
|
+
message: 'Status retrieved successfully',
|
|
422
|
+
data: { status: statusResult.output, detailed }
|
|
484
423
|
};
|
|
485
424
|
}
|
|
486
|
-
},
|
|
487
|
-
async runTests(projectPath) {
|
|
488
|
-
try {
|
|
489
|
-
// TODO: Run test suite
|
|
490
|
-
return { success: true };
|
|
491
|
-
}
|
|
492
425
|
catch (error) {
|
|
493
|
-
return
|
|
494
|
-
success: false,
|
|
495
|
-
error: error instanceof Error ? error.message : String(error)
|
|
496
|
-
};
|
|
426
|
+
return WorkflowErrorHandler.handleError(error, 'status');
|
|
497
427
|
}
|
|
498
428
|
},
|
|
499
|
-
async
|
|
429
|
+
async handleDiff(params) {
|
|
430
|
+
const { projectPath, staged, file } = params;
|
|
431
|
+
const gitOps = new git_operations_js_1.GitOperations(projectPath);
|
|
500
432
|
try {
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
433
|
+
const diffOptions = { patch: true };
|
|
434
|
+
if (staged)
|
|
435
|
+
diffOptions.cached = true;
|
|
436
|
+
if (file)
|
|
437
|
+
diffOptions.path = file;
|
|
438
|
+
const diffResult = await gitOps.diff(diffOptions);
|
|
505
439
|
return {
|
|
506
|
-
success:
|
|
507
|
-
|
|
440
|
+
success: true,
|
|
441
|
+
action: 'diff',
|
|
442
|
+
message: 'Diff retrieved successfully',
|
|
443
|
+
data: { diff: diffResult.output, staged, file }
|
|
508
444
|
};
|
|
509
445
|
}
|
|
510
|
-
},
|
|
511
|
-
async smartCommit(projectPath) {
|
|
512
|
-
try {
|
|
513
|
-
// TODO: Smart commit
|
|
514
|
-
return { success: true };
|
|
515
|
-
}
|
|
516
446
|
catch (error) {
|
|
517
|
-
return
|
|
518
|
-
success: false,
|
|
519
|
-
error: error instanceof Error ? error.message : String(error)
|
|
520
|
-
};
|
|
447
|
+
return WorkflowErrorHandler.handleError(error, 'diff');
|
|
521
448
|
}
|
|
522
449
|
},
|
|
523
|
-
async
|
|
450
|
+
async handleLog(params) {
|
|
451
|
+
const { projectPath, limit, oneline } = params;
|
|
452
|
+
const gitOps = new git_operations_js_1.GitOperations(projectPath);
|
|
524
453
|
try {
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
454
|
+
const logOptions = { maxCount: limit };
|
|
455
|
+
if (oneline)
|
|
456
|
+
logOptions.oneline = true;
|
|
457
|
+
const logResult = await gitOps.log(logOptions);
|
|
458
|
+
if (!logResult.success) {
|
|
459
|
+
throw new Error(`Log retrieval failed: ${logResult.error}`);
|
|
460
|
+
}
|
|
529
461
|
return {
|
|
530
|
-
success:
|
|
531
|
-
|
|
462
|
+
success: true,
|
|
463
|
+
action: 'log',
|
|
464
|
+
message: 'Log retrieved successfully',
|
|
465
|
+
data: { log: logResult.output, limit, oneline }
|
|
532
466
|
};
|
|
533
467
|
}
|
|
534
|
-
},
|
|
535
|
-
async createFeatureBranch(projectPath, featureName, baseBranch) {
|
|
536
|
-
try {
|
|
537
|
-
// TODO: Create feature branch
|
|
538
|
-
return { success: true };
|
|
539
|
-
}
|
|
540
468
|
catch (error) {
|
|
541
|
-
return
|
|
542
|
-
success: false,
|
|
543
|
-
error: error instanceof Error ? error.message : String(error)
|
|
544
|
-
};
|
|
469
|
+
return WorkflowErrorHandler.handleError(error, 'log');
|
|
545
470
|
}
|
|
546
471
|
},
|
|
547
|
-
async
|
|
472
|
+
async handleCreateRepo(params) {
|
|
473
|
+
const { name, description, private: isPrivate, provider } = params;
|
|
548
474
|
try {
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
475
|
+
const processedInput = await (0, user_detection_js_1.applyAutoUserDetection)({ provider }, provider);
|
|
476
|
+
const providerInstance = index_js_1.globalProviderFactory.getProvider(provider);
|
|
477
|
+
if (!providerInstance) {
|
|
478
|
+
throw new Error(`Provider ${provider} not configured`);
|
|
479
|
+
}
|
|
480
|
+
const repo = await providerInstance.createRepository(name, description || `Repository created via MCP`, isPrivate);
|
|
553
481
|
return {
|
|
554
|
-
success:
|
|
555
|
-
|
|
482
|
+
success: true,
|
|
483
|
+
action: 'create-repo',
|
|
484
|
+
message: 'Repository created successfully',
|
|
485
|
+
data: {
|
|
486
|
+
name,
|
|
487
|
+
url: repo.html_url,
|
|
488
|
+
clone_url: repo.clone_url,
|
|
489
|
+
private: repo.private
|
|
490
|
+
}
|
|
556
491
|
};
|
|
557
492
|
}
|
|
558
|
-
},
|
|
559
|
-
async createPullRequest(projectPath, featureName) {
|
|
560
|
-
try {
|
|
561
|
-
// TODO: Create pull request
|
|
562
|
-
return { success: true };
|
|
563
|
-
}
|
|
564
493
|
catch (error) {
|
|
565
|
-
return
|
|
566
|
-
success: false,
|
|
567
|
-
error: error instanceof Error ? error.message : String(error)
|
|
568
|
-
};
|
|
494
|
+
return WorkflowErrorHandler.handleError(error, 'create-repo');
|
|
569
495
|
}
|
|
570
496
|
},
|
|
571
|
-
async
|
|
497
|
+
async handleCloneRepo(params) {
|
|
498
|
+
const { name, provider, projectPath, branch } = params;
|
|
572
499
|
try {
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
500
|
+
const processedInput = await (0, user_detection_js_1.applyAutoUserDetection)({ provider }, provider);
|
|
501
|
+
const providerInstance = index_js_1.globalProviderFactory.getProvider(provider);
|
|
502
|
+
if (!providerInstance) {
|
|
503
|
+
throw new Error(`Provider ${provider} not configured`);
|
|
504
|
+
}
|
|
505
|
+
const repo = await providerInstance.getRepository(processedInput.owner, name);
|
|
506
|
+
const gitOps = new git_operations_js_1.GitOperations(projectPath);
|
|
507
|
+
// Clone repository
|
|
508
|
+
const cloneResult = await gitOps.cloneRepository(repo.clone_url, undefined, { branch });
|
|
509
|
+
if (!cloneResult.success) {
|
|
510
|
+
throw new Error(`Clone failed: ${cloneResult.error}`);
|
|
511
|
+
}
|
|
577
512
|
return {
|
|
578
|
-
success:
|
|
579
|
-
|
|
513
|
+
success: true,
|
|
514
|
+
action: 'clone-repo',
|
|
515
|
+
message: 'Repository cloned successfully',
|
|
516
|
+
data: {
|
|
517
|
+
path: projectPath,
|
|
518
|
+
url: repo.clone_url,
|
|
519
|
+
branch,
|
|
520
|
+
name: repo.name
|
|
521
|
+
}
|
|
580
522
|
};
|
|
581
523
|
}
|
|
582
|
-
},
|
|
583
|
-
async createReleaseTag(projectPath, version) {
|
|
584
|
-
try {
|
|
585
|
-
// TODO: Create release tag
|
|
586
|
-
return { success: true };
|
|
587
|
-
}
|
|
588
524
|
catch (error) {
|
|
589
|
-
return
|
|
590
|
-
success: false,
|
|
591
|
-
error: error instanceof Error ? error.message : String(error)
|
|
592
|
-
};
|
|
525
|
+
return WorkflowErrorHandler.handleError(error, 'clone-repo');
|
|
593
526
|
}
|
|
594
527
|
},
|
|
595
|
-
async
|
|
528
|
+
async handlePull(params) {
|
|
529
|
+
const { projectPath, branch } = params;
|
|
530
|
+
const gitOps = new git_operations_js_1.GitOperations(projectPath);
|
|
596
531
|
try {
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
532
|
+
const pullResult = await gitOps.pull('origin', branch);
|
|
533
|
+
if (!pullResult.success && !pullResult.error?.includes('up-to-date')) {
|
|
534
|
+
throw new Error(`Pull failed: ${pullResult.error}`);
|
|
535
|
+
}
|
|
601
536
|
return {
|
|
602
|
-
success:
|
|
603
|
-
|
|
537
|
+
success: true,
|
|
538
|
+
action: 'pull',
|
|
539
|
+
message: pullResult.error?.includes('up-to-date') ? 'Already up-to-date' : 'Pull completed successfully',
|
|
540
|
+
data: { branch, upToDate: pullResult.error?.includes('up-to-date') || false }
|
|
604
541
|
};
|
|
605
542
|
}
|
|
606
|
-
},
|
|
607
|
-
async removeMergedBranches(projectPath) {
|
|
608
|
-
try {
|
|
609
|
-
// TODO: Remove merged branches
|
|
610
|
-
return { success: true };
|
|
611
|
-
}
|
|
612
543
|
catch (error) {
|
|
613
|
-
return
|
|
614
|
-
success: false,
|
|
615
|
-
error: error instanceof Error ? error.message : String(error)
|
|
616
|
-
};
|
|
544
|
+
return WorkflowErrorHandler.handleError(error, 'pull');
|
|
617
545
|
}
|
|
618
546
|
},
|
|
619
|
-
async
|
|
547
|
+
async handlePush(params) {
|
|
548
|
+
const { projectPath, branch, force } = params;
|
|
549
|
+
const gitOps = new git_operations_js_1.GitOperations(projectPath);
|
|
620
550
|
try {
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
551
|
+
const pushOptions = {};
|
|
552
|
+
if (force)
|
|
553
|
+
pushOptions.force = true;
|
|
554
|
+
const pushResult = await gitOps.push('origin', branch, pushOptions);
|
|
555
|
+
if (!pushResult.success) {
|
|
556
|
+
throw new Error(`Push failed: ${pushResult.error}`);
|
|
557
|
+
}
|
|
625
558
|
return {
|
|
626
|
-
success:
|
|
627
|
-
|
|
559
|
+
success: true,
|
|
560
|
+
action: 'push',
|
|
561
|
+
message: 'Push completed successfully',
|
|
562
|
+
data: { branch, force }
|
|
628
563
|
};
|
|
629
564
|
}
|
|
630
|
-
},
|
|
631
|
-
async optimizeRepository(projectPath) {
|
|
632
|
-
try {
|
|
633
|
-
// TODO: Optimize repository
|
|
634
|
-
return { success: true };
|
|
635
|
-
}
|
|
636
565
|
catch (error) {
|
|
637
|
-
return
|
|
638
|
-
success: false,
|
|
639
|
-
error: error instanceof Error ? error.message : String(error)
|
|
640
|
-
};
|
|
566
|
+
return WorkflowErrorHandler.handleError(error, 'push');
|
|
641
567
|
}
|
|
642
568
|
}
|
|
643
569
|
};
|