n8n-nodes-github-copilot 1.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.
- package/LICENSE +21 -0
- package/README.md +305 -0
- package/dist/credentials/GitHubApi.credentials.d.ts +9 -0
- package/dist/credentials/GitHubApi.credentials.js +39 -0
- package/dist/nodes/GitHubCopilot/GitHubCopilot.node.d.ts +5 -0
- package/dist/nodes/GitHubCopilot/GitHubCopilot.node.js +235 -0
- package/dist/nodes/GitHubCopilot/githubcopilot.svg +34 -0
- package/package.json +61 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Sufficit
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
# n8n-nodes-github-copilot
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
Este é um **community node** para [n8n](https://n8n.io/) que integra o **GitHub Copilot CLI** diretamente nos seus workflows de automação, permitindo gerar código, explicar funcionalidades e obter sugestões de comandos shell usando IA.
|
|
8
|
+
|
|
9
|
+
## 🎯 Funcionalidades
|
|
10
|
+
|
|
11
|
+
- **Sugestões de Código**: Gere código em múltiplas linguagens de programação
|
|
12
|
+
- **Explicação de Código**: Obtenha explicações detalhadas sobre funcionalidades de código
|
|
13
|
+
- **Comandos Shell**: Receba sugestões de comandos para Git, Docker, NPM e muito mais
|
|
14
|
+
- **Múltiplas Linguagens**: Suporte para JavaScript, TypeScript, Python, Ruby, Java, C#, Go, PHP, C++, Rust, SQL, HTML, CSS
|
|
15
|
+
- **Integração Nativa**: Usa o GitHub Copilot CLI oficial por baixo dos panos
|
|
16
|
+
|
|
17
|
+
## 📋 Pré-requisitos
|
|
18
|
+
|
|
19
|
+
### 1. Assinatura do GitHub Copilot
|
|
20
|
+
Você precisa ter uma assinatura ativa do GitHub Copilot:
|
|
21
|
+
- **GitHub Copilot Individual**: $10/mês
|
|
22
|
+
- **GitHub Copilot Business**: $19/usuário/mês
|
|
23
|
+
- **GitHub Copilot Enterprise**: $39/usuário/mês
|
|
24
|
+
|
|
25
|
+
### 2. GitHub CLI Instalado
|
|
26
|
+
O node usa o GitHub CLI (`gh`) e a extensão Copilot:
|
|
27
|
+
|
|
28
|
+
#### Linux/Ubuntu:
|
|
29
|
+
```bash
|
|
30
|
+
# Instalar GitHub CLI
|
|
31
|
+
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
|
|
32
|
+
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
|
|
33
|
+
sudo apt update
|
|
34
|
+
sudo apt install gh
|
|
35
|
+
|
|
36
|
+
# Instalar extensão Copilot
|
|
37
|
+
gh extension install github/gh-copilot
|
|
38
|
+
|
|
39
|
+
# Autenticar
|
|
40
|
+
gh auth login
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
#### macOS:
|
|
44
|
+
```bash
|
|
45
|
+
# Usando Homebrew
|
|
46
|
+
brew install gh
|
|
47
|
+
|
|
48
|
+
# Instalar extensão Copilot
|
|
49
|
+
gh extension install github/gh-copilot
|
|
50
|
+
|
|
51
|
+
# Autenticar
|
|
52
|
+
gh auth login
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
#### Windows:
|
|
56
|
+
```powershell
|
|
57
|
+
# Usando Chocolatey
|
|
58
|
+
choco install gh
|
|
59
|
+
|
|
60
|
+
# Ou usando Scoop
|
|
61
|
+
scoop install gh
|
|
62
|
+
|
|
63
|
+
# Instalar extensão Copilot
|
|
64
|
+
gh extension install github/gh-copilot
|
|
65
|
+
|
|
66
|
+
# Autenticar
|
|
67
|
+
gh auth login
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### 3. Token de Acesso GitHub
|
|
71
|
+
Crie um Personal Access Token no GitHub com as seguintes permissões:
|
|
72
|
+
- `read:user`
|
|
73
|
+
- `user:email`
|
|
74
|
+
- Acesso ao GitHub Copilot (incluído automaticamente se você tem assinatura)
|
|
75
|
+
|
|
76
|
+
## 🚀 Instalação
|
|
77
|
+
|
|
78
|
+
### Opção 1: Via npm (Recomendado)
|
|
79
|
+
```bash
|
|
80
|
+
npm install n8n-nodes-github-copilot
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Opção 2: Via Interface do n8n
|
|
84
|
+
1. Vá para **Settings > Community Nodes**
|
|
85
|
+
2. Clique em **Install a community node**
|
|
86
|
+
3. Digite: `n8n-nodes-github-copilot`
|
|
87
|
+
4. Clique em **Install**
|
|
88
|
+
|
|
89
|
+
### Opção 3: Instalação Manual
|
|
90
|
+
1. Clone este repositório
|
|
91
|
+
2. Execute `npm run build`
|
|
92
|
+
3. Copie a pasta `dist` para o diretório de nodes do n8n
|
|
93
|
+
|
|
94
|
+
## ⚙️ Configuração
|
|
95
|
+
|
|
96
|
+
### 1. Configurar Credenciais
|
|
97
|
+
1. No n8n, vá para **Settings > Credentials**
|
|
98
|
+
2. Clique em **Create New Credential**
|
|
99
|
+
3. Selecione **GitHub API**
|
|
100
|
+
4. Insira seu Personal Access Token
|
|
101
|
+
5. Teste a conexão
|
|
102
|
+
|
|
103
|
+
### 2. Adicionar o Node
|
|
104
|
+
1. Crie um novo workflow
|
|
105
|
+
2. Procure por **GitHub Copilot** na lista de nodes
|
|
106
|
+
3. Arraste para o canvas
|
|
107
|
+
4. Configure as credenciais criadas anteriormente
|
|
108
|
+
|
|
109
|
+
## 🎮 Como Usar
|
|
110
|
+
|
|
111
|
+
### Operações Disponíveis
|
|
112
|
+
|
|
113
|
+
#### 1. **Suggest Code** (Sugerir Código)
|
|
114
|
+
Gera sugestões de código em linguagens específicas.
|
|
115
|
+
|
|
116
|
+
**Parâmetros:**
|
|
117
|
+
- **Prompt**: Descreva o que você quer criar
|
|
118
|
+
- **Language**: Selecione a linguagem de programação
|
|
119
|
+
- **Additional Context**: Contexto adicional (opcional)
|
|
120
|
+
|
|
121
|
+
**Exemplo:**
|
|
122
|
+
```
|
|
123
|
+
Prompt: "create a function to validate email addresses"
|
|
124
|
+
Language: "JavaScript"
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
#### 2. **Explain Code** (Explicar Código)
|
|
128
|
+
Explica funcionalidades de código existente.
|
|
129
|
+
|
|
130
|
+
**Parâmetros:**
|
|
131
|
+
- **Prompt**: Cole o código que quer explicar
|
|
132
|
+
- **Additional Context**: Contexto adicional (opcional)
|
|
133
|
+
|
|
134
|
+
**Exemplo:**
|
|
135
|
+
```
|
|
136
|
+
Prompt: "function validateEmail(email) { return /\S+@\S+\.\S+/.test(email); }"
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
#### 3. **Shell Command** (Comando Shell)
|
|
140
|
+
Sugere comandos shell para tarefas específicas.
|
|
141
|
+
|
|
142
|
+
**Parâmetros:**
|
|
143
|
+
- **Prompt**: Descreva a tarefa que quer executar
|
|
144
|
+
- **Command Type**: Tipo de comando (Git, Docker, NPM, etc.)
|
|
145
|
+
- **Additional Context**: Contexto adicional (opcional)
|
|
146
|
+
|
|
147
|
+
**Exemplo:**
|
|
148
|
+
```
|
|
149
|
+
Prompt: "commit all changes with message"
|
|
150
|
+
Command Type: "Git Command"
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Dados de Saída
|
|
154
|
+
|
|
155
|
+
O node retorna um objeto JSON com:
|
|
156
|
+
```json
|
|
157
|
+
{
|
|
158
|
+
"operation": "suggest",
|
|
159
|
+
"prompt": "create a REST API endpoint",
|
|
160
|
+
"language": "javascript",
|
|
161
|
+
"suggestion": "// Código sugerido pelo Copilot",
|
|
162
|
+
"rawOutput": "Saída completa do CLI",
|
|
163
|
+
"timestamp": "2024-01-15T10:30:00.000Z"
|
|
164
|
+
}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## 🔧 Exemplo de Workflow
|
|
168
|
+
|
|
169
|
+
### Gerador de Código Automático
|
|
170
|
+
```
|
|
171
|
+
Webhook (POST) → GitHub Copilot (Suggest) → HTTP Response
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
**Payload do Webhook:**
|
|
175
|
+
```json
|
|
176
|
+
{
|
|
177
|
+
"prompt": "create a login function",
|
|
178
|
+
"language": "python",
|
|
179
|
+
"context": "using Flask framework"
|
|
180
|
+
}
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### Bot de Ajuda para Comandos
|
|
184
|
+
```
|
|
185
|
+
Telegram Bot → GitHub Copilot (Shell) → Telegram Bot (Reply)
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
## 🐳 Docker
|
|
189
|
+
|
|
190
|
+
### Dockerfile para n8n com GitHub Copilot
|
|
191
|
+
```dockerfile
|
|
192
|
+
FROM n8nio/n8n:latest
|
|
193
|
+
|
|
194
|
+
USER root
|
|
195
|
+
|
|
196
|
+
# Instalar GitHub CLI
|
|
197
|
+
RUN apt-get update && apt-get install -y curl gnupg
|
|
198
|
+
RUN curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
|
|
199
|
+
RUN echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null
|
|
200
|
+
RUN apt-get update && apt-get install -y gh
|
|
201
|
+
|
|
202
|
+
# Instalar o community node
|
|
203
|
+
RUN npm install -g n8n-nodes-github-copilot
|
|
204
|
+
|
|
205
|
+
USER node
|
|
206
|
+
|
|
207
|
+
# Definir variáveis de ambiente
|
|
208
|
+
ENV GITHUB_TOKEN=""
|
|
209
|
+
ENV N8N_COMMUNITY_PACKAGES="n8n-nodes-github-copilot"
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
### docker-compose.yml
|
|
213
|
+
```yaml
|
|
214
|
+
version: '3.8'
|
|
215
|
+
services:
|
|
216
|
+
n8n:
|
|
217
|
+
build: .
|
|
218
|
+
ports:
|
|
219
|
+
- "5678:5678"
|
|
220
|
+
environment:
|
|
221
|
+
- GITHUB_TOKEN=${GITHUB_TOKEN}
|
|
222
|
+
- N8N_COMMUNITY_PACKAGES=n8n-nodes-github-copilot
|
|
223
|
+
volumes:
|
|
224
|
+
- n8n_data:/home/node/.n8n
|
|
225
|
+
|
|
226
|
+
volumes:
|
|
227
|
+
n8n_data:
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
## 🔒 Segurança
|
|
231
|
+
|
|
232
|
+
- **Dados Sensíveis**: Evite enviar informações confidenciais nos prompts
|
|
233
|
+
- **Rate Limiting**: O GitHub Copilot tem limites de uso - monitore seu consumo
|
|
234
|
+
- **Tokens**: Mantenha seus tokens seguros e com permissões mínimas necessárias
|
|
235
|
+
- **Logs**: O node registra atividades para auditoria
|
|
236
|
+
|
|
237
|
+
## 🚨 Limitações
|
|
238
|
+
|
|
239
|
+
- **Requer Assinatura**: Necessário ter GitHub Copilot ativo
|
|
240
|
+
- **Dependência CLI**: Requer GitHub CLI instalado no sistema
|
|
241
|
+
- **Rate Limits**: Sujeito aos limites de uso do GitHub Copilot
|
|
242
|
+
- **Contexto**: Limitado pelo contexto que o Copilot CLI suporta
|
|
243
|
+
|
|
244
|
+
## 🛠️ Desenvolvimento
|
|
245
|
+
|
|
246
|
+
### Construir do Código Fonte
|
|
247
|
+
```bash
|
|
248
|
+
# Clonar repositório
|
|
249
|
+
git clone https://github.com/sufficit/n8n-nodes-github-copilot.git
|
|
250
|
+
cd n8n-nodes-github-copilot
|
|
251
|
+
|
|
252
|
+
# Instalar dependências
|
|
253
|
+
npm install
|
|
254
|
+
|
|
255
|
+
# Construir
|
|
256
|
+
npm run build
|
|
257
|
+
|
|
258
|
+
# Lint
|
|
259
|
+
npm run lint
|
|
260
|
+
|
|
261
|
+
# Formatar código
|
|
262
|
+
npm run format
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
### Estrutura do Projeto
|
|
266
|
+
```
|
|
267
|
+
├── credentials/
|
|
268
|
+
│ └── GitHubApi.credentials.ts
|
|
269
|
+
├── nodes/
|
|
270
|
+
│ └── GitHubCopilot/
|
|
271
|
+
│ ├── GitHubCopilot.node.ts
|
|
272
|
+
│ └── githubcopilot.svg
|
|
273
|
+
├── package.json
|
|
274
|
+
├── tsconfig.json
|
|
275
|
+
├── gulpfile.js
|
|
276
|
+
└── README.md
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
## 📄 Licença
|
|
280
|
+
|
|
281
|
+
MIT License - veja [LICENSE](LICENSE) para detalhes.
|
|
282
|
+
|
|
283
|
+
## 🤝 Contribuindo
|
|
284
|
+
|
|
285
|
+
1. Fork o projeto
|
|
286
|
+
2. Crie uma branch para sua feature (`git checkout -b feature/AmazingFeature`)
|
|
287
|
+
3. Commit suas mudanças (`git commit -m 'Add some AmazingFeature'`)
|
|
288
|
+
4. Push para a branch (`git push origin feature/AmazingFeature`)
|
|
289
|
+
5. Abra um Pull Request
|
|
290
|
+
|
|
291
|
+
## 📞 Suporte
|
|
292
|
+
|
|
293
|
+
- **Email**: development@sufficit.com.br
|
|
294
|
+
- **Issues**: [GitHub Issues](https://github.com/sufficit/n8n-nodes-github-copilot/issues)
|
|
295
|
+
- **Documentação**: [n8n Community Nodes](https://docs.n8n.io/integrations/community-nodes/)
|
|
296
|
+
|
|
297
|
+
## 🙏 Agradecimentos
|
|
298
|
+
|
|
299
|
+
- [n8n.io](https://n8n.io/) - Plataforma de automação incrível
|
|
300
|
+
- [GitHub Copilot](https://copilot.github.com/) - IA que torna este node possível
|
|
301
|
+
- [GitHub CLI](https://cli.github.com/) - Interface de linha de comando essencial
|
|
302
|
+
|
|
303
|
+
---
|
|
304
|
+
|
|
305
|
+
**Feito com ❤️ pela equipe [Sufficit](https://sufficit.com.br)**
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IAuthenticateGeneric, ICredentialTestRequest, ICredentialType, INodeProperties } from 'n8n-workflow';
|
|
2
|
+
export declare class GitHubApi implements ICredentialType {
|
|
3
|
+
name: string;
|
|
4
|
+
displayName: string;
|
|
5
|
+
documentationUrl: string;
|
|
6
|
+
properties: INodeProperties[];
|
|
7
|
+
authenticate: IAuthenticateGeneric;
|
|
8
|
+
test: ICredentialTestRequest;
|
|
9
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GitHubApi = void 0;
|
|
4
|
+
class GitHubApi {
|
|
5
|
+
constructor() {
|
|
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';
|
|
9
|
+
this.properties = [
|
|
10
|
+
{
|
|
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.',
|
|
20
|
+
},
|
|
21
|
+
];
|
|
22
|
+
this.authenticate = {
|
|
23
|
+
type: 'generic',
|
|
24
|
+
properties: {
|
|
25
|
+
headers: {
|
|
26
|
+
Authorization: '=Bearer {{$credentials.accessToken}}',
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
this.test = {
|
|
31
|
+
request: {
|
|
32
|
+
baseURL: 'https://api.github.com',
|
|
33
|
+
url: '/user',
|
|
34
|
+
method: 'GET',
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.GitHubApi = GitHubApi;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
|
|
2
|
+
export declare class GitHubCopilot implements INodeType {
|
|
3
|
+
description: INodeTypeDescription;
|
|
4
|
+
execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
|
|
5
|
+
}
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GitHubCopilot = void 0;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
+
const child_process_1 = require("child_process");
|
|
6
|
+
const util_1 = require("util");
|
|
7
|
+
const execAsync = (0, util_1.promisify)(child_process_1.exec);
|
|
8
|
+
class GitHubCopilot {
|
|
9
|
+
constructor() {
|
|
10
|
+
this.description = {
|
|
11
|
+
displayName: 'GitHub Copilot',
|
|
12
|
+
name: 'gitHubCopilot',
|
|
13
|
+
icon: 'file:githubcopilot.svg',
|
|
14
|
+
group: ['transform'],
|
|
15
|
+
version: 1,
|
|
16
|
+
subtitle: '={{$parameter["operation"]}}',
|
|
17
|
+
description: 'Use GitHub Copilot CLI for AI-powered code suggestions and explanations',
|
|
18
|
+
defaults: {
|
|
19
|
+
name: 'GitHub Copilot',
|
|
20
|
+
},
|
|
21
|
+
inputs: ["main"],
|
|
22
|
+
outputs: ["main"],
|
|
23
|
+
credentials: [
|
|
24
|
+
{
|
|
25
|
+
name: 'gitHubApi',
|
|
26
|
+
required: true,
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
properties: [
|
|
30
|
+
{
|
|
31
|
+
displayName: 'Operation',
|
|
32
|
+
name: 'operation',
|
|
33
|
+
type: 'options',
|
|
34
|
+
noDataExpression: true,
|
|
35
|
+
options: [
|
|
36
|
+
{
|
|
37
|
+
name: 'Suggest Code',
|
|
38
|
+
value: 'suggest',
|
|
39
|
+
description: 'Get code suggestions from GitHub Copilot',
|
|
40
|
+
action: 'Get code suggestions',
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: 'Explain Code',
|
|
44
|
+
value: 'explain',
|
|
45
|
+
description: 'Explain code functionality using GitHub Copilot',
|
|
46
|
+
action: 'Explain code functionality',
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
name: 'Shell Command',
|
|
50
|
+
value: 'shell',
|
|
51
|
+
description: 'Get shell command suggestions',
|
|
52
|
+
action: 'Get shell command suggestions',
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
default: 'suggest',
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
displayName: 'Prompt',
|
|
59
|
+
name: 'prompt',
|
|
60
|
+
type: 'string',
|
|
61
|
+
typeOptions: {
|
|
62
|
+
rows: 3,
|
|
63
|
+
},
|
|
64
|
+
default: '',
|
|
65
|
+
placeholder: 'Enter your request...',
|
|
66
|
+
description: 'Describe what you want Copilot to help with',
|
|
67
|
+
required: true,
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
displayName: 'Programming Language',
|
|
71
|
+
name: 'language',
|
|
72
|
+
type: 'options',
|
|
73
|
+
options: [
|
|
74
|
+
{ name: 'JavaScript', value: 'javascript' },
|
|
75
|
+
{ name: 'TypeScript', value: 'typescript' },
|
|
76
|
+
{ name: 'Python', value: 'python' },
|
|
77
|
+
{ name: 'Ruby', value: 'ruby' },
|
|
78
|
+
{ name: 'Java', value: 'java' },
|
|
79
|
+
{ name: 'C#', value: 'csharp' },
|
|
80
|
+
{ name: 'Go', value: 'go' },
|
|
81
|
+
{ name: 'PHP', value: 'php' },
|
|
82
|
+
{ name: 'C++', value: 'cpp' },
|
|
83
|
+
{ name: 'Rust', value: 'rust' },
|
|
84
|
+
{ name: 'SQL', value: 'sql' },
|
|
85
|
+
{ name: 'HTML', value: 'html' },
|
|
86
|
+
{ name: 'CSS', value: 'css' },
|
|
87
|
+
{ name: 'Other', value: 'other' },
|
|
88
|
+
],
|
|
89
|
+
default: 'javascript',
|
|
90
|
+
displayOptions: {
|
|
91
|
+
show: {
|
|
92
|
+
operation: ['suggest'],
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
description: 'Programming language for code suggestions',
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
displayName: 'Command Type',
|
|
99
|
+
name: 'commandType',
|
|
100
|
+
type: 'options',
|
|
101
|
+
options: [
|
|
102
|
+
{ name: 'Generic Shell', value: 'shell' },
|
|
103
|
+
{ name: 'Git Command', value: 'git' },
|
|
104
|
+
{ name: 'Docker Command', value: 'docker' },
|
|
105
|
+
{ name: 'NPM/Yarn Command', value: 'npm' },
|
|
106
|
+
{ name: 'File Operations', value: 'file' },
|
|
107
|
+
],
|
|
108
|
+
default: 'shell',
|
|
109
|
+
displayOptions: {
|
|
110
|
+
show: {
|
|
111
|
+
operation: ['shell'],
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
description: 'Type of shell command to suggest',
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
displayName: 'Additional Context',
|
|
118
|
+
name: 'context',
|
|
119
|
+
type: 'string',
|
|
120
|
+
typeOptions: {
|
|
121
|
+
rows: 2,
|
|
122
|
+
},
|
|
123
|
+
default: '',
|
|
124
|
+
placeholder: 'Any additional context or constraints...',
|
|
125
|
+
description: 'Optional additional context to provide better suggestions',
|
|
126
|
+
},
|
|
127
|
+
],
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
async execute() {
|
|
131
|
+
const items = this.getInputData();
|
|
132
|
+
const returnData = [];
|
|
133
|
+
for (let i = 0; i < items.length; i++) {
|
|
134
|
+
try {
|
|
135
|
+
const operation = this.getNodeParameter('operation', i);
|
|
136
|
+
const prompt = this.getNodeParameter('prompt', i);
|
|
137
|
+
const context = this.getNodeParameter('context', i, '');
|
|
138
|
+
const credentials = await this.getCredentials('gitHubApi');
|
|
139
|
+
let command;
|
|
140
|
+
let fullPrompt = prompt;
|
|
141
|
+
if (context) {
|
|
142
|
+
fullPrompt = `${prompt}\n\nAdditional context: ${context}`;
|
|
143
|
+
}
|
|
144
|
+
switch (operation) {
|
|
145
|
+
case 'suggest':
|
|
146
|
+
const language = this.getNodeParameter('language', i);
|
|
147
|
+
if (language !== 'other') {
|
|
148
|
+
fullPrompt = `[${language}] ${fullPrompt}`;
|
|
149
|
+
}
|
|
150
|
+
command = `gh copilot suggest "${fullPrompt}"`;
|
|
151
|
+
break;
|
|
152
|
+
case 'explain':
|
|
153
|
+
command = `gh copilot explain "${fullPrompt}"`;
|
|
154
|
+
break;
|
|
155
|
+
case 'shell':
|
|
156
|
+
const commandType = this.getNodeParameter('commandType', i);
|
|
157
|
+
let shellPrompt = fullPrompt;
|
|
158
|
+
switch (commandType) {
|
|
159
|
+
case 'git':
|
|
160
|
+
shellPrompt = `git: ${fullPrompt}`;
|
|
161
|
+
break;
|
|
162
|
+
case 'docker':
|
|
163
|
+
shellPrompt = `docker: ${fullPrompt}`;
|
|
164
|
+
break;
|
|
165
|
+
case 'npm':
|
|
166
|
+
shellPrompt = `npm/yarn: ${fullPrompt}`;
|
|
167
|
+
break;
|
|
168
|
+
case 'file':
|
|
169
|
+
shellPrompt = `file operations: ${fullPrompt}`;
|
|
170
|
+
break;
|
|
171
|
+
default:
|
|
172
|
+
shellPrompt = fullPrompt;
|
|
173
|
+
}
|
|
174
|
+
command = `gh copilot suggest "${shellPrompt}" --type shell`;
|
|
175
|
+
break;
|
|
176
|
+
default:
|
|
177
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Unknown operation: ${operation}`);
|
|
178
|
+
}
|
|
179
|
+
const { stdout, stderr } = await execAsync(command, {
|
|
180
|
+
env: {
|
|
181
|
+
...process.env,
|
|
182
|
+
GITHUB_TOKEN: credentials.accessToken,
|
|
183
|
+
},
|
|
184
|
+
timeout: 30000,
|
|
185
|
+
maxBuffer: 1024 * 1024,
|
|
186
|
+
});
|
|
187
|
+
if (stderr && !stdout) {
|
|
188
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `GitHub Copilot CLI error: ${stderr}`);
|
|
189
|
+
}
|
|
190
|
+
const result = stdout.trim();
|
|
191
|
+
let suggestion = result;
|
|
192
|
+
if (operation === 'suggest' || operation === 'shell') {
|
|
193
|
+
const lines = result.split('\n');
|
|
194
|
+
const suggestionStart = lines.findIndex((line) => line.includes('Suggestion:') ||
|
|
195
|
+
line.includes('```') ||
|
|
196
|
+
line.trim().startsWith('$') ||
|
|
197
|
+
line.trim().startsWith('>'));
|
|
198
|
+
if (suggestionStart !== -1) {
|
|
199
|
+
suggestion = lines.slice(suggestionStart).join('\n').trim();
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
returnData.push({
|
|
203
|
+
json: {
|
|
204
|
+
operation,
|
|
205
|
+
prompt: prompt,
|
|
206
|
+
context: context || undefined,
|
|
207
|
+
language: operation === 'suggest' ? this.getNodeParameter('language', i) : undefined,
|
|
208
|
+
commandType: operation === 'shell' ? this.getNodeParameter('commandType', i) : undefined,
|
|
209
|
+
suggestion,
|
|
210
|
+
rawOutput: result,
|
|
211
|
+
timestamp: new Date().toISOString(),
|
|
212
|
+
},
|
|
213
|
+
pairedItem: { item: i },
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
catch (error) {
|
|
217
|
+
if (this.continueOnFail()) {
|
|
218
|
+
returnData.push({
|
|
219
|
+
json: {
|
|
220
|
+
error: error instanceof Error ? error.message : String(error),
|
|
221
|
+
operation: this.getNodeParameter('operation', i, 'unknown'),
|
|
222
|
+
prompt: this.getNodeParameter('prompt', i, ''),
|
|
223
|
+
timestamp: new Date().toISOString(),
|
|
224
|
+
},
|
|
225
|
+
pairedItem: { item: i },
|
|
226
|
+
});
|
|
227
|
+
continue;
|
|
228
|
+
}
|
|
229
|
+
throw error;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
return [returnData];
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
exports.GitHubCopilot = GitHubCopilot;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">
|
|
2
|
+
<defs>
|
|
3
|
+
<linearGradient id="copilotGradient" x1="0%" y1="0%" x2="100%" y2="100%">
|
|
4
|
+
<stop offset="0%" style="stop-color:#1f6feb;stop-opacity:1" />
|
|
5
|
+
<stop offset="100%" style="stop-color:#0969da;stop-opacity:1" />
|
|
6
|
+
</linearGradient>
|
|
7
|
+
</defs>
|
|
8
|
+
|
|
9
|
+
<!-- GitHub Copilot inspired icon -->
|
|
10
|
+
<circle cx="12" cy="12" r="11" fill="url(#copilotGradient)" stroke="#ffffff" stroke-width="1"/>
|
|
11
|
+
|
|
12
|
+
<!-- Copilot face -->
|
|
13
|
+
<ellipse cx="12" cy="10" rx="8" ry="6" fill="#ffffff" opacity="0.9"/>
|
|
14
|
+
|
|
15
|
+
<!-- Eyes -->
|
|
16
|
+
<circle cx="9" cy="9" r="1.5" fill="#1f6feb"/>
|
|
17
|
+
<circle cx="15" cy="9" r="1.5" fill="#1f6feb"/>
|
|
18
|
+
|
|
19
|
+
<!-- Light reflection in eyes -->
|
|
20
|
+
<circle cx="9.5" cy="8.5" r="0.5" fill="#ffffff"/>
|
|
21
|
+
<circle cx="15.5" cy="8.5" r="0.5" fill="#ffffff"/>
|
|
22
|
+
|
|
23
|
+
<!-- Mouth/Interface line -->
|
|
24
|
+
<path d="M8 12 L16 12" stroke="#1f6feb" stroke-width="1.5" stroke-linecap="round"/>
|
|
25
|
+
|
|
26
|
+
<!-- Code brackets -->
|
|
27
|
+
<path d="M6 15 L8 17 L6 19" stroke="#ffffff" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" fill="none"/>
|
|
28
|
+
<path d="M18 15 L16 17 L18 19" stroke="#ffffff" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" fill="none"/>
|
|
29
|
+
|
|
30
|
+
<!-- AI indicator dots -->
|
|
31
|
+
<circle cx="10" cy="17" r="0.5" fill="#ffffff" opacity="0.8"/>
|
|
32
|
+
<circle cx="12" cy="17" r="0.5" fill="#ffffff" opacity="0.6"/>
|
|
33
|
+
<circle cx="14" cy="17" r="0.5" fill="#ffffff" opacity="0.4"/>
|
|
34
|
+
</svg>
|
package/package.json
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "n8n-nodes-github-copilot",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "n8n community node for GitHub Copilot CLI integration",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"homepage": "https://github.com/sufficit/n8n-nodes-github-copilot",
|
|
7
|
+
"author": {
|
|
8
|
+
"name": "Sufficit",
|
|
9
|
+
"email": "development@sufficit.com.br"
|
|
10
|
+
},
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "https://github.com/sufficit/n8n-nodes-github-copilot.git"
|
|
14
|
+
},
|
|
15
|
+
"main": "index.js",
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "tsc && gulp build:icons",
|
|
18
|
+
"dev": "tsc --watch",
|
|
19
|
+
"format": "prettier nodes credentials --write",
|
|
20
|
+
"lint": "eslint nodes credentials package.json",
|
|
21
|
+
"lintfix": "eslint nodes credentials package.json --fix",
|
|
22
|
+
"prepublishOnly": "npm run build && npm run lint -s"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"dist"
|
|
26
|
+
],
|
|
27
|
+
"n8n": {
|
|
28
|
+
"n8nNodesApiVersion": 1,
|
|
29
|
+
"credentials": [
|
|
30
|
+
"dist/credentials/GitHubApi.credentials.js"
|
|
31
|
+
],
|
|
32
|
+
"nodes": [
|
|
33
|
+
"dist/nodes/GitHubCopilot/GitHubCopilot.node.js"
|
|
34
|
+
]
|
|
35
|
+
},
|
|
36
|
+
"keywords": [
|
|
37
|
+
"n8n-community-node-package",
|
|
38
|
+
"github",
|
|
39
|
+
"copilot",
|
|
40
|
+
"ai",
|
|
41
|
+
"code-generation",
|
|
42
|
+
"automation"
|
|
43
|
+
],
|
|
44
|
+
"engines": {
|
|
45
|
+
"node": ">=16.10",
|
|
46
|
+
"pnpm": ">=7.1"
|
|
47
|
+
},
|
|
48
|
+
"packageManager": "pnpm@7.1.0",
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"n8n-workflow": "*"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@types/node": "^18.16.16",
|
|
54
|
+
"@typescript-eslint/parser": "^5.45.0",
|
|
55
|
+
"@typescript-eslint/eslint-plugin": "^5.45.0",
|
|
56
|
+
"eslint": "^8.28.0",
|
|
57
|
+
"gulp": "^4.0.2",
|
|
58
|
+
"prettier": "^2.7.1",
|
|
59
|
+
"typescript": "~4.8.4"
|
|
60
|
+
}
|
|
61
|
+
}
|