n8n-nodes-github-copilot 1.0.6 → 1.0.8

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.
@@ -1,9 +1,8 @@
1
- import { IAuthenticateGeneric, ICredentialTestRequest, ICredentialType, INodeProperties } from 'n8n-workflow';
1
+ import { ICredentialType, INodeProperties } from 'n8n-workflow';
2
2
  export declare class GitHubApi implements ICredentialType {
3
3
  name: string;
4
4
  displayName: string;
5
+ extends: string[];
5
6
  documentationUrl: string;
6
7
  properties: INodeProperties[];
7
- authenticate: IAuthenticateGeneric;
8
- test: ICredentialTestRequest;
9
8
  }
@@ -4,36 +4,47 @@ exports.GitHubApi = void 0;
4
4
  class GitHubApi {
5
5
  constructor() {
6
6
  this.name = 'gitHubApi';
7
- this.displayName = 'GitHub API';
8
- this.documentationUrl = 'https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token';
7
+ this.displayName = 'GitHub OAuth2 API';
8
+ this.extends = ['oAuth2Api'];
9
+ this.documentationUrl = 'https://docs.github.com/en/developers/apps/building-oauth-apps/authorizing-oauth-apps';
9
10
  this.properties = [
10
11
  {
11
- displayName: 'GitHub Token',
12
- name: 'accessToken',
13
- type: 'string',
14
- typeOptions: {
15
- password: true,
16
- },
17
- default: '',
18
- required: true,
19
- description: 'GitHub personal access token with Copilot access. You need to have GitHub Copilot subscription and generate a token with appropriate permissions.',
12
+ displayName: 'Grant Type',
13
+ name: 'grantType',
14
+ type: 'hidden',
15
+ default: 'authorizationCode',
20
16
  },
21
- ];
22
- this.authenticate = {
23
- type: 'generic',
24
- properties: {
25
- headers: {
26
- Authorization: '=Bearer {{$credentials.accessToken}}',
27
- },
17
+ {
18
+ displayName: 'Authorization URL',
19
+ name: 'authUrl',
20
+ type: 'hidden',
21
+ default: 'https://github.com/login/oauth/authorize',
22
+ },
23
+ {
24
+ displayName: 'Access Token URL',
25
+ name: 'accessTokenUrl',
26
+ type: 'hidden',
27
+ default: 'https://github.com/login/oauth/access_token',
28
+ },
29
+ {
30
+ displayName: 'Scope',
31
+ name: 'scope',
32
+ type: 'hidden',
33
+ default: 'copilot read:org repo user',
34
+ },
35
+ {
36
+ displayName: 'Auth URI Query Parameters',
37
+ name: 'authQueryParameters',
38
+ type: 'hidden',
39
+ default: '',
28
40
  },
29
- };
30
- this.test = {
31
- request: {
32
- baseURL: 'https://api.github.com',
33
- url: '/user',
34
- method: 'GET',
41
+ {
42
+ displayName: 'Authentication',
43
+ name: 'authentication',
44
+ type: 'hidden',
45
+ default: 'header',
35
46
  },
36
- };
47
+ ];
37
48
  }
38
49
  }
39
50
  exports.GitHubApi = GitHubApi;
@@ -5,6 +5,45 @@ const n8n_workflow_1 = require("n8n-workflow");
5
5
  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
+ function filterCopilotOutput(rawOutput) {
9
+ const lines = rawOutput.split('\n');
10
+ let startIndex = -1;
11
+ const endIndex = lines.length;
12
+ for (let i = 0; i < lines.length; i++) {
13
+ const line = lines[i].trim();
14
+ if (line.includes('# Explanation:') ||
15
+ line.includes('# Suggestion:') ||
16
+ line.includes('# Command:') ||
17
+ line.includes('# Code:') ||
18
+ (line.startsWith('•') && i > 5)) {
19
+ startIndex = i;
20
+ break;
21
+ }
22
+ }
23
+ if (startIndex === -1) {
24
+ for (let i = 0; i < lines.length; i++) {
25
+ const line = lines[i].trim();
26
+ if (line.includes('version ') && line.includes('(') && line.includes(')')) {
27
+ startIndex = i + 3;
28
+ break;
29
+ }
30
+ }
31
+ }
32
+ if (startIndex === -1) {
33
+ for (let i = 0; i < lines.length; i++) {
34
+ const line = lines[i].trim();
35
+ if (line.length > 10 && !line.includes('Welcome to') && !line.includes('powered by AI')) {
36
+ startIndex = i;
37
+ break;
38
+ }
39
+ }
40
+ }
41
+ if (startIndex >= 0) {
42
+ const filteredLines = lines.slice(startIndex, endIndex);
43
+ return filteredLines.join('\n').trim();
44
+ }
45
+ return rawOutput.trim();
46
+ }
8
47
  class GitHubCopilot {
9
48
  constructor() {
10
49
  this.description = {
@@ -66,6 +105,13 @@ class GitHubCopilot {
66
105
  placeholder: 'Enter your request...',
67
106
  description: 'What you want GitHub Copilot to help with',
68
107
  },
108
+ {
109
+ displayName: 'Filter Output',
110
+ name: 'filterOutput',
111
+ type: 'boolean',
112
+ default: true,
113
+ description: 'Remove GitHub Copilot CLI header and footer, keeping only the useful response',
114
+ },
69
115
  {
70
116
  displayName: 'Language',
71
117
  name: 'language',
@@ -175,12 +221,12 @@ class GitHubCopilot {
175
221
  default:
176
222
  throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Unknown operation: ${operation}`);
177
223
  }
224
+ const accessToken = credentials.accessToken;
178
225
  const { stdout, stderr } = await execAsync(command, {
179
226
  env: {
180
227
  ...process.env,
181
- GITHUB_TOKEN: credentials.accessToken,
228
+ GH_TOKEN: accessToken,
182
229
  HOME: '/opt/n8n-source/packages/cli/bin',
183
- GH_TOKEN: credentials.accessToken,
184
230
  },
185
231
  timeout: 30000,
186
232
  maxBuffer: 1024 * 1024,
@@ -188,6 +234,11 @@ class GitHubCopilot {
188
234
  if (stderr && !stdout) {
189
235
  throw new n8n_workflow_1.NodeOperationError(this.getNode(), `GitHub Copilot CLI error: ${stderr}`);
190
236
  }
237
+ const filterOutput = this.getNodeParameter('filterOutput', i, true);
238
+ let processedOutput = stdout;
239
+ if (filterOutput) {
240
+ processedOutput = filterCopilotOutput(stdout);
241
+ }
191
242
  returnData.push({
192
243
  json: {
193
244
  operation,
@@ -195,6 +246,7 @@ class GitHubCopilot {
195
246
  context: context || undefined,
196
247
  language: operation === 'suggest' ? this.getNodeParameter('language', i) : undefined,
197
248
  commandType: operation === 'shell' ? this.getNodeParameter('commandType', i) : undefined,
249
+ output: processedOutput,
198
250
  cliRawOutput: stdout,
199
251
  timestamp: new Date().toISOString(),
200
252
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-github-copilot",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "n8n community node for GitHub Copilot CLI integration",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/sufficit/n8n-nodes-github-copilot",