n8n-nodes-github-copilot 3.38.25 → 3.38.26
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/credentials/GitHubCopilotApi.credentials.d.ts +1 -1
- package/dist/credentials/GitHubCopilotApi.credentials.js +25 -25
- package/dist/nodes/GitHubCopilot/GitHubCopilot.node.d.ts +1 -1
- package/dist/nodes/GitHubCopilot/GitHubCopilot.node.js +166 -166
- package/dist/nodes/GitHubCopilotAuthHelper/GitHubCopilotAuthHelper.node.d.ts +1 -1
- package/dist/nodes/GitHubCopilotAuthHelper/GitHubCopilotAuthHelper.node.js +539 -539
- package/dist/nodes/GitHubCopilotChatAPI/GitHubCopilotChatAPI.node.d.ts +1 -1
- package/dist/nodes/GitHubCopilotChatAPI/GitHubCopilotChatAPI.node.js +46 -44
- package/dist/nodes/GitHubCopilotChatAPI/nodeProperties.d.ts +1 -1
- package/dist/nodes/GitHubCopilotChatAPI/nodeProperties.js +82 -82
- package/dist/nodes/GitHubCopilotChatAPI/utils/helpers.d.ts +2 -2
- package/dist/nodes/GitHubCopilotChatAPI/utils/helpers.js +26 -26
- package/dist/nodes/GitHubCopilotChatAPI/utils/imageProcessor.d.ts +2 -2
- package/dist/nodes/GitHubCopilotChatAPI/utils/imageProcessor.js +12 -12
- package/dist/nodes/GitHubCopilotChatAPI/utils/index.d.ts +4 -4
- package/dist/nodes/GitHubCopilotChatAPI/utils/mediaDetection.d.ts +3 -3
- package/dist/nodes/GitHubCopilotChatAPI/utils/mediaDetection.js +19 -19
- package/dist/nodes/GitHubCopilotChatAPI/utils/modelCapabilities.d.ts +1 -1
- package/dist/nodes/GitHubCopilotChatAPI/utils/modelCapabilities.js +23 -23
- package/dist/nodes/GitHubCopilotChatAPI/utils/types.d.ts +5 -5
- package/dist/nodes/GitHubCopilotChatModel/GitHubCopilotChatModel.node.d.ts +1 -1
- package/dist/nodes/GitHubCopilotChatModel/GitHubCopilotChatModel.node.js +115 -106
- package/dist/nodes/GitHubCopilotEmbeddings/GitHubCopilotEmbeddings.node.d.ts +1 -1
- package/dist/nodes/GitHubCopilotEmbeddings/GitHubCopilotEmbeddings.node.js +114 -114
- package/dist/nodes/GitHubCopilotOpenAI/GitHubCopilotOpenAI.node.d.ts +1 -1
- package/dist/nodes/GitHubCopilotOpenAI/GitHubCopilotOpenAI.node.js +74 -69
- package/dist/nodes/GitHubCopilotOpenAI/nodeProperties.d.ts +1 -1
- package/dist/nodes/GitHubCopilotOpenAI/nodeProperties.js +181 -181
- package/dist/nodes/GitHubCopilotOpenAI/utils/index.d.ts +2 -2
- package/dist/nodes/GitHubCopilotOpenAI/utils/openaiCompat.d.ts +10 -10
- package/dist/nodes/GitHubCopilotOpenAI/utils/openaiCompat.js +53 -53
- package/dist/nodes/GitHubCopilotOpenAI/utils/types.d.ts +12 -12
- package/dist/nodes/GitHubCopilotTest/GitHubCopilotTest.node.d.ts +1 -1
- package/dist/nodes/GitHubCopilotTest/GitHubCopilotTest.node.js +120 -116
- package/dist/package.json +1 -1
- package/package.json +1 -1
|
@@ -6,16 +6,16 @@ const child_process_1 = require("child_process");
|
|
|
6
6
|
const util_1 = require("util");
|
|
7
7
|
const execAsync = (0, util_1.promisify)(child_process_1.exec);
|
|
8
8
|
function filterCopilotOutput(rawOutput) {
|
|
9
|
-
const lines = rawOutput.split(
|
|
9
|
+
const lines = rawOutput.split('\n');
|
|
10
10
|
let startIndex = -1;
|
|
11
11
|
const endIndex = lines.length;
|
|
12
12
|
for (let i = 0; i < lines.length; i++) {
|
|
13
13
|
const line = lines[i].trim();
|
|
14
|
-
if (line.includes(
|
|
15
|
-
line.includes(
|
|
16
|
-
line.includes(
|
|
17
|
-
line.includes(
|
|
18
|
-
(line.startsWith(
|
|
14
|
+
if (line.includes('# Explanation:') ||
|
|
15
|
+
line.includes('# Suggestion:') ||
|
|
16
|
+
line.includes('# Command:') ||
|
|
17
|
+
line.includes('# Code:') ||
|
|
18
|
+
(line.startsWith('•') && i > 5)) {
|
|
19
19
|
startIndex = i;
|
|
20
20
|
break;
|
|
21
21
|
}
|
|
@@ -23,7 +23,7 @@ function filterCopilotOutput(rawOutput) {
|
|
|
23
23
|
if (startIndex === -1) {
|
|
24
24
|
for (let i = 0; i < lines.length; i++) {
|
|
25
25
|
const line = lines[i].trim();
|
|
26
|
-
if (line.includes(
|
|
26
|
+
if (line.includes('version ') && line.includes('(') && line.includes(')')) {
|
|
27
27
|
startIndex = i + 3;
|
|
28
28
|
break;
|
|
29
29
|
}
|
|
@@ -32,7 +32,7 @@ function filterCopilotOutput(rawOutput) {
|
|
|
32
32
|
if (startIndex === -1) {
|
|
33
33
|
for (let i = 0; i < lines.length; i++) {
|
|
34
34
|
const line = lines[i].trim();
|
|
35
|
-
if (line.length > 10 && !line.includes(
|
|
35
|
+
if (line.length > 10 && !line.includes('Welcome to') && !line.includes('powered by AI')) {
|
|
36
36
|
startIndex = i;
|
|
37
37
|
break;
|
|
38
38
|
}
|
|
@@ -40,28 +40,28 @@ function filterCopilotOutput(rawOutput) {
|
|
|
40
40
|
}
|
|
41
41
|
if (startIndex >= 0) {
|
|
42
42
|
const filteredLines = lines.slice(startIndex, endIndex);
|
|
43
|
-
return filteredLines.join(
|
|
43
|
+
return filteredLines.join('\n').trim();
|
|
44
44
|
}
|
|
45
45
|
return rawOutput.trim();
|
|
46
46
|
}
|
|
47
47
|
class GitHubCopilot {
|
|
48
48
|
constructor() {
|
|
49
49
|
this.description = {
|
|
50
|
-
displayName:
|
|
51
|
-
name:
|
|
52
|
-
icon:
|
|
53
|
-
group: [
|
|
50
|
+
displayName: 'GitHub Copilot',
|
|
51
|
+
name: 'gitHubCopilot',
|
|
52
|
+
icon: 'file:../../shared/icons/copilot.svg',
|
|
53
|
+
group: ['transform'],
|
|
54
54
|
version: 1,
|
|
55
|
-
subtitle:
|
|
56
|
-
description:
|
|
55
|
+
subtitle: '',
|
|
56
|
+
description: 'Interact with GitHub Copilot API for code completions',
|
|
57
57
|
defaults: {
|
|
58
|
-
name:
|
|
58
|
+
name: 'GitHub Copilot',
|
|
59
59
|
},
|
|
60
|
-
inputs: [
|
|
61
|
-
outputs: [
|
|
60
|
+
inputs: ['main'],
|
|
61
|
+
outputs: ['main'],
|
|
62
62
|
credentials: [
|
|
63
63
|
{
|
|
64
|
-
name:
|
|
64
|
+
name: 'githubCopilotApi',
|
|
65
65
|
required: false,
|
|
66
66
|
displayOptions: {
|
|
67
67
|
show: {
|
|
@@ -72,177 +72,177 @@ class GitHubCopilot {
|
|
|
72
72
|
],
|
|
73
73
|
properties: [
|
|
74
74
|
{
|
|
75
|
-
displayName:
|
|
76
|
-
name:
|
|
77
|
-
type:
|
|
75
|
+
displayName: 'Authentication Method',
|
|
76
|
+
name: 'useCredential',
|
|
77
|
+
type: 'boolean',
|
|
78
78
|
default: false,
|
|
79
|
-
description:
|
|
79
|
+
description: 'Use GitHub Copilot API credential instead of local GitHub CLI authentication',
|
|
80
80
|
},
|
|
81
81
|
{
|
|
82
|
-
displayName:
|
|
83
|
-
name:
|
|
84
|
-
type:
|
|
82
|
+
displayName: 'Operation',
|
|
83
|
+
name: 'operation',
|
|
84
|
+
type: 'options',
|
|
85
85
|
noDataExpression: true,
|
|
86
86
|
options: [
|
|
87
87
|
{
|
|
88
|
-
name:
|
|
89
|
-
value:
|
|
90
|
-
description:
|
|
91
|
-
action:
|
|
88
|
+
name: 'Suggest',
|
|
89
|
+
value: 'suggest',
|
|
90
|
+
description: 'Get code suggestions from GitHub Copilot',
|
|
91
|
+
action: 'Get code suggestions',
|
|
92
92
|
},
|
|
93
93
|
{
|
|
94
|
-
name:
|
|
95
|
-
value:
|
|
96
|
-
description:
|
|
97
|
-
action:
|
|
94
|
+
name: 'Explain',
|
|
95
|
+
value: 'explain',
|
|
96
|
+
description: 'Explain code or commands using GitHub Copilot',
|
|
97
|
+
action: 'Explain code or commands',
|
|
98
98
|
},
|
|
99
99
|
{
|
|
100
|
-
name:
|
|
101
|
-
value:
|
|
102
|
-
description:
|
|
103
|
-
action:
|
|
100
|
+
name: 'Shell',
|
|
101
|
+
value: 'shell',
|
|
102
|
+
description: 'Get shell command suggestions from GitHub Copilot',
|
|
103
|
+
action: 'Get shell command suggestions',
|
|
104
104
|
},
|
|
105
105
|
{
|
|
106
|
-
name:
|
|
107
|
-
value:
|
|
108
|
-
description:
|
|
109
|
-
action:
|
|
106
|
+
name: 'Revise',
|
|
107
|
+
value: 'revise',
|
|
108
|
+
description: 'Revise and improve existing code or commands',
|
|
109
|
+
action: 'Revise code or commands',
|
|
110
110
|
},
|
|
111
111
|
{
|
|
112
|
-
name:
|
|
113
|
-
value:
|
|
114
|
-
description:
|
|
115
|
-
action:
|
|
112
|
+
name: 'Rate Response',
|
|
113
|
+
value: 'rating',
|
|
114
|
+
description: 'Rate a previous GitHub Copilot response',
|
|
115
|
+
action: 'Rate response',
|
|
116
116
|
},
|
|
117
117
|
],
|
|
118
|
-
default:
|
|
118
|
+
default: 'suggest',
|
|
119
119
|
},
|
|
120
120
|
{
|
|
121
|
-
displayName:
|
|
122
|
-
name:
|
|
123
|
-
type:
|
|
121
|
+
displayName: 'Prompt',
|
|
122
|
+
name: 'prompt',
|
|
123
|
+
type: 'string',
|
|
124
124
|
typeOptions: {
|
|
125
125
|
rows: 3,
|
|
126
126
|
},
|
|
127
127
|
required: true,
|
|
128
|
-
default:
|
|
129
|
-
placeholder:
|
|
130
|
-
description:
|
|
128
|
+
default: '',
|
|
129
|
+
placeholder: 'Enter your request...',
|
|
130
|
+
description: 'What you want GitHub Copilot to help with',
|
|
131
131
|
},
|
|
132
132
|
{
|
|
133
|
-
displayName:
|
|
134
|
-
name:
|
|
135
|
-
type:
|
|
133
|
+
displayName: 'Filter Output',
|
|
134
|
+
name: 'filterOutput',
|
|
135
|
+
type: 'boolean',
|
|
136
136
|
default: true,
|
|
137
|
-
description:
|
|
137
|
+
description: 'Remove GitHub Copilot CLI header and footer, keeping only the useful response',
|
|
138
138
|
},
|
|
139
139
|
{
|
|
140
|
-
displayName:
|
|
141
|
-
name:
|
|
142
|
-
type:
|
|
140
|
+
displayName: 'Language',
|
|
141
|
+
name: 'language',
|
|
142
|
+
type: 'options',
|
|
143
143
|
displayOptions: {
|
|
144
144
|
show: {
|
|
145
|
-
operation: [
|
|
145
|
+
operation: ['suggest'],
|
|
146
146
|
},
|
|
147
147
|
},
|
|
148
148
|
options: [
|
|
149
|
-
{ name:
|
|
150
|
-
{ name:
|
|
151
|
-
{ name:
|
|
152
|
-
{ name:
|
|
153
|
-
{ name:
|
|
154
|
-
{ name:
|
|
155
|
-
{ name:
|
|
156
|
-
{ name:
|
|
157
|
-
{ name:
|
|
158
|
-
{ name:
|
|
159
|
-
{ name:
|
|
160
|
-
{ name:
|
|
161
|
-
{ name:
|
|
149
|
+
{ name: 'JavaScript', value: 'javascript' },
|
|
150
|
+
{ name: 'TypeScript', value: 'typescript' },
|
|
151
|
+
{ name: 'Python', value: 'python' },
|
|
152
|
+
{ name: 'Java', value: 'java' },
|
|
153
|
+
{ name: 'C#', value: 'csharp' },
|
|
154
|
+
{ name: 'C++', value: 'cpp' },
|
|
155
|
+
{ name: 'Go', value: 'go' },
|
|
156
|
+
{ name: 'Rust', value: 'rust' },
|
|
157
|
+
{ name: 'PHP', value: 'php' },
|
|
158
|
+
{ name: 'Ruby', value: 'ruby' },
|
|
159
|
+
{ name: 'Shell', value: 'shell' },
|
|
160
|
+
{ name: 'SQL', value: 'sql' },
|
|
161
|
+
{ name: 'Other', value: 'other' },
|
|
162
162
|
],
|
|
163
|
-
default:
|
|
164
|
-
description:
|
|
163
|
+
default: 'javascript',
|
|
164
|
+
description: 'Programming language for code suggestions',
|
|
165
165
|
},
|
|
166
166
|
{
|
|
167
|
-
displayName:
|
|
168
|
-
name:
|
|
169
|
-
type:
|
|
167
|
+
displayName: 'Command Type',
|
|
168
|
+
name: 'commandType',
|
|
169
|
+
type: 'options',
|
|
170
170
|
displayOptions: {
|
|
171
171
|
show: {
|
|
172
|
-
operation: [
|
|
172
|
+
operation: ['shell'],
|
|
173
173
|
},
|
|
174
174
|
},
|
|
175
175
|
options: [
|
|
176
|
-
{ name:
|
|
177
|
-
{ name:
|
|
178
|
-
{ name:
|
|
179
|
-
{ name:
|
|
180
|
-
{ name:
|
|
176
|
+
{ name: 'General', value: 'general' },
|
|
177
|
+
{ name: 'Git', value: 'git' },
|
|
178
|
+
{ name: 'Docker', value: 'docker' },
|
|
179
|
+
{ name: 'npm/yarn', value: 'npm' },
|
|
180
|
+
{ name: 'File Operations', value: 'file' },
|
|
181
181
|
],
|
|
182
|
-
default:
|
|
183
|
-
description:
|
|
182
|
+
default: 'general',
|
|
183
|
+
description: 'Type of shell commands to suggest',
|
|
184
184
|
},
|
|
185
185
|
{
|
|
186
|
-
displayName:
|
|
187
|
-
name:
|
|
188
|
-
type:
|
|
186
|
+
displayName: 'Additional Context',
|
|
187
|
+
name: 'context',
|
|
188
|
+
type: 'string',
|
|
189
189
|
typeOptions: {
|
|
190
190
|
rows: 2,
|
|
191
191
|
},
|
|
192
|
-
default:
|
|
193
|
-
placeholder:
|
|
194
|
-
description:
|
|
192
|
+
default: '',
|
|
193
|
+
placeholder: 'Any additional context or constraints...',
|
|
194
|
+
description: 'Optional additional context to provide better suggestions',
|
|
195
195
|
},
|
|
196
196
|
{
|
|
197
|
-
displayName:
|
|
198
|
-
name:
|
|
199
|
-
type:
|
|
197
|
+
displayName: 'Original Code/Command',
|
|
198
|
+
name: 'originalCode',
|
|
199
|
+
type: 'string',
|
|
200
200
|
typeOptions: {
|
|
201
201
|
rows: 4,
|
|
202
202
|
},
|
|
203
203
|
required: true,
|
|
204
|
-
default:
|
|
205
|
-
placeholder:
|
|
206
|
-
description:
|
|
204
|
+
default: '',
|
|
205
|
+
placeholder: 'Enter the original code or command to revise...',
|
|
206
|
+
description: 'The original code or command that you want to improve',
|
|
207
207
|
displayOptions: {
|
|
208
208
|
show: {
|
|
209
|
-
operation: [
|
|
209
|
+
operation: ['revise'],
|
|
210
210
|
},
|
|
211
211
|
},
|
|
212
212
|
},
|
|
213
213
|
{
|
|
214
|
-
displayName:
|
|
215
|
-
name:
|
|
216
|
-
type:
|
|
214
|
+
displayName: 'Rating',
|
|
215
|
+
name: 'rating',
|
|
216
|
+
type: 'options',
|
|
217
217
|
options: [
|
|
218
|
-
{ name:
|
|
219
|
-
{ name:
|
|
220
|
-
{ name:
|
|
221
|
-
{ name:
|
|
218
|
+
{ name: 'Very Good', value: 'very-good' },
|
|
219
|
+
{ name: 'Good', value: 'good' },
|
|
220
|
+
{ name: 'Fair', value: 'fair' },
|
|
221
|
+
{ name: 'Poor', value: 'poor' },
|
|
222
222
|
],
|
|
223
223
|
required: true,
|
|
224
|
-
default:
|
|
225
|
-
description:
|
|
224
|
+
default: 'good',
|
|
225
|
+
description: 'Rate the GitHub Copilot response',
|
|
226
226
|
displayOptions: {
|
|
227
227
|
show: {
|
|
228
|
-
operation: [
|
|
228
|
+
operation: ['rating'],
|
|
229
229
|
},
|
|
230
230
|
},
|
|
231
231
|
},
|
|
232
232
|
{
|
|
233
|
-
displayName:
|
|
234
|
-
name:
|
|
235
|
-
type:
|
|
233
|
+
displayName: 'Response to Rate',
|
|
234
|
+
name: 'responseToRate',
|
|
235
|
+
type: 'string',
|
|
236
236
|
typeOptions: {
|
|
237
237
|
rows: 3,
|
|
238
238
|
},
|
|
239
239
|
required: true,
|
|
240
|
-
default:
|
|
241
|
-
placeholder:
|
|
242
|
-
description:
|
|
240
|
+
default: '',
|
|
241
|
+
placeholder: 'Enter the GitHub Copilot response you want to rate...',
|
|
242
|
+
description: 'The GitHub Copilot response that you want to rate',
|
|
243
243
|
displayOptions: {
|
|
244
244
|
show: {
|
|
245
|
-
operation: [
|
|
245
|
+
operation: ['rating'],
|
|
246
246
|
},
|
|
247
247
|
},
|
|
248
248
|
},
|
|
@@ -254,60 +254,60 @@ class GitHubCopilot {
|
|
|
254
254
|
const returnData = [];
|
|
255
255
|
for (let i = 0; i < items.length; i++) {
|
|
256
256
|
try {
|
|
257
|
-
const operation = this.getNodeParameter(
|
|
258
|
-
const prompt = this.getNodeParameter(
|
|
259
|
-
const context = this.getNodeParameter(
|
|
260
|
-
const useCredential = this.getNodeParameter(
|
|
261
|
-
let githubToken =
|
|
262
|
-
let authMethod =
|
|
257
|
+
const operation = this.getNodeParameter('operation', i);
|
|
258
|
+
const prompt = this.getNodeParameter('prompt', i);
|
|
259
|
+
const context = this.getNodeParameter('context', i, '');
|
|
260
|
+
const useCredential = this.getNodeParameter('useCredential', i, false);
|
|
261
|
+
let githubToken = '';
|
|
262
|
+
let authMethod = 'Local CLI';
|
|
263
263
|
if (useCredential) {
|
|
264
264
|
try {
|
|
265
|
-
const credentials = await this.getCredentials(
|
|
265
|
+
const credentials = await this.getCredentials('githubCopilotApi');
|
|
266
266
|
const token = credentials.token;
|
|
267
267
|
if (token) {
|
|
268
268
|
githubToken = token;
|
|
269
|
-
authMethod =
|
|
269
|
+
authMethod = 'GitHub Copilot API Credential';
|
|
270
270
|
}
|
|
271
271
|
}
|
|
272
272
|
catch {
|
|
273
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(),
|
|
273
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'GitHub Copilot credential is not configured. Please configure it or use Local CLI authentication.');
|
|
274
274
|
}
|
|
275
275
|
}
|
|
276
|
-
const useToken = githubToken && githubToken.trim() !==
|
|
276
|
+
const useToken = githubToken && githubToken.trim() !== '';
|
|
277
277
|
let command;
|
|
278
278
|
let fullPrompt = prompt;
|
|
279
279
|
if (context) {
|
|
280
280
|
fullPrompt = `${prompt}\n\nAdditional context: ${context}`;
|
|
281
281
|
}
|
|
282
282
|
switch (operation) {
|
|
283
|
-
case
|
|
284
|
-
const language = this.getNodeParameter(
|
|
285
|
-
if (language !==
|
|
283
|
+
case 'suggest': {
|
|
284
|
+
const language = this.getNodeParameter('language', i);
|
|
285
|
+
if (language !== 'other') {
|
|
286
286
|
fullPrompt = `[${language}] ${fullPrompt}`;
|
|
287
287
|
}
|
|
288
288
|
const escapedSuggestPrompt = fullPrompt.replace(/'/g, "'\"'\"'");
|
|
289
289
|
command = `gh copilot suggest '${escapedSuggestPrompt}'`;
|
|
290
290
|
break;
|
|
291
291
|
}
|
|
292
|
-
case
|
|
292
|
+
case 'explain': {
|
|
293
293
|
const escapedExplainPrompt = fullPrompt.replace(/'/g, "'\"'\"'");
|
|
294
294
|
command = `gh copilot explain '${escapedExplainPrompt}'`;
|
|
295
295
|
break;
|
|
296
296
|
}
|
|
297
|
-
case
|
|
298
|
-
const commandType = this.getNodeParameter(
|
|
297
|
+
case 'shell': {
|
|
298
|
+
const commandType = this.getNodeParameter('commandType', i);
|
|
299
299
|
let shellPrompt = fullPrompt;
|
|
300
300
|
switch (commandType) {
|
|
301
|
-
case
|
|
301
|
+
case 'git':
|
|
302
302
|
shellPrompt = `git: ${fullPrompt}`;
|
|
303
303
|
break;
|
|
304
|
-
case
|
|
304
|
+
case 'docker':
|
|
305
305
|
shellPrompt = `docker: ${fullPrompt}`;
|
|
306
306
|
break;
|
|
307
|
-
case
|
|
307
|
+
case 'npm':
|
|
308
308
|
shellPrompt = `npm/yarn: ${fullPrompt}`;
|
|
309
309
|
break;
|
|
310
|
-
case
|
|
310
|
+
case 'file':
|
|
311
311
|
shellPrompt = `file operations: ${fullPrompt}`;
|
|
312
312
|
break;
|
|
313
313
|
default:
|
|
@@ -317,16 +317,16 @@ class GitHubCopilot {
|
|
|
317
317
|
command = `gh copilot suggest '${escapedShellPrompt}' --type shell`;
|
|
318
318
|
break;
|
|
319
319
|
}
|
|
320
|
-
case
|
|
321
|
-
const originalCode = this.getNodeParameter(
|
|
320
|
+
case 'revise': {
|
|
321
|
+
const originalCode = this.getNodeParameter('originalCode', i);
|
|
322
322
|
const revisePrompt = `${fullPrompt}\n\nOriginal code/command:\n${originalCode}`;
|
|
323
323
|
const escapedRevisePrompt = revisePrompt.replace(/'/g, "'\"'\"'");
|
|
324
324
|
command = `gh copilot revise '${escapedRevisePrompt}'`;
|
|
325
325
|
break;
|
|
326
326
|
}
|
|
327
|
-
case
|
|
328
|
-
const rating = this.getNodeParameter(
|
|
329
|
-
const responseToRate = this.getNodeParameter(
|
|
327
|
+
case 'rating': {
|
|
328
|
+
const rating = this.getNodeParameter('rating', i);
|
|
329
|
+
const responseToRate = this.getNodeParameter('responseToRate', i);
|
|
330
330
|
const escapedResponseToRate = responseToRate.replace(/'/g, "'\"'\"'");
|
|
331
331
|
command = `gh copilot rate '${escapedResponseToRate}' --rating ${rating}`;
|
|
332
332
|
break;
|
|
@@ -334,11 +334,11 @@ class GitHubCopilot {
|
|
|
334
334
|
default:
|
|
335
335
|
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Unknown operation: ${operation}`);
|
|
336
336
|
}
|
|
337
|
-
console.log(
|
|
338
|
-
console.log(
|
|
339
|
-
console.log(
|
|
340
|
-
let stdout =
|
|
341
|
-
let stderr =
|
|
337
|
+
console.log('Executing command:', command);
|
|
338
|
+
console.log('Auth method:', authMethod);
|
|
339
|
+
console.log('Using token:', useToken ? 'Yes (Manual)' : 'No (Local CLI)');
|
|
340
|
+
let stdout = '';
|
|
341
|
+
let stderr = '';
|
|
342
342
|
try {
|
|
343
343
|
const envVars = {
|
|
344
344
|
...process.env,
|
|
@@ -358,34 +358,34 @@ class GitHubCopilot {
|
|
|
358
358
|
catch (execError) {
|
|
359
359
|
const err = execError;
|
|
360
360
|
stderr = err.stderr || err.message || String(execError);
|
|
361
|
-
stdout = err.stdout ||
|
|
361
|
+
stdout = err.stdout || '';
|
|
362
362
|
}
|
|
363
363
|
if (stderr) {
|
|
364
364
|
const debugInfo = useToken
|
|
365
365
|
? ` [Using manual token: ${githubToken.substring(0, 4)}...]`
|
|
366
|
-
:
|
|
367
|
-
if (stderr.includes(
|
|
366
|
+
: ' [Using local CLI authentication]';
|
|
367
|
+
if (stderr.includes('internal server error') || stderr.includes('code: 500')) {
|
|
368
368
|
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `GitHub Copilot service is temporarily unavailable (HTTP 500). This is a GitHub server issue. Please try again in a few moments.${debugInfo} Error: ${stderr}`);
|
|
369
369
|
}
|
|
370
|
-
else if (stderr.includes(
|
|
370
|
+
else if (stderr.includes('code: 400') || stderr.includes('Bad Request')) {
|
|
371
371
|
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `GitHub Copilot request failed (HTTP 400). The request is malformed or invalid.${debugInfo} Full error response: ${stderr}`);
|
|
372
372
|
}
|
|
373
|
-
else if (stderr.includes(
|
|
374
|
-
stderr.includes(
|
|
375
|
-
stderr.includes(
|
|
373
|
+
else if (stderr.includes('401') ||
|
|
374
|
+
stderr.includes('Unauthorized') ||
|
|
375
|
+
stderr.includes('Bad credentials')) {
|
|
376
376
|
const tokenHelp = useToken
|
|
377
|
-
?
|
|
378
|
-
:
|
|
377
|
+
? ' IMPORTANT: Only tokens generated by "gh auth token" command work with Copilot. Personal Access Tokens from GitHub website DO NOT work. Try: run "gh auth login" first, then use "gh auth token" to get a working token.'
|
|
378
|
+
: ' Please run "gh auth login" on the server first, or provide a token generated by "gh auth token" command.';
|
|
379
379
|
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `GitHub authentication failed (HTTP 401).${tokenHelp}${debugInfo} Full error response: ${stderr}`);
|
|
380
380
|
}
|
|
381
|
-
else if (stderr.includes(
|
|
381
|
+
else if (stderr.includes('403') || stderr.includes('Forbidden')) {
|
|
382
382
|
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `GitHub Copilot access denied (HTTP 403). Please ensure your account has Copilot subscription.${debugInfo} Full error response: ${stderr}`);
|
|
383
383
|
}
|
|
384
384
|
else if (!stdout) {
|
|
385
385
|
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `GitHub Copilot CLI error:${debugInfo} Full error response: ${stderr}`);
|
|
386
386
|
}
|
|
387
387
|
}
|
|
388
|
-
const filterOutput = this.getNodeParameter(
|
|
388
|
+
const filterOutput = this.getNodeParameter('filterOutput', i, true);
|
|
389
389
|
let processedOutput = stdout;
|
|
390
390
|
if (filterOutput) {
|
|
391
391
|
processedOutput = filterCopilotOutput(stdout);
|
|
@@ -397,12 +397,12 @@ class GitHubCopilot {
|
|
|
397
397
|
context: context || undefined,
|
|
398
398
|
authMethod: authMethod,
|
|
399
399
|
tokenUsed: useToken,
|
|
400
|
-
tokenPrefix: useToken ? githubToken.substring(0, 4) +
|
|
401
|
-
language: operation ===
|
|
402
|
-
commandType: operation ===
|
|
403
|
-
originalCode: operation ===
|
|
404
|
-
rating: operation ===
|
|
405
|
-
responseToRate: operation ===
|
|
400
|
+
tokenPrefix: useToken ? githubToken.substring(0, 4) + '...' : 'none',
|
|
401
|
+
language: operation === 'suggest' ? this.getNodeParameter('language', i) : undefined,
|
|
402
|
+
commandType: operation === 'shell' ? this.getNodeParameter('commandType', i) : undefined,
|
|
403
|
+
originalCode: operation === 'revise' ? this.getNodeParameter('originalCode', i) : undefined,
|
|
404
|
+
rating: operation === 'rating' ? this.getNodeParameter('rating', i) : undefined,
|
|
405
|
+
responseToRate: operation === 'rating' ? this.getNodeParameter('responseToRate', i) : undefined,
|
|
406
406
|
output: processedOutput,
|
|
407
407
|
cliRawOutput: stdout,
|
|
408
408
|
cliStderr: stderr || undefined,
|
|
@@ -416,8 +416,8 @@ class GitHubCopilot {
|
|
|
416
416
|
returnData.push({
|
|
417
417
|
json: {
|
|
418
418
|
error: error instanceof Error ? error.message : String(error),
|
|
419
|
-
operation: this.getNodeParameter(
|
|
420
|
-
prompt: this.getNodeParameter(
|
|
419
|
+
operation: this.getNodeParameter('operation', i, 'unknown'),
|
|
420
|
+
prompt: this.getNodeParameter('prompt', i, ''),
|
|
421
421
|
timestamp: new Date().toISOString(),
|
|
422
422
|
},
|
|
423
423
|
pairedItem: { item: i },
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IWebhookFunctions, IWebhookResponseData, INodeType, INodeTypeDescription } from
|
|
1
|
+
import { IWebhookFunctions, IWebhookResponseData, INodeType, INodeTypeDescription } from 'n8n-workflow';
|
|
2
2
|
export declare class GitHubCopilotAuthHelper implements INodeType {
|
|
3
3
|
description: INodeTypeDescription;
|
|
4
4
|
webhook(this: IWebhookFunctions): Promise<IWebhookResponseData>;
|