huntban-cli 1.0.1 → 1.0.3
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 +2 -2
- package/bin/huntban.js +1 -1
- package/lib/api.js +9 -1
- package/lib/commands/config.js +2 -2
- package/lib/commands/init.js +5 -4
- package/lib/config.js +21 -1
- package/package.json +2 -2
- package/templates/SKILL.md +2 -2
package/README.md
CHANGED
|
@@ -98,7 +98,7 @@ huntban init
|
|
|
98
98
|
### Parámetros en una sola línea (para CI/CD o scripts):
|
|
99
99
|
```bash
|
|
100
100
|
huntban attach \
|
|
101
|
-
--url https://next.huntban.com/
|
|
101
|
+
--url https://next.huntban.com/ \
|
|
102
102
|
--board <ID_DEL_TABLERO> \
|
|
103
103
|
--key <API_KEY> \
|
|
104
104
|
--secret <API_SECRET> \
|
|
@@ -121,7 +121,7 @@ huntban attach --global
|
|
|
121
121
|
2. Haz clic en el ícono de **Configuración del Tablero (⚙️)** en la cabecera.
|
|
122
122
|
3. Ve a la pestaña **Conector / Webhooks**.
|
|
123
123
|
4. Copia:
|
|
124
|
-
- **URL de la API**: `https://next.huntban.com
|
|
124
|
+
- **URL de la API**: Por defecto `https://next.huntban.com/` (el CLI la completa automáticamente con `/api/v2`).
|
|
125
125
|
- **ID del Tablero**: Identificador de 24 caracteres.
|
|
126
126
|
- **API Key**: Comienza con `hb_pk_...`.
|
|
127
127
|
- **API Secret**: Comienza con `hb_sk_...`.
|
package/bin/huntban.js
CHANGED
|
@@ -85,7 +85,7 @@ Comandos principales (admiten alias cortos):
|
|
|
85
85
|
Opciones y Flags globales:
|
|
86
86
|
--board <id> ID del tablero (Proxycard board)
|
|
87
87
|
--email <email> Email del usuario para atribución de autor (opcional)
|
|
88
|
-
--url <url> URL de la API (por defecto:
|
|
88
|
+
--url <url> URL de la API (por defecto: https://next.huntban.com/)
|
|
89
89
|
--key <key> API Key del conector (BoardWebhook)
|
|
90
90
|
--secret <secret> API Secret del conector (BoardWebhook)
|
|
91
91
|
-m, --comment <texto> Texto para comentarios o reportes de cierre
|
package/lib/api.js
CHANGED
|
@@ -3,7 +3,15 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
function buildUrl(baseUrl, endpoint) {
|
|
6
|
-
let base = (baseUrl || '
|
|
6
|
+
let base = (baseUrl || 'https://next.huntban.com/').trim().replace(/\/+$/, '');
|
|
7
|
+
|
|
8
|
+
// Completar automáticamente el prefijo de API si solo se provee el dominio
|
|
9
|
+
if (base.includes('huntban.com') && !base.includes('/api/')) {
|
|
10
|
+
base = `${base}/api/v2`;
|
|
11
|
+
} else if (base.includes('localhost') && !base.includes('/api/')) {
|
|
12
|
+
base = `${base}/api/v1`;
|
|
13
|
+
}
|
|
14
|
+
|
|
7
15
|
let path = endpoint.startsWith('/') ? endpoint : `/${endpoint}`;
|
|
8
16
|
|
|
9
17
|
// Si baseUrl ya incluye /api/v2 o /api/v1
|
package/lib/commands/config.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
const { setGlobalConfig, setLocalConfig, getGlobalConfig, loadConfig, GLOBAL_CONFIG_FILE, LOCAL_CONFIG_FILE } = require('../config');
|
|
1
|
+
const { setGlobalConfig, setLocalConfig, getGlobalConfig, loadConfig, normalizeApiUrl, GLOBAL_CONFIG_FILE, LOCAL_CONFIG_FILE } = require('../config');
|
|
2
2
|
|
|
3
3
|
module.exports = async function configCommand(parsed) {
|
|
4
4
|
const subAction = parsed.positional[0] || 'show';
|
|
5
5
|
|
|
6
6
|
if (subAction === 'set') {
|
|
7
7
|
const updates = {};
|
|
8
|
-
if (parsed.flags.url) updates.apiUrl = parsed.flags.url;
|
|
8
|
+
if (parsed.flags.url) updates.apiUrl = normalizeApiUrl(parsed.flags.url);
|
|
9
9
|
if (parsed.flags.key) updates.apiKey = parsed.flags.key;
|
|
10
10
|
if (parsed.flags.secret) updates.apiSecret = parsed.flags.secret;
|
|
11
11
|
if (parsed.flags.board) updates.boardId = parsed.flags.board;
|
package/lib/commands/init.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const path = require('path');
|
|
3
3
|
const os = require('os');
|
|
4
|
-
const { setLocalConfig, loadConfig, LOCAL_CONFIG_FILE } = require('../config');
|
|
4
|
+
const { setLocalConfig, loadConfig, normalizeApiUrl, LOCAL_CONFIG_FILE } = require('../config');
|
|
5
5
|
const { isInteractive, askQuestion } = require('../interactive');
|
|
6
6
|
const { getPipelines } = require('../api');
|
|
7
7
|
|
|
@@ -49,7 +49,7 @@ module.exports = async function initCommand(parsed, config) {
|
|
|
49
49
|
|
|
50
50
|
// 2. Configurar .huntban.json en el repositorio
|
|
51
51
|
const updates = {};
|
|
52
|
-
if (parsed.flags.url) updates.apiUrl = parsed.flags.url;
|
|
52
|
+
if (parsed.flags.url) updates.apiUrl = normalizeApiUrl(parsed.flags.url);
|
|
53
53
|
if (parsed.flags.board) updates.boardId = parsed.flags.board;
|
|
54
54
|
if (parsed.flags.key) updates.apiKey = parsed.flags.key;
|
|
55
55
|
if (parsed.flags.secret) updates.apiSecret = parsed.flags.secret;
|
|
@@ -62,9 +62,10 @@ module.exports = async function initCommand(parsed, config) {
|
|
|
62
62
|
console.log('\n📋 Configuración del Tablero de Huntban:');
|
|
63
63
|
console.log(' (Puedes obtener estos datos en: Tablero > Configuración ⚙️ > Conector / Webhooks)\n');
|
|
64
64
|
|
|
65
|
-
const defaultUrl =
|
|
65
|
+
const defaultUrl = 'https://next.huntban.com/';
|
|
66
66
|
const inputUrl = await askQuestion(`URL de la API [${defaultUrl}]: `);
|
|
67
|
-
|
|
67
|
+
const chosenUrl = inputUrl.trim() || defaultUrl;
|
|
68
|
+
updates.apiUrl = normalizeApiUrl(chosenUrl);
|
|
68
69
|
|
|
69
70
|
const inputBoard = await askQuestion(`ID del Tablero (24 caracteres): `);
|
|
70
71
|
if (inputBoard.trim()) updates.boardId = inputBoard.trim();
|
package/lib/config.js
CHANGED
|
@@ -31,6 +31,23 @@ function writeJsonFile(filePath, data) {
|
|
|
31
31
|
fs.writeFileSync(filePath, JSON.stringify(data, null, 2), 'utf8');
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
/**
|
|
35
|
+
* Normaliza la URL base de la API completando el prefijo si solo se pasa el dominio
|
|
36
|
+
* Ej: "https://next.huntban.com/" -> "https://next.huntban.com/api/v2"
|
|
37
|
+
* Ej: "http://localhost:3000/" -> "http://localhost:3000/api/v1"
|
|
38
|
+
*/
|
|
39
|
+
function normalizeApiUrl(rawUrl) {
|
|
40
|
+
let url = (rawUrl || 'https://next.huntban.com/').trim().replace(/\/+$/, '');
|
|
41
|
+
if (!url) url = 'https://next.huntban.com';
|
|
42
|
+
|
|
43
|
+
if (url.includes('huntban.com') && !url.includes('/api/')) {
|
|
44
|
+
url = `${url}/api/v2`;
|
|
45
|
+
} else if (url.includes('localhost') && !url.includes('/api/')) {
|
|
46
|
+
url = `${url}/api/v1`;
|
|
47
|
+
}
|
|
48
|
+
return url;
|
|
49
|
+
}
|
|
50
|
+
|
|
34
51
|
/**
|
|
35
52
|
* Carga la configuración combinada respetando el orden de precedencia:
|
|
36
53
|
* 1. Variables de Entorno (HUNTBAN_*)
|
|
@@ -55,8 +72,10 @@ function loadConfig() {
|
|
|
55
72
|
}
|
|
56
73
|
}
|
|
57
74
|
|
|
75
|
+
const rawApiUrl = process.env.HUNTBAN_API_URL || localConfig.apiUrl || globalConfig.apiUrl || 'https://next.huntban.com/';
|
|
76
|
+
|
|
58
77
|
const merged = {
|
|
59
|
-
apiUrl:
|
|
78
|
+
apiUrl: normalizeApiUrl(rawApiUrl),
|
|
60
79
|
apiKey: process.env.HUNTBAN_API_KEY || localConfig.apiKey || globalConfig.apiKey || '',
|
|
61
80
|
apiSecret: process.env.HUNTBAN_API_SECRET || localConfig.apiSecret || globalConfig.apiSecret || '',
|
|
62
81
|
boardId: process.env.HUNTBAN_BOARD_ID || localConfig.boardId || globalConfig.boardId || '',
|
|
@@ -98,6 +117,7 @@ function getGlobalConfig() {
|
|
|
98
117
|
module.exports = {
|
|
99
118
|
GLOBAL_CONFIG_FILE,
|
|
100
119
|
LOCAL_CONFIG_FILE,
|
|
120
|
+
normalizeApiUrl,
|
|
101
121
|
loadConfig,
|
|
102
122
|
setLocalConfig,
|
|
103
123
|
setGlobalConfig,
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "huntban-cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "CLI oficial y herramienta de automatización para Huntban y agentes Antigravity",
|
|
5
5
|
"main": "bin/huntban.js",
|
|
6
6
|
"bin": {
|
|
7
|
-
"huntban": "
|
|
7
|
+
"huntban": "bin/huntban.js"
|
|
8
8
|
},
|
|
9
9
|
"preferGlobal": true,
|
|
10
10
|
"files": [
|
package/templates/SKILL.md
CHANGED
|
@@ -57,7 +57,7 @@ Entra a tu tablero en Huntban y abre el menú de configuración:
|
|
|
57
57
|
2. Haz clic en el ícono de **Configuración del Tablero (⚙️)** en la cabecera.
|
|
58
58
|
3. Ve a la pestaña **Conector / Webhooks**.
|
|
59
59
|
4. Copia los siguientes datos:
|
|
60
|
-
- **URL de la API**: Por defecto `https://next.huntban.com
|
|
60
|
+
- **URL de la API**: Por defecto `https://next.huntban.com/` (el CLI la completa automáticamente como corresponda a `/api/v2`).
|
|
61
61
|
- **ID del Tablero (`boardId`)**: El identificador de 24 caracteres de tu tablero.
|
|
62
62
|
- **API Key (`x-api-key`)**: Tu clave pública (comienza con `hb_pk_...`).
|
|
63
63
|
- **API Secret (`x-api-secret`)**: Tu clave privada (comienza con `hb_sk_...`).
|
|
@@ -71,7 +71,7 @@ Si prefieres pasar todos los datos en una sola línea o en un script automatizad
|
|
|
71
71
|
|
|
72
72
|
```bash
|
|
73
73
|
huntban attach \
|
|
74
|
-
--url https://next.huntban.com/
|
|
74
|
+
--url https://next.huntban.com/ \
|
|
75
75
|
--board <ID_DEL_TABLERO> \
|
|
76
76
|
--key <API_KEY> \
|
|
77
77
|
--secret <API_SECRET> \
|